@absolutejs/absolute 0.19.0-beta.999 → 0.20.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/LICENSE +21 -13
  2. package/README.md +48 -2
  3. package/dist/angular/browser.js +82 -77
  4. package/dist/angular/browser.js.map +11 -11
  5. package/dist/angular/components/constants.js +43 -0
  6. package/dist/angular/components/core/streamingSlotRegistrar.js +1 -1
  7. package/dist/angular/components/core/streamingSlotRegistry.js +2 -2
  8. package/dist/angular/hmrPreserveCore.ts +132 -134
  9. package/dist/angular/index.js +1719 -844
  10. package/dist/angular/index.js.map +34 -26
  11. package/dist/angular/server.js +1620 -768
  12. package/dist/angular/server.js.map +28 -20
  13. package/dist/build.js +4935 -2593
  14. package/dist/build.js.map +72 -57
  15. package/dist/cli/config/client.js +578 -0
  16. package/dist/cli/config/server.js +39587 -0
  17. package/dist/cli/htmx/htmx.min.js +1 -0
  18. package/dist/cli/index.js +16828 -3511
  19. package/dist/client/index.js +49 -46
  20. package/dist/client/index.js.map +12 -12
  21. package/dist/core/streamingSlotRegistrar.js +1 -19
  22. package/dist/core/streamingSlotRegistrar.js.map +2 -2
  23. package/dist/core/streamingSlotRegistry.js +1 -19
  24. package/dist/core/streamingSlotRegistry.js.map +2 -2
  25. package/dist/dev/client/cssUtils.ts +98 -41
  26. package/dist/dev/client/domState.ts +2 -0
  27. package/dist/dev/client/errorOverlay.ts +14 -13
  28. package/dist/dev/client/handlers/angularHmrShim.ts +20 -20
  29. package/dist/dev/client/handlers/angularRemount.ts +74 -55
  30. package/dist/dev/client/handlers/angularRemountWiring.ts +1 -2
  31. package/dist/dev/client/handlers/html.ts +144 -41
  32. package/dist/dev/client/handlers/htmx.ts +43 -8
  33. package/dist/dev/client/handlers/react.ts +114 -32
  34. package/dist/dev/client/handlers/rebuild.ts +28 -8
  35. package/dist/dev/client/handlers/svelte.ts +92 -51
  36. package/dist/dev/client/handlers/vue.ts +36 -45
  37. package/dist/dev/client/hmrClient.ts +101 -26
  38. package/dist/dev/client/hmrTiming.ts +141 -0
  39. package/dist/dev/client/hmrToast.ts +22 -24
  40. package/dist/dev/client/reactRefreshSetup.ts +4 -0
  41. package/dist/dev/client/vendor/reactRefreshRuntime.d.ts +12 -0
  42. package/dist/dev/client/vendor/reactRefreshRuntime.js +313 -0
  43. package/dist/dev/serverBootstrap.js +45 -0
  44. package/dist/index.js +7153 -3224
  45. package/dist/index.js.map +118 -86
  46. package/dist/islands/browser.js +1 -19
  47. package/dist/islands/browser.js.map +3 -3
  48. package/dist/islands/index.js +709 -120
  49. package/dist/islands/index.js.map +18 -13
  50. package/dist/mobile/browser.js +428 -0
  51. package/dist/mobile/browser.js.map +12 -0
  52. package/dist/mobile/index.js +3058 -0
  53. package/dist/mobile/index.js.map +35 -0
  54. package/dist/react/browser.js +13 -62
  55. package/dist/react/browser.js.map +5 -6
  56. package/dist/react/components/browser/index.js +23 -13
  57. package/dist/react/components/index.js +30 -34
  58. package/dist/react/components/index.js.map +8 -7
  59. package/dist/react/hooks/index.js +1 -19
  60. package/dist/react/hooks/index.js.map +3 -3
  61. package/dist/react/index.js +1643 -679
  62. package/dist/react/index.js.map +29 -20
  63. package/dist/react/jsxDevRuntimeCompat.js +22 -20
  64. package/dist/react/jsxDevRuntimeCompat.js.map +5 -4
  65. package/dist/react/jsxRuntimeCompat.js +90 -0
  66. package/dist/react/jsxRuntimeCompat.js.map +10 -0
  67. package/dist/react/router/browser.js +77 -0
  68. package/dist/react/router/browser.js.map +10 -0
  69. package/dist/react/router/index.js +77 -0
  70. package/dist/react/router/index.js.map +10 -0
  71. package/dist/react/server.js +950 -565
  72. package/dist/react/server.js.map +16 -11
  73. package/dist/src/angular/components/constants.d.ts +21 -0
  74. package/dist/src/angular/hmrPreserveCore.d.ts +7 -20
  75. package/dist/src/angular/islands.d.ts +1 -1
  76. package/dist/src/angular/pageHandler.d.ts +2 -0
  77. package/dist/src/angular/ssrRender.d.ts +4 -1
  78. package/dist/src/build/bunStringRawUnicodePlugin.d.ts +12 -0
  79. package/dist/src/build/chainInlineSourcemaps.d.ts +1 -0
  80. package/dist/src/build/compileAngular.d.ts +5 -7
  81. package/dist/src/build/compileSvelte.d.ts +3 -0
  82. package/dist/src/build/compileVue.d.ts +3 -1
  83. package/dist/src/build/generateReactIndexes.d.ts +1 -0
  84. package/dist/src/build/islandRegistryTransform.d.ts +17 -0
  85. package/dist/src/build/maskLiterals.d.ts +28 -0
  86. package/dist/src/build/parseVueSpaRoutes.d.ts +5 -0
  87. package/dist/src/build/resolveBuildMode.d.ts +7 -0
  88. package/dist/src/build/serverExternals.d.ts +14 -0
  89. package/dist/src/build/spaSideManifests.d.ts +16 -0
  90. package/dist/src/build/tailwindCompiler.d.ts +0 -1
  91. package/dist/src/cli/add/dependencies.d.ts +13 -0
  92. package/dist/src/cli/config/absolute/AbsoluteConfigPanel.d.ts +6 -0
  93. package/dist/src/cli/config/absolute/editAbsoluteConfig.d.ts +5 -0
  94. package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +19 -0
  95. package/dist/src/cli/config/auth/AuthPanel.d.ts +6 -0
  96. package/dist/src/cli/config/auth/authCatalog.d.ts +10 -0
  97. package/dist/src/cli/config/auth/authScaffolds.d.ts +16 -0
  98. package/dist/src/cli/config/auth/editAuthConfig.d.ts +5 -0
  99. package/dist/src/cli/config/auth/resolveAuthSettings.d.ts +14 -0
  100. package/dist/src/cli/config/auth/resolveAuthState.d.ts +2 -0
  101. package/dist/src/cli/config/auth/scaffoldAuthFeature.d.ts +6 -0
  102. package/dist/src/cli/config/client.d.ts +1 -0
  103. package/dist/src/cli/config/configCert.d.ts +12 -0
  104. package/dist/src/cli/config/eslint/EslintPanel.d.ts +6 -0
  105. package/dist/src/cli/config/eslint/configAst.d.ts +18 -0
  106. package/dist/src/cli/config/eslint/editConfigRule.d.ts +6 -0
  107. package/dist/src/cli/config/eslint/eslintStyles.d.ts +1 -0
  108. package/dist/src/cli/config/eslint/resolveConfig.d.ts +3 -0
  109. package/dist/src/cli/config/eslint/serializeValue.d.ts +9 -0
  110. package/dist/src/cli/config/guards.d.ts +4 -0
  111. package/dist/src/cli/config/integrations/IntegrationsPanel.d.ts +6 -0
  112. package/dist/src/cli/config/packageJson/PackageJsonPanel.d.ts +6 -0
  113. package/dist/src/cli/config/packageJson/editPackageJson.d.ts +9 -0
  114. package/dist/src/cli/config/packageJson/resolvePackageJson.d.ts +8 -0
  115. package/dist/src/cli/config/page/ConfigShell.d.ts +6 -0
  116. package/dist/src/cli/config/page/FieldEditor.d.ts +9 -0
  117. package/dist/src/cli/config/page/PanelHost.d.ts +6 -0
  118. package/dist/src/cli/config/page/configStyles.d.ts +1 -0
  119. package/dist/src/cli/config/panels.d.ts +7 -0
  120. package/dist/src/cli/config/prettier/PrettierPanel.d.ts +6 -0
  121. package/dist/src/cli/config/prettier/editPrettier.d.ts +5 -0
  122. package/dist/src/cli/config/prettier/resolvePrettier.d.ts +11 -0
  123. package/dist/src/cli/config/schema/fromJsonSchema.d.ts +3 -0
  124. package/dist/src/cli/config/schema/fromType.d.ts +1 -0
  125. package/dist/src/cli/config/schema/serialize.d.ts +1 -0
  126. package/dist/src/cli/config/server.d.ts +527 -0
  127. package/dist/src/cli/config/tsconfig/TsconfigPanel.d.ts +6 -0
  128. package/dist/src/cli/config/tsconfig/editTsconfig.d.ts +5 -0
  129. package/dist/src/cli/config/tsconfig/resolveTsconfig.d.ts +8 -0
  130. package/dist/src/cli/config/tsconfig/tsconfigStyles.d.ts +1 -0
  131. package/dist/src/cli/discoverInstances.d.ts +5 -0
  132. package/dist/src/cli/elysiaOpenApiTypeboxPlugin.d.ts +8 -0
  133. package/dist/src/cli/generate/componentTemplates.d.ts +7 -0
  134. package/dist/src/cli/generate/context.d.ts +30 -0
  135. package/dist/src/cli/generate/cssStrategy.d.ts +20 -0
  136. package/dist/src/cli/generate/frameworkKey.d.ts +3 -0
  137. package/dist/src/cli/generate/frameworks.d.ts +40 -0
  138. package/dist/src/cli/generate/generateApi.d.ts +3 -0
  139. package/dist/src/cli/generate/generateComponent.d.ts +4 -0
  140. package/dist/src/cli/generate/generatePage.d.ts +4 -0
  141. package/dist/src/cli/generate/naming.d.ts +5 -0
  142. package/dist/src/cli/generate/navData.d.ts +10 -0
  143. package/dist/src/cli/generate/outcome.d.ts +17 -0
  144. package/dist/src/cli/generate/pageTemplates.d.ts +11 -0
  145. package/dist/src/cli/generate/routeWiring.d.ts +40 -0
  146. package/dist/src/cli/generate/staticNav.d.ts +5 -0
  147. package/dist/src/cli/heapDiff.d.ts +1 -0
  148. package/dist/src/cli/htmx/install.d.ts +6 -0
  149. package/dist/src/cli/inspectData.d.ts +12 -0
  150. package/dist/src/cli/inspectTui.d.ts +1 -0
  151. package/dist/src/cli/instanceStatus.d.ts +22 -0
  152. package/dist/src/cli/integrations/addPlugin.d.ts +8 -0
  153. package/dist/src/cli/integrations/catalog.d.ts +20 -0
  154. package/dist/src/cli/psTui.d.ts +1 -0
  155. package/dist/src/cli/scripts/add.d.ts +1 -0
  156. package/dist/src/cli/scripts/analyze.d.ts +1 -0
  157. package/dist/src/cli/scripts/api.d.ts +1 -0
  158. package/dist/src/cli/scripts/build.d.ts +1 -1
  159. package/dist/src/cli/scripts/db.d.ts +20 -0
  160. package/dist/src/cli/scripts/dev.d.ts +5 -1
  161. package/dist/src/cli/scripts/doctor.d.ts +1 -0
  162. package/dist/src/cli/scripts/env.d.ts +7 -0
  163. package/dist/src/cli/scripts/eslint.d.ts +37 -2
  164. package/dist/src/cli/scripts/eslintChunked.d.ts +37 -0
  165. package/dist/src/cli/scripts/generate.d.ts +1 -0
  166. package/dist/src/cli/scripts/htmx.d.ts +1 -0
  167. package/dist/src/cli/scripts/inspect.d.ts +1 -0
  168. package/dist/src/cli/scripts/islands.d.ts +1 -0
  169. package/dist/src/cli/scripts/lintProof.d.ts +42 -0
  170. package/dist/src/cli/scripts/logs.d.ts +1 -0
  171. package/dist/src/cli/scripts/ls.d.ts +1 -0
  172. package/dist/src/cli/scripts/mem.d.ts +1 -0
  173. package/dist/src/cli/scripts/mobile.d.ts +1 -0
  174. package/dist/src/cli/scripts/prettier.d.ts +2 -0
  175. package/dist/src/cli/scripts/ps.d.ts +1 -0
  176. package/dist/src/cli/scripts/remove.d.ts +1 -0
  177. package/dist/src/cli/scripts/routes.d.ts +1 -0
  178. package/dist/src/cli/scripts/start.d.ts +6 -1
  179. package/dist/src/cli/scripts/tunnelRelay.d.ts +9 -0
  180. package/dist/src/cli/scripts/workspace.d.ts +3 -1
  181. package/dist/src/cli/serverBundleExternals.d.ts +2 -0
  182. package/dist/src/cli/tuiPrimitives.d.ts +14 -0
  183. package/dist/src/cli/typeGraphCoherence.d.ts +32 -0
  184. package/dist/src/cli/utils.d.ts +3 -1
  185. package/dist/src/cli/workspaceTui.d.ts +2 -1
  186. package/dist/src/client/hydrators/react.d.ts +1 -1
  187. package/dist/src/client/hydrators/svelte.d.ts +1 -1
  188. package/dist/src/client/hydrators/vue.d.ts +1 -1
  189. package/dist/src/client/islandStore.d.ts +3 -3
  190. package/dist/src/client/preserveIslandMarkup.d.ts +4 -1
  191. package/dist/src/constants.d.ts +21 -0
  192. package/dist/src/core/angularServerModule.d.ts +1 -0
  193. package/dist/src/core/build.d.ts +11 -3
  194. package/dist/src/core/devRouteRegistrationCallsite.d.ts +1 -5
  195. package/dist/src/core/index.d.ts +1 -0
  196. package/dist/src/core/pageResponseCache.d.ts +23 -0
  197. package/dist/src/core/prepare.d.ts +192 -154
  198. package/dist/src/core/requestContext.d.ts +18 -0
  199. package/dist/src/dev/angular/fastHmrCompiler.d.ts +5 -3
  200. package/dist/src/dev/angular/hmrCompiler.d.ts +1 -1
  201. package/dist/src/dev/angular/resolveOwningComponents.d.ts +1 -1
  202. package/dist/src/dev/clientManager.d.ts +10 -1
  203. package/dist/src/dev/configResolver.d.ts +2 -0
  204. package/dist/src/dev/moduleMapper.d.ts +1 -1
  205. package/dist/src/dev/moduleServer.d.ts +2 -1
  206. package/dist/src/dev/pathUtils.d.ts +1 -1
  207. package/dist/src/dev/reactComponentClassifier.d.ts +1 -1
  208. package/dist/src/dev/rebuildTrigger.d.ts +4 -0
  209. package/dist/src/dev/requestInspector.d.ts +31 -0
  210. package/dist/src/dev/serverBootstrap.d.ts +1 -0
  211. package/dist/src/dev/serverEntryWatcher.d.ts +3 -3
  212. package/dist/src/dev/tunnel/client.d.ts +20 -0
  213. package/dist/src/dev/tunnel/protocol.d.ts +85 -0
  214. package/dist/src/dev/tunnel/relay.d.ts +28 -0
  215. package/dist/src/dev/webSocket.d.ts +1 -1
  216. package/dist/src/mobile/androidConformance.d.ts +42 -0
  217. package/dist/src/mobile/androidEmulatorController.d.ts +99 -0
  218. package/dist/src/mobile/androidNativeWatcher.d.ts +19 -0
  219. package/dist/src/mobile/androidRelease.d.ts +47 -0
  220. package/dist/src/mobile/androidWebView.d.ts +46 -0
  221. package/dist/src/mobile/artifactStore.d.ts +47 -0
  222. package/dist/src/mobile/associationFiles.d.ts +49 -0
  223. package/dist/src/mobile/browser.d.ts +2 -0
  224. package/dist/src/mobile/buildMetadata.d.ts +10 -0
  225. package/dist/src/mobile/buildPipeline.d.ts +8 -0
  226. package/dist/src/mobile/buildRelease.d.ts +24 -0
  227. package/dist/src/mobile/capacitorBundle.d.ts +28 -0
  228. package/dist/src/mobile/capacitorProject.d.ts +9 -0
  229. package/dist/src/mobile/client.d.ts +35 -0
  230. package/dist/src/mobile/compatibilityDispatcher.d.ts +26 -0
  231. package/dist/src/mobile/config.d.ts +16 -0
  232. package/dist/src/mobile/emulatorDoctor.d.ts +25 -0
  233. package/dist/src/mobile/emulatorInstaller.d.ts +41 -0
  234. package/dist/src/mobile/index.d.ts +19 -0
  235. package/dist/src/mobile/materializedBundle.d.ts +36 -0
  236. package/dist/src/mobile/nativeDeepLinks.d.ts +5 -0
  237. package/dist/src/mobile/pageProtocol.d.ts +89 -0
  238. package/dist/src/mobile/producerContext.d.ts +4 -0
  239. package/dist/src/mobile/producerContextState.d.ts +10 -0
  240. package/dist/src/mobile/releaseArtifact.d.ts +75 -0
  241. package/dist/src/mobile/releaseDoctor.d.ts +13 -0
  242. package/dist/src/mobile/routeMatcher.d.ts +3 -0
  243. package/dist/src/mobile/routeMetadataTransform.d.ts +13 -0
  244. package/dist/src/mobile/shellBootstrap.d.ts +1 -0
  245. package/dist/src/mobile/transport.d.ts +31 -0
  246. package/dist/src/plugins/devtoolsJson.d.ts +6 -47
  247. package/dist/src/plugins/hmr.d.ts +22 -96
  248. package/dist/src/plugins/imageOptimizer.d.ts +150 -62
  249. package/dist/src/plugins/networking.d.ts +2 -2
  250. package/dist/src/plugins/openApiPlugin.d.ts +4 -0
  251. package/dist/src/plugins/telemetryPlugin.d.ts +36 -0
  252. package/dist/src/react/browser.d.ts +0 -2
  253. package/dist/src/react/hooks/useMediaQuery.d.ts +1 -1
  254. package/dist/src/react/index.d.ts +0 -2
  255. package/dist/src/react/jsxDevRuntimeCompat.d.ts +1 -1
  256. package/dist/src/react/jsxRuntimeCompat.d.ts +7 -0
  257. package/dist/src/react/pageHandler.d.ts +8 -0
  258. package/dist/src/react/router/UniversalRouter.d.ts +43 -0
  259. package/dist/src/react/router/browser.d.ts +2 -0
  260. package/dist/src/react/router/index.d.ts +2 -0
  261. package/dist/src/svelte/pageHandler.d.ts +5 -0
  262. package/dist/src/svelte/router/hashMode.d.ts +1 -6
  263. package/dist/src/svelte/router/matchPath.d.ts +4 -24
  264. package/dist/src/svelte/router/page.svelte.d.ts +1 -10
  265. package/dist/src/svelte/router/prefetchCache.d.ts +2 -6
  266. package/dist/src/utils/cleanup.d.ts +1 -0
  267. package/dist/src/utils/defineConvention.d.ts +2 -2
  268. package/dist/src/utils/defineEnv.d.ts +4 -4
  269. package/dist/src/utils/formatBytes.d.ts +2 -0
  270. package/dist/src/utils/generatedDir.d.ts +1 -1
  271. package/dist/src/utils/iconVersion.d.ts +5 -0
  272. package/dist/src/utils/imageProcessing.d.ts +1 -1
  273. package/dist/src/utils/index.d.ts +2 -0
  274. package/dist/src/utils/inlinePageCss.d.ts +9 -0
  275. package/dist/src/utils/instanceRegistry.d.ts +13 -0
  276. package/dist/src/utils/isTestSourcePath.d.ts +1 -0
  277. package/dist/src/utils/jsonLd.d.ts +1 -1
  278. package/dist/src/utils/loadConfig.d.ts +11 -3
  279. package/dist/src/utils/logger.d.ts +2 -0
  280. package/dist/src/utils/portScan.d.ts +22 -0
  281. package/dist/src/utils/projectRoot.d.ts +17 -0
  282. package/dist/src/utils/resolveConvention.d.ts +1 -1
  283. package/dist/src/utils/resolveDevPort.d.ts +4 -1
  284. package/dist/src/utils/runtimeMode.d.ts +1 -1
  285. package/dist/src/utils/spaRouteCss.d.ts +10 -0
  286. package/dist/src/utils/spaRouteManifest.d.ts +8 -0
  287. package/dist/src/utils/stripStringsAndComments.d.ts +18 -0
  288. package/dist/src/utils/userAgentFunctions.d.ts +1 -1
  289. package/dist/src/utils/vueCompiler.d.ts +1 -0
  290. package/dist/src/vue/components/Image.d.ts +2 -2
  291. package/dist/src/vue/defineVuePage.d.ts +1 -11
  292. package/dist/src/vue/index.d.ts +3 -0
  293. package/dist/src/vue/pageHandler.d.ts +5 -0
  294. package/dist/src/vue/resolveGeneratedVueModulePath.d.ts +1 -0
  295. package/dist/src/vue/teleports.d.ts +2 -0
  296. package/dist/src/vue/useResource.d.ts +65 -0
  297. package/dist/svelte/browser.js +1 -19
  298. package/dist/svelte/browser.js.map +3 -3
  299. package/dist/svelte/components/Head.svelte +7 -1
  300. package/dist/svelte/index.js +1281 -543
  301. package/dist/svelte/index.js.map +27 -19
  302. package/dist/svelte/router/Link.svelte.d.ts +3 -3
  303. package/dist/svelte/router/Route.svelte.d.ts +5 -5
  304. package/dist/svelte/router/Router.svelte.d.ts +3 -3
  305. package/dist/svelte/router/hashMode.ts +6 -12
  306. package/dist/svelte/router/matchPath.ts +44 -61
  307. package/dist/svelte/router/page.d.ts +1 -10
  308. package/dist/svelte/router/page.js +6 -6
  309. package/dist/svelte/router/prefetchCache.ts +21 -23
  310. package/dist/svelte/router/viewTransitions.ts +22 -12
  311. package/dist/svelte/server.js +697 -565
  312. package/dist/svelte/server.js.map +14 -11
  313. package/dist/types/absoluteConfig.d.ts +22 -0
  314. package/dist/types/angular.d.ts +4 -1
  315. package/dist/types/authPanel.d.ts +62 -0
  316. package/dist/types/build.d.ts +116 -0
  317. package/dist/types/cli.d.ts +57 -0
  318. package/dist/types/config.d.ts +52 -0
  319. package/dist/types/eslintConfig.d.ts +68 -0
  320. package/dist/types/globals.d.ts +31 -10
  321. package/dist/types/image.d.ts +2 -0
  322. package/dist/types/index.d.ts +1 -0
  323. package/dist/types/integrationsPanel.d.ts +29 -0
  324. package/dist/types/messages.d.ts +12 -0
  325. package/dist/types/packageJson.d.ts +74 -0
  326. package/dist/types/packageJsonPanel.d.ts +29 -0
  327. package/dist/types/prettier.d.ts +26 -0
  328. package/dist/types/tsconfig.d.ts +31 -0
  329. package/dist/types/vue.d.ts +13 -15
  330. package/dist/vue/browser.js +14 -36
  331. package/dist/vue/browser.js.map +5 -5
  332. package/dist/vue/components/Image.js +3 -20
  333. package/dist/vue/components/Image.js.map +3 -3
  334. package/dist/vue/components/index.js +3 -20
  335. package/dist/vue/components/index.js.map +3 -3
  336. package/dist/vue/index.js +1573 -620
  337. package/dist/vue/index.js.map +34 -22
  338. package/dist/vue/server.js +800 -520
  339. package/dist/vue/server.js.map +17 -11
  340. package/package.json +145 -68
  341. package/dist/src/react/UniversalRouter.d.ts +0 -12
@@ -3,7 +3,6 @@ var __create = Object.create;
3
3
  var __getProtoOf = Object.getPrototypeOf;
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
7
  function __accessProp(key) {
9
8
  return this[key];
@@ -30,23 +29,6 @@ var __toESM = (mod, isNodeMode, target) => {
30
29
  cache.set(mod, to);
31
30
  return to;
32
31
  };
33
- var __toCommonJS = (from) => {
34
- var entry = (__moduleCache ??= new WeakMap).get(from), desc;
35
- if (entry)
36
- return entry;
37
- entry = __defProp({}, "__esModule", { value: true });
38
- if (from && typeof from === "object" || typeof from === "function") {
39
- for (var key of __getOwnPropNames(from))
40
- if (!__hasOwnProp.call(entry, key))
41
- __defProp(entry, key, {
42
- get: __accessProp.bind(from, key),
43
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44
- });
45
- }
46
- __moduleCache.set(from, entry);
47
- return entry;
48
- };
49
- var __moduleCache;
50
32
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
33
  var __returnValue = (v) => v;
52
34
  function __exportSetter(name, newValue) {
@@ -134,8 +116,9 @@ var resolveExportPath = (entry, conditions) => {
134
116
  var init_resolvePackageImport = () => {};
135
117
 
136
118
  // src/constants.ts
137
- 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", 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_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, 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, 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, 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, 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, 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;
119
+ 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_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, 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;
138
120
  var init_constants = __esm(() => {
121
+ TAILWIND_BUN_CSS_WARNING_PATTERN = /invalid @ rule encountered: '@(theme|tailwind|source|utility|variant|custom-variant|apply|reference|plugin|config)'/;
139
122
  IMAGE_DEFAULT_DEVICE_SIZES = [
140
123
  640,
141
124
  750,
@@ -1072,22 +1055,20 @@ __export(exports_devRouteRegistrationCallsite, {
1072
1055
  });
1073
1056
  import { AsyncLocalStorage } from "async_hooks";
1074
1057
  import { Elysia } from "elysia";
1075
- var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
1058
+ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, NODE_ENV_KEY = "NODE_ENV", ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, isPageHandlerFunction = (value) => typeof value === "function", handlerSourceMentionsPageHelper = (handler) => {
1076
1059
  const source = handler.toString();
1077
1060
  return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
1061
+ }, getOriginalPageHandlerSource = (handler) => {
1062
+ if (!isPageHandlerFunction(handler))
1063
+ return;
1064
+ const info = pageHandlerWrappers.get(handler);
1065
+ return (info?.originalHandler ?? handler).toString();
1078
1066
  }, isPageHandler = (handler) => {
1079
- if (typeof handler !== "function")
1067
+ if (!isPageHandlerFunction(handler))
1080
1068
  return false;
1081
- const fn = handler;
1082
- if (pageHandlerWrappers.has(fn))
1069
+ if (pageHandlerWrappers.has(handler))
1083
1070
  return true;
1084
- return handlerSourceMentionsPageHelper(fn);
1085
- }, getOriginalPageHandlerSource = (handler) => {
1086
- if (typeof handler !== "function")
1087
- return;
1088
- const fn = handler;
1089
- const info = pageHandlerWrappers.get(fn);
1090
- return (info?.originalHandler ?? fn).toString();
1071
+ return handlerSourceMentionsPageHelper(handler);
1091
1072
  }, 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", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
1092
1073
  const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
1093
1074
  if (value === null || typeof value === "undefined") {
@@ -1121,17 +1102,22 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
1121
1102
  return function wrappedRouteHandler(...args) {
1122
1103
  return storage.run({ callsite }, () => Reflect.apply(routeHandler, this, args));
1123
1104
  };
1124
- }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, handler, ...rest) {
1105
+ }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, ...routeArguments) {
1106
+ const handlerIndex = routeArguments.length >= 2 ? 1 : 0;
1107
+ const handler = routeArguments[handlerIndex];
1125
1108
  const callsite = captureRouteRegistrationCallsite();
1126
1109
  const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
1127
- if (methodName === "get" && typeof handler === "function" && typeof wrapped === "function" && handlerSourceMentionsPageHelper(handler)) {
1110
+ if (methodName === "get" && isPageHandlerFunction(handler) && isPageHandlerFunction(wrapped) && handlerSourceMentionsPageHelper(handler)) {
1128
1111
  pageHandlerWrappers.set(wrapped, {
1129
1112
  originalHandler: handler
1130
1113
  });
1131
1114
  }
1132
- return Reflect.apply(originalMethod, this, [path, wrapped, ...rest]);
1115
+ routeArguments[handlerIndex] = wrapped;
1116
+ return Reflect.apply(originalMethod, this, [path, ...routeArguments]);
1133
1117
  }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
1134
- if (false) {}
1118
+ if (process.env[NODE_ENV_KEY] === "production") {
1119
+ return;
1120
+ }
1135
1121
  if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
1136
1122
  return;
1137
1123
  }
@@ -1168,6 +1154,43 @@ var init_devRouteRegistrationCallsite = __esm(() => {
1168
1154
  pageHandlerWrappers = new WeakMap;
1169
1155
  });
1170
1156
 
1157
+ // src/core/pageResponseCache.ts
1158
+ import { createHash as createHash2 } from "crypto";
1159
+ var STREAMING_PAGE_HEADER = "x-absolute-stream", HTML_CONTENT_TYPE = "text/html", streamingPageHeaders = (extra) => {
1160
+ const headers = new Headers(extra);
1161
+ headers.set("content-type", HTML_CONTENT_TYPE);
1162
+ headers.set(STREAMING_PAGE_HEADER, "1");
1163
+ return headers;
1164
+ }, computeEtag = (html) => `W/"${createHash2("sha1").update(html).digest("base64url")}"`, withPageCacheHeaders = async (response, request, options) => {
1165
+ const contentType = response.headers.get("content-type") ?? "";
1166
+ if (!contentType.includes(HTML_CONTENT_TYPE))
1167
+ return response;
1168
+ const isStreaming = response.headers.get(STREAMING_PAGE_HEADER) === "1";
1169
+ if (isStreaming && !options?.bufferStreamForEtag || !response.body) {
1170
+ response.headers.delete(STREAMING_PAGE_HEADER);
1171
+ response.headers.set("cache-control", "no-cache");
1172
+ return response;
1173
+ }
1174
+ const html = await response.text();
1175
+ const etag = computeEtag(html);
1176
+ if (request?.headers.get("if-none-match") === etag) {
1177
+ return new Response(null, {
1178
+ headers: { "cache-control": "no-cache", etag },
1179
+ status: 304
1180
+ });
1181
+ }
1182
+ const headers = new Headers(response.headers);
1183
+ headers.delete(STREAMING_PAGE_HEADER);
1184
+ headers.set("cache-control", "no-cache");
1185
+ headers.set("etag", etag);
1186
+ return new Response(html, {
1187
+ headers,
1188
+ status: response.status,
1189
+ statusText: response.statusText
1190
+ });
1191
+ };
1192
+ var init_pageResponseCache = () => {};
1193
+
1171
1194
  // src/client/streamSwap.ts
1172
1195
  var streamSwapRuntime = () => {
1173
1196
  const absoluteWindow = window;
@@ -1953,6 +1976,19 @@ var colors2, frameworkColors, formatPath = (filePath) => {
1953
1976
  const errorMsg = error instanceof Error ? error.message : error;
1954
1977
  const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
1955
1978
  console.error(`${timestamp} ${tag} ${fullMessage}`);
1979
+ }, logHmrClientUpdate = (path, framework, duration, target, serverMs, clientMs, outcome = "applied", kind) => {
1980
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1981
+ const targetLabel = target.startsWith("capacitor-") ? target.slice("capacitor-".length) : target;
1982
+ const tag = `${colors2.cyan}[hmr:${targetLabel}]${colors2.reset}`;
1983
+ const pathColor = framework ? getFrameworkColor(framework) : colors2.white;
1984
+ const breakdown = serverMs === undefined || clientMs === undefined ? "" : `; server ${serverMs}ms, client ${clientMs}ms`;
1985
+ let action = "failed after";
1986
+ if (outcome === "applied")
1987
+ action = "applied in";
1988
+ else if (outcome === "reloaded")
1989
+ action = "falling back to reload after";
1990
+ const kindLabel = kind ? `${kind} ` : "";
1991
+ console.log(`${timestamp} ${tag} ${framework ?? "update"} ${kindLabel}${pathColor}${formatPath(path)}${colors2.reset} ${colors2.dim}${action} ${duration}ms${breakdown}${colors2.reset}`);
1956
1992
  }, logHmrUpdate = (path, framework, duration) => {
1957
1993
  log("hmr update", { duration, framework, path });
1958
1994
  }, logInfo = (message) => {
@@ -1992,6 +2028,37 @@ var init_logger = __esm(() => {
1992
2028
  };
1993
2029
  });
1994
2030
 
2031
+ // src/utils/inlinePageCss.ts
2032
+ var siblingCssCache, clearSiblingCssCache = () => {
2033
+ siblingCssCache.clear();
2034
+ }, injectInlineCss = (headTag, css) => {
2035
+ if (!css)
2036
+ return headTag;
2037
+ const styleBlock = `<style data-absolute-page-css>${css}</style>`;
2038
+ return headTag.replace("</head>", `${styleBlock}</head>`);
2039
+ }, readSiblingCss = async (siblingJsPath) => {
2040
+ if (!siblingJsPath)
2041
+ return "";
2042
+ const cssPath = siblingJsPath.replace(/\.js$/, ".css");
2043
+ if (cssPath === siblingJsPath)
2044
+ return "";
2045
+ const cached = siblingCssCache.get(cssPath);
2046
+ if (cached !== undefined)
2047
+ return cached;
2048
+ const { readFile: readFile2 } = await import("fs/promises");
2049
+ try {
2050
+ const css = await readFile2(cssPath, "utf-8");
2051
+ siblingCssCache.set(cssPath, css);
2052
+ return css;
2053
+ } catch {
2054
+ siblingCssCache.set(cssPath, "");
2055
+ return "";
2056
+ }
2057
+ };
2058
+ var init_inlinePageCss = __esm(() => {
2059
+ siblingCssCache = new Map;
2060
+ });
2061
+
1995
2062
  // src/utils/ssrErrorPage.ts
1996
2063
  var exports_ssrErrorPage = {};
1997
2064
  __export(exports_ssrErrorPage, {
@@ -2056,106 +2123,443 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
2056
2123
  return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
2057
2124
  };
2058
2125
 
2059
- // src/svelte/renderToReadableStream.ts
2060
- var exports_renderToReadableStream = {};
2061
- __export(exports_renderToReadableStream, {
2062
- renderToReadableStream: () => renderToReadableStream,
2063
- SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
2064
- });
2065
- var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
2066
- bootstrapScriptContent,
2067
- bootstrapScripts = [],
2068
- bootstrapModules = [],
2069
- nonce,
2070
- onError = console.error,
2071
- progressiveChunkSize = DEFAULT_CHUNK_SIZE,
2072
- signal,
2073
- headContent,
2074
- bodyContent
2075
- } = {}) => {
2076
- try {
2077
- const { render } = await import("svelte/server");
2078
- const renderComponent = render;
2079
- const rendered = typeof props === "undefined" ? await renderComponent(component) : await renderComponent(component, { props });
2080
- const { head, body } = rendered;
2081
- const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
2082
- 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("");
2083
- const encoder = new TextEncoder;
2084
- 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>`);
2085
- let offset = 0;
2086
- return new ReadableStream({
2087
- type: "bytes",
2088
- cancel(reason) {
2089
- onError?.(reason);
2090
- },
2091
- pull(controller) {
2092
- if (signal?.aborted) {
2093
- controller.close();
2094
- return;
2095
- }
2096
- if (offset >= full.length) {
2097
- controller.close();
2098
- return;
2099
- }
2100
- const end = Math.min(offset + progressiveChunkSize, full.length);
2101
- controller.enqueue(full.subarray(offset, end));
2102
- offset = end;
2103
- }
2104
- });
2105
- } catch (error) {
2106
- onError?.(error);
2107
- throw error;
2126
+ // src/utils/resolveConvention.ts
2127
+ import { basename as basename2 } from "path";
2128
+ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
2129
+ const value = Reflect.get(globalThis, CONVENTIONS_KEY);
2130
+ if (isConventionsMap(value))
2131
+ return value;
2132
+ const empty = {};
2133
+ return empty;
2134
+ }, derivePageName = (pagePath) => {
2135
+ const base = basename2(pagePath);
2136
+ const dotIndex = base.indexOf(".");
2137
+ const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
2138
+ return toPascal(name);
2139
+ }, normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, ""), hasErrorConvention = (framework) => {
2140
+ const conventions = getMap()[framework];
2141
+ if (!conventions)
2142
+ return false;
2143
+ if (conventions.defaults?.error)
2144
+ return true;
2145
+ return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
2146
+ }, resolveErrorConventionPath = (framework, pageName) => {
2147
+ const conventions = getMap()[framework];
2148
+ if (!conventions)
2149
+ return;
2150
+ const exact = conventions.pages?.[pageName]?.error;
2151
+ if (exact)
2152
+ return exact;
2153
+ const normalizedPageName = normalizeConventionPageName(pageName);
2154
+ for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
2155
+ if (normalizeConventionPageName(candidate) === normalizedPageName) {
2156
+ return page.error ?? conventions.defaults?.error;
2157
+ }
2108
2158
  }
2109
- };
2110
- var init_renderToReadableStream = __esm(() => {
2111
- init_constants();
2112
- init_escapeScriptContent();
2113
- });
2114
-
2115
- // src/angular/resolveAngularPackage.ts
2116
- import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
2117
- import { join as join4, resolve as resolve4 } from "path";
2118
- var resolveAngularPackageDir = (specifier) => {
2119
- const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve4(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
2120
- if (fromCompiledRuntime && existsSync3(fromCompiledRuntime)) {
2121
- return fromCompiledRuntime;
2159
+ return conventions.defaults?.error;
2160
+ }, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
2161
+ Reflect.set(globalThis, CONVENTIONS_KEY, map);
2162
+ }, isDev = () => true, buildErrorProps = (error) => {
2163
+ if (error instanceof Error) {
2164
+ return {
2165
+ message: error.message,
2166
+ name: error.name,
2167
+ ...isDev() && error.stack ? { stack: error.stack } : {}
2168
+ };
2122
2169
  }
2123
- const fromProject = resolve4(process.cwd(), "node_modules", specifier);
2124
- if (existsSync3(fromProject)) {
2125
- return fromProject;
2170
+ return { message: String(error), name: "Error" };
2171
+ }, renderReactError = async (conventionPath, errorProps) => {
2172
+ const { createElement } = await import("react");
2173
+ const { renderToReadableStream } = await import("react-dom/server");
2174
+ const mod = await import(conventionPath);
2175
+ const ErrorComponent = mod.default;
2176
+ if (typeof ErrorComponent !== "function")
2177
+ return null;
2178
+ const element = createElement(ErrorComponent, errorProps);
2179
+ const stream = await renderToReadableStream(element);
2180
+ return new Response(stream, {
2181
+ headers: { "Content-Type": "text/html" },
2182
+ status: 500
2183
+ });
2184
+ }, renderSvelteError = async (conventionPath, errorProps) => {
2185
+ const { render } = await import("svelte/server");
2186
+ const mod = await import(conventionPath);
2187
+ const ErrorComponent = mod.default;
2188
+ if (!ErrorComponent)
2189
+ return null;
2190
+ const { head, body } = render(ErrorComponent, {
2191
+ props: errorProps
2192
+ });
2193
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
2194
+ return new Response(html, {
2195
+ headers: { "Content-Type": "text/html" },
2196
+ status: 500
2197
+ });
2198
+ }, unescapeVueStyles = (ssrBody) => {
2199
+ let styles = "";
2200
+ const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
2201
+ styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
2202
+ return "";
2203
+ });
2204
+ return { body, styles };
2205
+ }, renderVueError = async (conventionPath, errorProps) => {
2206
+ const { createSSRApp, h } = await import("vue");
2207
+ const { renderToString } = await import("vue/server-renderer");
2208
+ const mod = await import(conventionPath);
2209
+ const ErrorComponent = mod.default;
2210
+ if (!ErrorComponent)
2211
+ return null;
2212
+ const app = createSSRApp({
2213
+ render: () => h(ErrorComponent, errorProps)
2214
+ });
2215
+ const rawBody = await renderToString(app);
2216
+ const { styles, body } = unescapeVueStyles(rawBody);
2217
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
2218
+ return new Response(html, {
2219
+ headers: { "Content-Type": "text/html" },
2220
+ status: 500
2221
+ });
2222
+ }, renderAngularError = async (conventionPath, errorProps) => {
2223
+ const mod = await import(conventionPath);
2224
+ const renderFn = mod.default;
2225
+ if (typeof renderFn !== "function")
2226
+ return null;
2227
+ const html = renderFn(errorProps);
2228
+ return new Response(html, {
2229
+ headers: { "Content-Type": "text/html" },
2230
+ status: 500
2231
+ });
2232
+ }, escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), 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) => {
2233
+ const template = await Bun.file(conventionPath).text();
2234
+ const html = replaceErrorTokens(template, errorProps);
2235
+ return new Response(html, {
2236
+ headers: { "Content-Type": "text/html" },
2237
+ status: 500
2238
+ });
2239
+ }, logConventionRenderError = (framework, label, renderError) => {
2240
+ const message = renderError instanceof Error ? renderError.message : "";
2241
+ if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
2242
+ 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}).`);
2243
+ return;
2126
2244
  }
2127
- return null;
2128
- }, resolvePackageEntry = (packageDir) => {
2245
+ console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
2246
+ }, renderEmberError = async () => null, renderEmberNotFound = async () => null, ERROR_RENDERERS, tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
2247
+ let conventionPath = resolveErrorConventionPath(framework, pageName);
2248
+ if (!conventionPath && error instanceof Error && error.stack) {
2249
+ for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
2250
+ const [, candidate] = match;
2251
+ if (!candidate)
2252
+ continue;
2253
+ conventionPath = resolveErrorConventionPath(framework, candidate);
2254
+ if (conventionPath)
2255
+ break;
2256
+ }
2257
+ }
2258
+ if (!conventionPath)
2259
+ return null;
2260
+ const renderer = ERROR_RENDERERS[framework];
2261
+ if (!renderer)
2262
+ return null;
2129
2263
  try {
2130
- const pkg = JSON.parse(readFileSync3(join4(packageDir, "package.json"), "utf-8"));
2131
- const rootExport = pkg.exports?.["."];
2132
- const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
2133
- return join4(packageDir, entry);
2134
- } catch {
2135
- return packageDir;
2264
+ return await renderer(conventionPath, errorProps);
2265
+ } catch (renderError) {
2266
+ logConventionRenderError(framework, "error", renderError);
2136
2267
  }
2137
- }, resolveAngularPackage = (specifier) => {
2138
- const packageDir = resolveAngularPackageDir(specifier);
2139
- if (packageDir)
2140
- return resolvePackageEntry(packageDir);
2141
- return specifier;
2142
- }, toSafeVendorName = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), resolveAngularRuntimePath = (specifier) => {
2143
- const buildDirs = [
2144
- process.env.ABSOLUTE_BUILD_DIR,
2145
- resolve4(process.cwd(), "build")
2146
- ].filter((value) => Boolean(value));
2147
- for (const buildDir of buildDirs) {
2148
- const vendorPath = join4(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
2149
- if (existsSync3(vendorPath))
2150
- return vendorPath;
2268
+ return null;
2269
+ }, renderConventionError = async (framework, pageName, error) => {
2270
+ const errorProps = buildErrorProps(error);
2271
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
2272
+ if (frameworkResponse)
2273
+ return frameworkResponse;
2274
+ if (framework !== "html") {
2275
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
2276
+ if (htmlResponse)
2277
+ return htmlResponse;
2151
2278
  }
2152
- return resolveAngularPackage(specifier);
2153
- };
2154
- var init_resolveAngularPackage = () => {};
2155
-
2156
- // src/utils/runtimeMode.ts
2157
- var ENV_VAR = "NODE_ENV", isProductionRuntime = () => process.env[ENV_VAR] === "production", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development";
2158
-
2279
+ return null;
2280
+ }, renderReactNotFound = async (conventionPath) => {
2281
+ const { createElement } = await import("react");
2282
+ const { renderToReadableStream } = await import("react-dom/server");
2283
+ const mod = await import(conventionPath);
2284
+ const NotFoundComponent = mod.default;
2285
+ if (typeof NotFoundComponent !== "function")
2286
+ return null;
2287
+ const element = createElement(NotFoundComponent);
2288
+ const stream = await renderToReadableStream(element);
2289
+ return new Response(stream, {
2290
+ headers: { "Content-Type": "text/html" },
2291
+ status: 404
2292
+ });
2293
+ }, renderSvelteNotFound = async (conventionPath) => {
2294
+ const { render } = await import("svelte/server");
2295
+ const mod = await import(conventionPath);
2296
+ const NotFoundComponent = mod.default;
2297
+ if (!NotFoundComponent)
2298
+ return null;
2299
+ const { head, body } = render(NotFoundComponent);
2300
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
2301
+ return new Response(html, {
2302
+ headers: { "Content-Type": "text/html" },
2303
+ status: 404
2304
+ });
2305
+ }, renderVueNotFound = async (conventionPath) => {
2306
+ const { createSSRApp, h } = await import("vue");
2307
+ const { renderToString } = await import("vue/server-renderer");
2308
+ const mod = await import(conventionPath);
2309
+ const NotFoundComponent = mod.default;
2310
+ if (!NotFoundComponent)
2311
+ return null;
2312
+ const app = createSSRApp({
2313
+ render: () => h(NotFoundComponent)
2314
+ });
2315
+ const rawBody = await renderToString(app);
2316
+ const { styles, body } = unescapeVueStyles(rawBody);
2317
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
2318
+ return new Response(html, {
2319
+ headers: { "Content-Type": "text/html" },
2320
+ status: 404
2321
+ });
2322
+ }, renderAngularNotFound = async (conventionPath) => {
2323
+ const mod = await import(conventionPath);
2324
+ const renderFn = mod.default;
2325
+ if (typeof renderFn !== "function")
2326
+ return null;
2327
+ const html = renderFn();
2328
+ return new Response(html, {
2329
+ headers: { "Content-Type": "text/html" },
2330
+ status: 404
2331
+ });
2332
+ }, renderHtmlNotFound = async (conventionPath) => {
2333
+ const html = await Bun.file(conventionPath).text();
2334
+ return new Response(html, {
2335
+ headers: { "Content-Type": "text/html" },
2336
+ status: 404
2337
+ });
2338
+ }, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
2339
+ const conventionPath = resolveNotFoundConventionPath(framework);
2340
+ if (!conventionPath)
2341
+ return null;
2342
+ const renderer = NOT_FOUND_RENDERERS[framework];
2343
+ if (!renderer)
2344
+ return null;
2345
+ try {
2346
+ return await renderer(conventionPath);
2347
+ } catch (renderError) {
2348
+ logConventionRenderError(framework, "not-found", renderError);
2349
+ }
2350
+ return null;
2351
+ }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
2352
+ const renderNext = async (frameworks) => {
2353
+ const [framework, ...remaining] = frameworks;
2354
+ if (!framework) {
2355
+ return null;
2356
+ }
2357
+ if (!getMap()[framework]?.defaults?.notFound) {
2358
+ return renderNext(remaining);
2359
+ }
2360
+ const response = await renderConventionNotFound(framework);
2361
+ if (response) {
2362
+ return response;
2363
+ }
2364
+ return renderNext(remaining);
2365
+ };
2366
+ return renderNext(NOT_FOUND_PRIORITY);
2367
+ };
2368
+ var init_resolveConvention = __esm(() => {
2369
+ ERROR_RENDERERS = {
2370
+ angular: renderAngularError,
2371
+ ember: renderEmberError,
2372
+ html: renderHtmlError,
2373
+ react: renderReactError,
2374
+ svelte: renderSvelteError,
2375
+ vue: renderVueError
2376
+ };
2377
+ NOT_FOUND_RENDERERS = {
2378
+ angular: renderAngularNotFound,
2379
+ ember: renderEmberNotFound,
2380
+ html: renderHtmlNotFound,
2381
+ react: renderReactNotFound,
2382
+ svelte: renderSvelteNotFound,
2383
+ vue: renderVueNotFound
2384
+ };
2385
+ NOT_FOUND_PRIORITY = [
2386
+ "react",
2387
+ "svelte",
2388
+ "vue",
2389
+ "angular",
2390
+ "html"
2391
+ ];
2392
+ });
2393
+
2394
+ // src/utils/spaRouteManifest.ts
2395
+ import { basename as basename3 } from "path";
2396
+ var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
2397
+ Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
2398
+ }, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
2399
+ const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
2400
+ return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
2401
+ }, normalizePath = (path) => {
2402
+ const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
2403
+ const trimmed = withLeadingSlash.replace(/\/+$/, "");
2404
+ return trimmed || "/";
2405
+ }, fullRoutePath = (baseHref, routePath) => {
2406
+ const base = normalizePath(baseHref);
2407
+ const route = normalizePath(routePath);
2408
+ if (base !== "/" && (route === base || route.startsWith(`${base}/`))) {
2409
+ return route;
2410
+ }
2411
+ if (base === "/")
2412
+ return route;
2413
+ return normalizePath(`${base}/${route.replace(/^\/+/, "")}`);
2414
+ }, routePattern = (path) => {
2415
+ const segments = normalizePath(path).split("/").filter(Boolean);
2416
+ let expression = "^";
2417
+ for (const segment of segments) {
2418
+ if (segment === "*" || segment === "**") {
2419
+ expression += "(?:/.*)?";
2420
+ continue;
2421
+ }
2422
+ const parameter = /^:[A-Za-z_$][A-Za-z0-9_$]*(?:\((.*)\))?(\?)?$/.exec(segment);
2423
+ if (parameter) {
2424
+ const valuePattern = parameter[1] || "[^/]+";
2425
+ expression += parameter[2] ? `(?:/${valuePattern})?` : `/${valuePattern}`;
2426
+ continue;
2427
+ }
2428
+ expression += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&")}`;
2429
+ }
2430
+ return new RegExp(`${expression || "^/"}/?$`);
2431
+ }, sourcePageName = (sourceFile) => basename3(sourceFile).replace(/\.[^.]+$/, "").toLowerCase(), isKnownSpaRoute = (framework, pageName, request) => {
2432
+ if (!request)
2433
+ return true;
2434
+ let pathname;
2435
+ try {
2436
+ pathname = normalizePath(new URL(request.url).pathname);
2437
+ } catch {
2438
+ return true;
2439
+ }
2440
+ const hosts = getSpaRouteManifest().filter((host) => {
2441
+ if (host.framework !== framework)
2442
+ return false;
2443
+ if (sourcePageName(host.sourceFile) !== pageName.toLowerCase())
2444
+ return false;
2445
+ const base = normalizePath(host.baseHref);
2446
+ return base === "/" || pathname === base || pathname.startsWith(`${base}/`);
2447
+ });
2448
+ if (hosts.length === 0)
2449
+ return true;
2450
+ return hosts.some((host) => host.routes.some((route) => routePattern(fullRoutePath(host.baseHref, route.path)).test(pathname)));
2451
+ }, renderSpaNotFound = async (framework, pageName, request) => {
2452
+ if (isKnownSpaRoute(framework, pageName, request))
2453
+ return null;
2454
+ return await renderFirstNotFound() ?? new Response("Not found", {
2455
+ headers: { "Content-Type": "text/plain" },
2456
+ status: 404
2457
+ });
2458
+ };
2459
+ var init_spaRouteManifest = __esm(() => {
2460
+ init_resolveConvention();
2461
+ });
2462
+
2463
+ // src/svelte/renderToReadableStream.ts
2464
+ var exports_renderToReadableStream = {};
2465
+ __export(exports_renderToReadableStream, {
2466
+ renderToReadableStream: () => renderToReadableStream,
2467
+ SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
2468
+ });
2469
+ var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
2470
+ bootstrapScriptContent,
2471
+ bootstrapScripts = [],
2472
+ bootstrapModules = [],
2473
+ nonce,
2474
+ onError = console.error,
2475
+ progressiveChunkSize = DEFAULT_CHUNK_SIZE,
2476
+ signal,
2477
+ headContent,
2478
+ bodyContent
2479
+ } = {}) => {
2480
+ try {
2481
+ const { render } = await import("svelte/server");
2482
+ const renderComponent = render;
2483
+ const rendered = typeof props === "undefined" ? await renderComponent(component) : await renderComponent(component, { props });
2484
+ const { head, body } = rendered;
2485
+ const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
2486
+ 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("");
2487
+ const encoder = new TextEncoder;
2488
+ 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>`);
2489
+ let offset = 0;
2490
+ return new ReadableStream({
2491
+ type: "bytes",
2492
+ cancel(reason) {
2493
+ onError?.(reason);
2494
+ },
2495
+ pull(controller) {
2496
+ if (signal?.aborted) {
2497
+ controller.close();
2498
+ return;
2499
+ }
2500
+ if (offset >= full.length) {
2501
+ controller.close();
2502
+ return;
2503
+ }
2504
+ const end = Math.min(offset + progressiveChunkSize, full.length);
2505
+ controller.enqueue(full.subarray(offset, end));
2506
+ offset = end;
2507
+ }
2508
+ });
2509
+ } catch (error) {
2510
+ onError?.(error);
2511
+ throw error;
2512
+ }
2513
+ };
2514
+ var init_renderToReadableStream = __esm(() => {
2515
+ init_constants();
2516
+ init_escapeScriptContent();
2517
+ });
2518
+
2519
+ // src/angular/resolveAngularPackage.ts
2520
+ import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
2521
+ import { join as join4, resolve as resolve4 } from "path";
2522
+ var resolveAngularPackageDir = (specifier) => {
2523
+ const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve4(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
2524
+ if (fromCompiledRuntime && existsSync3(fromCompiledRuntime)) {
2525
+ return fromCompiledRuntime;
2526
+ }
2527
+ const fromProject = resolve4(process.cwd(), "node_modules", specifier);
2528
+ if (existsSync3(fromProject)) {
2529
+ return fromProject;
2530
+ }
2531
+ return null;
2532
+ }, resolvePackageEntry = (packageDir) => {
2533
+ try {
2534
+ const pkg = JSON.parse(readFileSync3(join4(packageDir, "package.json"), "utf-8"));
2535
+ const rootExport = pkg.exports?.["."];
2536
+ const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
2537
+ return join4(packageDir, entry);
2538
+ } catch {
2539
+ return packageDir;
2540
+ }
2541
+ }, resolveAngularPackage = (specifier) => {
2542
+ const packageDir = resolveAngularPackageDir(specifier);
2543
+ if (packageDir)
2544
+ return resolvePackageEntry(packageDir);
2545
+ return specifier;
2546
+ }, toSafeVendorName = (specifier) => specifier.replace(/^@/, "").replace(/\//g, "_"), resolveAngularRuntimePath = (specifier) => {
2547
+ const buildDirs = [
2548
+ process.env.ABSOLUTE_BUILD_DIR,
2549
+ resolve4(process.cwd(), "build")
2550
+ ].filter((value) => Boolean(value));
2551
+ for (const buildDir of buildDirs) {
2552
+ const vendorPath = join4(buildDir, "angular", "vendor", "server", `${toSafeVendorName(specifier)}.js`);
2553
+ if (existsSync3(vendorPath))
2554
+ return vendorPath;
2555
+ }
2556
+ return resolveAngularPackage(specifier);
2557
+ };
2558
+ var init_resolveAngularPackage = () => {};
2559
+
2560
+ // src/utils/runtimeMode.ts
2561
+ var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
2562
+
2159
2563
  // src/angular/angularPatch.ts
2160
2564
  var exports_angularPatch = {};
2161
2565
  __export(exports_angularPatch, {
@@ -2246,7 +2650,14 @@ var ensureHead = (doc) => {
2246
2650
  }
2247
2651
  try {
2248
2652
  const adapter = new \u{275}DominoAdapter;
2249
- const seedDoc = typeof adapter.createHtmlDocument === "function" ? adapter.createHtmlDocument() : typeof adapter.getDefaultDocument === "function" ? adapter.getDefaultDocument() : null;
2653
+ const resolveSeedDoc = () => {
2654
+ if (typeof adapter.createHtmlDocument === "function")
2655
+ return adapter.createHtmlDocument();
2656
+ if (typeof adapter.getDefaultDocument === "function")
2657
+ return adapter.getDefaultDocument();
2658
+ return null;
2659
+ };
2660
+ const seedDoc = resolveSeedDoc();
2250
2661
  if (seedDoc) {
2251
2662
  patchElementLayout(seedDoc);
2252
2663
  const probe = seedDoc.createElement("div");
@@ -2325,9 +2736,12 @@ var initDominoAdapter = (platformServer) => {
2325
2736
  return {
2326
2737
  APP_BASE_HREF: common.APP_BASE_HREF,
2327
2738
  bootstrapApplication: platformBrowser.bootstrapApplication,
2739
+ Component: core.Component,
2328
2740
  DomSanitizer: platformBrowser.DomSanitizer,
2329
2741
  ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
2330
2742
  inject: core.inject,
2743
+ InjectionToken: core.InjectionToken,
2744
+ NgComponentOutlet: common.NgComponentOutlet,
2331
2745
  provideClientHydration: platformBrowser.provideClientHydration,
2332
2746
  provideServerRendering: platformServer.provideServerRendering,
2333
2747
  provideZonelessChangeDetection: core.provideZonelessChangeDetection,
@@ -2529,7 +2943,7 @@ __export(exports_islands, {
2529
2943
  isAngularComponent: () => isAngularComponent,
2530
2944
  getAngularIslandSelector: () => getAngularIslandSelector
2531
2945
  });
2532
- var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) => typeof value === "function", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
2946
+ var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, isAngularComponent = (value) => typeof value === "function", getSelectorFromRenderedIsland = (rootElement) => {
2533
2947
  const firstChild = rootElement.firstElementChild;
2534
2948
  if (!(firstChild instanceof HTMLElement)) {
2535
2949
  return null;
@@ -2583,9 +2997,8 @@ var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) =
2583
2997
  const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
2584
2998
  return `${componentName}:${JSON.stringify(props)}`;
2585
2999
  }, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
2586
- const { Component, InjectionToken, inject } = await import("@angular/core");
2587
- const { NgComponentOutlet } = await import("@angular/common");
2588
3000
  const deps = await getAngularDeps();
3001
+ const { Component, InjectionToken, NgComponentOutlet, inject } = deps;
2589
3002
  const selector = getAngularIslandSelector(islandId);
2590
3003
  const propsToken = new InjectionToken(`${wrapperKey}:props`);
2591
3004
 
@@ -2691,7 +3104,15 @@ var init_islands = __esm(() => {
2691
3104
  var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
2692
3105
  const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands(), exports_islands));
2693
3106
  return renderAngularIslandToHtml2(component, props, islandId);
2694
- }, renderAngularIslandToHtml2, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToStaticMarkup }) => renderToStaticMarkup(createElement(component, props)))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
3107
+ }, renderAngularIslandToHtml2, LEADING_HOISTED_RESOURCE_RE, stripLeadingHoistedResources = (html) => {
3108
+ let result = html;
3109
+ let match = LEADING_HOISTED_RESOURCE_RE.exec(result);
3110
+ while (match) {
3111
+ result = result.slice(match[0].length);
3112
+ match = LEADING_HOISTED_RESOURCE_RE.exec(result);
3113
+ }
3114
+ return result.trimStart();
3115
+ }, renderReactIslandToHtml = (component, props) => import("react").then(({ createElement }) => import("react-dom/server").then(({ renderToString }) => stripLeadingHoistedResources(renderToString(createElement(component, props))))), renderSvelteIslandToHtml = (component, props) => import("svelte/server").then(({ render }) => {
2695
3116
  const { body } = render(component, { props });
2696
3117
  return body;
2697
3118
  }), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
@@ -2702,62 +3123,641 @@ var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
2702
3123
  });
2703
3124
  var init_islandSsr = __esm(() => {
2704
3125
  renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
3126
+ LEADING_HOISTED_RESOURCE_RE = /^\s*(?:<link\b[^>]*\/?>|<meta\b[^>]*\/?>|<title\b[^>]*>[\s\S]*?<\/title>|<style\b[^>]*>[\s\S]*?<\/style>|<script\b[^>]*>[\s\S]*?<\/script>)/i;
2705
3127
  });
2706
3128
 
2707
- // src/core/vueServerModule.ts
2708
- import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync } from "fs";
2709
- import { mkdir as mkdir2 } from "fs/promises";
2710
- import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
2711
- var {Transpiler } = globalThis.Bun;
2712
- var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
2713
- const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
2714
- return importPath.startsWith(".") ? importPath : `./${importPath}`;
2715
- }, getCachedModulePath2 = (sourcePath) => {
2716
- const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
2717
- const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2718
- return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
2719
- }, writeIfChanged2 = async (path, content) => {
2720
- const targetFile = Bun.file(path);
2721
- if (await targetFile.exists()) {
2722
- const currentContent = await targetFile.text();
2723
- if (currentContent === content)
2724
- return;
2725
- }
2726
- await Bun.write(path, content);
2727
- }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
2728
- const lines = code.split(`
2729
- `);
2730
- const specifierSet = new Set;
2731
- const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
2732
- lines.forEach((line) => {
2733
- const match = line.match(vueImportRegex);
2734
- if (match?.[1])
2735
- match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
2736
- });
2737
- const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
2738
- return specifierSet.size ? [
2739
- `import { ${[...specifierSet].join(", ")} } from "vue";`,
2740
- ...nonVueLines
2741
- ].join(`
2742
- `) : nonVueLines.join(`
2743
- `);
2744
- }, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
2745
- const cachedModulePath = compiledModuleCache2.get(sourcePath);
2746
- if (cachedModulePath)
2747
- return cachedModulePath;
2748
- const compiler = await import("@vue/compiler-sfc");
2749
- const source = await Bun.file(sourcePath).text();
2750
- const { descriptor } = compiler.parse(source, { filename: sourcePath });
2751
- const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
2752
- const hasScript = descriptor.script || descriptor.scriptSetup;
2753
- const compiledScript = hasScript ? compiler.compileScript(descriptor, {
2754
- fs: {
2755
- fileExists: existsSync4,
2756
- readFile: (file) => existsSync4(file) ? readFileSync4(file, "utf-8") : undefined,
2757
- realpath: realpathSync
2758
- },
2759
- id: componentId,
2760
- inlineTemplate: false
3129
+ // src/build/maskLiterals.ts
3130
+ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
3131
+ const n = src.length;
3132
+ const pieces = [];
3133
+ let out = "";
3134
+ let i = 0;
3135
+ let prevChar = "";
3136
+ let prevWord = "";
3137
+ let prevWasSpace = false;
3138
+ const mask = (text) => {
3139
+ out += SENTINEL + pieces.length + SENTINEL;
3140
+ pieces.push(text);
3141
+ prevChar = ")";
3142
+ prevWord = "";
3143
+ prevWasSpace = false;
3144
+ };
3145
+ const endOfString = (start) => {
3146
+ const q = src[start];
3147
+ let j = start + 1;
3148
+ while (j < n) {
3149
+ const c = src[j];
3150
+ if (c === "\\") {
3151
+ j += 2;
3152
+ continue;
3153
+ }
3154
+ if (c === q)
3155
+ return j + 1;
3156
+ if (c === `
3157
+ `)
3158
+ return j;
3159
+ j++;
3160
+ }
3161
+ return j;
3162
+ };
3163
+ const endOfInterp = (start) => {
3164
+ let j = start;
3165
+ let depth = 1;
3166
+ let ipChar = "";
3167
+ let ipWord = "";
3168
+ let ipSpace = false;
3169
+ while (j < n && depth > 0) {
3170
+ const c = src[j];
3171
+ if (c === "\\") {
3172
+ j += 2;
3173
+ continue;
3174
+ }
3175
+ if (c === "`") {
3176
+ j = endOfTemplate(j);
3177
+ ipChar = ")";
3178
+ ipWord = "";
3179
+ ipSpace = false;
3180
+ continue;
3181
+ }
3182
+ if (c === '"' || c === "'") {
3183
+ j = endOfString(j);
3184
+ ipChar = '"';
3185
+ ipWord = "";
3186
+ ipSpace = false;
3187
+ continue;
3188
+ }
3189
+ if (c === "/" && src[j + 1] === "/") {
3190
+ const nl = src.indexOf(`
3191
+ `, j);
3192
+ j = nl < 0 ? n : nl;
3193
+ continue;
3194
+ }
3195
+ if (c === "/" && src[j + 1] === "*") {
3196
+ const e = src.indexOf("*/", j + 2);
3197
+ j = e < 0 ? n : e + 2;
3198
+ continue;
3199
+ }
3200
+ if (c === "/" && (ipChar === "" || REGEX_OK_AFTER_CHAR.has(ipChar) || REGEX_OK_AFTER_WORD.has(ipWord))) {
3201
+ const e = endOfRegex(j);
3202
+ if (e > 0) {
3203
+ j = e;
3204
+ ipChar = ")";
3205
+ ipWord = "";
3206
+ ipSpace = false;
3207
+ continue;
3208
+ }
3209
+ }
3210
+ if (c === "{")
3211
+ depth++;
3212
+ else if (c === "}")
3213
+ depth--;
3214
+ j++;
3215
+ if (c === " " || c === "\t" || c === "\r" || c === `
3216
+ `) {
3217
+ ipSpace = true;
3218
+ continue;
3219
+ }
3220
+ if (isIdentChar(c)) {
3221
+ ipWord = isIdentChar(ipChar) && !ipSpace ? ipWord + c : c;
3222
+ } else {
3223
+ ipWord = "";
3224
+ }
3225
+ ipChar = c;
3226
+ ipSpace = false;
3227
+ }
3228
+ return j;
3229
+ };
3230
+ function endOfTemplate(start) {
3231
+ let j = start + 1;
3232
+ while (j < n) {
3233
+ const c = src[j];
3234
+ if (c === "\\") {
3235
+ j += 2;
3236
+ continue;
3237
+ }
3238
+ if (c === "`")
3239
+ return j + 1;
3240
+ if (c === "$" && src[j + 1] === "{") {
3241
+ j = endOfInterp(j + 2);
3242
+ continue;
3243
+ }
3244
+ j++;
3245
+ }
3246
+ return j;
3247
+ }
3248
+ const endOfRegex = (start) => {
3249
+ let j = start + 1;
3250
+ let inClass = false;
3251
+ while (j < n) {
3252
+ const c = src[j];
3253
+ if (c === "\\") {
3254
+ j += 2;
3255
+ continue;
3256
+ }
3257
+ if (c === `
3258
+ `)
3259
+ return -1;
3260
+ if (c === "[")
3261
+ inClass = true;
3262
+ else if (c === "]")
3263
+ inClass = false;
3264
+ else if (c === "/" && !inClass) {
3265
+ j++;
3266
+ break;
3267
+ }
3268
+ j++;
3269
+ }
3270
+ while (j < n && /[a-z]/i.test(src[j] ?? ""))
3271
+ j++;
3272
+ return j;
3273
+ };
3274
+ while (i < n) {
3275
+ const c = src[i];
3276
+ const c2 = src[i + 1];
3277
+ if (c === "/" && c2 === "/") {
3278
+ out += "//";
3279
+ i += 2;
3280
+ const s = i;
3281
+ while (i < n && src[i] !== `
3282
+ `)
3283
+ i++;
3284
+ mask(src.slice(s, i));
3285
+ continue;
3286
+ }
3287
+ if (c === "/" && c2 === "*") {
3288
+ out += "/*";
3289
+ i += 2;
3290
+ const e = src.indexOf("*/", i);
3291
+ const end = e < 0 ? n : e;
3292
+ mask(src.slice(i, end));
3293
+ i = end < n ? end + 2 : n;
3294
+ if (end < n)
3295
+ out += "*/";
3296
+ continue;
3297
+ }
3298
+ if (c === "`") {
3299
+ const end = endOfTemplate(i);
3300
+ mask(src.slice(i, end));
3301
+ i = end;
3302
+ continue;
3303
+ }
3304
+ if (c === '"' || c === "'") {
3305
+ const end = endOfString(i);
3306
+ const text = src.slice(i, end);
3307
+ if (RISKY_STRING_CONTENT.test(text)) {
3308
+ mask(text);
3309
+ } else {
3310
+ out += text;
3311
+ prevChar = '"';
3312
+ prevWord = "";
3313
+ prevWasSpace = false;
3314
+ }
3315
+ i = end;
3316
+ continue;
3317
+ }
3318
+ if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
3319
+ const end = endOfRegex(i);
3320
+ if (end > 0) {
3321
+ out += src.slice(i, end);
3322
+ i = end;
3323
+ prevChar = ")";
3324
+ prevWord = "";
3325
+ prevWasSpace = false;
3326
+ continue;
3327
+ }
3328
+ }
3329
+ out += c;
3330
+ i++;
3331
+ if (c === " " || c === "\t" || c === "\r" || c === `
3332
+ `) {
3333
+ prevWasSpace = true;
3334
+ continue;
3335
+ }
3336
+ if (isIdentChar(c)) {
3337
+ const contiguous = isIdentChar(prevChar) && !prevWasSpace;
3338
+ prevWord = contiguous ? prevWord + c : c;
3339
+ } else {
3340
+ prevWord = "";
3341
+ }
3342
+ prevChar = c;
3343
+ prevWasSpace = false;
3344
+ }
3345
+ const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
3346
+ const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
3347
+ return { masked: out, restore };
3348
+ };
3349
+ var init_maskLiterals = __esm(() => {
3350
+ SENTINEL = String.fromCharCode(57344);
3351
+ RISKY_STRING_CONTENT = /\b(?:from|import|require)\s*\(?\s*["'`]/;
3352
+ REGEX_OK_AFTER_CHAR = new Set([
3353
+ "(",
3354
+ ",",
3355
+ "=",
3356
+ ":",
3357
+ "[",
3358
+ "!",
3359
+ "&",
3360
+ "|",
3361
+ "?",
3362
+ "{",
3363
+ "}",
3364
+ ";",
3365
+ "+",
3366
+ "-",
3367
+ "*",
3368
+ "/",
3369
+ "%",
3370
+ "^",
3371
+ "~",
3372
+ "<",
3373
+ ">"
3374
+ ]);
3375
+ REGEX_OK_AFTER_WORD = new Set([
3376
+ "return",
3377
+ "typeof",
3378
+ "instanceof",
3379
+ "in",
3380
+ "of",
3381
+ "new",
3382
+ "delete",
3383
+ "void",
3384
+ "do",
3385
+ "else",
3386
+ "yield",
3387
+ "await",
3388
+ "case"
3389
+ ]);
3390
+ });
3391
+
3392
+ // src/build/nativeRewrite.ts
3393
+ import { dlopen, FFIType, ptr } from "bun:ffi";
3394
+ import { platform, arch } from "os";
3395
+ import { resolve as resolve5 } from "path";
3396
+ var ffiDefinition, nativeLib = null, loadNative = () => {
3397
+ if (nativeLib !== null)
3398
+ return nativeLib;
3399
+ const osPlatform = platform();
3400
+ const cpu = arch();
3401
+ const platformMap = {
3402
+ "darwin-arm64": "darwin-arm64/fast_ops.dylib",
3403
+ "darwin-x64": "darwin-x64/fast_ops.dylib",
3404
+ "linux-arm64": "linux-arm64/fast_ops.so",
3405
+ "linux-x64": "linux-x64/fast_ops.so",
3406
+ "win32-arm64": "windows-arm64/fast_ops.dll",
3407
+ "win32-x64": "windows-x64/fast_ops.dll"
3408
+ };
3409
+ const libPath = platformMap[`${osPlatform}-${cpu}`];
3410
+ if (!libPath)
3411
+ return null;
3412
+ try {
3413
+ const fullPath = resolve5(import.meta.dir, "../../native/packages", libPath);
3414
+ const lib = dlopen(fullPath, ffiDefinition);
3415
+ nativeLib = lib.symbols;
3416
+ return nativeLib;
3417
+ } catch {
3418
+ return null;
3419
+ }
3420
+ }, nativeRewriteImports = (content, replacements) => {
3421
+ const lib = loadNative();
3422
+ if (!lib)
3423
+ return null;
3424
+ const jsonStr = JSON.stringify(replacements);
3425
+ const contentBuf = Buffer.from(content);
3426
+ const jsonBuf = Buffer.from(jsonStr);
3427
+ const outBuf = Buffer.alloc(content.length * 2);
3428
+ const outLenBuf = new BigUint64Array([BigInt(outBuf.length)]);
3429
+ const result = lib.rewrite_imports(ptr(contentBuf), contentBuf.length, ptr(jsonBuf), jsonBuf.length, ptr(outBuf), ptr(new Uint8Array(outLenBuf.buffer)));
3430
+ if (result < 0)
3431
+ return null;
3432
+ if (result === 0)
3433
+ return content;
3434
+ const outLen = Number(outLenBuf[0]);
3435
+ return outBuf.subarray(0, outLen).toString("utf-8");
3436
+ };
3437
+ var init_nativeRewrite = __esm(() => {
3438
+ ffiDefinition = {
3439
+ rewrite_imports: {
3440
+ args: [
3441
+ FFIType.ptr,
3442
+ FFIType.u64,
3443
+ FFIType.ptr,
3444
+ FFIType.u64,
3445
+ FFIType.ptr,
3446
+ FFIType.ptr
3447
+ ],
3448
+ returns: FFIType.i32
3449
+ }
3450
+ };
3451
+ });
3452
+
3453
+ // src/build/rewriteImportsPlugin.ts
3454
+ var exports_rewriteImportsPlugin = {};
3455
+ __export(exports_rewriteImportsPlugin, {
3456
+ rewriteVendorDirectories: () => rewriteVendorDirectories,
3457
+ rewriteImportsInContent: () => rewriteImportsInContent,
3458
+ rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
3459
+ rewriteBuildOutputs: () => rewriteBuildOutputs,
3460
+ jsRewriteImports: () => jsRewriteImports,
3461
+ fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
3462
+ buildWithImportRewrite: () => buildWithImportRewrite
3463
+ });
3464
+ import { readdir as readdir2 } from "fs/promises";
3465
+ import { join as join5 } from "path";
3466
+ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
3467
+ let result = content;
3468
+ for (const [specifier, webPath] of replacements) {
3469
+ const escaped = escapeRegex(specifier);
3470
+ const fromRegex = new RegExp(`(from\\s*["'])${escaped}(["'])`, "g");
3471
+ const sideEffectRegex = new RegExp(`(import\\s*["'])${escaped}(["'])`, "g");
3472
+ const dynamicRegex = new RegExp(`(import\\s*\\(\\s*["'])${escaped}(["']\\s*\\))`, "g");
3473
+ result = result.replace(fromRegex, `$1${webPath}$2`);
3474
+ result = result.replace(sideEffectRegex, `$1${webPath}$2`);
3475
+ result = result.replace(dynamicRegex, `$1${webPath}$2`);
3476
+ }
3477
+ return result;
3478
+ }, rewriteImportsInContent = (content, vendorPaths) => {
3479
+ if (Object.keys(vendorPaths).length === 0)
3480
+ return content;
3481
+ const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
3482
+ const { masked, restore } = maskLiterals(content);
3483
+ const native = nativeRewriteImports(masked, replacements);
3484
+ return restore(native ?? jsRewriteImports(masked, replacements));
3485
+ }, fixMissingReExportNamespacesInContent = (content) => {
3486
+ const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
3487
+ REEXPORT_PATTERN.lastIndex = 0;
3488
+ const missing = [];
3489
+ let match;
3490
+ while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
3491
+ const ident = match[1];
3492
+ if (!ident)
3493
+ continue;
3494
+ const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
3495
+ if (nsImportRe.test(content))
3496
+ continue;
3497
+ const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
3498
+ if (declRe.test(content))
3499
+ continue;
3500
+ const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
3501
+ if (namedImportRe.test(content))
3502
+ continue;
3503
+ const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
3504
+ let pathMatch;
3505
+ let sourcePath;
3506
+ while ((pathMatch = importPathRe.exec(content)) !== null) {
3507
+ const p = pathMatch[1];
3508
+ if (!p)
3509
+ continue;
3510
+ const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
3511
+ if (!base)
3512
+ continue;
3513
+ const normalized = base.startsWith("_") ? base.slice(1) : base;
3514
+ if (normalized === ident || normalized.endsWith(`_${ident}`)) {
3515
+ sourcePath = p;
3516
+ break;
3517
+ }
3518
+ }
3519
+ if (sourcePath)
3520
+ missing.push({ ident, path: sourcePath });
3521
+ }
3522
+ if (missing.length === 0)
3523
+ return content;
3524
+ const seen = new Set;
3525
+ const unique = missing.filter((entry) => {
3526
+ if (seen.has(entry.ident))
3527
+ return false;
3528
+ seen.add(entry.ident);
3529
+ return true;
3530
+ });
3531
+ const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
3532
+ `);
3533
+ return `${inserts}
3534
+ ${content}`;
3535
+ }, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
3536
+ if (Object.keys(vendorPaths).length === 0)
3537
+ return;
3538
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
3539
+ let original;
3540
+ try {
3541
+ original = await artifact.text();
3542
+ } catch (err) {
3543
+ const code = err.code;
3544
+ if (code === "ENOENT")
3545
+ return;
3546
+ throw err;
3547
+ }
3548
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
3549
+ if (rewritten === original)
3550
+ return;
3551
+ try {
3552
+ await Bun.write(artifact.path, rewritten);
3553
+ } catch (err) {
3554
+ const code = err.code;
3555
+ if (code === "ENOENT")
3556
+ return;
3557
+ throw err;
3558
+ }
3559
+ }));
3560
+ }, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
3561
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
3562
+ const vendorPaths = resolveVendorPaths(artifact);
3563
+ if (Object.keys(vendorPaths).length === 0)
3564
+ return;
3565
+ let original;
3566
+ try {
3567
+ original = await artifact.text();
3568
+ } catch (err) {
3569
+ const code = err.code;
3570
+ if (code === "ENOENT")
3571
+ return;
3572
+ throw err;
3573
+ }
3574
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
3575
+ if (rewritten === original)
3576
+ return;
3577
+ try {
3578
+ await Bun.write(artifact.path, rewritten);
3579
+ } catch (err) {
3580
+ const code = err.code;
3581
+ if (code === "ENOENT")
3582
+ return;
3583
+ throw err;
3584
+ }
3585
+ }));
3586
+ }, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
3587
+ if (Object.keys(vendorPaths).length === 0)
3588
+ return;
3589
+ const allFiles = [];
3590
+ for (const dir of vendorDirs) {
3591
+ try {
3592
+ const entries = await readdir2(dir);
3593
+ for (const entry of entries) {
3594
+ if (entry.endsWith(".js"))
3595
+ allFiles.push(join5(dir, entry));
3596
+ }
3597
+ } catch {}
3598
+ }
3599
+ await Promise.all(allFiles.map(async (filePath) => {
3600
+ let original;
3601
+ try {
3602
+ original = await Bun.file(filePath).text();
3603
+ } catch (err) {
3604
+ const code = err.code;
3605
+ if (code === "ENOENT")
3606
+ return;
3607
+ throw err;
3608
+ }
3609
+ let next = rewriteImportsInContent(original, vendorPaths);
3610
+ next = fixMissingReExportNamespacesInContent(next);
3611
+ if (next === original)
3612
+ return;
3613
+ try {
3614
+ await Bun.write(filePath, next);
3615
+ } catch (err) {
3616
+ const code = err.code;
3617
+ if (code === "ENOENT")
3618
+ return;
3619
+ throw err;
3620
+ }
3621
+ }));
3622
+ }, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
3623
+ const result = await pendingBuild;
3624
+ if (result.outputs.length > 0) {
3625
+ await rewriteBuildOutputs(result.outputs, vendorPaths);
3626
+ }
3627
+ return result;
3628
+ };
3629
+ var init_rewriteImportsPlugin = __esm(() => {
3630
+ init_maskLiterals();
3631
+ init_nativeRewrite();
3632
+ });
3633
+
3634
+ // src/core/angularServerModule.ts
3635
+ import { mkdir as mkdir2 } from "fs/promises";
3636
+ import { dirname as dirname3, join as join6, relative as relative3 } from "path";
3637
+ var serverCacheRoot2, compiledModuleCache2, ANGULAR_SPECIFIER_RE, getCachedModulePath2 = (sourcePath) => {
3638
+ const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
3639
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
3640
+ return join6(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
3641
+ }, collectVendorPaths = (code) => {
3642
+ const vendorPaths = {};
3643
+ if (!isProductionRuntime()) {
3644
+ return vendorPaths;
3645
+ }
3646
+ const specifiers = new Set([...code.matchAll(ANGULAR_SPECIFIER_RE)].map((match) => match[1]));
3647
+ specifiers.forEach((specifier) => {
3648
+ if (!specifier)
3649
+ return;
3650
+ const resolved = resolveAngularRuntimePath(specifier);
3651
+ if (resolved === specifier)
3652
+ return;
3653
+ vendorPaths[specifier] = resolved;
3654
+ });
3655
+ return vendorPaths;
3656
+ }, buildAngularServerModule = async (sourcePath) => {
3657
+ const result = await Bun.build({
3658
+ entrypoints: [sourcePath],
3659
+ format: "esm",
3660
+ packages: "external",
3661
+ target: "bun",
3662
+ throw: false
3663
+ });
3664
+ const entry = result.outputs.find((output) => output.kind === "entry-point");
3665
+ if (!result.success || !entry) {
3666
+ const message = result.logs.map((log2) => String(log2)).join(`
3667
+ `);
3668
+ throw new Error(`Failed to compile Angular island server module for "${sourcePath}":
3669
+ ${message}`);
3670
+ }
3671
+ const code = await entry.text();
3672
+ const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
3673
+ const modulePath = getCachedModulePath2(sourcePath);
3674
+ await mkdir2(dirname3(modulePath), { recursive: true });
3675
+ await Bun.write(modulePath, rewritten);
3676
+ return modulePath;
3677
+ }, compileAngularServerModule = (sourcePath) => {
3678
+ const cached = compiledModuleCache2.get(sourcePath);
3679
+ if (cached) {
3680
+ return cached;
3681
+ }
3682
+ const compiledModulePromise = buildAngularServerModule(sourcePath);
3683
+ compiledModuleCache2.set(sourcePath, compiledModulePromise);
3684
+ return compiledModulePromise;
3685
+ };
3686
+ var init_angularServerModule = __esm(() => {
3687
+ init_resolveAngularPackage();
3688
+ init_rewriteImportsPlugin();
3689
+ serverCacheRoot2 = join6(process.cwd(), ".absolutejs", "islands", "angular");
3690
+ compiledModuleCache2 = new Map;
3691
+ ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
3692
+ });
3693
+
3694
+ // src/utils/vueCompiler.ts
3695
+ var createVueCompiler = async () => {
3696
+ const [compiler, typescript] = await Promise.all([
3697
+ import("@vue/compiler-sfc"),
3698
+ import("typescript")
3699
+ ]);
3700
+ compiler.registerTS?.(() => typescript);
3701
+ return compiler;
3702
+ }, compilerPromise, loadVueCompiler = () => {
3703
+ compilerPromise ??= createVueCompiler();
3704
+ return compilerPromise;
3705
+ };
3706
+
3707
+ // src/core/vueServerModule.ts
3708
+ import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync } from "fs";
3709
+ import { mkdir as mkdir3 } from "fs/promises";
3710
+ import { dirname as dirname4, join as join7, relative as relative4, resolve as resolve6 } from "path";
3711
+ var {Transpiler } = globalThis.Bun;
3712
+ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
3713
+ const importPath = relative4(dirname4(from), target).replace(/\\/g, "/");
3714
+ return importPath.startsWith(".") ? importPath : `./${importPath}`;
3715
+ }, getCachedModulePath3 = (sourcePath) => {
3716
+ const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
3717
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
3718
+ return join7(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
3719
+ }, writeIfChanged2 = async (path, content) => {
3720
+ const targetFile = Bun.file(path);
3721
+ if (await targetFile.exists()) {
3722
+ const currentContent = await targetFile.text();
3723
+ if (currentContent === content)
3724
+ return;
3725
+ }
3726
+ await Bun.write(path, content);
3727
+ }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
3728
+ const lines = code.split(`
3729
+ `);
3730
+ const specifierSet = new Set;
3731
+ const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
3732
+ lines.forEach((line) => {
3733
+ const match = line.match(vueImportRegex);
3734
+ if (match?.[1])
3735
+ match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
3736
+ });
3737
+ const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
3738
+ return specifierSet.size ? [
3739
+ `import { ${[...specifierSet].join(", ")} } from "vue";`,
3740
+ ...nonVueLines
3741
+ ].join(`
3742
+ `) : nonVueLines.join(`
3743
+ `);
3744
+ }, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
3745
+ const cachedModulePath = compiledModuleCache3.get(sourcePath);
3746
+ if (cachedModulePath)
3747
+ return cachedModulePath;
3748
+ const compiler = await loadVueCompiler();
3749
+ const source = await Bun.file(sourcePath).text();
3750
+ const { descriptor } = compiler.parse(source, { filename: sourcePath });
3751
+ const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
3752
+ const hasScript = descriptor.script || descriptor.scriptSetup;
3753
+ const compiledScript = hasScript ? compiler.compileScript(descriptor, {
3754
+ fs: {
3755
+ fileExists: existsSync4,
3756
+ realpath: realpathSync,
3757
+ readFile: (file) => existsSync4(file) ? readFileSync4(file, "utf-8") : undefined
3758
+ },
3759
+ id: componentId,
3760
+ inlineTemplate: false
2761
3761
  }) : { bindings: {}, content: "export default {};" };
2762
3762
  const renderCode = descriptor.template ? compiler.compileTemplate({
2763
3763
  compilerOptions: {
@@ -2775,7 +3775,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2775
3775
  }).code : "const ssrRender = () => {};";
2776
3776
  const childImportPaths = extractRelativeVueImports(compiledScript.content);
2777
3777
  const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
2778
- compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
3778
+ compiledPath: await compileVueServerModule(resolve6(dirname4(sourcePath), relativeImport)),
2779
3779
  spec: relativeImport
2780
3780
  })));
2781
3781
  const strippedScript = stripExports(compiledScript.content);
@@ -2787,20 +3787,20 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2787
3787
  "export default script;"
2788
3788
  ].join(`
2789
3789
  `));
2790
- const compiledModulePath = getCachedModulePath2(sourcePath);
3790
+ const compiledModulePath = getCachedModulePath3(sourcePath);
2791
3791
  let rewritten = assembled;
2792
3792
  for (const child of compiledChildren) {
2793
3793
  rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
2794
3794
  }
2795
- await mkdir2(dirname3(compiledModulePath), { recursive: true });
3795
+ await mkdir3(dirname4(compiledModulePath), { recursive: true });
2796
3796
  await writeIfChanged2(compiledModulePath, rewritten);
2797
- compiledModuleCache2.set(sourcePath, compiledModulePath);
3797
+ compiledModuleCache3.set(sourcePath, compiledModulePath);
2798
3798
  return compiledModulePath;
2799
3799
  };
2800
3800
  var init_vueServerModule = __esm(() => {
2801
3801
  init_constants();
2802
- serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
2803
- compiledModuleCache2 = new Map;
3802
+ serverCacheRoot3 = join7(process.cwd(), ".absolutejs", "islands", "vue");
3803
+ compiledModuleCache3 = new Map;
2804
3804
  transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
2805
3805
  });
2806
3806
 
@@ -2946,8 +3946,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2946
3946
  throw new Error("Resolved Vue island is not a valid Vue component.");
2947
3947
  }
2948
3948
  return resolvedComponent;
3949
+ }, loadAngularServerBuildComponent = async (buildReferencePath, exportName) => {
3950
+ const serverModulePath = await compileAngularServerModule(buildReferencePath);
3951
+ const loadedModule = await import(serverModulePath);
3952
+ if (exportName && exportName !== "default" && exportName in loadedModule) {
3953
+ return loadedModule[exportName];
3954
+ }
3955
+ return "default" in loadedModule ? loadedModule.default : loadedModule;
2949
3956
  }, resolveAngularServerIslandComponent = async (component) => {
2950
- const resolvedComponent = await resolveServerIslandComponent(component);
3957
+ const buildReference = getIslandBuildReference(component);
3958
+ const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
3959
+ const resolvedComponent = buildReferencePath ? await loadAngularServerBuildComponent(buildReferencePath, buildReference?.export) : await resolveServerIslandComponent(component);
2951
3960
  if (!isAngularServerIslandComponent(resolvedComponent)) {
2952
3961
  throw new Error("Resolved Angular island is not a valid Angular component.");
2953
3962
  }
@@ -3003,6 +4012,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
3003
4012
  };
3004
4013
  var init_renderIslandMarkup = __esm(() => {
3005
4014
  init_islandSsr();
4015
+ init_angularServerModule();
3006
4016
  init_svelteServerModule();
3007
4017
  init_vueServerModule();
3008
4018
  init_islandMarkupAttributes();
@@ -3134,7 +4144,6 @@ var runWithStreamingSlotRegistry = async (task) => {
3134
4144
  init_svelteServerModule();
3135
4145
 
3136
4146
  // src/core/islandPageContext.ts
3137
- init_constants();
3138
4147
  var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
3139
4148
  var ISLAND_MARKER = 'data-island="true"';
3140
4149
  var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
@@ -3255,61 +4264,69 @@ var pipeStreamWithHeadInjection = (stream, markup) => {
3255
4264
  var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
3256
4265
  const encoder = new TextEncoder;
3257
4266
  const decoder = new TextDecoder;
3258
- const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
3259
- const processPending = (controller, pending, injected) => {
3260
- if (injected) {
3261
- controller.enqueue(encoder.encode(pending));
3262
- return { injected, pending: "" };
4267
+ const headLookbehind = CLOSING_HEAD_TAG.length - 1;
4268
+ const enqueue = (controller, text) => {
4269
+ if (text.length > 0) {
4270
+ controller.enqueue(encoder.encode(text));
3263
4271
  }
3264
- const markerIndex = pending.indexOf(ISLAND_MARKER);
3265
- if (markerIndex >= 0) {
3266
- const tagStart = pending.lastIndexOf("<", markerIndex);
3267
- const injectAt = tagStart >= 0 ? tagStart : markerIndex;
3268
- const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
3269
- controller.enqueue(encoder.encode(next));
3270
- return { injected: true, pending: "" };
4272
+ };
4273
+ const processHolding = (controller, held) => {
4274
+ if (!held.includes(ISLAND_MARKER)) {
4275
+ return { held, injected: false, pending: "", sawHead: true };
3271
4276
  }
3272
- return {
3273
- injected,
3274
- pending: flushSafePendingText(controller, encoder, pending, lookbehind)
3275
- };
4277
+ enqueue(controller, `${markup}${held}`);
4278
+ return { held: "", injected: true, pending: "", sawHead: true };
3276
4279
  };
3277
- const finishIslandMarkerStream = (controller, pending) => {
3278
- const finalPending = pending + decoder.decode();
3279
- if (finalPending.length > 0) {
3280
- controller.enqueue(encoder.encode(finalPending));
4280
+ const processHead = (controller, pending) => {
4281
+ const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
4282
+ if (headIndex < 0) {
4283
+ return {
4284
+ held: "",
4285
+ injected: false,
4286
+ pending: flushSafePendingText(controller, encoder, pending, headLookbehind),
4287
+ sawHead: false
4288
+ };
3281
4289
  }
3282
- controller.close();
4290
+ enqueue(controller, pending.slice(0, headIndex));
4291
+ return processHolding(controller, pending.slice(headIndex));
3283
4292
  };
3284
- const consumeIslandChunk = async (controller, reader, pending, injected) => {
3285
- const { done, value } = await readStreamChunk(reader);
3286
- if (done || !value) {
3287
- return { done, injected, pending };
4293
+ const processChunk = (controller, state, chunk) => {
4294
+ if (state.injected) {
4295
+ enqueue(controller, chunk);
4296
+ return state;
3288
4297
  }
3289
- const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
3290
- return {
3291
- done,
3292
- injected: processed.injected,
3293
- pending: processed.pending
3294
- };
4298
+ if (!state.sawHead) {
4299
+ return processHead(controller, state.pending + chunk);
4300
+ }
4301
+ return processHolding(controller, state.held + chunk);
3295
4302
  };
3296
- const runIslandMarkerLoop = async (controller, reader) => {
3297
- const consumeNextIslandChunk = async (injected, pending) => {
3298
- const consumed = await consumeIslandChunk(controller, reader, pending, injected);
3299
- const nextState = updateInjectedState(consumed, injected, pending);
3300
- if (nextState.done) {
3301
- return { injected, pending };
4303
+ const finishMarkerStream = (controller, state) => {
4304
+ const tail = decoder.decode();
4305
+ const remainder = state.injected ? tail : (state.sawHead ? state.held : state.pending) + tail;
4306
+ enqueue(controller, remainder);
4307
+ controller.close();
4308
+ };
4309
+ const runMarkerLoop = (controller, reader) => {
4310
+ const consumeNext = async (state) => {
4311
+ const { done, value } = await readStreamChunk(reader);
4312
+ if (done || !value) {
4313
+ return state;
3302
4314
  }
3303
- return consumeNextIslandChunk(nextState.injected, nextState.pending);
4315
+ return consumeNext(processChunk(controller, state, streamChunkToString(value, decoder)));
3304
4316
  };
3305
- return consumeNextIslandChunk(false, "");
4317
+ return consumeNext({
4318
+ held: "",
4319
+ injected: false,
4320
+ pending: "",
4321
+ sawHead: false
4322
+ });
3306
4323
  };
3307
4324
  return new ReadableStream({
3308
4325
  async start(controller) {
3309
4326
  const reader = stream.getReader();
3310
4327
  try {
3311
- const { pending } = await runIslandMarkerLoop(controller, reader);
3312
- finishIslandMarkerStream(controller, pending);
4328
+ const finalState = await runMarkerLoop(controller, reader);
4329
+ finishMarkerStream(controller, finalState);
3313
4330
  } catch (error) {
3314
4331
  controller.error(error);
3315
4332
  }
@@ -3347,9 +4364,11 @@ var setCurrentIslandManifest = (manifest) => {
3347
4364
 
3348
4365
  // src/svelte/pageHandler.ts
3349
4366
  init_devRouteRegistrationCallsite();
4367
+ init_pageResponseCache();
3350
4368
 
3351
4369
  // src/core/responseEnhancers.ts
3352
4370
  init_streamingSlots();
4371
+ init_pageResponseCache();
3353
4372
  var toResponse = async (responseLike) => responseLike;
3354
4373
  var cloneHeaders = (response) => {
3355
4374
  const headers = new Headers(response.headers);
@@ -3373,8 +4392,10 @@ var enhanceHtmlResponseWithStreamingSlots = (response, {
3373
4392
  runtimePlacement,
3374
4393
  runtimePreludeScript
3375
4394
  });
4395
+ const headers = cloneHeaders(response);
4396
+ headers.set(STREAMING_PAGE_HEADER, "1");
3376
4397
  return new Response(body, {
3377
- headers: cloneHeaders(response),
4398
+ headers,
3378
4399
  status: response.status,
3379
4400
  statusText: response.statusText
3380
4401
  });
@@ -3454,303 +4475,11 @@ var captureStreamingSlotWarningCallsite = () => {
3454
4475
  return extractCallsiteFromStack(stack);
3455
4476
  };
3456
4477
  var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
3457
- // src/utils/resolveConvention.ts
3458
- import { basename as basename2 } from "path";
3459
- var CONVENTIONS_KEY = "__absoluteConventions";
3460
- var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
3461
- var getMap = () => {
3462
- const value = Reflect.get(globalThis, CONVENTIONS_KEY);
3463
- if (isConventionsMap(value))
3464
- return value;
3465
- const empty = {};
3466
- return empty;
3467
- };
3468
- var derivePageName = (pagePath) => {
3469
- const base = basename2(pagePath);
3470
- const dotIndex = base.indexOf(".");
3471
- const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
3472
- return toPascal(name);
3473
- };
3474
- var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
3475
- var resolveErrorConventionPath = (framework, pageName) => {
3476
- const conventions = getMap()[framework];
3477
- if (!conventions)
3478
- return;
3479
- const exact = conventions.pages?.[pageName]?.error;
3480
- if (exact)
3481
- return exact;
3482
- const normalizedPageName = normalizeConventionPageName(pageName);
3483
- for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
3484
- if (normalizeConventionPageName(candidate) === normalizedPageName) {
3485
- return page.error ?? conventions.defaults?.error;
3486
- }
3487
- }
3488
- return conventions.defaults?.error;
3489
- };
3490
- var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
3491
- var hasErrorConvention = (framework) => {
3492
- const conventions = getMap()[framework];
3493
- if (!conventions)
3494
- return false;
3495
- if (conventions.defaults?.error)
3496
- return true;
3497
- return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
3498
- };
3499
- var setConventions = (map) => {
3500
- Reflect.set(globalThis, CONVENTIONS_KEY, map);
3501
- };
3502
- var isDev = () => true;
3503
- var buildErrorProps = (error) => {
3504
- if (error instanceof Error) {
3505
- return {
3506
- name: error.name,
3507
- message: error.message,
3508
- ...isDev() && error.stack ? { stack: error.stack } : {}
3509
- };
3510
- }
3511
- return { name: "Error", message: String(error) };
3512
- };
3513
- var renderReactError = async (conventionPath, errorProps) => {
3514
- const { createElement } = await import("react");
3515
- const { renderToReadableStream } = await import("react-dom/server");
3516
- const mod = await import(conventionPath);
3517
- const ErrorComponent = mod.default;
3518
- if (typeof ErrorComponent !== "function")
3519
- return null;
3520
- const element = createElement(ErrorComponent, errorProps);
3521
- const stream = await renderToReadableStream(element);
3522
- return new Response(stream, {
3523
- headers: { "Content-Type": "text/html" },
3524
- status: 500
3525
- });
3526
- };
3527
- var renderSvelteError = async (conventionPath, errorProps) => {
3528
- const { render } = await import("svelte/server");
3529
- const mod = await import(conventionPath);
3530
- const ErrorComponent = mod.default;
3531
- if (!ErrorComponent)
3532
- return null;
3533
- const { head, body } = render(ErrorComponent, {
3534
- props: errorProps
3535
- });
3536
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3537
- return new Response(html, {
3538
- headers: { "Content-Type": "text/html" },
3539
- status: 500
3540
- });
3541
- };
3542
- var unescapeVueStyles = (ssrBody) => {
3543
- let styles = "";
3544
- const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
3545
- styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
3546
- return "";
3547
- });
3548
- return { body, styles };
3549
- };
3550
- var renderVueError = async (conventionPath, errorProps) => {
3551
- const { createSSRApp, h } = await import("vue");
3552
- const { renderToString } = await import("vue/server-renderer");
3553
- const mod = await import(conventionPath);
3554
- const ErrorComponent = mod.default;
3555
- if (!ErrorComponent)
3556
- return null;
3557
- const app = createSSRApp({
3558
- render: () => h(ErrorComponent, errorProps)
3559
- });
3560
- const rawBody = await renderToString(app);
3561
- const { styles, body } = unescapeVueStyles(rawBody);
3562
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
3563
- return new Response(html, {
3564
- headers: { "Content-Type": "text/html" },
3565
- status: 500
3566
- });
3567
- };
3568
- var renderAngularError = async (conventionPath, errorProps) => {
3569
- const mod = await import(conventionPath);
3570
- const renderFn = mod.default;
3571
- if (typeof renderFn !== "function")
3572
- return null;
3573
- const html = renderFn(errorProps);
3574
- return new Response(html, {
3575
- headers: { "Content-Type": "text/html" },
3576
- status: 500
3577
- });
3578
- };
3579
- var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3580
- var 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) : "");
3581
- var renderHtmlError = async (conventionPath, errorProps) => {
3582
- const template = await Bun.file(conventionPath).text();
3583
- const html = replaceErrorTokens(template, errorProps);
3584
- return new Response(html, {
3585
- headers: { "Content-Type": "text/html" },
3586
- status: 500
3587
- });
3588
- };
3589
- var logConventionRenderError = (framework, label, renderError) => {
3590
- const message = renderError instanceof Error ? renderError.message : "";
3591
- if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
3592
- 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}).`);
3593
- return;
3594
- }
3595
- console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
3596
- };
3597
- var renderEmberError = async () => null;
3598
- var renderEmberNotFound = async () => null;
3599
- var ERROR_RENDERERS = {
3600
- angular: renderAngularError,
3601
- ember: renderEmberError,
3602
- html: renderHtmlError,
3603
- react: renderReactError,
3604
- svelte: renderSvelteError,
3605
- vue: renderVueError
3606
- };
3607
- var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
3608
- let conventionPath = resolveErrorConventionPath(framework, pageName);
3609
- if (!conventionPath && error instanceof Error && error.stack) {
3610
- for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
3611
- const candidate = match[1];
3612
- if (!candidate)
3613
- continue;
3614
- conventionPath = resolveErrorConventionPath(framework, candidate);
3615
- if (conventionPath)
3616
- break;
3617
- }
3618
- }
3619
- if (!conventionPath)
3620
- return null;
3621
- const renderer = ERROR_RENDERERS[framework];
3622
- if (!renderer)
3623
- return null;
3624
- try {
3625
- return await renderer(conventionPath, errorProps);
3626
- } catch (renderError) {
3627
- logConventionRenderError(framework, "error", renderError);
3628
- }
3629
- return null;
3630
- };
3631
- var renderConventionError = async (framework, pageName, error) => {
3632
- const errorProps = buildErrorProps(error);
3633
- const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
3634
- if (frameworkResponse)
3635
- return frameworkResponse;
3636
- if (framework !== "html") {
3637
- const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
3638
- if (htmlResponse)
3639
- return htmlResponse;
3640
- }
3641
- return null;
3642
- };
3643
- var renderReactNotFound = async (conventionPath) => {
3644
- const { createElement } = await import("react");
3645
- const { renderToReadableStream } = await import("react-dom/server");
3646
- const mod = await import(conventionPath);
3647
- const NotFoundComponent = mod.default;
3648
- if (typeof NotFoundComponent !== "function")
3649
- return null;
3650
- const element = createElement(NotFoundComponent);
3651
- const stream = await renderToReadableStream(element);
3652
- return new Response(stream, {
3653
- headers: { "Content-Type": "text/html" },
3654
- status: 404
3655
- });
3656
- };
3657
- var renderSvelteNotFound = async (conventionPath) => {
3658
- const { render } = await import("svelte/server");
3659
- const mod = await import(conventionPath);
3660
- const NotFoundComponent = mod.default;
3661
- if (!NotFoundComponent)
3662
- return null;
3663
- const { head, body } = render(NotFoundComponent);
3664
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3665
- return new Response(html, {
3666
- headers: { "Content-Type": "text/html" },
3667
- status: 404
3668
- });
3669
- };
3670
- var renderVueNotFound = async (conventionPath) => {
3671
- const { createSSRApp, h } = await import("vue");
3672
- const { renderToString } = await import("vue/server-renderer");
3673
- const mod = await import(conventionPath);
3674
- const NotFoundComponent = mod.default;
3675
- if (!NotFoundComponent)
3676
- return null;
3677
- const app = createSSRApp({
3678
- render: () => h(NotFoundComponent)
3679
- });
3680
- const rawBody = await renderToString(app);
3681
- const { styles, body } = unescapeVueStyles(rawBody);
3682
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
3683
- return new Response(html, {
3684
- headers: { "Content-Type": "text/html" },
3685
- status: 404
3686
- });
3687
- };
3688
- var renderAngularNotFound = async (conventionPath) => {
3689
- const mod = await import(conventionPath);
3690
- const renderFn = mod.default;
3691
- if (typeof renderFn !== "function")
3692
- return null;
3693
- const html = renderFn();
3694
- return new Response(html, {
3695
- headers: { "Content-Type": "text/html" },
3696
- status: 404
3697
- });
3698
- };
3699
- var renderHtmlNotFound = async (conventionPath) => {
3700
- const html = await Bun.file(conventionPath).text();
3701
- return new Response(html, {
3702
- headers: { "Content-Type": "text/html" },
3703
- status: 404
3704
- });
3705
- };
3706
- var NOT_FOUND_RENDERERS = {
3707
- angular: renderAngularNotFound,
3708
- ember: renderEmberNotFound,
3709
- html: renderHtmlNotFound,
3710
- react: renderReactNotFound,
3711
- svelte: renderSvelteNotFound,
3712
- vue: renderVueNotFound
3713
- };
3714
- var renderConventionNotFound = async (framework) => {
3715
- const conventionPath = resolveNotFoundConventionPath(framework);
3716
- if (!conventionPath)
3717
- return null;
3718
- const renderer = NOT_FOUND_RENDERERS[framework];
3719
- if (!renderer)
3720
- return null;
3721
- try {
3722
- return await renderer(conventionPath);
3723
- } catch (renderError) {
3724
- logConventionRenderError(framework, "not-found", renderError);
3725
- }
3726
- return null;
3727
- };
3728
- var NOT_FOUND_PRIORITY = [
3729
- "react",
3730
- "svelte",
3731
- "vue",
3732
- "angular",
3733
- "html"
3734
- ];
3735
- var renderFirstNotFound = async () => {
3736
- const renderNext = async (frameworks) => {
3737
- const [framework, ...remaining] = frameworks;
3738
- if (!framework) {
3739
- return null;
3740
- }
3741
- if (!getMap()[framework]?.defaults?.notFound) {
3742
- return renderNext(remaining);
3743
- }
3744
- const response = await renderConventionNotFound(framework);
3745
- if (response) {
3746
- return response;
3747
- }
3748
- return renderNext(remaining);
3749
- };
3750
- return renderNext(NOT_FOUND_PRIORITY);
3751
- };
3752
4478
 
3753
4479
  // src/svelte/pageHandler.ts
4480
+ init_inlinePageCss();
4481
+ init_spaRouteManifest();
4482
+ init_resolveConvention();
3754
4483
  var isRecord2 = (value) => typeof value === "object" && value !== null;
3755
4484
  var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
3756
4485
  var readHasIslands = (value) => {
@@ -3767,9 +4496,8 @@ var primeSvelteStream = async (stream) => {
3767
4496
  };
3768
4497
  var restorePrimedStream = (firstChunk, reader) => new ReadableStream({
3769
4498
  start(controller) {
3770
- if (!firstChunk.done) {
4499
+ if (!firstChunk.done)
3771
4500
  controller.enqueue(firstChunk.value);
3772
- }
3773
4501
  if (firstChunk.done) {
3774
4502
  controller.close();
3775
4503
  return;
@@ -3796,11 +4524,14 @@ var handleSveltePageRequest = async (input) => {
3796
4524
  const resolvedPagePath = input.pagePath;
3797
4525
  const userProps = input.props;
3798
4526
  const requestPathname = resolveRequestPathname(input.request);
3799
- const resolvedProps = requestPathname !== undefined && (!userProps || !("url" in userProps)) ? {
4527
+ const resolvedProps = requestPathname !== undefined && (!isRecord2(userProps) || !("url" in userProps)) ? {
3800
4528
  ...userProps ?? {},
3801
4529
  url: requestPathname
3802
4530
  } : userProps;
3803
4531
  try {
4532
+ const spaNotFound = await renderSpaNotFound("svelte", derivePageName(resolvedPagePath), input.request);
4533
+ if (spaNotFound)
4534
+ return withPageCacheHeaders(spaNotFound, input.request);
3804
4535
  const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
3805
4536
  const renderPageResponse = async () => {
3806
4537
  const resolvePageComponent = async () => {
@@ -3831,33 +4562,40 @@ var handleSveltePageRequest = async (input) => {
3831
4562
  };
3832
4563
  const { renderToReadableStream: renderToReadableStream2 } = await Promise.resolve().then(() => (init_renderToReadableStream(), exports_renderToReadableStream));
3833
4564
  const resolvedPage = await resolvePageComponent();
4565
+ const siblingCss = await readSiblingCss(resolvedPagePath);
4566
+ const cssBlock = siblingCss ? `<style data-absolute-page-css>${siblingCss}</style>` : "";
4567
+ const composedHeadContent = `${cssBlock}${resolvedOptions?.headContent ?? ""}`;
3834
4568
  const stream = await renderToReadableStream2(resolvedPage.component, resolvedProps, {
3835
4569
  bodyContent: resolvedOptions?.bodyContent,
3836
4570
  bootstrapScriptContent: `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(resolvedProps)};${resolvedIndexPath ? `import(${JSON.stringify(resolvedIndexPath)});` : ""}`,
3837
- headContent: resolvedOptions?.headContent
4571
+ headContent: composedHeadContent
3838
4572
  });
3839
4573
  const htmlStream = injectIslandPageContextStream(stream, {
3840
4574
  hasIslands: resolvedPage.hasIslands ? true : undefined
3841
4575
  });
3842
4576
  const { firstChunk, reader } = await primeSvelteStream(htmlStream);
3843
4577
  return new Response(restorePrimedStream(firstChunk, reader), {
3844
- headers: { "Content-Type": "text/html" }
4578
+ headers: streamingPageHeaders()
3845
4579
  });
3846
4580
  };
3847
- return await runWithStreamingSlotWarningScope(() => resolvedOptions?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, {
4581
+ const pageResponse = await runWithStreamingSlotWarningScope(() => resolvedOptions?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, {
3848
4582
  ...resolvedOptions,
3849
4583
  runtimePlacement: resolvedOptions.runtimePlacement ?? "body"
3850
4584
  }) : renderPageResponse(), { handlerCallsite });
4585
+ return withPageCacheHeaders(pageResponse, input.request, {
4586
+ bufferStreamForEtag: input.bufferStreamForEtag
4587
+ });
3851
4588
  } catch (error) {
3852
4589
  console.error("[SSR] Svelte render error:", error);
3853
4590
  const pageName = derivePageName(resolvedPagePath);
3854
4591
  const conventionResponse = await renderConventionError("svelte", pageName, error);
3855
- if (conventionResponse)
3856
- return conventionResponse;
3857
- return new Response(ssrErrorPage("svelte", error), {
4592
+ if (conventionResponse) {
4593
+ return withPageCacheHeaders(conventionResponse, input.request);
4594
+ }
4595
+ return withPageCacheHeaders(new Response(ssrErrorPage("svelte", error), {
3858
4596
  headers: { "Content-Type": "text/html" },
3859
4597
  status: 500
3860
- });
4598
+ }), input.request);
3861
4599
  }
3862
4600
  };
3863
4601
  // src/svelte/createIsland.ts
@@ -4001,5 +4739,5 @@ export {
4001
4739
  createTypedIsland
4002
4740
  };
4003
4741
 
4004
- //# debugId=1EB769EB23D636D964756E2164756E21
4742
+ //# debugId=8B013C6A3D2007D964756E2164756E21
4005
4743
  //# sourceMappingURL=index.js.map