@warp-drive-mirror/experiments 5.10.0-alpha.12 → 5.10.0-alpha.14
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/README.md +11 -1
- package/dist/data-worker.d.ts +8 -1
- package/dist/data-worker.d.ts.map +1 -1
- package/dist/data-worker.js +3 -1
- package/dist/data-worker.js.map +1 -1
- package/dist/{document-storage-CwwTQ49-.d.ts → document-storage-CxgHVe4i.d.ts} +4 -1
- package/dist/{document-storage-CwwTQ49-.d.ts.map → document-storage-CxgHVe4i.d.ts.map} +1 -1
- package/dist/{document-storage-LM925Stz.js → document-storage-GI-wDgId.js} +4 -1
- package/dist/{document-storage-LM925Stz.js.map → document-storage-GI-wDgId.js.map} +1 -1
- package/dist/document-storage.d.ts +6 -1
- package/dist/document-storage.js +1 -1
- package/dist/image-fetch.d.ts +9 -0
- package/dist/image-fetch.d.ts.map +1 -1
- package/dist/image-fetch.js +2 -0
- package/dist/image-fetch.js.map +1 -1
- package/dist/image-worker.d.ts +8 -0
- package/dist/image-worker.d.ts.map +1 -1
- package/dist/image-worker.js +2 -0
- package/dist/image-worker.js.map +1 -1
- package/dist/pagination.d.ts +16 -0
- package/dist/storage.d.ts +49 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +44 -0
- package/dist/storage.js.map +1 -1
- package/dist/unpkg/dev/data-worker.js +3 -1
- package/dist/unpkg/dev/data-worker.js.map +1 -1
- package/dist/unpkg/dev/{document-storage-DkiEg9rY.js → document-storage-CXjnkUtf.js} +4 -1
- package/dist/unpkg/dev/{document-storage-DkiEg9rY.js.map → document-storage-CXjnkUtf.js.map} +1 -1
- package/dist/unpkg/dev/document-storage.js +1 -1
- package/dist/unpkg/dev/image-fetch.js +2 -0
- package/dist/unpkg/dev/image-fetch.js.map +1 -1
- package/dist/unpkg/dev/image-worker.js +2 -0
- package/dist/unpkg/dev/image-worker.js.map +1 -1
- package/dist/unpkg/dev/storage.js +44 -0
- package/dist/unpkg/dev/storage.js.map +1 -1
- package/dist/unpkg/dev-deprecated/data-worker.js +3 -1
- package/dist/unpkg/dev-deprecated/data-worker.js.map +1 -1
- package/dist/unpkg/dev-deprecated/{document-storage-DkiEg9rY.js → document-storage-CXjnkUtf.js} +4 -1
- package/dist/unpkg/dev-deprecated/{document-storage-DkiEg9rY.js.map → document-storage-CXjnkUtf.js.map} +1 -1
- package/dist/unpkg/dev-deprecated/document-storage.js +1 -1
- package/dist/unpkg/dev-deprecated/image-fetch.js +2 -0
- package/dist/unpkg/dev-deprecated/image-fetch.js.map +1 -1
- package/dist/unpkg/dev-deprecated/image-worker.js +2 -0
- package/dist/unpkg/dev-deprecated/image-worker.js.map +1 -1
- package/dist/unpkg/dev-deprecated/storage.js +44 -0
- package/dist/unpkg/dev-deprecated/storage.js.map +1 -1
- package/dist/unpkg/prod/data-worker.js +3 -1
- package/dist/unpkg/prod/data-worker.js.map +1 -1
- package/dist/unpkg/{prod-deprecated/document-storage-D0k_6GM9.js → prod/document-storage-Boz-E7CE.js} +4 -1
- package/dist/unpkg/{prod-deprecated/document-storage-D0k_6GM9.js.map → prod/document-storage-Boz-E7CE.js.map} +1 -1
- package/dist/unpkg/prod/document-storage.js +1 -1
- package/dist/unpkg/prod/image-fetch.js +2 -0
- package/dist/unpkg/prod/image-fetch.js.map +1 -1
- package/dist/unpkg/prod/image-worker.js +2 -0
- package/dist/unpkg/prod/image-worker.js.map +1 -1
- package/dist/unpkg/prod/storage.js +44 -0
- package/dist/unpkg/prod/storage.js.map +1 -1
- package/dist/unpkg/prod-deprecated/data-worker.js +3 -1
- package/dist/unpkg/prod-deprecated/data-worker.js.map +1 -1
- package/dist/unpkg/{prod/document-storage-D0k_6GM9.js → prod-deprecated/document-storage-Boz-E7CE.js} +4 -1
- package/dist/unpkg/{prod/document-storage-D0k_6GM9.js.map → prod-deprecated/document-storage-Boz-E7CE.js.map} +1 -1
- package/dist/unpkg/prod-deprecated/document-storage.js +1 -1
- package/dist/unpkg/prod-deprecated/image-fetch.js +2 -0
- package/dist/unpkg/prod-deprecated/image-fetch.js.map +1 -1
- package/dist/unpkg/prod-deprecated/image-worker.js +2 -0
- package/dist/unpkg/prod-deprecated/image-worker.js.map +1 -1
- package/dist/unpkg/prod-deprecated/storage.js +44 -0
- package/dist/unpkg/prod-deprecated/storage.js.map +1 -1
- package/dist/worker-fetch.d.ts +6 -0
- package/dist/worker-fetch.d.ts.map +1 -1
- package/logos/README.md +1 -1
- package/package.json +7 -7
package/dist/storage.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @summary Experimental reactive wrappers over localStorage, sessionStorage and the Cache API, with decorators such as
|
|
4
|
+
* `LocalResource` and `param` that bind class fields to storage or query params.
|
|
5
|
+
*/
|
|
1
6
|
//#region src/storage/cache.d.ts
|
|
2
7
|
export declare const DEFAULT_CACHE_ID = "reactive-cache";
|
|
3
8
|
export interface InternalCacheStorageEvent {
|
|
@@ -17,6 +22,9 @@ export interface CacheStorageEvent {
|
|
|
17
22
|
*
|
|
18
23
|
* This is a good option for larger data sets than can be efficiently stored in localStorage
|
|
19
24
|
* but should not be used as a permanent DB or storage solution.
|
|
25
|
+
*
|
|
26
|
+
* @summary Experimental `Storage`-compatible interface over the browser Cache API, suited to larger JSON data sets than
|
|
27
|
+
* localStorage.
|
|
20
28
|
*/
|
|
21
29
|
export declare class CacheStorage implements Storage {
|
|
22
30
|
#private;
|
|
@@ -65,6 +73,9 @@ export interface ReactiveStorageOptions {
|
|
|
65
73
|
* Retrieves the singleton instance of the LocalStorage service.
|
|
66
74
|
*
|
|
67
75
|
* If the instance does not already exist, it is created.
|
|
76
|
+
*
|
|
77
|
+
* @summary Experimental function that returns the shared reactive wrapper around localStorage, creating it on first
|
|
78
|
+
* call.
|
|
68
79
|
*/
|
|
69
80
|
export declare function getLocalStorage(): ReactiveStorage;
|
|
70
81
|
export declare function getSessionStorage(): ReactiveStorage;
|
|
@@ -72,11 +83,17 @@ export declare function getCacheStorage(namespace?: string | null): ReactiveStor
|
|
|
72
83
|
/**
|
|
73
84
|
* Configure options for the localStorage singleton.
|
|
74
85
|
* Must be called before getLocalStorage() is first invoked.
|
|
86
|
+
*
|
|
87
|
+
* @summary Experimental function that sets fallback and quota-handling options for the reactive localStorage singleton
|
|
88
|
+
* before its first use.
|
|
75
89
|
*/
|
|
76
90
|
export declare function configureLocalStorage(options: ReactiveStorageOptions): void;
|
|
77
91
|
/**
|
|
78
92
|
* Configure options for the sessionStorage singleton.
|
|
79
93
|
* Must be called before getSessionStorage() is first invoked.
|
|
94
|
+
*
|
|
95
|
+
* @summary Experimental function that sets fallback and quota-handling options for the reactive sessionStorage
|
|
96
|
+
* singleton before its first use.
|
|
80
97
|
*/
|
|
81
98
|
export declare function configureSessionStorage(options: ReactiveStorageOptions): void;
|
|
82
99
|
export type EffectStorageEvent = CacheStorageEvent | StorageEvent;
|
|
@@ -97,6 +114,9 @@ export type EffectStorageEvent = CacheStorageEvent | StorageEvent;
|
|
|
97
114
|
*
|
|
98
115
|
* Route storage-event subscribers through this helper instead of calling
|
|
99
116
|
* `window.addEventListener('storage', ...)` directly.
|
|
117
|
+
*
|
|
118
|
+
* @summary Experimental helper that subscribes to storage changes from both native `StorageEvent`s and `CacheStorage`
|
|
119
|
+
* notifications, returning an unsubscribe function.
|
|
100
120
|
*/
|
|
101
121
|
export declare function onStorageEvent(listener: (event: EffectStorageEvent) => void): () => void;
|
|
102
122
|
/**
|
|
@@ -104,6 +124,9 @@ export declare function onStorageEvent(listener: (event: EffectStorageEvent) =>
|
|
|
104
124
|
* that provides signal-based access to storage items and length.
|
|
105
125
|
*
|
|
106
126
|
* Will automatically update when storage events occur in other tabs/windows.
|
|
127
|
+
*
|
|
128
|
+
* @summary Experimental signal-backed wrapper around a `Storage` area that makes reads reactive and updates on changes
|
|
129
|
+
* from other tabs.
|
|
107
130
|
*/
|
|
108
131
|
declare class ReactiveStorage implements Storage {
|
|
109
132
|
private _storage;
|
|
@@ -148,6 +171,9 @@ declare class ReactiveStorage implements Storage {
|
|
|
148
171
|
//#region src/storage/query-params.d.ts
|
|
149
172
|
/**
|
|
150
173
|
* Configuration options for fields that are also query parameters
|
|
174
|
+
*
|
|
175
|
+
* @summary Experimental config passed to the `param` decorator that describes how a field is serialized to and parsed
|
|
176
|
+
* from a URL query parameter.
|
|
151
177
|
*/
|
|
152
178
|
export interface ParamConfig {
|
|
153
179
|
/**
|
|
@@ -174,6 +200,8 @@ export interface ParamConfig {
|
|
|
174
200
|
/**
|
|
175
201
|
* Creates a {@link ParamConfig} for boolean fields that serialize to '1' or null.
|
|
176
202
|
*
|
|
203
|
+
* @summary Experimental helper that creates a query-param config serializing a boolean field as '1' when true and
|
|
204
|
+
* omitting it when false.
|
|
177
205
|
* @returns ParamConfig for boolean fields
|
|
178
206
|
*
|
|
179
207
|
* @example
|
|
@@ -187,6 +215,8 @@ export declare function BooleanParam(): ParamConfig;
|
|
|
187
215
|
/**
|
|
188
216
|
* Creates a {@link ParamConfig} for numeric fields with default value checking.
|
|
189
217
|
*
|
|
218
|
+
* @summary Experimental helper that creates a query-param config serializing numbers, optionally to a fixed precision,
|
|
219
|
+
* with an optional default value.
|
|
190
220
|
* @param precision - When given, the number of digits to serialize after the decimal point
|
|
191
221
|
* @param getDefault - Function to get the default value for comparison
|
|
192
222
|
* @returns ParamConfig for number fields
|
|
@@ -211,6 +241,8 @@ export declare function NumberParam(precision?: number, getDefault?: (instance:
|
|
|
211
241
|
* - Compare URL and local values
|
|
212
242
|
* - Determine when to include/exclude params from the URL
|
|
213
243
|
*
|
|
244
|
+
* @summary Experimental decorator that marks a storage resource field as a URL query parameter, recording how to
|
|
245
|
+
* serialize it for a router integration.
|
|
214
246
|
* @param config - Configuration for URL serialization/deserialization
|
|
215
247
|
*
|
|
216
248
|
* @example
|
|
@@ -260,6 +292,9 @@ interface StorageResourceMeta {
|
|
|
260
292
|
* Use functions when you want to create more than
|
|
261
293
|
* one instance of a resource type, each with its own
|
|
262
294
|
* persisted data.
|
|
295
|
+
*
|
|
296
|
+
* @summary Experimental function type that derives a unique storage key from a storage resource instance, so each
|
|
297
|
+
* instance persists its own data.
|
|
263
298
|
*/
|
|
264
299
|
type KeyFn = (obj: any) => string;
|
|
265
300
|
/**
|
|
@@ -304,6 +339,9 @@ declare function getParamCompanion(instance: object, groupControlMap?: Record<st
|
|
|
304
339
|
*
|
|
305
340
|
* The function will be called once per instance during
|
|
306
341
|
* initialization to determine the unique ID for that instance.
|
|
342
|
+
*
|
|
343
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist in
|
|
344
|
+
* localStorage.
|
|
307
345
|
*/
|
|
308
346
|
export declare function LocalResource(id: string | KeyFn): ClassDecorator;
|
|
309
347
|
/**
|
|
@@ -319,6 +357,9 @@ export declare function LocalResource(id: string | KeyFn): ClassDecorator;
|
|
|
319
357
|
*
|
|
320
358
|
* The function will be called once per instance during
|
|
321
359
|
* initialization to determine the unique ID for that instance.
|
|
360
|
+
*
|
|
361
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist in
|
|
362
|
+
* sessionStorage.
|
|
322
363
|
*/
|
|
323
364
|
export declare function SessionResource(id: string | KeyFn): ClassDecorator;
|
|
324
365
|
/**
|
|
@@ -339,6 +380,9 @@ export declare function SessionResource(id: string | KeyFn): ClassDecorator;
|
|
|
339
380
|
* All object cached in the same `namespace` share the namespace's storage context,
|
|
340
381
|
* so partitioning can be achieved by using different namespaces for different groups
|
|
341
382
|
* of data.
|
|
383
|
+
*
|
|
384
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist via the Cache
|
|
385
|
+
* API and are shared across tabs.
|
|
342
386
|
*/
|
|
343
387
|
export declare function CacheResource(id: string | KeyFn, namespace?: string | null): ClassDecorator;
|
|
344
388
|
/**
|
|
@@ -371,6 +415,8 @@ export declare function CacheResource(id: string | KeyFn, namespace?: string | n
|
|
|
371
415
|
* }
|
|
372
416
|
* ```
|
|
373
417
|
*
|
|
418
|
+
* @summary Experimental decorator that makes a storage resource property a reactive field persisted to local, session,
|
|
419
|
+
* or cache storage.
|
|
374
420
|
*/
|
|
375
421
|
export declare function field(type: "local" | "session" | "cache"): PropertyDecorator;
|
|
376
422
|
export declare function field(target: object, key: string, descriptor?: PropertyDescriptor): void;
|
|
@@ -425,6 +471,9 @@ export declare function input(type: "number" | "boolean" | "float"): PropertyDec
|
|
|
425
471
|
* }
|
|
426
472
|
* }
|
|
427
473
|
* ```
|
|
474
|
+
*
|
|
475
|
+
* @summary Experimental field decorator for storage resources that runs a callback when the stored value changes in
|
|
476
|
+
* another tab or window.
|
|
428
477
|
*/
|
|
429
478
|
export declare function effect(fn: <K>(update: ValueTransition<K>) => void, type?: "local" | "session"): PropertyDecorator;
|
|
430
479
|
//#endregion
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","names":[],"sources":["../src/storage/cache.ts","../src/storage/storage.ts","../src/storage/query-params.ts","../src/storage/-private/storage-infra.ts","../src/storage/storage-resource.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"storage.d.ts","names":[],"sources":["../src/storage/cache.ts","../src/storage/storage.ts","../src/storage/query-params.ts","../src/storage/-private/storage-infra.ts","../src/storage/storage-resource.ts"],"mappings":";;;;;;qBAEa;iBAKI;EACf;EACA;EACA;EACA;;iBAEe;EACf,aAAa;EACb;EACA;EACA;;;;;;;;;;;qBAqEW,wBAAwB;;EAInC,OAAO;EACP;EACA,iBAAiB;EAYjB,YAAY;MAMR;EA4BJ;EAKA,QAAQ;EAIR,IAAI;EAgBJ,WAAW;EAQX,QAAQ,aAAa;;;;;SAed,IAAI,mBAAqC,QAAQ;SASjD,YAAY,mBAAqC;;;;;SAYjD;;;;iBCzMQ;;;;;EAKf;;;;;EAMA;;;;;EAMA,mBAAmB,aAAa,4BAA4B;;;;;;;;;;wBAmB9C,mBAAmB;wBAOnB,qBAAqB;wBAQrB,gBAAgB,4BAAkC;;;;;;;;wBAkBlD,sBAAsB,SAAS;;;;;;;;wBAW/B,wBAAwB,SAAS;YA8BrC,qBAAqB,oBAAoB;;;;;;;;;;;;;;;;;;;;;;wBAuBrC,eAAe,WAAW,OAAO;;;;;;;;;;cAkB3C,2BAA2B;UACvB;UACA;UACA;UACA;UAEQ;UACA;UAER;EACR,UAAU,aAAa,KAAK,OAAO;EAKnC,YAAY,SAAS,SAAS,UAAS;;;;MAyCnC;;;;EAOJ,SAAS;;;;EAsBT,QAAQ;;;;EAyBR,QAAQ,aAAa;;;;EA2DrB,WAAW;;;;EAsBX;;;;EAeA,IAAI;;;;;;;;;;iBChWW;;;;;EAKf,YAAY,gBAAgB;;;;;EAK5B,cAAc,kBAAkB;;;;;;;;;;EAUhC,cAAc;;;;;;;;;;;;;;;;wBAiBA,gBAAgB;;;;;;;;;;;;;;;;;wBAuBhB,YAAY,oBAAoB,cAAc,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAiDrF,MAAM,QAAQ,cAAc;;;UClHlC,4BAA4B;EACpC;;UAGe,gBAAgB;EAC/B;EACA,MAAM;EACN,IAAI;;;;;UAMW;EACf;EACA;EACA,MAAM;EACN;EACA,eAAe;EACf,QAAQ,qBAAqB,QAAQ;EACrC,cAAc;EACd,cAAc,YAAY;EAC1B;EACA,WAAW,gBAAgB;;;;;;;;;;;;;;KAgBjB,SAAS;;;;;;;iBAaL,SAAS,iBAAiB;iBAsG1B,iBAAiB,kBAAkB;;;;;;;;;;;;;;;;;;;iBAgNnC,kBAAkB,kBAAkB,kBAAkB;;;;;;;;;;;;;;;;;;;;wBCjVtD,cAAc,aAAa,QAAQ;;;;;;;;;;;;;;;;;;wBAqBnC,gBAAgB,aAAa,QAAQ;;;;;;;;;;;;;;;;;;;;;;;wBA0BrC,cAAc,aAAa,OAAO,4BAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAqCpE,MAAM,sCAAsC;wBAC5C,MAAM,gBAAgB,aAAa,aAAa;wBAgBhD,MAAM,uCAAuC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAuF7C,OAAO,KAAK,GAAG,QAAQ,gBAAgB,aAAa,6BAA6B"}
|
package/dist/storage.js
CHANGED
|
@@ -81,6 +81,9 @@ StorageEvents.addEventListener("message", handleCacheEvent);
|
|
|
81
81
|
*
|
|
82
82
|
* This is a good option for larger data sets than can be efficiently stored in localStorage
|
|
83
83
|
* but should not be used as a permanent DB or storage solution.
|
|
84
|
+
*
|
|
85
|
+
* @summary Experimental `Storage`-compatible interface over the browser Cache API, suited to larger JSON data sets than
|
|
86
|
+
* localStorage.
|
|
84
87
|
*/
|
|
85
88
|
var CacheStorage = class CacheStorage {
|
|
86
89
|
#cache;
|
|
@@ -217,6 +220,9 @@ let sessionStorageOptions = {};
|
|
|
217
220
|
* Retrieves the singleton instance of the LocalStorage service.
|
|
218
221
|
*
|
|
219
222
|
* If the instance does not already exist, it is created.
|
|
223
|
+
*
|
|
224
|
+
* @summary Experimental function that returns the shared reactive wrapper around localStorage, creating it on first
|
|
225
|
+
* call.
|
|
220
226
|
*/
|
|
221
227
|
function getLocalStorage() {
|
|
222
228
|
if (!localStorageInstance) localStorageInstance = new ReactiveStorage(localStorage, localStorageOptions);
|
|
@@ -240,6 +246,9 @@ function getCacheStorage(namespace = null) {
|
|
|
240
246
|
/**
|
|
241
247
|
* Configure options for the localStorage singleton.
|
|
242
248
|
* Must be called before getLocalStorage() is first invoked.
|
|
249
|
+
*
|
|
250
|
+
* @summary Experimental function that sets fallback and quota-handling options for the reactive localStorage singleton
|
|
251
|
+
* before its first use.
|
|
243
252
|
*/
|
|
244
253
|
function configureLocalStorage(options) {
|
|
245
254
|
localStorageOptions = options;
|
|
@@ -247,6 +256,9 @@ function configureLocalStorage(options) {
|
|
|
247
256
|
/**
|
|
248
257
|
* Configure options for the sessionStorage singleton.
|
|
249
258
|
* Must be called before getSessionStorage() is first invoked.
|
|
259
|
+
*
|
|
260
|
+
* @summary Experimental function that sets fallback and quota-handling options for the reactive sessionStorage
|
|
261
|
+
* singleton before its first use.
|
|
250
262
|
*/
|
|
251
263
|
function configureSessionStorage(options) {
|
|
252
264
|
sessionStorageOptions = options;
|
|
@@ -288,6 +300,9 @@ function isStorageUnavailableError(error) {
|
|
|
288
300
|
*
|
|
289
301
|
* Route storage-event subscribers through this helper instead of calling
|
|
290
302
|
* `window.addEventListener('storage', ...)` directly.
|
|
303
|
+
*
|
|
304
|
+
* @summary Experimental helper that subscribes to storage changes from both native `StorageEvent`s and `CacheStorage`
|
|
305
|
+
* notifications, returning an unsubscribe function.
|
|
291
306
|
*/
|
|
292
307
|
function onStorageEvent(listener) {
|
|
293
308
|
const handler = (event) => {
|
|
@@ -301,6 +316,9 @@ function onStorageEvent(listener) {
|
|
|
301
316
|
* that provides signal-based access to storage items and length.
|
|
302
317
|
*
|
|
303
318
|
* Will automatically update when storage events occur in other tabs/windows.
|
|
319
|
+
*
|
|
320
|
+
* @summary Experimental signal-backed wrapper around a `Storage` area that makes reads reactive and updates on changes
|
|
321
|
+
* from other tabs.
|
|
304
322
|
*/
|
|
305
323
|
var ReactiveStorage = class {
|
|
306
324
|
_storage;
|
|
@@ -477,6 +495,9 @@ defineSignal(ReactiveStorage.prototype, "_signals", makeInitializer(() => new Si
|
|
|
477
495
|
* Use functions when you want to create more than
|
|
478
496
|
* one instance of a resource type, each with its own
|
|
479
497
|
* persisted data.
|
|
498
|
+
*
|
|
499
|
+
* @summary Experimental function type that derives a unique storage key from a storage resource instance, so each
|
|
500
|
+
* instance persists its own data.
|
|
480
501
|
*/
|
|
481
502
|
/**
|
|
482
503
|
* Symbol used to store persistence metadata on classes
|
|
@@ -761,6 +782,9 @@ function createParamField(companion, fieldName, config, controlFieldName, instan
|
|
|
761
782
|
*
|
|
762
783
|
* The function will be called once per instance during
|
|
763
784
|
* initialization to determine the unique ID for that instance.
|
|
785
|
+
*
|
|
786
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist in
|
|
787
|
+
* localStorage.
|
|
764
788
|
*/
|
|
765
789
|
function LocalResource(id) {
|
|
766
790
|
return _createStorageResource(id, "local-resource", null);
|
|
@@ -778,6 +802,9 @@ function LocalResource(id) {
|
|
|
778
802
|
*
|
|
779
803
|
* The function will be called once per instance during
|
|
780
804
|
* initialization to determine the unique ID for that instance.
|
|
805
|
+
*
|
|
806
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist in
|
|
807
|
+
* sessionStorage.
|
|
781
808
|
*/
|
|
782
809
|
function SessionResource(id) {
|
|
783
810
|
return _createStorageResource(id, "session-resource", null);
|
|
@@ -800,6 +827,9 @@ function SessionResource(id) {
|
|
|
800
827
|
* All object cached in the same `namespace` share the namespace's storage context,
|
|
801
828
|
* so partitioning can be achieved by using different namespaces for different groups
|
|
802
829
|
* of data.
|
|
830
|
+
*
|
|
831
|
+
* @summary Experimental class decorator that turns a class into a reactive resource whose fields persist via the Cache
|
|
832
|
+
* API and are shared across tabs.
|
|
803
833
|
*/
|
|
804
834
|
function CacheResource(id, namespace = null) {
|
|
805
835
|
return _createStorageResource(id, "cache-resource", namespace);
|
|
@@ -834,6 +864,8 @@ function CacheResource(id, namespace = null) {
|
|
|
834
864
|
* }
|
|
835
865
|
* ```
|
|
836
866
|
*
|
|
867
|
+
* @summary Experimental decorator that makes a storage resource property a reactive field persisted to local, session,
|
|
868
|
+
* or cache storage.
|
|
837
869
|
*/
|
|
838
870
|
function field(...args) {
|
|
839
871
|
if (args.length === 0) {
|
|
@@ -928,6 +960,9 @@ function input(type) {
|
|
|
928
960
|
* }
|
|
929
961
|
* }
|
|
930
962
|
* ```
|
|
963
|
+
*
|
|
964
|
+
* @summary Experimental field decorator for storage resources that runs a callback when the stored value changes in
|
|
965
|
+
* another tab or window.
|
|
931
966
|
*/
|
|
932
967
|
function effect(fn, type) {
|
|
933
968
|
const overrideType = type === "local" ? "local-storage" : type === "session" ? "session-storage" : null;
|
|
@@ -952,10 +987,15 @@ function effect(fn, type) {
|
|
|
952
987
|
//#region src/storage/query-params.ts
|
|
953
988
|
/**
|
|
954
989
|
* Configuration options for fields that are also query parameters
|
|
990
|
+
*
|
|
991
|
+
* @summary Experimental config passed to the `param` decorator that describes how a field is serialized to and parsed
|
|
992
|
+
* from a URL query parameter.
|
|
955
993
|
*/
|
|
956
994
|
/**
|
|
957
995
|
* Creates a {@link ParamConfig} for boolean fields that serialize to '1' or null.
|
|
958
996
|
*
|
|
997
|
+
* @summary Experimental helper that creates a query-param config serializing a boolean field as '1' when true and
|
|
998
|
+
* omitting it when false.
|
|
959
999
|
* @returns ParamConfig for boolean fields
|
|
960
1000
|
*
|
|
961
1001
|
* @example
|
|
@@ -974,6 +1014,8 @@ function BooleanParam() {
|
|
|
974
1014
|
/**
|
|
975
1015
|
* Creates a {@link ParamConfig} for numeric fields with default value checking.
|
|
976
1016
|
*
|
|
1017
|
+
* @summary Experimental helper that creates a query-param config serializing numbers, optionally to a fixed precision,
|
|
1018
|
+
* with an optional default value.
|
|
977
1019
|
* @param precision - When given, the number of digits to serialize after the decimal point
|
|
978
1020
|
* @param getDefault - Function to get the default value for comparison
|
|
979
1021
|
* @returns ParamConfig for number fields
|
|
@@ -1013,6 +1055,8 @@ function NumberParam(precision, getDefault) {
|
|
|
1013
1055
|
* - Compare URL and local values
|
|
1014
1056
|
* - Determine when to include/exclude params from the URL
|
|
1015
1057
|
*
|
|
1058
|
+
* @summary Experimental decorator that marks a storage resource field as a URL query parameter, recording how to
|
|
1059
|
+
* serialize it for a router integration.
|
|
1016
1060
|
* @param config - Configuration for URL serialization/deserialization
|
|
1017
1061
|
*
|
|
1018
1062
|
* @example
|