@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/react/index.js
CHANGED
|
@@ -72,6 +72,37 @@ var __esm = (fn, res, err) => () => {
|
|
|
72
72
|
};
|
|
73
73
|
var __require = import.meta.require;
|
|
74
74
|
|
|
75
|
+
// src/utils/cspNonceRef.ts
|
|
76
|
+
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 = () => {
|
|
77
|
+
const getter = Reflect.get(globalThis, GETTER_KEY);
|
|
78
|
+
if (typeof getter !== "function")
|
|
79
|
+
return;
|
|
80
|
+
const nonce = getter();
|
|
81
|
+
return typeof nonce === "string" ? nonce : undefined;
|
|
82
|
+
}, registerCspNonceGetter = (getter) => {
|
|
83
|
+
Reflect.set(globalThis, GETTER_KEY, getter);
|
|
84
|
+
};
|
|
85
|
+
var init_cspNonceRef = __esm(() => {
|
|
86
|
+
GETTER_KEY = Symbol.for("absolutejs.cspNonceGetter");
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// src/utils/runtimeMode.ts
|
|
90
|
+
var ENV_VAR = "NODE_ENV", getNodeEnv = () => process.env[ENV_VAR], isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
91
|
+
|
|
92
|
+
// src/utils/escapeScriptContent.ts
|
|
93
|
+
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
94
|
+
const escaped = ESCAPE_LOOKUP[char];
|
|
95
|
+
return escaped !== undefined ? escaped : char;
|
|
96
|
+
});
|
|
97
|
+
var init_escapeScriptContent = __esm(() => {
|
|
98
|
+
ESCAPE_LOOKUP = {
|
|
99
|
+
"\u2028": "\\u2028",
|
|
100
|
+
"\u2029": "\\u2029",
|
|
101
|
+
"<": "\\u003C"
|
|
102
|
+
};
|
|
103
|
+
ESCAPE_REGEX = /[<\u2028\u2029]/g;
|
|
104
|
+
});
|
|
105
|
+
|
|
75
106
|
// src/constants.ts
|
|
76
107
|
var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_CODE = 27, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", TAILWIND_BUN_CSS_WARNING_PATTERN, BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_RELOAD_BACKOFF_BASE_MS = 1000, CSS_RELOAD_BACKOFF_MAX_MS = 60000, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, ESLINT_STUDIO_DEFAULT_HOST = "eslint.absolute.localhost", ESLINT_STUDIO_DEFAULT_PORT = 4099, CONFIG_DEFAULT_HOST = "config.absolute.localhost", CONFIG_DEFAULT_PORT = 4099, HMR_UPDATE_TIMEOUT_MS = 2000, HOOK_SIGNATURE_LENGTH = 12, EXCLUDE_LAST_OFFSET = -1, HTTP_STATUS_OK = 200, HTTP_STATUS_BAD_REQUEST = 400, HTTP_STATUS_NOT_FOUND = 404, HTTP_STATUS_GONE = 410, HOURS_IN_DAY = 24, HOURS_IN_HALF_DAY = 12, IMAGE_DEFAULT_DEVICE_SIZES, IMAGE_DEFAULT_IMAGE_SIZES, IMAGE_DEFAULT_QUALITY = 75, IMAGE_GLOB_SUFFIX_LENGTH = 2, INSTANCE_PROBE_TIMEOUT_MS = 250, MAX_ERROR_LENGTH = 200, MAX_RECONNECT_ATTEMPTS = 60, MILLISECONDS_IN_A_SECOND = 1000, MINUTES_IN_AN_HOUR = 60, SECONDS_IN_A_MINUTE = 60, MILLISECONDS_IN_A_MINUTE, MILLISECONDS_IN_A_DAY, OVERLAY_FADE_DURATION_MS = 150, PING_INTERVAL_MS = 30000, LIST_LOG_TAIL_MAX_BYTES = 65536, LIST_TUI_COLUMN_GAP = 2, LIST_TUI_DEFAULT_HEIGHT = 28, LIST_TUI_DEFAULT_WIDTH = 100, LIST_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, LIST_TUI_FOOTER_LINE_COUNT = 2, LIST_TUI_MARKER_WIDTH = 2, LIST_TUI_MIN_LOG_HEIGHT = 3, LIST_TUI_MIN_URL_WIDTH = 16, LIST_TUI_RENDER_DEBOUNCE_MS = 16, LIST_TUI_STATUS_MESSAGE_TIMEOUT_MS = 4000, LIST_WATCH_REFRESH_MS = 1000, RAF_BATCH_COUNT = 3, RANDOM_ID_END_INDEX = 11, REBUILD_BATCH_DELAY_MS = 10, REBUILD_RELOAD_DELAY_MS = 200, RECONNECT_INITIAL_DELAY_MS = 500, RECONNECT_POLL_INTERVAL_MS = 300, REACT_STREAM_SLOT_FAST_DELAY_MS = 5, REACT_STREAM_SLOT_SLOW_DELAY_MS = 20, SIGINT_EXIT_CODE = 130, SIGTERM_EXIT_CODE = 143, SVELTE_CSS_LOAD_TIMEOUT_MS = 500, TIME_PRECISION = 2, TWO_THIRDS, UNFOUND_INDEX = -1, WEBSOCKET_NORMAL_CLOSURE = 1000, DEFAULT_WEBSOCKET_IDLE_TIMEOUT_SECONDS = 240, DEFAULT_HTTP_IDLE_TIMEOUT_SECONDS = 240, MAX_HTTP_IDLE_TIMEOUT_SECONDS = 255, WORKSPACE_COMMAND_ARGS_OFFSET = 3, WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30, WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60, WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5000, WORKSPACE_READY_PROBE_INTERVAL_MS = 250, WORKSPACE_READY_TIMEOUT_MS = 30000, WORKSPACE_SHUTDOWN_TIMEOUT_MS = 1e4, WORKSPACE_TUI_DEFAULT_HEIGHT = 28, WORKSPACE_TUI_DEFAULT_WIDTH = 100, WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, WORKSPACE_TUI_FOOTER_LINE_COUNT = 3, WORKSPACE_TUI_MIN_LOG_HEIGHT = 3, WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7, WORKSPACE_TUI_MIN_TARGET_WIDTH = 8, WORKSPACE_TUI_MIN_WRAP_WIDTH = 12, WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3, WORKSPACE_TUI_RECENT_LOG_LIMIT = 40, WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16, WORKSPACE_TUI_STATUS_WIDTH = 10, WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6, WORKSPACE_TUI_VISIBILITY_WIDTH = 8;
|
|
77
108
|
var init_constants = __esm(() => {
|
|
@@ -288,15 +319,15 @@ var ISLAND_BOOTSTRAP_MANIFEST_KEY = "AbsoluteIslandBootstrap", LEGACY_ISLAND_BOO
|
|
|
288
319
|
var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__", ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__", CLOSING_HEAD_TAG = "</head>", warnedMissingBootstrap = false, warnIfBootstrapMissing = (manifest) => {
|
|
289
320
|
if (warnedMissingBootstrap || getIslandBootstrapPath(manifest))
|
|
290
321
|
return;
|
|
291
|
-
if (
|
|
292
|
-
;
|
|
322
|
+
if (isProductionRuntime())
|
|
323
|
+
return;
|
|
293
324
|
warnedMissingBootstrap = true;
|
|
294
325
|
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().");
|
|
295
326
|
}, buildIslandsHeadMarkup = (manifest) => {
|
|
296
|
-
const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
|
|
297
|
-
const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
|
|
327
|
+
const manifestScript = `<script${nonceAttr()}>window.__ABSOLUTE_MANIFEST__ = ${escapeScriptContent(JSON.stringify(manifest))}</script>`;
|
|
328
|
+
const islandStateScript = `<script${nonceAttr()}>window.__ABS_ISLAND_STATE__ = ${escapeScriptContent(JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {}))}</script>`;
|
|
298
329
|
const bootstrapPath = getIslandBootstrapPath(manifest);
|
|
299
|
-
const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
|
|
330
|
+
const bootstrapScript = bootstrapPath ? `<script${nonceAttr()} type="module" src="${bootstrapPath}"></script>` : "";
|
|
300
331
|
return `${manifestScript}${islandStateScript}${bootstrapScript}`;
|
|
301
332
|
}, injectHeadMarkup = (html, markup) => {
|
|
302
333
|
const closingHeadIndex = html.indexOf("</head>");
|
|
@@ -497,6 +528,8 @@ var ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST
|
|
|
497
528
|
globalThis.__absoluteManifest = manifest;
|
|
498
529
|
};
|
|
499
530
|
var init_islandPageContext = __esm(() => {
|
|
531
|
+
init_escapeScriptContent();
|
|
532
|
+
init_cspNonceRef();
|
|
500
533
|
init_logger();
|
|
501
534
|
});
|
|
502
535
|
|
|
@@ -626,7 +659,7 @@ var errorPageHtml = ({
|
|
|
626
659
|
<meta charset="utf-8">
|
|
627
660
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
628
661
|
<title>SSR Error - AbsoluteJS</title>
|
|
629
|
-
<style>
|
|
662
|
+
<style${nonceAttr()}>
|
|
630
663
|
*{margin:0;padding:0;box-sizing:border-box}
|
|
631
664
|
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}
|
|
632
665
|
.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}
|
|
@@ -658,20 +691,23 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
|
|
|
658
691
|
${script}
|
|
659
692
|
</body>
|
|
660
693
|
</html>`;
|
|
661
|
-
},
|
|
694
|
+
}, 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({
|
|
662
695
|
framework,
|
|
663
696
|
hint: "Fix the file and save. This page reloads by itself when the build succeeds.",
|
|
664
697
|
kind: "Build Error",
|
|
665
698
|
message: `${pageName || "This page"} could not be built.
|
|
666
699
|
|
|
667
700
|
${error ?? "The dev-server terminal has the build output."}`,
|
|
668
|
-
script:
|
|
701
|
+
script: reloadOnRebuild()
|
|
669
702
|
}), ssrErrorPage = (framework, error) => errorPageHtml({
|
|
670
703
|
framework,
|
|
671
704
|
hint: "A component threw during server-side rendering. Check the terminal for the full stack trace.",
|
|
672
705
|
kind: "Server Render Error",
|
|
673
706
|
message: error instanceof Error ? error.message : String(error)
|
|
674
707
|
});
|
|
708
|
+
var init_ssrErrorPage = __esm(() => {
|
|
709
|
+
init_cspNonceRef();
|
|
710
|
+
});
|
|
675
711
|
|
|
676
712
|
// src/core/requestContext.ts
|
|
677
713
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
@@ -745,6 +781,7 @@ var REQUEST_STORAGE_KEY, PAGE_WARMER_KEY, isAbsoluteRequestStorage = (value) =>
|
|
|
745
781
|
return headClose ? head.slice(0, headClose.index) + links + head.slice(headClose.index) : head + links;
|
|
746
782
|
};
|
|
747
783
|
var init_requestContext = __esm(() => {
|
|
784
|
+
init_ssrErrorPage();
|
|
748
785
|
REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
|
|
749
786
|
PAGE_WARMER_KEY = Symbol.for("absolutejs.devPageWarmer");
|
|
750
787
|
absoluteRequestContext = new Elysia2({
|
|
@@ -908,7 +945,9 @@ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json", ABSO
|
|
|
908
945
|
return createAbsoluteMobilePageErrorResponse(page.pageId);
|
|
909
946
|
}
|
|
910
947
|
}, finalizeAbsoluteNativeRouteDevelopmentPage = (input) => {
|
|
911
|
-
if (
|
|
948
|
+
if (!isDevelopmentRuntime()) {
|
|
949
|
+
return createAbsoluteMobileInvalidRequestResponse("The native-route development representation is disabled outside development.");
|
|
950
|
+
}
|
|
912
951
|
if (input.request?.method !== "GET") {
|
|
913
952
|
return createAbsoluteMobileInvalidRequestResponse("Native-route data requests must use GET.");
|
|
914
953
|
}
|
|
@@ -1250,22 +1289,15 @@ var streamSwapRuntime = () => {
|
|
|
1250
1289
|
return value.slice(start + 1, end);
|
|
1251
1290
|
}, getStreamSwapRuntimeScript = () => `(function(){${stripFunctionWrapper(streamSwapRuntime.toString())}})();`;
|
|
1252
1291
|
|
|
1253
|
-
// src/utils/escapeScriptContent.ts
|
|
1254
|
-
var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
|
|
1255
|
-
const escaped = ESCAPE_LOOKUP[char];
|
|
1256
|
-
return escaped !== undefined ? escaped : char;
|
|
1257
|
-
});
|
|
1258
|
-
var init_escapeScriptContent = __esm(() => {
|
|
1259
|
-
ESCAPE_LOOKUP = {
|
|
1260
|
-
"\u2028": "\\u2028",
|
|
1261
|
-
"\u2029": "\\u2029",
|
|
1262
|
-
"<": "\\u003C"
|
|
1263
|
-
};
|
|
1264
|
-
ESCAPE_REGEX = /[<\u2028\u2029]/g;
|
|
1265
|
-
});
|
|
1266
|
-
|
|
1267
1292
|
// src/utils/streamingSlots.ts
|
|
1268
|
-
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,
|
|
1293
|
+
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) => {
|
|
1294
|
+
const head = text.slice(0, cut);
|
|
1295
|
+
const openScript = head.lastIndexOf("<script");
|
|
1296
|
+
const scriptCut = openScript > head.lastIndexOf("</script>") ? openScript : cut;
|
|
1297
|
+
const beforeScript = text.slice(0, scriptCut);
|
|
1298
|
+
const openTag = beforeScript.lastIndexOf("<");
|
|
1299
|
+
return openTag > beforeScript.lastIndexOf(">") ? openTag : scriptCut;
|
|
1300
|
+
}, 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) => {
|
|
1269
1301
|
const closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);
|
|
1270
1302
|
if (closingBodyIndex >= 0) {
|
|
1271
1303
|
return `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;
|
|
@@ -1345,6 +1377,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1345
1377
|
const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
|
|
1346
1378
|
return error;
|
|
1347
1379
|
}, isSlotPatchPayloadObject = (value) => isRecord2(value) && ("html" in value), isTimeoutError = (error) => isRecord2(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
|
|
1380
|
+
dynamic: slot.dynamic,
|
|
1348
1381
|
errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
|
|
1349
1382
|
fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
|
|
1350
1383
|
id: slot.id ?? createStreamingSlotId(),
|
|
@@ -1569,9 +1602,10 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1569
1602
|
if (tail.length <= STREAM_TAIL_LOOKBEHIND) {
|
|
1570
1603
|
return tail;
|
|
1571
1604
|
}
|
|
1572
|
-
const
|
|
1573
|
-
|
|
1574
|
-
|
|
1605
|
+
const cut = findSafeFlushIndex(tail, tail.length - STREAM_TAIL_LOOKBEHIND);
|
|
1606
|
+
if (cut > 0)
|
|
1607
|
+
controller.enqueue(encoder.encode(tail.slice(0, cut)));
|
|
1608
|
+
return tail.slice(cut);
|
|
1575
1609
|
};
|
|
1576
1610
|
const finalizeCompletedBaseWinner = (controller, decodedTail, baseRead) => {
|
|
1577
1611
|
const footerStart = decodedTail.search(CLOSING_PAGE_TAG_REGEX);
|
|
@@ -1804,6 +1838,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
|
|
|
1804
1838
|
});
|
|
1805
1839
|
};
|
|
1806
1840
|
var init_streamingSlots = __esm(() => {
|
|
1841
|
+
init_cspNonceRef();
|
|
1807
1842
|
init_constants();
|
|
1808
1843
|
init_escapeScriptContent();
|
|
1809
1844
|
CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;
|
|
@@ -1818,6 +1853,42 @@ var init_streamingSlots = __esm(() => {
|
|
|
1818
1853
|
};
|
|
1819
1854
|
});
|
|
1820
1855
|
|
|
1856
|
+
// src/core/partialPrerender.ts
|
|
1857
|
+
import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
|
|
1858
|
+
import { existsSync, readFileSync } from "fs";
|
|
1859
|
+
import { rm } from "fs/promises";
|
|
1860
|
+
var PARTIAL_HOLES_HEADER = "X-Absolute-Partial-Holes", PARTIAL_SHELL_HEADER = "X-Absolute-Partial-Shell", SINK_STORAGE_KEY, isSinkStorage = (value) => value instanceof AsyncLocalStorage3, getSinkStorage = () => {
|
|
1861
|
+
const existing = Reflect.get(globalThis, SINK_STORAGE_KEY);
|
|
1862
|
+
if (isSinkStorage(existing))
|
|
1863
|
+
return existing;
|
|
1864
|
+
const created = new AsyncLocalStorage3;
|
|
1865
|
+
Reflect.set(globalThis, SINK_STORAGE_KEY, created);
|
|
1866
|
+
return created;
|
|
1867
|
+
}, activePartialHolesSink = () => getSinkStorage().getStore(), collectPartialHoles = async (render) => {
|
|
1868
|
+
const sink = { slots: undefined };
|
|
1869
|
+
const response = await getSinkStorage().run(sink, render);
|
|
1870
|
+
return { response, slots: sink.slots };
|
|
1871
|
+
}, 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) => {
|
|
1872
|
+
const path = holesPath(htmlPath);
|
|
1873
|
+
if (!existsSync(path))
|
|
1874
|
+
return [];
|
|
1875
|
+
return decodePartialHoles(readFileSync(path, "utf-8").trim().split(`
|
|
1876
|
+
`).join(","));
|
|
1877
|
+
}, writePartialHoles = async (htmlPath, response) => {
|
|
1878
|
+
const ids = decodePartialHoles(response.headers.get(PARTIAL_HOLES_HEADER));
|
|
1879
|
+
if (ids.length > 0) {
|
|
1880
|
+
await Bun.write(holesPath(htmlPath), `${encodePartialHoles(ids).split(",").join(`
|
|
1881
|
+
`)}
|
|
1882
|
+
`);
|
|
1883
|
+
} else {
|
|
1884
|
+
await rm(holesPath(htmlPath), { force: true });
|
|
1885
|
+
}
|
|
1886
|
+
return ids;
|
|
1887
|
+
};
|
|
1888
|
+
var init_partialPrerender = __esm(() => {
|
|
1889
|
+
SINK_STORAGE_KEY = Symbol.for("absolutejs.partialPrerenderHolesSink");
|
|
1890
|
+
});
|
|
1891
|
+
|
|
1821
1892
|
// src/utils/stringModifiers.ts
|
|
1822
1893
|
var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
|
|
1823
1894
|
if (!str.includes("-") && !str.includes("_")) {
|
|
@@ -1826,6 +1897,45 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
|
|
|
1826
1897
|
return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
|
|
1827
1898
|
};
|
|
1828
1899
|
|
|
1900
|
+
// src/core/staticHtmlNonce.ts
|
|
1901
|
+
var nonceStaticHtml = async (html, nonce = readCspNonce()) => {
|
|
1902
|
+
if (!nonce)
|
|
1903
|
+
return html;
|
|
1904
|
+
const stamp = {
|
|
1905
|
+
element: (element) => {
|
|
1906
|
+
if (!element.hasAttribute("nonce"))
|
|
1907
|
+
element.setAttribute("nonce", nonce);
|
|
1908
|
+
}
|
|
1909
|
+
};
|
|
1910
|
+
return new HTMLRewriter().on("script", stamp).on("style", stamp).transform(new Response(html)).text();
|
|
1911
|
+
}, isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), parseHtmxConfig = (content) => {
|
|
1912
|
+
try {
|
|
1913
|
+
const parsed = JSON.parse(content ?? "{}");
|
|
1914
|
+
return isRecord3(parsed) ? parsed : {};
|
|
1915
|
+
} catch {
|
|
1916
|
+
return {};
|
|
1917
|
+
}
|
|
1918
|
+
}, withHtmxStyleNonce = async (html, nonce = readCspNonce()) => {
|
|
1919
|
+
if (!nonce)
|
|
1920
|
+
return html;
|
|
1921
|
+
let found = false;
|
|
1922
|
+
const merged = await new HTMLRewriter().on('meta[name="htmx-config"]', {
|
|
1923
|
+
element: (element) => {
|
|
1924
|
+
found = true;
|
|
1925
|
+
const config = parseHtmxConfig(element.getAttribute("content"));
|
|
1926
|
+
element.setAttribute("content", JSON.stringify({ ...config, inlineStyleNonce: nonce }));
|
|
1927
|
+
}
|
|
1928
|
+
}).transform(new Response(html)).text();
|
|
1929
|
+
if (found)
|
|
1930
|
+
return merged;
|
|
1931
|
+
const meta = `<meta name="htmx-config" content='${JSON.stringify({ inlineStyleNonce: nonce })}'>`;
|
|
1932
|
+
const headClose = merged.search(/<\/head>/i);
|
|
1933
|
+
return headClose >= 0 ? `${merged.slice(0, headClose)}${meta}${merged.slice(headClose)}` : `${meta}${merged}`;
|
|
1934
|
+
};
|
|
1935
|
+
var init_staticHtmlNonce = __esm(() => {
|
|
1936
|
+
init_cspNonceRef();
|
|
1937
|
+
});
|
|
1938
|
+
|
|
1829
1939
|
// src/utils/resolveConvention.ts
|
|
1830
1940
|
import { basename } from "path";
|
|
1831
1941
|
var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
|
|
@@ -1862,7 +1972,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1862
1972
|
return conventions.defaults?.error;
|
|
1863
1973
|
}, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
|
|
1864
1974
|
Reflect.set(globalThis, CONVENTIONS_KEY, map);
|
|
1865
|
-
}, isDev = () =>
|
|
1975
|
+
}, isDev = () => isDevelopmentRuntime(), buildErrorProps = (error) => {
|
|
1866
1976
|
if (error instanceof Error) {
|
|
1867
1977
|
return {
|
|
1868
1978
|
message: error.message,
|
|
@@ -1879,7 +1989,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1879
1989
|
if (typeof ErrorComponent !== "function")
|
|
1880
1990
|
return null;
|
|
1881
1991
|
const element = createElement(ErrorComponent, errorProps);
|
|
1882
|
-
const stream = await renderToReadableStream(element
|
|
1992
|
+
const stream = await renderToReadableStream(element, {
|
|
1993
|
+
nonce: readCspNonce()
|
|
1994
|
+
});
|
|
1883
1995
|
return new Response(stream, {
|
|
1884
1996
|
headers: { "Content-Type": "text/html" },
|
|
1885
1997
|
status: 500
|
|
@@ -1890,10 +2002,12 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1890
2002
|
const ErrorComponent = mod.default;
|
|
1891
2003
|
if (!ErrorComponent)
|
|
1892
2004
|
return null;
|
|
2005
|
+
const nonce = readCspNonce();
|
|
1893
2006
|
const { head, body } = render(ErrorComponent, {
|
|
1894
|
-
props: errorProps
|
|
2007
|
+
props: errorProps,
|
|
2008
|
+
...nonce ? { csp: { nonce } } : {}
|
|
1895
2009
|
});
|
|
1896
|
-
const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
|
|
2010
|
+
const html = `<!DOCTYPE html><html><head>${nonceSvelteHeadStyles(head)}</head><body>${body}</body></html>`;
|
|
1897
2011
|
return new Response(html, {
|
|
1898
2012
|
headers: { "Content-Type": "text/html" },
|
|
1899
2013
|
status: 500
|
|
@@ -1901,7 +2015,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1901
2015
|
}, unescapeVueStyles = (ssrBody) => {
|
|
1902
2016
|
let styles = "";
|
|
1903
2017
|
const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
|
|
1904
|
-
styles += `<style>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
2018
|
+
styles += `<style${nonceAttr()}>${css.replace(/"/g, '"').replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">")}</style>`;
|
|
1905
2019
|
return "";
|
|
1906
2020
|
});
|
|
1907
2021
|
return { body, styles };
|
|
@@ -1933,7 +2047,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1933
2047
|
status: 500
|
|
1934
2048
|
});
|
|
1935
2049
|
}, 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) => {
|
|
1936
|
-
const template = await Bun.file(conventionPath).text();
|
|
2050
|
+
const template = await nonceStaticHtml(await Bun.file(conventionPath).text());
|
|
1937
2051
|
const html = replaceErrorTokens(template, errorProps);
|
|
1938
2052
|
return new Response(html, {
|
|
1939
2053
|
headers: { "Content-Type": "text/html" },
|
|
@@ -1988,7 +2102,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1988
2102
|
if (typeof NotFoundComponent !== "function")
|
|
1989
2103
|
return null;
|
|
1990
2104
|
const element = createElement(NotFoundComponent);
|
|
1991
|
-
const stream = await renderToReadableStream(element
|
|
2105
|
+
const stream = await renderToReadableStream(element, {
|
|
2106
|
+
nonce: readCspNonce()
|
|
2107
|
+
});
|
|
1992
2108
|
return new Response(stream, {
|
|
1993
2109
|
headers: { "Content-Type": "text/html" },
|
|
1994
2110
|
status: 404
|
|
@@ -1999,8 +2115,9 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
1999
2115
|
const NotFoundComponent = mod.default;
|
|
2000
2116
|
if (!NotFoundComponent)
|
|
2001
2117
|
return null;
|
|
2002
|
-
const
|
|
2003
|
-
const
|
|
2118
|
+
const nonce = readCspNonce();
|
|
2119
|
+
const { head, body } = render(NotFoundComponent, nonce ? { csp: { nonce } } : {});
|
|
2120
|
+
const html = `<!DOCTYPE html><html><head>${nonceSvelteHeadStyles(head)}</head><body>${body}</body></html>`;
|
|
2004
2121
|
return new Response(html, {
|
|
2005
2122
|
headers: { "Content-Type": "text/html" },
|
|
2006
2123
|
status: 404
|
|
@@ -2033,7 +2150,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2033
2150
|
status: 404
|
|
2034
2151
|
});
|
|
2035
2152
|
}, renderHtmlNotFound = async (conventionPath) => {
|
|
2036
|
-
const html = await Bun.file(conventionPath).text();
|
|
2153
|
+
const html = await nonceStaticHtml(await Bun.file(conventionPath).text());
|
|
2037
2154
|
return new Response(html, {
|
|
2038
2155
|
headers: { "Content-Type": "text/html" },
|
|
2039
2156
|
status: 404
|
|
@@ -2051,7 +2168,7 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2051
2168
|
logConventionRenderError(framework, "not-found", renderError);
|
|
2052
2169
|
}
|
|
2053
2170
|
return null;
|
|
2054
|
-
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
|
|
2171
|
+
}, NOT_FOUND_PRIORITY, renderFirstNotFound = async (options = {}) => {
|
|
2055
2172
|
const renderNext = async (frameworks) => {
|
|
2056
2173
|
const [framework, ...remaining] = frameworks;
|
|
2057
2174
|
if (!framework) {
|
|
@@ -2066,13 +2183,16 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
|
|
|
2066
2183
|
}
|
|
2067
2184
|
return renderNext(remaining);
|
|
2068
2185
|
};
|
|
2069
|
-
return renderNext(NOT_FOUND_PRIORITY);
|
|
2186
|
+
return renderNext(options.preferHtmx ? ["htmx", ...NOT_FOUND_PRIORITY.filter((key) => key !== "htmx")] : NOT_FOUND_PRIORITY);
|
|
2070
2187
|
};
|
|
2071
2188
|
var init_resolveConvention = __esm(() => {
|
|
2189
|
+
init_cspNonceRef();
|
|
2190
|
+
init_staticHtmlNonce();
|
|
2072
2191
|
ERROR_RENDERERS = {
|
|
2073
2192
|
angular: renderAngularError,
|
|
2074
2193
|
ember: renderEmberError,
|
|
2075
2194
|
html: renderHtmlError,
|
|
2195
|
+
htmx: renderHtmlError,
|
|
2076
2196
|
react: renderReactError,
|
|
2077
2197
|
svelte: renderSvelteError,
|
|
2078
2198
|
vue: renderVueError
|
|
@@ -2081,6 +2201,7 @@ var init_resolveConvention = __esm(() => {
|
|
|
2081
2201
|
angular: renderAngularNotFound,
|
|
2082
2202
|
ember: renderEmberNotFound,
|
|
2083
2203
|
html: renderHtmlNotFound,
|
|
2204
|
+
htmx: renderHtmlNotFound,
|
|
2084
2205
|
react: renderReactNotFound,
|
|
2085
2206
|
svelte: renderSvelteNotFound,
|
|
2086
2207
|
vue: renderVueNotFound
|
|
@@ -2090,7 +2211,8 @@ var init_resolveConvention = __esm(() => {
|
|
|
2090
2211
|
"svelte",
|
|
2091
2212
|
"vue",
|
|
2092
2213
|
"angular",
|
|
2093
|
-
"html"
|
|
2214
|
+
"html",
|
|
2215
|
+
"htmx"
|
|
2094
2216
|
];
|
|
2095
2217
|
});
|
|
2096
2218
|
|
|
@@ -2175,7 +2297,7 @@ var init_browserTranslationAttributes = __esm(() => {
|
|
|
2175
2297
|
});
|
|
2176
2298
|
|
|
2177
2299
|
// src/core/browserTranslation.ts
|
|
2178
|
-
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
2300
|
+
var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BASELINE_SCRIPT, browserTranslationBaselineTag = () => `<script${nonceAttr()}>${BROWSER_TRANSLATION_BASELINE_SCRIPT}</script>`, injectBrowserTranslationBaseline = (html) => {
|
|
2179
2301
|
if (html.includes(BASELINE_MARKER))
|
|
2180
2302
|
return html;
|
|
2181
2303
|
const script = browserTranslationBaselineTag();
|
|
@@ -2185,10 +2307,14 @@ var BASELINE_MARKER = "__ABSOLUTE_SSR_TEXT_BASELINES__", BROWSER_TRANSLATION_BAS
|
|
|
2185
2307
|
return `${html.slice(0, closingBodyIndex)}${script}${html.slice(closingBodyIndex)}`;
|
|
2186
2308
|
};
|
|
2187
2309
|
var init_browserTranslation = __esm(() => {
|
|
2310
|
+
init_cspNonceRef();
|
|
2188
2311
|
init_browserTranslationAttributes();
|
|
2189
2312
|
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);}}";
|
|
2190
2313
|
});
|
|
2191
2314
|
|
|
2315
|
+
// src/react/serverComponents/constants.ts
|
|
2316
|
+
var REACT_SERVER_CLIENT_MANIFEST_KEY = "ReactServerClient", REACT_SERVER_PAGE_MANIFEST_SUFFIX = "RSC", REACT_SERVER_PAYLOAD_GLOBAL = "__absoluteReactServerPayload", REACT_SERVER_RENDERER_MANIFEST_KEY = "ReactServerRenderer", REACT_SERVER_RUNTIME_FILE = "react-server-runtime.json";
|
|
2317
|
+
|
|
2192
2318
|
// src/core/islands.ts
|
|
2193
2319
|
function getIslandComponent(component) {
|
|
2194
2320
|
if (isIslandComponentDefinition(component)) {
|
|
@@ -2200,14 +2326,14 @@ var defineIslandComponent = (component, options) => ({
|
|
|
2200
2326
|
component,
|
|
2201
2327
|
export: options.export,
|
|
2202
2328
|
source: options.source
|
|
2203
|
-
}), defineIslandRegistry = (registry) => registry,
|
|
2329
|
+
}), defineIslandRegistry = (registry) => registry, isRecord5 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
|
|
2204
2330
|
if (!isIslandComponentDefinition(component))
|
|
2205
2331
|
return null;
|
|
2206
2332
|
return {
|
|
2207
2333
|
export: component.export,
|
|
2208
2334
|
source: component.source
|
|
2209
2335
|
};
|
|
2210
|
-
}, isIslandComponentDefinition = (value) =>
|
|
2336
|
+
}, isIslandComponentDefinition = (value) => isRecord5(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
|
|
2211
2337
|
if (!rawProps)
|
|
2212
2338
|
return {};
|
|
2213
2339
|
return JSON.parse(rawProps);
|
|
@@ -2239,24 +2365,24 @@ var requireCurrentIslandRegistry = () => {
|
|
|
2239
2365
|
};
|
|
2240
2366
|
|
|
2241
2367
|
// src/angular/resolveAngularPackage.ts
|
|
2242
|
-
import { existsSync, readFileSync } from "fs";
|
|
2243
|
-
import { join, resolve } from "path";
|
|
2368
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
2369
|
+
import { join as join2, resolve } from "path";
|
|
2244
2370
|
var resolveAngularPackageDir = (specifier) => {
|
|
2245
2371
|
const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
|
|
2246
|
-
if (fromCompiledRuntime &&
|
|
2372
|
+
if (fromCompiledRuntime && existsSync2(fromCompiledRuntime)) {
|
|
2247
2373
|
return fromCompiledRuntime;
|
|
2248
2374
|
}
|
|
2249
2375
|
const fromProject = resolve(process.cwd(), "node_modules", specifier);
|
|
2250
|
-
if (
|
|
2376
|
+
if (existsSync2(fromProject)) {
|
|
2251
2377
|
return fromProject;
|
|
2252
2378
|
}
|
|
2253
2379
|
return null;
|
|
2254
2380
|
}, resolvePackageEntry = (packageDir) => {
|
|
2255
2381
|
try {
|
|
2256
|
-
const pkg = JSON.parse(
|
|
2382
|
+
const pkg = JSON.parse(readFileSync2(join2(packageDir, "package.json"), "utf-8"));
|
|
2257
2383
|
const rootExport = pkg.exports?.["."];
|
|
2258
2384
|
const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
|
|
2259
|
-
return
|
|
2385
|
+
return join2(packageDir, entry);
|
|
2260
2386
|
} catch {
|
|
2261
2387
|
return packageDir;
|
|
2262
2388
|
}
|
|
@@ -2271,17 +2397,14 @@ var resolveAngularPackageDir = (specifier) => {
|
|
|
2271
2397
|
resolve(process.cwd(), "build")
|
|
2272
2398
|
].filter((value) => Boolean(value));
|
|
2273
2399
|
for (const buildDir of buildDirs) {
|
|
2274
|
-
const vendorPath =
|
|
2275
|
-
if (
|
|
2400
|
+
const vendorPath = join2(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
|
|
2401
|
+
if (existsSync2(vendorPath))
|
|
2276
2402
|
return vendorPath;
|
|
2277
2403
|
}
|
|
2278
2404
|
return resolveAngularPackage(specifier);
|
|
2279
2405
|
};
|
|
2280
2406
|
var init_resolveAngularPackage = () => {};
|
|
2281
2407
|
|
|
2282
|
-
// src/utils/runtimeMode.ts
|
|
2283
|
-
var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
|
|
2284
|
-
|
|
2285
2408
|
// src/angular/angularPatch.ts
|
|
2286
2409
|
var ensureHead = (doc) => {
|
|
2287
2410
|
if (!doc || doc.head || !doc.documentElement) {
|
|
@@ -2455,6 +2578,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
2455
2578
|
APP_BASE_HREF: common.APP_BASE_HREF,
|
|
2456
2579
|
bootstrapApplication: platformBrowser.bootstrapApplication,
|
|
2457
2580
|
Component: core.Component,
|
|
2581
|
+
CSP_NONCE: core.CSP_NONCE,
|
|
2458
2582
|
DomSanitizer: platformBrowser.DomSanitizer,
|
|
2459
2583
|
ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
|
|
2460
2584
|
inject: core.inject,
|
|
@@ -2462,6 +2586,7 @@ var initDominoAdapter = (platformServer) => {
|
|
|
2462
2586
|
NgComponentOutlet: common.NgComponentOutlet,
|
|
2463
2587
|
provideClientHydration: platformBrowser.provideClientHydration,
|
|
2464
2588
|
provideServerRendering: platformServer.provideServerRendering,
|
|
2589
|
+
provideZoneChangeDetection: core.provideZoneChangeDetection,
|
|
2465
2590
|
provideZonelessChangeDetection: core.provideZonelessChangeDetection,
|
|
2466
2591
|
reflectComponentType: core.reflectComponentType,
|
|
2467
2592
|
renderApplication: platformServer.renderApplication,
|
|
@@ -2537,7 +2662,7 @@ var scriptRegistry, requestCounter = 0, getRequestId = () => `req_${Date.now()}_
|
|
|
2537
2662
|
})();`;
|
|
2538
2663
|
}).join(`
|
|
2539
2664
|
`);
|
|
2540
|
-
return `<script>
|
|
2665
|
+
return `<script${nonceAttr()}>
|
|
2541
2666
|
(function() {
|
|
2542
2667
|
${scriptCode}
|
|
2543
2668
|
})();
|
|
@@ -2555,6 +2680,7 @@ ${scriptCode}
|
|
|
2555
2680
|
return scriptArray;
|
|
2556
2681
|
};
|
|
2557
2682
|
var init_registerClientScript = __esm(() => {
|
|
2683
|
+
init_cspNonceRef();
|
|
2558
2684
|
scriptRegistry = new Map;
|
|
2559
2685
|
if (typeof globalThis !== "undefined") {
|
|
2560
2686
|
Object.assign(globalThis, { registerClientScript });
|
|
@@ -2583,6 +2709,81 @@ var buildRequestProviders = (deps, request, requestContext, responseInit) => [
|
|
|
2583
2709
|
{ provide: deps.RESPONSE_INIT, useValue: responseInit ?? null }
|
|
2584
2710
|
];
|
|
2585
2711
|
|
|
2712
|
+
// src/angular/zoneRuntime.ts
|
|
2713
|
+
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) => {
|
|
2714
|
+
globalThis.__absoluteAngularChangeDetection = mode ?? "zoneless";
|
|
2715
|
+
}, isRecord6 = (value) => typeof value === "object" && value !== null, adoptIntoNativePromise = (NativePromise, value) => {
|
|
2716
|
+
if (value instanceof NativePromise || !isRecord6(value))
|
|
2717
|
+
return value;
|
|
2718
|
+
const { then } = value;
|
|
2719
|
+
if (typeof then !== "function")
|
|
2720
|
+
return value;
|
|
2721
|
+
return new NativePromise((resolve, reject) => {
|
|
2722
|
+
Reflect.apply(then, value, [resolve, reject]);
|
|
2723
|
+
});
|
|
2724
|
+
}, wrapHandler = (NativePromise, handler) => {
|
|
2725
|
+
if (typeof handler !== "function")
|
|
2726
|
+
return handler;
|
|
2727
|
+
return function nativePromiseHandler(...args) {
|
|
2728
|
+
return adoptIntoNativePromise(NativePromise, Reflect.apply(handler, this, args));
|
|
2729
|
+
};
|
|
2730
|
+
}, wrapRoute = (NativePromise, route) => {
|
|
2731
|
+
if (typeof route === "function")
|
|
2732
|
+
return wrapHandler(NativePromise, route);
|
|
2733
|
+
if (!isRecord6(route) || route instanceof Response || route instanceof Blob)
|
|
2734
|
+
return route;
|
|
2735
|
+
return Object.fromEntries(Object.entries(route).map(([method, handler]) => [
|
|
2736
|
+
method,
|
|
2737
|
+
wrapHandler(NativePromise, handler)
|
|
2738
|
+
]));
|
|
2739
|
+
}, wrapServeOptions = (NativePromise, options) => {
|
|
2740
|
+
if (!isRecord6(options))
|
|
2741
|
+
return options;
|
|
2742
|
+
const wrapped = { ...options };
|
|
2743
|
+
if (options.fetch)
|
|
2744
|
+
wrapped.fetch = wrapHandler(NativePromise, options.fetch);
|
|
2745
|
+
if (options.error)
|
|
2746
|
+
wrapped.error = wrapHandler(NativePromise, options.error);
|
|
2747
|
+
if (isRecord6(options.routes))
|
|
2748
|
+
wrapped.routes = Object.fromEntries(Object.entries(options.routes).map(([path, route]) => [
|
|
2749
|
+
path,
|
|
2750
|
+
wrapRoute(NativePromise, route)
|
|
2751
|
+
]));
|
|
2752
|
+
return wrapped;
|
|
2753
|
+
}, wrapServerReload = (NativePromise, server) => {
|
|
2754
|
+
if (!isRecord6(server))
|
|
2755
|
+
return;
|
|
2756
|
+
const { reload } = server;
|
|
2757
|
+
if (typeof reload !== "function")
|
|
2758
|
+
return;
|
|
2759
|
+
Reflect.set(server, "reload", (options) => Reflect.apply(reload, server, [
|
|
2760
|
+
wrapServeOptions(NativePromise, options)
|
|
2761
|
+
]));
|
|
2762
|
+
}, patchBunServe = (NativePromise) => {
|
|
2763
|
+
const originalServe = Bun.serve;
|
|
2764
|
+
Reflect.set(Bun, "serve", (options) => {
|
|
2765
|
+
const server = Reflect.apply(originalServe, Bun, [
|
|
2766
|
+
wrapServeOptions(NativePromise, options)
|
|
2767
|
+
]);
|
|
2768
|
+
wrapServerReload(NativePromise, server);
|
|
2769
|
+
return server;
|
|
2770
|
+
});
|
|
2771
|
+
wrapServerReload(NativePromise, globalThis.__absoluteBunServer);
|
|
2772
|
+
}, installation = null, isPromiseConstructor = (value) => typeof value === "function", install = async () => {
|
|
2773
|
+
setAngularChangeDetection("zone");
|
|
2774
|
+
const savedNative = Reflect.get(globalThis, "__zone_symbol__Promise");
|
|
2775
|
+
const NativePromise = isPromiseConstructor(savedNative) ? savedNative : globalThis.Promise;
|
|
2776
|
+
try {
|
|
2777
|
+
await import(ZONE_NODE_SPECIFIER);
|
|
2778
|
+
} catch (error) {
|
|
2779
|
+
throw new Error(MISSING_ZONE_MESSAGE, { cause: error });
|
|
2780
|
+
}
|
|
2781
|
+
patchBunServe(NativePromise);
|
|
2782
|
+
}, installAngularZoneRuntime = () => {
|
|
2783
|
+
installation ??= install();
|
|
2784
|
+
return installation;
|
|
2785
|
+
};
|
|
2786
|
+
|
|
2586
2787
|
// src/angular/ssrRender.ts
|
|
2587
2788
|
var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
2588
2789
|
const cacheKey = pagePath.split("?")[0] ?? pagePath;
|
|
@@ -2590,7 +2791,7 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2590
2791
|
}, getCachedRouteData = (pagePath) => routeContextCache.get(pagePath), selectorCache, buildProviders = (deps, sanitizer, request, requestContext, responseInit, userProviders = []) => [
|
|
2591
2792
|
deps.provideServerRendering(),
|
|
2592
2793
|
deps.provideClientHydration(deps.withHttpTransferCacheOptions(buildAbsoluteHttpTransferCacheOptions())),
|
|
2593
|
-
deps.provideZonelessChangeDetection(),
|
|
2794
|
+
isAngularZoneMode() ? deps.provideZoneChangeDetection({ eventCoalescing: true }) : deps.provideZonelessChangeDetection(),
|
|
2594
2795
|
{ provide: deps.APP_BASE_HREF, useValue: "/" },
|
|
2595
2796
|
{ provide: deps.DomSanitizer, useValue: sanitizer },
|
|
2596
2797
|
{ provide: deps.Sanitizer, useValue: sanitizer },
|
|
@@ -2619,15 +2820,17 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2619
2820
|
result = injectBeforeClose(result, generateClientScriptCode(registeredScripts));
|
|
2620
2821
|
}
|
|
2621
2822
|
if (requestContext !== undefined) {
|
|
2622
|
-
result = injectBeforeClose(result, `<script>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${JSON.stringify(requestContext)};</script>`);
|
|
2823
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>window.__ABS_ANGULAR_REQUEST_CONTEXT__ = ${escapeScriptContent(JSON.stringify(requestContext))};</script>`);
|
|
2623
2824
|
}
|
|
2624
2825
|
if (indexPath) {
|
|
2625
2826
|
const escapedIndexPath = JSON.stringify(indexPath);
|
|
2626
|
-
result = injectBeforeClose(result, `<script>import(${escapedIndexPath});</script>`);
|
|
2827
|
+
result = injectBeforeClose(result, `<script${nonceAttr()}>import(${escapeScriptContent(escapedIndexPath)});</script>`);
|
|
2627
2828
|
}
|
|
2628
2829
|
return result;
|
|
2629
2830
|
}, renderAngularApp = async (deps, PageComponent, providers, document2, url = "/") => {
|
|
2630
|
-
const
|
|
2831
|
+
const nonce = readCspNonce();
|
|
2832
|
+
const cspProviders = nonce ? [{ provide: deps.CSP_NONCE, useValue: nonce }] : [];
|
|
2833
|
+
const bootstrap = (context) => deps.bootstrapApplication(PageComponent, { providers: [...providers, ...cspProviders] }, context);
|
|
2631
2834
|
return withSuppressedAngularDevLogs(() => deps.renderApplication(bootstrap, {
|
|
2632
2835
|
document: document2,
|
|
2633
2836
|
platformProviders: [],
|
|
@@ -2648,6 +2851,8 @@ var routeContextCache, cacheRouteData = (pagePath, data) => {
|
|
|
2648
2851
|
}
|
|
2649
2852
|
};
|
|
2650
2853
|
var init_ssrRender = __esm(() => {
|
|
2854
|
+
init_escapeScriptContent();
|
|
2855
|
+
init_cspNonceRef();
|
|
2651
2856
|
init_registerClientScript();
|
|
2652
2857
|
init_browserTranslation();
|
|
2653
2858
|
routeContextCache = new Map;
|
|
@@ -3092,7 +3297,7 @@ var init_specifierRewriter = __esm(() => {
|
|
|
3092
3297
|
|
|
3093
3298
|
// src/build/rewriteImportsPlugin.ts
|
|
3094
3299
|
import { readdir } from "fs/promises";
|
|
3095
|
-
import { join as
|
|
3300
|
+
import { join as join3 } from "path";
|
|
3096
3301
|
var REEXPORT_PATTERN, IMPORT_PATH_PATTERN, isMissingFile = (error) => error instanceof Error && ("code" in error) && error.code === "ENOENT", fixMissingReExportNamespacesInContent = (content) => {
|
|
3097
3302
|
const missing = collectMissingNamespaceImports(content);
|
|
3098
3303
|
if (missing.length === 0)
|
|
@@ -3179,7 +3384,7 @@ ${content}`;
|
|
|
3179
3384
|
}, listJsFiles = async (dir) => {
|
|
3180
3385
|
try {
|
|
3181
3386
|
const entries = await readdir(dir);
|
|
3182
|
-
return entries.filter((entry) => entry.endsWith(".js")).map((entry) =>
|
|
3387
|
+
return entries.filter((entry) => entry.endsWith(".js")).map((entry) => join3(dir, entry));
|
|
3183
3388
|
} catch {
|
|
3184
3389
|
return [];
|
|
3185
3390
|
}
|
|
@@ -3205,11 +3410,11 @@ var init_rewriteImportsPlugin = __esm(() => {
|
|
|
3205
3410
|
|
|
3206
3411
|
// src/core/angularServerModule.ts
|
|
3207
3412
|
import { mkdir } from "fs/promises";
|
|
3208
|
-
import { dirname, join as
|
|
3413
|
+
import { dirname as dirname2, join as join4, relative } from "path";
|
|
3209
3414
|
var serverCacheRoot, compiledModuleCache, ANGULAR_SPECIFIER_RE, getCachedModulePath = (sourcePath) => {
|
|
3210
3415
|
const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
3211
3416
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
3212
|
-
return
|
|
3417
|
+
return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
3213
3418
|
}, collectVendorPaths = (code) => {
|
|
3214
3419
|
const vendorPaths = {};
|
|
3215
3420
|
if (!isProductionRuntime()) {
|
|
@@ -3243,7 +3448,7 @@ ${message}`);
|
|
|
3243
3448
|
const code = await entry.text();
|
|
3244
3449
|
const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
|
|
3245
3450
|
const modulePath = getCachedModulePath(sourcePath);
|
|
3246
|
-
await mkdir(
|
|
3451
|
+
await mkdir(dirname2(modulePath), { recursive: true });
|
|
3247
3452
|
await Bun.write(modulePath, rewritten);
|
|
3248
3453
|
return modulePath;
|
|
3249
3454
|
}, compileAngularServerModule = (sourcePath) => {
|
|
@@ -3258,14 +3463,14 @@ ${message}`);
|
|
|
3258
3463
|
var init_angularServerModule = __esm(() => {
|
|
3259
3464
|
init_resolveAngularPackage();
|
|
3260
3465
|
init_rewriteImportsPlugin();
|
|
3261
|
-
serverCacheRoot =
|
|
3466
|
+
serverCacheRoot = join4(process.cwd(), ".absolutejs", "islands", "angular");
|
|
3262
3467
|
compiledModuleCache = new Map;
|
|
3263
3468
|
ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
|
|
3264
3469
|
});
|
|
3265
3470
|
|
|
3266
3471
|
// src/build/resolvePackageImport.ts
|
|
3267
|
-
import { resolve as resolve2, join as
|
|
3268
|
-
import { existsSync as
|
|
3472
|
+
import { resolve as resolve2, join as join5 } from "path";
|
|
3473
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
|
|
3269
3474
|
var resolveExportPath = (entry, conditions) => {
|
|
3270
3475
|
if (typeof entry === "string")
|
|
3271
3476
|
return entry;
|
|
@@ -3287,14 +3492,14 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
3287
3492
|
const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
|
|
3288
3493
|
const exportKey = subpath ? `./${subpath}` : ".";
|
|
3289
3494
|
const currentPackageJsonPath = resolve2(process.cwd(), "package.json");
|
|
3290
|
-
const currentPackageJson =
|
|
3495
|
+
const currentPackageJson = existsSync3(currentPackageJsonPath) ? JSON.parse(readFileSync3(currentPackageJsonPath, "utf-8")) : null;
|
|
3291
3496
|
const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
|
|
3292
3497
|
const packageDir = currentPackageDir ?? resolve2(process.cwd(), "node_modules", packageName ?? "");
|
|
3293
|
-
const packageJsonPath =
|
|
3294
|
-
if (!
|
|
3498
|
+
const packageJsonPath = join5(packageDir, "package.json");
|
|
3499
|
+
if (!existsSync3(packageJsonPath))
|
|
3295
3500
|
return null;
|
|
3296
3501
|
try {
|
|
3297
|
-
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(
|
|
3502
|
+
const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync3(packageJsonPath, "utf-8"));
|
|
3298
3503
|
const { exports } = packageJson;
|
|
3299
3504
|
if (!exports)
|
|
3300
3505
|
return null;
|
|
@@ -3306,12 +3511,12 @@ var resolveExportPath = (entry, conditions) => {
|
|
|
3306
3511
|
return null;
|
|
3307
3512
|
if (currentPackageDir && importPath.startsWith("./dist/")) {
|
|
3308
3513
|
const sourceCandidate = resolve2(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
|
|
3309
|
-
if (
|
|
3514
|
+
if (existsSync3(sourceCandidate)) {
|
|
3310
3515
|
return sourceCandidate;
|
|
3311
3516
|
}
|
|
3312
3517
|
}
|
|
3313
3518
|
const resolved = resolve2(packageDir, importPath);
|
|
3314
|
-
return
|
|
3519
|
+
return existsSync3(resolved) ? resolved : null;
|
|
3315
3520
|
} catch {
|
|
3316
3521
|
return null;
|
|
3317
3522
|
}
|
|
@@ -3391,47 +3596,140 @@ var init_lowerIslandSyntax = __esm(() => {
|
|
|
3391
3596
|
});
|
|
3392
3597
|
|
|
3393
3598
|
// src/svelte/lowerAwaitSlotSyntax.ts
|
|
3394
|
-
var
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
}
|
|
3399
|
-
if (
|
|
3599
|
+
var AWAIT_STREAM_DIRECTIVE = "<!-- absolute:stream -->", DIRECTIVE_RE, BRANCH_TAG_RE, SVELTE_ONLY_MARKUP_RE, QUOTES, scanCharacter = (scan, char) => {
|
|
3600
|
+
if (scan.escaped) {
|
|
3601
|
+
scan.escaped = false;
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3604
|
+
if (scan.quote) {
|
|
3605
|
+
scan.escaped = char === "\\";
|
|
3606
|
+
if (char === scan.quote)
|
|
3607
|
+
scan.quote = null;
|
|
3608
|
+
return;
|
|
3609
|
+
}
|
|
3610
|
+
if (QUOTES.has(char))
|
|
3611
|
+
scan.quote = char;
|
|
3612
|
+
if (char === "{")
|
|
3613
|
+
scan.depth += 1;
|
|
3614
|
+
if (char === "}")
|
|
3615
|
+
scan.depth -= 1;
|
|
3616
|
+
}, findTagEnd = (source, start) => {
|
|
3617
|
+
const scan = { depth: 0, escaped: false, quote: null };
|
|
3618
|
+
for (let index = start;index < source.length; index += 1) {
|
|
3619
|
+
scanCharacter(scan, source[index] ?? "");
|
|
3620
|
+
if (scan.depth === 0)
|
|
3621
|
+
return index + 1;
|
|
3622
|
+
}
|
|
3623
|
+
return -1;
|
|
3624
|
+
}, topLevelTags = (markup) => {
|
|
3625
|
+
const tags = [];
|
|
3626
|
+
let index = markup.indexOf("{");
|
|
3627
|
+
while (index !== -1) {
|
|
3628
|
+
const end = findTagEnd(markup, index);
|
|
3629
|
+
if (end === -1)
|
|
3630
|
+
break;
|
|
3631
|
+
tags.push({ end, start: index, text: markup.slice(index, end) });
|
|
3632
|
+
index = markup.indexOf("{", end);
|
|
3633
|
+
}
|
|
3634
|
+
return tags;
|
|
3635
|
+
}, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
|
|
3636
|
+
const parts = topLevelTags(markup.trim());
|
|
3637
|
+
const trimmed = markup.trim();
|
|
3638
|
+
let cursor = 0;
|
|
3639
|
+
let literal = "";
|
|
3640
|
+
for (const { end, start, text } of parts) {
|
|
3641
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor, start));
|
|
3642
|
+
literal += `\${${text.slice(1, -1).trim()}}`;
|
|
3643
|
+
cursor = end;
|
|
3644
|
+
}
|
|
3645
|
+
literal += escapeTemplateLiteral(trimmed.slice(cursor));
|
|
3646
|
+
return `\`${literal}\``;
|
|
3647
|
+
}, fail = (filePath, message) => {
|
|
3648
|
+
throw new Error(`${filePath ? `${filePath}: ` : ""}${message} (${AWAIT_STREAM_DIRECTIVE} streams plain HTML; remove the directive to let Svelte render the block and hydrate it)`);
|
|
3649
|
+
}, assertPlainHtml = (markup, branch, filePath) => {
|
|
3650
|
+
const withoutExpressions = topLevelTags(markup).reduceRight((text, { end, start }) => text.slice(0, start) + text.slice(end), markup);
|
|
3651
|
+
const nestedTag = topLevelTags(markup).find(({ text }) => /^\{[#:/@]/.test(text));
|
|
3652
|
+
if (nestedTag || SVELTE_ONLY_MARKUP_RE.test(withoutExpressions)) {
|
|
3653
|
+
fail(filePath, `the ${branch} branch of a streamed {#await} holds Svelte markup (${nestedTag?.text ?? withoutExpressions.match(SVELTE_ONLY_MARKUP_RE)?.[0]}\u2026)`);
|
|
3654
|
+
}
|
|
3655
|
+
}, parseStreamedAwait = (source, start, filePath) => {
|
|
3656
|
+
if (!source.startsWith("{#await", start)) {
|
|
3657
|
+
fail(filePath, `${AWAIT_STREAM_DIRECTIVE} must come directly before an {#await} block`);
|
|
3658
|
+
}
|
|
3659
|
+
const headerEnd = findTagEnd(source, start);
|
|
3660
|
+
if (headerEnd === -1)
|
|
3661
|
+
fail(filePath, "unterminated {#await} tag");
|
|
3662
|
+
const expression = source.slice(start + "{#await".length, headerEnd - 1).trim();
|
|
3663
|
+
if (!expression)
|
|
3664
|
+
fail(filePath, "{#await} without an expression");
|
|
3665
|
+
if (/\s(?:then|catch)\b/.test(` ${expression}`)) {
|
|
3666
|
+
fail(filePath, "a streamed {#await} needs a pending branch; the shorthand {#await \u2026 then \u2026} has none");
|
|
3667
|
+
}
|
|
3668
|
+
const close = source.indexOf("{/await}", headerEnd);
|
|
3669
|
+
if (close === -1)
|
|
3670
|
+
fail(filePath, "{#await} without a matching {/await}");
|
|
3671
|
+
const body = source.slice(headerEnd, close);
|
|
3672
|
+
const branchTags = topLevelTags(body).filter(({ text }) => /^\{:/.test(text));
|
|
3673
|
+
const [thenTag, catchTag, extra] = branchTags;
|
|
3674
|
+
const thenMatch = thenTag?.text.match(BRANCH_TAG_RE);
|
|
3675
|
+
const catchMatch = catchTag?.text.match(BRANCH_TAG_RE);
|
|
3676
|
+
if (!thenTag || thenMatch?.[1] !== "then" || catchTag && catchMatch?.[1] !== "catch" || extra) {
|
|
3677
|
+
fail(filePath, "a streamed {#await} takes exactly one {:then} and at most one {:catch}, in that order");
|
|
3678
|
+
}
|
|
3679
|
+
const pendingMarkup = body.slice(0, thenTag?.start);
|
|
3680
|
+
const thenMarkup = body.slice(thenTag?.end, catchTag?.start);
|
|
3681
|
+
const catchMarkup = catchTag ? body.slice(catchTag.end) : undefined;
|
|
3682
|
+
assertPlainHtml(pendingMarkup, "pending", filePath);
|
|
3683
|
+
assertPlainHtml(thenMarkup, "then", filePath);
|
|
3684
|
+
if (catchMarkup !== undefined)
|
|
3685
|
+
assertPlainHtml(catchMarkup, "catch", filePath);
|
|
3686
|
+
return {
|
|
3687
|
+
catchIdentifier: catchMatch?.[2],
|
|
3688
|
+
catchMarkup,
|
|
3689
|
+
end: close + "{/await}".length,
|
|
3690
|
+
expression,
|
|
3691
|
+
pendingMarkup,
|
|
3692
|
+
thenIdentifier: thenMatch?.[2],
|
|
3693
|
+
thenMarkup
|
|
3694
|
+
};
|
|
3695
|
+
}, renderSlot = (block, slotId, dynamic) => {
|
|
3696
|
+
const thenValueIdentifier = block.thenIdentifier ?? "__awaitValue";
|
|
3697
|
+
const catchValueIdentifier = block.catchIdentifier ?? "__awaitError";
|
|
3698
|
+
const catchBranch = block.catchMarkup === undefined ? "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }" : `catch (${catchValueIdentifier}) { return ${markupToTemplateLiteral(block.catchMarkup)}; }`;
|
|
3699
|
+
return `<AbsoluteAwaitSlot id="${slotId}"${dynamic ? " dynamic" : ""} fallbackHtml={${markupToTemplateLiteral(block.pendingMarkup)}} resolve={async () => { try { const ${thenValueIdentifier} = await (${block.expression}); return ${markupToTemplateLiteral(block.thenMarkup)}; } ${catchBranch} }} />`;
|
|
3700
|
+
}, IMPORT_LINE = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";', lowerSvelteAwaitSlotSyntax = (source, filePath) => {
|
|
3701
|
+
if (!source.includes("absolute:stream")) {
|
|
3400
3702
|
return { code: source, transformed: false };
|
|
3401
3703
|
}
|
|
3704
|
+
let lowered = "";
|
|
3705
|
+
let cursor = 0;
|
|
3402
3706
|
let awaitIndex = 0;
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
}
|
|
3707
|
+
for (const directive of source.matchAll(DIRECTIVE_RE)) {
|
|
3708
|
+
const awaitStart = directive.index + directive[0].length;
|
|
3709
|
+
if (awaitStart < cursor)
|
|
3710
|
+
continue;
|
|
3711
|
+
const block = parseStreamedAwait(source, awaitStart, filePath);
|
|
3409
3712
|
const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
|
|
3410
3713
|
awaitIndex += 1;
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
|
|
3417
|
-
const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
|
|
3418
|
-
return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
|
|
3419
|
-
});
|
|
3420
|
-
if (!transformed) {
|
|
3714
|
+
lowered += source.slice(cursor, directive.index);
|
|
3715
|
+
lowered += renderSlot(block, slotId, directive[1] !== undefined);
|
|
3716
|
+
cursor = block.end;
|
|
3717
|
+
}
|
|
3718
|
+
if (awaitIndex === 0) {
|
|
3421
3719
|
return { code: source, transformed: false };
|
|
3422
3720
|
}
|
|
3423
|
-
|
|
3721
|
+
lowered += source.slice(cursor);
|
|
3424
3722
|
if (lowered.includes("<script")) {
|
|
3425
3723
|
return {
|
|
3426
3724
|
code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
|
|
3427
|
-
${
|
|
3725
|
+
${IMPORT_LINE}
|
|
3428
3726
|
`),
|
|
3429
3727
|
transformed: true
|
|
3430
3728
|
};
|
|
3431
3729
|
}
|
|
3432
3730
|
return {
|
|
3433
3731
|
code: `<script lang="ts">
|
|
3434
|
-
${
|
|
3732
|
+
${IMPORT_LINE}
|
|
3435
3733
|
</script>
|
|
3436
3734
|
${lowered}`,
|
|
3437
3735
|
transformed: true
|
|
@@ -3439,18 +3737,21 @@ ${lowered}`,
|
|
|
3439
3737
|
};
|
|
3440
3738
|
var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
3441
3739
|
init_constants();
|
|
3442
|
-
|
|
3740
|
+
DIRECTIVE_RE = /<!--\s*absolute:stream(\s+dynamic)?\s*-->\s*/g;
|
|
3741
|
+
BRANCH_TAG_RE = /^\{:(then|catch)(?:\s+([A-Za-z_$][\w$]*))?\s*\}$/;
|
|
3742
|
+
SVELTE_ONLY_MARKUP_RE = /\{[#:/@]|<[A-Z]|<svelte:/;
|
|
3743
|
+
QUOTES = new Set(['"', "'", "`"]);
|
|
3443
3744
|
});
|
|
3444
3745
|
|
|
3445
3746
|
// src/build/stylePreprocessor.ts
|
|
3446
|
-
import { existsSync as
|
|
3447
|
-
import { readFile } from "fs/promises";
|
|
3747
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
|
|
3748
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
3448
3749
|
import { createRequire } from "module";
|
|
3449
3750
|
import {
|
|
3450
|
-
dirname as
|
|
3751
|
+
dirname as dirname3,
|
|
3451
3752
|
extname,
|
|
3452
3753
|
isAbsolute,
|
|
3453
|
-
join as
|
|
3754
|
+
join as join6,
|
|
3454
3755
|
relative as relative2,
|
|
3455
3756
|
resolve as resolve3
|
|
3456
3757
|
} from "path";
|
|
@@ -3488,7 +3789,7 @@ ${message}`);
|
|
|
3488
3789
|
return requireOptionalPeer(specifier);
|
|
3489
3790
|
}
|
|
3490
3791
|
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
3491
|
-
|
|
3792
|
+
dirname3(filePath),
|
|
3492
3793
|
process.cwd(),
|
|
3493
3794
|
...paths.map((path) => resolve3(process.cwd(), path))
|
|
3494
3795
|
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
@@ -3500,12 +3801,12 @@ ${message}`);
|
|
|
3500
3801
|
return tsconfigAliasCache;
|
|
3501
3802
|
const tsconfigPath = resolve3(cwd, "tsconfig.json");
|
|
3502
3803
|
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
3503
|
-
if (!
|
|
3804
|
+
if (!existsSync4(tsconfigPath)) {
|
|
3504
3805
|
tsconfigAliasCache = empty;
|
|
3505
3806
|
return empty;
|
|
3506
3807
|
}
|
|
3507
3808
|
try {
|
|
3508
|
-
const parsed = JSON.parse(stripJsonComments(
|
|
3809
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync4(tsconfigPath, "utf-8")));
|
|
3509
3810
|
const compilerOptions = parsed.compilerOptions ?? {};
|
|
3510
3811
|
const baseUrl = resolve3(cwd, compilerOptions.baseUrl ?? ".");
|
|
3511
3812
|
tsconfigAliasCache = {
|
|
@@ -3549,13 +3850,13 @@ ${message}`);
|
|
|
3549
3850
|
const ext = extname(basePath);
|
|
3550
3851
|
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
3551
3852
|
`${basePath}${extension}`,
|
|
3552
|
-
|
|
3853
|
+
join6(basePath, `index${extension}`)
|
|
3553
3854
|
]);
|
|
3554
3855
|
if (language === "scss" || language === "sass") {
|
|
3555
3856
|
return paths.flatMap((path) => {
|
|
3556
|
-
const dir =
|
|
3857
|
+
const dir = dirname3(path);
|
|
3557
3858
|
const base = path.slice(dir.length + 1);
|
|
3558
|
-
return [path,
|
|
3859
|
+
return [path, join6(dir, `_${base}`)];
|
|
3559
3860
|
});
|
|
3560
3861
|
}
|
|
3561
3862
|
return paths;
|
|
@@ -3566,7 +3867,7 @@ ${message}`);
|
|
|
3566
3867
|
...loadPaths.map((path) => resolve3(path, specifier))
|
|
3567
3868
|
];
|
|
3568
3869
|
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
3569
|
-
if (
|
|
3870
|
+
if (existsSync4(candidate))
|
|
3570
3871
|
return candidate;
|
|
3571
3872
|
}
|
|
3572
3873
|
return null;
|
|
@@ -3579,8 +3880,8 @@ ${message}`);
|
|
|
3579
3880
|
path: url.slice(0, markerIndex)
|
|
3580
3881
|
};
|
|
3581
3882
|
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
3582
|
-
const sourceDir =
|
|
3583
|
-
const entryDir =
|
|
3883
|
+
const sourceDir = dirname3(sourceFile);
|
|
3884
|
+
const entryDir = dirname3(entryFile);
|
|
3584
3885
|
if (sourceDir === entryDir)
|
|
3585
3886
|
return contents;
|
|
3586
3887
|
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
@@ -3596,7 +3897,7 @@ ${message}`);
|
|
|
3596
3897
|
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
3597
3898
|
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
3598
3899
|
return match;
|
|
3599
|
-
const resolved = resolveImportPath(specifier,
|
|
3900
|
+
const resolved = resolveImportPath(specifier, dirname3(sourceFile), loadPaths, language, config);
|
|
3600
3901
|
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
3601
3902
|
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
3602
3903
|
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
@@ -3631,7 +3932,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3631
3932
|
const config = normalizePostcssModule(loaded);
|
|
3632
3933
|
const value = typeof config === "function" ? await config({
|
|
3633
3934
|
cwd: process.cwd(),
|
|
3634
|
-
env:
|
|
3935
|
+
env: getNodeEnv()
|
|
3635
3936
|
}) : config;
|
|
3636
3937
|
return normalizePostcssModule(value) ?? {};
|
|
3637
3938
|
}, normalizePostcssPlugins = (plugins) => {
|
|
@@ -3686,7 +3987,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3686
3987
|
return result.css;
|
|
3687
3988
|
}, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
|
|
3688
3989
|
canonicalize(specifier, options) {
|
|
3689
|
-
const fromDirectory = options.containingUrl ?
|
|
3990
|
+
const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
|
|
3690
3991
|
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
3691
3992
|
return resolved ? new URL(pathToFileURL(resolve3(resolved)).href) : null;
|
|
3692
3993
|
},
|
|
@@ -3697,7 +3998,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3697
3998
|
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
3698
3999
|
return null;
|
|
3699
4000
|
return {
|
|
3700
|
-
contents: preprocessLoadedStyle(
|
|
4001
|
+
contents: preprocessLoadedStyle(readFileSync4(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
3701
4002
|
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
3702
4003
|
};
|
|
3703
4004
|
}
|
|
@@ -3713,7 +4014,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3713
4014
|
}
|
|
3714
4015
|
deps?.add(resolved);
|
|
3715
4016
|
return {
|
|
3716
|
-
contents: preprocessLoadedStyle(await
|
|
4017
|
+
contents: preprocessLoadedStyle(await readFile2(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
3717
4018
|
filename: resolved
|
|
3718
4019
|
};
|
|
3719
4020
|
};
|
|
@@ -3775,7 +4076,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3775
4076
|
return importers;
|
|
3776
4077
|
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
3777
4078
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
3778
|
-
const rawContents = source ?? await
|
|
4079
|
+
const rawContents = source ?? await readFile2(filePath, "utf-8");
|
|
3779
4080
|
const deps = new Set;
|
|
3780
4081
|
if (language === "scss" || language === "sass") {
|
|
3781
4082
|
const options = getSassOptions(config, language);
|
|
@@ -3926,41 +4227,41 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3926
4227
|
const end = start + match[0].length;
|
|
3927
4228
|
parts.push(content.slice(cursor, start));
|
|
3928
4229
|
const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
|
|
3929
|
-
if (visited.has(fullPath) || !
|
|
4230
|
+
if (visited.has(fullPath) || !existsSync4(fullPath)) {
|
|
3930
4231
|
parts.push(visited.has(fullPath) ? "" : match[0]);
|
|
3931
4232
|
cursor = end;
|
|
3932
4233
|
continue;
|
|
3933
4234
|
}
|
|
3934
4235
|
const nextVisited = new Set(visited);
|
|
3935
4236
|
nextVisited.add(fullPath);
|
|
3936
|
-
const imported = await
|
|
3937
|
-
parts.push(await resolveCssImportsAsync(imported,
|
|
4237
|
+
const imported = await readFile2(fullPath, "utf-8");
|
|
4238
|
+
parts.push(await resolveCssImportsAsync(imported, dirname3(fullPath), nextVisited));
|
|
3938
4239
|
cursor = end;
|
|
3939
4240
|
}
|
|
3940
4241
|
parts.push(content.slice(cursor));
|
|
3941
4242
|
return parts.join("");
|
|
3942
4243
|
}, compileStyleFileIfNeeded = async (filePath, config) => {
|
|
3943
4244
|
if (!isPreprocessableStylePath(filePath)) {
|
|
3944
|
-
const raw = await
|
|
4245
|
+
const raw = await readFile2(filePath, "utf-8");
|
|
3945
4246
|
const processed = await runPostcss(raw, filePath, config);
|
|
3946
|
-
return resolveCssImportsAsync(processed,
|
|
4247
|
+
return resolveCssImportsAsync(processed, dirname3(filePath), new Set([filePath]));
|
|
3947
4248
|
}
|
|
3948
4249
|
const compiled = await compileStyleSource(filePath, undefined, undefined, config);
|
|
3949
|
-
return resolveCssImportsAsync(compiled,
|
|
4250
|
+
return resolveCssImportsAsync(compiled, dirname3(filePath), new Set([filePath]));
|
|
3950
4251
|
}, resolveCssImportsSync = (content, baseDir, visited) => {
|
|
3951
4252
|
return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
|
|
3952
4253
|
const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
|
|
3953
4254
|
if (visited.has(fullPath))
|
|
3954
4255
|
return "";
|
|
3955
|
-
if (!
|
|
4256
|
+
if (!existsSync4(fullPath))
|
|
3956
4257
|
return match;
|
|
3957
4258
|
const nextVisited = new Set(visited);
|
|
3958
4259
|
nextVisited.add(fullPath);
|
|
3959
|
-
const imported =
|
|
3960
|
-
return resolveCssImportsSync(imported,
|
|
4260
|
+
const imported = readFileSync4(fullPath, "utf-8");
|
|
4261
|
+
return resolveCssImportsSync(imported, dirname3(fullPath), nextVisited);
|
|
3961
4262
|
});
|
|
3962
4263
|
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
3963
|
-
const rawContents =
|
|
4264
|
+
const rawContents = readFileSync4(filePath, "utf-8");
|
|
3964
4265
|
const language = getStyleLanguage(filePath);
|
|
3965
4266
|
if (config?.postcss) {
|
|
3966
4267
|
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
@@ -3994,15 +4295,15 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
|
3994
4295
|
continue;
|
|
3995
4296
|
addStyleImporter(filePath, dep);
|
|
3996
4297
|
}
|
|
3997
|
-
return resolveCssImportsSync(result.css,
|
|
4298
|
+
return resolveCssImportsSync(result.css, dirname3(filePath), new Set([filePath]));
|
|
3998
4299
|
}
|
|
3999
4300
|
if (language === "less") {
|
|
4000
|
-
throw new Error(`Unable to compile ${filePath}: Less
|
|
4301
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Less only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
4001
4302
|
}
|
|
4002
4303
|
if (language === "stylus") {
|
|
4003
|
-
throw new Error(`Unable to compile ${filePath}: Stylus
|
|
4304
|
+
throw new Error(`Unable to compile ${filePath} synchronously: Stylus only has an async compiler. Compile it with compileStyleFileIfNeeded() instead.`);
|
|
4004
4305
|
}
|
|
4005
|
-
return resolveCssImportsSync(rawContents,
|
|
4306
|
+
return resolveCssImportsSync(rawContents, dirname3(filePath), new Set([filePath]));
|
|
4006
4307
|
};
|
|
4007
4308
|
var init_stylePreprocessor = __esm(() => {
|
|
4008
4309
|
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
@@ -4011,22 +4312,48 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
4011
4312
|
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
4012
4313
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
4013
4314
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
4014
|
-
requireFromCwd = createRequire(
|
|
4315
|
+
requireFromCwd = createRequire(join6(process.cwd(), "package.json"));
|
|
4015
4316
|
styleDependencyGraph = new Map;
|
|
4016
4317
|
styleOutputHashes = new Map;
|
|
4017
4318
|
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
4018
4319
|
CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
|
|
4019
4320
|
});
|
|
4020
4321
|
|
|
4322
|
+
// src/svelte/router/lazyModule.ts
|
|
4323
|
+
var LAZY_RESOLVED_KEY, LAZY_SOURCE_EXPORT = "__ABSOLUTE_SVELTE_SOURCE__", isRecord7 = (value) => typeof value === "object" && value !== null, isComponent = (value) => typeof value === "function", toLazyComponent = (value) => {
|
|
4324
|
+
if (isComponent(value))
|
|
4325
|
+
return value;
|
|
4326
|
+
if (!isRecord7(value))
|
|
4327
|
+
return;
|
|
4328
|
+
const fallback = value.default;
|
|
4329
|
+
return isComponent(fallback) ? fallback : undefined;
|
|
4330
|
+
}, readSourceFrom = (value) => {
|
|
4331
|
+
if (!isRecord7(value) && !isComponent(value))
|
|
4332
|
+
return;
|
|
4333
|
+
const source = Reflect.get(value, LAZY_SOURCE_EXPORT);
|
|
4334
|
+
return typeof source === "string" ? source : undefined;
|
|
4335
|
+
}, lazyModuleRegistration = (sourceId, specifier) => `
|
|
4336
|
+
;(globalThis[Symbol.for("absolutejs.svelte.lazy-modules")] ??= new Map()).set(${JSON.stringify(sourceId)}, () => import(${JSON.stringify(specifier)}));`, readLazySource = (value) => {
|
|
4337
|
+
const fromValue = readSourceFrom(value);
|
|
4338
|
+
if (fromValue !== undefined)
|
|
4339
|
+
return fromValue;
|
|
4340
|
+
if (!isRecord7(value))
|
|
4341
|
+
return;
|
|
4342
|
+
return readSourceFrom(value.default);
|
|
4343
|
+
};
|
|
4344
|
+
var init_lazyModule = __esm(() => {
|
|
4345
|
+
LAZY_RESOLVED_KEY = Symbol.for("absolutejs.svelte.lazy-resolved");
|
|
4346
|
+
});
|
|
4347
|
+
|
|
4021
4348
|
// src/core/svelteServerModule.ts
|
|
4022
4349
|
import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
|
|
4023
|
-
import { basename as basename3, dirname as
|
|
4350
|
+
import { basename as basename3, dirname as dirname4, extname as extname2, join as join7, relative as relative3, resolve as resolve4 } from "path";
|
|
4024
4351
|
var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
4025
|
-
const importPath = relative3(
|
|
4352
|
+
const importPath = relative3(dirname4(from), target).replace(/\\/g, "/");
|
|
4026
4353
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
4027
4354
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
4028
4355
|
for (const entry of entries) {
|
|
4029
|
-
const entryPath =
|
|
4356
|
+
const entryPath = join7(dir, entry.name);
|
|
4030
4357
|
if (entry.isDirectory())
|
|
4031
4358
|
stack.push(entryPath);
|
|
4032
4359
|
if (entry.isFile() && entry.name === targetFileName) {
|
|
@@ -4056,11 +4383,11 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4056
4383
|
if (cachedPath !== undefined) {
|
|
4057
4384
|
return cachedPath;
|
|
4058
4385
|
}
|
|
4059
|
-
if (!sourcePath.includes(`${
|
|
4386
|
+
if (!sourcePath.includes(`${join7(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
|
|
4060
4387
|
originalSourcePathCache.set(sourcePath, sourcePath);
|
|
4061
4388
|
return sourcePath;
|
|
4062
4389
|
}
|
|
4063
|
-
const resolvedSourcePath = await findSourceFileByBasename(
|
|
4390
|
+
const resolvedSourcePath = await findSourceFileByBasename(join7(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
|
|
4064
4391
|
const nextPath = resolvedSourcePath ?? sourcePath;
|
|
4065
4392
|
originalSourcePathCache.set(sourcePath, nextPath);
|
|
4066
4393
|
return nextPath;
|
|
@@ -4068,7 +4395,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4068
4395
|
if (!spec.startsWith(".")) {
|
|
4069
4396
|
return null;
|
|
4070
4397
|
}
|
|
4071
|
-
const basePath = resolve4(
|
|
4398
|
+
const basePath = resolve4(dirname4(from), spec);
|
|
4072
4399
|
const candidates = [
|
|
4073
4400
|
basePath,
|
|
4074
4401
|
`${basePath}.ts`,
|
|
@@ -4076,11 +4403,11 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4076
4403
|
`${basePath}.mjs`,
|
|
4077
4404
|
`${basePath}.cjs`,
|
|
4078
4405
|
`${basePath}.json`,
|
|
4079
|
-
|
|
4080
|
-
|
|
4081
|
-
|
|
4082
|
-
|
|
4083
|
-
|
|
4406
|
+
join7(basePath, "index.ts"),
|
|
4407
|
+
join7(basePath, "index.js"),
|
|
4408
|
+
join7(basePath, "index.mjs"),
|
|
4409
|
+
join7(basePath, "index.cjs"),
|
|
4410
|
+
join7(basePath, "index.json")
|
|
4084
4411
|
];
|
|
4085
4412
|
const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
|
|
4086
4413
|
const foundIndex = existResults.indexOf(true);
|
|
@@ -4088,7 +4415,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4088
4415
|
}, getCachedModulePath2 = (sourcePath) => {
|
|
4089
4416
|
const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
4090
4417
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
4091
|
-
return
|
|
4418
|
+
return join7(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
|
|
4092
4419
|
}, resolveSvelteImport = async (spec, from) => {
|
|
4093
4420
|
if (!spec.startsWith(".") && !spec.startsWith("/")) {
|
|
4094
4421
|
const resolved = resolvePackageImport(spec);
|
|
@@ -4100,7 +4427,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4100
4427
|
if (!spec.startsWith(".")) {
|
|
4101
4428
|
return null;
|
|
4102
4429
|
}
|
|
4103
|
-
const explicitPath = resolve4(
|
|
4430
|
+
const explicitPath = resolve4(dirname4(from), spec);
|
|
4104
4431
|
if (extname2(explicitPath) === ".svelte") {
|
|
4105
4432
|
return explicitPath;
|
|
4106
4433
|
}
|
|
@@ -4127,11 +4454,11 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4127
4454
|
const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
|
|
4128
4455
|
const source = await Bun.file(sourcePath).text();
|
|
4129
4456
|
const { compile, preprocess } = await import("svelte/compiler");
|
|
4130
|
-
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
|
|
4457
|
+
const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source, sourcePath);
|
|
4131
4458
|
const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
|
|
4132
4459
|
const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
|
|
4133
4460
|
let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
|
|
4134
|
-
const childImportSpecs = Array.from(transpiled.matchAll(/from\s
|
|
4461
|
+
const childImportSpecs = Array.from(new Set(Array.from(transpiled.matchAll(/(?:from\s+|\bimport\s*\(\s*)['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined)));
|
|
4135
4462
|
const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
|
|
4136
4463
|
const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
|
|
4137
4464
|
const childModulePaths = new Map;
|
|
@@ -4178,8 +4505,16 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler,
|
|
|
4178
4505
|
for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
|
|
4179
4506
|
compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
|
|
4180
4507
|
}
|
|
4508
|
+
const sourceId = JSON.stringify(relative3(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
|
|
4509
|
+
const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
|
|
4510
|
+
compiledCode += `
|
|
4511
|
+
export const ${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
4512
|
+
if (componentName) {
|
|
4513
|
+
compiledCode += `
|
|
4514
|
+
${componentName}.${LAZY_SOURCE_EXPORT} = ${sourceId};`;
|
|
4515
|
+
}
|
|
4181
4516
|
const compiledModulePath = getCachedModulePath2(sourcePath);
|
|
4182
|
-
await mkdir2(
|
|
4517
|
+
await mkdir2(dirname4(compiledModulePath), { recursive: true });
|
|
4183
4518
|
await writeIfChanged(compiledModulePath, compiledCode);
|
|
4184
4519
|
compiledModuleCache2.set(sourcePath, compiledModulePath);
|
|
4185
4520
|
return compiledModulePath;
|
|
@@ -4189,7 +4524,8 @@ var init_svelteServerModule = __esm(() => {
|
|
|
4189
4524
|
init_lowerIslandSyntax();
|
|
4190
4525
|
init_lowerAwaitSlotSyntax();
|
|
4191
4526
|
init_stylePreprocessor();
|
|
4192
|
-
|
|
4527
|
+
init_lazyModule();
|
|
4528
|
+
serverCacheRoot2 = join7(process.cwd(), ".absolutejs", "islands", "svelte");
|
|
4193
4529
|
compiledModuleCache2 = new Map;
|
|
4194
4530
|
originalSourcePathCache = new Map;
|
|
4195
4531
|
transpiler = new Bun.Transpiler({
|
|
@@ -4221,17 +4557,17 @@ var createVueCompiler = async () => {
|
|
|
4221
4557
|
};
|
|
4222
4558
|
|
|
4223
4559
|
// src/core/vueServerModule.ts
|
|
4224
|
-
import { readFileSync as
|
|
4560
|
+
import { readFileSync as readFileSync5, realpathSync } from "fs";
|
|
4225
4561
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
4226
|
-
import { dirname as
|
|
4562
|
+
import { dirname as dirname5, join as join8, relative as relative4, resolve as resolve5 } from "path";
|
|
4227
4563
|
var {Transpiler } = globalThis.Bun;
|
|
4228
4564
|
var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
|
|
4229
|
-
const importPath = relative4(
|
|
4565
|
+
const importPath = relative4(dirname5(from), target).replace(/\\/g, "/");
|
|
4230
4566
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
4231
4567
|
}, getCachedModulePath3 = (sourcePath) => {
|
|
4232
4568
|
const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
4233
4569
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
4234
|
-
return
|
|
4570
|
+
return join8(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
|
|
4235
4571
|
}, writeIfChanged2 = async (path, content) => {
|
|
4236
4572
|
const targetFile = Bun.file(path);
|
|
4237
4573
|
if (await targetFile.exists()) {
|
|
@@ -4270,7 +4606,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, tran
|
|
|
4270
4606
|
fs: {
|
|
4271
4607
|
fileExists: isFile,
|
|
4272
4608
|
realpath: realpathSync,
|
|
4273
|
-
readFile: (file) => isFile(file) ?
|
|
4609
|
+
readFile: (file) => isFile(file) ? readFileSync5(file, "utf-8") : undefined
|
|
4274
4610
|
},
|
|
4275
4611
|
id: componentId,
|
|
4276
4612
|
inlineTemplate: false
|
|
@@ -4291,7 +4627,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, tran
|
|
|
4291
4627
|
}).code : "const ssrRender = () => {};";
|
|
4292
4628
|
const childImportPaths = extractRelativeVueImports(compiledScript.content);
|
|
4293
4629
|
const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
|
|
4294
|
-
compiledPath: await compileVueServerModule(resolve5(
|
|
4630
|
+
compiledPath: await compileVueServerModule(resolve5(dirname5(sourcePath), relativeImport)),
|
|
4295
4631
|
spec: relativeImport
|
|
4296
4632
|
})));
|
|
4297
4633
|
const strippedScript = stripExports(compiledScript.content);
|
|
@@ -4308,7 +4644,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, tran
|
|
|
4308
4644
|
for (const child of compiledChildren) {
|
|
4309
4645
|
rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
|
|
4310
4646
|
}
|
|
4311
|
-
await mkdir3(
|
|
4647
|
+
await mkdir3(dirname5(compiledModulePath), { recursive: true });
|
|
4312
4648
|
await writeIfChanged2(compiledModulePath, rewritten);
|
|
4313
4649
|
compiledModuleCache3.set(sourcePath, compiledModulePath);
|
|
4314
4650
|
return compiledModulePath;
|
|
@@ -4316,7 +4652,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, tran
|
|
|
4316
4652
|
var init_vueServerModule = __esm(() => {
|
|
4317
4653
|
init_constants();
|
|
4318
4654
|
init_isFile();
|
|
4319
|
-
serverCacheRoot3 =
|
|
4655
|
+
serverCacheRoot3 = join8(process.cwd(), ".absolutejs", "islands", "vue");
|
|
4320
4656
|
compiledModuleCache3 = new Map;
|
|
4321
4657
|
transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
|
|
4322
4658
|
});
|
|
@@ -4325,7 +4661,7 @@ var init_vueServerModule = __esm(() => {
|
|
|
4325
4661
|
var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
|
|
4326
4662
|
islandSequence += 1;
|
|
4327
4663
|
return `island-${islandSequence}`;
|
|
4328
|
-
},
|
|
4664
|
+
}, 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) => {
|
|
4329
4665
|
if (source.startsWith("file://"))
|
|
4330
4666
|
return new URL(source).pathname;
|
|
4331
4667
|
if (source.startsWith("."))
|
|
@@ -4475,6 +4811,7 @@ var init_renderIslandMarkup = __esm(() => {
|
|
|
4475
4811
|
});
|
|
4476
4812
|
|
|
4477
4813
|
// src/react/pageHandler.ts
|
|
4814
|
+
init_cspNonceRef();
|
|
4478
4815
|
init_islandPageContext();
|
|
4479
4816
|
init_devRouteRegistrationCallsite();
|
|
4480
4817
|
init_requestContext();
|
|
@@ -4484,6 +4821,8 @@ init_pageResponseCache();
|
|
|
4484
4821
|
// src/core/responseEnhancers.ts
|
|
4485
4822
|
init_streamingSlots();
|
|
4486
4823
|
init_pageResponseCache();
|
|
4824
|
+
init_partialPrerender();
|
|
4825
|
+
init_requestContext();
|
|
4487
4826
|
|
|
4488
4827
|
// src/core/streamingSlotRegistrar.ts
|
|
4489
4828
|
var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
|
|
@@ -4526,7 +4865,7 @@ var setStreamingSlotWarningController = (controller) => {
|
|
|
4526
4865
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
|
|
4527
4866
|
};
|
|
4528
4867
|
var warnMissingStreamingSlotCollector = (primitiveName) => {
|
|
4529
|
-
if (isStreamingSlotCollectionActive()) {
|
|
4868
|
+
if (isProductionRuntime() || isStreamingSlotCollectionActive()) {
|
|
4530
4869
|
return;
|
|
4531
4870
|
}
|
|
4532
4871
|
getWarningController()?.maybeWarn(primitiveName);
|
|
@@ -4634,18 +4973,51 @@ var mergeStreamingSlots = (registered, explicit) => {
|
|
|
4634
4973
|
merged.set(slot.id, slot);
|
|
4635
4974
|
return [...merged.values()];
|
|
4636
4975
|
};
|
|
4976
|
+
var captureStaticShell = async (responseLike, slots, options) => {
|
|
4977
|
+
const holes = slots.filter(isDynamicStreamingSlot);
|
|
4978
|
+
const staticSlots = slots.filter((slot) => !isDynamicStreamingSlot(slot));
|
|
4979
|
+
const response = await withStreamingSlots(responseLike, {
|
|
4980
|
+
...options,
|
|
4981
|
+
streamingSlots: staticSlots
|
|
4982
|
+
});
|
|
4983
|
+
if (holes.length === 0 || !response.body)
|
|
4984
|
+
return response;
|
|
4985
|
+
const headers = cloneHeaders(response);
|
|
4986
|
+
headers.set(PARTIAL_HOLES_HEADER, encodePartialHoles(holes.map((slot) => slot.id)));
|
|
4987
|
+
const body = staticSlots.length > 0 ? response.body : injectStreamingRuntimeIntoStream(response.body, options.nonce, options.runtimePlacement, options.runtimePreludeScript);
|
|
4988
|
+
return new Response(body, {
|
|
4989
|
+
headers,
|
|
4990
|
+
status: response.status,
|
|
4991
|
+
statusText: response.statusText
|
|
4992
|
+
});
|
|
4993
|
+
};
|
|
4994
|
+
var handOverHoles = async (responseLike, slots, sink) => {
|
|
4995
|
+
sink.slots = slots.filter(isDynamicStreamingSlot);
|
|
4996
|
+
const response = await toResponse(responseLike);
|
|
4997
|
+
await response.body?.cancel().catch(() => {
|
|
4998
|
+
return;
|
|
4999
|
+
});
|
|
5000
|
+
return new Response(null, { status: 204 });
|
|
5001
|
+
};
|
|
4637
5002
|
var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
|
|
4638
5003
|
const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
|
|
4639
5004
|
const explicit = options.streamingSlots ?? [];
|
|
5005
|
+
const streamingSlots = mergeStreamingSlots(slots, explicit);
|
|
5006
|
+
const holesSink = activePartialHolesSink();
|
|
5007
|
+
if (holesSink)
|
|
5008
|
+
return handOverHoles(result, streamingSlots, holesSink);
|
|
5009
|
+
if (isPartialShellCapture(getCurrentAbsoluteRequest())) {
|
|
5010
|
+
return captureStaticShell(result, streamingSlots, options);
|
|
5011
|
+
}
|
|
4640
5012
|
return withStreamingSlots(result, {
|
|
4641
5013
|
...options,
|
|
4642
|
-
streamingSlots
|
|
5014
|
+
streamingSlots
|
|
4643
5015
|
});
|
|
4644
5016
|
};
|
|
4645
5017
|
|
|
4646
5018
|
// src/core/streamingSlotWarningScope.ts
|
|
4647
5019
|
init_logger();
|
|
4648
|
-
import { AsyncLocalStorage as
|
|
5020
|
+
import { AsyncLocalStorage as AsyncLocalStorage4 } from "async_hooks";
|
|
4649
5021
|
var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
|
|
4650
5022
|
var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
|
|
4651
5023
|
var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
|
|
@@ -4661,7 +5033,7 @@ var ensureWarningStorage = () => {
|
|
|
4661
5033
|
if (existing) {
|
|
4662
5034
|
return existing;
|
|
4663
5035
|
}
|
|
4664
|
-
const storage = new
|
|
5036
|
+
const storage = new AsyncLocalStorage4;
|
|
4665
5037
|
Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
|
|
4666
5038
|
return storage;
|
|
4667
5039
|
};
|
|
@@ -4692,7 +5064,9 @@ setStreamingSlotWarningController({
|
|
|
4692
5064
|
}
|
|
4693
5065
|
});
|
|
4694
5066
|
var captureStreamingSlotWarningCallsite = () => {
|
|
4695
|
-
if (
|
|
5067
|
+
if (isProductionRuntime()) {
|
|
5068
|
+
return;
|
|
5069
|
+
}
|
|
4696
5070
|
const { stack } = new Error;
|
|
4697
5071
|
if (!stack) {
|
|
4698
5072
|
return;
|
|
@@ -4702,6 +5076,7 @@ var captureStreamingSlotWarningCallsite = () => {
|
|
|
4702
5076
|
var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
|
|
4703
5077
|
|
|
4704
5078
|
// src/react/pageHandler.ts
|
|
5079
|
+
init_ssrErrorPage();
|
|
4705
5080
|
init_spaRouteManifest();
|
|
4706
5081
|
init_resolveConvention();
|
|
4707
5082
|
init_browserTranslation();
|
|
@@ -4717,7 +5092,9 @@ var resolveRequestPathname = (request) => {
|
|
|
4717
5092
|
}
|
|
4718
5093
|
};
|
|
4719
5094
|
var buildRefreshSetup = () => {
|
|
4720
|
-
if (
|
|
5095
|
+
if (isProductionRuntime()) {
|
|
5096
|
+
return "";
|
|
5097
|
+
}
|
|
4721
5098
|
return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
|
|
4722
5099
|
};
|
|
4723
5100
|
var handleReactPageRequest = async (input) => {
|
|
@@ -4772,6 +5149,7 @@ var handleReactPageRequest = async (input) => {
|
|
|
4772
5149
|
const stream = await renderToReadableStream(element, {
|
|
4773
5150
|
bootstrapModules: [resolvedIndex],
|
|
4774
5151
|
bootstrapScriptContent: BROWSER_TRANSLATION_BASELINE_SCRIPT + propsScript + refreshSetup,
|
|
5152
|
+
nonce: readCspNonce(),
|
|
4775
5153
|
onError(error) {
|
|
4776
5154
|
console.error("[SSR] React streaming error:", error);
|
|
4777
5155
|
}
|
|
@@ -4803,6 +5181,229 @@ var handleReactPageRequest = async (input) => {
|
|
|
4803
5181
|
}), request);
|
|
4804
5182
|
}
|
|
4805
5183
|
};
|
|
5184
|
+
// src/core/fileRouteAdapter.ts
|
|
5185
|
+
var PARAM_NAME_RE = /:([A-Za-z_$][\w$]*)/g;
|
|
5186
|
+
var paramNamesOf = (path) => [...path.matchAll(PARAM_NAME_RE)].map((match) => match[1]).filter((name) => name !== undefined);
|
|
5187
|
+
var hasRouteParams = (context, names) => names.every((name) => typeof context.params[name] === "string");
|
|
5188
|
+
var serverHooksOf = ({
|
|
5189
|
+
path,
|
|
5190
|
+
server
|
|
5191
|
+
}) => {
|
|
5192
|
+
if (!server)
|
|
5193
|
+
return {};
|
|
5194
|
+
const names = paramNamesOf(path);
|
|
5195
|
+
const withParams = async (context, run) => {
|
|
5196
|
+
const module = await server();
|
|
5197
|
+
if (!module || !hasRouteParams(context, names))
|
|
5198
|
+
return;
|
|
5199
|
+
return run(module, context);
|
|
5200
|
+
};
|
|
5201
|
+
const hooks = {
|
|
5202
|
+
beforeHandle: (context) => withParams(context, (module, typed) => module.beforeHandle?.(typed)),
|
|
5203
|
+
load: (context) => withParams(context, (module, typed) => module.load?.(typed))
|
|
5204
|
+
};
|
|
5205
|
+
return hooks;
|
|
5206
|
+
};
|
|
5207
|
+
var defineFileRouteWith = (framework, route, render) => {
|
|
5208
|
+
const definition = {
|
|
5209
|
+
framework,
|
|
5210
|
+
name: route.name,
|
|
5211
|
+
path: route.path,
|
|
5212
|
+
render,
|
|
5213
|
+
source: route.source,
|
|
5214
|
+
...serverHooksOf(route)
|
|
5215
|
+
};
|
|
5216
|
+
return definition;
|
|
5217
|
+
};
|
|
5218
|
+
|
|
5219
|
+
// src/core/lookup.ts
|
|
5220
|
+
init_requestContext();
|
|
5221
|
+
var asset = (source, name) => {
|
|
5222
|
+
const assetPath = source[name];
|
|
5223
|
+
if (assetPath === undefined) {
|
|
5224
|
+
if (isProductionRuntime()) {
|
|
5225
|
+
throw new Error(`Asset "${name}" not found in manifest.`);
|
|
5226
|
+
}
|
|
5227
|
+
recordMissingAsset(name);
|
|
5228
|
+
const page = getDevPageWarmer()?.describe(name);
|
|
5229
|
+
if (page !== undefined && !page.built)
|
|
5230
|
+
return "";
|
|
5231
|
+
console.warn(`[asset] key "${name}" not found in manifest (dev mode \u2014 skipping)`);
|
|
5232
|
+
return "";
|
|
5233
|
+
}
|
|
5234
|
+
return assetPath;
|
|
5235
|
+
};
|
|
5236
|
+
|
|
5237
|
+
// src/react/fileRoute.ts
|
|
5238
|
+
var isReactComponent = (value) => typeof value === "function" || typeof value === "object" && value !== null && ("$$typeof" in value);
|
|
5239
|
+
var reactFileRoute = (route) => defineFileRouteWith("react", route, async ({ manifest, props, request }) => {
|
|
5240
|
+
const { default: Page } = await route.page();
|
|
5241
|
+
if (!isReactComponent(Page)) {
|
|
5242
|
+
throw new Error(`File route ${route.source} has no default-exported React component.`);
|
|
5243
|
+
}
|
|
5244
|
+
return handleReactPageRequest({
|
|
5245
|
+
index: asset(manifest, `${route.name}Index`),
|
|
5246
|
+
Page,
|
|
5247
|
+
props,
|
|
5248
|
+
request
|
|
5249
|
+
});
|
|
5250
|
+
});
|
|
5251
|
+
// src/react/serverComponents/pageHandler.ts
|
|
5252
|
+
init_cspNonceRef();
|
|
5253
|
+
init_requestContext();
|
|
5254
|
+
init_pageResponseCache();
|
|
5255
|
+
import { readFile } from "fs/promises";
|
|
5256
|
+
import { dirname, join } from "path";
|
|
5257
|
+
init_devRouteRegistrationCallsite();
|
|
5258
|
+
init_ssrErrorPage();
|
|
5259
|
+
init_browserTranslation();
|
|
5260
|
+
|
|
5261
|
+
// src/react/serverComponents/flightPayload.ts
|
|
5262
|
+
init_cspNonceRef();
|
|
5263
|
+
var BODY_OPEN = /<body[\s>]/i;
|
|
5264
|
+
var BODY_CLOSE = "</body>";
|
|
5265
|
+
var escapePayloadChunk = (chunk) => JSON.stringify(chunk).replace(/</g, "\\u003c").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
5266
|
+
var flightPayloadScript = (chunk, nonce) => `<script${nonceAttr(nonce)}>(self.${REACT_SERVER_PAYLOAD_GLOBAL}??=[]).push(${escapePayloadChunk(chunk)})</script>`;
|
|
5267
|
+
var readText = async (stream, onText) => {
|
|
5268
|
+
const reader = stream.getReader();
|
|
5269
|
+
const decoder = new TextDecoder;
|
|
5270
|
+
const step = async () => {
|
|
5271
|
+
const { done, value } = await reader.read();
|
|
5272
|
+
if (done) {
|
|
5273
|
+
onText(decoder.decode());
|
|
5274
|
+
return;
|
|
5275
|
+
}
|
|
5276
|
+
onText(decoder.decode(value, { stream: true }));
|
|
5277
|
+
await step();
|
|
5278
|
+
};
|
|
5279
|
+
await step();
|
|
5280
|
+
};
|
|
5281
|
+
var takeAll = (pending) => pending.splice(0).join("");
|
|
5282
|
+
var injectFlightPayload = (html, flight, nonce) => {
|
|
5283
|
+
const encoder = new TextEncoder;
|
|
5284
|
+
const pending = [];
|
|
5285
|
+
const flightDone = readText(flight, (text) => {
|
|
5286
|
+
if (text)
|
|
5287
|
+
pending.push(flightPayloadScript(text, nonce));
|
|
5288
|
+
});
|
|
5289
|
+
flightDone.catch(() => {
|
|
5290
|
+
return;
|
|
5291
|
+
});
|
|
5292
|
+
let bodyOpen = false;
|
|
5293
|
+
let tail = "";
|
|
5294
|
+
const handleHtml = (controller, text) => {
|
|
5295
|
+
if (!text)
|
|
5296
|
+
return;
|
|
5297
|
+
if (tail) {
|
|
5298
|
+
tail += text;
|
|
5299
|
+
return;
|
|
5300
|
+
}
|
|
5301
|
+
const closeIndex = text.indexOf(BODY_CLOSE);
|
|
5302
|
+
if (closeIndex >= 0) {
|
|
5303
|
+
tail = text.slice(closeIndex);
|
|
5304
|
+
controller.enqueue(encoder.encode(text.slice(0, closeIndex) + takeAll(pending)));
|
|
5305
|
+
return;
|
|
5306
|
+
}
|
|
5307
|
+
bodyOpen = bodyOpen || BODY_OPEN.test(text);
|
|
5308
|
+
controller.enqueue(encoder.encode(bodyOpen ? text + takeAll(pending) : text));
|
|
5309
|
+
};
|
|
5310
|
+
const pump = async (controller) => {
|
|
5311
|
+
try {
|
|
5312
|
+
await readText(html, (text) => handleHtml(controller, text));
|
|
5313
|
+
await flightDone;
|
|
5314
|
+
controller.enqueue(encoder.encode(takeAll(pending) + tail));
|
|
5315
|
+
controller.close();
|
|
5316
|
+
} catch (error) {
|
|
5317
|
+
controller.error(error);
|
|
5318
|
+
}
|
|
5319
|
+
};
|
|
5320
|
+
return new ReadableStream({
|
|
5321
|
+
start(controller) {
|
|
5322
|
+
pump(controller);
|
|
5323
|
+
}
|
|
5324
|
+
});
|
|
5325
|
+
};
|
|
5326
|
+
|
|
5327
|
+
// src/react/serverComponents/pageHandler.ts
|
|
5328
|
+
var isRecord4 = (value) => typeof value === "object" && value !== null;
|
|
5329
|
+
var isPageModule = (value) => isRecord4(value) && typeof value.Page === "function" && isRecord4(value.clientManifest) && typeof value.createElement === "function" && typeof value.renderToReadableStream === "function";
|
|
5330
|
+
var isRendererModule = (value) => isRecord4(value) && typeof value.renderHtml === "function";
|
|
5331
|
+
var isRuntime = (value) => isRecord4(value) && typeof value.client === "string" && typeof value.ssr === "string";
|
|
5332
|
+
var runtimeCache = new Map;
|
|
5333
|
+
var loadRuntime = async (pagePath) => {
|
|
5334
|
+
const runtimeDir = dirname(pagePath);
|
|
5335
|
+
const parsed = JSON.parse(await readFile(join(runtimeDir, REACT_SERVER_RUNTIME_FILE), "utf8"));
|
|
5336
|
+
if (!isRuntime(parsed)) {
|
|
5337
|
+
throw new Error(`Invalid ${REACT_SERVER_RUNTIME_FILE} in ${runtimeDir}`);
|
|
5338
|
+
}
|
|
5339
|
+
return { client: parsed.client, ssr: join(runtimeDir, parsed.ssr) };
|
|
5340
|
+
};
|
|
5341
|
+
var readRuntime = (pagePath) => {
|
|
5342
|
+
if (!isProductionRuntime())
|
|
5343
|
+
return loadRuntime(pagePath);
|
|
5344
|
+
const cached = runtimeCache.get(pagePath);
|
|
5345
|
+
if (cached)
|
|
5346
|
+
return cached;
|
|
5347
|
+
const loading = loadRuntime(pagePath);
|
|
5348
|
+
runtimeCache.set(pagePath, loading);
|
|
5349
|
+
loading.catch(() => runtimeCache.delete(pagePath));
|
|
5350
|
+
return loading;
|
|
5351
|
+
};
|
|
5352
|
+
var loadPageModule = async (pagePath) => {
|
|
5353
|
+
const loaded = await import(pagePath);
|
|
5354
|
+
if (!isPageModule(loaded)) {
|
|
5355
|
+
throw new Error(`${pagePath} is not a React Server Components page bundle. Pass asset(manifest, "<Page>RSC") and give the page a default export.`);
|
|
5356
|
+
}
|
|
5357
|
+
return loaded;
|
|
5358
|
+
};
|
|
5359
|
+
var loadRenderer = async (rendererPath) => {
|
|
5360
|
+
const loaded = await import(rendererPath);
|
|
5361
|
+
if (!isRendererModule(loaded)) {
|
|
5362
|
+
throw new Error(`${rendererPath} is not a React Server Components renderer.`);
|
|
5363
|
+
}
|
|
5364
|
+
return loaded;
|
|
5365
|
+
};
|
|
5366
|
+
var logRenderError = (error) => {
|
|
5367
|
+
console.error("[SSR] React Server Components error:", error);
|
|
5368
|
+
};
|
|
5369
|
+
var handleReactServerPageRequest = async (input) => {
|
|
5370
|
+
const request = input.request ?? getCurrentAbsoluteRequest();
|
|
5371
|
+
if (input.page === "") {
|
|
5372
|
+
throw new Error("React Server Components page bundle not found in manifest. Is reactServerComponentsDirectory set in absolute.config.ts?");
|
|
5373
|
+
}
|
|
5374
|
+
try {
|
|
5375
|
+
const handlerCallsite = input.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
|
|
5376
|
+
const renderPageResponse = async () => {
|
|
5377
|
+
const [pageModule, runtime] = await Promise.all([
|
|
5378
|
+
loadPageModule(input.page),
|
|
5379
|
+
readRuntime(input.page)
|
|
5380
|
+
]);
|
|
5381
|
+
const renderer = await loadRenderer(runtime.ssr);
|
|
5382
|
+
const nonce = readCspNonce();
|
|
5383
|
+
const flight = pageModule.renderToReadableStream(pageModule.createElement(pageModule.Page, input.props ?? {}), pageModule.clientManifest, { onError: logRenderError });
|
|
5384
|
+
const [forHtml, forPayload] = flight.tee();
|
|
5385
|
+
const html = await renderer.renderHtml(forHtml, {
|
|
5386
|
+
bootstrapModules: [runtime.client],
|
|
5387
|
+
bootstrapScriptContent: BROWSER_TRANSLATION_BASELINE_SCRIPT,
|
|
5388
|
+
nonce,
|
|
5389
|
+
onError: logRenderError
|
|
5390
|
+
});
|
|
5391
|
+
return new Response(injectFlightPayload(html, forPayload, nonce), {
|
|
5392
|
+
headers: streamingPageHeaders()
|
|
5393
|
+
});
|
|
5394
|
+
};
|
|
5395
|
+
const pageResponse = await runWithStreamingSlotWarningScope(() => input.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, input) : renderPageResponse(), { handlerCallsite });
|
|
5396
|
+
return withPageCacheHeaders(pageResponse, request, {
|
|
5397
|
+
bufferStreamForEtag: input.bufferStreamForEtag
|
|
5398
|
+
});
|
|
5399
|
+
} catch (error) {
|
|
5400
|
+
logRenderError(error);
|
|
5401
|
+
return withPageCacheHeaders(new Response(ssrErrorPage("react", error), {
|
|
5402
|
+
headers: { "Content-Type": "text/html" },
|
|
5403
|
+
status: 500
|
|
5404
|
+
}), request);
|
|
5405
|
+
}
|
|
5406
|
+
};
|
|
4806
5407
|
// src/react/Island.tsx
|
|
4807
5408
|
init_islandMarkupAttributes();
|
|
4808
5409
|
init_renderIslandMarkup();
|
|
@@ -4948,8 +5549,10 @@ export {
|
|
|
4948
5549
|
Island,
|
|
4949
5550
|
createTypedIsland,
|
|
4950
5551
|
handleReactPageRequest,
|
|
5552
|
+
handleReactServerPageRequest,
|
|
5553
|
+
reactFileRoute,
|
|
4951
5554
|
useIslandStore
|
|
4952
5555
|
};
|
|
4953
5556
|
|
|
4954
|
-
//# debugId=
|
|
5557
|
+
//# debugId=F1A7AE40C26B56F464756E2164756E21
|
|
4955
5558
|
//# sourceMappingURL=index.js.map
|