@esportsplus/reactivity 0.33.0 → 0.36.0
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 +9 -7
- package/bench/reactive/array.bench.ts +17 -17
- package/build/compiler/array.d.ts +2 -2
- package/build/compiler/array.js +12 -54
- package/build/compiler/constants.d.ts +4 -4
- package/build/compiler/constants.js +20 -4
- package/build/compiler/index.js +25 -38
- package/build/compiler/object.d.ts +2 -2
- package/build/compiler/object.js +10 -21
- package/build/compiler/plugins/vite.d.ts +4 -2
- package/build/compiler/primitives.d.ts +6 -2
- package/build/compiler/primitives.js +35 -42
- package/build/compiler/types.d.ts +3 -1
- package/build/constants.d.ts +2 -2
- package/build/constants.js +2 -2
- package/build/reactive/array.d.ts +1 -1
- package/build/reactive/array.js +26 -15
- package/build/reactive/index.js +5 -14
- package/build/reactive/object.js +1 -1
- package/build/system.d.ts +10 -13
- package/build/system.js +105 -83
- package/build/types.d.ts +2 -7
- package/package.json +5 -5
- package/pnpm-workspace.yaml +3 -0
- package/src/compiler/array.ts +14 -64
- package/src/compiler/constants.ts +21 -5
- package/src/compiler/index.ts +39 -70
- package/src/compiler/object.ts +12 -29
- package/src/compiler/primitives.ts +55 -53
- package/src/compiler/types.ts +4 -1
- package/src/constants.ts +4 -4
- package/src/reactive/array.ts +33 -17
- package/src/reactive/index.ts +5 -17
- package/src/reactive/object.ts +1 -1
- package/src/system.ts +138 -101
- package/src/types.ts +2 -9
- package/test/async-computed.test.ts +2 -2
- package/test/compiler/compiler.test.ts +40 -23
- package/test/effects.test.ts +37 -1
- package/test/lib/uncaught.ts +26 -0
- package/test/reactive/array.test.ts +169 -99
- package/test/reactive/nested.test.ts +14 -14
- package/test/reactive/objects.test.ts +1 -1
- package/test/reactive/reactive.test.ts +49 -0
- package/test/system.test.ts +130 -22
package/test/effects.test.ts
CHANGED
|
@@ -182,7 +182,7 @@ describe('effect patterns', () => {
|
|
|
182
182
|
|
|
183
183
|
describe('effect with reactive array', () => {
|
|
184
184
|
it('effect tracks array length changes', async () => {
|
|
185
|
-
let arr = new ReactiveArray(1, 2, 3),
|
|
185
|
+
let arr = new ReactiveArray([1, 2, 3]),
|
|
186
186
|
runs = 0,
|
|
187
187
|
lengths: number[] = [];
|
|
188
188
|
|
|
@@ -331,3 +331,39 @@ describe('effect apply phase', () => {
|
|
|
331
331
|
expect(applied).toEqual([101, 202]);
|
|
332
332
|
});
|
|
333
333
|
});
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
describe('scheduling from a top-level creation run', () => {
|
|
337
|
+
it('a write issued by a top-level effect creation propagates', async () => {
|
|
338
|
+
let runs = 0,
|
|
339
|
+
s = signal(0);
|
|
340
|
+
|
|
341
|
+
effect(() => {
|
|
342
|
+
read(s);
|
|
343
|
+
runs++;
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
effect(() => {
|
|
347
|
+
write(s, 5);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
await waitFor(() => runs === 2, 'the reader re-runs');
|
|
351
|
+
|
|
352
|
+
expect(read(s)).toBe(5);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
it('a deferred inner effect created by a top-level effect creation runs', async () => {
|
|
356
|
+
let inner = 0,
|
|
357
|
+
s = signal(0);
|
|
358
|
+
|
|
359
|
+
effect(() => {
|
|
360
|
+
read(s);
|
|
361
|
+
|
|
362
|
+
effect(() => {
|
|
363
|
+
inner++;
|
|
364
|
+
});
|
|
365
|
+
});
|
|
366
|
+
|
|
367
|
+
await waitFor(() => inner === 1, 'the inner effect runs');
|
|
368
|
+
});
|
|
369
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const captureUncaught = async (fn: () => void): Promise<unknown[]> => {
|
|
2
|
+
let captured: unknown[] = [],
|
|
3
|
+
previous = process.listeners('uncaughtException');
|
|
4
|
+
|
|
5
|
+
process.removeAllListeners('uncaughtException');
|
|
6
|
+
process.on('uncaughtException', (e) => { captured.push(e); });
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
fn();
|
|
10
|
+
|
|
11
|
+
await Promise.resolve();
|
|
12
|
+
await Promise.resolve();
|
|
13
|
+
}
|
|
14
|
+
finally {
|
|
15
|
+
process.removeAllListeners('uncaughtException');
|
|
16
|
+
|
|
17
|
+
for (let i = 0, n = previous.length; i < n; i++) {
|
|
18
|
+
process.on('uncaughtException', previous[i]);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return captured;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export { captureUncaught };
|