@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) {
@@ -78,25 +60,6 @@ var __legacyMetadataTS = (k, v) => {
78
60
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
79
61
  var __require = import.meta.require;
80
62
 
81
- // src/constants.ts
82
- 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;
83
- var init_constants = __esm(() => {
84
- IMAGE_DEFAULT_DEVICE_SIZES = [
85
- 640,
86
- 750,
87
- 828,
88
- 1080,
89
- 1200,
90
- 1920,
91
- 2048,
92
- 3840
93
- ];
94
- IMAGE_DEFAULT_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
95
- MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
96
- MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
97
- TWO_THIRDS = 2 / 3;
98
- });
99
-
100
63
  // src/core/devRouteRegistrationCallsite.ts
101
64
  var exports_devRouteRegistrationCallsite = {};
102
65
  __export(exports_devRouteRegistrationCallsite, {
@@ -107,22 +70,20 @@ __export(exports_devRouteRegistrationCallsite, {
107
70
  });
108
71
  import { AsyncLocalStorage } from "async_hooks";
109
72
  import { Elysia } from "elysia";
110
- var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
73
+ 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) => {
111
74
  const source = handler.toString();
112
75
  return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
76
+ }, getOriginalPageHandlerSource = (handler) => {
77
+ if (!isPageHandlerFunction(handler))
78
+ return;
79
+ const info = pageHandlerWrappers.get(handler);
80
+ return (info?.originalHandler ?? handler).toString();
113
81
  }, isPageHandler = (handler) => {
114
- if (typeof handler !== "function")
82
+ if (!isPageHandlerFunction(handler))
115
83
  return false;
116
- const fn = handler;
117
- if (pageHandlerWrappers.has(fn))
84
+ if (pageHandlerWrappers.has(handler))
118
85
  return true;
119
- return handlerSourceMentionsPageHelper(fn);
120
- }, getOriginalPageHandlerSource = (handler) => {
121
- if (typeof handler !== "function")
122
- return;
123
- const fn = handler;
124
- const info = pageHandlerWrappers.get(fn);
125
- return (info?.originalHandler ?? fn).toString();
86
+ return handlerSourceMentionsPageHelper(handler);
126
87
  }, 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 = () => {
127
88
  const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
128
89
  if (value === null || typeof value === "undefined") {
@@ -156,17 +117,22 @@ var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES,
156
117
  return function wrappedRouteHandler(...args) {
157
118
  return storage.run({ callsite }, () => Reflect.apply(routeHandler, this, args));
158
119
  };
159
- }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, handler, ...rest) {
120
+ }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, ...routeArguments) {
121
+ const handlerIndex = routeArguments.length >= 2 ? 1 : 0;
122
+ const handler = routeArguments[handlerIndex];
160
123
  const callsite = captureRouteRegistrationCallsite();
161
124
  const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
162
- if (methodName === "get" && typeof handler === "function" && typeof wrapped === "function" && handlerSourceMentionsPageHelper(handler)) {
125
+ if (methodName === "get" && isPageHandlerFunction(handler) && isPageHandlerFunction(wrapped) && handlerSourceMentionsPageHelper(handler)) {
163
126
  pageHandlerWrappers.set(wrapped, {
164
127
  originalHandler: handler
165
128
  });
166
129
  }
167
- return Reflect.apply(originalMethod, this, [path, wrapped, ...rest]);
130
+ routeArguments[handlerIndex] = wrapped;
131
+ return Reflect.apply(originalMethod, this, [path, ...routeArguments]);
168
132
  }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
169
- if (false) {}
133
+ if (process.env[NODE_ENV_KEY] === "production") {
134
+ return;
135
+ }
170
136
  if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
171
137
  return;
172
138
  }
@@ -203,6 +169,43 @@ var init_devRouteRegistrationCallsite = __esm(() => {
203
169
  pageHandlerWrappers = new WeakMap;
204
170
  });
205
171
 
172
+ // src/core/pageResponseCache.ts
173
+ import { createHash } from "crypto";
174
+ var STREAMING_PAGE_HEADER = "x-absolute-stream", HTML_CONTENT_TYPE = "text/html", streamingPageHeaders = (extra) => {
175
+ const headers = new Headers(extra);
176
+ headers.set("content-type", HTML_CONTENT_TYPE);
177
+ headers.set(STREAMING_PAGE_HEADER, "1");
178
+ return headers;
179
+ }, computeEtag = (html) => `W/"${createHash("sha1").update(html).digest("base64url")}"`, withPageCacheHeaders = async (response, request, options) => {
180
+ const contentType = response.headers.get("content-type") ?? "";
181
+ if (!contentType.includes(HTML_CONTENT_TYPE))
182
+ return response;
183
+ const isStreaming = response.headers.get(STREAMING_PAGE_HEADER) === "1";
184
+ if (isStreaming && !options?.bufferStreamForEtag || !response.body) {
185
+ response.headers.delete(STREAMING_PAGE_HEADER);
186
+ response.headers.set("cache-control", "no-cache");
187
+ return response;
188
+ }
189
+ const html = await response.text();
190
+ const etag = computeEtag(html);
191
+ if (request?.headers.get("if-none-match") === etag) {
192
+ return new Response(null, {
193
+ headers: { "cache-control": "no-cache", etag },
194
+ status: 304
195
+ });
196
+ }
197
+ const headers = new Headers(response.headers);
198
+ headers.delete(STREAMING_PAGE_HEADER);
199
+ headers.set("cache-control", "no-cache");
200
+ headers.set("etag", etag);
201
+ return new Response(html, {
202
+ headers,
203
+ status: response.status,
204
+ statusText: response.statusText
205
+ });
206
+ };
207
+ var init_pageResponseCache = () => {};
208
+
206
209
  // src/client/streamSwap.ts
207
210
  var streamSwapRuntime = () => {
208
211
  const absoluteWindow = window;
@@ -312,6 +315,26 @@ var streamSwapRuntime = () => {
312
315
  return value.slice(start + 1, end);
313
316
  }, getStreamSwapRuntimeScript = () => `(function(){${stripFunctionWrapper(streamSwapRuntime.toString())}})();`;
314
317
 
318
+ // src/constants.ts
319
+ 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;
320
+ var init_constants = __esm(() => {
321
+ TAILWIND_BUN_CSS_WARNING_PATTERN = /invalid @ rule encountered: '@(theme|tailwind|source|utility|variant|custom-variant|apply|reference|plugin|config)'/;
322
+ IMAGE_DEFAULT_DEVICE_SIZES = [
323
+ 640,
324
+ 750,
325
+ 828,
326
+ 1080,
327
+ 1200,
328
+ 1920,
329
+ 2048,
330
+ 3840
331
+ ];
332
+ IMAGE_DEFAULT_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
333
+ MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
334
+ MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
335
+ TWO_THIRDS = 2 / 3;
336
+ });
337
+
315
338
  // src/utils/escapeScriptContent.ts
316
339
  var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
317
340
  const escaped = ESCAPE_LOOKUP[char];
@@ -345,7 +368,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
345
368
  getStreamingSlotsRuntimeScript()
346
369
  ].filter(Boolean).join(";");
347
370
  return `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;
348
- }, toUint8 = (value, encoder) => encoder.encode(value), isRecord = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
371
+ }, toUint8 = (value, encoder) => encoder.encode(value), isRecord2 = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord2(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
349
372
  if (isSafeHtmlLike(value)) {
350
373
  return value.changingThisBreaksApplicationSecurity;
351
374
  }
@@ -406,7 +429,7 @@ var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG
406
429
  }, createTimeoutError = (slot, timeoutMs) => {
407
430
  const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
408
431
  return error;
409
- }, isSlotPatchPayloadObject = (value) => isRecord(value) && ("html" in value), isTimeoutError = (error) => isRecord(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
432
+ }, isSlotPatchPayloadObject = (value) => isRecord2(value) && ("html" in value), isTimeoutError = (error) => isRecord2(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
410
433
  errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
411
434
  fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
412
435
  id: slot.id ?? createStreamingSlotId(),
@@ -988,6 +1011,19 @@ var colors2, frameworkColors, formatPath = (filePath) => {
988
1011
  const errorMsg = error instanceof Error ? error.message : error;
989
1012
  const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
990
1013
  console.error(`${timestamp} ${tag} ${fullMessage}`);
1014
+ }, logHmrClientUpdate = (path, framework, duration, target, serverMs, clientMs, outcome = "applied", kind) => {
1015
+ const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1016
+ const targetLabel = target.startsWith("capacitor-") ? target.slice("capacitor-".length) : target;
1017
+ const tag = `${colors2.cyan}[hmr:${targetLabel}]${colors2.reset}`;
1018
+ const pathColor = framework ? getFrameworkColor(framework) : colors2.white;
1019
+ const breakdown = serverMs === undefined || clientMs === undefined ? "" : `; server ${serverMs}ms, client ${clientMs}ms`;
1020
+ let action = "failed after";
1021
+ if (outcome === "applied")
1022
+ action = "applied in";
1023
+ else if (outcome === "reloaded")
1024
+ action = "falling back to reload after";
1025
+ const kindLabel = kind ? `${kind} ` : "";
1026
+ console.log(`${timestamp} ${tag} ${framework ?? "update"} ${kindLabel}${pathColor}${formatPath(path)}${colors2.reset} ${colors2.dim}${action} ${duration}ms${breakdown}${colors2.reset}`);
991
1027
  }, logHmrUpdate = (path, framework, duration) => {
992
1028
  log("hmr update", { duration, framework, path });
993
1029
  }, logInfo = (message) => {
@@ -1091,98 +1127,435 @@ var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-
1091
1127
  return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
1092
1128
  };
1093
1129
 
1094
- // src/core/islandManifest.ts
1095
- var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
1096
- const entries = {};
1097
- let found = false;
1098
- for (const [key, value] of Object.entries(manifest)) {
1099
- if (!key.startsWith(prefix))
1100
- continue;
1101
- const component = key.slice(prefix.length);
1102
- if (!component)
1103
- continue;
1104
- entries[component] = value;
1105
- found = true;
1106
- }
1107
- return found ? entries : undefined;
1108
- }, getIslandManifestEntries = (manifest) => {
1109
- const islands = {};
1110
- const frameworks = ["react", "svelte", "vue", "angular"];
1111
- for (const framework of frameworks) {
1112
- const prefix = `Island${toIslandFrameworkSegment(framework)}`;
1113
- const entries = collectFrameworkIslands(manifest, prefix);
1114
- if (entries)
1115
- islands[framework] = entries;
1130
+ // src/utils/resolveConvention.ts
1131
+ import { basename } from "path";
1132
+ var CONVENTIONS_KEY = "__absoluteConventions", isConventionsMap = (value) => Boolean(value) && typeof value === "object", getMap = () => {
1133
+ const value = Reflect.get(globalThis, CONVENTIONS_KEY);
1134
+ if (isConventionsMap(value))
1135
+ return value;
1136
+ const empty = {};
1137
+ return empty;
1138
+ }, derivePageName = (pagePath) => {
1139
+ const base = basename(pagePath);
1140
+ const dotIndex = base.indexOf(".");
1141
+ const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
1142
+ return toPascal(name);
1143
+ }, normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, ""), hasErrorConvention = (framework) => {
1144
+ const conventions = getMap()[framework];
1145
+ if (!conventions)
1146
+ return false;
1147
+ if (conventions.defaults?.error)
1148
+ return true;
1149
+ return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
1150
+ }, resolveErrorConventionPath = (framework, pageName) => {
1151
+ const conventions = getMap()[framework];
1152
+ if (!conventions)
1153
+ return;
1154
+ const exact = conventions.pages?.[pageName]?.error;
1155
+ if (exact)
1156
+ return exact;
1157
+ const normalizedPageName = normalizeConventionPageName(pageName);
1158
+ for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
1159
+ if (normalizeConventionPageName(candidate) === normalizedPageName) {
1160
+ return page.error ?? conventions.defaults?.error;
1161
+ }
1116
1162
  }
1117
- return islands;
1118
- }, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
1119
-
1120
- // src/core/islands.ts
1121
- function getIslandComponent(component) {
1122
- if (isIslandComponentDefinition(component)) {
1123
- return component.component;
1163
+ return conventions.defaults?.error;
1164
+ }, resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound, setConventions = (map) => {
1165
+ Reflect.set(globalThis, CONVENTIONS_KEY, map);
1166
+ }, isDev = () => true, buildErrorProps = (error) => {
1167
+ if (error instanceof Error) {
1168
+ return {
1169
+ message: error.message,
1170
+ name: error.name,
1171
+ ...isDev() && error.stack ? { stack: error.stack } : {}
1172
+ };
1124
1173
  }
1125
- return component;
1126
- }
1127
- var defineIslandComponent = (component, options) => ({
1128
- component,
1129
- export: options.export,
1130
- source: options.source
1131
- }), defineIslandRegistry = (registry) => registry, isRecord2 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
1132
- if (!isIslandComponentDefinition(component))
1174
+ return { message: String(error), name: "Error" };
1175
+ }, renderReactError = async (conventionPath, errorProps) => {
1176
+ const { createElement } = await import("react");
1177
+ const { renderToReadableStream } = await import("react-dom/server");
1178
+ const mod = await import(conventionPath);
1179
+ const ErrorComponent = mod.default;
1180
+ if (typeof ErrorComponent !== "function")
1133
1181
  return null;
1134
- return {
1135
- export: component.export,
1136
- source: component.source
1137
- };
1138
- }, isIslandComponentDefinition = (value) => isRecord2(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
1139
- if (!rawProps)
1140
- return {};
1141
- return JSON.parse(rawProps);
1142
- }, serializeIslandProps = (props) => JSON.stringify(props ?? {});
1143
- var init_islands = () => {};
1144
-
1145
- // src/core/islandMarkupAttributes.ts
1146
- var getIslandMarkerAttributes = (props, islandId) => ({
1147
- "data-component": props.component,
1148
- "data-framework": props.framework,
1149
- "data-hydrate": props.hydrate ?? "load",
1150
- "data-island": "true",
1151
- ...islandId ? { "data-island-id": islandId } : {},
1152
- "data-props": serializeIslandProps(props.props)
1153
- }), escapeHtmlAttribute = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
1154
- var init_islandMarkupAttributes = __esm(() => {
1155
- init_islands();
1156
- });
1157
-
1158
- // src/core/currentIslandRegistry.ts
1159
- var requireCurrentIslandRegistry = () => {
1160
- const registry = globalThis.__absoluteIslandRegistry;
1161
- if (!registry) {
1162
- throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
1163
- }
1164
- return registry;
1165
- }, setCurrentIslandRegistry = (registry) => {
1166
- globalThis.__absoluteIslandRegistry = registry;
1167
- };
1168
-
1169
- // src/angular/resolveAngularPackage.ts
1170
- import { existsSync, readFileSync } from "fs";
1171
- import { join, resolve } from "path";
1172
- var resolveAngularPackageDir = (specifier) => {
1173
- const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
1174
- if (fromCompiledRuntime && existsSync(fromCompiledRuntime)) {
1175
- return fromCompiledRuntime;
1182
+ const element = createElement(ErrorComponent, errorProps);
1183
+ const stream = await renderToReadableStream(element);
1184
+ return new Response(stream, {
1185
+ headers: { "Content-Type": "text/html" },
1186
+ status: 500
1187
+ });
1188
+ }, renderSvelteError = async (conventionPath, errorProps) => {
1189
+ const { render } = await import("svelte/server");
1190
+ const mod = await import(conventionPath);
1191
+ const ErrorComponent = mod.default;
1192
+ if (!ErrorComponent)
1193
+ return null;
1194
+ const { head, body } = render(ErrorComponent, {
1195
+ props: errorProps
1196
+ });
1197
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
1198
+ return new Response(html, {
1199
+ headers: { "Content-Type": "text/html" },
1200
+ status: 500
1201
+ });
1202
+ }, unescapeVueStyles = (ssrBody) => {
1203
+ let styles = "";
1204
+ const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
1205
+ styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
1206
+ return "";
1207
+ });
1208
+ return { body, styles };
1209
+ }, renderVueError = async (conventionPath, errorProps) => {
1210
+ const { createSSRApp, h } = await import("vue");
1211
+ const { renderToString } = await import("vue/server-renderer");
1212
+ const mod = await import(conventionPath);
1213
+ const ErrorComponent = mod.default;
1214
+ if (!ErrorComponent)
1215
+ return null;
1216
+ const app = createSSRApp({
1217
+ render: () => h(ErrorComponent, errorProps)
1218
+ });
1219
+ const rawBody = await renderToString(app);
1220
+ const { styles, body } = unescapeVueStyles(rawBody);
1221
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
1222
+ return new Response(html, {
1223
+ headers: { "Content-Type": "text/html" },
1224
+ status: 500
1225
+ });
1226
+ }, renderAngularError = async (conventionPath, errorProps) => {
1227
+ const mod = await import(conventionPath);
1228
+ const renderFn = mod.default;
1229
+ if (typeof renderFn !== "function")
1230
+ return null;
1231
+ const html = renderFn(errorProps);
1232
+ return new Response(html, {
1233
+ headers: { "Content-Type": "text/html" },
1234
+ status: 500
1235
+ });
1236
+ }, 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) => {
1237
+ const template = await Bun.file(conventionPath).text();
1238
+ const html = replaceErrorTokens(template, errorProps);
1239
+ return new Response(html, {
1240
+ headers: { "Content-Type": "text/html" },
1241
+ status: 500
1242
+ });
1243
+ }, logConventionRenderError = (framework, label, renderError) => {
1244
+ const message = renderError instanceof Error ? renderError.message : "";
1245
+ if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
1246
+ 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}).`);
1247
+ return;
1176
1248
  }
1177
- const fromProject = resolve(process.cwd(), "node_modules", specifier);
1178
- if (existsSync(fromProject)) {
1179
- return fromProject;
1249
+ console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
1250
+ }, renderEmberError = async () => null, renderEmberNotFound = async () => null, ERROR_RENDERERS, tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
1251
+ let conventionPath = resolveErrorConventionPath(framework, pageName);
1252
+ if (!conventionPath && error instanceof Error && error.stack) {
1253
+ for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
1254
+ const [, candidate] = match;
1255
+ if (!candidate)
1256
+ continue;
1257
+ conventionPath = resolveErrorConventionPath(framework, candidate);
1258
+ if (conventionPath)
1259
+ break;
1260
+ }
1180
1261
  }
1181
- return null;
1182
- }, resolvePackageEntry = (packageDir) => {
1183
- try {
1184
- const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"));
1185
- const rootExport = pkg.exports?.["."];
1262
+ if (!conventionPath)
1263
+ return null;
1264
+ const renderer = ERROR_RENDERERS[framework];
1265
+ if (!renderer)
1266
+ return null;
1267
+ try {
1268
+ return await renderer(conventionPath, errorProps);
1269
+ } catch (renderError) {
1270
+ logConventionRenderError(framework, "error", renderError);
1271
+ }
1272
+ return null;
1273
+ }, renderConventionError = async (framework, pageName, error) => {
1274
+ const errorProps = buildErrorProps(error);
1275
+ const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
1276
+ if (frameworkResponse)
1277
+ return frameworkResponse;
1278
+ if (framework !== "html") {
1279
+ const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
1280
+ if (htmlResponse)
1281
+ return htmlResponse;
1282
+ }
1283
+ return null;
1284
+ }, renderReactNotFound = async (conventionPath) => {
1285
+ const { createElement } = await import("react");
1286
+ const { renderToReadableStream } = await import("react-dom/server");
1287
+ const mod = await import(conventionPath);
1288
+ const NotFoundComponent = mod.default;
1289
+ if (typeof NotFoundComponent !== "function")
1290
+ return null;
1291
+ const element = createElement(NotFoundComponent);
1292
+ const stream = await renderToReadableStream(element);
1293
+ return new Response(stream, {
1294
+ headers: { "Content-Type": "text/html" },
1295
+ status: 404
1296
+ });
1297
+ }, renderSvelteNotFound = async (conventionPath) => {
1298
+ const { render } = await import("svelte/server");
1299
+ const mod = await import(conventionPath);
1300
+ const NotFoundComponent = mod.default;
1301
+ if (!NotFoundComponent)
1302
+ return null;
1303
+ const { head, body } = render(NotFoundComponent);
1304
+ const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
1305
+ return new Response(html, {
1306
+ headers: { "Content-Type": "text/html" },
1307
+ status: 404
1308
+ });
1309
+ }, renderVueNotFound = async (conventionPath) => {
1310
+ const { createSSRApp, h } = await import("vue");
1311
+ const { renderToString } = await import("vue/server-renderer");
1312
+ const mod = await import(conventionPath);
1313
+ const NotFoundComponent = mod.default;
1314
+ if (!NotFoundComponent)
1315
+ return null;
1316
+ const app = createSSRApp({
1317
+ render: () => h(NotFoundComponent)
1318
+ });
1319
+ const rawBody = await renderToString(app);
1320
+ const { styles, body } = unescapeVueStyles(rawBody);
1321
+ const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
1322
+ return new Response(html, {
1323
+ headers: { "Content-Type": "text/html" },
1324
+ status: 404
1325
+ });
1326
+ }, renderAngularNotFound = async (conventionPath) => {
1327
+ const mod = await import(conventionPath);
1328
+ const renderFn = mod.default;
1329
+ if (typeof renderFn !== "function")
1330
+ return null;
1331
+ const html = renderFn();
1332
+ return new Response(html, {
1333
+ headers: { "Content-Type": "text/html" },
1334
+ status: 404
1335
+ });
1336
+ }, renderHtmlNotFound = async (conventionPath) => {
1337
+ const html = await Bun.file(conventionPath).text();
1338
+ return new Response(html, {
1339
+ headers: { "Content-Type": "text/html" },
1340
+ status: 404
1341
+ });
1342
+ }, NOT_FOUND_RENDERERS, renderConventionNotFound = async (framework) => {
1343
+ const conventionPath = resolveNotFoundConventionPath(framework);
1344
+ if (!conventionPath)
1345
+ return null;
1346
+ const renderer = NOT_FOUND_RENDERERS[framework];
1347
+ if (!renderer)
1348
+ return null;
1349
+ try {
1350
+ return await renderer(conventionPath);
1351
+ } catch (renderError) {
1352
+ logConventionRenderError(framework, "not-found", renderError);
1353
+ }
1354
+ return null;
1355
+ }, NOT_FOUND_PRIORITY, renderFirstNotFound = async () => {
1356
+ const renderNext = async (frameworks2) => {
1357
+ const [framework, ...remaining] = frameworks2;
1358
+ if (!framework) {
1359
+ return null;
1360
+ }
1361
+ if (!getMap()[framework]?.defaults?.notFound) {
1362
+ return renderNext(remaining);
1363
+ }
1364
+ const response = await renderConventionNotFound(framework);
1365
+ if (response) {
1366
+ return response;
1367
+ }
1368
+ return renderNext(remaining);
1369
+ };
1370
+ return renderNext(NOT_FOUND_PRIORITY);
1371
+ };
1372
+ var init_resolveConvention = __esm(() => {
1373
+ ERROR_RENDERERS = {
1374
+ angular: renderAngularError,
1375
+ ember: renderEmberError,
1376
+ html: renderHtmlError,
1377
+ react: renderReactError,
1378
+ svelte: renderSvelteError,
1379
+ vue: renderVueError
1380
+ };
1381
+ NOT_FOUND_RENDERERS = {
1382
+ angular: renderAngularNotFound,
1383
+ ember: renderEmberNotFound,
1384
+ html: renderHtmlNotFound,
1385
+ react: renderReactNotFound,
1386
+ svelte: renderSvelteNotFound,
1387
+ vue: renderVueNotFound
1388
+ };
1389
+ NOT_FOUND_PRIORITY = [
1390
+ "react",
1391
+ "svelte",
1392
+ "vue",
1393
+ "angular",
1394
+ "html"
1395
+ ];
1396
+ });
1397
+
1398
+ // src/utils/spaRouteManifest.ts
1399
+ import { basename as basename2 } from "path";
1400
+ var SPA_ROUTES_KEY = "__absoluteSpaRoutes", setSpaRouteManifest = (hosts) => {
1401
+ Reflect.set(globalThis, SPA_ROUTES_KEY, hosts);
1402
+ }, isRuntimeSpaHost = (value) => typeof value === "object" && value !== null && typeof Reflect.get(value, "framework") === "string", getSpaRouteManifest = () => {
1403
+ const value = Reflect.get(globalThis, SPA_ROUTES_KEY);
1404
+ return Array.isArray(value) ? value.filter(isRuntimeSpaHost) : [];
1405
+ }, normalizePath = (path) => {
1406
+ const withLeadingSlash = path.startsWith("/") ? path : `/${path}`;
1407
+ const trimmed = withLeadingSlash.replace(/\/+$/, "");
1408
+ return trimmed || "/";
1409
+ }, fullRoutePath = (baseHref, routePath) => {
1410
+ const base = normalizePath(baseHref);
1411
+ const route = normalizePath(routePath);
1412
+ if (base !== "/" && (route === base || route.startsWith(`${base}/`))) {
1413
+ return route;
1414
+ }
1415
+ if (base === "/")
1416
+ return route;
1417
+ return normalizePath(`${base}/${route.replace(/^\/+/, "")}`);
1418
+ }, routePattern = (path) => {
1419
+ const segments = normalizePath(path).split("/").filter(Boolean);
1420
+ let expression = "^";
1421
+ for (const segment of segments) {
1422
+ if (segment === "*" || segment === "**") {
1423
+ expression += "(?:/.*)?";
1424
+ continue;
1425
+ }
1426
+ const parameter = /^:[A-Za-z_$][A-Za-z0-9_$]*(?:\((.*)\))?(\?)?$/.exec(segment);
1427
+ if (parameter) {
1428
+ const valuePattern = parameter[1] || "[^/]+";
1429
+ expression += parameter[2] ? `(?:/${valuePattern})?` : `/${valuePattern}`;
1430
+ continue;
1431
+ }
1432
+ expression += `/${segment.replace(/[.+?^${}()|[\]\\]/g, "\\$&")}`;
1433
+ }
1434
+ return new RegExp(`${expression || "^/"}/?$`);
1435
+ }, sourcePageName = (sourceFile) => basename2(sourceFile).replace(/\.[^.]+$/, "").toLowerCase(), isKnownSpaRoute = (framework, pageName, request) => {
1436
+ if (!request)
1437
+ return true;
1438
+ let pathname;
1439
+ try {
1440
+ pathname = normalizePath(new URL(request.url).pathname);
1441
+ } catch {
1442
+ return true;
1443
+ }
1444
+ const hosts = getSpaRouteManifest().filter((host) => {
1445
+ if (host.framework !== framework)
1446
+ return false;
1447
+ if (sourcePageName(host.sourceFile) !== pageName.toLowerCase())
1448
+ return false;
1449
+ const base = normalizePath(host.baseHref);
1450
+ return base === "/" || pathname === base || pathname.startsWith(`${base}/`);
1451
+ });
1452
+ if (hosts.length === 0)
1453
+ return true;
1454
+ return hosts.some((host) => host.routes.some((route) => routePattern(fullRoutePath(host.baseHref, route.path)).test(pathname)));
1455
+ }, renderSpaNotFound = async (framework, pageName, request) => {
1456
+ if (isKnownSpaRoute(framework, pageName, request))
1457
+ return null;
1458
+ return await renderFirstNotFound() ?? new Response("Not found", {
1459
+ headers: { "Content-Type": "text/plain" },
1460
+ status: 404
1461
+ });
1462
+ };
1463
+ var init_spaRouteManifest = __esm(() => {
1464
+ init_resolveConvention();
1465
+ });
1466
+
1467
+ // src/core/islandManifest.ts
1468
+ var toIslandFrameworkSegment = (framework) => framework[0]?.toUpperCase() + framework.slice(1), collectFrameworkIslands = (manifest, prefix) => {
1469
+ const entries = {};
1470
+ let found = false;
1471
+ for (const [key, value] of Object.entries(manifest)) {
1472
+ if (!key.startsWith(prefix))
1473
+ continue;
1474
+ const component = key.slice(prefix.length);
1475
+ if (!component)
1476
+ continue;
1477
+ entries[component] = value;
1478
+ found = true;
1479
+ }
1480
+ return found ? entries : undefined;
1481
+ }, getIslandManifestEntries = (manifest) => {
1482
+ const islands = {};
1483
+ const frameworks2 = ["react", "svelte", "vue", "angular"];
1484
+ for (const framework of frameworks2) {
1485
+ const prefix = `Island${toIslandFrameworkSegment(framework)}`;
1486
+ const entries = collectFrameworkIslands(manifest, prefix);
1487
+ if (entries)
1488
+ islands[framework] = entries;
1489
+ }
1490
+ return islands;
1491
+ }, getIslandManifestKey = (framework, component) => `Island${toIslandFrameworkSegment(framework)}${component}`;
1492
+
1493
+ // src/core/islands.ts
1494
+ function getIslandComponent(component) {
1495
+ if (isIslandComponentDefinition(component)) {
1496
+ return component.component;
1497
+ }
1498
+ return component;
1499
+ }
1500
+ var defineIslandComponent = (component, options) => ({
1501
+ component,
1502
+ export: options.export,
1503
+ source: options.source
1504
+ }), defineIslandRegistry = (registry) => registry, isRecord3 = (value) => typeof value === "object" && value !== null, getIslandBuildReference = (component) => {
1505
+ if (!isIslandComponentDefinition(component))
1506
+ return null;
1507
+ return {
1508
+ export: component.export,
1509
+ source: component.source
1510
+ };
1511
+ }, isIslandComponentDefinition = (value) => isRecord3(value) && ("component" in value) && ("source" in value) && typeof value.source === "string", parseIslandProps = (rawProps) => {
1512
+ if (!rawProps)
1513
+ return {};
1514
+ return JSON.parse(rawProps);
1515
+ }, serializeIslandProps = (props) => JSON.stringify(props ?? {});
1516
+ var init_islands = () => {};
1517
+
1518
+ // src/core/islandMarkupAttributes.ts
1519
+ var getIslandMarkerAttributes = (props, islandId) => ({
1520
+ "data-component": props.component,
1521
+ "data-framework": props.framework,
1522
+ "data-hydrate": props.hydrate ?? "load",
1523
+ "data-island": "true",
1524
+ ...islandId ? { "data-island-id": islandId } : {},
1525
+ "data-props": serializeIslandProps(props.props)
1526
+ }), escapeHtmlAttribute = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("<", "&lt;").replaceAll(">", "&gt;"), serializeIslandAttributes = (attributes) => Object.entries(attributes).map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`).join(" ");
1527
+ var init_islandMarkupAttributes = __esm(() => {
1528
+ init_islands();
1529
+ });
1530
+
1531
+ // src/core/currentIslandRegistry.ts
1532
+ var requireCurrentIslandRegistry = () => {
1533
+ const registry = globalThis.__absoluteIslandRegistry;
1534
+ if (!registry) {
1535
+ throw new Error("No island registry is active. Configure `islands.registry` in absolute.config.ts before rendering <Island />.");
1536
+ }
1537
+ return registry;
1538
+ }, setCurrentIslandRegistry = (registry) => {
1539
+ globalThis.__absoluteIslandRegistry = registry;
1540
+ };
1541
+
1542
+ // src/angular/resolveAngularPackage.ts
1543
+ import { existsSync, readFileSync } from "fs";
1544
+ import { join, resolve } from "path";
1545
+ var resolveAngularPackageDir = (specifier) => {
1546
+ const fromCompiledRuntime = process.env.ABSOLUTE_BUILD_DIR ? resolve(process.env.ABSOLUTE_BUILD_DIR, "node_modules", specifier) : null;
1547
+ if (fromCompiledRuntime && existsSync(fromCompiledRuntime)) {
1548
+ return fromCompiledRuntime;
1549
+ }
1550
+ const fromProject = resolve(process.cwd(), "node_modules", specifier);
1551
+ if (existsSync(fromProject)) {
1552
+ return fromProject;
1553
+ }
1554
+ return null;
1555
+ }, resolvePackageEntry = (packageDir) => {
1556
+ try {
1557
+ const pkg = JSON.parse(readFileSync(join(packageDir, "package.json"), "utf-8"));
1558
+ const rootExport = pkg.exports?.["."];
1186
1559
  const entry = (typeof rootExport === "string" ? rootExport : rootExport?.default) ?? pkg.module ?? pkg.main ?? "index.js";
1187
1560
  return join(packageDir, entry);
1188
1561
  } catch {
@@ -1208,7 +1581,7 @@ var resolveAngularPackageDir = (specifier) => {
1208
1581
  var init_resolveAngularPackage = () => {};
1209
1582
 
1210
1583
  // src/utils/runtimeMode.ts
1211
- var ENV_VAR = "NODE_ENV", isProductionRuntime = () => process.env[ENV_VAR] === "production", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development";
1584
+ var ENV_VAR = "NODE_ENV", isDevelopmentRuntime = () => process.env[ENV_VAR] === "development", isProductionRuntime = () => process.env[ENV_VAR] === "production";
1212
1585
 
1213
1586
  // src/angular/angularPatch.ts
1214
1587
  var exports_angularPatch = {};
@@ -1300,7 +1673,14 @@ var ensureHead = (doc) => {
1300
1673
  }
1301
1674
  try {
1302
1675
  const adapter = new \u{275}DominoAdapter;
1303
- const seedDoc = typeof adapter.createHtmlDocument === "function" ? adapter.createHtmlDocument() : typeof adapter.getDefaultDocument === "function" ? adapter.getDefaultDocument() : null;
1676
+ const resolveSeedDoc = () => {
1677
+ if (typeof adapter.createHtmlDocument === "function")
1678
+ return adapter.createHtmlDocument();
1679
+ if (typeof adapter.getDefaultDocument === "function")
1680
+ return adapter.getDefaultDocument();
1681
+ return null;
1682
+ };
1683
+ const seedDoc = resolveSeedDoc();
1304
1684
  if (seedDoc) {
1305
1685
  patchElementLayout(seedDoc);
1306
1686
  const probe = seedDoc.createElement("div");
@@ -1379,9 +1759,12 @@ var initDominoAdapter = (platformServer) => {
1379
1759
  return {
1380
1760
  APP_BASE_HREF: common.APP_BASE_HREF,
1381
1761
  bootstrapApplication: platformBrowser.bootstrapApplication,
1762
+ Component: core.Component,
1382
1763
  DomSanitizer: platformBrowser.DomSanitizer,
1383
1764
  ENVIRONMENT_INITIALIZER: core.ENVIRONMENT_INITIALIZER,
1384
1765
  inject: core.inject,
1766
+ InjectionToken: core.InjectionToken,
1767
+ NgComponentOutlet: common.NgComponentOutlet,
1385
1768
  provideClientHydration: platformBrowser.provideClientHydration,
1386
1769
  provideServerRendering: platformServer.provideServerRendering,
1387
1770
  provideZonelessChangeDetection: core.provideZonelessChangeDetection,
@@ -1583,7 +1966,7 @@ __export(exports_islands, {
1583
1966
  isAngularComponent: () => isAngularComponent,
1584
1967
  getAngularIslandSelector: () => getAngularIslandSelector
1585
1968
  });
1586
- var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) => typeof value === "function", getAngularIslandSelector = (_islandId) => angularIslandSelector, getSelectorFromRenderedIsland = (rootElement) => {
1969
+ var angularIslandSelector = "abs-angular-island", getAngularIslandSelector = (_islandId) => angularIslandSelector, isAngularComponent = (value) => typeof value === "function", getSelectorFromRenderedIsland = (rootElement) => {
1587
1970
  const firstChild = rootElement.firstElementChild;
1588
1971
  if (!(firstChild instanceof HTMLElement)) {
1589
1972
  return null;
@@ -1637,9 +2020,8 @@ var angularIslandSelector = "abs-angular-island", isAngularComponent = (value) =
1637
2020
  const componentName = typeof component.name === "string" && component.name.length > 0 ? component.name : "AngularIsland";
1638
2021
  return `${componentName}:${JSON.stringify(props)}`;
1639
2022
  }, buildAngularIslandWrapperMetadata = async (component, islandId, wrapperKey) => {
1640
- const { Component, InjectionToken, inject } = await import("@angular/core");
1641
- const { NgComponentOutlet } = await import("@angular/common");
1642
2023
  const deps = await getAngularDeps();
2024
+ const { Component, InjectionToken, NgComponentOutlet, inject } = deps;
1643
2025
  const selector = getAngularIslandSelector(islandId);
1644
2026
  const propsToken = new InjectionToken(`${wrapperKey}:props`);
1645
2027
 
@@ -1745,7 +2127,15 @@ var init_islands2 = __esm(() => {
1745
2127
  var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
1746
2128
  const { renderAngularIslandToHtml: renderAngularIslandToHtml2 } = await Promise.resolve().then(() => (init_islands2(), exports_islands));
1747
2129
  return renderAngularIslandToHtml2(component, props, islandId);
1748
- }, 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 }) => {
2130
+ }, renderAngularIslandToHtml2, LEADING_HOISTED_RESOURCE_RE, stripLeadingHoistedResources = (html) => {
2131
+ let result = html;
2132
+ let match = LEADING_HOISTED_RESOURCE_RE.exec(result);
2133
+ while (match) {
2134
+ result = result.slice(match[0].length);
2135
+ match = LEADING_HOISTED_RESOURCE_RE.exec(result);
2136
+ }
2137
+ return result.trimStart();
2138
+ }, 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 }) => {
1749
2139
  const { body } = render(component, { props });
1750
2140
  return body;
1751
2141
  }), renderVueIslandToHtml = (component, props) => import("vue").then(({ createSSRApp, h: createVueVNode }) => {
@@ -1756,56 +2146,622 @@ var renderAngularIslandToHtmlInternal = async (component, props, islandId) => {
1756
2146
  });
1757
2147
  var init_islandSsr = __esm(() => {
1758
2148
  renderAngularIslandToHtml2 = renderAngularIslandToHtmlInternal;
2149
+ 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;
1759
2150
  });
1760
2151
 
1761
- // src/build/resolvePackageImport.ts
1762
- import { resolve as resolve2, join as join2 } from "path";
1763
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
1764
- var resolveExportPath = (entry, conditions) => {
1765
- if (typeof entry === "string")
1766
- return entry;
1767
- if (!entry || typeof entry !== "object")
1768
- return null;
1769
- for (const condition of conditions) {
1770
- const target = Reflect.get(entry, condition);
1771
- if (typeof target === "string") {
1772
- return target;
2152
+ // src/build/maskLiterals.ts
2153
+ var SENTINEL, RISKY_STRING_CONTENT, isIdentChar = (c) => /[A-Za-z0-9_$]/.test(c), REGEX_OK_AFTER_CHAR, REGEX_OK_AFTER_WORD, maskLiterals = (src) => {
2154
+ const n = src.length;
2155
+ const pieces = [];
2156
+ let out = "";
2157
+ let i = 0;
2158
+ let prevChar = "";
2159
+ let prevWord = "";
2160
+ let prevWasSpace = false;
2161
+ const mask = (text) => {
2162
+ out += SENTINEL + pieces.length + SENTINEL;
2163
+ pieces.push(text);
2164
+ prevChar = ")";
2165
+ prevWord = "";
2166
+ prevWasSpace = false;
2167
+ };
2168
+ const endOfString = (start) => {
2169
+ const q = src[start];
2170
+ let j = start + 1;
2171
+ while (j < n) {
2172
+ const c = src[j];
2173
+ if (c === "\\") {
2174
+ j += 2;
2175
+ continue;
2176
+ }
2177
+ if (c === q)
2178
+ return j + 1;
2179
+ if (c === `
2180
+ `)
2181
+ return j;
2182
+ j++;
1773
2183
  }
1774
- }
1775
- return null;
1776
- }, resolvePackageImport = (specifier, conditions = ["import"]) => {
1777
- if (specifier.startsWith(".") || specifier.startsWith("/"))
1778
- return null;
1779
- const parts = specifier.split("/");
1780
- const isScoped = specifier.startsWith("@");
1781
- const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
1782
- const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
1783
- const exportKey = subpath ? `./${subpath}` : ".";
1784
- const currentPackageJsonPath = resolve2(process.cwd(), "package.json");
1785
- const currentPackageJson = existsSync2(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
1786
- const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
1787
- const packageDir = currentPackageDir ?? resolve2(process.cwd(), "node_modules", packageName ?? "");
1788
- const packageJsonPath = join2(packageDir, "package.json");
1789
- if (!existsSync2(packageJsonPath))
1790
- return null;
1791
- try {
1792
- const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
1793
- const { exports } = packageJson;
1794
- if (!exports)
1795
- return null;
1796
- const entry = exports[exportKey];
1797
- if (!entry)
1798
- return null;
1799
- const importPath = resolveExportPath(entry, conditions);
1800
- if (!importPath)
2184
+ return j;
2185
+ };
2186
+ const endOfInterp = (start) => {
2187
+ let j = start;
2188
+ let depth = 1;
2189
+ let ipChar = "";
2190
+ let ipWord = "";
2191
+ let ipSpace = false;
2192
+ while (j < n && depth > 0) {
2193
+ const c = src[j];
2194
+ if (c === "\\") {
2195
+ j += 2;
2196
+ continue;
2197
+ }
2198
+ if (c === "`") {
2199
+ j = endOfTemplate(j);
2200
+ ipChar = ")";
2201
+ ipWord = "";
2202
+ ipSpace = false;
2203
+ continue;
2204
+ }
2205
+ if (c === '"' || c === "'") {
2206
+ j = endOfString(j);
2207
+ ipChar = '"';
2208
+ ipWord = "";
2209
+ ipSpace = false;
2210
+ continue;
2211
+ }
2212
+ if (c === "/" && src[j + 1] === "/") {
2213
+ const nl = src.indexOf(`
2214
+ `, j);
2215
+ j = nl < 0 ? n : nl;
2216
+ continue;
2217
+ }
2218
+ if (c === "/" && src[j + 1] === "*") {
2219
+ const e = src.indexOf("*/", j + 2);
2220
+ j = e < 0 ? n : e + 2;
2221
+ continue;
2222
+ }
2223
+ if (c === "/" && (ipChar === "" || REGEX_OK_AFTER_CHAR.has(ipChar) || REGEX_OK_AFTER_WORD.has(ipWord))) {
2224
+ const e = endOfRegex(j);
2225
+ if (e > 0) {
2226
+ j = e;
2227
+ ipChar = ")";
2228
+ ipWord = "";
2229
+ ipSpace = false;
2230
+ continue;
2231
+ }
2232
+ }
2233
+ if (c === "{")
2234
+ depth++;
2235
+ else if (c === "}")
2236
+ depth--;
2237
+ j++;
2238
+ if (c === " " || c === "\t" || c === "\r" || c === `
2239
+ `) {
2240
+ ipSpace = true;
2241
+ continue;
2242
+ }
2243
+ if (isIdentChar(c)) {
2244
+ ipWord = isIdentChar(ipChar) && !ipSpace ? ipWord + c : c;
2245
+ } else {
2246
+ ipWord = "";
2247
+ }
2248
+ ipChar = c;
2249
+ ipSpace = false;
2250
+ }
2251
+ return j;
2252
+ };
2253
+ function endOfTemplate(start) {
2254
+ let j = start + 1;
2255
+ while (j < n) {
2256
+ const c = src[j];
2257
+ if (c === "\\") {
2258
+ j += 2;
2259
+ continue;
2260
+ }
2261
+ if (c === "`")
2262
+ return j + 1;
2263
+ if (c === "$" && src[j + 1] === "{") {
2264
+ j = endOfInterp(j + 2);
2265
+ continue;
2266
+ }
2267
+ j++;
2268
+ }
2269
+ return j;
2270
+ }
2271
+ const endOfRegex = (start) => {
2272
+ let j = start + 1;
2273
+ let inClass = false;
2274
+ while (j < n) {
2275
+ const c = src[j];
2276
+ if (c === "\\") {
2277
+ j += 2;
2278
+ continue;
2279
+ }
2280
+ if (c === `
2281
+ `)
2282
+ return -1;
2283
+ if (c === "[")
2284
+ inClass = true;
2285
+ else if (c === "]")
2286
+ inClass = false;
2287
+ else if (c === "/" && !inClass) {
2288
+ j++;
2289
+ break;
2290
+ }
2291
+ j++;
2292
+ }
2293
+ while (j < n && /[a-z]/i.test(src[j] ?? ""))
2294
+ j++;
2295
+ return j;
2296
+ };
2297
+ while (i < n) {
2298
+ const c = src[i];
2299
+ const c2 = src[i + 1];
2300
+ if (c === "/" && c2 === "/") {
2301
+ out += "//";
2302
+ i += 2;
2303
+ const s = i;
2304
+ while (i < n && src[i] !== `
2305
+ `)
2306
+ i++;
2307
+ mask(src.slice(s, i));
2308
+ continue;
2309
+ }
2310
+ if (c === "/" && c2 === "*") {
2311
+ out += "/*";
2312
+ i += 2;
2313
+ const e = src.indexOf("*/", i);
2314
+ const end = e < 0 ? n : e;
2315
+ mask(src.slice(i, end));
2316
+ i = end < n ? end + 2 : n;
2317
+ if (end < n)
2318
+ out += "*/";
2319
+ continue;
2320
+ }
2321
+ if (c === "`") {
2322
+ const end = endOfTemplate(i);
2323
+ mask(src.slice(i, end));
2324
+ i = end;
2325
+ continue;
2326
+ }
2327
+ if (c === '"' || c === "'") {
2328
+ const end = endOfString(i);
2329
+ const text = src.slice(i, end);
2330
+ if (RISKY_STRING_CONTENT.test(text)) {
2331
+ mask(text);
2332
+ } else {
2333
+ out += text;
2334
+ prevChar = '"';
2335
+ prevWord = "";
2336
+ prevWasSpace = false;
2337
+ }
2338
+ i = end;
2339
+ continue;
2340
+ }
2341
+ if (c === "/" && (prevChar === "" || REGEX_OK_AFTER_CHAR.has(prevChar) || REGEX_OK_AFTER_WORD.has(prevWord))) {
2342
+ const end = endOfRegex(i);
2343
+ if (end > 0) {
2344
+ out += src.slice(i, end);
2345
+ i = end;
2346
+ prevChar = ")";
2347
+ prevWord = "";
2348
+ prevWasSpace = false;
2349
+ continue;
2350
+ }
2351
+ }
2352
+ out += c;
2353
+ i++;
2354
+ if (c === " " || c === "\t" || c === "\r" || c === `
2355
+ `) {
2356
+ prevWasSpace = true;
2357
+ continue;
2358
+ }
2359
+ if (isIdentChar(c)) {
2360
+ const contiguous = isIdentChar(prevChar) && !prevWasSpace;
2361
+ prevWord = contiguous ? prevWord + c : c;
2362
+ } else {
2363
+ prevWord = "";
2364
+ }
2365
+ prevChar = c;
2366
+ prevWasSpace = false;
2367
+ }
2368
+ const restoreRegex = new RegExp(`${SENTINEL}(\\d+)${SENTINEL}`, "g");
2369
+ const restore = (rewritten) => rewritten.replace(restoreRegex, (_m, d) => pieces[Number(d)] ?? "");
2370
+ return { masked: out, restore };
2371
+ };
2372
+ var init_maskLiterals = __esm(() => {
2373
+ SENTINEL = String.fromCharCode(57344);
2374
+ RISKY_STRING_CONTENT = /\b(?:from|import|require)\s*\(?\s*["'`]/;
2375
+ REGEX_OK_AFTER_CHAR = new Set([
2376
+ "(",
2377
+ ",",
2378
+ "=",
2379
+ ":",
2380
+ "[",
2381
+ "!",
2382
+ "&",
2383
+ "|",
2384
+ "?",
2385
+ "{",
2386
+ "}",
2387
+ ";",
2388
+ "+",
2389
+ "-",
2390
+ "*",
2391
+ "/",
2392
+ "%",
2393
+ "^",
2394
+ "~",
2395
+ "<",
2396
+ ">"
2397
+ ]);
2398
+ REGEX_OK_AFTER_WORD = new Set([
2399
+ "return",
2400
+ "typeof",
2401
+ "instanceof",
2402
+ "in",
2403
+ "of",
2404
+ "new",
2405
+ "delete",
2406
+ "void",
2407
+ "do",
2408
+ "else",
2409
+ "yield",
2410
+ "await",
2411
+ "case"
2412
+ ]);
2413
+ });
2414
+
2415
+ // src/build/nativeRewrite.ts
2416
+ import { dlopen, FFIType, ptr } from "bun:ffi";
2417
+ import { platform, arch } from "os";
2418
+ import { resolve as resolve2 } from "path";
2419
+ var ffiDefinition, nativeLib = null, loadNative = () => {
2420
+ if (nativeLib !== null)
2421
+ return nativeLib;
2422
+ const osPlatform = platform();
2423
+ const cpu = arch();
2424
+ const platformMap = {
2425
+ "darwin-arm64": "darwin-arm64/fast_ops.dylib",
2426
+ "darwin-x64": "darwin-x64/fast_ops.dylib",
2427
+ "linux-arm64": "linux-arm64/fast_ops.so",
2428
+ "linux-x64": "linux-x64/fast_ops.so",
2429
+ "win32-arm64": "windows-arm64/fast_ops.dll",
2430
+ "win32-x64": "windows-x64/fast_ops.dll"
2431
+ };
2432
+ const libPath = platformMap[`${osPlatform}-${cpu}`];
2433
+ if (!libPath)
2434
+ return null;
2435
+ try {
2436
+ const fullPath = resolve2(import.meta.dir, "../../native/packages", libPath);
2437
+ const lib = dlopen(fullPath, ffiDefinition);
2438
+ nativeLib = lib.symbols;
2439
+ return nativeLib;
2440
+ } catch {
2441
+ return null;
2442
+ }
2443
+ }, nativeRewriteImports = (content, replacements) => {
2444
+ const lib = loadNative();
2445
+ if (!lib)
2446
+ return null;
2447
+ const jsonStr = JSON.stringify(replacements);
2448
+ const contentBuf = Buffer.from(content);
2449
+ const jsonBuf = Buffer.from(jsonStr);
2450
+ const outBuf = Buffer.alloc(content.length * 2);
2451
+ const outLenBuf = new BigUint64Array([BigInt(outBuf.length)]);
2452
+ const result = lib.rewrite_imports(ptr(contentBuf), contentBuf.length, ptr(jsonBuf), jsonBuf.length, ptr(outBuf), ptr(new Uint8Array(outLenBuf.buffer)));
2453
+ if (result < 0)
2454
+ return null;
2455
+ if (result === 0)
2456
+ return content;
2457
+ const outLen = Number(outLenBuf[0]);
2458
+ return outBuf.subarray(0, outLen).toString("utf-8");
2459
+ };
2460
+ var init_nativeRewrite = __esm(() => {
2461
+ ffiDefinition = {
2462
+ rewrite_imports: {
2463
+ args: [
2464
+ FFIType.ptr,
2465
+ FFIType.u64,
2466
+ FFIType.ptr,
2467
+ FFIType.u64,
2468
+ FFIType.ptr,
2469
+ FFIType.ptr
2470
+ ],
2471
+ returns: FFIType.i32
2472
+ }
2473
+ };
2474
+ });
2475
+
2476
+ // src/build/rewriteImportsPlugin.ts
2477
+ var exports_rewriteImportsPlugin = {};
2478
+ __export(exports_rewriteImportsPlugin, {
2479
+ rewriteVendorDirectories: () => rewriteVendorDirectories,
2480
+ rewriteImportsInContent: () => rewriteImportsInContent,
2481
+ rewriteBuildOutputsWith: () => rewriteBuildOutputsWith,
2482
+ rewriteBuildOutputs: () => rewriteBuildOutputs,
2483
+ jsRewriteImports: () => jsRewriteImports,
2484
+ fixMissingReExportNamespacesInContent: () => fixMissingReExportNamespacesInContent,
2485
+ buildWithImportRewrite: () => buildWithImportRewrite
2486
+ });
2487
+ import { readdir } from "fs/promises";
2488
+ import { join as join2 } from "path";
2489
+ var escapeRegex = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), jsRewriteImports = (content, replacements) => {
2490
+ let result = content;
2491
+ for (const [specifier, webPath] of replacements) {
2492
+ const escaped = escapeRegex(specifier);
2493
+ const fromRegex = new RegExp(`(from\\s*["'])${escaped}(["'])`, "g");
2494
+ const sideEffectRegex = new RegExp(`(import\\s*["'])${escaped}(["'])`, "g");
2495
+ const dynamicRegex = new RegExp(`(import\\s*\\(\\s*["'])${escaped}(["']\\s*\\))`, "g");
2496
+ result = result.replace(fromRegex, `$1${webPath}$2`);
2497
+ result = result.replace(sideEffectRegex, `$1${webPath}$2`);
2498
+ result = result.replace(dynamicRegex, `$1${webPath}$2`);
2499
+ }
2500
+ return result;
2501
+ }, rewriteImportsInContent = (content, vendorPaths) => {
2502
+ if (Object.keys(vendorPaths).length === 0)
2503
+ return content;
2504
+ const replacements = Object.entries(vendorPaths).sort(([keyA], [keyB]) => keyB.length - keyA.length);
2505
+ const { masked, restore } = maskLiterals(content);
2506
+ const native = nativeRewriteImports(masked, replacements);
2507
+ return restore(native ?? jsRewriteImports(masked, replacements));
2508
+ }, fixMissingReExportNamespacesInContent = (content) => {
2509
+ const REEXPORT_PATTERN = /__reExport\(\s*[A-Za-z_$][\w$]*\s*,\s*([A-Za-z_$][\w$]*)\s*\)/g;
2510
+ REEXPORT_PATTERN.lastIndex = 0;
2511
+ const missing = [];
2512
+ let match;
2513
+ while ((match = REEXPORT_PATTERN.exec(content)) !== null) {
2514
+ const ident = match[1];
2515
+ if (!ident)
2516
+ continue;
2517
+ const nsImportRe = new RegExp(`\\bimport\\s*\\*\\s*as\\s+${ident}\\s+from\\b`);
2518
+ if (nsImportRe.test(content))
2519
+ continue;
2520
+ const declRe = new RegExp(`\\b(?:const|let|var|function|class)\\s+${ident}\\b`);
2521
+ if (declRe.test(content))
2522
+ continue;
2523
+ const namedImportRe = new RegExp(`\\bimport\\s*\\{[^}]*\\b${ident}\\b[^}]*\\}\\s*from\\b`);
2524
+ if (namedImportRe.test(content))
2525
+ continue;
2526
+ const importPathRe = /(?:from\s+|import\s*)["']([^"']+)["']/g;
2527
+ let pathMatch;
2528
+ let sourcePath;
2529
+ while ((pathMatch = importPathRe.exec(content)) !== null) {
2530
+ const p = pathMatch[1];
2531
+ if (!p)
2532
+ continue;
2533
+ const base = p.split("/").pop()?.replace(/\.[mc]?js$/, "");
2534
+ if (!base)
2535
+ continue;
2536
+ const normalized = base.startsWith("_") ? base.slice(1) : base;
2537
+ if (normalized === ident || normalized.endsWith(`_${ident}`)) {
2538
+ sourcePath = p;
2539
+ break;
2540
+ }
2541
+ }
2542
+ if (sourcePath)
2543
+ missing.push({ ident, path: sourcePath });
2544
+ }
2545
+ if (missing.length === 0)
2546
+ return content;
2547
+ const seen = new Set;
2548
+ const unique = missing.filter((entry) => {
2549
+ if (seen.has(entry.ident))
2550
+ return false;
2551
+ seen.add(entry.ident);
2552
+ return true;
2553
+ });
2554
+ const inserts = unique.map((entry) => `import * as ${entry.ident} from "${entry.path}";`).join(`
2555
+ `);
2556
+ return `${inserts}
2557
+ ${content}`;
2558
+ }, isReadableArtifact = (artifact) => artifact.path.endsWith(".js"), rewriteBuildOutputs = async (outputs, vendorPaths) => {
2559
+ if (Object.keys(vendorPaths).length === 0)
2560
+ return;
2561
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
2562
+ let original;
2563
+ try {
2564
+ original = await artifact.text();
2565
+ } catch (err) {
2566
+ const code = err.code;
2567
+ if (code === "ENOENT")
2568
+ return;
2569
+ throw err;
2570
+ }
2571
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
2572
+ if (rewritten === original)
2573
+ return;
2574
+ try {
2575
+ await Bun.write(artifact.path, rewritten);
2576
+ } catch (err) {
2577
+ const code = err.code;
2578
+ if (code === "ENOENT")
2579
+ return;
2580
+ throw err;
2581
+ }
2582
+ }));
2583
+ }, rewriteBuildOutputsWith = async (outputs, resolveVendorPaths) => {
2584
+ await Promise.all(outputs.filter(isReadableArtifact).map(async (artifact) => {
2585
+ const vendorPaths = resolveVendorPaths(artifact);
2586
+ if (Object.keys(vendorPaths).length === 0)
2587
+ return;
2588
+ let original;
2589
+ try {
2590
+ original = await artifact.text();
2591
+ } catch (err) {
2592
+ const code = err.code;
2593
+ if (code === "ENOENT")
2594
+ return;
2595
+ throw err;
2596
+ }
2597
+ const rewritten = rewriteImportsInContent(original, vendorPaths);
2598
+ if (rewritten === original)
2599
+ return;
2600
+ try {
2601
+ await Bun.write(artifact.path, rewritten);
2602
+ } catch (err) {
2603
+ const code = err.code;
2604
+ if (code === "ENOENT")
2605
+ return;
2606
+ throw err;
2607
+ }
2608
+ }));
2609
+ }, rewriteVendorDirectories = async (vendorDirs, vendorPaths) => {
2610
+ if (Object.keys(vendorPaths).length === 0)
2611
+ return;
2612
+ const allFiles = [];
2613
+ for (const dir of vendorDirs) {
2614
+ try {
2615
+ const entries = await readdir(dir);
2616
+ for (const entry of entries) {
2617
+ if (entry.endsWith(".js"))
2618
+ allFiles.push(join2(dir, entry));
2619
+ }
2620
+ } catch {}
2621
+ }
2622
+ await Promise.all(allFiles.map(async (filePath) => {
2623
+ let original;
2624
+ try {
2625
+ original = await Bun.file(filePath).text();
2626
+ } catch (err) {
2627
+ const code = err.code;
2628
+ if (code === "ENOENT")
2629
+ return;
2630
+ throw err;
2631
+ }
2632
+ let next = rewriteImportsInContent(original, vendorPaths);
2633
+ next = fixMissingReExportNamespacesInContent(next);
2634
+ if (next === original)
2635
+ return;
2636
+ try {
2637
+ await Bun.write(filePath, next);
2638
+ } catch (err) {
2639
+ const code = err.code;
2640
+ if (code === "ENOENT")
2641
+ return;
2642
+ throw err;
2643
+ }
2644
+ }));
2645
+ }, buildWithImportRewrite = async (pendingBuild, vendorPaths) => {
2646
+ const result = await pendingBuild;
2647
+ if (result.outputs.length > 0) {
2648
+ await rewriteBuildOutputs(result.outputs, vendorPaths);
2649
+ }
2650
+ return result;
2651
+ };
2652
+ var init_rewriteImportsPlugin = __esm(() => {
2653
+ init_maskLiterals();
2654
+ init_nativeRewrite();
2655
+ });
2656
+
2657
+ // src/core/angularServerModule.ts
2658
+ import { mkdir } from "fs/promises";
2659
+ import { dirname, join as join3, relative } from "path";
2660
+ var serverCacheRoot, compiledModuleCache, ANGULAR_SPECIFIER_RE, getCachedModulePath = (sourcePath) => {
2661
+ const relativeSourcePath = relative(process.cwd(), sourcePath).replace(/\\/g, "/");
2662
+ const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2663
+ return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
2664
+ }, collectVendorPaths = (code) => {
2665
+ const vendorPaths = {};
2666
+ if (!isProductionRuntime()) {
2667
+ return vendorPaths;
2668
+ }
2669
+ const specifiers = new Set([...code.matchAll(ANGULAR_SPECIFIER_RE)].map((match) => match[1]));
2670
+ specifiers.forEach((specifier) => {
2671
+ if (!specifier)
2672
+ return;
2673
+ const resolved = resolveAngularRuntimePath(specifier);
2674
+ if (resolved === specifier)
2675
+ return;
2676
+ vendorPaths[specifier] = resolved;
2677
+ });
2678
+ return vendorPaths;
2679
+ }, buildAngularServerModule = async (sourcePath) => {
2680
+ const result = await Bun.build({
2681
+ entrypoints: [sourcePath],
2682
+ format: "esm",
2683
+ packages: "external",
2684
+ target: "bun",
2685
+ throw: false
2686
+ });
2687
+ const entry = result.outputs.find((output) => output.kind === "entry-point");
2688
+ if (!result.success || !entry) {
2689
+ const message = result.logs.map((log2) => String(log2)).join(`
2690
+ `);
2691
+ throw new Error(`Failed to compile Angular island server module for "${sourcePath}":
2692
+ ${message}`);
2693
+ }
2694
+ const code = await entry.text();
2695
+ const rewritten = rewriteImportsInContent(code, collectVendorPaths(code));
2696
+ const modulePath = getCachedModulePath(sourcePath);
2697
+ await mkdir(dirname(modulePath), { recursive: true });
2698
+ await Bun.write(modulePath, rewritten);
2699
+ return modulePath;
2700
+ }, compileAngularServerModule = (sourcePath) => {
2701
+ const cached = compiledModuleCache.get(sourcePath);
2702
+ if (cached) {
2703
+ return cached;
2704
+ }
2705
+ const compiledModulePromise = buildAngularServerModule(sourcePath);
2706
+ compiledModuleCache.set(sourcePath, compiledModulePromise);
2707
+ return compiledModulePromise;
2708
+ };
2709
+ var init_angularServerModule = __esm(() => {
2710
+ init_resolveAngularPackage();
2711
+ init_rewriteImportsPlugin();
2712
+ serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "angular");
2713
+ compiledModuleCache = new Map;
2714
+ ANGULAR_SPECIFIER_RE = /["'](@angular\/[^"']+)["']/g;
2715
+ });
2716
+
2717
+ // src/build/resolvePackageImport.ts
2718
+ import { resolve as resolve3, join as join4 } from "path";
2719
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
2720
+ var resolveExportPath = (entry, conditions) => {
2721
+ if (typeof entry === "string")
2722
+ return entry;
2723
+ if (!entry || typeof entry !== "object")
2724
+ return null;
2725
+ for (const condition of conditions) {
2726
+ const target = Reflect.get(entry, condition);
2727
+ if (typeof target === "string") {
2728
+ return target;
2729
+ }
2730
+ }
2731
+ return null;
2732
+ }, resolvePackageImport = (specifier, conditions = ["import"]) => {
2733
+ if (specifier.startsWith(".") || specifier.startsWith("/"))
2734
+ return null;
2735
+ const parts = specifier.split("/");
2736
+ const isScoped = specifier.startsWith("@");
2737
+ const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
2738
+ const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
2739
+ const exportKey = subpath ? `./${subpath}` : ".";
2740
+ const currentPackageJsonPath = resolve3(process.cwd(), "package.json");
2741
+ const currentPackageJson = existsSync2(currentPackageJsonPath) ? JSON.parse(readFileSync2(currentPackageJsonPath, "utf-8")) : null;
2742
+ const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
2743
+ const packageDir = currentPackageDir ?? resolve3(process.cwd(), "node_modules", packageName ?? "");
2744
+ const packageJsonPath = join4(packageDir, "package.json");
2745
+ if (!existsSync2(packageJsonPath))
2746
+ return null;
2747
+ try {
2748
+ const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
2749
+ const { exports } = packageJson;
2750
+ if (!exports)
2751
+ return null;
2752
+ const entry = exports[exportKey];
2753
+ if (!entry)
2754
+ return null;
2755
+ const importPath = resolveExportPath(entry, conditions);
2756
+ if (!importPath)
1801
2757
  return null;
1802
2758
  if (currentPackageDir && importPath.startsWith("./dist/")) {
1803
- const sourceCandidate = resolve2(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
2759
+ const sourceCandidate = resolve3(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
1804
2760
  if (existsSync2(sourceCandidate)) {
1805
2761
  return sourceCandidate;
1806
2762
  }
1807
2763
  }
1808
- const resolved = resolve2(packageDir, importPath);
2764
+ const resolved = resolve3(packageDir, importPath);
1809
2765
  return existsSync2(resolved) ? resolved : null;
1810
2766
  } catch {
1811
2767
  return null;
@@ -1957,17 +2913,17 @@ __export(exports_stylePreprocessor, {
1957
2913
  compileStyleFileIfNeeded: () => compileStyleFileIfNeeded,
1958
2914
  addStyleImporter: () => addStyleImporter
1959
2915
  });
1960
- import { createHash } from "crypto";
2916
+ import { createHash as createHash2 } from "crypto";
1961
2917
  import { existsSync as existsSync3, readFileSync as readFileSync3 } from "fs";
1962
2918
  import { readFile } from "fs/promises";
1963
2919
  import { createRequire } from "module";
1964
2920
  import {
1965
- dirname,
2921
+ dirname as dirname2,
1966
2922
  extname,
1967
2923
  isAbsolute,
1968
- join as join3,
1969
- relative,
1970
- resolve as resolve3
2924
+ join as join5,
2925
+ relative as relative2,
2926
+ resolve as resolve4
1971
2927
  } from "path";
1972
2928
  import { fileURLToPath, pathToFileURL } from "url";
1973
2929
  var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
@@ -2003,9 +2959,9 @@ ${message}`);
2003
2959
  return requireOptionalPeer(specifier);
2004
2960
  }
2005
2961
  }, normalizeLoadPaths = (filePath, paths = []) => [
2006
- dirname(filePath),
2962
+ dirname2(filePath),
2007
2963
  process.cwd(),
2008
- ...paths.map((path) => resolve3(process.cwd(), path))
2964
+ ...paths.map((path) => resolve4(process.cwd(), path))
2009
2965
  ], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
2010
2966
  pattern,
2011
2967
  replacements: Array.isArray(value) ? value : [value]
@@ -2013,7 +2969,7 @@ ${message}`);
2013
2969
  const cwd = process.cwd();
2014
2970
  if (tsconfigAliasCache?.cwd === cwd)
2015
2971
  return tsconfigAliasCache;
2016
- const tsconfigPath = resolve3(cwd, "tsconfig.json");
2972
+ const tsconfigPath = resolve4(cwd, "tsconfig.json");
2017
2973
  const empty = { aliases: [], baseUrl: cwd, cwd };
2018
2974
  if (!existsSync3(tsconfigPath)) {
2019
2975
  tsconfigAliasCache = empty;
@@ -2022,7 +2978,7 @@ ${message}`);
2022
2978
  try {
2023
2979
  const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
2024
2980
  const compilerOptions = parsed.compilerOptions ?? {};
2025
- const baseUrl = resolve3(cwd, compilerOptions.baseUrl ?? ".");
2981
+ const baseUrl = resolve4(cwd, compilerOptions.baseUrl ?? ".");
2026
2982
  tsconfigAliasCache = {
2027
2983
  aliases: normalizeAliasEntries(compilerOptions.paths),
2028
2984
  baseUrl,
@@ -2050,7 +3006,7 @@ ${message}`);
2050
3006
  continue;
2051
3007
  const wildcard = match[1] ?? "";
2052
3008
  for (const replacement of alias.replacements) {
2053
- targets.push(resolve3(baseUrl, replacement.replace("*", wildcard)));
3009
+ targets.push(resolve4(baseUrl, replacement.replace("*", wildcard)));
2054
3010
  }
2055
3011
  }
2056
3012
  return targets;
@@ -2064,21 +3020,21 @@ ${message}`);
2064
3020
  const ext = extname(basePath);
2065
3021
  const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
2066
3022
  `${basePath}${extension}`,
2067
- join3(basePath, `index${extension}`)
3023
+ join5(basePath, `index${extension}`)
2068
3024
  ]);
2069
3025
  if (language === "scss" || language === "sass") {
2070
3026
  return paths.flatMap((path) => {
2071
- const dir = dirname(path);
3027
+ const dir = dirname2(path);
2072
3028
  const base = path.slice(dir.length + 1);
2073
- return [path, join3(dir, `_${base}`)];
3029
+ return [path, join5(dir, `_${base}`)];
2074
3030
  });
2075
3031
  }
2076
3032
  return paths;
2077
3033
  }, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
2078
3034
  const rawCandidates = [
2079
3035
  ...resolveAliasTargets(specifier, config),
2080
- isAbsolute(specifier) ? specifier : resolve3(fromDirectory, specifier),
2081
- ...loadPaths.map((path) => resolve3(path, specifier))
3036
+ isAbsolute(specifier) ? specifier : resolve4(fromDirectory, specifier),
3037
+ ...loadPaths.map((path) => resolve4(path, specifier))
2082
3038
  ];
2083
3039
  for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
2084
3040
  if (existsSync3(candidate))
@@ -2094,8 +3050,8 @@ ${message}`);
2094
3050
  path: url.slice(0, markerIndex)
2095
3051
  };
2096
3052
  }, rebaseCssUrls = (contents, sourceFile, entryFile) => {
2097
- const sourceDir = dirname(sourceFile);
2098
- const entryDir = dirname(entryFile);
3053
+ const sourceDir = dirname2(sourceFile);
3054
+ const entryDir = dirname2(entryFile);
2099
3055
  if (sourceDir === entryDir)
2100
3056
  return contents;
2101
3057
  return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
@@ -2103,7 +3059,7 @@ ${message}`);
2103
3059
  if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
2104
3060
  return match;
2105
3061
  const { marker, path } = splitCssUrl(trimmedUrl);
2106
- const rebased = relative(entryDir, resolve3(sourceDir, path)).replace(/\\/g, "/");
3062
+ const rebased = relative2(entryDir, resolve4(sourceDir, path)).replace(/\\/g, "/");
2107
3063
  const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
2108
3064
  const nextQuote = quote || '"';
2109
3065
  return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
@@ -2111,7 +3067,7 @@ ${message}`);
2111
3067
  }, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
2112
3068
  if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
2113
3069
  return match;
2114
- const resolved = resolveImportPath(specifier, dirname(sourceFile), loadPaths, language, config);
3070
+ const resolved = resolveImportPath(specifier, dirname2(sourceFile), loadPaths, language, config);
2115
3071
  return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
2116
3072
  }), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
2117
3073
  const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
@@ -2141,7 +3097,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2141
3097
  }
2142
3098
  return mod;
2143
3099
  }, loadPostcssConfigFile = async (configPath) => {
2144
- const resolved = resolve3(process.cwd(), configPath);
3100
+ const resolved = resolve4(process.cwd(), configPath);
2145
3101
  const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
2146
3102
  const config = normalizePostcssModule(loaded);
2147
3103
  const value = typeof config === "function" ? await config({
@@ -2201,9 +3157,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2201
3157
  return result.css;
2202
3158
  }, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
2203
3159
  canonicalize(specifier, options) {
2204
- const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
3160
+ const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
2205
3161
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
2206
- return resolved ? new URL(pathToFileURL(resolve3(resolved)).href) : null;
3162
+ return resolved ? new URL(pathToFileURL(resolve4(resolved)).href) : null;
2207
3163
  },
2208
3164
  load(canonicalUrl) {
2209
3165
  const filePath = fileURLToPath(canonicalUrl);
@@ -2220,9 +3176,9 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2220
3176
  install(less, pluginManager) {
2221
3177
  const baseManager = new less.FileManager;
2222
3178
  const manager = Object.create(baseManager);
2223
- manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve3(currentDirectory), loadPaths, "less", config));
3179
+ manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config));
2224
3180
  manager.loadFile = async (filename, currentDirectory) => {
2225
- const resolved = resolveImportPath(filename, resolve3(currentDirectory), loadPaths, "less", config);
3181
+ const resolved = resolveImportPath(filename, resolve4(currentDirectory), loadPaths, "less", config);
2226
3182
  if (!resolved) {
2227
3183
  throw new Error(`Unable to resolve Less import "${filename}"`);
2228
3184
  }
@@ -2259,29 +3215,29 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2259
3215
  const stylusDeps = renderer.deps?.();
2260
3216
  if (Array.isArray(stylusDeps)) {
2261
3217
  for (const dep of stylusDeps)
2262
- deps.add(resolve3(dep));
3218
+ deps.add(resolve4(dep));
2263
3219
  }
2264
3220
  }
2265
3221
  resolveCss(css ?? "");
2266
3222
  });
2267
3223
  });
2268
3224
  }, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
2269
- const key = resolve3(entry);
3225
+ const key = resolve4(entry);
2270
3226
  const stripped = new Set;
2271
3227
  for (const dep of deps) {
2272
- const resolved = resolve3(dep);
3228
+ const resolved = resolve4(dep);
2273
3229
  if (resolved !== key)
2274
3230
  stripped.add(resolved);
2275
3231
  }
2276
3232
  styleDependencyGraph.set(key, stripped);
2277
3233
  }, addStyleImporter = (importerPath, stylePath) => {
2278
- const key = resolve3(importerPath);
2279
- const target = resolve3(stylePath);
3234
+ const key = resolve4(importerPath);
3235
+ const target = resolve4(stylePath);
2280
3236
  const deps = styleDependencyGraph.get(key) ?? new Set;
2281
3237
  deps.add(target);
2282
3238
  styleDependencyGraph.set(key, deps);
2283
3239
  }, findStyleEntriesImporting = (changedPath) => {
2284
- const target = resolve3(changedPath);
3240
+ const target = resolve4(changedPath);
2285
3241
  const importers = [];
2286
3242
  for (const [entry, deps] of styleDependencyGraph) {
2287
3243
  if (deps.has(target))
@@ -2289,13 +3245,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2289
3245
  }
2290
3246
  return importers;
2291
3247
  }, recordStyleOutput = (entry, css) => {
2292
- const key = resolve3(entry);
2293
- const hash = createHash("sha1").update(css).digest("hex");
3248
+ const key = resolve4(entry);
3249
+ const hash = createHash2("sha1").update(css).digest("hex");
2294
3250
  const previous = styleOutputHashes.get(key);
2295
3251
  styleOutputHashes.set(key, hash);
2296
3252
  return previous !== hash;
2297
3253
  }, forgetStyleEntry = (entry) => {
2298
- const key = resolve3(entry);
3254
+ const key = resolve4(entry);
2299
3255
  styleDependencyGraph.delete(key);
2300
3256
  styleOutputHashes.delete(key);
2301
3257
  }, compileStyleSource = async (filePath, source, languageHint, config) => {
@@ -2321,7 +3277,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2321
3277
  loadPaths,
2322
3278
  style: "expanded",
2323
3279
  syntax: language === "sass" ? "indented" : "scss",
2324
- url: new URL(pathToFileURL(resolve3(filePath)).href)
3280
+ url: new URL(pathToFileURL(resolve4(filePath)).href)
2325
3281
  });
2326
3282
  const css = await runPostcss(result.css, filePath, config);
2327
3283
  const loadedUrls = result.loadedUrls ?? [];
@@ -2329,7 +3285,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2329
3285
  if (url.protocol !== "file:")
2330
3286
  continue;
2331
3287
  const dep = fileURLToPath(url);
2332
- if (resolve3(dep) === resolve3(filePath))
3288
+ if (resolve4(dep) === resolve4(filePath))
2333
3289
  continue;
2334
3290
  deps.add(dep);
2335
3291
  }
@@ -2450,7 +3406,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2450
3406
  const start = match.index ?? 0;
2451
3407
  const end = start + match[0].length;
2452
3408
  parts.push(content.slice(cursor, start));
2453
- const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
3409
+ const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
2454
3410
  if (visited.has(fullPath) || !existsSync3(fullPath)) {
2455
3411
  parts.push(visited.has(fullPath) ? "" : match[0]);
2456
3412
  cursor = end;
@@ -2459,7 +3415,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2459
3415
  const nextVisited = new Set(visited);
2460
3416
  nextVisited.add(fullPath);
2461
3417
  const imported = await readFile(fullPath, "utf-8");
2462
- parts.push(await resolveCssImportsAsync(imported, dirname(fullPath), nextVisited));
3418
+ parts.push(await resolveCssImportsAsync(imported, dirname2(fullPath), nextVisited));
2463
3419
  cursor = end;
2464
3420
  }
2465
3421
  parts.push(content.slice(cursor));
@@ -2468,13 +3424,13 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2468
3424
  if (!isPreprocessableStylePath(filePath)) {
2469
3425
  const raw = await readFile(filePath, "utf-8");
2470
3426
  const processed = await runPostcss(raw, filePath, config);
2471
- return resolveCssImportsAsync(processed, dirname(filePath), new Set([filePath]));
3427
+ return resolveCssImportsAsync(processed, dirname2(filePath), new Set([filePath]));
2472
3428
  }
2473
3429
  const compiled = await compileStyleSource(filePath, undefined, undefined, config);
2474
- return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
3430
+ return resolveCssImportsAsync(compiled, dirname2(filePath), new Set([filePath]));
2475
3431
  }, resolveCssImportsSync = (content, baseDir, visited) => {
2476
3432
  return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
2477
- const fullPath = isAbsolute(importPath) ? importPath : resolve3(baseDir, importPath);
3433
+ const fullPath = isAbsolute(importPath) ? importPath : resolve4(baseDir, importPath);
2478
3434
  if (visited.has(fullPath))
2479
3435
  return "";
2480
3436
  if (!existsSync3(fullPath))
@@ -2482,7 +3438,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2482
3438
  const nextVisited = new Set(visited);
2483
3439
  nextVisited.add(fullPath);
2484
3440
  const imported = readFileSync3(fullPath, "utf-8");
2485
- return resolveCssImportsSync(imported, dirname(fullPath), nextVisited);
3441
+ return resolveCssImportsSync(imported, dirname2(fullPath), nextVisited);
2486
3442
  });
2487
3443
  }, compileStyleFileIfNeededSync = (filePath, config) => {
2488
3444
  const rawContents = readFileSync3(filePath, "utf-8");
@@ -2508,18 +3464,18 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2508
3464
  loadPaths,
2509
3465
  style: "expanded",
2510
3466
  syntax: language === "sass" ? "indented" : "scss",
2511
- url: new URL(pathToFileURL(resolve3(filePath)).href)
3467
+ url: new URL(pathToFileURL(resolve4(filePath)).href)
2512
3468
  });
2513
3469
  const loadedUrls = result.loadedUrls ?? [];
2514
3470
  for (const url of loadedUrls) {
2515
3471
  if (url.protocol !== "file:")
2516
3472
  continue;
2517
3473
  const dep = fileURLToPath(url);
2518
- if (resolve3(dep) === resolve3(filePath))
3474
+ if (resolve4(dep) === resolve4(filePath))
2519
3475
  continue;
2520
3476
  addStyleImporter(filePath, dep);
2521
3477
  }
2522
- return resolveCssImportsSync(result.css, dirname(filePath), new Set([filePath]));
3478
+ return resolveCssImportsSync(result.css, dirname2(filePath), new Set([filePath]));
2523
3479
  }
2524
3480
  if (language === "less") {
2525
3481
  throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
@@ -2527,7 +3483,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
2527
3483
  if (language === "stylus") {
2528
3484
  throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
2529
3485
  }
2530
- return resolveCssImportsSync(rawContents, dirname(filePath), new Set([filePath]));
3486
+ return resolveCssImportsSync(rawContents, dirname2(filePath), new Set([filePath]));
2531
3487
  }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
2532
3488
  var init_stylePreprocessor = __esm(() => {
2533
3489
  CSS_EXTENSION_PATTERN = /\.css$/i;
@@ -2536,7 +3492,7 @@ var init_stylePreprocessor = __esm(() => {
2536
3492
  STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
2537
3493
  importOptionalPeer = new Function("specifier", "return import(specifier)");
2538
3494
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
2539
- requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
3495
+ requireFromCwd = createRequire(join5(process.cwd(), "package.json"));
2540
3496
  styleDependencyGraph = new Map;
2541
3497
  styleOutputHashes = new Map;
2542
3498
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
@@ -2544,14 +3500,14 @@ var init_stylePreprocessor = __esm(() => {
2544
3500
  });
2545
3501
 
2546
3502
  // src/core/svelteServerModule.ts
2547
- import { mkdir, readdir } from "fs/promises";
2548
- import { basename as basename2, dirname as dirname2, extname as extname2, join as join4, relative as relative2, resolve as resolve4 } from "path";
2549
- var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
2550
- const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
3503
+ import { mkdir as mkdir2, readdir as readdir2 } from "fs/promises";
3504
+ import { basename as basename3, dirname as dirname3, extname as extname2, join as join6, relative as relative3, resolve as resolve5 } from "path";
3505
+ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
3506
+ const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
2551
3507
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
2552
3508
  }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
2553
3509
  for (const entry of entries) {
2554
- const entryPath = join4(dir, entry.name);
3510
+ const entryPath = join6(dir, entry.name);
2555
3511
  if (entry.isDirectory())
2556
3512
  stack.push(entryPath);
2557
3513
  if (entry.isFile() && entry.name === targetFileName) {
@@ -2565,7 +3521,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2565
3521
  const nextStack = [];
2566
3522
  const dirEntries = await Promise.all(dirs.map(async (dir) => ({
2567
3523
  dir,
2568
- entries: await readdir(dir, {
3524
+ entries: await readdir2(dir, {
2569
3525
  encoding: "utf-8",
2570
3526
  withFileTypes: true
2571
3527
  })
@@ -2576,16 +3532,16 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2576
3532
  return found;
2577
3533
  }
2578
3534
  return searchDirectoryLevel(nextStack, targetFileName);
2579
- }, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename2(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
3535
+ }, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename3(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
2580
3536
  const cachedPath = originalSourcePathCache.get(sourcePath);
2581
3537
  if (cachedPath !== undefined) {
2582
3538
  return cachedPath;
2583
3539
  }
2584
- if (!sourcePath.includes(`${join4(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
3540
+ if (!sourcePath.includes(`${join6(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
2585
3541
  originalSourcePathCache.set(sourcePath, sourcePath);
2586
3542
  return sourcePath;
2587
3543
  }
2588
- const resolvedSourcePath = await findSourceFileByBasename(join4(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
3544
+ const resolvedSourcePath = await findSourceFileByBasename(join6(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
2589
3545
  const nextPath = resolvedSourcePath ?? sourcePath;
2590
3546
  originalSourcePathCache.set(sourcePath, nextPath);
2591
3547
  return nextPath;
@@ -2593,7 +3549,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2593
3549
  if (!spec.startsWith(".")) {
2594
3550
  return null;
2595
3551
  }
2596
- const basePath = resolve4(dirname2(from), spec);
3552
+ const basePath = resolve5(dirname3(from), spec);
2597
3553
  const candidates = [
2598
3554
  basePath,
2599
3555
  `${basePath}.ts`,
@@ -2601,19 +3557,19 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2601
3557
  `${basePath}.mjs`,
2602
3558
  `${basePath}.cjs`,
2603
3559
  `${basePath}.json`,
2604
- join4(basePath, "index.ts"),
2605
- join4(basePath, "index.js"),
2606
- join4(basePath, "index.mjs"),
2607
- join4(basePath, "index.cjs"),
2608
- join4(basePath, "index.json")
3560
+ join6(basePath, "index.ts"),
3561
+ join6(basePath, "index.js"),
3562
+ join6(basePath, "index.mjs"),
3563
+ join6(basePath, "index.cjs"),
3564
+ join6(basePath, "index.json")
2609
3565
  ];
2610
3566
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
2611
3567
  const foundIndex = existResults.indexOf(true);
2612
3568
  return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
2613
- }, getCachedModulePath = (sourcePath) => {
2614
- const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
3569
+ }, getCachedModulePath2 = (sourcePath) => {
3570
+ const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
2615
3571
  const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2616
- return join4(serverCacheRoot, `${normalizedSourcePath}.server.js`);
3572
+ return join6(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
2617
3573
  }, resolveSvelteImport = async (spec, from) => {
2618
3574
  if (!spec.startsWith(".") && !spec.startsWith("/")) {
2619
3575
  const resolved = resolvePackageImport(spec);
@@ -2625,7 +3581,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2625
3581
  if (!spec.startsWith(".")) {
2626
3582
  return null;
2627
3583
  }
2628
- const explicitPath = resolve4(dirname2(from), spec);
3584
+ const explicitPath = resolve5(dirname3(from), spec);
2629
3585
  if (extname2(explicitPath) === ".svelte") {
2630
3586
  return explicitPath;
2631
3587
  }
@@ -2645,7 +3601,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2645
3601
  }
2646
3602
  await Bun.write(path, content);
2647
3603
  }, compileSvelteServerModule = async (sourcePath) => {
2648
- const cachedModulePath = compiledModuleCache.get(sourcePath);
3604
+ const cachedModulePath = compiledModuleCache2.get(sourcePath);
2649
3605
  if (cachedModulePath) {
2650
3606
  return cachedModulePath;
2651
3607
  }
@@ -2684,7 +3640,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2684
3640
  continue;
2685
3641
  if (resolvedChildModules[index])
2686
3642
  continue;
2687
- rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
3643
+ rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
2688
3644
  }
2689
3645
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
2690
3646
  transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
@@ -2698,15 +3654,15 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2698
3654
  generate: "server"
2699
3655
  }).js.code;
2700
3656
  for (const [spec, compiledChildPath] of childModulePaths) {
2701
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
3657
+ compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
2702
3658
  }
2703
3659
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
2704
3660
  compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
2705
3661
  }
2706
- const compiledModulePath = getCachedModulePath(sourcePath);
2707
- await mkdir(dirname2(compiledModulePath), { recursive: true });
3662
+ const compiledModulePath = getCachedModulePath2(sourcePath);
3663
+ await mkdir2(dirname3(compiledModulePath), { recursive: true });
2708
3664
  await writeIfChanged(compiledModulePath, compiledCode);
2709
- compiledModuleCache.set(sourcePath, compiledModulePath);
3665
+ compiledModuleCache2.set(sourcePath, compiledModulePath);
2710
3666
  return compiledModulePath;
2711
3667
  };
2712
3668
  var init_svelteServerModule = __esm(() => {
@@ -2714,8 +3670,8 @@ var init_svelteServerModule = __esm(() => {
2714
3670
  init_lowerIslandSyntax();
2715
3671
  init_lowerAwaitSlotSyntax();
2716
3672
  init_stylePreprocessor();
2717
- serverCacheRoot = join4(process.cwd(), ".absolutejs", "islands", "svelte");
2718
- compiledModuleCache = new Map;
3673
+ serverCacheRoot2 = join6(process.cwd(), ".absolutejs", "islands", "svelte");
3674
+ compiledModuleCache2 = new Map;
2719
3675
  originalSourcePathCache = new Map;
2720
3676
  transpiler = new Bun.Transpiler({
2721
3677
  loader: "ts",
@@ -2723,18 +3679,31 @@ var init_svelteServerModule = __esm(() => {
2723
3679
  });
2724
3680
  });
2725
3681
 
3682
+ // src/utils/vueCompiler.ts
3683
+ var createVueCompiler = async () => {
3684
+ const [compiler, typescript] = await Promise.all([
3685
+ import("@vue/compiler-sfc"),
3686
+ import("typescript")
3687
+ ]);
3688
+ compiler.registerTS?.(() => typescript);
3689
+ return compiler;
3690
+ }, compilerPromise, loadVueCompiler = () => {
3691
+ compilerPromise ??= createVueCompiler();
3692
+ return compilerPromise;
3693
+ };
3694
+
2726
3695
  // src/core/vueServerModule.ts
2727
3696
  import { existsSync as existsSync4, readFileSync as readFileSync4, realpathSync } from "fs";
2728
- import { mkdir as mkdir2 } from "fs/promises";
2729
- import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
3697
+ import { mkdir as mkdir3 } from "fs/promises";
3698
+ import { dirname as dirname4, join as join7, relative as relative4, resolve as resolve6 } from "path";
2730
3699
  var {Transpiler } = globalThis.Bun;
2731
- var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
2732
- const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
3700
+ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot3, compiledModuleCache3, transpiler2, ensureRelativeImportPath2 = (from, target) => {
3701
+ const importPath = relative4(dirname4(from), target).replace(/\\/g, "/");
2733
3702
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
2734
- }, getCachedModulePath2 = (sourcePath) => {
2735
- const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
3703
+ }, getCachedModulePath3 = (sourcePath) => {
3704
+ const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
2736
3705
  const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2737
- return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
3706
+ return join7(serverCacheRoot3, `${normalizedSourcePath}.server.js`);
2738
3707
  }, writeIfChanged2 = async (path, content) => {
2739
3708
  const targetFile = Bun.file(path);
2740
3709
  if (await targetFile.exists()) {
@@ -2761,10 +3730,10 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2761
3730
  `) : nonVueLines.join(`
2762
3731
  `);
2763
3732
  }, 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) => {
2764
- const cachedModulePath = compiledModuleCache2.get(sourcePath);
3733
+ const cachedModulePath = compiledModuleCache3.get(sourcePath);
2765
3734
  if (cachedModulePath)
2766
3735
  return cachedModulePath;
2767
- const compiler = await import("@vue/compiler-sfc");
3736
+ const compiler = await loadVueCompiler();
2768
3737
  const source = await Bun.file(sourcePath).text();
2769
3738
  const { descriptor } = compiler.parse(source, { filename: sourcePath });
2770
3739
  const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
@@ -2772,8 +3741,8 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2772
3741
  const compiledScript = hasScript ? compiler.compileScript(descriptor, {
2773
3742
  fs: {
2774
3743
  fileExists: existsSync4,
2775
- readFile: (file) => existsSync4(file) ? readFileSync4(file, "utf-8") : undefined,
2776
- realpath: realpathSync
3744
+ realpath: realpathSync,
3745
+ readFile: (file) => existsSync4(file) ? readFileSync4(file, "utf-8") : undefined
2777
3746
  },
2778
3747
  id: componentId,
2779
3748
  inlineTemplate: false
@@ -2794,7 +3763,7 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2794
3763
  }).code : "const ssrRender = () => {};";
2795
3764
  const childImportPaths = extractRelativeVueImports(compiledScript.content);
2796
3765
  const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
2797
- compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
3766
+ compiledPath: await compileVueServerModule(resolve6(dirname4(sourcePath), relativeImport)),
2798
3767
  spec: relativeImport
2799
3768
  })));
2800
3769
  const strippedScript = stripExports(compiledScript.content);
@@ -2806,20 +3775,20 @@ var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, tran
2806
3775
  "export default script;"
2807
3776
  ].join(`
2808
3777
  `));
2809
- const compiledModulePath = getCachedModulePath2(sourcePath);
3778
+ const compiledModulePath = getCachedModulePath3(sourcePath);
2810
3779
  let rewritten = assembled;
2811
3780
  for (const child of compiledChildren) {
2812
3781
  rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
2813
3782
  }
2814
- await mkdir2(dirname3(compiledModulePath), { recursive: true });
3783
+ await mkdir3(dirname4(compiledModulePath), { recursive: true });
2815
3784
  await writeIfChanged2(compiledModulePath, rewritten);
2816
- compiledModuleCache2.set(sourcePath, compiledModulePath);
3785
+ compiledModuleCache3.set(sourcePath, compiledModulePath);
2817
3786
  return compiledModulePath;
2818
3787
  };
2819
3788
  var init_vueServerModule = __esm(() => {
2820
3789
  init_constants();
2821
- serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
2822
- compiledModuleCache2 = new Map;
3790
+ serverCacheRoot3 = join7(process.cwd(), ".absolutejs", "islands", "vue");
3791
+ compiledModuleCache3 = new Map;
2823
3792
  transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
2824
3793
  });
2825
3794
 
@@ -2827,7 +3796,7 @@ var init_vueServerModule = __esm(() => {
2827
3796
  var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
2828
3797
  islandSequence += 1;
2829
3798
  return `island-${islandSequence}`;
2830
- }, isRecord3 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord3(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
3799
+ }, isRecord4 = (value) => typeof value === "object" && value !== null, isReactServerIslandComponent = (value) => typeof value === "function", isSvelteServerIslandComponent = (value) => typeof value === "function", isVueServerIslandComponent = (value) => typeof value === "function" || isRecord4(value), isAngularServerIslandComponent = (value) => typeof value === "function", resolveBuildReferencePath = (source, registryPath) => {
2831
3800
  if (source.startsWith("file://"))
2832
3801
  return new URL(source).pathname;
2833
3802
  if (source.startsWith("."))
@@ -2901,8 +3870,17 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2901
3870
  throw new Error("Resolved Vue island is not a valid Vue component.");
2902
3871
  }
2903
3872
  return resolvedComponent;
3873
+ }, loadAngularServerBuildComponent = async (buildReferencePath, exportName) => {
3874
+ const serverModulePath = await compileAngularServerModule(buildReferencePath);
3875
+ const loadedModule = await import(serverModulePath);
3876
+ if (exportName && exportName !== "default" && exportName in loadedModule) {
3877
+ return loadedModule[exportName];
3878
+ }
3879
+ return "default" in loadedModule ? loadedModule.default : loadedModule;
2904
3880
  }, resolveAngularServerIslandComponent = async (component) => {
2905
- const resolvedComponent = await resolveServerIslandComponent(component);
3881
+ const buildReference = getIslandBuildReference(component);
3882
+ const buildReferencePath = buildReference?.source ? resolveBuildReferencePath(buildReference.source, import.meta.url) : null;
3883
+ const resolvedComponent = buildReferencePath ? await loadAngularServerBuildComponent(buildReferencePath, buildReference?.export) : await resolveServerIslandComponent(component);
2906
3884
  if (!isAngularServerIslandComponent(resolvedComponent)) {
2907
3885
  throw new Error("Resolved Angular island is not a valid Angular component.");
2908
3886
  }
@@ -2958,6 +3936,7 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2958
3936
  };
2959
3937
  var init_renderIslandMarkup = __esm(() => {
2960
3938
  init_islandSsr();
3939
+ init_angularServerModule();
2961
3940
  init_svelteServerModule();
2962
3941
  init_vueServerModule();
2963
3942
  init_islandMarkupAttributes();
@@ -3075,7 +4054,6 @@ var runWithStreamingSlotRegistry = async (task) => {
3075
4054
  };
3076
4055
 
3077
4056
  // src/core/islandPageContext.ts
3078
- init_constants();
3079
4057
  var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
3080
4058
  var ISLAND_MARKER = 'data-island="true"';
3081
4059
  var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
@@ -3196,61 +4174,69 @@ var pipeStreamWithHeadInjection = (stream, markup) => {
3196
4174
  var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
3197
4175
  const encoder = new TextEncoder;
3198
4176
  const decoder = new TextDecoder;
3199
- const lookbehind = Math.max(ISLAND_MARKER.length, BYTES_PER_KILOBYTE);
3200
- const processPending = (controller, pending, injected) => {
3201
- if (injected) {
3202
- controller.enqueue(encoder.encode(pending));
3203
- return { injected, pending: "" };
4177
+ const headLookbehind = CLOSING_HEAD_TAG.length - 1;
4178
+ const enqueue = (controller, text) => {
4179
+ if (text.length > 0) {
4180
+ controller.enqueue(encoder.encode(text));
3204
4181
  }
3205
- const markerIndex = pending.indexOf(ISLAND_MARKER);
3206
- if (markerIndex >= 0) {
3207
- const tagStart = pending.lastIndexOf("<", markerIndex);
3208
- const injectAt = tagStart >= 0 ? tagStart : markerIndex;
3209
- const next = `${pending.slice(0, injectAt)}${markup}${pending.slice(injectAt)}`;
3210
- controller.enqueue(encoder.encode(next));
3211
- return { injected: true, pending: "" };
4182
+ };
4183
+ const processHolding = (controller, held) => {
4184
+ if (!held.includes(ISLAND_MARKER)) {
4185
+ return { held, injected: false, pending: "", sawHead: true };
3212
4186
  }
3213
- return {
3214
- injected,
3215
- pending: flushSafePendingText(controller, encoder, pending, lookbehind)
3216
- };
4187
+ enqueue(controller, `${markup}${held}`);
4188
+ return { held: "", injected: true, pending: "", sawHead: true };
3217
4189
  };
3218
- const finishIslandMarkerStream = (controller, pending) => {
3219
- const finalPending = pending + decoder.decode();
3220
- if (finalPending.length > 0) {
3221
- controller.enqueue(encoder.encode(finalPending));
4190
+ const processHead = (controller, pending) => {
4191
+ const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
4192
+ if (headIndex < 0) {
4193
+ return {
4194
+ held: "",
4195
+ injected: false,
4196
+ pending: flushSafePendingText(controller, encoder, pending, headLookbehind),
4197
+ sawHead: false
4198
+ };
3222
4199
  }
3223
- controller.close();
4200
+ enqueue(controller, pending.slice(0, headIndex));
4201
+ return processHolding(controller, pending.slice(headIndex));
3224
4202
  };
3225
- const consumeIslandChunk = async (controller, reader, pending, injected) => {
3226
- const { done, value } = await readStreamChunk(reader);
3227
- if (done || !value) {
3228
- return { done, injected, pending };
4203
+ const processChunk = (controller, state, chunk) => {
4204
+ if (state.injected) {
4205
+ enqueue(controller, chunk);
4206
+ return state;
3229
4207
  }
3230
- const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
3231
- return {
3232
- done,
3233
- injected: processed.injected,
3234
- pending: processed.pending
3235
- };
4208
+ if (!state.sawHead) {
4209
+ return processHead(controller, state.pending + chunk);
4210
+ }
4211
+ return processHolding(controller, state.held + chunk);
3236
4212
  };
3237
- const runIslandMarkerLoop = async (controller, reader) => {
3238
- const consumeNextIslandChunk = async (injected, pending) => {
3239
- const consumed = await consumeIslandChunk(controller, reader, pending, injected);
3240
- const nextState = updateInjectedState(consumed, injected, pending);
3241
- if (nextState.done) {
3242
- return { injected, pending };
4213
+ const finishMarkerStream = (controller, state) => {
4214
+ const tail = decoder.decode();
4215
+ const remainder = state.injected ? tail : (state.sawHead ? state.held : state.pending) + tail;
4216
+ enqueue(controller, remainder);
4217
+ controller.close();
4218
+ };
4219
+ const runMarkerLoop = (controller, reader) => {
4220
+ const consumeNext = async (state) => {
4221
+ const { done, value } = await readStreamChunk(reader);
4222
+ if (done || !value) {
4223
+ return state;
3243
4224
  }
3244
- return consumeNextIslandChunk(nextState.injected, nextState.pending);
4225
+ return consumeNext(processChunk(controller, state, streamChunkToString(value, decoder)));
3245
4226
  };
3246
- return consumeNextIslandChunk(false, "");
4227
+ return consumeNext({
4228
+ held: "",
4229
+ injected: false,
4230
+ pending: "",
4231
+ sawHead: false
4232
+ });
3247
4233
  };
3248
4234
  return new ReadableStream({
3249
4235
  async start(controller) {
3250
4236
  const reader = stream.getReader();
3251
4237
  try {
3252
- const { pending } = await runIslandMarkerLoop(controller, reader);
3253
- finishIslandMarkerStream(controller, pending);
4238
+ const finalState = await runMarkerLoop(controller, reader);
4239
+ finishMarkerStream(controller, finalState);
3254
4240
  } catch (error) {
3255
4241
  controller.error(error);
3256
4242
  }
@@ -3289,33 +4275,309 @@ var setCurrentIslandManifest = (manifest) => {
3289
4275
  // src/react/pageHandler.ts
3290
4276
  init_devRouteRegistrationCallsite();
3291
4277
 
3292
- // src/core/responseEnhancers.ts
3293
- init_streamingSlots();
3294
- var toResponse = async (responseLike) => responseLike;
3295
- var cloneHeaders = (response) => {
3296
- const headers = new Headers(response.headers);
3297
- return headers;
4278
+ // src/core/requestContext.ts
4279
+ import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
4280
+ import { Elysia as Elysia2 } from "elysia";
4281
+ var REQUEST_STORAGE_KEY = Symbol.for("absolutejs.requestAsyncLocalStorage");
4282
+ var isAbsoluteRequestStorage = (value) => typeof value === "object" && value !== null && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
4283
+ var getRequestStorage = () => {
4284
+ const value = Reflect.get(globalThis, REQUEST_STORAGE_KEY);
4285
+ return isAbsoluteRequestStorage(value) ? value : undefined;
3298
4286
  };
3299
- var enhanceHtmlResponseWithStreamingSlots = (response, {
3300
- nonce,
3301
- onError,
3302
- runtimePlacement,
3303
- runtimePreludeScript,
3304
- streamingSlots = [],
3305
- policy
3306
- } = {}) => {
3307
- if (!response.body || streamingSlots.length === 0) {
3308
- return response;
3309
- }
3310
- const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
3311
- nonce,
4287
+ var ensureRequestStorage = () => {
4288
+ const existing = getRequestStorage();
4289
+ if (existing)
4290
+ return existing;
4291
+ const storage = new AsyncLocalStorage2;
4292
+ Reflect.set(globalThis, REQUEST_STORAGE_KEY, storage);
4293
+ return storage;
4294
+ };
4295
+ var absoluteRequestContext = new Elysia2({
4296
+ name: "absolutejs-request-context"
4297
+ }).request(({ request }) => {
4298
+ ensureRequestStorage().enterWith({ request });
4299
+ }).as("global");
4300
+ var getCurrentAbsoluteRequest = () => getRequestStorage()?.getStore()?.request;
4301
+ var runWithAbsoluteRequest = (request, callback) => ensureRequestStorage().run({ request }, callback);
4302
+
4303
+ // src/mobile/producerContextState.ts
4304
+ var ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY = Symbol.for("absolutejs.mobileProducerAsyncLocalStorage");
4305
+ var frameworks = new Set([
4306
+ "angular",
4307
+ "ember",
4308
+ "html",
4309
+ "htmx",
4310
+ "react",
4311
+ "svelte",
4312
+ "vue"
4313
+ ]);
4314
+ var isCompatibilityPage = (value) => typeof value === "object" && value !== null && ("bundleHash" in value) && typeof value.bundleHash === "string" && ("contract" in value) && typeof value.contract === "string" && ("framework" in value) && typeof value.framework === "string" && frameworks.has(value.framework) && ("pageId" in value) && typeof value.pageId === "string" && ("propsSchemaHash" in value) && typeof value.propsSchemaHash === "string";
4315
+ var getCurrentAbsoluteMobileProducerContext = () => {
4316
+ const value = Reflect.get(globalThis, ABSOLUTE_MOBILE_PRODUCER_STORAGE_KEY);
4317
+ if (typeof value !== "object" || value === null || !("getStore" in value) || typeof value.getStore !== "function") {
4318
+ return;
4319
+ }
4320
+ const context = value.getStore();
4321
+ if (typeof context !== "object" || context === null || !("page" in context) || !isCompatibilityPage(context.page) || !("releaseId" in context) || typeof context.releaseId !== "string") {
4322
+ return;
4323
+ }
4324
+ return { page: context.page, releaseId: context.releaseId };
4325
+ };
4326
+
4327
+ // src/mobile/pageProtocol.ts
4328
+ var ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE = "application/vnd.absolute.page+json";
4329
+ var ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION = 1;
4330
+ var BAD_REQUEST_STATUS = 400;
4331
+ var OK_STATUS = 200;
4332
+ var SERVER_ERROR_STATUS = 500;
4333
+ var UPGRADE_REQUIRED_STATUS = 426;
4334
+ var MOBILE_PAGE_REQUEST_HEADERS = {
4335
+ appBuild: "x-absolute-mobile-app-build",
4336
+ pageBundle: "x-absolute-mobile-page-bundle",
4337
+ pageContracts: "x-absolute-mobile-page-contracts",
4338
+ pageId: "x-absolute-mobile-page-id",
4339
+ protocol: "x-absolute-mobile-protocol",
4340
+ runtime: "x-absolute-mobile-runtime"
4341
+ };
4342
+ var parseMediaType = (value) => value.split(";", 1)[0]?.trim().toLowerCase();
4343
+ var acceptsAbsoluteMobilePage = (request) => {
4344
+ if (!request)
4345
+ return false;
4346
+ return (request.headers.get("accept") ?? "").split(",").some((value) => parseMediaType(value) === ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE);
4347
+ };
4348
+ var readRequiredHeader = (request, name) => {
4349
+ const value = request.headers.get(name)?.trim();
4350
+ return value ? value : undefined;
4351
+ };
4352
+ var parseAbsoluteMobilePageRequest = (request) => {
4353
+ if (!request || !acceptsAbsoluteMobilePage(request)) {
4354
+ return { kind: "not-mobile" };
4355
+ }
4356
+ const protocolValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.protocol);
4357
+ const runtime = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.runtime);
4358
+ const appBuild = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.appBuild);
4359
+ const pageBundle = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageBundle);
4360
+ const pageContractsValue = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageContracts);
4361
+ const pageId = readRequiredHeader(request, MOBILE_PAGE_REQUEST_HEADERS.pageId);
4362
+ if (!protocolValue || !/^\d+$/.test(protocolValue)) {
4363
+ return {
4364
+ kind: "invalid",
4365
+ message: `Missing or invalid ${MOBILE_PAGE_REQUEST_HEADERS.protocol} header.`
4366
+ };
4367
+ }
4368
+ if (!runtime) {
4369
+ return {
4370
+ kind: "invalid",
4371
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.runtime} header.`
4372
+ };
4373
+ }
4374
+ if (!appBuild) {
4375
+ return {
4376
+ kind: "invalid",
4377
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.appBuild} header.`
4378
+ };
4379
+ }
4380
+ if (!pageBundle) {
4381
+ return {
4382
+ kind: "invalid",
4383
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageBundle} header.`
4384
+ };
4385
+ }
4386
+ if (!pageContractsValue) {
4387
+ return {
4388
+ kind: "invalid",
4389
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} header.`
4390
+ };
4391
+ }
4392
+ if (!pageId) {
4393
+ return {
4394
+ kind: "invalid",
4395
+ message: `Missing ${MOBILE_PAGE_REQUEST_HEADERS.pageId} header.`
4396
+ };
4397
+ }
4398
+ const pageContracts = [
4399
+ ...new Set(pageContractsValue.split(",").map((value) => value.trim()).filter(Boolean))
4400
+ ];
4401
+ if (pageContracts.length === 0) {
4402
+ return {
4403
+ kind: "invalid",
4404
+ message: `${MOBILE_PAGE_REQUEST_HEADERS.pageContracts} must contain at least one contract.`
4405
+ };
4406
+ }
4407
+ return {
4408
+ client: {
4409
+ appBuild,
4410
+ pageBundle,
4411
+ pageContracts,
4412
+ pageId,
4413
+ protocol: Number(protocolValue),
4414
+ runtime
4415
+ },
4416
+ kind: "mobile"
4417
+ };
4418
+ };
4419
+ var responseHeaders = () => {
4420
+ const headers = new Headers({
4421
+ "cache-control": "no-store",
4422
+ "content-type": `${ABSOLUTE_MOBILE_PAGE_MEDIA_TYPE}; version=${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`
4423
+ });
4424
+ headerVaryValues.forEach((value) => headers.append("vary", value));
4425
+ return headers;
4426
+ };
4427
+ var headerVaryValues = [
4428
+ "Accept",
4429
+ MOBILE_PAGE_REQUEST_HEADERS.protocol,
4430
+ MOBILE_PAGE_REQUEST_HEADERS.runtime,
4431
+ MOBILE_PAGE_REQUEST_HEADERS.appBuild,
4432
+ MOBILE_PAGE_REQUEST_HEADERS.pageBundle,
4433
+ MOBILE_PAGE_REQUEST_HEADERS.pageContracts,
4434
+ MOBILE_PAGE_REQUEST_HEADERS.pageId
4435
+ ];
4436
+ var envelopeResponse = (response, status) => new Response(JSON.stringify({
4437
+ protocol: ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION,
4438
+ response
4439
+ }), { headers: responseHeaders(), status });
4440
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4441
+ var normalizeJsonValue = (value) => {
4442
+ const serialized = JSON.stringify(value);
4443
+ if (serialized === undefined) {
4444
+ throw new TypeError("Mobile page props must be JSON-serializable.");
4445
+ }
4446
+ const parsed = JSON.parse(serialized);
4447
+ if (!isRecord(parsed)) {
4448
+ throw new TypeError("Mobile page props must serialize to an object.");
4449
+ }
4450
+ return parsed;
4451
+ };
4452
+ var finalizeArchivedMobilePage = (context, input) => {
4453
+ const { page } = context;
4454
+ if (page.pageId !== input.compatibility.pageId || page.framework !== input.compatibility.framework) {
4455
+ return envelopeResponse({
4456
+ kind: "invalid-request",
4457
+ message: "Archived producer page identity does not match its release artifact."
4458
+ }, BAD_REQUEST_STATUS);
4459
+ }
4460
+ try {
4461
+ const [currentRepresentation] = input.compatibility.representations;
4462
+ if (!currentRepresentation) {
4463
+ throw new TypeError("Mobile page has no current representation.");
4464
+ }
4465
+ return envelopeResponse({
4466
+ contract: page.contract,
4467
+ framework: page.framework,
4468
+ kind: "page",
4469
+ pageId: page.pageId,
4470
+ props: normalizeJsonValue(currentRepresentation.mapProps(input.props)),
4471
+ status: input.status ?? OK_STATUS
4472
+ }, input.status ?? OK_STATUS);
4473
+ } catch (error) {
4474
+ console.error(`[Mobile] Archived producer ${context.releaseId} failed for ${page.pageId}:`, error);
4475
+ return createAbsoluteMobilePageErrorResponse(page.pageId);
4476
+ }
4477
+ };
4478
+ var createAbsoluteMobileInvalidRequestResponse = (message) => envelopeResponse({ kind: "invalid-request", message }, BAD_REQUEST_STATUS);
4479
+ var createAbsoluteMobilePageErrorResponse = (pageId) => envelopeResponse({
4480
+ code: "representation-failed",
4481
+ kind: "error",
4482
+ pageId,
4483
+ status: SERVER_ERROR_STATUS
4484
+ }, SERVER_ERROR_STATUS);
4485
+ var createAbsoluteMobileUpgradeResponse = (result) => envelopeResponse(result, UPGRADE_REQUIRED_STATUS);
4486
+ var finalizeAbsoluteMobilePage = (input) => {
4487
+ const parsed = parseAbsoluteMobilePageRequest(input.request);
4488
+ if (parsed.kind === "not-mobile")
4489
+ return;
4490
+ if (parsed.kind === "invalid") {
4491
+ return envelopeResponse({ kind: "invalid-request", message: parsed.message }, BAD_REQUEST_STATUS);
4492
+ }
4493
+ const { client } = parsed;
4494
+ if (client.pageId !== input.compatibility.pageId) {
4495
+ return envelopeResponse({
4496
+ kind: "invalid-request",
4497
+ message: `Requested mobile page ${client.pageId} does not match ${input.compatibility.pageId}.`
4498
+ }, BAD_REQUEST_STATUS);
4499
+ }
4500
+ const producerContext = getCurrentAbsoluteMobileProducerContext();
4501
+ if (producerContext)
4502
+ return finalizeArchivedMobilePage(producerContext, input);
4503
+ if (client.protocol !== ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION) {
4504
+ return envelopeResponse({
4505
+ kind: "upgrade-required",
4506
+ pageId: input.compatibility.pageId,
4507
+ reason: "protocol"
4508
+ }, UPGRADE_REQUIRED_STATUS);
4509
+ }
4510
+ if (!input.compatibility.runtimes.includes(client.runtime)) {
4511
+ return envelopeResponse({
4512
+ kind: "upgrade-required",
4513
+ pageId: input.compatibility.pageId,
4514
+ reason: "runtime",
4515
+ supportedRuntimes: [...input.compatibility.runtimes]
4516
+ }, UPGRADE_REQUIRED_STATUS);
4517
+ }
4518
+ const clientContracts = new Set(client.pageContracts);
4519
+ const representation = input.compatibility.representations.find(({ contract }) => clientContracts.has(contract));
4520
+ if (!representation) {
4521
+ return envelopeResponse({
4522
+ kind: "upgrade-required",
4523
+ pageId: input.compatibility.pageId,
4524
+ reason: "page-contract",
4525
+ supportedContracts: input.compatibility.representations.map(({ contract }) => contract)
4526
+ }, UPGRADE_REQUIRED_STATUS);
4527
+ }
4528
+ try {
4529
+ return envelopeResponse({
4530
+ contract: representation.contract,
4531
+ framework: input.compatibility.framework,
4532
+ kind: "page",
4533
+ pageId: input.compatibility.pageId,
4534
+ props: normalizeJsonValue(representation.mapProps(input.props)),
4535
+ status: input.status ?? OK_STATUS
4536
+ }, input.status ?? OK_STATUS);
4537
+ } catch (error) {
4538
+ console.error(`[Mobile] Failed to produce ${input.compatibility.pageId} representation ${representation.contract}:`, error);
4539
+ return envelopeResponse({
4540
+ code: "representation-failed",
4541
+ kind: "error",
4542
+ pageId: input.compatibility.pageId,
4543
+ status: SERVER_ERROR_STATUS
4544
+ }, SERVER_ERROR_STATUS);
4545
+ }
4546
+ };
4547
+
4548
+ // src/react/pageHandler.ts
4549
+ init_pageResponseCache();
4550
+
4551
+ // src/core/responseEnhancers.ts
4552
+ init_streamingSlots();
4553
+ init_pageResponseCache();
4554
+ var toResponse = async (responseLike) => responseLike;
4555
+ var cloneHeaders = (response) => {
4556
+ const headers = new Headers(response.headers);
4557
+ return headers;
4558
+ };
4559
+ var enhanceHtmlResponseWithStreamingSlots = (response, {
4560
+ nonce,
4561
+ onError,
4562
+ runtimePlacement,
4563
+ runtimePreludeScript,
4564
+ streamingSlots = [],
4565
+ policy
4566
+ } = {}) => {
4567
+ if (!response.body || streamingSlots.length === 0) {
4568
+ return response;
4569
+ }
4570
+ const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
4571
+ nonce,
3312
4572
  onError,
3313
4573
  policy,
3314
4574
  runtimePlacement,
3315
4575
  runtimePreludeScript
3316
4576
  });
4577
+ const headers = cloneHeaders(response);
4578
+ headers.set(STREAMING_PAGE_HEADER, "1");
3317
4579
  return new Response(body, {
3318
- headers: cloneHeaders(response),
4580
+ headers,
3319
4581
  status: response.status,
3320
4582
  statusText: response.statusText
3321
4583
  });
@@ -3340,7 +4602,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
3340
4602
 
3341
4603
  // src/core/streamingSlotWarningScope.ts
3342
4604
  init_logger();
3343
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
4605
+ import { AsyncLocalStorage as AsyncLocalStorage3 } from "async_hooks";
3344
4606
  var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
3345
4607
  var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
3346
4608
  var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
@@ -3356,7 +4618,7 @@ var ensureWarningStorage = () => {
3356
4618
  if (existing) {
3357
4619
  return existing;
3358
4620
  }
3359
- const storage = new AsyncLocalStorage2;
4621
+ const storage = new AsyncLocalStorage3;
3360
4622
  Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
3361
4623
  return storage;
3362
4624
  };
@@ -3395,303 +4657,11 @@ var captureStreamingSlotWarningCallsite = () => {
3395
4657
  return extractCallsiteFromStack(stack);
3396
4658
  };
3397
4659
  var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
3398
- // src/utils/resolveConvention.ts
3399
- import { basename } from "path";
3400
- var CONVENTIONS_KEY = "__absoluteConventions";
3401
- var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
3402
- var getMap = () => {
3403
- const value = Reflect.get(globalThis, CONVENTIONS_KEY);
3404
- if (isConventionsMap(value))
3405
- return value;
3406
- const empty = {};
3407
- return empty;
3408
- };
3409
- var derivePageName = (pagePath) => {
3410
- const base = basename(pagePath);
3411
- const dotIndex = base.indexOf(".");
3412
- const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
3413
- return toPascal(name);
3414
- };
3415
- var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
3416
- var resolveErrorConventionPath = (framework, pageName) => {
3417
- const conventions = getMap()[framework];
3418
- if (!conventions)
3419
- return;
3420
- const exact = conventions.pages?.[pageName]?.error;
3421
- if (exact)
3422
- return exact;
3423
- const normalizedPageName = normalizeConventionPageName(pageName);
3424
- for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
3425
- if (normalizeConventionPageName(candidate) === normalizedPageName) {
3426
- return page.error ?? conventions.defaults?.error;
3427
- }
3428
- }
3429
- return conventions.defaults?.error;
3430
- };
3431
- var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
3432
- var hasErrorConvention = (framework) => {
3433
- const conventions = getMap()[framework];
3434
- if (!conventions)
3435
- return false;
3436
- if (conventions.defaults?.error)
3437
- return true;
3438
- return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
3439
- };
3440
- var setConventions = (map) => {
3441
- Reflect.set(globalThis, CONVENTIONS_KEY, map);
3442
- };
3443
- var isDev = () => true;
3444
- var buildErrorProps = (error) => {
3445
- if (error instanceof Error) {
3446
- return {
3447
- name: error.name,
3448
- message: error.message,
3449
- ...isDev() && error.stack ? { stack: error.stack } : {}
3450
- };
3451
- }
3452
- return { name: "Error", message: String(error) };
3453
- };
3454
- var renderReactError = async (conventionPath, errorProps) => {
3455
- const { createElement } = await import("react");
3456
- const { renderToReadableStream } = await import("react-dom/server");
3457
- const mod = await import(conventionPath);
3458
- const ErrorComponent = mod.default;
3459
- if (typeof ErrorComponent !== "function")
3460
- return null;
3461
- const element = createElement(ErrorComponent, errorProps);
3462
- const stream = await renderToReadableStream(element);
3463
- return new Response(stream, {
3464
- headers: { "Content-Type": "text/html" },
3465
- status: 500
3466
- });
3467
- };
3468
- var renderSvelteError = async (conventionPath, errorProps) => {
3469
- const { render } = await import("svelte/server");
3470
- const mod = await import(conventionPath);
3471
- const ErrorComponent = mod.default;
3472
- if (!ErrorComponent)
3473
- return null;
3474
- const { head, body } = render(ErrorComponent, {
3475
- props: errorProps
3476
- });
3477
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3478
- return new Response(html, {
3479
- headers: { "Content-Type": "text/html" },
3480
- status: 500
3481
- });
3482
- };
3483
- var unescapeVueStyles = (ssrBody) => {
3484
- let styles = "";
3485
- const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
3486
- styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
3487
- return "";
3488
- });
3489
- return { body, styles };
3490
- };
3491
- var renderVueError = async (conventionPath, errorProps) => {
3492
- const { createSSRApp, h } = await import("vue");
3493
- const { renderToString } = await import("vue/server-renderer");
3494
- const mod = await import(conventionPath);
3495
- const ErrorComponent = mod.default;
3496
- if (!ErrorComponent)
3497
- return null;
3498
- const app = createSSRApp({
3499
- render: () => h(ErrorComponent, errorProps)
3500
- });
3501
- const rawBody = await renderToString(app);
3502
- const { styles, body } = unescapeVueStyles(rawBody);
3503
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
3504
- return new Response(html, {
3505
- headers: { "Content-Type": "text/html" },
3506
- status: 500
3507
- });
3508
- };
3509
- var renderAngularError = async (conventionPath, errorProps) => {
3510
- const mod = await import(conventionPath);
3511
- const renderFn = mod.default;
3512
- if (typeof renderFn !== "function")
3513
- return null;
3514
- const html = renderFn(errorProps);
3515
- return new Response(html, {
3516
- headers: { "Content-Type": "text/html" },
3517
- status: 500
3518
- });
3519
- };
3520
- var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
3521
- 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) : "");
3522
- var renderHtmlError = async (conventionPath, errorProps) => {
3523
- const template = await Bun.file(conventionPath).text();
3524
- const html = replaceErrorTokens(template, errorProps);
3525
- return new Response(html, {
3526
- headers: { "Content-Type": "text/html" },
3527
- status: 500
3528
- });
3529
- };
3530
- var logConventionRenderError = (framework, label, renderError) => {
3531
- const message = renderError instanceof Error ? renderError.message : "";
3532
- if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
3533
- 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}).`);
3534
- return;
3535
- }
3536
- console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
3537
- };
3538
- var renderEmberError = async () => null;
3539
- var renderEmberNotFound = async () => null;
3540
- var ERROR_RENDERERS = {
3541
- angular: renderAngularError,
3542
- ember: renderEmberError,
3543
- html: renderHtmlError,
3544
- react: renderReactError,
3545
- svelte: renderSvelteError,
3546
- vue: renderVueError
3547
- };
3548
- var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
3549
- let conventionPath = resolveErrorConventionPath(framework, pageName);
3550
- if (!conventionPath && error instanceof Error && error.stack) {
3551
- for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
3552
- const candidate = match[1];
3553
- if (!candidate)
3554
- continue;
3555
- conventionPath = resolveErrorConventionPath(framework, candidate);
3556
- if (conventionPath)
3557
- break;
3558
- }
3559
- }
3560
- if (!conventionPath)
3561
- return null;
3562
- const renderer = ERROR_RENDERERS[framework];
3563
- if (!renderer)
3564
- return null;
3565
- try {
3566
- return await renderer(conventionPath, errorProps);
3567
- } catch (renderError) {
3568
- logConventionRenderError(framework, "error", renderError);
3569
- }
3570
- return null;
3571
- };
3572
- var renderConventionError = async (framework, pageName, error) => {
3573
- const errorProps = buildErrorProps(error);
3574
- const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
3575
- if (frameworkResponse)
3576
- return frameworkResponse;
3577
- if (framework !== "html") {
3578
- const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
3579
- if (htmlResponse)
3580
- return htmlResponse;
3581
- }
3582
- return null;
3583
- };
3584
- var renderReactNotFound = async (conventionPath) => {
3585
- const { createElement } = await import("react");
3586
- const { renderToReadableStream } = await import("react-dom/server");
3587
- const mod = await import(conventionPath);
3588
- const NotFoundComponent = mod.default;
3589
- if (typeof NotFoundComponent !== "function")
3590
- return null;
3591
- const element = createElement(NotFoundComponent);
3592
- const stream = await renderToReadableStream(element);
3593
- return new Response(stream, {
3594
- headers: { "Content-Type": "text/html" },
3595
- status: 404
3596
- });
3597
- };
3598
- var renderSvelteNotFound = async (conventionPath) => {
3599
- const { render } = await import("svelte/server");
3600
- const mod = await import(conventionPath);
3601
- const NotFoundComponent = mod.default;
3602
- if (!NotFoundComponent)
3603
- return null;
3604
- const { head, body } = render(NotFoundComponent);
3605
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
3606
- return new Response(html, {
3607
- headers: { "Content-Type": "text/html" },
3608
- status: 404
3609
- });
3610
- };
3611
- var renderVueNotFound = async (conventionPath) => {
3612
- const { createSSRApp, h } = await import("vue");
3613
- const { renderToString } = await import("vue/server-renderer");
3614
- const mod = await import(conventionPath);
3615
- const NotFoundComponent = mod.default;
3616
- if (!NotFoundComponent)
3617
- return null;
3618
- const app = createSSRApp({
3619
- render: () => h(NotFoundComponent)
3620
- });
3621
- const rawBody = await renderToString(app);
3622
- const { styles, body } = unescapeVueStyles(rawBody);
3623
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
3624
- return new Response(html, {
3625
- headers: { "Content-Type": "text/html" },
3626
- status: 404
3627
- });
3628
- };
3629
- var renderAngularNotFound = async (conventionPath) => {
3630
- const mod = await import(conventionPath);
3631
- const renderFn = mod.default;
3632
- if (typeof renderFn !== "function")
3633
- return null;
3634
- const html = renderFn();
3635
- return new Response(html, {
3636
- headers: { "Content-Type": "text/html" },
3637
- status: 404
3638
- });
3639
- };
3640
- var renderHtmlNotFound = async (conventionPath) => {
3641
- const html = await Bun.file(conventionPath).text();
3642
- return new Response(html, {
3643
- headers: { "Content-Type": "text/html" },
3644
- status: 404
3645
- });
3646
- };
3647
- var NOT_FOUND_RENDERERS = {
3648
- angular: renderAngularNotFound,
3649
- ember: renderEmberNotFound,
3650
- html: renderHtmlNotFound,
3651
- react: renderReactNotFound,
3652
- svelte: renderSvelteNotFound,
3653
- vue: renderVueNotFound
3654
- };
3655
- var renderConventionNotFound = async (framework) => {
3656
- const conventionPath = resolveNotFoundConventionPath(framework);
3657
- if (!conventionPath)
3658
- return null;
3659
- const renderer = NOT_FOUND_RENDERERS[framework];
3660
- if (!renderer)
3661
- return null;
3662
- try {
3663
- return await renderer(conventionPath);
3664
- } catch (renderError) {
3665
- logConventionRenderError(framework, "not-found", renderError);
3666
- }
3667
- return null;
3668
- };
3669
- var NOT_FOUND_PRIORITY = [
3670
- "react",
3671
- "svelte",
3672
- "vue",
3673
- "angular",
3674
- "html"
3675
- ];
3676
- var renderFirstNotFound = async () => {
3677
- const renderNext = async (frameworks) => {
3678
- const [framework, ...remaining] = frameworks;
3679
- if (!framework) {
3680
- return null;
3681
- }
3682
- if (!getMap()[framework]?.defaults?.notFound) {
3683
- return renderNext(remaining);
3684
- }
3685
- const response = await renderConventionNotFound(framework);
3686
- if (response) {
3687
- return response;
3688
- }
3689
- return renderNext(remaining);
3690
- };
3691
- return renderNext(NOT_FOUND_PRIORITY);
3692
- };
3693
4660
 
3694
4661
  // src/react/pageHandler.ts
4662
+ init_spaRouteManifest();
4663
+ init_resolveConvention();
4664
+ var withRequestUrl = (props, url) => Object.assign(Object.create(null), props, { url });
3695
4665
  var resolveRequestPathname = (request) => {
3696
4666
  if (!request)
3697
4667
  return;
@@ -3707,17 +4677,34 @@ var buildRefreshSetup = () => {
3707
4677
  return "window.__REFRESH_BUFFER__=[];" + "window.$RefreshReg$=function(t,i){window.__REFRESH_BUFFER__.push([t,i])};" + "window.$RefreshSig$=function(){return function(t){return t}};";
3708
4678
  };
3709
4679
  var handleReactPageRequest = async (input) => {
3710
- const Page = input.Page;
4680
+ const { Page } = input;
3711
4681
  const resolvedIndex = input.index;
3712
4682
  const options = input;
3713
4683
  const userProps = input.props;
3714
- const requestPathname = resolveRequestPathname(input.request);
3715
- const maybeProps = requestPathname !== undefined && (!userProps || !("url" in userProps)) ? {
3716
- ...userProps ?? {},
3717
- url: requestPathname
3718
- } : userProps;
4684
+ const request = input.request ?? getCurrentAbsoluteRequest();
4685
+ const requestPathname = resolveRequestPathname(request);
4686
+ const maybeProps = requestPathname !== undefined && (!userProps || !("url" in userProps)) ? withRequestUrl(userProps, requestPathname) : userProps;
3719
4687
  const pageName = Page.name || Page.displayName || "";
4688
+ const pageId = input.__absoluteMobile?.pageId ?? (pageName || resolvedIndex);
4689
+ const currentContract = input.__absoluteMobile?.contract ?? `react:${pageId}:${ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION}`;
4690
+ const mobileResponse = finalizeAbsoluteMobilePage({
4691
+ compatibility: {
4692
+ framework: "react",
4693
+ pageId,
4694
+ representations: [
4695
+ { contract: currentContract, mapProps: (props) => props }
4696
+ ],
4697
+ runtimes: [String(ABSOLUTE_MOBILE_PAGE_PROTOCOL_VERSION)]
4698
+ },
4699
+ props: maybeProps ?? Object.create(null),
4700
+ request
4701
+ });
4702
+ if (mobileResponse)
4703
+ return mobileResponse;
3720
4704
  try {
4705
+ const spaNotFound = await renderSpaNotFound("react", pageName, request);
4706
+ if (spaNotFound)
4707
+ return withPageCacheHeaders(spaNotFound, request);
3721
4708
  const handlerCallsite = options?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
3722
4709
  const renderPageResponse = async () => {
3723
4710
  const { createElement } = await import("react");
@@ -3740,19 +4727,23 @@ var handleReactPageRequest = async (input) => {
3740
4727
  });
3741
4728
  }
3742
4729
  return new Response(htmlStream, {
3743
- headers: { "Content-Type": "text/html" }
4730
+ headers: streamingPageHeaders()
3744
4731
  });
3745
4732
  };
3746
- return await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
4733
+ const pageResponse = await runWithStreamingSlotWarningScope(() => options?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, options) : renderPageResponse(), { handlerCallsite });
4734
+ return withPageCacheHeaders(pageResponse, request, {
4735
+ bufferStreamForEtag: input.bufferStreamForEtag
4736
+ });
3747
4737
  } catch (error) {
3748
4738
  console.error("[SSR] React render error:", error);
3749
4739
  const conventionResponse = await renderConventionError("react", pageName, error);
3750
- if (conventionResponse)
3751
- return conventionResponse;
3752
- return new Response(ssrErrorPage("react", error), {
4740
+ if (conventionResponse) {
4741
+ return withPageCacheHeaders(conventionResponse, request);
4742
+ }
4743
+ return withPageCacheHeaders(new Response(ssrErrorPage("react", error), {
3753
4744
  headers: { "Content-Type": "text/html" },
3754
4745
  status: 500
3755
- });
4746
+ }), request);
3756
4747
  }
3757
4748
  };
3758
4749
  // src/react/Island.tsx
@@ -3792,32 +4783,6 @@ var createTypedIsland = (registry) => {
3792
4783
  };
3793
4784
  return Island2;
3794
4785
  };
3795
- // src/react/UniversalRouter.tsx
3796
- import { createElement } from "react";
3797
- var cachedReactRouter = null;
3798
- var loadReactRouter = () => {
3799
- if (cachedReactRouter)
3800
- return cachedReactRouter;
3801
- try {
3802
- const dynamicRequire = new Function("spec", "return require(spec)");
3803
- cachedReactRouter = dynamicRequire("react-router");
3804
- return cachedReactRouter;
3805
- } catch {
3806
- const fromWindow = globalThis.ReactRouterDOM;
3807
- if (fromWindow) {
3808
- cachedReactRouter = fromWindow;
3809
- return cachedReactRouter;
3810
- }
3811
- throw new Error("[UniversalRouter] react-router is not installed. Install it with `bun add react-router` to use UniversalRouter.");
3812
- }
3813
- };
3814
- var UniversalRouter = ({ url, children }) => {
3815
- const { BrowserRouter, StaticRouter } = loadReactRouter();
3816
- if (typeof window === "undefined") {
3817
- return createElement(StaticRouter, { location: url ?? "/" }, children);
3818
- }
3819
- return createElement(BrowserRouter, null, children);
3820
- };
3821
4786
  // src/react/hooks/useIslandStore.ts
3822
4787
  import { useSyncExternalStore } from "react";
3823
4788
 
@@ -3942,9 +4907,8 @@ export {
3942
4907
  useIslandStore,
3943
4908
  handleReactPageRequest,
3944
4909
  createTypedIsland,
3945
- UniversalRouter,
3946
4910
  Island
3947
4911
  };
3948
4912
 
3949
- //# debugId=01BEBE5786E9771C64756E2164756E21
4913
+ //# debugId=7CE6A5979AFA5A9664756E2164756E21
3950
4914
  //# sourceMappingURL=index.js.map