@sigil-dev/runtime 0.9.16 → 0.9.18
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/index.test.ts +26 -0
- package/index.ts +11 -1
- package/package.json +9 -2
- package/reactivity/map.ts +4 -4
- package/reactivity/set.ts +4 -4
- package/test-preload.ts +2 -0
- package/transition.ts +1 -1
package/index.test.ts
CHANGED
|
@@ -2001,6 +2001,32 @@ describe("collectEffects", () => {
|
|
|
2001
2001
|
expect(ran).toEqual(["second", "first"]);
|
|
2002
2002
|
});
|
|
2003
2003
|
|
|
2004
|
+
test("an effect that throws doesn't stop the others", () => {
|
|
2005
|
+
const ran: string[] = [];
|
|
2006
|
+
const { flush } = collectEffects(() => {
|
|
2007
|
+
createEffect(() => {
|
|
2008
|
+
throw new Error("boom");
|
|
2009
|
+
});
|
|
2010
|
+
createEffect(() => void ran.push("after"));
|
|
2011
|
+
});
|
|
2012
|
+
const original = globalThis.queueMicrotask;
|
|
2013
|
+
const reported: unknown[] = [];
|
|
2014
|
+
globalThis.queueMicrotask = (fn: () => void) => {
|
|
2015
|
+
try {
|
|
2016
|
+
fn();
|
|
2017
|
+
} catch (e) {
|
|
2018
|
+
reported.push(e);
|
|
2019
|
+
}
|
|
2020
|
+
};
|
|
2021
|
+
try {
|
|
2022
|
+
flush();
|
|
2023
|
+
} finally {
|
|
2024
|
+
globalThis.queueMicrotask = original;
|
|
2025
|
+
}
|
|
2026
|
+
expect(ran).toEqual(["after"]);
|
|
2027
|
+
expect(String(reported[0])).toContain("boom");
|
|
2028
|
+
});
|
|
2029
|
+
|
|
2004
2030
|
test("effects outside it run straight away again", () => {
|
|
2005
2031
|
collectEffects(() => {});
|
|
2006
2032
|
let ran = 0;
|
package/index.ts
CHANGED
|
@@ -461,8 +461,18 @@ export function collectEffects<T>(fn: () => T): {
|
|
|
461
461
|
}
|
|
462
462
|
return {
|
|
463
463
|
value,
|
|
464
|
+
// one effect that throws must not stop the rest (or the page swap the
|
|
465
|
+
// flush runs in); the error is still reported, as an uncaught one
|
|
464
466
|
flush: () => {
|
|
465
|
-
for (const run of queue.splice(0))
|
|
467
|
+
for (const run of queue.splice(0)) {
|
|
468
|
+
try {
|
|
469
|
+
run();
|
|
470
|
+
} catch (e) {
|
|
471
|
+
queueMicrotask(() => {
|
|
472
|
+
throw e;
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
466
476
|
},
|
|
467
477
|
};
|
|
468
478
|
}
|
package/package.json
CHANGED
|
@@ -2,8 +2,15 @@
|
|
|
2
2
|
"name": "@sigil-dev/runtime",
|
|
3
3
|
"module": "index.ts",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "0.9.
|
|
6
|
-
"description": "
|
|
5
|
+
"version": "0.9.18",
|
|
6
|
+
"description": "Signals and fine-grained DOM updates for compiled Sigil components",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://sigil.cane1712.dev/docs/reference/runtime",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://git.cane1712.dev/sigil/sigil.git",
|
|
12
|
+
"directory": "packages/runtime"
|
|
13
|
+
},
|
|
7
14
|
"private": false,
|
|
8
15
|
"devDependencies": {
|
|
9
16
|
"@types/bun": "latest",
|
package/reactivity/map.ts
CHANGED
|
@@ -76,22 +76,22 @@ export class ReactiveMap<K, V> extends Map<K, V> {
|
|
|
76
76
|
return super.size;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
entries():
|
|
79
|
+
entries(): ReturnType<Map<K, V>["entries"]> {
|
|
80
80
|
this.#structVersion();
|
|
81
81
|
return super.entries();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
keys():
|
|
84
|
+
keys(): ReturnType<Map<K, V>["keys"]> {
|
|
85
85
|
this.#structVersion();
|
|
86
86
|
return super.keys();
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
values():
|
|
89
|
+
values(): ReturnType<Map<K, V>["values"]> {
|
|
90
90
|
this.#structVersion();
|
|
91
91
|
return super.values();
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
[Symbol.iterator]():
|
|
94
|
+
[Symbol.iterator](): ReturnType<Map<K, V>[typeof Symbol.iterator]> {
|
|
95
95
|
this.#structVersion();
|
|
96
96
|
return super[Symbol.iterator]();
|
|
97
97
|
}
|
package/reactivity/set.ts
CHANGED
|
@@ -52,22 +52,22 @@ export class ReactiveSet<T> extends Set<T> {
|
|
|
52
52
|
return super.size;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
entries():
|
|
55
|
+
entries(): ReturnType<Set<T>["entries"]> {
|
|
56
56
|
this.#version();
|
|
57
57
|
return super.entries();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
keys():
|
|
60
|
+
keys(): ReturnType<Set<T>["keys"]> {
|
|
61
61
|
this.#version();
|
|
62
62
|
return super.keys();
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
values():
|
|
65
|
+
values(): ReturnType<Set<T>["values"]> {
|
|
66
66
|
this.#version();
|
|
67
67
|
return super.values();
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
[Symbol.iterator]():
|
|
70
|
+
[Symbol.iterator](): ReturnType<Set<T>[typeof Symbol.iterator]> {
|
|
71
71
|
this.#version();
|
|
72
72
|
return super[Symbol.iterator]();
|
|
73
73
|
}
|
package/test-preload.ts
CHANGED
|
@@ -7,3 +7,5 @@ const window = new Window();
|
|
|
7
7
|
(globalThis as any).Node = window.Node;
|
|
8
8
|
(globalThis as any).HTMLElement = window.HTMLElement;
|
|
9
9
|
(globalThis as any).Comment = window.Comment;
|
|
10
|
+
// events the tests dispatch must be the DOM's own: happy-dom refuses Bun's
|
|
11
|
+
(globalThis as any).Event = window.Event;
|
package/transition.ts
CHANGED