@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,19 @@
1
+ // src/runtime/lake-anchors.ts
2
+ /**
3
+ * After lifting lake content into a region, move trailing empty SSR comments
4
+ * (`<!---->`) back into the region. Those are Boundary/host delimiters — not lake
5
+ * content — and hydrate needs them for Boundary+Placeholder.
6
+ */
7
+ const COMMENT_NODE = 8;
8
+ /** Relocate trailing empty comments from `frag` into `lake`. Returns how many moved. */
9
+ function relocate_trailing_empty_comments(frag, lake) {
10
+ const moved = [];
11
+ while (frag.lastChild && frag.lastChild.nodeType === COMMENT_NODE && frag.lastChild.data === "") {
12
+ const node = frag.lastChild;
13
+ frag.removeChild(node);
14
+ moved.unshift(node);
15
+ }
16
+ for (const n of moved) lake.appendChild(n);
17
+ return moved.length;
18
+ }
19
+ export { relocate_trailing_empty_comments };
@@ -0,0 +1,15 @@
1
+ import { LakeArm, LiftedLake } from "./slots.js";
2
+ /** Feature entry: fill the `lakes` slot so core lifts/restores frozen regions. */
3
+ export declare function install(): void;
4
+ export declare function settle_in(root: ParentNode): void;
5
+ export declare function lift(parent: Element): LiftedLake[];
6
+ export declare function restore(parent: Element, lifted: LiftedLake[]): void;
7
+ export declare function on_frozen_connect(el: HTMLElement, arm: LakeArm): boolean;
8
+ export declare function wait_for_boundary(_el: HTMLElement, boundary: Element | null): boolean;
9
+ export declare function mark_frozen_settled(region: HTMLElement): void;
10
+ export declare function after_html_swap(region: HTMLElement, opts: {
11
+ revalidate?: boolean;
12
+ }): void;
13
+ export declare function after_fetch_exhausted(region: HTMLElement, opts: {
14
+ revalidate?: boolean;
15
+ }, wake_children: () => void): void;
@@ -0,0 +1,212 @@
1
+ import { relocate_trailing_empty_comments } from "./lake-anchors.js";
2
+ import { FROZEN_SELECTOR, document_is_stored, is_awake, is_frozen, region_is_vacant, region_max_age_ms, region_on_expire, region_remount } from "./region-attrs.js";
3
+ import { runtime_session } from "./session.js";
4
+ import { slots } from "./slots.js";
5
+ // src/runtime/lakes.ts
6
+ /** Feature entry: fill the `lakes` slot so core lifts/restores frozen regions. */
7
+ function install() {
8
+ slots.lakes = {
9
+ on_frozen_connect,
10
+ wait_for_boundary,
11
+ lift,
12
+ restore,
13
+ settle_in,
14
+ mark_frozen_settled,
15
+ after_html_swap,
16
+ after_fetch_exhausted
17
+ };
18
+ }
19
+ function settle_in(root) {
20
+ runtime_session.settle_lakes_in(root);
21
+ }
22
+ const in_live_snippet = (lake, parent) => {
23
+ const snippet = lake.parentElement?.closest("ogygia-snippet");
24
+ return !!snippet && parent.contains(snippet) && !snippet.hasAttribute("data-og-static");
25
+ };
26
+ /** The lakes `parent`'s own hydrate lifts and restores: nearest region is `parent`, outside live snippets. */
27
+ const lifted_lakes_of = (parent) => [...parent.querySelectorAll(FROZEN_SELECTOR)].filter((l) => l.parentElement?.closest("ogygia-region") === parent && !in_live_snippet(l, parent));
28
+ function lift(parent) {
29
+ const lifted = [];
30
+ for (const lake of lifted_lakes_of(parent)) {
31
+ const id = lake.getAttribute("entry") || "";
32
+ const frag = document.createDocumentFragment();
33
+ while (lake.firstChild) frag.appendChild(lake.firstChild);
34
+ relocate_trailing_empty_comments(frag, lake);
35
+ lifted.push({
36
+ id,
37
+ frag,
38
+ endpoint: lake.getAttribute("endpoint") || "",
39
+ when: lake.getAttribute("when") || "load",
40
+ maxAgeMs: region_max_age_ms(lake)
41
+ });
42
+ }
43
+ return lifted;
44
+ }
45
+ function restore(parent, lifted) {
46
+ const lakes = lifted_lakes_of(parent);
47
+ for (const lake of parent.querySelectorAll(FROZEN_SELECTOR)) {
48
+ if (lake.parentElement?.closest("ogygia-region") !== parent || !in_live_snippet(lake, parent)) continue;
49
+ const id = lake.getAttribute("entry") || "";
50
+ settle_in(lake);
51
+ runtime_session.initialized_lakes.add(id);
52
+ remember(lake, id, {
53
+ endpoint: lake.getAttribute("endpoint") || "",
54
+ when: lake.getAttribute("when") || "load",
55
+ maxAgeMs: region_max_age_ms(lake)
56
+ });
57
+ for (const r of lake.querySelectorAll("ogygia-region")) r.connectedCallback?.();
58
+ }
59
+ for (let i = 0; i < lifted.length && i < lakes.length; i++) {
60
+ const lake = lakes[i];
61
+ const { id, frag, endpoint, when, maxAgeMs } = lifted[i];
62
+ settle_in(lake);
63
+ settle_in(frag);
64
+ runtime_session.initialized_lakes.add(id);
65
+ lake.appendChild(frag);
66
+ if (endpoint && !lake.getAttribute("endpoint")) lake.setAttribute("endpoint", endpoint);
67
+ remember(lake, id, {
68
+ endpoint,
69
+ when,
70
+ maxAgeMs
71
+ });
72
+ }
73
+ }
74
+ /** A lake with no AWAKE region host: nothing will ever lift/restore it (that is a host island's
75
+ * hydrate), so it settles itself and remembers itself. The shapes: a lake ADOPTED under Kit
76
+ * hydration (csr=true page), a lake inside an inline (Kit-hydrated) island, a top-level lake. */
77
+ function unhosted(el) {
78
+ const host = el.parentElement?.closest("ogygia-region");
79
+ return !host || !is_awake(host);
80
+ }
81
+ /**
82
+ * Snapshot a lake's current children into the session cache — the copy a later VACANT connect of
83
+ * the same lake id repaints from (`remount="cache"` / `"swr"`). First snapshot wins: the SSR HTML
84
+ * (or the freshest revalidation, which replaces it in `after_html_swap`).
85
+ */
86
+ function remember(lake, id, meta) {
87
+ const policy = region_remount(lake);
88
+ if (!((policy === "cache" || policy === "swr") && id && !runtime_session.lake_cache.has(id))) return;
89
+ const cached = document.createDocumentFragment();
90
+ for (const child of Array.from(lake.childNodes)) cached.appendChild(child.cloneNode(true));
91
+ runtime_session.set_lake_cache(id, {
92
+ frag: cached,
93
+ endpoint: meta.endpoint,
94
+ when: meta.when,
95
+ cachedAt: Date.now(),
96
+ maxAgeMs: meta.maxAgeMs || region_max_age_ms(lake)
97
+ });
98
+ }
99
+ function on_frozen_connect(el, arm) {
100
+ if (!is_frozen(el)) return false;
101
+ const id = el.getAttribute("entry") || "";
102
+ if (!runtime_session.initialized_lakes.has(id)) {
103
+ if (region_remount(el) === "swr" && el.getAttribute("endpoint") && document_is_stored()) {
104
+ const when = el.getAttribute("when") || "load";
105
+ const fire = () => arm.fetch_revalidate();
106
+ if (when === "idle") arm.idle(fire);
107
+ else if (when === "visible") arm.visible(fire);
108
+ else if (when === "load") fire();
109
+ else arm.media(when, fire);
110
+ } else if (import.meta.env.DEV && region_remount(el) === "swr" && !el.parentElement?.closest("ogygia-region")) console.warn(`[ogygia] render:'live' region "${id}" has no island host — on regular pages it will never revalidate (only on documents served from a page store). Wrap it in a wake:'load' island to drive remount revalidation.`);
111
+ if (unhosted(el)) {
112
+ runtime_session.settled_lakes.add(el);
113
+ if (!region_is_vacant(el)) {
114
+ remember(el, id, {
115
+ endpoint: el.getAttribute("endpoint") || "",
116
+ when: el.getAttribute("when") || "load",
117
+ maxAgeMs: region_max_age_ms(el)
118
+ });
119
+ runtime_session.initialized_lakes.add(id);
120
+ }
121
+ }
122
+ return true;
123
+ }
124
+ if (!region_is_vacant(el)) {
125
+ if (unhosted(el)) runtime_session.settled_lakes.add(el);
126
+ return true;
127
+ }
128
+ const policy = region_remount(el);
129
+ switch (policy) {
130
+ case "empty":
131
+ runtime_session.settled_lakes.add(el);
132
+ return true;
133
+ case "cache":
134
+ case "swr": {
135
+ const cached = runtime_session.lake_cache.get(id);
136
+ if (!cached) {
137
+ runtime_session.settled_lakes.add(el);
138
+ return true;
139
+ }
140
+ const max_age = region_max_age_ms(el) || cached.maxAgeMs || 0;
141
+ const expired = max_age > 0 && Date.now() - cached.cachedAt > max_age;
142
+ const on_expire = region_on_expire(el);
143
+ if (expired && on_expire === "empty") {
144
+ runtime_session.settled_lakes.add(el);
145
+ return true;
146
+ }
147
+ if (expired && on_expire === "fetch") {
148
+ if (!cached.endpoint) {
149
+ runtime_session.settled_lakes.add(el);
150
+ return true;
151
+ }
152
+ el.setAttribute("endpoint", cached.endpoint);
153
+ const when = el.getAttribute("when") || cached.when || "load";
154
+ const fire = () => arm.fetch_revalidate();
155
+ if (when === "idle") arm.idle(fire);
156
+ else if (when === "visible") arm.visible(fire);
157
+ else if (when === "load") fire();
158
+ else arm.media(when, fire);
159
+ return true;
160
+ }
161
+ if (policy === "cache") {
162
+ runtime_session.settled_lakes.add(el);
163
+ el.appendChild(cached.frag.cloneNode(true));
164
+ return true;
165
+ }
166
+ el.appendChild(cached.frag.cloneNode(true));
167
+ if (!cached.endpoint) {
168
+ runtime_session.settled_lakes.add(el);
169
+ arm.wake_children();
170
+ if (import.meta.env.DEV) console.warn(`[ogygia] region "${id}" is render:'live' but no signed endpoint was captured at SSR — painting the cache only.`);
171
+ return true;
172
+ }
173
+ el.setAttribute("endpoint", cached.endpoint);
174
+ const when = el.getAttribute("when") || cached.when || "load";
175
+ const fire = () => arm.fetch_revalidate();
176
+ if (when === "idle") arm.idle(fire);
177
+ else if (when === "visible") arm.visible(fire);
178
+ else if (when === "load") fire();
179
+ else arm.media(when, fire);
180
+ return true;
181
+ }
182
+ default: return policy;
183
+ }
184
+ }
185
+ function wait_for_boundary(_el, boundary) {
186
+ return !!(boundary && is_frozen(boundary) && !runtime_session.settled_lakes.has(boundary));
187
+ }
188
+ function mark_frozen_settled(region) {
189
+ if (is_frozen(region)) runtime_session.settled_lakes.add(region);
190
+ }
191
+ function after_html_swap(region, opts) {
192
+ if (!(opts.revalidate && is_frozen(region))) return;
193
+ const id = region.getAttribute("entry") || "";
194
+ if (!id) return;
195
+ const cached = document.createDocumentFragment();
196
+ for (const child of Array.from(region.childNodes)) cached.appendChild(child.cloneNode(true));
197
+ const prev = runtime_session.lake_cache.get(id);
198
+ runtime_session.set_lake_cache(id, {
199
+ frag: cached,
200
+ endpoint: region.getAttribute("endpoint") || prev?.endpoint || "",
201
+ when: region.getAttribute("when") || prev?.when || "load",
202
+ cachedAt: Date.now(),
203
+ maxAgeMs: region_max_age_ms(region) || prev?.maxAgeMs || 0
204
+ });
205
+ }
206
+ function after_fetch_exhausted(region, opts, wake_children) {
207
+ if (opts.revalidate && is_frozen(region) && region.isConnected) {
208
+ runtime_session.settled_lakes.add(region);
209
+ wake_children();
210
+ }
211
+ }
212
+ export { after_fetch_exhausted, after_html_swap, install, lift, mark_frozen_settled, on_frozen_connect, restore, settle_in, wait_for_boundary };
@@ -0,0 +1,3 @@
1
+ /** Feature entry: fill the `live` slot with {@link LiveHost}, and `keep` with {@link KeepHost} (a
2
+ * kept island's host: the same pushable props, in a placed island's SSR shape). */
3
+ export declare function install(): void;
@@ -0,0 +1,17 @@
1
+ import { slots } from "./slots.js";
2
+ import LiveHost from "../LiveHost.svelte";
3
+ import KeepHost from "../KeepHost.svelte";
4
+ // src/runtime/live.ts
5
+ /**
6
+ * Live-region feature: the props-pushable host a live `<Region>` hydrates through, so later
7
+ * `query.live` ticks push new props into the mounted island (keep-alive) instead of re-hydrating.
8
+ *
9
+ * A HYDRATE-phase feature (link/runtime-entry.ts): installed by the hydrate core, never the boot.
10
+ */
11
+ /** Feature entry: fill the `live` slot with {@link LiveHost}, and `keep` with {@link KeepHost} (a
12
+ * kept island's host: the same pushable props, in a placed island's SSR shape). */
13
+ function install() {
14
+ slots.live = LiveHost;
15
+ slots.keep = KeepHost;
16
+ }
17
+ export { install };
@@ -0,0 +1,53 @@
1
+ export type LoadClass = "user" | "visible" | "ahead" | "speculative";
2
+ /** `code`: an island's modules. `content`: HTML (a hole's answer, a prefetched page). */
3
+ export type LoadKind = "code" | "content";
4
+ /** How long background work waits for the page's critical resources at most. */
5
+ export declare const CRITICAL_CAP_MS = 2500;
6
+ /** Background (`ahead` + `speculative`) downloads in flight at once. */
7
+ export declare const BACKGROUND_WINDOW = 3;
8
+ /** The fetch priority a class downloads at (`fetch(…, { priority })`, `<link fetchpriority>`). */
9
+ export declare function fetch_priority_of(cls: LoadClass): "high" | "auto" | "low";
10
+ /**
11
+ * `visible` when `el` — or, for a region with no area of its own, what it renders — intersects the
12
+ * viewport now, else `ahead`. A region whose content is out of flow (a `position: fixed` button) or
13
+ * that is `display: contents` has no area, and where such a box sits says nothing (`display:
14
+ * contents` reports 0,0), so its descendants' boxes decide first (bounded: the first few levels).
15
+ */
16
+ export declare function viewport_class(el: Element): "visible" | "ahead";
17
+ /** How the critical-resources wait ended: they `arrived` (or failed), the visitor's first `input`,
18
+ * the `cap`, or `none` were pending. */
19
+ export type CriticalOutcome = "arrived" | "input" | "cap" | "none";
20
+ declare let critical_report: {
21
+ outcome: CriticalOutcome;
22
+ resources: number;
23
+ waited_ms: number;
24
+ } | null;
25
+ /** The critical wait's outcome once it settled (the profiler's beacon reads it), else `null`. */
26
+ export declare function critical_outcome(): typeof critical_report;
27
+ /** The URLs a preload link may fetch: its `href`, else each `imagesrcset` candidate's. */
28
+ export declare function preload_urls(link: HTMLLinkElement): string[];
29
+ /**
30
+ * Resolves once the document is parsed and painted AND its author-marked critical resources have
31
+ * arrived (or failed) — or at the visitor's first click or key, or {@link CRITICAL_CAP_MS} into the
32
+ * wait. A page with no marked resource resolves right after the paint. Once resolved it stays so.
33
+ */
34
+ export declare function critical_settled(): Promise<void>;
35
+ /** A queued download: its current class, and a way to lift it. */
36
+ export interface LoadTicket {
37
+ promote(cls: LoadClass): void;
38
+ }
39
+ /**
40
+ * Ask for a slot. `ready` resolves with a `release` to call when the download is done (settled,
41
+ * success or not). `cls` may be a getter, re-read whenever the queue drains (viewport changes).
42
+ */
43
+ export declare function load_slot(o: {
44
+ kind: LoadKind;
45
+ cls: LoadClass | (() => LoadClass);
46
+ label?: string;
47
+ }): {
48
+ ready: Promise<() => void>;
49
+ ticket: LoadTicket;
50
+ };
51
+ /** Test seam: a fresh document. */
52
+ export declare function reset_load_scheduler(): void;
53
+ export {};
@@ -0,0 +1,317 @@
1
+ import { after_document_painted, yield_task } from "./schedule.js";
2
+ import { kit_hydrates_page } from "./kit-boot.js";
3
+ import { emit } from "../events/bus.js";
4
+ // src/runtime/load-scheduler.ts
5
+ /**
6
+ * THE LOAD SCHEDULER — every download ogygia starts on its own goes through one queue.
7
+ *
8
+ * Island code, a hole's HTML, a hole's prefetch, the module warm on hover, the router's page
9
+ * prefetch: each used to pick its own moment, and on a fast-parsing page they all started together,
10
+ * beside the page's own LCP image — a country home page's hero took 2.27 s instead of 1.19 s while
11
+ * 206 island requests (888 KB) shared its bandwidth. Priority hints alone do not fix that (a
12
+ * throttled or priority-blind connection splits bandwidth evenly); waiting for the right moment,
13
+ * and capping how much background work is in flight, does.
14
+ *
15
+ * Every download carries a CLASS, decided by who is waiting for it:
16
+ * - `user` — a visitor's gesture (an `interaction` wake, a click-time navigation, an explicit
17
+ * `preload()`): never waits, fetched at high priority.
18
+ * - `visible` — on screen now (an island or hole in the viewport): fetched at default priority.
19
+ * - `ahead` — not on screen yet (an `idle` island, one screen ahead, a hole prefetch): low
20
+ * priority, a small window.
21
+ * - `speculative` — a guess about the future (the router's page prefetch, its module warm): low
22
+ * priority, the same window, behind every `ahead`.
23
+ *
24
+ * And a GATE, decided by signals, not timers ({@link critical_settled}): island CODE and every
25
+ * background class wait until the document is parsed and painted AND the page's critical resources
26
+ * have arrived — the image or preload its author marked `fetchpriority="high"` (the LCP resource;
27
+ * nothing to guess) — or the visitor's first click / key (the browser stops measuring LCP there), or
28
+ * a cap. Visible CONTENT (a hole's HTML on screen) does not wait: it IS what the visitor sees.
29
+ *
30
+ * A queued download's class is re-read when the queue drains, so an island scrolling into view moves
31
+ * from `ahead` to `visible`; `promote()` lifts a queued one by hand (a click on a link whose prefetch
32
+ * still waits). On a Kit-hydrated document Kit's own start sets the pace, so nothing waits on the
33
+ * critical resources there (the window still applies).
34
+ */
35
+ const DEVTOOLS = typeof __OGYGIA_DEVTOOLS__ !== "undefined" ? __OGYGIA_DEVTOOLS__ : false;
36
+ /** How long background work waits for the page's critical resources at most. */
37
+ const CRITICAL_CAP_MS = 2500;
38
+ /** Background (`ahead` + `speculative`) downloads in flight at once. */
39
+ const BACKGROUND_WINDOW = 3;
40
+ const RANK = {
41
+ user: 0,
42
+ visible: 1,
43
+ ahead: 2,
44
+ speculative: 3
45
+ };
46
+ /** The fetch priority a class downloads at (`fetch(…, { priority })`, `<link fetchpriority>`). */
47
+ function fetch_priority_of(cls) {
48
+ return cls === "user" ? "high" : cls === "visible" ? "auto" : "low";
49
+ }
50
+ /**
51
+ * `visible` when `el` — or, for a region with no area of its own, what it renders — intersects the
52
+ * viewport now, else `ahead`. A region whose content is out of flow (a `position: fixed` button) or
53
+ * that is `display: contents` has no area, and where such a box sits says nothing (`display:
54
+ * contents` reports 0,0), so its descendants' boxes decide first (bounded: the first few levels).
55
+ */
56
+ function viewport_class(el) {
57
+ if (typeof innerHeight === "undefined" || !el.isConnected) return "ahead";
58
+ return on_screen(el, 3) ? "visible" : "ahead";
59
+ }
60
+ function on_screen(el, depth) {
61
+ const r = el.getBoundingClientRect();
62
+ const crosses = r.bottom > 0 && r.right > 0 && r.top < innerHeight && r.left < innerWidth;
63
+ if (r.width > 0 && r.height > 0) return crosses;
64
+ if (depth > 0) {
65
+ let seen = 0;
66
+ for (let c = el.firstElementChild; c && seen < 16; c = c.nextElementSibling, seen++) if (on_screen(c, depth - 1)) return true;
67
+ }
68
+ return crosses && (r.width > 0 || r.height > 0);
69
+ }
70
+ let input_seen = false;
71
+ const on_first_input = () => {
72
+ input_seen = true;
73
+ release_critical?.();
74
+ };
75
+ if (typeof document !== "undefined") for (const type of ["pointerdown", "keydown"]) addEventListener(type, on_first_input, {
76
+ capture: true,
77
+ passive: true,
78
+ once: true
79
+ });
80
+ let critical = null;
81
+ let critical_done = false;
82
+ let release_critical = null;
83
+ let critical_report = null;
84
+ /** The critical wait's outcome once it settled (the profiler's beacon reads it), else `null`. */
85
+ function critical_outcome() {
86
+ return critical_report;
87
+ }
88
+ /** Elements carrying the page's critical resources that have not arrived yet: an eager
89
+ * `img[fetchpriority=high]` not complete, a `link[rel=preload][fetchpriority=high]` not fetched. */
90
+ function pending_critical() {
91
+ const out = [];
92
+ for (const img of document.querySelectorAll("img[fetchpriority=\"high\" i]")) {
93
+ if (img.loading === "lazy" || img.complete) continue;
94
+ out.push(img);
95
+ }
96
+ for (const link of document.querySelectorAll("link[rel~=\"preload\"][fetchpriority=\"high\" i]")) {
97
+ if (link.media && !matchMedia(link.media).matches) continue;
98
+ const urls = preload_urls(link);
99
+ if (!urls.length) continue;
100
+ if (urls.some((u) => performance.getEntriesByName?.(u).length)) continue;
101
+ out.push(link);
102
+ }
103
+ return out;
104
+ }
105
+ /** The URLs a preload link may fetch: its `href`, else each `imagesrcset` candidate's. */
106
+ function preload_urls(link) {
107
+ if (link.href) return [link.href];
108
+ const set = link.getAttribute("imagesrcset");
109
+ if (!set) return [];
110
+ const out = [];
111
+ for (const part of set.split(",")) {
112
+ const candidate = part.trim();
113
+ let end = 0;
114
+ while (end < candidate.length && candidate.charCodeAt(end) > 32) end++;
115
+ const url = candidate.slice(0, end);
116
+ if (!url) continue;
117
+ try {
118
+ out.push(new URL(url, document.baseURI).href);
119
+ } catch {}
120
+ }
121
+ return out;
122
+ }
123
+ /**
124
+ * Resolves once the document is parsed and painted AND its author-marked critical resources have
125
+ * arrived (or failed) — or at the visitor's first click or key, or {@link CRITICAL_CAP_MS} into the
126
+ * wait. A page with no marked resource resolves right after the paint. Once resolved it stays so.
127
+ */
128
+ function critical_settled() {
129
+ return critical ??= after_document_painted().then(() => new Promise((resolve) => {
130
+ const t0 = now();
131
+ const done = (outcome) => {
132
+ if (critical_done) return;
133
+ critical_done = true;
134
+ release_critical = null;
135
+ clearTimeout(timer);
136
+ critical_report = {
137
+ outcome,
138
+ resources: waiting.length,
139
+ waited_ms: Math.round(now() - t0)
140
+ };
141
+ if (DEVTOOLS) emit({
142
+ domain: "runtime",
143
+ name: "load.critical",
144
+ ...critical_report
145
+ });
146
+ resolve();
147
+ drain();
148
+ };
149
+ const waiting = input_seen || document.visibilityState === "hidden" ? [] : pending_critical();
150
+ const timer = waiting.length ? setTimeout(() => done("cap"), CRITICAL_CAP_MS) : void 0;
151
+ if (!waiting.length) return done("none");
152
+ release_critical = () => done("input");
153
+ let left = waiting.length;
154
+ const one = () => {
155
+ if (--left === 0) done("arrived");
156
+ };
157
+ for (const el of waiting) {
158
+ el.addEventListener("load", one, { once: true });
159
+ el.addEventListener("error", one, { once: true });
160
+ }
161
+ }));
162
+ }
163
+ const queue = [];
164
+ let in_flight_background = 0;
165
+ let next_order = 0;
166
+ let scroll_watch = false;
167
+ /**
168
+ * Ask for a slot. `ready` resolves with a `release` to call when the download is done (settled,
169
+ * success or not). `cls` may be a getter, re-read whenever the queue drains (viewport changes).
170
+ */
171
+ function load_slot(o) {
172
+ let forced = null;
173
+ const read = typeof o.cls === "function" ? o.cls : () => o.cls;
174
+ const cls = () => {
175
+ const c = read();
176
+ return forced !== null && RANK[forced] < RANK[c] ? forced : c;
177
+ };
178
+ let resolve;
179
+ const ready = new Promise((r) => resolve = r);
180
+ const entry = {
181
+ kind: o.kind,
182
+ cls,
183
+ label: o.label,
184
+ queued_at: now(),
185
+ order: next_order++,
186
+ resolve,
187
+ background: false
188
+ };
189
+ queue.push(entry);
190
+ if (typeof o.cls === "function") watch_scroll();
191
+ if (!critical_done && waits_for_critical(entry.kind, cls())) critical_settled();
192
+ drain();
193
+ return {
194
+ ready,
195
+ ticket: { promote(c) {
196
+ forced = c;
197
+ drain();
198
+ } }
199
+ };
200
+ }
201
+ function waits_for_critical(kind, cls) {
202
+ if (cls === "user") return false;
203
+ if (kit_hydrates_page()) return false;
204
+ return !(kind === "content" && cls === "visible");
205
+ }
206
+ /**
207
+ * Starts go out across tasks: a start's holder runs its own start-up synchronously (an island adds
208
+ * its graph links and starts its imports; the first one also the runtime's lazy chunks), so when the
209
+ * gate opened on a page of 21 islands, every one of those ran in the task that opened it — one long
210
+ * task (52 ms on a 4×-throttled runner). After this much work in one task the drain yields.
211
+ */
212
+ const START_BUDGET_MS = 16;
213
+ let draining = false;
214
+ let drain_again = false;
215
+ function drain() {
216
+ if (draining) {
217
+ drain_again = true;
218
+ return;
219
+ }
220
+ if (!queue.length) return;
221
+ draining = true;
222
+ drain_queue().finally(() => {
223
+ draining = false;
224
+ if (drain_again) {
225
+ drain_again = false;
226
+ drain();
227
+ }
228
+ });
229
+ }
230
+ async function drain_queue() {
231
+ let until = now() + START_BUDGET_MS;
232
+ for (;;) {
233
+ drain_again = false;
234
+ queue.sort((a, b) => RANK[a.cls()] - RANK[b.cls()] || a.order - b.order);
235
+ let yielded = false;
236
+ for (let i = 0; i < queue.length;) {
237
+ const e = queue[i];
238
+ const cls = e.cls();
239
+ if (!critical_done && waits_for_critical(e.kind, cls)) {
240
+ i++;
241
+ continue;
242
+ }
243
+ const background = cls === "ahead" || cls === "speculative";
244
+ if (background && in_flight_background >= 3) {
245
+ i++;
246
+ continue;
247
+ }
248
+ queue.splice(i, 1);
249
+ start(e, cls, background);
250
+ await Promise.resolve();
251
+ if (now() >= until) {
252
+ await yield_task();
253
+ until = now() + START_BUDGET_MS;
254
+ yielded = true;
255
+ break;
256
+ }
257
+ }
258
+ if (!yielded && !drain_again) return;
259
+ }
260
+ }
261
+ function start(e, cls, background) {
262
+ if (background) in_flight_background++;
263
+ e.background = background;
264
+ let released = false;
265
+ if (DEVTOOLS) emit({
266
+ domain: "runtime",
267
+ name: "load.started",
268
+ class: cls,
269
+ kind: e.kind,
270
+ label: e.label,
271
+ waited_ms: Math.round(now() - e.queued_at)
272
+ });
273
+ e.resolve(() => {
274
+ if (released) return;
275
+ released = true;
276
+ if (background) in_flight_background--;
277
+ drain();
278
+ });
279
+ }
280
+ /** While a queued download's class can change with the viewport, re-drain on scroll (one frame). */
281
+ function watch_scroll() {
282
+ if (scroll_watch || typeof addEventListener === "undefined") return;
283
+ scroll_watch = true;
284
+ let framed = false;
285
+ const on_scroll = () => {
286
+ if (framed) return;
287
+ framed = true;
288
+ requestAnimationFrame(() => {
289
+ framed = false;
290
+ drain();
291
+ if (!queue.length) {
292
+ removeEventListener("scroll", on_scroll, true);
293
+ scroll_watch = false;
294
+ }
295
+ });
296
+ };
297
+ addEventListener("scroll", on_scroll, {
298
+ capture: true,
299
+ passive: true
300
+ });
301
+ }
302
+ function now() {
303
+ return typeof performance !== "undefined" ? performance.now() : Date.now();
304
+ }
305
+ /** Test seam: a fresh document. */
306
+ function reset_load_scheduler() {
307
+ queue.length = 0;
308
+ in_flight_background = 0;
309
+ draining = false;
310
+ drain_again = false;
311
+ critical = null;
312
+ critical_done = false;
313
+ release_critical = null;
314
+ critical_report = null;
315
+ input_seen = false;
316
+ }
317
+ export { BACKGROUND_WINDOW, CRITICAL_CAP_MS, critical_outcome, critical_settled, fetch_priority_of, load_slot, preload_urls, reset_load_scheduler, viewport_class };
@@ -0,0 +1,42 @@
1
+ /** Feature entry: fill the `morph` slot (live static-region ticks morph in place). */
2
+ export declare function install(): void;
3
+ /**
4
+ * Reconcile `parent`'s children toward `new_nodes` (a freshly parsed, detached region). Public slot
5
+ * shape: `(parent: Element, nodes: Node[]) => void` — a drop-in for the previous implementation.
6
+ *
7
+ * `new_nodes` is read but never mutated, so the recursion passes the incoming element's live
8
+ * `childNodes` straight through (see {@link morph_node}) — no per-level array snapshot. Accessed by
9
+ * index, so both a real `Array` (the top-level region) and a live `NodeList` (recursion) fit.
10
+ *
11
+ * Two phases:
12
+ * 1. **Lockstep** — walk old and new in parallel while their keys agree (both `null` and compatible,
13
+ * or the same non-null key), morphing in place. This is the dominant tick (same structure, values
14
+ * changed) and it allocates NOTHING — no key map, no cursor bookkeeping. Reorders/inserts/removals
15
+ * break the lockstep at the first divergence and hand the REMAINDER to phase 2.
16
+ * 2. **Keyed reconcile** — the general move/insert/remove algorithm, run only on the still-unmatched
17
+ * tail. The key map indexes just the remaining old children, so a change late in a long list still
18
+ * skips indexing the aligned prefix.
19
+ */
20
+ export declare function morph_children(parent: Element, new_nodes: ArrayLike<Node>, options?: MorphOptions): void;
21
+ /**
22
+ * One ownership rule (runtime/ownership.ts), two TARGETS.
23
+ *
24
+ * - **`live`** (default: a hole re-answer, a router body swap, a live region tick) — the target is the
25
+ * new answer, and the DOM stays live afterwards: a child an upgraded element gave itself is foreign
26
+ * content, kept (a web component must not lose its own upgrade work).
27
+ * - **`walk`** (the pre-hydration repair) — the target is the server sequence Svelte's walk binds by
28
+ * position, exactly. The same foreign child sitting in a position the walk reads is the node
29
+ * Svelte's cursor trips on (`getAttribute is not a function` on a nested web component's own
30
+ * residue), so here it is removed; and a subtree the walk never enters (`data-og-opaque`, a slot) is
31
+ * left alone — nothing reads it.
32
+ *
33
+ * In both targets a declared-foreign element and a hydrated region are matched, never entered, and an
34
+ * upgraded element's host ATTRIBUTES stay its runtime's.
35
+ */
36
+ export interface MorphOptions {
37
+ target?: "live" | "walk";
38
+ }
39
+ /** Add + update + remove attributes so `from` matches `to` exactly. Boolean attrs are attr presence.
40
+ * `keep_extra` (a self-owned element, {@link is_self_owned}): add + update only — an attribute the
41
+ * element gave itself is not the render's to take away. */
42
+ export declare function sync_attributes(from: Element, to: Element, keep_extra?: boolean): void;