mutts 1.0.9 → 1.0.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/README.md +58 -33
- package/dist/browser.cjs +1371 -1206
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +2 -1392
- package/dist/browser.dev.cjs +110 -0
- package/dist/browser.dev.cjs.map +1 -0
- package/dist/browser.dev.d.ts +2 -0
- package/dist/browser.dev.esm.js +5 -0
- package/dist/browser.dev.esm.js.map +1 -0
- package/dist/browser.esm.js +6 -87
- package/dist/browser.esm.js.map +1 -1
- package/dist/chunks/{async-browser-lvzLOCgk.cjs → async-browser-BU_IfxYD.cjs} +4 -85
- package/dist/chunks/async-browser-BU_IfxYD.cjs.map +1 -0
- package/dist/chunks/{async-node-C3DeIb0y.cjs → async-node-3PrbVAbB.cjs} +3 -1
- package/dist/chunks/async-node-3PrbVAbB.cjs.map +1 -0
- package/dist/chunks/{index-2vea86wD.esm.js → index-CaaQQlPJ.esm.js} +1116 -953
- package/dist/chunks/index-CaaQQlPJ.esm.js.map +1 -0
- package/dist/chunks/node-nKJBk8iJ.esm.js +96 -0
- package/dist/chunks/node-nKJBk8iJ.esm.js.map +1 -0
- package/dist/chunks/{index-VTO-b2vR.cjs → proxy-Dtg-bJ3T.cjs} +2285 -2983
- package/dist/chunks/proxy-Dtg-bJ3T.cjs.map +1 -0
- package/dist/chunks/{index-CtA2AWl3.esm.js → proxy-r7lARftl.esm.js} +2273 -2948
- package/dist/chunks/proxy-r7lARftl.esm.js.map +1 -0
- package/dist/debug.cjs +973 -28
- package/dist/debug.cjs.map +1 -1
- package/dist/debug.d.ts +36 -37
- package/dist/debug.esm.js +949 -1
- package/dist/debug.esm.js.map +1 -1
- package/dist/devtools/manifest.json +1 -1
- package/dist/devtools/panel.html +1 -1
- package/dist/devtools/panel.js +107 -94
- package/dist/devtools/panel.js.map +1 -1
- package/dist/index.d.ts +1447 -1
- package/dist/mutts.umd.js +7167 -1
- package/dist/mutts.umd.js.map +1 -1
- package/dist/mutts.umd.min.js +1 -1
- package/dist/mutts.umd.min.js.map +1 -1
- package/dist/node.cjs +62 -60
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.dev.cjs +110 -0
- package/dist/node.dev.cjs.map +1 -0
- package/dist/node.dev.d.ts +2 -0
- package/dist/node.dev.esm.js +6 -0
- package/dist/node.dev.esm.js.map +1 -0
- package/dist/node.esm.js +4 -97
- package/dist/node.esm.js.map +1 -1
- package/dist/{types-DaHFfhlN.d.ts → types-W5vD6m2n.d.ts} +99 -44
- package/docs/ai/api-reference.md +11 -18
- package/docs/ai/manual.md +308 -230
- package/docs/reactive/advanced.md +312 -2
- package/docs/reactive/attend.md +1 -2
- package/docs/reactive/collections.md +21 -39
- package/docs/reactive/core.md +7 -37
- package/docs/reactive/debugging.md +117 -10
- package/docs/reactive/error-handling.md +10 -10
- package/docs/reactive/resource.md +125 -0
- package/docs/reactive/scan.md +32 -1
- package/docs/reactive.md +3 -2
- package/docs/utils.md +70 -0
- package/package.json +59 -30
- package/dist/chunks/async-browser-lvzLOCgk.cjs.map +0 -1
- package/dist/chunks/async-node-C3DeIb0y.cjs.map +0 -1
- package/dist/chunks/index-2vea86wD.esm.js.map +0 -1
- package/dist/chunks/index-CtA2AWl3.esm.js.map +0 -1
- package/dist/chunks/index-VTO-b2vR.cjs.map +0 -1
- package/dist/debug/debug.d.ts +0 -122
- package/dist/debug/debug.d.ts.map +0 -1
- package/dist/debug/index.d.ts +0 -4
- package/dist/debug/index.d.ts.map +0 -1
- package/dist/debug/lineage-panel.d.ts +0 -5
- package/dist/debug/lineage-panel.d.ts.map +0 -1
- package/dist/debug/lineage.d.ts +0 -79
- package/dist/debug/lineage.d.ts.map +0 -1
- package/dist/src/async/browser.d.ts +0 -2
- package/dist/src/async/browser.d.ts.map +0 -1
- package/dist/src/async/index.d.ts +0 -19
- package/dist/src/async/index.d.ts.map +0 -1
- package/dist/src/async/node.d.ts +0 -2
- package/dist/src/async/node.d.ts.map +0 -1
- package/dist/src/decorator.d.ts +0 -106
- package/dist/src/decorator.d.ts.map +0 -1
- package/dist/src/destroyable.d.ts +0 -87
- package/dist/src/destroyable.d.ts.map +0 -1
- package/dist/src/entry-browser.d.ts +0 -3
- package/dist/src/entry-browser.d.ts.map +0 -1
- package/dist/src/entry-node.d.ts +0 -3
- package/dist/src/entry-node.d.ts.map +0 -1
- package/dist/src/eventful.d.ts +0 -20
- package/dist/src/eventful.d.ts.map +0 -1
- package/dist/src/flavored.d.ts +0 -33
- package/dist/src/flavored.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -14
- package/dist/src/index.d.ts.map +0 -1
- package/dist/src/indexable.d.ts +0 -243
- package/dist/src/indexable.d.ts.map +0 -1
- package/dist/src/introspection.d.ts +0 -27
- package/dist/src/introspection.d.ts.map +0 -1
- package/dist/src/iterableWeak.d.ts +0 -53
- package/dist/src/iterableWeak.d.ts.map +0 -1
- package/dist/src/mixins.d.ts +0 -25
- package/dist/src/mixins.d.ts.map +0 -1
- package/dist/src/promiseChain.d.ts +0 -20
- package/dist/src/promiseChain.d.ts.map +0 -1
- package/dist/src/reactive/array.d.ts +0 -48
- package/dist/src/reactive/array.d.ts.map +0 -1
- package/dist/src/reactive/buffer.d.ts +0 -120
- package/dist/src/reactive/buffer.d.ts.map +0 -1
- package/dist/src/reactive/change.d.ts +0 -29
- package/dist/src/reactive/change.d.ts.map +0 -1
- package/dist/src/reactive/deep-touch.d.ts +0 -28
- package/dist/src/reactive/deep-touch.d.ts.map +0 -1
- package/dist/src/reactive/deep-watch-state.d.ts +0 -25
- package/dist/src/reactive/deep-watch-state.d.ts.map +0 -1
- package/dist/src/reactive/deep-watch.d.ts +0 -20
- package/dist/src/reactive/deep-watch.d.ts.map +0 -1
- package/dist/src/reactive/describe.d.ts +0 -12
- package/dist/src/reactive/describe.d.ts.map +0 -1
- package/dist/src/reactive/effect-context.d.ts +0 -34
- package/dist/src/reactive/effect-context.d.ts.map +0 -1
- package/dist/src/reactive/effects.d.ts +0 -164
- package/dist/src/reactive/effects.d.ts.map +0 -1
- package/dist/src/reactive/index.d.ts +0 -19
- package/dist/src/reactive/index.d.ts.map +0 -1
- package/dist/src/reactive/map.d.ts +0 -28
- package/dist/src/reactive/map.d.ts.map +0 -1
- package/dist/src/reactive/memoize.d.ts +0 -28
- package/dist/src/reactive/memoize.d.ts.map +0 -1
- package/dist/src/reactive/non-reactive-state.d.ts +0 -9
- package/dist/src/reactive/non-reactive-state.d.ts.map +0 -1
- package/dist/src/reactive/non-reactive.d.ts +0 -11
- package/dist/src/reactive/non-reactive.d.ts.map +0 -1
- package/dist/src/reactive/project.d.ts +0 -40
- package/dist/src/reactive/project.d.ts.map +0 -1
- package/dist/src/reactive/proxy-state.d.ts +0 -8
- package/dist/src/reactive/proxy-state.d.ts.map +0 -1
- package/dist/src/reactive/proxy.d.ts +0 -23
- package/dist/src/reactive/proxy.d.ts.map +0 -1
- package/dist/src/reactive/record.d.ts +0 -115
- package/dist/src/reactive/record.d.ts.map +0 -1
- package/dist/src/reactive/register.d.ts +0 -125
- package/dist/src/reactive/register.d.ts.map +0 -1
- package/dist/src/reactive/registry.d.ts +0 -21
- package/dist/src/reactive/registry.d.ts.map +0 -1
- package/dist/src/reactive/set.d.ts +0 -26
- package/dist/src/reactive/set.d.ts.map +0 -1
- package/dist/src/reactive/tracking.d.ts +0 -7
- package/dist/src/reactive/tracking.d.ts.map +0 -1
- package/dist/src/reactive/types.d.ts +0 -424
- package/dist/src/reactive/types.d.ts.map +0 -1
- package/dist/src/reactive/watch.d.ts +0 -48
- package/dist/src/reactive/watch.d.ts.map +0 -1
- package/dist/src/std-decorators.d.ts +0 -45
- package/dist/src/std-decorators.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -49
- package/dist/src/utils.d.ts.map +0 -1
- package/dist/src/zone.d.ts +0 -40
- package/dist/src/zone.d.ts.map +0 -1
- package/docs/reactive/describe.md +0 -85
- package/docs/reactive/project.md +0 -93
- package/src/async/browser.ts +0 -323
- package/src/async/index.ts +0 -27
- package/src/async/node.ts +0 -92
- package/src/decorator.ts +0 -272
- package/src/destroyable.ts +0 -199
- package/src/entry-browser.ts +0 -5
- package/src/entry-node.ts +0 -5
- package/src/eventful.ts +0 -110
- package/src/flavored.ts +0 -106
- package/src/index.d.ts +0 -12
- package/src/index.ts +0 -64
- package/src/indexable.ts +0 -526
- package/src/introspection.ts +0 -59
- package/src/iterableWeak.ts +0 -233
- package/src/mixins.ts +0 -123
- package/src/promiseChain.ts +0 -110
- package/src/reactive/array.ts +0 -500
- package/src/reactive/buffer.ts +0 -328
- package/src/reactive/change.ts +0 -131
- package/src/reactive/deep-touch.ts +0 -273
- package/src/reactive/deep-watch-state.ts +0 -82
- package/src/reactive/deep-watch.ts +0 -171
- package/src/reactive/describe.ts +0 -39
- package/src/reactive/effect-context.ts +0 -83
- package/src/reactive/effects.ts +0 -1434
- package/src/reactive/index.ts +0 -72
- package/src/reactive/map.ts +0 -142
- package/src/reactive/memoize.ts +0 -186
- package/src/reactive/non-reactive-state.ts +0 -49
- package/src/reactive/non-reactive.ts +0 -43
- package/src/reactive/project.md +0 -107
- package/src/reactive/project.ts +0 -430
- package/src/reactive/proxy-state.ts +0 -27
- package/src/reactive/proxy.ts +0 -282
- package/src/reactive/record.ts +0 -181
- package/src/reactive/register.ts +0 -538
- package/src/reactive/registry.ts +0 -72
- package/src/reactive/set.ts +0 -117
- package/src/reactive/tracking.ts +0 -41
- package/src/reactive/types.ts +0 -520
- package/src/reactive/watch.ts +0 -180
- package/src/std-decorators.ts +0 -256
- package/src/utils.ts +0 -300
- package/src/zone.ts +0 -142
package/dist/browser.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./chunks/async-browser-
|
|
4
|
-
var
|
|
3
|
+
require('./chunks/async-browser-BU_IfxYD.cjs');
|
|
4
|
+
var proxy = require('./chunks/proxy-Dtg-bJ3T.cjs');
|
|
5
5
|
var asyncCore = require('./chunks/async-core-CRLKP3l-.cjs');
|
|
6
|
-
require('./chunks/async-node-
|
|
6
|
+
require('./chunks/async-node-3PrbVAbB.cjs');
|
|
7
7
|
require('node:async_hooks');
|
|
8
8
|
|
|
9
9
|
// Integrated with `using` statement via Symbol.dispose
|
|
@@ -86,7 +86,7 @@ function Destroyable(base, destructorObj) {
|
|
|
86
86
|
* Decorator that marks properties to be stored in the allocated object and passed to the destructor
|
|
87
87
|
* Use with accessor properties or explicit get/set pairs
|
|
88
88
|
*/
|
|
89
|
-
const allocated =
|
|
89
|
+
const allocated = proxy.decorator({
|
|
90
90
|
setter(original, _target, propertyKey) {
|
|
91
91
|
return function (value) {
|
|
92
92
|
this[allocatedValues][propertyKey] = value;
|
|
@@ -111,6 +111,154 @@ function callOnGC(cb) {
|
|
|
111
111
|
return forward;
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/** Max edit distance before bailing out to a single "replace all" patch */
|
|
115
|
+
const BAILOUT_D = 256;
|
|
116
|
+
/**
|
|
117
|
+
* Myers' diff producing grouped patches: `{indexA, indexB, sliceA, sliceB}[]`.
|
|
118
|
+
* - O(N) for identical or prefix/suffix-only differences
|
|
119
|
+
* - O(ND) for small D, with a hard bailout at D=BAILOUT_D → single replacement patch
|
|
120
|
+
*/
|
|
121
|
+
function arrayDiff(A, B) {
|
|
122
|
+
let start = 0;
|
|
123
|
+
let endA = A.length;
|
|
124
|
+
let endB = B.length;
|
|
125
|
+
// Trim common prefix
|
|
126
|
+
while (start < endA && start < endB && A[start] === B[start])
|
|
127
|
+
start++;
|
|
128
|
+
// Trim common suffix
|
|
129
|
+
while (endA > start && endB > start && A[endA - 1] === B[endB - 1]) {
|
|
130
|
+
endA--;
|
|
131
|
+
endB--;
|
|
132
|
+
}
|
|
133
|
+
const lenA = endA - start;
|
|
134
|
+
const lenB = endB - start;
|
|
135
|
+
if (lenA === 0 && lenB === 0)
|
|
136
|
+
return [];
|
|
137
|
+
if (lenA === 0)
|
|
138
|
+
return [{ indexA: start, indexB: start, sliceA: [], sliceB: B.slice(start, endB) }];
|
|
139
|
+
if (lenB === 0)
|
|
140
|
+
return [{ indexA: start, indexB: start, sliceA: A.slice(start, endA), sliceB: [] }];
|
|
141
|
+
// Myers with bailout
|
|
142
|
+
const maxD = Math.min(lenA + lenB, BAILOUT_D);
|
|
143
|
+
const vSize = 2 * maxD + 1;
|
|
144
|
+
const vOffset = maxD;
|
|
145
|
+
const V = new Int32Array(vSize);
|
|
146
|
+
V[vOffset + 1] = 0;
|
|
147
|
+
const history = [];
|
|
148
|
+
for (let d = 0; d <= maxD; d++) {
|
|
149
|
+
for (let k = -d; k <= d; k += 2) {
|
|
150
|
+
let x;
|
|
151
|
+
if (k === -d || (k !== d && V[vOffset + k - 1] < V[vOffset + k + 1])) {
|
|
152
|
+
x = V[vOffset + k + 1];
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
x = V[vOffset + k - 1] + 1;
|
|
156
|
+
}
|
|
157
|
+
let y = x - k;
|
|
158
|
+
while (x < lenA && y < lenB && A[start + x] === B[start + y]) {
|
|
159
|
+
x++;
|
|
160
|
+
y++;
|
|
161
|
+
}
|
|
162
|
+
V[vOffset + k] = x;
|
|
163
|
+
if (x >= lenA && y >= lenB)
|
|
164
|
+
return buildPatches(history, A, B, start, x, y, d, k, vOffset);
|
|
165
|
+
}
|
|
166
|
+
history.push(new Int32Array(V));
|
|
167
|
+
}
|
|
168
|
+
// Bailout: too many differences
|
|
169
|
+
return [
|
|
170
|
+
{ indexA: start, indexB: start, sliceA: A.slice(start, endA), sliceB: B.slice(start, endB) },
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
function buildPatches(history, A, B, offset, finalX, finalY, finalD, finalK, vOffset) {
|
|
174
|
+
// Backtrack from (finalX, finalY) at step finalD to step 0, collecting ops in reverse
|
|
175
|
+
const ops = []; // 0=eq, 1=ins, 2=del
|
|
176
|
+
let x = finalX;
|
|
177
|
+
let y = finalY;
|
|
178
|
+
let k = finalK;
|
|
179
|
+
for (let d = finalD; d > 0; d--) {
|
|
180
|
+
const prev = history[d - 1];
|
|
181
|
+
let prevK;
|
|
182
|
+
let down;
|
|
183
|
+
if (k === -d) {
|
|
184
|
+
prevK = k + 1;
|
|
185
|
+
down = true;
|
|
186
|
+
}
|
|
187
|
+
else if (k === d) {
|
|
188
|
+
prevK = k - 1;
|
|
189
|
+
down = false;
|
|
190
|
+
}
|
|
191
|
+
else if (prev[vOffset + k - 1] < prev[vOffset + k + 1]) {
|
|
192
|
+
prevK = k + 1;
|
|
193
|
+
down = true;
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
prevK = k - 1;
|
|
197
|
+
down = false;
|
|
198
|
+
}
|
|
199
|
+
const prevXEnd = prev[vOffset + prevK];
|
|
200
|
+
const prevYEnd = prevXEnd - prevK;
|
|
201
|
+
const xStart = down ? prevXEnd : prevXEnd + 1;
|
|
202
|
+
const yStart = down ? prevYEnd + 1 : prevXEnd + 1 - k;
|
|
203
|
+
// Diagonal matches (pushed in reverse)
|
|
204
|
+
while (x > xStart && y > yStart) {
|
|
205
|
+
ops.push(0);
|
|
206
|
+
x--;
|
|
207
|
+
y--;
|
|
208
|
+
}
|
|
209
|
+
// The edit step
|
|
210
|
+
if (down) {
|
|
211
|
+
ops.push(1); // ins
|
|
212
|
+
y--;
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
ops.push(2); // del
|
|
216
|
+
x--;
|
|
217
|
+
}
|
|
218
|
+
k = prevK;
|
|
219
|
+
}
|
|
220
|
+
// Walk ops forward (they were pushed in reverse), grouping contiguous edits
|
|
221
|
+
const patches = [];
|
|
222
|
+
let currA = offset;
|
|
223
|
+
let currB = offset;
|
|
224
|
+
let sliceA = [];
|
|
225
|
+
let sliceB = [];
|
|
226
|
+
let patchA = -1;
|
|
227
|
+
let patchB = -1;
|
|
228
|
+
const flush = () => {
|
|
229
|
+
if (patchA !== -1) {
|
|
230
|
+
patches.push({ indexA: patchA, indexB: patchB, sliceA, sliceB });
|
|
231
|
+
sliceA = [];
|
|
232
|
+
sliceB = [];
|
|
233
|
+
patchA = -1;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
for (let i = ops.length - 1; i >= 0; i--) {
|
|
237
|
+
const op = ops[i];
|
|
238
|
+
if (op === 0) {
|
|
239
|
+
flush();
|
|
240
|
+
currA++;
|
|
241
|
+
currB++;
|
|
242
|
+
}
|
|
243
|
+
else if (op === 1) {
|
|
244
|
+
if (patchA === -1) {
|
|
245
|
+
patchA = currA;
|
|
246
|
+
patchB = currB;
|
|
247
|
+
}
|
|
248
|
+
sliceB.push(B[currB++]);
|
|
249
|
+
}
|
|
250
|
+
else {
|
|
251
|
+
if (patchA === -1) {
|
|
252
|
+
patchA = currA;
|
|
253
|
+
patchB = currB;
|
|
254
|
+
}
|
|
255
|
+
sliceA.push(A[currA++]);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
flush();
|
|
259
|
+
return patches;
|
|
260
|
+
}
|
|
261
|
+
|
|
114
262
|
var _a, _b;
|
|
115
263
|
const events = Symbol('events');
|
|
116
264
|
const hooks = Symbol('hooks');
|
|
@@ -613,67 +761,69 @@ function getBranch(tree, key) {
|
|
|
613
761
|
}
|
|
614
762
|
return branch;
|
|
615
763
|
}
|
|
616
|
-
function memoizeFunction(fn) {
|
|
617
|
-
const fnRoot =
|
|
764
|
+
function memoizeFunction(fn, opts) {
|
|
765
|
+
const fnRoot = proxy.getRoot(fn);
|
|
618
766
|
const existing = memoizedRegistry.get(fnRoot);
|
|
619
767
|
if (existing)
|
|
620
768
|
return existing;
|
|
621
769
|
const cacheRoot = {};
|
|
622
|
-
const memoized =
|
|
623
|
-
|
|
624
|
-
|
|
770
|
+
const memoized = proxy.markWithRoot(function memoized(...args) {
|
|
771
|
+
if (args.some((arg) => !(arg && ['object', 'symbol', 'function'].includes(typeof arg)))) {
|
|
772
|
+
if (opts?.lenient)
|
|
773
|
+
return fn.apply(this, args);
|
|
625
774
|
throw new Error('memoize expects non-null object arguments');
|
|
775
|
+
}
|
|
626
776
|
let node = cacheRoot;
|
|
627
777
|
// Note: decorators add `this` as first argument
|
|
628
|
-
for (const arg of
|
|
778
|
+
for (const arg of args) {
|
|
629
779
|
node = getBranch(node, arg);
|
|
630
780
|
}
|
|
631
|
-
|
|
781
|
+
proxy.dependant(node, 'memoize');
|
|
632
782
|
if ('result' in node) {
|
|
633
|
-
if (
|
|
634
|
-
const wasVerification =
|
|
635
|
-
|
|
783
|
+
if (proxy.options.onMemoizationDiscrepancy) {
|
|
784
|
+
const wasVerification = proxy.options.isVerificationRun;
|
|
785
|
+
proxy.options.isVerificationRun = true;
|
|
636
786
|
try {
|
|
637
|
-
const fresh =
|
|
638
|
-
if (!
|
|
639
|
-
|
|
787
|
+
const fresh = proxy.untracked(() => fn.apply(this, args));
|
|
788
|
+
if (!proxy.deepCompare(node.result, fresh)) {
|
|
789
|
+
proxy.optionCall('onMemoizationDiscrepancy', node.result, fresh, fn, args, 'calculation');
|
|
640
790
|
}
|
|
641
791
|
}
|
|
642
792
|
finally {
|
|
643
|
-
|
|
793
|
+
proxy.options.isVerificationRun = wasVerification;
|
|
644
794
|
}
|
|
645
795
|
}
|
|
646
796
|
return node.result;
|
|
647
797
|
}
|
|
648
798
|
// Create memoize internal effect to track dependencies and invalidate cache
|
|
649
799
|
// Use untracked to prevent the effect creation from being affected by parent effects
|
|
650
|
-
node.cleanup =
|
|
800
|
+
node.cleanup = proxy.root(() => proxy.effect.named('memoize')(() => {
|
|
651
801
|
// Execute the function and track its dependencies
|
|
652
802
|
// The function execution will automatically track dependencies on reactive objects
|
|
653
|
-
node.result = fn(
|
|
654
|
-
return () => {
|
|
803
|
+
node.result = fn.apply(this, args);
|
|
804
|
+
return (reason) => {
|
|
655
805
|
// When dependencies change, clear the cache and notify consumers
|
|
656
806
|
delete node.result;
|
|
657
|
-
|
|
807
|
+
proxy.touched1(node, { type: 'invalidate', prop: args }, 'memoize');
|
|
658
808
|
// Lazy memoization: stop the effect so it doesn't re-run immediately.
|
|
659
809
|
// It will be re-created on next access.
|
|
660
810
|
if (node.cleanup) {
|
|
661
|
-
node.cleanup();
|
|
811
|
+
node.cleanup({ type: 'invalidate', cause: reason });
|
|
662
812
|
node.cleanup = undefined;
|
|
663
813
|
}
|
|
664
814
|
};
|
|
665
815
|
}, { opaque: true }));
|
|
666
|
-
if (
|
|
667
|
-
const wasVerification =
|
|
668
|
-
|
|
816
|
+
if (proxy.options.onMemoizationDiscrepancy) {
|
|
817
|
+
const wasVerification = proxy.options.isVerificationRun;
|
|
818
|
+
proxy.options.isVerificationRun = true;
|
|
669
819
|
try {
|
|
670
|
-
const fresh =
|
|
671
|
-
if (!
|
|
672
|
-
|
|
820
|
+
const fresh = proxy.untracked(() => fn.apply(this, args));
|
|
821
|
+
if (!proxy.deepCompare(node.result, fresh)) {
|
|
822
|
+
proxy.optionCall('onMemoizationDiscrepancy', node.result, fresh, fn, args, 'comparison');
|
|
673
823
|
}
|
|
674
824
|
}
|
|
675
825
|
finally {
|
|
676
|
-
|
|
826
|
+
proxy.options.isVerificationRun = wasVerification;
|
|
677
827
|
}
|
|
678
828
|
}
|
|
679
829
|
return node.result;
|
|
@@ -682,6 +832,55 @@ function memoizeFunction(fn) {
|
|
|
682
832
|
memoizedRegistry.set(memoized, memoized);
|
|
683
833
|
return memoized;
|
|
684
834
|
}
|
|
835
|
+
function memoizeObject(target, opts) {
|
|
836
|
+
const existing = memoizedRegistry.get(target);
|
|
837
|
+
if (existing)
|
|
838
|
+
return existing;
|
|
839
|
+
const proxy$1 = new Proxy(target, {
|
|
840
|
+
get(source, prop, receiver) {
|
|
841
|
+
// 1. Walk prototype chain to find descriptor
|
|
842
|
+
let current = source;
|
|
843
|
+
let desc;
|
|
844
|
+
while (current) {
|
|
845
|
+
desc = Object.getOwnPropertyDescriptor(current, prop);
|
|
846
|
+
if (desc)
|
|
847
|
+
break;
|
|
848
|
+
current = Object.getPrototypeOf(current);
|
|
849
|
+
}
|
|
850
|
+
if (!desc)
|
|
851
|
+
return Reflect.get(source, prop, receiver);
|
|
852
|
+
// 2. If getter, memoize
|
|
853
|
+
if (desc.get) {
|
|
854
|
+
const originalGetter = desc.get;
|
|
855
|
+
let wrapper = wrapperRegistry.get(originalGetter);
|
|
856
|
+
if (!wrapper) {
|
|
857
|
+
wrapper = proxy.markWithRoot(proxy.named(`${String(source?.constructor?.name ?? 'Object')}.${String(prop)}`, (that) => {
|
|
858
|
+
return originalGetter.call(that);
|
|
859
|
+
}), {
|
|
860
|
+
propertyKey: prop,
|
|
861
|
+
});
|
|
862
|
+
const origRoot = originalGetter[proxy.rootFunctionSymbol];
|
|
863
|
+
if (origRoot)
|
|
864
|
+
wrapper[proxy.rootFunctionSymbol] = origRoot;
|
|
865
|
+
wrapperRegistry.set(originalGetter, wrapper);
|
|
866
|
+
}
|
|
867
|
+
const memoized = memoizeFunction(wrapper, opts);
|
|
868
|
+
return memoized(receiver);
|
|
869
|
+
}
|
|
870
|
+
// 3. Otherwise forward
|
|
871
|
+
return Reflect.get(source, prop, receiver);
|
|
872
|
+
},
|
|
873
|
+
// Forward set to the target (source) to ensure it acts as the receiver for reactivity notifications
|
|
874
|
+
set(source, prop, value, _receiver) {
|
|
875
|
+
// By strictly passing `source` as receiver, we ensure that if `source` is a reactive proxy,
|
|
876
|
+
// it recognizes itself and triggers change notifications.
|
|
877
|
+
return Reflect.set(source, prop, value, source);
|
|
878
|
+
},
|
|
879
|
+
});
|
|
880
|
+
proxy.proxyToObject.set(proxy$1, target);
|
|
881
|
+
memoizedRegistry.set(target, proxy$1);
|
|
882
|
+
return proxy$1;
|
|
883
|
+
}
|
|
685
884
|
/**
|
|
686
885
|
* Decorator and function wrapper for memoizing computed values based on reactive dependencies.
|
|
687
886
|
*
|
|
@@ -705,46 +904,55 @@ function memoizeFunction(fn) {
|
|
|
705
904
|
* })
|
|
706
905
|
* ```
|
|
707
906
|
*/
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
907
|
+
function makeMemoizeDecorator(memoizeOpts) {
|
|
908
|
+
return proxy.decorator({
|
|
909
|
+
getter(original, target, propertyKey) {
|
|
910
|
+
return function () {
|
|
911
|
+
let wrapper = wrapperRegistry.get(original);
|
|
912
|
+
if (!wrapper) {
|
|
913
|
+
wrapper = proxy.markWithRoot(proxy.named(`${String(target?.constructor?.name ?? target?.name ?? 'Object')}.${String(propertyKey)}`, (that) => {
|
|
914
|
+
return original.call(that);
|
|
915
|
+
}), {
|
|
916
|
+
method: original,
|
|
917
|
+
propertyKey,
|
|
918
|
+
});
|
|
919
|
+
const origRoot = original[proxy.rootFunctionSymbol];
|
|
920
|
+
if (origRoot)
|
|
921
|
+
wrapper[proxy.rootFunctionSymbol] = origRoot;
|
|
922
|
+
wrapperRegistry.set(original, wrapper);
|
|
923
|
+
}
|
|
924
|
+
const memoized = memoizeFunction(wrapper, memoizeOpts);
|
|
925
|
+
return memoized(this);
|
|
926
|
+
};
|
|
927
|
+
},
|
|
928
|
+
method(original, target, name) {
|
|
929
|
+
return function (...args) {
|
|
930
|
+
let wrapper = wrapperRegistry.get(original);
|
|
931
|
+
if (!wrapper) {
|
|
932
|
+
wrapper = proxy.markWithRoot(proxy.named(`${String(target?.constructor?.name ?? target?.name ?? 'Object')}.${String(name)}`, (that, ...args) => {
|
|
933
|
+
return original.call(that, ...args);
|
|
934
|
+
}), {
|
|
935
|
+
method: original,
|
|
936
|
+
propertyKey: name,
|
|
937
|
+
});
|
|
938
|
+
const origRoot = original[proxy.rootFunctionSymbol];
|
|
939
|
+
if (origRoot)
|
|
940
|
+
wrapper[proxy.rootFunctionSymbol] = origRoot;
|
|
941
|
+
wrapperRegistry.set(original, wrapper);
|
|
942
|
+
}
|
|
943
|
+
const memoized = memoizeFunction(wrapper, memoizeOpts);
|
|
944
|
+
return memoized(this, ...args);
|
|
945
|
+
};
|
|
946
|
+
},
|
|
947
|
+
default: (target) => typeof target === 'object'
|
|
948
|
+
? memoizeObject(target, memoizeOpts)
|
|
949
|
+
: memoizeFunction(target, memoizeOpts),
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
const memoize = proxy.flavored(makeMemoizeDecorator(), {
|
|
953
|
+
get lenient() {
|
|
954
|
+
return makeMemoizeDecorator({ lenient: true });
|
|
746
955
|
},
|
|
747
|
-
default: memoizeFunction,
|
|
748
956
|
});
|
|
749
957
|
|
|
750
958
|
function attend(source, callback) {
|
|
@@ -758,14 +966,14 @@ function attend(source, callback) {
|
|
|
758
966
|
? () => source.values()
|
|
759
967
|
: () => Object.keys(source);
|
|
760
968
|
const keyEffects = new Map();
|
|
761
|
-
const outer =
|
|
969
|
+
const outer = proxy.effect(({ ascend }) => {
|
|
762
970
|
const keys = new Set();
|
|
763
971
|
for (const key of enumerate())
|
|
764
972
|
keys.add(key);
|
|
765
973
|
for (const key of keys) {
|
|
766
974
|
if (keyEffects.has(key))
|
|
767
975
|
continue;
|
|
768
|
-
keyEffects.set(key, ascend(() =>
|
|
976
|
+
keyEffects.set(key, ascend(() => proxy.effect(() => callback(key))));
|
|
769
977
|
}
|
|
770
978
|
for (const key of Array.from(keyEffects.keys())) {
|
|
771
979
|
if (!keys.has(key)) {
|
|
@@ -774,10 +982,10 @@ function attend(source, callback) {
|
|
|
774
982
|
}
|
|
775
983
|
}
|
|
776
984
|
});
|
|
777
|
-
return () => {
|
|
778
|
-
outer();
|
|
985
|
+
return (reason) => {
|
|
986
|
+
outer(reason);
|
|
779
987
|
for (const stop of keyEffects.values())
|
|
780
|
-
stop();
|
|
988
|
+
stop(reason);
|
|
781
989
|
keyEffects.clear();
|
|
782
990
|
};
|
|
783
991
|
}
|
|
@@ -812,12 +1020,13 @@ function attend(source, callback) {
|
|
|
812
1020
|
* @returns A reactive array of accumulated values, with a [cleanup] property to stop the tracking
|
|
813
1021
|
*/
|
|
814
1022
|
function scan(source, callback, initialValue) {
|
|
815
|
-
const observedSource =
|
|
816
|
-
const
|
|
1023
|
+
const observedSource = proxy.reactive(source);
|
|
1024
|
+
const rawResult = [];
|
|
1025
|
+
const result = proxy.reactive(rawResult);
|
|
817
1026
|
// Track effects for each index to dispose them when the array shrinks
|
|
818
1027
|
const indexEffects = new Map();
|
|
819
1028
|
// Mapping from index to its current intermediate object
|
|
820
|
-
const indexToIntermediate =
|
|
1029
|
+
const indexToIntermediate = proxy.reactive([]);
|
|
821
1030
|
const intermediaries = new WeakMap();
|
|
822
1031
|
let Intermediate = (() => {
|
|
823
1032
|
var _a;
|
|
@@ -825,7 +1034,7 @@ function scan(source, callback, initialValue) {
|
|
|
825
1034
|
let _get_acc_decorators;
|
|
826
1035
|
return _a = class Intermediate {
|
|
827
1036
|
constructor(val, prev) {
|
|
828
|
-
this.val = (
|
|
1037
|
+
this.val = (proxy.__runInitializers(this, _instanceExtraInitializers), val);
|
|
829
1038
|
this.prev = prev;
|
|
830
1039
|
}
|
|
831
1040
|
get acc() {
|
|
@@ -836,7 +1045,7 @@ function scan(source, callback, initialValue) {
|
|
|
836
1045
|
(() => {
|
|
837
1046
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
838
1047
|
_get_acc_decorators = [memoize];
|
|
839
|
-
|
|
1048
|
+
proxy.__esDecorate(_a, null, _get_acc_decorators, { kind: "getter", name: "acc", static: false, private: false, access: { has: obj => "acc" in obj, get: obj => obj.acc }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
840
1049
|
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
841
1050
|
})(),
|
|
842
1051
|
_a;
|
|
@@ -846,117 +1055,473 @@ function scan(source, callback, initialValue) {
|
|
|
846
1055
|
if (stop) {
|
|
847
1056
|
stop();
|
|
848
1057
|
indexEffects.delete(index);
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
Reflect.deleteProperty(result, index);
|
|
852
|
-
});
|
|
1058
|
+
Reflect.deleteProperty(indexToIntermediate, index);
|
|
1059
|
+
Reflect.deleteProperty(result, index);
|
|
853
1060
|
}
|
|
854
1061
|
}
|
|
855
|
-
const mainEffect =
|
|
1062
|
+
const mainEffect = proxy.effect(function scanMainEffect({ ascend }) {
|
|
856
1063
|
const length = observedSource.length;
|
|
857
1064
|
const occurrenceCount = new Map();
|
|
858
1065
|
let prev;
|
|
859
|
-
for (let i = 0; i < length; i++)
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
occurrenceCount.set(val, count + 1);
|
|
866
|
-
let list = intermediaries.get(val);
|
|
867
|
-
if (!list) {
|
|
868
|
-
list = [];
|
|
869
|
-
intermediaries.set(val, list);
|
|
870
|
-
}
|
|
871
|
-
let intermediate = list[count];
|
|
872
|
-
if (!intermediate) {
|
|
873
|
-
intermediate = debug.reactive(new Intermediate(val, prev));
|
|
874
|
-
list[count] = intermediate;
|
|
875
|
-
}
|
|
876
|
-
else {
|
|
877
|
-
// Update the link.
|
|
878
|
-
if (debug.untracked(() => intermediate.prev) !== prev) {
|
|
879
|
-
intermediate.prev = prev;
|
|
1066
|
+
for (let i = 0; i < length; i++)
|
|
1067
|
+
if (i in observedSource) {
|
|
1068
|
+
const val = observedSource[i];
|
|
1069
|
+
if (!(val &&
|
|
1070
|
+
(typeof val === 'object' || typeof val === 'function' || typeof val === 'symbol'))) {
|
|
1071
|
+
throw new Error('scan: items must be objects (WeakKey) for intermediate caching');
|
|
880
1072
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
1073
|
+
const count = occurrenceCount.get(val) ?? 0;
|
|
1074
|
+
occurrenceCount.set(val, count + 1);
|
|
1075
|
+
let list = intermediaries.get(val);
|
|
1076
|
+
if (!list) {
|
|
1077
|
+
list = [];
|
|
1078
|
+
intermediaries.set(val, list);
|
|
1079
|
+
}
|
|
1080
|
+
let intermediate = list[count];
|
|
1081
|
+
if (!intermediate) {
|
|
1082
|
+
intermediate = proxy.reactive(new Intermediate(val, prev));
|
|
1083
|
+
list[count] = intermediate;
|
|
1084
|
+
}
|
|
1085
|
+
else {
|
|
1086
|
+
// Update the link.
|
|
1087
|
+
if (proxy.untracked(() => intermediate.prev) !== prev) {
|
|
1088
|
+
intermediate.prev = prev;
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
// Update the reactive mapping for this index
|
|
1092
|
+
if (indexToIntermediate[i] !== intermediate) {
|
|
1093
|
+
indexToIntermediate[i] = intermediate;
|
|
1094
|
+
}
|
|
1095
|
+
// If we don't have an effect for this index yet, create one
|
|
1096
|
+
if (!indexEffects.has(i)) {
|
|
1097
|
+
ascend(() => {
|
|
1098
|
+
const index = i;
|
|
1099
|
+
const stop = proxy.effect(function scanIndexSyncEffect() {
|
|
1100
|
+
const inter = indexToIntermediate[index];
|
|
1101
|
+
if (inter) {
|
|
1102
|
+
const accValue = inter.acc;
|
|
895
1103
|
result[index] = accValue;
|
|
896
|
-
}
|
|
897
|
-
}
|
|
1104
|
+
}
|
|
1105
|
+
});
|
|
1106
|
+
indexEffects.set(index, stop);
|
|
898
1107
|
});
|
|
899
|
-
|
|
900
|
-
|
|
1108
|
+
}
|
|
1109
|
+
prev = intermediate;
|
|
901
1110
|
}
|
|
902
|
-
prev = intermediate;
|
|
903
|
-
}
|
|
904
1111
|
// Cleanup trailing indices
|
|
905
1112
|
for (const index of Array.from(indexEffects.keys())) {
|
|
906
1113
|
if (index >= length)
|
|
907
1114
|
disposeIndex(index);
|
|
908
1115
|
}
|
|
909
1116
|
// Ensure result length matches source length
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
}
|
|
914
|
-
});
|
|
1117
|
+
if (rawResult.length !== length) {
|
|
1118
|
+
proxy.FoolProof.set(result, 'length', length, result);
|
|
1119
|
+
}
|
|
915
1120
|
});
|
|
916
|
-
return
|
|
917
|
-
mainEffect();
|
|
1121
|
+
return proxy.cleanedBy(result, ((reason) => {
|
|
1122
|
+
mainEffect(reason);
|
|
918
1123
|
for (const stop of indexEffects.values())
|
|
919
|
-
stop();
|
|
1124
|
+
stop(reason);
|
|
920
1125
|
indexEffects.clear();
|
|
921
1126
|
}));
|
|
922
1127
|
}
|
|
923
1128
|
function lift(cb) {
|
|
924
1129
|
let result;
|
|
925
|
-
|
|
1130
|
+
let rawResult;
|
|
1131
|
+
const liftCleanup = proxy.effect.named('lift')(proxy.markWithRoot((access) => {
|
|
926
1132
|
const source = cb(access);
|
|
927
1133
|
if (!source || typeof source !== 'object')
|
|
928
1134
|
throw new Error('lift callback must return an array or object');
|
|
1135
|
+
const sourceProto = Object.getPrototypeOf(source);
|
|
929
1136
|
if (!result) {
|
|
930
|
-
|
|
931
|
-
|
|
1137
|
+
rawResult = Array.isArray(source) ? [] : Object.create(sourceProto);
|
|
1138
|
+
result = proxy.reactive(rawResult);
|
|
1139
|
+
}
|
|
1140
|
+
if (sourceProto !== Object.getPrototypeOf(result))
|
|
1141
|
+
throw new Error('lift callback must return the same type as the previous result');
|
|
1142
|
+
if (Array.isArray(source)) {
|
|
1143
|
+
const res = result;
|
|
1144
|
+
const patches = arrayDiff(res, source);
|
|
1145
|
+
for (let i = patches.length - 1; i >= 0; i--) {
|
|
1146
|
+
const { indexA, sliceA, sliceB } = patches[i];
|
|
1147
|
+
res.splice(indexA, sliceA.length, ...sliceB);
|
|
932
1148
|
}
|
|
933
|
-
|
|
934
|
-
|
|
1149
|
+
}
|
|
1150
|
+
else {
|
|
1151
|
+
for (const key of Object.keys(source)) {
|
|
1152
|
+
const had = key in rawResult;
|
|
1153
|
+
const newDesc = Object.getOwnPropertyDescriptor(source, key);
|
|
1154
|
+
if (had) {
|
|
1155
|
+
const oldDesc = Object.getOwnPropertyDescriptor(rawResult, key);
|
|
1156
|
+
const sameAccessor = oldDesc && newDesc.get && oldDesc.get === newDesc.get;
|
|
1157
|
+
Object.defineProperty(rawResult, key, newDesc);
|
|
1158
|
+
if (!sameAccessor &&
|
|
1159
|
+
rawResult[key] !==
|
|
1160
|
+
(oldDesc ? (oldDesc.get ? oldDesc.get() : oldDesc.value) : undefined))
|
|
1161
|
+
proxy.touched1(rawResult, { type: 'set', prop: key }, key);
|
|
1162
|
+
}
|
|
1163
|
+
else {
|
|
1164
|
+
Object.defineProperty(rawResult, key, newDesc);
|
|
1165
|
+
proxy.touched1(rawResult, { type: 'add', prop: key }, key);
|
|
1166
|
+
}
|
|
935
1167
|
}
|
|
1168
|
+
for (const key of Object.keys(rawResult))
|
|
1169
|
+
if (!(key in source)) {
|
|
1170
|
+
delete rawResult[key];
|
|
1171
|
+
proxy.touched1(rawResult, { type: 'del', prop: key }, key);
|
|
1172
|
+
}
|
|
936
1173
|
}
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1174
|
+
}, cb));
|
|
1175
|
+
return proxy.cleanedBy(result, liftCleanup);
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1178
|
+
* Reactively maps an array source through `fn`, producing a lazy reactive output array.
|
|
1179
|
+
*
|
|
1180
|
+
* Each source item gets its own isolated effect (via `root()`) so that changes to one item
|
|
1181
|
+
* only recompute that item's projection. Structural changes (push, splice, reorder) are detected
|
|
1182
|
+
* via `arrayDiff` and surgically applied to the output cache.
|
|
1183
|
+
*
|
|
1184
|
+
* The source can be a reactive array or a function returning an array. When a function is provided,
|
|
1185
|
+
* the function is re-evaluated inside an effect whenever its dependencies change.
|
|
1186
|
+
*
|
|
1187
|
+
* Output elements are computed lazily — accessing `result[i]` triggers computation if not yet cached.
|
|
1188
|
+
*
|
|
1189
|
+
* @param source - A reactive array or a function returning an array
|
|
1190
|
+
* @param fn - Mapping function applied to each element
|
|
1191
|
+
* @param options - Optional purity hints to skip per-item effects
|
|
1192
|
+
* @returns A readonly reactive array with a `[cleanup]` method to dispose all effects
|
|
1193
|
+
*/
|
|
1194
|
+
function morphArray(source, fn, options) {
|
|
1195
|
+
if (typeof source !== 'function' && !proxy.isReactive(source) && options?.pure === true) {
|
|
1196
|
+
return source.map(fn);
|
|
1197
|
+
}
|
|
1198
|
+
let track;
|
|
1199
|
+
const itemEffects = new Map();
|
|
1200
|
+
const cache = [];
|
|
1201
|
+
let input = [];
|
|
1202
|
+
function stopItem(key) {
|
|
1203
|
+
const entry = itemEffects.get(key);
|
|
1204
|
+
if (entry) {
|
|
1205
|
+
entry.stop({ type: 'stopped' });
|
|
1206
|
+
itemEffects.delete(key);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function computeItem(key, input) {
|
|
1210
|
+
const isPure = options?.pure === true || (typeof options?.pure === 'function' && options.pure(input));
|
|
1211
|
+
if (isPure) {
|
|
1212
|
+
track(() => {
|
|
1213
|
+
cache[key] = fn(input);
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
else {
|
|
1217
|
+
const indexRef = { value: key };
|
|
1218
|
+
let stop;
|
|
1219
|
+
track(() => {
|
|
1220
|
+
stop = proxy.effect.opaque(() => {
|
|
1221
|
+
cache[indexRef.value] = fn(input);
|
|
1222
|
+
return (reason) => {
|
|
1223
|
+
delete cache[indexRef.value];
|
|
1224
|
+
proxy.touched1(cache, { type: 'invalidate', prop: 'morph' }, String(key));
|
|
1225
|
+
stop({ type: 'invalidate', cause: reason });
|
|
1226
|
+
};
|
|
1227
|
+
});
|
|
1228
|
+
});
|
|
1229
|
+
itemEffects.set(key, { stop, index: indexRef });
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
const proxy$1 = proxy.reactive(cache, {
|
|
1233
|
+
get(cache, prop) {
|
|
1234
|
+
const n = typeof prop === 'string' ? Number(prop) : NaN;
|
|
1235
|
+
if (Number.isNaN(n))
|
|
1236
|
+
return cache[prop];
|
|
1237
|
+
if (!(n in cache))
|
|
1238
|
+
computeItem(n, input[n]);
|
|
1239
|
+
return cache[n];
|
|
1240
|
+
},
|
|
1241
|
+
has(_cache, prop) {
|
|
1242
|
+
return Reflect.has(input, prop);
|
|
1243
|
+
},
|
|
1244
|
+
});
|
|
1245
|
+
const stopMain = proxy.effect.named('morph:array')(({ ascend }) => {
|
|
1246
|
+
track = ascend;
|
|
1247
|
+
const newInput = [...(typeof source === 'function' ? source() : source)];
|
|
1248
|
+
const diffs = arrayDiff(input, newInput).toSorted((a, b) => b.indexA - a.indexA);
|
|
1249
|
+
if (diffs.length > 0) {
|
|
1250
|
+
for (const diff of diffs) {
|
|
1251
|
+
// Stop items in removed range
|
|
1252
|
+
for (let i = diff.indexA; i < diff.indexA + diff.sliceA.length; i++)
|
|
1253
|
+
stopItem(i);
|
|
1254
|
+
// Shift existing itemEffects in the Map to match the new indices
|
|
1255
|
+
const shift = diff.sliceB.length - diff.sliceA.length;
|
|
1256
|
+
if (shift !== 0) {
|
|
1257
|
+
// We need to move entries in the Map.
|
|
1258
|
+
const entries = Array.from(itemEffects.entries()).sort((a, b) => a[0] - b[0]);
|
|
1259
|
+
// Remove entries that will be shifted
|
|
1260
|
+
for (const [idx, entry] of entries) {
|
|
1261
|
+
if (idx >= diff.indexA + diff.sliceA.length) {
|
|
1262
|
+
itemEffects.delete(idx);
|
|
1263
|
+
}
|
|
1264
|
+
}
|
|
1265
|
+
// Re-add them with shifted indices
|
|
1266
|
+
for (const [idx, entry] of entries) {
|
|
1267
|
+
if (idx >= diff.indexA + diff.sliceA.length) {
|
|
1268
|
+
const newIdx = idx + shift;
|
|
1269
|
+
entry.index.value = newIdx;
|
|
1270
|
+
itemEffects.set(newIdx, entry);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
// Splice the cache
|
|
1275
|
+
cache.splice(diff.indexA, diff.sliceA.length, ...new Array(diff.sliceB.length).fill(undefined));
|
|
1276
|
+
// Make holes for lazy computation
|
|
1277
|
+
for (let i = diff.indexA; i < diff.indexA + diff.sliceB.length; i++)
|
|
1278
|
+
delete cache[i];
|
|
1279
|
+
}
|
|
1280
|
+
const invalidates = new Set([proxy.keysOf]);
|
|
1281
|
+
if (input.length !== newInput.length)
|
|
1282
|
+
invalidates.add('length');
|
|
1283
|
+
for (const diff of diffs) {
|
|
1284
|
+
const max = Math.max(diff.sliceA.length, diff.sliceB.length);
|
|
1285
|
+
for (let i = 0; i < max; i++)
|
|
1286
|
+
invalidates.add(String(diff.indexA + i));
|
|
1287
|
+
}
|
|
1288
|
+
proxy.touched(cache, { type: 'bunch', method: 'morph-input' }, invalidates);
|
|
1289
|
+
}
|
|
1290
|
+
input = newInput;
|
|
1291
|
+
});
|
|
1292
|
+
return proxy.cleanedBy(proxy$1, (reason) => {
|
|
1293
|
+
stopMain(reason);
|
|
1294
|
+
for (const entry of itemEffects.values())
|
|
1295
|
+
entry.stop(reason);
|
|
1296
|
+
itemEffects.clear();
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1299
|
+
/**
|
|
1300
|
+
* Reactively maps a `Map` source through `fn`, producing a reactive output Map.
|
|
1301
|
+
*
|
|
1302
|
+
* Each key gets its own isolated effect so that value changes for one key only recompute
|
|
1303
|
+
* that key's projection. Key additions and removals are tracked via `keysOf` dependency.
|
|
1304
|
+
*
|
|
1305
|
+
* @param source - A reactive Map
|
|
1306
|
+
* @param fn - Mapping function applied to each value
|
|
1307
|
+
* @param options - Optional purity hints to skip per-key effects
|
|
1308
|
+
* @returns A reactive Map with a `[cleanup]` method to dispose all effects
|
|
1309
|
+
*/
|
|
1310
|
+
function morphMap(source, fn, options) {
|
|
1311
|
+
if (!proxy.isReactive(source) && options?.pure === true) {
|
|
1312
|
+
const res = new Map();
|
|
1313
|
+
for (const [k, v] of source)
|
|
1314
|
+
res.set(k, fn(v));
|
|
1315
|
+
return res;
|
|
1316
|
+
}
|
|
1317
|
+
let track;
|
|
1318
|
+
const itemEffects = new Map();
|
|
1319
|
+
const cache = new Map();
|
|
1320
|
+
Object.defineProperty(cache, 'constructor', { value: Object, enumerable: false });
|
|
1321
|
+
function stopItem(key) {
|
|
1322
|
+
const stop = itemEffects.get(key);
|
|
1323
|
+
if (stop) {
|
|
1324
|
+
stop({ type: 'stopped' });
|
|
1325
|
+
itemEffects.delete(key);
|
|
943
1326
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
1327
|
+
}
|
|
1328
|
+
function computeItem(key, val) {
|
|
1329
|
+
const isPure = options?.pure === true || (typeof options?.pure === 'function' && options.pure(val));
|
|
1330
|
+
if (isPure) {
|
|
1331
|
+
cache.set(key, track(() => fn(val)));
|
|
949
1332
|
}
|
|
950
1333
|
else {
|
|
951
|
-
|
|
1334
|
+
const stop = track(() => proxy.effect.opaque(() => {
|
|
1335
|
+
cache.set(key, fn(source.get(key)));
|
|
1336
|
+
return (reason) => {
|
|
1337
|
+
cache.delete(key);
|
|
1338
|
+
proxy.touched1(cache, { type: 'invalidate', prop: 'morph' }, String(key));
|
|
1339
|
+
stop({ type: 'invalidate', cause: reason });
|
|
1340
|
+
};
|
|
1341
|
+
}));
|
|
1342
|
+
itemEffects.set(key, stop);
|
|
1343
|
+
}
|
|
1344
|
+
}
|
|
1345
|
+
const proxy$1 = proxy.reactive(cache, {
|
|
1346
|
+
get(cache, prop) {
|
|
1347
|
+
if (prop === 'get')
|
|
1348
|
+
return (key) => {
|
|
1349
|
+
if (!cache.has(key) && source.has(key))
|
|
1350
|
+
computeItem(key, source.get(key));
|
|
1351
|
+
return cache.get(key);
|
|
1352
|
+
};
|
|
1353
|
+
if (prop === 'has')
|
|
1354
|
+
return (key) => {
|
|
1355
|
+
return source.has(key);
|
|
1356
|
+
};
|
|
1357
|
+
if (prop === 'keys')
|
|
1358
|
+
return () => {
|
|
1359
|
+
return source.keys();
|
|
1360
|
+
};
|
|
1361
|
+
if (prop === 'values')
|
|
1362
|
+
return function* () {
|
|
1363
|
+
for (const key of source.keys()) {
|
|
1364
|
+
yield proxy$1.get(key);
|
|
1365
|
+
}
|
|
1366
|
+
};
|
|
1367
|
+
if (prop === 'entries')
|
|
1368
|
+
return function* () {
|
|
1369
|
+
for (const key of source.keys()) {
|
|
1370
|
+
yield [key, proxy$1.get(key)];
|
|
1371
|
+
}
|
|
1372
|
+
};
|
|
1373
|
+
if (prop === Symbol.iterator)
|
|
1374
|
+
return function* () {
|
|
1375
|
+
for (const key of source.keys()) {
|
|
1376
|
+
yield [key, proxy$1.get(key)];
|
|
1377
|
+
}
|
|
1378
|
+
};
|
|
1379
|
+
return cache[prop];
|
|
1380
|
+
},
|
|
1381
|
+
});
|
|
1382
|
+
let stateSnapshot = proxy.getState(source);
|
|
1383
|
+
const stopMain = proxy.effect.named('morph:map')(({ ascend }) => {
|
|
1384
|
+
track = ascend;
|
|
1385
|
+
proxy.dependant(source, proxy.keysOf);
|
|
1386
|
+
while ('evolution' in stateSnapshot) {
|
|
1387
|
+
const { evolution } = stateSnapshot;
|
|
1388
|
+
stateSnapshot = stateSnapshot.next;
|
|
1389
|
+
if (evolution.type === 'add') {
|
|
1390
|
+
proxy.touched1(cache, evolution, evolution.prop);
|
|
1391
|
+
}
|
|
1392
|
+
else if (evolution.type === 'del') {
|
|
1393
|
+
stopItem(evolution.prop);
|
|
1394
|
+
cache.delete(evolution.prop);
|
|
1395
|
+
proxy.touched1(cache, evolution, evolution.prop);
|
|
1396
|
+
}
|
|
952
1397
|
}
|
|
953
1398
|
});
|
|
954
|
-
return
|
|
1399
|
+
return proxy.cleanedBy(proxy$1, (reason) => {
|
|
1400
|
+
stopMain(reason);
|
|
1401
|
+
for (const stop of itemEffects.values())
|
|
1402
|
+
stop(reason);
|
|
1403
|
+
itemEffects.clear();
|
|
1404
|
+
});
|
|
955
1405
|
}
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
1406
|
+
/**
|
|
1407
|
+
* Reactively maps a record/object source through `fn`, producing a reactive output record.
|
|
1408
|
+
*
|
|
1409
|
+
* Each key gets its own isolated effect so that value changes for one key only recompute
|
|
1410
|
+
* that key's projection. Key additions and removals are tracked automatically.
|
|
1411
|
+
*
|
|
1412
|
+
* @param source - A reactive record
|
|
1413
|
+
* @param fn - Mapping function applied to each value
|
|
1414
|
+
* @param options - Optional purity hints to skip per-key effects
|
|
1415
|
+
* @returns A reactive record with a `[cleanup]` method to dispose all effects
|
|
1416
|
+
*/
|
|
1417
|
+
function morphRecord(source, fn, options) {
|
|
1418
|
+
if (!proxy.isReactive(source) && options?.pure === true) {
|
|
1419
|
+
const res = {};
|
|
1420
|
+
for (const k of Object.keys(source))
|
|
1421
|
+
res[k] = fn(source[k]);
|
|
1422
|
+
return res;
|
|
1423
|
+
}
|
|
1424
|
+
let track;
|
|
1425
|
+
const itemEffects = new Map();
|
|
1426
|
+
const cache = {};
|
|
1427
|
+
function stopItem(key) {
|
|
1428
|
+
const stop = itemEffects.get(key);
|
|
1429
|
+
if (stop) {
|
|
1430
|
+
stop({ type: 'stopped' });
|
|
1431
|
+
itemEffects.delete(key);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
function computeItem(key, val) {
|
|
1435
|
+
const isPure = options?.pure === true || (typeof options?.pure === 'function' && options.pure(val));
|
|
1436
|
+
if (isPure) {
|
|
1437
|
+
cache[key] = track(() => fn(val));
|
|
1438
|
+
}
|
|
1439
|
+
else {
|
|
1440
|
+
const stop = track(() => proxy.effect.opaque(() => {
|
|
1441
|
+
cache[key] = fn(source[key]);
|
|
1442
|
+
return (reason) => {
|
|
1443
|
+
delete cache[key];
|
|
1444
|
+
proxy.touched1(cache, { type: 'invalidate', prop: 'morph' }, String(key));
|
|
1445
|
+
stop({ type: 'invalidate', cause: reason });
|
|
1446
|
+
};
|
|
1447
|
+
}));
|
|
1448
|
+
itemEffects.set(key, stop);
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
function get(prop) {
|
|
1452
|
+
if (!(prop in cache) && prop in source)
|
|
1453
|
+
computeItem(prop, source[prop]);
|
|
1454
|
+
return cache[prop];
|
|
1455
|
+
}
|
|
1456
|
+
const proxy$1 = proxy.reactive(cache, {
|
|
1457
|
+
get(_, prop) {
|
|
1458
|
+
return get(prop);
|
|
1459
|
+
},
|
|
1460
|
+
has(_, prop) {
|
|
1461
|
+
return prop in source;
|
|
1462
|
+
},
|
|
1463
|
+
ownKeys() {
|
|
1464
|
+
return Reflect.ownKeys(source);
|
|
1465
|
+
},
|
|
1466
|
+
getOwnPropertyDescriptor(_cache, prop) {
|
|
1467
|
+
if (prop in source)
|
|
1468
|
+
return { configurable: true, enumerable: true, get: () => get(prop) };
|
|
1469
|
+
},
|
|
1470
|
+
});
|
|
1471
|
+
let stateSnapshot = proxy.getState(source);
|
|
1472
|
+
const stopMain = proxy.effect.named('morph:record')(({ ascend }) => {
|
|
1473
|
+
track = ascend;
|
|
1474
|
+
// Track only structural changes on source
|
|
1475
|
+
proxy.dependant(source, proxy.keysOf);
|
|
1476
|
+
while ('evolution' in stateSnapshot) {
|
|
1477
|
+
const { evolution } = stateSnapshot;
|
|
1478
|
+
stateSnapshot = stateSnapshot.next;
|
|
1479
|
+
if (evolution.type === 'add') {
|
|
1480
|
+
proxy.touched1(cache, evolution, evolution.prop);
|
|
1481
|
+
}
|
|
1482
|
+
else if (evolution.type === 'del') {
|
|
1483
|
+
stopItem(evolution.prop);
|
|
1484
|
+
delete cache[evolution.prop];
|
|
1485
|
+
proxy.touched1(cache, evolution, evolution.prop);
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1488
|
+
});
|
|
1489
|
+
return proxy.cleanedBy(proxy$1, (reason) => {
|
|
1490
|
+
stopMain(reason);
|
|
1491
|
+
for (const stop of itemEffects.values())
|
|
1492
|
+
stop(reason);
|
|
1493
|
+
itemEffects.clear();
|
|
1494
|
+
});
|
|
959
1495
|
}
|
|
1496
|
+
/**
|
|
1497
|
+
* Reactively maps a collection (array, Map, or record) through a per-entry function.
|
|
1498
|
+
*
|
|
1499
|
+
* Each entry in the source gets its own reactive context — when only one entry's dependencies
|
|
1500
|
+
* change, only that entry's projection recomputes. Structural changes (additions, removals,
|
|
1501
|
+
* reorders) are detected via diffing and applied surgically.
|
|
1502
|
+
*
|
|
1503
|
+
* Use `morph.pure(source, fn)` when `fn` has no reactive reads (skips per-item effects).
|
|
1504
|
+
*
|
|
1505
|
+
* @example
|
|
1506
|
+
* ```ts
|
|
1507
|
+
* const users = reactive([{ name: 'John' }, { name: 'Jane' }])
|
|
1508
|
+
* const names = morph(users, u => u.name.toUpperCase())
|
|
1509
|
+
* // names[0] = 'JOHN', names[1] = 'JANE'
|
|
1510
|
+
* // Changing users[0].name only recomputes names[0]
|
|
1511
|
+
* ```
|
|
1512
|
+
*/
|
|
1513
|
+
const morph = proxy.flavored(function morph(source, fn, options) {
|
|
1514
|
+
if (Array.isArray(source) || typeof source === 'function')
|
|
1515
|
+
return morphArray(source, fn, options);
|
|
1516
|
+
if (source instanceof Map)
|
|
1517
|
+
return morphMap(source, fn, options);
|
|
1518
|
+
return morphRecord(source, fn, options);
|
|
1519
|
+
}, {
|
|
1520
|
+
get pure() {
|
|
1521
|
+
return (source, fn, _opt) => this(source, fn, { pure: true });
|
|
1522
|
+
},
|
|
1523
|
+
});
|
|
1524
|
+
|
|
960
1525
|
/**
|
|
961
1526
|
* Deep watch an object and all its nested properties
|
|
962
1527
|
* @param target - The object to watch deeply
|
|
@@ -977,16 +1542,17 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
977
1542
|
if (typeof target !== 'object')
|
|
978
1543
|
throw new Error('Target of deep watching must be an object');
|
|
979
1544
|
// Create a wrapper callback that matches EffectTrigger signature
|
|
980
|
-
const wrappedCallback =
|
|
1545
|
+
const wrappedCallback = proxy.markWithRoot((() => callback(target)), callback);
|
|
1546
|
+
proxy.registerDeepWatcher();
|
|
981
1547
|
// Use the existing effect system to register dependencies
|
|
982
|
-
return
|
|
1548
|
+
return proxy.effect(() => {
|
|
983
1549
|
// Mark the target object as having deep watchers
|
|
984
|
-
|
|
1550
|
+
proxy.objectsWithDeepWatchers.add(target);
|
|
985
1551
|
// Track which objects this effect is watching for cleanup
|
|
986
|
-
let effectObjects =
|
|
1552
|
+
let effectObjects = proxy.effectToDeepWatchedObjects.get(wrappedCallback);
|
|
987
1553
|
if (!effectObjects) {
|
|
988
1554
|
effectObjects = new Set();
|
|
989
|
-
|
|
1555
|
+
proxy.effectToDeepWatchedObjects.set(wrappedCallback, effectObjects);
|
|
990
1556
|
}
|
|
991
1557
|
effectObjects.add(target);
|
|
992
1558
|
// Traverse the object graph and register dependencies
|
|
@@ -994,23 +1560,23 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
994
1560
|
const visited = new WeakSet();
|
|
995
1561
|
function traverseAndTrack(obj, depth = 0) {
|
|
996
1562
|
// Prevent infinite recursion and excessive depth
|
|
997
|
-
if (!obj || visited.has(obj) ||
|
|
1563
|
+
if (!obj || visited.has(obj) || typeof obj !== 'object' || depth > proxy.options.maxDeepWatchDepth)
|
|
998
1564
|
return;
|
|
999
1565
|
// Do not traverse into unreactive objects
|
|
1000
|
-
if (
|
|
1566
|
+
if (proxy.isNonReactive(obj))
|
|
1001
1567
|
return;
|
|
1002
1568
|
visited.add(obj);
|
|
1003
1569
|
// Mark this object as having deep watchers
|
|
1004
|
-
|
|
1570
|
+
proxy.objectsWithDeepWatchers.add(obj);
|
|
1005
1571
|
effectObjects.add(obj);
|
|
1006
1572
|
// Traverse all properties to register dependencies
|
|
1007
1573
|
// unwrap to avoid kicking dependency
|
|
1008
|
-
for (const key in
|
|
1574
|
+
for (const key in proxy.unwrap(obj)) {
|
|
1009
1575
|
if (Object.hasOwn(obj, key)) {
|
|
1010
1576
|
// Access the property to register dependency
|
|
1011
1577
|
const value = obj[key];
|
|
1012
1578
|
// Make the value reactive if it's an object
|
|
1013
|
-
const reactiveValue = typeof value === 'object' && value !== null ?
|
|
1579
|
+
const reactiveValue = typeof value === 'object' && value !== null ? proxy.reactive(value) : value;
|
|
1014
1580
|
traverseAndTrack(reactiveValue, depth + 1);
|
|
1015
1581
|
}
|
|
1016
1582
|
}
|
|
@@ -1024,7 +1590,7 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
1024
1590
|
// Access the array element to register dependency
|
|
1025
1591
|
const value = obj[i];
|
|
1026
1592
|
// Make the value reactive if it's an object
|
|
1027
|
-
const reactiveValue = typeof value === 'object' && value !== null ?
|
|
1593
|
+
const reactiveValue = typeof value === 'object' && value !== null ? proxy.reactive(value) : value;
|
|
1028
1594
|
traverseAndTrack(reactiveValue, depth + 1);
|
|
1029
1595
|
}
|
|
1030
1596
|
}
|
|
@@ -1033,7 +1599,7 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
1033
1599
|
// Access all Set values to register dependencies
|
|
1034
1600
|
for (const value of obj) {
|
|
1035
1601
|
// Make the value reactive if it's an object
|
|
1036
|
-
const reactiveValue = typeof value === 'object' && value !== null ?
|
|
1602
|
+
const reactiveValue = typeof value === 'object' && value !== null ? proxy.reactive(value) : value;
|
|
1037
1603
|
traverseAndTrack(reactiveValue, depth + 1);
|
|
1038
1604
|
}
|
|
1039
1605
|
}
|
|
@@ -1042,7 +1608,7 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
1042
1608
|
// Access all Map values to register dependencies
|
|
1043
1609
|
for (const [_key, value] of obj) {
|
|
1044
1610
|
// Make the value reactive if it's an object
|
|
1045
|
-
const reactiveValue = typeof value === 'object' && value !== null ?
|
|
1611
|
+
const reactiveValue = typeof value === 'object' && value !== null ? proxy.reactive(value) : value;
|
|
1046
1612
|
traverseAndTrack(reactiveValue, depth + 1);
|
|
1047
1613
|
}
|
|
1048
1614
|
}
|
|
@@ -1053,64 +1619,138 @@ function deepWatch(target, callback, { immediate = false } = {}) {
|
|
|
1053
1619
|
// This will register dependencies on all current properties and array elements
|
|
1054
1620
|
traverseAndTrack(target);
|
|
1055
1621
|
// Only call the callback if immediate is true or if it's not the first run
|
|
1056
|
-
if (immediate)
|
|
1057
|
-
callback(target);
|
|
1622
|
+
if (immediate) {
|
|
1623
|
+
proxy.untracked(() => callback(target));
|
|
1624
|
+
}
|
|
1058
1625
|
immediate = true;
|
|
1059
1626
|
// Return a cleanup function that properly removes deep watcher tracking
|
|
1060
1627
|
return () => {
|
|
1061
1628
|
// Get the objects this effect was watching
|
|
1062
|
-
const effectObjects =
|
|
1629
|
+
const effectObjects = proxy.effectToDeepWatchedObjects.get(wrappedCallback);
|
|
1063
1630
|
if (effectObjects) {
|
|
1064
1631
|
// Remove deep watcher tracking from all objects this effect was watching
|
|
1065
1632
|
for (const obj of effectObjects) {
|
|
1066
1633
|
// Check if this object still has other deep watchers
|
|
1067
|
-
const watchers =
|
|
1634
|
+
const watchers = proxy.deepWatchers.get(obj);
|
|
1068
1635
|
if (watchers) {
|
|
1069
1636
|
// Remove this effect's callback from the watchers
|
|
1070
1637
|
watchers.delete(wrappedCallback);
|
|
1071
1638
|
// If no more watchers, remove the object from deep watchers tracking
|
|
1072
1639
|
if (watchers.size === 0) {
|
|
1073
|
-
|
|
1074
|
-
|
|
1640
|
+
proxy.deepWatchers.delete(obj);
|
|
1641
|
+
proxy.objectsWithDeepWatchers.delete(obj);
|
|
1075
1642
|
}
|
|
1076
1643
|
}
|
|
1077
1644
|
else {
|
|
1078
1645
|
// No watchers found, remove from deep watchers tracking
|
|
1079
|
-
|
|
1646
|
+
proxy.objectsWithDeepWatchers.delete(obj);
|
|
1080
1647
|
}
|
|
1081
1648
|
}
|
|
1082
1649
|
// Clean up the tracking data
|
|
1083
|
-
|
|
1650
|
+
proxy.effectToDeepWatchedObjects.delete(wrappedCallback);
|
|
1084
1651
|
}
|
|
1085
1652
|
};
|
|
1086
1653
|
});
|
|
1087
1654
|
}
|
|
1088
1655
|
|
|
1089
1656
|
/**
|
|
1090
|
-
*
|
|
1657
|
+
* Organizes a source object's properties into a target object using a callback function.
|
|
1658
|
+
* This creates a reactive mapping between source properties and a target object,
|
|
1659
|
+
* automatically handling property additions, updates, and removals.
|
|
1660
|
+
*
|
|
1661
|
+
* @template Source - The type of the source object
|
|
1662
|
+
* @template Target - The type of the target object (defaults to Record<PropertyKey, any>)
|
|
1663
|
+
*
|
|
1664
|
+
* @param {Source} source - The source object to organize
|
|
1665
|
+
* @param {OrganizedCallback<Source, Target>} apply - Callback function that defines how each source property is mapped to the target
|
|
1666
|
+
* @param {Target} [baseTarget={}] - Optional base target object to use (will be made reactive if not already)
|
|
1667
|
+
*
|
|
1668
|
+
* @returns {OrganizedResult<Target>} The target object with cleanup capability
|
|
1669
|
+
*
|
|
1670
|
+
* @example
|
|
1671
|
+
* // Organize user permissions into role-based access
|
|
1672
|
+
* const user = reactive({ isAdmin: true, canEdit: false });
|
|
1673
|
+
* const permissions = organized(
|
|
1674
|
+
* user,
|
|
1675
|
+
* (access, target) => {
|
|
1676
|
+
* if (access.key === 'isAdmin') {
|
|
1677
|
+
* target.hasFullAccess = access.value;
|
|
1678
|
+
* }
|
|
1679
|
+
* target[`can${access.key.charAt(0).toUpperCase() + access.key.slice(1)}`] = access.value;
|
|
1680
|
+
* }
|
|
1681
|
+
* );
|
|
1682
|
+
*
|
|
1683
|
+
* @example
|
|
1684
|
+
* // Transform object structure with cleanup
|
|
1685
|
+
* const source = reactive({ firstName: 'John', lastName: 'Doe' });
|
|
1686
|
+
* const formatted = organized(
|
|
1687
|
+
* source,
|
|
1688
|
+
* (access, target) => {
|
|
1689
|
+
* if (access.key === 'firstName' || access.key === 'lastName') {
|
|
1690
|
+
* target.fullName = `${source.firstName} ${source.lastName}`.trim();
|
|
1691
|
+
* }
|
|
1692
|
+
* }
|
|
1693
|
+
* );
|
|
1694
|
+
*
|
|
1695
|
+
* @example
|
|
1696
|
+
* // Using with cleanup in a component
|
|
1697
|
+
* effect(() => {
|
|
1698
|
+
* const data = fetchData();
|
|
1699
|
+
* const organizedData = organized(data, (access, target) => {
|
|
1700
|
+
* // Transform data
|
|
1701
|
+
* });
|
|
1702
|
+
*
|
|
1703
|
+
* // The cleanup will be called automatically when the effect is disposed
|
|
1704
|
+
* return () => organizedData[cleanup]();
|
|
1705
|
+
* });
|
|
1091
1706
|
*/
|
|
1092
|
-
function
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1707
|
+
function organized(source, apply, baseTarget = {}) {
|
|
1708
|
+
const observedSource = proxy.reactive(source);
|
|
1709
|
+
const target = proxy.reactive(baseTarget);
|
|
1710
|
+
const stop = attend(() => {
|
|
1711
|
+
const keys = [];
|
|
1712
|
+
for (const key in observedSource)
|
|
1713
|
+
keys.push(key);
|
|
1714
|
+
return keys;
|
|
1715
|
+
}, (key) => {
|
|
1716
|
+
const sourceKey = key;
|
|
1717
|
+
const accessBase = {
|
|
1718
|
+
key: sourceKey,
|
|
1719
|
+
get: () => proxy.FoolProof.get(observedSource, sourceKey, observedSource),
|
|
1720
|
+
set: (value) => proxy.FoolProof.set(observedSource, sourceKey, value, observedSource),
|
|
1721
|
+
};
|
|
1722
|
+
Object.defineProperty(accessBase, 'value', {
|
|
1723
|
+
get: accessBase.get,
|
|
1724
|
+
set: accessBase.set,
|
|
1725
|
+
configurable: true,
|
|
1726
|
+
enumerable: true,
|
|
1727
|
+
});
|
|
1728
|
+
return apply(accessBase, target);
|
|
1729
|
+
});
|
|
1730
|
+
return proxy.cleanedBy(target, (reason) => stop(reason));
|
|
1098
1731
|
}
|
|
1099
1732
|
/**
|
|
1100
|
-
*
|
|
1733
|
+
* Organizes a property on a target object
|
|
1734
|
+
* Shortcut for defineProperty/delete with touched signal
|
|
1735
|
+
* @param target - The target object
|
|
1736
|
+
* @param property - The property to organize
|
|
1737
|
+
* @param access - The access object
|
|
1738
|
+
* @returns The property descriptor
|
|
1101
1739
|
*/
|
|
1102
|
-
function
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
}
|
|
1740
|
+
function organize(target, property, access) {
|
|
1741
|
+
Object.defineProperty(target, property, {
|
|
1742
|
+
get: access.get,
|
|
1743
|
+
set: access.set,
|
|
1744
|
+
configurable: true,
|
|
1745
|
+
enumerable: true,
|
|
1746
|
+
});
|
|
1747
|
+
proxy.touched1(target, { type: 'set', prop: property }, property);
|
|
1748
|
+
return () => delete target[property];
|
|
1109
1749
|
}
|
|
1110
1750
|
|
|
1111
1751
|
//#region watch
|
|
1112
1752
|
const unsetYet = Symbol('unset-yet');
|
|
1113
|
-
function watch(value, //object | ((dep: DependencyAccess) => object),
|
|
1753
|
+
const watch = proxy.flavored(function watch(value, //object | ((dep: DependencyAccess) => object),
|
|
1114
1754
|
changed, options = {}) {
|
|
1115
1755
|
return typeof value === 'function'
|
|
1116
1756
|
? watchCallBack(value, changed, options)
|
|
@@ -1119,12 +1759,19 @@ changed, options = {}) {
|
|
|
1119
1759
|
: (() => {
|
|
1120
1760
|
throw new Error('watch: value must be a function or an object');
|
|
1121
1761
|
})();
|
|
1122
|
-
}
|
|
1762
|
+
}, {
|
|
1763
|
+
get deep() {
|
|
1764
|
+
return proxy.flavorOptions(this, { deep: true });
|
|
1765
|
+
},
|
|
1766
|
+
get immediate() {
|
|
1767
|
+
return proxy.flavorOptions(this, { immediate: true });
|
|
1768
|
+
},
|
|
1769
|
+
});
|
|
1123
1770
|
function watchObject(value, changed, { immediate = false, deep = false } = {}) {
|
|
1124
1771
|
if (deep)
|
|
1125
1772
|
return deepWatch(value, changed, { immediate });
|
|
1126
|
-
return
|
|
1127
|
-
|
|
1773
|
+
return proxy.effect(function watchObjectEffect() {
|
|
1774
|
+
proxy.dependant(value);
|
|
1128
1775
|
if (immediate)
|
|
1129
1776
|
changed(value);
|
|
1130
1777
|
immediate = true;
|
|
@@ -1133,15 +1780,17 @@ function watchObject(value, changed, { immediate = false, deep = false } = {}) {
|
|
|
1133
1780
|
function watchCallBack(value, changed, { immediate = false, deep = false } = {}) {
|
|
1134
1781
|
let oldValue = unsetYet;
|
|
1135
1782
|
let deepCleanup;
|
|
1136
|
-
const cbCleanup =
|
|
1783
|
+
const cbCleanup = proxy.effect(proxy.markWithRoot(function watchCallBackEffect(access) {
|
|
1137
1784
|
const newValue = value(access);
|
|
1138
|
-
if (oldValue !== newValue)
|
|
1139
|
-
|
|
1785
|
+
if (oldValue !== newValue) {
|
|
1786
|
+
const old = oldValue;
|
|
1787
|
+
if (old === unsetYet) {
|
|
1140
1788
|
if (immediate)
|
|
1141
|
-
changed(newValue);
|
|
1789
|
+
proxy.untracked(() => changed(newValue));
|
|
1142
1790
|
}
|
|
1143
1791
|
else
|
|
1144
|
-
changed(newValue,
|
|
1792
|
+
proxy.untracked(() => changed(newValue, old));
|
|
1793
|
+
}
|
|
1145
1794
|
oldValue = newValue;
|
|
1146
1795
|
if (deep) {
|
|
1147
1796
|
if (deepCleanup)
|
|
@@ -1154,7 +1803,46 @@ function watchCallBack(value, changed, { immediate = false, deep = false } = {})
|
|
|
1154
1803
|
if (deepCleanup)
|
|
1155
1804
|
deepCleanup();
|
|
1156
1805
|
}, {
|
|
1157
|
-
[
|
|
1806
|
+
[proxy.stopped]: { get: () => cbCleanup[proxy.stopped] },
|
|
1807
|
+
});
|
|
1808
|
+
}
|
|
1809
|
+
//#endregion
|
|
1810
|
+
//#region when
|
|
1811
|
+
/**
|
|
1812
|
+
* Returns a promise that resolves when the predicate returns a truthy value.
|
|
1813
|
+
* The predicate is evaluated reactively — it re-runs whenever its dependencies change.
|
|
1814
|
+
* @param predicate - Reactive function that returns a value; resolves when truthy
|
|
1815
|
+
* @param timeout - Optional timeout in milliseconds — rejects if condition is not met within this duration
|
|
1816
|
+
* @returns Promise that resolves with the first truthy return value
|
|
1817
|
+
*/
|
|
1818
|
+
function when(predicate, timeout) {
|
|
1819
|
+
return new Promise((resolve, reject) => {
|
|
1820
|
+
let timer;
|
|
1821
|
+
const stop = proxy.effect(function whenEffect(access) {
|
|
1822
|
+
try {
|
|
1823
|
+
const value = predicate(access);
|
|
1824
|
+
if (value) {
|
|
1825
|
+
if (timer !== undefined)
|
|
1826
|
+
clearTimeout(timer);
|
|
1827
|
+
timer = undefined;
|
|
1828
|
+
queueMicrotask(() => stop());
|
|
1829
|
+
resolve(value);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
catch (error) {
|
|
1833
|
+
if (timer !== undefined)
|
|
1834
|
+
clearTimeout(timer);
|
|
1835
|
+
timer = undefined;
|
|
1836
|
+
reject(error);
|
|
1837
|
+
}
|
|
1838
|
+
});
|
|
1839
|
+
if (timeout !== undefined) {
|
|
1840
|
+
timer = setTimeout(() => {
|
|
1841
|
+
stop();
|
|
1842
|
+
timer = undefined;
|
|
1843
|
+
reject(new Error(`when: timed out after ${timeout}ms`));
|
|
1844
|
+
}, timeout);
|
|
1845
|
+
}
|
|
1158
1846
|
});
|
|
1159
1847
|
}
|
|
1160
1848
|
//#endregion
|
|
@@ -1164,22 +1852,10 @@ function watchCallBack(value, changed, { immediate = false, deep = false } = {})
|
|
|
1164
1852
|
* @param obj - The object to mark as non-reactive
|
|
1165
1853
|
*/
|
|
1166
1854
|
function shallowNonReactive(obj) {
|
|
1167
|
-
obj =
|
|
1168
|
-
if (
|
|
1855
|
+
obj = proxy.unwrap(obj);
|
|
1856
|
+
if (proxy.isNonReactive(obj))
|
|
1169
1857
|
return obj;
|
|
1170
|
-
|
|
1171
|
-
Object.defineProperty(obj, debug.nonReactiveMark, {
|
|
1172
|
-
value: true,
|
|
1173
|
-
writable: false,
|
|
1174
|
-
enumerable: false,
|
|
1175
|
-
configurable: true,
|
|
1176
|
-
});
|
|
1177
|
-
}
|
|
1178
|
-
catch { }
|
|
1179
|
-
if (!(debug.nonReactiveMark in obj))
|
|
1180
|
-
debug.nonReactiveObjects.add(obj);
|
|
1181
|
-
// Finally, not deep
|
|
1182
|
-
//for (const key in obj) deepNonReactive(obj[key])
|
|
1858
|
+
proxy.nonReactiveObjects.add(obj);
|
|
1183
1859
|
return obj;
|
|
1184
1860
|
}
|
|
1185
1861
|
function unreactiveApplication(arg1, ...args) {
|
|
@@ -1187,11 +1863,13 @@ function unreactiveApplication(arg1, ...args) {
|
|
|
1187
1863
|
? shallowNonReactive(arg1)
|
|
1188
1864
|
: ((original) => {
|
|
1189
1865
|
// Copy the parent's unreactive properties if they exist
|
|
1190
|
-
|
|
1866
|
+
const parentSet = proxy.unreactiveProps.get(original.prototype);
|
|
1867
|
+
const set = new Set(parentSet || []);
|
|
1191
1868
|
// Add all arguments (including the first one)
|
|
1192
|
-
|
|
1869
|
+
set.add(arg1);
|
|
1193
1870
|
for (const arg of args)
|
|
1194
|
-
|
|
1871
|
+
set.add(arg);
|
|
1872
|
+
proxy.addUnreactiveProps(original.prototype, set);
|
|
1195
1873
|
return original; // Return the class
|
|
1196
1874
|
});
|
|
1197
1875
|
}
|
|
@@ -1199,13 +1877,67 @@ function unreactiveApplication(arg1, ...args) {
|
|
|
1199
1877
|
* Decorator that marks classes or properties as non-reactive
|
|
1200
1878
|
* Prevents objects from being made reactive
|
|
1201
1879
|
*/
|
|
1202
|
-
const unreactive =
|
|
1880
|
+
const unreactive = proxy.decorator({
|
|
1203
1881
|
class(original) {
|
|
1204
1882
|
// Called without arguments, mark entire class as non-reactive
|
|
1205
|
-
|
|
1883
|
+
proxy.nonReactiveClass(original);
|
|
1206
1884
|
},
|
|
1207
1885
|
default: unreactiveApplication,
|
|
1208
1886
|
});
|
|
1887
|
+
/**
|
|
1888
|
+
* Creates a reactive resource that automatically tracks async state.
|
|
1889
|
+
* @param fetcher - Async function that returns the value. Reactive dependencies are tracked.
|
|
1890
|
+
* @param options - Resource options (initialValue)
|
|
1891
|
+
* @returns Reactive Resource object with value, loading, error, latest properties
|
|
1892
|
+
*/
|
|
1893
|
+
function resource(fetcher, options = {}) {
|
|
1894
|
+
const state = proxy.reactive({
|
|
1895
|
+
value: options.initialValue,
|
|
1896
|
+
loading: true,
|
|
1897
|
+
error: undefined,
|
|
1898
|
+
latest: options.initialValue,
|
|
1899
|
+
reload: () => {
|
|
1900
|
+
reloadSignal.value++;
|
|
1901
|
+
},
|
|
1902
|
+
});
|
|
1903
|
+
const reloadSignal = proxy.reactive({ value: 0 });
|
|
1904
|
+
let counter = 0;
|
|
1905
|
+
const stop = proxy.effect(function resourceEffect(access) {
|
|
1906
|
+
// Track reload signal to enable manual reloading
|
|
1907
|
+
if (reloadSignal.value) ;
|
|
1908
|
+
const id = ++counter;
|
|
1909
|
+
state.loading = true;
|
|
1910
|
+
state.error = undefined;
|
|
1911
|
+
try {
|
|
1912
|
+
const result = fetcher(access);
|
|
1913
|
+
if (result instanceof Promise) {
|
|
1914
|
+
result.then((val) => {
|
|
1915
|
+
if (id === counter) {
|
|
1916
|
+
state.value = val;
|
|
1917
|
+
state.latest = val;
|
|
1918
|
+
state.loading = false;
|
|
1919
|
+
}
|
|
1920
|
+
}, (err) => {
|
|
1921
|
+
if (id === counter) {
|
|
1922
|
+
state.error = err;
|
|
1923
|
+
state.loading = false;
|
|
1924
|
+
}
|
|
1925
|
+
});
|
|
1926
|
+
}
|
|
1927
|
+
else {
|
|
1928
|
+
state.value = result;
|
|
1929
|
+
state.latest = result;
|
|
1930
|
+
state.loading = false;
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
catch (err) {
|
|
1934
|
+
state.error = err;
|
|
1935
|
+
state.loading = false;
|
|
1936
|
+
}
|
|
1937
|
+
});
|
|
1938
|
+
state.stop = stop;
|
|
1939
|
+
return state;
|
|
1940
|
+
}
|
|
1209
1941
|
//#endregion
|
|
1210
1942
|
|
|
1211
1943
|
// Helper to work around TypeScript limitation: base class expressions cannot reference class type parameters
|
|
@@ -1243,17 +1975,17 @@ let RegisterClass = (() => {
|
|
|
1243
1975
|
}
|
|
1244
1976
|
on(eventOrEvents, cb) {
|
|
1245
1977
|
// @ts-expect-error Delegate to Eventful
|
|
1246
|
-
return
|
|
1978
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").on(eventOrEvents, cb);
|
|
1247
1979
|
}
|
|
1248
1980
|
off(eventOrEvents, cb) {
|
|
1249
1981
|
// @ts-expect-error Delegate to Eventful
|
|
1250
|
-
|
|
1982
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").off(eventOrEvents, cb);
|
|
1251
1983
|
}
|
|
1252
1984
|
/**
|
|
1253
1985
|
* Register a global hook that receives all events
|
|
1254
1986
|
*/
|
|
1255
1987
|
hook(cb) {
|
|
1256
|
-
return
|
|
1988
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").hook(cb);
|
|
1257
1989
|
}
|
|
1258
1990
|
constructor(keyFn, initial) {
|
|
1259
1991
|
super();
|
|
@@ -1272,35 +2004,35 @@ let RegisterClass = (() => {
|
|
|
1272
2004
|
);
|
|
1273
2005
|
/* Moved below initialization */
|
|
1274
2006
|
let ascendGet;
|
|
1275
|
-
|
|
2007
|
+
proxy.effect(({ ascend }) => {
|
|
1276
2008
|
ascendGet = ascend;
|
|
1277
2009
|
});
|
|
1278
|
-
|
|
2010
|
+
proxy.__classPrivateFieldSet(this, _RegisterClass_ascend, ascendGet, "f");
|
|
1279
2011
|
if (typeof keyFn !== 'function')
|
|
1280
2012
|
throw new Error('Register requires a key function');
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
2013
|
+
proxy.__classPrivateFieldSet(this, _RegisterClass_keyFn, keyFn, "f");
|
|
2014
|
+
proxy.__classPrivateFieldSet(this, _RegisterClass_keys, proxy.reactive([]), "f");
|
|
2015
|
+
proxy.__classPrivateFieldSet(this, _RegisterClass_values, proxy.reactive(new Map()), "f");
|
|
1284
2016
|
if (initial)
|
|
1285
2017
|
this.push(...initial);
|
|
1286
2018
|
}
|
|
1287
2019
|
ensureKey(value) {
|
|
1288
|
-
let info =
|
|
2020
|
+
let info = proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").get(value);
|
|
1289
2021
|
if (info)
|
|
1290
2022
|
return info.key;
|
|
1291
2023
|
info = { key: undefined };
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
const stop =
|
|
1295
|
-
const nextKey =
|
|
2024
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").set(value, info);
|
|
2025
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_ascend, "f").call(this, () => {
|
|
2026
|
+
const stop = proxy.effect(({ reaction }) => {
|
|
2027
|
+
const nextKey = proxy.__classPrivateFieldGet(this, _RegisterClass_keyFn, "f").call(this, value);
|
|
1296
2028
|
this.assertValidKey(nextKey);
|
|
1297
2029
|
const previousKey = info.key;
|
|
1298
2030
|
if (reaction && previousKey !== undefined && !Object.is(nextKey, previousKey))
|
|
1299
|
-
|
|
2031
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_instances, "m", _RegisterClass_rekeyValue).call(this, value, previousKey, nextKey);
|
|
1300
2032
|
info.key = nextKey;
|
|
1301
2033
|
});
|
|
1302
2034
|
info.stop = stop;
|
|
1303
|
-
|
|
2035
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keyEffects, "f").add(stop);
|
|
1304
2036
|
});
|
|
1305
2037
|
if (info.key === undefined)
|
|
1306
2038
|
throw new Error('Register key function must return a property key');
|
|
@@ -1312,55 +2044,55 @@ let RegisterClass = (() => {
|
|
|
1312
2044
|
throw new Error('Register key function must return a property key');
|
|
1313
2045
|
}
|
|
1314
2046
|
setKeyValue(key, value, index) {
|
|
1315
|
-
const existing =
|
|
2047
|
+
const existing = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1316
2048
|
if (existing !== undefined && existing !== value) {
|
|
1317
2049
|
this.cleanupValue(existing);
|
|
1318
|
-
|
|
2050
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").set(key, value);
|
|
1319
2051
|
if (index !== undefined) {
|
|
1320
|
-
|
|
2052
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('update', existing, value, key, index);
|
|
1321
2053
|
}
|
|
1322
2054
|
}
|
|
1323
2055
|
else {
|
|
1324
|
-
|
|
2056
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").set(key, value);
|
|
1325
2057
|
}
|
|
1326
2058
|
}
|
|
1327
2059
|
cleanupValue(value) {
|
|
1328
|
-
const info =
|
|
2060
|
+
const info = proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").get(value);
|
|
1329
2061
|
if (!info)
|
|
1330
2062
|
return;
|
|
1331
2063
|
const stop = info.stop;
|
|
1332
2064
|
if (stop) {
|
|
1333
2065
|
info.stop = undefined;
|
|
1334
|
-
|
|
2066
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keyEffects, "f").delete(stop);
|
|
1335
2067
|
stop();
|
|
1336
2068
|
}
|
|
1337
|
-
|
|
2069
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").delete(value);
|
|
1338
2070
|
}
|
|
1339
2071
|
disposeKeyEffects() {
|
|
1340
|
-
for (const value of Array.from(
|
|
2072
|
+
for (const value of Array.from(proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").keys()))
|
|
1341
2073
|
this.cleanupValue(value);
|
|
1342
|
-
|
|
2074
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keyEffects, "f").clear();
|
|
1343
2075
|
}
|
|
1344
2076
|
incrementUsage(key) {
|
|
1345
|
-
const count =
|
|
1346
|
-
|
|
2077
|
+
const count = proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").get(key) ?? 0;
|
|
2078
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").set(key, count + 1);
|
|
1347
2079
|
}
|
|
1348
2080
|
decrementUsage(key, index) {
|
|
1349
|
-
const count =
|
|
2081
|
+
const count = proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").get(key);
|
|
1350
2082
|
if (!count)
|
|
1351
2083
|
return;
|
|
1352
2084
|
if (count <= 1) {
|
|
1353
|
-
const value =
|
|
1354
|
-
|
|
1355
|
-
|
|
2085
|
+
const value = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
2086
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").delete(key);
|
|
2087
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").delete(key);
|
|
1356
2088
|
if (value !== undefined) {
|
|
1357
2089
|
this.cleanupValue(value);
|
|
1358
|
-
const idx = index ??
|
|
1359
|
-
|
|
2090
|
+
const idx = index ?? proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").indexOf(key);
|
|
2091
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('delete', value, key, idx);
|
|
1360
2092
|
}
|
|
1361
2093
|
}
|
|
1362
2094
|
else {
|
|
1363
|
-
|
|
2095
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").set(key, count - 1);
|
|
1364
2096
|
}
|
|
1365
2097
|
}
|
|
1366
2098
|
normalizeIndex(index, allowEnd = false) {
|
|
@@ -1379,73 +2111,73 @@ let RegisterClass = (() => {
|
|
|
1379
2111
|
return resolved;
|
|
1380
2112
|
}
|
|
1381
2113
|
assignAt(index, key, value) {
|
|
1382
|
-
const oldKey =
|
|
2114
|
+
const oldKey = proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f")[index];
|
|
1383
2115
|
if (oldKey !== undefined && Object.is(oldKey, key)) {
|
|
1384
|
-
const oldValue =
|
|
2116
|
+
const oldValue = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1385
2117
|
this.setKeyValue(key, value);
|
|
1386
2118
|
if (oldValue !== undefined && oldValue !== value) {
|
|
1387
|
-
|
|
2119
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('update', oldValue, value, key, index);
|
|
1388
2120
|
}
|
|
1389
2121
|
return;
|
|
1390
2122
|
}
|
|
1391
2123
|
if (oldKey !== undefined)
|
|
1392
2124
|
this.decrementUsage(oldKey);
|
|
1393
|
-
|
|
2125
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f")[index] = key;
|
|
1394
2126
|
this.incrementUsage(key);
|
|
1395
2127
|
this.setKeyValue(key, value);
|
|
1396
|
-
|
|
2128
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('add', value, key, index);
|
|
1397
2129
|
}
|
|
1398
2130
|
insertKeyValue(index, key, value) {
|
|
1399
|
-
|
|
2131
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").splice(index, 0, key);
|
|
1400
2132
|
this.incrementUsage(key);
|
|
1401
2133
|
this.setKeyValue(key, value);
|
|
1402
|
-
|
|
2134
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('add', value, key, index);
|
|
1403
2135
|
}
|
|
1404
2136
|
rebuildFrom(values) {
|
|
1405
2137
|
this.disposeKeyEffects();
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
2138
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").splice(0, proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").length);
|
|
2139
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").clear();
|
|
2140
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").clear();
|
|
1409
2141
|
for (const value of values) {
|
|
1410
2142
|
const key = this.ensureKey(value);
|
|
1411
|
-
|
|
2143
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").push(key);
|
|
1412
2144
|
this.incrementUsage(key);
|
|
1413
|
-
|
|
2145
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").set(key, value);
|
|
1414
2146
|
}
|
|
1415
2147
|
}
|
|
1416
2148
|
get length() {
|
|
1417
|
-
return
|
|
2149
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").length;
|
|
1418
2150
|
}
|
|
1419
2151
|
[(_RegisterClass_rekeyValue = function _RegisterClass_rekeyValue(value, oldKey, newKey) {
|
|
1420
2152
|
if (Object.is(oldKey, newKey))
|
|
1421
2153
|
return;
|
|
1422
|
-
const existingValue =
|
|
2154
|
+
const existingValue = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(newKey);
|
|
1423
2155
|
if (existingValue !== undefined && existingValue !== value)
|
|
1424
2156
|
throw new Error(`Register key collision for key ${String(newKey)}`);
|
|
1425
|
-
const count =
|
|
2157
|
+
const count = proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").get(oldKey);
|
|
1426
2158
|
if (!count)
|
|
1427
2159
|
return;
|
|
1428
|
-
const existingCount =
|
|
2160
|
+
const existingCount = proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").get(newKey) ?? 0;
|
|
1429
2161
|
this.setKeyValue(newKey, value);
|
|
1430
2162
|
let index = -1;
|
|
1431
|
-
for (let i = 0; i <
|
|
1432
|
-
if (Object.is(
|
|
1433
|
-
|
|
2163
|
+
for (let i = 0; i < proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").length; i++)
|
|
2164
|
+
if (Object.is(proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f")[i], oldKey)) {
|
|
2165
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f")[i] = newKey;
|
|
1434
2166
|
if (index === -1)
|
|
1435
2167
|
index = i;
|
|
1436
2168
|
}
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
const updatedInfo =
|
|
2169
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").set(newKey, existingCount + count);
|
|
2170
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").delete(oldKey);
|
|
2171
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").delete(oldKey);
|
|
2172
|
+
const updatedInfo = proxy.__classPrivateFieldGet(this, _RegisterClass_valueInfo, "f").get(value);
|
|
1441
2173
|
if (updatedInfo)
|
|
1442
2174
|
updatedInfo.key = newKey;
|
|
1443
2175
|
if (index !== -1) {
|
|
1444
|
-
|
|
2176
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_events, "f").emit('rekey', value, oldKey, newKey, index);
|
|
1445
2177
|
}
|
|
1446
2178
|
}, getAt)](index) {
|
|
1447
|
-
const key =
|
|
1448
|
-
return key === undefined ? undefined :
|
|
2179
|
+
const key = proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f")[index];
|
|
2180
|
+
return key === undefined ? undefined : proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1449
2181
|
}
|
|
1450
2182
|
[setAt](index, value) {
|
|
1451
2183
|
const key = this.ensureKey(value);
|
|
@@ -1488,13 +2220,13 @@ let RegisterClass = (() => {
|
|
|
1488
2220
|
const keysToInsert = [];
|
|
1489
2221
|
for (const item of items)
|
|
1490
2222
|
keysToInsert.push(this.ensureKey(item));
|
|
1491
|
-
const removedKeys =
|
|
2223
|
+
const removedKeys = proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").splice(normalizedStart, actualDelete, ...keysToInsert);
|
|
1492
2224
|
const removedValues = [];
|
|
1493
2225
|
for (let i = 0; i < removedKeys.length; i++) {
|
|
1494
2226
|
const key = removedKeys[i];
|
|
1495
2227
|
if (key === undefined)
|
|
1496
2228
|
continue;
|
|
1497
|
-
const value =
|
|
2229
|
+
const value = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1498
2230
|
this.decrementUsage(key, normalizedStart + i);
|
|
1499
2231
|
removedValues.push(value);
|
|
1500
2232
|
}
|
|
@@ -1507,16 +2239,16 @@ let RegisterClass = (() => {
|
|
|
1507
2239
|
return removedValues;
|
|
1508
2240
|
}
|
|
1509
2241
|
clear() {
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
2242
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").length = 0;
|
|
2243
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").clear();
|
|
2244
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").clear();
|
|
1513
2245
|
this.disposeKeyEffects();
|
|
1514
2246
|
}
|
|
1515
2247
|
get(key) {
|
|
1516
|
-
return
|
|
2248
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1517
2249
|
}
|
|
1518
2250
|
set(key, value) {
|
|
1519
|
-
if (
|
|
2251
|
+
if (proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").has(key))
|
|
1520
2252
|
this.setKeyValue(key, value);
|
|
1521
2253
|
}
|
|
1522
2254
|
remove(key) {
|
|
@@ -1527,10 +2259,10 @@ let RegisterClass = (() => {
|
|
|
1527
2259
|
}
|
|
1528
2260
|
}
|
|
1529
2261
|
removeAt(index) {
|
|
1530
|
-
const [key] =
|
|
2262
|
+
const [key] = proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").splice(index, 1);
|
|
1531
2263
|
if (key === undefined)
|
|
1532
2264
|
return undefined;
|
|
1533
|
-
const value =
|
|
2265
|
+
const value = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1534
2266
|
this.decrementUsage(key, index);
|
|
1535
2267
|
return value;
|
|
1536
2268
|
}
|
|
@@ -1543,13 +2275,13 @@ let RegisterClass = (() => {
|
|
|
1543
2275
|
*/
|
|
1544
2276
|
keep(predicate) {
|
|
1545
2277
|
const decisions = new Map();
|
|
1546
|
-
for (const [index, key] of
|
|
2278
|
+
for (const [index, key] of proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").entries()) {
|
|
1547
2279
|
if (decisions.has(key)) {
|
|
1548
2280
|
if (!decisions.get(key))
|
|
1549
2281
|
this.removeAt(index);
|
|
1550
2282
|
continue;
|
|
1551
2283
|
}
|
|
1552
|
-
const value =
|
|
2284
|
+
const value = proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(key);
|
|
1553
2285
|
const shouldKeep = predicate(value);
|
|
1554
2286
|
decisions.set(key, shouldKeep);
|
|
1555
2287
|
if (!shouldKeep)
|
|
@@ -1557,19 +2289,19 @@ let RegisterClass = (() => {
|
|
|
1557
2289
|
}
|
|
1558
2290
|
}
|
|
1559
2291
|
hasKey(key) {
|
|
1560
|
-
return
|
|
2292
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_usage, "f").has(key);
|
|
1561
2293
|
}
|
|
1562
2294
|
indexOfKey(key) {
|
|
1563
|
-
return
|
|
2295
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").indexOf(key);
|
|
1564
2296
|
}
|
|
1565
2297
|
mapKeys() {
|
|
1566
|
-
return
|
|
2298
|
+
return proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").keys();
|
|
1567
2299
|
}
|
|
1568
2300
|
update(...values) {
|
|
1569
2301
|
for (const value of values) {
|
|
1570
2302
|
const key = this.ensureKey(value);
|
|
1571
|
-
if (
|
|
1572
|
-
const index =
|
|
2303
|
+
if (proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").has(key)) {
|
|
2304
|
+
const index = proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").indexOf(key);
|
|
1573
2305
|
this.setKeyValue(key, value, index);
|
|
1574
2306
|
}
|
|
1575
2307
|
}
|
|
@@ -1577,7 +2309,7 @@ let RegisterClass = (() => {
|
|
|
1577
2309
|
upsert(insert, ...values) {
|
|
1578
2310
|
for (const value of values) {
|
|
1579
2311
|
const key = this.ensureKey(value);
|
|
1580
|
-
if (
|
|
2312
|
+
if (proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").has(key))
|
|
1581
2313
|
this.setKeyValue(key, value);
|
|
1582
2314
|
else
|
|
1583
2315
|
insert(value);
|
|
@@ -1586,8 +2318,8 @@ let RegisterClass = (() => {
|
|
|
1586
2318
|
entries() {
|
|
1587
2319
|
const self = this;
|
|
1588
2320
|
function* iterator() {
|
|
1589
|
-
for (let i = 0; i <
|
|
1590
|
-
const val =
|
|
2321
|
+
for (let i = 0; i < proxy.__classPrivateFieldGet(self, _RegisterClass_keys, "f").length; i++) {
|
|
2322
|
+
const val = proxy.__classPrivateFieldGet(self, _RegisterClass_values, "f").get(proxy.__classPrivateFieldGet(self, _RegisterClass_keys, "f")[i]);
|
|
1591
2323
|
if (val !== undefined)
|
|
1592
2324
|
yield [i, val];
|
|
1593
2325
|
}
|
|
@@ -1597,8 +2329,8 @@ let RegisterClass = (() => {
|
|
|
1597
2329
|
[Symbol.iterator]() {
|
|
1598
2330
|
const self = this;
|
|
1599
2331
|
function* iterator() {
|
|
1600
|
-
for (const key of
|
|
1601
|
-
const value =
|
|
2332
|
+
for (const key of proxy.__classPrivateFieldGet(self, _RegisterClass_keys, "f")) {
|
|
2333
|
+
const value = proxy.__classPrivateFieldGet(self, _RegisterClass_values, "f").get(key);
|
|
1602
2334
|
if (value !== undefined)
|
|
1603
2335
|
yield value;
|
|
1604
2336
|
}
|
|
@@ -1615,14 +2347,14 @@ let RegisterClass = (() => {
|
|
|
1615
2347
|
return this[getAt](resolved);
|
|
1616
2348
|
}
|
|
1617
2349
|
reverse() {
|
|
1618
|
-
|
|
2350
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").reverse();
|
|
1619
2351
|
return this;
|
|
1620
2352
|
}
|
|
1621
2353
|
sort(compareFn) {
|
|
1622
2354
|
const fwdCompareFn = compareFn
|
|
1623
|
-
? (a, b) => compareFn(
|
|
2355
|
+
? (a, b) => compareFn(proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(a), proxy.__classPrivateFieldGet(this, _RegisterClass_values, "f").get(b))
|
|
1624
2356
|
: undefined;
|
|
1625
|
-
|
|
2357
|
+
proxy.__classPrivateFieldGet(this, _RegisterClass_keys, "f").sort(fwdCompareFn);
|
|
1626
2358
|
return this;
|
|
1627
2359
|
}
|
|
1628
2360
|
fill(value, start = 0, end = this.length) {
|
|
@@ -1638,13 +2370,13 @@ let RegisterClass = (() => {
|
|
|
1638
2370
|
return this;
|
|
1639
2371
|
}
|
|
1640
2372
|
};
|
|
1641
|
-
|
|
2373
|
+
proxy.__setFunctionName(_classThis, "RegisterClass");
|
|
1642
2374
|
(() => {
|
|
1643
2375
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
1644
|
-
|
|
2376
|
+
proxy.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
1645
2377
|
_classThis = _classDescriptor.value;
|
|
1646
2378
|
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
1647
|
-
|
|
2379
|
+
proxy.__runInitializers(_classThis, _classExtraInitializers);
|
|
1648
2380
|
})();
|
|
1649
2381
|
return _classThis;
|
|
1650
2382
|
})();
|
|
@@ -1676,410 +2408,25 @@ function register(keyFn, initial) {
|
|
|
1676
2408
|
}
|
|
1677
2409
|
|
|
1678
2410
|
/**
|
|
1679
|
-
*
|
|
1680
|
-
*/
|
|
1681
|
-
const effectProjectionMetadata = new WeakMap();
|
|
1682
|
-
/**
|
|
1683
|
-
* Returns the projection context of the currently running effect, if any.
|
|
2411
|
+
* Converts an iterator to a generator that yields reactive values
|
|
1684
2412
|
*/
|
|
1685
|
-
function
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
const active = debug.getActiveEffect();
|
|
1691
|
-
if (active)
|
|
1692
|
-
effectProjectionMetadata.set(active, projection);
|
|
1693
|
-
}
|
|
1694
|
-
function defineAccessValue(access) {
|
|
1695
|
-
Object.defineProperty(access, 'value', {
|
|
1696
|
-
get: access.get,
|
|
1697
|
-
set: access.set,
|
|
1698
|
-
configurable: true,
|
|
1699
|
-
enumerable: true,
|
|
1700
|
-
});
|
|
1701
|
-
}
|
|
1702
|
-
function makeCleanup(target, effectMap, onDispose, metadata) {
|
|
1703
|
-
if (metadata) {
|
|
1704
|
-
Object.defineProperty(target, debug.projectionInfo, {
|
|
1705
|
-
value: metadata,
|
|
1706
|
-
writable: false,
|
|
1707
|
-
enumerable: false,
|
|
1708
|
-
configurable: true,
|
|
1709
|
-
});
|
|
1710
|
-
}
|
|
1711
|
-
return debug.cleanedBy(target, () => {
|
|
1712
|
-
onDispose();
|
|
1713
|
-
for (const stop of effectMap.values())
|
|
1714
|
-
stop?.();
|
|
1715
|
-
effectMap.clear();
|
|
1716
|
-
});
|
|
1717
|
-
}
|
|
1718
|
-
function projectArray(source, apply) {
|
|
1719
|
-
source = debug.reactive(source);
|
|
1720
|
-
const target = debug.reactive([]);
|
|
1721
|
-
const indexEffects = new Map();
|
|
1722
|
-
function normalizeTargetLength(length) {
|
|
1723
|
-
debug.FoolProof.set(target, 'length', length, target);
|
|
1724
|
-
}
|
|
1725
|
-
function disposeIndex(index) {
|
|
1726
|
-
const stopEffect = indexEffects.get(index);
|
|
1727
|
-
if (stopEffect) {
|
|
1728
|
-
indexEffects.delete(index);
|
|
1729
|
-
stopEffect();
|
|
1730
|
-
Reflect.deleteProperty(target, index);
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
const parent = getActiveProjection();
|
|
1734
|
-
const depth = parent ? parent.depth + 1 : 0;
|
|
1735
|
-
const cleanupLength = debug.effect(debug.named(`project:${source[Symbol.toStringTag]}.length`, ({ ascend }) => {
|
|
1736
|
-
const length = source.length;
|
|
1737
|
-
normalizeTargetLength(length);
|
|
1738
|
-
const existing = Array.from(indexEffects.keys());
|
|
1739
|
-
for (let i = 0; i < length; i++) {
|
|
1740
|
-
if (indexEffects.has(i))
|
|
1741
|
-
continue;
|
|
1742
|
-
ascend(function projectArrayIndexAscend() {
|
|
1743
|
-
const index = i;
|
|
1744
|
-
const stop = debug.effect(debug.named(`project:${source[Symbol.toStringTag]}[${index}]`, ({ reaction }) => {
|
|
1745
|
-
if (!reaction)
|
|
1746
|
-
setActiveProjection({ source, key: index, target, depth, parent });
|
|
1747
|
-
const previous = debug.untracked(() => target[index]);
|
|
1748
|
-
const accessBase = {
|
|
1749
|
-
key: index,
|
|
1750
|
-
source,
|
|
1751
|
-
get: () => debug.FoolProof.get(source, index, source),
|
|
1752
|
-
set: (value) => debug.FoolProof.set(source, index, value, source),
|
|
1753
|
-
old: previous,
|
|
1754
|
-
};
|
|
1755
|
-
defineAccessValue(accessBase);
|
|
1756
|
-
target[index] = apply(accessBase, target);
|
|
1757
|
-
}));
|
|
1758
|
-
debug.setEffectName(stop, `project[${depth}]:${index}`);
|
|
1759
|
-
indexEffects.set(i, stop);
|
|
1760
|
-
});
|
|
1761
|
-
}
|
|
1762
|
-
for (const index of existing)
|
|
1763
|
-
if (index >= length)
|
|
1764
|
-
disposeIndex(index);
|
|
1765
|
-
}));
|
|
1766
|
-
return makeCleanup(target, indexEffects, () => cleanupLength(), {
|
|
1767
|
-
source,
|
|
1768
|
-
target,
|
|
1769
|
-
apply,
|
|
1770
|
-
depth,
|
|
1771
|
-
parent,
|
|
1772
|
-
});
|
|
1773
|
-
}
|
|
1774
|
-
function projectRegister(source, apply) {
|
|
1775
|
-
source = debug.reactive(source);
|
|
1776
|
-
const rawTarget = new Map();
|
|
1777
|
-
const target = debug.reactive(rawTarget);
|
|
1778
|
-
const keyEffects = new Map();
|
|
1779
|
-
function disposeKey(key) {
|
|
1780
|
-
const stopEffect = keyEffects.get(key);
|
|
1781
|
-
if (stopEffect) {
|
|
1782
|
-
stopEffect();
|
|
1783
|
-
keyEffects.delete(key);
|
|
1784
|
-
target.delete(key);
|
|
1785
|
-
}
|
|
1786
|
-
}
|
|
1787
|
-
const parent = getActiveProjection();
|
|
1788
|
-
const depth = parent ? parent.depth + 1 : 0;
|
|
1789
|
-
const cleanupKeys = debug.effect(function projectRegisterEffect({ ascend }) {
|
|
1790
|
-
const keys = new Set();
|
|
1791
|
-
for (const key of source.mapKeys())
|
|
1792
|
-
keys.add(key);
|
|
1793
|
-
for (const key of keys) {
|
|
1794
|
-
if (keyEffects.has(key))
|
|
1795
|
-
continue;
|
|
1796
|
-
ascend(() => {
|
|
1797
|
-
const stop = debug.effect(function projectRegisterKeyEffect({ reaction }) {
|
|
1798
|
-
if (!reaction)
|
|
1799
|
-
setActiveProjection({ source, key, target, depth, parent });
|
|
1800
|
-
const previous = debug.untracked(() => target.get(key));
|
|
1801
|
-
const accessBase = {
|
|
1802
|
-
key,
|
|
1803
|
-
source: source,
|
|
1804
|
-
get: () => source.get(key),
|
|
1805
|
-
set: (value) => {
|
|
1806
|
-
source.set(key, value);
|
|
1807
|
-
return true;
|
|
1808
|
-
},
|
|
1809
|
-
old: previous,
|
|
1810
|
-
};
|
|
1811
|
-
defineAccessValue(accessBase);
|
|
1812
|
-
const produced = apply(accessBase, target);
|
|
1813
|
-
target.set(key, produced);
|
|
1814
|
-
});
|
|
1815
|
-
debug.setEffectName(stop, `project[${depth}]:${String(key)}`);
|
|
1816
|
-
keyEffects.set(key, stop);
|
|
1817
|
-
});
|
|
1818
|
-
}
|
|
1819
|
-
for (const key of Array.from(keyEffects.keys()))
|
|
1820
|
-
if (!keys.has(key))
|
|
1821
|
-
disposeKey(key);
|
|
1822
|
-
});
|
|
1823
|
-
return makeCleanup(target, keyEffects, () => cleanupKeys(), {
|
|
1824
|
-
source: source,
|
|
1825
|
-
target,
|
|
1826
|
-
apply,
|
|
1827
|
-
depth,
|
|
1828
|
-
parent,
|
|
1829
|
-
});
|
|
1830
|
-
}
|
|
1831
|
-
function projectRecord(source, apply) {
|
|
1832
|
-
source = debug.reactive(source);
|
|
1833
|
-
const target = debug.reactive({});
|
|
1834
|
-
const keyEffects = new Map();
|
|
1835
|
-
function disposeKey(key) {
|
|
1836
|
-
const stopEffect = keyEffects.get(key);
|
|
1837
|
-
if (stopEffect) {
|
|
1838
|
-
stopEffect();
|
|
1839
|
-
keyEffects.delete(key);
|
|
1840
|
-
Reflect.deleteProperty(target, key);
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
const parent = getActiveProjection();
|
|
1844
|
-
const depth = parent ? parent.depth + 1 : 0;
|
|
1845
|
-
const cleanupKeys = debug.effect(function projectRecordEffect({ ascend }) {
|
|
1846
|
-
const keys = new Set();
|
|
1847
|
-
for (const key in source)
|
|
1848
|
-
keys.add(key);
|
|
1849
|
-
const observed = Reflect.ownKeys(source);
|
|
1850
|
-
for (const key of observed)
|
|
1851
|
-
keys.add(key);
|
|
1852
|
-
for (const key of keys) {
|
|
1853
|
-
if (keyEffects.has(key))
|
|
1854
|
-
continue;
|
|
1855
|
-
ascend(() => {
|
|
1856
|
-
const stop = debug.effect(function projectRecordKeyEffect({ reaction }) {
|
|
1857
|
-
if (!reaction)
|
|
1858
|
-
setActiveProjection({ source, key, target, depth, parent });
|
|
1859
|
-
const sourceKey = key;
|
|
1860
|
-
const previous = debug.untracked(() => target[key]);
|
|
1861
|
-
const accessBase = {
|
|
1862
|
-
key: sourceKey,
|
|
1863
|
-
source: source,
|
|
1864
|
-
get: () => debug.FoolProof.get(source, sourceKey, source),
|
|
1865
|
-
set: (value) => debug.FoolProof.set(source, sourceKey, value, source),
|
|
1866
|
-
old: previous,
|
|
1867
|
-
};
|
|
1868
|
-
defineAccessValue(accessBase);
|
|
1869
|
-
const produced = apply(accessBase, target);
|
|
1870
|
-
target[sourceKey] = produced;
|
|
1871
|
-
});
|
|
1872
|
-
debug.setEffectName(stop, `project[${depth}]:${String(key)}`);
|
|
1873
|
-
keyEffects.set(key, stop);
|
|
1874
|
-
});
|
|
1875
|
-
}
|
|
1876
|
-
for (const key of Array.from(keyEffects.keys()))
|
|
1877
|
-
if (!keys.has(key))
|
|
1878
|
-
disposeKey(key);
|
|
1879
|
-
});
|
|
1880
|
-
return makeCleanup(target, keyEffects, () => cleanupKeys(), {
|
|
1881
|
-
source: source,
|
|
1882
|
-
target,
|
|
1883
|
-
apply,
|
|
1884
|
-
depth,
|
|
1885
|
-
parent,
|
|
1886
|
-
});
|
|
1887
|
-
}
|
|
1888
|
-
function projectMap(source, apply) {
|
|
1889
|
-
source = debug.reactive(source);
|
|
1890
|
-
const rawTarget = new Map();
|
|
1891
|
-
const target = debug.reactive(rawTarget);
|
|
1892
|
-
const keyEffects = new Map();
|
|
1893
|
-
function disposeKey(key) {
|
|
1894
|
-
const stopEffect = keyEffects.get(key);
|
|
1895
|
-
if (stopEffect) {
|
|
1896
|
-
stopEffect();
|
|
1897
|
-
keyEffects.delete(key);
|
|
1898
|
-
target.delete(key);
|
|
1899
|
-
}
|
|
2413
|
+
function* makeReactiveIterator(iterator) {
|
|
2414
|
+
let result = iterator.next();
|
|
2415
|
+
while (!result.done) {
|
|
2416
|
+
yield proxy.reactive(result.value);
|
|
2417
|
+
result = iterator.next();
|
|
1900
2418
|
}
|
|
1901
|
-
const parent = getActiveProjection();
|
|
1902
|
-
const depth = parent ? parent.depth + 1 : 0;
|
|
1903
|
-
const cleanupKeys = debug.effect(function projectMapEffect({ ascend }) {
|
|
1904
|
-
const keys = new Set();
|
|
1905
|
-
for (const key of source.keys())
|
|
1906
|
-
keys.add(key);
|
|
1907
|
-
for (const key of keys) {
|
|
1908
|
-
if (keyEffects.has(key))
|
|
1909
|
-
continue;
|
|
1910
|
-
ascend(() => {
|
|
1911
|
-
const stop = debug.effect(function projectMapKeyEffect({ reaction }) {
|
|
1912
|
-
if (!reaction)
|
|
1913
|
-
setActiveProjection({ source, key, target, depth, parent });
|
|
1914
|
-
const previous = debug.untracked(() => target.get(key));
|
|
1915
|
-
const accessBase = {
|
|
1916
|
-
key,
|
|
1917
|
-
source: source,
|
|
1918
|
-
get: () => source.get(key),
|
|
1919
|
-
set: (value) => {
|
|
1920
|
-
source.set(key, value);
|
|
1921
|
-
return true;
|
|
1922
|
-
},
|
|
1923
|
-
old: previous,
|
|
1924
|
-
};
|
|
1925
|
-
defineAccessValue(accessBase);
|
|
1926
|
-
const produced = apply(accessBase, target);
|
|
1927
|
-
target.set(key, produced);
|
|
1928
|
-
});
|
|
1929
|
-
debug.setEffectName(stop, `project[${depth}]:${String(key)}`);
|
|
1930
|
-
keyEffects.set(key, stop);
|
|
1931
|
-
});
|
|
1932
|
-
}
|
|
1933
|
-
for (const key of Array.from(keyEffects.keys()))
|
|
1934
|
-
if (!keys.has(key))
|
|
1935
|
-
disposeKey(key);
|
|
1936
|
-
});
|
|
1937
|
-
return makeCleanup(target, keyEffects, () => cleanupKeys(), {
|
|
1938
|
-
source: source,
|
|
1939
|
-
target,
|
|
1940
|
-
apply,
|
|
1941
|
-
depth,
|
|
1942
|
-
parent,
|
|
1943
|
-
});
|
|
1944
|
-
}
|
|
1945
|
-
function projectCore(source, apply) {
|
|
1946
|
-
if (Array.isArray(source))
|
|
1947
|
-
return projectArray(source, apply);
|
|
1948
|
-
if (source instanceof Map)
|
|
1949
|
-
return projectMap(source, apply);
|
|
1950
|
-
if (source instanceof Register)
|
|
1951
|
-
return projectRegister(source, apply);
|
|
1952
|
-
if (source && (source.constructor === Object || source.constructor === undefined))
|
|
1953
|
-
return projectRecord(source, apply);
|
|
1954
|
-
throw new Error('Unsupported source type');
|
|
1955
|
-
}
|
|
1956
|
-
const project = Object.assign(projectCore, {
|
|
1957
|
-
array: projectArray,
|
|
1958
|
-
register: projectRegister,
|
|
1959
|
-
record: projectRecord,
|
|
1960
|
-
map: projectMap,
|
|
1961
|
-
});
|
|
1962
|
-
|
|
1963
|
-
/**
|
|
1964
|
-
* Organizes a source object's properties into a target object using a callback function.
|
|
1965
|
-
* This creates a reactive mapping between source properties and a target object,
|
|
1966
|
-
* automatically handling property additions, updates, and removals.
|
|
1967
|
-
*
|
|
1968
|
-
* @template Source - The type of the source object
|
|
1969
|
-
* @template Target - The type of the target object (defaults to Record<PropertyKey, any>)
|
|
1970
|
-
*
|
|
1971
|
-
* @param {Source} source - The source object to organize
|
|
1972
|
-
* @param {OrganizedCallback<Source, Target>} apply - Callback function that defines how each source property is mapped to the target
|
|
1973
|
-
* @param {Target} [baseTarget={}] - Optional base target object to use (will be made reactive if not already)
|
|
1974
|
-
*
|
|
1975
|
-
* @returns {OrganizedResult<Target>} The target object with cleanup capability
|
|
1976
|
-
*
|
|
1977
|
-
* @example
|
|
1978
|
-
* // Organize user permissions into role-based access
|
|
1979
|
-
* const user = reactive({ isAdmin: true, canEdit: false });
|
|
1980
|
-
* const permissions = organized(
|
|
1981
|
-
* user,
|
|
1982
|
-
* (access, target) => {
|
|
1983
|
-
* if (access.key === 'isAdmin') {
|
|
1984
|
-
* target.hasFullAccess = access.value;
|
|
1985
|
-
* }
|
|
1986
|
-
* target[`can${access.key.charAt(0).toUpperCase() + access.key.slice(1)}`] = access.value;
|
|
1987
|
-
* }
|
|
1988
|
-
* );
|
|
1989
|
-
*
|
|
1990
|
-
* @example
|
|
1991
|
-
* // Transform object structure with cleanup
|
|
1992
|
-
* const source = reactive({ firstName: 'John', lastName: 'Doe' });
|
|
1993
|
-
* const formatted = organized(
|
|
1994
|
-
* source,
|
|
1995
|
-
* (access, target) => {
|
|
1996
|
-
* if (access.key === 'firstName' || access.key === 'lastName') {
|
|
1997
|
-
* target.fullName = `${source.firstName} ${source.lastName}`.trim();
|
|
1998
|
-
* }
|
|
1999
|
-
* }
|
|
2000
|
-
* );
|
|
2001
|
-
*
|
|
2002
|
-
* @example
|
|
2003
|
-
* // Using with cleanup in a component
|
|
2004
|
-
* effect(() => {
|
|
2005
|
-
* const data = fetchData();
|
|
2006
|
-
* const organizedData = organized(data, (access, target) => {
|
|
2007
|
-
* // Transform data
|
|
2008
|
-
* });
|
|
2009
|
-
*
|
|
2010
|
-
* // The cleanup will be called automatically when the effect is disposed
|
|
2011
|
-
* return () => organizedData[cleanup]();
|
|
2012
|
-
* });
|
|
2013
|
-
*/
|
|
2014
|
-
function organized(source, apply, baseTarget = {}) {
|
|
2015
|
-
const observedSource = debug.reactive(source);
|
|
2016
|
-
const target = debug.reactive(baseTarget);
|
|
2017
|
-
const stop = attend(() => {
|
|
2018
|
-
const keys = [];
|
|
2019
|
-
for (const key in observedSource)
|
|
2020
|
-
keys.push(key);
|
|
2021
|
-
return keys;
|
|
2022
|
-
}, (key) => {
|
|
2023
|
-
const sourceKey = key;
|
|
2024
|
-
const accessBase = {
|
|
2025
|
-
key: sourceKey,
|
|
2026
|
-
get: () => debug.FoolProof.get(observedSource, sourceKey, observedSource),
|
|
2027
|
-
set: (value) => debug.FoolProof.set(observedSource, sourceKey, value, observedSource),
|
|
2028
|
-
};
|
|
2029
|
-
Object.defineProperty(accessBase, 'value', {
|
|
2030
|
-
get: accessBase.get,
|
|
2031
|
-
set: accessBase.set,
|
|
2032
|
-
configurable: true,
|
|
2033
|
-
enumerable: true,
|
|
2034
|
-
});
|
|
2035
|
-
return apply(accessBase, target);
|
|
2036
|
-
});
|
|
2037
|
-
return debug.cleanedBy(target, stop);
|
|
2038
2419
|
}
|
|
2039
2420
|
/**
|
|
2040
|
-
*
|
|
2041
|
-
* Shortcut for defineProperty/delete with touched signal
|
|
2042
|
-
* @param target - The target object
|
|
2043
|
-
* @param property - The property to organize
|
|
2044
|
-
* @param access - The access object
|
|
2045
|
-
* @returns The property descriptor
|
|
2046
|
-
*/
|
|
2047
|
-
function organize(target, property, access) {
|
|
2048
|
-
Object.defineProperty(target, property, {
|
|
2049
|
-
get: access.get,
|
|
2050
|
-
set: access.set,
|
|
2051
|
-
configurable: true,
|
|
2052
|
-
enumerable: true,
|
|
2053
|
-
});
|
|
2054
|
-
debug.touched1(target, { type: 'set', prop: property }, property);
|
|
2055
|
-
return () => delete target[property];
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
/**
|
|
2059
|
-
* Reactively defines properties on a target object based on a descriptors record.
|
|
2060
|
-
*
|
|
2061
|
-
* It tracks the keys of the descriptors record and defines/updates/removes
|
|
2062
|
-
* properties on the target object as they change.
|
|
2063
|
-
*
|
|
2064
|
-
* @param descriptors - A reactive record of property descriptors.
|
|
2065
|
-
* @param target - The object to define properties on (defaults to a new object).
|
|
2066
|
-
* @returns The target object with reactive property definitions.
|
|
2421
|
+
* Converts an iterator of key-value pairs to a generator that yields reactive key-value pairs
|
|
2067
2422
|
*/
|
|
2068
|
-
function
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
const
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
...desc,
|
|
2076
|
-
configurable: true,
|
|
2077
|
-
});
|
|
2078
|
-
debug.touched1(target, { type: 'set', prop: key }, key);
|
|
2079
|
-
}
|
|
2080
|
-
return () => Reflect.deleteProperty(target, key);
|
|
2081
|
-
});
|
|
2082
|
-
return debug.cleanedBy(target, stop);
|
|
2423
|
+
function* makeReactiveEntriesIterator(iterator) {
|
|
2424
|
+
let result = iterator.next();
|
|
2425
|
+
while (!result.done) {
|
|
2426
|
+
const [key, value] = result.value;
|
|
2427
|
+
yield [proxy.reactive(key), proxy.reactive(value)];
|
|
2428
|
+
result = iterator.next();
|
|
2429
|
+
}
|
|
2083
2430
|
}
|
|
2084
2431
|
|
|
2085
2432
|
function* index(i, { length = true } = {}) {
|
|
@@ -2087,42 +2434,42 @@ function* index(i, { length = true } = {}) {
|
|
|
2087
2434
|
yield 'length';
|
|
2088
2435
|
yield i;
|
|
2089
2436
|
}
|
|
2090
|
-
function* range(a, b, { length = false } = {}) {
|
|
2091
|
-
const start = Math.min(a, b);
|
|
2092
|
-
const end = Math.max(a, b);
|
|
2093
|
-
if (length)
|
|
2094
|
-
yield 'length';
|
|
2095
|
-
for (let i = start; i <= end; i++)
|
|
2096
|
-
yield i;
|
|
2097
|
-
}
|
|
2098
2437
|
class Indexer extends Array {
|
|
2099
2438
|
get(i) {
|
|
2100
|
-
|
|
2101
|
-
return
|
|
2439
|
+
proxy.dependant(this, i);
|
|
2440
|
+
return proxy.reactive(this[i]);
|
|
2102
2441
|
}
|
|
2103
2442
|
// Returns undefined intentionally: signals the proxy handler that notifications
|
|
2104
2443
|
// were already dispatched via touched(), preventing double notification
|
|
2105
2444
|
set(i, value) {
|
|
2106
2445
|
const added = i >= this.length;
|
|
2107
2446
|
this[i] = value;
|
|
2108
|
-
|
|
2447
|
+
proxy.touched(this, { type: 'set', prop: i }, index(i, { length: added }));
|
|
2109
2448
|
}
|
|
2110
2449
|
}
|
|
2111
|
-
const indexLess = { get:
|
|
2112
|
-
|
|
2450
|
+
const indexLess = { get: proxy.FoolProof.get, set: proxy.FoolProof.set };
|
|
2451
|
+
// Fast numeric-string check: first char is a digit (0-9)
|
|
2452
|
+
function asIndex(prop) {
|
|
2453
|
+
const c = prop.charCodeAt(0);
|
|
2454
|
+
if (c < 48 || c > 57)
|
|
2455
|
+
return -1; // not 0-9
|
|
2456
|
+
const n = +prop; // coerce — faster than parseInt, handles "0", "12", etc.
|
|
2457
|
+
return n === (n | 0) && n >= 0 ? n : -1;
|
|
2458
|
+
}
|
|
2459
|
+
Object.assign(proxy.FoolProof, {
|
|
2113
2460
|
get(obj, prop, receiver) {
|
|
2114
|
-
if (obj
|
|
2115
|
-
const
|
|
2116
|
-
if (
|
|
2117
|
-
return Indexer.prototype.get.call(obj,
|
|
2461
|
+
if (Array.isArray(obj) && typeof prop === 'string') {
|
|
2462
|
+
const i = asIndex(prop);
|
|
2463
|
+
if (i >= 0)
|
|
2464
|
+
return Indexer.prototype.get.call(obj, i);
|
|
2118
2465
|
}
|
|
2119
2466
|
return indexLess.get(obj, prop, receiver);
|
|
2120
2467
|
},
|
|
2121
2468
|
set(obj, prop, value, receiver) {
|
|
2122
|
-
if (obj
|
|
2123
|
-
const
|
|
2124
|
-
if (
|
|
2125
|
-
return Indexer.prototype.set.call(obj,
|
|
2469
|
+
if (Array.isArray(obj) && typeof prop === 'string') {
|
|
2470
|
+
const i = asIndex(prop);
|
|
2471
|
+
if (i >= 0)
|
|
2472
|
+
return Indexer.prototype.set.call(obj, i, value);
|
|
2126
2473
|
}
|
|
2127
2474
|
return indexLess.set(obj, prop, value, receiver);
|
|
2128
2475
|
},
|
|
@@ -2131,374 +2478,186 @@ class ReactiveArray extends Array {
|
|
|
2131
2478
|
toJSON() {
|
|
2132
2479
|
return this;
|
|
2133
2480
|
}
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
debug.dependant(this, 'length');
|
|
2155
|
-
if (actualIndex < 0 || actualIndex >= this.length)
|
|
2156
|
-
return undefined;
|
|
2157
|
-
return debug.reactive(this[actualIndex]);
|
|
2158
|
-
}
|
|
2159
|
-
// Immutable versions of mutator methods
|
|
2160
|
-
toReversed() {
|
|
2161
|
-
debug.dependant(this);
|
|
2162
|
-
return debug.reactive(this.toReversed());
|
|
2163
|
-
}
|
|
2164
|
-
toSorted(compareFn) {
|
|
2165
|
-
debug.dependant(this);
|
|
2166
|
-
return debug.reactive(this.toSorted(compareFn));
|
|
2167
|
-
}
|
|
2168
|
-
toSpliced(start, deleteCount, ...items) {
|
|
2169
|
-
debug.dependant(this);
|
|
2170
|
-
return deleteCount === undefined
|
|
2171
|
-
? this.toSpliced(start)
|
|
2172
|
-
: this.toSpliced(start, deleteCount, ...items);
|
|
2173
|
-
}
|
|
2174
|
-
with(index, value) {
|
|
2175
|
-
debug.dependant(this);
|
|
2176
|
-
return debug.reactive(this.with(index, value));
|
|
2177
|
-
}
|
|
2178
|
-
// Iterator methods with reactivity tracking
|
|
2179
|
-
entries() {
|
|
2180
|
-
debug.dependant(this);
|
|
2181
|
-
return makeReactiveEntriesIterator(this.entries());
|
|
2182
|
-
}
|
|
2183
|
-
keys() {
|
|
2184
|
-
debug.dependant(this, 'length');
|
|
2185
|
-
return this.keys();
|
|
2186
|
-
}
|
|
2187
|
-
values() {
|
|
2188
|
-
debug.dependant(this);
|
|
2189
|
-
return makeReactiveIterator(this.values());
|
|
2190
|
-
}
|
|
2191
|
-
[Symbol.iterator]() {
|
|
2192
|
-
debug.dependant(this);
|
|
2193
|
-
const nativeIterator = this[Symbol.iterator]();
|
|
2194
|
-
return {
|
|
2195
|
-
next() {
|
|
2196
|
-
const result = nativeIterator.next();
|
|
2197
|
-
if (result.done) {
|
|
2198
|
-
return result;
|
|
2199
|
-
}
|
|
2200
|
-
return { value: debug.reactive(result.value), done: false };
|
|
2201
|
-
},
|
|
2202
|
-
[Symbol.iterator]() {
|
|
2203
|
-
return this;
|
|
2204
|
-
},
|
|
2205
|
-
[Symbol.dispose]() { },
|
|
2206
|
-
};
|
|
2207
|
-
}
|
|
2208
|
-
indexOf(searchElement, fromIndex) {
|
|
2209
|
-
const length = this.length;
|
|
2210
|
-
let i = fromIndex === undefined ? 0 : fromIndex;
|
|
2211
|
-
if (i < 0)
|
|
2212
|
-
i = Math.max(length + i, 0);
|
|
2213
|
-
const unwrappedSearch = debug.unwrap(searchElement);
|
|
2214
|
-
for (; i < length; i++) {
|
|
2215
|
-
debug.dependant(this, i);
|
|
2216
|
-
const item = this[i];
|
|
2217
|
-
if (item === searchElement || item === unwrappedSearch || debug.unwrap(item) === unwrappedSearch) {
|
|
2218
|
-
return i;
|
|
2481
|
+
}
|
|
2482
|
+
/**
|
|
2483
|
+
* This is a wrapper class for Array that adds reactive behavior.
|
|
2484
|
+
* It extends Array and overrides methods to add reactive behavior, while making sure that the internal representation is not reactive.
|
|
2485
|
+
*/
|
|
2486
|
+
let ReactiveArrayWrapper = (() => {
|
|
2487
|
+
var _a;
|
|
2488
|
+
let _classSuper = Array;
|
|
2489
|
+
let _instanceExtraInitializers = [];
|
|
2490
|
+
let _fill_decorators;
|
|
2491
|
+
let _pop_decorators;
|
|
2492
|
+
let _push_decorators;
|
|
2493
|
+
let _reverse_decorators;
|
|
2494
|
+
let _shift_decorators;
|
|
2495
|
+
let _sort_decorators;
|
|
2496
|
+
let _splice_decorators;
|
|
2497
|
+
let _unshift_decorators;
|
|
2498
|
+
return _a = class ReactiveArrayWrapper extends _classSuper {
|
|
2499
|
+
at(index) {
|
|
2500
|
+
return proxy.reactive(super.at(index));
|
|
2219
2501
|
}
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2502
|
+
concat(...items) {
|
|
2503
|
+
return proxy.reactive(super.concat(...items.map(proxy.unwrap)));
|
|
2504
|
+
}
|
|
2505
|
+
entries() {
|
|
2506
|
+
proxy.dependant(this, proxy.keysOf);
|
|
2507
|
+
return makeReactiveEntriesIterator(super.entries());
|
|
2508
|
+
}
|
|
2509
|
+
every(predicate, thisArg) {
|
|
2510
|
+
return super.every((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg);
|
|
2511
|
+
}
|
|
2512
|
+
fill(value, start, end) {
|
|
2513
|
+
return super.fill(proxy.unwrap(value), start, end);
|
|
2514
|
+
}
|
|
2515
|
+
filter(predicate, thisArg) {
|
|
2516
|
+
return proxy.reactive(super.filter((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg));
|
|
2517
|
+
}
|
|
2518
|
+
find(predicate, thisArg) {
|
|
2519
|
+
return proxy.reactive(super.find((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg));
|
|
2520
|
+
}
|
|
2521
|
+
findIndex(predicate, thisArg) {
|
|
2522
|
+
return super.findIndex((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg);
|
|
2523
|
+
}
|
|
2524
|
+
findLast(predicate, thisArg) {
|
|
2525
|
+
return proxy.reactive(super.findLast((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg));
|
|
2526
|
+
}
|
|
2527
|
+
findLastIndex(predicate, thisArg) {
|
|
2528
|
+
return super.findLastIndex((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg);
|
|
2529
|
+
}
|
|
2530
|
+
flat(depth) {
|
|
2531
|
+
return proxy.reactive(super.flat(depth));
|
|
2532
|
+
}
|
|
2533
|
+
flatMap(callbackfn, thisArg) {
|
|
2534
|
+
return proxy.reactive(super.flatMap((v, i, a) => proxy.unwrap(callbackfn.call(thisArg, proxy.reactive(v), i, a)), thisArg));
|
|
2535
|
+
}
|
|
2536
|
+
forEach(callbackfn, thisArg) {
|
|
2537
|
+
super.forEach((v, i, a) => {
|
|
2538
|
+
callbackfn.call(thisArg, proxy.reactive(v), i, a);
|
|
2539
|
+
}, thisArg);
|
|
2540
|
+
}
|
|
2541
|
+
includes(searchElement, fromIndex) {
|
|
2542
|
+
return arguments.length > 1
|
|
2543
|
+
? super.includes(proxy.unwrap(searchElement), fromIndex)
|
|
2544
|
+
: super.includes(proxy.unwrap(searchElement));
|
|
2545
|
+
}
|
|
2546
|
+
indexOf(searchElement, fromIndex) {
|
|
2547
|
+
return arguments.length > 1
|
|
2548
|
+
? super.indexOf(proxy.unwrap(searchElement), fromIndex)
|
|
2549
|
+
: super.indexOf(proxy.unwrap(searchElement));
|
|
2550
|
+
}
|
|
2551
|
+
join(separator) {
|
|
2552
|
+
return super.join(separator);
|
|
2553
|
+
}
|
|
2554
|
+
keys() {
|
|
2555
|
+
proxy.dependant(this, 'length');
|
|
2556
|
+
return super.keys();
|
|
2557
|
+
}
|
|
2558
|
+
lastIndexOf(searchElement, fromIndex) {
|
|
2559
|
+
return arguments.length > 1
|
|
2560
|
+
? super.lastIndexOf(proxy.unwrap(searchElement), fromIndex)
|
|
2561
|
+
: super.lastIndexOf(proxy.unwrap(searchElement));
|
|
2562
|
+
}
|
|
2563
|
+
map(callbackfn, thisArg) {
|
|
2564
|
+
return proxy.reactive(super.map((v, i, a) => proxy.unwrap(callbackfn.call(thisArg, proxy.reactive(v), i, a)), thisArg));
|
|
2565
|
+
}
|
|
2566
|
+
pop() {
|
|
2567
|
+
return proxy.reactive(super.pop());
|
|
2568
|
+
}
|
|
2569
|
+
push(...items) {
|
|
2570
|
+
return super.push(...items.map(proxy.unwrap));
|
|
2571
|
+
}
|
|
2572
|
+
reduce(callbackfn, initialValue) {
|
|
2573
|
+
return proxy.reactive(arguments.length > 1
|
|
2574
|
+
? super.reduce((acc, v, i, a) => proxy.unwrap(callbackfn(acc, proxy.reactive(v), i, a)), initialValue)
|
|
2575
|
+
: super.reduce((acc, v, i, a) => proxy.unwrap(callbackfn(acc, proxy.reactive(v), i, a))));
|
|
2576
|
+
}
|
|
2577
|
+
reduceRight(callbackfn, initialValue) {
|
|
2578
|
+
return proxy.reactive(arguments.length > 1
|
|
2579
|
+
? super.reduceRight((acc, v, i, a) => proxy.unwrap(callbackfn(acc, proxy.reactive(v), i, a)), initialValue)
|
|
2580
|
+
: super.reduceRight((acc, v, i, a) => proxy.unwrap(callbackfn(acc, proxy.reactive(v), i, a))));
|
|
2581
|
+
}
|
|
2582
|
+
reverse() {
|
|
2583
|
+
return proxy.reactive(super.reverse());
|
|
2584
|
+
}
|
|
2585
|
+
shift() {
|
|
2586
|
+
return proxy.reactive(super.shift());
|
|
2587
|
+
}
|
|
2588
|
+
slice(start, end) {
|
|
2589
|
+
return proxy.reactive(super.slice(start, end));
|
|
2590
|
+
}
|
|
2591
|
+
some(predicate, thisArg) {
|
|
2592
|
+
return super.some((v, i, a) => predicate.call(thisArg, proxy.reactive(v), i, a), thisArg);
|
|
2593
|
+
}
|
|
2594
|
+
sort(compareFn) {
|
|
2595
|
+
const wrappedCompare = compareFn
|
|
2596
|
+
? (a, b) => compareFn(proxy.reactive(a), proxy.reactive(b))
|
|
2597
|
+
: undefined;
|
|
2598
|
+
return super.sort(wrappedCompare);
|
|
2261
2599
|
}
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
}
|
|
2271
|
-
findIndex(predicateOrElement, thisArg) {
|
|
2272
|
-
if (typeof predicateOrElement === 'function') {
|
|
2273
|
-
const predicate = predicateOrElement;
|
|
2274
|
-
const length = this.length;
|
|
2275
|
-
for (let i = 0; i < length; i++) {
|
|
2276
|
-
debug.dependant(this, i);
|
|
2277
|
-
const val = debug.reactive(this[i]);
|
|
2278
|
-
if (predicate.call(thisArg, val, i, this)) {
|
|
2279
|
-
return i;
|
|
2280
|
-
}
|
|
2600
|
+
splice(start, deleteCount, ...items) {
|
|
2601
|
+
if (arguments.length > 2)
|
|
2602
|
+
return proxy.reactive(super.splice(start, deleteCount, ...items.map(proxy.unwrap)));
|
|
2603
|
+
if (arguments.length === 2)
|
|
2604
|
+
return proxy.reactive(super.splice(start, deleteCount));
|
|
2605
|
+
if (arguments.length === 1)
|
|
2606
|
+
return proxy.reactive(super.splice(start));
|
|
2607
|
+
return proxy.reactive([]);
|
|
2281
2608
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
}
|
|
2285
|
-
const fromIndex = typeof thisArg === 'number' ? thisArg : undefined;
|
|
2286
|
-
return this.indexOf(predicateOrElement, fromIndex);
|
|
2287
|
-
}
|
|
2288
|
-
flat(depth) {
|
|
2289
|
-
debug.dependant(this);
|
|
2290
|
-
return debug.reactive(depth === undefined ? this.flat() : this.flat(depth));
|
|
2291
|
-
}
|
|
2292
|
-
flatMap(callbackfn, thisArg) {
|
|
2293
|
-
debug.dependant(this);
|
|
2294
|
-
return debug.reactive(this.flatMap((item, index, array) => callbackfn.call(thisArg, debug.reactive(item), index, array), thisArg));
|
|
2295
|
-
}
|
|
2296
|
-
filter(callbackfn, thisArg) {
|
|
2297
|
-
debug.dependant(this);
|
|
2298
|
-
return debug.reactive(this.filter((item, index, array) => callbackfn(debug.reactive(item), index, array), thisArg));
|
|
2299
|
-
}
|
|
2300
|
-
map(callbackfn, thisArg) {
|
|
2301
|
-
debug.dependant(this);
|
|
2302
|
-
return debug.reactive(this.map((item, index, array) => callbackfn(debug.reactive(item), index, array), thisArg));
|
|
2303
|
-
}
|
|
2304
|
-
reduce(callbackfn, initialValue) {
|
|
2305
|
-
debug.dependant(this);
|
|
2306
|
-
const result = initialValue === undefined
|
|
2307
|
-
? this.reduce(callbackfn)
|
|
2308
|
-
: this.reduce(callbackfn, initialValue);
|
|
2309
|
-
return debug.reactive(result);
|
|
2310
|
-
}
|
|
2311
|
-
reduceRight(callbackfn, initialValue) {
|
|
2312
|
-
debug.dependant(this);
|
|
2313
|
-
const result = initialValue !== undefined
|
|
2314
|
-
? this.reduceRight(callbackfn, initialValue)
|
|
2315
|
-
: this.reduceRight(callbackfn);
|
|
2316
|
-
return debug.reactive(result);
|
|
2317
|
-
}
|
|
2318
|
-
slice(start, end) {
|
|
2319
|
-
for (const i of range(start || 0, end || this.length - 1))
|
|
2320
|
-
debug.dependant(this, i);
|
|
2321
|
-
return start === undefined
|
|
2322
|
-
? this.slice()
|
|
2323
|
-
: end === undefined
|
|
2324
|
-
? this.slice(start)
|
|
2325
|
-
: this.slice(start, end);
|
|
2326
|
-
}
|
|
2327
|
-
concat(...items) {
|
|
2328
|
-
debug.dependant(this);
|
|
2329
|
-
return debug.reactive(this.concat(...items));
|
|
2330
|
-
}
|
|
2331
|
-
join(separator) {
|
|
2332
|
-
debug.dependant(this);
|
|
2333
|
-
return this.join(separator);
|
|
2334
|
-
}
|
|
2335
|
-
forEach(callbackfn, thisArg) {
|
|
2336
|
-
debug.dependant(this);
|
|
2337
|
-
this.forEach((value, index, array) => {
|
|
2338
|
-
callbackfn.call(thisArg, debug.reactive(value), index, array);
|
|
2339
|
-
});
|
|
2340
|
-
}
|
|
2341
|
-
every(callbackfn, thisArg) {
|
|
2342
|
-
const length = this.length;
|
|
2343
|
-
for (let i = 0; i < length; i++) {
|
|
2344
|
-
debug.dependant(this, i);
|
|
2345
|
-
if (!callbackfn.call(thisArg, debug.reactive(this[i]), i, this)) {
|
|
2346
|
-
return false;
|
|
2609
|
+
unshift(...items) {
|
|
2610
|
+
return super.unshift(...items.map(proxy.unwrap));
|
|
2347
2611
|
}
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
}
|
|
2352
|
-
some(callbackfn, thisArg) {
|
|
2353
|
-
const length = this.length;
|
|
2354
|
-
for (let i = 0; i < length; i++) {
|
|
2355
|
-
debug.dependant(this, i);
|
|
2356
|
-
if (callbackfn.call(thisArg, debug.reactive(this[i]), i, this)) {
|
|
2357
|
-
return true;
|
|
2612
|
+
values() {
|
|
2613
|
+
proxy.dependant(this, proxy.keysOf);
|
|
2614
|
+
return makeReactiveIterator(super.values());
|
|
2358
2615
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
}
|
|
2363
|
-
// Side-effectful
|
|
2364
|
-
push(...items) {
|
|
2365
|
-
const oldLength = this.length;
|
|
2366
|
-
try {
|
|
2367
|
-
return this.push(...items);
|
|
2368
|
-
}
|
|
2369
|
-
finally {
|
|
2370
|
-
debug.touched(this, { type: 'bunch', method: 'push' }, range(oldLength, oldLength + items.length - 1, { length: true }));
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2373
|
-
pop() {
|
|
2374
|
-
if (this.length === 0)
|
|
2375
|
-
return undefined;
|
|
2376
|
-
try {
|
|
2377
|
-
return debug.reactive(this.pop());
|
|
2378
|
-
}
|
|
2379
|
-
finally {
|
|
2380
|
-
debug.touched(this, { type: 'bunch', method: 'pop' }, index(this.length));
|
|
2381
|
-
}
|
|
2382
|
-
}
|
|
2383
|
-
shift() {
|
|
2384
|
-
if (this.length === 0)
|
|
2385
|
-
return undefined;
|
|
2386
|
-
try {
|
|
2387
|
-
return debug.reactive(this.shift());
|
|
2388
|
-
}
|
|
2389
|
-
finally {
|
|
2390
|
-
debug.touched(this, { type: 'bunch', method: 'shift' }, range(0, this.length + 1, { length: true }));
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
unshift(...items) {
|
|
2394
|
-
try {
|
|
2395
|
-
return this.unshift(...items);
|
|
2396
|
-
}
|
|
2397
|
-
finally {
|
|
2398
|
-
debug.touched(this, { type: 'bunch', method: 'unshift' }, range(0, this.length - items.length, { length: true }));
|
|
2399
|
-
}
|
|
2400
|
-
}
|
|
2401
|
-
splice(start, deleteCount, ...items) {
|
|
2402
|
-
const oldLength = this.length;
|
|
2403
|
-
// Normalize start index
|
|
2404
|
-
let actualStart = start;
|
|
2405
|
-
if (actualStart < 0)
|
|
2406
|
-
actualStart = Math.max(oldLength + actualStart, 0);
|
|
2407
|
-
else
|
|
2408
|
-
actualStart = Math.min(actualStart, oldLength);
|
|
2409
|
-
// Normalize deleteCount
|
|
2410
|
-
let actualDeleteCount = deleteCount;
|
|
2411
|
-
if (actualDeleteCount === undefined) {
|
|
2412
|
-
actualDeleteCount = oldLength - actualStart;
|
|
2413
|
-
}
|
|
2414
|
-
else {
|
|
2415
|
-
actualDeleteCount = Math.max(0, Math.min(actualDeleteCount, oldLength - actualStart));
|
|
2416
|
-
}
|
|
2417
|
-
try {
|
|
2418
|
-
if (deleteCount === undefined)
|
|
2419
|
-
return debug.reactive(this.splice(start));
|
|
2420
|
-
return debug.reactive(this.splice(start, deleteCount, ...items));
|
|
2421
|
-
}
|
|
2422
|
-
finally {
|
|
2423
|
-
debug.touched(this, { type: 'bunch', method: 'splice' }, actualDeleteCount === items.length
|
|
2424
|
-
? range(actualStart, actualStart + actualDeleteCount - 1)
|
|
2425
|
-
: range(actualStart, oldLength + Math.max(items.length - actualDeleteCount, 0), {
|
|
2426
|
-
length: true,
|
|
2427
|
-
}));
|
|
2428
|
-
}
|
|
2429
|
-
}
|
|
2430
|
-
reverse() {
|
|
2431
|
-
try {
|
|
2432
|
-
return this.reverse();
|
|
2433
|
-
}
|
|
2434
|
-
finally {
|
|
2435
|
-
debug.touched(this, { type: 'bunch', method: 'reverse' }, range(0, this.length - 1));
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
sort(compareFn) {
|
|
2439
|
-
compareFn = compareFn || ((a, b) => a.toString().localeCompare(b.toString()));
|
|
2440
|
-
try {
|
|
2441
|
-
return this.sort((a, b) => compareFn(debug.reactive(a), debug.reactive(b)));
|
|
2442
|
-
}
|
|
2443
|
-
finally {
|
|
2444
|
-
debug.touched(this, { type: 'bunch', method: 'sort' }, range(0, this.length - 1));
|
|
2445
|
-
}
|
|
2446
|
-
}
|
|
2447
|
-
fill(value, start, end) {
|
|
2448
|
-
const len = this.length;
|
|
2449
|
-
let k = start === undefined ? 0 : start;
|
|
2450
|
-
if (k < 0)
|
|
2451
|
-
k = Math.max(len + k, 0);
|
|
2452
|
-
else
|
|
2453
|
-
k = Math.min(k, len);
|
|
2454
|
-
let final = end === undefined ? len : end;
|
|
2455
|
-
if (final < 0)
|
|
2456
|
-
final = Math.max(len + final, 0);
|
|
2457
|
-
else
|
|
2458
|
-
final = Math.min(final, len);
|
|
2459
|
-
try {
|
|
2460
|
-
if (start === undefined)
|
|
2461
|
-
return this.fill(value);
|
|
2462
|
-
if (end === undefined)
|
|
2463
|
-
return this.fill(value, start);
|
|
2464
|
-
return this.fill(value, start, end);
|
|
2465
|
-
}
|
|
2466
|
-
finally {
|
|
2467
|
-
if (final > k) {
|
|
2468
|
-
debug.touched(this, { type: 'bunch', method: 'fill' }, range(k, final - 1));
|
|
2616
|
+
[(_fill_decorators = [proxy.atomic], _pop_decorators = [proxy.atomic], _push_decorators = [proxy.atomic], _reverse_decorators = [proxy.atomic], _shift_decorators = [proxy.atomic], _sort_decorators = [proxy.atomic], _splice_decorators = [proxy.atomic], _unshift_decorators = [proxy.atomic], Symbol.iterator)]() {
|
|
2617
|
+
proxy.dependant(this, proxy.keysOf);
|
|
2618
|
+
return makeReactiveIterator(super[Symbol.iterator]());
|
|
2469
2619
|
}
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
const count = Math.min(final - from, len - to);
|
|
2496
|
-
if (count > 0) {
|
|
2497
|
-
debug.touched(this, { type: 'bunch', method: 'copyWithin' }, range(to, to + count - 1));
|
|
2620
|
+
toReversed() {
|
|
2621
|
+
return proxy.reactive(super.toReversed());
|
|
2622
|
+
}
|
|
2623
|
+
toSorted(compareFn) {
|
|
2624
|
+
const wrappedCompare = compareFn
|
|
2625
|
+
? (a, b) => compareFn(proxy.reactive(a), proxy.reactive(b))
|
|
2626
|
+
: undefined;
|
|
2627
|
+
return proxy.reactive(super.toSorted(wrappedCompare));
|
|
2628
|
+
}
|
|
2629
|
+
// biome-ignore lint/complexity/noArguments: Needed to distinguish fn() from fn(undefined)
|
|
2630
|
+
toSpliced(start, deleteCount, ...items) {
|
|
2631
|
+
if (arguments.length > 2)
|
|
2632
|
+
return proxy.reactive(super.toSpliced(start, deleteCount, ...items.map(proxy.unwrap)));
|
|
2633
|
+
if (arguments.length === 2)
|
|
2634
|
+
return proxy.reactive(super.toSpliced(start, deleteCount));
|
|
2635
|
+
if (arguments.length === 1)
|
|
2636
|
+
return proxy.reactive(super.toSpliced(start));
|
|
2637
|
+
return proxy.reactive([...this]);
|
|
2638
|
+
}
|
|
2639
|
+
with(index, value) {
|
|
2640
|
+
return proxy.reactive(super.with(index, proxy.unwrap(value)));
|
|
2641
|
+
}
|
|
2642
|
+
constructor() {
|
|
2643
|
+
super(...arguments);
|
|
2644
|
+
proxy.__runInitializers(this, _instanceExtraInitializers);
|
|
2498
2645
|
}
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2501
|
-
|
|
2646
|
+
},
|
|
2647
|
+
(() => {
|
|
2648
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
2649
|
+
proxy.__esDecorate(_a, null, _fill_decorators, { kind: "method", name: "fill", static: false, private: false, access: { has: obj => "fill" in obj, get: obj => obj.fill }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2650
|
+
proxy.__esDecorate(_a, null, _pop_decorators, { kind: "method", name: "pop", static: false, private: false, access: { has: obj => "pop" in obj, get: obj => obj.pop }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2651
|
+
proxy.__esDecorate(_a, null, _push_decorators, { kind: "method", name: "push", static: false, private: false, access: { has: obj => "push" in obj, get: obj => obj.push }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2652
|
+
proxy.__esDecorate(_a, null, _reverse_decorators, { kind: "method", name: "reverse", static: false, private: false, access: { has: obj => "reverse" in obj, get: obj => obj.reverse }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2653
|
+
proxy.__esDecorate(_a, null, _shift_decorators, { kind: "method", name: "shift", static: false, private: false, access: { has: obj => "shift" in obj, get: obj => obj.shift }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2654
|
+
proxy.__esDecorate(_a, null, _sort_decorators, { kind: "method", name: "sort", static: false, private: false, access: { has: obj => "sort" in obj, get: obj => obj.sort }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2655
|
+
proxy.__esDecorate(_a, null, _splice_decorators, { kind: "method", name: "splice", static: false, private: false, access: { has: obj => "splice" in obj, get: obj => obj.splice }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2656
|
+
proxy.__esDecorate(_a, null, _unshift_decorators, { kind: "method", name: "unshift", static: false, private: false, access: { has: obj => "unshift" in obj, get: obj => obj.unshift }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
2657
|
+
if (_metadata) Object.defineProperty(_a, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
2658
|
+
})(),
|
|
2659
|
+
_a;
|
|
2660
|
+
})();
|
|
2502
2661
|
|
|
2503
2662
|
/**
|
|
2504
2663
|
* Reactive wrapper around JavaScript's WeakMap class
|
|
@@ -2510,24 +2669,24 @@ class ReactiveWeakMap extends WeakMap {
|
|
|
2510
2669
|
const hadKey = this.has(key);
|
|
2511
2670
|
const result = this.delete(key);
|
|
2512
2671
|
if (hadKey)
|
|
2513
|
-
|
|
2672
|
+
proxy.touched1(proxy.contentRef(this), { type: 'del', prop: key }, key);
|
|
2514
2673
|
return result;
|
|
2515
2674
|
}
|
|
2516
2675
|
get(key) {
|
|
2517
|
-
|
|
2518
|
-
return
|
|
2676
|
+
proxy.dependant(proxy.contentRef(this), key);
|
|
2677
|
+
return proxy.reactive(this.get(key));
|
|
2519
2678
|
}
|
|
2520
2679
|
has(key) {
|
|
2521
|
-
|
|
2680
|
+
proxy.dependant(proxy.contentRef(this), key);
|
|
2522
2681
|
return this.has(key);
|
|
2523
2682
|
}
|
|
2524
2683
|
set(key, value) {
|
|
2525
2684
|
const hadKey = this.has(key);
|
|
2526
2685
|
const oldValue = this.get(key);
|
|
2527
|
-
const reactiveValue =
|
|
2686
|
+
const reactiveValue = proxy.reactive(value);
|
|
2528
2687
|
this.set(key, reactiveValue);
|
|
2529
2688
|
if (!hadKey || oldValue !== reactiveValue) {
|
|
2530
|
-
|
|
2689
|
+
proxy.notifyPropertyChange(proxy.contentRef(this), key, oldValue, reactiveValue, hadKey);
|
|
2531
2690
|
}
|
|
2532
2691
|
return this;
|
|
2533
2692
|
}
|
|
@@ -2539,7 +2698,7 @@ class ReactiveWeakMap extends WeakMap {
|
|
|
2539
2698
|
class ReactiveMap extends Map {
|
|
2540
2699
|
// Implement Map interface methods with reactivity
|
|
2541
2700
|
get size() {
|
|
2542
|
-
|
|
2701
|
+
proxy.dependant(this, 'size'); // The ReactiveMap instance still goes through proxy
|
|
2543
2702
|
return this.size;
|
|
2544
2703
|
}
|
|
2545
2704
|
clear() {
|
|
@@ -2548,28 +2707,28 @@ class ReactiveMap extends Map {
|
|
|
2548
2707
|
if (hadEntries) {
|
|
2549
2708
|
const evolution = { type: 'bunch', method: 'clear' };
|
|
2550
2709
|
// Clear triggers all effects since all keys are affected
|
|
2551
|
-
|
|
2552
|
-
|
|
2710
|
+
proxy.touched1(this, evolution, 'size');
|
|
2711
|
+
proxy.touched(proxy.contentRef(this), evolution);
|
|
2553
2712
|
}
|
|
2554
2713
|
}
|
|
2555
2714
|
entries() {
|
|
2556
|
-
|
|
2715
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2557
2716
|
return makeReactiveEntriesIterator(this.entries());
|
|
2558
2717
|
}
|
|
2559
2718
|
forEach(callbackfn, thisArg) {
|
|
2560
|
-
|
|
2719
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2561
2720
|
this.forEach(callbackfn, thisArg);
|
|
2562
2721
|
}
|
|
2563
2722
|
keys() {
|
|
2564
|
-
|
|
2723
|
+
proxy.dependant(proxy.contentRef(this), proxy.keysOf);
|
|
2565
2724
|
return this.keys();
|
|
2566
2725
|
}
|
|
2567
2726
|
values() {
|
|
2568
|
-
|
|
2727
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2569
2728
|
return makeReactiveIterator(this.values());
|
|
2570
2729
|
}
|
|
2571
2730
|
[Symbol.iterator]() {
|
|
2572
|
-
|
|
2731
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2573
2732
|
const it = Map.prototype[Symbol.iterator].call(this);
|
|
2574
2733
|
const nativeNext = it.next.bind(it);
|
|
2575
2734
|
it.next = () => {
|
|
@@ -2577,7 +2736,7 @@ class ReactiveMap extends Map {
|
|
|
2577
2736
|
if (result.done)
|
|
2578
2737
|
return result;
|
|
2579
2738
|
const [key, value] = result.value;
|
|
2580
|
-
return { value: [
|
|
2739
|
+
return { value: [proxy.reactive(key), proxy.reactive(value)], done: false };
|
|
2581
2740
|
};
|
|
2582
2741
|
return it;
|
|
2583
2742
|
}
|
|
@@ -2587,29 +2746,29 @@ class ReactiveMap extends Map {
|
|
|
2587
2746
|
const result = this.delete(key);
|
|
2588
2747
|
if (hadKey) {
|
|
2589
2748
|
const evolution = { type: 'del', prop: key };
|
|
2590
|
-
|
|
2591
|
-
|
|
2749
|
+
proxy.touched1(proxy.contentRef(this), evolution, key);
|
|
2750
|
+
proxy.touched1(this, evolution, 'size');
|
|
2592
2751
|
}
|
|
2593
2752
|
return result;
|
|
2594
2753
|
}
|
|
2595
2754
|
get(key) {
|
|
2596
|
-
|
|
2597
|
-
return
|
|
2755
|
+
proxy.dependant(proxy.contentRef(this), key);
|
|
2756
|
+
return proxy.reactive(this.get(key));
|
|
2598
2757
|
}
|
|
2599
2758
|
has(key) {
|
|
2600
|
-
|
|
2759
|
+
proxy.dependant(proxy.contentRef(this), key);
|
|
2601
2760
|
return this.has(key);
|
|
2602
2761
|
}
|
|
2603
2762
|
set(key, value) {
|
|
2604
2763
|
const hadKey = this.has(key);
|
|
2605
2764
|
const oldValue = this.get(key);
|
|
2606
|
-
const reactiveValue =
|
|
2765
|
+
const reactiveValue = proxy.reactive(value);
|
|
2607
2766
|
this.set(key, reactiveValue);
|
|
2608
2767
|
if (!hadKey || oldValue !== reactiveValue) {
|
|
2609
|
-
|
|
2768
|
+
proxy.notifyPropertyChange(proxy.contentRef(this), key, oldValue, reactiveValue, hadKey);
|
|
2610
2769
|
// Also notify size change for Map (WeakMap doesn't track size)
|
|
2611
2770
|
const evolution = { type: hadKey ? 'set' : 'add', prop: key };
|
|
2612
|
-
|
|
2771
|
+
proxy.touched1(this, evolution, 'size');
|
|
2613
2772
|
}
|
|
2614
2773
|
return this;
|
|
2615
2774
|
}
|
|
@@ -2625,7 +2784,7 @@ class ReactiveWeakSet extends WeakSet {
|
|
|
2625
2784
|
this.add(value);
|
|
2626
2785
|
if (!had) {
|
|
2627
2786
|
// touch the specific value and the collection view
|
|
2628
|
-
|
|
2787
|
+
proxy.touched1(proxy.contentRef(this), { type: 'add', prop: value }, value);
|
|
2629
2788
|
// no size/allProps for WeakSet
|
|
2630
2789
|
}
|
|
2631
2790
|
return this;
|
|
@@ -2634,11 +2793,11 @@ class ReactiveWeakSet extends WeakSet {
|
|
|
2634
2793
|
const had = this.has(value);
|
|
2635
2794
|
const res = this.delete(value);
|
|
2636
2795
|
if (had)
|
|
2637
|
-
|
|
2796
|
+
proxy.touched1(proxy.contentRef(this), { type: 'del', prop: value }, value);
|
|
2638
2797
|
return res;
|
|
2639
2798
|
}
|
|
2640
2799
|
has(value) {
|
|
2641
|
-
|
|
2800
|
+
proxy.dependant(proxy.contentRef(this), value);
|
|
2642
2801
|
return this.has(value);
|
|
2643
2802
|
}
|
|
2644
2803
|
}
|
|
@@ -2649,18 +2808,18 @@ class ReactiveWeakSet extends WeakSet {
|
|
|
2649
2808
|
class ReactiveSet extends Set {
|
|
2650
2809
|
get size() {
|
|
2651
2810
|
// size depends on the wrapper instance, like Map counterpart
|
|
2652
|
-
|
|
2811
|
+
proxy.dependant(this, 'size');
|
|
2653
2812
|
return this.size;
|
|
2654
2813
|
}
|
|
2655
2814
|
add(value) {
|
|
2656
2815
|
const had = this.has(value);
|
|
2657
|
-
const reactiveValue =
|
|
2816
|
+
const reactiveValue = proxy.reactive(value);
|
|
2658
2817
|
this.add(reactiveValue);
|
|
2659
2818
|
if (!had) {
|
|
2660
2819
|
const evolution = { type: 'add', prop: reactiveValue };
|
|
2661
2820
|
// touch for value-specific and aggregate dependencies
|
|
2662
|
-
|
|
2663
|
-
|
|
2821
|
+
proxy.touched1(proxy.contentRef(this), evolution, reactiveValue);
|
|
2822
|
+
proxy.touched1(this, evolution, 'size');
|
|
2664
2823
|
}
|
|
2665
2824
|
return this;
|
|
2666
2825
|
}
|
|
@@ -2669,8 +2828,8 @@ class ReactiveSet extends Set {
|
|
|
2669
2828
|
this.clear();
|
|
2670
2829
|
if (hadEntries) {
|
|
2671
2830
|
const evolution = { type: 'bunch', method: 'clear' };
|
|
2672
|
-
|
|
2673
|
-
|
|
2831
|
+
proxy.touched1(this, evolution, 'size');
|
|
2832
|
+
proxy.touched(proxy.contentRef(this), evolution);
|
|
2674
2833
|
}
|
|
2675
2834
|
}
|
|
2676
2835
|
delete(value) {
|
|
@@ -2678,64 +2837,67 @@ class ReactiveSet extends Set {
|
|
|
2678
2837
|
const res = this.delete(value);
|
|
2679
2838
|
if (had) {
|
|
2680
2839
|
const evolution = { type: 'del', prop: value };
|
|
2681
|
-
|
|
2682
|
-
|
|
2840
|
+
proxy.touched1(proxy.contentRef(this), evolution, value);
|
|
2841
|
+
proxy.touched1(this, evolution, 'size');
|
|
2683
2842
|
}
|
|
2684
2843
|
return res;
|
|
2685
2844
|
}
|
|
2686
2845
|
has(value) {
|
|
2687
|
-
|
|
2846
|
+
proxy.dependant(proxy.contentRef(this), value);
|
|
2688
2847
|
return this.has(value);
|
|
2689
2848
|
}
|
|
2690
2849
|
entries() {
|
|
2691
|
-
|
|
2850
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2692
2851
|
return makeReactiveEntriesIterator(this.entries());
|
|
2693
2852
|
}
|
|
2694
2853
|
forEach(callbackfn, thisArg) {
|
|
2695
|
-
|
|
2854
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2696
2855
|
this.forEach(callbackfn, thisArg);
|
|
2697
2856
|
}
|
|
2698
2857
|
keys() {
|
|
2699
|
-
|
|
2858
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2700
2859
|
return makeReactiveIterator(this.keys());
|
|
2701
2860
|
}
|
|
2702
2861
|
values() {
|
|
2703
|
-
|
|
2862
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2704
2863
|
return makeReactiveIterator(this.values());
|
|
2705
2864
|
}
|
|
2706
2865
|
[Symbol.iterator]() {
|
|
2707
|
-
|
|
2866
|
+
proxy.dependant(proxy.contentRef(this));
|
|
2708
2867
|
const it = Set.prototype[Symbol.iterator].call(this);
|
|
2709
2868
|
const nativeNext = it.next.bind(it);
|
|
2710
2869
|
it.next = () => {
|
|
2711
2870
|
const result = nativeNext();
|
|
2712
2871
|
if (result.done)
|
|
2713
2872
|
return result;
|
|
2714
|
-
return { value:
|
|
2873
|
+
return { value: proxy.reactive(result.value), done: false };
|
|
2715
2874
|
};
|
|
2716
2875
|
return it;
|
|
2717
2876
|
}
|
|
2718
2877
|
}
|
|
2719
2878
|
|
|
2720
2879
|
// Register native collection types to use specialized reactive wrappers
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2880
|
+
console.time('mutts-reactive-init');
|
|
2881
|
+
proxy.metaProtos.set(Array, ReactiveArray.prototype);
|
|
2882
|
+
proxy.metaProtos.set(Set, ReactiveSet.prototype);
|
|
2883
|
+
proxy.metaProtos.set(WeakSet, ReactiveWeakSet.prototype);
|
|
2884
|
+
proxy.metaProtos.set(Map, ReactiveMap.prototype);
|
|
2885
|
+
proxy.metaProtos.set(WeakMap, ReactiveWeakMap.prototype);
|
|
2886
|
+
proxy.wrapProtos.set(Array, ReactiveArrayWrapper.prototype);
|
|
2887
|
+
console.timeEnd('mutts-reactive-init');
|
|
2726
2888
|
/**
|
|
2727
2889
|
* Object containing internal reactive system state for debugging and profiling
|
|
2728
2890
|
*/
|
|
2729
2891
|
const profileInfo = {
|
|
2730
|
-
objectToProxy:
|
|
2731
|
-
proxyToObject:
|
|
2732
|
-
effectToReactiveObjects:
|
|
2733
|
-
watchers:
|
|
2734
|
-
objectParents:
|
|
2735
|
-
objectsWithDeepWatchers:
|
|
2736
|
-
deepWatchers:
|
|
2737
|
-
effectToDeepWatchedObjects:
|
|
2738
|
-
nonReactiveObjects:
|
|
2892
|
+
objectToProxy: proxy.objectToProxy,
|
|
2893
|
+
proxyToObject: proxy.proxyToObject,
|
|
2894
|
+
effectToReactiveObjects: proxy.effectToReactiveObjects,
|
|
2895
|
+
watchers: proxy.watchers,
|
|
2896
|
+
objectParents: proxy.objectParents,
|
|
2897
|
+
objectsWithDeepWatchers: proxy.objectsWithDeepWatchers,
|
|
2898
|
+
deepWatchers: proxy.deepWatchers,
|
|
2899
|
+
effectToDeepWatchedObjects: proxy.effectToDeepWatchedObjects,
|
|
2900
|
+
nonReactiveObjects: proxy.nonReactiveObjects,
|
|
2739
2901
|
};
|
|
2740
2902
|
|
|
2741
2903
|
// In order to avoid async re-entrance, we could use zone.js or something like that.
|
|
@@ -2744,7 +2906,7 @@ const syncCalculating = [];
|
|
|
2744
2906
|
* Decorator that caches the result of a getter method and only recomputes when dependencies change
|
|
2745
2907
|
* Prevents circular dependencies and provides automatic cache invalidation
|
|
2746
2908
|
*/
|
|
2747
|
-
const cached =
|
|
2909
|
+
const cached = proxy.decorator({
|
|
2748
2910
|
getter(original, _target, propertyKey) {
|
|
2749
2911
|
return function () {
|
|
2750
2912
|
const alreadyCalculating = syncCalculating.findIndex((c) => c.object === this && c.prop === propertyKey);
|
|
@@ -2788,7 +2950,7 @@ function cache(object, propertyKey, value) {
|
|
|
2788
2950
|
* @param descriptor - The descriptor properties to apply
|
|
2789
2951
|
* @returns A class decorator that applies the descriptor to specified properties
|
|
2790
2952
|
*/
|
|
2791
|
-
const descriptor =
|
|
2953
|
+
const descriptor = proxy.flavored(function descriptor(descriptor) {
|
|
2792
2954
|
return (...properties) => (Base) => {
|
|
2793
2955
|
return class extends Base {
|
|
2794
2956
|
constructor(...args) {
|
|
@@ -2842,7 +3004,7 @@ const descriptor = debug.flavored(function descriptor(descriptor) {
|
|
|
2842
3004
|
* Decorator that marks methods, properties, or classes as deprecated
|
|
2843
3005
|
* Provides warning messages when deprecated items are used
|
|
2844
3006
|
*/
|
|
2845
|
-
const deprecated = Object.assign(
|
|
3007
|
+
const deprecated = Object.assign(proxy.decorator({
|
|
2846
3008
|
method(original, _target, propertyKey) {
|
|
2847
3009
|
return function (...args) {
|
|
2848
3010
|
deprecated.warn(this, propertyKey);
|
|
@@ -2870,7 +3032,7 @@ const deprecated = Object.assign(debug.decorator({
|
|
|
2870
3032
|
};
|
|
2871
3033
|
},
|
|
2872
3034
|
default(message) {
|
|
2873
|
-
return
|
|
3035
|
+
return proxy.decorator({
|
|
2874
3036
|
method(original, _target, propertyKey) {
|
|
2875
3037
|
return function (...args) {
|
|
2876
3038
|
deprecated.warn(this, propertyKey, message);
|
|
@@ -2911,7 +3073,7 @@ const deprecated = Object.assign(debug.decorator({
|
|
|
2911
3073
|
* @returns A method decorator that debounces method calls
|
|
2912
3074
|
*/
|
|
2913
3075
|
function debounce(delay) {
|
|
2914
|
-
return
|
|
3076
|
+
return proxy.decorator({
|
|
2915
3077
|
method(original, _target, _propertyKey) {
|
|
2916
3078
|
let timeoutId = null;
|
|
2917
3079
|
return function (...args) {
|
|
@@ -2934,7 +3096,7 @@ function debounce(delay) {
|
|
|
2934
3096
|
* @returns A method decorator that throttles method calls
|
|
2935
3097
|
*/
|
|
2936
3098
|
function throttle(delay) {
|
|
2937
|
-
return
|
|
3099
|
+
return proxy.decorator({
|
|
2938
3100
|
method(original, _target, _propertyKey) {
|
|
2939
3101
|
let lastCallTime = 0;
|
|
2940
3102
|
let timeoutId = null;
|
|
@@ -2965,7 +3127,7 @@ function throttle(delay) {
|
|
|
2965
3127
|
});
|
|
2966
3128
|
}
|
|
2967
3129
|
|
|
2968
|
-
var version$1 = "1.0.
|
|
3130
|
+
var version$1 = "1.0.10";
|
|
2969
3131
|
var pkg = {
|
|
2970
3132
|
version: version$1};
|
|
2971
3133
|
|
|
@@ -2982,6 +3144,7 @@ const globalScope = (typeof globalThis !== 'undefined'
|
|
|
2982
3144
|
if (globalScope) {
|
|
2983
3145
|
// Detect the source of this instance safely across different environments
|
|
2984
3146
|
let source = 'mutts/index';
|
|
3147
|
+
// biome-ignore lint/security/noGlobalEval: Intentional eval for cross-env import.meta detection
|
|
2985
3148
|
const viteEval = eval;
|
|
2986
3149
|
try {
|
|
2987
3150
|
if (typeof __filename !== 'undefined')
|
|
@@ -3013,63 +3176,63 @@ if (globalScope) {
|
|
|
3013
3176
|
globalScope[GLOBAL_MUTTS_KEY] = currentSourceInfo;
|
|
3014
3177
|
}
|
|
3015
3178
|
|
|
3016
|
-
exports.AZone =
|
|
3017
|
-
exports.DecoratorError =
|
|
3018
|
-
exports.
|
|
3019
|
-
exports.
|
|
3020
|
-
exports.
|
|
3021
|
-
exports.
|
|
3022
|
-
exports.ReactiveError = debug.ReactiveError;
|
|
3179
|
+
exports.AZone = proxy.AZone;
|
|
3180
|
+
exports.DecoratorError = proxy.DecoratorError;
|
|
3181
|
+
exports.IterableWeakMap = proxy.IterableWeakMap;
|
|
3182
|
+
exports.IterableWeakSet = proxy.IterableWeakSet;
|
|
3183
|
+
exports.ReactiveBase = proxy.ReactiveBase;
|
|
3184
|
+
exports.ReactiveError = proxy.ReactiveError;
|
|
3023
3185
|
Object.defineProperty(exports, "ReactiveErrorCode", {
|
|
3024
3186
|
enumerable: true,
|
|
3025
|
-
get: function () { return
|
|
3187
|
+
get: function () { return proxy.ReactiveErrorCode; }
|
|
3026
3188
|
});
|
|
3027
|
-
exports.Zone =
|
|
3028
|
-
exports.ZoneAggregator =
|
|
3029
|
-
exports.ZoneHistory =
|
|
3030
|
-
exports.addBatchCleanup =
|
|
3031
|
-
exports.arrayEquals =
|
|
3032
|
-
exports.asyncZone =
|
|
3033
|
-
exports.
|
|
3034
|
-
exports.
|
|
3035
|
-
exports.
|
|
3036
|
-
exports.
|
|
3037
|
-
exports.
|
|
3038
|
-
exports.
|
|
3039
|
-
exports.
|
|
3040
|
-
exports.
|
|
3041
|
-
exports.
|
|
3042
|
-
exports.
|
|
3043
|
-
exports.effect =
|
|
3044
|
-
exports.effectAggregator =
|
|
3045
|
-
exports.flavorOptions =
|
|
3046
|
-
exports.flavored =
|
|
3047
|
-
exports.
|
|
3048
|
-
exports.
|
|
3049
|
-
exports.
|
|
3050
|
-
exports.
|
|
3051
|
-
exports.
|
|
3052
|
-
exports.
|
|
3053
|
-
exports.
|
|
3054
|
-
exports.
|
|
3055
|
-
exports.
|
|
3056
|
-
exports.
|
|
3057
|
-
exports.
|
|
3058
|
-
exports.
|
|
3059
|
-
exports.
|
|
3060
|
-
exports.
|
|
3061
|
-
exports.
|
|
3062
|
-
exports.
|
|
3063
|
-
exports.
|
|
3064
|
-
exports.
|
|
3065
|
-
exports.reset =
|
|
3066
|
-
exports.root =
|
|
3067
|
-
exports.
|
|
3068
|
-
exports.
|
|
3069
|
-
exports.
|
|
3070
|
-
exports.
|
|
3071
|
-
exports.
|
|
3072
|
-
exports.
|
|
3189
|
+
exports.Zone = proxy.Zone;
|
|
3190
|
+
exports.ZoneAggregator = proxy.ZoneAggregator;
|
|
3191
|
+
exports.ZoneHistory = proxy.ZoneHistory;
|
|
3192
|
+
exports.addBatchCleanup = proxy.addBatchCleanup;
|
|
3193
|
+
exports.arrayEquals = proxy.arrayEquals;
|
|
3194
|
+
exports.asyncZone = proxy.asyncZone;
|
|
3195
|
+
exports.atom = proxy.atom;
|
|
3196
|
+
exports.atomic = proxy.atomic;
|
|
3197
|
+
exports.biDi = proxy.biDi;
|
|
3198
|
+
exports.caught = proxy.caught;
|
|
3199
|
+
exports.cleanedBy = proxy.cleanedBy;
|
|
3200
|
+
exports.cleanup = proxy.cleanup;
|
|
3201
|
+
exports.createFlavor = proxy.createFlavor;
|
|
3202
|
+
exports.decorator = proxy.decorator;
|
|
3203
|
+
exports.deepCompare = proxy.deepCompare;
|
|
3204
|
+
exports.defer = proxy.defer;
|
|
3205
|
+
exports.effect = proxy.effect;
|
|
3206
|
+
exports.effectAggregator = proxy.effectAggregator;
|
|
3207
|
+
exports.flavorOptions = proxy.flavorOptions;
|
|
3208
|
+
exports.flavored = proxy.flavored;
|
|
3209
|
+
exports.formatCleanupReason = proxy.formatCleanupReason;
|
|
3210
|
+
exports.getActivationLog = proxy.getActivationLog;
|
|
3211
|
+
exports.getActiveEffect = proxy.getActiveEffect;
|
|
3212
|
+
exports.getState = proxy.getState;
|
|
3213
|
+
exports.immutables = proxy.immutables;
|
|
3214
|
+
exports.isConstructor = proxy.isConstructor;
|
|
3215
|
+
exports.isNonReactive = proxy.isNonReactive;
|
|
3216
|
+
exports.isObject = proxy.isObject;
|
|
3217
|
+
exports.isReactive = proxy.isReactive;
|
|
3218
|
+
exports.legacyDecorator = proxy.legacyDecorator;
|
|
3219
|
+
exports.mixin = proxy.mixin;
|
|
3220
|
+
exports.modernDecorator = proxy.modernDecorator;
|
|
3221
|
+
exports.named = proxy.named;
|
|
3222
|
+
exports.objectToProxy = proxy.objectToProxy;
|
|
3223
|
+
exports.onEffectThrow = proxy.onEffectThrow;
|
|
3224
|
+
exports.proxyToObject = proxy.proxyToObject;
|
|
3225
|
+
exports.reactive = proxy.reactive;
|
|
3226
|
+
exports.reactiveOptions = proxy.options;
|
|
3227
|
+
exports.reset = proxy.reset;
|
|
3228
|
+
exports.root = proxy.root;
|
|
3229
|
+
exports.stopped = proxy.stopped;
|
|
3230
|
+
exports.tag = proxy.tag;
|
|
3231
|
+
exports.touched = proxy.touched;
|
|
3232
|
+
exports.touched1 = proxy.touched1;
|
|
3233
|
+
exports.untracked = proxy.untracked;
|
|
3234
|
+
exports.unwrap = proxy.unwrap;
|
|
3235
|
+
exports.zip = proxy.zip;
|
|
3073
3236
|
exports.asyncHook = asyncCore.asyncHook;
|
|
3074
3237
|
exports.asyncHooks = asyncCore.asyncHooks;
|
|
3075
3238
|
exports.hooks = asyncCore.hooks;
|
|
@@ -3081,6 +3244,7 @@ exports.Indexable = Indexable;
|
|
|
3081
3244
|
exports.Register = Register;
|
|
3082
3245
|
exports.allocated = allocated;
|
|
3083
3246
|
exports.allocatedValues = allocatedValues;
|
|
3247
|
+
exports.arrayDiff = arrayDiff;
|
|
3084
3248
|
exports.attend = attend;
|
|
3085
3249
|
exports.cache = cache;
|
|
3086
3250
|
exports.cached = cached;
|
|
@@ -3089,23 +3253,24 @@ exports.chainPromise = chainPromise;
|
|
|
3089
3253
|
exports.debounce = debounce;
|
|
3090
3254
|
exports.deepWatch = deepWatch;
|
|
3091
3255
|
exports.deprecated = deprecated;
|
|
3092
|
-
exports.describe = describe;
|
|
3093
3256
|
exports.descriptor = descriptor;
|
|
3094
3257
|
exports.destructor = destructor;
|
|
3095
3258
|
exports.forwardArray = forwardArray;
|
|
3096
|
-
exports.getActiveProjection = getActiveProjection;
|
|
3097
3259
|
exports.getAt = getAt;
|
|
3098
3260
|
exports.isCached = isCached;
|
|
3099
3261
|
exports.lift = lift;
|
|
3100
3262
|
exports.memoize = memoize;
|
|
3263
|
+
exports.morph = morph;
|
|
3101
3264
|
exports.organize = organize;
|
|
3102
3265
|
exports.organized = organized;
|
|
3103
3266
|
exports.profileInfo = profileInfo;
|
|
3104
|
-
exports.project =
|
|
3267
|
+
exports.project = morph;
|
|
3105
3268
|
exports.register = register;
|
|
3269
|
+
exports.resource = resource;
|
|
3106
3270
|
exports.scan = scan;
|
|
3107
3271
|
exports.setAt = setAt;
|
|
3108
3272
|
exports.throttle = throttle;
|
|
3109
3273
|
exports.unreactive = unreactive;
|
|
3110
3274
|
exports.watch = watch;
|
|
3275
|
+
exports.when = when;
|
|
3111
3276
|
//# sourceMappingURL=browser.cjs.map
|