vue-context-storage 0.1.8 → 0.1.10
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 +411 -10
- package/dist/index.js +193 -22
- package/package.json +38 -37
- package/dist/collection.d.cts +0 -22
- package/dist/collection.d.ts +0 -22
- package/dist/constants.d.cts +0 -2
- package/dist/constants.d.ts +0 -2
- package/dist/handlers/query/helpers.d.cts +0 -45
- package/dist/handlers/query/helpers.d.ts +0 -45
- package/dist/handlers/query/index.d.cts +0 -31
- package/dist/handlers/query/index.d.ts +0 -31
- package/dist/handlers/query/transform-helpers.d.cts +0 -123
- package/dist/handlers/query/transform-helpers.d.ts +0 -123
- package/dist/handlers/query/types.d.cts +0 -103
- package/dist/handlers/query/types.d.ts +0 -103
- package/dist/handlers.d.cts +0 -15
- package/dist/handlers.d.ts +0 -15
- package/dist/index.cjs +0 -409
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -10
- package/dist/index.js.map +0 -1
- package/dist/injectionSymbols.d.cts +0 -7
- package/dist/injectionSymbols.d.ts +0 -7
- package/dist/symbols.d.cts +0 -4
- package/dist/symbols.d.ts +0 -4
- package/src/collection.ts +0 -71
- package/src/components/ContextStorage.vue +0 -23
- package/src/components/ContextStorageActivator.vue +0 -20
- package/src/components/ContextStorageCollection.vue +0 -92
- package/src/components/ContextStorageProvider.vue +0 -38
- package/src/constants.ts +0 -5
- package/src/handlers/query/helpers.ts +0 -134
- package/src/handlers/query/index.ts +0 -355
- package/src/handlers/query/transform-helpers.ts +0 -309
- package/src/handlers/query/types.ts +0 -125
- package/src/handlers.ts +0 -18
- package/src/index.ts +0 -40
- package/src/injectionSymbols.ts +0 -15
- package/src/main.ts +0 -12
- package/src/plugin.ts +0 -16
- package/src/shims-vue.d.ts +0 -5
- package/src/symbols.ts +0 -4
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { LocationQueryValue } from 'vue-router';
|
|
2
|
-
import { MaybeRefOrGetter, UnwrapNestedRefs, WatchHandle } from 'vue';
|
|
3
|
-
import { ContextStorageHandler, RegisterBaseOptions } from '../../handlers';
|
|
4
|
-
export type QueryValue = LocationQueryValue | LocationQueryValue[];
|
|
5
|
-
export type DeepTransformValuesToLocationQueryValue<T> = {
|
|
6
|
-
[K in keyof T]?: T[K] extends object ? T[K] extends Array<any> ? QueryValue : DeepTransformValuesToLocationQueryValue<T[K]> : QueryValue;
|
|
7
|
-
};
|
|
8
|
-
interface QueryHandlerSharedOptions {
|
|
9
|
-
/**
|
|
10
|
-
* Default: false
|
|
11
|
-
*
|
|
12
|
-
* If enabled - empty state will be preserved in query.
|
|
13
|
-
*
|
|
14
|
-
* Useful, when you have default values, and want to preserve empty state in query.
|
|
15
|
-
* @example
|
|
16
|
-
* ```
|
|
17
|
-
* Options: {preserveEmptyState: true, prefix: 'filters'}
|
|
18
|
-
*
|
|
19
|
-
* When filters are empty we will get this in query string:
|
|
20
|
-
*
|
|
21
|
-
* /list?filters
|
|
22
|
-
*
|
|
23
|
-
* After page reload state will be not restored to default
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```
|
|
28
|
-
* Options: {preserveEmptyState: false, prefix: 'filters'}
|
|
29
|
-
*
|
|
30
|
-
* When filters are empty we will get this in query string:
|
|
31
|
-
*
|
|
32
|
-
* /list
|
|
33
|
-
*
|
|
34
|
-
* After page reload state will be restored to default
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```
|
|
39
|
-
* Options: {preserveEmptyState: true}
|
|
40
|
-
*
|
|
41
|
-
* When filters are empty we will get this in query string:
|
|
42
|
-
*
|
|
43
|
-
* /list?_
|
|
44
|
-
*
|
|
45
|
-
* After page reload state will be not restored to default.
|
|
46
|
-
* Underscore (_) is default value for emptyPlaceholder option
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
preserveEmptyState?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Default: true
|
|
52
|
-
*
|
|
53
|
-
* If transform option is not passed, ref will be merged with query only by keys that exists in ref.
|
|
54
|
-
*/
|
|
55
|
-
mergeOnlyExistingKeysWithoutTransform?: boolean;
|
|
56
|
-
}
|
|
57
|
-
export interface QueryHandlerBaseOptions extends QueryHandlerSharedOptions {
|
|
58
|
-
/**
|
|
59
|
-
* Default: replace
|
|
60
|
-
*
|
|
61
|
-
* Vue-router navigate mode.
|
|
62
|
-
* Use push if you want to add new query to history.
|
|
63
|
-
* Use replace if you want to replace current query without adding to history.
|
|
64
|
-
*/
|
|
65
|
-
mode?: 'replace' | 'push';
|
|
66
|
-
/**
|
|
67
|
-
* Default: _
|
|
68
|
-
*
|
|
69
|
-
* Placeholder for empty state, used when preserveEmptyState is true and all ref values are empty.
|
|
70
|
-
*/
|
|
71
|
-
emptyPlaceholder?: string;
|
|
72
|
-
/**
|
|
73
|
-
* Default: false
|
|
74
|
-
*
|
|
75
|
-
* If enabled - unused keys will be preserved in query.
|
|
76
|
-
* Unused keys are keys, that are not exists in ref.
|
|
77
|
-
*/
|
|
78
|
-
preserveUnusedKeys?: boolean;
|
|
79
|
-
}
|
|
80
|
-
export interface RegisterQueryHandlerBaseOptions<T> extends QueryHandlerSharedOptions {
|
|
81
|
-
/**
|
|
82
|
-
* Prefix in query string.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```
|
|
86
|
-
* filters, table-1[filters], table-2[filters]
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
prefix?: string;
|
|
90
|
-
transform?: (deserialized: DeepTransformValuesToLocationQueryValue<UnwrapNestedRefs<T>>, initialData: T) => UnwrapNestedRefs<T>;
|
|
91
|
-
}
|
|
92
|
-
export interface RegisterQueryHandlerOptions<T> extends RegisterBaseOptions, RegisterQueryHandlerBaseOptions<T> {
|
|
93
|
-
}
|
|
94
|
-
export interface IContextStorageQueryHandler extends ContextStorageHandler {
|
|
95
|
-
register: <T extends Record<string, unknown>>(data: MaybeRefOrGetter<T>, options: RegisterQueryHandlerOptions<T>) => () => void;
|
|
96
|
-
}
|
|
97
|
-
export interface ContextStorageQueryRegisteredItem<T extends Record<string, unknown>> {
|
|
98
|
-
data: MaybeRefOrGetter<T>;
|
|
99
|
-
initialData: T;
|
|
100
|
-
options: RegisterQueryHandlerOptions<T>;
|
|
101
|
-
watchHandle: WatchHandle;
|
|
102
|
-
}
|
|
103
|
-
export {};
|
package/dist/handlers.d.cts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { InjectionKey, MaybeRefOrGetter } from 'vue';
|
|
2
|
-
export interface ContextStorageHandlerConstructor {
|
|
3
|
-
new (): ContextStorageHandler;
|
|
4
|
-
getInitialStateResolver?: () => () => Record<string, unknown>;
|
|
5
|
-
}
|
|
6
|
-
export interface RegisterBaseOptions {
|
|
7
|
-
causer: string;
|
|
8
|
-
uid: number;
|
|
9
|
-
}
|
|
10
|
-
export interface ContextStorageHandler {
|
|
11
|
-
register: (data: MaybeRefOrGetter, options: RegisterBaseOptions) => () => void;
|
|
12
|
-
setInitialState?: (state: Record<string, unknown>) => void;
|
|
13
|
-
setEnabled?: (enabled: boolean, initial: boolean) => void;
|
|
14
|
-
getInjectionKey(): InjectionKey<ContextStorageHandler>;
|
|
15
|
-
}
|
package/dist/handlers.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { InjectionKey, MaybeRefOrGetter } from 'vue';
|
|
2
|
-
export interface ContextStorageHandlerConstructor {
|
|
3
|
-
new (): ContextStorageHandler;
|
|
4
|
-
getInitialStateResolver?: () => () => Record<string, unknown>;
|
|
5
|
-
}
|
|
6
|
-
export interface RegisterBaseOptions {
|
|
7
|
-
causer: string;
|
|
8
|
-
uid: number;
|
|
9
|
-
}
|
|
10
|
-
export interface ContextStorageHandler {
|
|
11
|
-
register: (data: MaybeRefOrGetter, options: RegisterBaseOptions) => () => void;
|
|
12
|
-
setInitialState?: (state: Record<string, unknown>) => void;
|
|
13
|
-
setEnabled?: (enabled: boolean, initial: boolean) => void;
|
|
14
|
-
getInjectionKey(): InjectionKey<ContextStorageHandler>;
|
|
15
|
-
}
|
package/dist/index.cjs
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const lodash_es = __toESM(require("lodash-es"));
|
|
25
|
-
const vue = __toESM(require("vue"));
|
|
26
|
-
const vue_router = __toESM(require("vue-router"));
|
|
27
|
-
|
|
28
|
-
//#region src/handlers/query/helpers.ts
|
|
29
|
-
/**
|
|
30
|
-
* Serializes filter parameters into a URL-friendly format.
|
|
31
|
-
*
|
|
32
|
-
* @param params - Raw parameters object to serialize
|
|
33
|
-
* @param options - Serialization options
|
|
34
|
-
* @returns Serialized parameters with prefixed keys
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* // With default prefix 'filters'
|
|
38
|
-
* serializeFiltersParams({ status: 'active', tags: ['a', 'b'] })
|
|
39
|
-
* // => { 'filters[status]': 'active', 'filters[tags]': 'a,b' }
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* // With custom prefix
|
|
43
|
-
* serializeFiltersParams({ name: 'John', all: true }, { prefix: 'search' })
|
|
44
|
-
* // => { 'search[name]': 'John', 'search[all]': '1' }
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // Without prefix
|
|
48
|
-
* serializeFiltersParams({ page: 1, all: false }, { prefix: '' })
|
|
49
|
-
* // => { 'page': '1', 'all': '0' }
|
|
50
|
-
*/
|
|
51
|
-
function serializeParams(params, options = {}) {
|
|
52
|
-
const { prefix = "" } = options;
|
|
53
|
-
const result = {};
|
|
54
|
-
Object.keys(params).forEach((key) => {
|
|
55
|
-
const value = params[key];
|
|
56
|
-
if (value === "") return;
|
|
57
|
-
if (value === null) return;
|
|
58
|
-
if (Array.isArray(value) && value.length === 0) return;
|
|
59
|
-
const formattedKey = prefix ? `${prefix}[${key}]` : key;
|
|
60
|
-
if (typeof value === "object") if (Array.isArray(value)) result[formattedKey] = value.map(String);
|
|
61
|
-
else Object.assign(result, serializeParams(value, {
|
|
62
|
-
...options,
|
|
63
|
-
prefix: formattedKey
|
|
64
|
-
}));
|
|
65
|
-
else if (typeof value === "boolean") result[formattedKey] = value ? "1" : "0";
|
|
66
|
-
else result[formattedKey] = String(value);
|
|
67
|
-
});
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Deserializes query parameters from a URL-friendly format back to an object.
|
|
72
|
-
*
|
|
73
|
-
* @param params - Serialized parameters object
|
|
74
|
-
* @returns Deserialized parameters object
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* deserializeParams({ 'filters[status]': 'active', search: 'test' })
|
|
78
|
-
* // => { filters: {status: 'active'}, search: 'test' }
|
|
79
|
-
*/
|
|
80
|
-
function deserializeParams(params) {
|
|
81
|
-
return Object.keys(params).reduce((acc, key) => {
|
|
82
|
-
const value = params[key];
|
|
83
|
-
const bracketMatch = key.match(/^([^[]+)\[(.+)]$/);
|
|
84
|
-
if (bracketMatch) {
|
|
85
|
-
const [, rootKey, nestedPath] = bracketMatch;
|
|
86
|
-
if (!acc[rootKey]) acc[rootKey] = {};
|
|
87
|
-
const pathParts = nestedPath.split("][");
|
|
88
|
-
let current = acc[rootKey];
|
|
89
|
-
for (let i = 0; i < pathParts.length - 1; i++) {
|
|
90
|
-
const part = pathParts[i];
|
|
91
|
-
if (!current[part]) current[part] = {};
|
|
92
|
-
current = current[part];
|
|
93
|
-
}
|
|
94
|
-
const finalKey = pathParts[pathParts.length - 1];
|
|
95
|
-
current[finalKey] = value;
|
|
96
|
-
} else acc[key] = value;
|
|
97
|
-
return acc;
|
|
98
|
-
}, {});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
//#endregion
|
|
102
|
-
//#region src/symbols.ts
|
|
103
|
-
const collection = Symbol("context-storage-collection");
|
|
104
|
-
const collectionItem = Symbol("context-storage-collection-item");
|
|
105
|
-
const handlers = Symbol("context-storage-handlers");
|
|
106
|
-
const contextStorageQueryHandler = Symbol("context-storage-query-handler");
|
|
107
|
-
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/handlers/query/index.ts
|
|
110
|
-
function useContextStorageQueryHandler(data, options) {
|
|
111
|
-
const handler = (0, vue.inject)(contextStorageQueryHandler);
|
|
112
|
-
if (!handler) throw new Error("[ContextStorage] ContextStorageQueryHandler is not provided");
|
|
113
|
-
const currentInstance = (0, vue.getCurrentInstance)();
|
|
114
|
-
const uid = currentInstance?.uid || 0;
|
|
115
|
-
const causer = new Error().stack?.split("\n")[2]?.trimStart() || "unknown";
|
|
116
|
-
const stop = handler.register(data, {
|
|
117
|
-
causer,
|
|
118
|
-
uid,
|
|
119
|
-
...options
|
|
120
|
-
});
|
|
121
|
-
(0, vue.onBeforeUnmount)(() => {
|
|
122
|
-
stop();
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
function sortQueryByReference(query, ...references) {
|
|
126
|
-
const sorted = {};
|
|
127
|
-
const referenceKeys = /* @__PURE__ */ new Set();
|
|
128
|
-
references.forEach((reference) => {
|
|
129
|
-
Object.keys(reference).forEach((key) => {
|
|
130
|
-
referenceKeys.add(key);
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
referenceKeys.forEach((key) => {
|
|
134
|
-
if (key in query && !(key in sorted)) sorted[key] = query[key];
|
|
135
|
-
});
|
|
136
|
-
Object.keys(query).forEach((key) => {
|
|
137
|
-
if (!(key in sorted)) sorted[key] = query[key];
|
|
138
|
-
});
|
|
139
|
-
return sorted;
|
|
140
|
-
}
|
|
141
|
-
var ContextStorageQueryHandler = class ContextStorageQueryHandler {
|
|
142
|
-
enabled = false;
|
|
143
|
-
registered = [];
|
|
144
|
-
currentQuery = void 0;
|
|
145
|
-
route;
|
|
146
|
-
router;
|
|
147
|
-
initialState;
|
|
148
|
-
hasAnyRegistered = false;
|
|
149
|
-
preventSyncRegisteredToQueryByAfterEachRoute = false;
|
|
150
|
-
preventAfterEachRouteCallsWhileCallingRouter = false;
|
|
151
|
-
static customQueryHandlerOptions = {};
|
|
152
|
-
options = {
|
|
153
|
-
mode: "replace",
|
|
154
|
-
emptyPlaceholder: "_",
|
|
155
|
-
mergeOnlyExistingKeysWithoutTransform: true,
|
|
156
|
-
preserveUnusedKeys: false,
|
|
157
|
-
preserveEmptyState: false
|
|
158
|
-
};
|
|
159
|
-
static configure(options) {
|
|
160
|
-
ContextStorageQueryHandler.customQueryHandlerOptions = options;
|
|
161
|
-
return ContextStorageQueryHandler;
|
|
162
|
-
}
|
|
163
|
-
constructor() {
|
|
164
|
-
this.route = (0, vue_router.useRoute)();
|
|
165
|
-
this.router = (0, vue_router.useRouter)();
|
|
166
|
-
this.options = {
|
|
167
|
-
...this.options,
|
|
168
|
-
...ContextStorageQueryHandler.customQueryHandlerOptions
|
|
169
|
-
};
|
|
170
|
-
const stopAfterEach = this.router.afterEach(() => {
|
|
171
|
-
this.afterEachRoute();
|
|
172
|
-
});
|
|
173
|
-
(0, vue.onBeforeUnmount)(() => {
|
|
174
|
-
stopAfterEach();
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
getInjectionKey() {
|
|
178
|
-
return contextStorageQueryHandler;
|
|
179
|
-
}
|
|
180
|
-
setInitialState(state) {
|
|
181
|
-
this.initialState = state;
|
|
182
|
-
}
|
|
183
|
-
static getInitialStateResolver() {
|
|
184
|
-
const route = (0, vue_router.useRoute)();
|
|
185
|
-
return () => route.query;
|
|
186
|
-
}
|
|
187
|
-
setEnabled(state, initial) {
|
|
188
|
-
const prevState = this.enabled;
|
|
189
|
-
this.enabled = state;
|
|
190
|
-
if (this.hasAnyRegistered) {
|
|
191
|
-
if (initial) this.syncInitialStateToRegistered();
|
|
192
|
-
if (state && !prevState || !initial) this.syncRegisteredToQuery();
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
async syncRegisteredToQuery() {
|
|
196
|
-
if (!this.enabled) return;
|
|
197
|
-
if (this.preventSyncRegisteredToQueryByAfterEachRoute) return;
|
|
198
|
-
const { newQuery, newQueryRaw } = this.#buildQueryFromRegistered();
|
|
199
|
-
this.currentQuery = newQueryRaw;
|
|
200
|
-
if ((0, lodash_es.isEqual)(newQuery, this.route.query)) return;
|
|
201
|
-
this.preventAfterEachRouteCallsWhileCallingRouter = true;
|
|
202
|
-
try {
|
|
203
|
-
if (this.options.mode === "replace") await this.router.replace({
|
|
204
|
-
...this.route,
|
|
205
|
-
query: newQuery
|
|
206
|
-
});
|
|
207
|
-
else await this.router.push({
|
|
208
|
-
...this.route,
|
|
209
|
-
query: newQuery
|
|
210
|
-
});
|
|
211
|
-
} catch (e) {
|
|
212
|
-
console.error("[ContextStorage] Got error while routing", e);
|
|
213
|
-
}
|
|
214
|
-
this.preventAfterEachRouteCallsWhileCallingRouter = false;
|
|
215
|
-
}
|
|
216
|
-
afterEachRoute() {
|
|
217
|
-
if (!this.enabled) return;
|
|
218
|
-
if (this.preventAfterEachRouteCallsWhileCallingRouter) return;
|
|
219
|
-
this.setInitialState(this.route.query);
|
|
220
|
-
this.preventSyncRegisteredToQueryByAfterEachRoute = true;
|
|
221
|
-
queueMicrotask(() => {
|
|
222
|
-
this.preventSyncRegisteredToQueryByAfterEachRoute = false;
|
|
223
|
-
this.syncInitialStateToRegistered();
|
|
224
|
-
this.syncRegisteredToQuery();
|
|
225
|
-
});
|
|
226
|
-
setTimeout(() => {
|
|
227
|
-
this.syncInitialStateToRegistered();
|
|
228
|
-
this.syncRegisteredToQuery();
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
syncInitialStateToRegisteredItem(item) {
|
|
232
|
-
if (this.initialState === void 0) return;
|
|
233
|
-
let deserialized = deserializeParams(this.initialState);
|
|
234
|
-
const { prefix, mergeOnlyExistingKeysWithoutTransform = this.options.mergeOnlyExistingKeysWithoutTransform } = item.options || {};
|
|
235
|
-
if (typeof prefix === "string" && prefix.length > 0) deserialized = deserialized[prefix];
|
|
236
|
-
if (deserialized === void 0) return;
|
|
237
|
-
const itemData = (0, vue.toValue)(item.data);
|
|
238
|
-
/**
|
|
239
|
-
* null can be if query parameter only has a name without a value sign
|
|
240
|
-
*/
|
|
241
|
-
if (deserialized !== null) {
|
|
242
|
-
const deserializedKeys = Object.keys(deserialized);
|
|
243
|
-
/**
|
|
244
|
-
* If the data is empty, return the initial value.
|
|
245
|
-
*
|
|
246
|
-
* This can happen when directly navigating to a route, for example through a menu item.
|
|
247
|
-
*/
|
|
248
|
-
if (!deserializedKeys.length) {
|
|
249
|
-
(0, lodash_es.merge)(itemData, item.initialData);
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (deserializedKeys.length === 1 && deserialized[this.options.emptyPlaceholder] === null) delete deserialized[this.options.emptyPlaceholder];
|
|
253
|
-
}
|
|
254
|
-
if (item.options?.transform) deserialized = item.options.transform(deserialized, item.initialData);
|
|
255
|
-
else if (mergeOnlyExistingKeysWithoutTransform) deserialized = (0, lodash_es.pick)(deserialized, Object.keys(item.initialData));
|
|
256
|
-
if ((0, lodash_es.isEqual)(itemData, deserialized)) return;
|
|
257
|
-
(0, lodash_es.merge)(itemData, deserialized);
|
|
258
|
-
}
|
|
259
|
-
syncInitialStateToRegistered() {
|
|
260
|
-
this.registered.forEach((item) => this.syncInitialStateToRegisteredItem(item));
|
|
261
|
-
}
|
|
262
|
-
register(data, options) {
|
|
263
|
-
this.hasAnyRegistered = true;
|
|
264
|
-
const watchHandle = (0, vue.watch)(data, () => this.syncRegisteredToQuery(), { deep: true });
|
|
265
|
-
const item = {
|
|
266
|
-
data,
|
|
267
|
-
initialData: (0, lodash_es.cloneDeep)((0, vue.toValue)(data)),
|
|
268
|
-
options,
|
|
269
|
-
watchHandle
|
|
270
|
-
};
|
|
271
|
-
this.registered.push(item);
|
|
272
|
-
const syncCallback = () => {
|
|
273
|
-
this.syncInitialStateToRegisteredItem(item);
|
|
274
|
-
this.syncRegisteredToQuery();
|
|
275
|
-
};
|
|
276
|
-
if (this.preventAfterEachRouteCallsWhileCallingRouter)
|
|
277
|
-
/**
|
|
278
|
-
* Macrotask solves syncing issues when syncRegisteredToQuery called after HMR
|
|
279
|
-
*/
|
|
280
|
-
setTimeout(syncCallback);
|
|
281
|
-
else queueMicrotask(syncCallback);
|
|
282
|
-
return () => {
|
|
283
|
-
this.registered.splice(this.registered.indexOf(item), 1);
|
|
284
|
-
this.syncRegisteredToQuery();
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
#buildQueryFromRegistered() {
|
|
288
|
-
const newQueryRaw = {};
|
|
289
|
-
this.registered.forEach((item) => {
|
|
290
|
-
const { prefix, preserveEmptyState = this.options.preserveEmptyState } = item.options || {};
|
|
291
|
-
const patch = serializeParams((0, vue.toValue)(item.data), { prefix });
|
|
292
|
-
const patchKeys = Object.keys(patch);
|
|
293
|
-
patchKeys.forEach((key) => {
|
|
294
|
-
if (newQueryRaw.hasOwnProperty(key)) console.warn(`[ContextStorage] Key ${key} is already present, overriding ` + (item.options?.causer || ""));
|
|
295
|
-
});
|
|
296
|
-
if (!patchKeys.length && preserveEmptyState) patch[prefix || this.options.emptyPlaceholder] = null;
|
|
297
|
-
Object.assign(newQueryRaw, patch);
|
|
298
|
-
});
|
|
299
|
-
let newQuery = { ...newQueryRaw };
|
|
300
|
-
if (this.options.preserveUnusedKeys) newQuery = {
|
|
301
|
-
...this.route.query,
|
|
302
|
-
...newQuery
|
|
303
|
-
};
|
|
304
|
-
if (this.currentQuery !== void 0) Object.keys(this.currentQuery).forEach((key) => {
|
|
305
|
-
if (!newQueryRaw.hasOwnProperty(key)) delete newQuery[key];
|
|
306
|
-
});
|
|
307
|
-
if (Object.keys(newQuery).length > 1 && newQuery[this.options.emptyPlaceholder] === null) delete newQuery[this.options.emptyPlaceholder];
|
|
308
|
-
newQuery = sortQueryByReference(newQuery, newQueryRaw);
|
|
309
|
-
return {
|
|
310
|
-
newQuery,
|
|
311
|
-
newQueryRaw
|
|
312
|
-
};
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
//#endregion
|
|
317
|
-
//#region src/handlers/query/transform-helpers.ts
|
|
318
|
-
function asNumber(value, options) {
|
|
319
|
-
const { nullable = false, missable = false, fallbackValue = missable ? void 0 : nullable ? null : 0 } = options || {};
|
|
320
|
-
if (value === null && nullable) return null;
|
|
321
|
-
if (value === void 0 && missable) return void 0;
|
|
322
|
-
value = Number(value);
|
|
323
|
-
return isNaN(value) ? fallbackValue : value;
|
|
324
|
-
}
|
|
325
|
-
function asString(value, options) {
|
|
326
|
-
const { nullable = false, missable = false, fallbackValue = missable ? void 0 : nullable ? null : "", allowedValues } = options || {};
|
|
327
|
-
if (value === null && nullable) return null;
|
|
328
|
-
if (value === void 0 && missable) return void 0;
|
|
329
|
-
const stringValue = value ?? fallbackValue;
|
|
330
|
-
if (allowedValues && typeof stringValue === "string" && !allowedValues.includes(stringValue)) return fallbackValue;
|
|
331
|
-
return stringValue;
|
|
332
|
-
}
|
|
333
|
-
function asNumberArray(value, options) {
|
|
334
|
-
const { nullable = false } = options || {};
|
|
335
|
-
if (value === null && nullable) return null;
|
|
336
|
-
if (value === void 0) return nullable ? null : [];
|
|
337
|
-
let arrayValue;
|
|
338
|
-
if (Array.isArray(value)) arrayValue = value;
|
|
339
|
-
else if (typeof value === "string") arrayValue = [value];
|
|
340
|
-
else arrayValue = [];
|
|
341
|
-
return arrayValue.map((item) => {
|
|
342
|
-
if (item === null) return 0;
|
|
343
|
-
const num = Number(item);
|
|
344
|
-
return isNaN(num) ? 0 : num;
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
function asArray(value, options) {
|
|
348
|
-
const { nullable = false, missable = false, transform: transform$1 } = options || {};
|
|
349
|
-
if (value === null && nullable) return null;
|
|
350
|
-
if (value === void 0 && missable) return void 0;
|
|
351
|
-
if (value === void 0) return nullable ? null : [];
|
|
352
|
-
let arrayValue;
|
|
353
|
-
if (Array.isArray(value)) arrayValue = value;
|
|
354
|
-
else arrayValue = [value];
|
|
355
|
-
if (transform$1) return arrayValue.map((item) => transform$1(item));
|
|
356
|
-
return arrayValue;
|
|
357
|
-
}
|
|
358
|
-
function asBoolean(value, options) {
|
|
359
|
-
const { nullable = false, missable = false, fallbackValue = missable ? void 0 : nullable ? null : false } = options || {};
|
|
360
|
-
if (value === null && nullable) return null;
|
|
361
|
-
if (value === void 0 && missable) return void 0;
|
|
362
|
-
if (value === void 0 || value === null) return fallbackValue;
|
|
363
|
-
if (typeof value === "string") {
|
|
364
|
-
const lowerValue = value.toLowerCase();
|
|
365
|
-
if (lowerValue === "true" || lowerValue === "1") return true;
|
|
366
|
-
if (lowerValue === "false" || lowerValue === "0") return false;
|
|
367
|
-
}
|
|
368
|
-
return fallbackValue;
|
|
369
|
-
}
|
|
370
|
-
const transform = {
|
|
371
|
-
asString,
|
|
372
|
-
asNumber,
|
|
373
|
-
asArray,
|
|
374
|
-
asNumberArray,
|
|
375
|
-
asBoolean
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
//#endregion
|
|
379
|
-
//#region src/injectionSymbols.ts
|
|
380
|
-
const contextStorageCollectionInjectKey = collection;
|
|
381
|
-
const contextStorageCollectionItemInjectKey = collectionItem;
|
|
382
|
-
const contextStorageHandlersInjectKey = handlers;
|
|
383
|
-
const contextStorageQueryHandlerInjectKey = contextStorageQueryHandler;
|
|
384
|
-
|
|
385
|
-
//#endregion
|
|
386
|
-
//#region src/constants.ts
|
|
387
|
-
const defaultHandlers = [ContextStorageQueryHandler];
|
|
388
|
-
|
|
389
|
-
//#endregion
|
|
390
|
-
exports.ContextStorageQueryHandler = ContextStorageQueryHandler;
|
|
391
|
-
exports.asArray = asArray;
|
|
392
|
-
exports.asBoolean = asBoolean;
|
|
393
|
-
exports.asNumber = asNumber;
|
|
394
|
-
exports.asNumberArray = asNumberArray;
|
|
395
|
-
exports.asString = asString;
|
|
396
|
-
exports.collection = collection;
|
|
397
|
-
exports.collectionItem = collectionItem;
|
|
398
|
-
exports.contextStorageCollectionInjectKey = contextStorageCollectionInjectKey;
|
|
399
|
-
exports.contextStorageCollectionItemInjectKey = contextStorageCollectionItemInjectKey;
|
|
400
|
-
exports.contextStorageHandlersInjectKey = contextStorageHandlersInjectKey;
|
|
401
|
-
exports.contextStorageQueryHandler = contextStorageQueryHandler;
|
|
402
|
-
exports.contextStorageQueryHandlerInjectKey = contextStorageQueryHandlerInjectKey;
|
|
403
|
-
exports.defaultHandlers = defaultHandlers;
|
|
404
|
-
exports.deserializeParams = deserializeParams;
|
|
405
|
-
exports.handlers = handlers;
|
|
406
|
-
exports.serializeParams = serializeParams;
|
|
407
|
-
exports.transform = transform;
|
|
408
|
-
exports.useContextStorageQueryHandler = useContextStorageQueryHandler;
|
|
409
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["params: Record<string, unknown>","options: SerializeOptions","result: LocationQuery","params: Record<string, any>","collection: unique symbol","collectionItem: unique symbol","handlers: unique symbol","contextStorageQueryHandler: unique symbol","data: MaybeRefOrGetter<T>","options?: RegisterQueryHandlerBaseOptions<T>","query: LocationQuery","sorted: LocationQuery","options: QueryHandlerBaseOptions","state: Record<string, unknown> | undefined","state: boolean","initial: boolean","#buildQueryFromRegistered","item: ContextStorageQueryRegisteredItem<T>","options: RegisterQueryHandlerOptions<T>","newQueryRaw: LocationQuery","value: QueryValue | number | undefined","options?: AsNumberOptions","value: QueryValue | undefined","options?: AsStringOptions","options?: AsNumberArrayOptions","arrayValue: (string | null)[]","options?: AsArrayOptions<T>","arrayValue: QueryValue[]","transform","options?: AsBooleanOptions","transform: {\n asString: typeof asString\n asNumber: typeof asNumber\n asArray: typeof asArray\n asNumberArray: typeof asNumberArray\n asBoolean: typeof asBoolean\n}","contextStorageCollectionInjectKey: InjectionKey<ContextStorageCollection>","contextStorageCollectionItemInjectKey: InjectionKey<ContextStorageCollectionItem>","contextStorageHandlersInjectKey: InjectionKey<\n ContextStorageCollectionItem['handlers']\n>","contextStorageQueryHandlerInjectKey: InjectionKey<\n InstanceType<typeof ContextStorageQueryHandler>\n>","defaultHandlers: ContextStorageHandlerConstructor[]"],"sources":["../src/handlers/query/helpers.ts","../src/symbols.ts","../src/handlers/query/index.ts","../src/handlers/query/transform-helpers.ts","../src/injectionSymbols.ts","../src/constants.ts"],"sourcesContent":["import { LocationQuery } from 'vue-router'\n\nexport interface SerializeOptions {\n /**\n * Custom prefix for serialized keys.\n * @example\n * - prefix: 'filters' => 'filters[key]'\n * - prefix: 'search' => 'search[key]'\n * - prefix: '' => 'key' (no prefix)\n */\n prefix?: string\n}\n\n/**\n * Serializes filter parameters into a URL-friendly format.\n *\n * @param params - Raw parameters object to serialize\n * @param options - Serialization options\n * @returns Serialized parameters with prefixed keys\n *\n * @example\n * // With default prefix 'filters'\n * serializeFiltersParams({ status: 'active', tags: ['a', 'b'] })\n * // => { 'filters[status]': 'active', 'filters[tags]': 'a,b' }\n *\n * @example\n * // With custom prefix\n * serializeFiltersParams({ name: 'John', all: true }, { prefix: 'search' })\n * // => { 'search[name]': 'John', 'search[all]': '1' }\n *\n * @example\n * // Without prefix\n * serializeFiltersParams({ page: 1, all: false }, { prefix: '' })\n * // => { 'page': '1', 'all': '0' }\n */\nexport function serializeParams(\n params: Record<string, unknown>,\n options: SerializeOptions = {},\n): LocationQuery {\n const { prefix = '' } = options\n\n const result: LocationQuery = {}\n\n Object.keys(params).forEach((key) => {\n const value = params[key]\n\n // Skip empty values, null, and empty arrays\n if (value === '') {\n return\n }\n\n if (value === null) {\n return\n }\n\n if (Array.isArray(value) && value.length === 0) {\n return\n }\n\n // Format the key with prefix (or without if prefix is empty)\n const formattedKey = prefix ? `${prefix}[${key}]` : key\n\n if (typeof value === 'object') {\n if (Array.isArray(value)) {\n // Serialize arrays directly: a=1&a=2&a=3\n result[formattedKey] = value.map(String)\n } else {\n Object.assign(\n result,\n serializeParams(value as Record<string, unknown>, {\n ...options,\n prefix: formattedKey,\n }),\n )\n }\n } else if (typeof value === 'boolean') {\n result[formattedKey] = value ? '1' : '0'\n } else {\n result[formattedKey] = String(value)\n }\n })\n\n return result\n}\n\n/**\n * Deserializes query parameters from a URL-friendly format back to an object.\n *\n * @param params - Serialized parameters object\n * @returns Deserialized parameters object\n *\n * @example\n * deserializeParams({ 'filters[status]': 'active', search: 'test' })\n * // => { filters: {status: 'active'}, search: 'test' }\n */\nexport function deserializeParams(params: Record<string, any>): Record<string, any> {\n return Object.keys(params).reduce<Record<string, any>>((acc, key) => {\n const value = params[key]\n\n // Parse nested structure: 'filters[status]' -> { filters: { status: value } }\n const bracketMatch = key.match(/^([^[]+)\\[(.+)]$/)\n\n if (bracketMatch) {\n const [, rootKey, nestedPath] = bracketMatch\n\n // Initialize root object if needed\n if (!acc[rootKey]) {\n acc[rootKey] = {}\n }\n\n // Parse nested path: 'created_at][from' -> ['created_at', 'from']\n const pathParts = nestedPath.split('][')\n\n // Navigate/create nested structure\n let current = acc[rootKey]\n for (let i = 0; i < pathParts.length - 1; i++) {\n const part = pathParts[i]\n if (!current[part]) {\n current[part] = {}\n }\n current = current[part]\n }\n\n // Set the final value\n const finalKey = pathParts[pathParts.length - 1]\n current[finalKey] = value\n } else {\n // No brackets - simple key\n acc[key] = value\n }\n\n return acc\n }, {})\n}\n","export const collection: unique symbol = Symbol('context-storage-collection')\nexport const collectionItem: unique symbol = Symbol('context-storage-collection-item')\nexport const handlers: unique symbol = Symbol('context-storage-handlers')\nexport const contextStorageQueryHandler: unique symbol = Symbol('context-storage-query-handler')\n","import { ContextStorageHandlerConstructor } from '../../handlers'\nimport { deserializeParams, serializeParams } from './helpers'\nimport { contextStorageQueryHandler } from '../../symbols'\nimport { cloneDeep, isEqual, merge, pick } from 'lodash-es'\nimport { getCurrentInstance, inject, MaybeRefOrGetter, onBeforeUnmount, toValue, watch } from 'vue'\nimport { LocationQuery, useRoute, useRouter } from 'vue-router'\nimport {\n ContextStorageQueryRegisteredItem,\n IContextStorageQueryHandler,\n QueryHandlerBaseOptions,\n RegisterQueryHandlerBaseOptions,\n RegisterQueryHandlerOptions,\n} from './types'\n\nexport function useContextStorageQueryHandler<T extends Record<string, unknown>>(\n data: MaybeRefOrGetter<T>,\n options?: RegisterQueryHandlerBaseOptions<T>,\n): void {\n const handler = inject<InstanceType<typeof ContextStorageQueryHandler>>(\n contextStorageQueryHandler,\n )\n\n if (!handler) {\n throw new Error('[ContextStorage] ContextStorageQueryHandler is not provided')\n }\n\n const currentInstance = getCurrentInstance()\n const uid = currentInstance?.uid || 0\n\n const causer = new Error().stack?.split('\\n')[2]?.trimStart() || 'unknown'\n\n const stop = handler.register(data, { causer, uid, ...options })\n onBeforeUnmount(() => {\n stop()\n })\n}\n\nfunction sortQueryByReference(query: LocationQuery, ...references: LocationQuery[]): LocationQuery {\n const sorted: LocationQuery = {}\n\n const referenceKeys = new Set<string>()\n\n references.forEach((reference) => {\n Object.keys(reference).forEach((key) => {\n referenceKeys.add(key)\n })\n })\n\n referenceKeys.forEach((key) => {\n if (key in query && !(key in sorted)) {\n sorted[key] = query[key]\n }\n })\n\n Object.keys(query).forEach((key) => {\n if (!(key in sorted)) {\n sorted[key] = query[key]\n }\n })\n\n return sorted\n}\n\nexport class ContextStorageQueryHandler implements IContextStorageQueryHandler {\n private enabled = false\n private registered: ContextStorageQueryRegisteredItem<any>[] = []\n private currentQuery: LocationQuery | undefined = undefined\n private readonly route: ReturnType<typeof useRoute>\n private router: ReturnType<typeof useRouter>\n private initialState?: Record<string, unknown>\n private hasAnyRegistered = false\n private preventSyncRegisteredToQueryByAfterEachRoute = false\n private preventAfterEachRouteCallsWhileCallingRouter = false\n\n static customQueryHandlerOptions: QueryHandlerBaseOptions = {}\n\n private readonly options: Required<QueryHandlerBaseOptions> = {\n mode: 'replace',\n emptyPlaceholder: '_',\n mergeOnlyExistingKeysWithoutTransform: true,\n preserveUnusedKeys: false,\n preserveEmptyState: false,\n }\n\n // noinspection JSUnusedGlobalSymbols\n static configure(options: QueryHandlerBaseOptions): ContextStorageHandlerConstructor {\n ContextStorageQueryHandler.customQueryHandlerOptions = options\n\n return ContextStorageQueryHandler\n }\n\n constructor() {\n this.route = useRoute()\n this.router = useRouter()\n\n this.options = {\n ...this.options,\n ...ContextStorageQueryHandler.customQueryHandlerOptions,\n }\n\n const stopAfterEach = this.router.afterEach(() => {\n this.afterEachRoute()\n })\n\n onBeforeUnmount(() => {\n stopAfterEach()\n })\n }\n\n getInjectionKey(): typeof contextStorageQueryHandler {\n return contextStorageQueryHandler\n }\n\n setInitialState(state: Record<string, unknown> | undefined): void {\n this.initialState = state\n }\n\n static getInitialStateResolver(): () => LocationQuery {\n const route = useRoute()\n\n return () => route.query\n }\n\n setEnabled(state: boolean, initial: boolean): void {\n const prevState = this.enabled\n this.enabled = state\n\n if (this.hasAnyRegistered) {\n if (initial) {\n this.syncInitialStateToRegistered()\n }\n\n if ((state && !prevState) || !initial) {\n this.syncRegisteredToQuery()\n }\n }\n }\n\n async syncRegisteredToQuery(): Promise<void> {\n if (!this.enabled) {\n return\n }\n\n if (this.preventSyncRegisteredToQueryByAfterEachRoute) {\n return\n }\n\n const { newQuery, newQueryRaw } = this.#buildQueryFromRegistered()\n\n this.currentQuery = newQueryRaw\n\n if (isEqual(newQuery, this.route.query)) {\n return\n }\n\n this.preventAfterEachRouteCallsWhileCallingRouter = true\n try {\n if (this.options.mode === 'replace') {\n await this.router.replace({ ...this.route, query: newQuery })\n } else {\n await this.router.push({ ...this.route, query: newQuery })\n }\n } catch (e) {\n console.error('[ContextStorage] Got error while routing', e)\n }\n this.preventAfterEachRouteCallsWhileCallingRouter = false\n }\n\n afterEachRoute(): void {\n if (!this.enabled) {\n return\n }\n\n if (this.preventAfterEachRouteCallsWhileCallingRouter) {\n return\n }\n\n this.setInitialState(this.route.query)\n\n this.preventSyncRegisteredToQueryByAfterEachRoute = true\n queueMicrotask(() => {\n this.preventSyncRegisteredToQueryByAfterEachRoute = false\n\n this.syncInitialStateToRegistered()\n this.syncRegisteredToQuery()\n })\n\n setTimeout(() => {\n this.syncInitialStateToRegistered()\n this.syncRegisteredToQuery()\n })\n }\n\n syncInitialStateToRegisteredItem<T extends Record<string, unknown>>(\n item: ContextStorageQueryRegisteredItem<T>,\n ): void {\n if (this.initialState === undefined) {\n return\n }\n\n let deserialized = deserializeParams(this.initialState)\n\n const {\n prefix,\n mergeOnlyExistingKeysWithoutTransform = this.options.mergeOnlyExistingKeysWithoutTransform,\n } = item.options || {}\n\n if (typeof prefix === 'string' && prefix.length > 0) {\n deserialized = deserialized[prefix]\n }\n\n if (deserialized === undefined) {\n return\n }\n\n const itemData = toValue(item.data)\n\n /**\n * null can be if query parameter only has a name without a value sign\n */\n if (deserialized !== null) {\n const deserializedKeys = Object.keys(deserialized)\n\n /**\n * If the data is empty, return the initial value.\n *\n * This can happen when directly navigating to a route, for example through a menu item.\n */\n if (!deserializedKeys.length) {\n merge(itemData, item.initialData)\n return\n }\n\n if (deserializedKeys.length === 1 && deserialized[this.options.emptyPlaceholder] === null) {\n delete deserialized[this.options.emptyPlaceholder]\n }\n }\n\n if (item.options?.transform) {\n deserialized = item.options.transform(deserialized, item.initialData)\n } else {\n if (mergeOnlyExistingKeysWithoutTransform) {\n deserialized = pick(deserialized, Object.keys(item.initialData))\n }\n }\n\n if (isEqual(itemData, deserialized)) {\n return\n }\n\n merge(itemData, deserialized)\n }\n\n syncInitialStateToRegistered(): void {\n this.registered.forEach((item) => this.syncInitialStateToRegisteredItem(item))\n }\n\n register<T extends Record<string, unknown>>(\n data: MaybeRefOrGetter<T>,\n options: RegisterQueryHandlerOptions<T>,\n ): () => void {\n this.hasAnyRegistered = true\n\n const watchHandle = watch(data, () => this.syncRegisteredToQuery(), {\n deep: true,\n })\n\n const item: ContextStorageQueryRegisteredItem<T> = {\n data,\n initialData: cloneDeep(toValue(data)) as T,\n options,\n watchHandle,\n }\n this.registered.push(item)\n\n const syncCallback = (): void => {\n this.syncInitialStateToRegisteredItem(item)\n this.syncRegisteredToQuery()\n }\n\n if (this.preventAfterEachRouteCallsWhileCallingRouter) {\n /**\n * Macrotask solves syncing issues when syncRegisteredToQuery called after HMR\n */\n setTimeout(syncCallback)\n } else {\n queueMicrotask(syncCallback)\n }\n\n return (): void => {\n this.registered.splice(this.registered.indexOf(item), 1)\n this.syncRegisteredToQuery()\n }\n }\n\n #buildQueryFromRegistered(): { newQuery: LocationQuery; newQueryRaw: LocationQuery } {\n const newQueryRaw: LocationQuery = {}\n\n this.registered.forEach((item) => {\n const { prefix, preserveEmptyState = this.options.preserveEmptyState } = item.options || {}\n const patch = serializeParams(toValue(item.data), {\n prefix,\n })\n\n const patchKeys = Object.keys(patch)\n\n // If there are key intersections between the query and the patch, a warning is issued.\n // Patches should not overwrite each other, otherwise, upon reload, an incorrect value will be restored.\n patchKeys.forEach((key) => {\n if (newQueryRaw.hasOwnProperty(key)) {\n console.warn(\n `[ContextStorage] Key ${key} is already present, overriding ` +\n (item.options?.causer || ''),\n )\n }\n })\n\n if (!patchKeys.length && preserveEmptyState) {\n patch[prefix || this.options.emptyPlaceholder] = null\n }\n\n Object.assign(newQueryRaw, patch)\n })\n\n let newQuery = { ...newQueryRaw }\n\n /*\n * It will not delete from the query the keys that are not used in the patch.\n *\n * It will only work if the registered item has a transform, otherwise without\n * it - all keys are dumped into item.data during the initial fill from initialState\n */\n if (this.options.preserveUnusedKeys) {\n newQuery = { ...this.route.query, ...newQuery }\n }\n\n if (this.currentQuery !== undefined) {\n //Perform a diff of keys between currentQuery and newQueryRaw, and remove the keys that are in currentQuery but not in newQueryRaw.\n //This is necessary to ensure that the query string does not contain keys that are no longer used.\n Object.keys(this.currentQuery).forEach((key) => {\n if (!newQueryRaw.hasOwnProperty(key)) {\n delete newQuery[key]\n }\n })\n }\n\n if (Object.keys(newQuery).length > 1 && newQuery[this.options.emptyPlaceholder] === null) {\n delete newQuery[this.options.emptyPlaceholder]\n }\n\n newQuery = sortQueryByReference(newQuery, newQueryRaw)\n\n return { newQuery, newQueryRaw }\n }\n}\n","import { QueryValue } from './types'\n\ninterface AsNumberOptions {\n nullable?: boolean\n missable?: boolean\n fallbackValue?: number\n}\n\nexport function asNumber(value: QueryValue | number | undefined): number\nexport function asNumber(\n value: QueryValue | number | undefined,\n options: { nullable: true; missable: true; fallbackValue?: number },\n): number | null | undefined\nexport function asNumber(\n value: QueryValue | number | undefined,\n options: { nullable: true; missable?: false; fallbackValue?: number },\n): number | null\nexport function asNumber(\n value: QueryValue | number | undefined,\n options: { nullable?: false; missable: true; fallbackValue?: number },\n): number | undefined\nexport function asNumber(\n value: QueryValue | number | undefined,\n options: { nullable?: false; missable?: false; fallbackValue?: number },\n): number\nexport function asNumber(\n value: QueryValue | number | undefined,\n options?: AsNumberOptions,\n): number | null | undefined {\n const {\n nullable = false,\n missable = false,\n fallbackValue = missable ? undefined : nullable ? null : 0,\n } = options || {}\n\n if (value === null && nullable) {\n return null\n }\n\n if (value === undefined && missable) {\n return undefined\n }\n\n value = Number(value)\n\n return isNaN(value) ? fallbackValue : value\n}\n\ninterface AsStringOptions<T extends readonly string[] = string[]> {\n nullable?: boolean\n missable?: boolean\n fallbackValue?: T extends readonly string[] ? T[number] : string\n allowedValues?: T\n}\n\nexport function asString(value: QueryValue | undefined): string\nexport function asString<T extends readonly string[]>(\n value: QueryValue | undefined,\n options: {\n nullable: true\n missable: true\n fallbackValue?: T[number]\n allowedValues: T\n },\n): T[number] | null | undefined\nexport function asString<T extends readonly string[]>(\n value: QueryValue | undefined,\n options: {\n nullable: true\n missable?: false\n fallbackValue?: T[number]\n allowedValues: T\n },\n): T[number] | null\nexport function asString<T extends readonly string[]>(\n value: QueryValue | undefined,\n options: {\n nullable?: false\n missable: true\n fallbackValue?: T[number]\n allowedValues: T\n },\n): T[number] | undefined\nexport function asString<T extends readonly string[]>(\n value: QueryValue | undefined,\n options: {\n nullable?: false\n missable?: false\n fallbackValue?: T[number]\n allowedValues: T\n },\n): T[number]\nexport function asString(\n value: QueryValue | undefined,\n options: { nullable: true; missable: true; fallbackValue?: string },\n): string | null | undefined\nexport function asString(\n value: QueryValue | undefined,\n options: { nullable: true; missable?: false; fallbackValue?: string },\n): string | null\nexport function asString(\n value: QueryValue | undefined,\n options: { nullable?: false; missable: true; fallbackValue?: string },\n): string | undefined\nexport function asString(\n value: QueryValue | undefined,\n options: { nullable?: false; missable?: false; fallbackValue?: string },\n): string\nexport function asString(\n value: QueryValue | undefined,\n options?: AsStringOptions,\n): QueryValue | undefined {\n const {\n nullable = false,\n missable = false,\n fallbackValue = missable ? undefined : nullable ? null : '',\n allowedValues,\n } = options || {}\n\n if (value === null && nullable) {\n return null\n }\n\n if (value === undefined && missable) {\n return undefined\n }\n\n const stringValue = value ?? fallbackValue\n\n if (allowedValues && typeof stringValue === 'string' && !allowedValues.includes(stringValue)) {\n return fallbackValue\n }\n\n return stringValue\n}\n\ninterface AsNumberArrayOptions {\n nullable?: boolean\n}\n\nexport function asNumberArray(value: QueryValue | undefined): number[]\nexport function asNumberArray(\n value: QueryValue | undefined,\n options: { nullable: true },\n): number[] | null\nexport function asNumberArray(\n value: QueryValue | undefined,\n options: { nullable?: false },\n): number[]\nexport function asNumberArray(\n value: QueryValue | undefined,\n options?: AsNumberArrayOptions,\n): number[] | null {\n const { nullable = false } = options || {}\n\n if (value === null && nullable) {\n return null\n }\n\n if (value === undefined) {\n return nullable ? null : []\n }\n\n let arrayValue: (string | null)[]\n\n if (Array.isArray(value)) {\n arrayValue = value\n } else if (typeof value === 'string') {\n arrayValue = [value]\n } else {\n arrayValue = []\n }\n\n return arrayValue.map((item) => {\n if (item === null) {\n return 0\n }\n const num = Number(item)\n return isNaN(num) ? 0 : num\n })\n}\n\ninterface AsArrayOptions<T> {\n nullable?: boolean\n missable?: boolean\n transform?: (value: QueryValue) => T\n}\n\nexport function asArray<T>(value: QueryValue | undefined): T[]\nexport function asArray<T>(\n value: QueryValue | undefined,\n options: { nullable: true; missable: true; transform?: (value: QueryValue) => T },\n): T[] | null | undefined\nexport function asArray<T>(\n value: QueryValue | undefined,\n options: { nullable: true; missable?: false; transform?: (value: QueryValue) => T },\n): T[] | null\nexport function asArray<T>(\n value: QueryValue | undefined,\n options: { nullable?: false; missable: true; transform?: (value: QueryValue) => T },\n): T[] | undefined\nexport function asArray<T>(\n value: QueryValue | undefined,\n options: { nullable?: false; missable?: false; transform?: (value: QueryValue) => T },\n): T[]\nexport function asArray<T>(\n value: QueryValue | undefined,\n options?: AsArrayOptions<T>,\n): T[] | null | undefined {\n const { nullable = false, missable = false, transform } = options || {}\n\n if (value === null && nullable) {\n return null\n }\n\n if (value === undefined && missable) {\n return undefined\n }\n\n if (value === undefined) {\n return nullable ? null : []\n }\n\n let arrayValue: QueryValue[]\n\n if (Array.isArray(value)) {\n arrayValue = value\n } else {\n arrayValue = [value]\n }\n\n if (transform) {\n return arrayValue.map((item) => transform(item))\n }\n\n return arrayValue as T[]\n}\n\ninterface AsBooleanOptions {\n nullable?: boolean\n missable?: boolean\n fallbackValue?: boolean\n}\n\nexport function asBoolean(value: QueryValue | undefined): boolean\nexport function asBoolean(\n value: QueryValue | undefined,\n options: { nullable: true; missable: true; fallbackValue?: boolean },\n): boolean | null | undefined\nexport function asBoolean(\n value: QueryValue | undefined,\n options: { nullable: true; missable?: false; fallbackValue?: boolean },\n): boolean | null\nexport function asBoolean(\n value: QueryValue | undefined,\n options: { nullable?: false; missable: true; fallbackValue?: boolean },\n): boolean | undefined\nexport function asBoolean(\n value: QueryValue | undefined,\n options: { nullable?: false; missable?: false; fallbackValue?: boolean },\n): boolean\nexport function asBoolean(\n value: QueryValue | undefined,\n options?: AsBooleanOptions,\n): boolean | null | undefined {\n const {\n nullable = false,\n missable = false,\n fallbackValue = missable ? undefined : nullable ? null : false,\n } = options || {}\n\n if (value === null && nullable) {\n return null\n }\n\n if (value === undefined && missable) {\n return undefined\n }\n\n if (value === undefined || value === null) {\n return fallbackValue\n }\n\n if (typeof value === 'string') {\n const lowerValue = value.toLowerCase()\n if (lowerValue === 'true' || lowerValue === '1') {\n return true\n }\n if (lowerValue === 'false' || lowerValue === '0') {\n return false\n }\n }\n\n return fallbackValue\n}\n\nexport const transform: {\n asString: typeof asString\n asNumber: typeof asNumber\n asArray: typeof asArray\n asNumberArray: typeof asNumberArray\n asBoolean: typeof asBoolean\n} = {\n asString,\n asNumber,\n asArray,\n asNumberArray,\n asBoolean,\n}\n","import { ContextStorageCollection, ContextStorageCollectionItem } from './collection'\nimport { ContextStorageQueryHandler } from './handlers/query'\nimport { collection, collectionItem, contextStorageQueryHandler, handlers } from './symbols'\nimport { InjectionKey } from 'vue'\n\nexport const contextStorageCollectionInjectKey: InjectionKey<ContextStorageCollection> = collection\nexport const contextStorageCollectionItemInjectKey: InjectionKey<ContextStorageCollectionItem> =\n collectionItem\nexport const contextStorageHandlersInjectKey: InjectionKey<\n ContextStorageCollectionItem['handlers']\n> = handlers\n\nexport const contextStorageQueryHandlerInjectKey: InjectionKey<\n InstanceType<typeof ContextStorageQueryHandler>\n> = contextStorageQueryHandler\n","// Singleton file for constants to prevent module duplication\nimport { ContextStorageQueryHandler } from './handlers/query'\nimport type { ContextStorageHandlerConstructor } from './handlers'\n\nexport const defaultHandlers: ContextStorageHandlerConstructor[] = [ContextStorageQueryHandler]\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAgB,gBACdA,QACAC,UAA4B,CAAE,GACf;CACf,MAAM,EAAE,SAAS,IAAI,GAAG;CAExB,MAAMC,SAAwB,CAAE;AAEhC,QAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,QAAQ;EACnC,MAAM,QAAQ,OAAO;AAGrB,MAAI,UAAU,GACZ;AAGF,MAAI,UAAU,KACZ;AAGF,MAAI,MAAM,QAAQ,MAAM,IAAI,MAAM,WAAW,EAC3C;EAIF,MAAM,eAAe,UAAU,EAAE,OAAO,GAAG,IAAI,KAAK;AAEpD,aAAW,UAAU,SACnB,KAAI,MAAM,QAAQ,MAAM,CAEtB,QAAO,gBAAgB,MAAM,IAAI,OAAO;MAExC,QAAO,OACL,QACA,gBAAgB,OAAkC;GAChD,GAAG;GACH,QAAQ;EACT,EAAC,CACH;kBAEa,UAAU,UAC1B,QAAO,gBAAgB,QAAQ,MAAM;MAErC,QAAO,gBAAgB,OAAO,MAAM;CAEvC,EAAC;AAEF,QAAO;AACR;;;;;;;;;;;AAYD,SAAgB,kBAAkBC,QAAkD;AAClF,QAAO,OAAO,KAAK,OAAO,CAAC,OAA4B,CAAC,KAAK,QAAQ;EACnE,MAAM,QAAQ,OAAO;EAGrB,MAAM,eAAe,IAAI,MAAM,mBAAmB;AAElD,MAAI,cAAc;GAChB,MAAM,GA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terBaseOptions, } from './handlers';
|
|
2
|
-
export { ContextStorageQueryHandler, useContextStorageQueryHandler } from './handlers/query';
|
|
3
|
-
export { deserializeParams, serializeParams } from './handlers/query/helpers';
|
|
4
|
-
export type { SerializeOptions } from './handlers/query/helpers';
|
|
5
|
-
export { asArray, asBoolean, asNumber, asNumberArray, asString, transform, } from './handlers/query/transform-helpers';
|
|
6
|
-
export { contextStorageCollectionInjectKey, contextStorageCollectionItemInjectKey, contextStorageHandlersInjectKey, contextStorageQueryHandlerInjectKey, } from './injectionSymbols';
|
|
7
|
-
export { collection, collectionItem, contextStorageQueryHandler, handlers } from './symbols';
|
|
8
|
-
export { defaultHandlers } from './constants';
|
|
9
|
-
export type { QueryValue, IContextStorageQueryHandler } from './handlers/query/types';
|
|
10
|
-
export type { ContextStorageCollectionItem } from './collection';
|