@real-router/svelte 0.15.17 → 0.16.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.
|
@@ -55,9 +55,24 @@
|
|
|
55
55
|
|
|
56
56
|
if (sink) {
|
|
57
57
|
// svelte-ignore state_referenced_locally
|
|
58
|
-
// Intentional one-time
|
|
58
|
+
// Intentional one-time read at component init: the sink is read by the
|
|
59
59
|
// server after `await render()` and a single value is the contract.
|
|
60
|
-
// Consumers that need to update the code mid-render should remount.
|
|
61
|
-
|
|
60
|
+
// Consumers that need to update the code mid-render should remount. Captured
|
|
61
|
+
// into a local so the validation + write below don't re-reference the prop.
|
|
62
|
+
const value = code;
|
|
63
|
+
|
|
64
|
+
// Dev-only validation: Node's `res.end()` throws `Invalid status code` on
|
|
65
|
+
// NaN / 0 / negative / non-integer / >999. Surface the bad value at the
|
|
66
|
+
// source; production builds strip the `process.env.NODE_ENV` check.
|
|
67
|
+
if (
|
|
68
|
+
process.env.NODE_ENV !== "production" &&
|
|
69
|
+
(!Number.isInteger(value) || value < 100 || value > 999)
|
|
70
|
+
) {
|
|
71
|
+
console.error(
|
|
72
|
+
`[real-router] <HttpStatusCode code={${String(value)}} /> received an invalid HTTP status code. Node's res.end() rejects values that are not an integer in [100, 999] — pass a real HTTP status (commonly 4xx/5xx).`,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
sink.code = value;
|
|
62
77
|
}
|
|
63
78
|
</script>
|
|
@@ -20,7 +20,21 @@
|
|
|
20
20
|
state = { status: "loading" };
|
|
21
21
|
let active = true;
|
|
22
22
|
|
|
23
|
-
loader()
|
|
23
|
+
// Isolate a synchronously-throwing loader (#1476): a loader that throws
|
|
24
|
+
// *before* returning its promise (init work before the dynamic import) would
|
|
25
|
+
// otherwise escape the `.catch` below — the async channel only covers the
|
|
26
|
+
// returned promise — and bypass the error UI. The try/catch routes a sync
|
|
27
|
+
// throw into the same rejection path as an async failure, while still
|
|
28
|
+
// invoking the loader synchronously on mount (throw-isolation class, #806).
|
|
29
|
+
let pending: Promise<{ default: Component }>;
|
|
30
|
+
|
|
31
|
+
try {
|
|
32
|
+
pending = loader();
|
|
33
|
+
} catch (err) {
|
|
34
|
+
pending = Promise.reject(err);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pending
|
|
24
38
|
.then((module) => {
|
|
25
39
|
if (!active) return;
|
|
26
40
|
if (!module || typeof module.default === "undefined") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Svelte 5 integration for Real-Router",
|
|
6
6
|
"svelte": "./dist/index.js",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@real-router/core": "^0.76.0",
|
|
52
52
|
"@real-router/route-utils": "^0.2.8",
|
|
53
|
-
"@real-router/sources": "^0.11.
|
|
53
|
+
"@real-router/sources": "^0.11.3"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@sveltejs/package": "2.5.8",
|