@ogygia/core 0.11.3 → 0.11.5
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 +1 -1
- package/dist/KeepHost.svelte +1 -1
- package/dist/LiveHost.svelte +1 -1
- package/dist/NestedProvider.svelte +1 -1
- package/dist/SlotBoundary.svelte +1 -1
- package/dist/compiler/driver.js +53 -11
- package/dist/compiler/ids.d.ts +3 -0
- package/dist/compiler/ids.js +4 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/compiler/index.js +2 -2
- package/dist/compiler/kit.d.ts +7 -0
- package/dist/compiler/kit.js +22 -10
- package/dist/compiler/link/runtime-entry.d.ts +19 -2
- package/dist/compiler/link/runtime-entry.js +34 -1
- package/dist/compiler/program.d.ts +4 -0
- package/dist/compiler/program.js +5 -1
- package/dist/context.d.ts +3 -12
- package/dist/context.js +1 -16
- package/dist/hooks.d.ts +2 -1
- package/dist/internal.d.ts +2 -1
- package/dist/internal.js +2 -1
- package/dist/kit-handle.d.ts +20 -0
- package/dist/kit-handle.js +0 -0
- package/dist/nested.d.ts +11 -0
- package/dist/nested.js +19 -0
- package/dist/plugin/index.d.ts +3 -4
- package/dist/plugin/server.d.ts +3 -2
- package/dist/ref-sink.d.ts +15 -0
- package/dist/ref-sink.js +19 -0
- package/dist/ref.d.ts +2 -2
- package/dist/ref.js +1 -11
- package/dist/runtime/core.js +7 -5
- package/dist/runtime/full.js +5 -1
- package/dist/runtime/hydrate-core.d.ts +4 -4
- package/dist/runtime/hydrate-core.js +8 -5
- package/dist/runtime/nav-handle.d.ts +3 -0
- package/dist/runtime/nav-handle.js +12 -5
- package/dist/runtime/region-ids.js +2 -2
- package/dist/runtime/remote-seeds.js +14 -3
- package/dist/runtime/seeds.d.ts +10 -5
- package/dist/runtime/seeds.js +16 -12
- package/dist/runtime/slots.d.ts +16 -0
- package/dist/runtime/slots.js +2 -0
- package/dist/runtime/wire-classes.d.ts +2 -0
- package/dist/runtime/wire-classes.js +10 -1
- package/dist/runtime/wire-format.d.ts +4 -1
- package/dist/runtime/wire-format.js +6 -1
- package/dist/seed-ref-reviver.d.ts +24 -0
- package/dist/seed-ref-reviver.js +44 -0
- package/dist/seed-refs.d.ts +2 -16
- package/dist/seed-refs.js +1 -33
- package/dist/server/props-wire.js +2 -1
- package/package.json +3 -3
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The CLIENT half of seed references (seed-refs.ts): the devalue type tag and the reviver that
|
|
3
|
+
* resolves a reference against the page seed. Its own module because the hydrate core is a lazy
|
|
4
|
+
* runtime chunk that shares modules with Kit's client graph (route components compiled for the
|
|
5
|
+
* browser, never loaded on a csr=false page). The bundler keeps a shared module whole — every
|
|
6
|
+
* export ANY importer uses — so while the reviver lived beside the server-side index and planner,
|
|
7
|
+
* every island page downloaded the planner (~4 kB) for the Kit graph's sake. A leaf holds only
|
|
8
|
+
* what the hydrate core runs.
|
|
9
|
+
*/
|
|
10
|
+
/** The devalue type tag. */
|
|
11
|
+
export declare const SEED_REF_KEY = "OgygiaSeedRef";
|
|
12
|
+
export type SeedPath = (string | number)[];
|
|
13
|
+
/** Client: the node a path points at, or `undefined` when the seed does not have it. */
|
|
14
|
+
export declare function resolve_seed_ref(data: unknown, path: SeedPath): unknown;
|
|
15
|
+
/**
|
|
16
|
+
* Client reviver for the devalue type: resolve BY REFERENCE. The island receives the seed's own
|
|
17
|
+
* node — the same object its `page.data` read would hand it, shared exactly the way `page.data`
|
|
18
|
+
* already is between islands. A deep copy per reference (129 of them on a measured page) bought
|
|
19
|
+
* nothing: island props are a snapshot either way, and the DEV mutation guard the runtime wraps
|
|
20
|
+
* every island's props in (`PropMutationGuard`) already warns on a write into them. `get_data` is
|
|
21
|
+
* called lazily, once per reviver — the first reference resolves the seed. A dangling path (no seed,
|
|
22
|
+
* or a seed that does not carry the node) revives to `undefined` and, in dev, says why.
|
|
23
|
+
*/
|
|
24
|
+
export declare function seed_ref_reviver(get_data: () => unknown): (path: SeedPath) => unknown;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// src/seed-ref-reviver.ts
|
|
2
|
+
/**
|
|
3
|
+
* The CLIENT half of seed references (seed-refs.ts): the devalue type tag and the reviver that
|
|
4
|
+
* resolves a reference against the page seed. Its own module because the hydrate core is a lazy
|
|
5
|
+
* runtime chunk that shares modules with Kit's client graph (route components compiled for the
|
|
6
|
+
* browser, never loaded on a csr=false page). The bundler keeps a shared module whole — every
|
|
7
|
+
* export ANY importer uses — so while the reviver lived beside the server-side index and planner,
|
|
8
|
+
* every island page downloaded the planner (~4 kB) for the Kit graph's sake. A leaf holds only
|
|
9
|
+
* what the hydrate core runs.
|
|
10
|
+
*/
|
|
11
|
+
/** The devalue type tag. */
|
|
12
|
+
const SEED_REF_KEY = "OgygiaSeedRef";
|
|
13
|
+
/** Client: the node a path points at, or `undefined` when the seed does not have it. */
|
|
14
|
+
function resolve_seed_ref(data, path) {
|
|
15
|
+
let cur = data;
|
|
16
|
+
for (const key of path) {
|
|
17
|
+
if (cur === null || typeof cur !== "object") return void 0;
|
|
18
|
+
cur = cur[key];
|
|
19
|
+
}
|
|
20
|
+
return cur;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Client reviver for the devalue type: resolve BY REFERENCE. The island receives the seed's own
|
|
24
|
+
* node — the same object its `page.data` read would hand it, shared exactly the way `page.data`
|
|
25
|
+
* already is between islands. A deep copy per reference (129 of them on a measured page) bought
|
|
26
|
+
* nothing: island props are a snapshot either way, and the DEV mutation guard the runtime wraps
|
|
27
|
+
* every island's props in (`PropMutationGuard`) already warns on a write into them. `get_data` is
|
|
28
|
+
* called lazily, once per reviver — the first reference resolves the seed. A dangling path (no seed,
|
|
29
|
+
* or a seed that does not carry the node) revives to `undefined` and, in dev, says why.
|
|
30
|
+
*/
|
|
31
|
+
function seed_ref_reviver(get_data) {
|
|
32
|
+
let data;
|
|
33
|
+
let resolved = false;
|
|
34
|
+
return (path) => {
|
|
35
|
+
if (!resolved) {
|
|
36
|
+
data = get_data();
|
|
37
|
+
resolved = true;
|
|
38
|
+
}
|
|
39
|
+
const node = resolve_seed_ref(data, path);
|
|
40
|
+
if (node === void 0 && typeof console !== "undefined" && import.meta.env?.DEV) console.warn(`[ogygia] island props reference page.data at ${JSON.stringify(path)} but the page seed does not carry it — the island receives undefined there.`);
|
|
41
|
+
return node;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { SEED_REF_KEY, resolve_seed_ref, seed_ref_reviver };
|
package/dist/seed-refs.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const SEED_REF_KEY = "OgygiaSeedRef";
|
|
3
|
-
export type SeedPath = (string | number)[];
|
|
1
|
+
import { SEED_REF_KEY, SeedPath, resolve_seed_ref, seed_ref_reviver } from "./seed-ref-reviver.js";
|
|
4
2
|
export interface SeedIndex {
|
|
5
3
|
/** node → its path from `page.data` (identity matches: the app passed the seed's own object).
|
|
6
4
|
* The path is materialised on the first ask — an indexed node that no island references
|
|
@@ -90,16 +88,4 @@ export interface SeedRefPlan {
|
|
|
90
88
|
* no walk of its own beyond the pointer lookups.
|
|
91
89
|
*/
|
|
92
90
|
export declare function plan_seed_refs(index: SeedIndex, props: unknown, min_bytes?: number): SeedRefPlan;
|
|
93
|
-
|
|
94
|
-
export declare function resolve_seed_ref(data: unknown, path: SeedPath): unknown;
|
|
95
|
-
/**
|
|
96
|
-
* Client reviver for the devalue type: resolve BY REFERENCE. The island receives the seed's own
|
|
97
|
-
* node — the same object its `page.data` read would hand it, shared exactly the way `page.data`
|
|
98
|
-
* already is between islands. A deep copy per reference (129 of them on a measured page) bought
|
|
99
|
-
* nothing: island props are a snapshot either way, and the DEV mutation guard the runtime wraps
|
|
100
|
-
* every island's props in (`PropMutationGuard`) already warns on a write into them. `get_data` is
|
|
101
|
-
* called lazily, once per reviver — the first reference resolves the seed. A dangling path (no seed,
|
|
102
|
-
* or a seed that does not carry the node) revives to `undefined` and, in dev, says why.
|
|
103
|
-
*/
|
|
104
|
-
export declare function seed_ref_reviver(get_data: () => unknown): (path: SeedPath) => unknown;
|
|
105
|
-
export {};
|
|
91
|
+
export { SEED_REF_KEY, type SeedPath, resolve_seed_ref, seed_ref_reviver };
|
package/dist/seed-refs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { fnv1a } from "./runtime/hash.js";
|
|
2
|
+
import { SEED_REF_KEY, resolve_seed_ref, seed_ref_reviver } from "./seed-ref-reviver.js";
|
|
2
3
|
// src/seed-refs.ts
|
|
3
4
|
/**
|
|
4
5
|
* SEED REFERENCES — island props that point into the page seed instead of copying it.
|
|
@@ -43,8 +44,6 @@ import { fnv1a } from "./runtime/hash.js";
|
|
|
43
44
|
* Universal module (no Node imports): the index + reducer run on the server, the resolver on the
|
|
44
45
|
* client, and the unit tests exercise both ends against a real devalue round trip.
|
|
45
46
|
*/
|
|
46
|
-
/** The devalue type tag. */
|
|
47
|
-
const SEED_REF_KEY = "OgygiaSeedRef";
|
|
48
47
|
/** A node the codec may reference: a plain object or an array (own prototype only). */
|
|
49
48
|
function is_plain(v) {
|
|
50
49
|
if (v === null || typeof v !== "object") return false;
|
|
@@ -453,35 +452,4 @@ function plan_seed_refs(index, props, min_bytes = 96) {
|
|
|
453
452
|
keys
|
|
454
453
|
};
|
|
455
454
|
}
|
|
456
|
-
/** Client: the node a path points at, or `undefined` when the seed does not have it. */
|
|
457
|
-
function resolve_seed_ref(data, path) {
|
|
458
|
-
let cur = data;
|
|
459
|
-
for (const key of path) {
|
|
460
|
-
if (cur === null || typeof cur !== "object") return void 0;
|
|
461
|
-
cur = cur[key];
|
|
462
|
-
}
|
|
463
|
-
return cur;
|
|
464
|
-
}
|
|
465
|
-
/**
|
|
466
|
-
* Client reviver for the devalue type: resolve BY REFERENCE. The island receives the seed's own
|
|
467
|
-
* node — the same object its `page.data` read would hand it, shared exactly the way `page.data`
|
|
468
|
-
* already is between islands. A deep copy per reference (129 of them on a measured page) bought
|
|
469
|
-
* nothing: island props are a snapshot either way, and the DEV mutation guard the runtime wraps
|
|
470
|
-
* every island's props in (`PropMutationGuard`) already warns on a write into them. `get_data` is
|
|
471
|
-
* called lazily, once per reviver — the first reference resolves the seed. A dangling path (no seed,
|
|
472
|
-
* or a seed that does not carry the node) revives to `undefined` and, in dev, says why.
|
|
473
|
-
*/
|
|
474
|
-
function seed_ref_reviver(get_data) {
|
|
475
|
-
let data;
|
|
476
|
-
let resolved = false;
|
|
477
|
-
return (path) => {
|
|
478
|
-
if (!resolved) {
|
|
479
|
-
data = get_data();
|
|
480
|
-
resolved = true;
|
|
481
|
-
}
|
|
482
|
-
const node = resolve_seed_ref(data, path);
|
|
483
|
-
if (node === void 0 && typeof console !== "undefined" && import.meta.env?.DEV) console.warn(`[ogygia] island props reference page.data at ${JSON.stringify(path)} but the page seed does not carry it — the island receives undefined there.`);
|
|
484
|
-
return node;
|
|
485
|
-
};
|
|
486
|
-
}
|
|
487
455
|
export { SEED_REF_KEY, analyze, deep_equal_plain, index_seed, json_culprit, plan_seed_refs, resolve_seed_ref, seed_ref_reviver, set_measure_memo_reader };
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { escape_script_text } from "../escape.js";
|
|
2
|
+
import { SEED_REF_KEY } from "../seed-ref-reviver.js";
|
|
2
3
|
import { REF_WIRE_KEY, ref_reducer } from "../ref.js";
|
|
3
4
|
import { register_wire_kind } from "../live-transport.js";
|
|
4
5
|
import { register_derived_kind, register_store_kind } from "../store-transport.js";
|
|
5
6
|
import { register_snippet_kind } from "../region-snippet.js";
|
|
6
7
|
import { register_fn_kind } from "../fn-transport.js";
|
|
7
|
-
import {
|
|
8
|
+
import { analyze, json_culprit, plan_seed_refs } from "../seed-refs.js";
|
|
8
9
|
import { stringify } from "devalue";
|
|
9
10
|
// src/server/props-wire.ts
|
|
10
11
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ogygia/core",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.5",
|
|
4
4
|
"description": "The core of ogygia (SSR islands for SvelteKit): apps install `ogygia`, plugins build on this",
|
|
5
5
|
"homepage": "https://ogygiajs.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -141,6 +141,7 @@
|
|
|
141
141
|
"tinyglobby": "^0.2.17"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
+
"@ogygia/tsdown-plugin-svelte": "1.1.1",
|
|
144
145
|
"@sveltejs/kit": "^2.70.2",
|
|
145
146
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
146
147
|
"@types/node": "^26.1.2",
|
|
@@ -156,8 +157,7 @@
|
|
|
156
157
|
"typescript": "^6.0.3",
|
|
157
158
|
"valibot": "^1.4.2",
|
|
158
159
|
"vite": "^8.3.5",
|
|
159
|
-
"vitest": "^4.1.12"
|
|
160
|
-
"@ogygia/tsdown-plugin-svelte": "1.1.0"
|
|
160
|
+
"vitest": "^4.1.12"
|
|
161
161
|
},
|
|
162
162
|
"peerDependencies": {
|
|
163
163
|
"@sveltejs/kit": ">=2.70.2 <4",
|