vue-context-storage 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +47 -21
- package/dist/index.js +3 -1
- package/package.json +90 -90
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as vue9 from "vue";
|
|
2
2
|
import { ComputedRef, InjectionKey, MaybeRefOrGetter, Plugin, PropType, UnwrapNestedRefs } from "vue";
|
|
3
3
|
import { LocationQuery, LocationQueryValue } from "vue-router";
|
|
4
4
|
|
|
5
5
|
//#region src/components/ContextStorageActivator.vue.d.ts
|
|
6
6
|
declare const _default$1: typeof __VLS_export$4;
|
|
7
|
-
declare const __VLS_export$4:
|
|
7
|
+
declare const __VLS_export$4: vue9.DefineComponent<{}, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
|
|
8
8
|
[key: string]: any;
|
|
9
|
-
}>, {}, {}, {},
|
|
9
|
+
}>, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
|
|
10
10
|
//#endregion
|
|
11
11
|
//#region src/handlers/types.d.ts
|
|
12
12
|
interface HandlerSchema<T> {
|
|
@@ -65,55 +65,55 @@ interface ContextStorageHandler<T, O> {
|
|
|
65
65
|
//#endregion
|
|
66
66
|
//#region src/components/ContextStorageCollection.vue.d.ts
|
|
67
67
|
declare const _default$2: typeof __VLS_export$3;
|
|
68
|
-
declare const __VLS_export$3:
|
|
68
|
+
declare const __VLS_export$3: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
69
69
|
handlers: {
|
|
70
70
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
71
71
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
72
72
|
};
|
|
73
|
-
}>, () =>
|
|
73
|
+
}>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
|
|
74
74
|
[key: string]: any;
|
|
75
|
-
}>[] | undefined, {}, {}, {},
|
|
75
|
+
}>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
|
|
76
76
|
handlers: {
|
|
77
77
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
78
78
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
79
79
|
};
|
|
80
80
|
}>> & Readonly<{}>, {
|
|
81
81
|
handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
82
|
-
}, {}, {}, {}, string,
|
|
82
|
+
}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/components/ContextStorageProvider.vue.d.ts
|
|
85
85
|
declare const _default$4: typeof __VLS_export$2;
|
|
86
|
-
declare const __VLS_export$2:
|
|
86
|
+
declare const __VLS_export$2: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
87
87
|
itemKey: {
|
|
88
88
|
type: StringConstructor;
|
|
89
89
|
required: true;
|
|
90
90
|
};
|
|
91
|
-
}>, () =>
|
|
91
|
+
}>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
|
|
92
92
|
[key: string]: any;
|
|
93
|
-
}>[] | undefined, {}, {}, {},
|
|
93
|
+
}>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
|
|
94
94
|
itemKey: {
|
|
95
95
|
type: StringConstructor;
|
|
96
96
|
required: true;
|
|
97
97
|
};
|
|
98
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string,
|
|
98
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
|
|
99
99
|
//#endregion
|
|
100
100
|
//#region src/components/ContextStorage.vue.d.ts
|
|
101
101
|
declare const _default: typeof __VLS_export$1;
|
|
102
|
-
declare const __VLS_export$1:
|
|
102
|
+
declare const __VLS_export$1: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
103
103
|
handlers: {
|
|
104
104
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
105
105
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
106
106
|
};
|
|
107
|
-
}>, () =>
|
|
107
|
+
}>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
|
|
108
108
|
[key: string]: any;
|
|
109
|
-
}>[] | undefined, {}, {}, {},
|
|
109
|
+
}>[] | undefined, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
|
|
110
110
|
handlers: {
|
|
111
111
|
type: PropType<ContextStorageHandlerFactory[]>;
|
|
112
112
|
default: () => ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
113
113
|
};
|
|
114
114
|
}>> & Readonly<{}>, {
|
|
115
115
|
handlers: ContextStorageHandlerFactory<{}, RegisterOptions<{}>>[];
|
|
116
|
-
}, {}, {}, {}, string,
|
|
116
|
+
}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
|
|
117
117
|
//#endregion
|
|
118
118
|
//#region src/prefix.d.ts
|
|
119
119
|
/**
|
|
@@ -136,19 +136,19 @@ declare const contextStoragePrefixSegmentsInjectKey: InjectionKey<MaybeRefOrGett
|
|
|
136
136
|
//#endregion
|
|
137
137
|
//#region src/components/ContextStoragePrefix.vue.d.ts
|
|
138
138
|
declare const _default$3: typeof __VLS_export;
|
|
139
|
-
declare const __VLS_export:
|
|
139
|
+
declare const __VLS_export: vue9.DefineComponent<vue9.ExtractPropTypes<{
|
|
140
140
|
name: {
|
|
141
141
|
type: PropType<ContextStoragePrefixSegment>;
|
|
142
142
|
required: true;
|
|
143
143
|
};
|
|
144
|
-
}>, () =>
|
|
144
|
+
}>, () => vue9.VNode<vue9.RendererNode, vue9.RendererElement, {
|
|
145
145
|
[key: string]: any;
|
|
146
|
-
}>, {}, {}, {},
|
|
146
|
+
}>, {}, {}, {}, vue9.ComponentOptionsMixin, vue9.ComponentOptionsMixin, {}, string, vue9.PublicProps, Readonly<vue9.ExtractPropTypes<{
|
|
147
147
|
name: {
|
|
148
148
|
type: PropType<ContextStoragePrefixSegment>;
|
|
149
149
|
required: true;
|
|
150
150
|
};
|
|
151
|
-
}>> & Readonly<{}>, {}, {}, {}, {}, string,
|
|
151
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, vue9.ComponentProvideOptions, true, {}, any>;
|
|
152
152
|
//#endregion
|
|
153
153
|
//#region src/plugin.d.ts
|
|
154
154
|
declare const VueContextStoragePlugin: Plugin;
|
|
@@ -284,6 +284,32 @@ interface RegisterQueryHandlerBaseOptions<T> extends QueryHandlerSharedOptions {
|
|
|
284
284
|
* Note: If `schema` is provided, it takes priority over `transform`.
|
|
285
285
|
*/
|
|
286
286
|
transform?: (deserialized: DeepTransformValuesToLocationQueryValue<UnwrapNestedRefs<T>>, initialData: T) => UnwrapNestedRefs<T>;
|
|
287
|
+
/**
|
|
288
|
+
* Additional default values for `onlyChanges` comparison.
|
|
289
|
+
*
|
|
290
|
+
* When `onlyChanges` is enabled, a key is omitted from the URL if its current value
|
|
291
|
+
* equals the initial snapshot **or** a value specified here.
|
|
292
|
+
*
|
|
293
|
+
* This is useful when the initial reactive data contains `undefined` for a field,
|
|
294
|
+
* but you also want a specific value (e.g. `1`) to be treated as a default
|
|
295
|
+
* and not appear in the query string.
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```ts
|
|
299
|
+
* const data = ref({ page: undefined as number | undefined })
|
|
300
|
+
*
|
|
301
|
+
* useContextStorageQueryHandler(data, {
|
|
302
|
+
* prefix: 'filters',
|
|
303
|
+
* onlyChanges: true,
|
|
304
|
+
* additionalDefaultData: { page: 1 },
|
|
305
|
+
* })
|
|
306
|
+
*
|
|
307
|
+
* // page=undefined → not in query (matches initial)
|
|
308
|
+
* // page=1 → not in query (matches additionalDefaultData)
|
|
309
|
+
* // page=2 → appears in query
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
additionalDefaultData?: Partial<UnwrapNestedRefs<T>>;
|
|
287
313
|
}
|
|
288
314
|
interface RegisterQueryHandlerOptions<T> extends RegisterBaseOptions<T>, RegisterQueryHandlerBaseOptions<T> {}
|
|
289
315
|
//#endregion
|
|
@@ -380,11 +406,11 @@ declare function createQueryHandler(baseOptions?: QueryHandlerBaseOptions): Cont
|
|
|
380
406
|
//#endregion
|
|
381
407
|
//#region src/handlers/local-storage/index.d.ts
|
|
382
408
|
declare function createLocalStorageHandler(customOptions?: WebStorageHandlerBaseOptions): ContextStorageHandlerFactory;
|
|
383
|
-
declare const useContextStorageLocalStorage: (data:
|
|
409
|
+
declare const useContextStorageLocalStorage: (data: vue9.MaybeRefOrGetter<Record<string, unknown>>, options: RegisterWebStorageHandlerOptions<Record<string, unknown>>) => UseContextStorageResult<Record<string, unknown>>;
|
|
384
410
|
//#endregion
|
|
385
411
|
//#region src/handlers/session-storage/index.d.ts
|
|
386
412
|
declare function createSessionStorageHandler(customOptions?: WebStorageHandlerBaseOptions): ContextStorageHandlerFactory;
|
|
387
|
-
declare const useContextStorageSessionStorage: (data:
|
|
413
|
+
declare const useContextStorageSessionStorage: (data: vue9.MaybeRefOrGetter<Record<string, unknown>>, options: RegisterWebStorageHandlerOptions<Record<string, unknown>>) => UseContextStorageResult<Record<string, unknown>>;
|
|
388
414
|
//#endregion
|
|
389
415
|
//#region src/handlers/query/transform-helpers.d.ts
|
|
390
416
|
declare function asNumber(value: QueryValue | number | undefined): number;
|
package/dist/index.js
CHANGED
|
@@ -198,7 +198,7 @@ function buildQuery(input) {
|
|
|
198
198
|
warnings.push("[vue-context-storage] preserveEmptyState is not supported with onlyChanges");
|
|
199
199
|
}
|
|
200
200
|
Object.keys(patch).forEach((key) => {
|
|
201
|
-
if (isEqual(patch[key], item.initialQueryData[key])) delete patch[key];
|
|
201
|
+
if (isEqual(patch[key], item.initialQueryData[key]) || item.additionalDefaultQueryData && isEqual(patch[key], item.additionalDefaultQueryData[key])) delete patch[key];
|
|
202
202
|
});
|
|
203
203
|
}
|
|
204
204
|
const patchKeys = Object.keys(patch);
|
|
@@ -392,6 +392,7 @@ function createQueryHandler(baseOptions) {
|
|
|
392
392
|
data,
|
|
393
393
|
initialData,
|
|
394
394
|
initialQueryData: serializeParams(initialData, { prefix: registerOptions.prefix }),
|
|
395
|
+
additionalDefaultQueryData: registerOptions.additionalDefaultData ? serializeParams(registerOptions.additionalDefaultData, { prefix: registerOptions.prefix }) : void 0,
|
|
395
396
|
options: registerOptions,
|
|
396
397
|
watchHandle
|
|
397
398
|
};
|
|
@@ -430,6 +431,7 @@ function createQueryHandler(baseOptions) {
|
|
|
430
431
|
items: registered.map((item) => ({
|
|
431
432
|
data: toValue(item.data),
|
|
432
433
|
initialQueryData: item.initialQueryData,
|
|
434
|
+
additionalDefaultQueryData: item.additionalDefaultQueryData,
|
|
433
435
|
prefix: item.options?.prefix,
|
|
434
436
|
onlyChanges: item.options?.onlyChanges,
|
|
435
437
|
preserveEmptyState: item.options?.preserveEmptyState,
|
package/package.json
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vue-context-storage",
|
|
3
|
-
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
5
|
-
"description": "Vue 3 context storage system with URL query synchronization support",
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"homepage": "https://github.com/lviobio/vue-context-storage#readme",
|
|
9
|
-
"repository": {
|
|
10
|
-
"type": "git",
|
|
11
|
-
"url": "git+https://github.com/lviobio/vue-context-storage.git"
|
|
12
|
-
},
|
|
13
|
-
"bugs": {
|
|
14
|
-
"url": "https://github.com/lviobio/vue-context-storage/issues"
|
|
15
|
-
},
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/index.js",
|
|
18
|
-
"./package.json": "./package.json"
|
|
19
|
-
},
|
|
20
|
-
"main": "./dist/index.js",
|
|
21
|
-
"module": "./dist/index.js",
|
|
22
|
-
"types": "./dist/index.d.ts",
|
|
23
|
-
"files": [
|
|
24
|
-
"dist"
|
|
25
|
-
],
|
|
26
|
-
"publishConfig": {
|
|
27
|
-
"access": "public"
|
|
28
|
-
},
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsdown",
|
|
31
|
-
"dev": "tsdown --watch",
|
|
32
|
-
"check": "npm run ts:check && npm run lint:check && npm run format:check && npm run dependency-cruiser:check",
|
|
33
|
-
"ts:check": "vue-tsc --noEmit",
|
|
34
|
-
"format": "prettier --write src/ playground/src",
|
|
35
|
-
"format:check": "prettier --check src/ playground/src",
|
|
36
|
-
"lint": "eslint . --fix",
|
|
37
|
-
"lint:check": "eslint .",
|
|
38
|
-
"dependency-cruiser:check": "depcruise --config .dependency-cruiser.cjs src playground/src",
|
|
39
|
-
"play": "vite",
|
|
40
|
-
"build:playground": "vite build",
|
|
41
|
-
"preview:playground": "vite preview --outDir playground/dist",
|
|
42
|
-
"test": "vitest run",
|
|
43
|
-
"release": "bumpp && npm publish",
|
|
44
|
-
"prepublishOnly": "npm run check && npm run test && npm run build"
|
|
45
|
-
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"vue": "^3.0.0",
|
|
48
|
-
"vue-router": "^4.0.0 || ^5.0.0",
|
|
49
|
-
"zod": "^4.0.0"
|
|
50
|
-
},
|
|
51
|
-
"peerDependenciesMeta": {
|
|
52
|
-
"zod": {
|
|
53
|
-
"optional": true
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
"devDependencies": {
|
|
57
|
-
"@tailwindcss/vite": "^4.1.18",
|
|
58
|
-
"@types/lodash": "^4.17.21",
|
|
59
|
-
"@types/node": "^25.0.3",
|
|
60
|
-
"@vitejs/plugin-vue": "^6.0.3",
|
|
61
|
-
"@vitest/browser-playwright": "^4.0.16",
|
|
62
|
-
"@vitest/coverage-v8": "^4.0.16",
|
|
63
|
-
"@vue/eslint-config-typescript": "^14.6.0",
|
|
64
|
-
"@vue/test-utils": "^2.4.6",
|
|
65
|
-
"bumpp": "^10.3.2",
|
|
66
|
-
"dependency-cruiser": "^17.3.6",
|
|
67
|
-
"eslint": "^9.39.2",
|
|
68
|
-
"eslint-config-prettier": "^10.1.8",
|
|
69
|
-
"eslint-plugin-vue": "^10.6.2",
|
|
70
|
-
"happy-dom": "^20.1.0",
|
|
71
|
-
"highlight.js": "^11.11.1",
|
|
72
|
-
"jsdom": "^27.4.0",
|
|
73
|
-
"naive-ui": "^2.43.2",
|
|
74
|
-
"playwright": "^1.57.0",
|
|
75
|
-
"prettier": "^3.7.4",
|
|
76
|
-
"tailwindcss": "^4.1.18",
|
|
77
|
-
"tsdown": "^0.18.4",
|
|
78
|
-
"typescript": "^5.9.3",
|
|
79
|
-
"typescript-eslint": "^8.51.0",
|
|
80
|
-
"vite": "^7.3.0",
|
|
81
|
-
"vitest": "^4.0.16",
|
|
82
|
-
"vitest-browser-vue": "^2.0.1",
|
|
83
|
-
"vue": "^3.5.26",
|
|
84
|
-
"vue-tsc": "^3.2.1",
|
|
85
|
-
"zod": "^4.3.5"
|
|
86
|
-
},
|
|
87
|
-
"dependencies": {
|
|
88
|
-
"lodash": "^4.17.23"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-context-storage",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.1.29",
|
|
5
|
+
"description": "Vue 3 context storage system with URL query synchronization support",
|
|
6
|
+
"author": "",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/lviobio/vue-context-storage#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/lviobio/vue-context-storage.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/lviobio/vue-context-storage/issues"
|
|
15
|
+
},
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
},
|
|
29
|
+
"scripts": {
|
|
30
|
+
"build": "tsdown",
|
|
31
|
+
"dev": "tsdown --watch",
|
|
32
|
+
"check": "npm run ts:check && npm run lint:check && npm run format:check && npm run dependency-cruiser:check",
|
|
33
|
+
"ts:check": "vue-tsc --noEmit",
|
|
34
|
+
"format": "prettier --write src/ playground/src",
|
|
35
|
+
"format:check": "prettier --check src/ playground/src",
|
|
36
|
+
"lint": "eslint . --fix",
|
|
37
|
+
"lint:check": "eslint .",
|
|
38
|
+
"dependency-cruiser:check": "depcruise --config .dependency-cruiser.cjs src playground/src",
|
|
39
|
+
"play": "vite",
|
|
40
|
+
"build:playground": "vite build",
|
|
41
|
+
"preview:playground": "vite preview --outDir playground/dist",
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"release": "bumpp && npm publish",
|
|
44
|
+
"prepublishOnly": "npm run check && npm run test && npm run build"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"vue": "^3.0.0",
|
|
48
|
+
"vue-router": "^4.0.0 || ^5.0.0",
|
|
49
|
+
"zod": "^4.0.0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependenciesMeta": {
|
|
52
|
+
"zod": {
|
|
53
|
+
"optional": true
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
58
|
+
"@types/lodash": "^4.17.21",
|
|
59
|
+
"@types/node": "^25.0.3",
|
|
60
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
61
|
+
"@vitest/browser-playwright": "^4.0.16",
|
|
62
|
+
"@vitest/coverage-v8": "^4.0.16",
|
|
63
|
+
"@vue/eslint-config-typescript": "^14.6.0",
|
|
64
|
+
"@vue/test-utils": "^2.4.6",
|
|
65
|
+
"bumpp": "^10.3.2",
|
|
66
|
+
"dependency-cruiser": "^17.3.6",
|
|
67
|
+
"eslint": "^9.39.2",
|
|
68
|
+
"eslint-config-prettier": "^10.1.8",
|
|
69
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
70
|
+
"happy-dom": "^20.1.0",
|
|
71
|
+
"highlight.js": "^11.11.1",
|
|
72
|
+
"jsdom": "^27.4.0",
|
|
73
|
+
"naive-ui": "^2.43.2",
|
|
74
|
+
"playwright": "^1.57.0",
|
|
75
|
+
"prettier": "^3.7.4",
|
|
76
|
+
"tailwindcss": "^4.1.18",
|
|
77
|
+
"tsdown": "^0.18.4",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"typescript-eslint": "^8.51.0",
|
|
80
|
+
"vite": "^7.3.0",
|
|
81
|
+
"vitest": "^4.0.16",
|
|
82
|
+
"vitest-browser-vue": "^2.0.1",
|
|
83
|
+
"vue": "^3.5.26",
|
|
84
|
+
"vue-tsc": "^3.2.1",
|
|
85
|
+
"zod": "^4.3.5"
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"lodash": "^4.17.23"
|
|
89
|
+
}
|
|
90
|
+
}
|