@ogygia/core 0.0.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +180 -0
  49. package/dist/compiler/ctx.js +183 -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,36 @@
1
+ // src/compiler/macros/dedent.ts
2
+ const CRLF_G = /\r\n?/g;
3
+ const LEADING_INDENT_RE = /^[\t ]*/;
4
+ /**
5
+ * Strip the common leading indentation from a block of source, and trim leading/trailing blank
6
+ * lines. Source embedded in a call (`import.meta.og.code(\`…\`, …)`) is indented to match where the
7
+ * call sits; that indentation is an artifact of the surrounding code, not part of the snippet. This
8
+ * normalizes it so the rendered `<pre>` shows the snippet's OWN logical indentation, flush-left.
9
+ *
10
+ * Blank lines (whitespace-only) don't count toward the common indent; tabs and spaces are treated by
11
+ * their literal column contribution to the prefix (the common prefix is computed on raw characters,
12
+ * so mixed tabs/spaces still de-indent correctly as long as the leading run is consistent — which it
13
+ * is for machine-indented source).
14
+ */
15
+ function dedent(text) {
16
+ const lines = text.replace(CRLF_G, "\n").split("\n");
17
+ while (lines.length && lines[0].trim() === "") lines.shift();
18
+ while (lines.length && lines[lines.length - 1].trim() === "") lines.pop();
19
+ if (!lines.length) return "";
20
+ let common = null;
21
+ for (const line of lines) {
22
+ if (line.trim() === "") continue;
23
+ const lead = LEADING_INDENT_RE.exec(line)[0];
24
+ if (common === null) common = lead;
25
+ else {
26
+ let i = 0;
27
+ const max = Math.min(common.length, lead.length);
28
+ while (i < max && common[i] === lead[i]) i++;
29
+ common = common.slice(0, i);
30
+ }
31
+ if (common === "") break;
32
+ }
33
+ const n = common?.length ?? 0;
34
+ return lines.map((line) => line.trim() === "" ? "" : line.slice(n)).join("\n");
35
+ }
36
+ export { dedent };
@@ -0,0 +1,15 @@
1
+ /** One hoisted factory, destined for the fn manifest. `factory_src` is self-contained. */
2
+ export interface DollarHoist {
3
+ tag: string;
4
+ factory_src: string;
5
+ }
6
+ export interface DollarResult {
7
+ code: string;
8
+ hoists: DollarHoist[];
9
+ }
10
+ /**
11
+ * Rewrite every `import.meta.og.$` mark in `src`. Returns the input (same reference, empty
12
+ * hoists) when there is nothing to do. Throws build-error voice on misuse. `rel_id` is the
13
+ * root-relative module path used for tags; `markup_exts` as in og-wire (['.svelte']).
14
+ */
15
+ export declare function rewrite_dollar(src: string, id: string, rel_id: string, markup_exts: readonly string[]): DollarResult;
@@ -0,0 +1,387 @@
1
+ import { match_close, og_js_regions } from "../parse/scan.js";
2
+ import { parse_module } from "../parse/oxc.js";
3
+ import { og_member } from "./wire.js";
4
+ // src/compiler/macros/dollar.ts
5
+ /**
6
+ * `import.meta.og.$()` — the boundary mark for FUNCTIONS, as a compile construct.
7
+ *
8
+ * A closure can't serialize; what can is a handle: WHERE the code lives + WHAT it captured.
9
+ * The construct does the split at build time:
10
+ *
11
+ * setContext('fmt', import.meta.og.$((n) => `€${(n * (1 + tax)).toFixed(2)}`));
12
+ * ↓
13
+ * setContext('fmt', __og_$('src/routes/+layout.svelte#$0', [tax],
14
+ * (tax) => ((n) => `€${(n * (1 + tax)).toFixed(2)}`)));
15
+ *
16
+ * `__og_$` (runtime, fn-transport.ts) registers the factory under the tag and returns the LIVE
17
+ * bound function — the host renders with a real closure; if it crosses a boundary, the fn kind
18
+ * ships `{t: tag, d: bound}` and the far side rebinds. The factory is SELF-CONTAINED by
19
+ * construction (see capture law), so the same factory text is also collected for the
20
+ * `virtual:ogygia/fn-manifest` module the client runtime imports — every factory registers
21
+ * before any island hydrates, and calls stay synchronous.
22
+ *
23
+ * CAPTURE LAW (v1): a free identifier inside the marked function becomes a BOUND PARAMETER —
24
+ * its VALUE crosses as data (same law as island props; the boundary classifier judges it at
25
+ * the seam). Recognized globals (console, Math, JSON, fetch, …) pass through untouched.
26
+ * Because every non-global free name is bound, the factory references NOTHING from its module
27
+ * — which is what makes hoisting it into the manifest a pure text move. A capture that is a
28
+ * module IMPORT therefore crosses by VALUE too; if that value can't serialize (a function),
29
+ * the boundary errors at the seam with the path — move that dependency inside the marked fn
30
+ * (import it there via a bound serializable, or use a store/wire capture for live state).
31
+ *
32
+ * STRICT BY CONSTRUCTION (og-wire's playbook): the construct is legal in exactly ONE shape —
33
+ * a direct call `import.meta.og.$(<inline function expression>)`. Bare access, aliasing,
34
+ * zero/multiple arguments, or a non-function argument are BUILD ERRORS naming file:line.
35
+ * Detection is AST-precise over the module's JS regions; no scanner fallback — a mid-edit
36
+ * unparseable file simply doesn't transform (the marker then fails at runtime loudly, since
37
+ * `import.meta.og` is undefined without the transform).
38
+ */
39
+ const SERVER_MODULE_RE = /\.server(\.|$|\/)/;
40
+ const IDENT_CHAR_RE = /[A-Za-z0-9_$.]/;
41
+ const WS_RE = /\s/;
42
+ const MARKER = "import.meta.og.$";
43
+ /** Globals a hoisted factory may reference without binding (never captured). */
44
+ const KNOWN_GLOBALS = /* @__PURE__ */ new Set([
45
+ "undefined",
46
+ "null",
47
+ "true",
48
+ "false",
49
+ "NaN",
50
+ "Infinity",
51
+ "globalThis",
52
+ "console",
53
+ "Math",
54
+ "JSON",
55
+ "Date",
56
+ "RegExp",
57
+ "Error",
58
+ "TypeError",
59
+ "RangeError",
60
+ "Object",
61
+ "Array",
62
+ "String",
63
+ "Number",
64
+ "Boolean",
65
+ "Symbol",
66
+ "BigInt",
67
+ "Map",
68
+ "Set",
69
+ "WeakMap",
70
+ "WeakSet",
71
+ "Promise",
72
+ "Proxy",
73
+ "Reflect",
74
+ "ArrayBuffer",
75
+ "Uint8Array",
76
+ "TextEncoder",
77
+ "TextDecoder",
78
+ "URL",
79
+ "URLSearchParams",
80
+ "fetch",
81
+ "Request",
82
+ "Response",
83
+ "Headers",
84
+ "FormData",
85
+ "AbortController",
86
+ "structuredClone",
87
+ "queueMicrotask",
88
+ "setTimeout",
89
+ "clearTimeout",
90
+ "setInterval",
91
+ "clearInterval",
92
+ "crypto",
93
+ "performance",
94
+ "atob",
95
+ "btoa",
96
+ "isNaN",
97
+ "isFinite",
98
+ "parseInt",
99
+ "parseFloat",
100
+ "encodeURIComponent",
101
+ "decodeURIComponent",
102
+ "window",
103
+ "document",
104
+ "navigator",
105
+ "location",
106
+ "arguments"
107
+ ]);
108
+ function walk(node, visit, parent = null) {
109
+ visit(node, parent);
110
+ for (const key in node) {
111
+ if (key === "type" || key === "start" || key === "end") continue;
112
+ const child = node[key];
113
+ if (Array.isArray(child)) {
114
+ for (const c of child) if (c && typeof c === "object" && typeof c.type === "string") walk(c, visit, node);
115
+ } else if (child && typeof child === "object" && typeof child.type === "string") walk(child, visit, node);
116
+ }
117
+ }
118
+ function line_of(src, offset) {
119
+ let line = 1;
120
+ for (let i = 0; i < offset && i < src.length; i++) if (src[i] === "\n") line++;
121
+ return line;
122
+ }
123
+ function misuse(id, src, offset, what) {
124
+ throw new Error(`[ogygia] ${id}:${line_of(src, offset)} — ${what}. import.meta.og.$ is legal in exactly one shape: a direct call wrapping an inline function — import.meta.og.$((args) => { … }). It hoists that function so its VALUE can cross an island boundary as a handle.`);
125
+ }
126
+ /** Names DECLARED anywhere inside `fn` (params, vars, inner fns, catch, destructuring). */
127
+ function declared_names(fn) {
128
+ const out = /* @__PURE__ */ new Set();
129
+ const collect_pattern = (p) => {
130
+ if (!p) return;
131
+ switch (p.type) {
132
+ case "Identifier":
133
+ out.add(p.name);
134
+ break;
135
+ case "ObjectPattern":
136
+ for (const prop of p.properties ?? []) collect_pattern(prop.value ?? prop.argument);
137
+ break;
138
+ case "ArrayPattern":
139
+ for (const el of p.elements ?? []) collect_pattern(el);
140
+ break;
141
+ case "AssignmentPattern":
142
+ collect_pattern(p.left);
143
+ break;
144
+ case "RestElement": collect_pattern(p.argument);
145
+ }
146
+ };
147
+ walk(fn, (n) => {
148
+ if (n.type === "VariableDeclarator") collect_pattern(n.id);
149
+ else if (n.type === "FunctionDeclaration" || n.type === "ClassDeclaration") {
150
+ if (n.id?.name) out.add(n.id.name);
151
+ } else if (n.type === "CatchClause") collect_pattern(n.param);
152
+ else if (n.type === "FunctionExpression" || n.type === "ArrowFunctionExpression" || n.type === "FunctionDeclaration") {
153
+ for (const p of n.params ?? []) collect_pattern(p);
154
+ if (n.id?.name) out.add(n.id.name);
155
+ }
156
+ });
157
+ for (const p of fn.params ?? []) collect_pattern(p);
158
+ return out;
159
+ }
160
+ /** Free identifiers of `fn`: referenced, not declared inside, not a known global. Source order. */
161
+ function free_names(fn) {
162
+ const declared = declared_names(fn);
163
+ const seen = /* @__PURE__ */ new Set();
164
+ const out = [];
165
+ walk(fn, (n, parent) => {
166
+ if (n.type !== "Identifier") return;
167
+ const name = n.name;
168
+ if (declared.has(name) || KNOWN_GLOBALS.has(name) || seen.has(name)) return;
169
+ if (parent) {
170
+ const pt = parent.type;
171
+ if (pt.startsWith("TS")) return;
172
+ if (pt === "MemberExpression" && parent.property === n && !parent.computed) return;
173
+ if ((pt === "Property" || pt === "ObjectProperty") && parent.key === n && !parent.shorthand) return;
174
+ if (pt === "LabeledStatement" || pt === "BreakStatement" || pt === "ContinueStatement") return;
175
+ }
176
+ seen.add(name);
177
+ out.push(name);
178
+ });
179
+ return out;
180
+ }
181
+ /**
182
+ * The moved factory text is a RAW source slice, so in a `<script lang="ts">` (or `.ts`) file it still
183
+ * carries TS type annotations — and it lands in a PLAIN-JS registration script (`data-ogygia-fnm`) +
184
+ * the fn-manifest module. `(n: number) => …` there is a syntax error. Blank every TS-only span inside
185
+ * `fn` (type annotations, generics, `as`/`satisfies`/`!`) with spaces — length-preserving, so the
186
+ * captured-name offsets and the surrounding slice stay valid. This is the same technique as
187
+ * ts-blank-space, scoped to the one hoisted function.
188
+ */
189
+ function strip_ts_types(fn, region_code) {
190
+ const base = fn.start;
191
+ const chars = region_code.slice(base, fn.end).split("");
192
+ const blank = (s, e) => {
193
+ for (let i = s - base; i < e - base; i++) if (i >= 0 && i < chars.length) chars[i] = " ";
194
+ };
195
+ walk(fn, (n) => {
196
+ const t = n.type;
197
+ if (t === "TSTypeAnnotation" || t === "TSTypeParameterDeclaration" || t === "TSTypeParameterInstantiation") blank(n.start, n.end);
198
+ else if (t === "TSAsExpression" || t === "TSSatisfiesExpression" || t === "TSNonNullExpression" || t === "TSInstantiationExpression") {
199
+ const expr = n.expression;
200
+ if (expr) blank(expr.end, n.end);
201
+ }
202
+ });
203
+ return chars.join("");
204
+ }
205
+ /**
206
+ * Rewrite every `import.meta.og.$` mark in `src`. Returns the input (same reference, empty
207
+ * hoists) when there is nothing to do. Throws build-error voice on misuse. `rel_id` is the
208
+ * root-relative module path used for tags; `markup_exts` as in og-wire (['.svelte']).
209
+ */
210
+ function rewrite_dollar(src, id, rel_id, markup_exts) {
211
+ if (!src.includes(MARKER)) return {
212
+ code: src,
213
+ hoists: []
214
+ };
215
+ const regions = og_js_regions(src, id, markup_exts);
216
+ if (!regions) return {
217
+ code: src,
218
+ hoists: []
219
+ };
220
+ const edits = [];
221
+ const hoists = [];
222
+ let seq = 0;
223
+ let needs_import = false;
224
+ let needs_boundary_import = false;
225
+ for (const region of regions) {
226
+ const { program, ok } = parse_module(region.code, id.endsWith(".svelte") ? id + ".ts" : id);
227
+ if (!ok || !program) continue;
228
+ const server_only = /* @__PURE__ */ new Map();
229
+ for (const node of program.body ?? []) {
230
+ if (node.type !== "ImportDeclaration") continue;
231
+ const src_val = node.source?.value;
232
+ if (!src_val) continue;
233
+ if (!(src_val === "$app/server" || src_val.startsWith("$env/static/private") || src_val.startsWith("$env/dynamic/private") || SERVER_MODULE_RE.test(src_val))) continue;
234
+ for (const sp of node.specifiers ?? []) if (sp.local?.name) server_only.set(sp.local.name, src_val);
235
+ }
236
+ const claimed = /* @__PURE__ */ new Set();
237
+ walk(program, (n) => {
238
+ if (n.type === "CallExpression" && og_member(n.callee) === "$") {
239
+ const abs = region.offset + n.start;
240
+ const args = n.arguments;
241
+ if (!args || args.length !== 1) misuse(id, src, abs, `$() takes exactly one argument — the function to hoist`);
242
+ const fn = args[0];
243
+ if (fn.type !== "ArrowFunctionExpression" && fn.type !== "FunctionExpression") {
244
+ claimed.add(n);
245
+ claimed.add(n.callee);
246
+ const expr_text = strip_ts_types(fn, region.code);
247
+ const site = `${rel_id}:${line_of(src, abs)}`;
248
+ needs_boundary_import = true;
249
+ edits.push({
250
+ start: abs,
251
+ end: region.offset + n.end,
252
+ text: `__og_boundary((${expr_text}), ${JSON.stringify(site)})`
253
+ });
254
+ return;
255
+ }
256
+ claimed.add(n);
257
+ claimed.add(n.callee);
258
+ const captures = free_names(fn);
259
+ for (const c of captures) {
260
+ const from = server_only.get(c);
261
+ if (from) misuse(id, src, abs, `$() captures \`${c}\` from the server-only module '${from}' — its value would ship into client HTML. Do the server work in a remote function and capture ITS result, or pass a derived, non-secret value instead`);
262
+ }
263
+ const fn_text = strip_ts_types(fn, region.code);
264
+ const tag = `${rel_id}#$${seq++}`;
265
+ const factory = `(${captures.join(", ")}) => (${fn_text})`;
266
+ hoists.push({
267
+ tag,
268
+ factory_src: factory
269
+ });
270
+ needs_import = true;
271
+ edits.push({
272
+ start: abs,
273
+ end: region.offset + n.end,
274
+ text: `__og_$(${JSON.stringify(tag)}, [${captures.join(", ")}], ${factory})`
275
+ });
276
+ return;
277
+ }
278
+ if (og_member(n) === "$" && !claimed.has(n)) misuse(id, src, region.offset + n.start, `bare import.meta.og.$ used as a value`);
279
+ });
280
+ if ((needs_import || needs_boundary_import) && !edits.some((e) => e.text.startsWith("import"))) {
281
+ const names = [needs_import ? "__og_$" : "", needs_boundary_import ? "__og_boundary" : ""].filter(Boolean).join(", ");
282
+ edits.push({
283
+ start: region.offset,
284
+ end: region.offset,
285
+ text: `import { ${names} } from 'ogygia/internal';`
286
+ });
287
+ needs_import = false;
288
+ needs_boundary_import = false;
289
+ }
290
+ }
291
+ const in_region = (pos) => regions.some((r) => pos >= r.offset && pos < r.offset + r.code.length);
292
+ const template_calls = [];
293
+ {
294
+ const M = "import.meta.og.$";
295
+ let at = -1;
296
+ while ((at = src.indexOf(M, at + 1)) !== -1) {
297
+ if (in_region(at)) continue;
298
+ const after = at + 16;
299
+ if (IDENT_CHAR_RE.test(src[after] ?? "")) continue;
300
+ let open = after;
301
+ while (open < src.length && WS_RE.test(src[open])) open++;
302
+ if (src[open] !== "(") continue;
303
+ let before = at - 1;
304
+ while (before >= 0 && WS_RE.test(src[before])) before--;
305
+ if (src[before] !== "{" && src[before] !== "(") continue;
306
+ const close = match_close(src, open);
307
+ if (close < 0) continue;
308
+ template_calls.push({
309
+ start: at,
310
+ end: close + 1,
311
+ args: src.slice(open + 1, close)
312
+ });
313
+ at = close;
314
+ }
315
+ }
316
+ let template_needs = null;
317
+ for (const call of template_calls) {
318
+ const arg_text = call.args.trim();
319
+ if (!arg_text) misuse(id, src, call.start, `$() takes exactly one argument`);
320
+ const wrapped = `(${arg_text})`;
321
+ const { program, ok } = parse_module(wrapped, id.endsWith(".svelte") ? id + ".expr.ts" : id);
322
+ if (!ok || !program) misuse(id, src, call.start, `$()'s argument does not parse as an expression`);
323
+ let expr = (program.body?.[0] ?? {}).expression ?? {};
324
+ while (expr.type === "ParenthesizedExpression") expr = expr.expression;
325
+ const expr_text = strip_ts_types(expr, wrapped);
326
+ if (expr.type === "ArrowFunctionExpression" || expr.type === "FunctionExpression") {
327
+ const captures = free_names(expr);
328
+ const tag = `${rel_id}#$${seq++}`;
329
+ const factory = `(${captures.join(", ")}) => (${expr_text})`;
330
+ hoists.push({
331
+ tag,
332
+ factory_src: factory
333
+ });
334
+ (template_needs ??= {
335
+ fn: false,
336
+ boundary: false
337
+ }).fn = true;
338
+ edits.push({
339
+ start: call.start,
340
+ end: call.end,
341
+ text: `__og_$(${JSON.stringify(tag)}, [${captures.join(", ")}], ${factory})`
342
+ });
343
+ } else {
344
+ const site = `${rel_id}:${line_of(src, call.start)}`;
345
+ (template_needs ??= {
346
+ fn: false,
347
+ boundary: false
348
+ }).boundary = true;
349
+ edits.push({
350
+ start: call.start,
351
+ end: call.end,
352
+ text: `__og_boundary((${expr_text}), ${JSON.stringify(site)})`
353
+ });
354
+ }
355
+ }
356
+ if (template_needs) {
357
+ const first = regions[0];
358
+ if (!first) misuse(id, src, 0, `og.$ in markup needs a <script> block to receive its runtime import`);
359
+ const names = [template_needs.fn ? "__og_$" : "", template_needs.boundary ? "__og_boundary" : ""].filter(Boolean).join(", ");
360
+ const existing = edits.find((e) => e.start === first.offset && e.text.startsWith("import { "));
361
+ if (existing) {
362
+ const have = existing.text.slice(9, existing.text.indexOf(" }"));
363
+ existing.text = `import { ${[.../* @__PURE__ */ new Set([...have.split(", "), ...names.split(", ")])].filter(Boolean).join(", ")} } from 'ogygia/internal';`;
364
+ } else edits.push({
365
+ start: first.offset,
366
+ end: first.offset,
367
+ text: `import { ${names} } from 'ogygia/internal';`
368
+ });
369
+ }
370
+ if (!edits.length) return {
371
+ code: src,
372
+ hoists: []
373
+ };
374
+ edits.sort((a, b) => a.start - b.start);
375
+ let out = "";
376
+ let last = 0;
377
+ for (const e of edits) {
378
+ out += src.slice(last, e.start) + e.text;
379
+ last = e.end;
380
+ }
381
+ out += src.slice(last);
382
+ return {
383
+ code: out,
384
+ hoists
385
+ };
386
+ }
387
+ export { rewrite_dollar };
@@ -0,0 +1,31 @@
1
+ import { Profiler } from "../driver.js";
2
+ /** A plugin's `import.meta.og.<name>` macro (registered with `b.macro`). */
3
+ export interface PluginMacro {
4
+ name: string;
5
+ handler: (code: string, m: {
6
+ id: string;
7
+ rel: string;
8
+ root: string;
9
+ markupExts: readonly string[];
10
+ }) => string | Promise<string>;
11
+ }
12
+ export interface MacroPipelineCtx {
13
+ root: string;
14
+ /** Resolved Vite aliases the `bake` pass hands to its mini-bundler. */
15
+ resolveAlias: unknown[];
16
+ /** ogygia's own package root — auto-brand skips ogygia source. */
17
+ pkgRoot: string;
18
+ /** Filled with every `import.meta.og.$` hoist (tag → factory source) for the fn-manifest emit. */
19
+ dollarHoists: Map<string, string>;
20
+ /** The plugins' macros, in plugin order (after core's, before `bake`). */
21
+ macros?: readonly PluginMacro[];
22
+ }
23
+ /**
24
+ * Run the ordered macro passes over one module. `source` is the CURRENT text (a content-preset tag
25
+ * or an earlier pass may already have edited it upstream) — never the raw file — because each pass
26
+ * feeds the next. Returns the rewritten code and whether anything changed.
27
+ */
28
+ export declare function run_module_macros(source: string, id: string, ctx: MacroPipelineCtx, profiler: Profiler): Promise<{
29
+ code: string;
30
+ touched: boolean;
31
+ }>;
@@ -0,0 +1,106 @@
1
+ import { path } from "../host.js";
2
+ import { rewrite_wire } from "./wire.js";
3
+ import { rewrite_dollar } from "./dollar.js";
4
+ import { rewrite_source } from "./source.js";
5
+ import { auto_brand_stores, rewrite_store } from "./store.js";
6
+ // src/compiler/macros/pipeline.ts
7
+ /**
8
+ * The module-macro pipeline — the ordered `import.meta.og.*` passes that run BEFORE either branch
9
+ * (island transform / svelte compile / ts-region minting) sees a module: `wire`, `$`, `store`,
10
+ * auto-branding, `code`/`md`, and `bake`. Each pass is a no-op unless its exact marker is present, is
11
+ * extension-aware, and (where it matters) AST-precise. Pulled out of the Vite adapter so the whole
12
+ * macro leg is one call (`Compiler.macros`) the driver owns — a REPL runs the same passes with no Vite
13
+ * in sight. Pure over `(source, id, ctx)` apart from the `dollarHoists` map it fills and the profiler
14
+ * timing it records; returns `{ code, touched }` (the caller invalidates its own sourcemap on touch).
15
+ */
16
+ const performance = globalThis.performance;
17
+ const EXPORT_CONST_RE = /export\s+const/;
18
+ const CONSTRUCT_MARKUP_EXTS = [".svelte"];
19
+ /**
20
+ * Run the ordered macro passes over one module. `source` is the CURRENT text (a content-preset tag
21
+ * or an earlier pass may already have edited it upstream) — never the raw file — because each pass
22
+ * feeds the next. Returns the rewritten code and whether anything changed.
23
+ */
24
+ async function run_module_macros(source, id, ctx, profiler) {
25
+ let out = source;
26
+ let touched = false;
27
+ if (out.includes("import.meta.og.wire")) {
28
+ const rewritten = rewrite_wire(out, id, CONSTRUCT_MARKUP_EXTS);
29
+ if (rewritten !== out) {
30
+ out = rewritten;
31
+ touched = true;
32
+ }
33
+ }
34
+ if (out.includes("import.meta.og.$")) {
35
+ const rel_dollar = path.relative(ctx.root, id.split("?")[0]).split(path.sep).join("/");
36
+ const res = rewrite_dollar(out, id, rel_dollar, CONSTRUCT_MARKUP_EXTS);
37
+ if (res.code !== out) {
38
+ out = res.code;
39
+ touched = true;
40
+ for (const h of res.hoists) ctx.dollarHoists.set(h.tag, h.factory_src);
41
+ }
42
+ }
43
+ if (out.includes("import.meta.og.source")) {
44
+ const rel_source = path.relative(ctx.root, id.split("?")[0]).split(path.sep).join("/");
45
+ const rewritten = rewrite_source(out, id, rel_source, CONSTRUCT_MARKUP_EXTS);
46
+ if (rewritten !== out) {
47
+ out = rewritten;
48
+ touched = true;
49
+ }
50
+ }
51
+ if (out.includes("import.meta.og.store")) {
52
+ const rel_store = path.relative(ctx.root, id.split("?")[0]).split(path.sep).join("/");
53
+ const rewritten = rewrite_store(out, id, rel_store, CONSTRUCT_MARKUP_EXTS);
54
+ if (rewritten !== out) {
55
+ out = rewritten;
56
+ touched = true;
57
+ }
58
+ }
59
+ if (!id.includes("node_modules") && !id.startsWith(ctx.pkgRoot) && EXPORT_CONST_RE.test(out)) {
60
+ const rel_auto = path.relative(ctx.root, id.split("?")[0]).split(path.sep).join("/");
61
+ const branded = auto_brand_stores(out, id, rel_auto, CONSTRUCT_MARKUP_EXTS);
62
+ if (branded !== out) {
63
+ out = branded;
64
+ touched = true;
65
+ }
66
+ }
67
+ if (ctx.macros?.length) {
68
+ let rel;
69
+ for (const macro of ctx.macros) {
70
+ if (!out.includes("import.meta.og." + macro.name)) continue;
71
+ rel ??= path.relative(ctx.root, id.split("?")[0]).split(path.sep).join("/");
72
+ const rewritten = await macro.handler(out, {
73
+ id: id.split("?")[0],
74
+ rel,
75
+ root: ctx.root,
76
+ markupExts: CONSTRUCT_MARKUP_EXTS
77
+ });
78
+ if (rewritten !== out) {
79
+ out = rewritten;
80
+ touched = true;
81
+ }
82
+ }
83
+ }
84
+ if (out.includes("import.meta.og.bake")) {
85
+ const __bk = profiler.P ? performance.now() : 0;
86
+ const { rewrite_bake } = await import("./bake.js");
87
+ const rewritten = await rewrite_bake(out, id, {
88
+ alias: ctx.resolveAlias,
89
+ root: ctx.root,
90
+ markupExts: CONSTRUCT_MARKUP_EXTS
91
+ });
92
+ if (rewritten !== out) {
93
+ out = rewritten;
94
+ touched = true;
95
+ }
96
+ if (profiler.P) {
97
+ profiler.prof.bakeMs += performance.now() - __bk;
98
+ profiler.prof.bakeN++;
99
+ }
100
+ }
101
+ return {
102
+ code: out,
103
+ touched
104
+ };
105
+ }
106
+ export { run_module_macros };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Rewrite every source mark in `src` (strict position rules), injecting the runtime-wrapper
3
+ * import once. `rel` is the module's root-relative posix path (the id rail). Returns the input
4
+ * unchanged (same reference) when there is nothing to do.
5
+ */
6
+ export declare function rewrite_source(src: string, id: string, rel: string, markup_exts: readonly string[]): string;