@ilha/router 0.11.2 → 0.11.4
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 +75 -66
- package/dist/codegen.d.ts +3 -3
- package/dist/hash.d.ts +13 -9
- package/dist/head-BLtm0xtK.js +342 -0
- package/dist/head.d.ts +42 -28
- package/dist/http.d.ts +1 -1
- package/dist/index.d.ts +52 -55
- package/dist/index.js +339 -305
- package/dist/plugin-DCdQ9yO8.js +1140 -0
- package/dist/plugin.d.ts +15 -15
- package/dist/request-scope.d.ts +3 -5
- package/dist/route-error.d.ts +6 -0
- package/dist/route-match.d.ts +3 -3
- package/dist/rsbuild.d.ts +3 -3
- package/dist/rsbuild.js +2 -4
- package/dist/server-island.d.ts +26 -15
- package/dist/server-island.js +166 -136
- package/dist/server-islands.d.ts +15 -14
- package/dist/snapshot-XpAkSV8s.js +57 -0
- package/dist/snapshot.d.ts +15 -2
- package/dist/{ssr-CV_vNpS3.js → ssr-Dvq_qXs4.js} +170 -142
- package/dist/ssr.d.ts +38 -39
- package/dist/ssr.js +2 -2
- package/dist/vite.d.ts +3 -3
- package/dist/vite.js +2 -4
- package/oxlint.cjs +201 -122
- package/package.json +3 -3
- package/dist/head-DpYV3bHH.js +0 -285
- package/dist/plugin-Bfnn44nu.js +0 -1034
- package/dist/snapshot-C0E2OGwL.js +0 -55
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
//#region src/snapshot.ts
|
|
2
|
-
/**
|
|
3
|
-
* Defensive parser for `data-ilha-state` / `data-ilha-props` snapshot
|
|
4
|
-
* attributes on the router side. Mirrors the core ilha guards: size cap,
|
|
5
|
-
* plain-object check, depth cap, and prototype-key stripping. Returns
|
|
6
|
-
* undefined (degrade gracefully) on any failure.
|
|
7
|
-
*/
|
|
8
|
-
const MAX_SNAPSHOT_CHARS = 262144;
|
|
9
|
-
const MAX_SNAPSHOT_DEPTH = 32;
|
|
10
|
-
const UNSAFE_SNAPSHOT_KEYS = /* @__PURE__ */ new Set([
|
|
11
|
-
"__proto__",
|
|
12
|
-
"constructor",
|
|
13
|
-
"prototype"
|
|
14
|
-
]);
|
|
15
|
-
function stripUnsafeKeys(value) {
|
|
16
|
-
if (value === null || typeof value !== "object") return;
|
|
17
|
-
if (Array.isArray(value)) {
|
|
18
|
-
for (const item of value) stripUnsafeKeys(item);
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
for (const key of Object.getOwnPropertyNames(value)) if (UNSAFE_SNAPSHOT_KEYS.has(key)) delete value[key];
|
|
22
|
-
else stripUnsafeKeys(value[key]);
|
|
23
|
-
}
|
|
24
|
-
function exceedsDepth(value, depth) {
|
|
25
|
-
if (depth > MAX_SNAPSHOT_DEPTH) return true;
|
|
26
|
-
if (value === null || typeof value !== "object") return false;
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
for (const item of value) if (exceedsDepth(item, depth + 1)) return true;
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
for (const key in value) {
|
|
32
|
-
if (!Object.hasOwn(value, key)) continue;
|
|
33
|
-
if (exceedsDepth(value[key], depth + 1)) return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
function sanitizeSnapshotObject(value) {
|
|
38
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) return void 0;
|
|
39
|
-
if (exceedsDepth(value, 1)) return void 0;
|
|
40
|
-
stripUnsafeKeys(value);
|
|
41
|
-
return value;
|
|
42
|
-
}
|
|
43
|
-
function parseSnapshotAttr(raw) {
|
|
44
|
-
if (raw.length > MAX_SNAPSHOT_CHARS) return void 0;
|
|
45
|
-
let parsed;
|
|
46
|
-
try {
|
|
47
|
-
parsed = JSON.parse(raw);
|
|
48
|
-
} catch {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
return sanitizeSnapshotObject(parsed);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
export { sanitizeSnapshotObject as n, parseSnapshotAttr as t };
|