@ogygia/core 0.12.3 → 0.13.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.
Files changed (226) hide show
  1. package/dist/LateIsland.svelte +3 -2
  2. package/dist/LateIslandAwait.svelte +6 -2
  3. package/dist/Region.svelte +22 -33
  4. package/dist/boundary.d.ts +0 -2
  5. package/dist/boundary.js +8 -6
  6. package/dist/compiler/debarrel/barrel.d.ts +15 -8
  7. package/dist/compiler/debarrel/barrel.js +92 -45
  8. package/dist/compiler/debarrel/plugin.js +41 -17
  9. package/dist/compiler/dev/dev-hmr.d.ts +3 -0
  10. package/dist/compiler/dev/dev-hmr.js +3 -0
  11. package/dist/compiler/driver.js +11 -4
  12. package/dist/compiler/flags.js +21 -7
  13. package/dist/compiler/fouc-css.js +5 -1
  14. package/dist/compiler/kit.js +5 -1
  15. package/dist/compiler/link/build-output.js +12 -3
  16. package/dist/compiler/macros/bake.js +18 -4
  17. package/dist/compiler/macros/dollar.js +6 -1
  18. package/dist/compiler/macros/source.js +6 -1
  19. package/dist/compiler/macros/store.js +10 -2
  20. package/dist/compiler/macros/wire.js +6 -1
  21. package/dist/compiler/parse/scan.js +10 -3
  22. package/dist/compiler/region/transform.js +188 -74
  23. package/dist/context-bridge.js +13 -5
  24. package/dist/context.d.ts +9 -0
  25. package/dist/context.js +30 -1
  26. package/dist/document.d.ts +1 -1
  27. package/dist/document.js +7 -1
  28. package/dist/early-holes-head.d.ts +5 -0
  29. package/dist/early-holes-head.js +20 -0
  30. package/dist/early-holes.d.ts +34 -0
  31. package/dist/early-holes.js +51 -0
  32. package/dist/entry-hydrate.js +9 -12
  33. package/dist/events/bus.js +7 -2
  34. package/dist/events/schema.d.ts +2 -2
  35. package/dist/fn-transport.js +4 -3
  36. package/dist/hooks.js +94 -163
  37. package/dist/insights/page-assets.js +11 -3
  38. package/dist/insights/page-insights.d.ts +0 -2
  39. package/dist/insights/page-insights.js +14 -10
  40. package/dist/insights/session-insights.js +2 -2
  41. package/dist/internal-instruments.d.ts +3 -1
  42. package/dist/internal-instruments.js +3 -1
  43. package/dist/internal-server.d.ts +3 -2
  44. package/dist/internal-server.js +3 -2
  45. package/dist/internal.d.ts +1 -2
  46. package/dist/internal.js +1 -2
  47. package/dist/keep-fallback.d.ts +0 -2
  48. package/dist/keep-fallback.js +4 -5
  49. package/dist/live-transport.js +3 -2
  50. package/dist/messages/build.d.ts +585 -0
  51. package/dist/messages/build.js +800 -0
  52. package/dist/messages/core.d.ts +464 -0
  53. package/dist/messages/core.js +843 -0
  54. package/dist/messages/define.d.ts +62 -0
  55. package/dist/messages/define.js +49 -0
  56. package/dist/messages/index.d.ts +6 -0
  57. package/dist/messages/index.js +6 -0
  58. package/dist/messages/island.d.ts +4 -0
  59. package/dist/messages/island.js +34 -0
  60. package/dist/messages/lazy.d.ts +3 -0
  61. package/dist/messages/lazy.js +22 -0
  62. package/dist/messages/prose.d.ts +15 -0
  63. package/dist/messages/prose.js +43 -0
  64. package/dist/messages/server.d.ts +142 -0
  65. package/dist/messages/server.js +246 -0
  66. package/dist/nested.d.ts +3 -0
  67. package/dist/nested.js +8 -1
  68. package/dist/plugin/css.js +14 -13
  69. package/dist/plugin/facts.d.ts +2 -0
  70. package/dist/plugin/facts.js +10 -6
  71. package/dist/plugin/hooks.d.ts +7 -17
  72. package/dist/plugin/hooks.js +32 -4
  73. package/dist/plugin/index.d.ts +9 -2
  74. package/dist/plugin/request-scope.d.ts +20 -0
  75. package/dist/plugin/request-scope.js +149 -0
  76. package/dist/plugin/server.d.ts +20 -2
  77. package/dist/plugin/server.js +98 -28
  78. package/dist/plugin/testing.d.ts +6 -0
  79. package/dist/plugin/testing.js +14 -2
  80. package/dist/policies.d.ts +21 -0
  81. package/dist/policies.js +66 -0
  82. package/dist/preference.js +6 -1
  83. package/dist/preload.js +6 -9
  84. package/dist/ref-watch.d.ts +0 -10
  85. package/dist/ref-watch.js +14 -1
  86. package/dist/ref.js +17 -5
  87. package/dist/region-snippet.js +9 -3
  88. package/dist/region.js +2 -1
  89. package/dist/report-thrown.d.ts +9 -0
  90. package/dist/report-thrown.js +15 -0
  91. package/dist/rules.d.ts +17 -0
  92. package/dist/rules.js +57 -0
  93. package/dist/runtime/beacon.d.ts +0 -4
  94. package/dist/runtime/beacon.js +58 -43
  95. package/dist/runtime/boot-link.js +19 -2
  96. package/dist/runtime/client-hooks.js +2 -1
  97. package/dist/runtime/concurrency.d.ts +16 -5
  98. package/dist/runtime/concurrency.js +123 -7
  99. package/dist/runtime/core.d.ts +3 -1
  100. package/dist/runtime/core.js +718 -384
  101. package/dist/runtime/devalue-lane.d.ts +13 -0
  102. package/dist/runtime/devalue-lane.js +49 -0
  103. package/dist/runtime/disclose-version.d.ts +1 -0
  104. package/dist/runtime/disclose-version.js +14 -0
  105. package/dist/runtime/early-holes.d.ts +4 -0
  106. package/dist/runtime/early-holes.js +40 -0
  107. package/dist/runtime/entry-locations.js +40 -49
  108. package/dist/runtime/foreign-props.d.ts +0 -7
  109. package/dist/runtime/foreign-props.js +2 -1
  110. package/dist/runtime/form-continuity.d.ts +2 -2
  111. package/dist/runtime/form-continuity.js +30 -8
  112. package/dist/runtime/frame-nav.d.ts +7 -1
  113. package/dist/runtime/frame-nav.js +84 -18
  114. package/dist/runtime/frame-store.d.ts +25 -16
  115. package/dist/runtime/frame-store.js +124 -98
  116. package/dist/runtime/frames.js +8 -4
  117. package/dist/runtime/hole-facts.js +6 -7
  118. package/dist/runtime/hole-fetch.d.ts +17 -0
  119. package/dist/runtime/hole-fetch.js +47 -0
  120. package/dist/runtime/hydrate-core.d.ts +4 -4
  121. package/dist/runtime/hydrate-core.js +80 -64
  122. package/dist/runtime/import-again.d.ts +33 -0
  123. package/dist/runtime/import-again.js +217 -0
  124. package/dist/runtime/interaction-replay.d.ts +5 -3
  125. package/dist/runtime/interaction-replay.js +6 -6
  126. package/dist/runtime/interaction.d.ts +14 -3
  127. package/dist/runtime/interaction.js +46 -23
  128. package/dist/runtime/kit-page-thread.svelte.d.ts +2 -1
  129. package/dist/runtime/kit-page-thread.svelte.js +44 -20
  130. package/dist/runtime/lakes.d.ts +1 -1
  131. package/dist/runtime/lakes.js +18 -5
  132. package/dist/runtime/live.d.ts +1 -2
  133. package/dist/runtime/live.js +6 -8
  134. package/dist/runtime/load-scheduler.d.ts +29 -18
  135. package/dist/runtime/load-scheduler.js +236 -136
  136. package/dist/runtime/nav-handle.js +25 -6
  137. package/dist/runtime/navigation.d.ts +24 -0
  138. package/dist/runtime/navigation.js +24 -0
  139. package/dist/runtime/ownership.d.ts +1 -1
  140. package/dist/runtime/page-defer.js +3 -3
  141. package/dist/runtime/parse-html.d.ts +15 -4
  142. package/dist/runtime/parse-html.js +24 -5
  143. package/dist/runtime/pushable-props.svelte.d.ts +21 -0
  144. package/dist/runtime/pushable-props.svelte.js +37 -0
  145. package/dist/runtime/region-endpoint-url.js +4 -6
  146. package/dist/runtime/region-machines.d.ts +111 -0
  147. package/dist/runtime/region-machines.js +97 -0
  148. package/dist/runtime/region-sheets.d.ts +31 -0
  149. package/dist/runtime/region-sheets.js +49 -0
  150. package/dist/runtime/restore-report.d.ts +1 -0
  151. package/dist/runtime/restore-report.js +36 -0
  152. package/dist/runtime/restore.d.ts +5 -2
  153. package/dist/runtime/restore.js +33 -14
  154. package/dist/runtime/router-nav.d.ts +32 -12
  155. package/dist/runtime/router-nav.js +320 -228
  156. package/dist/runtime/router.d.ts +83 -19
  157. package/dist/runtime/router.js +297 -129
  158. package/dist/runtime/rules.d.ts +35 -0
  159. package/dist/runtime/rules.js +137 -0
  160. package/dist/runtime/schedule.d.ts +6 -3
  161. package/dist/runtime/schedule.js +172 -57
  162. package/dist/runtime/seeds.d.ts +5 -1
  163. package/dist/runtime/seeds.js +11 -5
  164. package/dist/runtime/session.d.ts +46 -7
  165. package/dist/runtime/session.js +78 -10
  166. package/dist/runtime/slots.d.ts +53 -20
  167. package/dist/runtime/slots.js +2 -3
  168. package/dist/runtime/soft-refresh.d.ts +16 -0
  169. package/dist/runtime/soft-refresh.js +14 -0
  170. package/dist/runtime/svelte-warnings.d.ts +4 -10
  171. package/dist/runtime/svelte-warnings.js +7 -4
  172. package/dist/runtime/wire-classes.js +21 -8
  173. package/dist/runtime/wire-format.js +6 -3
  174. package/dist/script.js +8 -7
  175. package/dist/seed-ref-reviver.d.ts +0 -9
  176. package/dist/seed-ref-reviver.js +2 -1
  177. package/dist/seed-refs.d.ts +46 -36
  178. package/dist/seed-refs.js +131 -92
  179. package/dist/server/document-tail.d.ts +6 -0
  180. package/dist/server/document-tail.js +7 -1
  181. package/dist/server/early-holes-csp.d.ts +14 -0
  182. package/dist/server/early-holes-csp.js +73 -0
  183. package/dist/server/page-facts.d.ts +4 -1
  184. package/dist/server/page-facts.js +4 -1
  185. package/dist/server/page-seed.d.ts +2 -2
  186. package/dist/server/page-seed.js +104 -11
  187. package/dist/server/page-stream.d.ts +14 -1
  188. package/dist/server/page-stream.js +119 -2
  189. package/dist/server/personal-response.d.ts +0 -5
  190. package/dist/server/personal-response.js +6 -2
  191. package/dist/server/props-wire.js +5 -1
  192. package/dist/server/region-endpoint.js +10 -2
  193. package/dist/server/render-cache.d.ts +24 -20
  194. package/dist/server/render-cache.js +99 -40
  195. package/dist/server/render-page.js +46 -15
  196. package/dist/server/request-stats.d.ts +10 -8
  197. package/dist/server/request-stats.js +20 -12
  198. package/dist/server/rules.d.ts +11 -0
  199. package/dist/server/rules.js +64 -0
  200. package/dist/server/signing-key.js +31 -18
  201. package/dist/server/stream-regions.d.ts +14 -1
  202. package/dist/server/stream-regions.js +38 -2
  203. package/dist/shared-state.js +5 -1
  204. package/dist/shims/app-navigation.js +3 -2
  205. package/dist/shims/page-store.svelte.js +16 -2
  206. package/dist/source.js +7 -2
  207. package/dist/store-transport.js +12 -5
  208. package/dist/transport.js +3 -2
  209. package/dist/vite/index.js +17 -10
  210. package/dist/vite/kit-dirs.js +7 -1
  211. package/dist/vite/options.d.ts +2 -1
  212. package/dist/vite/options.js +11 -20
  213. package/dist/vite/package-files.js +13 -3
  214. package/dist/vite/paths.d.ts +2 -0
  215. package/dist/vite/paths.js +4 -4
  216. package/dist/vite/plugin-api.js +42 -14
  217. package/dist/vite/style-preprocess.js +10 -3
  218. package/package.json +8 -1
  219. package/dist/KeepHost.svelte +0 -19
  220. package/dist/KeepHost.svelte.d.ts +0 -10
  221. package/dist/LiveHost.svelte +0 -19
  222. package/dist/LiveHost.svelte.d.ts +0 -10
  223. package/dist/NestedProvider.svelte +0 -13
  224. package/dist/NestedProvider.svelte.d.ts +0 -8
  225. package/dist/runtime/page-cache.d.ts +0 -23
  226. package/dist/runtime/page-cache.js +0 -74
@@ -0,0 +1,34 @@
1
+ /**
2
+ * THE EARLY START OF A HOLE THAT LOADS AT ONCE. A `defer: 'load'` hole's request starts during the
3
+ * HTML parse, before the runtime is in, so its answer is on its way when the hole wakes. The page's
4
+ * head carries one data block (the endpoints, JSON: no CSP allowance needed) and one inline script
5
+ * that is the same bytes on every page ({@link start_early_holes}): it starts each `fetch` as the
6
+ * runtime's hole fetch would (./runtime/hole-fetch.ts) and parks the requests by resolved URL on one
7
+ * global. The runtime takes them over as the frame store's flights (./runtime/early-holes.ts), so
8
+ * each hole is asked for once. (A `<link rel="preload" as="fetch">` did the early start before:
9
+ * WebKit never hands one to a later `fetch()`, and every hole was asked for, and rendered, twice
10
+ * there: #404.)
11
+ *
12
+ * The script never changes, so its hash is a constant: a policy that would block it gets that hash
13
+ * (./server/early-holes-csp.ts, computed from the text ./early-holes-head.ts writes). Universal and
14
+ * import-free: the runtime reads the global through it.
15
+ */
16
+ /** The id of the head's data block: the `load` holes' endpoints, as rendered. */
17
+ export declare const EARLY_HOLES_ID = "ogygia-early-holes";
18
+ /** The `Symbol.for` name of the global the script parks its requests on (a list of
19
+ * {@link EarlyHole}), until the runtime takes them over. */
20
+ export declare const EARLY_HOLES_KEY = "ogygia.early-holes";
21
+ /** One request the head started: the hole's endpoint, resolved, the `fetch` that asks for it, and
22
+ * the controller that cancels it (the flight that takes it over owns it). */
23
+ export type EarlyHole = {
24
+ url: string;
25
+ response: Promise<Response>;
26
+ controller: AbortController;
27
+ };
28
+ /**
29
+ * The early start, run inline in the head (`script()` writes its source: self-contained, browser
30
+ * globals only). Each endpoint in the data block is resolved against the document's base, as the
31
+ * runtime resolves it, and asked for once. A request that fails is the runtime's to say when it
32
+ * takes it over: the park only keeps its rejection from reading as unhandled.
33
+ */
34
+ export declare function start_early_holes(id: string, key: string): void;
@@ -0,0 +1,51 @@
1
+ // src/early-holes.ts
2
+ /**
3
+ * THE EARLY START OF A HOLE THAT LOADS AT ONCE. A `defer: 'load'` hole's request starts during the
4
+ * HTML parse, before the runtime is in, so its answer is on its way when the hole wakes. The page's
5
+ * head carries one data block (the endpoints, JSON: no CSP allowance needed) and one inline script
6
+ * that is the same bytes on every page ({@link start_early_holes}): it starts each `fetch` as the
7
+ * runtime's hole fetch would (./runtime/hole-fetch.ts) and parks the requests by resolved URL on one
8
+ * global. The runtime takes them over as the frame store's flights (./runtime/early-holes.ts), so
9
+ * each hole is asked for once. (A `<link rel="preload" as="fetch">` did the early start before:
10
+ * WebKit never hands one to a later `fetch()`, and every hole was asked for, and rendered, twice
11
+ * there: #404.)
12
+ *
13
+ * The script never changes, so its hash is a constant: a policy that would block it gets that hash
14
+ * (./server/early-holes-csp.ts, computed from the text ./early-holes-head.ts writes). Universal and
15
+ * import-free: the runtime reads the global through it.
16
+ */
17
+ /** The id of the head's data block: the `load` holes' endpoints, as rendered. */
18
+ const EARLY_HOLES_ID = "ogygia-early-holes";
19
+ /** The `Symbol.for` name of the global the script parks its requests on (a list of
20
+ * {@link EarlyHole}), until the runtime takes them over. */
21
+ const EARLY_HOLES_KEY = "ogygia.early-holes";
22
+ /**
23
+ * The early start, run inline in the head (`script()` writes its source: self-contained, browser
24
+ * globals only). Each endpoint in the data block is resolved against the document's base, as the
25
+ * runtime resolves it, and asked for once. A request that fails is the runtime's to say when it
26
+ * takes it over: the park only keeps its rejection from reading as unhandled.
27
+ */
28
+ function start_early_holes(id, key) {
29
+ const data = document.getElementById(id);
30
+ if (!data) return;
31
+ const parked = [];
32
+ const asked = /* @__PURE__ */ new Set();
33
+ for (const endpoint of JSON.parse(data.textContent || "[]")) {
34
+ const url = new URL(endpoint, document.baseURI).href;
35
+ if (asked.has(url)) continue;
36
+ asked.add(url);
37
+ const controller = new AbortController();
38
+ const response = fetch(url, {
39
+ credentials: "same-origin",
40
+ signal: controller.signal
41
+ });
42
+ response.catch(() => {});
43
+ parked.push({
44
+ url,
45
+ response,
46
+ controller
47
+ });
48
+ }
49
+ globalThis[Symbol.for(key)] = parked;
50
+ }
51
+ export { EARLY_HOLES_ID, EARLY_HOLES_KEY, start_early_holes };
@@ -1,5 +1,5 @@
1
+ import { nested_context } from "./nested.js";
1
2
  import { hydrate, unmount } from "svelte";
2
- import NestedProvider from "./NestedProvider.svelte";
3
3
  // src/entry-hydrate.ts
4
4
  /**
5
5
  * THE FOREIGN-HYDRATE CONTRACT (fragment federation), in one place. A stitched fragment's island
@@ -13,12 +13,11 @@ import NestedProvider from "./NestedProvider.svelte";
13
13
  * `__og_unmount` (compiler/region/emit.ts); an app that does not federate ships neither. This module
14
14
  * sits in the producer's own build, so its `svelte` is the producer's.
15
15
  *
16
- * Hydrate through THIS build's NestedProvider, mirroring the local runtime's call shape: the SSR
17
- * children were rendered through the provider's dynamic-component branch (the `<!--[0-->` marker), so
18
- * a bare-component hydrate walks one marker layer short — svelte aborts mid-walk and client-re-renders.
19
- * `options.recover === false`: the consumer's self-heal (hydrate-core.ts) asks THIS svelte to throw on
20
- * a mismatch instead of re-rendering; the envelope is re-checked per call because a restore from the
21
- * server markup drops it.
16
+ * The component itself is hydrated, as the local runtime does (runtime/hydrate-core.ts), marked
17
+ * "inside an island" through its context: the SSR children are its nodes in one anchor pair (the
18
+ * placed island's dynamic-component pair). `options.recover === false`: the consumer's self-heal
19
+ * asks THIS svelte to throw on a mismatch instead of re-rendering; the envelope is re-checked per
20
+ * call because a restore from the server markup drops it.
22
21
  */
23
22
  function og_entry_hydrate(component, target, props, options) {
24
23
  const first = target.firstChild;
@@ -27,12 +26,10 @@ function og_entry_hydrate(component, target, props, options) {
27
26
  target.appendChild(document.createComment("]"));
28
27
  }
29
28
  const recovery = options && options.recover === false ? { recover: false } : {};
30
- return hydrate(NestedProvider, {
29
+ return hydrate(component, {
31
30
  target,
32
- props: {
33
- component,
34
- props
35
- },
31
+ props,
32
+ context: nested_context(),
36
33
  ...recovery
37
34
  });
38
35
  }
@@ -1,4 +1,5 @@
1
1
  import "./schema.js";
2
+ import { report_thrown } from "../report-thrown.js";
2
3
  // src/events/bus.ts
3
4
  /**
4
5
  * The devtools EVENT BUS — the whole product's spine (internal/notes/devtools.md, Rung 0).
@@ -83,7 +84,9 @@ function emit(input) {
83
84
  if (b.count < b.cap) b.count++;
84
85
  if (b.sinks.size) for (const sink of b.sinks) try {
85
86
  sink(event);
86
- } catch {}
87
+ } catch (error) {
88
+ report_thrown(error);
89
+ }
87
90
  }
88
91
  /**
89
92
  * Push ALREADY-STAMPED events into the buffer + sinks WITHOUT re-stamping — the ingest path for the
@@ -101,7 +104,9 @@ function ingest(events) {
101
104
  if (b.count < b.cap) b.count++;
102
105
  if (b.sinks.size) for (const sink of b.sinks) try {
103
106
  sink(event);
104
- } catch {}
107
+ } catch (error) {
108
+ report_thrown(error);
109
+ }
105
110
  }
106
111
  }
107
112
  /** Buffered events in emission order (oldest → newest). Copies out — safe to hold/serialize. */
@@ -223,8 +223,8 @@ export type RuntimeEventInput = {
223
223
  domain: "runtime";
224
224
  /** Two owners wanted the same nodes (runtime/ownership.ts): a web component changed its own
225
225
  * children in a position Svelte's hydration reads, and the repair removed what it added so
226
- * the island could hydrate. `reason` names the element and the way out ({@html} / static
227
- * markup / a lake / data-ogygia-keep). */
226
+ * the island could hydrate. `reason` names the element (the message `ownership_conflict`
227
+ * says the way out). */
228
228
  name: "region.hydrate.conflict";
229
229
  entry?: string;
230
230
  fp?: string;
@@ -1,4 +1,5 @@
1
1
  import { mint, register_kind, resolve } from "./ref.js";
2
+ import { OgygiaError } from "./messages/island.js";
2
3
  // src/fn-transport.ts
3
4
  /**
4
5
  * Transportable functions — the hub's FN kind (the runtime half of `import.meta.og.$`).
@@ -52,9 +53,9 @@ function is_branded_fn(value) {
52
53
  function fn_handle(tag, bound) {
53
54
  register_fn_kind();
54
55
  const factory = fn_registry().factories.get(tag);
55
- if (factory === void 0) throw new Error(`[ogygia] fn_handle("${tag}"): its factory is not registered on this side. The generated module must be imported as a VALUE at the call site (the compiler emits this import).`);
56
+ if (factory === void 0) throw new OgygiaError("fn_factory_missing", { tag });
56
57
  const live = factory(...bound);
57
- if (typeof live !== "function") throw new Error(`[ogygia] fn factory "${tag}" did not return a function.`);
58
+ if (typeof live !== "function") throw new OgygiaError("fn_factory_not_function", { tag });
58
59
  live[FN_BRAND] = {
59
60
  t: tag,
60
61
  d: bound,
@@ -94,7 +95,7 @@ function register_fn_kind() {
94
95
  factory = (0, eval)(`(${payload.s})`);
95
96
  fn_registry().factories.set(ref.t, factory);
96
97
  }
97
- if (factory === void 0) throw new Error(`[ogygia] cannot revive fn "${ref.t}": its factory is not loaded on this side and the payload carries no source. The island must import the generated module as a VALUE so \`__register_fn\` runs in its bundle (or the fn manifest must be in the runtime).`);
98
+ if (factory === void 0) throw new OgygiaError("fn_revive_missing", { tag: String(ref.t) });
98
99
  const bound = Array.isArray(payload.b) ? payload.b : [];
99
100
  const live = factory(...bound);
100
101
  live[FN_BRAND] = {