@ogygia/core 0.0.0 → 0.11.1

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 (548) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -1
  3. package/ambient.d.ts +194 -0
  4. package/dist/ClientBindingStub.svelte +6 -0
  5. package/dist/ClientBindingStub.svelte.d.ts +26 -0
  6. package/dist/KeepHost.svelte +19 -0
  7. package/dist/KeepHost.svelte.d.ts +10 -0
  8. package/dist/LakeBoundary.svelte +16 -0
  9. package/dist/LakeBoundary.svelte.d.ts +11 -0
  10. package/dist/LateIsland.svelte +22 -0
  11. package/dist/LateIsland.svelte.d.ts +15 -0
  12. package/dist/LateIslandAwait.svelte +17 -0
  13. package/dist/LateIslandAwait.svelte.d.ts +15 -0
  14. package/dist/LiveHost.svelte +19 -0
  15. package/dist/LiveHost.svelte.d.ts +10 -0
  16. package/dist/NestedProvider.svelte +13 -0
  17. package/dist/NestedProvider.svelte.d.ts +8 -0
  18. package/dist/OgygiaBoundary.svelte +5 -0
  19. package/dist/OgygiaBoundary.svelte.d.ts +17 -0
  20. package/dist/PromiseRegion.svelte +40 -0
  21. package/dist/PromiseRegion.svelte.d.ts +15 -0
  22. package/dist/PromiseRegionAwait.svelte +27 -0
  23. package/dist/PromiseRegionAwait.svelte.d.ts +15 -0
  24. package/dist/Provide.svelte +27 -0
  25. package/dist/Provide.svelte.d.ts +8 -0
  26. package/dist/RawHtml.svelte +9 -0
  27. package/dist/RawHtml.svelte.d.ts +6 -0
  28. package/dist/Region.svelte +1173 -0
  29. package/dist/Region.svelte.d.ts +68 -0
  30. package/dist/SlotBoundary.svelte +13 -0
  31. package/dist/SlotBoundary.svelte.d.ts +7 -0
  32. package/dist/app.d.ts +4 -0
  33. package/dist/app.js +3 -0
  34. package/dist/boundary.d.ts +35 -0
  35. package/dist/boundary.js +127 -0
  36. package/dist/build-cache.d.ts +13 -0
  37. package/dist/build-cache.js +77 -0
  38. package/dist/compiler/blank-styles.d.ts +1 -0
  39. package/dist/compiler/blank-styles.js +63 -0
  40. package/dist/compiler/bom.d.ts +2 -0
  41. package/dist/compiler/bom.js +15 -0
  42. package/dist/compiler/browser-full.d.ts +8 -0
  43. package/dist/compiler/browser-full.js +8 -0
  44. package/dist/compiler/browser.d.ts +11 -0
  45. package/dist/compiler/browser.js +11 -0
  46. package/dist/compiler/content/transportables.d.ts +26 -0
  47. package/dist/compiler/content/transportables.js +219 -0
  48. package/dist/compiler/ctx.d.ts +185 -0
  49. package/dist/compiler/ctx.js +203 -0
  50. package/dist/compiler/debarrel/barrel.d.ts +55 -0
  51. package/dist/compiler/debarrel/barrel.js +248 -0
  52. package/dist/compiler/debarrel/options.d.ts +67 -0
  53. package/dist/compiler/debarrel/options.js +31 -0
  54. package/dist/compiler/debarrel/parse.d.ts +65 -0
  55. package/dist/compiler/debarrel/parse.js +256 -0
  56. package/dist/compiler/debarrel/plugin.d.ts +31 -0
  57. package/dist/compiler/debarrel/plugin.js +190 -0
  58. package/dist/compiler/debarrel/rewrite.d.ts +27 -0
  59. package/dist/compiler/debarrel/rewrite.js +118 -0
  60. package/dist/compiler/debarrel/svelte.d.ts +13 -0
  61. package/dist/compiler/debarrel/svelte.js +56 -0
  62. package/dist/compiler/dev/css-scope.d.ts +16 -0
  63. package/dist/compiler/dev/css-scope.js +38 -0
  64. package/dist/compiler/dev/dev-hmr.d.ts +25 -0
  65. package/dist/compiler/dev/dev-hmr.js +29 -0
  66. package/dist/compiler/dev/hmr.d.ts +34 -0
  67. package/dist/compiler/dev/hmr.js +57 -0
  68. package/dist/compiler/dev/region-bytes.d.ts +34 -0
  69. package/dist/compiler/dev/region-bytes.js +126 -0
  70. package/dist/compiler/driver.d.ts +280 -0
  71. package/dist/compiler/driver.js +1352 -0
  72. package/dist/compiler/flags.d.ts +16 -0
  73. package/dist/compiler/flags.js +101 -0
  74. package/dist/compiler/fouc-css.d.ts +97 -0
  75. package/dist/compiler/fouc-css.js +335 -0
  76. package/dist/compiler/free-vars.d.ts +20 -0
  77. package/dist/compiler/free-vars.js +327 -0
  78. package/dist/compiler/host.d.ts +65 -0
  79. package/dist/compiler/host.js +51 -0
  80. package/dist/compiler/ids.d.ts +84 -0
  81. package/dist/compiler/ids.js +86 -0
  82. package/dist/compiler/index.d.ts +11 -0
  83. package/dist/compiler/index.js +11 -0
  84. package/dist/compiler/kit.d.ts +129 -0
  85. package/dist/compiler/kit.js +563 -0
  86. package/dist/compiler/link/build-output.d.ts +44 -0
  87. package/dist/compiler/link/build-output.js +147 -0
  88. package/dist/compiler/link/caps.d.ts +48 -0
  89. package/dist/compiler/link/caps.js +64 -0
  90. package/dist/compiler/link/context-detect.d.ts +23 -0
  91. package/dist/compiler/link/context-detect.js +137 -0
  92. package/dist/compiler/link/emit-gate.d.ts +11 -0
  93. package/dist/compiler/link/emit-gate.js +40 -0
  94. package/dist/compiler/link/entry-shim.d.ts +4 -0
  95. package/dist/compiler/link/entry-shim.js +29 -0
  96. package/dist/compiler/link/island-deps.d.ts +142 -0
  97. package/dist/compiler/link/island-deps.js +525 -0
  98. package/dist/compiler/link/manifest.d.ts +5 -0
  99. package/dist/compiler/link/manifest.js +9 -0
  100. package/dist/compiler/link/page-keys.d.ts +64 -0
  101. package/dist/compiler/link/page-keys.js +683 -0
  102. package/dist/compiler/link/registry-stub.d.ts +41 -0
  103. package/dist/compiler/link/registry-stub.js +212 -0
  104. package/dist/compiler/link/router-config.d.ts +11 -0
  105. package/dist/compiler/link/router-config.js +15 -0
  106. package/dist/compiler/link/router-css.d.ts +22 -0
  107. package/dist/compiler/link/router-css.js +142 -0
  108. package/dist/compiler/link/runtime-entry.d.ts +71 -0
  109. package/dist/compiler/link/runtime-entry.js +132 -0
  110. package/dist/compiler/link/server-manifest.d.ts +12 -0
  111. package/dist/compiler/link/server-manifest.js +45 -0
  112. package/dist/compiler/link/speculation.d.ts +17 -0
  113. package/dist/compiler/link/speculation.js +36 -0
  114. package/dist/compiler/link/transport.d.ts +31 -0
  115. package/dist/compiler/link/transport.js +67 -0
  116. package/dist/compiler/macros/bake.d.ts +20 -0
  117. package/dist/compiler/macros/bake.js +317 -0
  118. package/dist/compiler/macros/browser.d.ts +11 -0
  119. package/dist/compiler/macros/browser.js +69 -0
  120. package/dist/compiler/macros/dedent.d.ts +12 -0
  121. package/dist/compiler/macros/dedent.js +36 -0
  122. package/dist/compiler/macros/dollar.d.ts +15 -0
  123. package/dist/compiler/macros/dollar.js +387 -0
  124. package/dist/compiler/macros/pipeline.d.ts +31 -0
  125. package/dist/compiler/macros/pipeline.js +106 -0
  126. package/dist/compiler/macros/source.d.ts +6 -0
  127. package/dist/compiler/macros/source.js +127 -0
  128. package/dist/compiler/macros/store.d.ts +17 -0
  129. package/dist/compiler/macros/store.js +244 -0
  130. package/dist/compiler/macros/wire.d.ts +14 -0
  131. package/dist/compiler/macros/wire.js +160 -0
  132. package/dist/compiler/ownership-stamps.d.ts +6 -0
  133. package/dist/compiler/ownership-stamps.js +144 -0
  134. package/dist/compiler/parse/oxc.d.ts +34 -0
  135. package/dist/compiler/parse/oxc.js +59 -0
  136. package/dist/compiler/parse/scan.d.ts +43 -0
  137. package/dist/compiler/parse/scan.js +232 -0
  138. package/dist/compiler/program.d.ts +140 -0
  139. package/dist/compiler/program.js +242 -0
  140. package/dist/compiler/region/emit.d.ts +169 -0
  141. package/dist/compiler/region/emit.js +286 -0
  142. package/dist/compiler/region/identity.d.ts +28 -0
  143. package/dist/compiler/region/identity.js +75 -0
  144. package/dist/compiler/region/ir.d.ts +65 -0
  145. package/dist/compiler/region/ir.js +0 -0
  146. package/dist/compiler/region/transform.d.ts +178 -0
  147. package/dist/compiler/region/transform.js +1933 -0
  148. package/dist/compiler/script-request.d.ts +1 -0
  149. package/dist/compiler/script-request.js +43 -0
  150. package/dist/context-bridge.d.ts +65 -0
  151. package/dist/context-bridge.js +217 -0
  152. package/dist/context-registry.d.ts +40 -0
  153. package/dist/context-registry.js +15 -0
  154. package/dist/context.d.ts +72 -0
  155. package/dist/context.js +158 -0
  156. package/dist/current-region.d.ts +14 -0
  157. package/dist/current-region.js +36 -0
  158. package/dist/document.d.ts +41 -0
  159. package/dist/document.js +125 -0
  160. package/dist/entry-hydrate.d.ts +5 -0
  161. package/dist/entry-hydrate.js +42 -0
  162. package/dist/escape.d.ts +18 -0
  163. package/dist/escape.js +37 -0
  164. package/dist/events/bus.d.ts +33 -0
  165. package/dist/events/bus.js +153 -0
  166. package/dist/events/index.d.ts +4 -0
  167. package/dist/events/index.js +4 -0
  168. package/dist/events/schema.d.ts +389 -0
  169. package/dist/events/schema.js +23 -0
  170. package/dist/events/server-registry.d.ts +7 -0
  171. package/dist/events/server-registry.js +13 -0
  172. package/dist/events/sinks.d.ts +64 -0
  173. package/dist/events/sinks.js +85 -0
  174. package/dist/fn-transport.d.ts +33 -0
  175. package/dist/fn-transport.js +140 -0
  176. package/dist/frame.d.ts +20 -0
  177. package/dist/frame.js +19 -0
  178. package/dist/holes-record.d.ts +6 -0
  179. package/dist/holes-record.js +8 -0
  180. package/dist/hooks.d.ts +43 -0
  181. package/dist/hooks.js +1191 -0
  182. package/dist/hydration-info.d.ts +1 -0
  183. package/dist/hydration-info.js +31 -0
  184. package/dist/index.d.ts +21 -0
  185. package/dist/index.js +17 -0
  186. package/dist/insights/attr-rules.d.ts +15 -0
  187. package/dist/insights/attr-rules.js +27 -0
  188. package/dist/insights/cpu.d.ts +82 -0
  189. package/dist/insights/cpu.js +177 -0
  190. package/dist/insights/fp-drift.d.ts +28 -0
  191. package/dist/insights/fp-drift.js +148 -0
  192. package/dist/insights/hole-segments.d.ts +26 -0
  193. package/dist/insights/hole-segments.js +50 -0
  194. package/dist/insights/html-diff.d.ts +25 -0
  195. package/dist/insights/html-diff.js +157 -0
  196. package/dist/insights/hydration-hazards.d.ts +36 -0
  197. package/dist/insights/hydration-hazards.js +136 -0
  198. package/dist/insights/hydration-status.d.ts +2 -0
  199. package/dist/insights/hydration-status.js +0 -0
  200. package/dist/insights/index.d.ts +14 -0
  201. package/dist/insights/index.js +12 -0
  202. package/dist/insights/page-assets.d.ts +211 -0
  203. package/dist/insights/page-assets.js +608 -0
  204. package/dist/insights/page-insights.d.ts +749 -0
  205. package/dist/insights/page-insights.js +2157 -0
  206. package/dist/insights/session-data.d.ts +108 -0
  207. package/dist/insights/session-data.js +0 -0
  208. package/dist/insights/session-insights.d.ts +121 -0
  209. package/dist/insights/session-insights.js +548 -0
  210. package/dist/insights/switch.d.ts +53 -0
  211. package/dist/insights/switch.js +91 -0
  212. package/dist/insights/testing-version.d.ts +19 -0
  213. package/dist/insights/testing-version.js +21 -0
  214. package/dist/insights/third-party.d.ts +75 -0
  215. package/dist/insights/third-party.js +160 -0
  216. package/dist/internal-instruments.d.ts +13 -0
  217. package/dist/internal-instruments.js +12 -0
  218. package/dist/internal-reconcile.d.ts +3 -0
  219. package/dist/internal-reconcile.js +3 -0
  220. package/dist/internal-register.d.ts +7 -0
  221. package/dist/internal-register.js +7 -0
  222. package/dist/internal-server.d.ts +7 -0
  223. package/dist/internal-server.js +7 -0
  224. package/dist/internal.d.ts +13 -0
  225. package/dist/internal.js +13 -0
  226. package/dist/island-graph.d.ts +36 -0
  227. package/dist/island-graph.js +89 -0
  228. package/dist/keep-fallback-marker.d.ts +7 -0
  229. package/dist/keep-fallback-marker.js +9 -0
  230. package/dist/keep-fallback.d.ts +13 -0
  231. package/dist/keep-fallback.js +39 -0
  232. package/dist/kit-paths.d.ts +2 -0
  233. package/dist/kit-paths.js +39 -0
  234. package/dist/late-region-registry.d.ts +40 -0
  235. package/dist/late-region-registry.js +36 -0
  236. package/dist/live-transport.d.ts +57 -0
  237. package/dist/live-transport.js +145 -0
  238. package/dist/markup.d.ts +4 -0
  239. package/dist/markup.js +4 -0
  240. package/dist/own-package.d.ts +15 -0
  241. package/dist/own-package.js +20 -0
  242. package/dist/page-defer.d.ts +33 -0
  243. package/dist/page-defer.js +35 -0
  244. package/dist/page-facts-script.d.ts +7 -0
  245. package/dist/page-facts-script.js +9 -0
  246. package/dist/page-seed-registry.d.ts +72 -0
  247. package/dist/page-seed-registry.js +31 -0
  248. package/dist/plugin/capability.d.ts +14 -0
  249. package/dist/plugin/capability.js +44 -0
  250. package/dist/plugin/client.d.ts +39 -0
  251. package/dist/plugin/client.js +6 -0
  252. package/dist/plugin/css.d.ts +3 -0
  253. package/dist/plugin/css.js +54 -0
  254. package/dist/plugin/facts.d.ts +42 -0
  255. package/dist/plugin/facts.js +37 -0
  256. package/dist/plugin/hooks.d.ts +33 -0
  257. package/dist/plugin/hooks.js +38 -0
  258. package/dist/plugin/index.d.ts +127 -0
  259. package/dist/plugin/index.js +26 -0
  260. package/dist/plugin/routes.d.ts +32 -0
  261. package/dist/plugin/routes.js +35 -0
  262. package/dist/plugin/server.d.ts +27 -0
  263. package/dist/plugin/server.js +92 -0
  264. package/dist/plugin/standard-schema.d.ts +27 -0
  265. package/dist/plugin/standard-schema.js +0 -0
  266. package/dist/plugin/testing.d.ts +13 -0
  267. package/dist/plugin/testing.js +54 -0
  268. package/dist/plugin/utils.d.ts +13 -0
  269. package/dist/plugin/utils.js +19 -0
  270. package/dist/portable-form.d.ts +22 -0
  271. package/dist/portable-form.js +52 -0
  272. package/dist/preference.d.ts +35 -0
  273. package/dist/preference.js +84 -0
  274. package/dist/preload.d.ts +1 -0
  275. package/dist/preload.js +21 -0
  276. package/dist/ref-watch.d.ts +31 -0
  277. package/dist/ref-watch.js +66 -0
  278. package/dist/ref.d.ts +124 -0
  279. package/dist/ref.js +272 -0
  280. package/dist/region-brand.d.ts +8 -0
  281. package/dist/region-brand.js +10 -0
  282. package/dist/region-core.d.ts +2 -0
  283. package/dist/region-core.js +1 -0
  284. package/dist/region-snippet.d.ts +73 -0
  285. package/dist/region-snippet.js +351 -0
  286. package/dist/region.d.ts +127 -0
  287. package/dist/region.js +162 -0
  288. package/dist/request-event.d.ts +1 -0
  289. package/dist/request-event.js +37 -0
  290. package/dist/router-css.d.ts +39 -0
  291. package/dist/router-css.js +66 -0
  292. package/dist/runtime/app-transport.d.ts +2 -0
  293. package/dist/runtime/app-transport.js +13 -0
  294. package/dist/runtime/beacon.d.ts +271 -0
  295. package/dist/runtime/beacon.js +2190 -0
  296. package/dist/runtime/boot-link.d.ts +1 -0
  297. package/dist/runtime/boot-link.js +44 -0
  298. package/dist/runtime/client-hooks.d.ts +5 -0
  299. package/dist/runtime/client-hooks.js +22 -0
  300. package/dist/runtime/client-plugins.d.ts +8 -0
  301. package/dist/runtime/client-plugins.js +34 -0
  302. package/dist/runtime/concurrency.d.ts +12 -0
  303. package/dist/runtime/concurrency.js +29 -0
  304. package/dist/runtime/connected.d.ts +12 -0
  305. package/dist/runtime/connected.js +16 -0
  306. package/dist/runtime/context.d.ts +1 -0
  307. package/dist/runtime/context.js +19 -0
  308. package/dist/runtime/core.d.ts +15 -0
  309. package/dist/runtime/core.js +1173 -0
  310. package/dist/runtime/drift-watch.d.ts +9 -0
  311. package/dist/runtime/drift-watch.js +60 -0
  312. package/dist/runtime/entry-locations.d.ts +33 -0
  313. package/dist/runtime/entry-locations.js +119 -0
  314. package/dist/runtime/foreign-props.d.ts +8 -0
  315. package/dist/runtime/foreign-props.js +14 -0
  316. package/dist/runtime/form-continuity.d.ts +10 -0
  317. package/dist/runtime/form-continuity.js +107 -0
  318. package/dist/runtime/frame-nav.d.ts +36 -0
  319. package/dist/runtime/frame-nav.js +225 -0
  320. package/dist/runtime/frame-store.d.ts +62 -0
  321. package/dist/runtime/frame-store.js +214 -0
  322. package/dist/runtime/frames.d.ts +1 -0
  323. package/dist/runtime/frames.js +25 -0
  324. package/dist/runtime/full.d.ts +4 -0
  325. package/dist/runtime/full.js +32 -0
  326. package/dist/runtime/hash.d.ts +41 -0
  327. package/dist/runtime/hash.js +79 -0
  328. package/dist/runtime/hole-facts.d.ts +8 -0
  329. package/dist/runtime/hole-facts.js +57 -0
  330. package/dist/runtime/host-classes.d.ts +24 -0
  331. package/dist/runtime/host-classes.js +43 -0
  332. package/dist/runtime/hydrate-core.d.ts +101 -0
  333. package/dist/runtime/hydrate-core.js +605 -0
  334. package/dist/runtime/index.d.ts +2 -0
  335. package/dist/runtime/index.js +1 -0
  336. package/dist/runtime/interaction-replay.d.ts +11 -0
  337. package/dist/runtime/interaction-replay.js +70 -0
  338. package/dist/runtime/interaction.d.ts +33 -0
  339. package/dist/runtime/interaction.js +217 -0
  340. package/dist/runtime/island-graph-preload.d.ts +13 -0
  341. package/dist/runtime/island-graph-preload.js +99 -0
  342. package/dist/runtime/kit-boot.d.ts +29 -0
  343. package/dist/runtime/kit-boot.js +60 -0
  344. package/dist/runtime/kit-page-thread.svelte.d.ts +1 -0
  345. package/dist/runtime/kit-page-thread.svelte.js +116 -0
  346. package/dist/runtime/lake-anchors.d.ts +13 -0
  347. package/dist/runtime/lake-anchors.js +19 -0
  348. package/dist/runtime/lakes.d.ts +15 -0
  349. package/dist/runtime/lakes.js +212 -0
  350. package/dist/runtime/live.d.ts +3 -0
  351. package/dist/runtime/live.js +17 -0
  352. package/dist/runtime/load-scheduler.d.ts +53 -0
  353. package/dist/runtime/load-scheduler.js +317 -0
  354. package/dist/runtime/morph.d.ts +42 -0
  355. package/dist/runtime/morph.js +671 -0
  356. package/dist/runtime/nav-handle.d.ts +25 -0
  357. package/dist/runtime/nav-handle.js +71 -0
  358. package/dist/runtime/nav-hooks.d.ts +2 -0
  359. package/dist/runtime/nav-hooks.js +23 -0
  360. package/dist/runtime/nearest-attr.d.ts +4 -0
  361. package/dist/runtime/nearest-attr.js +16 -0
  362. package/dist/runtime/observe.d.ts +27 -0
  363. package/dist/runtime/observe.js +63 -0
  364. package/dist/runtime/own-cost.d.ts +9 -0
  365. package/dist/runtime/own-cost.js +35 -0
  366. package/dist/runtime/ownership.d.ts +101 -0
  367. package/dist/runtime/ownership.js +115 -0
  368. package/dist/runtime/page-cache.d.ts +23 -0
  369. package/dist/runtime/page-cache.js +74 -0
  370. package/dist/runtime/page-defer.d.ts +14 -0
  371. package/dist/runtime/page-defer.js +103 -0
  372. package/dist/runtime/parse-html.d.ts +40 -0
  373. package/dist/runtime/parse-html.js +81 -0
  374. package/dist/runtime/reconcile.d.ts +41 -0
  375. package/dist/runtime/reconcile.js +194 -0
  376. package/dist/runtime/region-attrs.d.ts +95 -0
  377. package/dist/runtime/region-attrs.js +153 -0
  378. package/dist/runtime/region-endpoint-url.d.ts +76 -0
  379. package/dist/runtime/region-endpoint-url.js +169 -0
  380. package/dist/runtime/region-ids.d.ts +8 -0
  381. package/dist/runtime/region-ids.js +33 -0
  382. package/dist/runtime/remote-seeds.d.ts +2 -0
  383. package/dist/runtime/remote-seeds.js +21 -0
  384. package/dist/runtime/render-blocking.d.ts +2 -0
  385. package/dist/runtime/render-blocking.js +30 -0
  386. package/dist/runtime/restore.d.ts +34 -0
  387. package/dist/runtime/restore.js +390 -0
  388. package/dist/runtime/router-nav.d.ts +63 -0
  389. package/dist/runtime/router-nav.js +740 -0
  390. package/dist/runtime/router.d.ts +201 -0
  391. package/dist/runtime/router.js +593 -0
  392. package/dist/runtime/schedule.d.ts +49 -0
  393. package/dist/runtime/schedule.js +256 -0
  394. package/dist/runtime/seeds.d.ts +50 -0
  395. package/dist/runtime/seeds.js +208 -0
  396. package/dist/runtime/session.d.ts +52 -0
  397. package/dist/runtime/session.js +130 -0
  398. package/dist/runtime/sidecar.d.ts +3 -0
  399. package/dist/runtime/sidecar.js +56 -0
  400. package/dist/runtime/slots.d.ts +183 -0
  401. package/dist/runtime/slots.js +44 -0
  402. package/dist/runtime/spa-cacheable.d.ts +7 -0
  403. package/dist/runtime/spa-cacheable.js +18 -0
  404. package/dist/runtime/speculate-hint.d.ts +1 -0
  405. package/dist/runtime/speculate-hint.js +35 -0
  406. package/dist/runtime/svelte-warnings.d.ts +28 -0
  407. package/dist/runtime/svelte-warnings.js +71 -0
  408. package/dist/runtime/wire-classes.d.ts +3 -0
  409. package/dist/runtime/wire-classes.js +69 -0
  410. package/dist/runtime/wire-format.d.ts +7 -0
  411. package/dist/runtime/wire-format.js +22 -0
  412. package/dist/script.d.ts +134 -0
  413. package/dist/script.js +184 -0
  414. package/dist/seed-refs.d.ts +105 -0
  415. package/dist/seed-refs.js +487 -0
  416. package/dist/server/capability-lifetime.d.ts +28 -0
  417. package/dist/server/capability-lifetime.js +31 -0
  418. package/dist/server/dead-kit-resolves.d.ts +1 -0
  419. package/dist/server/dead-kit-resolves.js +39 -0
  420. package/dist/server/document-assembly.d.ts +30 -0
  421. package/dist/server/document-assembly.js +26 -0
  422. package/dist/server/document-tail.d.ts +113 -0
  423. package/dist/server/document-tail.js +208 -0
  424. package/dist/server/endpoint.d.ts +51 -0
  425. package/dist/server/endpoint.js +90 -0
  426. package/dist/server/entry-location.d.ts +8 -0
  427. package/dist/server/entry-location.js +29 -0
  428. package/dist/server/fingerprint.d.ts +1 -0
  429. package/dist/server/fingerprint.js +25 -0
  430. package/dist/server/head-presence.d.ts +45 -0
  431. package/dist/server/head-presence.js +156 -0
  432. package/dist/server/hmac.d.ts +38 -0
  433. package/dist/server/hmac.js +89 -0
  434. package/dist/server/hole-graph.d.ts +7 -0
  435. package/dist/server/hole-graph.js +71 -0
  436. package/dist/server/hole-urls.d.ts +3 -0
  437. package/dist/server/hole-urls.js +76 -0
  438. package/dist/server/html-scan.d.ts +19 -0
  439. package/dist/server/html-scan.js +60 -0
  440. package/dist/server/kit-context.d.ts +78 -0
  441. package/dist/server/kit-context.js +110 -0
  442. package/dist/server/late-wire.d.ts +22 -0
  443. package/dist/server/late-wire.js +28 -0
  444. package/dist/server/page-facts.d.ts +25 -0
  445. package/dist/server/page-facts.js +138 -0
  446. package/dist/server/page-seed.d.ts +33 -0
  447. package/dist/server/page-seed.js +60 -0
  448. package/dist/server/page-stream.d.ts +55 -0
  449. package/dist/server/page-stream.js +121 -0
  450. package/dist/server/payload.d.ts +6 -0
  451. package/dist/server/payload.js +22 -0
  452. package/dist/server/personal-response.d.ts +6 -0
  453. package/dist/server/personal-response.js +13 -0
  454. package/dist/server/props-wire.d.ts +56 -0
  455. package/dist/server/props-wire.js +178 -0
  456. package/dist/server/rate-limit.d.ts +22 -0
  457. package/dist/server/rate-limit.js +63 -0
  458. package/dist/server/region-css.d.ts +5 -0
  459. package/dist/server/region-css.js +30 -0
  460. package/dist/server/region-endpoint.d.ts +35 -0
  461. package/dist/server/region-endpoint.js +142 -0
  462. package/dist/server/region-props.d.ts +6 -0
  463. package/dist/server/region-props.js +44 -0
  464. package/dist/server/remote-seed-gate.d.ts +50 -0
  465. package/dist/server/remote-seed-gate.js +66 -0
  466. package/dist/server/render-cache.d.ts +26 -0
  467. package/dist/server/render-cache.js +51 -0
  468. package/dist/server/render-page.d.ts +51 -0
  469. package/dist/server/render-page.js +176 -0
  470. package/dist/server/render-region-html.d.ts +2 -0
  471. package/dist/server/render-region-html.js +19 -0
  472. package/dist/server/request-stats.d.ts +174 -0
  473. package/dist/server/request-stats.js +54 -0
  474. package/dist/server/reversible.d.ts +83 -0
  475. package/dist/server/reversible.js +994 -0
  476. package/dist/server/seed-shape.d.ts +22 -0
  477. package/dist/server/seed-shape.js +24 -0
  478. package/dist/server/shared-cache.d.ts +35 -0
  479. package/dist/server/shared-cache.js +104 -0
  480. package/dist/server/signing-key.d.ts +11 -0
  481. package/dist/server/signing-key.js +47 -0
  482. package/dist/server/sized-lru.d.ts +20 -0
  483. package/dist/server/sized-lru.js +68 -0
  484. package/dist/server/split-regions.d.ts +81 -0
  485. package/dist/server/split-regions.js +368 -0
  486. package/dist/server/stream-regions.d.ts +5 -0
  487. package/dist/server/stream-regions.js +36 -0
  488. package/dist/shared-state.d.ts +7 -0
  489. package/dist/shared-state.js +152 -0
  490. package/dist/shims/app-environment.d.ts +4 -0
  491. package/dist/shims/app-environment.js +6 -0
  492. package/dist/shims/app-navigation.d.ts +33 -0
  493. package/dist/shims/app-navigation.js +119 -0
  494. package/dist/shims/app-paths.d.ts +6 -0
  495. package/dist/shims/app-paths.js +18 -0
  496. package/dist/shims/app-state.svelte.d.ts +23 -0
  497. package/dist/shims/app-state.svelte.js +50 -0
  498. package/dist/shims/app-stores.d.ts +21 -0
  499. package/dist/shims/app-stores.js +54 -0
  500. package/dist/shims/kit-bridge.d.ts +29 -0
  501. package/dist/shims/kit-bridge.js +7 -0
  502. package/dist/shims/kit-remote/client-stub.d.ts +27 -0
  503. package/dist/shims/kit-remote/client-stub.js +43 -0
  504. package/dist/shims/kit-remote/paths-internal-stub.d.ts +3 -0
  505. package/dist/shims/kit-remote/paths-internal-stub.js +5 -0
  506. package/dist/shims/kit-remote/remote-cache.d.ts +49 -0
  507. package/dist/shims/kit-remote/remote-cache.js +73 -0
  508. package/dist/shims/kit-remote/state-stub.d.ts +8 -0
  509. package/dist/shims/kit-remote/state-stub.js +8 -0
  510. package/dist/shims/page-store.svelte.d.ts +39 -0
  511. package/dist/shims/page-store.svelte.js +77 -0
  512. package/dist/source.d.ts +29 -0
  513. package/dist/source.js +87 -0
  514. package/dist/store-transport.d.ts +86 -0
  515. package/dist/store-transport.js +229 -0
  516. package/dist/tool-fetches.d.ts +5 -0
  517. package/dist/tool-fetches.js +41 -0
  518. package/dist/transport.d.ts +48 -0
  519. package/dist/transport.js +181 -0
  520. package/dist/unscoped-css.d.ts +26 -0
  521. package/dist/unscoped-css.js +53 -0
  522. package/dist/vite/dev-maps.d.ts +33 -0
  523. package/dist/vite/dev-maps.js +140 -0
  524. package/dist/vite/index.d.ts +19 -0
  525. package/dist/vite/index.js +820 -0
  526. package/dist/vite/kit-dirs.d.ts +7 -0
  527. package/dist/vite/kit-dirs.js +67 -0
  528. package/dist/vite/late-island.d.ts +25 -0
  529. package/dist/vite/late-island.js +33 -0
  530. package/dist/vite/module-map.d.ts +8 -0
  531. package/dist/vite/module-map.js +144 -0
  532. package/dist/vite/options.d.ts +208 -0
  533. package/dist/vite/options.js +74 -0
  534. package/dist/vite/package-files.d.ts +3 -0
  535. package/dist/vite/package-files.js +84 -0
  536. package/dist/vite/paths.d.ts +45 -0
  537. package/dist/vite/paths.js +112 -0
  538. package/dist/vite/plugin-api.d.ts +166 -0
  539. package/dist/vite/plugin-api.js +212 -0
  540. package/dist/vite/profiler-maps.d.ts +23 -0
  541. package/dist/vite/profiler-maps.js +178 -0
  542. package/dist/vite/server-sourcemaps.d.ts +8 -0
  543. package/dist/vite/server-sourcemaps.js +80 -0
  544. package/dist/vite/sourcemaps.d.ts +18 -0
  545. package/dist/vite/sourcemaps.js +80 -0
  546. package/dist/vite/style-preprocess.d.ts +2 -0
  547. package/dist/vite/style-preprocess.js +96 -0
  548. package/package.json +180 -6
@@ -0,0 +1,1173 @@
1
+ import { frameAddress } from "../frame.js";
2
+ import { kit_hydrates_page } from "./kit-boot.js";
3
+ import { init_shadow_registries, parse_region_html, restore_adopt_sheets, restore_markup } from "./parse-html.js";
4
+ import { wire_classes_for } from "./wire-classes.js";
5
+ import { mark_region_changed, region_changed, unwatch_region, watch_region } from "./drift-watch.js";
6
+ import { runtime_session } from "./session.js";
7
+ import { RegionAnswerRefused, capability_expired, deny_of, is_allowed_region_endpoint, is_document_answer, is_redirected_answer, is_same_origin_response, island_module_url, renewal_url } from "./region-endpoint-url.js";
8
+ import { import_entry, island_entry_of, on_entry_fallback, pin_region_urls } from "./entry-locations.js";
9
+ import { is_awake, is_deferred, is_frozen, ours_on_kit_document, phase2_hydrate_schedule, region_hydrate_schedule, region_schedule } from "./region-attrs.js";
10
+ import { slots } from "./slots.js";
11
+ import { KEEP_FALLBACK_HTML } from "../keep-fallback-marker.js";
12
+ import { PAGE_FACTS_SELECTOR } from "../page-facts-script.js";
13
+ import { NAV_HANDLE_KEY, mpa_nav, publish_nav } from "./nav-handle.js";
14
+ import { link_boot } from "./boot-link.js";
15
+ import { background_start, hydrate_settled, hydrate_started, hydrate_turn, register_region, unregister_region, yield_task } from "./schedule.js";
16
+ import { once_visible } from "./observe.js";
17
+ import { preload_island_graph } from "./island-graph-preload.js";
18
+ import { fetch_priority_of, load_slot, viewport_class } from "./load-scheduler.js";
19
+ import { connected_regions } from "./connected.js";
20
+ import { restore_props_sidecar } from "./sidecar.js";
21
+ import { hole_facts_of } from "./hole-facts.js";
22
+ import { beacon_entry_fallback, beacon_failed, beacon_hole_answered, beacon_hole_failed, beacon_hole_fetched, beacon_hydrated, beacon_warning, beacon_watch } from "./beacon.js";
23
+ import { on_svelte_warning, set_hydrating, tap_svelte_warnings } from "./svelte-warnings.js";
24
+ import { emit } from "../events/bus.js";
25
+ import { ingest_server_events, install_window_sink } from "../events/sinks.js";
26
+ import { CLIENT_PLUGINS, boot_client_plugins, client_region_mount, client_region_unmount } from "./client-plugins.js";
27
+ // src/runtime/core.ts
28
+ const DEVTOOLS = typeof __OGYGIA_DEVTOOLS__ !== "undefined" ? __OGYGIA_DEVTOOLS__ : false;
29
+ const BEACON = typeof __OGYGIA_BEACON__ !== "undefined" ? __OGYGIA_BEACON__ : true;
30
+ /** Above this many characters an island keeps no server copy (its hydration falls back to
31
+ * Svelte's own recovery on a mismatch) — a bound on memory, not a behaviour anyone tunes. */
32
+ const SSR_SNAPSHOT_MAX = 1 << 19;
33
+ /** Per-node stash of a nested island's PRISTINE server markup, captured from a fetched fragment WHILE it
34
+ * is still disconnected — nothing has upgraded it — so the island repairs against its true server bytes
35
+ * instead of a DOM a swapped-in foreign runtime may have already mutated. See region_fragment. */
36
+ const PRISTINE_SSR = Symbol("ogygia.pristine-ssr");
37
+ /** A dynamic-import failure of the island ENTRY (network/stale), not a hydration throw. The browser
38
+ * message is `Failed to fetch dynamically imported module: <url>` across engines. */
39
+ const ENTRY_FETCH_FAILED_RE = /failed to fetch dynamically imported module|error loading dynamically imported module/i;
40
+ const CSS_ASSET_HREF_RE = /\.css(\?|$)/;
41
+ /** The island's server markup to hydrate against later (#ssr_html), or `null` when there is
42
+ * nothing worth keeping: no children, or more than SSR_SNAPSHOT_MAX characters. */
43
+ function snapshot_markup(region) {
44
+ if (!region.firstChild) return null;
45
+ const html = region.innerHTML;
46
+ return html.length > SSR_SNAPSHOT_MAX ? null : html;
47
+ }
48
+ /** The same copy for a hole's answer BEFORE it is put in the document: serialized through a
49
+ * detached box (a fragment has no `innerHTML`; nothing connects, so no element reacts) and the
50
+ * nodes handed back. Taken after the swap it would be the DOM as the custom elements inside the
51
+ * answer left it — their connect reactions run at insertion, before any line after it. */
52
+ function fragment_markup(frag) {
53
+ if (!frag.firstChild) return null;
54
+ const box = document.createElement("div");
55
+ box.appendChild(frag);
56
+ const html = box.innerHTML;
57
+ frag.append(...Array.from(box.childNodes));
58
+ return html.length > SSR_SNAPSHOT_MAX ? null : html;
59
+ }
60
+ const HOLE_WITHOUT_ADDRESS_WARNING = "[ogygia] deferred region %s was rendered in the browser with no server-minted address, and the document records none for it (a client-side navigation mounted it, or its props differ from the server render) — its fallback stands. A hole is server HTML: render it on the server.";
61
+ /** Read the identity fields devtools events correlate on, off a region element. Cheap — attributes
62
+ * already in hand. Only ever called from behind an `if (DEVTOOLS)` guard, so it costs nothing off. */
63
+ function dt_ids(el) {
64
+ return {
65
+ entry: el.getAttribute("entry") || void 0,
66
+ fp: el.getAttribute("data-og-fp") || void 0
67
+ };
68
+ }
69
+ /** High-res clock for devtools timings (guarded — dead when devtools is off). */
70
+ function now_ms() {
71
+ return typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
72
+ }
73
+ let core_promise = null;
74
+ let loaded_core = null;
75
+ function hydrate_core() {
76
+ if (!core_promise) core_promise = yield_task().then(() => import("./hydrate-core.js")).then((m) => loaded_core = m);
77
+ return core_promise;
78
+ }
79
+ /** An answer just went in carrying the page facts it rendered with (server/render-page.ts): once
80
+ * islands are awake (the hydrate core loaded), they join the page store NOW, so a KEPT island reading
81
+ * those keys shows the new values; before any island woke, the first hydrate absorbs them. */
82
+ function absorb_page_facts_now() {
83
+ if (runtime_session.page_facts.length) loaded_core?.seed_page_once();
84
+ }
85
+ /** What counts as intent for an ON-DEMAND hole (`render: 'deferred'` + `fetch: 'interaction'`).
86
+ * `pointerover` (not `pointerenter`) so it fires on hover AND bubbles through the boxless
87
+ * `display: contents` wrapper from a descendant the pointer actually moves over. */
88
+ const ON_DEMAND_EVENTS = [
89
+ "pointerover",
90
+ "focusin",
91
+ "pointerdown",
92
+ "touchstart",
93
+ "keydown"
94
+ ];
95
+ const ON_DEMAND_SELECTOR = "ogygia-region[render=\"defer\"][when=\"interaction\"]";
96
+ /**
97
+ * ON-DEMAND holes, delegated: ONE set of capture listeners on the document for every armed hole
98
+ * (five listeners per hole used to be five hundred on a page of mega-menus). Intent lands anywhere
99
+ * inside a hole; the nearest ARMED hole above the target fires once and is forgotten.
100
+ */
101
+ const on_demand_armed = /* @__PURE__ */ new Map();
102
+ let on_demand_installed = false;
103
+ function on_demand_event(e) {
104
+ if (on_demand_armed.size === 0) return;
105
+ let region = e.target instanceof Element ? e.target.closest(ON_DEMAND_SELECTOR) : null;
106
+ while (region && !on_demand_armed.has(region)) region = region.parentElement?.closest(ON_DEMAND_SELECTOR) ?? null;
107
+ if (!region) return;
108
+ const fire = on_demand_armed.get(region);
109
+ on_demand_armed.delete(region);
110
+ fire();
111
+ }
112
+ function arm_on_demand(region, fire) {
113
+ on_demand_armed.set(region, fire);
114
+ if (on_demand_installed) return;
115
+ on_demand_installed = true;
116
+ for (const type of ON_DEMAND_EVENTS) document.addEventListener(type, on_demand_event, {
117
+ capture: true,
118
+ passive: true
119
+ });
120
+ }
121
+ /** Load a hydrate island module from `<ogygia-region entry>` (dev + prod), its whole chunk graph
122
+ * preloaded in the same task so nothing waits on a discovery waterfall (island-graph-preload.ts), at
123
+ * the priority its load class downloads at (load-scheduler.ts). */
124
+ const load_island = (entry, cls = "visible") => {
125
+ preload_island_graph(entry, void 0, fetch_priority_of(cls));
126
+ return import_entry(entry, island_module_url(entry));
127
+ };
128
+ /**
129
+ * DEV watchdog for a stranded tab (dev only; the branch is dead in a production build). Under
130
+ * `csr = false` Kit ships no client bootstrap, so a Vite dep re-optimization — which rotates the
131
+ * optimizer's browserHash — can leave a tab that was loaded under the old hash importing island dep
132
+ * URLs (`svelte.js?v=<old>`) that now 404, and Vite's own full-reload does not always reach a
133
+ * csr=false page. The island entry then throws `Failed to fetch dynamically imported module` on
134
+ * wake, and nothing recovers it.
135
+ *
136
+ * We CONFIRM it is staleness, not a genuinely-missing module: re-fetch the entry URL, and reload
137
+ * only when the server still serves it (200) — a real 404 is a different bug and must stay visible.
138
+ * A timestamp in `sessionStorage` bounds it to one reload per few seconds, so a genuinely broken
139
+ * entry (200 that keeps failing to import) never loops.
140
+ */
141
+ const STALE_DEP_RELOAD_KEY = "ogygia:dev:dep-reload";
142
+ const STALE_DEP_RELOAD_WINDOW_MS = 6e3;
143
+ async function recover_from_stale_deps(entry) {
144
+ if (!import.meta.env.DEV || !entry || typeof location === "undefined") return;
145
+ try {
146
+ const last = Number(sessionStorage.getItem(STALE_DEP_RELOAD_KEY) || 0);
147
+ if (Date.now() - last < STALE_DEP_RELOAD_WINDOW_MS) return;
148
+ if (!(await fetch(island_module_url(entry), { cache: "no-store" })).ok) return;
149
+ sessionStorage.setItem(STALE_DEP_RELOAD_KEY, String(Date.now()));
150
+ location.reload();
151
+ } catch {}
152
+ }
153
+ function dom_ready() {
154
+ if (typeof document === "undefined" || document.readyState !== "loading") return Promise.resolve();
155
+ return new Promise((r) => document.addEventListener("DOMContentLoaded", r, { once: true }));
156
+ }
157
+ /** Where a live snippet's pending hydrate waits on its host region (region-snippet.ts `hold_host`). */
158
+ const SNIPPET_BOOTS = Symbol.for("ogygia.snippet-boots");
159
+ /** A snippet whose entry never arrives must not hold its host's signal forever. */
160
+ const SNIPPET_BOOT_CAP_MS = 1e4;
161
+ /** Settle the live snippets a just-hydrated region renders — and the snippets those render, which
162
+ * register as they boot — or the cap, whichever is first. A failed boot settles too. */
163
+ async function snippets_settled(region) {
164
+ const host = region;
165
+ let timer;
166
+ const cap = new Promise((r) => timer = setTimeout(r, SNIPPET_BOOT_CAP_MS));
167
+ let capped = false;
168
+ cap.then(() => capped = true);
169
+ try {
170
+ for (let batch = host[SNIPPET_BOOTS]; batch?.length && !capped; batch = host[SNIPPET_BOOTS]) {
171
+ host[SNIPPET_BOOTS] = [];
172
+ await Promise.race([Promise.allSettled(batch), cap]);
173
+ await Promise.resolve();
174
+ }
175
+ } finally {
176
+ clearTimeout(timer);
177
+ delete host[SNIPPET_BOOTS];
178
+ }
179
+ }
180
+ /**
181
+ * Parse a fetched region's HTML into a fragment, HOISTING any `<link data-ogygia-region-css>` (or
182
+ * inlined `<style data-ogygia-region-css="href">`) it carries into `<head>` (deduped by href). A held / server-picked region's component was never
183
+ * imported by the page, so its scoped CSS is in no stylesheet the page loaded; the region response
184
+ * ships the links and the runtime lifts them to the head — where they load once and stick. (A link
185
+ * left in the body would also fail to load inside a `<template>` batch parcel.)
186
+ */
187
+ function region_fragment(html) {
188
+ const frag = parse_region_html(html);
189
+ for (const facts of frag.querySelectorAll(PAGE_FACTS_SELECTOR)) {
190
+ facts.remove();
191
+ runtime_session.page_facts.push(facts.textContent ?? "");
192
+ }
193
+ const links = frag.querySelectorAll("link[data-ogygia-region-css]");
194
+ const pending = [];
195
+ if (links.length && import.meta.env.DEV) {
196
+ const seen = /* @__PURE__ */ new Set();
197
+ for (const link of links) {
198
+ const href = link.getAttribute("href");
199
+ link.remove();
200
+ if (!href) continue;
201
+ const url = island_module_url(href);
202
+ if (seen.has(url)) continue;
203
+ seen.add(url);
204
+ pending.push(import(
205
+ /* @vite-ignore */
206
+ url
207
+ ).then(() => void 0, () => void 0));
208
+ }
209
+ } else if (links.length) {
210
+ const existing = new Map(Array.from(document.querySelectorAll("link[rel=\"stylesheet\"]"), (l) => [l.getAttribute("href"), l]));
211
+ const until_loaded = (l) => new Promise((resolve) => {
212
+ l.addEventListener("load", () => resolve(), { once: true });
213
+ l.addEventListener("error", () => resolve(), { once: true });
214
+ if (l.sheet) resolve();
215
+ });
216
+ for (const link of links) {
217
+ const href = link.getAttribute("href");
218
+ link.remove();
219
+ if (!href) continue;
220
+ const present = existing.get(href);
221
+ if (present) {
222
+ if (!present.sheet) pending.push(until_loaded(present));
223
+ continue;
224
+ }
225
+ const clone = document.createElement("link");
226
+ clone.rel = "stylesheet";
227
+ clone.href = href;
228
+ clone.setAttribute("data-ogygia-region-css", "");
229
+ pending.push(until_loaded(clone));
230
+ existing.set(href, clone);
231
+ runtime_session.claim_page_head(clone);
232
+ document.head.appendChild(clone);
233
+ }
234
+ }
235
+ const styles = frag.querySelectorAll("style[data-ogygia-region-css]");
236
+ if (styles.length) {
237
+ const present = /* @__PURE__ */ new Set();
238
+ for (const n of document.head.querySelectorAll("[data-ogygia-region-css], link[rel=\"stylesheet\"]")) {
239
+ const id = n.tagName === "STYLE" ? n.getAttribute("data-ogygia-region-css") : n.getAttribute("href");
240
+ if (id) present.add(id);
241
+ }
242
+ for (const style of styles) {
243
+ const id = style.getAttribute("data-ogygia-region-css") || "";
244
+ style.remove();
245
+ if (!id || present.has(id)) continue;
246
+ present.add(id);
247
+ const el = document.createElement("style");
248
+ el.setAttribute("data-ogygia-region-css", id);
249
+ el.textContent = style.textContent || "";
250
+ runtime_session.claim_page_head(el);
251
+ document.head.insertBefore(el, document.head.firstChild);
252
+ }
253
+ }
254
+ const ready = pending.length ? Promise.race([Promise.all(pending).then(() => void 0), new Promise((r) => setTimeout(r, 5e3))]) : Promise.resolve();
255
+ restore_markup(frag);
256
+ for (const el of frag.querySelectorAll("ogygia-region")) if (el.getAttribute("entry") && !is_deferred(el) && !is_frozen(el)) el[PRISTINE_SSR] = el.innerHTML;
257
+ return {
258
+ frag,
259
+ ready
260
+ };
261
+ }
262
+ /** TEST: the pristine server markup {@link region_fragment} stashed on a nested island, if any. */
263
+ function pristine_ssr_of(el) {
264
+ return el[PRISTINE_SSR];
265
+ }
266
+ var OgygiaRegion = class OgygiaRegion extends HTMLElement {
267
+ #scheduled = false;
268
+ /** The server-minted `endpoint` of a deferred hole, captured at connect. On a Kit-hydrated
269
+ * (csr=true) document the wrapper's client leg cannot mint (the virtual is stubbed to ''), so
270
+ * Kit's hydration pass reconciles the attribute to '' — after the runtime saw it at parse time.
271
+ * The fetch reads this copy and restores the attribute (lakes, devtools and the router's
272
+ * next-page warm all read the DOM). */
273
+ #minted_endpoint = null;
274
+ /** A fresh capability a renewal answered (#frame_fetcher), adopted once the fetch that got it is
275
+ * applied (#adopt_renewed) — moving addresses mid-fetch would orphan that answer. */
276
+ #renewed_endpoint = null;
277
+ /** THE HYDRATION SOURCE OF TRUTH: this island's server markup as it connected (or, for a
278
+ * hydrating hole, as its answer was swapped in). An island can sleep a long time and other
279
+ * scripts edit the page meanwhile; on wake, hydrate-core hydrates against THIS when the live
280
+ * DOM drifted, instead of letting Svelte re-render the island client-side. Dropped once the
281
+ * island is awake. `null` for a nested region (rides its parent) and above SSR_SNAPSHOT_MAX. */
282
+ #ssr_html = null;
283
+ /** Counted in drift-watch.ts's sleeping islands (paired: one watch, one unwatch). */
284
+ #watching = false;
285
+ #watch() {
286
+ if (this.#watching) return;
287
+ this.#watching = true;
288
+ watch_region();
289
+ }
290
+ #unwatch() {
291
+ if (!this.#watching) return;
292
+ this.#watching = false;
293
+ unwatch_region();
294
+ }
295
+ /** True after a successful HTML swap — failures leave this false so a later schedule can retry. */
296
+ #done = false;
297
+ /** In-flight `#apply` run. `#apply` awaits the region's stylesheet before swapping, so anyone
298
+ * who needs the post-swap state (`#done`, phase-2 hydrate arming) must await this first —
299
+ * sampling `#done` right after the fetch races the CSS wait and reads stale `false`. */
300
+ #applying;
301
+ /** In-flight fetch guard (separate from `#done` so a failed fetch does not one-shot the region). */
302
+ #fetching = false;
303
+ /** Bounded automatic retries after a failed defer/SWR fetch. */
304
+ #fetch_attempts = 0;
305
+ /** when this hole's first fetch started (devtools + profiler: how long its fallback showed) */
306
+ #fetch_started = 0;
307
+ /** Frame-store address (endpoint call) this region is fetching, so disconnect can release it. */
308
+ #frame_address = null;
309
+ /** Unsubscribe from the frame store (a defer region binds to its address). */
310
+ #frame_unsub = null;
311
+ /** Set while an SWR revalidate is in flight, so the next apply marks `data-revalidated`. */
312
+ #revalidating = false;
313
+ #hydrating = false;
314
+ /** A visitor's gesture woke this region (`interaction`): its downloads are the `user` class. */
315
+ #user_woken = false;
316
+ /** The hydrated island (hydrate core handle): dispose, and for a kept island, props push. */
317
+ #app = null;
318
+ /** Stops the shared `visible` observation (set while armed, cold). */
319
+ #stop_visible = null;
320
+ /** Removes the `wake="interaction"` wake listeners (set while armed, cold). */
321
+ #disarm_interaction = null;
322
+ #mql = null;
323
+ /** The hole answered `keepFallback()`: the page's fallback stands, no phase-2 wake. */
324
+ #kept = false;
325
+ /** Abort in-flight region HTML fetch on disconnect (P-ABORT). */
326
+ #fetch_abort = null;
327
+ /** Cancel idle schedule when disconnected. */
328
+ #idle_handle = null;
329
+ /** Disconnected, teardown waiting a microtask: a reconnect before it is a move. */
330
+ #leaving = false;
331
+ /** Live region (`<ogygia-region live>`): driven imperatively by Region.svelte's applyLive. */
332
+ #live_ready = false;
333
+ #live_app = null;
334
+ #live_module = "";
335
+ #hydrate_run = null;
336
+ #fire_hydrate = () => this.#hydrate_run ??= this.#hydrate().finally(() => this.#hydrate_run = null);
337
+ #fire_server = () => this.#server();
338
+ #fire_prefetch = () => this.#prefetch_html();
339
+ /**
340
+ * CONTINUITY: this persisted island is relocating onto `next` (the incoming page's SSR region).
341
+ * Push the new page's props into the live app so a `persist`ed component reflects the new route
342
+ * (e.g. a player's `track` changes) instead of freezing at first-mount props. Called by the
343
+ * router just before `next` is discarded. Synchronous by contract — a kept island has hydrated,
344
+ * so the hydrate core is loaded.
345
+ */
346
+ absorbKeptProps(next) {
347
+ if (!this.#app?.set_props || !loaded_core) return;
348
+ try {
349
+ this.#app.set_props(loaded_core.read_region_props(next));
350
+ } catch {}
351
+ }
352
+ connectedCallback() {
353
+ connected_regions.add(this);
354
+ pin_region_urls(this);
355
+ if (this.hasAttribute("live")) return;
356
+ if (this.#minted_endpoint === null && is_deferred(this)) {
357
+ const minted = this.getAttribute("endpoint");
358
+ if (minted) this.#minted_endpoint = minted;
359
+ else {
360
+ const identity = this.getAttribute("data-og-hole");
361
+ const facts = identity ? hole_facts_of(this.ownerDocument, identity) : null;
362
+ if (facts) {
363
+ this.setAttribute("endpoint", facts.endpoint);
364
+ pin_region_urls(this);
365
+ this.#minted_endpoint = this.getAttribute("endpoint");
366
+ if (facts.sidecar) restore_props_sidecar(this, facts.sidecar.cloneNode(true));
367
+ } else if (import.meta.env.DEV && identity) console.warn(HOLE_WITHOUT_ADDRESS_WARNING, this.getAttribute("entry") || identity);
368
+ }
369
+ }
370
+ if (is_frozen(this) && slots.lakes.on_frozen_connect(this, this.#lake_arm())) return;
371
+ if (this.#scheduled) return;
372
+ const boundary = this.parentElement && this.parentElement.closest("ogygia-region");
373
+ const slot = this.parentElement && this.parentElement.closest("ogygia-slot,ogygia-snippet[data-og-static]");
374
+ const in_adopted_slot = !!(boundary && slot && boundary.contains(slot));
375
+ const entry_attr = this.getAttribute("entry") || "";
376
+ const foreign_entry = entry_attr.indexOf(":") > 0 && /^[a-z][a-z0-9+.-]*:/i.test(entry_attr) && new URL(entry_attr).origin !== location.origin;
377
+ if (boundary && is_awake(boundary) && !is_deferred(this) && !in_adopted_slot && !foreign_entry) {
378
+ this.setAttribute("data-nested", "");
379
+ if (DEVTOOLS) emit({
380
+ domain: "runtime",
381
+ name: "region.connected",
382
+ ...dt_ids(this),
383
+ wake: this.getAttribute("wake") || void 0,
384
+ deferred: false,
385
+ nested: true
386
+ });
387
+ if (import.meta.env.DEV) console.warn(`[ogygia] nested region "${this.getAttribute("entry")}" skipped self-run; the nearest region above it is awake, so it rides that hydration (inner hydrate "${this.getAttribute("wake") || "load"}" ignored).`);
388
+ return;
389
+ }
390
+ const deferred = is_deferred(this);
391
+ if (!deferred && this.#ssr_html === null) {
392
+ const pristine = this[PRISTINE_SSR];
393
+ this.#ssr_html = pristine ?? snapshot_markup(this);
394
+ if (pristine != null) mark_region_changed(this);
395
+ }
396
+ if (this.#ssr_html !== null) this.#watch();
397
+ if (slots.lakes.wait_for_boundary(this, boundary)) return;
398
+ this.#scheduled = true;
399
+ const when = region_schedule(this);
400
+ if (DEVTOOLS) {
401
+ emit({
402
+ domain: "runtime",
403
+ name: "region.connected",
404
+ ...dt_ids(this),
405
+ wake: this.getAttribute("wake") || void 0,
406
+ deferred,
407
+ nested: false
408
+ });
409
+ emit({
410
+ domain: "runtime",
411
+ name: "wake.scheduled",
412
+ ...dt_ids(this),
413
+ when
414
+ });
415
+ }
416
+ if (!deferred) register_region(this);
417
+ if (deferred) this.#arm(when, this.#fire_server);
418
+ else this.#arm(when, this.#fire_hydrate);
419
+ const prefetch = deferred ? this.getAttribute("prefetch") : null;
420
+ if (prefetch && prefetch !== when && prefetch !== "interaction") this.#arm(prefetch, this.#fire_prefetch, this.getAttribute("margin") || void 0);
421
+ }
422
+ /**
423
+ * Warm this hole's HTML into the frame store ahead of its `when` — the `prefetch` schedule. No
424
+ * subscription is taken, so nothing is applied now; the later wake (`#server`) subscribes, the
425
+ * store replays the warm frame at once, and its `ensure` joins instead of fetching. A failed
426
+ * warm is harmless: the wake falls back to its own fetch. A hole already done or fetching has
427
+ * nothing left to warm.
428
+ */
429
+ #prefetch_html() {
430
+ if (this.#done || this.#fetching || !this.isConnected) return;
431
+ const endpoint = this.#endpoint();
432
+ if (!endpoint || !is_allowed_region_endpoint(endpoint)) return;
433
+ const address = frameAddress(endpoint);
434
+ if (DEVTOOLS) emit({
435
+ domain: "runtime",
436
+ name: "region.prefetch",
437
+ ...dt_ids(this)
438
+ });
439
+ slots.frames?.ensure(address, this.#frame_fetcher(endpoint, false, "ahead"))?.catch(() => {});
440
+ }
441
+ /**
442
+ * The one network fetch for this hole's HTML — its own wake and a `prefetch` warm share it, so
443
+ * the frame store sees one fetcher shape per address. The endpoint's text, or the keep-fallback
444
+ * marker on a 204 (`keepFallback()` on the server). A revalidate bypasses the browser cache
445
+ * (the endpoint may answer `private, max-age`, and stale is the whole point of revalidating).
446
+ */
447
+ #frame_fetcher(endpoint, revalidate, cls) {
448
+ const class_now = typeof cls === "function" ? cls : () => cls;
449
+ return async (signal) => {
450
+ const release = await load_slot({
451
+ kind: "content",
452
+ cls,
453
+ label: endpoint
454
+ }).ready;
455
+ try {
456
+ return await this.#fetch_region(endpoint, revalidate, fetch_priority_of(class_now()), signal);
457
+ } finally {
458
+ release();
459
+ }
460
+ };
461
+ }
462
+ #fetch_region(endpoint, revalidate, priority, signal) {
463
+ return runtime_session.server_gate.run(async () => {
464
+ if (BEACON) beacon_hole_fetched(endpoint);
465
+ let res = await fetch(endpoint, {
466
+ credentials: "same-origin",
467
+ cache: revalidate ? "no-store" : "default",
468
+ priority,
469
+ signal
470
+ });
471
+ if (res.status === 403 && capability_expired(endpoint)) {
472
+ res = await fetch(renewal_url(endpoint), {
473
+ credentials: "same-origin",
474
+ cache: "no-store",
475
+ signal
476
+ });
477
+ const fresh = res.ok ? res.headers.get("x-ogygia-capability") : null;
478
+ if (fresh && is_allowed_region_endpoint(fresh)) this.#renewed_endpoint = fresh;
479
+ }
480
+ if (!is_same_origin_response(res)) throw new Error("cross-origin redirect");
481
+ if (is_redirected_answer(res)) throw new RegionAnswerRefused("redirected", res.url);
482
+ if (res.status === 403) throw new RegionAnswerRefused("forbidden", res.url || endpoint, deny_of(res, endpoint));
483
+ if (!res.ok) throw new Error("status " + res.status);
484
+ if (res.status === 204) return KEEP_FALLBACK_HTML;
485
+ const text = await res.text();
486
+ if (is_document_answer(text)) throw new RegionAnswerRefused("document", res.url);
487
+ return text;
488
+ });
489
+ }
490
+ /** The schedule hooks a frozen region (lake) drives its revalidation through. */
491
+ #lake_arm() {
492
+ return {
493
+ idle: (fire) => this.#on_idle(fire),
494
+ visible: (fire, margin) => this.#on_visible(fire, margin),
495
+ media: (when, fire) => this.#on_media(when, fire),
496
+ fetch_revalidate: () => void this.#fetch_html({ revalidate: true }),
497
+ wake_children: () => this.#wake_waiting_regions()
498
+ };
499
+ }
500
+ /** Arm idle / visible / load / interaction / media for a schedule callback. */
501
+ #arm(when, fire, visible_margin) {
502
+ if (fire === this.#fire_hydrate && when !== "interaction") this.#catch_early_input(fire);
503
+ if (DEVTOOLS) {
504
+ const raw = fire;
505
+ fire = () => {
506
+ emit({
507
+ domain: "runtime",
508
+ name: "wake.fired",
509
+ ...dt_ids(this),
510
+ when
511
+ });
512
+ return raw();
513
+ };
514
+ }
515
+ const start = () => background_start(fire);
516
+ if (when === "idle") this.#on_idle(fire);
517
+ else if (when === "visible") this.#on_visible(start, visible_margin);
518
+ else if (when === "load") start();
519
+ else if (when === "interaction") {
520
+ const by_user = () => {
521
+ this.#user_woken = true;
522
+ return fire();
523
+ };
524
+ if (is_deferred(this)) arm_on_demand(this, by_user);
525
+ else this.#on_interaction(by_user);
526
+ } else this.#on_media(when, start);
527
+ }
528
+ /**
529
+ * `wake="interaction"`: sleep until a pointer/key/focus/click lands inside the region, then
530
+ * hydrate and replay what arrived meanwhile (see runtime/interaction.ts). `pointerenter` warms
531
+ * the module so the wake is usually served from cache. On a csr=true page Kit already hydrated
532
+ * this island — do not arm (our click-cancel would eat live clicks); #hydrate's own guard
533
+ * handles the marking if it ever fires. Unless the island is ours even there: inside a lake
534
+ * (Kit adopts it as opaque DOM) or inside a hole's fetched answer (Kit never sees it).
535
+ */
536
+ #on_interaction(fire) {
537
+ if (kit_hydrates_page() && !ours_on_kit_document(this)) {
538
+ this.setAttribute("data-kit-hydrated", "");
539
+ return;
540
+ }
541
+ const arm = slots.interaction;
542
+ if (!arm) {
543
+ fire();
544
+ return;
545
+ }
546
+ const disarm = arm(this, fire);
547
+ this.#disarm_interaction = typeof disarm === "function" ? disarm : null;
548
+ }
549
+ /**
550
+ * A scheduled island (`load` / `idle` / `visible` / media) also catches input until it is live — the
551
+ * interaction capture, armed beside its schedule: the first press, key or focus on it wakes it now,
552
+ * as a gesture, and a click is replayed once it is live. Not on a Kit-hydrated page (Kit owns the
553
+ * island there, as for `interaction`), not without the interaction feature, never once awake.
554
+ */
555
+ #catch_early_input(fire) {
556
+ const arm = slots.interaction;
557
+ if (!arm || this.#app || kit_hydrates_page() && !ours_on_kit_document(this)) return;
558
+ const disarm = arm(this, () => {
559
+ this.#user_woken = true;
560
+ return fire();
561
+ });
562
+ this.#disarm_interaction = typeof disarm === "function" ? disarm : null;
563
+ }
564
+ /**
565
+ * Move this hole onto the fresh capability a renewal answered: the attribute (every DOM reader —
566
+ * lakes, devtools, the router's warm — agrees), the minted copy, and the frame-store address its
567
+ * later wakes and revalidates fetch and apply at. Called after the answer that carried it landed.
568
+ */
569
+ #adopt_renewed() {
570
+ const fresh = this.#renewed_endpoint;
571
+ if (!fresh) return;
572
+ this.#renewed_endpoint = null;
573
+ this.#minted_endpoint = fresh;
574
+ this.setAttribute("endpoint", fresh);
575
+ if (this.#frame_unsub) {
576
+ this.#frame_unsub();
577
+ const address = this.#frame_address = frameAddress(fresh);
578
+ this.#frame_unsub = slots.frames?.subscribe(address, (f) => void (this.#applying = this.#apply(f.html))) ?? null;
579
+ }
580
+ }
581
+ /** The hole's endpoint: the attribute, or the server-minted copy when Kit's hydration wiped it
582
+ * (restored on the element so every other DOM reader agrees). */
583
+ #endpoint() {
584
+ const attr = this.getAttribute("endpoint");
585
+ if (attr) return attr;
586
+ if (!this.#minted_endpoint) return null;
587
+ this.setAttribute("endpoint", this.#minted_endpoint);
588
+ return this.#minted_endpoint;
589
+ }
590
+ /**
591
+ * Deferred hole: get its HTML and swap it in. When `hydrate` is also set (deferred client
592
+ * island), schedule phase-2 hydrate — coalescing matching schedules to immediate load.
593
+ */
594
+ async #server() {
595
+ const endpoint = this.#endpoint();
596
+ if (endpoint && !this.#frame_unsub) {
597
+ const address = this.#frame_address = frameAddress(endpoint);
598
+ this.#frame_unsub = slots.frames?.subscribe(address, (f) => void (this.#applying = this.#apply(f.html))) ?? null;
599
+ }
600
+ await this.#fetch_html();
601
+ await this.#applying;
602
+ if (!this.#done || !this.isConnected) return;
603
+ if (this.#kept) return;
604
+ const hydrate = region_hydrate_schedule(this);
605
+ if (!hydrate) return;
606
+ const defer_when = this.getAttribute("when") || "load";
607
+ const phase2 = phase2_hydrate_schedule(defer_when, hydrate);
608
+ const margin = phase2 === "visible" ? this.getAttribute("hydrate-margin") || this.getAttribute("margin") || void 0 : void 0;
609
+ register_region(this);
610
+ this.#arm(phase2, this.#fire_hydrate, margin);
611
+ }
612
+ /**
613
+ * THE single apply path. A frame's HTML lands here from any source (own fetch, stream parcel,
614
+ * navigation batch, mutation). First arrival hydrates the hole; a later arrival at a newer
615
+ * version (SWR revalidate, live refresh) re-applies. Keeps all the DOM-side work — lakes settle
616
+ * offline before custom elements connect, then swap, mark, event. HOLE-TRUST: the HTML is our own
617
+ * signed same-origin SSR.
618
+ */
619
+ async #apply(html) {
620
+ if (!this.isConnected) return;
621
+ if (html === "<!--ogygia:keep-fallback-->") {
622
+ this.#revalidating = false;
623
+ this.#done = true;
624
+ this.#kept = true;
625
+ if (!is_awake(this)) this.setAttribute("data-hydrated", "");
626
+ this.setAttribute("data-og-kept", "");
627
+ this.dispatchEvent(new CustomEvent("ogygia:server", { bubbles: true }));
628
+ return;
629
+ }
630
+ const revalidate = this.#revalidating || this.#done;
631
+ this.#revalidating = false;
632
+ const { frag, ready } = region_fragment(html);
633
+ await ready;
634
+ if (!this.isConnected) return;
635
+ slots.lakes.settle_in(frag);
636
+ slots.lakes.mark_frozen_settled(this);
637
+ const morph = slots.morph;
638
+ if (!this.#app && region_hydrate_schedule(this)) {
639
+ this.#ssr_html = fragment_markup(frag);
640
+ this.#watch();
641
+ }
642
+ if (morph) morph(this, Array.from(frag.childNodes));
643
+ else this.replaceChildren(frag);
644
+ restore_adopt_sheets();
645
+ init_shadow_registries(this);
646
+ absorb_page_facts_now();
647
+ this.#done = true;
648
+ if (revalidate) this.setAttribute("data-revalidated", "");
649
+ else if (!is_awake(this)) this.setAttribute("data-hydrated", "");
650
+ slots.lakes.after_html_swap(this, { revalidate });
651
+ if (BEACON && !revalidate && this.#fetch_started) {
652
+ const ep = this.getAttribute("endpoint");
653
+ beacon_hole_answered(this, this.#fetch_started, ep ? slots.frames?.batch_times?.(ep) : void 0);
654
+ }
655
+ if (DEVTOOLS) emit({
656
+ domain: "runtime",
657
+ name: "region.server.applied",
658
+ entry: this.getAttribute("entry") || void 0,
659
+ endpoint: this.getAttribute("endpoint") || void 0,
660
+ bytes: html.length,
661
+ revalidate,
662
+ ...!revalidate && this.#fetch_started ? { wait_ms: Math.round(performance.now() - this.#fetch_started) } : {}
663
+ });
664
+ this.dispatchEvent(new CustomEvent("ogygia:server", { bubbles: true }));
665
+ }
666
+ /**
667
+ * Store applicator for a STATIC live/held region (`<ogygia-region live>` with no interactive
668
+ * module). Every frame at its address lands here — first paint (store replay), a live-query tick,
669
+ * or a single-flight mutation. First paint swaps in; a later frame morphs in place (same node
670
+ * survives — the breathing update live partials rely on). Interactive live regions never reach
671
+ * here: they keep the imperative keep-alive path in {@link applyLive}.
672
+ */
673
+ async #morph_live(html) {
674
+ if (!this.isConnected) return;
675
+ if (!this.#live_ready && this.hasAttribute("data-og-baked")) {
676
+ this.#live_ready = true;
677
+ this.setAttribute("data-hydrated", "");
678
+ this.dispatchEvent(new CustomEvent("ogygia:live", { bubbles: true }));
679
+ return;
680
+ }
681
+ const { frag, ready } = region_fragment(html);
682
+ await ready;
683
+ if (!this.isConnected) return;
684
+ slots.lakes.settle_in(frag);
685
+ if (!this.#live_ready) {
686
+ this.replaceChildren(frag);
687
+ this.#live_ready = true;
688
+ this.setAttribute("data-hydrated", "");
689
+ } else {
690
+ const nodes = Array.from(frag.childNodes);
691
+ const morph = slots.morph;
692
+ if (morph) morph(this, nodes);
693
+ else this.replaceChildren(...nodes);
694
+ for (const el of this.querySelectorAll("ogygia-region")) if (el instanceof OgygiaRegion) el.#renew();
695
+ }
696
+ restore_adopt_sheets();
697
+ init_shadow_registries(this);
698
+ absorb_page_facts_now();
699
+ this.dispatchEvent(new CustomEvent("ogygia:live", { bubbles: true }));
700
+ }
701
+ /**
702
+ * A refreshed region re-minted this hole (server/render-page.ts): at a new address — new props, or
703
+ * new page facts (`pv`) — it fetches its new answer, the current one on screen until that lands.
704
+ * A hole that never fetched yet fetches the new address on its own schedule.
705
+ */
706
+ #renew() {
707
+ if (!this.#frame_address || !is_deferred(this)) return;
708
+ const endpoint = this.getAttribute("endpoint");
709
+ if (!endpoint || frameAddress(endpoint) === this.#frame_address) return;
710
+ this.#fetch_html({ revalidate: true });
711
+ }
712
+ /**
713
+ * Fetch `endpoint` HTML and swap it in.
714
+ * Success sets `#done` (at most one successful swap per element). Failure leaves `#done` false
715
+ * so a reconnect, remount, or deferred retry can try again — previously `#done` was set up front
716
+ * and a transient network error permanently killed the hole.
717
+ * A deferred hole reuses the browser's `<link rel="preload">` response; an swr REVALIDATE must
718
+ * not (the endpoint answers `cache-control: private, max-age=30`, and stale is the whole point).
719
+ */
720
+ async #fetch_html(opts = {}) {
721
+ if (this.#fetching || this.#done && !opts.revalidate) return;
722
+ const endpoint = this.#endpoint();
723
+ if (!endpoint) return;
724
+ if (!is_allowed_region_endpoint(endpoint)) {
725
+ if (import.meta.env.DEV) console.warn("[ogygia] refused non-same-origin region endpoint", endpoint);
726
+ return;
727
+ }
728
+ this.#fetching = true;
729
+ if (!this.#fetch_started) this.#fetch_started = performance.now();
730
+ this.#fetch_abort?.abort();
731
+ this.#fetch_abort = new AbortController();
732
+ const outer = this.#fetch_abort.signal;
733
+ const previous = this.#frame_address;
734
+ const address = this.#frame_address = frameAddress(endpoint);
735
+ if (this.#frame_unsub && previous !== address) {
736
+ this.#frame_unsub();
737
+ this.#frame_unsub = null;
738
+ }
739
+ if (!this.#frame_unsub) this.#frame_unsub = slots.frames?.subscribe(address, (f) => void (this.#applying = this.#apply(f.html))) ?? null;
740
+ if (opts.revalidate) this.#revalidating = true;
741
+ try {
742
+ const frames = slots.frames;
743
+ if (!opts.revalidate && frames?.join && !endpoint.includes("&ttl=") && !capability_expired(endpoint)) await frames.join(endpoint);
744
+ const run = () => frames?.ensure(address, this.#frame_fetcher(endpoint, !!opts.revalidate, () => this.#user_woken ? "user" : viewport_class(this)), { force: opts.revalidate });
745
+ try {
746
+ await run();
747
+ } catch (err) {
748
+ if (err?.name !== "OgygiaBatchMiss" || outer.aborted) throw err;
749
+ await run();
750
+ }
751
+ this.#adopt_renewed();
752
+ } catch (err) {
753
+ if (err?.name === "AbortError" || outer.aborted) return;
754
+ const refused = err instanceof RegionAnswerRefused;
755
+ const deny = refused && err.reason === "forbidden" ? err.deny || "no reason given" : void 0;
756
+ if (import.meta.env.DEV) {
757
+ if (deny !== void 0) console.warn(`[ogygia] region answer refused for ${endpoint}: ${deny.startsWith("not ogygia") ? deny : `the islands endpoint refused its capability (403: ${deny})`}. ` + (deny.startsWith("foreign-key") ? "The page and its islands endpoint came from different deployments (two keys): route the endpoint to the deployment that served the page, or give every deployment one OGYGIA_SECRET. " : "") + "The fallback stands.");
758
+ else if (refused) console.warn(`[ogygia] region answer refused for ${endpoint}: the request was ${err.reason === "redirected" ? "redirected to" : "answered with a whole document at"} ${err.final_url}. A handle in front of ogygia.handle() (an auth redirect, a locale bounce, a 404 handler) took the region request — exempt the islands endpoint there. The fallback stands.`);
759
+ else console.warn("[ogygia] region fetch failed for", endpoint, err);
760
+ }
761
+ this.#fetch_attempts++;
762
+ const final = refused || !this.isConnected || this.#fetch_attempts >= 3;
763
+ if (final) {
764
+ let id = "";
765
+ let final_path;
766
+ try {
767
+ id = new URL(endpoint, location.href).searchParams.get("id") ?? "";
768
+ if (refused) final_path = new URL(err.final_url, location.href).pathname;
769
+ } catch {}
770
+ if (BEACON && id) beacon_hole_failed({
771
+ id,
772
+ reason: refused ? err.reason : "error",
773
+ ...final_path ? { final_path } : {},
774
+ ...refused ? {} : { message: String(err?.message ?? err).split("\n")[0].slice(0, 200) },
775
+ ...deny !== void 0 ? { message: deny.slice(0, 200) } : {},
776
+ attempts: this.#fetch_attempts,
777
+ t: Math.round(performance.now())
778
+ });
779
+ }
780
+ if (DEVTOOLS) emit({
781
+ domain: "runtime",
782
+ name: "region.server.failed",
783
+ entry: this.getAttribute("entry") || void 0,
784
+ endpoint,
785
+ reason: refused ? err.reason : "error",
786
+ ...refused ? { final_url: err.final_url } : { message: String(err?.message ?? err).split("\n")[0].slice(0, 200) },
787
+ ...deny !== void 0 ? { message: deny.slice(0, 200) } : {},
788
+ attempt: this.#fetch_attempts,
789
+ final
790
+ });
791
+ this.#scheduled = false;
792
+ if (!refused && this.isConnected && this.#fetch_attempts < 3) {
793
+ const delay = 500 * this.#fetch_attempts;
794
+ setTimeout(() => {
795
+ if (!this.isConnected || this.#done || this.#fetching) return;
796
+ if (opts.revalidate) this.#fetch_html({ revalidate: true });
797
+ else this.connectedCallback();
798
+ }, delay);
799
+ return;
800
+ }
801
+ slots.lakes.after_fetch_exhausted(this, opts, () => this.#wake_waiting_regions());
802
+ } finally {
803
+ this.#fetching = false;
804
+ }
805
+ }
806
+ /** Re-enter connectedCallback for descendants that early-returned on an unsettled lake. */
807
+ #wake_waiting_regions() {
808
+ for (const el of this.querySelectorAll("ogygia-region")) if (el instanceof OgygiaRegion) el.connectedCallback();
809
+ }
810
+ #on_idle(fire) {
811
+ if ("requestIdleCallback" in window) this.#idle_handle = requestIdleCallback(() => {
812
+ this.#idle_handle = null;
813
+ fire();
814
+ }, { timeout: 2e3 });
815
+ else this.#idle_handle = setTimeout(() => {
816
+ this.#idle_handle = null;
817
+ fire();
818
+ }, 200);
819
+ }
820
+ /** `visible`: the shared observer for this margin (observe.ts) — fires once, on first entry. */
821
+ #on_visible(fire, root_margin) {
822
+ const rootMargin = root_margin || this.getAttribute("margin") || "0px";
823
+ this.#stop_visible = once_visible(this, rootMargin, () => {
824
+ this.#stop_visible = null;
825
+ fire();
826
+ });
827
+ }
828
+ #on_media(q, fire) {
829
+ if (!q) return fire();
830
+ const mql = matchMedia(q);
831
+ if (mql.matches) return fire();
832
+ const on = (e) => {
833
+ if (e.matches) {
834
+ mql.removeEventListener("change", on);
835
+ this.#mql = null;
836
+ fire();
837
+ }
838
+ };
839
+ mql.addEventListener("change", on);
840
+ this.#mql = {
841
+ mql,
842
+ on
843
+ };
844
+ }
845
+ /**
846
+ * Wake this island: load its module and the hydrate core in parallel, then take a SCHEDULER
847
+ * TURN (one island per task, viewport first — schedule.ts) and run the synchronous hydrate step
848
+ * (hydrate-core.ts) inside it.
849
+ */
850
+ async #hydrate() {
851
+ if (this.#app || this.#hydrating) return;
852
+ this.#hydrating = true;
853
+ const t0 = now_ms();
854
+ const dt_t0 = DEVTOOLS ? t0 : 0;
855
+ let t_loaded = t0;
856
+ /** when its hydrate step began: a failed step held the thread from here (the reports count it busy) */
857
+ let t_turn;
858
+ if (DEVTOOLS) emit({
859
+ domain: "runtime",
860
+ name: "region.hydrate.start",
861
+ ...dt_ids(this)
862
+ });
863
+ if (CLIENT_PLUGINS) client_region_mount(this);
864
+ try {
865
+ if (typeof document !== "undefined" && document.readyState === "loading") await dom_ready();
866
+ if (!this.isConnected) return;
867
+ const entry = island_entry_of(this);
868
+ if (!entry) return;
869
+ const cls = () => this.#user_woken ? "user" : viewport_class(this);
870
+ const release = await load_slot({
871
+ kind: "code",
872
+ cls,
873
+ label: entry
874
+ }).ready;
875
+ let mod, core;
876
+ try {
877
+ if (!this.isConnected) return;
878
+ hydrate_started(this);
879
+ [mod, core] = await Promise.all([
880
+ load_island(entry, cls()),
881
+ hydrate_core(),
882
+ wire_classes_for(this)
883
+ ]);
884
+ } finally {
885
+ release();
886
+ }
887
+ t_loaded = now_ms();
888
+ if (!this.isConnected) return;
889
+ await this.#kit_page_ready(core);
890
+ if (!this.isConnected) return;
891
+ core.seed_remote_once();
892
+ core.seed_page_once();
893
+ await hydrate_turn(this);
894
+ if (!this.isConnected || this.#app) return;
895
+ t_turn = now_ms();
896
+ const ssr_html = this.#ssr_html;
897
+ const touched = ssr_html === null || region_changed(this);
898
+ if (import.meta.env.DEV) set_hydrating(this);
899
+ this.#app = core.hydrate_island(this, entry, mod, ssr_html, touched);
900
+ this.#ssr_html = null;
901
+ this.#unwatch();
902
+ if (!this.#app) return;
903
+ const t_done = now_ms();
904
+ await Promise.resolve();
905
+ const t_mounted = now_ms();
906
+ await snippets_settled(this);
907
+ if (!this.isConnected || !this.#app) return;
908
+ this.setAttribute("data-hydrated", "");
909
+ if (BEACON) beacon_hydrated(this, t0, t_loaded, t_done, ssr_html, t_turn);
910
+ if (DEVTOOLS) emit({
911
+ domain: "runtime",
912
+ name: "region.hydrate.done",
913
+ ...dt_ids(this),
914
+ ms: t_mounted - dt_t0
915
+ });
916
+ this.dispatchEvent(new CustomEvent("ogygia:hydrated", { bubbles: true }));
917
+ } catch (err) {
918
+ if (this.#watching) mark_region_changed(this);
919
+ this.#unwatch();
920
+ if (BEACON) beacon_failed(this, err?.message ?? String(err), t0, t_turn);
921
+ if (DEVTOOLS) emit({
922
+ domain: "runtime",
923
+ name: "region.hydrate.failed",
924
+ ...dt_ids(this),
925
+ message: err?.message ?? String(err),
926
+ ...t_turn !== void 0 ? { turn: t_turn } : {}
927
+ });
928
+ const msg = err?.message ?? "";
929
+ const entry = this.getAttribute("entry");
930
+ if (ENTRY_FETCH_FAILED_RE.test(msg)) {
931
+ if (import.meta.env.DEV) {
932
+ console.error(`[ogygia] island entry failed to load: ${entry}\nThe module could not be FETCHED (not a hydration error). In dev this almost always means Vite re-optimized dependencies and rotated its optimizer hash while this tab was open, so its dep imports 404. Recovering… Original error:`, err);
933
+ recover_from_stale_deps(entry);
934
+ } else console.error("[ogygia] island entry failed to load:", entry, err);
935
+ } else console.error("[ogygia] hydration failed for", entry, err);
936
+ } finally {
937
+ this.#hydrating = false;
938
+ hydrate_settled(this);
939
+ this.#disarm_interaction?.();
940
+ this.#disarm_interaction = null;
941
+ }
942
+ }
943
+ /**
944
+ * Apply a live region tick (called by Region.svelte for a deferred region whose ticket
945
+ * carries server-rendered HTML). No fetch — the HTML is already here.
946
+ *
947
+ * - **First tick:** parse + swap the HTML in. Interactive (`hydrate` + `module`) → hydrate a
948
+ * {@link LiveHost} so later ticks can push props. Static → done (no JS ever ships).
949
+ * - **Later tick, same interactive module:** keep-alive — push the new props to the mounted
950
+ * component (focus + local state survive; Svelte reconciles). No swap, no re-hydrate.
951
+ * - **Later tick, static:** morph the new HTML in place (see {@link morph_children}).
952
+ * - **Later tick, module changed:** unmount, swap, re-hydrate.
953
+ */
954
+ async applyLive(desc) {
955
+ this.setAttribute("render", "defer");
956
+ this.setAttribute("entry", desc.module || desc.id);
957
+ if (desc.url) this.setAttribute("endpoint", desc.url);
958
+ if (desc.hydrate) this.setAttribute("wake", desc.hydrate);
959
+ else this.removeAttribute("wake");
960
+ if (desc.hydrateMargin) this.setAttribute("hydrate-margin", desc.hydrateMargin);
961
+ const interactive = !!desc.hydrate && !!desc.module;
962
+ if (!interactive) {
963
+ if (desc.url && !this.#frame_unsub) {
964
+ this.#frame_address = frameAddress(desc.url);
965
+ this.#frame_unsub = slots.frames?.subscribe(this.#frame_address, (f) => this.#morph_live(f.html)) ?? null;
966
+ }
967
+ this.#morph_live(desc.html);
968
+ return;
969
+ }
970
+ if (this.#live_ready && interactive && this.#live_app && desc.module === this.#live_module) {
971
+ this.#live_app.set_props?.(desc.props);
972
+ this.dispatchEvent(new CustomEvent("ogygia:live", { bubbles: true }));
973
+ return;
974
+ }
975
+ if (this.#live_app) {
976
+ this.#live_app.dispose();
977
+ this.#live_app = null;
978
+ }
979
+ this.#live_ready = true;
980
+ this.#live_module = desc.module;
981
+ const { frag, ready } = region_fragment(desc.html);
982
+ await ready;
983
+ if (!this.isConnected) return;
984
+ slots.lakes.settle_in(frag);
985
+ this.replaceChildren(frag);
986
+ restore_adopt_sheets();
987
+ init_shadow_registries(this);
988
+ if (interactive) await this.#live_hydrate(desc.props);
989
+ else {
990
+ this.setAttribute("data-hydrated", "");
991
+ this.dispatchEvent(new CustomEvent("ogygia:live", { bubbles: true }));
992
+ }
993
+ }
994
+ /**
995
+ * On a Kit-hydrated document, a region of ours (a lake's inside, a hole's answer) waits for Kit to
996
+ * apply its page before it hydrates — `null` (no await) once applied. The wait lives in the lazy
997
+ * hydrate core (it observes Kit's reactive page, i.e. it needs Svelte), so it never reaches the boot.
998
+ */
999
+ #kit_page_ready(core) {
1000
+ if (!kit_hydrates_page() || !ours_on_kit_document(this)) return null;
1001
+ return core.kit_page_thread();
1002
+ }
1003
+ /** Hydrate a live region's swapped-in HTML through the hydrate core's LiveHost path. */
1004
+ async #live_hydrate(props) {
1005
+ await dom_ready();
1006
+ if (!this.isConnected) return;
1007
+ const entry = island_entry_of(this);
1008
+ if (!entry) return;
1009
+ const cls = () => viewport_class(this);
1010
+ const release = await load_slot({
1011
+ kind: "code",
1012
+ cls,
1013
+ label: entry
1014
+ }).ready;
1015
+ let mod, core;
1016
+ try {
1017
+ if (!this.isConnected) return;
1018
+ [mod, core] = await Promise.all([load_island(entry, cls()), hydrate_core()]);
1019
+ } finally {
1020
+ release();
1021
+ }
1022
+ if (!this.isConnected) return;
1023
+ await this.#kit_page_ready(core);
1024
+ if (!this.isConnected) return;
1025
+ if (CLIENT_PLUGINS) client_region_mount(this);
1026
+ this.#live_app = core.hydrate_live(this, entry, mod, props);
1027
+ if (!this.#live_app) return;
1028
+ this.setAttribute("data-hydrated", "");
1029
+ this.dispatchEvent(new CustomEvent("ogygia:hydrated", { bubbles: true }));
1030
+ this.dispatchEvent(new CustomEvent("ogygia:live", { bubbles: true }));
1031
+ }
1032
+ /**
1033
+ * A MOVE IS NOT A REMOVAL. Another script relocating the element (a custom element that, at its
1034
+ * upgrade, moves its server-placed children out of its markup and back into its own light DOM)
1035
+ * disconnects and reconnects it in one task. Tearing down there aborted a hole's in-flight
1036
+ * fetch, re-armed its wake and fetched it again; disposed a woken island and woke it again. The
1037
+ * teardown waits a microtask and runs only if the element is still out of the document. The
1038
+ * reconnect itself runs as any connect: a region already scheduled stops at `#scheduled`, and one
1039
+ * that was not (a nested island a lake lifted out and put back, now under a frozen boundary)
1040
+ * decides afresh where it stands.
1041
+ */
1042
+ disconnectedCallback() {
1043
+ if (this.#leaving) return;
1044
+ this.#leaving = true;
1045
+ queueMicrotask(() => {
1046
+ this.#leaving = false;
1047
+ if (!this.isConnected) this.#teardown();
1048
+ });
1049
+ }
1050
+ #teardown() {
1051
+ connected_regions.delete(this);
1052
+ unregister_region(this);
1053
+ if (this.#watching) mark_region_changed(this);
1054
+ this.#unwatch();
1055
+ if (CLIENT_PLUGINS && (this.#live_app || this.#app)) client_region_unmount(this, this.getAttribute("entry") ?? "");
1056
+ if (this.#live_app) {
1057
+ this.#live_app.dispose();
1058
+ this.#live_app = null;
1059
+ }
1060
+ this.#fetch_abort?.abort();
1061
+ this.#fetch_abort = null;
1062
+ this.#frame_unsub?.();
1063
+ this.#frame_unsub = null;
1064
+ if (this.#frame_address) {
1065
+ slots.frames?.abandon(this.#frame_address);
1066
+ this.#frame_address = null;
1067
+ }
1068
+ if (this.#idle_handle != null) {
1069
+ if ("cancelIdleCallback" in window) cancelIdleCallback(this.#idle_handle);
1070
+ else clearTimeout(this.#idle_handle);
1071
+ this.#idle_handle = null;
1072
+ }
1073
+ this.#stop_visible?.();
1074
+ this.#stop_visible = null;
1075
+ on_demand_armed.delete(this);
1076
+ this.#disarm_interaction?.();
1077
+ this.#disarm_interaction = null;
1078
+ if (this.#mql) {
1079
+ this.#mql.mql.removeEventListener("change", this.#mql.on);
1080
+ this.#mql = null;
1081
+ }
1082
+ if (this.#app) {
1083
+ this.#app.dispose();
1084
+ this.#app = null;
1085
+ }
1086
+ this.#scheduled = false;
1087
+ }
1088
+ };
1089
+ /**
1090
+ * Boot the always-on custom element after each selected feature has filled its {@link slots} entry.
1091
+ * Core never statically imports an optional feature — the generated entry (or {@link ./full.js})
1092
+ * passes each feature's `install` here, in {@link ../vite/runtime-entry.js FEATURE_ORDER}. Order is
1093
+ * load-bearing: `live` needs `morph` present first.
1094
+ */
1095
+ /**
1096
+ * DEV ONLY: apply the region-CSS `<link data-ogygia-region-css>`s the SSR baked into the document.
1097
+ * In dev there is no extracted `.css` asset — `islandCss` hands a region its dev MODULE url as the
1098
+ * href, and a `<link rel="stylesheet">` to a JS module makes an EMPTY sheet (the server serves it as
1099
+ * `text/javascript`), so CSS authored in any hole or region silently never applied on first load.
1100
+ * Import each module instead — executing it injects the scoped `<style>` (Vite's dev CSS mechanism),
1101
+ * the exact rescue {@link region_fragment} already runs for a FETCHED answer, here for the links that
1102
+ * shipped on the page. Prod links a real `.css` asset, so `import.meta.env.DEV` DCEs this whole path.
1103
+ * Deferred to {@link dom_ready}: the runtime bootstrap is the FIRST node in `<head>`, so the region
1104
+ * links below it are not parsed yet at boot.
1105
+ */
1106
+ function apply_dev_head_region_css() {
1107
+ if (!import.meta.env.DEV || typeof document === "undefined") return;
1108
+ dom_ready().then(() => {
1109
+ const seen = /* @__PURE__ */ new Set();
1110
+ for (const link of document.querySelectorAll("link[data-ogygia-region-css]")) {
1111
+ const href = link.getAttribute("href");
1112
+ if (!href || CSS_ASSET_HREF_RE.test(href)) continue;
1113
+ link.remove();
1114
+ const url = island_module_url(href);
1115
+ if (seen.has(url)) continue;
1116
+ seen.add(url);
1117
+ import(
1118
+ /* @vite-ignore */
1119
+ url
1120
+ ).catch(() => {});
1121
+ }
1122
+ });
1123
+ }
1124
+ function boot(installers = [], client_plugins = []) {
1125
+ if (typeof document !== "undefined" && !(NAV_HANDLE_KEY in globalThis)) publish_nav(mpa_nav());
1126
+ runtime_session.adopt_document_head();
1127
+ link_boot();
1128
+ for (const install of installers) install();
1129
+ on_entry_fallback((report) => {
1130
+ if (DEVTOOLS) emit({
1131
+ domain: "runtime",
1132
+ name: "entry.fallback",
1133
+ ...report
1134
+ });
1135
+ if (BEACON) beacon_entry_fallback(report);
1136
+ });
1137
+ if (import.meta.env.DEV) apply_dev_head_region_css();
1138
+ if (BEACON) beacon_watch();
1139
+ if (import.meta.env.DEV) {
1140
+ tap_svelte_warnings();
1141
+ on_svelte_warning((w) => {
1142
+ if (BEACON) beacon_warning(w);
1143
+ if (DEVTOOLS) emit({
1144
+ domain: "runtime",
1145
+ name: "svelte.hydration.warning",
1146
+ code: w.code,
1147
+ message: w.message,
1148
+ ...w.file ? { file: w.file } : {},
1149
+ ...w.fp ? { fp: w.fp } : {}
1150
+ });
1151
+ });
1152
+ }
1153
+ if (DEVTOOLS) {
1154
+ install_window_sink();
1155
+ ingest_server_events();
1156
+ }
1157
+ if (CLIENT_PLUGINS) boot_client_plugins(client_plugins, false);
1158
+ if (DEVTOOLS) {
1159
+ const features = [];
1160
+ if (slots.interaction) features.push("interaction");
1161
+ if (slots.morph) features.push("morph");
1162
+ if (slots.frames) features.push("frames");
1163
+ if (slots.nav) features.push("router");
1164
+ if (slots.forms.enabled) features.push("forms");
1165
+ emit({
1166
+ domain: "runtime",
1167
+ name: "runtime.boot",
1168
+ features
1169
+ });
1170
+ }
1171
+ if (typeof customElements !== "undefined" && !customElements.get("ogygia-region")) customElements.define("ogygia-region", OgygiaRegion);
1172
+ }
1173
+ export { boot, pristine_ssr_of, region_fragment };