@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.
- package/LICENSE +21 -0
- package/README.md +7 -1
- package/ambient.d.ts +194 -0
- package/dist/ClientBindingStub.svelte +6 -0
- package/dist/ClientBindingStub.svelte.d.ts +26 -0
- package/dist/KeepHost.svelte +19 -0
- package/dist/KeepHost.svelte.d.ts +10 -0
- package/dist/LakeBoundary.svelte +16 -0
- package/dist/LakeBoundary.svelte.d.ts +11 -0
- package/dist/LateIsland.svelte +22 -0
- package/dist/LateIsland.svelte.d.ts +15 -0
- package/dist/LateIslandAwait.svelte +17 -0
- package/dist/LateIslandAwait.svelte.d.ts +15 -0
- package/dist/LiveHost.svelte +19 -0
- package/dist/LiveHost.svelte.d.ts +10 -0
- package/dist/NestedProvider.svelte +13 -0
- package/dist/NestedProvider.svelte.d.ts +8 -0
- package/dist/OgygiaBoundary.svelte +5 -0
- package/dist/OgygiaBoundary.svelte.d.ts +17 -0
- package/dist/PromiseRegion.svelte +40 -0
- package/dist/PromiseRegion.svelte.d.ts +15 -0
- package/dist/PromiseRegionAwait.svelte +27 -0
- package/dist/PromiseRegionAwait.svelte.d.ts +15 -0
- package/dist/Provide.svelte +27 -0
- package/dist/Provide.svelte.d.ts +8 -0
- package/dist/RawHtml.svelte +9 -0
- package/dist/RawHtml.svelte.d.ts +6 -0
- package/dist/Region.svelte +1173 -0
- package/dist/Region.svelte.d.ts +68 -0
- package/dist/SlotBoundary.svelte +13 -0
- package/dist/SlotBoundary.svelte.d.ts +7 -0
- package/dist/app.d.ts +4 -0
- package/dist/app.js +3 -0
- package/dist/boundary.d.ts +35 -0
- package/dist/boundary.js +127 -0
- package/dist/build-cache.d.ts +13 -0
- package/dist/build-cache.js +77 -0
- package/dist/compiler/blank-styles.d.ts +1 -0
- package/dist/compiler/blank-styles.js +63 -0
- package/dist/compiler/bom.d.ts +2 -0
- package/dist/compiler/bom.js +15 -0
- package/dist/compiler/browser-full.d.ts +8 -0
- package/dist/compiler/browser-full.js +8 -0
- package/dist/compiler/browser.d.ts +11 -0
- package/dist/compiler/browser.js +11 -0
- package/dist/compiler/content/transportables.d.ts +26 -0
- package/dist/compiler/content/transportables.js +219 -0
- package/dist/compiler/ctx.d.ts +185 -0
- package/dist/compiler/ctx.js +203 -0
- package/dist/compiler/debarrel/barrel.d.ts +55 -0
- package/dist/compiler/debarrel/barrel.js +248 -0
- package/dist/compiler/debarrel/options.d.ts +67 -0
- package/dist/compiler/debarrel/options.js +31 -0
- package/dist/compiler/debarrel/parse.d.ts +65 -0
- package/dist/compiler/debarrel/parse.js +256 -0
- package/dist/compiler/debarrel/plugin.d.ts +31 -0
- package/dist/compiler/debarrel/plugin.js +190 -0
- package/dist/compiler/debarrel/rewrite.d.ts +27 -0
- package/dist/compiler/debarrel/rewrite.js +118 -0
- package/dist/compiler/debarrel/svelte.d.ts +13 -0
- package/dist/compiler/debarrel/svelte.js +56 -0
- package/dist/compiler/dev/css-scope.d.ts +16 -0
- package/dist/compiler/dev/css-scope.js +38 -0
- package/dist/compiler/dev/dev-hmr.d.ts +25 -0
- package/dist/compiler/dev/dev-hmr.js +29 -0
- package/dist/compiler/dev/hmr.d.ts +34 -0
- package/dist/compiler/dev/hmr.js +57 -0
- package/dist/compiler/dev/region-bytes.d.ts +34 -0
- package/dist/compiler/dev/region-bytes.js +126 -0
- package/dist/compiler/driver.d.ts +280 -0
- package/dist/compiler/driver.js +1352 -0
- package/dist/compiler/flags.d.ts +16 -0
- package/dist/compiler/flags.js +101 -0
- package/dist/compiler/fouc-css.d.ts +97 -0
- package/dist/compiler/fouc-css.js +335 -0
- package/dist/compiler/free-vars.d.ts +20 -0
- package/dist/compiler/free-vars.js +327 -0
- package/dist/compiler/host.d.ts +65 -0
- package/dist/compiler/host.js +51 -0
- package/dist/compiler/ids.d.ts +84 -0
- package/dist/compiler/ids.js +86 -0
- package/dist/compiler/index.d.ts +11 -0
- package/dist/compiler/index.js +11 -0
- package/dist/compiler/kit.d.ts +129 -0
- package/dist/compiler/kit.js +563 -0
- package/dist/compiler/link/build-output.d.ts +44 -0
- package/dist/compiler/link/build-output.js +147 -0
- package/dist/compiler/link/caps.d.ts +48 -0
- package/dist/compiler/link/caps.js +64 -0
- package/dist/compiler/link/context-detect.d.ts +23 -0
- package/dist/compiler/link/context-detect.js +137 -0
- package/dist/compiler/link/emit-gate.d.ts +11 -0
- package/dist/compiler/link/emit-gate.js +40 -0
- package/dist/compiler/link/entry-shim.d.ts +4 -0
- package/dist/compiler/link/entry-shim.js +29 -0
- package/dist/compiler/link/island-deps.d.ts +142 -0
- package/dist/compiler/link/island-deps.js +525 -0
- package/dist/compiler/link/manifest.d.ts +5 -0
- package/dist/compiler/link/manifest.js +9 -0
- package/dist/compiler/link/page-keys.d.ts +64 -0
- package/dist/compiler/link/page-keys.js +683 -0
- package/dist/compiler/link/registry-stub.d.ts +41 -0
- package/dist/compiler/link/registry-stub.js +212 -0
- package/dist/compiler/link/router-config.d.ts +11 -0
- package/dist/compiler/link/router-config.js +15 -0
- package/dist/compiler/link/router-css.d.ts +22 -0
- package/dist/compiler/link/router-css.js +142 -0
- package/dist/compiler/link/runtime-entry.d.ts +71 -0
- package/dist/compiler/link/runtime-entry.js +132 -0
- package/dist/compiler/link/server-manifest.d.ts +12 -0
- package/dist/compiler/link/server-manifest.js +45 -0
- package/dist/compiler/link/speculation.d.ts +17 -0
- package/dist/compiler/link/speculation.js +36 -0
- package/dist/compiler/link/transport.d.ts +31 -0
- package/dist/compiler/link/transport.js +67 -0
- package/dist/compiler/macros/bake.d.ts +20 -0
- package/dist/compiler/macros/bake.js +317 -0
- package/dist/compiler/macros/browser.d.ts +11 -0
- package/dist/compiler/macros/browser.js +69 -0
- package/dist/compiler/macros/dedent.d.ts +12 -0
- package/dist/compiler/macros/dedent.js +36 -0
- package/dist/compiler/macros/dollar.d.ts +15 -0
- package/dist/compiler/macros/dollar.js +387 -0
- package/dist/compiler/macros/pipeline.d.ts +31 -0
- package/dist/compiler/macros/pipeline.js +106 -0
- package/dist/compiler/macros/source.d.ts +6 -0
- package/dist/compiler/macros/source.js +127 -0
- package/dist/compiler/macros/store.d.ts +17 -0
- package/dist/compiler/macros/store.js +244 -0
- package/dist/compiler/macros/wire.d.ts +14 -0
- package/dist/compiler/macros/wire.js +160 -0
- package/dist/compiler/ownership-stamps.d.ts +6 -0
- package/dist/compiler/ownership-stamps.js +144 -0
- package/dist/compiler/parse/oxc.d.ts +34 -0
- package/dist/compiler/parse/oxc.js +59 -0
- package/dist/compiler/parse/scan.d.ts +43 -0
- package/dist/compiler/parse/scan.js +232 -0
- package/dist/compiler/program.d.ts +140 -0
- package/dist/compiler/program.js +242 -0
- package/dist/compiler/region/emit.d.ts +169 -0
- package/dist/compiler/region/emit.js +286 -0
- package/dist/compiler/region/identity.d.ts +28 -0
- package/dist/compiler/region/identity.js +75 -0
- package/dist/compiler/region/ir.d.ts +65 -0
- package/dist/compiler/region/ir.js +0 -0
- package/dist/compiler/region/transform.d.ts +178 -0
- package/dist/compiler/region/transform.js +1933 -0
- package/dist/compiler/script-request.d.ts +1 -0
- package/dist/compiler/script-request.js +43 -0
- package/dist/context-bridge.d.ts +65 -0
- package/dist/context-bridge.js +217 -0
- package/dist/context-registry.d.ts +40 -0
- package/dist/context-registry.js +15 -0
- package/dist/context.d.ts +72 -0
- package/dist/context.js +158 -0
- package/dist/current-region.d.ts +14 -0
- package/dist/current-region.js +36 -0
- package/dist/document.d.ts +41 -0
- package/dist/document.js +125 -0
- package/dist/entry-hydrate.d.ts +5 -0
- package/dist/entry-hydrate.js +42 -0
- package/dist/escape.d.ts +18 -0
- package/dist/escape.js +37 -0
- package/dist/events/bus.d.ts +33 -0
- package/dist/events/bus.js +153 -0
- package/dist/events/index.d.ts +4 -0
- package/dist/events/index.js +4 -0
- package/dist/events/schema.d.ts +389 -0
- package/dist/events/schema.js +23 -0
- package/dist/events/server-registry.d.ts +7 -0
- package/dist/events/server-registry.js +13 -0
- package/dist/events/sinks.d.ts +64 -0
- package/dist/events/sinks.js +85 -0
- package/dist/fn-transport.d.ts +33 -0
- package/dist/fn-transport.js +140 -0
- package/dist/frame.d.ts +20 -0
- package/dist/frame.js +19 -0
- package/dist/holes-record.d.ts +6 -0
- package/dist/holes-record.js +8 -0
- package/dist/hooks.d.ts +43 -0
- package/dist/hooks.js +1191 -0
- package/dist/hydration-info.d.ts +1 -0
- package/dist/hydration-info.js +31 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +17 -0
- package/dist/insights/attr-rules.d.ts +15 -0
- package/dist/insights/attr-rules.js +27 -0
- package/dist/insights/cpu.d.ts +82 -0
- package/dist/insights/cpu.js +177 -0
- package/dist/insights/fp-drift.d.ts +28 -0
- package/dist/insights/fp-drift.js +148 -0
- package/dist/insights/hole-segments.d.ts +26 -0
- package/dist/insights/hole-segments.js +50 -0
- package/dist/insights/html-diff.d.ts +25 -0
- package/dist/insights/html-diff.js +157 -0
- package/dist/insights/hydration-hazards.d.ts +36 -0
- package/dist/insights/hydration-hazards.js +136 -0
- package/dist/insights/hydration-status.d.ts +2 -0
- package/dist/insights/hydration-status.js +0 -0
- package/dist/insights/index.d.ts +14 -0
- package/dist/insights/index.js +12 -0
- package/dist/insights/page-assets.d.ts +211 -0
- package/dist/insights/page-assets.js +608 -0
- package/dist/insights/page-insights.d.ts +749 -0
- package/dist/insights/page-insights.js +2157 -0
- package/dist/insights/session-data.d.ts +108 -0
- package/dist/insights/session-data.js +0 -0
- package/dist/insights/session-insights.d.ts +121 -0
- package/dist/insights/session-insights.js +548 -0
- package/dist/insights/switch.d.ts +53 -0
- package/dist/insights/switch.js +91 -0
- package/dist/insights/testing-version.d.ts +19 -0
- package/dist/insights/testing-version.js +21 -0
- package/dist/insights/third-party.d.ts +75 -0
- package/dist/insights/third-party.js +160 -0
- package/dist/internal-instruments.d.ts +13 -0
- package/dist/internal-instruments.js +12 -0
- package/dist/internal-reconcile.d.ts +3 -0
- package/dist/internal-reconcile.js +3 -0
- package/dist/internal-register.d.ts +7 -0
- package/dist/internal-register.js +7 -0
- package/dist/internal-server.d.ts +7 -0
- package/dist/internal-server.js +7 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.js +13 -0
- package/dist/island-graph.d.ts +36 -0
- package/dist/island-graph.js +89 -0
- package/dist/keep-fallback-marker.d.ts +7 -0
- package/dist/keep-fallback-marker.js +9 -0
- package/dist/keep-fallback.d.ts +13 -0
- package/dist/keep-fallback.js +39 -0
- package/dist/kit-paths.d.ts +2 -0
- package/dist/kit-paths.js +39 -0
- package/dist/late-region-registry.d.ts +40 -0
- package/dist/late-region-registry.js +36 -0
- package/dist/live-transport.d.ts +57 -0
- package/dist/live-transport.js +145 -0
- package/dist/markup.d.ts +4 -0
- package/dist/markup.js +4 -0
- package/dist/own-package.d.ts +15 -0
- package/dist/own-package.js +20 -0
- package/dist/page-defer.d.ts +33 -0
- package/dist/page-defer.js +35 -0
- package/dist/page-facts-script.d.ts +7 -0
- package/dist/page-facts-script.js +9 -0
- package/dist/page-seed-registry.d.ts +72 -0
- package/dist/page-seed-registry.js +31 -0
- package/dist/plugin/capability.d.ts +14 -0
- package/dist/plugin/capability.js +44 -0
- package/dist/plugin/client.d.ts +39 -0
- package/dist/plugin/client.js +6 -0
- package/dist/plugin/css.d.ts +3 -0
- package/dist/plugin/css.js +54 -0
- package/dist/plugin/facts.d.ts +42 -0
- package/dist/plugin/facts.js +37 -0
- package/dist/plugin/hooks.d.ts +33 -0
- package/dist/plugin/hooks.js +38 -0
- package/dist/plugin/index.d.ts +127 -0
- package/dist/plugin/index.js +26 -0
- package/dist/plugin/routes.d.ts +32 -0
- package/dist/plugin/routes.js +35 -0
- package/dist/plugin/server.d.ts +27 -0
- package/dist/plugin/server.js +92 -0
- package/dist/plugin/standard-schema.d.ts +27 -0
- package/dist/plugin/standard-schema.js +0 -0
- package/dist/plugin/testing.d.ts +13 -0
- package/dist/plugin/testing.js +54 -0
- package/dist/plugin/utils.d.ts +13 -0
- package/dist/plugin/utils.js +19 -0
- package/dist/portable-form.d.ts +22 -0
- package/dist/portable-form.js +52 -0
- package/dist/preference.d.ts +35 -0
- package/dist/preference.js +84 -0
- package/dist/preload.d.ts +1 -0
- package/dist/preload.js +21 -0
- package/dist/ref-watch.d.ts +31 -0
- package/dist/ref-watch.js +66 -0
- package/dist/ref.d.ts +124 -0
- package/dist/ref.js +272 -0
- package/dist/region-brand.d.ts +8 -0
- package/dist/region-brand.js +10 -0
- package/dist/region-core.d.ts +2 -0
- package/dist/region-core.js +1 -0
- package/dist/region-snippet.d.ts +73 -0
- package/dist/region-snippet.js +351 -0
- package/dist/region.d.ts +127 -0
- package/dist/region.js +162 -0
- package/dist/request-event.d.ts +1 -0
- package/dist/request-event.js +37 -0
- package/dist/router-css.d.ts +39 -0
- package/dist/router-css.js +66 -0
- package/dist/runtime/app-transport.d.ts +2 -0
- package/dist/runtime/app-transport.js +13 -0
- package/dist/runtime/beacon.d.ts +271 -0
- package/dist/runtime/beacon.js +2190 -0
- package/dist/runtime/boot-link.d.ts +1 -0
- package/dist/runtime/boot-link.js +44 -0
- package/dist/runtime/client-hooks.d.ts +5 -0
- package/dist/runtime/client-hooks.js +22 -0
- package/dist/runtime/client-plugins.d.ts +8 -0
- package/dist/runtime/client-plugins.js +34 -0
- package/dist/runtime/concurrency.d.ts +12 -0
- package/dist/runtime/concurrency.js +29 -0
- package/dist/runtime/connected.d.ts +12 -0
- package/dist/runtime/connected.js +16 -0
- package/dist/runtime/context.d.ts +1 -0
- package/dist/runtime/context.js +19 -0
- package/dist/runtime/core.d.ts +15 -0
- package/dist/runtime/core.js +1173 -0
- package/dist/runtime/drift-watch.d.ts +9 -0
- package/dist/runtime/drift-watch.js +60 -0
- package/dist/runtime/entry-locations.d.ts +33 -0
- package/dist/runtime/entry-locations.js +119 -0
- package/dist/runtime/foreign-props.d.ts +8 -0
- package/dist/runtime/foreign-props.js +14 -0
- package/dist/runtime/form-continuity.d.ts +10 -0
- package/dist/runtime/form-continuity.js +107 -0
- package/dist/runtime/frame-nav.d.ts +36 -0
- package/dist/runtime/frame-nav.js +225 -0
- package/dist/runtime/frame-store.d.ts +62 -0
- package/dist/runtime/frame-store.js +214 -0
- package/dist/runtime/frames.d.ts +1 -0
- package/dist/runtime/frames.js +25 -0
- package/dist/runtime/full.d.ts +4 -0
- package/dist/runtime/full.js +32 -0
- package/dist/runtime/hash.d.ts +41 -0
- package/dist/runtime/hash.js +79 -0
- package/dist/runtime/hole-facts.d.ts +8 -0
- package/dist/runtime/hole-facts.js +57 -0
- package/dist/runtime/host-classes.d.ts +24 -0
- package/dist/runtime/host-classes.js +43 -0
- package/dist/runtime/hydrate-core.d.ts +101 -0
- package/dist/runtime/hydrate-core.js +605 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/interaction-replay.d.ts +11 -0
- package/dist/runtime/interaction-replay.js +70 -0
- package/dist/runtime/interaction.d.ts +33 -0
- package/dist/runtime/interaction.js +217 -0
- package/dist/runtime/island-graph-preload.d.ts +13 -0
- package/dist/runtime/island-graph-preload.js +99 -0
- package/dist/runtime/kit-boot.d.ts +29 -0
- package/dist/runtime/kit-boot.js +60 -0
- package/dist/runtime/kit-page-thread.svelte.d.ts +1 -0
- package/dist/runtime/kit-page-thread.svelte.js +116 -0
- package/dist/runtime/lake-anchors.d.ts +13 -0
- package/dist/runtime/lake-anchors.js +19 -0
- package/dist/runtime/lakes.d.ts +15 -0
- package/dist/runtime/lakes.js +212 -0
- package/dist/runtime/live.d.ts +3 -0
- package/dist/runtime/live.js +17 -0
- package/dist/runtime/load-scheduler.d.ts +53 -0
- package/dist/runtime/load-scheduler.js +317 -0
- package/dist/runtime/morph.d.ts +42 -0
- package/dist/runtime/morph.js +671 -0
- package/dist/runtime/nav-handle.d.ts +25 -0
- package/dist/runtime/nav-handle.js +71 -0
- package/dist/runtime/nav-hooks.d.ts +2 -0
- package/dist/runtime/nav-hooks.js +23 -0
- package/dist/runtime/nearest-attr.d.ts +4 -0
- package/dist/runtime/nearest-attr.js +16 -0
- package/dist/runtime/observe.d.ts +27 -0
- package/dist/runtime/observe.js +63 -0
- package/dist/runtime/own-cost.d.ts +9 -0
- package/dist/runtime/own-cost.js +35 -0
- package/dist/runtime/ownership.d.ts +101 -0
- package/dist/runtime/ownership.js +115 -0
- package/dist/runtime/page-cache.d.ts +23 -0
- package/dist/runtime/page-cache.js +74 -0
- package/dist/runtime/page-defer.d.ts +14 -0
- package/dist/runtime/page-defer.js +103 -0
- package/dist/runtime/parse-html.d.ts +40 -0
- package/dist/runtime/parse-html.js +81 -0
- package/dist/runtime/reconcile.d.ts +41 -0
- package/dist/runtime/reconcile.js +194 -0
- package/dist/runtime/region-attrs.d.ts +95 -0
- package/dist/runtime/region-attrs.js +153 -0
- package/dist/runtime/region-endpoint-url.d.ts +76 -0
- package/dist/runtime/region-endpoint-url.js +169 -0
- package/dist/runtime/region-ids.d.ts +8 -0
- package/dist/runtime/region-ids.js +33 -0
- package/dist/runtime/remote-seeds.d.ts +2 -0
- package/dist/runtime/remote-seeds.js +21 -0
- package/dist/runtime/render-blocking.d.ts +2 -0
- package/dist/runtime/render-blocking.js +30 -0
- package/dist/runtime/restore.d.ts +34 -0
- package/dist/runtime/restore.js +390 -0
- package/dist/runtime/router-nav.d.ts +63 -0
- package/dist/runtime/router-nav.js +740 -0
- package/dist/runtime/router.d.ts +201 -0
- package/dist/runtime/router.js +593 -0
- package/dist/runtime/schedule.d.ts +49 -0
- package/dist/runtime/schedule.js +256 -0
- package/dist/runtime/seeds.d.ts +50 -0
- package/dist/runtime/seeds.js +208 -0
- package/dist/runtime/session.d.ts +52 -0
- package/dist/runtime/session.js +130 -0
- package/dist/runtime/sidecar.d.ts +3 -0
- package/dist/runtime/sidecar.js +56 -0
- package/dist/runtime/slots.d.ts +183 -0
- package/dist/runtime/slots.js +44 -0
- package/dist/runtime/spa-cacheable.d.ts +7 -0
- package/dist/runtime/spa-cacheable.js +18 -0
- package/dist/runtime/speculate-hint.d.ts +1 -0
- package/dist/runtime/speculate-hint.js +35 -0
- package/dist/runtime/svelte-warnings.d.ts +28 -0
- package/dist/runtime/svelte-warnings.js +71 -0
- package/dist/runtime/wire-classes.d.ts +3 -0
- package/dist/runtime/wire-classes.js +69 -0
- package/dist/runtime/wire-format.d.ts +7 -0
- package/dist/runtime/wire-format.js +22 -0
- package/dist/script.d.ts +134 -0
- package/dist/script.js +184 -0
- package/dist/seed-refs.d.ts +105 -0
- package/dist/seed-refs.js +487 -0
- package/dist/server/capability-lifetime.d.ts +28 -0
- package/dist/server/capability-lifetime.js +31 -0
- package/dist/server/dead-kit-resolves.d.ts +1 -0
- package/dist/server/dead-kit-resolves.js +39 -0
- package/dist/server/document-assembly.d.ts +30 -0
- package/dist/server/document-assembly.js +26 -0
- package/dist/server/document-tail.d.ts +113 -0
- package/dist/server/document-tail.js +208 -0
- package/dist/server/endpoint.d.ts +51 -0
- package/dist/server/endpoint.js +90 -0
- package/dist/server/entry-location.d.ts +8 -0
- package/dist/server/entry-location.js +29 -0
- package/dist/server/fingerprint.d.ts +1 -0
- package/dist/server/fingerprint.js +25 -0
- package/dist/server/head-presence.d.ts +45 -0
- package/dist/server/head-presence.js +156 -0
- package/dist/server/hmac.d.ts +38 -0
- package/dist/server/hmac.js +89 -0
- package/dist/server/hole-graph.d.ts +7 -0
- package/dist/server/hole-graph.js +71 -0
- package/dist/server/hole-urls.d.ts +3 -0
- package/dist/server/hole-urls.js +76 -0
- package/dist/server/html-scan.d.ts +19 -0
- package/dist/server/html-scan.js +60 -0
- package/dist/server/kit-context.d.ts +78 -0
- package/dist/server/kit-context.js +110 -0
- package/dist/server/late-wire.d.ts +22 -0
- package/dist/server/late-wire.js +28 -0
- package/dist/server/page-facts.d.ts +25 -0
- package/dist/server/page-facts.js +138 -0
- package/dist/server/page-seed.d.ts +33 -0
- package/dist/server/page-seed.js +60 -0
- package/dist/server/page-stream.d.ts +55 -0
- package/dist/server/page-stream.js +121 -0
- package/dist/server/payload.d.ts +6 -0
- package/dist/server/payload.js +22 -0
- package/dist/server/personal-response.d.ts +6 -0
- package/dist/server/personal-response.js +13 -0
- package/dist/server/props-wire.d.ts +56 -0
- package/dist/server/props-wire.js +178 -0
- package/dist/server/rate-limit.d.ts +22 -0
- package/dist/server/rate-limit.js +63 -0
- package/dist/server/region-css.d.ts +5 -0
- package/dist/server/region-css.js +30 -0
- package/dist/server/region-endpoint.d.ts +35 -0
- package/dist/server/region-endpoint.js +142 -0
- package/dist/server/region-props.d.ts +6 -0
- package/dist/server/region-props.js +44 -0
- package/dist/server/remote-seed-gate.d.ts +50 -0
- package/dist/server/remote-seed-gate.js +66 -0
- package/dist/server/render-cache.d.ts +26 -0
- package/dist/server/render-cache.js +51 -0
- package/dist/server/render-page.d.ts +51 -0
- package/dist/server/render-page.js +176 -0
- package/dist/server/render-region-html.d.ts +2 -0
- package/dist/server/render-region-html.js +19 -0
- package/dist/server/request-stats.d.ts +174 -0
- package/dist/server/request-stats.js +54 -0
- package/dist/server/reversible.d.ts +83 -0
- package/dist/server/reversible.js +994 -0
- package/dist/server/seed-shape.d.ts +22 -0
- package/dist/server/seed-shape.js +24 -0
- package/dist/server/shared-cache.d.ts +35 -0
- package/dist/server/shared-cache.js +104 -0
- package/dist/server/signing-key.d.ts +11 -0
- package/dist/server/signing-key.js +47 -0
- package/dist/server/sized-lru.d.ts +20 -0
- package/dist/server/sized-lru.js +68 -0
- package/dist/server/split-regions.d.ts +81 -0
- package/dist/server/split-regions.js +368 -0
- package/dist/server/stream-regions.d.ts +5 -0
- package/dist/server/stream-regions.js +36 -0
- package/dist/shared-state.d.ts +7 -0
- package/dist/shared-state.js +152 -0
- package/dist/shims/app-environment.d.ts +4 -0
- package/dist/shims/app-environment.js +6 -0
- package/dist/shims/app-navigation.d.ts +33 -0
- package/dist/shims/app-navigation.js +119 -0
- package/dist/shims/app-paths.d.ts +6 -0
- package/dist/shims/app-paths.js +18 -0
- package/dist/shims/app-state.svelte.d.ts +23 -0
- package/dist/shims/app-state.svelte.js +50 -0
- package/dist/shims/app-stores.d.ts +21 -0
- package/dist/shims/app-stores.js +54 -0
- package/dist/shims/kit-bridge.d.ts +29 -0
- package/dist/shims/kit-bridge.js +7 -0
- package/dist/shims/kit-remote/client-stub.d.ts +27 -0
- package/dist/shims/kit-remote/client-stub.js +43 -0
- package/dist/shims/kit-remote/paths-internal-stub.d.ts +3 -0
- package/dist/shims/kit-remote/paths-internal-stub.js +5 -0
- package/dist/shims/kit-remote/remote-cache.d.ts +49 -0
- package/dist/shims/kit-remote/remote-cache.js +73 -0
- package/dist/shims/kit-remote/state-stub.d.ts +8 -0
- package/dist/shims/kit-remote/state-stub.js +8 -0
- package/dist/shims/page-store.svelte.d.ts +39 -0
- package/dist/shims/page-store.svelte.js +77 -0
- package/dist/source.d.ts +29 -0
- package/dist/source.js +87 -0
- package/dist/store-transport.d.ts +86 -0
- package/dist/store-transport.js +229 -0
- package/dist/tool-fetches.d.ts +5 -0
- package/dist/tool-fetches.js +41 -0
- package/dist/transport.d.ts +48 -0
- package/dist/transport.js +181 -0
- package/dist/unscoped-css.d.ts +26 -0
- package/dist/unscoped-css.js +53 -0
- package/dist/vite/dev-maps.d.ts +33 -0
- package/dist/vite/dev-maps.js +140 -0
- package/dist/vite/index.d.ts +19 -0
- package/dist/vite/index.js +820 -0
- package/dist/vite/kit-dirs.d.ts +7 -0
- package/dist/vite/kit-dirs.js +67 -0
- package/dist/vite/late-island.d.ts +25 -0
- package/dist/vite/late-island.js +33 -0
- package/dist/vite/module-map.d.ts +8 -0
- package/dist/vite/module-map.js +144 -0
- package/dist/vite/options.d.ts +208 -0
- package/dist/vite/options.js +74 -0
- package/dist/vite/package-files.d.ts +3 -0
- package/dist/vite/package-files.js +84 -0
- package/dist/vite/paths.d.ts +45 -0
- package/dist/vite/paths.js +112 -0
- package/dist/vite/plugin-api.d.ts +166 -0
- package/dist/vite/plugin-api.js +212 -0
- package/dist/vite/profiler-maps.d.ts +23 -0
- package/dist/vite/profiler-maps.js +178 -0
- package/dist/vite/server-sourcemaps.d.ts +8 -0
- package/dist/vite/server-sourcemaps.js +80 -0
- package/dist/vite/sourcemaps.d.ts +18 -0
- package/dist/vite/sourcemaps.js +80 -0
- package/dist/vite/style-preprocess.d.ts +2 -0
- package/dist/vite/style-preprocess.js +96 -0
- package/package.json +180 -6
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { router_css_active, router_css_of } from "../router-css.js";
|
|
2
|
+
import { claim_region_css } from "../context.js";
|
|
3
|
+
import { DEV } from "esm-env";
|
|
4
|
+
// src/plugin/css.ts
|
|
5
|
+
/**
|
|
6
|
+
* `ogygia/plugin/css` — the CSS of components a programmatic router renders (see the server-router-css
|
|
7
|
+
* notes + compiler/link/router-css.ts). Such a page's component is a VALUE, not a Kit route, so nothing
|
|
8
|
+
* file-derived links its scoped `<style>` / plain `.css` imports. The build registers every component a
|
|
9
|
+
* page module (`b.pageModules()`) can reach in a runtime registry (`virtual:ogygia/router-css`); this
|
|
10
|
+
* turns the components ONE render places into the `<link>` / `<style>` head tags `document()` hoists,
|
|
11
|
+
* deduped against the request's held-region links.
|
|
12
|
+
*
|
|
13
|
+
* Its own subpath: the generated registry is a virtual module, so it stays out of `ogygia/plugin` (every
|
|
14
|
+
* plugin's server realm) — and it is imported on the first call, never at module load.
|
|
15
|
+
*/
|
|
16
|
+
const STYLE_CLOSE_G = /<\/style/gi;
|
|
17
|
+
let rcss_ready;
|
|
18
|
+
let warned_inactive = false;
|
|
19
|
+
function registry_ready() {
|
|
20
|
+
if (rcss_ready === void 0) try {
|
|
21
|
+
rcss_ready = import("virtual:ogygia/router-css").catch(() => null);
|
|
22
|
+
} catch {
|
|
23
|
+
rcss_ready = null;
|
|
24
|
+
}
|
|
25
|
+
return rcss_ready;
|
|
26
|
+
}
|
|
27
|
+
/** Head tags for the components ONE render places (a layout chain + its page or error component):
|
|
28
|
+
* each component's whole-tree CSS, linked once per request. */
|
|
29
|
+
async function componentCssHead(components) {
|
|
30
|
+
const ready = registry_ready();
|
|
31
|
+
const registry = ready ? await ready : null;
|
|
32
|
+
if (DEV && registry && !warned_inactive && components.length && !router_css_active()) {
|
|
33
|
+
warned_inactive = true;
|
|
34
|
+
console.warn("[ogygia] a page rendered outside Kit's routes, but no plugin declared page modules, so its components' CSS is not linked. Using `@ogygia/router`? List `router()` from `@ogygia/router/vite` beside `ogygia()` in vite.config `plugins`.");
|
|
35
|
+
}
|
|
36
|
+
const entries = components.flatMap((c) => router_css_of(c));
|
|
37
|
+
if (!entries.length) return "";
|
|
38
|
+
const keys = entries.map((e) => e.key);
|
|
39
|
+
let fresh = new Set(claim_region_css(keys));
|
|
40
|
+
if (fresh.size === 0 && keys.length) try {
|
|
41
|
+
if (claim_region_css(["\0og-rcss-probe"]).length === 0) fresh = new Set(keys);
|
|
42
|
+
} catch {
|
|
43
|
+
fresh = new Set(keys);
|
|
44
|
+
}
|
|
45
|
+
let head = "";
|
|
46
|
+
for (const e of entries) {
|
|
47
|
+
if (!fresh.has(e.key)) continue;
|
|
48
|
+
fresh.delete(e.key);
|
|
49
|
+
if (e.href) head += `<link rel="stylesheet" href="${e.href}" data-ogygia-region-css>`;
|
|
50
|
+
else if (e.css) head += `<style data-ogygia-rcss>${e.css.replace(STYLE_CLOSE_G, "<\\/style")}</style>`;
|
|
51
|
+
}
|
|
52
|
+
return head;
|
|
53
|
+
}
|
|
54
|
+
export { componentCssHead };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FACTS — per-request shared state. A fact is filled by whoever learns it and read by whoever needs
|
|
3
|
+
* it; neither side imports the other. Keyed by the `Request` (every request has its own record, made
|
|
4
|
+
* on first touch, gone with the request), so a plugin's own code can reach them outside a hook too:
|
|
5
|
+
* a `flag()` read during the render holds its request.
|
|
6
|
+
*
|
|
7
|
+
* Plugins add their own facts by declaration merging:
|
|
8
|
+
*
|
|
9
|
+
* declare module 'ogygia/plugin' { interface RequestFacts { myThing?: string } }
|
|
10
|
+
*
|
|
11
|
+
* One global slot, not module scope: a plugin package and core can end up as two module instances
|
|
12
|
+
* of this file (src beside dist, a dual install), and a fact written through one must be read
|
|
13
|
+
* through the other.
|
|
14
|
+
*/
|
|
15
|
+
export interface RequestFacts {
|
|
16
|
+
/** This render MAY be stored and served to others later (a plugin decided so before the render):
|
|
17
|
+
* the holes it mints get prerender-grade capabilities, and data-source receipts are kept. */
|
|
18
|
+
storable: boolean;
|
|
19
|
+
/** The first reason this render is per-visitor (a flag read, a streamed promise, a personal
|
|
20
|
+
* cookie or header a plugin observed), named for the dev note — or null. */
|
|
21
|
+
perVisitor: string | null;
|
|
22
|
+
/** The page streams load promises after the document. */
|
|
23
|
+
streamed: boolean;
|
|
24
|
+
/** The response belongs to one browser (devtools switched on for it): never store or share it. */
|
|
25
|
+
private: boolean;
|
|
26
|
+
/** An app transform renders this router-fetched page as an ANSWER, a form a store keyed by path
|
|
27
|
+
* does not hold. */
|
|
28
|
+
answerForm: boolean;
|
|
29
|
+
/** Data-source receipts (`s:<id>:<fp>`) the render filed — collected only once a plugin asks for
|
|
30
|
+
* them by setting a list here (a storable render's reverse index, a fragment's provenance). */
|
|
31
|
+
sources: string[] | null;
|
|
32
|
+
/** Every flag decided for this request (name → variant): federation carries them as claims. */
|
|
33
|
+
assignments: Record<string, string>;
|
|
34
|
+
}
|
|
35
|
+
/** This request's facts (made on first touch). */
|
|
36
|
+
export declare function facts_of(request: Request): RequestFacts;
|
|
37
|
+
/** Core only (hooks.ts): how the running code's Request is found. */
|
|
38
|
+
export declare function set_current_request(fn: (() => Request | undefined) | null): void;
|
|
39
|
+
/** The facts of the request the running code belongs to, or null outside one (the client, a test). */
|
|
40
|
+
export declare function current_facts(): RequestFacts | null;
|
|
41
|
+
/** Name the first reason a render is per-visitor (later reasons do not replace it). */
|
|
42
|
+
export declare function mark_per_visitor(facts: RequestFacts, reason: string): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// src/plugin/facts.ts
|
|
2
|
+
const slot = globalThis[Symbol.for("ogygia.facts.v2")] ??= {
|
|
3
|
+
by_request: /* @__PURE__ */ new WeakMap(),
|
|
4
|
+
current: null
|
|
5
|
+
};
|
|
6
|
+
/** This request's facts (made on first touch). */
|
|
7
|
+
function facts_of(request) {
|
|
8
|
+
let facts = slot.by_request.get(request);
|
|
9
|
+
if (!facts) slot.by_request.set(request, facts = {
|
|
10
|
+
storable: false,
|
|
11
|
+
perVisitor: null,
|
|
12
|
+
streamed: false,
|
|
13
|
+
private: false,
|
|
14
|
+
answerForm: false,
|
|
15
|
+
sources: null,
|
|
16
|
+
assignments: {}
|
|
17
|
+
});
|
|
18
|
+
return facts;
|
|
19
|
+
}
|
|
20
|
+
/** Core only (hooks.ts): how the running code's Request is found. */
|
|
21
|
+
function set_current_request(fn) {
|
|
22
|
+
slot.current = fn;
|
|
23
|
+
}
|
|
24
|
+
/** The facts of the request the running code belongs to, or null outside one (the client, a test). */
|
|
25
|
+
function current_facts() {
|
|
26
|
+
try {
|
|
27
|
+
const request = slot.current?.();
|
|
28
|
+
return request ? facts_of(request) : null;
|
|
29
|
+
} catch {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Name the first reason a render is per-visitor (later reasons do not replace it). */
|
|
34
|
+
function mark_per_visitor(facts, reason) {
|
|
35
|
+
if (facts.perVisitor === null) facts.perVisitor = reason;
|
|
36
|
+
}
|
|
37
|
+
export { current_facts, facts_of, mark_per_visitor, set_current_request };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SHARED HOOKS — how plugins (and core) talk to each other: the same way core talks to them. A
|
|
3
|
+
* plugin implements a hook as a method of its server half; anyone calls it through `app`:
|
|
4
|
+
*
|
|
5
|
+
* app.notify.invalidate(tags) every implementation runs (resolves when all are done)
|
|
6
|
+
* app.ask.lastBuild(version) the first answer that is not `undefined`, in plugin order
|
|
7
|
+
*
|
|
8
|
+
* Nobody implementing a hook is normal: `notify` does nothing, `ask` answers `undefined`. Core owns
|
|
9
|
+
* the common names below; a plugin's own hooks carry its name (`federationThaw`), added by
|
|
10
|
+
* declaration merging:
|
|
11
|
+
*
|
|
12
|
+
* declare module 'ogygia/plugin' { interface ServerHooks { myThing(x: number): void } }
|
|
13
|
+
*
|
|
14
|
+
* One global slot: every module instance dispatches over the same implementations.
|
|
15
|
+
*/
|
|
16
|
+
/** The shared hooks. Each is optional on a plugin; the signature is the contract. */
|
|
17
|
+
export interface ServerHooks {
|
|
18
|
+
/** Drop every stored page carrying any of `tags` (a peer said they are stale). Never re-announced. */
|
|
19
|
+
invalidate(tags: string[]): void | Promise<void>;
|
|
20
|
+
/** Stored pages were dropped: `tags` names what (`p:<path>`, `s:<source>:<fp>`), or `'all'`. */
|
|
21
|
+
invalidated(tags: string[] | "all"): void | Promise<void>;
|
|
22
|
+
/** Record `version` as the build the shared store last saw; answer the one before (or undefined). */
|
|
23
|
+
lastBuild(version: string): string | undefined | Promise<string | undefined>;
|
|
24
|
+
}
|
|
25
|
+
/** Core only: a set of hook implementations joins (a plugin's server half, or core's own). Keyed by
|
|
26
|
+
* identity; returns the leave. */
|
|
27
|
+
export declare function register_hooks(impl: object): () => void;
|
|
28
|
+
export type Notify = { [K in keyof ServerHooks]: (...args: Parameters<ServerHooks[K]>) => Promise<void>; };
|
|
29
|
+
export type Ask = { [K in keyof ServerHooks]: (...args: Parameters<ServerHooks[K]>) => Promise<Awaited<ReturnType<ServerHooks[K]>> | undefined>; };
|
|
30
|
+
/** Every implementation of the named hook runs; a failing one is logged, never thrown. */
|
|
31
|
+
export declare const notify: Notify;
|
|
32
|
+
/** The first implementation that answers something other than `undefined`. */
|
|
33
|
+
export declare const ask: Ask;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// src/plugin/hooks.ts
|
|
2
|
+
const implementations = globalThis[Symbol.for("ogygia.server-hooks.v1")] ??= [];
|
|
3
|
+
/** Core only: a set of hook implementations joins (a plugin's server half, or core's own). Keyed by
|
|
4
|
+
* identity; returns the leave. */
|
|
5
|
+
function register_hooks(impl) {
|
|
6
|
+
const entry = impl;
|
|
7
|
+
if (!implementations.includes(entry)) implementations.push(entry);
|
|
8
|
+
return () => {
|
|
9
|
+
const at = implementations.indexOf(entry);
|
|
10
|
+
if (at !== -1) implementations.splice(at, 1);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
/** Every implementation of the named hook runs; a failing one is logged, never thrown. */
|
|
14
|
+
const notify = new Proxy({}, { get: (_, name) => async (...args) => {
|
|
15
|
+
for (const impl of implementations.slice()) {
|
|
16
|
+
const fn = impl[name];
|
|
17
|
+
if (typeof fn !== "function") continue;
|
|
18
|
+
try {
|
|
19
|
+
await fn.apply(impl, args);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
console.warn(`[ogygia] a \`${name}\` hook failed —`, e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
} });
|
|
25
|
+
/** The first implementation that answers something other than `undefined`. */
|
|
26
|
+
const ask = new Proxy({}, { get: (_, name) => async (...args) => {
|
|
27
|
+
for (const impl of implementations.slice()) {
|
|
28
|
+
const fn = impl[name];
|
|
29
|
+
if (typeof fn !== "function") continue;
|
|
30
|
+
try {
|
|
31
|
+
const answer = await fn.apply(impl, args);
|
|
32
|
+
if (answer !== void 0) return answer;
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.warn(`[ogygia] a \`${name}\` hook failed —`, e);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
} });
|
|
38
|
+
export { ask, notify, register_hooks };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { RequestFacts } from "./facts.js";
|
|
2
|
+
import { Ask, Notify, ServerHooks } from "./hooks.js";
|
|
3
|
+
import { DevtoolsEventInput } from "../events/schema.js";
|
|
4
|
+
import { DeferredRegion, og_html_region, region } from "../region.js";
|
|
5
|
+
import { RouteConfig, RouteConfigMatcher, register_route_config } from "./routes.js";
|
|
6
|
+
import { LateRegion, open_late_scope, take_late_regions } from "../late-region-registry.js";
|
|
7
|
+
import { LATE_BOOT_SCRIPT, late_chunk, late_slot } from "../server/late-wire.js";
|
|
8
|
+
import { Handle, RequestEvent } from "@sveltejs/kit";
|
|
9
|
+
/** The server process, as one plugin sees it (handed to `setup`, and on every `ctx.app`). */
|
|
10
|
+
export interface ServerApp<Options = undefined> {
|
|
11
|
+
/** The plugin's name (its package name). */
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/** The options the app gave the plugin in vite.config (JSON). */
|
|
14
|
+
readonly options: Options;
|
|
15
|
+
/** Call a shared hook on every plugin that has it. */
|
|
16
|
+
readonly notify: Notify;
|
|
17
|
+
/** Ask a shared hook: the first answer that is not `undefined`, in plugin order. */
|
|
18
|
+
readonly ask: Ask;
|
|
19
|
+
/** A request's facts (made on first touch) — for the plugin's own code outside a hook. */
|
|
20
|
+
facts(request: Request): RequestFacts;
|
|
21
|
+
/** The facts of the request the running code belongs to (a load, a render), or null outside one. */
|
|
22
|
+
current(): RequestFacts | null;
|
|
23
|
+
/** Sign `message` with the app's region key (HMAC): a capability only this app can mint. */
|
|
24
|
+
sign(message: string): string;
|
|
25
|
+
/** Check a signature `sign` made (constant-time). */
|
|
26
|
+
verify(message: string, signature: string): boolean;
|
|
27
|
+
/** Signed capabilities for an endpoint the plugin serves, held to the rules of region holes. */
|
|
28
|
+
readonly capability: PluginCapabilities;
|
|
29
|
+
/** Record a server-realm event into the current request's devtools stream (a no-op unless
|
|
30
|
+
* devtools is on for that browser). */
|
|
31
|
+
devtools(event: DevtoolsEventInput): void;
|
|
32
|
+
/** Warn once per message, prefixed with the plugin's name. */
|
|
33
|
+
warn(message: string): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A capability URL for an endpoint the plugin serves (a hole the browser fetches later), held to the
|
|
37
|
+
* rules of the app's own region holes: the same lifetime, expiry in unix seconds, and the same answer
|
|
38
|
+
* once one has expired, so the runtime renews it the way it renews a region hole. The URL carries the
|
|
39
|
+
* plugin's own fields first, then `exp` and `sig`.
|
|
40
|
+
*/
|
|
41
|
+
export interface PluginCapabilities {
|
|
42
|
+
/** Sign a capability minted now: its `exp` (long on a page a plugin may store or a shared cache
|
|
43
|
+
* keeps, else the app's `ttl`) and the `sig` over `message(exp)`. */
|
|
44
|
+
mint(message: (exp: string) => string): {
|
|
45
|
+
exp: string;
|
|
46
|
+
sig: string;
|
|
47
|
+
};
|
|
48
|
+
/** Check a request for a capability `mint` made, by its URL's `exp` and `sig` (with `renew=1`, the
|
|
49
|
+
* runtime's one retry of an expired one). Refused: the response to answer with, the 403 a region
|
|
50
|
+
* request gets. Accepted: headers to send with the answer (a renewal's carry the fresh URL). */
|
|
51
|
+
open(url: URL, message: (exp: string) => string): CapabilityOpened;
|
|
52
|
+
}
|
|
53
|
+
/** What `capability.open` decided. */
|
|
54
|
+
export type CapabilityOpened = {
|
|
55
|
+
ok: true;
|
|
56
|
+
headers: Record<string, string>;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
response: Response;
|
|
60
|
+
};
|
|
61
|
+
/** One request, as one plugin sees it. */
|
|
62
|
+
export interface RequestContext<Options = undefined, State = undefined> {
|
|
63
|
+
/** Kit's own event, untouched. */
|
|
64
|
+
readonly event: RequestEvent;
|
|
65
|
+
/** The decoded pathname. */
|
|
66
|
+
readonly path: string;
|
|
67
|
+
/** This plugin's per-request state, from its `state()`. */
|
|
68
|
+
readonly state: State;
|
|
69
|
+
readonly options: Options;
|
|
70
|
+
readonly app: ServerApp<Options>;
|
|
71
|
+
/** The request's shared facts. */
|
|
72
|
+
readonly facts: RequestFacts;
|
|
73
|
+
/** This request's value for a key this plugin claimed inside Kit's `config` page option
|
|
74
|
+
* (`b.routeConfig(key)`: `export const config = { <key>: … }` on a Kit page or layout, merged the
|
|
75
|
+
* way Kit merges it, or a programmatic router's `config`), or `undefined` when nothing declares it. */
|
|
76
|
+
routeConfig(key: string): unknown;
|
|
77
|
+
/** Render one signed hole in place, with this request's event (its cookies ride in): the hole's
|
|
78
|
+
* HTML, or null when it cannot render now (the stored fallback stays, the browser fetches). */
|
|
79
|
+
renderHole(endpoint: string): Promise<string | null>;
|
|
80
|
+
/** Name the first reason this render is per-visitor (later reasons do not replace it). */
|
|
81
|
+
perVisitor(reason: string): void;
|
|
82
|
+
}
|
|
83
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
84
|
+
/** Kit's `resolve()` options (a `transformPageChunk`, `filterSerializedResponseHeaders`, …). */
|
|
85
|
+
export type ResolveOptions = NonNullable<Parameters<Parameters<Handle>[0]["resolve"]>[1]>;
|
|
86
|
+
/** A request as an AROUND hook sees it: before anything is decided about it. */
|
|
87
|
+
export interface HandleContext<Options = undefined> {
|
|
88
|
+
/** Kit's own event, untouched. */
|
|
89
|
+
readonly event: RequestEvent;
|
|
90
|
+
readonly options: Options;
|
|
91
|
+
readonly app: ServerApp<Options>;
|
|
92
|
+
}
|
|
93
|
+
/** A plugin's server half: lifecycle hooks plus any shared hooks it implements. */
|
|
94
|
+
export type ServerPlugin<Options = undefined, State = undefined> = Partial<ServerHooks> & {
|
|
95
|
+
/** Once, when the server starts. */
|
|
96
|
+
setup?(app: ServerApp<Options>): void;
|
|
97
|
+
/** Fresh per-request state, handed back on `ctx.state`. */
|
|
98
|
+
state?(): State;
|
|
99
|
+
/**
|
|
100
|
+
* AROUND — the whole request, shaped like Kit's `handle`: `next()` runs the rest (the later plugins'
|
|
101
|
+
* `handle`, then ogygia) and returns its response; return it, or your own. The first plugin's is the
|
|
102
|
+
* outermost. `next(options)` passes Kit `resolve()` options: a `transformPageChunk` sees the finished
|
|
103
|
+
* document, after ogygia's own. Most plugins want the stages below instead; this is for what must
|
|
104
|
+
* wrap everything (a profiler timing the render, serving its own UI).
|
|
105
|
+
*/
|
|
106
|
+
handle?(ctx: HandleContext<Options>, next: (options?: ResolveOptions) => Promise<Response>): MaybePromise<Response>;
|
|
107
|
+
/** FIRST — every request, before anything else in the handle (above the page / hole split).
|
|
108
|
+
* A Response answers it. */
|
|
109
|
+
request?(ctx: RequestContext<Options, State>): MaybePromise<void | Response>;
|
|
110
|
+
/** FIRST — a PAGE request (not a hole, not a page-facts lookup), before Kit renders it. A
|
|
111
|
+
* Response answers it (a stored copy). */
|
|
112
|
+
page?(ctx: RequestContext<Options, State>): MaybePromise<void | Response>;
|
|
113
|
+
/** SEQUENTIAL — the page's response, before it streams out. A Response replaces it. */
|
|
114
|
+
response?(ctx: RequestContext<Options, State>, response: Response): MaybePromise<void | Response>;
|
|
115
|
+
/** PARALLEL — the request's end, always (an answered, failed or streamed request included). Must
|
|
116
|
+
* not throw; must not await anything slow. */
|
|
117
|
+
done?(ctx: RequestContext<Options, State>): void;
|
|
118
|
+
};
|
|
119
|
+
/** Typed identity: a plugin's server half. */
|
|
120
|
+
export declare function defineServer<Options = undefined, State = undefined>(plugin: ServerPlugin<Options, State>): ServerPlugin<Options, State>;
|
|
121
|
+
/** Stamped into a document served FROM a store (not the render that just happened): the browser
|
|
122
|
+
* runtime then treats `render: 'live'` lakes as stale on first mount and revalidates them. */
|
|
123
|
+
export declare const STORED_DOCUMENT_META = "<meta name=\"ogygia-stored\" content=\"hit\">";
|
|
124
|
+
/** A deferred region value whose HTML the browser fetches from `url` (a capability the plugin minted,
|
|
125
|
+
* `''` for an inert one). HTML only: whatever islands the answer carries wake themselves. */
|
|
126
|
+
export declare function deferredRegion(id: string, url: string): DeferredRegion;
|
|
127
|
+
export { type DevtoolsEventInput, LATE_BOOT_SCRIPT, type LateRegion, type RequestFacts, type RouteConfig, type RouteConfigMatcher, type ServerHooks, og_html_region as htmlRegion, late_chunk as lateChunk, late_slot as lateSlot, open_late_scope as openLateScope, region, register_route_config as registerRouteConfig, take_late_regions as takeLateRegions };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { og_html_region, region } from "../region.js";
|
|
2
|
+
import { register_route_config } from "./routes.js";
|
|
3
|
+
import { open_late_scope, take_late_regions } from "../late-region-registry.js";
|
|
4
|
+
import { LATE_BOOT_SCRIPT, late_chunk, late_slot } from "../server/late-wire.js";
|
|
5
|
+
import { REGION_BRAND } from "../region-brand.js";
|
|
6
|
+
// src/plugin/index.ts
|
|
7
|
+
/** Typed identity: a plugin's server half. */
|
|
8
|
+
function defineServer(plugin) {
|
|
9
|
+
return plugin;
|
|
10
|
+
}
|
|
11
|
+
/** Stamped into a document served FROM a store (not the render that just happened): the browser
|
|
12
|
+
* runtime then treats `render: 'live'` lakes as stale on first mount and revalidates them. */
|
|
13
|
+
const STORED_DOCUMENT_META = "<meta name=\"ogygia-stored\" content=\"hit\">";
|
|
14
|
+
/** A deferred region value whose HTML the browser fetches from `url` (a capability the plugin minted,
|
|
15
|
+
* `''` for an inert one). HTML only: whatever islands the answer carries wake themselves. */
|
|
16
|
+
function deferredRegion(id, url) {
|
|
17
|
+
return {
|
|
18
|
+
[REGION_BRAND]: true,
|
|
19
|
+
kind: "deferred",
|
|
20
|
+
id,
|
|
21
|
+
props: {},
|
|
22
|
+
url,
|
|
23
|
+
module: ""
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export { LATE_BOOT_SCRIPT, STORED_DOCUMENT_META, deferredRegion, defineServer, og_html_region as htmlRegion, late_chunk as lateChunk, late_slot as lateSlot, open_late_scope as openLateScope, region, register_route_config as registerRouteConfig, take_late_regions as takeLateRegions };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ROUTE CONFIG — the keys a plugin reads inside Kit's own `config` page option
|
|
3
|
+
* (`export const config = { postrender: false }` in a `+page.ts`). Kit takes anything inside
|
|
4
|
+
* `config`, so nothing is stripped and no plugin invents an export in Kit's files. A plugin claims
|
|
5
|
+
* its keys once (`b.routeConfig(key)`); the compiler reads each page's merged `config` at build time
|
|
6
|
+
* the way Kit merges it (layouts root → leaf, then the page; at each level the server module, then
|
|
7
|
+
* the universal one; later wins, top level only) and bakes the claimed keys.
|
|
8
|
+
*
|
|
9
|
+
* Two worlds answer, in the order dispatch itself resolves a request:
|
|
10
|
+
* 1. A mounted programmatic `routes()` table that CLAIMS the pathname (it answers inside the
|
|
11
|
+
* handle, ahead of any file route): its merged page > layout > table `config`.
|
|
12
|
+
* 2. A Kit page route: its build-time merged value.
|
|
13
|
+
* Anything else (an endpoint, a request no route claimed) answers `undefined`: the plugin's own
|
|
14
|
+
* default applies.
|
|
15
|
+
*
|
|
16
|
+
* One global slot: dist entries and plugin packages must share the registry.
|
|
17
|
+
*/
|
|
18
|
+
/** A route's merged `config`, as far as the claimed keys go. */
|
|
19
|
+
export type RouteConfig = Readonly<Record<string, unknown>>;
|
|
20
|
+
/** Per matcher: `undefined` = not mine (ask the next one, then the file world) · an object = mine,
|
|
21
|
+
* with this merged config (a claimed key it lacks answers `undefined`, never the file world). */
|
|
22
|
+
export type RouteConfigMatcher = (pathname: string) => RouteConfig | undefined;
|
|
23
|
+
/** A `routes()` table joins (keyed: dev re-evaluates hooks.server.ts and calls `routes()` again; a
|
|
24
|
+
* matcher with the same key REPLACES its stale twin instead of shadowing it). */
|
|
25
|
+
export declare function register_route_config(key: string, matcher: RouteConfigMatcher): void;
|
|
26
|
+
/** Core only (hooks.ts): the Kit pages' merged config, baked by the compiler. */
|
|
27
|
+
export declare function set_page_route_config(pages: Record<string, RouteConfig>): void;
|
|
28
|
+
/** Tests only. */
|
|
29
|
+
export declare function clear_route_config(): void;
|
|
30
|
+
/** This request's value for `key` in its route's merged `config`, or `undefined` (use the plugin's
|
|
31
|
+
* default). A null `routeId` is never normalized to `/` — that would be a different route. */
|
|
32
|
+
export declare function route_config(key: string, route_id: string | null | undefined, pathname: string): unknown;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// src/plugin/routes.ts
|
|
2
|
+
const slot = globalThis[Symbol.for("ogygia.route-config.v1")] ??= {
|
|
3
|
+
routers: /* @__PURE__ */ new Map(),
|
|
4
|
+
pages: /* @__PURE__ */ new Map()
|
|
5
|
+
};
|
|
6
|
+
/** A `routes()` table joins (keyed: dev re-evaluates hooks.server.ts and calls `routes()` again; a
|
|
7
|
+
* matcher with the same key REPLACES its stale twin instead of shadowing it). */
|
|
8
|
+
function register_route_config(key, matcher) {
|
|
9
|
+
slot.routers.delete(key);
|
|
10
|
+
slot.routers.set(key, matcher);
|
|
11
|
+
}
|
|
12
|
+
/** Core only (hooks.ts): the Kit pages' merged config, baked by the compiler. */
|
|
13
|
+
function set_page_route_config(pages) {
|
|
14
|
+
slot.pages = new Map(Object.entries(pages));
|
|
15
|
+
}
|
|
16
|
+
/** Tests only. */
|
|
17
|
+
function clear_route_config() {
|
|
18
|
+
slot.routers.clear();
|
|
19
|
+
slot.pages.clear();
|
|
20
|
+
}
|
|
21
|
+
/** Kit's `(group)` segments dropped from a `route.id` (the compiler keys pages the same way). */
|
|
22
|
+
function strip_route_groups(id) {
|
|
23
|
+
return "/" + id.split("/").filter(Boolean).filter((s) => !(s.startsWith("(") && s.endsWith(")"))).join("/");
|
|
24
|
+
}
|
|
25
|
+
/** This request's value for `key` in its route's merged `config`, or `undefined` (use the plugin's
|
|
26
|
+
* default). A null `routeId` is never normalized to `/` — that would be a different route. */
|
|
27
|
+
function route_config(key, route_id, pathname) {
|
|
28
|
+
for (const matcher of slot.routers.values()) {
|
|
29
|
+
const config = matcher(pathname);
|
|
30
|
+
if (config !== void 0) return config[key];
|
|
31
|
+
}
|
|
32
|
+
if (route_id == null) return void 0;
|
|
33
|
+
return slot.pages.get(strip_route_groups(route_id))?.[key];
|
|
34
|
+
}
|
|
35
|
+
export { clear_route_config, register_route_config, route_config, set_page_route_config };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RequestContext, ResolveOptions, ServerApp, ServerPlugin } from "./index.js";
|
|
2
|
+
import { RequestFacts } from "./facts.js";
|
|
3
|
+
import { CapabilitySigner } from "./capability.js";
|
|
4
|
+
import { Handle, RequestEvent } from "@sveltejs/kit";
|
|
5
|
+
/** One plugin's server half as the build lists it (`virtual:ogygia/server-plugins`). */
|
|
6
|
+
export interface ServerPluginEntry {
|
|
7
|
+
name: string;
|
|
8
|
+
options: unknown;
|
|
9
|
+
server: ServerPlugin<unknown, unknown>;
|
|
10
|
+
}
|
|
11
|
+
/** A live plugin: its definition and its app. */
|
|
12
|
+
export interface LivePlugin {
|
|
13
|
+
def: ServerPlugin<unknown, unknown>;
|
|
14
|
+
app: ServerApp<unknown>;
|
|
15
|
+
}
|
|
16
|
+
/** The app's signer, handed in by the handle (it holds the region key, and answers a refused
|
|
17
|
+
* capability the way it answers a refused region request). */
|
|
18
|
+
export type AppSigner = CapabilitySigner;
|
|
19
|
+
/** Make each plugin live, in order: app, shared hooks, `setup`. */
|
|
20
|
+
export declare function start_plugins(entries: readonly ServerPluginEntry[], signer: AppSigner): LivePlugin[];
|
|
21
|
+
/** Two `resolve()` option sets as one: the inner transform (ogygia's document injection) runs first,
|
|
22
|
+
* the outer (a plugin's `handle`) sees the finished chunk; the other options merge, outer last. */
|
|
23
|
+
export declare function compose_resolve_options(inner?: ResolveOptions, outer?: ResolveOptions): ResolveOptions | undefined;
|
|
24
|
+
/** The plugins' `handle` hooks nested around `core`, first plugin outermost. No hook: `core` itself. */
|
|
25
|
+
export declare function around(plugins: readonly LivePlugin[], core: Handle): Handle;
|
|
26
|
+
/** The per-plugin contexts of one request. */
|
|
27
|
+
export declare function request_contexts(plugins: readonly LivePlugin[], event: RequestEvent, path: string, facts: RequestFacts, render_hole: (endpoint: string) => Promise<string | null>): RequestContext<unknown, unknown>[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { current_facts, facts_of, mark_per_visitor } from "./facts.js";
|
|
2
|
+
import { ask, notify, register_hooks } from "./hooks.js";
|
|
3
|
+
import { route_config } from "./routes.js";
|
|
4
|
+
import { plugin_capabilities } from "./capability.js";
|
|
5
|
+
import { record_server_event } from "../events/server-registry.js";
|
|
6
|
+
// src/plugin/server.ts
|
|
7
|
+
/** Make each plugin live, in order: app, shared hooks, `setup`. */
|
|
8
|
+
function start_plugins(entries, signer) {
|
|
9
|
+
return entries.map(({ name, options, server }) => {
|
|
10
|
+
const warned = /* @__PURE__ */ new Set();
|
|
11
|
+
const app = {
|
|
12
|
+
name,
|
|
13
|
+
options,
|
|
14
|
+
notify,
|
|
15
|
+
ask,
|
|
16
|
+
facts: facts_of,
|
|
17
|
+
current: current_facts,
|
|
18
|
+
sign: signer.sign,
|
|
19
|
+
verify: signer.verify,
|
|
20
|
+
capability: plugin_capabilities(name, signer),
|
|
21
|
+
devtools: record_server_event,
|
|
22
|
+
warn(message) {
|
|
23
|
+
if (warned.has(message)) return;
|
|
24
|
+
warned.add(message);
|
|
25
|
+
console.warn(`[${name}] ${message}`);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
register_hooks(server);
|
|
29
|
+
server.setup?.(app);
|
|
30
|
+
return {
|
|
31
|
+
def: server,
|
|
32
|
+
app
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/** Two `resolve()` option sets as one: the inner transform (ogygia's document injection) runs first,
|
|
37
|
+
* the outer (a plugin's `handle`) sees the finished chunk; the other options merge, outer last. */
|
|
38
|
+
function compose_resolve_options(inner, outer) {
|
|
39
|
+
if (!inner) return outer;
|
|
40
|
+
if (!outer) return inner;
|
|
41
|
+
const a = inner.transformPageChunk;
|
|
42
|
+
const b = outer.transformPageChunk;
|
|
43
|
+
return {
|
|
44
|
+
...inner,
|
|
45
|
+
...outer,
|
|
46
|
+
transformPageChunk: !a ? b : !b ? a : async (input) => {
|
|
47
|
+
const first = await a(input);
|
|
48
|
+
if (first === void 0) return first;
|
|
49
|
+
return b({
|
|
50
|
+
...input,
|
|
51
|
+
html: first
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The plugins' `handle` hooks nested around `core`, first plugin outermost. No hook: `core` itself. */
|
|
57
|
+
function around(plugins, core) {
|
|
58
|
+
let inner = core;
|
|
59
|
+
for (let i = plugins.length - 1; i >= 0; i--) {
|
|
60
|
+
const { def, app } = plugins[i];
|
|
61
|
+
const handle = def.handle;
|
|
62
|
+
if (!handle) continue;
|
|
63
|
+
const next_handle = inner;
|
|
64
|
+
inner = async ({ event, resolve }) => handle({
|
|
65
|
+
event,
|
|
66
|
+
options: app.options,
|
|
67
|
+
app
|
|
68
|
+
}, (outer) => Promise.resolve(next_handle({
|
|
69
|
+
event,
|
|
70
|
+
resolve: (ev, opts) => resolve(ev, compose_resolve_options(opts, outer))
|
|
71
|
+
})));
|
|
72
|
+
}
|
|
73
|
+
return inner;
|
|
74
|
+
}
|
|
75
|
+
/** The per-plugin contexts of one request. */
|
|
76
|
+
function request_contexts(plugins, event, path, facts, render_hole) {
|
|
77
|
+
const route_id = event.route?.id;
|
|
78
|
+
const route_cfg = (key) => route_config(key, route_id, path);
|
|
79
|
+
const per_visitor = (reason) => mark_per_visitor(facts, reason);
|
|
80
|
+
return plugins.map(({ def, app }) => ({
|
|
81
|
+
event,
|
|
82
|
+
path,
|
|
83
|
+
state: def.state?.(),
|
|
84
|
+
options: app.options,
|
|
85
|
+
app,
|
|
86
|
+
facts,
|
|
87
|
+
routeConfig: route_cfg,
|
|
88
|
+
renderHole: render_hole,
|
|
89
|
+
perVisitor: per_visitor
|
|
90
|
+
}));
|
|
91
|
+
}
|
|
92
|
+
export { around, compose_resolve_options, request_contexts, start_plugins };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Standard Schema interface (standardschema.dev): the `~standard` spec Zod / Valibot / ArkType all
|
|
3
|
+
* implement, the very thing Kit's remote functions consume. Validate a value with any schema library.
|
|
4
|
+
* Types only.
|
|
5
|
+
*/
|
|
6
|
+
export interface StandardSchemaV1<Output = unknown> {
|
|
7
|
+
readonly "~standard": {
|
|
8
|
+
readonly version: 1;
|
|
9
|
+
readonly vendor: string;
|
|
10
|
+
readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
|
|
11
|
+
readonly types?: {
|
|
12
|
+
readonly output: Output;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export type StandardResult<Output> = {
|
|
17
|
+
readonly value: Output;
|
|
18
|
+
readonly issues?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
readonly issues: ReadonlyArray<StandardIssue>;
|
|
21
|
+
};
|
|
22
|
+
export interface StandardIssue {
|
|
23
|
+
readonly message: string;
|
|
24
|
+
readonly path?: ReadonlyArray<PropertyKey | {
|
|
25
|
+
readonly key: PropertyKey;
|
|
26
|
+
}>;
|
|
27
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RequestContext, ServerApp, ServerPlugin } from "./index.js";
|
|
2
|
+
import { clear_route_config, route_config, set_page_route_config } from "./routes.js";
|
|
3
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
4
|
+
export interface StartedPlugin<Options, State> {
|
|
5
|
+
app: ServerApp<Options>;
|
|
6
|
+
/** A request context for `request` (a bare event: url, request, cookies that read nothing). */
|
|
7
|
+
ctx(request: Request, event?: Partial<RequestEvent>): RequestContext<Options, State>;
|
|
8
|
+
}
|
|
9
|
+
export declare function startPlugin<Options = undefined, State = undefined>(server: ServerPlugin<Options, State>, { name, options }?: {
|
|
10
|
+
name?: string;
|
|
11
|
+
options?: Options;
|
|
12
|
+
}): StartedPlugin<Options, State>;
|
|
13
|
+
export { clear_route_config as clearRouteConfig, route_config as routeConfig, set_page_route_config as setPageRouteConfig };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { facts_of } from "./facts.js";
|
|
2
|
+
import { request_contexts, start_plugins } from "./server.js";
|
|
3
|
+
import { capability_lifetime } from "../server/capability-lifetime.js";
|
|
4
|
+
import { RENEW_WINDOW_SEC } from "../server/shared-cache.js";
|
|
5
|
+
import { clear_route_config, route_config, set_page_route_config } from "./routes.js";
|
|
6
|
+
import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
|
|
7
|
+
// src/plugin/testing.ts
|
|
8
|
+
/** A real HMAC under a key made for this test process. */
|
|
9
|
+
const TEST_KEY = randomBytes(32);
|
|
10
|
+
const TEST_SIGNER = {
|
|
11
|
+
sign: (message) => createHmac("sha256", TEST_KEY).update(message).digest("base64url"),
|
|
12
|
+
verify(message, signature) {
|
|
13
|
+
const want = Buffer.from(createHmac("sha256", TEST_KEY).update(message).digest("base64url"));
|
|
14
|
+
const got = Buffer.from(signature);
|
|
15
|
+
return want.length === got.length && timingSafeEqual(want, got);
|
|
16
|
+
},
|
|
17
|
+
lifetime: capability_lifetime({
|
|
18
|
+
building: false,
|
|
19
|
+
region_ttl: 3600,
|
|
20
|
+
renew_window: RENEW_WINDOW_SEC,
|
|
21
|
+
request: () => null
|
|
22
|
+
}),
|
|
23
|
+
deny: (why) => new Response("Forbidden", {
|
|
24
|
+
status: 403,
|
|
25
|
+
headers: { "x-ogygia-deny": why }
|
|
26
|
+
})
|
|
27
|
+
};
|
|
28
|
+
function startPlugin(server, { name = "test-plugin", options } = {}) {
|
|
29
|
+
const [live] = start_plugins([{
|
|
30
|
+
name,
|
|
31
|
+
options,
|
|
32
|
+
server
|
|
33
|
+
}], TEST_SIGNER);
|
|
34
|
+
return {
|
|
35
|
+
app: live.app,
|
|
36
|
+
ctx(request, event = {}) {
|
|
37
|
+
const url = new URL(request.url);
|
|
38
|
+
const full = {
|
|
39
|
+
request,
|
|
40
|
+
url,
|
|
41
|
+
route: { id: null },
|
|
42
|
+
cookies: {
|
|
43
|
+
get: () => void 0,
|
|
44
|
+
getAll: () => []
|
|
45
|
+
},
|
|
46
|
+
locals: {},
|
|
47
|
+
...event
|
|
48
|
+
};
|
|
49
|
+
const [ctx] = request_contexts([live], full, url.pathname, facts_of(request), async () => null);
|
|
50
|
+
return ctx;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export { clear_route_config as clearRouteConfig, route_config as routeConfig, set_page_route_config as setPageRouteConfig, startPlugin };
|