New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@atoms-studio/composables

Package Overview
Dependencies
Maintainers
5
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atoms-studio/composables - npm Package Compare versions

Comparing version 0.0.0-685c89e to 0.0.0-6bbbfdc

dist/useRouteState.d.ts

92

dist/composables.es.js

@@ -1,2 +0,18 @@

import { computed } from "vue";
var __defProp = Object.defineProperty;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a, prop, b[prop]);
}
return a;
};
import { computed, inject } from "vue";
const useURL = (to, base) => {

@@ -32,2 +48,74 @@ if (!base) {

};
export { useURL };
/*!
* vue-router v4.0.13
* (c) 2022 Eduardo San Martin Morote
* @license MIT
*/
const hasSymbol = typeof Symbol === "function" && typeof Symbol.toStringTag === "symbol";
const PolySymbol = (name) => hasSymbol ? Symbol(name) : "_vr_" + name;
const routerKey = /* @__PURE__ */ PolySymbol("r");
const routeLocationKey = /* @__PURE__ */ PolySymbol("rl");
var NavigationType;
(function(NavigationType2) {
NavigationType2["pop"] = "pop";
NavigationType2["push"] = "push";
})(NavigationType || (NavigationType = {}));
var NavigationDirection;
(function(NavigationDirection2) {
NavigationDirection2["back"] = "back";
NavigationDirection2["forward"] = "forward";
NavigationDirection2["unknown"] = "";
})(NavigationDirection || (NavigationDirection = {}));
var NavigationFailureType;
(function(NavigationFailureType2) {
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
})(NavigationFailureType || (NavigationFailureType = {}));
function useRouter() {
return inject(routerKey);
}
function useRoute() {
return inject(routeLocationKey);
}
const useRouteState = (configOrKeys) => {
const route = useRoute();
const router = useRouter();
let config;
if (Array.isArray(configOrKeys)) {
config = configOrKeys.reduce((acc, key) => {
acc[key] = {
get: (value) => value,
set: (value) => value
};
return acc;
}, {});
} else {
config = configOrKeys;
}
const stateKeys = Object.keys(config);
const state = computed(() => {
const result = {};
for (const stateKey of stateKeys) {
const queryValue = route.query[stateKey];
const stateValue = config[stateKey].get(queryValue);
result[stateKey] = stateValue;
}
return result;
});
const updateState = (partialState) => {
const newState = __spreadValues(__spreadValues({}, state.value), partialState);
const newQuery = {};
for (const stateKey of stateKeys) {
const stateValue = newState[stateKey];
const queryValue = config[stateKey].set(stateValue);
newQuery[stateKey] = queryValue;
}
return router.replace({ query: __spreadValues(__spreadValues({}, route.query), newQuery) });
};
return {
state,
updateState
};
};
export { useRouteState, useURL };

@@ -1,1 +0,5 @@

(function(u,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(u=typeof globalThis!="undefined"?globalThis:u||self,e(u.MyLib={},u.Vue))})(this,function(u,e){"use strict";const s=(i,o)=>{if(!o)throw new Error("Base is required");const r=e.computed(()=>i.value==="#"),t=e.computed(()=>typeof i.value=="string"?new URL(i.value,o):null),l=e.computed(()=>{var n;return((n=t.value)==null?void 0:n.origin)||""}),d=e.computed(()=>{var n;return r.value?"#":((n=t.value)==null?void 0:n.pathname)||""}),c=e.computed(()=>r.value||t.value!==null&&l.value!==o);return{url:t,origin:l,path:d,isExternal:c,isDummy:r}};u.useURL=s,Object.defineProperty(u,"__esModule",{value:!0}),u[Symbol.toStringTag]="Module"});
var M=Object.defineProperty;var w=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable;var q=(o,t,u)=>t in o?M(o,t,{enumerable:!0,configurable:!0,writable:!0,value:u}):o[t]=u,i=(o,t)=>{for(var u in t||(t={}))U.call(t,u)&&q(o,u,t[u]);if(w)for(var u of w(t))g.call(t,u)&&q(o,u,t[u]);return o};(function(o,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(o=typeof globalThis!="undefined"?globalThis:o||self,t(o.MyLib={},o.Vue))})(this,function(o,t){"use strict";const u=(e,l)=>{if(!l)throw new Error("Base is required");const a=t.computed(()=>e.value==="#"),r=t.computed(()=>typeof e.value=="string"?new URL(e.value,l):null),d=t.computed(()=>{var n;return((n=r.value)==null?void 0:n.origin)||""}),y=t.computed(()=>{var n;return a.value?"#":((n=r.value)==null?void 0:n.pathname)||""}),h=t.computed(()=>a.value||r.value!==null&&d.value!==l);return{url:r,origin:d,path:y,isExternal:h,isDummy:a}};/*!
* vue-router v4.0.13
* (c) 2022 Eduardo San Martin Morote
* @license MIT
*/const R=typeof Symbol=="function"&&typeof Symbol.toStringTag=="symbol",p=e=>R?Symbol(e):"_vr_"+e,j=p("r"),v=p("rl");var m;(function(e){e.pop="pop",e.push="push"})(m||(m={}));var S;(function(e){e.back="back",e.forward="forward",e.unknown=""})(S||(S={}));var b;(function(e){e[e.aborted=4]="aborted",e[e.cancelled=8]="cancelled",e[e.duplicated=16]="duplicated"})(b||(b={}));function L(){return t.inject(j)}function V(){return t.inject(v)}const k=e=>{const l=V(),a=L();let r;Array.isArray(e)?r=e.reduce((n,c)=>(n[c]={get:s=>s,set:s=>s},n),{}):r=e;const d=Object.keys(r),y=t.computed(()=>{const n={};for(const c of d){const s=l.query[c],f=r[c].get(s);n[c]=f}return n});return{state:y,updateState:n=>{const c=i(i({},y.value),n),s={};for(const f of d){const _=c[f],K=r[f].set(_);s[f]=K}return a.replace({query:i(i({},l.query),s)})}}};o.useRouteState=k,o.useURL=u,Object.defineProperty(o,"__esModule",{value:!0}),o[Symbol.toStringTag]="Module"});
export { useURL } from './useURL';
export { useRouteState } from './useRouteState';

2

package.json

@@ -7,3 +7,3 @@ {

},
"version": "0.0.0-685c89e",
"version": "0.0.0-6bbbfdc",
"license": "MIT",

@@ -10,0 +10,0 @@ "files": [

@@ -1,59 +0,29 @@

# .
# Atoms UI Kit / 📦 Composables
This template should help get you started developing with Vue 3 in Vite.
General purpose Vue composables.<br>
Uses Vite in lib mode to build for production.<br>
Uses Vitest to run unit tests.
## Recommended IDE Setup
## Installation
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin).
## Type Support for `.vue` Imports in TS
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=johnsoncodehk.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```bash
yarn add @atoms-studio/composables
```
### Compile and Hot-Reload for Development
Then import the composables you need, ie:
```sh
npm run dev
```
```vue
<script setup lang="ts">
import { useURL } from '@atoms-studio/composables'
### Type-Check, Compile and Minify for Production
```sh
npm run build
const { url } = useURL('/about', 'http://localhost:3000')
</script>
```
### Run Unit Tests with [Vitest](https://vitest.dev/)
## Development
```sh
npm run test:unit
```
1. Composables must be written in Typescript
2. Every composable must have a test suite in the `tests` folder named after it, ie: `test/<composableName>.test.ts`.<br>
### Run End-to-End Tests with [Cypress](https://www.cypress.io/)
To execute tests, run `yarn test` in the `packages/composables` folder.
```sh
npm run build
npm run test:e2e # or `npm run test:e2e:ci` for headless testing
```
### Lint with [ESLint](https://eslint.org/)
```sh
npm run lint
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc