@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
package/dist/vue/index.js
CHANGED
|
@@ -72,13 +72,44 @@ var __esm = (fn, res, err) => () => {
|
|
|
72
72
|
};
|
|
73
73
|
var __require = import.meta.require;
|
|
74
74
|
|
|
75
|
+
// src/utils/escapeScriptContent.ts
|
|
76
|
+
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
77
|
+
const escaped = ESCAPE_LOOKUP[char];
|
|
78
|
+
return escaped !== undefined ? escaped : char;
|
|
79
|
+
});
|
|
80
|
+
var init_escapeScriptContent = __esm(() => {
|
|
81
|
+
ESCAPE_LOOKUP = {
|
|
82
|
+
"\u2028": "\\u2028",
|
|
83
|
+
"\u2029": "\\u2029",
|
|
84
|
+
"<": "\\u003C"
|
|
85
|
+
};
|
|
86
|
+
ESCAPE_REGEX = /[<\u2028\u2029]/g;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// src/utils/cspNonceRef.ts
|
|
90
|
+
var GETTER_KEY, nonceAttr = (nonce = readCspNonce()) => nonce ? ` nonce="${nonce}"` : "", nonceSvelteHeadStyles = (head, nonce = readCspNonce()) => nonce ? head.replace(/<style(?=\s+id="svelte-[^"]*")(?![^>]*\snonce=)/g, `<style nonce="${nonce}"`) : head, readCspNonce = () => {
|
|
91
|
+
const getter = Reflect.get(globalThis, GETTER_KEY);
|
|
92
|
+
if (typeof getter !== "function")
|
|
93
|
+
return;
|
|
94
|
+
const nonce = getter();
|
|
95
|
+
return typeof nonce === "string" ? nonce : undefined;
|
|
96
|
+
}, registerCspNonceGetter = (getter) => {
|
|
97
|
+
Reflect.set(globalThis, GETTER_KEY, getter);
|
|
98
|
+
};
|
|
99
|
+
var init_cspNonceRef = __esm(() => {
|
|
100
|
+
GETTER_KEY = Symbol.for("absolutejs.cspNonceGetter");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// src/utils/runtimeMode.ts
|
|
104
|
+
var ENV_VAR = "NODE_ENV", getNodeEnv = () => process.env[ENV_VAR], isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
105
|
+
|
|
75
106
|
// src/utils/inlinePageCss.ts
|
|
76
107
|
var siblingCssCache, clearSiblingCssCache = () => {
|
|
77
108
|
siblingCssCache.clear();
|
|
78
109
|
}, injectInlineCss = (headTag, css) => {
|
|
79
110
|
if (!css)
|
|
80
111
|
return headTag;
|
|
81
|
-
const styleBlock = `<style data-absolute-page-css>${css}</style>`;
|
|
112
|
+
const styleBlock = `<style data-absolute-page-css${nonceAttr()}>${css}</style>`;
|
|
82
113
|
return headTag.replace("</head>", `${styleBlock}</head>`);
|
|
83
114
|
}, readSiblingCss = async (siblingJsPath) => {
|
|
84
115
|
if (!siblingJsPath)
|
|
@@ -100,6 +131,7 @@ var siblingCssCache, clearSiblingCssCache = () => {
|
|
|
100
131
|
}
|
|
101
132
|
};
|
|
102
133
|
var init_inlinePageCss = __esm(() => {
|
|
134
|
+
init_cspNonceRef();
|
|
103
135
|
siblingCssCache = new Map;
|
|
104
136
|
});
|
|
105
137
|
|
|
@@ -196,6 +228,45 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
196
228
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
197
229
|
};
|
|
198
230
|
|
|
231
|
+
// src/core/staticHtmlNonce.ts
|
|
232
|
+
var nonceStaticHtml = async (html, nonce = readCspNonce()) => {
|
|
233
|
+
if (!nonce)
|
|
234
|
+
return html;
|
|
235
|
+
const stamp = {
|
|
236
|
+
element: (element) => {
|
|
237
|
+
if (!element.hasAttribute("nonce"))
|
|
238
|
+
element.setAttribute("nonce", nonce);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
return new HTMLRewriter().on("script", stamp).on("style", stamp).transform(new Response(html)).text();
|
|
242
|
+
}, isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value), parseHtmxConfig = (content) => {
|
|
243
|
+
try {
|
|
244
|
+
const parsed = JSON.parse(content ?? "{}");
|
|
245
|
+
return isRecord(parsed) ? parsed : {};
|
|
246
|
+
} catch {
|
|
247
|
+
return {};
|
|
248
|
+
}
|
|
249
|
+
}, withHtmxStyleNonce = async (html, nonce = readCspNonce()) => {
|
|
250
|
+
if (!nonce)
|
|
251
|
+
return html;
|
|
252
|
+
let found = false;
|
|
253
|
+
const merged = await new HTMLRewriter().on('meta[name="htmx-config"]', {
|
|
254
|
+
element: (element) => {
|
|
255
|
+
found = true;
|
|
256
|
+
const config = parseHtmxConfig(element.getAttribute("content"));
|
|
257
|
+
element.setAttribute("content", JSON.stringify({ ...config, inlineStyleNonce: nonce }));
|
|
258
|
+
}
|
|
259
|
+
}).transform(new Response(html)).text();
|
|
260
|
+
if (found)
|
|
261
|
+
return merged;
|
|
262
|
+
const meta = `<meta name="htmx-config" content='${JSON.stringify({ inlineStyleNonce: nonce })}'>`;
|
|
263
|
+
const headClose = merged.search(/<\/head>/i);
|
|
264
|
+
return headClose >= 0 ? `${merged.slice(0, headClose)}${meta}${merged.slice(headClose)}` : `${meta}${merged}`;
|
|
265
|
+
};
|
|
266
|
+
var init_staticHtmlNonce = __esm(() => {
|
|
267
|
+
init_cspNonceRef();
|
|
268
|
+
});
|
|
269
|
+
|
|
199
270
|
// src/utils/resolveConvention.ts
|
|
200
271
|
import { basename } from "path";
|
|
201
272
|
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
@@ -232,7 +303,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
232
303
|
return conventions.defaults?.error;
|
|
233
304
|
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
234
305
|
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
235
|
-
}, isDev = () =>
|
|
306
|
+
}, isDev = () => isDevelopmentRuntime(), buildErrorProps = (error) => {
|
|
236
307
|
if (error instanceof Error) {
|
|
237
308
|
return {
|
|
238
309
|
message: error.message,
|
|
@@ -249,7 +320,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
249
320
|
if (typeof ErrorComponent !== "function")
|
|
250
321
|
return null;
|
|
251
322
|
const element = createElement(ErrorComponent, errorProps);
|
|
252
|
-
const stream = await renderToReadableStream(element
|
|
323
|
+
const stream = await renderToReadableStream(element, {
|
|
324
|
+
nonce: readCspNonce()
|
|
325
|
+
});
|
|
253
326
|
return new Response(stream, {
|
|
254
327
|
headers: { "Content-Type": "text/html" },
|
|
255
328
|
status: 500
|
|
@@ -260,10 +333,12 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
260
333
|
const ErrorComponent = mod.default;
|
|
261
334
|
if (!ErrorComponent)
|
|
262
335
|
return null;
|
|
336
|
+
const nonce = readCspNonce();
|
|
263
337
|
const { head, body } = render(ErrorComponent, {
|
|
264
|
-
props: errorProps
|
|
338
|
+
props: errorProps,
|
|
339
|
+
...nonce ? { csp: { nonce } } : {}
|
|
265
340
|
});
|
|
266
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
341
|
+
const html = `<!DOCTYPE html><html><head>${nonceSvelteHeadStyles(head)}</head><body>${body}</body></html>`;
|
|
267
342
|
return new Response(html, {
|
|
268
343
|
headers: { "Content-Type": "text/html" },
|
|
269
344
|
status: 500
|
|
@@ -271,7 +346,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
271
346
|
}, unescapeVueStyles = (ssrBody) => {
|
|
272
347
|
let styles = "";
|
|
273
348
|
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
274
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
349
|
+
styles += `<style${nonceAttr()}>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
275
350
|
return "";
|
|
276
351
|
});
|
|
277
352
|
return { body, styles };
|
|
@@ -303,7 +378,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
303
378
|
status: 500
|
|
304
379
|
});
|
|
305
380
|
}, escapeHtml = (value) => value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), replaceErrorTokens = (template, errorProps) => template.replace(/\{\{\s*name\s*\}\}/g, escapeHtml(errorProps.name)).replace(/\{\{\s*message\s*\}\}/g, escapeHtml(errorProps.message)).replace(/\{\{\s*stack\s*\}\}/g, errorProps.stack ? escapeHtml(errorProps.stack) : ""), renderHtmlError = async (conventionPath, errorProps) => {
|
|
306
|
-
const template = await Bun.file(conventionPath).text();
|
|
381
|
+
const template = await nonceStaticHtml(await Bun.file(conventionPath).text());
|
|
307
382
|
const html = replaceErrorTokens(template, errorProps);
|
|
308
383
|
return new Response(html, {
|
|
309
384
|
headers: { "Content-Type": "text/html" },
|
|
@@ -358,7 +433,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
358
433
|
if (typeof NotFoundComponent !== "function")
|
|
359
434
|
return null;
|
|
360
435
|
const element = createElement(NotFoundComponent);
|
|
361
|
-
const stream = await renderToReadableStream(element
|
|
436
|
+
const stream = await renderToReadableStream(element, {
|
|
437
|
+
nonce: readCspNonce()
|
|
438
|
+
});
|
|
362
439
|
return new Response(stream, {
|
|
363
440
|
headers: { "Content-Type": "text/html" },
|
|
364
441
|
status: 404
|
|
@@ -369,8 +446,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
369
446
|
const NotFoundComponent = mod.default;
|
|
370
447
|
if (!NotFoundComponent)
|
|
371
448
|
return null;
|
|
372
|
-
const
|
|
373
|
-
const
|
|
449
|
+
const nonce = readCspNonce();
|
|
450
|
+
const { head, body } = render(NotFoundComponent, nonce ? { csp: { nonce } } : {});
|
|
451
|
+
const html = `<!DOCTYPE html><html><head>${nonceSvelteHeadStyles(head)}</head><body>${body}</body></html>`;
|
|
374
452
|
return new Response(html, {
|
|
375
453
|
headers: { "Content-Type": "text/html" },
|
|
376
454
|
status: 404
|
|
@@ -403,7 +481,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
403
481
|
status: 404
|
|
404
482
|
});
|
|
405
483
|
}, renderHtmlNotFound = async (conventionPath) => {
|
|
406
|
-
const html = await Bun.file(conventionPath).text();
|
|
484
|
+
const html = await nonceStaticHtml(await Bun.file(conventionPath).text());
|
|
407
485
|
return new Response(html, {
|
|
408
486
|
headers: { "Content-Type": "text/html" },
|
|
409
487
|
status: 404
|
|
@@ -421,7 +499,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
421
499
|
logConventionRenderError(framework, "not-found", renderError);
|
|
422
500
|
}
|
|
423
501
|
return null;
|
|
424
|
-
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
502
|
+
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async (options = {}) => {
|
|
425
503
|
const renderNext = async (frameworks) => {
|
|
426
504
|
const [framework, ...remaining] = frameworks;
|
|
427
505
|
if (!framework) {
|
|
@@ -436,13 +514,16 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
436
514
|
}
|
|
437
515
|
return renderNext(remaining);
|
|
438
516
|
};
|
|
439
|
-
return renderNext(NOT_FOUND_PRIORITY);
|
|
517
|
+
return renderNext(options.preferHtmx ? ["htmx", ...NOT_FOUND_PRIORITY.filter((key) => key !== "htmx")] : NOT_FOUND_PRIORITY);
|
|
440
518
|
};
|
|
441
519
|
var init_resolveConvention = __esm(() => {
|
|
520
|
+
init_cspNonceRef();
|
|
521
|
+
init_staticHtmlNonce();
|
|
442
522
|
ERROR_RENDERERS = {
|
|
443
523
|
angular: renderAngularError,
|
|
444
524
|
ember: renderEmberError,
|
|
445
525
|
html: renderHtmlError,
|
|
526
|
+
htmx: renderHtmlError,
|
|
446
527
|
react: renderReactError,
|
|
447
528
|
svelte: renderSvelteError,
|
|
448
529
|
vue: renderVueError
|
|
@@ -451,6 +532,7 @@ var init_resolveConvention = __esm(() => {
|
|
|
451
532
|
angular: renderAngularNotFound,
|
|
452
533
|
ember: renderEmberNotFound,
|
|
453
534
|
html: renderHtmlNotFound,
|
|
535
|
+
htmx: renderHtmlNotFound,
|
|
454
536
|
react: renderReactNotFound,
|
|
455
537
|
svelte: renderSvelteNotFound,
|
|
456
538
|
vue: renderVueNotFound
|
|
@@ -460,7 +542,8 @@ var init_resolveConvention = __esm(() => {
|
|
|
460
542
|
"svelte",
|
|
461
543
|
"vue",
|
|
462
544
|
"angular",
|
|
463
|
-
"html"
|
|
545
|
+
"html",
|
|
546
|
+
"htmx"
|
|
464
547
|
];
|
|
465
548
|
});
|
|
466
549
|
|
|
@@ -749,15 +832,15 @@ var ISLAND_BOOTSTRAP_MANIFEST_KEY = "AbsoluteIslandBootstrap", LEGACY_ISLAND_BOO
|
|
|
749
832
|
var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__", ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__", CLOSING_HEAD_TAG = "</head>", warnedMissingBootstrap = false, warnIfBootstrapMissing = (manifest) => {
|
|
750
833
|
if (warnedMissingBootstrap || getIslandBootstrapPath(manifest))
|
|
751
834
|
return;
|
|
752
|
-
if (
|
|
753
|
-
;
|
|
835
|
+
if (isProductionRuntime())
|
|
836
|
+
return;
|
|
754
837
|
warnedMissingBootstrap = true;
|
|
755
838
|
logWarn("A page contains islands, but the build manifest has no islands bootstrap, so they will render without hydrating. Set `islands.registry` in absolute.config.ts (a default bootstrap is generated from it) or point `islands.bootstrap` at a file that calls startIslands().");
|
|
756
839
|
}, buildIslandsHeadMarkup = (manifest) => {
|
|
757
|
-
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
758
|
-
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
840
|
+
const manifestScript = `<script${nonceAttr()}>window.__ABSOLUTE_MANIFEST__ = ${escapeScriptContent(JSON.stringify(manifest))}</script>`;
|
|
841
|
+
const islandStateScript = `<script${nonceAttr()}>window.__ABS_ISLAND_STATE__ = ${escapeScriptContent(JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {}))}</script>`;
|
|
759
842
|
const bootstrapPath = getIslandBootstrapPath(manifest);
|
|
760
|
-
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
843
|
+
const bootstrapScript = bootstrapPath ? `<script${nonceAttr()} type="module" src="${bootstrapPath}"></script>` : "";
|
|
761
844
|
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
762
845
|
}, injectHeadMarkup = (html, markup) => {
|
|
763
846
|
const closingHeadIndex = html.indexOf("</head>");
|
|
@@ -958,6 +1041,8 @@ var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST
|
|
|
958
1041
|
globalThis.__absoluteManifest = manifest;
|
|
959
1042
|
};
|
|
960
1043
|
var init_islandPageContext = __esm(() => {
|
|
1044
|
+
init_escapeScriptContent();
|
|
1045
|
+
init_cspNonceRef();
|
|
961
1046
|
init_logger();
|
|
962
1047
|
});
|
|
963
1048
|
|
|
@@ -1087,7 +1172,7 @@ var errorPageHtml = ({
|
|
|
1087
1172
|
<meta charset="utf-8">
|
|
1088
1173
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1089
1174
|
<title>SSR Error - AbsoluteJS</title>
|
|
1090
|
-
<style>
|
|
1175
|
+
<style${nonceAttr()}>
|
|
1091
1176
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
1092
1177
|
body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:"JetBrains Mono","Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}
|
|
1093
1178
|
.card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}
|
|
@@ -1119,20 +1204,23 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
1119
1204
|
${script}
|
|
1120
1205
|
</body>
|
|
1121
1206
|
</html>`;
|
|
1122
|
-
},
|
|
1207
|
+
}, reloadOnRebuild = () => `<script${nonceAttr()}>(()=>{const url=(location.protocol==='https:'?'wss://':'ws://')+location.host+'/hmr';let seen=false;const connect=()=>{const socket=new WebSocket(url);socket.onopen=()=>{if(seen)location.reload();seen=true;};socket.onmessage=(event)=>{try{const message=JSON.parse(event.data);const type=message&&typeof message.type==='string'?message.type:'';if(type==='rebuild-complete'||type==='server-entry-reloaded'||type.endsWith('-update'))location.reload();}catch{}};socket.onclose=()=>setTimeout(connect,500);};connect();})();</script>`, buildErrorPage = (framework, pageName, error) => errorPageHtml({
|
|
1123
1208
|
framework,
|
|
1124
1209
|
hint: "Fix the file and save. This page reloads by itself when the build succeeds.",
|
|
1125
1210
|
kind: "Build Error",
|
|
1126
1211
|
message: `${pageName || "This page"} could not be built.
|
|
1127
1212
|
|
|
1128
1213
|
${error ?? "The dev-server terminal has the build output."}`,
|
|
1129
|
-
script:
|
|
1214
|
+
script: reloadOnRebuild()
|
|
1130
1215
|
}), ssrErrorPage = (framework, error) => errorPageHtml({
|
|
1131
1216
|
framework,
|
|
1132
1217
|
hint: "A component threw during server-side rendering. Check the terminal for the full stack trace.",
|
|
1133
1218
|
kind: "Server Render Error",
|
|
1134
1219
|
message: error instanceof Error ? error.message : String(error)
|
|
1135
1220
|
});
|
|
1221
|
+
var init_ssrErrorPage = __esm(() => {
|
|
1222
|
+
init_cspNonceRef();
|
|
1223
|
+
});
|
|
1136
1224
|
|
|
1137
1225
|
// src/core/requestContext.ts
|
|
1138
1226
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
@@ -1206,6 +1294,7 @@ var REQUEST_STORAGE_KEY, PAGE_WARMER_KEY, isAbsoluteRequestStorage = (value) =>
|
|
|
1206
1294
|
return headClose ? head.slice(0, headClose.index) + links + head.slice(headClose.index) : head + links;
|
|
1207
1295
|
};
|
|
1208
1296
|
var init_requestContext = __esm(() => {
|
|
1297
|
+
init_ssrErrorPage();
|
|
1209
1298
|
REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
|
|
1210
1299
|
PAGE_WARMER_KEY = Symbol.for("absolutejs.devPageWarmer");
|
|
1211
1300
|
absoluteRequestContext = new Elysia2({
|
|
@@ -1333,13 +1422,13 @@ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json", ABSO
|
|
|
1333
1422
|
}, headerVaryValues, envelopeResponse = (response, status) => new Response(JSON.stringify({
|
|
1334
1423
|
protocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
|
|
1335
1424
|
response
|
|
1336
|
-
}), { headers: responseHeaders(), status }),
|
|
1425
|
+
}), { headers: responseHeaders(), status }), isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), normalizeJsonValue = (value) => {
|
|
1337
1426
|
const serialized = JSON.stringify(value);
|
|
1338
1427
|
if (serialized === undefined) {
|
|
1339
1428
|
throw new TypeError("Mobile page props must be JSON-serializable.");
|
|
1340
1429
|
}
|
|
1341
1430
|
const parsed = JSON.parse(serialized);
|
|
1342
|
-
if (!
|
|
1431
|
+
if (!isRecord2(parsed)) {
|
|
1343
1432
|
throw new TypeError("Mobile page props must serialize to an object.");
|
|
1344
1433
|
}
|
|
1345
1434
|
return parsed;
|
|
@@ -1369,7 +1458,9 @@ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json", ABSO
|
|
|
1369
1458
|
return createAbsoluteMobilePageErrorResponse(page.pageId);
|
|
1370
1459
|
}
|
|
1371
1460
|
}, finalizeAbsoluteNativeRouteDevelopmentPage = (input) => {
|
|
1372
|
-
if (
|
|
1461
|
+
if (!isDevelopmentRuntime()) {
|
|
1462
|
+
return createAbsoluteMobileInvalidRequestResponse("The native-route development representation is disabled outside development.");
|
|
1463
|
+
}
|
|
1373
1464
|
if (input.request?.method !== "GET") {
|
|
1374
1465
|
return createAbsoluteMobileInvalidRequestResponse("Native-route data requests must use GET.");
|
|
1375
1466
|
}
|
|
@@ -1711,22 +1802,15 @@ var streamSwapRuntime = () => {
|
|
|
1711
1802
|
return value.slice(start + 1, end);
|
|
1712
1803
|
}, getStreamSwapRuntimeScript = () => `(function(){${stripFunctionWrapper(streamSwapRuntime.toString())}})();`;
|
|
1713
1804
|
|
|
1714
|
-
// src/utils/escapeScriptContent.ts
|
|
1715
|
-
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
1716
|
-
const escaped = ESCAPE_LOOKUP[char];
|
|
1717
|
-
return escaped !== undefined ? escaped : char;
|
|
1718
|
-
});
|
|
1719
|
-
var init_escapeScriptContent = __esm(() => {
|
|
1720
|
-
ESCAPE_LOOKUP = {
|
|
1721
|
-
"\u2028": "\\u2028",
|
|
1722
|
-
"\u2029": "\\u2029",
|
|
1723
|
-
"<": "\\u003C"
|
|
1724
|
-
};
|
|
1725
|
-
ESCAPE_REGEX = /[<\u2028\u2029]/g;
|
|
1726
|
-
});
|
|
1727
|
-
|
|
1728
1805
|
// src/utils/streamingSlots.ts
|
|
1729
|
-
var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG2 = "</head>", CLOSING_BODY_TAG_LENGTH, CLOSING_HEAD_TAG_LENGTH, CLOSING_PAGE_TAG_REGEX, STREAMING_RUNTIME_GLOBAL = "__ABS_SLOT_ENQUEUE__", STREAMING_PENDING_GLOBAL = "__ABS_SLOT_PENDING__", STREAM_TAIL_LOOKBEHIND = 128, STREAMING_SLOT_TIMEOUT_MS = 5000,
|
|
1806
|
+
var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG2 = "</head>", CLOSING_BODY_TAG_LENGTH, CLOSING_HEAD_TAG_LENGTH, CLOSING_PAGE_TAG_REGEX, STREAMING_RUNTIME_GLOBAL = "__ABS_SLOT_ENQUEUE__", STREAMING_PENDING_GLOBAL = "__ABS_SLOT_PENDING__", STREAM_TAIL_LOOKBEHIND = 128, STREAMING_SLOT_TIMEOUT_MS = 5000, findSafeFlushIndex = (text, cut) => {
|
|
1807
|
+
const head = text.slice(0, cut);
|
|
1808
|
+
const openScript = head.lastIndexOf("<script");
|
|
1809
|
+
const scriptCut = openScript > head.lastIndexOf("</script>") ? openScript : cut;
|
|
1810
|
+
const beforeScript = text.slice(0, scriptCut);
|
|
1811
|
+
const openTag = beforeScript.lastIndexOf("<");
|
|
1812
|
+
return openTag > beforeScript.lastIndexOf(">") ? openTag : scriptCut;
|
|
1813
|
+
}, STREAMING_SLOT_MAX_PER_RESPONSE = 128, STREAMING_SLOT_MAX_HTML_BYTES = 64000, createSlotPatchStatement = (id, payload) => `(window.${STREAMING_RUNTIME_GLOBAL}||function(i,p){window.${STREAMING_PENDING_GLOBAL}=window.${STREAMING_PENDING_GLOBAL}||{};window.${STREAMING_PENDING_GLOBAL}[i]=p;})(${JSON.stringify(id)},${JSON.stringify(payload)});`, createNonceAttr = (nonce) => nonceAttr(nonce), createStreamingSlotId = () => `${SLOT_ID_PREFIX}${Math.random().toString(BASE_36_RADIX).slice(2, RANDOM_ID_END_INDEX)}`, getStreamingSlotsRuntimeScript = () => getStreamSwapRuntimeScript(), injectHtmlIntoBody = (html, injection) => {
|
|
1730
1814
|
const closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);
|
|
1731
1815
|
if (closingBodyIndex >= 0) {
|
|
1732
1816
|
return `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;
|
|
@@ -1744,7 +1828,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1744
1828
|
getStreamingSlotsRuntimeScript()
|
|
1745
1829
|
].filter(Boolean).join(";");
|
|
1746
1830
|
return `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;
|
|
1747
|
-
}, toUint8 = (value, encoder) => encoder.encode(value),
|
|
1831
|
+
}, toUint8 = (value, encoder) => encoder.encode(value), isRecord3 = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord3(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
|
|
1748
1832
|
if (isSafeHtmlLike(value)) {
|
|
1749
1833
|
return value.changingThisBreaksApplicationSecurity;
|
|
1750
1834
|
}
|
|
@@ -1805,7 +1889,8 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1805
1889
|
}, createTimeoutError = (slot, timeoutMs) => {
|
|
1806
1890
|
const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
|
|
1807
1891
|
return error;
|
|
1808
|
-
}, isSlotPatchPayloadObject = (value) =>
|
|
1892
|
+
}, isSlotPatchPayloadObject = (value) => isRecord3(value) && ("html" in value), isTimeoutError = (error) => isRecord3(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
|
|
1893
|
+
dynamic: slot.dynamic,
|
|
1809
1894
|
errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
|
|
1810
1895
|
fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
|
|
1811
1896
|
id: slot.id ?? createStreamingSlotId(),
|
|
@@ -2030,9 +2115,10 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
2030
2115
|
if (tail.length <= STREAM_TAIL_LOOKBEHIND) {
|
|
2031
2116
|
return tail;
|
|
2032
2117
|
}
|
|
2033
|
-
const
|
|
2034
|
-
|
|
2035
|
-
|
|
2118
|
+
const cut = findSafeFlushIndex(tail, tail.length - STREAM_TAIL_LOOKBEHIND);
|
|
2119
|
+
if (cut > 0)
|
|
2120
|
+
controller.enqueue(encoder.encode(tail.slice(0, cut)));
|
|
2121
|
+
return tail.slice(cut);
|
|
2036
2122
|
};
|
|
2037
2123
|
const finalizeCompletedBaseWinner = (controller, decodedTail, baseRead) => {
|
|
2038
2124
|
const footerStart = decodedTail.search(CLOSING_PAGE_TAG_REGEX);
|
|
@@ -2265,6 +2351,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
2265
2351
|
});
|
|
2266
2352
|
};
|
|
2267
2353
|
var init_streamingSlots = __esm(() => {
|
|
2354
|
+
init_cspNonceRef();
|
|
2268
2355
|
init_constants();
|
|
2269
2356
|
init_escapeScriptContent();
|
|
2270
2357
|
CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;
|
|
@@ -2279,6 +2366,42 @@ var init_streamingSlots = __esm(() => {
|
|
|
2279
2366
|
};
|
|
2280
2367
|
});
|
|
2281
2368
|
|
|
2369
|
+
// src/core/partialPrerender.ts
|
|
2370
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
2371
|
+
import { existsSync, readFileSync } from "fs";
|
|
2372
|
+
import { rm } from "fs/promises";
|
|
2373
|
+
var PARTIAL_HOLES_HEADER = "X-Absolute-Partial-Holes", PARTIAL_SHELL_HEADER = "X-Absolute-Partial-Shell", SINK_STORAGE_KEY, isSinkStorage = (value) => value instanceof AsyncLocalStorage3, getSinkStorage = () => {
|
|
2374
|
+
const existing = Reflect.get(globalThis, SINK_STORAGE_KEY);
|
|
2375
|
+
if (isSinkStorage(existing))
|
|
2376
|
+
return existing;
|
|
2377
|
+
const created = new AsyncLocalStorage3;
|
|
2378
|
+
Reflect.set(globalThis, SINK_STORAGE_KEY, created);
|
|
2379
|
+
return created;
|
|
2380
|
+
}, activePartialHolesSink = () => getSinkStorage().getStore(), collectPartialHoles = async (render) => {
|
|
2381
|
+
const sink = { slots: undefined };
|
|
2382
|
+
const response = await getSinkStorage().run(sink, render);
|
|
2383
|
+
return { response, slots: sink.slots };
|
|
2384
|
+
}, decodePartialHoles = (value) => value ? value.split(",").filter(Boolean).map((id) => decodeURIComponent(id)) : [], encodePartialHoles = (ids) => ids.map((id) => encodeURIComponent(id)).join(","), isDynamicStreamingSlot = (slot) => slot.dynamic === true, isPartialShellCapture = (request) => request?.headers.get(PARTIAL_SHELL_HEADER) === "1", holesPath = (htmlPath) => htmlPath.replace(/\.html$/, ".holes"), readPartialHoles = (htmlPath) => {
|
|
2385
|
+
const path = holesPath(htmlPath);
|
|
2386
|
+
if (!existsSync(path))
|
|
2387
|
+
return [];
|
|
2388
|
+
return decodePartialHoles(readFileSync(path, "utf-8").trim().split(`
|
|
2389
|
+
`).join(","));
|
|
2390
|
+
}, writePartialHoles = async (htmlPath, response) => {
|
|
2391
|
+
const ids = decodePartialHoles(response.headers.get(PARTIAL_HOLES_HEADER));
|
|
2392
|
+
if (ids.length > 0) {
|
|
2393
|
+
await Bun.write(holesPath(htmlPath), `${encodePartialHoles(ids).split(",").join(`
|
|
2394
|
+
`)}
|
|
2395
|
+
`);
|
|
2396
|
+
} else {
|
|
2397
|
+
await rm(holesPath(htmlPath), { force: true });
|
|
2398
|
+
}
|
|
2399
|
+
return ids;
|
|
2400
|
+
};
|
|
2401
|
+
var init_partialPrerender = __esm(() => {
|
|
2402
|
+
SINK_STORAGE_KEY = Symbol.for("absolutejs.partialPrerenderHolesSink");
|
|
2403
|
+
});
|
|
2404
|
+
|
|
2282
2405
|
// src/core/routeAssets.ts
|
|
2283
2406
|
var LINK_TAG_RE, REL_STYLESHEET_RE, HREF_RE, TITLE_RE, ENTITIES, ENTITY_RE, decodeEntities = (value) => value.replace(ENTITY_RE, (match) => ENTITIES[match] ?? match), readHeadStylesheets = (head) => {
|
|
2284
2407
|
if (!head)
|
|
@@ -2328,7 +2451,7 @@ var init_browserTranslationAttributes = __esm(() => {
|
|
|
2328
2451
|
});
|
|
2329
2452
|
|
|
2330
2453
|
// src/core/browserTranslation.ts
|
|
2331
|
-
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
2454
|
+
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script${nonceAttr()}>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
2332
2455
|
if (html.includes(BASELINE_MARKER))
|
|
2333
2456
|
return html;
|
|
2334
2457
|
const script = browserTranslationBaselineTag();
|
|
@@ -2338,19 +2461,20 @@ var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BAS
|
|
|
2338
2461
|
return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;
|
|
2339
2462
|
};
|
|
2340
2463
|
var init_browserTranslation = __esm(() => {
|
|
2464
|
+
init_cspNonceRef();
|
|
2341
2465
|
init_browserTranslationAttributes();
|
|
2342
2466
|
BROWSER_TRANSLATION_BASELINE_SCRIPT = "window.__ABSOLUTE_SSR_TEXT_BASELINES__=new WeakMap();" + "window.__ABSOLUTE_SSR_ATTRIBUTE_BASELINES__=new WeakMap();" + "{const r=document.body,b=window.__ABSOLUTE_SSR_TEXT_BASELINES__," + "a=window.__ABSOLUTE_SSR_ATTRIBUTE_BASELINES__;" + 'if(r)for(const e of [r,...r.querySelectorAll("*")]){' + "const t=new Map();for(const [i,n]of[...e.childNodes].entries())" + 'if(n.nodeType===3)t.set(i,n.nodeValue??"");if(t.size)b.set(e,t);' + `const v=new Map();for(const k of ${JSON.stringify(TRANSLATABLE_ATTRIBUTES)}){` + "const s=e.getAttribute(k);if(s!==null)v.set(k,s);}if(v.size)a.set(e,v);}}";
|
|
2343
2467
|
});
|
|
2344
2468
|
|
|
2345
2469
|
// src/cli/scripts/telemetry.ts
|
|
2346
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
2470
|
+
import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
2347
2471
|
import { homedir } from "os";
|
|
2348
2472
|
import { join } from "path";
|
|
2349
2473
|
var configDir, configPath, getTelemetryConfig = () => {
|
|
2350
2474
|
try {
|
|
2351
|
-
if (!
|
|
2475
|
+
if (!existsSync2(configPath))
|
|
2352
2476
|
return null;
|
|
2353
|
-
const raw =
|
|
2477
|
+
const raw = readFileSync2(configPath, "utf-8");
|
|
2354
2478
|
const config = JSON.parse(raw);
|
|
2355
2479
|
return config;
|
|
2356
2480
|
} catch {
|
|
@@ -2363,14 +2487,14 @@ var init_telemetry = __esm(() => {
|
|
|
2363
2487
|
});
|
|
2364
2488
|
|
|
2365
2489
|
// src/cli/telemetryEvent.ts
|
|
2366
|
-
import { existsSync as
|
|
2490
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
2367
2491
|
import { arch, platform } from "os";
|
|
2368
2492
|
import { dirname as dirname3, join as join2, parse } from "path";
|
|
2369
2493
|
var checkCandidate = (candidate) => {
|
|
2370
|
-
if (!
|
|
2494
|
+
if (!existsSync3(candidate)) {
|
|
2371
2495
|
return null;
|
|
2372
2496
|
}
|
|
2373
|
-
const pkg = JSON.parse(
|
|
2497
|
+
const pkg = JSON.parse(readFileSync3(candidate, "utf-8"));
|
|
2374
2498
|
if (pkg.name === "@absolutejs/absolute") {
|
|
2375
2499
|
const ver = pkg.version;
|
|
2376
2500
|
return ver;
|
|
@@ -2424,17 +2548,17 @@ var init_telemetryEvent = __esm(() => {
|
|
|
2424
2548
|
});
|
|
2425
2549
|
|
|
2426
2550
|
// src/dev/buildHMRClient.ts
|
|
2427
|
-
import { existsSync as
|
|
2551
|
+
import { existsSync as existsSync4 } from "fs";
|
|
2428
2552
|
import { resolve as resolve2 } from "path";
|
|
2429
2553
|
var {build: bunBuild } = globalThis.Bun;
|
|
2430
2554
|
var resolveHmrClientPath = () => {
|
|
2431
2555
|
const projectRoot = process.cwd();
|
|
2432
2556
|
const fromSource = resolve2(import.meta.dir, "client/hmrClient.ts");
|
|
2433
|
-
if (
|
|
2557
|
+
if (existsSync4(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
2434
2558
|
return fromSource;
|
|
2435
2559
|
}
|
|
2436
2560
|
const fromNodeModules = resolve2(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client/hmrClient.ts");
|
|
2437
|
-
if (
|
|
2561
|
+
if (existsSync4(fromNodeModules))
|
|
2438
2562
|
return fromNodeModules;
|
|
2439
2563
|
return resolve2(import.meta.dir, "dev/client/hmrClient.ts");
|
|
2440
2564
|
}, hmrClientPath, buildHMRClient = async () => {
|
|
@@ -2474,14 +2598,14 @@ var defineIslandComponent = (component, options) => ({
|
|
|
2474
2598
|
component,
|
|
2475
2599
|
export: options.export,
|
|
2476
2600
|
source: options.source
|
|
2477
|
-
}), defineIslandRegistry = (registry) => registry,
|
|
2601
|
+
}), defineIslandRegistry = (registry) => registry, isRecord5 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
|
|
2478
2602
|
if (!isIslandComponentDefinition(component))
|
|
2479
2603
|
return null;
|
|
2480
2604
|
return {
|
|
2481
2605
|
export: component.export,
|
|
2482
2606
|
source: component.source
|
|
2483
2607
|
};
|
|
2484
|
-
}, isIslandComponentDefinition = (value) =>
|
|
2608
|
+
}, isIslandComponentDefinition = (value) => isRecord5(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
|
|
2485
2609
|
if (!rawProps)
|
|
2486
2610
|
return {};
|
|
2487
2611
|
return JSON.parse(rawProps);
|
|
@@ -2513,21 +2637,21 @@ var requireCurrentIslandRegistry = () => {
|
|
|
2513
2637
|
};
|
|
2514
2638
|
|
|
2515
2639
|
// src/angular/resolveAngularPackage.ts
|
|
2516
|
-
import { existsSync as
|
|
2640
|
+
import { existsSync as existsSync5, readFileSync as readFileSync4 } from "fs";
|
|
2517
2641
|
import { join as join3, resolve as resolve3 } from "path";
|
|
2518
2642
|
var resolveAngularPackageDir = (specifier) => {
|
|
2519
2643
|
const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve3(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
|
|
2520
|
-
if (fromCompiledRuntime &&
|
|
2644
|
+
if (fromCompiledRuntime && existsSync5(fromCompiledRuntime)) {
|
|
2521
2645
|
return fromCompiledRuntime;
|
|
2522
2646
|
}
|
|
2523
2647
|
const fromProject = resolve3(process.cwd(), "node_modules", specifier);
|
|
2524
|
-
if (
|
|
2648
|
+
if (existsSync5(fromProject)) {
|
|
2525
2649
|
return fromProject;
|
|
2526
2650
|
}
|
|
2527
2651
|
return null;
|
|
2528
2652
|
}, resolvePackageEntry = (packageDir) => {
|
|
2529
2653
|
try {
|
|
2530
|
-
const pkg = JSON.parse(
|
|
2654
|
+
const pkg = JSON.parse(readFileSync4(join3(packageDir, "package.json"), "utf-8"));
|
|
2531
2655
|
const rootExport = pkg.exports?.["."];
|
|
2532
2656
|
const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
|
|
2533
2657
|
return join3(packageDir, entry);
|
|
@@ -2546,16 +2670,13 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
2546
2670
|
].filter((value) => Boolean(value));
|
|
2547
2671
|
for (const buildDir of buildDirs) {
|
|
2548
2672
|
const vendorPath = join3(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
|
|
2549
|
-
if (
|
|
2673
|
+
if (existsSync5(vendorPath))
|
|
2550
2674
|
return vendorPath;
|
|
2551
2675
|
}
|
|
2552
2676
|
return resolveAngularPackage(specifier);
|
|
2553
2677
|
};
|
|
2554
2678
|
var init_resolveAngularPackage = () => {};
|
|
2555
2679
|
|
|
2556
|
-
// src/utils/runtimeMode.ts
|
|
2557
|
-
var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
2558
|
-
|
|
2559
2680
|
// src/angular/angularPatch.ts
|
|
2560
2681
|
var ensureHead = (doc) => {
|
|
2561
2682
|
if (!doc || doc.head || !doc.documentElement) {
|
|
@@ -2729,6 +2850,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
2729
2850
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
2730
2851
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
2731
2852
|
Component: core.Component,
|
|
2853
|
+
CSP_NONCE: core.CSP_NONCE,
|
|
2732
2854
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
2733
2855
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
2734
2856
|
inject: core.inject,
|
|
@@ -2736,6 +2858,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
2736
2858
|
NgComponentOutlet: common.NgComponentOutlet,
|
|
2737
2859
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
2738
2860
|
provideServerRendering: platformServer.provideServerRendering,
|
|
2861
|
+
provideZoneChangeDetection: core.provideZoneChangeDetection,
|
|
2739
2862
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
2740
2863
|
reflectComponentType: core.reflectComponentType,
|
|
2741
2864
|
renderApplication: platformServer.renderApplication,
|
|
@@ -2811,7 +2934,7 @@ var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_
|
|
|
2811
2934
|
})();`;
|
|
2812
2935
|
}).join(`
|
|
2813
2936
|
`);
|
|
2814
|
-
return `<script>
|
|
2937
|
+
return `<script${nonceAttr()}>
|
|
2815
2938
|
(function() {
|
|
2816
2939
|
${scriptCode}
|
|
2817
2940
|
})();
|
|
@@ -2829,6 +2952,7 @@ ${scriptCode}
|
|
|
2829
2952
|
return scriptArray;
|
|
2830
2953
|
};
|
|
2831
2954
|
var init_registerClientScript = __esm(() => {
|
|
2955
|
+
init_cspNonceRef();
|
|
2832
2956
|
scriptRegistry = new Map;
|
|
2833
2957
|
if (typeof globalThis !== "undefined") {
|
|
2834
2958
|
Object.assign(globalThis, { registerClientScript });
|
|
@@ -2857,6 +2981,81 @@ var buildRequestProviders = (deps, request, requestContext, responseInit) => [
|
|
|
2857
2981
|
{ provide: deps.RESPONSE_INIT, useValue: responseInit ?? null }
|
|
2858
2982
|
];
|
|
2859
2983
|
|
|
2984
|
+
// src/angular/zoneRuntime.ts
|
|
2985
|
+
var ZONE_NODE_SPECIFIER = "zone.js/node", MISSING_ZONE_MESSAGE = 'angular.changeDetection is "zone" but zone.js could not be loaded. Install it in your app (bun add zone.js).', isAngularZoneMode = () => globalThis.__absoluteAngularChangeDetection === "zone", setAngularChangeDetection = (mode) => {
|
|
2986
|
+
globalThis.__absoluteAngularChangeDetection = mode ?? "zoneless";
|
|
2987
|
+
}, isRecord6 = (value) => typeof value === "object" && value !== null, adoptIntoNativePromise = (NativePromise, value) => {
|
|
2988
|
+
if (value instanceof NativePromise || !isRecord6(value))
|
|
2989
|
+
return value;
|
|
2990
|
+
const { then } = value;
|
|
2991
|
+
if (typeof then !== "function")
|
|
2992
|
+
return value;
|
|
2993
|
+
return new NativePromise((resolve, reject) => {
|
|
2994
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
2995
|
+
});
|
|
2996
|
+
}, wrapHandler = (NativePromise, handler) => {
|
|
2997
|
+
if (typeof handler !== "function")
|
|
2998
|
+
return handler;
|
|
2999
|
+
return function nativePromiseHandler(...args) {
|
|
3000
|
+
return adoptIntoNativePromise(NativePromise, Reflect.apply(handler, this, args));
|
|
3001
|
+
};
|
|
3002
|
+
}, wrapRoute = (NativePromise, route) => {
|
|
3003
|
+
if (typeof route === "function")
|
|
3004
|
+
return wrapHandler(NativePromise, route);
|
|
3005
|
+
if (!isRecord6(route) || route instanceof Response || route instanceof Blob)
|
|
3006
|
+
return route;
|
|
3007
|
+
return Object.fromEntries(Object.entries(route).map(([method, handler]) => [
|
|
3008
|
+
method,
|
|
3009
|
+
wrapHandler(NativePromise, handler)
|
|
3010
|
+
]));
|
|
3011
|
+
}, wrapServeOptions = (NativePromise, options) => {
|
|
3012
|
+
if (!isRecord6(options))
|
|
3013
|
+
return options;
|
|
3014
|
+
const wrapped = { ...options };
|
|
3015
|
+
if (options.fetch)
|
|
3016
|
+
wrapped.fetch = wrapHandler(NativePromise, options.fetch);
|
|
3017
|
+
if (options.error)
|
|
3018
|
+
wrapped.error = wrapHandler(NativePromise, options.error);
|
|
3019
|
+
if (isRecord6(options.routes))
|
|
3020
|
+
wrapped.routes = Object.fromEntries(Object.entries(options.routes).map(([path, route]) => [
|
|
3021
|
+
path,
|
|
3022
|
+
wrapRoute(NativePromise, route)
|
|
3023
|
+
]));
|
|
3024
|
+
return wrapped;
|
|
3025
|
+
}, wrapServerReload = (NativePromise, server) => {
|
|
3026
|
+
if (!isRecord6(server))
|
|
3027
|
+
return;
|
|
3028
|
+
const { reload } = server;
|
|
3029
|
+
if (typeof reload !== "function")
|
|
3030
|
+
return;
|
|
3031
|
+
Reflect.set(server, "reload", (options) => Reflect.apply(reload, server, [
|
|
3032
|
+
wrapServeOptions(NativePromise, options)
|
|
3033
|
+
]));
|
|
3034
|
+
}, patchBunServe = (NativePromise) => {
|
|
3035
|
+
const originalServe = Bun.serve;
|
|
3036
|
+
Reflect.set(Bun, "serve", (options) => {
|
|
3037
|
+
const server = Reflect.apply(originalServe, Bun, [
|
|
3038
|
+
wrapServeOptions(NativePromise, options)
|
|
3039
|
+
]);
|
|
3040
|
+
wrapServerReload(NativePromise, server);
|
|
3041
|
+
return server;
|
|
3042
|
+
});
|
|
3043
|
+
wrapServerReload(NativePromise, globalThis.__absoluteBunServer);
|
|
3044
|
+
}, installation = null, isPromiseConstructor = (value) => typeof value === "function", install = async () => {
|
|
3045
|
+
setAngularChangeDetection("zone");
|
|
3046
|
+
const savedNative = Reflect.get(globalThis, "__zone_symbol__Promise");
|
|
3047
|
+
const NativePromise = isPromiseConstructor(savedNative) ? savedNative : globalThis.Promise;
|
|
3048
|
+
try {
|
|
3049
|
+
await import(ZONE_NODE_SPECIFIER);
|
|
3050
|
+
} catch (error) {
|
|
3051
|
+
throw new Error(MISSING_ZONE_MESSAGE, { cause: error });
|
|
3052
|
+
}
|
|
3053
|
+
patchBunServe(NativePromise);
|
|
3054
|
+
}, installAngularZoneRuntime = () => {
|
|
3055
|
+
installation ??= install();
|
|
3056
|
+
return installation;
|
|
3057
|
+
};
|
|
3058
|
+
|
|
2860
3059
|
// src/angular/ssrRender.ts
|
|
2861
3060
|
var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
2862
3061
|
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
@@ -2864,7 +3063,7 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2864
3063
|
}, getCachedRouteData = (pagePath) => routeContextCache.get(pagePath), selectorCache, buildProviders = (deps, sanitizer, request, requestContext, responseInit, userProviders = []) => [
|
|
2865
3064
|
deps.provideServerRendering(),
|
|
2866
3065
|
deps.provideClientHydration(deps.withHttpTransferCacheOptions(buildAbsoluteHttpTransferCacheOptions())),
|
|
2867
|
-
deps.provideZonelessChangeDetection(),
|
|
3066
|
+
isAngularZoneMode() ? deps.provideZoneChangeDetection({ eventCoalescing: true }) : deps.provideZonelessChangeDetection(),
|
|
2868
3067
|
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
2869
3068
|
{ provide: deps.DomSanitizer, useValue: sanitizer },
|
|
2870
3069
|
{ provide: deps.Sanitizer, useValue: sanitizer },
|
|
@@ -2893,15 +3092,17 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2893
3092
|
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
2894
3093
|
}
|
|
2895
3094
|
if (requestContext !== undefined) {
|
|
2896
|
-
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${JSON.stringify(requestContext)};</script>`);
|
|
3095
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${escapeScriptContent(JSON.stringify(requestContext))};</script>`);
|
|
2897
3096
|
}
|
|
2898
3097
|
if (indexPath) {
|
|
2899
3098
|
const escapedIndexPath = JSON.stringify(indexPath);
|
|
2900
|
-
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
3099
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>import(${escapeScriptContent(escapedIndexPath)});</script>`);
|
|
2901
3100
|
}
|
|
2902
3101
|
return result;
|
|
2903
3102
|
}, renderAngularApp = async (deps, PageComponent, providers, document2, url = "/") => {
|
|
2904
|
-
const
|
|
3103
|
+
const nonce = readCspNonce();
|
|
3104
|
+
const cspProviders = nonce ? [{ provide: deps.CSP_NONCE, useValue: nonce }] : [];
|
|
3105
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers: [...providers, ...cspProviders] }, context);
|
|
2905
3106
|
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
2906
3107
|
document: document2,
|
|
2907
3108
|
platformProviders: [],
|
|
@@ -2922,6 +3123,8 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2922
3123
|
}
|
|
2923
3124
|
};
|
|
2924
3125
|
var init_ssrRender = __esm(() => {
|
|
3126
|
+
init_escapeScriptContent();
|
|
3127
|
+
init_cspNonceRef();
|
|
2925
3128
|
init_registerClientScript();
|
|
2926
3129
|
init_browserTranslation();
|
|
2927
3130
|
routeContextCache = new Map;
|
|
@@ -3539,7 +3742,7 @@ var init_angularServerModule = __esm(() => {
|
|
|
3539
3742
|
|
|
3540
3743
|
// src/build/resolvePackageImport.ts
|
|
3541
3744
|
import { resolve as resolve4, join as join6 } from "path";
|
|
3542
|
-
import { existsSync as
|
|
3745
|
+
import { existsSync as existsSync6, readFileSync as readFileSync5 } from "fs";
|
|
3543
3746
|
var resolveExportPath = (entry, conditions) => {
|
|
3544
3747
|
if (typeof entry === "string")
|
|
3545
3748
|
return entry;
|
|
@@ -3561,14 +3764,14 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
3561
3764
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
3562
3765
|
const exportKey = subpath ? `./${subpath}` : ".";
|
|
3563
3766
|
const currentPackageJsonPath = resolve4(process.cwd(), "package.json");
|
|
3564
|
-
const currentPackageJson =
|
|
3767
|
+
const currentPackageJson = existsSync6(currentPackageJsonPath) ? JSON.parse(readFileSync5(currentPackageJsonPath, "utf-8")) : null;
|
|
3565
3768
|
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
3566
3769
|
const packageDir = currentPackageDir ?? resolve4(process.cwd(), "node_modules", packageName ?? "");
|
|
3567
3770
|
const packageJsonPath = join6(packageDir, "package.json");
|
|
3568
|
-
if (!
|
|
3771
|
+
if (!existsSync6(packageJsonPath))
|
|
3569
3772
|
return null;
|
|
3570
3773
|
try {
|
|
3571
|
-
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(
|
|
3774
|
+
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync5(packageJsonPath, "utf-8"));
|
|
3572
3775
|
const { exports } = packageJson;
|
|
3573
3776
|
if (!exports)
|
|
3574
3777
|
return null;
|
|
@@ -3580,12 +3783,12 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
3580
3783
|
return null;
|
|
3581
3784
|
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
3582
3785
|
const sourceCandidate = resolve4(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
3583
|
-
if (
|
|
3786
|
+
if (existsSync6(sourceCandidate)) {
|
|
3584
3787
|
return sourceCandidate;
|
|
3585
3788
|
}
|
|
3586
3789
|
}
|
|
3587
3790
|
const resolved = resolve4(packageDir, importPath);
|
|
3588
|
-
return
|
|
3791
|
+
return existsSync6(resolved) ? resolved : null;
|
|
3589
3792
|
} catch {
|
|
3590
3793
|
return null;
|
|
3591
3794
|
}
|
|
@@ -3665,47 +3868,140 @@ var init_lowerIslandSyntax = __esm(() => {
|
|
|
3665
3868
|
});
|
|
3666
3869
|
|
|
3667
3870
|
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
3668
|
-
var
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
}
|
|
3673
|
-
if (
|
|
3871
|
+
var AWAIT_STREAM_DIRECTIVE = "<!-- absolute:stream -->", DIRECTIVE_RE, BRANCH_TAG_RE, SVELTE_ONLY_MARKUP_RE, QUOTES, scanCharacter = (scan, char) => {
|
|
3872
|
+
if (scan.escaped) {
|
|
3873
|
+
scan.escaped = false;
|
|
3874
|
+
return;
|
|
3875
|
+
}
|
|
3876
|
+
if (scan.quote) {
|
|
3877
|
+
scan.escaped = char === "\\";
|
|
3878
|
+
if (char === scan.quote)
|
|
3879
|
+
scan.quote = null;
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3882
|
+
if (QUOTES.has(char))
|
|
3883
|
+
scan.quote = char;
|
|
3884
|
+
if (char === "{")
|
|
3885
|
+
scan.depth += 1;
|
|
3886
|
+
if (char === "}")
|
|
3887
|
+
scan.depth -= 1;
|
|
3888
|
+
}, findTagEnd = (source, start) => {
|
|
3889
|
+
const scan = { depth: 0, escaped: false, quote: null };
|
|
3890
|
+
for (let index = start;index < source.length; index += 1) {
|
|
3891
|
+
scanCharacter(scan, source[index] ?? "");
|
|
3892
|
+
if (scan.depth === 0)
|
|
3893
|
+
return index + 1;
|
|
3894
|
+
}
|
|
3895
|
+
return -1;
|
|
3896
|
+
}, topLevelTags = (markup) => {
|
|
3897
|
+
const tags = [];
|
|
3898
|
+
let index = markup.indexOf("{");
|
|
3899
|
+
while (index !== -1) {
|
|
3900
|
+
const end = findTagEnd(markup, index);
|
|
3901
|
+
if (end === -1)
|
|
3902
|
+
break;
|
|
3903
|
+
tags.push({ end, start: index, text: markup.slice(index, end) });
|
|
3904
|
+
index = markup.indexOf("{", end);
|
|
3905
|
+
}
|
|
3906
|
+
return tags;
|
|
3907
|
+
}, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
3908
|
+
const parts = topLevelTags(markup.trim());
|
|
3909
|
+
const trimmed = markup.trim();
|
|
3910
|
+
let cursor = 0;
|
|
3911
|
+
let literal = "";
|
|
3912
|
+
for (const { end, start, text } of parts) {
|
|
3913
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor, start));
|
|
3914
|
+
literal += `\${${text.slice(1, -1).trim()}}`;
|
|
3915
|
+
cursor = end;
|
|
3916
|
+
}
|
|
3917
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor));
|
|
3918
|
+
return `\`${literal}\``;
|
|
3919
|
+
}, fail = (filePath, message) => {
|
|
3920
|
+
throw new Error(`${filePath ? `${filePath}: ` : ""}${message} (${AWAIT_STREAM_DIRECTIVE} streams plain HTML; remove the directive to let Svelte render the block and hydrate it)`);
|
|
3921
|
+
}, assertPlainHtml = (markup, branch, filePath) => {
|
|
3922
|
+
const withoutExpressions = topLevelTags(markup).reduceRight((text, { end, start }) => text.slice(0, start) + text.slice(end), markup);
|
|
3923
|
+
const nestedTag = topLevelTags(markup).find(({ text }) => /^\{[#:/@]/.test(text));
|
|
3924
|
+
if (nestedTag || SVELTE_ONLY_MARKUP_RE.test(withoutExpressions)) {
|
|
3925
|
+
fail(filePath, `the ${branch} branch of a streamed {#await} holds Svelte markup (${nestedTag?.text ?? withoutExpressions.match(SVELTE_ONLY_MARKUP_RE)?.[0]}\u2026)`);
|
|
3926
|
+
}
|
|
3927
|
+
}, parseStreamedAwait = (source, start, filePath) => {
|
|
3928
|
+
if (!source.startsWith("{#await", start)) {
|
|
3929
|
+
fail(filePath, `${AWAIT_STREAM_DIRECTIVE} must come directly before an {#await} block`);
|
|
3930
|
+
}
|
|
3931
|
+
const headerEnd = findTagEnd(source, start);
|
|
3932
|
+
if (headerEnd === -1)
|
|
3933
|
+
fail(filePath, "unterminated {#await} tag");
|
|
3934
|
+
const expression = source.slice(start + "{#await".length, headerEnd - 1).trim();
|
|
3935
|
+
if (!expression)
|
|
3936
|
+
fail(filePath, "{#await} without an expression");
|
|
3937
|
+
if (/\s(?:then|catch)\b/.test(` ${expression}`)) {
|
|
3938
|
+
fail(filePath, "a streamed {#await} needs a pending branch; the shorthand {#await \u2026 then \u2026} has none");
|
|
3939
|
+
}
|
|
3940
|
+
const close = source.indexOf("{/await}", headerEnd);
|
|
3941
|
+
if (close === -1)
|
|
3942
|
+
fail(filePath, "{#await} without a matching {/await}");
|
|
3943
|
+
const body = source.slice(headerEnd, close);
|
|
3944
|
+
const branchTags = topLevelTags(body).filter(({ text }) => /^\{:/.test(text));
|
|
3945
|
+
const [thenTag, catchTag, extra] = branchTags;
|
|
3946
|
+
const thenMatch = thenTag?.text.match(BRANCH_TAG_RE);
|
|
3947
|
+
const catchMatch = catchTag?.text.match(BRANCH_TAG_RE);
|
|
3948
|
+
if (!thenTag || thenMatch?.[1] !== "then" || catchTag && catchMatch?.[1] !== "catch" || extra) {
|
|
3949
|
+
fail(filePath, "a streamed {#await} takes exactly one {:then} and at most one {:catch}, in that order");
|
|
3950
|
+
}
|
|
3951
|
+
const pendingMarkup = body.slice(0, thenTag?.start);
|
|
3952
|
+
const thenMarkup = body.slice(thenTag?.end, catchTag?.start);
|
|
3953
|
+
const catchMarkup = catchTag ? body.slice(catchTag.end) : undefined;
|
|
3954
|
+
assertPlainHtml(pendingMarkup, "pending", filePath);
|
|
3955
|
+
assertPlainHtml(thenMarkup, "then", filePath);
|
|
3956
|
+
if (catchMarkup !== undefined)
|
|
3957
|
+
assertPlainHtml(catchMarkup, "catch", filePath);
|
|
3958
|
+
return {
|
|
3959
|
+
catchIdentifier: catchMatch?.[2],
|
|
3960
|
+
catchMarkup,
|
|
3961
|
+
end: close + "{/await}".length,
|
|
3962
|
+
expression,
|
|
3963
|
+
pendingMarkup,
|
|
3964
|
+
thenIdentifier: thenMatch?.[2],
|
|
3965
|
+
thenMarkup
|
|
3966
|
+
};
|
|
3967
|
+
}, renderSlot = (block, slotId, dynamic) => {
|
|
3968
|
+
const thenValueIdentifier = block.thenIdentifier ?? "__awaitValue";
|
|
3969
|
+
const catchValueIdentifier = block.catchIdentifier ?? "__awaitError";
|
|
3970
|
+
const catchBranch = block.catchMarkup === undefined ? "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }" : `catch (${catchValueIdentifier}) { return ${markupToTemplateLiteral(block.catchMarkup)}; }`;
|
|
3971
|
+
return `<AbsoluteAwaitSlot id="${slotId}"${dynamic ? " dynamic" : ""} fallbackHtml={${markupToTemplateLiteral(block.pendingMarkup)}} resolve={async () => { try { const ${thenValueIdentifier} = await (${block.expression}); return ${markupToTemplateLiteral(block.thenMarkup)}; } ${catchBranch} }} />`;
|
|
3972
|
+
}, IMPORT_LINE = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";', lowerSvelteAwaitSlotSyntax = (source, filePath) => {
|
|
3973
|
+
if (!source.includes("absolute:stream")) {
|
|
3674
3974
|
return { code: source, transformed: false };
|
|
3675
3975
|
}
|
|
3976
|
+
let lowered = "";
|
|
3977
|
+
let cursor = 0;
|
|
3676
3978
|
let awaitIndex = 0;
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
}
|
|
3979
|
+
for (const directive of source.matchAll(DIRECTIVE_RE)) {
|
|
3980
|
+
const awaitStart = directive.index + directive[0].length;
|
|
3981
|
+
if (awaitStart < cursor)
|
|
3982
|
+
continue;
|
|
3983
|
+
const block = parseStreamedAwait(source, awaitStart, filePath);
|
|
3683
3984
|
const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
|
|
3684
3985
|
awaitIndex += 1;
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
|
|
3691
|
-
const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
|
|
3692
|
-
return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
|
|
3693
|
-
});
|
|
3694
|
-
if (!transformed) {
|
|
3986
|
+
lowered += source.slice(cursor, directive.index);
|
|
3987
|
+
lowered += renderSlot(block, slotId, directive[1] !== undefined);
|
|
3988
|
+
cursor = block.end;
|
|
3989
|
+
}
|
|
3990
|
+
if (awaitIndex === 0) {
|
|
3695
3991
|
return { code: source, transformed: false };
|
|
3696
3992
|
}
|
|
3697
|
-
|
|
3993
|
+
lowered += source.slice(cursor);
|
|
3698
3994
|
if (lowered.includes("<script")) {
|
|
3699
3995
|
return {
|
|
3700
3996
|
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
3701
|
-
${
|
|
3997
|
+
${IMPORT_LINE}
|
|
3702
3998
|
`),
|
|
3703
3999
|
transformed: true
|
|
3704
4000
|
};
|
|
3705
4001
|
}
|
|
3706
4002
|
return {
|
|
3707
4003
|
code: `<script lang="ts">
|
|
3708
|
-
${
|
|
4004
|
+
${IMPORT_LINE}
|
|
3709
4005
|
</script>
|
|
3710
4006
|
${lowered}`,
|
|
3711
4007
|
transformed: true
|
|
@@ -3713,11 +4009,14 @@ ${lowered}`,
|
|
|
3713
4009
|
};
|
|
3714
4010
|
var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
3715
4011
|
init_constants();
|
|
3716
|
-
|
|
4012
|
+
DIRECTIVE_RE = /<!--\s*absolute:stream(\s+dynamic)?\s*-->\s*/g;
|
|
4013
|
+
BRANCH_TAG_RE = /^\{:(then|catch)(?:\s+([A-Za-z_$][\w$]*))?\s*\}$/;
|
|
4014
|
+
SVELTE_ONLY_MARKUP_RE = /\{[#:/@]|<[A-Z]|<svelte:/;
|
|
4015
|
+
QUOTES = new Set(['"', "'", "`"]);
|
|
3717
4016
|
});
|
|
3718
4017
|
|
|
3719
4018
|
// src/build/stylePreprocessor.ts
|
|
3720
|
-
import { existsSync as
|
|
4019
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "fs";
|
|
3721
4020
|
import { readFile as readFile2 } from "fs/promises";
|
|
3722
4021
|
import { createRequire } from "module";
|
|
3723
4022
|
import {
|
|
@@ -3774,12 +4073,12 @@ ${message}`);
|
|
|
3774
4073
|
return tsconfigAliasCache;
|
|
3775
4074
|
const tsconfigPath = resolve5(cwd, "tsconfig.json");
|
|
3776
4075
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
3777
|
-
if (!
|
|
4076
|
+
if (!existsSync7(tsconfigPath)) {
|
|
3778
4077
|
tsconfigAliasCache = empty;
|
|
3779
4078
|
return empty;
|
|
3780
4079
|
}
|
|
3781
4080
|
try {
|
|
3782
|
-
const parsed = JSON.parse(stripJsonComments(
|
|
4081
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync6(tsconfigPath, "utf-8")));
|
|
3783
4082
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
3784
4083
|
const baseUrl = resolve5(cwd, compilerOptions.baseUrl ?? ".");
|
|
3785
4084
|
tsconfigAliasCache = {
|
|
@@ -3840,7 +4139,7 @@ ${message}`);
|
|
|
3840
4139
|
...loadPaths.map((path) => resolve5(path, specifier))
|
|
3841
4140
|
];
|
|
3842
4141
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
3843
|
-
if (
|
|
4142
|
+
if (existsSync7(candidate))
|
|
3844
4143
|
return candidate;
|
|
3845
4144
|
}
|
|
3846
4145
|
return null;
|
|
@@ -3905,7 +4204,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3905
4204
|
const config = normalizePostcssModule(loaded);
|
|
3906
4205
|
const value = typeof config === "function" ? await config({
|
|
3907
4206
|
cwd: process.cwd(),
|
|
3908
|
-
env:
|
|
4207
|
+
env: getNodeEnv()
|
|
3909
4208
|
}) : config;
|
|
3910
4209
|
return normalizePostcssModule(value) ?? {};
|
|
3911
4210
|
}, normalizePostcssPlugins = (plugins) => {
|
|
@@ -3971,7 +4270,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3971
4270
|
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
3972
4271
|
return null;
|
|
3973
4272
|
return {
|
|
3974
|
-
contents: preprocessLoadedStyle(
|
|
4273
|
+
contents: preprocessLoadedStyle(readFileSync6(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
3975
4274
|
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
3976
4275
|
};
|
|
3977
4276
|
}
|
|
@@ -4200,7 +4499,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
4200
4499
|
const end = start + match[0].length;
|
|
4201
4500
|
parts.push(content.slice(cursor, start));
|
|
4202
4501
|
const fullPath = isAbsolute2(importPath) ? importPath : resolve5(baseDir, importPath);
|
|
4203
|
-
if (visited.has(fullPath) || !
|
|
4502
|
+
if (visited.has(fullPath) || !existsSync7(fullPath)) {
|
|
4204
4503
|
parts.push(visited.has(fullPath) ? "" : match[0]);
|
|
4205
4504
|
cursor = end;
|
|
4206
4505
|
continue;
|
|
@@ -4226,15 +4525,15 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
4226
4525
|
const fullPath = isAbsolute2(importPath) ? importPath : resolve5(baseDir, importPath);
|
|
4227
4526
|
if (visited.has(fullPath))
|
|
4228
4527
|
return "";
|
|
4229
|
-
if (!
|
|
4528
|
+
if (!existsSync7(fullPath))
|
|
4230
4529
|
return match;
|
|
4231
4530
|
const nextVisited = new Set(visited);
|
|
4232
4531
|
nextVisited.add(fullPath);
|
|
4233
|
-
const imported =
|
|
4532
|
+
const imported = readFileSync6(fullPath, "utf-8");
|
|
4234
4533
|
return resolveCssImportsSync(imported, dirname5(fullPath), nextVisited);
|
|
4235
4534
|
});
|
|
4236
4535
|
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
4237
|
-
const rawContents =
|
|
4536
|
+
const rawContents = readFileSync6(filePath, "utf-8");
|
|
4238
4537
|
const language = getStyleLanguage(filePath);
|
|
4239
4538
|
if (config?.postcss) {
|
|
4240
4539
|
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
@@ -4271,10 +4570,10 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
4271
4570
|
return resolveCssImportsSync(result.css, dirname5(filePath), new Set([filePath]));
|
|
4272
4571
|
}
|
|
4273
4572
|
if (language === "less") {
|
|
4274
|
-
throw new Error(`Unable to compile ${filePath}: Less
|
|
4573
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Less only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
4275
4574
|
}
|
|
4276
4575
|
if (language === "stylus") {
|
|
4277
|
-
throw new Error(`Unable to compile ${filePath}: Stylus
|
|
4576
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Stylus only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
4278
4577
|
}
|
|
4279
4578
|
return resolveCssImportsSync(rawContents, dirname5(filePath), new Set([filePath]));
|
|
4280
4579
|
};
|
|
@@ -4292,6 +4591,32 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
4292
4591
|
CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
|
|
4293
4592
|
});
|
|
4294
4593
|
|
|
4594
|
+
// src/svelte/router/lazyModule.ts
|
|
4595
|
+
var LAZY_RESOLVED_KEY, LAZY_SOURCE_EXPORT = "__ABSOLUTE_SVELTE_SOURCE__", isRecord7 = (value) => typeof value === "object" && value !== null, isComponent = (value) => typeof value === "function", toLazyComponent = (value) => {
|
|
4596
|
+
if (isComponent(value))
|
|
4597
|
+
return value;
|
|
4598
|
+
if (!isRecord7(value))
|
|
4599
|
+
return;
|
|
4600
|
+
const fallback = value.default;
|
|
4601
|
+
return isComponent(fallback) ? fallback : undefined;
|
|
4602
|
+
}, readSourceFrom = (value) => {
|
|
4603
|
+
if (!isRecord7(value) && !isComponent(value))
|
|
4604
|
+
return;
|
|
4605
|
+
const source = Reflect.get(value, LAZY_SOURCE_EXPORT);
|
|
4606
|
+
return typeof source === "string" ? source : undefined;
|
|
4607
|
+
}, lazyModuleRegistration = (sourceId, specifier) => `
|
|
4608
|
+
;(globalThis[Symbol.for("absolutejs.svelte.lazy-modules")] ??= new Map()).set(${JSON.stringify(sourceId)}, () => import(${JSON.stringify(specifier)}));`, readLazySource = (value) => {
|
|
4609
|
+
const fromValue = readSourceFrom(value);
|
|
4610
|
+
if (fromValue !== undefined)
|
|
4611
|
+
return fromValue;
|
|
4612
|
+
if (!isRecord7(value))
|
|
4613
|
+
return;
|
|
4614
|
+
return readSourceFrom(value.default);
|
|
4615
|
+
};
|
|
4616
|
+
var init_lazyModule = __esm(() => {
|
|
4617
|
+
LAZY_RESOLVED_KEY = Symbol.for("absolutejs.svelte.lazy-resolved");
|
|
4618
|
+
});
|
|
4619
|
+
|
|
4295
4620
|
// src/core/svelteServerModule.ts
|
|
4296
4621
|
import { mkdir as mkdir2, readdir as readdir3 } from "fs/promises";
|
|
4297
4622
|
import { basename as basename4, dirname as dirname6, extname as extname2, join as join8, relative as relative3, resolve as resolve6 } from "path";
|
|
@@ -4401,11 +4726,11 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4401
4726
|
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
4402
4727
|
const source = await Bun.file(sourcePath).text();
|
|
4403
4728
|
const { compile, preprocess } = await import("svelte/compiler");
|
|
4404
|
-
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
4729
|
+
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source, sourcePath);
|
|
4405
4730
|
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
4406
4731
|
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
4407
4732
|
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
4408
|
-
const childImportSpecs = Array.from(transpiled.matchAll(/from\s
|
|
4733
|
+
const childImportSpecs = Array.from(new Set(Array.from(transpiled.matchAll(/(?:from\s+|\bimport\s*\(\s*)['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined)));
|
|
4409
4734
|
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
4410
4735
|
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
4411
4736
|
const childModulePaths = new Map;
|
|
@@ -4452,6 +4777,14 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4452
4777
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
4453
4778
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
4454
4779
|
}
|
|
4780
|
+
const sourceId = JSON.stringify(relative3(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
|
|
4781
|
+
const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
|
|
4782
|
+
compiledCode += `
|
|
4783
|
+
export const ${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
4784
|
+
if (componentName) {
|
|
4785
|
+
compiledCode += `
|
|
4786
|
+
${componentName}.${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
4787
|
+
}
|
|
4455
4788
|
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
4456
4789
|
await mkdir2(dirname6(compiledModulePath), { recursive: true });
|
|
4457
4790
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
@@ -4463,6 +4796,7 @@ var init_svelteServerModule = __esm(() => {
|
|
|
4463
4796
|
init_lowerIslandSyntax();
|
|
4464
4797
|
init_lowerAwaitSlotSyntax();
|
|
4465
4798
|
init_stylePreprocessor();
|
|
4799
|
+
init_lazyModule();
|
|
4466
4800
|
serverCacheRoot2 = join8(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
4467
4801
|
compiledModuleCache2 = new Map;
|
|
4468
4802
|
originalSourcePathCache = new Map;
|
|
@@ -4495,7 +4829,7 @@ var createVueCompiler = async () => {
|
|
|
4495
4829
|
};
|
|
4496
4830
|
|
|
4497
4831
|
// src/core/vueServerModule.ts
|
|
4498
|
-
import { readFileSync as
|
|
4832
|
+
import { readFileSync as readFileSync7, realpathSync } from "fs";
|
|
4499
4833
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
4500
4834
|
import { dirname as dirname7, join as join9, relative as relative4, resolve as resolve7 } from "path";
|
|
4501
4835
|
var {Transpiler } = globalThis.Bun;
|
|
@@ -4544,7 +4878,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, tran
|
|
|
4544
4878
|
fs: {
|
|
4545
4879
|
fileExists: isFile,
|
|
4546
4880
|
realpath: realpathSync,
|
|
4547
|
-
readFile: (file) => isFile(file) ?
|
|
4881
|
+
readFile: (file) => isFile(file) ? readFileSync7(file, "utf-8") : undefined
|
|
4548
4882
|
},
|
|
4549
4883
|
id: componentId,
|
|
4550
4884
|
inlineTemplate: false
|
|
@@ -4599,7 +4933,7 @@ var init_vueServerModule = __esm(() => {
|
|
|
4599
4933
|
var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
|
|
4600
4934
|
islandSequence += 1;
|
|
4601
4935
|
return `island-${islandSequence}`;
|
|
4602
|
-
},
|
|
4936
|
+
}, isRecord8 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord8(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
|
|
4603
4937
|
if (source.startsWith("file://"))
|
|
4604
4938
|
return new URL(source).pathname;
|
|
4605
4939
|
if (source.startsWith("."))
|
|
@@ -4749,6 +5083,8 @@ var init_renderIslandMarkup = __esm(() => {
|
|
|
4749
5083
|
});
|
|
4750
5084
|
|
|
4751
5085
|
// src/vue/pageHandler.ts
|
|
5086
|
+
init_escapeScriptContent();
|
|
5087
|
+
init_cspNonceRef();
|
|
4752
5088
|
init_inlinePageCss();
|
|
4753
5089
|
init_spaRouteCss();
|
|
4754
5090
|
init_spaRouteManifest();
|
|
@@ -4761,6 +5097,8 @@ init_pageResponseCache();
|
|
|
4761
5097
|
// src/core/responseEnhancers.ts
|
|
4762
5098
|
init_streamingSlots();
|
|
4763
5099
|
init_pageResponseCache();
|
|
5100
|
+
init_partialPrerender();
|
|
5101
|
+
init_requestContext();
|
|
4764
5102
|
|
|
4765
5103
|
// src/core/streamingSlotRegistrar.ts
|
|
4766
5104
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
@@ -4803,7 +5141,7 @@ var setStreamingSlotWarningController = (controller) => {
|
|
|
4803
5141
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
4804
5142
|
};
|
|
4805
5143
|
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
4806
|
-
if (isStreamingSlotCollectionActive()) {
|
|
5144
|
+
if (isProductionRuntime() || isStreamingSlotCollectionActive()) {
|
|
4807
5145
|
return;
|
|
4808
5146
|
}
|
|
4809
5147
|
getWarningController()?.maybeWarn(primitiveName);
|
|
@@ -4911,18 +5249,51 @@ var mergeStreamingSlots = (registered, explicit) => {
|
|
|
4911
5249
|
merged.set(slot.id, slot);
|
|
4912
5250
|
return [...merged.values()];
|
|
4913
5251
|
};
|
|
5252
|
+
var captureStaticShell = async (responseLike, slots, options) => {
|
|
5253
|
+
const holes = slots.filter(isDynamicStreamingSlot);
|
|
5254
|
+
const staticSlots = slots.filter((slot) => !isDynamicStreamingSlot(slot));
|
|
5255
|
+
const response = await withStreamingSlots(responseLike, {
|
|
5256
|
+
...options,
|
|
5257
|
+
streamingSlots: staticSlots
|
|
5258
|
+
});
|
|
5259
|
+
if (holes.length === 0 || !response.body)
|
|
5260
|
+
return response;
|
|
5261
|
+
const headers = cloneHeaders(response);
|
|
5262
|
+
headers.set(PARTIAL_HOLES_HEADER, encodePartialHoles(holes.map((slot) => slot.id)));
|
|
5263
|
+
const body = staticSlots.length > 0 ? response.body : injectStreamingRuntimeIntoStream(response.body, options.nonce, options.runtimePlacement, options.runtimePreludeScript);
|
|
5264
|
+
return new Response(body, {
|
|
5265
|
+
headers,
|
|
5266
|
+
status: response.status,
|
|
5267
|
+
statusText: response.statusText
|
|
5268
|
+
});
|
|
5269
|
+
};
|
|
5270
|
+
var handOverHoles = async (responseLike, slots, sink) => {
|
|
5271
|
+
sink.slots = slots.filter(isDynamicStreamingSlot);
|
|
5272
|
+
const response = await toResponse(responseLike);
|
|
5273
|
+
await response.body?.cancel().catch(() => {
|
|
5274
|
+
return;
|
|
5275
|
+
});
|
|
5276
|
+
return new Response(null, { status: 204 });
|
|
5277
|
+
};
|
|
4914
5278
|
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
4915
5279
|
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
4916
5280
|
const explicit = options.streamingSlots ?? [];
|
|
5281
|
+
const streamingSlots = mergeStreamingSlots(slots, explicit);
|
|
5282
|
+
const holesSink = activePartialHolesSink();
|
|
5283
|
+
if (holesSink)
|
|
5284
|
+
return handOverHoles(result, streamingSlots, holesSink);
|
|
5285
|
+
if (isPartialShellCapture(getCurrentAbsoluteRequest())) {
|
|
5286
|
+
return captureStaticShell(result, streamingSlots, options);
|
|
5287
|
+
}
|
|
4917
5288
|
return withStreamingSlots(result, {
|
|
4918
5289
|
...options,
|
|
4919
|
-
streamingSlots
|
|
5290
|
+
streamingSlots
|
|
4920
5291
|
});
|
|
4921
5292
|
};
|
|
4922
5293
|
|
|
4923
5294
|
// src/core/streamingSlotWarningScope.ts
|
|
4924
5295
|
init_logger();
|
|
4925
|
-
import { AsyncLocalStorage as
|
|
5296
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
4926
5297
|
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
4927
5298
|
var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
4928
5299
|
var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
@@ -4938,7 +5309,7 @@ var ensureWarningStorage = () => {
|
|
|
4938
5309
|
if (existing) {
|
|
4939
5310
|
return existing;
|
|
4940
5311
|
}
|
|
4941
|
-
const storage = new
|
|
5312
|
+
const storage = new AsyncLocalStorage4;
|
|
4942
5313
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
4943
5314
|
return storage;
|
|
4944
5315
|
};
|
|
@@ -4969,7 +5340,9 @@ setStreamingSlotWarningController({
|
|
|
4969
5340
|
}
|
|
4970
5341
|
});
|
|
4971
5342
|
var captureStreamingSlotWarningCallsite = () => {
|
|
4972
|
-
if (
|
|
5343
|
+
if (isProductionRuntime()) {
|
|
5344
|
+
return;
|
|
5345
|
+
}
|
|
4973
5346
|
const { stack } = new Error;
|
|
4974
5347
|
if (!stack) {
|
|
4975
5348
|
return;
|
|
@@ -4979,6 +5352,7 @@ var captureStreamingSlotWarningCallsite = () => {
|
|
|
4979
5352
|
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
4980
5353
|
|
|
4981
5354
|
// src/vue/pageHandler.ts
|
|
5355
|
+
init_ssrErrorPage();
|
|
4982
5356
|
init_resolveConvention();
|
|
4983
5357
|
init_routeAssets();
|
|
4984
5358
|
|
|
@@ -5022,23 +5396,87 @@ var ABSOLUTE_TELEPORT_TARGET = `#${ABSOLUTE_TELEPORT_TARGET_ID}`;
|
|
|
5022
5396
|
|
|
5023
5397
|
// src/vue/pageHandler.ts
|
|
5024
5398
|
init_browserTranslation();
|
|
5025
|
-
|
|
5026
|
-
|
|
5399
|
+
|
|
5400
|
+
// src/vue/serverDataPayload.ts
|
|
5401
|
+
init_cspNonceRef();
|
|
5402
|
+
init_escapeScriptContent();
|
|
5403
|
+
var SERVER_DATA_CONTEXT_KEY = "__absoluteServerData";
|
|
5404
|
+
var SERVER_DATA_GLOBAL = "__ABSOLUTE_SERVER_DATA__";
|
|
5405
|
+
var GENERIC_ERROR_MESSAGE = "Loading server data failed.";
|
|
5406
|
+
var toPublicError = (cause) => {
|
|
5407
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
5408
|
+
const publicError = new Error(isProductionRuntime() ? GENERIC_ERROR_MESSAGE : detail);
|
|
5409
|
+
publicError.name = cause instanceof Error ? cause.name : "Error";
|
|
5410
|
+
return publicError;
|
|
5411
|
+
};
|
|
5412
|
+
var claimServerDataKey = (collector, key) => {
|
|
5413
|
+
if (!collector.claimed.has(key)) {
|
|
5414
|
+
collector.claimed.add(key);
|
|
5415
|
+
return true;
|
|
5416
|
+
}
|
|
5417
|
+
const message = `useServerData: the key "${key}" is used more than once while rendering this page. Each useServerData() call in one request needs its own key \u2014 include the component's identity (for example an id or route param) in the key.`;
|
|
5418
|
+
if (isProductionRuntime()) {
|
|
5419
|
+
console.warn(`${message} The repeated call will load in the browser.`);
|
|
5420
|
+
} else {
|
|
5421
|
+
collector.failure ??= new Error(message);
|
|
5422
|
+
}
|
|
5423
|
+
return false;
|
|
5424
|
+
};
|
|
5425
|
+
var createServerDataCollector = () => {
|
|
5426
|
+
const collector = {
|
|
5427
|
+
claimed: new Set,
|
|
5428
|
+
failure: null,
|
|
5429
|
+
json: new Map
|
|
5430
|
+
};
|
|
5431
|
+
return collector;
|
|
5432
|
+
};
|
|
5433
|
+
var isServerDataCollector = (value) => typeof value === "object" && value !== null && ("claimed" in value) && value.claimed instanceof Set && ("failure" in value) && (value.failure === null || value.failure instanceof Error) && ("json" in value) && value.json instanceof Map;
|
|
5434
|
+
var serializeServerDataScript = (collector) => {
|
|
5435
|
+
if (!collector || collector.json.size === 0)
|
|
5436
|
+
return "";
|
|
5437
|
+
const members = [...collector.json].map(([key, json]) => `${JSON.stringify(key)}:${json}`);
|
|
5438
|
+
return `<script${nonceAttr()}>window.${SERVER_DATA_GLOBAL}=${escapeScriptContent(`{${members.join(",")}}`)}</script>`;
|
|
5439
|
+
};
|
|
5440
|
+
var storeServerDataError = (collector, key, cause) => {
|
|
5441
|
+
console.error(`[SSR] useServerData("${key}") failed:`, cause);
|
|
5442
|
+
const publicError = toPublicError(cause);
|
|
5443
|
+
const { message, name } = publicError;
|
|
5444
|
+
collector.json.set(key, JSON.stringify({ error: { message, name } }));
|
|
5445
|
+
return publicError;
|
|
5446
|
+
};
|
|
5447
|
+
var storeServerDataValue = (collector, key, value) => {
|
|
5448
|
+
try {
|
|
5449
|
+
collector.json.set(key, `{"data":${JSON.stringify(value) ?? "null"}}`);
|
|
5450
|
+
return null;
|
|
5451
|
+
} catch (cause) {
|
|
5452
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
5453
|
+
const failure = new Error(`useServerData: the value for "${key}" cannot be serialized to JSON (${reason}).`);
|
|
5454
|
+
return storeServerDataError(collector, key, failure);
|
|
5455
|
+
}
|
|
5456
|
+
};
|
|
5457
|
+
var throwServerDataFailure = (collector) => {
|
|
5458
|
+
if (collector.failure)
|
|
5459
|
+
throw collector.failure;
|
|
5460
|
+
};
|
|
5461
|
+
|
|
5462
|
+
// src/vue/pageHandler.ts
|
|
5463
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null;
|
|
5464
|
+
var isGenericVueComponent = (value) => typeof value === "function" || isRecord4(value);
|
|
5027
5465
|
var readHasIslands = (value) => {
|
|
5028
|
-
if (!
|
|
5466
|
+
if (!isRecord4(value))
|
|
5029
5467
|
return false;
|
|
5030
5468
|
const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
|
|
5031
5469
|
return typeof hasIslands === "boolean" ? hasIslands : false;
|
|
5032
5470
|
};
|
|
5033
5471
|
var isVueSetupApp = (value) => typeof value === "function";
|
|
5034
5472
|
var readSetupAppHook = (value) => {
|
|
5035
|
-
if (!
|
|
5473
|
+
if (!isRecord4(value))
|
|
5036
5474
|
return null;
|
|
5037
5475
|
const { setupApp } = value;
|
|
5038
5476
|
return isVueSetupApp(setupApp) ? setupApp : null;
|
|
5039
5477
|
};
|
|
5040
|
-
var readHasSpaRoutes = (value) =>
|
|
5041
|
-
var readDefaultExport = (value) =>
|
|
5478
|
+
var readHasSpaRoutes = (value) => isRecord4(value) && Array.isArray(value["routes"]);
|
|
5479
|
+
var readDefaultExport = (value) => isRecord4(value) ? value.default : undefined;
|
|
5042
5480
|
var resolveRequestRenderUrl = (request) => {
|
|
5043
5481
|
if (!request)
|
|
5044
5482
|
return "/";
|
|
@@ -5054,17 +5492,16 @@ var primeVueStream = async (stream) => {
|
|
|
5054
5492
|
const firstChunk = await reader.read();
|
|
5055
5493
|
return { firstChunk, reader };
|
|
5056
5494
|
};
|
|
5057
|
-
var
|
|
5058
|
-
var
|
|
5495
|
+
var cachedSsrOnlyHmrBundle = null;
|
|
5496
|
+
var loadSsrOnlyHmrBundle = async () => {
|
|
5059
5497
|
await Promise.resolve().then(() => init_buildHMRClient());
|
|
5060
|
-
|
|
5061
|
-
return `<script>window.__HMR_FRAMEWORK__="vue";</script><script data-hmr-client>${bundle}</script>`;
|
|
5498
|
+
return buildHMRClient();
|
|
5062
5499
|
};
|
|
5063
|
-
var getSsrOnlyHmrShim = () => {
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
return
|
|
5500
|
+
var getSsrOnlyHmrShim = async () => {
|
|
5501
|
+
cachedSsrOnlyHmrBundle ??= loadSsrOnlyHmrBundle();
|
|
5502
|
+
const bundle = await cachedSsrOnlyHmrBundle;
|
|
5503
|
+
const nonce = nonceAttr();
|
|
5504
|
+
return `<script${nonce}>window.__HMR_FRAMEWORK__="vue";</script><script${nonce} data-hmr-client>${bundle}</script>`;
|
|
5068
5505
|
};
|
|
5069
5506
|
var handleVuePageRequest = async (input) => {
|
|
5070
5507
|
const passedPageComponent = input.Page;
|
|
@@ -5186,13 +5623,17 @@ var handleVuePageRequest = async (input) => {
|
|
|
5186
5623
|
status: 404
|
|
5187
5624
|
});
|
|
5188
5625
|
}
|
|
5189
|
-
const
|
|
5626
|
+
const serverData = createServerDataCollector();
|
|
5627
|
+
const ssrContext = {
|
|
5628
|
+
[SERVER_DATA_CONTEXT_KEY]: serverData
|
|
5629
|
+
};
|
|
5190
5630
|
const head = `<!DOCTYPE html><html>${resolvedHeadTag}<body><div id="root">`;
|
|
5191
|
-
const ssrOnlyHmrShim = clientMode === "none" ? await getSsrOnlyHmrShim() : "";
|
|
5631
|
+
const ssrOnlyHmrShim = clientMode === "none" && isDevelopmentRuntime() ? await getSsrOnlyHmrShim() : "";
|
|
5192
5632
|
const buildTail = () => {
|
|
5633
|
+
throwServerDataFailure(serverData);
|
|
5193
5634
|
const teleports = ssrContext.teleports?.[ABSOLUTE_TELEPORT_TARGET] ?? "";
|
|
5194
5635
|
const teleportHost = `<div id="${ABSOLUTE_TELEPORT_TARGET_ID}">${teleports}</div>`;
|
|
5195
|
-
return clientMode === "none" ? `</div>${teleportHost}${ssrOnlyHmrShim}</body></html>` : `</div>${teleportHost}<script>${BROWSER_TRANSLATION_BASELINE_SCRIPT}window.__INITIAL_PROPS__=${JSON.stringify(maybeProps ?? {})}</script
|
|
5636
|
+
return clientMode === "none" ? `</div>${teleportHost}${ssrOnlyHmrShim}</body></html>` : `</div>${teleportHost}<script${nonceAttr()}>${BROWSER_TRANSLATION_BASELINE_SCRIPT}window.__INITIAL_PROPS__=${escapeScriptContent(JSON.stringify(maybeProps ?? {}))}</script>${serializeServerDataScript(serverData)}<script${nonceAttr()} type="module" src="${resolvedIndexPath}"></script></body></html>`;
|
|
5196
5637
|
};
|
|
5197
5638
|
if (resolvedPage.hasSpaRoutes && clientMode === "auto") {
|
|
5198
5639
|
return new Response(`${head}${buildTail()}`, {
|
|
@@ -6225,8 +6666,117 @@ var useResource = (fetcher, options = {}) => {
|
|
|
6225
6666
|
}
|
|
6226
6667
|
return { cancel, data, error, loading, mutate, refresh };
|
|
6227
6668
|
};
|
|
6669
|
+
// src/vue/useServerData.ts
|
|
6670
|
+
import {
|
|
6671
|
+
getCurrentInstance,
|
|
6672
|
+
inject,
|
|
6673
|
+
onServerPrefetch as onServerPrefetch3,
|
|
6674
|
+
ssrContextKey
|
|
6675
|
+
} from "vue";
|
|
6676
|
+
|
|
6677
|
+
// src/vue/serverDataState.ts
|
|
6678
|
+
import { getCurrentScope as getCurrentScope2, onScopeDispose as onScopeDispose2, ref as ref4, shallowRef as shallowRef2 } from "vue";
|
|
6679
|
+
var toError = (cause) => cause instanceof Error ? cause : new Error(String(cause));
|
|
6680
|
+
var createServerDataState = (fetcher, initiallyPending) => {
|
|
6681
|
+
const data = shallowRef2(null);
|
|
6682
|
+
const error = shallowRef2(null);
|
|
6683
|
+
const pending = ref4(initiallyPending);
|
|
6684
|
+
let controller = null;
|
|
6685
|
+
let disposed = false;
|
|
6686
|
+
const cancel = () => {
|
|
6687
|
+
controller?.abort();
|
|
6688
|
+
controller = null;
|
|
6689
|
+
};
|
|
6690
|
+
const finish = (current) => {
|
|
6691
|
+
if (controller === current)
|
|
6692
|
+
controller = null;
|
|
6693
|
+
if (!current.signal.aborted)
|
|
6694
|
+
pending.value = false;
|
|
6695
|
+
};
|
|
6696
|
+
const refresh = async () => {
|
|
6697
|
+
if (disposed)
|
|
6698
|
+
return;
|
|
6699
|
+
cancel();
|
|
6700
|
+
const current = new AbortController;
|
|
6701
|
+
controller = current;
|
|
6702
|
+
pending.value = true;
|
|
6703
|
+
error.value = null;
|
|
6704
|
+
try {
|
|
6705
|
+
const result = await fetcher(current.signal);
|
|
6706
|
+
if (!current.signal.aborted)
|
|
6707
|
+
data.value = result;
|
|
6708
|
+
} catch (cause) {
|
|
6709
|
+
if (!current.signal.aborted)
|
|
6710
|
+
error.value = toError(cause);
|
|
6711
|
+
} finally {
|
|
6712
|
+
finish(current);
|
|
6713
|
+
}
|
|
6714
|
+
};
|
|
6715
|
+
if (getCurrentScope2()) {
|
|
6716
|
+
onScopeDispose2(() => {
|
|
6717
|
+
disposed = true;
|
|
6718
|
+
cancel();
|
|
6719
|
+
});
|
|
6720
|
+
}
|
|
6721
|
+
const result = { data, error, pending, refresh };
|
|
6722
|
+
return result;
|
|
6723
|
+
};
|
|
6724
|
+
var errorFromEntry = ({ error }) => {
|
|
6725
|
+
const restored = new Error(error.message);
|
|
6726
|
+
restored.name = error.name;
|
|
6727
|
+
return restored;
|
|
6728
|
+
};
|
|
6729
|
+
var isFetcherResult = (_fetcher, _value) => true;
|
|
6730
|
+
|
|
6731
|
+
// src/vue/useServerData.ts
|
|
6732
|
+
var readCollector = () => {
|
|
6733
|
+
const ssrContext = inject(ssrContextKey, null);
|
|
6734
|
+
if (typeof ssrContext !== "object" || ssrContext === null)
|
|
6735
|
+
return null;
|
|
6736
|
+
const candidate = Reflect.get(ssrContext, SERVER_DATA_CONTEXT_KEY);
|
|
6737
|
+
return isServerDataCollector(candidate) ? candidate : null;
|
|
6738
|
+
};
|
|
6739
|
+
var prefetchInto = async (state, fetcher, collector, key) => {
|
|
6740
|
+
try {
|
|
6741
|
+
const value = await fetcher(new AbortController().signal);
|
|
6742
|
+
const failure = storeServerDataValue(collector, key, value);
|
|
6743
|
+
state.data.value = failure ? null : value;
|
|
6744
|
+
state.error.value = failure;
|
|
6745
|
+
} catch (cause) {
|
|
6746
|
+
state.error.value = storeServerDataError(collector, key, cause);
|
|
6747
|
+
} finally {
|
|
6748
|
+
state.pending.value = false;
|
|
6749
|
+
}
|
|
6750
|
+
};
|
|
6751
|
+
var useServerData = (key, fetcher, options = {}) => {
|
|
6752
|
+
if (!getCurrentInstance()) {
|
|
6753
|
+
throw new Error(`useServerData("${key}") must be called inside a Vue component's setup().`);
|
|
6754
|
+
}
|
|
6755
|
+
const state = createServerDataState(fetcher, true);
|
|
6756
|
+
const collector = options.server === false ? null : readCollector();
|
|
6757
|
+
if (!collector)
|
|
6758
|
+
return state;
|
|
6759
|
+
if (!claimServerDataKey(collector, key))
|
|
6760
|
+
return state;
|
|
6761
|
+
onServerPrefetch3(() => prefetchInto(state, fetcher, collector, key));
|
|
6762
|
+
return state;
|
|
6763
|
+
};
|
|
6228
6764
|
// src/vue/router/Link.ts
|
|
6229
|
-
import { defineComponent as defineComponent6, getCurrentInstance, h as h6 } from "vue";
|
|
6765
|
+
import { defineComponent as defineComponent6, getCurrentInstance as getCurrentInstance2, h as h6 } from "vue";
|
|
6766
|
+
|
|
6767
|
+
// src/dev/client/cspNonce.ts
|
|
6768
|
+
var applyPageNonce = (element) => {
|
|
6769
|
+
const nonce = readPageNonce();
|
|
6770
|
+
if (nonce)
|
|
6771
|
+
element.nonce = nonce;
|
|
6772
|
+
return element;
|
|
6773
|
+
};
|
|
6774
|
+
var readPageNonce = () => {
|
|
6775
|
+
if (typeof document === "undefined")
|
|
6776
|
+
return;
|
|
6777
|
+
const carrier = document.querySelector("script[nonce], style[nonce]");
|
|
6778
|
+
return carrier?.nonce || undefined;
|
|
6779
|
+
};
|
|
6230
6780
|
|
|
6231
6781
|
// src/client/prefetch.ts
|
|
6232
6782
|
var PREFETCH_CACHE_LIMIT = 16;
|
|
@@ -6419,13 +6969,13 @@ var preloadModule = (href) => {
|
|
|
6419
6969
|
injectLink("modulepreload", href);
|
|
6420
6970
|
return true;
|
|
6421
6971
|
};
|
|
6422
|
-
var
|
|
6972
|
+
var isRecord9 = (value) => typeof value === "object" && value !== null;
|
|
6423
6973
|
var isHref = (value) => typeof value === "string" && value.length > 0;
|
|
6424
6974
|
var warmRouteDataAssets = (envelope) => {
|
|
6425
|
-
if (!
|
|
6975
|
+
if (!isRecord9(envelope))
|
|
6426
6976
|
return;
|
|
6427
6977
|
const { assets } = envelope;
|
|
6428
|
-
if (!
|
|
6978
|
+
if (!isRecord9(assets))
|
|
6429
6979
|
return;
|
|
6430
6980
|
const { client, css, index } = assets;
|
|
6431
6981
|
for (const href of [index, client].filter(isHref))
|
|
@@ -6502,7 +7052,7 @@ var speculate = (url) => {
|
|
|
6502
7052
|
liveSpeculationRules.get(oldest.value)?.remove();
|
|
6503
7053
|
liveSpeculationRules.delete(oldest.value);
|
|
6504
7054
|
}
|
|
6505
|
-
const script = document.createElement("script");
|
|
7055
|
+
const script = applyPageNonce(document.createElement("script"));
|
|
6506
7056
|
script.type = "speculationrules";
|
|
6507
7057
|
script.textContent = JSON.stringify({
|
|
6508
7058
|
prerender: [{ eagerness: "immediate", urls: [url] }]
|
|
@@ -6521,6 +7071,7 @@ var scheduleHoverPrefetch = (url, options = {}) => {
|
|
|
6521
7071
|
prefetch(url, { kind: options.kind ?? "route" });
|
|
6522
7072
|
if (options.prerender)
|
|
6523
7073
|
speculate(url);
|
|
7074
|
+
options.onPrefetch?.();
|
|
6524
7075
|
}, HOVER_DEBOUNCE_MS);
|
|
6525
7076
|
return {
|
|
6526
7077
|
cancel: () => window.clearTimeout(timer)
|
|
@@ -6535,8 +7086,10 @@ var handleIntersections = (entries) => {
|
|
|
6535
7086
|
const target = viewportTargets.get(entry.target);
|
|
6536
7087
|
viewportObserver?.unobserve(entry.target);
|
|
6537
7088
|
viewportTargets.delete(entry.target);
|
|
6538
|
-
if (target)
|
|
6539
|
-
|
|
7089
|
+
if (!target)
|
|
7090
|
+
continue;
|
|
7091
|
+
prefetch(target.url, { kind: target.options.kind });
|
|
7092
|
+
target.options.onVisible?.();
|
|
6540
7093
|
}
|
|
6541
7094
|
};
|
|
6542
7095
|
var getViewportObserver = () => {
|
|
@@ -6565,16 +7118,16 @@ var observeViewport = (element, url, options = {}) => {
|
|
|
6565
7118
|
|
|
6566
7119
|
// src/vue/usePrefetch.ts
|
|
6567
7120
|
import {
|
|
6568
|
-
getCurrentScope as
|
|
6569
|
-
onScopeDispose as
|
|
6570
|
-
ref as
|
|
7121
|
+
getCurrentScope as getCurrentScope3,
|
|
7122
|
+
onScopeDispose as onScopeDispose3,
|
|
7123
|
+
ref as ref5,
|
|
6571
7124
|
toValue,
|
|
6572
7125
|
watchEffect
|
|
6573
7126
|
} from "vue";
|
|
6574
7127
|
var usePrefetch = (href, options = {}) => {
|
|
6575
7128
|
const viewportKind = options.kind ?? "document";
|
|
6576
7129
|
const triggerKind = options.kind ?? "route";
|
|
6577
|
-
const element =
|
|
7130
|
+
const element = ref5(null);
|
|
6578
7131
|
let hoverHandle = null;
|
|
6579
7132
|
const currentHref = () => toValue(href);
|
|
6580
7133
|
const currentMode = () => toValue(options.mode) ?? resolveDefaultPrefetchMode();
|
|
@@ -6619,8 +7172,8 @@ var usePrefetch = (href, options = {}) => {
|
|
|
6619
7172
|
onCleanup(observeViewport(node, target, { kind: viewportKind }));
|
|
6620
7173
|
}, { flush: "post" });
|
|
6621
7174
|
}
|
|
6622
|
-
if (
|
|
6623
|
-
|
|
7175
|
+
if (getCurrentScope3())
|
|
7176
|
+
onScopeDispose3(cancelHover);
|
|
6624
7177
|
return {
|
|
6625
7178
|
element,
|
|
6626
7179
|
onBlur: cancelHover,
|
|
@@ -6634,7 +7187,7 @@ var usePrefetch = (href, options = {}) => {
|
|
|
6634
7187
|
// src/vue/router/Link.ts
|
|
6635
7188
|
var isRouterLike = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "push") === "function" && typeof Reflect.get(value, "replace") === "function" && typeof Reflect.get(value, "resolve") === "function";
|
|
6636
7189
|
var discoverRouter = () => {
|
|
6637
|
-
const instance =
|
|
7190
|
+
const instance = getCurrentInstance2();
|
|
6638
7191
|
if (!instance)
|
|
6639
7192
|
return null;
|
|
6640
7193
|
const candidate = Reflect.get(instance.appContext.config.globalProperties, "$router");
|
|
@@ -6723,8 +7276,9 @@ export {
|
|
|
6723
7276
|
preserveBrowserTranslation,
|
|
6724
7277
|
useIslandStore,
|
|
6725
7278
|
usePrefetch,
|
|
6726
|
-
useResource
|
|
7279
|
+
useResource,
|
|
7280
|
+
useServerData
|
|
6727
7281
|
};
|
|
6728
7282
|
|
|
6729
|
-
//# debugId=
|
|
7283
|
+
//# debugId=45D17845E8EA738564756E2164756E21
|
|
6730
7284
|
//# sourceMappingURL=index.js.map
|