@jqhtml/core 2.3.70 → 2.3.71
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.cjs +691 -604
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +691 -604
- package/dist/index.js.map +1 -1
- package/dist/jqhtml-core.esm.js +692 -605
- package/dist/jqhtml-core.esm.js.map +1 -1
- package/dist/load-coordinator.d.ts +9 -0
- package/dist/load-coordinator.d.ts.map +1 -1
- package/dist/local-storage.d.ts +61 -4
- package/dist/local-storage.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -17,6 +17,15 @@
|
|
|
17
17
|
* 3. Leader completes → distribute data to all followers
|
|
18
18
|
* 4. Clear coordination entry (no caching)
|
|
19
19
|
*
|
|
20
|
+
* The hand-off is a copy, and it is made by the cache serializer
|
|
21
|
+
* (Jqhtml_Local_Storage.serialize()/deserialize()), never by JSON.stringify.
|
|
22
|
+
* A follower never runs on_load() and never revalidates, so whatever it is
|
|
23
|
+
* handed is final: the copy has to rebuild Date, Map, Set and every
|
|
24
|
+
* register_cache_class() instance exactly as the leader's this.data holds them.
|
|
25
|
+
* JSON.stringify would consult toJSON() and hand out a wire form that
|
|
26
|
+
* normalize_for_cache() cannot recognise - the follower would then render
|
|
27
|
+
* against plain objects while the leader renders against instances.
|
|
28
|
+
*
|
|
20
29
|
* @internal This class is not exposed in the public API
|
|
21
30
|
*/
|
|
22
31
|
import type { Jqhtml_Component } from './component.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-coordinator.d.ts","sourceRoot":"","sources":["../src/load-coordinator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"load-coordinator.d.ts","sourceRoot":"","sources":["../src/load-coordinator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,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CAAC,kBAAkB,IAAI,GAAG;IAahC;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,IAAI;CAG3B"}
|
package/dist/local-storage.d.ts
CHANGED
|
@@ -16,7 +16,19 @@
|
|
|
16
16
|
* ES6 class instances can be serialized and deserialized if registered via
|
|
17
17
|
* register_cache_class(). Classes are wrapped as {__jqhtml_class__: "Name", __jqhtml_props__: {...}}
|
|
18
18
|
* and restored to proper instances on retrieval. Nested class instances in objects
|
|
19
|
-
* and arrays are handled recursively.
|
|
19
|
+
* and arrays are handled recursively. A class whose wire form is not its own
|
|
20
|
+
* properties (one that defines toJSON(), or keeps state in private fields)
|
|
21
|
+
* registers a {to_plain, from_plain} pair and is rebuilt through it. Date, Map and
|
|
22
|
+
* Set are pre-registered the same way - there is no second mechanism.
|
|
23
|
+
*
|
|
24
|
+
* ONE SERIALIZER. Every copy of on_load() data the framework makes goes through
|
|
25
|
+
* this file: the localStorage cache (set()/get()), the normalization of every
|
|
26
|
+
* on_load() result into this.data (normalize_for_cache()), and the copy a
|
|
27
|
+
* deduplicated follower takes of its leader's data (serialize()/deserialize(),
|
|
28
|
+
* used by load-coordinator.ts). Anything that survives one of those survives all
|
|
29
|
+
* of them, and anything dropped is dropped identically on all of them. A plain
|
|
30
|
+
* JSON.stringify anywhere on those paths would consult toJSON() and hand out a
|
|
31
|
+
* wire form nothing knows how to restore.
|
|
20
32
|
*
|
|
21
33
|
* Scoping Strategy:
|
|
22
34
|
* Storage is scoped by a user-provided cache key (typically a session identifier,
|
|
@@ -92,14 +104,40 @@
|
|
|
92
104
|
* silently. Neither ever throws.
|
|
93
105
|
* ---------------------------------------------------------------------------
|
|
94
106
|
*/
|
|
107
|
+
/**
|
|
108
|
+
* How a registered class travels through the serializer.
|
|
109
|
+
*
|
|
110
|
+
* With no options, an instance's own enumerable properties go out and come back
|
|
111
|
+
* through Object.create(prototype) + Object.assign - right for a class whose
|
|
112
|
+
* state IS its own properties.
|
|
113
|
+
*
|
|
114
|
+
* A class whose wire form is something else names how to rebuild itself:
|
|
115
|
+
*
|
|
116
|
+
* to_plain(instance) -> the plain value to store. Default when from_plain is
|
|
117
|
+
* given: instance.toJSON() if the class defines one,
|
|
118
|
+
* otherwise its own enumerable properties. The result is
|
|
119
|
+
* walked by the serializer like any other value, so
|
|
120
|
+
* instances nested inside it are handled too.
|
|
121
|
+
* from_plain(plain) -> a live instance. Required whenever to_plain is given,
|
|
122
|
+
* because the serializer cannot guess how to undo a
|
|
123
|
+
* custom wire form.
|
|
124
|
+
*/
|
|
125
|
+
export interface Cache_Class_Options<T = any> {
|
|
126
|
+
to_plain?: (instance: T) => any;
|
|
127
|
+
from_plain?: (plain: any) => T;
|
|
128
|
+
}
|
|
95
129
|
/**
|
|
96
130
|
* Register a class for cache serialization/deserialization.
|
|
97
131
|
* Must be called before attempting to cache instances of this class.
|
|
98
132
|
*
|
|
99
133
|
* @param klass - The class constructor to register
|
|
100
|
-
* @
|
|
134
|
+
* @param options - How to convert instances to and from their plain form; see
|
|
135
|
+
* Cache_Class_Options. Omit for a class whose state is its own
|
|
136
|
+
* enumerable properties.
|
|
137
|
+
* @throws Error if klass is not a named function/class, or if to_plain is given
|
|
138
|
+
* without the from_plain that undoes it
|
|
101
139
|
*/
|
|
102
|
-
export declare function register_cache_class(klass: new (...args: any[]) => any): void;
|
|
140
|
+
export declare function register_cache_class(klass: new (...args: any[]) => any, options?: Cache_Class_Options): void;
|
|
103
141
|
/**
|
|
104
142
|
* Check if a class is registered for caching
|
|
105
143
|
*/
|
|
@@ -108,7 +146,7 @@ export declare function is_cache_class_registered(class_name: string): boolean;
|
|
|
108
146
|
* What kind of value the serializer had to drop or degrade. Reported to a
|
|
109
147
|
* collector; each kind maps to one piece of advice in strip_advice().
|
|
110
148
|
*/
|
|
111
|
-
export type Strip_Kind = 'function' | 'promise' | 'dom-node' | 'jquery' | 'component' | 'symbol' | 'bigint' | 'circular' | 'unregistered-class';
|
|
149
|
+
export type Strip_Kind = 'function' | 'promise' | 'dom-node' | 'jquery' | 'component' | 'symbol' | 'bigint' | 'circular' | 'unregistered-class' | 'to-plain-threw';
|
|
112
150
|
/** Called once per dropped/degraded value with its path and what it was. */
|
|
113
151
|
export type Strip_Collector = (path: string, kind: Strip_Kind, detail?: string) => void;
|
|
114
152
|
/**
|
|
@@ -214,6 +252,25 @@ export declare class Jqhtml_Local_Storage {
|
|
|
214
252
|
* @param {string} key - Storage key
|
|
215
253
|
*/
|
|
216
254
|
static remove(key: string): void;
|
|
255
|
+
/**
|
|
256
|
+
* Serialize a value to its class-aware TEXT form - the same text set() stores.
|
|
257
|
+
*
|
|
258
|
+
* This is the copy-by-value primitive the rest of the framework uses whenever
|
|
259
|
+
* data has to cross from one component to another (load-coordinator.ts hands a
|
|
260
|
+
* leader's data to its followers through it). Plain JSON.stringify is not a
|
|
261
|
+
* substitute: it consults toJSON() and produces a wire form that deserialize()
|
|
262
|
+
* cannot recognise, so a registered class would come back as a plain object.
|
|
263
|
+
*
|
|
264
|
+
* @returns The text, or null when the value as a whole cannot be expressed.
|
|
265
|
+
*/
|
|
266
|
+
static serialize(value: any): string | null;
|
|
267
|
+
/**
|
|
268
|
+
* Rebuild a value from text produced by serialize(), restoring Date, Map, Set
|
|
269
|
+
* and every register_cache_class() class. Returns null when the text is not
|
|
270
|
+
* restorable (a registered from_plain threw at the root) - the same signal
|
|
271
|
+
* get() gives for a corrupt entry.
|
|
272
|
+
*/
|
|
273
|
+
static deserialize(text: string): any;
|
|
217
274
|
/**
|
|
218
275
|
* Perform a serialize/deserialize round-trip on a value.
|
|
219
276
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../src/local-storage.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"local-storage.d.ts","sourceRoot":"","sources":["../src/local-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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