@absolutejs/absolute 0.19.0-beta.1041 → 0.19.0-beta.1043

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 (519) hide show
  1. package/package.json +1 -1
  2. package/dist/angular/browser.js +0 -10358
  3. package/dist/angular/browser.js.map +0 -260
  4. package/dist/angular/components/constants.js +0 -101
  5. package/dist/angular/components/core/streamingSlotRegistrar.js +0 -58
  6. package/dist/angular/components/core/streamingSlotRegistry.js +0 -114
  7. package/dist/angular/components/defer-slot-payload.js +0 -6
  8. package/dist/angular/components/defer-slot-templates.directive.js +0 -44
  9. package/dist/angular/components/defer-slot.component.js +0 -152
  10. package/dist/angular/components/image.component.js +0 -202
  11. package/dist/angular/components/index.js +0 -4
  12. package/dist/angular/components/stream-slot.component.js +0 -102
  13. package/dist/angular/hmrPreserveCore.ts +0 -188
  14. package/dist/angular/index.js +0 -15793
  15. package/dist/angular/index.js.map +0 -299
  16. package/dist/angular/server.js +0 -6357
  17. package/dist/angular/server.js.map +0 -61
  18. package/dist/build.js +0 -27484
  19. package/dist/build.js.map +0 -146
  20. package/dist/cli/config/client.js +0 -527
  21. package/dist/cli/config/server.js +0 -37130
  22. package/dist/cli/htmx/htmx.min.js +0 -1
  23. package/dist/cli/index.js +0 -179275
  24. package/dist/client/index.js +0 -1267
  25. package/dist/client/index.js.map +0 -31
  26. package/dist/core/streamingSlotRegistrar.js +0 -138
  27. package/dist/core/streamingSlotRegistrar.js.map +0 -10
  28. package/dist/core/streamingSlotRegistry.js +0 -194
  29. package/dist/core/streamingSlotRegistry.js.map +0 -11
  30. package/dist/dev/client/constants.ts +0 -26
  31. package/dist/dev/client/cssUtils.ts +0 -311
  32. package/dist/dev/client/domDiff.ts +0 -226
  33. package/dist/dev/client/domState.ts +0 -423
  34. package/dist/dev/client/domTracker.ts +0 -61
  35. package/dist/dev/client/errorOverlay.ts +0 -445
  36. package/dist/dev/client/frameworkDetect.ts +0 -63
  37. package/dist/dev/client/handlers/angularHmrShim.ts +0 -88
  38. package/dist/dev/client/handlers/angularRemount.ts +0 -362
  39. package/dist/dev/client/handlers/angularRemountWiring.ts +0 -52
  40. package/dist/dev/client/handlers/html.ts +0 -364
  41. package/dist/dev/client/handlers/htmx.ts +0 -278
  42. package/dist/dev/client/handlers/react.ts +0 -108
  43. package/dist/dev/client/handlers/rebuild.ts +0 -153
  44. package/dist/dev/client/handlers/svelte.ts +0 -334
  45. package/dist/dev/client/handlers/vue.ts +0 -292
  46. package/dist/dev/client/headPatch.ts +0 -233
  47. package/dist/dev/client/hmrClient.ts +0 -352
  48. package/dist/dev/client/hmrState.ts +0 -14
  49. package/dist/dev/client/hmrToast.ts +0 -150
  50. package/dist/dev/client/moduleVersions.ts +0 -62
  51. package/dist/dev/client/reactRefreshSetup.ts +0 -31
  52. package/dist/dev/client/vendor/lview/lViewOps.ts +0 -196
  53. package/dist/dev/client/vendor/lview/slotConstants.ts +0 -44
  54. package/dist/dev/client/vendor/reactRefreshRuntime.d.ts +0 -12
  55. package/dist/dev/client/vendor/reactRefreshRuntime.js +0 -313
  56. package/dist/image-client/imageClient.js +0 -69
  57. package/dist/index.js +0 -36361
  58. package/dist/index.js.map +0 -320
  59. package/dist/islands/browser.js +0 -259
  60. package/dist/islands/browser.js.map +0 -15
  61. package/dist/islands/index.js +0 -2415
  62. package/dist/islands/index.js.map +0 -37
  63. package/dist/react/browser.js +0 -374
  64. package/dist/react/browser.js.map +0 -19
  65. package/dist/react/components/browser/index.js +0 -467
  66. package/dist/react/components/index.js +0 -684
  67. package/dist/react/components/index.js.map +0 -18
  68. package/dist/react/hooks/index.js +0 -285
  69. package/dist/react/hooks/index.js.map +0 -14
  70. package/dist/react/index.js +0 -4258
  71. package/dist/react/index.js.map +0 -56
  72. package/dist/react/jsxDevRuntimeCompat.js +0 -90
  73. package/dist/react/jsxDevRuntimeCompat.js.map +0 -10
  74. package/dist/react/router/browser.js +0 -95
  75. package/dist/react/router/browser.js.map +0 -10
  76. package/dist/react/router/index.js +0 -95
  77. package/dist/react/router/index.js.map +0 -10
  78. package/dist/react/server.js +0 -1895
  79. package/dist/react/server.js.map +0 -26
  80. package/dist/src/angular/Island.browser.d.ts +0 -34
  81. package/dist/src/angular/Island.d.ts +0 -29
  82. package/dist/src/angular/angularDeps.d.ts +0 -2
  83. package/dist/src/angular/angularPatch.d.ts +0 -1
  84. package/dist/src/angular/animationProviders.d.ts +0 -2
  85. package/dist/src/angular/browser.d.ts +0 -14
  86. package/dist/src/angular/components/constants.d.ts +0 -96
  87. package/dist/src/angular/components/defer-slot-payload.d.ts +0 -7
  88. package/dist/src/angular/components/defer-slot-templates.directive.d.ts +0 -21
  89. package/dist/src/angular/components/defer-slot.component.d.ts +0 -29
  90. package/dist/src/angular/components/image.component.d.ts +0 -42
  91. package/dist/src/angular/components/index.d.ts +0 -4
  92. package/dist/src/angular/components/stream-slot.component.d.ts +0 -20
  93. package/dist/src/angular/composables/index.d.ts +0 -6
  94. package/dist/src/angular/composables/usePageContext.d.ts +0 -16
  95. package/dist/src/angular/composables/useResource.d.ts +0 -57
  96. package/dist/src/angular/composables/useSubscription.d.ts +0 -33
  97. package/dist/src/angular/composables/useTimers.d.ts +0 -18
  98. package/dist/src/angular/createIsland.browser.d.ts +0 -2
  99. package/dist/src/angular/createIsland.d.ts +0 -2
  100. package/dist/src/angular/deterministicEnv.d.ts +0 -26
  101. package/dist/src/angular/hmrPreserveCore.d.ts +0 -21
  102. package/dist/src/angular/httpTransferCache.d.ts +0 -12
  103. package/dist/src/angular/index.d.ts +0 -14
  104. package/dist/src/angular/injectorPatch.d.ts +0 -1
  105. package/dist/src/angular/islandStore.d.ts +0 -9
  106. package/dist/src/angular/islands.d.ts +0 -4
  107. package/dist/src/angular/lowerDeferSyntax.d.ts +0 -18
  108. package/dist/src/angular/lowerServerIslands.d.ts +0 -1
  109. package/dist/src/angular/pageHandler.d.ts +0 -48
  110. package/dist/src/angular/pendingTask.d.ts +0 -1
  111. package/dist/src/angular/preserveAcrossHmr.d.ts +0 -12
  112. package/dist/src/angular/renderIsland.d.ts +0 -2
  113. package/dist/src/angular/requestProviders.d.ts +0 -5
  114. package/dist/src/angular/resolveAngularPackage.d.ts +0 -19
  115. package/dist/src/angular/routerRedirectProviders.d.ts +0 -6
  116. package/dist/src/angular/server.d.ts +0 -4
  117. package/dist/src/angular/ssrRender.d.ts +0 -13
  118. package/dist/src/angular/ssrSanitizer.d.ts +0 -3
  119. package/dist/src/angular/staticAnalyzeSpaRoutes.d.ts +0 -7
  120. package/dist/src/build/angularLinkerPlugin.d.ts +0 -29
  121. package/dist/src/build/buildAngularVendor.d.ts +0 -40
  122. package/dist/src/build/buildDepVendor.d.ts +0 -2
  123. package/dist/src/build/buildEmberVendor.d.ts +0 -24
  124. package/dist/src/build/buildReactVendor.d.ts +0 -8
  125. package/dist/src/build/buildSvelteVendor.d.ts +0 -6
  126. package/dist/src/build/buildVueVendor.d.ts +0 -6
  127. package/dist/src/build/chainInlineSourcemaps.d.ts +0 -13
  128. package/dist/src/build/compileAngular.d.ts +0 -40
  129. package/dist/src/build/compileEmber.d.ts +0 -43
  130. package/dist/src/build/compileSvelte.d.ts +0 -14
  131. package/dist/src/build/compileTailwind.d.ts +0 -5
  132. package/dist/src/build/compileVue.d.ts +0 -22
  133. package/dist/src/build/externalAssetPlugin.d.ts +0 -2
  134. package/dist/src/build/generateManifest.d.ts +0 -2
  135. package/dist/src/build/generateReactIndexes.d.ts +0 -2
  136. package/dist/src/build/htmlScriptHMRPlugin.d.ts +0 -13
  137. package/dist/src/build/index.d.ts +0 -2
  138. package/dist/src/build/islandEntries.d.ts +0 -32
  139. package/dist/src/build/islandRegistryTransform.d.ts +0 -17
  140. package/dist/src/build/nativeRewrite.d.ts +0 -5
  141. package/dist/src/build/optimizeHtmlImages.d.ts +0 -2
  142. package/dist/src/build/outputLogs.d.ts +0 -1
  143. package/dist/src/build/parseAngularConfigImports.d.ts +0 -9
  144. package/dist/src/build/parseVueSpaRoutes.d.ts +0 -20
  145. package/dist/src/build/resolvePackageImport.d.ts +0 -9
  146. package/dist/src/build/rewriteImports.d.ts +0 -8
  147. package/dist/src/build/rewriteImportsPlugin.d.ts +0 -48
  148. package/dist/src/build/rewriteReactImports.d.ts +0 -7
  149. package/dist/src/build/runAngularHandlerScan.d.ts +0 -7
  150. package/dist/src/build/scanAngularHandlerCalls.d.ts +0 -13
  151. package/dist/src/build/scanAngularPageRoutes.d.ts +0 -10
  152. package/dist/src/build/scanConventions.d.ts +0 -5
  153. package/dist/src/build/scanCssEntryPoints.d.ts +0 -1
  154. package/dist/src/build/scanEntryPoints.d.ts +0 -1
  155. package/dist/src/build/scanRouteRegistrations.d.ts +0 -23
  156. package/dist/src/build/scanVueSsrOnlyPages.d.ts +0 -6
  157. package/dist/src/build/staticIslandPages.d.ts +0 -9
  158. package/dist/src/build/stylePreprocessor.d.ts +0 -26
  159. package/dist/src/build/tailwindCompiler.d.ts +0 -8
  160. package/dist/src/build/updateAssetPaths.d.ts +0 -1
  161. package/dist/src/build/vendorEntrySource.d.ts +0 -1
  162. package/dist/src/build/verifyAngularCoreUniqueness.d.ts +0 -2
  163. package/dist/src/build/vueAutoRouterTransform.d.ts +0 -1
  164. package/dist/src/build/wrapHTMLScript.d.ts +0 -17
  165. package/dist/src/build.d.ts +0 -2
  166. package/dist/src/cli/add/dependencies.d.ts +0 -12
  167. package/dist/src/cli/cache.d.ts +0 -15
  168. package/dist/src/cli/config/absolute/AbsoluteConfigPanel.d.ts +0 -6
  169. package/dist/src/cli/config/absolute/editAbsoluteConfig.d.ts +0 -5
  170. package/dist/src/cli/config/absolute/resolveAbsoluteConfig.d.ts +0 -14
  171. package/dist/src/cli/config/client.d.ts +0 -1
  172. package/dist/src/cli/config/configCert.d.ts +0 -12
  173. package/dist/src/cli/config/eslint/EslintPanel.d.ts +0 -6
  174. package/dist/src/cli/config/eslint/configAst.d.ts +0 -18
  175. package/dist/src/cli/config/eslint/editConfigRule.d.ts +0 -6
  176. package/dist/src/cli/config/eslint/eslintStyles.d.ts +0 -1
  177. package/dist/src/cli/config/eslint/resolveConfig.d.ts +0 -3
  178. package/dist/src/cli/config/eslint/serializeValue.d.ts +0 -9
  179. package/dist/src/cli/config/guards.d.ts +0 -4
  180. package/dist/src/cli/config/packageJson/PackageJsonPanel.d.ts +0 -6
  181. package/dist/src/cli/config/packageJson/editPackageJson.d.ts +0 -9
  182. package/dist/src/cli/config/packageJson/resolvePackageJson.d.ts +0 -9
  183. package/dist/src/cli/config/page/ConfigShell.d.ts +0 -6
  184. package/dist/src/cli/config/page/FieldEditor.d.ts +0 -9
  185. package/dist/src/cli/config/page/PanelHost.d.ts +0 -6
  186. package/dist/src/cli/config/page/configStyles.d.ts +0 -1
  187. package/dist/src/cli/config/panels.d.ts +0 -7
  188. package/dist/src/cli/config/prettier/PrettierPanel.d.ts +0 -6
  189. package/dist/src/cli/config/prettier/editPrettier.d.ts +0 -5
  190. package/dist/src/cli/config/prettier/resolvePrettier.d.ts +0 -11
  191. package/dist/src/cli/config/schema/fromJsonSchema.d.ts +0 -3
  192. package/dist/src/cli/config/schema/fromType.d.ts +0 -2
  193. package/dist/src/cli/config/schema/serialize.d.ts +0 -1
  194. package/dist/src/cli/config/server.d.ts +0 -298
  195. package/dist/src/cli/config/tsconfig/TsconfigPanel.d.ts +0 -6
  196. package/dist/src/cli/config/tsconfig/editTsconfig.d.ts +0 -5
  197. package/dist/src/cli/config/tsconfig/resolveTsconfig.d.ts +0 -8
  198. package/dist/src/cli/config/tsconfig/tsconfigStyles.d.ts +0 -1
  199. package/dist/src/cli/discoverInstances.d.ts +0 -5
  200. package/dist/src/cli/generate/componentTemplates.d.ts +0 -7
  201. package/dist/src/cli/generate/context.d.ts +0 -30
  202. package/dist/src/cli/generate/cssStrategy.d.ts +0 -20
  203. package/dist/src/cli/generate/frameworkKey.d.ts +0 -3
  204. package/dist/src/cli/generate/frameworks.d.ts +0 -40
  205. package/dist/src/cli/generate/generateApi.d.ts +0 -3
  206. package/dist/src/cli/generate/generateComponent.d.ts +0 -4
  207. package/dist/src/cli/generate/generatePage.d.ts +0 -4
  208. package/dist/src/cli/generate/naming.d.ts +0 -5
  209. package/dist/src/cli/generate/navData.d.ts +0 -10
  210. package/dist/src/cli/generate/outcome.d.ts +0 -17
  211. package/dist/src/cli/generate/pageTemplates.d.ts +0 -11
  212. package/dist/src/cli/generate/routeWiring.d.ts +0 -40
  213. package/dist/src/cli/generate/staticNav.d.ts +0 -5
  214. package/dist/src/cli/htmx/install.d.ts +0 -6
  215. package/dist/src/cli/index.d.ts +0 -2
  216. package/dist/src/cli/inspectData.d.ts +0 -11
  217. package/dist/src/cli/inspectTui.d.ts +0 -1
  218. package/dist/src/cli/instanceStatus.d.ts +0 -22
  219. package/dist/src/cli/interactive.d.ts +0 -2
  220. package/dist/src/cli/psTui.d.ts +0 -1
  221. package/dist/src/cli/scripts/add.d.ts +0 -1
  222. package/dist/src/cli/scripts/build.d.ts +0 -1
  223. package/dist/src/cli/scripts/compile.d.ts +0 -2
  224. package/dist/src/cli/scripts/dev.d.ts +0 -1
  225. package/dist/src/cli/scripts/doctor.d.ts +0 -1
  226. package/dist/src/cli/scripts/env.d.ts +0 -7
  227. package/dist/src/cli/scripts/eslint.d.ts +0 -16
  228. package/dist/src/cli/scripts/generate.d.ts +0 -1
  229. package/dist/src/cli/scripts/htmx.d.ts +0 -1
  230. package/dist/src/cli/scripts/info.d.ts +0 -1
  231. package/dist/src/cli/scripts/inspect.d.ts +0 -1
  232. package/dist/src/cli/scripts/logs.d.ts +0 -1
  233. package/dist/src/cli/scripts/ls.d.ts +0 -1
  234. package/dist/src/cli/scripts/mem.d.ts +0 -1
  235. package/dist/src/cli/scripts/prettier.d.ts +0 -3
  236. package/dist/src/cli/scripts/ps.d.ts +0 -1
  237. package/dist/src/cli/scripts/remove.d.ts +0 -1
  238. package/dist/src/cli/scripts/routes.d.ts +0 -1
  239. package/dist/src/cli/scripts/start.d.ts +0 -1
  240. package/dist/src/cli/scripts/telemetry.d.ts +0 -5
  241. package/dist/src/cli/scripts/tunnelRelay.d.ts +0 -9
  242. package/dist/src/cli/scripts/typecheck.d.ts +0 -1
  243. package/dist/src/cli/scripts/workspace.d.ts +0 -11
  244. package/dist/src/cli/telemetryEvent.d.ts +0 -1
  245. package/dist/src/cli/tuiPrimitives.d.ts +0 -14
  246. package/dist/src/cli/utils.d.ts +0 -15
  247. package/dist/src/cli/workspaceTui.d.ts +0 -44
  248. package/dist/src/client/hydrators/react.d.ts +0 -3
  249. package/dist/src/client/hydrators/svelte.d.ts +0 -2
  250. package/dist/src/client/hydrators/vue.d.ts +0 -2
  251. package/dist/src/client/index.d.ts +0 -4
  252. package/dist/src/client/islandResolver.d.ts +0 -2
  253. package/dist/src/client/islandRuntime.d.ts +0 -9
  254. package/dist/src/client/islandStore.d.ts +0 -22
  255. package/dist/src/client/preserveIslandMarkup.d.ts +0 -16
  256. package/dist/src/client/streamSwap.d.ts +0 -1
  257. package/dist/src/constants.d.ts +0 -96
  258. package/dist/src/core/angularServerModule.d.ts +0 -1
  259. package/dist/src/core/build.d.ts +0 -14
  260. package/dist/src/core/currentIslandRegistry.d.ts +0 -7
  261. package/dist/src/core/devBuild.d.ts +0 -23
  262. package/dist/src/core/devRouteRegistrationCallsite.d.ts +0 -4
  263. package/dist/src/core/devVendorPaths.d.ts +0 -17
  264. package/dist/src/core/index.d.ts +0 -7
  265. package/dist/src/core/islandManifest.d.ts +0 -3
  266. package/dist/src/core/islandMarkupAttributes.d.ts +0 -12
  267. package/dist/src/core/islandPageContext.d.ts +0 -12
  268. package/dist/src/core/islandSsr.d.ts +0 -6
  269. package/dist/src/core/islands.d.ts +0 -16
  270. package/dist/src/core/loadIslandRegistry.d.ts +0 -1
  271. package/dist/src/core/lookup.d.ts +0 -1
  272. package/dist/src/core/normalizeIslandProps.d.ts +0 -15
  273. package/dist/src/core/pageHandlers.d.ts +0 -5
  274. package/dist/src/core/prepare.d.ts +0 -417
  275. package/dist/src/core/prerender.d.ts +0 -31
  276. package/dist/src/core/renderIslandMarkup.d.ts +0 -13
  277. package/dist/src/core/responseEnhancers.d.ts +0 -10
  278. package/dist/src/core/staticStreaming.d.ts +0 -25
  279. package/dist/src/core/streamingSlotRegistrar.d.ts +0 -16
  280. package/dist/src/core/streamingSlotRegistry.d.ts +0 -2
  281. package/dist/src/core/streamingSlotWarningScope.d.ts +0 -4
  282. package/dist/src/core/svelteServerModule.d.ts +0 -1
  283. package/dist/src/core/vueServerModule.d.ts +0 -1
  284. package/dist/src/core/wrapPageHandlerWithStreamingSlots.d.ts +0 -2
  285. package/dist/src/dev/angular/fastHmrCompiler.d.ts +0 -58
  286. package/dist/src/dev/angular/hmrCompiler.d.ts +0 -2
  287. package/dist/src/dev/angular/hmrImportGenerator.d.ts +0 -3
  288. package/dist/src/dev/angular/hmrInjectionPlugin.d.ts +0 -8
  289. package/dist/src/dev/angular/resolveOwningComponents.d.ts +0 -16
  290. package/dist/src/dev/angular/vendor/translator/api/ast_factory.d.ts +0 -363
  291. package/dist/src/dev/angular/vendor/translator/api/import_generator.d.ts +0 -49
  292. package/dist/src/dev/angular/vendor/translator/context.d.ts +0 -18
  293. package/dist/src/dev/angular/vendor/translator/translator.d.ts +0 -75
  294. package/dist/src/dev/angular/vendor/translator/ts_util.d.ts +0 -12
  295. package/dist/src/dev/angular/vendor/translator/typescript_ast_factory.d.ts +0 -66
  296. package/dist/src/dev/angular/vendor/translator/typescript_translator.d.ts +0 -13
  297. package/dist/src/dev/assetStore.d.ts +0 -8
  298. package/dist/src/dev/buildHMRClient.d.ts +0 -1
  299. package/dist/src/dev/clientManager.d.ts +0 -33
  300. package/dist/src/dev/configResolver.d.ts +0 -16
  301. package/dist/src/dev/dependencyGraph.d.ts +0 -10
  302. package/dist/src/dev/devCert.d.ts +0 -11
  303. package/dist/src/dev/fileHashTracker.d.ts +0 -2
  304. package/dist/src/dev/fileWatcher.d.ts +0 -4
  305. package/dist/src/dev/moduleMapper.d.ts +0 -27
  306. package/dist/src/dev/moduleServer.d.ts +0 -24
  307. package/dist/src/dev/moduleVersionTracker.d.ts +0 -7
  308. package/dist/src/dev/pathUtils.d.ts +0 -8
  309. package/dist/src/dev/reactComponentClassifier.d.ts +0 -2
  310. package/dist/src/dev/rebuildTrigger.d.ts +0 -11
  311. package/dist/src/dev/requestInspector.d.ts +0 -43
  312. package/dist/src/dev/serverEntryWatcher.d.ts +0 -5
  313. package/dist/src/dev/simpleHTMLHMR.d.ts +0 -4
  314. package/dist/src/dev/simpleHTMXHMR.d.ts +0 -4
  315. package/dist/src/dev/transformCache.d.ts +0 -22
  316. package/dist/src/dev/tunnel/client.d.ts +0 -20
  317. package/dist/src/dev/tunnel/protocol.d.ts +0 -85
  318. package/dist/src/dev/tunnel/relay.d.ts +0 -28
  319. package/dist/src/dev/webSocket.d.ts +0 -9
  320. package/dist/src/ember/browser.d.ts +0 -24
  321. package/dist/src/ember/index.d.ts +0 -2
  322. package/dist/src/ember/pageHandler.d.ts +0 -35
  323. package/dist/src/ember/server.d.ts +0 -2
  324. package/dist/src/index.d.ts +0 -7
  325. package/dist/src/islands/browser.d.ts +0 -3
  326. package/dist/src/islands/index.d.ts +0 -3
  327. package/dist/src/islands/pageMetadata.d.ts +0 -13
  328. package/dist/src/islands/sourceMetadata.d.ts +0 -10
  329. package/dist/src/plugins/devtoolsJson.d.ts +0 -58
  330. package/dist/src/plugins/hmr.d.ts +0 -163
  331. package/dist/src/plugins/imageOptimizer.d.ts +0 -67
  332. package/dist/src/plugins/index.d.ts +0 -3
  333. package/dist/src/plugins/networking.d.ts +0 -2
  334. package/dist/src/plugins/pageRouter.d.ts +0 -1
  335. package/dist/src/react/Island.browser.d.ts +0 -2
  336. package/dist/src/react/Island.d.ts +0 -2
  337. package/dist/src/react/bridgeInternals.d.ts +0 -1
  338. package/dist/src/react/browser.d.ts +0 -3
  339. package/dist/src/react/components/Head.d.ts +0 -2
  340. package/dist/src/react/components/Image.d.ts +0 -2
  341. package/dist/src/react/components/JsonLd.d.ts +0 -4
  342. package/dist/src/react/components/StreamSlot.browser.d.ts +0 -10
  343. package/dist/src/react/components/StreamSlot.d.ts +0 -10
  344. package/dist/src/react/components/SuspenseSlot.browser.d.ts +0 -22
  345. package/dist/src/react/components/SuspenseSlot.d.ts +0 -37
  346. package/dist/src/react/components/browser/index.d.ts +0 -5
  347. package/dist/src/react/components/index.d.ts +0 -5
  348. package/dist/src/react/createIsland.browser.d.ts +0 -2
  349. package/dist/src/react/createIsland.d.ts +0 -2
  350. package/dist/src/react/hooks/index.d.ts +0 -3
  351. package/dist/src/react/hooks/useIslandStore.d.ts +0 -3
  352. package/dist/src/react/hooks/useMediaQuery.d.ts +0 -7
  353. package/dist/src/react/index.d.ts +0 -4
  354. package/dist/src/react/jsxDevRuntimeCompat.d.ts +0 -8
  355. package/dist/src/react/pageHandler.d.ts +0 -25
  356. package/dist/src/react/router/UniversalRouter.d.ts +0 -43
  357. package/dist/src/react/router/browser.d.ts +0 -2
  358. package/dist/src/react/router/index.d.ts +0 -2
  359. package/dist/src/react/server.d.ts +0 -1
  360. package/dist/src/react/staticAnalyzeSpaRoutes.d.ts +0 -7
  361. package/dist/src/svelte/browser.d.ts +0 -4
  362. package/dist/src/svelte/createIsland.browser.d.ts +0 -2
  363. package/dist/src/svelte/createIsland.d.ts +0 -2
  364. package/dist/src/svelte/index.d.ts +0 -6
  365. package/dist/src/svelte/islandStore.d.ts +0 -5
  366. package/dist/src/svelte/lowerAwaitSlotSyntax.d.ts +0 -4
  367. package/dist/src/svelte/lowerIslandSyntax.d.ts +0 -4
  368. package/dist/src/svelte/pageHandler.d.ts +0 -28
  369. package/dist/src/svelte/renderIsland.d.ts +0 -2
  370. package/dist/src/svelte/renderToPipeableStream.d.ts +0 -12
  371. package/dist/src/svelte/renderToReadableStream.d.ts +0 -14
  372. package/dist/src/svelte/renderToString.d.ts +0 -9
  373. package/dist/src/svelte/resolveIslandHtml.browser.d.ts +0 -2
  374. package/dist/src/svelte/resolveIslandHtml.d.ts +0 -2
  375. package/dist/src/svelte/router/browser.d.ts +0 -4
  376. package/dist/src/svelte/router/goto.d.ts +0 -15
  377. package/dist/src/svelte/router/hashMode.d.ts +0 -16
  378. package/dist/src/svelte/router/index.d.ts +0 -4
  379. package/dist/src/svelte/router/matchPath.d.ts +0 -30
  380. package/dist/src/svelte/router/page.svelte.d.ts +0 -15
  381. package/dist/src/svelte/router/prefetchCache.d.ts +0 -17
  382. package/dist/src/svelte/router/pushState.d.ts +0 -13
  383. package/dist/src/svelte/router/viewTransitions.d.ts +0 -6
  384. package/dist/src/svelte/server.d.ts +0 -1
  385. package/dist/src/svelte/staticAnalyzeSpaRoutes.d.ts +0 -7
  386. package/dist/src/utils/buildDirectoryLock.d.ts +0 -28
  387. package/dist/src/utils/cleanStaleOutputs.d.ts +0 -1
  388. package/dist/src/utils/cleanup.d.ts +0 -9
  389. package/dist/src/utils/commonAncestor.d.ts +0 -1
  390. package/dist/src/utils/defineConfig.d.ts +0 -39
  391. package/dist/src/utils/defineConvention.d.ts +0 -3
  392. package/dist/src/utils/defineEnv.d.ts +0 -10
  393. package/dist/src/utils/escapeScriptContent.d.ts +0 -1
  394. package/dist/src/utils/formatBytes.d.ts +0 -2
  395. package/dist/src/utils/generateHeadElement.d.ts +0 -4
  396. package/dist/src/utils/generateSitemap.d.ts +0 -21
  397. package/dist/src/utils/generatedDir.d.ts +0 -3
  398. package/dist/src/utils/getDurationString.d.ts +0 -1
  399. package/dist/src/utils/getEnv.d.ts +0 -1
  400. package/dist/src/utils/imageClient.d.ts +0 -13
  401. package/dist/src/utils/imageProcessing.d.ts +0 -33
  402. package/dist/src/utils/index.d.ts +0 -11
  403. package/dist/src/utils/inlinePageCss.d.ts +0 -2
  404. package/dist/src/utils/instanceRegistry.d.ts +0 -13
  405. package/dist/src/utils/jsonLd.d.ts +0 -3
  406. package/dist/src/utils/loadConfig.d.ts +0 -55
  407. package/dist/src/utils/logger.d.ts +0 -56
  408. package/dist/src/utils/networking.d.ts +0 -2
  409. package/dist/src/utils/normalizePath.d.ts +0 -9
  410. package/dist/src/utils/portScan.d.ts +0 -22
  411. package/dist/src/utils/projectRoot.d.ts +0 -17
  412. package/dist/src/utils/registerClientScript.d.ts +0 -36
  413. package/dist/src/utils/resolveConvention.d.ts +0 -10
  414. package/dist/src/utils/resolveDevPort.d.ts +0 -24
  415. package/dist/src/utils/runtimeMode.d.ts +0 -3
  416. package/dist/src/utils/spaRouteCss.d.ts +0 -4
  417. package/dist/src/utils/spaRouteTypes.d.ts +0 -25
  418. package/dist/src/utils/ssrErrorPage.d.ts +0 -1
  419. package/dist/src/utils/startupBanner.d.ts +0 -10
  420. package/dist/src/utils/startupTimings.d.ts +0 -7
  421. package/dist/src/utils/streamingSlotMetricSink.d.ts +0 -18
  422. package/dist/src/utils/streamingSlots.d.ts +0 -76
  423. package/dist/src/utils/stringModifiers.d.ts +0 -3
  424. package/dist/src/utils/userAgentFunctions.d.ts +0 -1
  425. package/dist/src/utils/validateSafePath.d.ts +0 -1
  426. package/dist/src/vue/Island.browser.d.ts +0 -37
  427. package/dist/src/vue/Island.d.ts +0 -36
  428. package/dist/src/vue/browser.d.ts +0 -6
  429. package/dist/src/vue/components/Image.d.ts +0 -74
  430. package/dist/src/vue/components/StreamSlot.d.ts +0 -22
  431. package/dist/src/vue/components/SuspenseSlot.d.ts +0 -26
  432. package/dist/src/vue/components/index.d.ts +0 -3
  433. package/dist/src/vue/createIsland.browser.d.ts +0 -13
  434. package/dist/src/vue/createIsland.d.ts +0 -13
  435. package/dist/src/vue/defineVuePage.d.ts +0 -6
  436. package/dist/src/vue/index.d.ts +0 -9
  437. package/dist/src/vue/pageHandler.d.ts +0 -45
  438. package/dist/src/vue/routerRedirectProviders.d.ts +0 -45
  439. package/dist/src/vue/server.d.ts +0 -2
  440. package/dist/src/vue/staticAnalyzeSpaRoutes.d.ts +0 -7
  441. package/dist/src/vue/useIslandStore.d.ts +0 -3
  442. package/dist/svelte/browser.js +0 -309
  443. package/dist/svelte/browser.js.map +0 -19
  444. package/dist/svelte/components/AwaitSlot.svelte +0 -39
  445. package/dist/svelte/components/AwaitSlot.svelte.d.ts +0 -2
  446. package/dist/svelte/components/Head.svelte +0 -144
  447. package/dist/svelte/components/Head.svelte.d.ts +0 -2
  448. package/dist/svelte/components/Image.svelte +0 -164
  449. package/dist/svelte/components/Image.svelte.d.ts +0 -5
  450. package/dist/svelte/components/Island.svelte +0 -71
  451. package/dist/svelte/components/Island.svelte.d.ts +0 -5
  452. package/dist/svelte/components/JsonLd.svelte +0 -21
  453. package/dist/svelte/components/JsonLd.svelte.d.ts +0 -2
  454. package/dist/svelte/components/StreamSlot.svelte +0 -41
  455. package/dist/svelte/components/StreamSlot.svelte.d.ts +0 -2
  456. package/dist/svelte/index.js +0 -4371
  457. package/dist/svelte/index.js.map +0 -60
  458. package/dist/svelte/router/Link.svelte +0 -124
  459. package/dist/svelte/router/Link.svelte.d.ts +0 -21
  460. package/dist/svelte/router/Route.svelte +0 -54
  461. package/dist/svelte/router/Route.svelte.d.ts +0 -13
  462. package/dist/svelte/router/Router.svelte +0 -189
  463. package/dist/svelte/router/Router.svelte.d.ts +0 -16
  464. package/dist/svelte/router/browser.ts +0 -14
  465. package/dist/svelte/router/goto.ts +0 -89
  466. package/dist/svelte/router/hashMode.ts +0 -31
  467. package/dist/svelte/router/index.ts +0 -23
  468. package/dist/svelte/router/matchPath.ts +0 -136
  469. package/dist/svelte/router/page.d.ts +0 -15
  470. package/dist/svelte/router/page.js +0 -27
  471. package/dist/svelte/router/prefetchCache.ts +0 -85
  472. package/dist/svelte/router/pushState.ts +0 -35
  473. package/dist/svelte/router/viewTransitions.ts +0 -35
  474. package/dist/svelte/server.js +0 -2996
  475. package/dist/svelte/server.js.map +0 -33
  476. package/dist/types/absoluteConfig.d.ts +0 -22
  477. package/dist/types/angular.d.ts +0 -43
  478. package/dist/types/build.d.ts +0 -245
  479. package/dist/types/cli.d.ts +0 -71
  480. package/dist/types/client.d.ts +0 -70
  481. package/dist/types/config.d.ts +0 -50
  482. package/dist/types/conventions.d.ts +0 -26
  483. package/dist/types/ember.d.ts +0 -39
  484. package/dist/types/env.d.ts +0 -2
  485. package/dist/types/eslintConfig.d.ts +0 -68
  486. package/dist/types/globals.d.ts +0 -163
  487. package/dist/types/image.d.ts +0 -77
  488. package/dist/types/index.d.ts +0 -17
  489. package/dist/types/island.d.ts +0 -52
  490. package/dist/types/jsonLd.d.ts +0 -300
  491. package/dist/types/mediaQuery.d.ts +0 -9
  492. package/dist/types/messages.d.ts +0 -152
  493. package/dist/types/metadata.d.ts +0 -51
  494. package/dist/types/packageJson.d.ts +0 -74
  495. package/dist/types/packageJsonPanel.d.ts +0 -29
  496. package/dist/types/prettier.d.ts +0 -26
  497. package/dist/types/react.d.ts +0 -2
  498. package/dist/types/sitemap.d.ts +0 -24
  499. package/dist/types/style-module-shim.d.ts +0 -29
  500. package/dist/types/svelte.d.ts +0 -2
  501. package/dist/types/svelteRouter.d.ts +0 -65
  502. package/dist/types/svelteRouter.ts +0 -91
  503. package/dist/types/telemetry.d.ts +0 -15
  504. package/dist/types/tool.d.ts +0 -11
  505. package/dist/types/tsconfig.d.ts +0 -31
  506. package/dist/types/typeGuards.d.ts +0 -2
  507. package/dist/types/userAgentTypes.d.ts +0 -2
  508. package/dist/types/vue.d.ts +0 -56
  509. package/dist/types/websocket.d.ts +0 -6
  510. package/dist/vue/browser.js +0 -512
  511. package/dist/vue/browser.js.map +0 -22
  512. package/dist/vue/components/Image.js +0 -264
  513. package/dist/vue/components/Image.js.map +0 -12
  514. package/dist/vue/components/index.js +0 -571
  515. package/dist/vue/components/index.js.map +0 -15
  516. package/dist/vue/index.js +0 -5238
  517. package/dist/vue/index.js.map +0 -69
  518. package/dist/vue/server.js +0 -2251
  519. package/dist/vue/server.js.map +0 -32
@@ -1,2996 +0,0 @@
1
- // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- function __accessProp(key) {
9
- return this[key];
10
- }
11
- var __toESMCache_node;
12
- var __toESMCache_esm;
13
- var __toESM = (mod, isNodeMode, target) => {
14
- var canCache = mod != null && typeof mod === "object";
15
- if (canCache) {
16
- var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
- var cached = cache.get(mod);
18
- if (cached)
19
- return cached;
20
- }
21
- target = mod != null ? __create(__getProtoOf(mod)) : {};
22
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
23
- for (let key of __getOwnPropNames(mod))
24
- if (!__hasOwnProp.call(to, key))
25
- __defProp(to, key, {
26
- get: __accessProp.bind(mod, key),
27
- enumerable: true
28
- });
29
- if (canCache)
30
- cache.set(mod, to);
31
- return to;
32
- };
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
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
51
- var __returnValue = (v) => v;
52
- function __exportSetter(name, newValue) {
53
- this[name] = __returnValue.bind(null, newValue);
54
- }
55
- var __export = (target, all) => {
56
- for (var name in all)
57
- __defProp(target, name, {
58
- get: all[name],
59
- enumerable: true,
60
- configurable: true,
61
- set: __exportSetter.bind(all, name)
62
- });
63
- };
64
- var __legacyDecorateClassTS = function(decorators, target, key, desc) {
65
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
66
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
67
- r = Reflect.decorate(decorators, target, key, desc);
68
- else
69
- for (var i = decorators.length - 1;i >= 0; i--)
70
- if (d = decorators[i])
71
- r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
72
- return c > 3 && r && Object.defineProperty(target, key, r), r;
73
- };
74
- var __legacyMetadataTS = (k, v) => {
75
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
76
- return Reflect.metadata(k, v);
77
- };
78
- var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
79
- var __require = import.meta.require;
80
-
81
- // src/build/resolvePackageImport.ts
82
- import { resolve, join } from "path";
83
- import { existsSync, readFileSync } from "fs";
84
- var resolveExportPath = (entry, conditions) => {
85
- if (typeof entry === "string")
86
- return entry;
87
- if (!entry || typeof entry !== "object")
88
- return null;
89
- for (const condition of conditions) {
90
- const target = Reflect.get(entry, condition);
91
- if (typeof target === "string") {
92
- return target;
93
- }
94
- }
95
- return null;
96
- }, resolvePackageImport = (specifier, conditions = ["import"]) => {
97
- if (specifier.startsWith(".") || specifier.startsWith("/"))
98
- return null;
99
- const parts = specifier.split("/");
100
- const isScoped = specifier.startsWith("@");
101
- const packageName = isScoped ? `${parts[0]}/${parts[1]}` : parts[0];
102
- const subpath = isScoped ? parts.slice(2).join("/") : parts.slice(1).join("/");
103
- const exportKey = subpath ? `./${subpath}` : ".";
104
- const currentPackageJsonPath = resolve(process.cwd(), "package.json");
105
- const currentPackageJson = existsSync(currentPackageJsonPath) ? JSON.parse(readFileSync(currentPackageJsonPath, "utf-8")) : null;
106
- const currentPackageDir = currentPackageJson?.name === packageName ? process.cwd() : null;
107
- const packageDir = currentPackageDir ?? resolve(process.cwd(), "node_modules", packageName ?? "");
108
- const packageJsonPath = join(packageDir, "package.json");
109
- if (!existsSync(packageJsonPath))
110
- return null;
111
- try {
112
- const packageJson = currentPackageDir && currentPackageJson ? currentPackageJson : JSON.parse(readFileSync(packageJsonPath, "utf-8"));
113
- const { exports } = packageJson;
114
- if (!exports)
115
- return null;
116
- const entry = exports[exportKey];
117
- if (!entry)
118
- return null;
119
- const importPath = resolveExportPath(entry, conditions);
120
- if (!importPath)
121
- return null;
122
- if (currentPackageDir && importPath.startsWith("./dist/")) {
123
- const sourceCandidate = resolve(packageDir, importPath.replace(/^\.\/dist\//, "./src/"));
124
- if (existsSync(sourceCandidate)) {
125
- return sourceCandidate;
126
- }
127
- }
128
- const resolved = resolve(packageDir, importPath);
129
- return existsSync(resolved) ? resolved : null;
130
- } catch {
131
- return null;
132
- }
133
- };
134
- var init_resolvePackageImport = () => {};
135
-
136
- // src/constants.ts
137
- var ANGULAR_INIT_TIMEOUT_MS = 500, ANSI_ESCAPE_CODE = 27, ANSI_ESCAPE_LENGTH = 3, ASCII_SPACE = 32, BASE_36_RADIX = 36, BUN_BUILD_WARNING_SUPPRESSION = "wildcard sideEffects are not supported yet", BODY_SLICE_LENGTH = 2000, BYTES_PER_KILOBYTE = 1024, CLI_ARGS_OFFSET = 3, CSS_ERROR_RESOLVE_DELAY_MS = 50, CSS_MAX_CHECK_ATTEMPTS = 10, CSS_MAX_PARSE_TIMEOUT_MS = 500, CSS_SHEET_READY_TIMEOUT_MS = 100, DEFAULT_CHUNK_SIZE = 16384, DEFAULT_DEBOUNCE_MS = 15, DEFAULT_PORT = 3000, DEV_SERVER_RESTART_DEBOUNCE_MS = 100, DOM_UPDATE_DELAY_MS = 50, FILE_PROTOCOL_PREFIX_LENGTH = 7, FOCUS_ID_PREFIX_LENGTH = 3, FOCUS_IDX_PREFIX_LENGTH = 4, FOCUS_NAME_PREFIX_LENGTH = 5, 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, WORKSPACE_COMMAND_ARGS_OFFSET = 3, WORKSPACE_FAILURE_LOG_PRINT_LIMIT = 30, WORKSPACE_FAILURE_RECENT_LOG_LIMIT = 60, WORKSPACE_READY_ATTEMPT_TIMEOUT_MS = 5000, WORKSPACE_READY_PROBE_INTERVAL_MS = 250, WORKSPACE_READY_TIMEOUT_MS = 30000, WORKSPACE_SHUTDOWN_TIMEOUT_MS = 1e4, WORKSPACE_TUI_DEFAULT_HEIGHT = 28, WORKSPACE_TUI_DEFAULT_WIDTH = 100, WORKSPACE_TUI_ESCAPE_SEQUENCE_TIMEOUT_MS = 30, WORKSPACE_TUI_FOOTER_LINE_COUNT = 3, WORKSPACE_TUI_MIN_LOG_HEIGHT = 3, WORKSPACE_TUI_MIN_SERVICE_NAME_WIDTH = 7, WORKSPACE_TUI_MIN_TARGET_WIDTH = 8, WORKSPACE_TUI_MIN_WRAP_WIDTH = 12, WORKSPACE_TUI_PROMPT_CURSOR_OFFSET = 3, WORKSPACE_TUI_RECENT_LOG_LIMIT = 40, WORKSPACE_TUI_RENDER_DEBOUNCE_MS = 16, WORKSPACE_TUI_STATUS_WIDTH = 10, WORKSPACE_TUI_TARGET_PADDING_WIDTH = 6, WORKSPACE_TUI_VISIBILITY_WIDTH = 8;
138
- var init_constants = __esm(() => {
139
- IMAGE_DEFAULT_DEVICE_SIZES = [
140
- 640,
141
- 750,
142
- 828,
143
- 1080,
144
- 1200,
145
- 1920,
146
- 2048,
147
- 3840
148
- ];
149
- IMAGE_DEFAULT_IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
150
- MILLISECONDS_IN_A_MINUTE = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE;
151
- MILLISECONDS_IN_A_DAY = MILLISECONDS_IN_A_SECOND * SECONDS_IN_A_MINUTE * MINUTES_IN_AN_HOUR * HOURS_IN_DAY;
152
- TWO_THIRDS = 2 / 3;
153
- });
154
-
155
- // src/svelte/lowerIslandSyntax.ts
156
- var ISLAND_TAG_RE, extractBracedExpression = (text, braceStart) => {
157
- let depth = 0;
158
- for (let index = braceStart;index < text.length; index += 1) {
159
- const char = text[index];
160
- if (char === "{")
161
- depth += 1;
162
- if (char === "}")
163
- depth -= 1;
164
- if (depth === 0) {
165
- return text.slice(braceStart + 1, index).trim();
166
- }
167
- }
168
- return null;
169
- }, extractIslandAttribute = (attributeString, name) => {
170
- const quotedMatch = attributeString.match(new RegExp(`\\b${name}\\s*=\\s*["']([^"']+)["']`));
171
- if (quotedMatch?.[1]) {
172
- return { expression: JSON.stringify(quotedMatch[1]), found: true };
173
- }
174
- const attributeIndex = attributeString.search(new RegExp(`\\b${name}\\s*=\\s*\\{`));
175
- if (attributeIndex < 0) {
176
- return { expression: "", found: false };
177
- }
178
- const braceStart = attributeString.indexOf("{", attributeIndex);
179
- if (braceStart < 0) {
180
- return { expression: "", found: false };
181
- }
182
- const expression = extractBracedExpression(attributeString, braceStart);
183
- if (expression === null) {
184
- return { expression: "", found: false };
185
- }
186
- return { expression, found: true };
187
- }, lowerSvelteIslandSyntax = (source, _mode = "server") => {
188
- if (!source.includes("<Island")) {
189
- return { code: source, transformed: false };
190
- }
191
- let islandIndex = 0;
192
- const transformedMarkup = source.replace(ISLAND_TAG_RE, (fullMatch, attributeString) => {
193
- const framework = extractIslandAttribute(attributeString, "framework");
194
- const component = extractIslandAttribute(attributeString, "component");
195
- if (!framework.found || !component.found) {
196
- return fullMatch;
197
- }
198
- const hydrate = extractIslandAttribute(attributeString, "hydrate");
199
- const props = extractIslandAttribute(attributeString, "props");
200
- const slotId = `absolute-svelte-island-${islandIndex.toString(BASE_36_RADIX)}`;
201
- islandIndex += 1;
202
- const resolveExpression = `await __absoluteResolveIslandHtml(${JSON.stringify(slotId)}, { component: ${component.expression}, framework: ${framework.expression}, hydrate: ${hydrate.found ? hydrate.expression : JSON.stringify("load")}, props: ${props.found ? props.expression : "{}"} })`;
203
- return `<div data-absolute-island-slot="${slotId}" style="display: contents">{@html ${resolveExpression}}</div>`;
204
- });
205
- const importLine = 'import { resolveIslandHtml as __absoluteResolveIslandHtml } from "@absolutejs/absolute/svelte";';
206
- if (transformedMarkup.includes("<script")) {
207
- return {
208
- code: transformedMarkup.replace(/<script(\s[^>]*)?>/, (match) => `${match}
209
- ${importLine}
210
- `),
211
- transformed: true
212
- };
213
- }
214
- return {
215
- code: `<script lang="ts">
216
- ${importLine}
217
- </script>
218
- ${transformedMarkup}`,
219
- transformed: true
220
- };
221
- };
222
- var init_lowerIslandSyntax = __esm(() => {
223
- init_constants();
224
- ISLAND_TAG_RE = /<Island\b([\s\S]*?)\/>/g;
225
- });
226
-
227
- // src/svelte/lowerAwaitSlotSyntax.ts
228
- var AWAIT_BLOCK_RE, escapeTemplateLiteral = (value) => value.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${"), markupToTemplateLiteral = (markup) => {
229
- const escaped = escapeTemplateLiteral(markup.trim());
230
- const withExpressions = escaped.replace(/\{([^{}]+)\}/g, (_, expression) => `\${${String(expression).trim()}}`);
231
- return `\`${withExpressions}\``;
232
- }, lowerSvelteAwaitSlotSyntax = (source) => {
233
- if (!source.includes("{#await")) {
234
- return { code: source, transformed: false };
235
- }
236
- let awaitIndex = 0;
237
- let transformed = false;
238
- const lowered = source.replace(AWAIT_BLOCK_RE, (fullMatch, awaitExpression, pendingMarkup, thenIdentifier, thenMarkup, catchIdentifier, catchMarkup) => {
239
- const trimmedAwaitExpression = awaitExpression.trim();
240
- if (!trimmedAwaitExpression) {
241
- return fullMatch;
242
- }
243
- const slotId = `absolute-svelte-await-${awaitIndex.toString(BASE_36_RADIX)}`;
244
- awaitIndex += 1;
245
- transformed = true;
246
- const thenValueIdentifier = thenIdentifier?.trim() || "__awaitValue";
247
- const catchValueIdentifier = catchIdentifier?.trim() || "__awaitError";
248
- const fallbackHtml = markupToTemplateLiteral(pendingMarkup);
249
- const resolvedHtml = markupToTemplateLiteral(thenMarkup);
250
- const rejectedHtml = typeof catchMarkup === "string" ? markupToTemplateLiteral(catchMarkup) : null;
251
- const catchBranch = rejectedHtml ? `catch (${catchValueIdentifier}) { return ${rejectedHtml}; }` : "catch (_absoluteAwaitError) { throw _absoluteAwaitError; }";
252
- return `<AbsoluteAwaitSlot id="${slotId}" fallbackHtml={${fallbackHtml}} resolve={async () => { try { const ${thenValueIdentifier} = await (${trimmedAwaitExpression}); return ${resolvedHtml}; } ${catchBranch} }} />`;
253
- });
254
- if (!transformed) {
255
- return { code: source, transformed: false };
256
- }
257
- const importLine = 'import AbsoluteAwaitSlot from "@absolutejs/absolute/svelte/components/AwaitSlot.svelte";';
258
- if (lowered.includes("<script")) {
259
- return {
260
- code: lowered.replace(/<script(\s[^>]*)?>/, (match) => `${match}
261
- ${importLine}
262
- `),
263
- transformed: true
264
- };
265
- }
266
- return {
267
- code: `<script lang="ts">
268
- ${importLine}
269
- </script>
270
- ${lowered}`,
271
- transformed: true
272
- };
273
- };
274
- var init_lowerAwaitSlotSyntax = __esm(() => {
275
- init_constants();
276
- AWAIT_BLOCK_RE = /\{#await\s+([^}]+)\}([\s\S]*?)\{:then(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?)(?:\{:catch(?:\s+([A-Za-z_$][\w$]*))?\}([\s\S]*?))?\{\/await\}/g;
277
- });
278
-
279
- // src/build/stylePreprocessor.ts
280
- var exports_stylePreprocessor = {};
281
- __export(exports_stylePreprocessor, {
282
- stylePreprocessorPlugin: () => stylePreprocessorPlugin,
283
- recordStyleOutput: () => recordStyleOutput,
284
- isStylePath: () => isStylePath,
285
- isStyleModulePath: () => isStyleModulePath,
286
- isPreprocessableStylePath: () => isPreprocessableStylePath,
287
- getStyleBaseName: () => getStyleBaseName,
288
- getCssOutputExtension: () => getCssOutputExtension,
289
- forgetStyleEntry: () => forgetStyleEntry,
290
- findStyleEntriesImporting: () => findStyleEntriesImporting,
291
- createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
292
- createStyleTransformConfig: () => createStyleTransformConfig,
293
- createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
294
- compileStyleSource: () => compileStyleSource,
295
- compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
296
- compileStyleFileIfNeeded: () => compileStyleFileIfNeeded,
297
- addStyleImporter: () => addStyleImporter
298
- });
299
- import { createHash } from "crypto";
300
- import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
301
- import { readFile } from "fs/promises";
302
- import { createRequire } from "module";
303
- import {
304
- dirname,
305
- extname,
306
- isAbsolute,
307
- join as join2,
308
- relative,
309
- resolve as resolve2
310
- } from "path";
311
- import { fileURLToPath, pathToFileURL } from "url";
312
- 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) => {
313
- const normalized = filePathOrLanguage.toLowerCase();
314
- if (normalized === "scss" || normalized.endsWith(".scss"))
315
- return "scss";
316
- if (normalized === "sass" || normalized.endsWith(".sass"))
317
- return "sass";
318
- if (normalized === "less" || normalized.endsWith(".less"))
319
- return "less";
320
- if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
321
- return "stylus";
322
- return null;
323
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), throwPreprocessorError = (error, filePath, language) => {
324
- if (!(error instanceof Error)) {
325
- throw new Error(`${language} compile failed in ${filePath}: ${String(error)}`);
326
- }
327
- const detail = error;
328
- const sassLine = detail.span?.start?.line;
329
- const sassCol = detail.span?.start?.column;
330
- const line = detail.line ?? sassLine;
331
- const column = detail.column ?? sassCol;
332
- const location = typeof line === "number" ? `:${line}${typeof column === "number" ? `:${column}` : ""}` : "";
333
- const message = detail.formatted ?? detail.message;
334
- const wrapped = new Error(`${language} compile failed in ${filePath}${location}
335
- ${message}`);
336
- wrapped.cause = error;
337
- throw wrapped;
338
- }, requireOptionalPeerSync = (specifier) => {
339
- try {
340
- return requireFromCwd(specifier);
341
- } catch {
342
- return requireOptionalPeer(specifier);
343
- }
344
- }, normalizeLoadPaths = (filePath, paths = []) => [
345
- dirname(filePath),
346
- process.cwd(),
347
- ...paths.map((path) => resolve2(process.cwd(), path))
348
- ], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
349
- pattern,
350
- replacements: Array.isArray(value) ? value : [value]
351
- })), readTsconfigAliases = () => {
352
- const cwd = process.cwd();
353
- if (tsconfigAliasCache?.cwd === cwd)
354
- return tsconfigAliasCache;
355
- const tsconfigPath = resolve2(cwd, "tsconfig.json");
356
- const empty = { aliases: [], baseUrl: cwd, cwd };
357
- if (!existsSync2(tsconfigPath)) {
358
- tsconfigAliasCache = empty;
359
- return empty;
360
- }
361
- try {
362
- const parsed = JSON.parse(stripJsonComments(readFileSync2(tsconfigPath, "utf-8")));
363
- const compilerOptions = parsed.compilerOptions ?? {};
364
- const baseUrl = resolve2(cwd, compilerOptions.baseUrl ?? ".");
365
- tsconfigAliasCache = {
366
- aliases: normalizeAliasEntries(compilerOptions.paths),
367
- baseUrl,
368
- cwd
369
- };
370
- } catch {
371
- tsconfigAliasCache = empty;
372
- }
373
- return tsconfigAliasCache;
374
- }, getAliasEntries = (config) => {
375
- const tsconfig = readTsconfigAliases();
376
- return {
377
- aliases: [
378
- ...normalizeAliasEntries(config?.aliases),
379
- ...tsconfig.aliases
380
- ],
381
- baseUrl: tsconfig.baseUrl
382
- };
383
- }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
384
- const { aliases, baseUrl } = getAliasEntries(config);
385
- const targets = [];
386
- for (const alias of aliases) {
387
- const match = specifier.match(aliasPatternToRegExp(alias.pattern));
388
- if (!match)
389
- continue;
390
- const wildcard = match[1] ?? "";
391
- for (const replacement of alias.replacements) {
392
- targets.push(resolve2(baseUrl, replacement.replace("*", wildcard)));
393
- }
394
- }
395
- return targets;
396
- }, getLanguageExtensions = (language) => {
397
- if (language === "less")
398
- return [".less", ".css"];
399
- if (language === "stylus")
400
- return [".styl", ".stylus", ".css"];
401
- return [".scss", ".sass", ".css"];
402
- }, getCandidatePaths = (basePath, language) => {
403
- const ext = extname(basePath);
404
- const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
405
- `${basePath}${extension}`,
406
- join2(basePath, `index${extension}`)
407
- ]);
408
- if (language === "scss" || language === "sass") {
409
- return paths.flatMap((path) => {
410
- const dir = dirname(path);
411
- const base = path.slice(dir.length + 1);
412
- return [path, join2(dir, `_${base}`)];
413
- });
414
- }
415
- return paths;
416
- }, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
417
- const rawCandidates = [
418
- ...resolveAliasTargets(specifier, config),
419
- isAbsolute(specifier) ? specifier : resolve2(fromDirectory, specifier),
420
- ...loadPaths.map((path) => resolve2(path, specifier))
421
- ];
422
- for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
423
- if (existsSync2(candidate))
424
- return candidate;
425
- }
426
- return null;
427
- }, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
428
- const markerIndex = url.search(/[?#]/);
429
- if (markerIndex === -1)
430
- return { marker: "", path: url };
431
- return {
432
- marker: url.slice(markerIndex),
433
- path: url.slice(0, markerIndex)
434
- };
435
- }, rebaseCssUrls = (contents, sourceFile, entryFile) => {
436
- const sourceDir = dirname(sourceFile);
437
- const entryDir = dirname(entryFile);
438
- if (sourceDir === entryDir)
439
- return contents;
440
- return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
441
- const trimmedUrl = rawUrl.trim();
442
- if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
443
- return match;
444
- const { marker, path } = splitCssUrl(trimmedUrl);
445
- const rebased = relative(entryDir, resolve2(sourceDir, path)).replace(/\\/g, "/");
446
- const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
447
- const nextQuote = quote || '"';
448
- return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
449
- });
450
- }, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
451
- if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
452
- return match;
453
- const resolved = resolveImportPath(specifier, dirname(sourceFile), loadPaths, language, config);
454
- return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
455
- }), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
456
- const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
457
- return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
458
- }, extractCssModuleExports = (css) => {
459
- const exports = {};
460
- const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
461
- for (const declaration of body.split(";")) {
462
- const separator = declaration.indexOf(":");
463
- if (separator === -1)
464
- continue;
465
- const key = declaration.slice(0, separator).trim();
466
- const value = declaration.slice(separator + 1).trim();
467
- if (key && value)
468
- exports[key] = value;
469
- }
470
- return "";
471
- });
472
- return { css: nextCss, exports };
473
- }, getSassOptions = (config, language) => ({
474
- ...config?.sass ?? {},
475
- ...language === "scss" ? config?.scss ?? {} : {}
476
- }), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
477
- ${contents}` : contents, normalizePostcssModule = (mod) => {
478
- if (mod && typeof mod === "object" && "default" in mod) {
479
- return mod.default ?? mod;
480
- }
481
- return mod;
482
- }, loadPostcssConfigFile = async (configPath) => {
483
- const resolved = resolve2(process.cwd(), configPath);
484
- const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
485
- const config = normalizePostcssModule(loaded);
486
- const value = typeof config === "function" ? await config({
487
- cwd: process.cwd(),
488
- env: "development"
489
- }) : config;
490
- return normalizePostcssModule(value) ?? {};
491
- }, normalizePostcssPlugins = (plugins) => {
492
- if (!plugins)
493
- return [];
494
- if (Array.isArray(plugins))
495
- return plugins.filter(Boolean);
496
- const resolved = [];
497
- for (const [specifier, options] of Object.entries(plugins)) {
498
- if (options === false)
499
- continue;
500
- const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
501
- const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
502
- if (plugin)
503
- resolved.push(plugin);
504
- }
505
- return resolved;
506
- }, resolvePostcssConfig = async (config) => {
507
- const inlineConfig = config?.postcss;
508
- if (!inlineConfig)
509
- return null;
510
- const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
511
- const plugins = [
512
- ...normalizePostcssPlugins(fileConfig.plugins),
513
- ...normalizePostcssPlugins(inlineConfig.plugins)
514
- ];
515
- if (plugins.length === 0)
516
- return null;
517
- return {
518
- options: {
519
- ...fileConfig.options ?? {},
520
- ...inlineConfig.options ?? {}
521
- },
522
- plugins
523
- };
524
- }, runPostcss = async (css, filePath, config) => {
525
- const postcssConfig = await resolvePostcssConfig(config);
526
- if (!postcssConfig)
527
- return css;
528
- let postcssModule;
529
- try {
530
- postcssModule = await importOptionalPeer("postcss");
531
- } catch {
532
- throw missingDependencyError("postcss", filePath);
533
- }
534
- const postcss = postcssModule.default ?? postcssModule;
535
- const result = await postcss(postcssConfig.plugins).process(css, {
536
- from: filePath,
537
- map: false,
538
- ...postcssConfig.options
539
- });
540
- return result.css;
541
- }, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
542
- canonicalize(specifier, options) {
543
- const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
544
- const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
545
- return resolved ? new URL(pathToFileURL(resolve2(resolved)).href) : null;
546
- },
547
- load(canonicalUrl) {
548
- const filePath = fileURLToPath(canonicalUrl);
549
- deps?.add(filePath);
550
- const fileLanguage = getStyleLanguage(filePath);
551
- if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
552
- return null;
553
- return {
554
- contents: preprocessLoadedStyle(readFileSync2(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
555
- syntax: filePath.endsWith(".sass") ? "indented" : "scss"
556
- };
557
- }
558
- }), createLessFileManager = (entryFile, loadPaths, config, deps) => ({
559
- install(less, pluginManager) {
560
- const baseManager = new less.FileManager;
561
- const manager = Object.create(baseManager);
562
- manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config));
563
- manager.loadFile = async (filename, currentDirectory) => {
564
- const resolved = resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config);
565
- if (!resolved) {
566
- throw new Error(`Unable to resolve Less import "${filename}"`);
567
- }
568
- deps?.add(resolved);
569
- return {
570
- contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
571
- filename: resolved
572
- };
573
- };
574
- pluginManager.addFileManager(manager);
575
- }
576
- }), renderStylus = async (contents, filePath, loadPaths, options, deps) => {
577
- let stylus;
578
- try {
579
- const stylusModule = await importOptionalPeer("stylus");
580
- stylus = stylusModule.default ?? stylusModule;
581
- } catch {
582
- throw missingDependencyError("stylus", filePath);
583
- }
584
- return new Promise((resolveCss, reject) => {
585
- const renderer = stylus(contents);
586
- renderer.set("filename", filePath);
587
- for (const [key, value] of Object.entries(options.options ?? {})) {
588
- renderer.set(key, value);
589
- }
590
- for (const path of loadPaths)
591
- renderer.include(path);
592
- renderer.render((error, css) => {
593
- if (error) {
594
- reject(error);
595
- return;
596
- }
597
- if (deps) {
598
- const stylusDeps = renderer.deps?.();
599
- if (Array.isArray(stylusDeps)) {
600
- for (const dep of stylusDeps)
601
- deps.add(resolve2(dep));
602
- }
603
- }
604
- resolveCss(css ?? "");
605
- });
606
- });
607
- }, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
608
- const key = resolve2(entry);
609
- const stripped = new Set;
610
- for (const dep of deps) {
611
- const resolved = resolve2(dep);
612
- if (resolved !== key)
613
- stripped.add(resolved);
614
- }
615
- styleDependencyGraph.set(key, stripped);
616
- }, addStyleImporter = (importerPath, stylePath) => {
617
- const key = resolve2(importerPath);
618
- const target = resolve2(stylePath);
619
- const deps = styleDependencyGraph.get(key) ?? new Set;
620
- deps.add(target);
621
- styleDependencyGraph.set(key, deps);
622
- }, findStyleEntriesImporting = (changedPath) => {
623
- const target = resolve2(changedPath);
624
- const importers = [];
625
- for (const [entry, deps] of styleDependencyGraph) {
626
- if (deps.has(target))
627
- importers.push(entry);
628
- }
629
- return importers;
630
- }, recordStyleOutput = (entry, css) => {
631
- const key = resolve2(entry);
632
- const hash = createHash("sha1").update(css).digest("hex");
633
- const previous = styleOutputHashes.get(key);
634
- styleOutputHashes.set(key, hash);
635
- return previous !== hash;
636
- }, forgetStyleEntry = (entry) => {
637
- const key = resolve2(entry);
638
- styleDependencyGraph.delete(key);
639
- styleOutputHashes.delete(key);
640
- }, compileStyleSource = async (filePath, source, languageHint, config) => {
641
- const language = getStyleLanguage(languageHint ?? filePath);
642
- const rawContents = source ?? await readFile(filePath, "utf-8");
643
- const deps = new Set;
644
- if (language === "scss" || language === "sass") {
645
- const options = getSassOptions(config, language);
646
- const packageName = options.implementation ?? "sass";
647
- let sass;
648
- try {
649
- sass = await importOptionalPeer(packageName);
650
- } catch {
651
- throw missingDependencyError(packageName, filePath);
652
- }
653
- const contents = withAdditionalData(rawContents, options.additionalData);
654
- const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
655
- try {
656
- const result = sass.compileString(contents, {
657
- importers: [
658
- createSassImporter(filePath, loadPaths, language, config, deps)
659
- ],
660
- loadPaths,
661
- style: "expanded",
662
- syntax: language === "sass" ? "indented" : "scss",
663
- url: new URL(pathToFileURL(resolve2(filePath)).href)
664
- });
665
- const css = await runPostcss(result.css, filePath, config);
666
- const loadedUrls = result.loadedUrls ?? [];
667
- for (const url of loadedUrls) {
668
- if (url.protocol !== "file:")
669
- continue;
670
- const dep = fileURLToPath(url);
671
- if (resolve2(dep) === resolve2(filePath))
672
- continue;
673
- deps.add(dep);
674
- }
675
- recordStyleDeps(filePath, deps);
676
- return css;
677
- } catch (error) {
678
- throwPreprocessorError(error, filePath, language);
679
- }
680
- }
681
- if (language === "less") {
682
- const options = getLessOptions(config);
683
- let lessModule;
684
- try {
685
- lessModule = await importOptionalPeer("less");
686
- } catch {
687
- throw missingDependencyError("less", filePath);
688
- }
689
- const less = lessModule.render ? lessModule : lessModule.default;
690
- const render = less?.render;
691
- if (!render)
692
- throw missingDependencyError("less", filePath);
693
- const contents = withAdditionalData(rawContents, options.additionalData);
694
- const loadPaths = normalizeLoadPaths(filePath, options.paths);
695
- try {
696
- const result = await render(contents, {
697
- ...options.options ?? {},
698
- filename: filePath,
699
- paths: loadPaths,
700
- plugins: [
701
- ...options.options?.plugins ?? [],
702
- createLessFileManager(filePath, loadPaths, config, deps)
703
- ]
704
- });
705
- const css = await runPostcss(result.css, filePath, config);
706
- recordStyleDeps(filePath, deps);
707
- return css;
708
- } catch (error) {
709
- throwPreprocessorError(error, filePath, "less");
710
- }
711
- }
712
- if (language === "stylus") {
713
- const options = getStylusOptions(config);
714
- const loadPaths = normalizeLoadPaths(filePath, options.paths);
715
- const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
716
- try {
717
- const css = await runPostcss(await renderStylus(contents, filePath, loadPaths, options, deps), filePath, config);
718
- recordStyleDeps(filePath, deps);
719
- return css;
720
- } catch (error) {
721
- throwPreprocessorError(error, filePath, "stylus");
722
- }
723
- }
724
- return runPostcss(rawContents, filePath, config);
725
- }, createStylePreprocessorPlugin = (config) => ({
726
- name: "absolute-style-preprocessor",
727
- setup(build) {
728
- const cssModuleSources = new Map;
729
- build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
730
- namespace: "absolute-style-module",
731
- path: path.slice("absolute-style-module:".length)
732
- }));
733
- build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
734
- const source = cssModuleSources.get(path);
735
- if (!source) {
736
- throw new Error(`Unable to resolve CSS module source for ${path}`);
737
- }
738
- return {
739
- contents: source.css,
740
- loader: "css"
741
- };
742
- });
743
- build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
744
- if (isStyleModulePath(path)) {
745
- const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
746
- const compiled = await compileStyleSource(path, undefined, undefined, config);
747
- const { css, exports } = extractCssModuleExports(compiled);
748
- cssModuleSources.set(cssModulePath, { css, exports });
749
- const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
750
- return {
751
- contents: exportSource,
752
- loader: "js"
753
- };
754
- }
755
- return {
756
- contents: await compileStyleSource(path, undefined, undefined, config),
757
- loader: "css"
758
- };
759
- });
760
- build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
761
- contents: await compileStyleSource(path, undefined, undefined, config),
762
- loader: "css"
763
- }));
764
- }
765
- }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
766
- style: async ({
767
- attributes,
768
- content,
769
- filename
770
- }) => {
771
- const language = typeof attributes.lang === "string" ? attributes.lang : typeof attributes.type === "string" ? attributes.type.replace(/^text\//, "") : null;
772
- if (!language || !STYLE_LANGUAGE_PATTERN.test(language))
773
- return;
774
- const path = filename ?? `style.${language}`;
775
- return {
776
- code: await compileStyleSource(path, content, language, config)
777
- };
778
- }
779
- }), CSS_IMPORT_PATTERN, resolveCssImportsAsync = async (content, baseDir, visited) => {
780
- const matches = Array.from(content.matchAll(CSS_IMPORT_PATTERN));
781
- if (matches.length === 0)
782
- return content;
783
- let cursor = 0;
784
- const parts = [];
785
- for (const match of matches) {
786
- const importPath = match[1];
787
- if (importPath === undefined)
788
- continue;
789
- const start = match.index ?? 0;
790
- const end = start + match[0].length;
791
- parts.push(content.slice(cursor, start));
792
- const fullPath = isAbsolute(importPath) ? importPath : resolve2(baseDir, importPath);
793
- if (visited.has(fullPath) || !existsSync2(fullPath)) {
794
- parts.push(visited.has(fullPath) ? "" : match[0]);
795
- cursor = end;
796
- continue;
797
- }
798
- const nextVisited = new Set(visited);
799
- nextVisited.add(fullPath);
800
- const imported = await readFile(fullPath, "utf-8");
801
- parts.push(await resolveCssImportsAsync(imported, dirname(fullPath), nextVisited));
802
- cursor = end;
803
- }
804
- parts.push(content.slice(cursor));
805
- return parts.join("");
806
- }, compileStyleFileIfNeeded = async (filePath, config) => {
807
- if (!isPreprocessableStylePath(filePath)) {
808
- const raw = await readFile(filePath, "utf-8");
809
- const processed = await runPostcss(raw, filePath, config);
810
- return resolveCssImportsAsync(processed, dirname(filePath), new Set([filePath]));
811
- }
812
- const compiled = await compileStyleSource(filePath, undefined, undefined, config);
813
- return resolveCssImportsAsync(compiled, dirname(filePath), new Set([filePath]));
814
- }, resolveCssImportsSync = (content, baseDir, visited) => {
815
- return content.replace(CSS_IMPORT_PATTERN, (match, importPath) => {
816
- const fullPath = isAbsolute(importPath) ? importPath : resolve2(baseDir, importPath);
817
- if (visited.has(fullPath))
818
- return "";
819
- if (!existsSync2(fullPath))
820
- return match;
821
- const nextVisited = new Set(visited);
822
- nextVisited.add(fullPath);
823
- const imported = readFileSync2(fullPath, "utf-8");
824
- return resolveCssImportsSync(imported, dirname(fullPath), nextVisited);
825
- });
826
- }, compileStyleFileIfNeededSync = (filePath, config) => {
827
- const rawContents = readFileSync2(filePath, "utf-8");
828
- const language = getStyleLanguage(filePath);
829
- if (config?.postcss) {
830
- throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
831
- }
832
- if (language === "scss" || language === "sass") {
833
- const options = getSassOptions(config, language);
834
- const packageName = options.implementation ?? "sass";
835
- let sass;
836
- try {
837
- sass = requireOptionalPeerSync(packageName);
838
- } catch {
839
- throw missingDependencyError(packageName, filePath);
840
- }
841
- const contents = withAdditionalData(rawContents, options.additionalData);
842
- const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
843
- const result = sass.compileString(contents, {
844
- importers: [
845
- createSassImporter(filePath, loadPaths, language, config)
846
- ],
847
- loadPaths,
848
- style: "expanded",
849
- syntax: language === "sass" ? "indented" : "scss",
850
- url: new URL(pathToFileURL(resolve2(filePath)).href)
851
- });
852
- const loadedUrls = result.loadedUrls ?? [];
853
- for (const url of loadedUrls) {
854
- if (url.protocol !== "file:")
855
- continue;
856
- const dep = fileURLToPath(url);
857
- if (resolve2(dep) === resolve2(filePath))
858
- continue;
859
- addStyleImporter(filePath, dep);
860
- }
861
- return resolveCssImportsSync(result.css, dirname(filePath), new Set([filePath]));
862
- }
863
- if (language === "less") {
864
- 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.`);
865
- }
866
- if (language === "stylus") {
867
- 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.`);
868
- }
869
- return resolveCssImportsSync(rawContents, dirname(filePath), new Set([filePath]));
870
- }, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
871
- var init_stylePreprocessor = __esm(() => {
872
- CSS_EXTENSION_PATTERN = /\.css$/i;
873
- STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
874
- STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
875
- STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
876
- importOptionalPeer = new Function("specifier", "return import(specifier)");
877
- requireOptionalPeer = new Function("specifier", "return require(specifier)");
878
- requireFromCwd = createRequire(join2(process.cwd(), "package.json"));
879
- styleDependencyGraph = new Map;
880
- styleOutputHashes = new Map;
881
- stylePreprocessorPlugin = createStylePreprocessorPlugin();
882
- CSS_IMPORT_PATTERN = /@import\s+["']([^"']+)["']\s*;?/g;
883
- });
884
-
885
- // src/core/svelteServerModule.ts
886
- import { mkdir, readdir } from "fs/promises";
887
- import { basename, dirname as dirname2, extname as extname2, join as join3, relative as relative2, resolve as resolve3 } from "path";
888
- var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
889
- const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
890
- return importPath.startsWith(".") ? importPath : `./${importPath}`;
891
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
892
- for (const entry of entries) {
893
- const entryPath = join3(dir, entry.name);
894
- if (entry.isDirectory())
895
- stack.push(entryPath);
896
- if (entry.isFile() && entry.name === targetFileName) {
897
- return entryPath;
898
- }
899
- }
900
- return null;
901
- }, searchDirectoryLevel = async (dirs, targetFileName) => {
902
- if (dirs.length === 0)
903
- return null;
904
- const nextStack = [];
905
- const dirEntries = await Promise.all(dirs.map(async (dir) => ({
906
- dir,
907
- entries: await readdir(dir, {
908
- encoding: "utf-8",
909
- withFileTypes: true
910
- })
911
- })));
912
- for (const { dir, entries } of dirEntries) {
913
- const found = processDirectoryEntries(entries, dir, targetFileName, nextStack);
914
- if (found)
915
- return found;
916
- }
917
- return searchDirectoryLevel(nextStack, targetFileName);
918
- }, findSourceFileByBasename = async (searchRoot, targetFileName) => searchDirectoryLevel([searchRoot], targetFileName), normalizeBuiltSvelteFileName = (sourcePath) => basename(sourcePath).replace(/-[a-z0-9]{6,}(?=\.svelte$)/i, ""), resolveOriginalSourcePath = async (sourcePath) => {
919
- const cachedPath = originalSourcePathCache.get(sourcePath);
920
- if (cachedPath !== undefined) {
921
- return cachedPath;
922
- }
923
- if (!sourcePath.includes(`${join3(process.cwd(), "build")}${process.platform === "win32" ? "" : "/"}`) && !sourcePath.includes("/build/")) {
924
- originalSourcePathCache.set(sourcePath, sourcePath);
925
- return sourcePath;
926
- }
927
- const resolvedSourcePath = await findSourceFileByBasename(join3(process.cwd(), "src"), normalizeBuiltSvelteFileName(sourcePath));
928
- const nextPath = resolvedSourcePath ?? sourcePath;
929
- originalSourcePathCache.set(sourcePath, nextPath);
930
- return nextPath;
931
- }, resolveRelativeModule = async (spec, from) => {
932
- if (!spec.startsWith(".")) {
933
- return null;
934
- }
935
- const basePath = resolve3(dirname2(from), spec);
936
- const candidates = [
937
- basePath,
938
- `${basePath}.ts`,
939
- `${basePath}.js`,
940
- `${basePath}.mjs`,
941
- `${basePath}.cjs`,
942
- `${basePath}.json`,
943
- join3(basePath, "index.ts"),
944
- join3(basePath, "index.js"),
945
- join3(basePath, "index.mjs"),
946
- join3(basePath, "index.cjs"),
947
- join3(basePath, "index.json")
948
- ];
949
- const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
950
- const foundIndex = existResults.indexOf(true);
951
- return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
952
- }, getCachedModulePath = (sourcePath) => {
953
- const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
954
- const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
955
- return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
956
- }, resolveSvelteImport = async (spec, from) => {
957
- if (!spec.startsWith(".") && !spec.startsWith("/")) {
958
- const resolved = resolvePackageImport(spec);
959
- return resolved && resolved.endsWith(".svelte") ? resolved : null;
960
- }
961
- if (spec.startsWith("/")) {
962
- return spec;
963
- }
964
- if (!spec.startsWith(".")) {
965
- return null;
966
- }
967
- const explicitPath = resolve3(dirname2(from), spec);
968
- if (extname2(explicitPath) === ".svelte") {
969
- return explicitPath;
970
- }
971
- const candidate = `${explicitPath}.svelte`;
972
- if (await Bun.file(candidate).exists() === true) {
973
- return candidate;
974
- }
975
- return null;
976
- }, writeIfChanged = async (path, content) => {
977
- const targetFile = Bun.file(path);
978
- const exists = await targetFile.exists();
979
- if (exists) {
980
- const currentContent = await targetFile.text();
981
- if (currentContent === content) {
982
- return;
983
- }
984
- }
985
- await Bun.write(path, content);
986
- }, compileSvelteServerModule = async (sourcePath) => {
987
- const cachedModulePath = compiledModuleCache.get(sourcePath);
988
- if (cachedModulePath) {
989
- return cachedModulePath;
990
- }
991
- const resolutionSourcePath = await resolveOriginalSourcePath(sourcePath);
992
- const source = await Bun.file(sourcePath).text();
993
- const { compile, preprocess } = await import("svelte/compiler");
994
- const loweredAwaitSource = lowerSvelteAwaitSlotSyntax(source);
995
- const loweredSource = lowerSvelteIslandSyntax(loweredAwaitSource.code, "server");
996
- const preprocessed = await preprocess(loweredSource.code, createSvelteStylePreprocessor());
997
- let transpiled = sourcePath.endsWith(".ts") || sourcePath.endsWith(".svelte.ts") ? transpiler.transformSync(preprocessed.code) : preprocessed.code;
998
- const childImportSpecs = Array.from(transpiled.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((value) => value !== undefined);
999
- const resolvedChildModules = await Promise.all(childImportSpecs.map((spec) => resolveSvelteImport(spec, resolutionSourcePath)));
1000
- const resolvedModuleImports = await Promise.all(childImportSpecs.map((spec) => resolveRelativeModule(spec, resolutionSourcePath)));
1001
- const childModulePaths = new Map;
1002
- const rewrittenModulePaths = new Map;
1003
- const compiledChildren = await Promise.all(childImportSpecs.map(async (spec, index) => {
1004
- const resolvedChild = resolvedChildModules[index];
1005
- if (!spec || !resolvedChild)
1006
- return null;
1007
- return {
1008
- compiledPath: await compileSvelteServerModule(resolvedChild),
1009
- resolvedChild,
1010
- spec
1011
- };
1012
- }));
1013
- for (const result of compiledChildren) {
1014
- if (!result)
1015
- continue;
1016
- childModulePaths.set(result.spec, result.compiledPath);
1017
- childModulePaths.set(result.resolvedChild, result.compiledPath);
1018
- }
1019
- for (let index = 0;index < childImportSpecs.length; index += 1) {
1020
- const spec = childImportSpecs[index];
1021
- const resolvedModuleImport = resolvedModuleImports[index];
1022
- if (!spec || !resolvedModuleImport)
1023
- continue;
1024
- if (resolvedChildModules[index])
1025
- continue;
1026
- rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), resolvedModuleImport));
1027
- }
1028
- for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1029
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
1030
- }
1031
- let compiledCode = compile(transpiled, {
1032
- css: "injected",
1033
- experimental: {
1034
- async: loweredAwaitSource.transformed || loweredSource.transformed
1035
- },
1036
- filename: resolutionSourcePath,
1037
- generate: "server"
1038
- }).js.code;
1039
- for (const [spec, compiledChildPath] of childModulePaths) {
1040
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath(sourcePath), compiledChildPath));
1041
- }
1042
- for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
1043
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
1044
- }
1045
- const compiledModulePath = getCachedModulePath(sourcePath);
1046
- await mkdir(dirname2(compiledModulePath), { recursive: true });
1047
- await writeIfChanged(compiledModulePath, compiledCode);
1048
- compiledModuleCache.set(sourcePath, compiledModulePath);
1049
- return compiledModulePath;
1050
- };
1051
- var init_svelteServerModule = __esm(() => {
1052
- init_resolvePackageImport();
1053
- init_lowerIslandSyntax();
1054
- init_lowerAwaitSlotSyntax();
1055
- init_stylePreprocessor();
1056
- serverCacheRoot = join3(process.cwd(), ".absolutejs", "islands", "svelte");
1057
- compiledModuleCache = new Map;
1058
- originalSourcePathCache = new Map;
1059
- transpiler = new Bun.Transpiler({
1060
- loader: "ts",
1061
- target: "browser"
1062
- });
1063
- });
1064
-
1065
- // src/core/devRouteRegistrationCallsite.ts
1066
- var exports_devRouteRegistrationCallsite = {};
1067
- __export(exports_devRouteRegistrationCallsite, {
1068
- patchElysiaRouteRegistrationCallsites: () => patchElysiaRouteRegistrationCallsites,
1069
- isPageHandler: () => isPageHandler,
1070
- getOriginalPageHandlerSource: () => getOriginalPageHandlerSource,
1071
- getCurrentRouteRegistrationCallsite: () => getCurrentRouteRegistrationCallsite
1072
- });
1073
- import { AsyncLocalStorage } from "async_hooks";
1074
- import { Elysia } from "elysia";
1075
- var ROUTE_CALLSITE_STORAGE_KEY, ROUTE_CALLSITE_PATCHED_KEY, ROUTE_METHOD_NAMES, PAGE_HANDLER_NAMES, pageHandlerWrappers, handlerSourceMentionsPageHelper = (handler) => {
1076
- const source = handler.toString();
1077
- return PAGE_HANDLER_NAMES.some((name) => source.includes(name));
1078
- }, getOriginalPageHandlerSource = (handler) => {
1079
- if (typeof handler !== "function")
1080
- return;
1081
- const fn = handler;
1082
- const info = pageHandlerWrappers.get(fn);
1083
- return (info?.originalHandler ?? fn).toString();
1084
- }, isPageHandler = (handler) => {
1085
- if (typeof handler !== "function")
1086
- return false;
1087
- const fn = handler;
1088
- if (pageHandlerWrappers.has(fn))
1089
- return true;
1090
- return handlerSourceMentionsPageHelper(fn);
1091
- }, isObjectRecord3 = (value) => Boolean(value) && typeof value === "object", isAsyncLocalStorage2 = (value) => isObjectRecord3(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function", isRouteMethod = (value) => typeof value === "function", getRouteCallsiteStorage = () => {
1092
- const value = Reflect.get(globalThis, ROUTE_CALLSITE_STORAGE_KEY);
1093
- if (value === null || typeof value === "undefined") {
1094
- return;
1095
- }
1096
- return isAsyncLocalStorage2(value) ? value : undefined;
1097
- }, ensureRouteCallsiteStorage = () => {
1098
- const existing = getRouteCallsiteStorage();
1099
- if (existing) {
1100
- return existing;
1101
- }
1102
- const storage = new AsyncLocalStorage;
1103
- Reflect.set(globalThis, ROUTE_CALLSITE_STORAGE_KEY, storage);
1104
- return storage;
1105
- }, normalizeCallsitePath = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, ""), shouldIgnoreRouteCallsiteFrame = (frame) => frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/core/devRouteRegistrationCallsite."), getRouteCallsiteLocation = (frame) => frame.match(/\((\/[^)]+:\d+:\d+)\)$/)?.[1] ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/)?.[1], extractRouteRegistrationCallsite = (stack) => {
1106
- const location = stack.split(`
1107
- `).slice(1).map((line) => line.trim()).filter((frame) => !shouldIgnoreRouteCallsiteFrame(frame)).map((frame) => getRouteCallsiteLocation(frame)).find((frameLocation) => frameLocation !== undefined);
1108
- return location ? normalizeCallsitePath(location) : undefined;
1109
- }, captureRouteRegistrationCallsite = () => {
1110
- const { stack } = new Error;
1111
- if (!stack) {
1112
- return;
1113
- }
1114
- return extractRouteRegistrationCallsite(stack);
1115
- }, wrapRouteHandlerWithCallsite = (handler, callsite) => {
1116
- if (typeof handler !== "function" || !callsite) {
1117
- return handler;
1118
- }
1119
- const storage = ensureRouteCallsiteStorage();
1120
- const routeHandler = handler;
1121
- return function wrappedRouteHandler(...args) {
1122
- return storage.run({ callsite }, () => Reflect.apply(routeHandler, this, args));
1123
- };
1124
- }, createPatchedRouteMethod = (originalMethod, methodName) => function patchedRouteMethod(path, handler, ...rest) {
1125
- const callsite = captureRouteRegistrationCallsite();
1126
- const wrapped = wrapRouteHandlerWithCallsite(handler, callsite);
1127
- if (methodName === "get" && typeof handler === "function" && typeof wrapped === "function" && handlerSourceMentionsPageHelper(handler)) {
1128
- pageHandlerWrappers.set(wrapped, {
1129
- originalHandler: handler
1130
- });
1131
- }
1132
- return Reflect.apply(originalMethod, this, [path, wrapped, ...rest]);
1133
- }, getCurrentRouteRegistrationCallsite = () => getRouteCallsiteStorage()?.getStore()?.callsite, patchElysiaRouteRegistrationCallsites = () => {
1134
- if (false) {}
1135
- if (Reflect.get(globalThis, ROUTE_CALLSITE_PATCHED_KEY) === true) {
1136
- return;
1137
- }
1138
- const { prototype } = Elysia;
1139
- ROUTE_METHOD_NAMES.forEach((methodName) => {
1140
- const originalMethod = Reflect.get(prototype, methodName);
1141
- if (!isRouteMethod(originalMethod))
1142
- return;
1143
- Reflect.set(prototype, methodName, createPatchedRouteMethod(originalMethod, methodName));
1144
- });
1145
- Reflect.set(globalThis, ROUTE_CALLSITE_PATCHED_KEY, true);
1146
- };
1147
- var init_devRouteRegistrationCallsite = __esm(() => {
1148
- ROUTE_CALLSITE_STORAGE_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsiteStorage");
1149
- ROUTE_CALLSITE_PATCHED_KEY = Symbol.for("absolutejs.devRouteRegistrationCallsitePatched");
1150
- ROUTE_METHOD_NAMES = [
1151
- "all",
1152
- "delete",
1153
- "get",
1154
- "head",
1155
- "options",
1156
- "patch",
1157
- "post",
1158
- "put"
1159
- ];
1160
- PAGE_HANDLER_NAMES = [
1161
- "handleReactPageRequest",
1162
- "handleSveltePageRequest",
1163
- "handleVuePageRequest",
1164
- "handleAngularPageRequest",
1165
- "handleHTMLPageRequest",
1166
- "handleHTMXPageRequest"
1167
- ];
1168
- pageHandlerWrappers = new WeakMap;
1169
- });
1170
-
1171
- // src/client/streamSwap.ts
1172
- var streamSwapRuntime = () => {
1173
- const absoluteWindow = window;
1174
- const SLOT_PATCH_EVENT = "absolutejs:slot-patch";
1175
- if (absoluteWindow.__ABS_SLOT_RUNTIME__ === true)
1176
- return;
1177
- absoluteWindow.__ABS_SLOT_RUNTIME__ = true;
1178
- absoluteWindow.__ABS_SLOT_CONSUMERS__ = absoluteWindow.__ABS_SLOT_CONSUMERS__ ?? {};
1179
- absoluteWindow.__ABS_SLOT_PENDING__ = absoluteWindow.__ABS_SLOT_PENDING__ ?? {};
1180
- const consumers = absoluteWindow.__ABS_SLOT_CONSUMERS__;
1181
- const pending = absoluteWindow.__ABS_SLOT_PENDING__;
1182
- const isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
1183
- const isPatchedPendingEntry = (value) => {
1184
- if (!isObjectRecord4(value))
1185
- return false;
1186
- return value.domPatched === true && "payload" in value;
1187
- };
1188
- const unwrapPendingPayload = (value) => isPatchedPendingEntry(value) ? value.payload : value;
1189
- const canApplyImmediately = () => absoluteWindow.__ABS_SLOT_HYDRATION_PENDING__ !== true;
1190
- const isAngularDeferPayload = (payload) => {
1191
- if (!isObjectRecord4(payload))
1192
- return false;
1193
- return payload.kind === "angular-defer";
1194
- };
1195
- const isVueSuspensePayload = (payload) => {
1196
- if (!isObjectRecord4(payload))
1197
- return false;
1198
- return payload.kind === "vue-suspense";
1199
- };
1200
- const resolveHtml = (payload) => {
1201
- if (!isObjectRecord4(payload)) {
1202
- return typeof payload === "string" ? payload : "";
1203
- }
1204
- if (typeof payload.html === "string") {
1205
- return payload.html;
1206
- }
1207
- return "";
1208
- };
1209
- const apply = (id, pendingEntry) => {
1210
- const payload = unwrapPendingPayload(pendingEntry);
1211
- if (!canApplyImmediately()) {
1212
- pending[id] = payload;
1213
- return;
1214
- }
1215
- const consumer = consumers[id];
1216
- if (typeof consumer !== "function") {
1217
- applyToDom(id, payload, pendingEntry);
1218
- return;
1219
- }
1220
- const handled = consumer(payload);
1221
- if (handled !== false) {
1222
- delete pending[id];
1223
- return;
1224
- }
1225
- applyToDom(id, payload, pendingEntry);
1226
- };
1227
- const applyToDom = (id, payload, pendingEntry) => {
1228
- if (isAngularDeferPayload(payload)) {
1229
- pending[id] = payload;
1230
- return;
1231
- }
1232
- const node = document.getElementById(id);
1233
- if (!node) {
1234
- pending[id] = payload;
1235
- return;
1236
- }
1237
- const html = resolveHtml(payload);
1238
- if (isVueSuspensePayload(payload) && isPatchedPendingEntry(pendingEntry)) {
1239
- return;
1240
- }
1241
- node.innerHTML = html;
1242
- node.setAttribute("data-absolute-slot-state", "resolved");
1243
- window.dispatchEvent(new CustomEvent(SLOT_PATCH_EVENT, {
1244
- detail: { html, id, payload }
1245
- }));
1246
- if (isVueSuspensePayload(payload)) {
1247
- pending[id] = { domPatched: true, payload };
1248
- return;
1249
- }
1250
- delete pending[id];
1251
- };
1252
- const flush = () => {
1253
- for (const id in pending) {
1254
- if (!Object.prototype.hasOwnProperty.call(pending, id))
1255
- continue;
1256
- apply(id, pending[id] ?? "");
1257
- }
1258
- };
1259
- absoluteWindow.__ABS_SLOT_FLUSH__ = flush;
1260
- absoluteWindow.__ABS_SLOT_ENQUEUE__ = (id, payload) => {
1261
- apply(id, payload);
1262
- };
1263
- if (typeof MutationObserver === "function") {
1264
- const observer = new MutationObserver(flush);
1265
- const root = document.documentElement ?? document.body ?? document;
1266
- observer.observe(root, { childList: true, subtree: true });
1267
- }
1268
- if (document.readyState === "loading") {
1269
- document.addEventListener("DOMContentLoaded", flush, { once: true });
1270
- }
1271
- flush();
1272
- }, stripFunctionWrapper = (value) => {
1273
- const start = value.indexOf("{");
1274
- const end = value.lastIndexOf("}");
1275
- if (start < 0 || end <= start)
1276
- return "";
1277
- return value.slice(start + 1, end);
1278
- }, getStreamSwapRuntimeScript = () => `(function(){${stripFunctionWrapper(streamSwapRuntime.toString())}})();`;
1279
-
1280
- // src/utils/escapeScriptContent.ts
1281
- var ESCAPE_LOOKUP, ESCAPE_REGEX, escapeScriptContent = (content) => content.replace(ESCAPE_REGEX, (char) => {
1282
- const escaped = ESCAPE_LOOKUP[char];
1283
- return escaped !== undefined ? escaped : char;
1284
- });
1285
- var init_escapeScriptContent = __esm(() => {
1286
- ESCAPE_LOOKUP = {
1287
- "\u2028": "\\u2028",
1288
- "\u2029": "\\u2029",
1289
- "<": "\\u003C"
1290
- };
1291
- ESCAPE_REGEX = /[<\u2028\u2029]/g;
1292
- });
1293
-
1294
- // src/utils/streamingSlots.ts
1295
- var SLOT_ID_PREFIX = "abs-slot-", CLOSING_BODY_TAG = "</body>", CLOSING_HEAD_TAG2 = "</head>", CLOSING_BODY_TAG_LENGTH, CLOSING_HEAD_TAG_LENGTH, CLOSING_PAGE_TAG_REGEX, STREAMING_RUNTIME_GLOBAL = "__ABS_SLOT_ENQUEUE__", STREAMING_PENDING_GLOBAL = "__ABS_SLOT_PENDING__", STREAM_TAIL_LOOKBEHIND = 128, STREAMING_SLOT_TIMEOUT_MS = 5000, STREAMING_SLOT_MAX_PER_RESPONSE = 128, STREAMING_SLOT_MAX_HTML_BYTES = 64000, createSlotPatchStatement = (id, payload) => `(window.${STREAMING_RUNTIME_GLOBAL}||function(i,p){window.${STREAMING_PENDING_GLOBAL}=window.${STREAMING_PENDING_GLOBAL}||{};window.${STREAMING_PENDING_GLOBAL}[i]=p;})(${JSON.stringify(id)},${JSON.stringify(payload)});`, createNonceAttr = (nonce) => nonce ? ` nonce="${nonce}"` : "", createStreamingSlotId = () => `${SLOT_ID_PREFIX}${Math.random().toString(BASE_36_RADIX).slice(2, RANDOM_ID_END_INDEX)}`, getStreamingSlotsRuntimeScript = () => getStreamSwapRuntimeScript(), injectHtmlIntoBody = (html, injection) => {
1296
- const closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);
1297
- if (closingBodyIndex >= 0) {
1298
- return `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;
1299
- }
1300
- return `${html}${injection}`;
1301
- }, injectHtmlIntoHead = (html, injection) => {
1302
- const closingHeadIndex = html.indexOf(CLOSING_HEAD_TAG2);
1303
- if (closingHeadIndex >= 0) {
1304
- return `${html.slice(0, closingHeadIndex)}${injection}${html.slice(closingHeadIndex)}`;
1305
- }
1306
- return `${html}${injection}`;
1307
- }, renderStreamingSlotPatchTag = (id, payload, nonce) => `<script${createNonceAttr(nonce)}>${escapeScriptContent(createSlotPatchStatement(id, payload))}</script>`, renderStreamingSlotPlaceholder = (id, fallbackHtml = "") => `<div id="${id}" data-absolute-slot="true" data-absolute-slot-state="fallback">${fallbackHtml}</div>`, renderStreamingSlotsRuntimeTag = (nonce, runtimePreludeScript) => {
1308
- const runtimeBody = [
1309
- runtimePreludeScript?.trim() ? runtimePreludeScript.trim() : "",
1310
- getStreamingSlotsRuntimeScript()
1311
- ].filter(Boolean).join(";");
1312
- return `<script${createNonceAttr(nonce)}>${escapeScriptContent(runtimeBody)}</script>`;
1313
- }, toUint8 = (value, encoder) => encoder.encode(value), isRecord = (value) => Boolean(value) && typeof value === "object", isSafeHtmlLike = (value) => isRecord(value) && typeof value.changingThisBreaksApplicationSecurity === "string", normalizeSafeHtml = (value) => {
1314
- if (isSafeHtmlLike(value)) {
1315
- return value.changingThisBreaksApplicationSecurity;
1316
- }
1317
- return value;
1318
- }, currentStreamingSlotPolicy, clonePolicy = (policy) => ({
1319
- ...policy
1320
- }), normalizeSlotBytes = (value, fallback) => {
1321
- if (typeof value === "number" && Number.isFinite(value) && value >= 0) {
1322
- return Math.floor(value);
1323
- }
1324
- return fallback;
1325
- }, normalizeSlotText = (value, fallback) => {
1326
- const normalizedValue = normalizeSafeHtml(value);
1327
- return typeof normalizedValue === "string" ? normalizedValue : fallback;
1328
- }, normalizeSlotError = (value, fallback = undefined) => {
1329
- const safeValue = normalizeSafeHtml(value);
1330
- if (typeof safeValue === "string")
1331
- return safeValue;
1332
- return fallback;
1333
- }, hasPolicyValue = (policy, key) => Object.prototype.hasOwnProperty.call(policy, key), applyStreamingSlotPolicyOverrides = (base, overridePolicy = {}) => ({
1334
- errorHtml: hasPolicyValue(overridePolicy, "errorHtml") ? normalizeSlotError(overridePolicy.errorHtml) : base.errorHtml,
1335
- fallbackHtml: hasPolicyValue(overridePolicy, "fallbackHtml") ? normalizeSlotText(overridePolicy.fallbackHtml, "") : base.fallbackHtml,
1336
- maxSlotHtmlSizeBytes: hasPolicyValue(overridePolicy, "maxSlotHtmlSizeBytes") ? normalizeSlotBytes(overridePolicy.maxSlotHtmlSizeBytes, base.maxSlotHtmlSizeBytes) : base.maxSlotHtmlSizeBytes,
1337
- maxSlotsPerResponse: hasPolicyValue(overridePolicy, "maxSlotsPerResponse") ? normalizeSlotBytes(overridePolicy.maxSlotsPerResponse, base.maxSlotsPerResponse) : base.maxSlotsPerResponse,
1338
- onError: hasPolicyValue(overridePolicy, "onError") ? overridePolicy.onError : base.onError,
1339
- onSlotMetric: hasPolicyValue(overridePolicy, "onSlotMetric") ? overridePolicy.onSlotMetric : base.onSlotMetric,
1340
- timeoutMs: hasPolicyValue(overridePolicy, "timeoutMs") ? normalizeSlotBytes(overridePolicy.timeoutMs, base.timeoutMs) : base.timeoutMs
1341
- }), createCombinedSlotErrorHandler = (policyOnError, enhancerOnError) => {
1342
- if (!policyOnError && !enhancerOnError)
1343
- return;
1344
- return (error, slot) => {
1345
- policyOnError?.(error, slot);
1346
- enhancerOnError?.(error, slot);
1347
- };
1348
- }, createCombinedSlotMetricHandler = (policyOnSlotMetric, callOnSlotMetric) => {
1349
- if (!policyOnSlotMetric && !callOnSlotMetric)
1350
- return;
1351
- return (metric) => {
1352
- policyOnSlotMetric?.(metric);
1353
- callOnSlotMetric?.(metric);
1354
- };
1355
- }, resolveStreamingSlotPolicy = (overridePolicy = {}) => {
1356
- const base = getStreamingSlotPolicy();
1357
- return applyStreamingSlotPolicyOverrides(base, overridePolicy);
1358
- }, getStreamingSlotPolicy = () => clonePolicy(currentStreamingSlotPolicy), setStreamingSlotPolicy = (policy = {}) => {
1359
- const base = getStreamingSlotPolicy();
1360
- currentStreamingSlotPolicy = applyStreamingSlotPolicyOverrides(base, policy);
1361
- }, withStreamingSlotPolicy = async (policy, callback) => {
1362
- const previous = getStreamingSlotPolicy();
1363
- setStreamingSlotPolicy(policy);
1364
- try {
1365
- return await callback();
1366
- } finally {
1367
- currentStreamingSlotPolicy = previous;
1368
- }
1369
- }, emitSlotMetric = (metric, onSlotMetric) => {
1370
- onSlotMetric?.(metric);
1371
- }, createTimeoutError = (slot, timeoutMs) => {
1372
- const error = Object.assign(new Error(`Streaming slot "${slot.id}" timed out after ${timeoutMs}ms`), { __absTimeout: true });
1373
- return error;
1374
- }, isSlotPatchPayloadObject = (value) => isRecord(value) && ("html" in value), isTimeoutError = (error) => isRecord(error) && error.__absTimeout === true, toStreamingSlot = (slot, policy) => ({
1375
- errorHtml: slot.errorHtml === undefined ? policy.errorHtml : slot.errorHtml,
1376
- fallbackHtml: normalizeSlotText(slot.fallbackHtml, policy.fallbackHtml),
1377
- id: slot.id ?? createStreamingSlotId(),
1378
- resolve: slot.resolve,
1379
- timeoutMs: normalizeSlotBytes(slot.timeoutMs, policy.timeoutMs)
1380
- }), prepareSlots = ({
1381
- policy,
1382
- slots,
1383
- onError,
1384
- onSlotMetric
1385
- }) => {
1386
- const preparedSlots = slots.map((slot) => toStreamingSlot(slot, policy));
1387
- const emitPreparedSlotMetric = (slot) => {
1388
- emitSlotMetric({
1389
- slotId: slot.id,
1390
- type: "prepared"
1391
- }, onSlotMetric);
1392
- };
1393
- const dropPreparedSlot = (slot, reason) => {
1394
- onError?.(new Error(reason), slot);
1395
- emitSlotMetric({
1396
- reason,
1397
- slotId: slot.id,
1398
- type: "dropped"
1399
- }, onSlotMetric);
1400
- };
1401
- const { maxSlotsPerResponse } = policy;
1402
- if (maxSlotsPerResponse === 0) {
1403
- preparedSlots.forEach((slot) => dropPreparedSlot(slot, "maxSlotsPerResponse is 0"));
1404
- return [];
1405
- }
1406
- if (preparedSlots.length <= maxSlotsPerResponse) {
1407
- preparedSlots.forEach(emitPreparedSlotMetric);
1408
- return preparedSlots;
1409
- }
1410
- const keptSlots = preparedSlots.slice(0, maxSlotsPerResponse);
1411
- const droppedSlots = preparedSlots.slice(maxSlotsPerResponse);
1412
- droppedSlots.forEach((slot) => {
1413
- dropPreparedSlot(slot, `Streaming slot "${slot.id}" dropped because ${maxSlotsPerResponse} slots is the configured maximum`);
1414
- });
1415
- keptSlots.forEach(emitPreparedSlotMetric);
1416
- return keptSlots;
1417
- }, htmlByteLength = (value, encoder) => encoder.encode(value).length, normalizeSlotPatchPayload = (value) => {
1418
- const safeValue = normalizeSafeHtml(value);
1419
- if (isSlotPatchPayloadObject(safeValue) && typeof safeValue.html === "string") {
1420
- return {
1421
- ...safeValue,
1422
- html: normalizeSlotText(safeValue.html, "")
1423
- };
1424
- }
1425
- return typeof safeValue === "string" ? safeValue : `${safeValue}`;
1426
- }, getPayloadHtml = (payload) => typeof payload === "string" ? payload : payload.html, enqueueEncodedText = (controller, encoder, value) => {
1427
- if (value.length === 0) {
1428
- return;
1429
- }
1430
- controller.enqueue(encoder.encode(value));
1431
- }, readStreamingRuntimeChunk = async (reader) => {
1432
- const { done, value } = await reader.read();
1433
- if (done || !value) {
1434
- return { done, value: undefined };
1435
- }
1436
- return { done, value };
1437
- }, applyBaseWinnerState = (state, winner, handleResolved) => {
1438
- if (!state.handled && winner.kind === "slot") {
1439
- handleResolved(winner);
1440
- }
1441
- return state;
1442
- }, resolveOversizedSlotPayload = (input) => {
1443
- const {
1444
- encoder,
1445
- html,
1446
- maxSlotHtmlSizeBytes,
1447
- onError,
1448
- onSlotMetric,
1449
- slot,
1450
- start
1451
- } = input;
1452
- const bytes = htmlByteLength(html, encoder);
1453
- if (bytes <= maxSlotHtmlSizeBytes) {
1454
- return null;
1455
- }
1456
- const error = new Error(`Streaming slot "${slot.id}" exceeded max payload size of ${maxSlotHtmlSizeBytes} bytes`);
1457
- const durationMs = Date.now() - start;
1458
- onError?.(error, slot);
1459
- emitSlotMetric({
1460
- bytes,
1461
- durationMs,
1462
- error,
1463
- slotId: slot.id,
1464
- type: "size_exceeded"
1465
- }, onSlotMetric);
1466
- const fallbackHtml = normalizeSlotError(slot.errorHtml, undefined);
1467
- return {
1468
- bytes: fallbackHtml === undefined ? 0 : htmlByteLength(fallbackHtml, encoder),
1469
- durationMs,
1470
- id: slot.id,
1471
- payload: fallbackHtml === undefined ? null : fallbackHtml
1472
- };
1473
- }, raceWithTimeout = (promise, slot) => {
1474
- const { timeoutMs } = slot;
1475
- if (typeof timeoutMs !== "number" || timeoutMs <= 0) {
1476
- return promise;
1477
- }
1478
- const { promise: timeoutPromise, reject } = Promise.withResolvers();
1479
- setTimeout(() => {
1480
- reject(createTimeoutError(slot, timeoutMs));
1481
- }, timeoutMs);
1482
- return Promise.race([promise, timeoutPromise]);
1483
- }, resolveSlot = async (slot, onError, policy, onSlotMetric) => {
1484
- const safePolicy = policy ?? getStreamingSlotPolicy();
1485
- const encoder = new TextEncoder;
1486
- const start = Date.now();
1487
- try {
1488
- const maybeAsyncValue = Promise.resolve(slot.resolve());
1489
- const resolved = await raceWithTimeout(maybeAsyncValue, slot);
1490
- const payload = normalizeSlotPatchPayload(resolved);
1491
- const html = getPayloadHtml(payload);
1492
- const oversizedResult = safePolicy.maxSlotHtmlSizeBytes > 0 ? resolveOversizedSlotPayload({
1493
- encoder,
1494
- html,
1495
- maxSlotHtmlSizeBytes: safePolicy.maxSlotHtmlSizeBytes,
1496
- onError,
1497
- onSlotMetric,
1498
- slot,
1499
- start
1500
- }) : null;
1501
- if (oversizedResult) {
1502
- return oversizedResult;
1503
- }
1504
- const durationMs = Date.now() - start;
1505
- const bytes = htmlByteLength(html, encoder);
1506
- emitSlotMetric({
1507
- bytes,
1508
- durationMs,
1509
- slotId: slot.id,
1510
- type: "resolved"
1511
- }, onSlotMetric);
1512
- return {
1513
- bytes,
1514
- durationMs,
1515
- id: slot.id,
1516
- payload
1517
- };
1518
- } catch (error) {
1519
- const durationMs = Date.now() - start;
1520
- onError?.(error, slot);
1521
- emitSlotMetric({
1522
- durationMs,
1523
- error,
1524
- slotId: slot.id,
1525
- type: isTimeoutError(error) ? "timeout" : "error"
1526
- }, onSlotMetric);
1527
- const html = normalizeSlotError(slot.errorHtml, undefined);
1528
- if (html) {
1529
- return {
1530
- bytes: htmlByteLength(html, encoder),
1531
- durationMs,
1532
- id: slot.id,
1533
- payload: html
1534
- };
1535
- }
1536
- return {
1537
- bytes: 0,
1538
- durationMs,
1539
- id: slot.id,
1540
- payload: null
1541
- };
1542
- }
1543
- }, nextResolvedSlot = async (pending) => {
1544
- const wrapped = pending.map((promise) => promise.then((result) => ({
1545
- original: promise,
1546
- result
1547
- })));
1548
- return Promise.race(wrapped);
1549
- }, streamChunkToString2 = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true }), appendStreamingSlotPatchesToStream = (stream, slots = [], {
1550
- injectRuntime = true,
1551
- nonce,
1552
- onError,
1553
- onSlotMetric,
1554
- policy,
1555
- runtimePreludeScript,
1556
- runtimePlacement = "head"
1557
- } = {}) => {
1558
- const resolvedPolicy = resolveStreamingSlotPolicy(policy);
1559
- const combinedOnError = createCombinedSlotErrorHandler(resolvedPolicy.onError, onError);
1560
- const combinedOnSlotMetric = createCombinedSlotMetricHandler(resolvedPolicy.onSlotMetric, onSlotMetric);
1561
- const effectivePolicy = {
1562
- ...resolvedPolicy,
1563
- onSlotMetric: combinedOnSlotMetric
1564
- };
1565
- const preparedSlots = prepareSlots({
1566
- onError: combinedOnError,
1567
- onSlotMetric: combinedOnSlotMetric,
1568
- policy: effectivePolicy,
1569
- slots
1570
- });
1571
- if (preparedSlots.length === 0)
1572
- return stream;
1573
- const source = injectRuntime ? injectStreamingRuntimeIntoStream(stream, nonce, runtimePlacement, runtimePreludeScript) : stream;
1574
- const encoder = new TextEncoder;
1575
- const decoder = new TextDecoder;
1576
- const reader = source.getReader();
1577
- const pending = preparedSlots.map((slot) => resolveSlot(slot, combinedOnError, effectivePolicy, combinedOnSlotMetric));
1578
- const createRaceCandidates = (baseDone, baseRead) => {
1579
- const racers = [];
1580
- if (!baseDone) {
1581
- racers.push(baseRead.then(({ done, value }) => ({
1582
- done,
1583
- kind: "base",
1584
- value
1585
- })));
1586
- }
1587
- if (pending.length > 0) {
1588
- racers.push(nextResolvedSlot(pending).then((resolved) => ({
1589
- kind: "slot",
1590
- ...resolved
1591
- })));
1592
- }
1593
- return racers;
1594
- };
1595
- const flushTailLookbehind = (controller, tail) => {
1596
- if (tail.length <= STREAM_TAIL_LOOKBEHIND) {
1597
- return tail;
1598
- }
1599
- const content = tail.slice(0, tail.length - STREAM_TAIL_LOOKBEHIND);
1600
- controller.enqueue(encoder.encode(content));
1601
- return tail.slice(-STREAM_TAIL_LOOKBEHIND);
1602
- };
1603
- const finalizeCompletedBaseWinner = (controller, decodedTail, baseRead) => {
1604
- const footerStart = decodedTail.search(CLOSING_PAGE_TAG_REGEX);
1605
- if (footerStart < 0) {
1606
- enqueueEncodedText(controller, encoder, decodedTail);
1607
- return {
1608
- baseDone: true,
1609
- baseRead,
1610
- footer: "",
1611
- handled: true,
1612
- tail: ""
1613
- };
1614
- }
1615
- const content = decodedTail.slice(0, footerStart);
1616
- const nextFooter = decodedTail.slice(footerStart);
1617
- enqueueEncodedText(controller, encoder, content);
1618
- return {
1619
- baseDone: true,
1620
- baseRead,
1621
- footer: nextFooter,
1622
- handled: true,
1623
- tail: ""
1624
- };
1625
- };
1626
- const handleBaseWinner = (controller, winner, baseRead, tail, footer) => {
1627
- if (winner.kind !== "base") {
1628
- return { baseDone: false, baseRead, footer, handled: false, tail };
1629
- }
1630
- if (winner.done) {
1631
- return finalizeCompletedBaseWinner(controller, tail + decoder.decode(), baseRead);
1632
- }
1633
- if (!winner.value) {
1634
- return { baseDone: false, baseRead, footer, handled: true, tail };
1635
- }
1636
- const nextTail = flushTailLookbehind(controller, tail + streamChunkToString2(winner.value, decoder));
1637
- return {
1638
- baseDone: false,
1639
- baseRead: reader.read(),
1640
- footer,
1641
- handled: true,
1642
- tail: nextTail
1643
- };
1644
- };
1645
- const handleResolvedSlot = (controller, winner) => {
1646
- const index = pending.indexOf(winner.original);
1647
- if (index >= 0)
1648
- pending.splice(index, 1);
1649
- if (winner.result.payload === null) {
1650
- return;
1651
- }
1652
- emitSlotMetric({
1653
- bytes: winner.result.bytes,
1654
- durationMs: winner.result.durationMs,
1655
- slotId: winner.result.id,
1656
- type: "patched"
1657
- }, combinedOnSlotMetric);
1658
- controller.enqueue(encoder.encode(renderStreamingSlotPatchTag(winner.result.id, winner.result.payload, nonce)));
1659
- };
1660
- const runPatchedStreamLoop = async (controller) => {
1661
- let baseDone = false;
1662
- let baseRead = reader.read();
1663
- let tail = "";
1664
- let footer = "";
1665
- const readNextRaceWinner = async () => {
1666
- const racers = createRaceCandidates(baseDone, baseRead);
1667
- if (racers.length === 0) {
1668
- return footer;
1669
- }
1670
- const winner = await Promise.race(racers);
1671
- const baseWinnerState = applyBaseWinnerState(handleBaseWinner(controller, winner, baseRead, tail, footer), winner, (slotWinner) => {
1672
- handleResolvedSlot(controller, slotWinner);
1673
- });
1674
- ({ baseDone, baseRead, footer, tail } = baseWinnerState);
1675
- if (baseDone && pending.length === 0) {
1676
- return footer;
1677
- }
1678
- return readNextRaceWinner();
1679
- };
1680
- return readNextRaceWinner();
1681
- };
1682
- return new ReadableStream({
1683
- async start(controller) {
1684
- try {
1685
- const footer = await runPatchedStreamLoop(controller);
1686
- enqueueEncodedText(controller, encoder, footer);
1687
- controller.close();
1688
- } catch (error) {
1689
- controller.error(error);
1690
- }
1691
- }
1692
- });
1693
- }, injectStreamingRuntimeIntoStream = (stream, nonce, runtimePlacement = "head", runtimePreludeScript) => {
1694
- const runtimeTag = renderStreamingSlotsRuntimeTag(nonce, runtimePreludeScript);
1695
- const encoder = new TextEncoder;
1696
- const decoder = new TextDecoder;
1697
- const closingTag = runtimePlacement === "body" ? CLOSING_BODY_TAG : CLOSING_HEAD_TAG2;
1698
- const lookbehind = (runtimePlacement === "body" ? CLOSING_BODY_TAG_LENGTH : CLOSING_HEAD_TAG_LENGTH) - 1;
1699
- const flushRuntimeLookbehind = (controller, pending) => {
1700
- if (pending.length <= lookbehind) {
1701
- return pending;
1702
- }
1703
- const safeText = pending.slice(0, pending.length - lookbehind);
1704
- controller.enqueue(encoder.encode(safeText));
1705
- return pending.slice(-lookbehind);
1706
- };
1707
- const injectRuntimeIntoPending = (pending) => runtimePlacement === "body" ? injectHtmlIntoBody(pending, runtimeTag) : injectHtmlIntoHead(pending, runtimeTag);
1708
- const processRuntimePending = (controller, pending, injected) => {
1709
- if (injected) {
1710
- controller.enqueue(encoder.encode(pending));
1711
- return { injected, pending: "" };
1712
- }
1713
- const closingTagIndex = pending.indexOf(closingTag);
1714
- if (closingTagIndex >= 0) {
1715
- const withRuntime = `${pending.slice(0, closingTagIndex)}${runtimeTag}${pending.slice(closingTagIndex)}`;
1716
- controller.enqueue(encoder.encode(withRuntime));
1717
- return { injected: true, pending: "" };
1718
- }
1719
- return {
1720
- injected,
1721
- pending: flushRuntimeLookbehind(controller, pending)
1722
- };
1723
- };
1724
- return new ReadableStream({
1725
- async start(controller) {
1726
- const reader = stream.getReader();
1727
- let injected = false;
1728
- let pending = "";
1729
- const enqueuePending = () => enqueueEncodedText(controller, encoder, pending);
1730
- const consumeRuntimeChunk = async () => {
1731
- const { done, value } = await readStreamingRuntimeChunk(reader);
1732
- if (done || !value) {
1733
- return done;
1734
- }
1735
- pending += streamChunkToString2(value, decoder);
1736
- ({ injected, pending } = processRuntimePending(controller, pending, injected));
1737
- return false;
1738
- };
1739
- const runRuntimeInjectionLoop = async () => {
1740
- const done = await consumeRuntimeChunk();
1741
- if (done) {
1742
- return;
1743
- }
1744
- await runRuntimeInjectionLoop();
1745
- };
1746
- try {
1747
- await runRuntimeInjectionLoop();
1748
- pending += decoder.decode();
1749
- pending = injected ? pending : injectRuntimeIntoPending(pending);
1750
- enqueuePending();
1751
- controller.close();
1752
- } catch (error) {
1753
- controller.error(error);
1754
- }
1755
- }
1756
- });
1757
- }, streamOutOfOrderSlots = ({
1758
- footerHtml = "",
1759
- headerHtml = "",
1760
- nonce,
1761
- policy,
1762
- onSlotMetric,
1763
- onError,
1764
- slots
1765
- }) => {
1766
- const resolvedPolicy = resolveStreamingSlotPolicy(policy);
1767
- const combinedOnError = createCombinedSlotErrorHandler(resolvedPolicy.onError, onError);
1768
- const combinedOnSlotMetric = createCombinedSlotMetricHandler(resolvedPolicy.onSlotMetric, onSlotMetric);
1769
- const effectivePolicy = {
1770
- ...resolvedPolicy,
1771
- onSlotMetric: combinedOnSlotMetric
1772
- };
1773
- const preparedSlots = prepareSlots({
1774
- onError: combinedOnError,
1775
- onSlotMetric: combinedOnSlotMetric,
1776
- policy: effectivePolicy,
1777
- slots
1778
- });
1779
- const encoder = new TextEncoder;
1780
- const createPendingSlots = (controller) => preparedSlots.map((slot) => {
1781
- const fallback = renderStreamingSlotPlaceholder(slot.id, normalizeSlotText(slot.fallbackHtml, ""));
1782
- controller.enqueue(toUint8(fallback, encoder));
1783
- return resolveSlot(slot, combinedOnError, effectivePolicy, combinedOnSlotMetric);
1784
- });
1785
- const handleResolvedPreparedSlot = async (controller, pending) => {
1786
- const { original, result } = await nextResolvedSlot(pending);
1787
- const index = pending.indexOf(original);
1788
- if (index >= 0)
1789
- pending.splice(index, 1);
1790
- if (result.payload === null) {
1791
- return;
1792
- }
1793
- emitSlotMetric({
1794
- bytes: result.bytes,
1795
- durationMs: result.durationMs,
1796
- slotId: result.id,
1797
- type: "patched"
1798
- }, combinedOnSlotMetric);
1799
- controller.enqueue(toUint8(renderStreamingSlotPatchTag(result.id, result.payload, nonce), encoder));
1800
- };
1801
- const streamPreparedSlots = async (controller) => {
1802
- const pending = createPendingSlots(controller);
1803
- const streamNextPreparedSlot = async () => {
1804
- if (pending.length === 0) {
1805
- return;
1806
- }
1807
- await handleResolvedPreparedSlot(controller, pending);
1808
- await streamNextPreparedSlot();
1809
- };
1810
- await streamNextPreparedSlot();
1811
- };
1812
- const resolveHeaderHtml = () => {
1813
- const needsRuntimeTag = preparedSlots.length > 0 && !headerHtml.includes(STREAMING_RUNTIME_GLOBAL);
1814
- if (!needsRuntimeTag) {
1815
- return headerHtml;
1816
- }
1817
- return injectHtmlIntoHead(headerHtml, renderStreamingSlotsRuntimeTag(nonce));
1818
- };
1819
- return new ReadableStream({
1820
- async start(controller) {
1821
- try {
1822
- const header = resolveHeaderHtml();
1823
- controller.enqueue(toUint8(header, encoder));
1824
- await streamPreparedSlots(controller);
1825
- enqueueEncodedText(controller, encoder, footerHtml);
1826
- controller.close();
1827
- } catch (error) {
1828
- controller.error(error);
1829
- }
1830
- }
1831
- });
1832
- };
1833
- var init_streamingSlots = __esm(() => {
1834
- init_constants();
1835
- init_escapeScriptContent();
1836
- CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;
1837
- CLOSING_HEAD_TAG_LENGTH = CLOSING_HEAD_TAG2.length;
1838
- CLOSING_PAGE_TAG_REGEX = /<\/body>\s*<\/html>\s*$/i;
1839
- currentStreamingSlotPolicy = {
1840
- errorHtml: undefined,
1841
- fallbackHtml: "",
1842
- maxSlotHtmlSizeBytes: STREAMING_SLOT_MAX_HTML_BYTES,
1843
- maxSlotsPerResponse: STREAMING_SLOT_MAX_PER_RESPONSE,
1844
- timeoutMs: STREAMING_SLOT_TIMEOUT_MS
1845
- };
1846
- });
1847
-
1848
- // src/utils/getDurationString.ts
1849
- var getDurationString = (duration) => {
1850
- let durationString;
1851
- if (duration < MILLISECONDS_IN_A_SECOND) {
1852
- durationString = `${duration.toFixed(TIME_PRECISION)}ms`;
1853
- } else if (duration < MILLISECONDS_IN_A_MINUTE) {
1854
- durationString = `${(duration / MILLISECONDS_IN_A_SECOND).toFixed(TIME_PRECISION)}s`;
1855
- } else {
1856
- const totalSeconds = Math.round(duration / MILLISECONDS_IN_A_SECOND);
1857
- const minutes = Math.floor(totalSeconds / 60);
1858
- const seconds = totalSeconds % 60;
1859
- durationString = seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;
1860
- }
1861
- return durationString;
1862
- };
1863
- var init_getDurationString = __esm(() => {
1864
- init_constants();
1865
- });
1866
-
1867
- // src/utils/startupBanner.ts
1868
- var colors, MONTHS, formatTimestamp = () => {
1869
- const now = new Date;
1870
- const month = MONTHS[now.getMonth()];
1871
- const day = now.getDate().toString().padStart(2, "0");
1872
- let hours = now.getHours();
1873
- const minutes = now.getMinutes().toString().padStart(2, "0");
1874
- const seconds = now.getSeconds().toString().padStart(2, "0");
1875
- const ampm = hours >= HOURS_IN_HALF_DAY ? "PM" : "AM";
1876
- hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
1877
- return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
1878
- }, startupBanner = (options) => {
1879
- const {
1880
- version,
1881
- readyDuration,
1882
- buildDuration,
1883
- port,
1884
- host,
1885
- networkUrl,
1886
- protocol = "http"
1887
- } = options;
1888
- const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
1889
- const ver = `${colors.dim}v${version}${colors.reset}`;
1890
- const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(readyDuration)}${colors.reset}`;
1891
- const build = typeof buildDuration === "number" && Number.isFinite(buildDuration) ? ` ${colors.dim}(build ${getDurationString(buildDuration)})${colors.reset}` : "";
1892
- console.log("");
1893
- console.log(` ${name} ${ver} ${time}${build}`);
1894
- console.log("");
1895
- console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Local:${colors.reset} ${protocol}://${host === "0.0.0.0" ? "localhost" : host}:${port}/`);
1896
- if (networkUrl) {
1897
- console.log(` ${colors.green}\u279C${colors.reset} ${colors.bold}Network:${colors.reset} ${networkUrl}`);
1898
- }
1899
- console.log("");
1900
- };
1901
- var init_startupBanner = __esm(() => {
1902
- init_constants();
1903
- init_getDurationString();
1904
- colors = {
1905
- bold: "\x1B[1m",
1906
- cyan: "\x1B[36m",
1907
- dim: "\x1B[2m",
1908
- green: "\x1B[32m",
1909
- reset: "\x1B[0m"
1910
- };
1911
- MONTHS = [
1912
- "Jan",
1913
- "Feb",
1914
- "Mar",
1915
- "Apr",
1916
- "May",
1917
- "Jun",
1918
- "Jul",
1919
- "Aug",
1920
- "Sep",
1921
- "Oct",
1922
- "Nov",
1923
- "Dec"
1924
- ];
1925
- });
1926
-
1927
- // src/utils/logger.ts
1928
- var colors2, frameworkColors, formatPath = (filePath) => {
1929
- const cwd = process.cwd();
1930
- let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
1931
- relative3 = relative3.replace(/\\/g, "/");
1932
- if (!relative3.startsWith("/")) {
1933
- relative3 = `/${relative3}`;
1934
- }
1935
- return relative3;
1936
- }, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
1937
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1938
- const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
1939
- let message = action;
1940
- if (options?.path) {
1941
- const pathColor = options.framework ? getFrameworkColor(options.framework) : colors2.white;
1942
- message += ` ${pathColor}${formatPath(options.path)}${colors2.reset}`;
1943
- }
1944
- if (options?.duration !== undefined) {
1945
- message += ` ${colors2.dim}(${options.duration}ms)${colors2.reset}`;
1946
- }
1947
- console.log(`${timestamp} ${tag} ${message}`);
1948
- }, logCssUpdate = (path, framework, duration) => {
1949
- log("css update", { duration, framework: framework ?? "css", path });
1950
- }, logError = (message, error) => {
1951
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1952
- const tag = `${colors2.red}[hmr]${colors2.reset}`;
1953
- const errorMsg = error instanceof Error ? error.message : error;
1954
- const fullMessage = `${colors2.red}error${colors2.reset} ${message}${errorMsg ? `: ${errorMsg}` : ""}`;
1955
- console.error(`${timestamp} ${tag} ${fullMessage}`);
1956
- }, logHmrUpdate = (path, framework, duration) => {
1957
- log("hmr update", { duration, framework, path });
1958
- }, logInfo = (message) => {
1959
- log(message);
1960
- }, logScriptUpdate = (path, framework, duration) => {
1961
- log("script update", { duration, framework, path });
1962
- }, logServerReload = () => {
1963
- log(`${colors2.cyan}server module reloaded${colors2.reset}`);
1964
- }, logWarn = (message) => {
1965
- const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
1966
- const tag = `${colors2.yellow}[hmr]${colors2.reset}`;
1967
- console.log(`${timestamp} ${tag} ${colors2.yellow}warning ${message}${colors2.reset}`);
1968
- };
1969
- var init_logger = __esm(() => {
1970
- init_startupBanner();
1971
- colors2 = {
1972
- blue: "\x1B[34m",
1973
- bold: "\x1B[1m",
1974
- cyan: "\x1B[36m",
1975
- dim: "\x1B[2m",
1976
- green: "\x1B[32m",
1977
- magenta: "\x1B[35m",
1978
- red: "\x1B[31m",
1979
- reset: "\x1B[0m",
1980
- white: "\x1B[37m",
1981
- yellow: "\x1B[33m"
1982
- };
1983
- frameworkColors = {
1984
- angular: colors2.magenta,
1985
- assets: colors2.dim,
1986
- css: colors2.cyan,
1987
- html: colors2.white,
1988
- htmx: colors2.white,
1989
- react: colors2.blue,
1990
- svelte: colors2.yellow,
1991
- vue: colors2.green
1992
- };
1993
- });
1994
-
1995
- // src/utils/ssrErrorPage.ts
1996
- var exports_ssrErrorPage = {};
1997
- __export(exports_ssrErrorPage, {
1998
- ssrErrorPage: () => ssrErrorPage
1999
- });
2000
- var ssrErrorPage = (framework, error) => {
2001
- const frameworkColors2 = {
2002
- angular: "#dd0031",
2003
- html: "#e34c26",
2004
- htmx: "#1a365d",
2005
- react: "#61dafb",
2006
- svelte: "#ff3e00",
2007
- vue: "#42b883"
2008
- };
2009
- const accent = frameworkColors2[framework] ?? "#94a3b8";
2010
- const label = framework.charAt(0).toUpperCase() + framework.slice(1);
2011
- const message = error instanceof Error ? error.message : String(error);
2012
- return `<!DOCTYPE html>
2013
- <html>
2014
- <head>
2015
- <meta charset="utf-8">
2016
- <meta name="viewport" content="width=device-width, initial-scale=1">
2017
- <title>SSR Error - AbsoluteJS</title>
2018
- <style>
2019
- *{margin:0;padding:0;box-sizing:border-box}
2020
- body{min-height:100vh;background:linear-gradient(135deg,rgba(15,23,42,0.98) 0%,rgba(30,41,59,0.98) 100%);color:#e2e8f0;font-family:"JetBrains Mono","Fira Code",ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;font-size:14px;line-height:1.6;display:flex;align-items:flex-start;justify-content:center;padding:32px}
2021
- .card{max-width:720px;width:100%;background:rgba(30,41,59,0.6);border:1px solid rgba(71,85,105,0.5);border-radius:16px;box-shadow:0 25px 50px -12px rgba(0,0,0,0.5),0 0 0 1px rgba(255,255,255,0.05);overflow:hidden}
2022
- .header{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:20px 24px;background:rgba(15,23,42,0.5);border-bottom:1px solid rgba(71,85,105,0.4)}
2023
- .brand{font-weight:700;font-size:20px;color:#fff;letter-spacing:-0.02em}
2024
- .badge{padding:5px 10px;border-radius:8px;font-size:12px;font-weight:600;background:${accent};color:#fff;opacity:0.95;box-shadow:0 2px 4px rgba(0,0,0,0.2)}
2025
- .kind{color:#94a3b8;font-size:13px;font-weight:500}
2026
- .content{padding:24px}
2027
- .label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.08em;color:#94a3b8;margin-bottom:8px}
2028
- .message{margin:0;padding:16px 20px;background:rgba(239,68,68,0.12);border:1px solid rgba(239,68,68,0.25);border-radius:10px;overflow-x:auto;white-space:pre-wrap;word-break:break-word;color:#fca5a5;font-size:13px;line-height:1.5}
2029
- .hint{margin-top:20px;padding:12px 20px;background:rgba(71,85,105,0.3);border-radius:10px;border:1px solid rgba(71,85,105,0.4);color:#cbd5e1;font-size:13px}
2030
- </style>
2031
- </head>
2032
- <body>
2033
- <div class="card">
2034
- <div class="header">
2035
- <div style="display:flex;align-items:center;gap:12px">
2036
- <span class="brand">AbsoluteJS</span>
2037
- <span class="badge">${label}</span>
2038
- </div>
2039
- <span class="kind">Server Render Error</span>
2040
- </div>
2041
- <div class="content">
2042
- <div class="label">What went wrong</div>
2043
- <pre class="message">${message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")}</pre>
2044
- <div class="hint">A component threw during server-side rendering. Check the terminal for the full stack trace.</div>
2045
- </div>
2046
- </div>
2047
- </body>
2048
- </html>`;
2049
- };
2050
-
2051
- // src/utils/stringModifiers.ts
2052
- var normalizeSlug = (str) => str.trim().replace(/\s+/g, "-").replace(/[^A-Za-z0-9\-_]+/g, "").replace(/[-_]{2,}/g, "-"), toKebab = (str) => normalizeSlug(str).replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), toPascal = (str) => {
2053
- if (!str.includes("-") && !str.includes("_")) {
2054
- return str.charAt(0).toUpperCase() + str.slice(1);
2055
- }
2056
- return normalizeSlug(str).split(/[-_]/).filter(Boolean).map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1).toLowerCase()).join("");
2057
- };
2058
-
2059
- // src/svelte/renderToReadableStream.ts
2060
- var exports_renderToReadableStream = {};
2061
- __export(exports_renderToReadableStream, {
2062
- renderToReadableStream: () => renderToReadableStream,
2063
- SVELTE_PAGE_ROOT_ID: () => SVELTE_PAGE_ROOT_ID
2064
- });
2065
- var SVELTE_PAGE_ROOT_ID = "__absolute_svelte_root__", renderToReadableStream = async (component, props, {
2066
- bootstrapScriptContent,
2067
- bootstrapScripts = [],
2068
- bootstrapModules = [],
2069
- nonce,
2070
- onError = console.error,
2071
- progressiveChunkSize = DEFAULT_CHUNK_SIZE,
2072
- signal,
2073
- headContent,
2074
- bodyContent
2075
- } = {}) => {
2076
- try {
2077
- const { render } = await import("svelte/server");
2078
- const renderComponent = render;
2079
- const rendered = typeof props === "undefined" ? await renderComponent(component) : await renderComponent(component, { props });
2080
- const { head, body } = rendered;
2081
- const nonceAttr = nonce ? ` nonce="${nonce}"` : "";
2082
- const scripts = (bootstrapScriptContent ? `<script${nonceAttr}>${escapeScriptContent(bootstrapScriptContent)}</script>` : "") + bootstrapScripts.map((src) => `<script${nonceAttr} src="${src}"></script>`).join("") + bootstrapModules.map((src) => `<script${nonceAttr} type="module" src="${src}"></script>`).join("");
2083
- const encoder = new TextEncoder;
2084
- const full = encoder.encode(`<!DOCTYPE html><html lang="en"><head>${head}${headContent ?? ""}</head><body><div id="${SVELTE_PAGE_ROOT_ID}">${body}</div>${scripts}${bodyContent ?? ""}</body></html>`);
2085
- let offset = 0;
2086
- return new ReadableStream({
2087
- type: "bytes",
2088
- cancel(reason) {
2089
- onError?.(reason);
2090
- },
2091
- pull(controller) {
2092
- if (signal?.aborted) {
2093
- controller.close();
2094
- return;
2095
- }
2096
- if (offset >= full.length) {
2097
- controller.close();
2098
- return;
2099
- }
2100
- const end = Math.min(offset + progressiveChunkSize, full.length);
2101
- controller.enqueue(full.subarray(offset, end));
2102
- offset = end;
2103
- }
2104
- });
2105
- } catch (error) {
2106
- onError?.(error);
2107
- throw error;
2108
- }
2109
- };
2110
- var init_renderToReadableStream = __esm(() => {
2111
- init_constants();
2112
- init_escapeScriptContent();
2113
- });
2114
-
2115
- // src/core/streamingSlotRegistrar.ts
2116
- var STREAMING_SLOT_REGISTRAR_KEY = Symbol.for("absolutejs.streamingSlotRegistrar");
2117
- var STREAMING_SLOT_WARNING_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotWarningController");
2118
- var STREAMING_SLOT_COLLECTION_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotCollectionController");
2119
- var getRegisteredStreamingSlotRegistrar = () => {
2120
- const value = Reflect.get(globalThis, STREAMING_SLOT_REGISTRAR_KEY);
2121
- if (typeof value === "function" || value === null) {
2122
- return value;
2123
- }
2124
- return;
2125
- };
2126
- var isObjectRecord = (value) => Boolean(value) && typeof value === "object";
2127
- var isStreamingSlotWarningController = (value) => isObjectRecord(value) && ("maybeWarn" in value) && typeof value.maybeWarn === "function";
2128
- var isStreamingSlotCollectionController = (value) => isObjectRecord(value) && ("isCollecting" in value) && typeof value.isCollecting === "function";
2129
- var getWarningController = () => {
2130
- const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY);
2131
- if (value === null || typeof value === "undefined")
2132
- return;
2133
- return isStreamingSlotWarningController(value) ? value : undefined;
2134
- };
2135
- var getCollectionController = () => {
2136
- const value = Reflect.get(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY);
2137
- if (value === null || typeof value === "undefined")
2138
- return;
2139
- return isStreamingSlotCollectionController(value) ? value : undefined;
2140
- };
2141
- var hasRegisteredStreamingSlotRegistrar = () => typeof getRegisteredStreamingSlotRegistrar() === "function";
2142
- var isStreamingSlotCollectionActive = () => getCollectionController()?.isCollecting() === true;
2143
- var registerStreamingSlot = (slot) => {
2144
- getRegisteredStreamingSlotRegistrar()?.(slot);
2145
- };
2146
- var setStreamingSlotCollectionController = (controller) => {
2147
- Reflect.set(globalThis, STREAMING_SLOT_COLLECTION_STORAGE_KEY, controller);
2148
- };
2149
- var setStreamingSlotRegistrar = (nextRegistrar) => {
2150
- Reflect.set(globalThis, STREAMING_SLOT_REGISTRAR_KEY, nextRegistrar);
2151
- };
2152
- var setStreamingSlotWarningController = (controller) => {
2153
- Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY, controller);
2154
- };
2155
- var warnMissingStreamingSlotCollector = (primitiveName) => {
2156
- if (isStreamingSlotCollectionActive()) {
2157
- return;
2158
- }
2159
- getWarningController()?.maybeWarn(primitiveName);
2160
- };
2161
-
2162
- // src/core/streamingSlotRegistry.ts
2163
- var STREAMING_SLOT_STORAGE_KEY = Symbol.for("absolutejs.streamingSlotAsyncLocalStorage");
2164
- var isObjectRecord2 = (value) => Boolean(value) && typeof value === "object";
2165
- var isAsyncLocalStorage = (value) => isObjectRecord2(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
2166
- var getStorageGlobal = () => {
2167
- const value = Reflect.get(globalThis, STREAMING_SLOT_STORAGE_KEY);
2168
- if (value === null || typeof value === "undefined") {
2169
- return value;
2170
- }
2171
- return isAsyncLocalStorage(value) ? value : undefined;
2172
- };
2173
- var isServerRuntime = () => typeof process !== "undefined" && typeof process.versions?.node === "string";
2174
- var ensureAsyncLocalStorage = async () => {
2175
- const storage = getStorageGlobal();
2176
- if (typeof storage !== "undefined") {
2177
- return storage;
2178
- }
2179
- if (!isServerRuntime()) {
2180
- Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, null);
2181
- return getStorageGlobal();
2182
- }
2183
- const mod = await import("async_hooks");
2184
- Reflect.set(globalThis, STREAMING_SLOT_STORAGE_KEY, new mod.AsyncLocalStorage);
2185
- return getStorageGlobal();
2186
- };
2187
- var getActiveSlotStore = () => {
2188
- const storage = getStorageGlobal();
2189
- if (!storage)
2190
- return;
2191
- return storage.getStore();
2192
- };
2193
- var registerStreamingSlot2 = (slot) => {
2194
- const store = getActiveSlotStore();
2195
- if (!store)
2196
- return;
2197
- store.set(slot.id, slot);
2198
- };
2199
- setStreamingSlotRegistrar(registerStreamingSlot2);
2200
- setStreamingSlotCollectionController({
2201
- isCollecting: () => getActiveSlotStore() !== undefined
2202
- });
2203
- var hasActiveStreamingSlotRegistry = () => getActiveSlotStore() !== undefined;
2204
- var runWithStreamingSlotRegistry = async (task) => {
2205
- const storage = await ensureAsyncLocalStorage();
2206
- if (!storage) {
2207
- const slots = [];
2208
- return {
2209
- result: await task(),
2210
- slots
2211
- };
2212
- }
2213
- return storage.run(new Map, async () => {
2214
- const result = await task();
2215
- const store = storage.getStore();
2216
- return {
2217
- result,
2218
- slots: store ? [...store.values()] : []
2219
- };
2220
- });
2221
- };
2222
-
2223
- // src/svelte/pageHandler.ts
2224
- init_svelteServerModule();
2225
-
2226
- // src/core/islandPageContext.ts
2227
- var BOOTSTRAP_MANIFEST_KEY = "BootstrapClient";
2228
- var ISLAND_MARKER = 'data-island="true"';
2229
- var MANIFEST_MARKER = "__ABSOLUTE_MANIFEST__";
2230
- var ISLAND_STATE_MARKER = "__ABS_ISLAND_STATE__";
2231
- var CLOSING_HEAD_TAG = "</head>";
2232
- var buildIslandsHeadMarkup = (manifest) => {
2233
- const manifestScript = `<script>window.__ABSOLUTE_MANIFEST__ = ${JSON.stringify(manifest)}</script>`;
2234
- const islandStateScript = `<script>window.__ABS_ISLAND_STATE__ = ${JSON.stringify(globalThis.__ABS_ISLAND_STATE__ ?? {})}</script>`;
2235
- const bootstrapPath = manifest[BOOTSTRAP_MANIFEST_KEY];
2236
- const bootstrapScript = bootstrapPath ? `<script type="module" src="${bootstrapPath}"></script>` : "";
2237
- return `${manifestScript}${islandStateScript}${bootstrapScript}`;
2238
- };
2239
- var injectHeadMarkup = (html, markup) => {
2240
- const closingHeadIndex = html.indexOf("</head>");
2241
- if (closingHeadIndex >= 0) {
2242
- return `${html.slice(0, closingHeadIndex)}${markup}${html.slice(closingHeadIndex)}`;
2243
- }
2244
- const openingBodyIndex = html.indexOf("<body");
2245
- if (openingBodyIndex >= 0) {
2246
- const bodyStart = html.indexOf(">", openingBodyIndex);
2247
- if (bodyStart >= 0) {
2248
- return `${html.slice(0, openingBodyIndex)}<head>${markup}</head>${html.slice(openingBodyIndex)}`;
2249
- }
2250
- }
2251
- return `<!DOCTYPE html><html><head>${markup}</head><body>${html}</body></html>`;
2252
- };
2253
- var streamChunkToString = (value, decoder) => typeof value === "string" ? value : decoder.decode(value, { stream: true });
2254
- var flushSafePendingText = (controller, encoder, pending, lookbehind) => {
2255
- if (pending.length <= lookbehind) {
2256
- return pending;
2257
- }
2258
- const safeText = pending.slice(0, pending.length - lookbehind);
2259
- controller.enqueue(encoder.encode(safeText));
2260
- return pending.slice(-lookbehind);
2261
- };
2262
- var updateInjectedState = (consumed, injected, pending) => {
2263
- if (consumed.done) {
2264
- return { done: true, injected, pending };
2265
- }
2266
- return {
2267
- done: false,
2268
- injected: consumed.injected,
2269
- pending: consumed.pending
2270
- };
2271
- };
2272
- var readStreamChunk = async (reader) => {
2273
- const { done, value } = await reader.read();
2274
- if (done || !value) {
2275
- return { done, value: undefined };
2276
- }
2277
- return { done, value };
2278
- };
2279
- var pipeStreamWithHeadInjection = (stream, markup) => {
2280
- const encoder = new TextEncoder;
2281
- const decoder = new TextDecoder;
2282
- const lookbehind = CLOSING_HEAD_TAG.length - 1;
2283
- const processPending = (controller, pending, injected) => {
2284
- if (injected) {
2285
- controller.enqueue(encoder.encode(pending));
2286
- return { injected, pending: "" };
2287
- }
2288
- const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
2289
- if (headIndex >= 0) {
2290
- const next = `${pending.slice(0, headIndex)}${markup}${pending.slice(headIndex)}`;
2291
- controller.enqueue(encoder.encode(next));
2292
- return { injected: true, pending: "" };
2293
- }
2294
- return {
2295
- injected,
2296
- pending: flushSafePendingText(controller, encoder, pending, lookbehind)
2297
- };
2298
- };
2299
- const finishHeadInjectionStream = (controller, pending, injected) => {
2300
- let finalPending = pending + decoder.decode();
2301
- if (!injected) {
2302
- finalPending = injectHeadMarkup(finalPending, markup);
2303
- }
2304
- if (finalPending.length > 0) {
2305
- controller.enqueue(encoder.encode(finalPending));
2306
- }
2307
- controller.close();
2308
- };
2309
- const consumeHeadChunk = async (controller, reader, pending, injected) => {
2310
- const { done, value } = await readStreamChunk(reader);
2311
- if (done || !value) {
2312
- return { done, injected, pending };
2313
- }
2314
- const processed = processPending(controller, pending + streamChunkToString(value, decoder), injected);
2315
- return {
2316
- done,
2317
- injected: processed.injected,
2318
- pending: processed.pending
2319
- };
2320
- };
2321
- const runHeadInjectionLoop = async (controller, reader) => {
2322
- const consumeNextHeadChunk = async (injected, pending) => {
2323
- const consumed = await consumeHeadChunk(controller, reader, pending, injected);
2324
- const nextState = updateInjectedState(consumed, injected, pending);
2325
- if (nextState.done) {
2326
- return { injected, pending };
2327
- }
2328
- return consumeNextHeadChunk(nextState.injected, nextState.pending);
2329
- };
2330
- return consumeNextHeadChunk(false, "");
2331
- };
2332
- return new ReadableStream({
2333
- async start(controller) {
2334
- const reader = stream.getReader();
2335
- try {
2336
- const { injected, pending } = await runHeadInjectionLoop(controller, reader);
2337
- finishHeadInjectionStream(controller, pending, injected);
2338
- } catch (error) {
2339
- controller.error(error);
2340
- }
2341
- }
2342
- });
2343
- };
2344
- var pipeStreamWithIslandMarkerDetection = (stream, markup) => {
2345
- const encoder = new TextEncoder;
2346
- const decoder = new TextDecoder;
2347
- const headLookbehind = CLOSING_HEAD_TAG.length - 1;
2348
- const enqueue = (controller, text) => {
2349
- if (text.length > 0) {
2350
- controller.enqueue(encoder.encode(text));
2351
- }
2352
- };
2353
- const processHolding = (controller, held) => {
2354
- if (!held.includes(ISLAND_MARKER)) {
2355
- return { held, injected: false, pending: "", sawHead: true };
2356
- }
2357
- enqueue(controller, `${markup}${held}`);
2358
- return { held: "", injected: true, pending: "", sawHead: true };
2359
- };
2360
- const processHead = (controller, pending) => {
2361
- const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
2362
- if (headIndex < 0) {
2363
- return {
2364
- held: "",
2365
- injected: false,
2366
- pending: flushSafePendingText(controller, encoder, pending, headLookbehind),
2367
- sawHead: false
2368
- };
2369
- }
2370
- enqueue(controller, pending.slice(0, headIndex));
2371
- return processHolding(controller, pending.slice(headIndex));
2372
- };
2373
- const processChunk = (controller, state, chunk) => {
2374
- if (state.injected) {
2375
- enqueue(controller, chunk);
2376
- return state;
2377
- }
2378
- if (!state.sawHead) {
2379
- return processHead(controller, state.pending + chunk);
2380
- }
2381
- return processHolding(controller, state.held + chunk);
2382
- };
2383
- const finishMarkerStream = (controller, state) => {
2384
- const tail = decoder.decode();
2385
- const remainder = state.injected ? tail : (state.sawHead ? state.held : state.pending) + tail;
2386
- enqueue(controller, remainder);
2387
- controller.close();
2388
- };
2389
- const runMarkerLoop = (controller, reader) => {
2390
- const consumeNext = async (state) => {
2391
- const { done, value } = await readStreamChunk(reader);
2392
- if (done || !value) {
2393
- return state;
2394
- }
2395
- return consumeNext(processChunk(controller, state, streamChunkToString(value, decoder)));
2396
- };
2397
- return consumeNext({
2398
- held: "",
2399
- injected: false,
2400
- pending: "",
2401
- sawHead: false
2402
- });
2403
- };
2404
- return new ReadableStream({
2405
- async start(controller) {
2406
- const reader = stream.getReader();
2407
- try {
2408
- const finalState = await runMarkerLoop(controller, reader);
2409
- finishMarkerStream(controller, finalState);
2410
- } catch (error) {
2411
- controller.error(error);
2412
- }
2413
- }
2414
- });
2415
- };
2416
- var htmlContainsIslands = (html) => html.includes(ISLAND_MARKER);
2417
- var injectIslandPageContext = (html, options) => {
2418
- const manifest = globalThis.__absoluteManifest;
2419
- const hasIslands = options?.hasIslands ?? htmlContainsIslands(html);
2420
- if (!manifest || !hasIslands) {
2421
- return html;
2422
- }
2423
- if (html.includes(MANIFEST_MARKER) || html.includes(ISLAND_STATE_MARKER)) {
2424
- return html;
2425
- }
2426
- return injectHeadMarkup(html, buildIslandsHeadMarkup(manifest));
2427
- };
2428
- var injectIslandPageContextStream = (stream, options) => {
2429
- const manifest = globalThis.__absoluteManifest;
2430
- if (!manifest)
2431
- return stream;
2432
- const markup = buildIslandsHeadMarkup(manifest);
2433
- if (options?.hasIslands === true) {
2434
- return pipeStreamWithHeadInjection(stream, markup);
2435
- }
2436
- if (options?.hasIslands === false) {
2437
- return stream;
2438
- }
2439
- return pipeStreamWithIslandMarkerDetection(stream, markup);
2440
- };
2441
- var setCurrentIslandManifest = (manifest) => {
2442
- globalThis.__absoluteManifest = manifest;
2443
- };
2444
-
2445
- // src/svelte/pageHandler.ts
2446
- init_devRouteRegistrationCallsite();
2447
-
2448
- // src/core/responseEnhancers.ts
2449
- init_streamingSlots();
2450
- var toResponse = async (responseLike) => responseLike;
2451
- var cloneHeaders = (response) => {
2452
- const headers = new Headers(response.headers);
2453
- return headers;
2454
- };
2455
- var enhanceHtmlResponseWithStreamingSlots = (response, {
2456
- nonce,
2457
- onError,
2458
- runtimePlacement,
2459
- runtimePreludeScript,
2460
- streamingSlots = [],
2461
- policy
2462
- } = {}) => {
2463
- if (!response.body || streamingSlots.length === 0) {
2464
- return response;
2465
- }
2466
- const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
2467
- nonce,
2468
- onError,
2469
- policy,
2470
- runtimePlacement,
2471
- runtimePreludeScript
2472
- });
2473
- return new Response(body, {
2474
- headers: cloneHeaders(response),
2475
- status: response.status,
2476
- statusText: response.statusText
2477
- });
2478
- };
2479
- var withStreamingSlots = async (responseLike, options = {}) => enhanceHtmlResponseWithStreamingSlots(await toResponse(responseLike), options);
2480
- var mergeStreamingSlots = (registered, explicit) => {
2481
- const merged = new Map;
2482
- for (const slot of registered)
2483
- merged.set(slot.id, slot);
2484
- for (const slot of explicit)
2485
- merged.set(slot.id, slot);
2486
- return [...merged.values()];
2487
- };
2488
- var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
2489
- const { result, slots } = await runWithStreamingSlotRegistry(renderResponse);
2490
- const explicit = options.streamingSlots ?? [];
2491
- return withStreamingSlots(result, {
2492
- ...options,
2493
- streamingSlots: mergeStreamingSlots(slots, explicit)
2494
- });
2495
- };
2496
-
2497
- // src/core/streamingSlotWarningScope.ts
2498
- init_logger();
2499
- import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
2500
- var STREAMING_SLOT_WARNING_STORAGE_KEY2 = Symbol.for("absolutejs.streamingSlotWarningAsyncLocalStorage");
2501
- var isObjectRecord4 = (value) => Boolean(value) && typeof value === "object";
2502
- var isAsyncLocalStorage3 = (value) => isObjectRecord4(value) && ("getStore" in value) && typeof value.getStore === "function" && ("run" in value) && typeof value.run === "function";
2503
- var getWarningStorage = () => {
2504
- const value = Reflect.get(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2);
2505
- if (value === null || typeof value === "undefined") {
2506
- return;
2507
- }
2508
- return isAsyncLocalStorage3(value) ? value : undefined;
2509
- };
2510
- var ensureWarningStorage = () => {
2511
- const existing = getWarningStorage();
2512
- if (existing) {
2513
- return existing;
2514
- }
2515
- const storage = new AsyncLocalStorage2;
2516
- Reflect.set(globalThis, STREAMING_SLOT_WARNING_STORAGE_KEY2, storage);
2517
- return storage;
2518
- };
2519
- var normalizeCallsitePath2 = (value) => value.replace(`${process.cwd()}/`, "").replace(process.cwd(), "").replace(/^\.\/+/, "");
2520
- var formatWarningCallsite = (callsite) => {
2521
- const match = callsite.match(/^(.*?)(:\d+:\d+)$/);
2522
- if (!match) {
2523
- return `\x1B[36m${callsite}\x1B[0m`;
2524
- }
2525
- return `\x1B[36m${match[1]}\x1B[33m${match[2]}\x1B[0m`;
2526
- };
2527
- var shouldIgnoreWarningFrame = (frame) => frame.includes("/node_modules/") || frame.includes("/dist/") || frame.includes("/src/react/pageHandler.") || frame.includes("/src/vue/pageHandler.") || frame.includes("/src/svelte/pageHandler.") || frame.includes("/src/angular/pageHandler.") || frame.includes("/src/core/streamingSlotWarningScope.");
2528
- var getWarningLocation = (frame) => frame.match(/\((\/[^)]+:\d+:\d+)\)$/)?.[1] ?? frame.match(/at (\/[^ ]+:\d+:\d+)$/)?.[1];
2529
- var extractCallsiteFromStack = (stack) => {
2530
- const location = stack.split(`
2531
- `).slice(1).map((line) => line.trim()).filter((frame) => !shouldIgnoreWarningFrame(frame)).map((frame) => getWarningLocation(frame)).find((frameLocation) => frameLocation !== undefined);
2532
- return location ? normalizeCallsitePath2(location) : undefined;
2533
- };
2534
- var buildMissingCollectorWarning = (primitiveName, handlerCallsite) => `${primitiveName} rendered during SSR without streaming slot collection enabled. Add { collectStreamingSlots: true } to this page handler to enable out-of-order streaming for this route.${handlerCallsite ? ` Update ${formatWarningCallsite(handlerCallsite)}.` : ""}`;
2535
- setStreamingSlotWarningController({
2536
- maybeWarn: (primitiveName) => {
2537
- const store = getWarningStorage()?.getStore();
2538
- if (!store || store.hasWarned) {
2539
- return;
2540
- }
2541
- store.hasWarned = true;
2542
- logWarn(buildMissingCollectorWarning(primitiveName, store.handlerCallsite));
2543
- }
2544
- });
2545
- var captureStreamingSlotWarningCallsite = () => {
2546
- if (false) {}
2547
- const { stack } = new Error;
2548
- if (!stack) {
2549
- return;
2550
- }
2551
- return extractCallsiteFromStack(stack);
2552
- };
2553
- var runWithStreamingSlotWarningScope = (task, metadata) => ensureWarningStorage().run({ handlerCallsite: metadata?.handlerCallsite, hasWarned: false }, task);
2554
-
2555
- // src/utils/inlinePageCss.ts
2556
- var siblingCssCache = new Map;
2557
- var injectInlineCss = (headTag, css) => {
2558
- if (!css)
2559
- return headTag;
2560
- const styleBlock = `<style data-absolute-page-css>${css}</style>`;
2561
- return headTag.replace("</head>", `${styleBlock}</head>`);
2562
- };
2563
- var readSiblingCss = async (siblingJsPath) => {
2564
- if (!siblingJsPath)
2565
- return "";
2566
- const cssPath = siblingJsPath.replace(/\.js$/, ".css");
2567
- if (cssPath === siblingJsPath)
2568
- return "";
2569
- const cached = siblingCssCache.get(cssPath);
2570
- if (cached !== undefined)
2571
- return cached;
2572
- const { readFile: readFile2 } = await import("fs/promises");
2573
- try {
2574
- const css = await readFile2(cssPath, "utf-8");
2575
- siblingCssCache.set(cssPath, css);
2576
- return css;
2577
- } catch {
2578
- siblingCssCache.set(cssPath, "");
2579
- return "";
2580
- }
2581
- };
2582
- // src/utils/resolveConvention.ts
2583
- import { basename as basename2 } from "path";
2584
- var CONVENTIONS_KEY = "__absoluteConventions";
2585
- var isConventionsMap = (value) => Boolean(value) && typeof value === "object";
2586
- var getMap = () => {
2587
- const value = Reflect.get(globalThis, CONVENTIONS_KEY);
2588
- if (isConventionsMap(value))
2589
- return value;
2590
- const empty = {};
2591
- return empty;
2592
- };
2593
- var derivePageName = (pagePath) => {
2594
- const base = basename2(pagePath);
2595
- const dotIndex = base.indexOf(".");
2596
- const name = dotIndex > 0 ? base.slice(0, dotIndex) : base;
2597
- return toPascal(name);
2598
- };
2599
- var normalizeConventionPageName = (name) => toPascal(name).replace(/\d+$/, "");
2600
- var hasErrorConvention = (framework) => {
2601
- const conventions = getMap()[framework];
2602
- if (!conventions)
2603
- return false;
2604
- if (conventions.defaults?.error)
2605
- return true;
2606
- return Object.values(conventions.pages ?? {}).some((page) => Boolean(page.error));
2607
- };
2608
- var resolveErrorConventionPath = (framework, pageName) => {
2609
- const conventions = getMap()[framework];
2610
- if (!conventions)
2611
- return;
2612
- const exact = conventions.pages?.[pageName]?.error;
2613
- if (exact)
2614
- return exact;
2615
- const normalizedPageName = normalizeConventionPageName(pageName);
2616
- for (const [candidate, page] of Object.entries(conventions.pages ?? {})) {
2617
- if (normalizeConventionPageName(candidate) === normalizedPageName) {
2618
- return page.error ?? conventions.defaults?.error;
2619
- }
2620
- }
2621
- return conventions.defaults?.error;
2622
- };
2623
- var resolveNotFoundConventionPath = (framework) => getMap()[framework]?.defaults?.notFound;
2624
- var setConventions = (map) => {
2625
- Reflect.set(globalThis, CONVENTIONS_KEY, map);
2626
- };
2627
- var isDev = () => true;
2628
- var buildErrorProps = (error) => {
2629
- if (error instanceof Error) {
2630
- return {
2631
- name: error.name,
2632
- message: error.message,
2633
- ...isDev() && error.stack ? { stack: error.stack } : {}
2634
- };
2635
- }
2636
- return { message: String(error), name: "Error" };
2637
- };
2638
- var renderReactError = async (conventionPath, errorProps) => {
2639
- const { createElement } = await import("react");
2640
- const { renderToReadableStream } = await import("react-dom/server");
2641
- const mod = await import(conventionPath);
2642
- const ErrorComponent = mod.default;
2643
- if (typeof ErrorComponent !== "function")
2644
- return null;
2645
- const element = createElement(ErrorComponent, errorProps);
2646
- const stream = await renderToReadableStream(element);
2647
- return new Response(stream, {
2648
- headers: { "Content-Type": "text/html" },
2649
- status: 500
2650
- });
2651
- };
2652
- var renderSvelteError = async (conventionPath, errorProps) => {
2653
- const { render } = await import("svelte/server");
2654
- const mod = await import(conventionPath);
2655
- const ErrorComponent = mod.default;
2656
- if (!ErrorComponent)
2657
- return null;
2658
- const { head, body } = render(ErrorComponent, {
2659
- props: errorProps
2660
- });
2661
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
2662
- return new Response(html, {
2663
- headers: { "Content-Type": "text/html" },
2664
- status: 500
2665
- });
2666
- };
2667
- var unescapeVueStyles = (ssrBody) => {
2668
- let styles = "";
2669
- const body = ssrBody.replace(/<style>([\s\S]*?)<\/style>/g, (_, css) => {
2670
- styles += `<style>${css.replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">")}</style>`;
2671
- return "";
2672
- });
2673
- return { body, styles };
2674
- };
2675
- var renderVueError = async (conventionPath, errorProps) => {
2676
- const { createSSRApp, h } = await import("vue");
2677
- const { renderToString } = await import("vue/server-renderer");
2678
- const mod = await import(conventionPath);
2679
- const ErrorComponent = mod.default;
2680
- if (!ErrorComponent)
2681
- return null;
2682
- const app = createSSRApp({
2683
- render: () => h(ErrorComponent, errorProps)
2684
- });
2685
- const rawBody = await renderToString(app);
2686
- const { styles, body } = unescapeVueStyles(rawBody);
2687
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
2688
- return new Response(html, {
2689
- headers: { "Content-Type": "text/html" },
2690
- status: 500
2691
- });
2692
- };
2693
- var renderAngularError = async (conventionPath, errorProps) => {
2694
- const mod = await import(conventionPath);
2695
- const renderFn = mod.default;
2696
- if (typeof renderFn !== "function")
2697
- return null;
2698
- const html = renderFn(errorProps);
2699
- return new Response(html, {
2700
- headers: { "Content-Type": "text/html" },
2701
- status: 500
2702
- });
2703
- };
2704
- var escapeHtml = (value) => value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
2705
- 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) : "");
2706
- var renderHtmlError = async (conventionPath, errorProps) => {
2707
- const template = await Bun.file(conventionPath).text();
2708
- const html = replaceErrorTokens(template, errorProps);
2709
- return new Response(html, {
2710
- headers: { "Content-Type": "text/html" },
2711
- status: 500
2712
- });
2713
- };
2714
- var logConventionRenderError = (framework, label, renderError) => {
2715
- const message = renderError instanceof Error ? renderError.message : "";
2716
- if (message.includes("Cannot find module") || message.includes("Cannot find package") || message.includes("not found in module")) {
2717
- 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}).`);
2718
- return;
2719
- }
2720
- console.error(`[SSR] Failed to render ${framework} convention ${label} page:`, renderError);
2721
- };
2722
- var renderEmberError = async () => null;
2723
- var renderEmberNotFound = async () => null;
2724
- var ERROR_RENDERERS = {
2725
- angular: renderAngularError,
2726
- ember: renderEmberError,
2727
- html: renderHtmlError,
2728
- react: renderReactError,
2729
- svelte: renderSvelteError,
2730
- vue: renderVueError
2731
- };
2732
- var tryFrameworkErrorConvention = async (framework, pageName, errorProps, error) => {
2733
- let conventionPath = resolveErrorConventionPath(framework, pageName);
2734
- if (!conventionPath && error instanceof Error && error.stack) {
2735
- for (const match of error.stack.matchAll(/^\s*at\s+([A-Za-z_$][\w$]*)/gm)) {
2736
- const candidate = match[1];
2737
- if (!candidate)
2738
- continue;
2739
- conventionPath = resolveErrorConventionPath(framework, candidate);
2740
- if (conventionPath)
2741
- break;
2742
- }
2743
- }
2744
- if (!conventionPath)
2745
- return null;
2746
- const renderer = ERROR_RENDERERS[framework];
2747
- if (!renderer)
2748
- return null;
2749
- try {
2750
- return await renderer(conventionPath, errorProps);
2751
- } catch (renderError) {
2752
- logConventionRenderError(framework, "error", renderError);
2753
- }
2754
- return null;
2755
- };
2756
- var renderConventionError = async (framework, pageName, error) => {
2757
- const errorProps = buildErrorProps(error);
2758
- const frameworkResponse = await tryFrameworkErrorConvention(framework, pageName, errorProps, error);
2759
- if (frameworkResponse)
2760
- return frameworkResponse;
2761
- if (framework !== "html") {
2762
- const htmlResponse = await tryFrameworkErrorConvention("html", pageName, errorProps, error);
2763
- if (htmlResponse)
2764
- return htmlResponse;
2765
- }
2766
- return null;
2767
- };
2768
- var renderReactNotFound = async (conventionPath) => {
2769
- const { createElement } = await import("react");
2770
- const { renderToReadableStream } = await import("react-dom/server");
2771
- const mod = await import(conventionPath);
2772
- const NotFoundComponent = mod.default;
2773
- if (typeof NotFoundComponent !== "function")
2774
- return null;
2775
- const element = createElement(NotFoundComponent);
2776
- const stream = await renderToReadableStream(element);
2777
- return new Response(stream, {
2778
- headers: { "Content-Type": "text/html" },
2779
- status: 404
2780
- });
2781
- };
2782
- var renderSvelteNotFound = async (conventionPath) => {
2783
- const { render } = await import("svelte/server");
2784
- const mod = await import(conventionPath);
2785
- const NotFoundComponent = mod.default;
2786
- if (!NotFoundComponent)
2787
- return null;
2788
- const { head, body } = render(NotFoundComponent);
2789
- const html = `<!DOCTYPE html><html><head>${head}</head><body>${body}</body></html>`;
2790
- return new Response(html, {
2791
- headers: { "Content-Type": "text/html" },
2792
- status: 404
2793
- });
2794
- };
2795
- var renderVueNotFound = async (conventionPath) => {
2796
- const { createSSRApp, h } = await import("vue");
2797
- const { renderToString } = await import("vue/server-renderer");
2798
- const mod = await import(conventionPath);
2799
- const NotFoundComponent = mod.default;
2800
- if (!NotFoundComponent)
2801
- return null;
2802
- const app = createSSRApp({
2803
- render: () => h(NotFoundComponent)
2804
- });
2805
- const rawBody = await renderToString(app);
2806
- const { styles, body } = unescapeVueStyles(rawBody);
2807
- const html = `<!DOCTYPE html><html><head>${styles}</head><body><div id="root">${body}</div></body></html>`;
2808
- return new Response(html, {
2809
- headers: { "Content-Type": "text/html" },
2810
- status: 404
2811
- });
2812
- };
2813
- var renderAngularNotFound = async (conventionPath) => {
2814
- const mod = await import(conventionPath);
2815
- const renderFn = mod.default;
2816
- if (typeof renderFn !== "function")
2817
- return null;
2818
- const html = renderFn();
2819
- return new Response(html, {
2820
- headers: { "Content-Type": "text/html" },
2821
- status: 404
2822
- });
2823
- };
2824
- var renderHtmlNotFound = async (conventionPath) => {
2825
- const html = await Bun.file(conventionPath).text();
2826
- return new Response(html, {
2827
- headers: { "Content-Type": "text/html" },
2828
- status: 404
2829
- });
2830
- };
2831
- var NOT_FOUND_RENDERERS = {
2832
- angular: renderAngularNotFound,
2833
- ember: renderEmberNotFound,
2834
- html: renderHtmlNotFound,
2835
- react: renderReactNotFound,
2836
- svelte: renderSvelteNotFound,
2837
- vue: renderVueNotFound
2838
- };
2839
- var renderConventionNotFound = async (framework) => {
2840
- const conventionPath = resolveNotFoundConventionPath(framework);
2841
- if (!conventionPath)
2842
- return null;
2843
- const renderer = NOT_FOUND_RENDERERS[framework];
2844
- if (!renderer)
2845
- return null;
2846
- try {
2847
- return await renderer(conventionPath);
2848
- } catch (renderError) {
2849
- logConventionRenderError(framework, "not-found", renderError);
2850
- }
2851
- return null;
2852
- };
2853
- var NOT_FOUND_PRIORITY = [
2854
- "react",
2855
- "svelte",
2856
- "vue",
2857
- "angular",
2858
- "html"
2859
- ];
2860
- var renderFirstNotFound = async () => {
2861
- const renderNext = async (frameworks) => {
2862
- const [framework, ...remaining] = frameworks;
2863
- if (!framework) {
2864
- return null;
2865
- }
2866
- if (!getMap()[framework]?.defaults?.notFound) {
2867
- return renderNext(remaining);
2868
- }
2869
- const response = await renderConventionNotFound(framework);
2870
- if (response) {
2871
- return response;
2872
- }
2873
- return renderNext(remaining);
2874
- };
2875
- return renderNext(NOT_FOUND_PRIORITY);
2876
- };
2877
-
2878
- // src/svelte/pageHandler.ts
2879
- var isRecord2 = (value) => typeof value === "object" && value !== null;
2880
- var isGenericSvelteComponent = (value) => typeof value === "function" || isRecord2(value);
2881
- var readHasIslands = (value) => {
2882
- if (!isRecord2(value))
2883
- return false;
2884
- const hasIslands = value["__ABSOLUTE_PAGE_HAS_ISLANDS__"];
2885
- return typeof hasIslands === "boolean" ? hasIslands : false;
2886
- };
2887
- var readDefaultExport = (value) => isRecord2(value) ? value.default : undefined;
2888
- var primeSvelteStream = async (stream) => {
2889
- const reader = stream.getReader();
2890
- const firstChunk = await reader.read();
2891
- return { firstChunk, reader };
2892
- };
2893
- var restorePrimedStream = (firstChunk, reader) => new ReadableStream({
2894
- start(controller) {
2895
- if (!firstChunk.done) {
2896
- controller.enqueue(firstChunk.value);
2897
- }
2898
- if (firstChunk.done) {
2899
- controller.close();
2900
- return;
2901
- }
2902
- const pumpLoop = () => {
2903
- reader.read().then(({ done, value }) => done ? controller.close() : (controller.enqueue(value), pumpLoop())).catch((err) => controller.error(err));
2904
- };
2905
- pumpLoop();
2906
- }
2907
- });
2908
- var resolveRequestPathname = (request) => {
2909
- if (!request)
2910
- return;
2911
- try {
2912
- const parsed = new URL(request.url);
2913
- return `${parsed.pathname}${parsed.search}`;
2914
- } catch {
2915
- return;
2916
- }
2917
- };
2918
- var handleSveltePageRequest = async (input) => {
2919
- const resolvedIndexPath = input.indexPath;
2920
- const resolvedOptions = input;
2921
- const resolvedPagePath = input.pagePath;
2922
- const userProps = input.props;
2923
- const requestPathname = resolveRequestPathname(input.request);
2924
- const resolvedProps = requestPathname !== undefined && (!userProps || !("url" in userProps)) ? {
2925
- ...userProps ?? {},
2926
- url: requestPathname
2927
- } : userProps;
2928
- try {
2929
- const handlerCallsite = resolvedOptions?.collectStreamingSlots === true ? undefined : getCurrentRouteRegistrationCallsite() ?? captureStreamingSlotWarningCallsite();
2930
- const renderPageResponse = async () => {
2931
- const resolvePageComponent = async () => {
2932
- const loadCompiledSourcePath = async (sourcePath) => {
2933
- const compiledModulePath = await compileSvelteServerModule(sourcePath);
2934
- const loadedModule = await import(compiledModulePath);
2935
- const loadedComponent = readDefaultExport(loadedModule) ?? loadedModule;
2936
- if (!isGenericSvelteComponent(loadedComponent)) {
2937
- throw new Error(`Invalid compiled Svelte page module: ${sourcePath}`);
2938
- }
2939
- return {
2940
- component: loadedComponent,
2941
- hasIslands: readHasIslands(loadedModule)
2942
- };
2943
- };
2944
- const importedPageModule = await import(resolvedPagePath);
2945
- const importedPageComponent = readDefaultExport(importedPageModule) ?? importedPageModule;
2946
- if (typeof importedPageComponent === "string" && importedPageComponent.endsWith(".svelte")) {
2947
- return loadCompiledSourcePath(importedPageComponent);
2948
- }
2949
- if (!isGenericSvelteComponent(importedPageComponent)) {
2950
- throw new Error(`Invalid Svelte page module: ${resolvedPagePath}`);
2951
- }
2952
- return {
2953
- component: importedPageComponent,
2954
- hasIslands: readHasIslands(importedPageModule)
2955
- };
2956
- };
2957
- const { renderToReadableStream: renderToReadableStream2 } = await Promise.resolve().then(() => (init_renderToReadableStream(), exports_renderToReadableStream));
2958
- const resolvedPage = await resolvePageComponent();
2959
- const siblingCss = await readSiblingCss(resolvedPagePath);
2960
- const cssBlock = siblingCss ? `<style data-absolute-page-css>${siblingCss}</style>` : "";
2961
- const composedHeadContent = `${cssBlock}${resolvedOptions?.headContent ?? ""}`;
2962
- const stream = await renderToReadableStream2(resolvedPage.component, resolvedProps, {
2963
- bodyContent: resolvedOptions?.bodyContent,
2964
- bootstrapScriptContent: `window.__ABS_SLOT_HYDRATION_PENDING__=true;window.__INITIAL_PROPS__=${JSON.stringify(resolvedProps)};${resolvedIndexPath ? `import(${JSON.stringify(resolvedIndexPath)});` : ""}`,
2965
- headContent: composedHeadContent
2966
- });
2967
- const htmlStream = injectIslandPageContextStream(stream, {
2968
- hasIslands: resolvedPage.hasIslands ? true : undefined
2969
- });
2970
- const { firstChunk, reader } = await primeSvelteStream(htmlStream);
2971
- return new Response(restorePrimedStream(firstChunk, reader), {
2972
- headers: { "Content-Type": "text/html" }
2973
- });
2974
- };
2975
- return await runWithStreamingSlotWarningScope(() => resolvedOptions?.collectStreamingSlots === true ? withRegisteredStreamingSlots(renderPageResponse, {
2976
- ...resolvedOptions,
2977
- runtimePlacement: resolvedOptions.runtimePlacement ?? "body"
2978
- }) : renderPageResponse(), { handlerCallsite });
2979
- } catch (error) {
2980
- console.error("[SSR] Svelte render error:", error);
2981
- const pageName = derivePageName(resolvedPagePath);
2982
- const conventionResponse = await renderConventionError("svelte", pageName, error);
2983
- if (conventionResponse)
2984
- return conventionResponse;
2985
- return new Response(ssrErrorPage("svelte", error), {
2986
- headers: { "Content-Type": "text/html" },
2987
- status: 500
2988
- });
2989
- }
2990
- };
2991
- export {
2992
- handleSveltePageRequest
2993
- };
2994
-
2995
- //# debugId=60043A1DAC6A8BBA64756E2164756E21
2996
- //# sourceMappingURL=server.js.map