@absolutejs/absolute 0.20.0-beta.169 → 0.20.0-beta.170
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/CHANGELOG.md +80 -0
- package/README.md +232 -0
- package/changelog.json +228 -0
- package/dist/angular/browser.js +7 -8
- package/dist/angular/browser.js.map +6 -5
- package/dist/angular/components/core/streamingSlotRegistrar.js +6 -2
- package/dist/angular/components/core/streamingSlotRegistry.js +7 -3
- package/dist/angular/index.js +555 -156
- package/dist/angular/index.js.map +29 -23
- package/dist/angular/server.js +555 -156
- package/dist/angular/server.js.map +29 -23
- package/dist/build/buildWorker.js +14 -8
- package/dist/build.js +4949 -1941
- package/dist/build.js.map +72 -42
- package/dist/cli/{add-7azr0c83.js → add-6a7pjkn9.js} +11 -7
- package/dist/cli/{analyze-3cyek6v3.js → analyze-606fshwa.js} +1 -1
- package/dist/cli/{build-25rz8v25.js → build-g81xqbb9.js} +1 -1
- package/dist/cli/{compile-4jnfxts9.js → compile-9y1w9zpj.js} +3 -3
- package/dist/cli/config/server.js +10699 -1538
- package/dist/cli/{dev-9tk5hn2e.js → dev-hyeb89hp.js} +5 -1
- package/dist/cli/{doctor-4nv2c2j3.js → doctor-h55y9hj1.js} +1 -1
- package/dist/cli/{generate-v75p2fct.js → generate-20x1pkf7.js} +4 -4
- package/dist/cli/{htmx-427swtdz.js → htmx-6mz2h7k1.js} +2 -2
- package/dist/cli/{index-bhbs6d5z.js → index-32ge2w1f.js} +12 -4
- package/dist/cli/{index-a4ws2jwd.js → index-3wz3mktm.js} +1 -1
- package/dist/cli/{index-b7hjgknf.js → index-9sksd8c8.js} +13 -4
- package/dist/cli/{index-eyzwc7gz.js → index-qbrzvmh9.js} +4 -2
- package/dist/cli/index-qw98g1p6.js +269 -0
- package/dist/cli/{index-434b7j4a.js → index-vtp20gwf.js} +69 -1
- package/dist/cli/{index-h7qhz02e.js → index-wk0pyxrg.js} +3 -0
- package/dist/cli/{index-k3y8cb6c.js → index-z6f43b20.js} +1 -1
- package/dist/cli/index.js +16 -16
- package/dist/cli/{islands-8sgky9gh.js → islands-dc54e5y1.js} +1 -1
- package/dist/cli/{ls-4m4yqwww.js → ls-b6zz24nt.js} +1 -1
- package/dist/cli/{mobile-hcxjr2gf.js → mobile-ajnnvqtv.js} +3 -3
- package/dist/cli/prerender-fqpp0m1j.js +10 -0
- package/dist/cli/{remove-1ycjx85k.js → remove-t8x1mrxg.js} +4 -4
- package/dist/cli/{start-mbaejxhm.js → start-d6p831ny.js} +3 -3
- package/dist/cli/{typecheck-dr068pmh.js → typecheck-stbt0qt5.js} +6 -1
- package/dist/cli/{workspace-1sycp9g1.js → workspace-61hh6jq1.js} +1 -1
- package/dist/client/chunks/index-6b66nzyf.js +381 -0
- package/dist/client/chunks/index-6b66nzyf.js.map +11 -0
- package/dist/client/chunks/{islands-rc28k5sx.js → islands-s2ta5ajb.js} +5 -2
- package/dist/client/chunks/{islands-rc28k5sx.js.map → islands-s2ta5ajb.js.map} +7 -6
- package/dist/client/index.js +160 -3
- package/dist/client/index.js.map +6 -4
- package/dist/client/navigation.js +764 -0
- package/dist/client/navigation.js.map +10 -0
- package/dist/client/prefetch.js +33 -375
- package/dist/client/prefetch.js.map +3 -4
- package/dist/core/streamingSlotRegistrar.js +5 -2
- package/dist/core/streamingSlotRegistrar.js.map +5 -4
- package/dist/core/streamingSlotRegistry.js +5 -2
- package/dist/core/streamingSlotRegistry.js.map +5 -4
- package/dist/dev/client/cspNonce.ts +28 -0
- package/dist/dev/client/handlers/html.ts +4 -3
- package/dist/dev/client/handlers/htmx.ts +3 -2
- package/dist/dev/client/handlers/svelte.ts +15 -90
- package/dist/dev/client/syncDevtools.ts +2 -1
- package/dist/dev/serverBootstrap.js +11 -4
- package/dist/i18n/index.js +543 -0
- package/dist/i18n/index.js.map +15 -0
- package/dist/index.js +6339 -2233
- package/dist/index.js.map +89 -54
- package/dist/islands/index.js +282 -40
- package/dist/islands/index.js.map +14 -10
- package/dist/mobile/browser.js +7 -2
- package/dist/mobile/browser.js.map +5 -4
- package/dist/mobile/index.js +7 -2
- package/dist/mobile/index.js.map +5 -4
- package/dist/mobile/remoteMacAgentEntry.js +1 -1
- package/dist/react/components/browser/index.js +94 -4
- package/dist/react/components/index.js +150 -10
- package/dist/react/components/index.js.map +15 -10
- package/dist/react/hooks/index.js +479 -13
- package/dist/react/hooks/index.js.map +12 -4
- package/dist/react/index.js +769 -166
- package/dist/react/index.js.map +32 -21
- package/dist/react/router/browser.js +21 -4
- package/dist/react/router/browser.js.map +5 -4
- package/dist/react/router/index.js +21 -4
- package/dist/react/router/index.js.map +5 -4
- package/dist/react/server.js +597 -203
- package/dist/react/server.js.map +25 -15
- package/dist/src/angular/zoneRuntime.d.ts +5 -0
- package/dist/src/build/buildReactServerComponents.d.ts +22 -0
- package/dist/src/build/downlevelAsyncForZone.d.ts +1 -0
- package/dist/src/build/fileRoutes.d.ts +65 -0
- package/dist/src/build/fonts/buildFonts.d.ts +25 -0
- package/dist/src/build/fonts/fallbackMetrics.d.ts +13 -0
- package/dist/src/build/fonts/googleFonts.d.ts +18 -0
- package/dist/src/build/fonts/injectFontTags.d.ts +7 -0
- package/dist/src/build/fonts/parseFontMetrics.d.ts +4 -0
- package/dist/src/build/generateReactIndexes.d.ts +7 -1
- package/dist/src/build/htmlIncludes.d.ts +16 -0
- package/dist/src/build/inlineSourceMapComment.d.ts +1 -0
- package/dist/src/build/scanConventions.d.ts +3 -0
- package/dist/src/build/vitals.d.ts +21 -0
- package/dist/src/client/formActions.d.ts +29 -0
- package/dist/src/client/index.d.ts +2 -0
- package/dist/src/client/navigation.d.ts +16 -0
- package/dist/src/client/prefetch.d.ts +2 -30
- package/dist/src/core/build.d.ts +2 -2
- package/dist/src/core/cspNonce.d.ts +12 -0
- package/dist/src/core/fileRouteAdapter.d.ts +15 -0
- package/dist/src/core/fileRoutes.d.ts +5 -0
- package/dist/src/core/formActionFlash.d.ts +25 -0
- package/dist/src/core/formActions.d.ts +249 -0
- package/dist/src/core/index.d.ts +5 -0
- package/dist/src/core/partialPrerender.d.ts +28 -0
- package/dist/src/core/partialPrerenderServe.d.ts +24 -0
- package/dist/src/core/precompressed.d.ts +11 -1
- package/dist/src/core/prerenderNonce.d.ts +9 -0
- package/dist/src/core/productionRuntime.d.ts +4 -2
- package/dist/src/core/serverOnlyStaticFiles.d.ts +8 -0
- package/dist/src/core/staticHtmlNonce.d.ts +2 -0
- package/dist/src/core/vitals.d.ts +108 -0
- package/dist/src/dev/angular/fastHmrCompiler.d.ts +1 -1
- package/dist/src/dev/client/cspNonce.d.ts +2 -0
- package/dist/src/dev/fileRouteRefresher.d.ts +5 -0
- package/dist/src/dev/importCost/instrument.d.ts +1 -1
- package/dist/src/dev/reactServerComponentsRebuild.d.ts +3 -0
- package/dist/src/i18n/defineMessages.d.ts +5 -0
- package/dist/src/i18n/formatMessage.d.ts +26 -0
- package/dist/src/i18n/index.d.ts +6 -0
- package/dist/src/i18n/intlCache.d.ts +5 -0
- package/dist/src/i18n/routing.d.ts +28 -0
- package/dist/src/i18n/translator.d.ts +11 -0
- package/dist/src/mobile/androidRelease.d.ts +2 -2
- package/dist/src/mobile/iosRelease.d.ts +4 -4
- package/dist/src/mobile/materializedBundle.d.ts +1 -1
- package/dist/src/mobile/mobileInspect.d.ts +1 -1
- package/dist/src/mobile/releaseArtifact.d.ts +2 -2
- package/dist/src/mobile/remoteMacProtocol.d.ts +2 -2
- package/dist/src/plugins/i18n.d.ts +30 -0
- package/dist/src/plugins/index.d.ts +2 -1
- package/dist/src/plugins/secureHeaders.d.ts +48 -0
- package/dist/src/react/components/Head.d.ts +1 -1
- package/dist/src/react/components/StreamSlot.browser.d.ts +1 -0
- package/dist/src/react/components/StreamSlot.d.ts +5 -1
- package/dist/src/react/components/SuspenseSlot.browser.d.ts +2 -0
- package/dist/src/react/components/SuspenseSlot.d.ts +12 -0
- package/dist/src/react/fileRoute.d.ts +18 -0
- package/dist/src/react/hooks/index.d.ts +4 -0
- package/dist/src/react/hooks/useFormAction.d.ts +42 -0
- package/dist/src/react/hooks/useI18n.d.ts +15 -0
- package/dist/src/react/index.d.ts +2 -0
- package/dist/src/react/server.d.ts +2 -0
- package/dist/src/react/serverComponents/constants.d.ts +11 -0
- package/dist/src/react/serverComponents/flightPayload.d.ts +2 -0
- package/dist/src/react/serverComponents/pageHandler.d.ts +14 -0
- package/dist/src/svelte/browser.d.ts +1 -0
- package/dist/src/svelte/fileRoute.d.ts +15 -0
- package/dist/src/svelte/i18n.d.ts +8 -0
- package/dist/src/svelte/index.d.ts +2 -0
- package/dist/src/svelte/lowerAwaitSlotSyntax.d.ts +5 -1
- package/dist/src/svelte/renderToReadableStream.d.ts +10 -2
- package/dist/src/svelte/router/browser.d.ts +3 -1
- package/dist/src/svelte/router/goto.d.ts +13 -10
- package/dist/src/svelte/router/guards.d.ts +43 -0
- package/dist/src/svelte/router/index.d.ts +3 -1
- package/dist/src/svelte/router/lazy.d.ts +17 -0
- package/dist/src/svelte/router/lazyModule.d.ts +29 -0
- package/dist/src/svelte/router/navigation.d.ts +55 -0
- package/dist/src/svelte/router/pushState.d.ts +4 -2
- package/dist/src/svelte/router/scroll.d.ts +34 -0
- package/dist/src/svelte/routerSsr.d.ts +9 -0
- package/dist/src/svelte/server.d.ts +1 -0
- package/dist/src/utils/cspNonceRef.d.ts +8 -0
- package/dist/src/utils/fontAssets.d.ts +17 -0
- package/dist/src/utils/formActionProtocol.d.ts +10 -0
- package/dist/src/utils/generateHeadElement.d.ts +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/inlinePageCss.d.ts +18 -0
- package/dist/src/utils/loadConfig.d.ts +5 -0
- package/dist/src/utils/localeRef.d.ts +10 -0
- package/dist/src/utils/resolveConvention.d.ts +6 -1
- package/dist/src/utils/streamingSlots.d.ts +5 -0
- package/dist/src/vue/browser.d.ts +2 -0
- package/dist/src/vue/components/Image.d.ts +2 -2
- package/dist/src/vue/index.d.ts +2 -0
- package/dist/src/vue/serverDataPayload.d.ts +32 -0
- package/dist/src/vue/serverDataState.d.ts +9 -0
- package/dist/src/vue/useServerData.browser.d.ts +6 -0
- package/dist/src/vue/useServerData.d.ts +24 -0
- package/dist/svelte/browser.js +330 -3
- package/dist/svelte/browser.js.map +8 -4
- package/dist/svelte/components/AwaitSlot.svelte +5 -0
- package/dist/svelte/components/Head.svelte +50 -0
- package/dist/svelte/components/JsonLd.svelte +9 -1
- package/dist/svelte/components/StreamSlot.svelte +5 -0
- package/dist/svelte/index.js +1017 -117
- package/dist/svelte/index.js.map +38 -24
- package/dist/svelte/router/Link.svelte +40 -8
- package/dist/svelte/router/Route.svelte +157 -12
- package/dist/svelte/router/Route.svelte.d.ts +39 -5
- package/dist/svelte/router/Router.svelte +140 -25
- package/dist/svelte/router/Router.svelte.d.ts +5 -1
- package/dist/svelte/router/browser.ts +10 -0
- package/dist/svelte/router/goto.ts +15 -86
- package/dist/svelte/router/guards.ts +112 -0
- package/dist/svelte/router/index.ts +10 -0
- package/dist/svelte/router/lazy.ts +82 -0
- package/dist/svelte/router/lazyModule.ts +74 -0
- package/dist/svelte/router/navigation.ts +412 -0
- package/dist/svelte/router/pushState.ts +7 -4
- package/dist/svelte/router/scroll.ts +286 -0
- package/dist/svelte/server.js +747 -252
- package/dist/svelte/server.js.map +30 -20
- package/dist/types/angular.d.ts +2 -0
- package/dist/types/build.d.ts +37 -0
- package/dist/types/conventions.d.ts +3 -0
- package/dist/types/fileRoutes.d.ts +72 -0
- package/dist/types/fonts.d.ts +86 -0
- package/dist/types/formAction.d.ts +54 -0
- package/dist/types/globals.d.ts +10 -0
- package/dist/types/i18n.d.ts +185 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/metadata.d.ts +11 -0
- package/dist/types/navigation.d.ts +37 -0
- package/dist/types/prefetch.d.ts +10 -0
- package/dist/types/sitemap.d.ts +4 -0
- package/dist/types/svelteRouter.d.ts +89 -2
- package/dist/types/svelteRouter.ts +112 -2
- package/dist/types/vue.d.ts +46 -1
- package/dist/utils/iconVersion.ts +34 -0
- package/dist/vue/browser.js +107 -11
- package/dist/vue/browser.js.map +7 -4
- package/dist/vue/components/index.js +5 -2
- package/dist/vue/components/index.js.map +5 -4
- package/dist/vue/index.js +712 -158
- package/dist/vue/index.js.map +32 -23
- package/dist/vue/server.js +310 -79
- package/dist/vue/server.js.map +20 -15
- package/package.json +9 -1
- package/dist/cli/prerender-mfnwsvyt.js +0 -7
- package/dist/src/plugins/pageRouter.d.ts +0 -1
- /package/dist/cli/{index-j7m8pq48.js → index-rervww4p.js} +0 -0
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/utils/runtimeMode.ts
|
|
3
|
+
var ENV_VAR = "NODE_ENV", getNodeEnv = () => process.env[ENV_VAR], isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
4
|
+
|
|
2
5
|
// src/core/streamingSlotRegistrar.ts
|
|
3
6
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
4
7
|
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
@@ -40,7 +43,7 @@ var setStreamingSlotWarningController = (controller) => {
|
|
|
40
43
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
41
44
|
};
|
|
42
45
|
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
43
|
-
if (isStreamingSlotCollectionActive()) {
|
|
46
|
+
if (isProductionRuntime() || isStreamingSlotCollectionActive()) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
getWarningController()?.maybeWarn(primitiveName);
|
|
@@ -55,5 +58,5 @@ export {
|
|
|
55
58
|
warnMissingStreamingSlotCollector
|
|
56
59
|
};
|
|
57
60
|
|
|
58
|
-
//# debugId=
|
|
61
|
+
//# debugId=8D60BFFA24E01FAE64756E2164756E21
|
|
59
62
|
//# sourceMappingURL=streamingSlotRegistrar.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/streamingSlotRegistrar.ts"],
|
|
3
|
+
"sources": ["../src/utils/runtimeMode.ts", "../src/core/streamingSlotRegistrar.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"
|
|
5
|
+
"/* Bundler-safe NODE_ENV reader.\n *\n * Bun (like esbuild and most modern bundlers) statically replaces\n * `process.env.NODE_ENV` with the build-time string. When absolutejs\n * itself is bundled (`bun run scripts/build.ts`), NODE_ENV is unset,\n * so every `process.env.NODE_ENV === 'production'` site collapses to\n * `false` and the production branch is dead-code-eliminated from\n * `dist/`. That breaks `bun start`, `bun compile`, and the standalone\n * compiled binary — they all run with NODE_ENV=production but see the\n * dev branches baked in.\n *\n * Computed-property access (`process.env[KEY]`) is NOT constant-folded\n * by Bun, so we read NODE_ENV through a string variable. Both branches\n * stay live in `dist/`, and the consumer's actual runtime NODE_ENV\n * decides which one fires.\n *\n * Verified empirically: Bun's bundler matches the literal AST shape\n * `MemberExpression { object: process.env, property: NODE_ENV }` for\n * its replacement. Computed-key access uses\n * `MemberExpression { computed: true, property: Identifier(KEY) }`,\n * which doesn't match the pattern. */\n\nconst ENV_VAR = 'NODE_ENV';\n\nexport const getNodeEnv = () => process.env[ENV_VAR];\nexport const isDevelopmentRuntime = () =>\n\tprocess.env[ENV_VAR] === 'development';\nexport const isProductionRuntime = () => process.env[ENV_VAR] === 'production';\n",
|
|
6
|
+
"import { isProductionRuntime } from '../utils/runtimeMode';\nimport type { StreamingSlot } from '../utils/streamingSlots';\n\ntype StreamingSlotRegistrar = (slot: StreamingSlot) => void;\ntype StreamingSlotWarningController = {\n\tmaybeWarn(primitiveName: string): void;\n};\ntype StreamingSlotCollectionController = {\n\tisCollecting(): boolean;\n};\n\nconst STREAMING_SLOT_REGISTRAR_KEY = Symbol.for(\n\t'absolutejs.streamingSlotRegistrar'\n);\nconst STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for(\n\t'absolutejs.streamingSlotWarningController'\n);\nconst STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for(\n\t'absolutejs.streamingSlotCollectionController'\n);\n\nconst getRegisteredStreamingSlotRegistrar = () => {\n\tconst value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);\n\tif (typeof value === 'function' || value === null) {\n\t\treturn value;\n\t}\n\n\treturn undefined;\n};\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object';\n\nconst isStreamingSlotWarningController = (\n\tvalue: unknown\n): value is StreamingSlotWarningController =>\n\tisObjectRecord(value) &&\n\t'maybeWarn' in value &&\n\ttypeof value.maybeWarn === 'function';\n\nconst isStreamingSlotCollectionController = (\n\tvalue: unknown\n): value is StreamingSlotCollectionController =>\n\tisObjectRecord(value) &&\n\t'isCollecting' in value &&\n\ttypeof value.isCollecting === 'function';\n\nconst getWarningController = () => {\n\tconst value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);\n\tif (value === null || typeof value === 'undefined') return undefined;\n\n\treturn isStreamingSlotWarningController(value) ? value : undefined;\n};\n\nconst getCollectionController = () => {\n\tconst value = Reflect.get(\n\t\tglobalThis,\n\t\tSTREAMING_SLOT_COLLECTION_STORAGE_KEY\n\t);\n\tif (value === null || typeof value === 'undefined') return undefined;\n\n\treturn isStreamingSlotCollectionController(value) ? value : undefined;\n};\n\nexport const hasRegisteredStreamingSlotRegistrar = () =>\n\ttypeof getRegisteredStreamingSlotRegistrar() === 'function';\nexport const isStreamingSlotCollectionActive = () =>\n\tgetCollectionController()?.isCollecting() === true;\nexport const registerStreamingSlot = (slot: StreamingSlot) => {\n\tgetRegisteredStreamingSlotRegistrar()?.(slot);\n};\nexport const setStreamingSlotCollectionController = (\n\tcontroller: StreamingSlotCollectionController | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);\n};\nexport const setStreamingSlotRegistrar = (\n\tnextRegistrar: StreamingSlotRegistrar | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);\n};\nexport const setStreamingSlotWarningController = (\n\tcontroller: StreamingSlotWarningController | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);\n};\nexport const warnMissingStreamingSlotCollector = (primitiveName: string) => {\n\tif (isProductionRuntime() || isStreamingSlotCollectionActive()) {\n\t\treturn;\n\t}\n\n\tgetWarningController()?.maybeWarn(primitiveName);\n};\n"
|
|
6
7
|
],
|
|
7
|
-
"mappings": ";;
|
|
8
|
-
"debugId": "
|
|
8
|
+
"mappings": ";;IAsBM,UAAU,YAEH,aAAa,MAAM,QAAQ,IAAI,UAC/B,uBAAuB,MACnC,QAAQ,IAAI,aAAa,eACb,sBAAsB,MAAM,QAAQ,IAAI,aAAa;;;AChBlE,IAAM,+BAA+B,OAAO,IAC3C,mCACD;AACA,IAAM,qCAAqC,OAAO,IACjD,2CACD;AACA,IAAM,wCAAwC,OAAO,IACpD,8CACD;AAEA,IAAM,sCAAsC,MAAM;AAAA,EACjD,MAAM,QAAQ,QAAQ,IAAI,YAAY,4BAA4B;AAAA,EAClE,IAAI,OAAO,UAAU,cAAc,UAAU,MAAM;AAAA,IAClD,OAAO;AAAA,EACR;AAAA,EAEA;AAAA;AAGD,IAAM,iBAAiB,CAAC,UACvB,QAAQ,KAAK,KAAK,OAAO,UAAU;AAEpC,IAAM,mCAAmC,CACxC,UAEA,eAAe,KAAK,MACpB,eAAe,UACf,OAAO,MAAM,cAAc;AAE5B,IAAM,sCAAsC,CAC3C,UAEA,eAAe,KAAK,MACpB,kBAAkB,UAClB,OAAO,MAAM,iBAAiB;AAE/B,IAAM,uBAAuB,MAAM;AAAA,EAClC,MAAM,QAAQ,QAAQ,IAAI,YAAY,kCAAkC;AAAA,EACxE,IAAI,UAAU,QAAQ,OAAO,UAAU;AAAA,IAAa;AAAA,EAEpD,OAAO,iCAAiC,KAAK,IAAI,QAAQ;AAAA;AAG1D,IAAM,0BAA0B,MAAM;AAAA,EACrC,MAAM,QAAQ,QAAQ,IACrB,YACA,qCACD;AAAA,EACA,IAAI,UAAU,QAAQ,OAAO,UAAU;AAAA,IAAa;AAAA,EAEpD,OAAO,oCAAoC,KAAK,IAAI,QAAQ;AAAA;AAGtD,IAAM,sCAAsC,MAClD,OAAO,oCAAoC,MAAM;AAC3C,IAAM,kCAAkC,MAC9C,wBAAwB,GAAG,aAAa,MAAM;AACxC,IAAM,wBAAwB,CAAC,SAAwB;AAAA,EAC7D,oCAAoC,IAAI,IAAI;AAAA;AAEtC,IAAM,uCAAuC,CACnD,eACI;AAAA,EACJ,QAAQ,IAAI,YAAY,uCAAuC,UAAU;AAAA;AAEnE,IAAM,4BAA4B,CACxC,kBACI;AAAA,EACJ,QAAQ,IAAI,YAAY,8BAA8B,aAAa;AAAA;AAE7D,IAAM,oCAAoC,CAChD,eACI;AAAA,EACJ,QAAQ,IAAI,YAAY,oCAAoC,UAAU;AAAA;AAEhE,IAAM,oCAAoC,CAAC,kBAA0B;AAAA,EAC3E,IAAI,oBAAoB,KAAK,gCAAgC,GAAG;AAAA,IAC/D;AAAA,EACD;AAAA,EAEA,qBAAqB,GAAG,UAAU,aAAa;AAAA;",
|
|
9
|
+
"debugId": "8D60BFFA24E01FAE64756E2164756E21",
|
|
9
10
|
"names": []
|
|
10
11
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
// src/utils/runtimeMode.ts
|
|
3
|
+
var ENV_VAR = "NODE_ENV", getNodeEnv = () => process.env[ENV_VAR], isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
4
|
+
|
|
2
5
|
// src/core/streamingSlotRegistrar.ts
|
|
3
6
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
4
7
|
var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
|
|
@@ -40,7 +43,7 @@ var setStreamingSlotWarningController = (controller) => {
|
|
|
40
43
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
41
44
|
};
|
|
42
45
|
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
43
|
-
if (isStreamingSlotCollectionActive()) {
|
|
46
|
+
if (isProductionRuntime() || isStreamingSlotCollectionActive()) {
|
|
44
47
|
return;
|
|
45
48
|
}
|
|
46
49
|
getWarningController()?.maybeWarn(primitiveName);
|
|
@@ -111,5 +114,5 @@ export {
|
|
|
111
114
|
runWithStreamingSlotRegistry
|
|
112
115
|
};
|
|
113
116
|
|
|
114
|
-
//# debugId=
|
|
117
|
+
//# debugId=3B31AEA3DCB5AEB464756E2164756E21
|
|
115
118
|
//# sourceMappingURL=streamingSlotRegistry.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/core/streamingSlotRegistrar.ts", "../src/core/streamingSlotRegistry.ts"],
|
|
3
|
+
"sources": ["../src/utils/runtimeMode.ts", "../src/core/streamingSlotRegistrar.ts", "../src/core/streamingSlotRegistry.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"
|
|
5
|
+
"/* Bundler-safe NODE_ENV reader.\n *\n * Bun (like esbuild and most modern bundlers) statically replaces\n * `process.env.NODE_ENV` with the build-time string. When absolutejs\n * itself is bundled (`bun run scripts/build.ts`), NODE_ENV is unset,\n * so every `process.env.NODE_ENV === 'production'` site collapses to\n * `false` and the production branch is dead-code-eliminated from\n * `dist/`. That breaks `bun start`, `bun compile`, and the standalone\n * compiled binary — they all run with NODE_ENV=production but see the\n * dev branches baked in.\n *\n * Computed-property access (`process.env[KEY]`) is NOT constant-folded\n * by Bun, so we read NODE_ENV through a string variable. Both branches\n * stay live in `dist/`, and the consumer's actual runtime NODE_ENV\n * decides which one fires.\n *\n * Verified empirically: Bun's bundler matches the literal AST shape\n * `MemberExpression { object: process.env, property: NODE_ENV }` for\n * its replacement. Computed-key access uses\n * `MemberExpression { computed: true, property: Identifier(KEY) }`,\n * which doesn't match the pattern. */\n\nconst ENV_VAR = 'NODE_ENV';\n\nexport const getNodeEnv = () => process.env[ENV_VAR];\nexport const isDevelopmentRuntime = () =>\n\tprocess.env[ENV_VAR] === 'development';\nexport const isProductionRuntime = () => process.env[ENV_VAR] === 'production';\n",
|
|
6
|
+
"import { isProductionRuntime } from '../utils/runtimeMode';\nimport type { StreamingSlot } from '../utils/streamingSlots';\n\ntype StreamingSlotRegistrar = (slot: StreamingSlot) => void;\ntype StreamingSlotWarningController = {\n\tmaybeWarn(primitiveName: string): void;\n};\ntype StreamingSlotCollectionController = {\n\tisCollecting(): boolean;\n};\n\nconst STREAMING_SLOT_REGISTRAR_KEY = Symbol.for(\n\t'absolutejs.streamingSlotRegistrar'\n);\nconst STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for(\n\t'absolutejs.streamingSlotWarningController'\n);\nconst STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for(\n\t'absolutejs.streamingSlotCollectionController'\n);\n\nconst getRegisteredStreamingSlotRegistrar = () => {\n\tconst value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);\n\tif (typeof value === 'function' || value === null) {\n\t\treturn value;\n\t}\n\n\treturn undefined;\n};\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object';\n\nconst isStreamingSlotWarningController = (\n\tvalue: unknown\n): value is StreamingSlotWarningController =>\n\tisObjectRecord(value) &&\n\t'maybeWarn' in value &&\n\ttypeof value.maybeWarn === 'function';\n\nconst isStreamingSlotCollectionController = (\n\tvalue: unknown\n): value is StreamingSlotCollectionController =>\n\tisObjectRecord(value) &&\n\t'isCollecting' in value &&\n\ttypeof value.isCollecting === 'function';\n\nconst getWarningController = () => {\n\tconst value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);\n\tif (value === null || typeof value === 'undefined') return undefined;\n\n\treturn isStreamingSlotWarningController(value) ? value : undefined;\n};\n\nconst getCollectionController = () => {\n\tconst value = Reflect.get(\n\t\tglobalThis,\n\t\tSTREAMING_SLOT_COLLECTION_STORAGE_KEY\n\t);\n\tif (value === null || typeof value === 'undefined') return undefined;\n\n\treturn isStreamingSlotCollectionController(value) ? value : undefined;\n};\n\nexport const hasRegisteredStreamingSlotRegistrar = () =>\n\ttypeof getRegisteredStreamingSlotRegistrar() === 'function';\nexport const isStreamingSlotCollectionActive = () =>\n\tgetCollectionController()?.isCollecting() === true;\nexport const registerStreamingSlot = (slot: StreamingSlot) => {\n\tgetRegisteredStreamingSlotRegistrar()?.(slot);\n};\nexport const setStreamingSlotCollectionController = (\n\tcontroller: StreamingSlotCollectionController | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);\n};\nexport const setStreamingSlotRegistrar = (\n\tnextRegistrar: StreamingSlotRegistrar | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);\n};\nexport const setStreamingSlotWarningController = (\n\tcontroller: StreamingSlotWarningController | null\n) => {\n\tReflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);\n};\nexport const warnMissingStreamingSlotCollector = (primitiveName: string) => {\n\tif (isProductionRuntime() || isStreamingSlotCollectionActive()) {\n\t\treturn;\n\t}\n\n\tgetWarningController()?.maybeWarn(primitiveName);\n};\n",
|
|
6
7
|
"import type { StreamingSlot } from '../utils/streamingSlots';\nimport {\n\tsetStreamingSlotCollectionController,\n\tsetStreamingSlotRegistrar\n} from './streamingSlotRegistrar';\n\ntype SlotStore = Map<string, StreamingSlot>;\ntype AsyncLocalStorageType =\n\timport('node:async_hooks').AsyncLocalStorage<SlotStore>;\n\nconst STREAMING_SLOT_STORAGE_KEY = Symbol.for(\n\t'absolutejs.streamingSlotAsyncLocalStorage'\n);\n\nconst isObjectRecord = (value: unknown): value is Record<string, unknown> =>\n\tBoolean(value) && typeof value === 'object';\n\nconst isAsyncLocalStorage = (value: unknown): value is AsyncLocalStorageType =>\n\tisObjectRecord(value) &&\n\t'getStore' in value &&\n\ttypeof value.getStore === 'function' &&\n\t'run' in value &&\n\ttypeof value.run === 'function';\n\nconst getStorageGlobal = () => {\n\tconst value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);\n\tif (value === null || typeof value === 'undefined') {\n\t\treturn value;\n\t}\n\n\treturn isAsyncLocalStorage(value) ? value : undefined;\n};\n\nconst isServerRuntime = () =>\n\ttypeof process !== 'undefined' &&\n\ttypeof process.versions?.node === 'string';\n\nconst ensureAsyncLocalStorage = async () => {\n\tconst storage = getStorageGlobal();\n\tif (typeof storage !== 'undefined') {\n\t\treturn storage;\n\t}\n\tif (!isServerRuntime()) {\n\t\tReflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);\n\n\t\treturn getStorageGlobal();\n\t}\n\n\tconst mod = await import('node:async_hooks');\n\tReflect.set(\n\t\tglobalThis,\n\t\tSTREAMING_SLOT_STORAGE_KEY,\n\t\tnew mod.AsyncLocalStorage<SlotStore>()\n\t);\n\n\treturn getStorageGlobal();\n};\n\nconst getActiveSlotStore = () => {\n\tconst storage = getStorageGlobal();\n\tif (!storage) return undefined;\n\n\treturn storage.getStore();\n};\n\nconst registerStreamingSlot = (slot: StreamingSlot) => {\n\tconst store = getActiveSlotStore();\n\tif (!store) return;\n\tstore.set(slot.id, slot);\n};\n\nsetStreamingSlotRegistrar(registerStreamingSlot);\nsetStreamingSlotCollectionController({\n\tisCollecting: () => getActiveSlotStore() !== undefined\n});\n\nexport const hasActiveStreamingSlotRegistry = () =>\n\tgetActiveSlotStore() !== undefined;\n\nexport const runWithStreamingSlotRegistry = async <T>(\n\ttask: () => Promise<T> | T\n) => {\n\tconst storage = await ensureAsyncLocalStorage();\n\tif (!storage) {\n\t\tconst slots: StreamingSlot[] = [];\n\n\t\treturn {\n\t\t\tresult: await task(),\n\t\t\tslots\n\t\t};\n\t}\n\n\treturn storage.run(new Map<string, StreamingSlot>(), async () => {\n\t\tconst result = await task();\n\t\tconst store = storage.getStore();\n\n\t\treturn {\n\t\t\tresult,\n\t\t\tslots: store ? [...store.values()] : []\n\t\t};\n\t});\n};\n"
|
|
7
8
|
],
|
|
8
|
-
"mappings": ";;
|
|
9
|
-
"debugId": "
|
|
9
|
+
"mappings": "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",
|
|
10
|
+
"debugId": "3B31AEA3DCB5AEB464756E2164756E21",
|
|
10
11
|
"names": []
|
|
11
12
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type {} from '../../types/globals';
|
|
2
|
+
/* The page's CSP nonce, read back in the browser from an element the server
|
|
3
|
+
* gave it to. Browsers hide the attribute's value but keep the `nonce`
|
|
4
|
+
* property, so a script that runs can hand the nonce to the <style>/<script>
|
|
5
|
+
* elements it creates; a nonce-based policy blocks them otherwise. Without
|
|
6
|
+
* secureHeaders() there is no nonce and this does nothing.
|
|
7
|
+
*
|
|
8
|
+
* Lives in the dev client because that ships as raw TypeScript and may only
|
|
9
|
+
* import from its own directory; the bundled client runtime
|
|
10
|
+
* (src/client/prefetch.ts) imports it from here. */
|
|
11
|
+
|
|
12
|
+
export const applyPageNonce = <Element extends HTMLElement>(
|
|
13
|
+
element: Element
|
|
14
|
+
) => {
|
|
15
|
+
const nonce = readPageNonce();
|
|
16
|
+
if (nonce) element.nonce = nonce;
|
|
17
|
+
|
|
18
|
+
return element;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const readPageNonce = () => {
|
|
22
|
+
if (typeof document === 'undefined') return undefined;
|
|
23
|
+
const carrier = document.querySelector<HTMLElement>(
|
|
24
|
+
'script[nonce], style[nonce]'
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return carrier?.nonce || undefined;
|
|
28
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {} from '../../../types/globals';
|
|
2
2
|
/* HTML + script HMR update handlers */
|
|
3
3
|
|
|
4
|
+
import { applyPageNonce } from '../cspNonce';
|
|
4
5
|
import { DOM_UPDATE_DELAY_MS } from '../constants';
|
|
5
6
|
import { patchDOMInPlace } from '../domDiff';
|
|
6
7
|
import {
|
|
@@ -287,7 +288,7 @@ const replaceInlineScript = (script: Element) => {
|
|
|
287
288
|
return;
|
|
288
289
|
}
|
|
289
290
|
|
|
290
|
-
const newScript = document.createElement('script');
|
|
291
|
+
const newScript = applyPageNonce(document.createElement('script'));
|
|
291
292
|
newScript.textContent = script.textContent || '';
|
|
292
293
|
const scriptEl = script instanceof HTMLScriptElement ? script : null;
|
|
293
294
|
newScript.type = scriptEl?.type || 'text/javascript';
|
|
@@ -331,7 +332,7 @@ const updateHTMLBodyDirect = (
|
|
|
331
332
|
|
|
332
333
|
removeOldScripts(container);
|
|
333
334
|
newScripts.forEach((scriptInfo) => {
|
|
334
|
-
const newScript = document.createElement('script');
|
|
335
|
+
const newScript = applyPageNonce(document.createElement('script'));
|
|
335
336
|
const separator = scriptInfo.src.includes('?') ? '&' : '?';
|
|
336
337
|
newScript.src = `${scriptInfo.src + separator}t=${Date.now()}`;
|
|
337
338
|
newScript.type = scriptInfo.type;
|
|
@@ -437,7 +438,7 @@ const reExecuteScripts = (
|
|
|
437
438
|
removeOldScripts(container);
|
|
438
439
|
|
|
439
440
|
newScripts.forEach((scriptInfo) => {
|
|
440
|
-
const newScript = document.createElement('script');
|
|
441
|
+
const newScript = applyPageNonce(document.createElement('script'));
|
|
441
442
|
const separator = scriptInfo.src.includes('?') ? '&' : '?';
|
|
442
443
|
newScript.src = `${scriptInfo.src + separator}t=${Date.now()}`;
|
|
443
444
|
newScript.type = scriptInfo.type;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {} from '../../../types/globals';
|
|
2
2
|
/* HTMX HMR update handler */
|
|
3
3
|
|
|
4
|
+
import { applyPageNonce } from '../cspNonce';
|
|
4
5
|
import { DOM_UPDATE_DELAY_MS } from '../constants';
|
|
5
6
|
import { patchDOMInPlace } from '../domDiff';
|
|
6
7
|
import {
|
|
@@ -148,7 +149,7 @@ const removeOldScripts = (container: HTMLElement) => {
|
|
|
148
149
|
|
|
149
150
|
const addNewScripts = (container: HTMLElement, newScripts: ScriptInfo[]) => {
|
|
150
151
|
newScripts.forEach((scriptInfo) => {
|
|
151
|
-
const newScript = document.createElement('script');
|
|
152
|
+
const newScript = applyPageNonce(document.createElement('script'));
|
|
152
153
|
const separator = scriptInfo.src.includes('?') ? '&' : '?';
|
|
153
154
|
newScript.src = `${scriptInfo.src + separator}t=${Date.now()}`;
|
|
154
155
|
newScript.type = scriptInfo.type;
|
|
@@ -161,7 +162,7 @@ const replaceInlineScript = (script: Element) => {
|
|
|
161
162
|
return;
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
const newScript = document.createElement('script');
|
|
165
|
+
const newScript = applyPageNonce(document.createElement('script'));
|
|
165
166
|
newScript.textContent = script.textContent || '';
|
|
166
167
|
newScript.type = script.getAttribute('type') || 'text/javascript';
|
|
167
168
|
if (script.parentNode) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {} from '../../../types/globals';
|
|
2
2
|
/* Svelte HMR update handler */
|
|
3
3
|
|
|
4
|
+
import { applyPageNonce } from '../cspNonce';
|
|
4
5
|
import { SVELTE_CSS_LOAD_TIMEOUT_MS } from '../constants';
|
|
5
6
|
import {
|
|
6
7
|
saveDOMState,
|
|
@@ -16,53 +17,6 @@ type SvelteHmrWindow = Window & {
|
|
|
16
17
|
__SVELTE_HMR_ACCEPT__?: Record<string, (mod: unknown) => void>;
|
|
17
18
|
};
|
|
18
19
|
|
|
19
|
-
const extractCountFromDOM = () => {
|
|
20
|
-
const countButton = document.querySelector('button');
|
|
21
|
-
if (!countButton || !countButton.textContent) {
|
|
22
|
-
return {};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const countMatch = countButton.textContent.match(/(\d+)/);
|
|
26
|
-
if (!countMatch) {
|
|
27
|
-
return {};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return { initialCount: parseInt(countMatch[1] ?? '0', 10) };
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const loadStateFromSession = () => {
|
|
34
|
-
try {
|
|
35
|
-
const stored = sessionStorage.getItem('__SVELTE_HMR_STATE__');
|
|
36
|
-
if (!stored) {
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const parsed: Record<string, unknown> = JSON.parse(stored);
|
|
41
|
-
if (parsed && Object.keys(parsed).length > 0) {
|
|
42
|
-
return parsed;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return {};
|
|
46
|
-
} catch {
|
|
47
|
-
return {};
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const saveStateToSession = (preservedState: Record<string, unknown>) => {
|
|
52
|
-
if (Object.keys(preservedState).length === 0) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
sessionStorage.setItem(
|
|
58
|
-
'__SVELTE_HMR_STATE__',
|
|
59
|
-
JSON.stringify(preservedState)
|
|
60
|
-
);
|
|
61
|
-
} catch {
|
|
62
|
-
/* ignore */
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
20
|
const collectCssRules = (sheet: CSSStyleSheet) => {
|
|
67
21
|
let rules = '';
|
|
68
22
|
for (let idx = 0; idx < sheet.cssRules.length; idx++) {
|
|
@@ -81,7 +35,7 @@ const preserveLinkAsInlineStyle = (link: HTMLLinkElement) => {
|
|
|
81
35
|
return null;
|
|
82
36
|
}
|
|
83
37
|
|
|
84
|
-
const style = document.createElement('style');
|
|
38
|
+
const style = applyPageNonce(document.createElement('style'));
|
|
85
39
|
style.dataset.hmrPreserved = 'true';
|
|
86
40
|
style.textContent = collectCssRules(sheet);
|
|
87
41
|
document.head.appendChild(style);
|
|
@@ -116,7 +70,7 @@ const preserveAllStylesheets = () => {
|
|
|
116
70
|
'head style:not([data-hmr-preserved])'
|
|
117
71
|
)
|
|
118
72
|
.forEach((style) => {
|
|
119
|
-
const clone = document.createElement('style');
|
|
73
|
+
const clone = applyPageNonce(document.createElement('style'));
|
|
120
74
|
clone.dataset.hmrPreserved = 'true';
|
|
121
75
|
clone.textContent = style.textContent;
|
|
122
76
|
document.head.appendChild(clone);
|
|
@@ -217,22 +171,15 @@ export const handleSvelteUpdate = (message: {
|
|
|
217
171
|
return;
|
|
218
172
|
}
|
|
219
173
|
|
|
220
|
-
/* Component update
|
|
174
|
+
/* Component update. Svelte's own HMR keeps state: `$.hmr` swaps only the
|
|
175
|
+
* edited component, so every other component's `$state` survives. The
|
|
176
|
+
* edited component restarts from its real props, as in any Svelte HMR
|
|
177
|
+
* setup; nothing here reads state back out of the DOM. */
|
|
221
178
|
|
|
222
179
|
/* Save DOM state and scroll position */
|
|
223
180
|
const domState = saveDOMState(document.body);
|
|
224
181
|
const scrollState = saveScrollState();
|
|
225
182
|
|
|
226
|
-
let preservedState: Record<string, unknown> = extractCountFromDOM();
|
|
227
|
-
|
|
228
|
-
if (Object.keys(preservedState).length === 0) {
|
|
229
|
-
preservedState = loadStateFromSession();
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
/* Set preserved state on window + backup to sessionStorage */
|
|
233
|
-
window.__HMR_PRESERVED_STATE__ = preservedState;
|
|
234
|
-
saveStateToSession(preservedState);
|
|
235
|
-
|
|
236
183
|
/* CSS pre-update: swap stylesheet BEFORE importing to prevent FOUC */
|
|
237
184
|
if (message.data.cssUrl) {
|
|
238
185
|
const cssBaseName = message.data.cssBaseName || '';
|
|
@@ -273,48 +220,26 @@ export const handleSvelteUpdate = (message: {
|
|
|
273
220
|
}
|
|
274
221
|
|
|
275
222
|
import(modulePath)
|
|
276
|
-
.then(
|
|
277
|
-
let applied = false;
|
|
223
|
+
.then((newModule) => {
|
|
278
224
|
if (acceptFn) {
|
|
279
225
|
acceptFn(newModule);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
const remount = window.__SVELTE_REMOUNT__;
|
|
288
|
-
const hasPreserved =
|
|
289
|
-
preserved && Object.keys(preserved).length > 0;
|
|
290
|
-
|
|
291
|
-
if (applied) await Promise.resolve();
|
|
292
|
-
if (applied && typeof remount === 'function' && hasPreserved) {
|
|
293
|
-
remount({
|
|
294
|
-
...(window.__INITIAL_PROPS__ ?? {}),
|
|
295
|
-
...preserved
|
|
296
|
-
});
|
|
297
|
-
} else if (!applied && typeof remount === 'function') {
|
|
298
|
-
/* Resilience fallback: no accept callback was found, so
|
|
299
|
-
* `$.hmr` never wired the freshly imported module in. The
|
|
300
|
-
* import warmed the module cache; remount the page with
|
|
301
|
-
* merged props to actually apply the new code instead of
|
|
302
|
-
* silently doing nothing. */
|
|
303
|
-
remount({
|
|
304
|
-
...(window.__INITIAL_PROPS__ ?? {}),
|
|
305
|
-
...(preserved ?? {})
|
|
226
|
+
} else if (typeof window.__SVELTE_REMOUNT__ === 'function') {
|
|
227
|
+
/* No accept callback was registered for this module, so
|
|
228
|
+
* `$.hmr` can't wire the new code in. The import warmed the
|
|
229
|
+
* module cache; remount the page with its own props so the
|
|
230
|
+
* update still lands. */
|
|
231
|
+
window.__SVELTE_REMOUNT__({
|
|
232
|
+
...(window.__INITIAL_PROPS__ ?? {})
|
|
306
233
|
});
|
|
307
234
|
} else {
|
|
308
235
|
/* Last resort: nothing can apply the update in place. */
|
|
309
236
|
console.warn(
|
|
310
237
|
'[HMR] Svelte accept callback missing and no remount available; reloading'
|
|
311
238
|
);
|
|
312
|
-
window.__HMR_PRESERVED_STATE__ = undefined;
|
|
313
239
|
window.location.reload();
|
|
314
240
|
|
|
315
241
|
return undefined;
|
|
316
242
|
}
|
|
317
|
-
window.__HMR_PRESERVED_STATE__ = undefined;
|
|
318
243
|
|
|
319
244
|
if (message.data.serverDuration !== undefined) {
|
|
320
245
|
sendAbsoluteHmrTiming({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {} from '../../types/globals';
|
|
2
|
+
import { applyPageNonce } from './cspNonce';
|
|
2
3
|
import {
|
|
3
4
|
discardSyncRuntimeDeadLetter,
|
|
4
5
|
inspectSyncRuntime,
|
|
@@ -131,7 +132,7 @@ export const installAbsoluteNativeSyncDevtools = (
|
|
|
131
132
|
host.id = DEVTOOLS_ID;
|
|
132
133
|
host.dataset.hmrOverlay = 'true';
|
|
133
134
|
const root = host.attachShadow({ mode: 'open' });
|
|
134
|
-
const style = document.createElement('style');
|
|
135
|
+
const style = applyPageNonce(document.createElement('style'));
|
|
135
136
|
style.textContent = styles;
|
|
136
137
|
const trigger = document.createElement('button');
|
|
137
138
|
trigger.className = 'trigger';
|
|
@@ -486,8 +486,10 @@ var init_loadConfig = __esm(() => {
|
|
|
486
486
|
"emberDirectory",
|
|
487
487
|
"entry",
|
|
488
488
|
"env",
|
|
489
|
+
"fileRoutes",
|
|
489
490
|
"htmlDirectory",
|
|
490
491
|
"htmxDirectory",
|
|
492
|
+
"fonts",
|
|
491
493
|
"images",
|
|
492
494
|
"incrementalFiles",
|
|
493
495
|
"islands",
|
|
@@ -506,6 +508,7 @@ var init_loadConfig = __esm(() => {
|
|
|
506
508
|
"tailwind",
|
|
507
509
|
"ready",
|
|
508
510
|
"visibility",
|
|
511
|
+
"vitals",
|
|
509
512
|
"vueDirectory"
|
|
510
513
|
]);
|
|
511
514
|
});
|
|
@@ -172785,6 +172788,10 @@ var init_install = __esm(() => {
|
|
|
172785
172788
|
init_plugin();
|
|
172786
172789
|
});
|
|
172787
172790
|
|
|
172791
|
+
// src/utils/runtimeMode.ts
|
|
172792
|
+
var ENV_VAR = "NODE_ENV";
|
|
172793
|
+
var isDevelopmentRuntime = () => process.env[ENV_VAR] === "development";
|
|
172794
|
+
|
|
172788
172795
|
// src/dev/serverBootstrap.ts
|
|
172789
172796
|
init_constants();
|
|
172790
172797
|
import { copyFileSync as copyFileSync2, existsSync as existsSync2, readdirSync, unlinkSync } from "fs";
|
|
@@ -172998,8 +173005,8 @@ if (!isHotReevaluation && !globalThis.__absoluteBunServer && process.env.ABSOLUT
|
|
|
172998
173005
|
const earlyHost = process.env.ABSOLUTE_HOST ?? process.env.HOST ?? "localhost";
|
|
172999
173006
|
const earlyPort = Number(process.env.ABSOLUTE_PORT ?? process.env.PORT ?? DEFAULT_PORT);
|
|
173000
173007
|
const loadEarlyTls = async () => {
|
|
173001
|
-
if (
|
|
173002
|
-
;
|
|
173008
|
+
if (!isDevelopmentRuntime())
|
|
173009
|
+
return null;
|
|
173003
173010
|
if (process.env.ABSOLUTE_HTTPS !== "true")
|
|
173004
173011
|
return null;
|
|
173005
173012
|
try {
|
|
@@ -173024,7 +173031,7 @@ if (!isHotReevaluation && !globalThis.__absoluteBunServer && process.env.ABSOLUT
|
|
|
173024
173031
|
}
|
|
173025
173032
|
}
|
|
173026
173033
|
}
|
|
173027
|
-
if (!isHotReevaluation &&
|
|
173034
|
+
if (!isHotReevaluation && isDevelopmentRuntime() && process.env.ABSOLUTE_DEV_PREBUILD !== "0" && process.env.ABSOLUTE_DEV_IMPORT_COST !== "1") {
|
|
173028
173035
|
const compiledRuntime = join4(import.meta.dir, "..", "index.js");
|
|
173029
173036
|
const runtimeEntry = existsSync2(compiledRuntime) ? compiledRuntime : join4(import.meta.dir, "..", "index.ts");
|
|
173030
173037
|
markBoot("prebuild import issued");
|
|
@@ -173041,7 +173048,7 @@ if (importCostRecorder !== undefined) {
|
|
|
173041
173048
|
importCostRecorder.entryOriginalModule = entryPath;
|
|
173042
173049
|
importCostRecorder.rootModule = import.meta.path;
|
|
173043
173050
|
}
|
|
173044
|
-
if (!isHotReevaluation &&
|
|
173051
|
+
if (!isHotReevaluation && isDevelopmentRuntime()) {
|
|
173045
173052
|
await Promise.resolve().then(() => init_install());
|
|
173046
173053
|
await startBackendHmr(entryPath);
|
|
173047
173054
|
markBoot("backend hmr ready");
|