informa 4.0.1 → 5.0.1
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 +31 -48
- package/dist/EnumerableWeakSet.d.ts +1 -0
- package/dist/EnumerableWeakSet.d.ts.map +1 -1
- package/dist/EnumerableWeakSet.js +8 -5
- package/dist/EnumerableWeakSet.js.map +1 -1
- package/dist/high.d.ts +3 -2
- package/dist/high.d.ts.map +1 -1
- package/dist/high.js +2 -1
- package/dist/high.js.map +1 -1
- package/dist/low.d.ts +0 -15
- package/dist/low.d.ts.map +1 -1
- package/dist/low.js +25 -48
- package/dist/low.js.map +1 -1
- package/dist/quirks/basestatified.d.ts +5 -23
- package/dist/quirks/basestatified.d.ts.map +1 -1
- package/dist/quirks/basestatified.js +107 -229
- package/dist/quirks/basestatified.js.map +1 -1
- package/dist/test.js +13 -9
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/src/EnumerableWeakSet.ts +8 -5
- package/src/high.ts +3 -2
- package/src/low.ts +32 -58
- package/src/quirks/basestatified.ts +133 -259
- package/src/test.ts +20 -13
- package/src/quirks/basestatified.test.ts +0 -375
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
3
|
+
exports.makeBaseStatified = void 0;
|
|
4
|
+
exports.clearPendingAssemblies = clearPendingAssemblies;
|
|
5
|
+
exports.makeStatified = makeStatified;
|
|
5
6
|
const EnumerableWeakSet_js_1 = require("../EnumerableWeakSet.js");
|
|
6
7
|
const internals_js_1 = require("../internals.js");
|
|
7
8
|
const low_js_1 = require("../low.js");
|
|
8
|
-
// Classes whose instances have been constructed but not yet field-instrumented.
|
|
9
9
|
const pendingAssemblies = new EnumerableWeakSet_js_1.EnumerableWeakSet();
|
|
10
|
-
// Map from a still-pending child instance → list of (parentMetadata, prop) pairs
|
|
11
|
-
// that need hook() called once the child is reconciled.
|
|
12
|
-
const deferredHooks = new EnumerableWeakMap_js_1.EnumerableWeakMap();
|
|
13
|
-
// One shim proxy per outermost constructor (new.target).
|
|
14
10
|
const shimCache = new WeakMap();
|
|
15
11
|
function getPrototypeChainDescriptor(obj, prop) {
|
|
16
12
|
let curr = obj;
|
|
@@ -22,239 +18,121 @@ function getPrototypeChainDescriptor(obj, prop) {
|
|
|
22
18
|
}
|
|
23
19
|
return undefined;
|
|
24
20
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
21
|
+
function clearAssembly(assembly) {
|
|
22
|
+
for (const key of Reflect.ownKeys(assembly)) {
|
|
23
|
+
const value = Reflect.get(assembly, key);
|
|
24
|
+
Reflect.deleteProperty(assembly, key);
|
|
25
|
+
assembly[key] = value;
|
|
26
|
+
}
|
|
27
|
+
console.log(Reflect.ownKeys(assembly));
|
|
28
|
+
pendingAssemblies.delete(assembly);
|
|
29
|
+
}
|
|
30
|
+
function clearPendingAssemblies() {
|
|
31
|
+
for (const assembly of pendingAssemblies) {
|
|
32
|
+
clearAssembly(assembly);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function makeStatified(Superclass) {
|
|
36
|
+
if (shimCache.has(Superclass)) {
|
|
37
|
+
return shimCache.get(Superclass);
|
|
38
|
+
}
|
|
39
|
+
const dataLayers = new WeakMap();
|
|
40
|
+
const ExtractionShimBase = function (...args) {
|
|
41
|
+
const inst = Reflect.construct(Superclass, args, new.target);
|
|
42
|
+
if (!pendingAssemblies.has(inst)) {
|
|
43
|
+
(0, internals_js_1.setMetadataOf)(inst, new low_js_1.StateMetadata());
|
|
44
|
+
pendingAssemblies.add(inst);
|
|
43
45
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
46
|
+
queueMicrotask(() => {
|
|
47
|
+
clearPendingAssemblies();
|
|
48
|
+
});
|
|
49
|
+
const proto = new Proxy({}, {
|
|
50
|
+
get(target, prop, receiver) {
|
|
51
|
+
const result = Reflect.get(target, prop, receiver);
|
|
52
|
+
if ((0, internals_js_1.getGlobalStateMode)() === "extract-proxy-path") {
|
|
53
|
+
if (prop === internals_js_1.exitProxySymbol) {
|
|
54
|
+
return { path: [], stateRoot: receiver };
|
|
55
|
+
}
|
|
56
|
+
return (0, low_js_1.extract)(result, receiver, [prop]);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
Reflect.setPrototypeOf(proto, Reflect.getPrototypeOf(inst));
|
|
62
|
+
Reflect.setPrototypeOf(inst, proto);
|
|
63
|
+
dataLayers.set(inst, {});
|
|
64
|
+
return inst;
|
|
65
|
+
};
|
|
66
|
+
ExtractionShimBase.prototype = new Proxy({}, {
|
|
67
|
+
get(target, prop, recv) {
|
|
68
|
+
return Reflect.has(dataLayers.get(recv), prop)
|
|
69
|
+
? Reflect.get(dataLayers.get(recv), prop)
|
|
70
|
+
: Reflect.get(target, prop, recv);
|
|
71
|
+
},
|
|
72
|
+
set(target, prop, newVal, recv) {
|
|
62
73
|
const stateMetadata = (0, internals_js_1.getMetadataOf)(recv);
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
74
|
+
const had = Reflect.has(recv, prop);
|
|
75
|
+
const oldVal = Reflect.get(recv, prop);
|
|
76
|
+
let result;
|
|
77
|
+
const desc = getPrototypeChainDescriptor(target, prop);
|
|
78
|
+
if (desc?.set || desc?.get) {
|
|
79
|
+
result = Reflect.set(target, prop, newVal, recv);
|
|
68
80
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
72
|
-
has(target, prop) {
|
|
73
|
-
if (prop === internals_js_1.statifySealKey || prop === internals_js_1.exitProxySymbol)
|
|
74
|
-
return true;
|
|
75
|
-
return Reflect.has(target, prop);
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
function getOrCreateShim(ctor) {
|
|
79
|
-
const cached = shimCache.get(ctor);
|
|
80
|
-
if (cached)
|
|
81
|
-
return cached;
|
|
82
|
-
// shimTarget's [[Prototype]] = ctor.prototype, so the full chain is:
|
|
83
|
-
// instance → shim → shimTarget → ctor.prototype → … → Superclass.prototype
|
|
84
|
-
// This preserves instanceof for all classes in the chain.
|
|
85
|
-
const shimTarget = Object.create(ctor.prototype);
|
|
86
|
-
const shim = new Proxy(shimTarget, shimHandler);
|
|
87
|
-
shimCache.set(ctor, shim);
|
|
88
|
-
return shim;
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Converts all enumerable, configurable own data properties of `instance` into
|
|
92
|
-
* accessor-backed reactive properties connected to `instance`'s StateMetadata.
|
|
93
|
-
*
|
|
94
|
-
* Idempotent: returns immediately if the instance is not in pendingAssemblies.
|
|
95
|
-
*/
|
|
96
|
-
function reconcileInstance(instance) {
|
|
97
|
-
if (!pendingAssemblies.has(instance))
|
|
98
|
-
return;
|
|
99
|
-
pendingAssemblies.delete(instance);
|
|
100
|
-
// Drain any deferred hooks where this instance was the pending child.
|
|
101
|
-
const deferred = deferredHooks.get(instance);
|
|
102
|
-
if (deferred) {
|
|
103
|
-
deferredHooks.delete(instance);
|
|
104
|
-
const childMetadata = (0, internals_js_1.getMetadataOf)(instance);
|
|
105
|
-
for (const { metadata: parentMetadata, prop } of deferred) {
|
|
106
|
-
(0, low_js_1.hook)(parentMetadata, prop, childMetadata);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Metadata was installed eagerly in ExtractionShimBase's constructor.
|
|
110
|
-
const metadata = (0, internals_js_1.getMetadataOf)(instance);
|
|
111
|
-
const isArray = Array.isArray(instance);
|
|
112
|
-
const props = [
|
|
113
|
-
...Object.getOwnPropertyNames(instance),
|
|
114
|
-
...Object.getOwnPropertySymbols(instance),
|
|
115
|
-
];
|
|
116
|
-
for (const prop of props) {
|
|
117
|
-
// Skip Informa internal symbols.
|
|
118
|
-
if (prop === internals_js_1.statifySealKey || prop === internals_js_1.exitProxySymbol)
|
|
119
|
-
continue;
|
|
120
|
-
// Skip array numeric indices — managed by the array's own push/pop/splice overrides.
|
|
121
|
-
if (isArray && typeof prop === "string" && Number.isInteger(Number(prop)))
|
|
122
|
-
continue;
|
|
123
|
-
const desc = Object.getOwnPropertyDescriptor(instance, prop);
|
|
124
|
-
// Non-configurable: cannot be redefined; leave non-reactive.
|
|
125
|
-
// Note: these properties retain their value but won't participate in the
|
|
126
|
-
// observable graph. This is intentional and tested.
|
|
127
|
-
if (!desc.configurable)
|
|
128
|
-
continue;
|
|
129
|
-
// Existing accessor (get/set): do not double-wrap.
|
|
130
|
-
if ("get" in desc || "set" in desc)
|
|
131
|
-
continue;
|
|
132
|
-
// ---- Instrument this configurable data property ----
|
|
133
|
-
let value = desc.value;
|
|
134
|
-
// Hook the initial value if it is itself statified.
|
|
135
|
-
if (value != null &&
|
|
136
|
-
typeof value === "object" &&
|
|
137
|
-
(0, internals_js_1.isStatified)(value)) {
|
|
138
|
-
if (pendingAssemblies.has(value)) {
|
|
139
|
-
// The nested value is itself pending (constructed during this constructor
|
|
140
|
-
// but not yet reconciled — its metadata doesn't exist yet). Defer the
|
|
141
|
-
// hook: it will be wired once reconcileInstance runs for that child.
|
|
142
|
-
deferredHooks.getOrInsertComputed(value, () => []).push({ metadata, prop });
|
|
81
|
+
else if (typeof prop === "string" && prop.startsWith("#")) {
|
|
82
|
+
result = Reflect.set(target, prop, newVal, recv);
|
|
143
83
|
}
|
|
144
84
|
else {
|
|
145
|
-
|
|
85
|
+
result = Reflect.set(dataLayers.get(recv), prop, newVal);
|
|
146
86
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
87
|
+
if (result) {
|
|
88
|
+
if (oldVal !== newVal
|
|
89
|
+
&& typeof newVal === "object"
|
|
90
|
+
&& newVal != null
|
|
91
|
+
&& newVal[internals_js_1.statifySealKey]) {
|
|
92
|
+
const newValMetadata = (0, internals_js_1.getMetadataOf)(newVal);
|
|
93
|
+
(0, low_js_1.hook)(stateMetadata, prop, newValMetadata);
|
|
152
94
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
typeof old === "object" &&
|
|
161
|
-
(0, internals_js_1.isStatified)(old)) {
|
|
162
|
-
(0, low_js_1.unhook)(metadata, prop, (0, internals_js_1.getMetadataOf)(old));
|
|
95
|
+
if (had) {
|
|
96
|
+
if (oldVal !== newVal
|
|
97
|
+
&& typeof oldVal === "object"
|
|
98
|
+
&& oldVal != null
|
|
99
|
+
&& oldVal[internals_js_1.statifySealKey]) {
|
|
100
|
+
const oldValMetadata = (0, internals_js_1.getMetadataOf)(oldVal);
|
|
101
|
+
(0, low_js_1.unhook)(stateMetadata, prop, oldValMetadata);
|
|
163
102
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
103
|
+
(0, low_js_1.emitCollectionTransition)(oldVal, newVal);
|
|
104
|
+
if (typeof prop !== "symbol" &&
|
|
105
|
+
Number.isInteger(Number(prop)) &&
|
|
106
|
+
Array.isArray(target)) {
|
|
107
|
+
stateMetadata.emit('replaceElement', newVal, Number(prop));
|
|
168
108
|
}
|
|
169
|
-
(
|
|
109
|
+
stateMetadata.emit('replaceProp', newVal, prop);
|
|
170
110
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
111
|
+
else {
|
|
112
|
+
if (typeof prop !== "symbol" &&
|
|
113
|
+
Number.isInteger(Number(prop)) &&
|
|
114
|
+
Array.isArray(target)) {
|
|
115
|
+
stateMetadata.emit('spliceInElement', newVal, Number(prop));
|
|
116
|
+
}
|
|
117
|
+
stateMetadata.emit('addProp', newVal, prop);
|
|
118
|
+
}
|
|
119
|
+
stateMetadata.emit('setProp', newVal, prop);
|
|
120
|
+
const maybeEventEmitterAtVal = stateMetadata.eventEmitterAtPathMaybe([prop]);
|
|
121
|
+
if (maybeEventEmitterAtVal) {
|
|
122
|
+
if (had) {
|
|
123
|
+
maybeEventEmitterAtVal.emit('replace', newVal);
|
|
124
|
+
}
|
|
125
|
+
maybeEventEmitterAtVal.emit('set', newVal);
|
|
126
|
+
(0, low_js_1.emitDescendantPathEvents)(stateMetadata, [prop], newVal, had);
|
|
179
127
|
}
|
|
180
|
-
},
|
|
181
|
-
enumerable: desc.enumerable ?? true,
|
|
182
|
-
configurable: true,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
// Selector/stateRoot identity: verified correct. Every on*()/off*() call goes
|
|
186
|
-
// through selectorToRootAndPath(), which fires preExtractionHooks() before
|
|
187
|
-
// entering extract-proxy-path mode. The preExtractionHook registered below
|
|
188
|
-
// reconciles all pending instances first — so by the time the selector function
|
|
189
|
-
// runs, every pending `this.x` field is already an accessor that returns
|
|
190
|
-
// extract(value, this, ['x']). Path chains like `() => this.a.b.c` are therefore
|
|
191
|
-
// built up correctly, and stateRoot is the raw instance, which is the same object
|
|
192
|
-
// keyed in metadataMap. No re-mapping needed.
|
|
193
|
-
}
|
|
194
|
-
// Before selectorToRootAndPath enters extract-proxy-path mode it calls all
|
|
195
|
-
// registered hooks. This hook reconciles every pending instance so that their
|
|
196
|
-
// own data properties are already accessor-backed when the selector runs.
|
|
197
|
-
(0, low_js_1.registerPreExtractionHook)(() => {
|
|
198
|
-
// Snapshot: reconcileInstance removes from pendingAssemblies, which mutates
|
|
199
|
-
// the set during iteration — take a copy first.
|
|
200
|
-
const snapshot = [...pendingAssemblies];
|
|
201
|
-
for (const instance of snapshot) {
|
|
202
|
-
reconcileInstance(instance);
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
/**
|
|
206
|
-
* Wraps a user-defined class factory in the Informa observable lifecycle.
|
|
207
|
-
*
|
|
208
|
-
* Usage:
|
|
209
|
-
* ```ts
|
|
210
|
-
* const MyClass = statifyClass(
|
|
211
|
-
* (Base) => class MyClass extends Base {
|
|
212
|
-
* name = "default";
|
|
213
|
-
* constructor(name: string) { super(); this.name = name; }
|
|
214
|
-
* },
|
|
215
|
-
* Object,
|
|
216
|
-
* );
|
|
217
|
-
* ```
|
|
218
|
-
*
|
|
219
|
-
* Construction lifecycle:
|
|
220
|
-
* 1. ExtractionShimBase constructor runs → metadata installed, shim set as prototype.
|
|
221
|
-
* 2. UserSubclass field initializers run → own data properties created on instance.
|
|
222
|
-
* 3. UserSubclass constructor body runs.
|
|
223
|
-
* 4. Instance is in pendingAssemblies (field instrumentation deferred).
|
|
224
|
-
* 5. On first `on()`/`off()` call → registerPreExtractionHook fires → reconcileInstance
|
|
225
|
-
* converts own data properties to reactive accessor-backed properties.
|
|
226
|
-
*/
|
|
227
|
-
function statifyClass(makeSubclass, Superclass) {
|
|
228
|
-
// ExtractionShimBase sits between Superclass and the user's class.
|
|
229
|
-
// Its constructor:
|
|
230
|
-
// - Installs StateMetadata on the instance eagerly (so subclasses like
|
|
231
|
-
// StatifiedArray can call getMetadataOf() from their constructor bodies).
|
|
232
|
-
// - Marks the instance as pending for lazy field instrumentation.
|
|
233
|
-
// - Inserts the shim proxy as the instance's [[Prototype]], enabling
|
|
234
|
-
// statifySealKey / exitProxySymbol / extract-proxy-path handling.
|
|
235
|
-
//
|
|
236
|
-
// Guard: in nested statifyClass chains (e.g. statifyClass(..., A) where A
|
|
237
|
-
// was itself produced by statifyClass), multiple ExtractionShimBase
|
|
238
|
-
// constructors run. The guard ensures setup happens exactly once — at the
|
|
239
|
-
// innermost (deepest) ExtractionShimBase call.
|
|
240
|
-
class ExtractionShimBase extends Superclass {
|
|
241
|
-
constructor(...args) {
|
|
242
|
-
super(...args);
|
|
243
|
-
if (!pendingAssemblies.has(this)) {
|
|
244
|
-
(0, internals_js_1.setMetadataOf)(this, new low_js_1.StateMetadata());
|
|
245
|
-
pendingAssemblies.add(this);
|
|
246
128
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
// Invoke the user's factory with the shim base, then return the result.
|
|
256
|
-
// No outer Statified wrapper is needed: field instrumentation is lazy,
|
|
257
|
-
// triggered by registerPreExtractionHook before any selectorToRootAndPath call.
|
|
258
|
-
return makeSubclass(ExtractionShimBase);
|
|
129
|
+
return result;
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
Reflect.setPrototypeOf(ExtractionShimBase.prototype, Superclass.prototype);
|
|
133
|
+
shimCache.set(Superclass, ExtractionShimBase);
|
|
134
|
+
return ExtractionShimBase;
|
|
259
135
|
}
|
|
136
|
+
const makeBaseStatified = () => makeStatified(Object);
|
|
137
|
+
exports.makeBaseStatified = makeBaseStatified;
|
|
260
138
|
//# sourceMappingURL=basestatified.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"basestatified.js","sourceRoot":"","sources":["../../src/quirks/basestatified.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"basestatified.js","sourceRoot":"","sources":["../../src/quirks/basestatified.ts"],"names":[],"mappings":";;;;;AAAA,kEAA4D;AAC5D,kDAOyB;AACzB,sCAQmB;AAInB,MAAM,iBAAiB,GAAG,IAAI,wCAAiB,EAAU,CAAC;AAE1D,MAAM,SAAS,GAAG,IAAI,OAAO,EAAoB,CAAC;AAElD,SAAS,2BAA2B,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C,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;gBAC9C,CAAC;gBAED,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;gBAE5C,MAAM,sBAAsB,GAAG,aAAa,CAAC,uBAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC7E,IAAI,sBAAsB,EAAE,CAAC;oBAC3B,IAAI,GAAG,EAAE,CAAC;wBACR,sBAAsB,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;oBACjD,CAAC;oBAED,sBAAsB,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;oBAE3C,IAAA,iCAAwB,EACtB,aAAa,EACb,CAAC,IAAI,CAAC,EACN,MAAM,EACN,GAAG,CACJ,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,SAAS,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;IAE9C,OAAO,kBAA0F,CAAC;AACpG,CAAC;AAEM,MAAM,iBAAiB,GAAG,GAAqB,EAAE,CAAC,aAAa,CAAmB,MAAM,CAAC,CAAC;AAApF,QAAA,iBAAiB,GAAjB,iBAAiB,CAAmE"}
|
package/dist/test.js
CHANGED
|
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const high_js_1 = __importDefault(require("./high.js"));
|
|
7
|
-
const set_js_1 = require("./quirks/set.js");
|
|
8
7
|
const stateful = high_js_1.default.state({ a: [] });
|
|
9
8
|
high_js_1.default.onSpliceInElement(() => stateful.a, (v) => {
|
|
10
9
|
console.log("pushed", v);
|
|
@@ -22,20 +21,25 @@ const asdf = high_js_1.default.state({ d: new Set() });
|
|
|
22
21
|
const asdf2 = high_js_1.default.state({ c: asdf });
|
|
23
22
|
// const aassddff = $.state(new Set());
|
|
24
23
|
stateful.b = asdf2;
|
|
25
|
-
|
|
26
|
-
displays = new
|
|
27
|
-
|
|
28
|
-
get
|
|
29
|
-
|
|
30
|
-
console.log("set", v);
|
|
31
|
-
this.#state = v;
|
|
24
|
+
class Wayland extends high_js_1.default.makeBaseStatified() {
|
|
25
|
+
displays = new high_js_1.default.StatifiedSet();
|
|
26
|
+
state = 10;
|
|
27
|
+
get state2() {
|
|
28
|
+
return super.state2;
|
|
32
29
|
}
|
|
33
|
-
|
|
30
|
+
set state2(v) {
|
|
31
|
+
super.state2 = v;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
34
|
const w = new Wayland();
|
|
35
35
|
high_js_1.default.onSet(() => w.state, (v) => console.log("asdf awawa!!", v));
|
|
36
36
|
// w.state = 5;
|
|
37
37
|
w.state = 6;
|
|
38
38
|
w.state = 7;
|
|
39
|
+
high_js_1.default.onSet(() => w.state2, (v) => console.log("asdf awawa!!", v));
|
|
40
|
+
// w.state2 = 5;
|
|
41
|
+
w.state2 = 1234;
|
|
42
|
+
w.state2 = 12345;
|
|
39
43
|
const map = high_js_1.default.state(new Map());
|
|
40
44
|
high_js_1.default.onSetEntry(() => map, (k, v) => console.log("set", k, v));
|
|
41
45
|
high_js_1.default.onReplaceEntry(() => map, (k, v) => console.log("replace", k, v));
|
package/dist/test.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0B;
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;AAAA,wDAA0B;AAE1B,MAAM,QAAQ,GAAG,iBAAC,CAAC,KAAK,CAA4D,EAAE,CAAC,EAAE,E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,MAAM,CAAC,CAAC;AACnB,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC"}
|
package/package.json
CHANGED
package/src/EnumerableWeakSet.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export class EnumerableWeakSet<T extends WeakKey> implements WeakSet<T>, Iterable<T> {
|
|
2
2
|
#set = new WeakSet<T>();
|
|
3
3
|
|
|
4
|
-
#refs: WeakRef<T
|
|
4
|
+
#refs: Set<WeakRef<T>> = new Set();
|
|
5
5
|
|
|
6
6
|
constructor(iterable: Iterable<T> | null = null) {
|
|
7
7
|
if (iterable) {
|
|
@@ -17,7 +17,7 @@ export class EnumerableWeakSet<T extends WeakKey> implements WeakSet<T>, Iterabl
|
|
|
17
17
|
|
|
18
18
|
add(value: T): this {
|
|
19
19
|
if (!this.#set.has(value)) {
|
|
20
|
-
this.#refs.
|
|
20
|
+
this.#refs.add(new WeakRef(value));
|
|
21
21
|
this.#set.add(value);
|
|
22
22
|
}
|
|
23
23
|
return this;
|
|
@@ -31,16 +31,19 @@ export class EnumerableWeakSet<T extends WeakKey> implements WeakSet<T>, Iterabl
|
|
|
31
31
|
return this.#set.has(value);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
clear(): void {
|
|
35
|
+
this.#refs.clear();
|
|
36
|
+
}
|
|
37
|
+
|
|
34
38
|
*[Symbol.iterator](): Generator<T, void, unknown> {
|
|
35
39
|
const set = this.#set;
|
|
36
|
-
const refs: WeakRef<T>[] = [];
|
|
37
40
|
for (const wr of this.#refs) {
|
|
38
41
|
const value = wr.deref();
|
|
39
42
|
if (value && set.has(value)) {
|
|
40
|
-
refs.push(wr);
|
|
41
43
|
yield value;
|
|
44
|
+
} else {
|
|
45
|
+
this.#refs.delete(wr);
|
|
42
46
|
}
|
|
43
47
|
}
|
|
44
|
-
this.#refs = refs;
|
|
45
48
|
}
|
|
46
49
|
}
|
package/src/high.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getMetadataOf, isStatified, proxyMemoized, type Statify } from "./internals.js";
|
|
2
2
|
import { hook, selectorToRootAndPath, statifyObject, type StatifiableObj, type StatifiableProp, type Statified } from "./low.js";
|
|
3
3
|
import { StatifiedArray } from "./quirks/array.js";
|
|
4
|
-
import {
|
|
4
|
+
import { makeBaseStatified, makeStatified } from "./quirks/basestatified.js";
|
|
5
5
|
import { StatifiedMap } from "./quirks/map.js";
|
|
6
6
|
import { StatifiedSet } from "./quirks/set.js";
|
|
7
7
|
|
|
@@ -292,7 +292,8 @@ export default {
|
|
|
292
292
|
offSizeChanged,
|
|
293
293
|
state,
|
|
294
294
|
|
|
295
|
-
|
|
295
|
+
makeStatified,
|
|
296
|
+
makeBaseStatified,
|
|
296
297
|
StatifiedArray,
|
|
297
298
|
StatifiedSet,
|
|
298
299
|
StatifiedMap,
|