@absolutejs/absolute 0.19.0-beta.694 → 0.19.0-beta.696

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/angular/browser.js +48 -40
  3. package/dist/angular/browser.js.map +4 -4
  4. package/dist/angular/index.js +3090 -2890
  5. package/dist/angular/index.js.map +15 -14
  6. package/dist/angular/server.js +3083 -2883
  7. package/dist/angular/server.js.map +15 -15
  8. package/dist/build.js +42942 -6408
  9. package/dist/build.js.map +9 -20
  10. package/dist/cli/index.js +2 -1
  11. package/dist/core/streamingSlotRegistrar.js +24 -16
  12. package/dist/core/streamingSlotRegistrar.js.map +2 -2
  13. package/dist/core/streamingSlotRegistry.js +42 -29
  14. package/dist/core/streamingSlotRegistry.js.map +2 -2
  15. package/dist/index.js +41443 -4405
  16. package/dist/index.js.map +28 -40
  17. package/dist/islands/index.js +135 -11
  18. package/dist/islands/index.js.map +3 -3
  19. package/dist/react/components/index.js +24 -16
  20. package/dist/react/components/index.js.map +2 -2
  21. package/dist/react/index.js +1056 -873
  22. package/dist/react/index.js.map +13 -13
  23. package/dist/react/server.js +903 -843
  24. package/dist/react/server.js.map +11 -11
  25. package/dist/src/build/compileTailwind.d.ts +3 -0
  26. package/dist/src/build/stylePreprocessor.d.ts +2 -1
  27. package/dist/src/core/build.d.ts +1 -1
  28. package/dist/src/core/pageHandlers.d.ts +0 -1
  29. package/dist/src/core/ssrCache.d.ts +3 -0
  30. package/dist/svelte/index.js +1104 -916
  31. package/dist/svelte/index.js.map +15 -14
  32. package/dist/svelte/server.js +891 -702
  33. package/dist/svelte/server.js.map +13 -13
  34. package/dist/types/build.d.ts +18 -4
  35. package/dist/types/index.d.ts +0 -1
  36. package/dist/types/island.d.ts +14 -11
  37. package/dist/vue/components/index.js +24 -16
  38. package/dist/vue/components/index.js.map +2 -2
  39. package/dist/vue/index.js +1144 -956
  40. package/dist/vue/index.js.map +13 -13
  41. package/dist/vue/server.js +908 -841
  42. package/dist/vue/server.js.map +11 -11
  43. package/package.json +20 -8
@@ -78,99 +78,6 @@ var __legacyMetadataTS = (k, v) => {
78
78
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
79
79
  var __require = import.meta.require;
80
80
 
81
- // src/core/streamingSlotRegistrar.ts
82
- var STREAMING_SLOT_REGISTRAR_KEY, STREAMING_SLOT_WARNING_STORAGE_KEY, STREAMING_SLOT_COLLECTION_STORAGE_KEY, getRegisteredStreamingSlotRegistrar = () => {
83
- const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
84
- if (typeof value === "function" || value === null) {
85
- return value;
86
- }
87
- return;
88
- }, isObjectRecord = (value) => Boolean(value) && typeof value === "object", isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function", isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function", getWarningController = () => {
89
- const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
90
- if (value === null || typeof value === "undefined")
91
- return;
92
- return isStreamingSlotWarningController(value) ? value : undefined;
93
- }, getCollectionController = () => {
94
- const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
95
- if (value === null || typeof value === "undefined")
96
- return;
97
- return isStreamingSlotCollectionController(value) ? value : undefined;
98
- }, hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function", isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true, registerStreamingSlot = (slot) => {
99
- getRegisteredStreamingSlotRegistrar()?.(slot);
100
- }, setStreamingSlotCollectionController = (controller) => {
101
- Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
102
- }, setStreamingSlotRegistrar = (nextRegistrar) => {
103
- Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
104
- }, setStreamingSlotWarningController = (controller) => {
105
- Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
106
- }, warnMissingStreamingSlotCollector = (primitiveName) => {
107
- if (isStreamingSlotCollectionActive()) {
108
- return;
109
- }
110
- getWarningController()?.maybeWarn(primitiveName);
111
- };
112
- var init_streamingSlotRegistrar = __esm(() => {
113
- STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
114
- STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
115
- STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
116
- });
117
-
118
- // src/core/streamingSlotRegistry.ts
119
- var STREAMING_SLOT_STORAGE_KEY, isObjectRecord2 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getStorageGlobal = () => {
120
- const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
121
- if (value === null || typeof value === "undefined") {
122
- return value;
123
- }
124
- return isAsyncLocalStorage(value) ? value : undefined;
125
- }, isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string", ensureAsyncLocalStorage = async () => {
126
- const storage = getStorageGlobal();
127
- if (typeof storage !== "undefined") {
128
- return storage;
129
- }
130
- if (!isServerRuntime()) {
131
- Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
132
- return getStorageGlobal();
133
- }
134
- const mod = await import("async_hooks");
135
- Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
136
- return getStorageGlobal();
137
- }, getActiveSlotStore = () => {
138
- const storage = getStorageGlobal();
139
- if (!storage)
140
- return;
141
- return storage.getStore();
142
- }, registerStreamingSlot2 = (slot) => {
143
- const store = getActiveSlotStore();
144
- if (!store)
145
- return;
146
- store.set(slot.id, slot);
147
- }, hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined, runWithStreamingSlotRegistry = async (task) => {
148
- const storage = await ensureAsyncLocalStorage();
149
- if (!storage) {
150
- const slots = [];
151
- return {
152
- result: await task(),
153
- slots
154
- };
155
- }
156
- return storage.run(new Map, async () => {
157
- const result = await task();
158
- const store = storage.getStore();
159
- return {
160
- result,
161
- slots: store ? [...store.values()] : []
162
- };
163
- });
164
- };
165
- var init_streamingSlotRegistry = __esm(() => {
166
- init_streamingSlotRegistrar();
167
- STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
168
- setStreamingSlotRegistrar(registerStreamingSlot2);
169
- setStreamingSlotCollectionController({
170
- isCollecting: () => getActiveSlotStore() !== undefined
171
- });
172
- });
173
-
174
81
  // src/build/resolvePackageImport.ts
175
82
  import { resolve, join } from "path";
176
83
  import { existsSync, readFileSync } from "fs";
@@ -359,12 +266,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
359
266
  });
360
267
 
361
268
  // src/build/stylePreprocessor.ts
269
+ var exports_stylePreprocessor = {};
270
+ __export(exports_stylePreprocessor, {
271
+ stylePreprocessorPlugin: () => stylePreprocessorPlugin,
272
+ isStylePath: () => isStylePath,
273
+ isStyleModulePath: () => isStyleModulePath,
274
+ isPreprocessableStylePath: () => isPreprocessableStylePath,
275
+ getStyleBaseName: () => getStyleBaseName,
276
+ getCssOutputExtension: () => getCssOutputExtension,
277
+ createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
278
+ createStyleTransformConfig: () => createStyleTransformConfig,
279
+ createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
280
+ compileStyleSource: () => compileStyleSource,
281
+ compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
282
+ compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
283
+ });
362
284
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
363
285
  import { readFile } from "fs/promises";
364
286
  import { createRequire } from "module";
365
287
  import { dirname, extname, isAbsolute, join as join2, relative, resolve as resolve2 } from "path";
366
288
  import { fileURLToPath } from "url";
367
- var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
289
+ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
368
290
  const normalized = filePathOrLanguage.toLowerCase();
369
291
  if (normalized === "scss" || normalized.endsWith(".scss"))
370
292
  return "scss";
@@ -375,7 +297,13 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
375
297
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
376
298
  return "stylus";
377
299
  return null;
378
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
300
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
301
+ try {
302
+ return requireFromCwd(specifier);
303
+ } catch {
304
+ return requireOptionalPeer(specifier);
305
+ }
306
+ }, normalizeLoadPaths = (filePath, paths = []) => [
379
307
  dirname(filePath),
380
308
  process.cwd(),
381
309
  ...paths.map((path) => resolve2(process.cwd(), path))
@@ -504,8 +432,72 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
504
432
  }, getSassOptions = (config, language) => ({
505
433
  ...config?.sass ?? {},
506
434
  ...language === "scss" ? config?.scss ?? {} : {}
507
- }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
508
- ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
435
+ }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
436
+ ${contents}` : contents, normalizePostcssModule = (mod) => {
437
+ if (mod && typeof mod === "object" && "default" in mod) {
438
+ return mod.default ?? mod;
439
+ }
440
+ return mod;
441
+ }, loadPostcssConfigFile = async (configPath) => {
442
+ const resolved = resolve2(process.cwd(), configPath);
443
+ const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
444
+ const config = normalizePostcssModule(loaded);
445
+ const value = typeof config === "function" ? await config({
446
+ cwd: process.cwd(),
447
+ env: "development"
448
+ }) : config;
449
+ return normalizePostcssModule(value) ?? {};
450
+ }, normalizePostcssPlugins = (plugins) => {
451
+ if (!plugins)
452
+ return [];
453
+ if (Array.isArray(plugins))
454
+ return plugins.filter(Boolean);
455
+ const resolved = [];
456
+ for (const [specifier, options] of Object.entries(plugins)) {
457
+ if (options === false)
458
+ continue;
459
+ const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
460
+ const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
461
+ if (plugin)
462
+ resolved.push(plugin);
463
+ }
464
+ return resolved;
465
+ }, resolvePostcssConfig = async (config) => {
466
+ const inlineConfig = config?.postcss;
467
+ if (!inlineConfig)
468
+ return null;
469
+ const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
470
+ const plugins = [
471
+ ...normalizePostcssPlugins(fileConfig.plugins),
472
+ ...normalizePostcssPlugins(inlineConfig.plugins)
473
+ ];
474
+ if (plugins.length === 0)
475
+ return null;
476
+ return {
477
+ options: {
478
+ ...fileConfig.options ?? {},
479
+ ...inlineConfig.options ?? {}
480
+ },
481
+ plugins
482
+ };
483
+ }, runPostcss = async (css, filePath, config) => {
484
+ const postcssConfig = await resolvePostcssConfig(config);
485
+ if (!postcssConfig)
486
+ return css;
487
+ let postcssModule;
488
+ try {
489
+ postcssModule = await importOptionalPeer("postcss");
490
+ } catch {
491
+ throw missingDependencyError("postcss", filePath);
492
+ }
493
+ const postcss = postcssModule.default ?? postcssModule;
494
+ const result = await postcss(postcssConfig.plugins).process(css, {
495
+ from: filePath,
496
+ map: false,
497
+ ...postcssConfig.options
498
+ });
499
+ return result.css;
500
+ }, createSassImporter = (entryFile, loadPaths, language, config) => ({
509
501
  canonicalize(specifier, options) {
510
502
  const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
511
503
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -584,7 +576,7 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
584
576
  syntax: language === "sass" ? "indented" : "scss",
585
577
  url: new URL(`file://${filePath}`)
586
578
  });
587
- return result.css;
579
+ return runPostcss(result.css, filePath, config);
588
580
  }
589
581
  if (language === "less") {
590
582
  const options = getLessOptions(config);
@@ -609,15 +601,15 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
609
601
  createLessFileManager(filePath, loadPaths, config)
610
602
  ]
611
603
  });
612
- return result.css;
604
+ return runPostcss(result.css, filePath, config);
613
605
  }
614
606
  if (language === "stylus") {
615
607
  const options = getStylusOptions(config);
616
608
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
617
609
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
618
- return renderStylus(contents, filePath, loadPaths, options);
610
+ return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
619
611
  }
620
- return rawContents;
612
+ return runPostcss(rawContents, filePath, config);
621
613
  }, createStylePreprocessorPlugin = (config) => ({
622
614
  name: "absolute-style-preprocessor",
623
615
  setup(build) {
@@ -653,6 +645,10 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
653
645
  loader: "css"
654
646
  };
655
647
  });
648
+ build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
649
+ contents: await compileStyleSource(path, undefined, undefined, config),
650
+ loader: "css"
651
+ }));
656
652
  }
657
653
  }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
658
654
  style: async ({
@@ -670,11 +666,46 @@ ${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, c
670
666
  }
671
667
  }), compileStyleFileIfNeeded = async (filePath, config) => {
672
668
  if (!isPreprocessableStylePath(filePath)) {
673
- return readFile(filePath, "utf-8");
669
+ return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
674
670
  }
675
671
  return compileStyleSource(filePath, undefined, undefined, config);
676
- };
672
+ }, compileStyleFileIfNeededSync = (filePath, config) => {
673
+ const rawContents = readFileSync2(filePath, "utf-8");
674
+ const language = getStyleLanguage(filePath);
675
+ if (config?.postcss) {
676
+ throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
677
+ }
678
+ if (language === "scss" || language === "sass") {
679
+ const options = getSassOptions(config, language);
680
+ const packageName = options.implementation ?? "sass";
681
+ let sass;
682
+ try {
683
+ sass = requireOptionalPeerSync(packageName);
684
+ } catch {
685
+ throw missingDependencyError(packageName, filePath);
686
+ }
687
+ const contents = withAdditionalData(rawContents, options.additionalData);
688
+ const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
689
+ return sass.compileString(contents, {
690
+ importers: [
691
+ createSassImporter(filePath, loadPaths, language, config)
692
+ ],
693
+ loadPaths,
694
+ style: "expanded",
695
+ syntax: language === "sass" ? "indented" : "scss",
696
+ url: new URL(`file://${filePath}`)
697
+ }).css;
698
+ }
699
+ if (language === "less") {
700
+ throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
701
+ }
702
+ if (language === "stylus") {
703
+ throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
704
+ }
705
+ return rawContents;
706
+ }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
677
707
  var init_stylePreprocessor = __esm(() => {
708
+ CSS_EXTENSION_PATTERN = /\.css$/i;
678
709
  STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
679
710
  STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
680
711
  STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
@@ -864,305 +895,107 @@ var init_svelteServerModule = __esm(() => {
864
895
  });
865
896
  });
866
897
 
867
- // src/core/islandPageContext.ts
868
- var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient", ISLAND_MARKER = 'data-island="true"', MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__", ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__", CLOSING_HEAD_TAG = "</head>", buildIslandsHeadMarkup = (manifest) => {
869
- const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
870
- const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
871
- const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
872
- const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
873
- return `${manifestScript}${islandStateScript}${bootstrapScript}`;
874
- }, injectHeadMarkup = (html, markup) => {
875
- const closingHeadIndex = html.indexOf("</head>");
876
- if (closingHeadIndex >= 0) {
877
- return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
898
+ // src/core/devRouteRegistrationCallsite.ts
899
+ var exports_devRouteRegistrationCallsite = {};
900
+ __export(exports_devRouteRegistrationCallsite, {
901
+ patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
902
+ getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
903
+ });
904
+ import { AsyncLocalStorage } from "async_hooks";
905
+ import { Elysia } from "elysia";
906
+ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getRouteCallsiteStorage = () => {
907
+ const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
908
+ if (value === null || typeof value === "undefined") {
909
+ return;
878
910
  }
879
- const openingBodyIndex = html.indexOf("<body");
880
- if (openingBodyIndex >= 0) {
881
- const bodyStart = html.indexOf(">", openingBodyIndex);
882
- if (bodyStart >= 0) {
883
- return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
911
+ return isAsyncLocalStorage2(value) ? value : undefined;
912
+ }, ensureRouteCallsiteStorage = () => {
913
+ const existing = getRouteCallsiteStorage();
914
+ if (existing) {
915
+ return existing;
916
+ }
917
+ const storage = new AsyncLocalStorage;
918
+ Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
919
+ return storage;
920
+ }, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
921
+ const frames = stack.split(`
922
+ `).slice(1).map((line) => line.trim());
923
+ for (const frame of frames) {
924
+ if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
925
+ continue;
926
+ }
927
+ const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
928
+ if (locationMatch?.[1]) {
929
+ return normalizeCallsitePath(locationMatch[1]);
884
930
  }
885
931
  }
886
- return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
887
- }, streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true }), flushSafePendingText = (controller, encoder, pending, lookbehind) => {
888
- if (pending.length <= lookbehind) {
889
- return pending;
932
+ return;
933
+ }, captureRouteRegistrationCallsite = () => {
934
+ const { stack } = new Error;
935
+ if (!stack) {
936
+ return;
890
937
  }
891
- const safeText = pending.slice(0, pending.length - lookbehind);
892
- controller.enqueue(encoder.encode(safeText));
893
- return pending.slice(-lookbehind);
894
- }, updateInjectedState = (consumed, injected, pending) => {
895
- if (consumed.done) {
896
- return { done: true, injected, pending };
938
+ return extractRouteRegistrationCallsite(stack);
939
+ }, wrapRouteHandlerWithCallsite = (handler, callsite) => {
940
+ if (typeof handler !== "function" || !callsite) {
941
+ return handler;
897
942
  }
898
- return {
899
- done: false,
900
- injected: consumed.injected,
901
- pending: consumed.pending
943
+ const storage = ensureRouteCallsiteStorage();
944
+ return function wrappedRouteHandler(...args) {
945
+ return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
902
946
  };
903
- }, readStreamChunk = async (reader) => {
904
- const { done, value } = await reader.read();
905
- if (done || !value) {
906
- return { done, value: undefined };
947
+ }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
948
+ if (false) {}
949
+ if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
950
+ return;
907
951
  }
908
- return { done, value };
909
- }, pipeStreamWithHeadInjection = (stream, markup) => {
910
- const encoder = new TextEncoder;
911
- const decoder = new TextDecoder;
912
- const lookbehind = CLOSING_HEAD_TAG.length - 1;
913
- const processPending = (controller, pending, injected) => {
914
- if (injected) {
915
- controller.enqueue(encoder.encode(pending));
916
- return { injected, pending: "" };
917
- }
918
- const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
919
- if (headIndex >= 0) {
920
- const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
921
- controller.enqueue(encoder.encode(next));
922
- return { injected: true, pending: "" };
952
+ const prototype = Elysia.prototype;
953
+ for (const methodName of ROUTE_METHOD_NAMES) {
954
+ const originalMethod = prototype[methodName];
955
+ if (typeof originalMethod !== "function") {
956
+ continue;
923
957
  }
924
- return {
925
- injected,
926
- pending: flushSafePendingText(controller, encoder, pending, lookbehind)
958
+ prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
959
+ const callsite = captureRouteRegistrationCallsite();
960
+ return Reflect.apply(originalMethod, this, [
961
+ path,
962
+ wrapRouteHandlerWithCallsite(handler, callsite),
963
+ ...rest
964
+ ]);
927
965
  };
928
- };
929
- const finishHeadInjectionStream = (controller, pending, injected) => {
930
- let finalPending = pending + decoder.decode();
931
- if (!injected) {
932
- finalPending = injectHeadMarkup(finalPending, markup);
933
- }
934
- if (finalPending.length > 0) {
935
- controller.enqueue(encoder.encode(finalPending));
936
- }
937
- controller.close();
938
- };
939
- const consumeHeadChunk = async (controller, reader, pending, injected) => {
940
- const { done, value } = await readStreamChunk(reader);
941
- if (done || !value) {
942
- return { done, injected, pending };
943
- }
944
- const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
945
- return {
946
- done,
947
- injected: processed.injected,
948
- pending: processed.pending
949
- };
950
- };
951
- const runHeadInjectionLoop = async (controller, reader) => {
952
- const consumeNextHeadChunk = async (injected, pending) => {
953
- const consumed = await consumeHeadChunk(controller, reader, pending, injected);
954
- const nextState = updateInjectedState(consumed, injected, pending);
955
- if (nextState.done) {
956
- return { injected, pending };
957
- }
958
- return consumeNextHeadChunk(nextState.injected, nextState.pending);
959
- };
960
- return consumeNextHeadChunk(false, "");
961
- };
962
- return new ReadableStream({
963
- async start(controller) {
964
- const reader = stream.getReader();
965
- try {
966
- const { injected, pending } = await runHeadInjectionLoop(controller, reader);
967
- finishHeadInjectionStream(controller, pending, injected);
968
- } catch (error) {
969
- controller.error(error);
970
- }
971
- }
972
- });
973
- }, pipeStreamWithIslandMarkerDetection = (stream, markup) => {
974
- const encoder = new TextEncoder;
975
- const decoder = new TextDecoder;
976
- const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
977
- const processPending = (controller, pending, injected) => {
978
- if (injected) {
979
- controller.enqueue(encoder.encode(pending));
980
- return { injected, pending: "" };
981
- }
982
- const markerIndex = pending.indexOf(ISLAND_MARKER);
983
- if (markerIndex >= 0) {
984
- const tagStart = pending.lastIndexOf("<", markerIndex);
985
- const injectAt = tagStart >= 0 ? tagStart : markerIndex;
986
- const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
987
- controller.enqueue(encoder.encode(next));
988
- return { injected: true, pending: "" };
989
- }
990
- return {
991
- injected,
992
- pending: flushSafePendingText(controller, encoder, pending, lookbehind)
993
- };
994
- };
995
- const finishIslandMarkerStream = (controller, pending) => {
996
- const finalPending = pending + decoder.decode();
997
- if (finalPending.length > 0) {
998
- controller.enqueue(encoder.encode(finalPending));
999
- }
1000
- controller.close();
1001
- };
1002
- const consumeIslandChunk = async (controller, reader, pending, injected) => {
1003
- const { done, value } = await readStreamChunk(reader);
1004
- if (done || !value) {
1005
- return { done, injected, pending };
1006
- }
1007
- const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
1008
- return {
1009
- done,
1010
- injected: processed.injected,
1011
- pending: processed.pending
1012
- };
1013
- };
1014
- const runIslandMarkerLoop = async (controller, reader) => {
1015
- const consumeNextIslandChunk = async (injected, pending) => {
1016
- const consumed = await consumeIslandChunk(controller, reader, pending, injected);
1017
- const nextState = updateInjectedState(consumed, injected, pending);
1018
- if (nextState.done) {
1019
- return { injected, pending };
1020
- }
1021
- return consumeNextIslandChunk(nextState.injected, nextState.pending);
1022
- };
1023
- return consumeNextIslandChunk(false, "");
1024
- };
1025
- return new ReadableStream({
1026
- async start(controller) {
1027
- const reader = stream.getReader();
1028
- try {
1029
- const { pending } = await runIslandMarkerLoop(controller, reader);
1030
- finishIslandMarkerStream(controller, pending);
1031
- } catch (error) {
1032
- controller.error(error);
1033
- }
1034
- }
1035
- });
1036
- }, htmlContainsIslands = (html) => html.includes(ISLAND_MARKER), injectIslandPageContext = (html, options) => {
1037
- const manifest = globalThis.__absoluteManifest;
1038
- const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
1039
- if (!manifest || !hasIslands) {
1040
- return html;
1041
- }
1042
- if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
1043
- return html;
1044
- }
1045
- return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
1046
- }, injectIslandPageContextStream = (stream, options) => {
1047
- const manifest = globalThis.__absoluteManifest;
1048
- if (!manifest)
1049
- return stream;
1050
- const markup = buildIslandsHeadMarkup(manifest);
1051
- if (options?.hasIslands === true) {
1052
- return pipeStreamWithHeadInjection(stream, markup);
1053
- }
1054
- if (options?.hasIslands === false) {
1055
- return stream;
1056
- }
1057
- return pipeStreamWithIslandMarkerDetection(stream, markup);
1058
- }, setCurrentIslandManifest = (manifest) => {
1059
- globalThis.__absoluteManifest = manifest;
1060
- };
1061
- var init_islandPageContext = __esm(() => {
1062
- init_constants();
1063
- });
1064
-
1065
- // src/core/devRouteRegistrationCallsite.ts
1066
- var exports_devRouteRegistrationCallsite = {};
1067
- __export(exports_devRouteRegistrationCallsite, {
1068
- patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
1069
- getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
1070
- });
1071
- import { AsyncLocalStorage } from "async_hooks";
1072
- import { Elysia } from "elysia";
1073
- var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getRouteCallsiteStorage = () => {
1074
- const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
1075
- if (value === null || typeof value === "undefined") {
1076
- return;
1077
- }
1078
- return isAsyncLocalStorage2(value) ? value : undefined;
1079
- }, ensureRouteCallsiteStorage = () => {
1080
- const existing = getRouteCallsiteStorage();
1081
- if (existing) {
1082
- return existing;
1083
- }
1084
- const storage = new AsyncLocalStorage;
1085
- Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
1086
- return storage;
1087
- }, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), extractRouteRegistrationCallsite = (stack) => {
1088
- const frames = stack.split(`
1089
- `).slice(1).map((line) => line.trim());
1090
- for (const frame of frames) {
1091
- if (frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite.")) {
1092
- continue;
1093
- }
1094
- const locationMatch = frame.match(/\((\/[^)]+:\d+:\d+)\)$/) ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/);
1095
- if (locationMatch?.[1]) {
1096
- return normalizeCallsitePath(locationMatch[1]);
1097
- }
1098
- }
1099
- return;
1100
- }, captureRouteRegistrationCallsite = () => {
1101
- const { stack } = new Error;
1102
- if (!stack) {
1103
- return;
1104
- }
1105
- return extractRouteRegistrationCallsite(stack);
1106
- }, wrapRouteHandlerWithCallsite = (handler, callsite) => {
1107
- if (typeof handler !== "function" || !callsite) {
1108
- return handler;
1109
- }
1110
- const storage = ensureRouteCallsiteStorage();
1111
- return function wrappedRouteHandler(...args) {
1112
- return storage.run({ callsite }, () => Reflect.apply(handler, this, args));
1113
- };
1114
- }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
1115
- if (false) {}
1116
- if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
1117
- return;
1118
- }
1119
- const prototype = Elysia.prototype;
1120
- for (const methodName of ROUTE_METHOD_NAMES) {
1121
- const originalMethod = prototype[methodName];
1122
- if (typeof originalMethod !== "function") {
1123
- continue;
1124
- }
1125
- prototype[methodName] = function patchedRouteMethod(path, handler, ...rest) {
1126
- const callsite = captureRouteRegistrationCallsite();
1127
- return Reflect.apply(originalMethod, this, [
1128
- path,
1129
- wrapRouteHandlerWithCallsite(handler, callsite),
1130
- ...rest
1131
- ]);
1132
- };
1133
- }
1134
- Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
1135
- };
1136
- var init_devRouteRegistrationCallsite = __esm(() => {
1137
- ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
1138
- ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
1139
- ROUTE_METHOD_NAMES = [
1140
- "all",
1141
- "delete",
1142
- "get",
1143
- "head",
1144
- "options",
1145
- "patch",
1146
- "post",
1147
- "put"
1148
- ];
1149
- });
1150
-
1151
- // src/client/streamSwap.ts
1152
- var streamSwapRuntime = () => {
1153
- const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
1154
- if (window.__ABS_SLOT_RUNTIME__ === true)
1155
- return;
1156
- window.__ABS_SLOT_RUNTIME__ = true;
1157
- window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
1158
- window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
1159
- const consumers = window.__ABS_SLOT_CONSUMERS__;
1160
- const pending = window.__ABS_SLOT_PENDING__;
1161
- const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
1162
- const isPatchedPendingEntry = (value) => {
1163
- if (!isObjectRecord4(value))
1164
- return false;
1165
- return value.domPatched === true && "payload" in value;
966
+ }
967
+ Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
968
+ };
969
+ var init_devRouteRegistrationCallsite = __esm(() => {
970
+ ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
971
+ ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
972
+ ROUTE_METHOD_NAMES = [
973
+ "all",
974
+ "delete",
975
+ "get",
976
+ "head",
977
+ "options",
978
+ "patch",
979
+ "post",
980
+ "put"
981
+ ];
982
+ });
983
+
984
+ // src/client/streamSwap.ts
985
+ var streamSwapRuntime = () => {
986
+ const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
987
+ if (window.__ABS_SLOT_RUNTIME__ === true)
988
+ return;
989
+ window.__ABS_SLOT_RUNTIME__ = true;
990
+ window.__ABS_SLOT_CONSUMERS__ = window.__ABS_SLOT_CONSUMERS__ ?? {};
991
+ window.__ABS_SLOT_PENDING__ = window.__ABS_SLOT_PENDING__ ?? {};
992
+ const consumers = window.__ABS_SLOT_CONSUMERS__;
993
+ const pending = window.__ABS_SLOT_PENDING__;
994
+ const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
995
+ const isPatchedPendingEntry = (value) => {
996
+ if (!isObjectRecord4(value))
997
+ return false;
998
+ return value.domPatched === true && "payload" in value;
1166
999
  };
1167
1000
  const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
1168
1001
  const canApplyImmediately = () => window.__ABS_SLOT_HYDRATION_PENDING__ !== true;
@@ -1824,41 +1657,586 @@ var init_streamingSlots = __esm(() => {
1824
1657
  };
1825
1658
  });
1826
1659
 
1827
- // src/core/responseEnhancers.ts
1828
- var toResponse = async (responseLike) => responseLike, cloneHeaders = (response) => {
1829
- const headers = new Headers(response.headers);
1830
- return headers;
1831
- }, enhanceHtmlResponseWithStreamingSlots = (response, {
1832
- nonce,
1833
- onError,
1834
- runtimePlacement,
1835
- runtimePreludeScript,
1836
- streamingSlots = [],
1837
- policy
1838
- } = {}) => {
1839
- if (!response.body || streamingSlots.length === 0) {
1840
- return response;
1660
+ // src/utils/getDurationString.ts
1661
+ var getDurationString = (duration) => {
1662
+ let durationString;
1663
+ if (duration < MILLISECONDS_IN_A_SECOND) {
1664
+ durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
1665
+ } else if (duration < MILLISECONDS_IN_A_MINUTE) {
1666
+ durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
1667
+ } else {
1668
+ durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
1841
1669
  }
1842
- const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
1843
- nonce,
1844
- onError,
1845
- policy,
1846
- runtimePlacement,
1847
- runtimePreludeScript
1848
- });
1670
+ return durationString;
1671
+ };
1672
+ var init_getDurationString = __esm(() => {
1673
+ init_constants();
1674
+ });
1675
+
1676
+ // src/utils/startupBanner.ts
1677
+ var colors, MONTHS, formatTimestamp = () => {
1678
+ const now = new Date;
1679
+ const month = MONTHS[now.getMonth()];
1680
+ const day = now.getDate().toString().padStart(2, "0");
1681
+ let hours = now.getHours();
1682
+ const minutes = now.getMinutes().toString().padStart(2, "0");
1683
+ const seconds = now.getSeconds().toString().padStart(2, "0");
1684
+ const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
1685
+ hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
1686
+ return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
1687
+ }, startupBanner = (options) => {
1688
+ const {
1689
+ version,
1690
+ readyDuration,
1691
+ buildDuration,
1692
+ port,
1693
+ host,
1694
+ networkUrl,
1695
+ protocol = "http"
1696
+ } = options;
1697
+ const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
1698
+ const ver = `${colors.dim}v${version}${colors.reset}`;
1699
+ const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
1700
+ const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
1701
+ console.log("");
1702
+ console.log(` ${name} ${ver} ${time}${build}`);
1703
+ console.log("");
1704
+ console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
1705
+ if (networkUrl) {
1706
+ console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
1707
+ }
1708
+ console.log("");
1709
+ };
1710
+ var init_startupBanner = __esm(() => {
1711
+ init_constants();
1712
+ init_getDurationString();
1713
+ colors = {
1714
+ bold: "\x1B[1m",
1715
+ cyan: "\x1B[36m",
1716
+ dim: "\x1B[2m",
1717
+ green: "\x1B[32m",
1718
+ reset: "\x1B[0m"
1719
+ };
1720
+ MONTHS = [
1721
+ "Jan",
1722
+ "Feb",
1723
+ "Mar",
1724
+ "Apr",
1725
+ "May",
1726
+ "Jun",
1727
+ "Jul",
1728
+ "Aug",
1729
+ "Sep",
1730
+ "Oct",
1731
+ "Nov",
1732
+ "Dec"
1733
+ ];
1734
+ });
1735
+
1736
+ // src/utils/logger.ts
1737
+ var colors2, frameworkColors, formatPath = (filePath) => {
1738
+ const cwd = process.cwd();
1739
+ let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1740
+ relative3 = relative3.replace(/\\/g, "/");
1741
+ if (!relative3.startsWith("/")) {
1742
+ relative3 = `/${relative3}`;
1743
+ }
1744
+ return relative3;
1745
+ }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
1746
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1747
+ const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
1748
+ let message = action;
1749
+ if (options?.path) {
1750
+ const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
1751
+ message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
1752
+ }
1753
+ if (options?.duration !== undefined) {
1754
+ message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
1755
+ }
1756
+ console.log(`${timestamp} ${tag} ${message}`);
1757
+ }, logCssUpdate = (path, framework, duration) => {
1758
+ log("css update", { duration, framework: framework ?? "css", path });
1759
+ }, logError = (message, error) => {
1760
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1761
+ const tag = `${colors2.red}[hmr]${colors2.reset}`;
1762
+ const errorMsg = error instanceof Error ? error.message : error;
1763
+ const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
1764
+ console.error(`${timestamp} ${tag} ${fullMessage}`);
1765
+ }, logHmrUpdate = (path, framework, duration) => {
1766
+ log("hmr update", { duration, framework, path });
1767
+ }, logScriptUpdate = (path, framework, duration) => {
1768
+ log("script update", { duration, framework, path });
1769
+ }, logServerReload = () => {
1770
+ log(`${colors2.cyan}server module reloaded${colors2.reset}`);
1771
+ }, logWarn = (message) => {
1772
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1773
+ const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
1774
+ console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
1775
+ };
1776
+ var init_logger = __esm(() => {
1777
+ init_startupBanner();
1778
+ colors2 = {
1779
+ blue: "\x1B[34m",
1780
+ bold: "\x1B[1m",
1781
+ cyan: "\x1B[36m",
1782
+ dim: "\x1B[2m",
1783
+ green: "\x1B[32m",
1784
+ magenta: "\x1B[35m",
1785
+ red: "\x1B[31m",
1786
+ reset: "\x1B[0m",
1787
+ white: "\x1B[37m",
1788
+ yellow: "\x1B[33m"
1789
+ };
1790
+ frameworkColors = {
1791
+ angular: colors2.magenta,
1792
+ assets: colors2.dim,
1793
+ css: colors2.cyan,
1794
+ html: colors2.white,
1795
+ htmx: colors2.white,
1796
+ react: colors2.blue,
1797
+ svelte: colors2.yellow,
1798
+ vue: colors2.green
1799
+ };
1800
+ });
1801
+
1802
+ // src/core/ssrCache.ts
1803
+ var dirtyFrameworks, markSsrCacheDirty = (framework) => {
1804
+ dirtyFrameworks.add(framework);
1805
+ }, isSsrCacheDirty = (framework) => dirtyFrameworks.has(framework);
1806
+ var init_ssrCache = __esm(() => {
1807
+ dirtyFrameworks = new Set;
1808
+ });
1809
+
1810
+ // src/utils/stringModifiers.ts
1811
+ 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) => {
1812
+ if (!str.includes("-") && !str.includes("_")) {
1813
+ return str.charAt(0).toUpperCase() + str.slice(1);
1814
+ }
1815
+ return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
1816
+ }, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
1817
+
1818
+ // src/svelte/renderToReadableStream.ts
1819
+ var exports_renderToReadableStream = {};
1820
+ __export(exports_renderToReadableStream, {
1821
+ renderToReadableStream: () => renderToReadableStream,
1822
+ SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
1823
+ });
1824
+ var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
1825
+ bootstrapScriptContent,
1826
+ bootstrapScripts = [],
1827
+ bootstrapModules = [],
1828
+ nonce,
1829
+ onError = console.error,
1830
+ progressiveChunkSize = DEFAULT_CHUNK_SIZE,
1831
+ signal,
1832
+ headContent,
1833
+ bodyContent
1834
+ } = {}) => {
1835
+ try {
1836
+ const { render } = await import("svelte/server");
1837
+ const rendered = typeof props === "undefined" ? await render(component) : await render(component, { props });
1838
+ const { head, body } = rendered;
1839
+ const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
1840
+ const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
1841
+ const encoder = new TextEncoder;
1842
+ const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body><div id="${SVELTE_PAGE_ROOT_ID}">${body}</div>${scripts}${bodyContent ?? ""}</body></html>`);
1843
+ let offset = 0;
1844
+ return new ReadableStream({
1845
+ type: "bytes",
1846
+ cancel(reason) {
1847
+ onError?.(reason);
1848
+ },
1849
+ pull(controller) {
1850
+ if (signal?.aborted) {
1851
+ controller.close();
1852
+ return;
1853
+ }
1854
+ if (offset >= full.length) {
1855
+ controller.close();
1856
+ return;
1857
+ }
1858
+ const end = Math.min(offset + progressiveChunkSize, full.length);
1859
+ controller.enqueue(full.subarray(offset, end));
1860
+ offset = end;
1861
+ }
1862
+ });
1863
+ } catch (error) {
1864
+ onError?.(error);
1865
+ throw error;
1866
+ }
1867
+ };
1868
+ var init_renderToReadableStream = __esm(() => {
1869
+ init_constants();
1870
+ init_escapeScriptContent();
1871
+ });
1872
+
1873
+ // src/core/streamingSlotRegistrar.ts
1874
+ var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
1875
+ var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
1876
+ var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
1877
+ var getRegisteredStreamingSlotRegistrar = () => {
1878
+ const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
1879
+ if (typeof value === "function" || value === null) {
1880
+ return value;
1881
+ }
1882
+ return;
1883
+ };
1884
+ var isObjectRecord = (value) => Boolean(value) && typeof value === "object";
1885
+ var isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function";
1886
+ var isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function";
1887
+ var getWarningController = () => {
1888
+ const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
1889
+ if (value === null || typeof value === "undefined")
1890
+ return;
1891
+ return isStreamingSlotWarningController(value) ? value : undefined;
1892
+ };
1893
+ var getCollectionController = () => {
1894
+ const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
1895
+ if (value === null || typeof value === "undefined")
1896
+ return;
1897
+ return isStreamingSlotCollectionController(value) ? value : undefined;
1898
+ };
1899
+ var hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function";
1900
+ var isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true;
1901
+ var registerStreamingSlot = (slot) => {
1902
+ getRegisteredStreamingSlotRegistrar()?.(slot);
1903
+ };
1904
+ var setStreamingSlotCollectionController = (controller) => {
1905
+ Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
1906
+ };
1907
+ var setStreamingSlotRegistrar = (nextRegistrar) => {
1908
+ Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
1909
+ };
1910
+ var setStreamingSlotWarningController = (controller) => {
1911
+ Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
1912
+ };
1913
+ var warnMissingStreamingSlotCollector = (primitiveName) => {
1914
+ if (isStreamingSlotCollectionActive()) {
1915
+ return;
1916
+ }
1917
+ getWarningController()?.maybeWarn(primitiveName);
1918
+ };
1919
+
1920
+ // src/core/streamingSlotRegistry.ts
1921
+ var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
1922
+ var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
1923
+ var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
1924
+ var getStorageGlobal = () => {
1925
+ const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
1926
+ if (value === null || typeof value === "undefined") {
1927
+ return value;
1928
+ }
1929
+ return isAsyncLocalStorage(value) ? value : undefined;
1930
+ };
1931
+ var isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string";
1932
+ var ensureAsyncLocalStorage = async () => {
1933
+ const storage = getStorageGlobal();
1934
+ if (typeof storage !== "undefined") {
1935
+ return storage;
1936
+ }
1937
+ if (!isServerRuntime()) {
1938
+ Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
1939
+ return getStorageGlobal();
1940
+ }
1941
+ const mod = await import("async_hooks");
1942
+ Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
1943
+ return getStorageGlobal();
1944
+ };
1945
+ var getActiveSlotStore = () => {
1946
+ const storage = getStorageGlobal();
1947
+ if (!storage)
1948
+ return;
1949
+ return storage.getStore();
1950
+ };
1951
+ var registerStreamingSlot2 = (slot) => {
1952
+ const store = getActiveSlotStore();
1953
+ if (!store)
1954
+ return;
1955
+ store.set(slot.id, slot);
1956
+ };
1957
+ setStreamingSlotRegistrar(registerStreamingSlot2);
1958
+ setStreamingSlotCollectionController({
1959
+ isCollecting: () => getActiveSlotStore() !== undefined
1960
+ });
1961
+ var hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined;
1962
+ var runWithStreamingSlotRegistry = async (task) => {
1963
+ const storage = await ensureAsyncLocalStorage();
1964
+ if (!storage) {
1965
+ const slots = [];
1966
+ return {
1967
+ result: await task(),
1968
+ slots
1969
+ };
1970
+ }
1971
+ return storage.run(new Map, async () => {
1972
+ const result = await task();
1973
+ const store = storage.getStore();
1974
+ return {
1975
+ result,
1976
+ slots: store ? [...store.values()] : []
1977
+ };
1978
+ });
1979
+ };
1980
+
1981
+ // src/svelte/pageHandler.ts
1982
+ init_svelteServerModule();
1983
+
1984
+ // src/core/islandPageContext.ts
1985
+ init_constants();
1986
+ var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
1987
+ var ISLAND_MARKER = 'data-island="true"';
1988
+ var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
1989
+ var ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__";
1990
+ var CLOSING_HEAD_TAG = "</head>";
1991
+ var buildIslandsHeadMarkup = (manifest) => {
1992
+ const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
1993
+ const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
1994
+ const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
1995
+ const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
1996
+ return `${manifestScript}${islandStateScript}${bootstrapScript}`;
1997
+ };
1998
+ var injectHeadMarkup = (html, markup) => {
1999
+ const closingHeadIndex = html.indexOf("</head>");
2000
+ if (closingHeadIndex >= 0) {
2001
+ return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
2002
+ }
2003
+ const openingBodyIndex = html.indexOf("<body");
2004
+ if (openingBodyIndex >= 0) {
2005
+ const bodyStart = html.indexOf(">", openingBodyIndex);
2006
+ if (bodyStart >= 0) {
2007
+ return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
2008
+ }
2009
+ }
2010
+ return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
2011
+ };
2012
+ var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
2013
+ var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
2014
+ if (pending.length <= lookbehind) {
2015
+ return pending;
2016
+ }
2017
+ const safeText = pending.slice(0, pending.length - lookbehind);
2018
+ controller.enqueue(encoder.encode(safeText));
2019
+ return pending.slice(-lookbehind);
2020
+ };
2021
+ var updateInjectedState = (consumed, injected, pending) => {
2022
+ if (consumed.done) {
2023
+ return { done: true, injected, pending };
2024
+ }
2025
+ return {
2026
+ done: false,
2027
+ injected: consumed.injected,
2028
+ pending: consumed.pending
2029
+ };
2030
+ };
2031
+ var readStreamChunk = async (reader) => {
2032
+ const { done, value } = await reader.read();
2033
+ if (done || !value) {
2034
+ return { done, value: undefined };
2035
+ }
2036
+ return { done, value };
2037
+ };
2038
+ var pipeStreamWithHeadInjection = (stream, markup) => {
2039
+ const encoder = new TextEncoder;
2040
+ const decoder = new TextDecoder;
2041
+ const lookbehind = CLOSING_HEAD_TAG.length - 1;
2042
+ const processPending = (controller, pending, injected) => {
2043
+ if (injected) {
2044
+ controller.enqueue(encoder.encode(pending));
2045
+ return { injected, pending: "" };
2046
+ }
2047
+ const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
2048
+ if (headIndex >= 0) {
2049
+ const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
2050
+ controller.enqueue(encoder.encode(next));
2051
+ return { injected: true, pending: "" };
2052
+ }
2053
+ return {
2054
+ injected,
2055
+ pending: flushSafePendingText(controller, encoder, pending, lookbehind)
2056
+ };
2057
+ };
2058
+ const finishHeadInjectionStream = (controller, pending, injected) => {
2059
+ let finalPending = pending + decoder.decode();
2060
+ if (!injected) {
2061
+ finalPending = injectHeadMarkup(finalPending, markup);
2062
+ }
2063
+ if (finalPending.length > 0) {
2064
+ controller.enqueue(encoder.encode(finalPending));
2065
+ }
2066
+ controller.close();
2067
+ };
2068
+ const consumeHeadChunk = async (controller, reader, pending, injected) => {
2069
+ const { done, value } = await readStreamChunk(reader);
2070
+ if (done || !value) {
2071
+ return { done, injected, pending };
2072
+ }
2073
+ const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
2074
+ return {
2075
+ done,
2076
+ injected: processed.injected,
2077
+ pending: processed.pending
2078
+ };
2079
+ };
2080
+ const runHeadInjectionLoop = async (controller, reader) => {
2081
+ const consumeNextHeadChunk = async (injected, pending) => {
2082
+ const consumed = await consumeHeadChunk(controller, reader, pending, injected);
2083
+ const nextState = updateInjectedState(consumed, injected, pending);
2084
+ if (nextState.done) {
2085
+ return { injected, pending };
2086
+ }
2087
+ return consumeNextHeadChunk(nextState.injected, nextState.pending);
2088
+ };
2089
+ return consumeNextHeadChunk(false, "");
2090
+ };
2091
+ return new ReadableStream({
2092
+ async start(controller) {
2093
+ const reader = stream.getReader();
2094
+ try {
2095
+ const { injected, pending } = await runHeadInjectionLoop(controller, reader);
2096
+ finishHeadInjectionStream(controller, pending, injected);
2097
+ } catch (error) {
2098
+ controller.error(error);
2099
+ }
2100
+ }
2101
+ });
2102
+ };
2103
+ var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
2104
+ const encoder = new TextEncoder;
2105
+ const decoder = new TextDecoder;
2106
+ const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
2107
+ const processPending = (controller, pending, injected) => {
2108
+ if (injected) {
2109
+ controller.enqueue(encoder.encode(pending));
2110
+ return { injected, pending: "" };
2111
+ }
2112
+ const markerIndex = pending.indexOf(ISLAND_MARKER);
2113
+ if (markerIndex >= 0) {
2114
+ const tagStart = pending.lastIndexOf("<", markerIndex);
2115
+ const injectAt = tagStart >= 0 ? tagStart : markerIndex;
2116
+ const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
2117
+ controller.enqueue(encoder.encode(next));
2118
+ return { injected: true, pending: "" };
2119
+ }
2120
+ return {
2121
+ injected,
2122
+ pending: flushSafePendingText(controller, encoder, pending, lookbehind)
2123
+ };
2124
+ };
2125
+ const finishIslandMarkerStream = (controller, pending) => {
2126
+ const finalPending = pending + decoder.decode();
2127
+ if (finalPending.length > 0) {
2128
+ controller.enqueue(encoder.encode(finalPending));
2129
+ }
2130
+ controller.close();
2131
+ };
2132
+ const consumeIslandChunk = async (controller, reader, pending, injected) => {
2133
+ const { done, value } = await readStreamChunk(reader);
2134
+ if (done || !value) {
2135
+ return { done, injected, pending };
2136
+ }
2137
+ const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
2138
+ return {
2139
+ done,
2140
+ injected: processed.injected,
2141
+ pending: processed.pending
2142
+ };
2143
+ };
2144
+ const runIslandMarkerLoop = async (controller, reader) => {
2145
+ const consumeNextIslandChunk = async (injected, pending) => {
2146
+ const consumed = await consumeIslandChunk(controller, reader, pending, injected);
2147
+ const nextState = updateInjectedState(consumed, injected, pending);
2148
+ if (nextState.done) {
2149
+ return { injected, pending };
2150
+ }
2151
+ return consumeNextIslandChunk(nextState.injected, nextState.pending);
2152
+ };
2153
+ return consumeNextIslandChunk(false, "");
2154
+ };
2155
+ return new ReadableStream({
2156
+ async start(controller) {
2157
+ const reader = stream.getReader();
2158
+ try {
2159
+ const { pending } = await runIslandMarkerLoop(controller, reader);
2160
+ finishIslandMarkerStream(controller, pending);
2161
+ } catch (error) {
2162
+ controller.error(error);
2163
+ }
2164
+ }
2165
+ });
2166
+ };
2167
+ var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
2168
+ var injectIslandPageContext = (html, options) => {
2169
+ const manifest = globalThis.__absoluteManifest;
2170
+ const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
2171
+ if (!manifest || !hasIslands) {
2172
+ return html;
2173
+ }
2174
+ if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
2175
+ return html;
2176
+ }
2177
+ return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
2178
+ };
2179
+ var injectIslandPageContextStream = (stream, options) => {
2180
+ const manifest = globalThis.__absoluteManifest;
2181
+ if (!manifest)
2182
+ return stream;
2183
+ const markup = buildIslandsHeadMarkup(manifest);
2184
+ if (options?.hasIslands === true) {
2185
+ return pipeStreamWithHeadInjection(stream, markup);
2186
+ }
2187
+ if (options?.hasIslands === false) {
2188
+ return stream;
2189
+ }
2190
+ return pipeStreamWithIslandMarkerDetection(stream, markup);
2191
+ };
2192
+ var setCurrentIslandManifest = (manifest) => {
2193
+ globalThis.__absoluteManifest = manifest;
2194
+ };
2195
+
2196
+ // src/svelte/pageHandler.ts
2197
+ init_devRouteRegistrationCallsite();
2198
+
2199
+ // src/core/responseEnhancers.ts
2200
+ init_streamingSlots();
2201
+ var toResponse = async (responseLike) => responseLike;
2202
+ var cloneHeaders = (response) => {
2203
+ const headers = new Headers(response.headers);
2204
+ return headers;
2205
+ };
2206
+ var enhanceHtmlResponseWithStreamingSlots = (response, {
2207
+ nonce,
2208
+ onError,
2209
+ runtimePlacement,
2210
+ runtimePreludeScript,
2211
+ streamingSlots = [],
2212
+ policy
2213
+ } = {}) => {
2214
+ if (!response.body || streamingSlots.length === 0) {
2215
+ return response;
2216
+ }
2217
+ const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
2218
+ nonce,
2219
+ onError,
2220
+ policy,
2221
+ runtimePlacement,
2222
+ runtimePreludeScript
2223
+ });
1849
2224
  return new Response(body, {
1850
2225
  headers: cloneHeaders(response),
1851
2226
  status: response.status,
1852
2227
  statusText: response.statusText
1853
2228
  });
1854
- }, withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options), mergeStreamingSlots = (registered, explicit) => {
2229
+ };
2230
+ var withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options);
2231
+ var mergeStreamingSlots = (registered, explicit) => {
1855
2232
  const merged = new Map;
1856
2233
  for (const slot of registered)
1857
2234
  merged.set(slot.id, slot);
1858
2235
  for (const slot of explicit)
1859
2236
  merged.set(slot.id, slot);
1860
2237
  return [...merged.values()];
1861
- }, withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
2238
+ };
2239
+ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
1862
2240
  const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
1863
2241
  const explicit = options.streamingSlots ?? [];
1864
2242
  return withStreamingSlots(result, {
@@ -1866,162 +2244,21 @@ var toResponse = async (responseLike) => responseLike, cloneHeaders = (response)
1866
2244
  streamingSlots: mergeStreamingSlots(slots, explicit)
1867
2245
  });
1868
2246
  };
1869
- var init_responseEnhancers = __esm(() => {
1870
- init_streamingSlots();
1871
- init_streamingSlotRegistry();
1872
- });
1873
-
1874
- // src/utils/getDurationString.ts
1875
- var getDurationString = (duration) => {
1876
- let durationString;
1877
- if (duration < MILLISECONDS_IN_A_SECOND) {
1878
- durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
1879
- } else if (duration < MILLISECONDS_IN_A_MINUTE) {
1880
- durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
1881
- } else {
1882
- durationString = `${(duration / MILLISECONDS_IN_A_MINUTE).toFixed(TIME_PRECISION)}m`;
1883
- }
1884
- return durationString;
1885
- };
1886
- var init_getDurationString = __esm(() => {
1887
- init_constants();
1888
- });
1889
-
1890
- // src/utils/startupBanner.ts
1891
- var colors, MONTHS, formatTimestamp = () => {
1892
- const now = new Date;
1893
- const month = MONTHS[now.getMonth()];
1894
- const day = now.getDate().toString().padStart(2, "0");
1895
- let hours = now.getHours();
1896
- const minutes = now.getMinutes().toString().padStart(2, "0");
1897
- const seconds = now.getSeconds().toString().padStart(2, "0");
1898
- const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
1899
- hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
1900
- return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
1901
- }, startupBanner = (options) => {
1902
- const {
1903
- version,
1904
- readyDuration,
1905
- buildDuration,
1906
- port,
1907
- host,
1908
- networkUrl,
1909
- protocol = "http"
1910
- } = options;
1911
- const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
1912
- const ver = `${colors.dim}v${version}${colors.reset}`;
1913
- const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
1914
- const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
1915
- console.log("");
1916
- console.log(` ${name} ${ver} ${time}${build}`);
1917
- console.log("");
1918
- console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
1919
- if (networkUrl) {
1920
- console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
1921
- }
1922
- console.log("");
1923
- };
1924
- var init_startupBanner = __esm(() => {
1925
- init_constants();
1926
- init_getDurationString();
1927
- colors = {
1928
- bold: "\x1B[1m",
1929
- cyan: "\x1B[36m",
1930
- dim: "\x1B[2m",
1931
- green: "\x1B[32m",
1932
- reset: "\x1B[0m"
1933
- };
1934
- MONTHS = [
1935
- "Jan",
1936
- "Feb",
1937
- "Mar",
1938
- "Apr",
1939
- "May",
1940
- "Jun",
1941
- "Jul",
1942
- "Aug",
1943
- "Sep",
1944
- "Oct",
1945
- "Nov",
1946
- "Dec"
1947
- ];
1948
- });
1949
-
1950
- // src/utils/logger.ts
1951
- var colors2, frameworkColors, formatPath = (filePath) => {
1952
- const cwd = process.cwd();
1953
- let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1954
- relative3 = relative3.replace(/\\/g, "/");
1955
- if (!relative3.startsWith("/")) {
1956
- relative3 = `/${relative3}`;
1957
- }
1958
- return relative3;
1959
- }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
1960
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1961
- const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
1962
- let message = action;
1963
- if (options?.path) {
1964
- const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
1965
- message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
1966
- }
1967
- if (options?.duration !== undefined) {
1968
- message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
1969
- }
1970
- console.log(`${timestamp} ${tag} ${message}`);
1971
- }, logCssUpdate = (path, framework, duration) => {
1972
- log("css update", { duration, framework: framework ?? "css", path });
1973
- }, logError = (message, error) => {
1974
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1975
- const tag = `${colors2.red}[hmr]${colors2.reset}`;
1976
- const errorMsg = error instanceof Error ? error.message : error;
1977
- const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
1978
- console.error(`${timestamp} ${tag} ${fullMessage}`);
1979
- }, logHmrUpdate = (path, framework, duration) => {
1980
- log("hmr update", { duration, framework, path });
1981
- }, logScriptUpdate = (path, framework, duration) => {
1982
- log("script update", { duration, framework, path });
1983
- }, logServerReload = () => {
1984
- log(`${colors2.cyan}server module reloaded${colors2.reset}`);
1985
- }, logWarn = (message) => {
1986
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1987
- const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
1988
- console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
1989
- };
1990
- var init_logger = __esm(() => {
1991
- init_startupBanner();
1992
- colors2 = {
1993
- blue: "\x1B[34m",
1994
- bold: "\x1B[1m",
1995
- cyan: "\x1B[36m",
1996
- dim: "\x1B[2m",
1997
- green: "\x1B[32m",
1998
- magenta: "\x1B[35m",
1999
- red: "\x1B[31m",
2000
- reset: "\x1B[0m",
2001
- white: "\x1B[37m",
2002
- yellow: "\x1B[33m"
2003
- };
2004
- frameworkColors = {
2005
- angular: colors2.magenta,
2006
- assets: colors2.dim,
2007
- css: colors2.cyan,
2008
- html: colors2.white,
2009
- htmx: colors2.white,
2010
- react: colors2.blue,
2011
- svelte: colors2.yellow,
2012
- vue: colors2.green
2013
- };
2014
- });
2015
2247
 
2016
2248
  // src/core/streamingSlotWarningScope.ts
2249
+ init_logger();
2017
2250
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
2018
- var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", getWarningStorage = () => {
2251
+ var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
2252
+ var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
2253
+ var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
2254
+ var getWarningStorage = () => {
2019
2255
  const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
2020
2256
  if (value === null || typeof value === "undefined") {
2021
2257
  return;
2022
2258
  }
2023
2259
  return isAsyncLocalStorage3(value) ? value : undefined;
2024
- }, ensureWarningStorage = () => {
2260
+ };
2261
+ var ensureWarningStorage = () => {
2025
2262
  const existing = getWarningStorage();
2026
2263
  if (existing) {
2027
2264
  return existing;
@@ -2029,13 +2266,16 @@ var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(va
2029
2266
  const storage = new AsyncLocalStorage2;
2030
2267
  Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
2031
2268
  return storage;
2032
- }, normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), formatWarningCallsite = (callsite) => {
2269
+ };
2270
+ var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
2271
+ var formatWarningCallsite = (callsite) => {
2033
2272
  const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
2034
2273
  if (!match) {
2035
2274
  return `\x1B[36m${callsite}\x1B[0m`;
2036
2275
  }
2037
2276
  return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
2038
- }, extractCallsiteFromStack = (stack) => {
2277
+ };
2278
+ var extractCallsiteFromStack = (stack) => {
2039
2279
  const frames = stack.split(`
2040
2280
  `).slice(1).map((line) => line.trim());
2041
2281
  for (const frame of frames) {
@@ -2048,29 +2288,30 @@ var STREAMING_SLOT_WARNING_STORAGE_KEY2, isObjectRecord4 = (value) => Boolean(va
2048
2288
  }
2049
2289
  }
2050
2290
  return;
2051
- }, buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`, captureStreamingSlotWarningCallsite = () => {
2291
+ };
2292
+ var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
2293
+ setStreamingSlotWarningController({
2294
+ maybeWarn: (primitiveName) => {
2295
+ const store = getWarningStorage()?.getStore();
2296
+ if (!store || store.hasWarned) {
2297
+ return;
2298
+ }
2299
+ store.hasWarned = true;
2300
+ logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
2301
+ }
2302
+ });
2303
+ var captureStreamingSlotWarningCallsite = () => {
2052
2304
  if (false) {}
2053
2305
  const { stack } = new Error;
2054
2306
  if (!stack) {
2055
2307
  return;
2056
2308
  }
2057
2309
  return extractCallsiteFromStack(stack);
2058
- }, runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
2059
- var init_streamingSlotWarningScope = __esm(() => {
2060
- init_logger();
2061
- init_streamingSlotRegistrar();
2062
- STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
2063
- setStreamingSlotWarningController({
2064
- maybeWarn: (primitiveName) => {
2065
- const store = getWarningStorage()?.getStore();
2066
- if (!store || store.hasWarned) {
2067
- return;
2068
- }
2069
- store.hasWarned = true;
2070
- logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
2071
- }
2072
- });
2073
- });
2310
+ };
2311
+ var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
2312
+
2313
+ // src/svelte/pageHandler.ts
2314
+ init_ssrCache();
2074
2315
 
2075
2316
  // src/utils/ssrErrorPage.ts
2076
2317
  var ssrErrorPage = (framework, error) => {
@@ -2124,39 +2365,40 @@ body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,r
2124
2365
  </html>`;
2125
2366
  };
2126
2367
 
2127
- // src/utils/stringModifiers.ts
2128
- 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) => {
2129
- if (!str.includes("-") && !str.includes("_")) {
2130
- return str.charAt(0).toUpperCase() + str.slice(1);
2131
- }
2132
- return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
2133
- }, toScreamingSnake = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
2134
-
2135
2368
  // src/utils/resolveConvention.ts
2136
2369
  import { basename as basename2 } from "path";
2137
- var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
2370
+ var CONVENTIONS_KEY = "__absoluteConventions";
2371
+ var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
2372
+ var getMap = () => {
2138
2373
  const value = Reflect.get(globalThis, CONVENTIONS_KEY);
2139
2374
  if (isConventionsMap(value))
2140
2375
  return value;
2141
2376
  const empty = {};
2142
2377
  return empty;
2143
- }, derivePageName = (pagePath) => {
2378
+ };
2379
+ var derivePageName = (pagePath) => {
2144
2380
  const base = basename2(pagePath);
2145
2381
  const dotIndex = base.indexOf(".");
2146
2382
  const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
2147
2383
  return toPascal(name);
2148
- }, resolveErrorConventionPath = (framework, pageName) => {
2384
+ };
2385
+ var resolveErrorConventionPath = (framework, pageName) => {
2149
2386
  const conventions = getMap()[framework];
2150
2387
  if (!conventions)
2151
2388
  return;
2152
2389
  return conventions.pages?.[pageName]?.error ?? conventions.defaults?.error;
2153
- }, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
2390
+ };
2391
+ var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
2392
+ var setConventions = (map) => {
2154
2393
  Reflect.set(globalThis, CONVENTIONS_KEY, map);
2155
- }, isDev = () => true, buildErrorProps = (error) => {
2394
+ };
2395
+ var isDev = () => true;
2396
+ var buildErrorProps = (error) => {
2156
2397
  const message = error instanceof Error ? error.message : String(error);
2157
2398
  const stack = isDev() && error instanceof Error ? error.stack : undefined;
2158
2399
  return { error: { message, stack } };
2159
- }, renderReactError = async (conventionPath, errorProps) => {
2400
+ };
2401
+ var renderReactError = async (conventionPath, errorProps) => {
2160
2402
  const { createElement } = await import("react");
2161
2403
  const { renderToReadableStream } = await import("react-dom/server");
2162
2404
  const mod = await import(conventionPath);
@@ -2168,7 +2410,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2168
2410
  headers: { "Content-Type": "text/html" },
2169
2411
  status: 500
2170
2412
  });
2171
- }, renderSvelteError = async (conventionPath, errorProps) => {
2413
+ };
2414
+ var renderSvelteError = async (conventionPath, errorProps) => {
2172
2415
  const { render } = await import("svelte/server");
2173
2416
  const mod = await import(conventionPath);
2174
2417
  const ErrorComponent = mod.default;
@@ -2180,14 +2423,16 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2180
2423
  headers: { "Content-Type": "text/html" },
2181
2424
  status: 500
2182
2425
  });
2183
- }, unescapeVueStyles = (ssrBody) => {
2426
+ };
2427
+ var unescapeVueStyles = (ssrBody) => {
2184
2428
  let styles = "";
2185
2429
  const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
2186
2430
  styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
2187
2431
  return "";
2188
2432
  });
2189
2433
  return { body, styles };
2190
- }, renderVueError = async (conventionPath, errorProps) => {
2434
+ };
2435
+ var renderVueError = async (conventionPath, errorProps) => {
2191
2436
  const { createSSRApp, h } = await import("vue");
2192
2437
  const { renderToString } = await import("vue/server-renderer");
2193
2438
  const mod = await import(conventionPath);
@@ -2202,7 +2447,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2202
2447
  headers: { "Content-Type": "text/html" },
2203
2448
  status: 500
2204
2449
  });
2205
- }, renderAngularError = async (conventionPath, errorProps) => {
2450
+ };
2451
+ var renderAngularError = async (conventionPath, errorProps) => {
2206
2452
  const mod = await import(conventionPath);
2207
2453
  const renderError = mod.default ?? mod.renderError;
2208
2454
  if (typeof renderError !== "function")
@@ -2212,14 +2458,22 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2212
2458
  headers: { "Content-Type": "text/html" },
2213
2459
  status: 500
2214
2460
  });
2215
- }, logConventionRenderError = (framework, label, renderError) => {
2461
+ };
2462
+ var logConventionRenderError = (framework, label, renderError) => {
2216
2463
  const message = renderError instanceof Error ? renderError.message : "";
2217
2464
  if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
2218
2465
  console.error(`[SSR] Convention ${label} page for ${framework} failed: missing framework package. Ensure the ${framework} runtime is installed (e.g. bun add ${framework === "react" ? "react react-dom" : framework}).`);
2219
2466
  return;
2220
2467
  }
2221
2468
  console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
2222
- }, ERROR_RENDERERS, renderConventionError = async (framework, pageName, error) => {
2469
+ };
2470
+ var ERROR_RENDERERS = {
2471
+ angular: renderAngularError,
2472
+ react: renderReactError,
2473
+ svelte: renderSvelteError,
2474
+ vue: renderVueError
2475
+ };
2476
+ var renderConventionError = async (framework, pageName, error) => {
2223
2477
  const conventionPath = resolveErrorConventionPath(framework, pageName);
2224
2478
  if (!conventionPath)
2225
2479
  return null;
@@ -2233,7 +2487,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2233
2487
  logConventionRenderError(framework, "error", renderError);
2234
2488
  }
2235
2489
  return null;
2236
- }, renderReactNotFound = async (conventionPath) => {
2490
+ };
2491
+ var renderReactNotFound = async (conventionPath) => {
2237
2492
  const { createElement } = await import("react");
2238
2493
  const { renderToReadableStream } = await import("react-dom/server");
2239
2494
  const mod = await import(conventionPath);
@@ -2245,7 +2500,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2245
2500
  headers: { "Content-Type": "text/html" },
2246
2501
  status: 404
2247
2502
  });
2248
- }, renderSvelteNotFound = async (conventionPath) => {
2503
+ };
2504
+ var renderSvelteNotFound = async (conventionPath) => {
2249
2505
  const { render } = await import("svelte/server");
2250
2506
  const mod = await import(conventionPath);
2251
2507
  const NotFoundComponent = mod.default;
@@ -2255,7 +2511,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2255
2511
  headers: { "Content-Type": "text/html" },
2256
2512
  status: 404
2257
2513
  });
2258
- }, renderVueNotFound = async (conventionPath) => {
2514
+ };
2515
+ var renderVueNotFound = async (conventionPath) => {
2259
2516
  const { createSSRApp, h } = await import("vue");
2260
2517
  const { renderToString } = await import("vue/server-renderer");
2261
2518
  const mod = await import(conventionPath);
@@ -2270,7 +2527,8 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2270
2527
  headers: { "Content-Type": "text/html" },
2271
2528
  status: 404
2272
2529
  });
2273
- }, renderAngularNotFound = async (conventionPath) => {
2530
+ };
2531
+ var renderAngularNotFound = async (conventionPath) => {
2274
2532
  const mod = await import(conventionPath);
2275
2533
  const renderNotFound = mod.default ?? mod.renderNotFound;
2276
2534
  if (typeof renderNotFound !== "function")
@@ -2280,7 +2538,14 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2280
2538
  headers: { "Content-Type": "text/html" },
2281
2539
  status: 404
2282
2540
  });
2283
- }, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
2541
+ };
2542
+ var NOT_FOUND_RENDERERS = {
2543
+ angular: renderAngularNotFound,
2544
+ react: renderReactNotFound,
2545
+ svelte: renderSvelteNotFound,
2546
+ vue: renderVueNotFound
2547
+ };
2548
+ var renderConventionNotFound = async (framework) => {
2284
2549
  const conventionPath = resolveNotFoundConventionPath(framework);
2285
2550
  if (!conventionPath)
2286
2551
  return null;
@@ -2293,7 +2558,14 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2293
2558
  logConventionRenderError(framework, "not-found", renderError);
2294
2559
  }
2295
2560
  return null;
2296
- }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
2561
+ };
2562
+ var NOT_FOUND_PRIORITY = [
2563
+ "react",
2564
+ "svelte",
2565
+ "vue",
2566
+ "angular"
2567
+ ];
2568
+ var renderFirstNotFound = async () => {
2297
2569
  for (const framework of NOT_FOUND_PRIORITY) {
2298
2570
  if (!getMap()[framework]?.defaults?.notFound)
2299
2571
  continue;
@@ -2303,96 +2575,26 @@ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boo
2303
2575
  }
2304
2576
  return null;
2305
2577
  };
2306
- var init_resolveConvention = __esm(() => {
2307
- ERROR_RENDERERS = {
2308
- angular: renderAngularError,
2309
- react: renderReactError,
2310
- svelte: renderSvelteError,
2311
- vue: renderVueError
2312
- };
2313
- NOT_FOUND_RENDERERS = {
2314
- angular: renderAngularNotFound,
2315
- react: renderReactNotFound,
2316
- svelte: renderSvelteNotFound,
2317
- vue: renderVueNotFound
2318
- };
2319
- NOT_FOUND_PRIORITY = [
2320
- "react",
2321
- "svelte",
2322
- "vue",
2323
- "angular"
2324
- ];
2325
- });
2326
-
2327
- // src/svelte/renderToReadableStream.ts
2328
- var exports_renderToReadableStream = {};
2329
- __export(exports_renderToReadableStream, {
2330
- renderToReadableStream: () => renderToReadableStream,
2331
- SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
2332
- });
2333
- var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
2334
- bootstrapScriptContent,
2335
- bootstrapScripts = [],
2336
- bootstrapModules = [],
2337
- nonce,
2338
- onError = console.error,
2339
- progressiveChunkSize = DEFAULT_CHUNK_SIZE,
2340
- signal,
2341
- headContent,
2342
- bodyContent
2343
- } = {}) => {
2344
- try {
2345
- const { render } = await import("svelte/server");
2346
- const rendered = typeof props === "undefined" ? await render(component) : await render(component, { props });
2347
- const { head, body } = rendered;
2348
- const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
2349
- const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
2350
- const encoder = new TextEncoder;
2351
- const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body><div id="${SVELTE_PAGE_ROOT_ID}">${body}</div>${scripts}${bodyContent ?? ""}</body></html>`);
2352
- let offset = 0;
2353
- return new ReadableStream({
2354
- type: "bytes",
2355
- cancel(reason) {
2356
- onError?.(reason);
2357
- },
2358
- pull(controller) {
2359
- if (signal?.aborted) {
2360
- controller.close();
2361
- return;
2362
- }
2363
- if (offset >= full.length) {
2364
- controller.close();
2365
- return;
2366
- }
2367
- const end = Math.min(offset + progressiveChunkSize, full.length);
2368
- controller.enqueue(full.subarray(offset, end));
2369
- offset = end;
2370
- }
2371
- });
2372
- } catch (error) {
2373
- onError?.(error);
2374
- throw error;
2375
- }
2376
- };
2377
- var init_renderToReadableStream = __esm(() => {
2378
- init_constants();
2379
- init_escapeScriptContent();
2380
- });
2381
2578
 
2382
2579
  // src/svelte/pageHandler.ts
2383
- var ssrDirty = false, isRecord2 = (value) => typeof value === "object" && value !== null, isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value), readHasIslands = (value) => {
2580
+ var isRecord2 = (value) => typeof value === "object" && value !== null;
2581
+ var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
2582
+ var readHasIslands = (value) => {
2384
2583
  if (!isRecord2(value))
2385
2584
  return false;
2386
2585
  const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
2387
2586
  return typeof hasIslands === "boolean" ? hasIslands : false;
2388
- }, readDefaultExport = (value) => isRecord2(value) ? value.default : undefined, buildDirtyResponse = (indexPath, props) => {
2587
+ };
2588
+ var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
2589
+ var buildDirtyResponse = (indexPath, props) => {
2389
2590
  const propsScript = `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(props)};${indexPath ? `import(${JSON.stringify(indexPath)});` : ""}`;
2390
2591
  const dirtyFlag = "window.__SSR_DIRTY__=true;";
2391
2592
  const html = `<!DOCTYPE html><html><head></head><body><script>${propsScript}${dirtyFlag}</script></body></html>`;
2392
2593
  return new Response(html, {
2393
2594
  headers: { "Content-Type": "text/html" }
2394
2595
  });
2395
- }, handleSveltePageRequest = async (PageComponentOrInput, pagePath, indexPath, props, options) => {
2596
+ };
2597
+ var handleSveltePageRequest = async (PageComponentOrInput, pagePath, indexPath, props, options) => {
2396
2598
  const {
2397
2599
  PageComponent,
2398
2600
  indexPath: resolvedIndexPath,
@@ -2412,7 +2614,7 @@ var ssrDirty = false, isRecord2 = (value) => typeof value === "object" && value
2412
2614
  pagePath: pagePath ?? "",
2413
2615
  props
2414
2616
  };
2415
- if (ssrDirty) {
2617
+ if (isSsrCacheDirty("svelte")) {
2416
2618
  return buildDirtyResponse(resolvedIndexPath, resolvedProps);
2417
2619
  }
2418
2620
  try {
@@ -2483,23 +2685,10 @@ var ssrDirty = false, isRecord2 = (value) => typeof value === "object" && value
2483
2685
  status: 500
2484
2686
  });
2485
2687
  }
2486
- }, invalidateSvelteSsrCache = () => {
2487
- ssrDirty = true;
2488
2688
  };
2489
- var init_pageHandler = __esm(() => {
2490
- init_svelteServerModule();
2491
- init_islandPageContext();
2492
- init_devRouteRegistrationCallsite();
2493
- init_responseEnhancers();
2494
- init_streamingSlotWarningScope();
2495
- init_resolveConvention();
2496
- });
2497
-
2498
- // src/svelte/server.ts
2499
- init_pageHandler();
2500
2689
  export {
2501
2690
  handleSveltePageRequest
2502
2691
  };
2503
2692
 
2504
- //# debugId=B4B4A0E1AC4FA91264756E2164756E21
2693
+ //# debugId=30012EB2373C394964756E2164756E21
2505
2694
  //# sourceMappingURL=server.js.map