@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
@@ -1,6 +1,8 @@
1
1
  /** This package's root (the plugin runs from `dist/vite/`, so `../..` is the package root). A NATIVE
2
2
  * path (backslashes on Windows): for the file system, never to compare against a module id. */
3
3
  export declare const PKG_ROOT: string;
4
+ /** This package's version, as installed (the runtime discloses it: runtime/disclose-version.ts). */
5
+ export declare const OGYGIA_VERSION: string;
4
6
  /** A native path as Vite writes module ids: symlinks resolved (pnpm), forward slashes (Windows). */
5
7
  export declare function real_posix(p: string): string;
6
8
  /** A native directory as the PREFIX of the module ids inside it: `real_posix` + one trailing `/`, so a
@@ -12,6 +12,8 @@ import { fileURLToPath } from "node:url";
12
12
  /** This package's root (the plugin runs from `dist/vite/`, so `../..` is the package root). A NATIVE
13
13
  * path (backslashes on Windows): for the file system, never to compare against a module id. */
14
14
  const PKG_ROOT = fileURLToPath(new URL("../..", import.meta.url));
15
+ /** This package's version, as installed (the runtime discloses it: runtime/disclose-version.ts). */
16
+ const OGYGIA_VERSION = JSON.parse(fs.readFileSync(path.join(PKG_ROOT, "package.json"), "utf8")).version;
15
17
  /** Windows separators → posix. */
16
18
  const WIN_SEP_RE = /\\/g;
17
19
  /** A native path as Vite writes module ids: symlinks resolved (pnpm), forward slashes (Windows). */
@@ -93,9 +95,7 @@ function runtime_content_hash() {
93
95
  fileURLToPath(new URL("../keep-fallback-marker.js", import.meta.url)),
94
96
  fileURLToPath(new URL("../shims/page-store.svelte.js", import.meta.url)),
95
97
  fileURLToPath(new URL("../shims/kit-remote/client-stub.js", import.meta.url)),
96
- fileURLToPath(new URL("../NestedProvider.svelte", import.meta.url)),
97
- fileURLToPath(new URL("../LiveHost.svelte", import.meta.url)),
98
- fileURLToPath(new URL("../KeepHost.svelte", import.meta.url))
98
+ fileURLToPath(new URL("../nested.js", import.meta.url))
99
99
  ];
100
100
  try {
101
101
  const rt_dir = fileURLToPath(new URL("../runtime", import.meta.url));
@@ -109,4 +109,4 @@ function runtime_content_hash() {
109
109
  }
110
110
  /** The runtime chunk's source-content hash (the immutable-filename base; feature hash rides on top). */
111
111
  const RUNTIME_HASH = runtime_content_hash();
112
- export { APP_SHIMS, CLIENT_BINDING_STUB_FILE, HMAC_MODULE, KIT_REMOTE_CLIENT, KIT_REMOTE_STATE, OGYGIA_INJECTED_FILES, OGYGIA_INJECTED_IMPORTS, OGYGIA_REGION_MODULES, PKG_ROOT, PKG_ROOT_ID, REGION_ENDPOINT_MODULE, RUNTIME_DIR, RUNTIME_HASH, STUB_CLIENT, STUB_PATHS, STUB_STATE, id_dir, real_posix, scan_entry_pattern };
112
+ export { APP_SHIMS, CLIENT_BINDING_STUB_FILE, HMAC_MODULE, KIT_REMOTE_CLIENT, KIT_REMOTE_STATE, OGYGIA_INJECTED_FILES, OGYGIA_INJECTED_IMPORTS, OGYGIA_REGION_MODULES, OGYGIA_VERSION, PKG_ROOT, PKG_ROOT_ID, REGION_ENDPOINT_MODULE, RUNTIME_DIR, RUNTIME_HASH, STUB_CLIENT, STUB_PATHS, STUB_STATE, id_dir, real_posix, scan_entry_pattern };
@@ -1,3 +1,4 @@
1
+ import { OgygiaError } from "../messages/build.js";
1
2
  import { createRequire } from "node:module";
2
3
  import fs from "node:fs";
3
4
  import path from "node:path";
@@ -34,7 +35,7 @@ function definePlugin(definition) {
34
35
  name: definition.name,
35
36
  [PLUGIN]: definition,
36
37
  configResolved(config) {
37
- if (!config.plugins.some((p) => p.name === OGYGIA_VITE_PLUGIN)) throw new Error(`[ogygia] \`${definition.name}\` is listed in vite.config but \`ogygia()\` is not — add \`ogygia()\` from \`ogygia/vite\` to \`plugins\`.`);
38
+ if (!config.plugins.some((p) => p.name === OGYGIA_VITE_PLUGIN)) throw new OgygiaError("plugin_without_ogygia", { plugin: definition.name });
38
39
  }
39
40
  };
40
41
  }
@@ -53,13 +54,13 @@ async function find_plugins(list) {
53
54
  for (const item of value) await walk(item);
54
55
  return;
55
56
  }
56
- if (typeof value === "function") throw new Error("[ogygia] a function is listed in vite.config `plugins` — call the factory: `flags()`, not `flags`.");
57
+ if (typeof value === "function") throw new OgygiaError("plugin_factory_not_called");
57
58
  const plugin = value;
58
59
  const name = typeof plugin?.name === "string" ? plugin.name : "";
59
60
  const definition = plugin?.[PLUGIN];
60
61
  if (name.startsWith(KIT_VITE_PLUGIN_PREFIX)) kit_seen = true;
61
62
  const own = name === OGYGIA_VITE_PLUGIN;
62
- if ((own || definition) && kit_seen) throw new Error(`[ogygia] \`${own ? "ogygia()" : String(definition?.name)}\` is listed after \`sveltekit()\` in vite.config — list \`ogygia()\` and its plugins first: \`plugins: [ogygia(), flags(), sveltekit()]\`.`);
63
+ if ((own || definition) && kit_seen) throw new OgygiaError("plugin_after_sveltekit", { plugin: own ? "ogygia()" : String(definition?.name) });
63
64
  if (definition) found.push(definition);
64
65
  };
65
66
  await walk(list);
@@ -90,14 +91,17 @@ function check_plugins(plugins) {
90
91
  const seen = /* @__PURE__ */ new Set();
91
92
  for (const p of plugins) {
92
93
  const plugin = p;
93
- if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string" || plugin.name === "") throw new Error("[ogygia] a plugin definition needs a `name` (its package name).");
94
- if (seen.has(plugin.name)) throw new Error(`[ogygia] plugin \`${plugin.name}\` is listed twice.`);
94
+ if (!plugin || typeof plugin !== "object" || typeof plugin.name !== "string" || plugin.name === "") throw new OgygiaError("plugin_name_missing");
95
+ if (seen.has(plugin.name)) throw new OgygiaError("plugin_listed_twice", { plugin: plugin.name });
95
96
  seen.add(plugin.name);
96
- for (const realm of ["server", "client"]) if (plugin[realm] !== void 0 && typeof plugin[realm] !== "string") throw new Error(`[ogygia] plugin \`${plugin.name}\`: \`${realm}\` is a module location — \`import.meta.resolve('./${realm}.ts')\`.`);
97
+ for (const realm of ["server", "client"]) if (plugin[realm] !== void 0 && typeof plugin[realm] !== "string") throw new OgygiaError("plugin_realm_not_location", {
98
+ plugin: plugin.name,
99
+ realm
100
+ });
97
101
  if (plugin.options !== void 0) try {
98
102
  JSON.stringify(plugin.options);
99
103
  } catch {
100
- throw new Error(`[ogygia] plugin \`${plugin.name}\`: \`options\` must be plain JSON (configure live objects in hooks.server.ts).`);
104
+ throw new OgygiaError("plugin_options_not_json", { plugin: plugin.name });
101
105
  }
102
106
  }
103
107
  return plugins;
@@ -108,7 +112,11 @@ function realm_path(plugin, realm) {
108
112
  const where = plugin[realm];
109
113
  if (where === void 0) return null;
110
114
  const abs = where.startsWith("file:") ? fileURLToPath(where) : where;
111
- if (!path.isAbsolute(abs) || !fs.existsSync(abs)) throw new Error(`[ogygia] plugin \`${plugin.name}\`: its \`${realm}\` realm \`${where}\` is not a file — resolve it next to the factory: \`import.meta.resolve('./${realm}.ts')\`.`);
115
+ if (!path.isAbsolute(abs) || !fs.existsSync(abs)) throw new OgygiaError("plugin_realm_not_file", {
116
+ plugin: plugin.name,
117
+ realm,
118
+ location: where
119
+ });
112
120
  return abs.split(path.sep).join("/");
113
121
  }
114
122
  function package_resolves(req, name) {
@@ -145,7 +153,10 @@ function resolve_plugins(plugins, root, dev, markup_transform = () => null) {
145
153
  const config_owner = /* @__PURE__ */ new Map();
146
154
  const macro_owner = /* @__PURE__ */ new Map();
147
155
  for (const plugin of ordered) {
148
- if (!package_resolves(req, plugin.name)) throw new Error(`[ogygia] plugin \`${plugin.name}\`: no package by that name resolves from ${root} — its name must be its package name.`);
156
+ if (!package_resolves(req, plugin.name)) throw new OgygiaError("plugin_package_unresolved", {
157
+ plugin: plugin.name,
158
+ root
159
+ });
149
160
  const server = realm_path(plugin, "server");
150
161
  if (server) out.servers.push({
151
162
  name: plugin.name,
@@ -158,9 +169,16 @@ function resolve_plugins(plugins, root, dev, markup_transform = () => null) {
158
169
  root,
159
170
  dev,
160
171
  routeConfig(key) {
161
- if (!ROUTE_CONFIG_KEY_RE.test(key)) throw new Error(`[ogygia] plugin \`${plugin.name}\`: route config key \`${key}\` must be a camelCase identifier.`);
172
+ if (!ROUTE_CONFIG_KEY_RE.test(key)) throw new OgygiaError("route_config_key_invalid", {
173
+ plugin: plugin.name,
174
+ key
175
+ });
162
176
  const owner = config_owner.get(key);
163
- if (owner && owner !== plugin.name) throw new Error(`[ogygia] route config key \`${key}\` is claimed by both \`${owner}\` and \`${plugin.name}\`.`);
177
+ if (owner && owner !== plugin.name) throw new OgygiaError("route_config_key_claimed", {
178
+ key,
179
+ owner,
180
+ plugin: plugin.name
181
+ });
164
182
  if (!owner) {
165
183
  config_owner.set(key, plugin.name);
166
184
  out.route_config.push(key);
@@ -170,9 +188,16 @@ function resolve_plugins(plugins, root, dev, markup_transform = () => null) {
170
188
  out.foreign_hydrate = true;
171
189
  },
172
190
  macro(name, handler) {
173
- if (!MACRO_NAME_RE.test(name) || CORE_MACROS.has(name)) throw new Error(`[ogygia] plugin \`${plugin.name}\`: macro \`import.meta.og.${name}\` must be a camelCase name core does not own.`);
191
+ if (!MACRO_NAME_RE.test(name) || CORE_MACROS.has(name)) throw new OgygiaError("plugin_macro_name_invalid", {
192
+ plugin: plugin.name,
193
+ name
194
+ });
174
195
  const owner = macro_owner.get(name);
175
- if (owner) throw new Error(`[ogygia] macro \`import.meta.og.${name}\` is claimed by both \`${owner}\` and \`${plugin.name}\`.`);
196
+ if (owner) throw new OgygiaError("plugin_macro_claimed", {
197
+ name,
198
+ owner,
199
+ plugin: plugin.name
200
+ });
176
201
  macro_owner.set(name, plugin.name);
177
202
  out.macros.push({
178
203
  name,
@@ -201,7 +226,10 @@ function resolve_plugins(plugins, root, dev, markup_transform = () => null) {
201
226
  pageModules(modules) {
202
227
  for (const spec of modules.importers ?? []) if (!out.page_modules.importers.includes(spec)) out.page_modules.importers.push(spec);
203
228
  for (const file of modules.files ?? []) {
204
- if (!path.isAbsolute(file)) throw new Error(`[ogygia] plugin \`${plugin.name}\`: \`pageModules({ files })\` takes absolute paths (got \`${file}\`).`);
229
+ if (!path.isAbsolute(file)) throw new OgygiaError("page_modules_not_absolute", {
230
+ plugin: plugin.name,
231
+ file
232
+ });
205
233
  if (!out.page_modules.files.includes(file)) out.page_modules.files.push(file);
206
234
  }
207
235
  }
@@ -1,3 +1,4 @@
1
+ import { warn } from "../messages/build.js";
1
2
  import { createRequire } from "node:module";
2
3
  import path from "node:path";
3
4
  // src/vite/style-preprocess.ts
@@ -52,7 +53,7 @@ async function preprocess_component_for_css(source, abs, root) {
52
53
  if (!compiler) {
53
54
  if (!sass_warned) {
54
55
  sass_warned = true;
55
- console.warn("[ogygia] a server-rendered component has `<style lang=\"scss\">` but neither `sass-embedded` nor `sass` is installed — its hole/router CSS ships unprocessed");
56
+ warn("sass_missing");
56
57
  }
57
58
  } else out = out.replace(STYLE_BLOCK_G, (whole, attrs, body) => {
58
59
  const lang = STYLE_LANG_ATTR.exec(attrs)?.[1]?.toLowerCase();
@@ -70,7 +71,10 @@ async function preprocess_component_for_css(source, abs, root) {
70
71
  });
71
72
  return `<style${attrs.replace(STYLE_LANG_ATTR, "")}>${css}</style>`;
72
73
  } catch (err) {
73
- console.warn(`[ogygia] ${path.relative(root, abs)}: scss compile failed — ${err.message}`);
74
+ warn("scss_compile_failed", {
75
+ file: path.relative(root, abs),
76
+ reason: err.message
77
+ });
74
78
  return whole;
75
79
  }
76
80
  });
@@ -86,7 +90,10 @@ async function preprocess_component_for_css(source, abs, root) {
86
90
  const { code } = await ts(body, abs + ".ts");
87
91
  out = out.replace(whole, `<script${attrs}>${code}<\/script>`);
88
92
  } catch (err) {
89
- console.warn(`[ogygia] ${path.relative(root, abs)}: TypeScript strip failed — ${err.message}`);
93
+ warn("ts_strip_failed", {
94
+ file: path.relative(root, abs),
95
+ reason: err.message
96
+ });
90
97
  }
91
98
  }
92
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygia/core",
3
- "version": "0.12.3",
3
+ "version": "0.13.0",
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": {
@@ -58,6 +58,11 @@
58
58
  "svelte": "./dist/internal-instruments.js",
59
59
  "default": "./dist/internal-instruments.js"
60
60
  },
61
+ "./internal/messages": {
62
+ "types": "./dist/messages/index.d.ts",
63
+ "svelte": "./dist/messages/index.js",
64
+ "default": "./dist/messages/index.js"
65
+ },
61
66
  "./internal/register": {
62
67
  "types": "./dist/internal-register.d.ts",
63
68
  "svelte": "./dist/internal-register.js",
@@ -134,6 +139,7 @@
134
139
  "access": "public"
135
140
  },
136
141
  "dependencies": {
142
+ "@ogygia/machine": "^0.13.0",
137
143
  "devalue": "^5.9.3",
138
144
  "esm-env": "^1.2.2",
139
145
  "estree-walker": "^3.0.3",
@@ -141,6 +147,7 @@
141
147
  "tinyglobby": "^0.2.17"
142
148
  },
143
149
  "devDependencies": {
150
+ "@ogygia/config": "0.0.0",
144
151
  "@ogygia/tsdown-plugin-svelte": "1.1.1",
145
152
  "@sveltejs/kit": "^2.70.2",
146
153
  "@sveltejs/vite-plugin-svelte": "^7.2.0",
@@ -1,19 +0,0 @@
1
- <script>// Keep-alive host for a KEPT island (`keep:`): LiveHost's props-pushable host — the "inside an
2
- // island" context, `$state` props, `setProps` so the next page's props reach the relocated island —
3
- // in the SSR shape of a placed island (Region.svelte's `{#if Component}<Component {...props} />{/if}`,
4
- // as NestedProvider mirrors it). LiveHost has no `{#if}`: it hydrates a live region's render()
5
- // output, and a kept island hydrated through it met the server's `[0` branch marker where it
6
- // expected the component's own, discarding the server DOM on every load. NOT part of the public API.
7
- import { setNested } from "./nested.js";
8
- let { component: Component, initialProps } = $props();
9
- // Seed once from the incoming prop; later pages replace it via setProps(). Intentional initial read.
10
- // svelte-ignore state_referenced_locally
11
- let current = $state(initialProps);
12
- /** Called by the runtime when the island crosses to the next page — reactive prop push. */
13
- export function setProps(next) {
14
- current = next;
15
- }
16
- setNested();
17
- </script>
18
-
19
- {#if Component}<Component {...current} />{/if}
@@ -1,10 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- type $$ComponentProps = {
3
- component: SvelteComponent<Record<string, unknown>>;
4
- initialProps: Record<string, unknown>;
5
- };
6
- declare const KeepHost: import("svelte").Component<$$ComponentProps, {
7
- setProps: (next: Record<string, unknown>) => void;
8
- }, "">;
9
- type KeepHost = ReturnType<typeof KeepHost>;
10
- export default KeepHost;
@@ -1,19 +0,0 @@
1
- <script>// Keep-alive host for an INTERACTIVE live region (`query.live` yielding `region(C, props)`
2
- // with a wake schedule). Like NestedProvider, it sets the "inside an island" context and renders
3
- // the component with no DOM of its own (so it hydrates the server render() output cleanly). Unlike
4
- // NestedProvider, its props are `$state` and it exposes `setProps` — so a live tick updates the
5
- // MOUNTED component reactively instead of tearing it down and re-hydrating. Focus and local island
6
- // state survive; Svelte reconciles the view. NOT part of the public API.
7
- import { setNested } from "./nested.js";
8
- let { component: Component, initialProps } = $props();
9
- // Seed once from the incoming prop; later ticks replace it via setProps(). Intentional initial read.
10
- // svelte-ignore state_referenced_locally
11
- let current = $state(initialProps);
12
- /** Called by the runtime on each live tick with the same component — reactive prop push. */
13
- export function setProps(next) {
14
- current = next;
15
- }
16
- setNested();
17
- </script>
18
-
19
- <Component {...current} />
@@ -1,10 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- type $$ComponentProps = {
3
- component: SvelteComponent<Record<string, unknown>>;
4
- initialProps: Record<string, unknown>;
5
- };
6
- declare const LiveHost: import("svelte").Component<$$ComponentProps, {
7
- setProps: (next: Record<string, unknown>) => void;
8
- }, "">;
9
- type LiveHost = ReturnType<typeof LiveHost>;
10
- export default LiveHost;
@@ -1,13 +0,0 @@
1
- <script>// Passthrough the runtime hydrates a top-level island into, so descendants see the
2
- // "inside an island" context. Mirrors Region.svelte's island SSR shape EXACTLY
3
- // (`{#if Component}<Component {...props} />{/if}`) so Svelte adopts the SSR nodes in place instead
4
- // of discarding and re-creating the island root (a re-created root is class-less for a tick → a
5
- // `class:`-driven `position: fixed` drops to `static` for a frame). SELF-CLOSING on purpose: any
6
- // slot content here would pass an implicit `children` snippet that OVERRIDES the decoded
7
- // `props.children` (the revived slot/region snippet) and desyncs hydration with an extra anchor.
8
- import { setNested } from "./nested.js";
9
- let { component: Component, props } = $props();
10
- setNested();
11
- </script>
12
-
13
- {#if Component}<Component {...props} />{/if}
@@ -1,8 +0,0 @@
1
- import { SvelteComponent } from "svelte";
2
- type $$ComponentProps = {
3
- component: SvelteComponent<Record<string, unknown>>;
4
- props: Record<string, unknown>;
5
- };
6
- declare const NestedProvider: import("svelte").Component<$$ComponentProps, {}, "">;
7
- type NestedProvider = ReturnType<typeof NestedProvider>;
8
- export default NestedProvider;
@@ -1,23 +0,0 @@
1
- /**
2
- * Bounded SPA HTML cache: TTL + max entries + approximate byte budget.
3
- * Expired entries are dropped on read/insert; overflow drops oldest by timestamp.
4
- */
5
- export type PageCacheEntry = {
6
- html: string;
7
- t: number;
8
- bytes: number;
9
- };
10
- export declare class PageCache {
11
- #private;
12
- constructor(opts?: {
13
- ttlMs?: number;
14
- maxEntries?: number;
15
- maxBytes?: number;
16
- });
17
- get(href: string): string | null;
18
- set(href: string, html: string): void;
19
- delete(href: string): void;
20
- clear(): void;
21
- get size(): number;
22
- get bytes(): number;
23
- }
@@ -1,74 +0,0 @@
1
- // src/runtime/page-cache.ts
2
- var PageCache = class {
3
- #map = /* @__PURE__ */ new Map();
4
- #total_bytes = 0;
5
- #ttlMs;
6
- #maxEntries;
7
- #maxBytes;
8
- constructor(opts) {
9
- this.#ttlMs = opts?.ttlMs ?? 8e3;
10
- this.#maxEntries = opts?.maxEntries ?? 32;
11
- this.#maxBytes = opts?.maxBytes ?? 4e6;
12
- }
13
- #drop(href) {
14
- const e = this.#map.get(href);
15
- if (!e) return;
16
- this.#map.delete(href);
17
- this.#total_bytes -= e.bytes;
18
- }
19
- #evict_expired(now) {
20
- for (const [href, e] of this.#map) if (now - e.t >= this.#ttlMs) this.#drop(href);
21
- }
22
- #evict_overflow() {
23
- while (this.#map.size > this.#maxEntries || this.#total_bytes > this.#maxBytes) {
24
- let oldest_href = null;
25
- let oldest_t = Infinity;
26
- for (const [href, e] of this.#map) if (e.t < oldest_t) {
27
- oldest_t = e.t;
28
- oldest_href = href;
29
- }
30
- if (!oldest_href) break;
31
- this.#drop(oldest_href);
32
- }
33
- }
34
- get(href) {
35
- const now = Date.now();
36
- const e = this.#map.get(href);
37
- if (!e) return null;
38
- if (now - e.t >= this.#ttlMs) {
39
- this.#drop(href);
40
- return null;
41
- }
42
- this.#map.delete(href);
43
- e.t = now;
44
- this.#map.set(href, e);
45
- return e.html;
46
- }
47
- set(href, html) {
48
- const now = Date.now();
49
- this.#evict_expired(now);
50
- this.#drop(href);
51
- const bytes = html.length * 2;
52
- this.#map.set(href, {
53
- html,
54
- t: now,
55
- bytes
56
- });
57
- this.#total_bytes += bytes;
58
- this.#evict_overflow();
59
- }
60
- delete(href) {
61
- this.#drop(href);
62
- }
63
- clear() {
64
- this.#map.clear();
65
- this.#total_bytes = 0;
66
- }
67
- get size() {
68
- return this.#map.size;
69
- }
70
- get bytes() {
71
- return this.#total_bytes;
72
- }
73
- };
74
- export { PageCache };