@ecopages/core 0.2.1-beta.0 → 0.3.0

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 (920) hide show
  1. package/README.md +176 -101
  2. package/package.json +74 -205
  3. package/src/adapters/README.md +25 -6
  4. package/src/adapters/create-app.d.ts +56 -19
  5. package/src/adapters/create-app.js +48 -63
  6. package/src/adapters/node/create-app.d.ts +198 -19
  7. package/src/adapters/node/create-app.js +582 -89
  8. package/src/adapters/node/dev-session.d.ts +35 -0
  9. package/src/adapters/node/dev-session.js +117 -0
  10. package/src/adapters/node/http-request-bridge.d.ts +2 -2
  11. package/src/adapters/node/http-request-bridge.js +187 -106
  12. package/src/adapters/node/node-client-bridge.d.ts +2 -1
  13. package/src/adapters/node/node-client-bridge.js +62 -61
  14. package/src/adapters/node/runtime-host.d.ts +11 -11
  15. package/src/adapters/node/runtime-host.js +101 -89
  16. package/src/adapters/node/server-adapter.d.ts +124 -71
  17. package/src/adapters/node/server-adapter.js +411 -297
  18. package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.d.ts +16 -0
  19. package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +32 -0
  20. package/src/adapters/shared/hmr/hmr-html-response.d.ts +14 -0
  21. package/src/adapters/shared/hmr/hmr-html-response.js +25 -0
  22. package/src/adapters/shared/hmr/hmr-manager.d.ts +116 -0
  23. package/src/adapters/shared/hmr/hmr-manager.js +464 -0
  24. package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +28 -0
  25. package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +53 -0
  26. package/src/adapters/shared/http/api-request-pipeline.d.ts +50 -0
  27. package/src/adapters/shared/http/api-request-pipeline.js +204 -0
  28. package/src/adapters/shared/{api-response.d.ts → http/api-response.d.ts} +3 -2
  29. package/src/adapters/shared/http/api-response.js +79 -0
  30. package/src/adapters/shared/http/create-body-response.d.ts +12 -0
  31. package/src/adapters/shared/http/create-body-response.js +26 -0
  32. package/src/adapters/shared/http/define-api-handler.d.ts +48 -0
  33. package/src/adapters/shared/http/define-api-handler.js +49 -0
  34. package/src/adapters/shared/{explicit-static-route-matcher.d.ts → http/explicit-static-route-matcher.d.ts} +5 -10
  35. package/src/adapters/shared/http/explicit-static-route-matcher.js +63 -0
  36. package/src/adapters/shared/{file-route-middleware-pipeline.d.ts → http/file-route-middleware-pipeline.d.ts} +2 -2
  37. package/src/adapters/shared/http/file-route-middleware-pipeline.js +84 -0
  38. package/src/adapters/shared/http/fs-server-response-factory.d.ts +9 -0
  39. package/src/adapters/shared/http/fs-server-response-factory.js +23 -0
  40. package/src/adapters/shared/{fs-server-response-matcher.d.ts → http/fs-server-response-matcher.d.ts} +35 -12
  41. package/src/adapters/shared/http/fs-server-response-matcher.js +244 -0
  42. package/src/adapters/shared/http/run-middleware-chain.d.ts +5 -0
  43. package/src/adapters/shared/http/run-middleware-chain.js +17 -0
  44. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  45. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  46. package/src/adapters/shared/runtime/copy-runtime-public-dir.d.ts +8 -0
  47. package/src/adapters/shared/runtime/copy-runtime-public-dir.js +71 -0
  48. package/src/adapters/shared/runtime/dev-static-route-prewarm.d.ts +13 -0
  49. package/src/adapters/shared/runtime/dev-static-route-prewarm.js +56 -0
  50. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  51. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  52. package/src/adapters/shared/runtime/port-manager.d.ts +116 -0
  53. package/src/adapters/shared/runtime/port-manager.js +195 -0
  54. package/src/adapters/shared/{render-context.d.ts → runtime/render-context.d.ts} +3 -3
  55. package/src/adapters/shared/runtime/render-context.js +94 -0
  56. package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +17 -0
  57. package/src/adapters/shared/runtime/runtime-app-bootstrap.js +34 -0
  58. package/src/adapters/shared/{runtime-host.d.ts → runtime/runtime-host.d.ts} +5 -2
  59. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +45 -0
  60. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +93 -0
  61. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +100 -0
  62. package/src/adapters/shared/runtime/server-request-pipeline.js +276 -0
  63. package/src/adapters/shared/{server-route-handler.d.ts → runtime/server-route-handler.d.ts} +9 -38
  64. package/src/adapters/shared/runtime/server-route-handler.js +95 -0
  65. package/src/adapters/shared/runtime/server-static-builder.d.ts +107 -0
  66. package/src/adapters/shared/runtime/server-static-builder.js +172 -0
  67. package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +20 -0
  68. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +122 -0
  69. package/src/adapters/shared/ws/websocket-lifecycle.d.ts +24 -0
  70. package/src/adapters/shared/ws/websocket-lifecycle.js +62 -0
  71. package/src/adapters/shared/ws/ws-pattern-matcher.d.ts +7 -0
  72. package/src/adapters/shared/ws/ws-pattern-matcher.js +20 -0
  73. package/src/assets/README.md +35 -0
  74. package/src/assets/app-browser-client-build.d.ts +18 -0
  75. package/src/assets/app-browser-client-build.js +476 -0
  76. package/src/assets/app-browser-client-manifest.d.ts +69 -0
  77. package/src/assets/app-browser-client-manifest.js +332 -0
  78. package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +35 -0
  79. package/src/assets/asset-processing-service/app-browser-client-bundle.js +41 -0
  80. package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +16 -0
  81. package/src/assets/asset-processing-service/asset-dependency-keys.js +80 -0
  82. package/src/assets/asset-processing-service/asset-package-role.d.ts +2 -0
  83. package/src/assets/asset-processing-service/asset-package-role.js +3 -0
  84. package/src/assets/asset-processing-service/asset-processing-integration.d.ts +7 -0
  85. package/src/assets/asset-processing-service/asset-processing-integration.js +6 -0
  86. package/src/assets/asset-processing-service/asset-processing.service.d.ts +156 -0
  87. package/src/assets/asset-processing-service/asset-processing.service.js +555 -0
  88. package/src/assets/asset-processing-service/asset.factory.js +79 -0
  89. package/src/assets/asset-processing-service/assets.types.d.ts +1 -0
  90. package/src/{services/assets → assets}/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -1
  91. package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +61 -0
  92. package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +79 -0
  93. package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +200 -0
  94. package/src/{services/assets → assets}/asset-processing-service/browser-runtime-entry.factory.d.ts +6 -2
  95. package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +67 -0
  96. package/src/assets/asset-processing-service/finalize-processed-asset.d.ts +3 -0
  97. package/src/assets/asset-processing-service/finalize-processed-asset.js +5 -0
  98. package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +11 -0
  99. package/src/assets/asset-processing-service/grouped-content-bundles.js +39 -0
  100. package/src/assets/asset-processing-service/index.d.ts +10 -0
  101. package/src/{services/assets/asset-processing-service/index.d.ts → assets/asset-processing-service/index.js} +3 -0
  102. package/src/assets/asset-processing-service/inline-content-script-body.d.ts +11 -0
  103. package/src/assets/asset-processing-service/inline-content-script-body.js +23 -0
  104. package/src/assets/asset-processing-service/materialize-content-script-asset.d.ts +9 -0
  105. package/src/assets/asset-processing-service/materialize-content-script-asset.js +22 -0
  106. package/src/{services/assets → assets}/asset-processing-service/page-package.d.ts +2 -2
  107. package/src/assets/asset-processing-service/page-package.js +81 -0
  108. package/src/assets/asset-processing-service/processor.interface.d.ts +8 -0
  109. package/src/assets/asset-processing-service/processor.interface.js +1 -0
  110. package/src/assets/asset-processing-service/processors/base/base-processor.d.ts +13 -0
  111. package/src/assets/asset-processing-service/processors/base/base-processor.js +22 -0
  112. package/src/assets/asset-processing-service/processors/base/base-script-processor.d.ts +40 -0
  113. package/src/assets/asset-processing-service/processors/base/base-script-processor.js +136 -0
  114. package/src/assets/asset-processing-service/processors/index.js +5 -0
  115. package/src/assets/asset-processing-service/processors/script/classic-script-compiler.d.ts +26 -0
  116. package/src/assets/asset-processing-service/processors/script/classic-script-compiler.js +92 -0
  117. package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +21 -0
  118. package/src/assets/asset-processing-service/processors/script/content-script.processor.js +88 -0
  119. package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +43 -0
  120. package/src/assets/asset-processing-service/processors/script/file-script.processor.js +165 -0
  121. package/src/{services/assets → assets}/asset-processing-service/processors/script/node-module-script.processor.d.ts +23 -1
  122. package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +135 -0
  123. package/src/{services/assets → assets}/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
  124. package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +36 -0
  125. package/src/{services/assets → assets}/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
  126. package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +40 -0
  127. package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
  128. package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +19 -0
  129. package/src/assets/browser-bundle.service.d.ts +45 -0
  130. package/src/assets/browser-bundle.service.js +50 -0
  131. package/src/assets/browser-runtime-asset-page-cache.d.ts +11 -0
  132. package/src/assets/browser-runtime-asset-page-cache.js +17 -0
  133. package/src/assets/hashed-browser-asset.d.ts +25 -0
  134. package/src/assets/hashed-browser-asset.js +99 -0
  135. package/src/{route-renderer/orchestration → assets}/processed-asset-dedupe.d.ts +1 -1
  136. package/src/assets/processed-asset-dedupe.js +24 -0
  137. package/src/browser-env.d.ts +4 -0
  138. package/src/browser-env.js +11 -0
  139. package/src/build/README.md +251 -44
  140. package/src/build/app-build-manifest-runtime.d.ts +38 -0
  141. package/src/build/app-build-manifest-runtime.js +126 -0
  142. package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +4 -0
  143. package/src/build/browser/browser-runtime-manifest.js +65 -0
  144. package/src/build/browser/browser-runtime-plugin-helpers.d.ts +14 -0
  145. package/src/build/browser/browser-runtime-plugin-helpers.js +21 -0
  146. package/src/build/browser/browser-runtime-plugin.d.ts +54 -0
  147. package/src/build/browser/browser-runtime-plugin.js +76 -0
  148. package/src/build/browser/jsx-ownership-plugins.d.ts +24 -0
  149. package/src/build/browser/jsx-ownership-plugins.js +55 -0
  150. package/src/build/browser/lit-static-render-worker-context.d.ts +1 -0
  151. package/src/build/browser/lit-static-render-worker-context.js +5 -0
  152. package/src/build/build-adapter.d.ts +16 -490
  153. package/src/build/build-adapter.js +39 -243
  154. package/src/build/build-graph.d.ts +34 -0
  155. package/src/build/build-graph.js +162 -0
  156. package/src/build/build-log.d.ts +19 -0
  157. package/src/build/build-log.js +35 -0
  158. package/src/build/build-parallelism.d.ts +4 -0
  159. package/src/build/build-parallelism.js +7 -0
  160. package/src/build/cache/app-config-hash.d.ts +10 -0
  161. package/src/build/cache/app-config-hash.js +22 -0
  162. package/src/build/cache/build-input-dependency-index.d.ts +118 -0
  163. package/src/build/cache/build-input-dependency-index.js +249 -0
  164. package/src/build/cache/cache-keys.d.ts +9 -0
  165. package/src/build/cache/cache-keys.js +31 -0
  166. package/src/build/cache/pages-unified-graph-build.d.ts +54 -0
  167. package/src/build/cache/pages-unified-graph-build.js +197 -0
  168. package/src/build/contracts/build-contracts.d.ts +157 -0
  169. package/src/build/contracts/build-contracts.js +1 -0
  170. package/src/build/contracts/build-manifest.d.ts +29 -0
  171. package/src/build/contracts/build-manifest.js +52 -0
  172. package/src/build/contracts/build-types.d.ts +1 -0
  173. package/src/build/contracts/build-types.js +1 -0
  174. package/src/build/contracts/content-virtual-modules.d.ts +14 -0
  175. package/src/build/contracts/content-virtual-modules.js +37 -0
  176. package/src/build/contracts/server-only-specifier.d.ts +8 -0
  177. package/src/build/contracts/server-only-specifier.js +11 -0
  178. package/src/build/contracts.d.ts +4 -0
  179. package/src/build/contracts.js +2 -0
  180. package/src/build/mapped-source-transform.d.ts +22 -0
  181. package/src/build/mapped-source-transform.js +31 -0
  182. package/src/build/preserve-import-meta-transform.d.ts +32 -0
  183. package/src/build/preserve-import-meta-transform.js +138 -0
  184. package/src/build/rolldown/app-package-declarations.d.ts +8 -0
  185. package/src/build/rolldown/app-package-declarations.js +81 -0
  186. package/src/build/rolldown/entry-module-closures.d.ts +8 -0
  187. package/src/build/rolldown/entry-module-closures.js +39 -0
  188. package/src/build/rolldown/rolldown-adapter-helpers.d.ts +97 -0
  189. package/src/build/rolldown/rolldown-adapter-helpers.js +570 -0
  190. package/src/build/rolldown/rolldown-build-adapter.d.ts +27 -0
  191. package/src/build/rolldown/rolldown-build-adapter.js +86 -0
  192. package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +12 -0
  193. package/src/build/rolldown/rolldown-build-invocation-metrics.js +40 -0
  194. package/src/build/rolldown/rolldown-plugin-bridge.d.ts +76 -0
  195. package/src/build/rolldown/rolldown-plugin-bridge.js +450 -0
  196. package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +2 -15
  197. package/src/build/rolldown/server-side-css-shim-plugin.js +59 -0
  198. package/src/build/runtime/build-environment-options.d.ts +4 -0
  199. package/src/build/runtime/build-environment-options.js +20 -0
  200. package/src/build/runtime/build-queue.d.ts +63 -0
  201. package/src/build/runtime/build-queue.js +117 -0
  202. package/src/build/runtime/build-request-identity.d.ts +15 -0
  203. package/src/build/runtime/build-request-identity.js +52 -0
  204. package/src/build/runtime/build-request-policy.d.ts +80 -0
  205. package/src/build/runtime/build-request-policy.js +132 -0
  206. package/src/build/server/README.md +50 -0
  207. package/src/build/server/app-module-loader.service.d.ts +35 -0
  208. package/src/build/server/app-module-loader.service.js +36 -0
  209. package/src/{services/module-loading → build/server}/page-module-import.service.d.ts +37 -20
  210. package/src/build/server/page-module-import.service.js +264 -0
  211. package/src/build/server/route-module-build-cache-registry.d.ts +20 -0
  212. package/src/build/server/route-module-build-cache-registry.js +41 -0
  213. package/src/build/server/route-module-build-cache.store.d.ts +49 -0
  214. package/src/build/server/route-module-build-cache.store.js +75 -0
  215. package/src/build/server/route-module-build-manifest.d.ts +56 -0
  216. package/src/build/server/route-module-build-manifest.js +49 -0
  217. package/src/build/server/route-module-dependency-hasher.d.ts +66 -0
  218. package/src/build/server/route-module-dependency-hasher.js +131 -0
  219. package/src/build/server/view-module-loader.d.ts +10 -0
  220. package/src/build/server/view-module-loader.js +46 -0
  221. package/src/build/server-bundle-deploy-manifest.d.ts +71 -0
  222. package/src/build/server-bundle-deploy-manifest.js +164 -0
  223. package/src/build/server-bundle-publication.d.ts +12 -0
  224. package/src/build/server-bundle-publication.js +39 -0
  225. package/src/build/server-module.d.ts +8 -0
  226. package/src/build/server-module.js +22 -0
  227. package/src/build/source-maps.d.ts +17 -0
  228. package/src/build/source-maps.js +29 -0
  229. package/src/build.d.ts +19 -0
  230. package/src/build.js +19 -0
  231. package/src/cache/README.md +5 -0
  232. package/src/cache/index.d.ts +3 -2
  233. package/src/cache/index.js +7 -6
  234. package/src/cache/module-parse-cache.d.ts +4 -26
  235. package/src/cache/module-parse-cache.js +90 -68
  236. package/src/cache/module-transform-profiler.d.ts +7 -0
  237. package/src/cache/module-transform-profiler.js +8 -0
  238. package/src/client/README.md +5 -0
  239. package/src/client/navigation-attributes.d.ts +2 -0
  240. package/src/client/navigation-attributes.js +2 -0
  241. package/src/client/navigation-scripts/activation.d.ts +36 -0
  242. package/src/client/navigation-scripts/activation.js +97 -0
  243. package/src/client/navigation-scripts/classification.d.ts +12 -0
  244. package/src/client/navigation-scripts/classification.js +49 -0
  245. package/src/client/navigation-scripts/identity.d.ts +19 -0
  246. package/src/client/navigation-scripts/identity.js +26 -0
  247. package/src/client/navigation-scripts/index.d.ts +4 -0
  248. package/src/client/navigation-scripts/index.js +4 -0
  249. package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +1 -0
  250. package/src/client/navigation-scripts/navigation-scripts.test.browser.js +111 -0
  251. package/src/client/navigation-scripts/registry.d.ts +12 -0
  252. package/src/client/navigation-scripts/registry.js +17 -0
  253. package/src/client/navigation-scripts/rerun-queue.d.ts +30 -0
  254. package/src/client/navigation-scripts/rerun-queue.js +84 -0
  255. package/src/client/scroll.d.ts +17 -0
  256. package/src/client/scroll.js +33 -0
  257. package/src/client/scroll.test.browser.d.ts +1 -0
  258. package/src/client/scroll.test.browser.js +31 -0
  259. package/src/client/view-transitions.d.ts +28 -0
  260. package/src/client/view-transitions.js +121 -0
  261. package/src/client/view-transitions.test.browser.d.ts +1 -0
  262. package/src/client/view-transitions.test.browser.js +53 -0
  263. package/src/client.d.ts +15 -0
  264. package/src/client.js +15 -0
  265. package/src/config/README.md +34 -12
  266. package/src/config/assembly/app-runtime.d.ts +73 -0
  267. package/src/config/assembly/app-runtime.js +82 -0
  268. package/src/config/assembly/finalize-config.d.ts +26 -0
  269. package/src/config/assembly/finalize-config.js +243 -0
  270. package/src/config/config-module-files.d.ts +11 -0
  271. package/src/config/config-module-files.js +70 -0
  272. package/src/config/constants.d.ts +1 -45
  273. package/src/config/constants.js +1 -25
  274. package/src/config/define-config.d.ts +11 -0
  275. package/src/config/define-config.js +3 -0
  276. package/src/config/index.d.ts +6 -0
  277. package/src/config/index.js +5 -0
  278. package/src/config/internal-types.d.ts +187 -0
  279. package/src/config/internal-types.js +1 -0
  280. package/src/config/load-eco-config.d.ts +15 -0
  281. package/src/config/load-eco-config.js +72 -0
  282. package/src/config/resolve-eco-config-path.d.ts +38 -0
  283. package/src/config/resolve-eco-config-path.js +70 -0
  284. package/src/config/server-config-bundle.d.ts +14 -0
  285. package/src/config/server-config-bundle.js +36 -0
  286. package/src/config/user-config-types.d.ts +156 -0
  287. package/src/config/user-config-types.js +1 -0
  288. package/src/config/write-types.d.ts +1 -0
  289. package/src/config/write-types.js +18 -0
  290. package/src/constants.d.ts +46 -0
  291. package/src/constants.js +46 -0
  292. package/src/css-imports.d.ts +4 -0
  293. package/src/declarations.d.ts +13 -6
  294. package/src/dev/README.md +61 -0
  295. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  296. package/src/dev/development-restart-watch-paths.js +44 -0
  297. package/src/dev/development-restart.d.ts +25 -0
  298. package/src/dev/development-restart.js +45 -0
  299. package/src/dev/invalidation/README.md +11 -0
  300. package/src/dev/invalidation/development-invalidation.service.d.ts +153 -0
  301. package/src/dev/invalidation/development-invalidation.service.js +338 -0
  302. package/src/dev/runtime-server-started-message.d.ts +10 -0
  303. package/src/dev/runtime-server-started-message.js +14 -0
  304. package/src/dev/transform-server/dev-transform-bundler.d.ts +26 -0
  305. package/src/dev/transform-server/dev-transform-bundler.js +77 -0
  306. package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +12 -0
  307. package/src/dev/transform-server/dev-transform-externalize-plugin.js +29 -0
  308. package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +17 -0
  309. package/src/dev/transform-server/dev-transform-import-rewriter.js +128 -0
  310. package/src/dev/transform-server/dev-transform-module-kind.d.ts +13 -0
  311. package/src/dev/transform-server/dev-transform-module-kind.js +17 -0
  312. package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +5 -0
  313. package/src/dev/transform-server/dev-transform-runtime-specifiers.js +16 -0
  314. package/src/dev/transform-server/dev-transform-server.d.ts +61 -0
  315. package/src/dev/transform-server/dev-transform-server.js +234 -0
  316. package/src/dev/transform-server/dev-transform-url.d.ts +18 -0
  317. package/src/dev/transform-server/dev-transform-url.js +88 -0
  318. package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +28 -0
  319. package/src/dev/transform-server/dev-transform-vendor-registry.js +148 -0
  320. package/src/dev/transform-server/index.d.ts +6 -0
  321. package/src/dev/transform-server/index.js +4 -0
  322. package/src/dev/transform-server/types.d.ts +1 -0
  323. package/src/dev/transform-server/types.js +1 -0
  324. package/src/dev-toolbar/README.md +66 -0
  325. package/src/dev-toolbar/build-error-contract.d.ts +12 -0
  326. package/src/dev-toolbar/build-error-contract.js +3 -0
  327. package/src/dev-toolbar/define-dev-tool.d.ts +21 -0
  328. package/src/dev-toolbar/define-dev-tool.js +9 -0
  329. package/src/dev-toolbar/dev-toolbar-config.d.ts +24 -0
  330. package/src/dev-toolbar/dev-toolbar-config.js +17 -0
  331. package/src/dev-toolbar/dev-toolbar-manifest-contract.d.ts +22 -0
  332. package/src/dev-toolbar/dev-toolbar-manifest-contract.js +2 -0
  333. package/src/dev-toolbar/dev-toolbar-manifest.d.ts +27 -0
  334. package/src/dev-toolbar/dev-toolbar-manifest.js +65 -0
  335. package/src/dev-toolbar/dev-toolbar-package.d.ts +34 -0
  336. package/src/dev-toolbar/dev-toolbar-package.js +78 -0
  337. package/src/dev-toolbar/dev-toolbar-runtime-paths.d.ts +8 -0
  338. package/src/dev-toolbar/dev-toolbar-runtime-paths.js +11 -0
  339. package/src/dev-toolbar/dev-toolbar-runtime.d.ts +10 -0
  340. package/src/dev-toolbar/dev-toolbar-runtime.js +26 -0
  341. package/src/diagnostics/README.md +11 -0
  342. package/src/diagnostics/request-pipeline-metrics.d.ts +48 -0
  343. package/src/diagnostics/request-pipeline-metrics.js +113 -0
  344. package/src/diagnostics/startup-trace.d.ts +71 -0
  345. package/src/diagnostics/startup-trace.js +247 -0
  346. package/src/eco/README.md +108 -22
  347. package/src/eco/component-identity.d.ts +17 -0
  348. package/src/eco/component-identity.js +25 -0
  349. package/src/eco/component-internal-state.d.ts +5 -0
  350. package/src/eco/component-internal-state.js +17 -0
  351. package/src/eco/component-render-context.d.ts +60 -0
  352. package/src/eco/component-render-context.js +140 -0
  353. package/src/{route-renderer/orchestration/render-output.utils.d.ts → eco/component-render-output.d.ts} +7 -19
  354. package/src/eco/component-render-output.js +123 -0
  355. package/src/eco/discovered-dependencies.d.ts +45 -0
  356. package/src/eco/discovered-dependencies.js +87 -0
  357. package/src/eco/eco-declared-component.d.ts +15 -0
  358. package/src/eco/eco-declared-component.js +23 -0
  359. package/src/eco/eco.browser.d.ts +1 -1
  360. package/src/eco/eco.browser.js +63 -70
  361. package/src/eco/eco.d.ts +1 -1
  362. package/src/eco/eco.js +169 -97
  363. package/src/eco/global-injector-map.d.ts +1 -1
  364. package/src/eco/global-injector-map.js +55 -41
  365. package/src/eco/module-dependencies.js +52 -44
  366. package/src/eco/page-dependency-contributions.d.ts +19 -0
  367. package/src/eco/page-dependency-contributions.js +52 -0
  368. package/src/eco/page-layout-normalization.d.ts +21 -0
  369. package/src/eco/page-layout-normalization.js +69 -0
  370. package/src/env.d.ts +31 -7
  371. package/src/env.js +38 -0
  372. package/src/errors/README.md +5 -0
  373. package/src/errors/http-error-page-contract.d.ts +77 -0
  374. package/src/errors/http-error-page-contract.js +106 -0
  375. package/src/errors/http-error.d.ts +8 -0
  376. package/src/errors/http-error.js +66 -49
  377. package/src/errors/index.d.ts +1 -0
  378. package/src/errors/index.js +3 -6
  379. package/src/errors/locals-access-error.js +5 -8
  380. package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
  381. package/src/errors/undeclared-component-dependency-error.js +17 -0
  382. package/src/global/README.md +5 -0
  383. package/src/global/app-logger.js +4 -6
  384. package/src/hmr/README.md +38 -0
  385. package/src/hmr/client/build-error-overlay.d.ts +17 -0
  386. package/src/hmr/client/build-error-overlay.js +79 -0
  387. package/src/hmr/client/build-error-overlay.test.browser.d.ts +1 -0
  388. package/src/hmr/client/build-error-overlay.test.browser.js +48 -0
  389. package/src/hmr/client/build-error-presentation.d.ts +2 -0
  390. package/src/hmr/client/build-error-presentation.js +30 -0
  391. package/src/hmr/client/hmr-runtime.js +122 -109
  392. package/src/hmr/client/hmr-runtime.test.browser.d.ts +1 -0
  393. package/src/hmr/client/hmr-runtime.test.browser.js +32 -0
  394. package/src/hmr/client/module-update.d.ts +13 -0
  395. package/src/hmr/client/module-update.js +39 -0
  396. package/src/hmr/dev-client-runtime.d.ts +39 -0
  397. package/src/hmr/dev-client-runtime.js +78 -0
  398. package/src/hmr/entrypoint-dependency-graph.d.ts +12 -0
  399. package/src/hmr/entrypoint-dependency-graph.js +27 -0
  400. package/src/hmr/hmr-asset-paths.d.ts +14 -0
  401. package/src/hmr/hmr-asset-paths.js +22 -0
  402. package/src/hmr/hmr-entrypoint-output.d.ts +11 -0
  403. package/src/hmr/hmr-entrypoint-output.js +34 -0
  404. package/src/hmr/hmr-file-change-prep.d.ts +9 -0
  405. package/src/hmr/hmr-file-change-prep.js +11 -0
  406. package/src/hmr/hmr-registered-entrypoints-context.d.ts +7 -0
  407. package/src/hmr/hmr-registered-entrypoints-context.js +1 -0
  408. package/src/hmr/hmr-runtime-paths.d.ts +10 -0
  409. package/src/hmr/hmr-runtime-paths.js +13 -0
  410. package/src/hmr/hmr-strategy.d.ts +18 -22
  411. package/src/hmr/hmr-strategy.js +111 -42
  412. package/src/hmr/strategies/default-hmr-strategy.js +55 -33
  413. package/src/hmr/strategies/js-hmr-strategy.d.ts +16 -97
  414. package/src/hmr/strategies/js-hmr-strategy.js +113 -165
  415. package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
  416. package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +35 -0
  417. package/src/html/README.md +15 -0
  418. package/src/html/html-rewriter.d.ts +77 -0
  419. package/src/html/html-rewriter.js +590 -0
  420. package/src/html/html-source-parser.d.ts +59 -0
  421. package/src/html/html-source-parser.js +203 -0
  422. package/src/html/html-tokenizer.d.ts +69 -0
  423. package/src/html/html-tokenizer.js +193 -0
  424. package/src/html/html-transformer.service.d.ts +74 -0
  425. package/src/html/html-transformer.service.js +173 -0
  426. package/src/html-pages/README.md +104 -0
  427. package/src/html-pages/html-page-classic-script.d.ts +15 -0
  428. package/src/html-pages/html-page-classic-script.js +25 -0
  429. package/src/html-pages/html-page-document.d.ts +33 -0
  430. package/src/html-pages/html-page-document.js +100 -0
  431. package/src/html-pages/html-page-module-scripts.d.ts +86 -0
  432. package/src/html-pages/html-page-module-scripts.js +293 -0
  433. package/src/html-pages/html-page-module.d.ts +32 -0
  434. package/src/html-pages/html-page-module.js +113 -0
  435. package/src/html-pages/html-page-renderer.d.ts +69 -0
  436. package/src/html-pages/html-page-renderer.js +287 -0
  437. package/src/html-pages/html-page-template.d.ts +128 -0
  438. package/src/html-pages/html-page-template.js +495 -0
  439. package/src/html-pages/html-page-warning-state.d.ts +8 -0
  440. package/src/html-pages/html-page-warning-state.js +6 -0
  441. package/src/html-pages/html-pages.plugin.d.ts +23 -0
  442. package/src/html-pages/html-pages.plugin.js +32 -0
  443. package/src/index.browser.d.ts +4 -1
  444. package/src/index.browser.js +5 -4
  445. package/src/index.d.ts +8 -4
  446. package/src/index.js +9 -21
  447. package/src/integration.d.ts +25 -0
  448. package/src/integration.js +23 -0
  449. package/src/islands/README.md +44 -0
  450. package/src/islands/island-host.d.ts +43 -0
  451. package/src/islands/island-host.js +65 -0
  452. package/src/page-cache/README.md +17 -0
  453. package/src/page-cache/cache.types.d.ts +1 -0
  454. package/src/page-cache/cache.types.js +1 -0
  455. package/src/page-cache/html-page-cache-dependency-index.d.ts +15 -0
  456. package/src/page-cache/html-page-cache-dependency-index.js +27 -0
  457. package/src/{services/cache → page-cache}/memory-cache-store.d.ts +3 -3
  458. package/src/page-cache/memory-cache-store.js +118 -0
  459. package/src/{services/cache → page-cache}/page-cache-service.d.ts +29 -10
  460. package/src/page-cache/page-cache-service.js +374 -0
  461. package/src/{services/cache → page-cache}/page-request-cache-coordinator.service.d.ts +7 -2
  462. package/src/page-cache/page-request-cache-coordinator.service.js +139 -0
  463. package/src/plugins/README.md +29 -11
  464. package/src/plugins/alias-resolver-cache.d.ts +6 -35
  465. package/src/plugins/alias-resolver-cache.js +56 -100
  466. package/src/plugins/alias-resolver-plugin.d.ts +3 -6
  467. package/src/plugins/alias-resolver-plugin.js +34 -62
  468. package/src/plugins/component-import-discovery.d.ts +28 -0
  469. package/src/plugins/component-import-discovery.js +244 -0
  470. package/src/plugins/define-integration.d.ts +24 -0
  471. package/src/plugins/define-integration.js +20 -0
  472. package/src/plugins/eco-component-meta-plugin.d.ts +21 -93
  473. package/src/plugins/eco-component-meta-plugin.js +310 -172
  474. package/src/plugins/find-integration-for-file.d.ts +16 -0
  475. package/src/plugins/find-integration-for-file.js +34 -0
  476. package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
  477. package/src/plugins/foreign-jsx-override-plugin.js +48 -37
  478. package/src/plugins/integration-plugin.d.ts +98 -121
  479. package/src/plugins/integration-plugin.js +148 -191
  480. package/src/plugins/jsx-import-source.utils.d.ts +7 -0
  481. package/src/plugins/jsx-import-source.utils.js +15 -0
  482. package/src/plugins/package-specifier.d.ts +8 -0
  483. package/src/plugins/package-specifier.js +24 -0
  484. package/src/plugins/processor.d.ts +84 -35
  485. package/src/plugins/processor.js +159 -130
  486. package/src/plugins/tsconfig-import-resolver.d.ts +46 -0
  487. package/src/plugins/tsconfig-import-resolver.js +268 -0
  488. package/src/processor.d.ts +4 -0
  489. package/src/processor.js +3 -0
  490. package/src/route-renderer/GRAPH.md +54 -57
  491. package/src/route-renderer/README.md +81 -39
  492. package/src/route-renderer/error-pages/README.md +11 -0
  493. package/src/route-renderer/error-pages/default-error-pages.d.ts +39 -0
  494. package/src/route-renderer/error-pages/default-error-pages.js +192 -0
  495. package/src/route-renderer/error-pages/error-page-renderer.d.ts +51 -0
  496. package/src/route-renderer/error-pages/error-page-renderer.js +130 -0
  497. package/src/route-renderer/error-pages/semantic-error-page-exporter.d.ts +22 -0
  498. package/src/route-renderer/error-pages/semantic-error-page-exporter.js +33 -0
  499. package/src/{adapters/shared/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +22 -3
  500. package/src/route-renderer/explicit-view-render-preparation.js +49 -0
  501. package/src/route-renderer/orchestration/custom-element-scripts/README.md +15 -0
  502. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
  503. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +24 -0
  504. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +78 -0
  505. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +164 -0
  506. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
  507. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +34 -0
  508. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +15 -0
  509. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +65 -0
  510. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +114 -0
  511. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +161 -0
  512. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +32 -0
  513. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +52 -0
  514. package/src/route-renderer/orchestration/foreign-child/foreign-child-output.utils.d.ts +4 -0
  515. package/src/route-renderer/orchestration/foreign-child/foreign-child-output.utils.js +27 -0
  516. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +127 -0
  517. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +319 -0
  518. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +18 -0
  519. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +33 -0
  520. package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +27 -0
  521. package/src/route-renderer/orchestration/foreign-child/render-session.js +9 -0
  522. package/src/route-renderer/orchestration/integration-renderer.d.ts +280 -290
  523. package/src/route-renderer/orchestration/integration-renderer.js +1210 -987
  524. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +39 -0
  525. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +94 -0
  526. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +15 -0
  527. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +49 -0
  528. package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +70 -0
  529. package/src/route-renderer/orchestration/ownership-graph/component-graph.js +177 -0
  530. package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.d.ts +26 -0
  531. package/src/route-renderer/orchestration/ownership-graph/ownership-validation.service.js +74 -0
  532. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.d.ts +28 -0
  533. package/src/route-renderer/orchestration/ownership-graph/page-client-browser-assets.js +44 -0
  534. package/src/route-renderer/orchestration/ownership-graph/page-client-plan.d.ts +40 -0
  535. package/src/route-renderer/orchestration/ownership-graph/page-client-plan.js +175 -0
  536. package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.d.ts +7 -0
  537. package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +31 -0
  538. package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +33 -0
  539. package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +14 -0
  540. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.merge.d.ts +5 -0
  541. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.merge.js +30 -0
  542. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
  543. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +32 -0
  544. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +113 -0
  545. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +492 -0
  546. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +58 -0
  547. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +360 -0
  548. package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +26 -0
  549. package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +32 -0
  550. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +5 -0
  551. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +11 -0
  552. package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.d.ts +15 -0
  553. package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.js +43 -0
  554. package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.d.ts +26 -0
  555. package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +43 -0
  556. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.d.ts +26 -0
  557. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +44 -0
  558. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +4 -0
  559. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +30 -0
  560. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +131 -0
  561. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +350 -0
  562. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +35 -0
  563. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +69 -0
  564. package/src/route-renderer/orchestration/string-markup-renderer.d.ts +11 -0
  565. package/src/route-renderer/orchestration/string-markup-renderer.js +10 -0
  566. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +18 -5
  567. package/src/route-renderer/page-loading/component-dependency-collection.js +165 -100
  568. package/src/route-renderer/page-loading/declared-asset-collection.d.ts +2 -2
  569. package/src/route-renderer/page-loading/declared-asset-collection.js +66 -94
  570. package/src/route-renderer/page-loading/dependency-resolver.d.ts +41 -6
  571. package/src/route-renderer/page-loading/dependency-resolver.js +248 -104
  572. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +1 -0
  573. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +87 -44
  574. package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +41 -0
  575. package/src/route-renderer/page-loading/file-scoped-dependency-components.js +120 -0
  576. package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +2 -3
  577. package/src/route-renderer/page-loading/lazy-entry-collection.js +67 -98
  578. package/src/route-renderer/page-loading/lazy-trigger-planning.d.ts +1 -1
  579. package/src/route-renderer/page-loading/lazy-trigger-planning.js +47 -36
  580. package/src/route-renderer/page-loading/module-declaration-aggregation.js +39 -28
  581. package/src/route-renderer/page-loading/module-declaration-scripts.js +10 -15
  582. package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +6 -7
  583. package/src/route-renderer/page-loading/page-dependency-bundling.js +175 -112
  584. package/src/route-renderer/page-loading/page-module-loader.d.ts +9 -10
  585. package/src/route-renderer/page-loading/page-module-loader.js +136 -124
  586. package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +11 -0
  587. package/src/route-renderer/page-loading/resolved-page-dependencies.js +39 -0
  588. package/src/route-renderer/route-renderer.d.ts +15 -17
  589. package/src/route-renderer/route-renderer.js +50 -76
  590. package/src/router/README.md +73 -7
  591. package/src/router/client/link-intent.d.ts +11 -21
  592. package/src/router/client/link-intent.js +56 -30
  593. package/src/router/client/link-intent.test.browser.js +30 -40
  594. package/src/router/client/link-navigation-policy.d.ts +45 -0
  595. package/src/router/client/link-navigation-policy.js +102 -0
  596. package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
  597. package/src/router/client/link-navigation-policy.test.browser.js +142 -0
  598. package/src/router/client/navigation-commit.d.ts +22 -0
  599. package/src/router/client/navigation-commit.js +57 -0
  600. package/src/router/client/navigation-commit.test.browser.d.ts +1 -0
  601. package/src/router/client/navigation-commit.test.browser.js +116 -0
  602. package/src/router/client/navigation-coordinator.d.ts +1 -20
  603. package/src/router/client/navigation-coordinator.js +194 -204
  604. package/src/router/client/navigation-document.d.ts +37 -0
  605. package/src/router/client/navigation-document.js +106 -0
  606. package/src/router/client/navigation-document.test.browser.d.ts +1 -0
  607. package/src/router/client/navigation-document.test.browser.js +77 -0
  608. package/src/router/client/navigation-head.d.ts +13 -0
  609. package/src/router/client/navigation-head.js +238 -0
  610. package/src/router/client/navigation-head.test.browser.d.ts +1 -0
  611. package/src/router/client/navigation-head.test.browser.js +101 -0
  612. package/src/router/client/navigation-lifecycle.d.ts +49 -0
  613. package/src/router/client/navigation-lifecycle.js +50 -0
  614. package/src/router/client/navigation-lifecycle.test.browser.d.ts +1 -0
  615. package/src/router/client/navigation-lifecycle.test.browser.js +97 -0
  616. package/src/router/client/navigation-pipeline.d.ts +8 -0
  617. package/src/router/client/navigation-pipeline.js +8 -0
  618. package/src/router/client/navigation-replay.d.ts +16 -0
  619. package/src/router/client/navigation-replay.js +17 -0
  620. package/src/router/client/navigation-view-transition.d.ts +9 -0
  621. package/src/router/client/navigation-view-transition.js +61 -0
  622. package/src/router/client/navigation-view-transition.test.browser.d.ts +1 -0
  623. package/src/router/client/navigation-view-transition.test.browser.js +189 -0
  624. package/src/router/client/staged-stylesheets.test-fixtures.d.ts +18 -0
  625. package/src/router/client/staged-stylesheets.test-fixtures.js +31 -0
  626. package/src/router/server/parse-search-params.d.ts +9 -0
  627. package/src/router/server/parse-search-params.js +16 -0
  628. package/src/router/server/route-registry.d.ts +32 -7
  629. package/src/router/server/route-registry.js +220 -243
  630. package/src/router/server/segment-path-matcher.d.ts +27 -0
  631. package/src/router/server/segment-path-matcher.js +149 -0
  632. package/src/static-site-generator/README.md +41 -0
  633. package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +36 -0
  634. package/src/static-site-generator/production-page-browser-graph-prebuild.js +196 -0
  635. package/src/static-site-generator/sitemap-routes.d.ts +14 -0
  636. package/src/static-site-generator/sitemap-routes.js +36 -0
  637. package/src/static-site-generator/sitemap.d.ts +15 -0
  638. package/src/static-site-generator/sitemap.js +42 -0
  639. package/src/static-site-generator/static-export-context.d.ts +33 -0
  640. package/src/static-site-generator/static-export-context.js +1 -0
  641. package/src/static-site-generator/static-site-generator.d.ts +38 -28
  642. package/src/static-site-generator/static-site-generator.js +556 -295
  643. package/src/static-site-generator/static-site-generator.test-utils.d.ts +2 -0
  644. package/src/static-site-generator/static-site-generator.test-utils.js +41 -0
  645. package/src/types/README.md +5 -0
  646. package/src/types/api-response.d.ts +9 -0
  647. package/src/types/api-response.js +1 -0
  648. package/src/{services/assets/asset-processing-service/assets.types.d.ts → types/asset-types.d.ts} +22 -4
  649. package/src/types/asset-types.js +1 -0
  650. package/src/types/build-types.d.ts +104 -0
  651. package/src/types/build-types.js +1 -0
  652. package/src/{services/cache/cache.types.d.ts → types/cache-types.d.ts} +20 -9
  653. package/src/types/cache-types.js +5 -0
  654. package/src/types/component-identity.d.ts +6 -0
  655. package/src/types/component-identity.js +1 -0
  656. package/src/types/contracts.d.ts +1523 -0
  657. package/src/types/contracts.js +1 -0
  658. package/src/types/dev-transform-types.d.ts +15 -0
  659. package/src/types/dev-transform-types.js +1 -0
  660. package/src/{eco/eco.types.d.ts → types/eco-api-types.d.ts} +21 -38
  661. package/src/types/eco-api-types.js +5 -0
  662. package/src/types/integration-types.d.ts +3 -0
  663. package/src/types/integration-types.js +1 -0
  664. package/src/types/public-types.d.ts +3 -1307
  665. package/src/types/public-types.js +1 -0
  666. package/src/types/standard-schema-types.d.ts +12 -0
  667. package/src/types/standard-schema-types.js +1 -0
  668. package/src/utils/README.md +7 -0
  669. package/src/utils/additional-watch-paths.d.ts +25 -0
  670. package/src/utils/additional-watch-paths.js +49 -0
  671. package/src/utils/app-runtime.d.ts +9 -0
  672. package/src/utils/app-runtime.js +13 -0
  673. package/src/utils/content-hash.d.ts +8 -0
  674. package/src/utils/content-hash.js +16 -0
  675. package/src/utils/deep-merge.js +39 -26
  676. package/src/utils/ecopages-route-info.d.ts +22 -0
  677. package/src/utils/ecopages-route-info.js +20 -0
  678. package/src/utils/html-entities.d.ts +10 -0
  679. package/src/utils/html-entities.js +34 -0
  680. package/src/utils/html-escaping.d.ts +14 -0
  681. package/src/utils/html-escaping.js +42 -5
  682. package/src/utils/invariant.js +11 -10
  683. package/src/utils/locals-utils.d.ts +1 -1
  684. package/src/utils/locals-utils.js +32 -22
  685. package/src/utils/parse-cli-args.d.ts +3 -6
  686. package/src/utils/parse-cli-args.js +55 -60
  687. package/src/utils/path-containment.d.ts +15 -0
  688. package/src/utils/path-containment.js +27 -0
  689. package/src/utils/path-pattern.d.ts +23 -0
  690. package/src/utils/path-pattern.js +42 -0
  691. package/src/utils/regex-escaping.d.ts +2 -0
  692. package/src/utils/regex-escaping.js +4 -0
  693. package/src/utils/resolve-entry-file.d.ts +72 -0
  694. package/src/utils/resolve-entry-file.js +74 -0
  695. package/src/utils/resolve-work-dir.js +23 -27
  696. package/src/utils/runtime.d.ts +12 -9
  697. package/src/utils/runtime.js +14 -39
  698. package/src/utils/server-utils.module.d.ts +13 -2
  699. package/src/utils/server-utils.module.js +74 -53
  700. package/src/utils/static-file-extensions.d.ts +12 -0
  701. package/src/utils/static-file-extensions.js +54 -0
  702. package/src/validation/README.md +9 -0
  703. package/src/validation/standard-schema.types.d.ts +1 -0
  704. package/src/validation/standard-schema.types.js +1 -0
  705. package/src/validation/validate-request.d.ts +36 -0
  706. package/src/validation/validate-request.js +56 -0
  707. package/src/validation/validate-standard-schema.d.ts +7 -0
  708. package/src/validation/validate-standard-schema.js +14 -0
  709. package/src/watchers/README.md +15 -0
  710. package/src/watchers/project-watcher-ignore.d.ts +13 -0
  711. package/src/watchers/project-watcher-ignore.js +27 -0
  712. package/src/watchers/project-watcher.d.ts +80 -84
  713. package/src/watchers/project-watcher.js +489 -258
  714. package/src/watchers/project-watcher.test-helpers.d.ts +59 -3
  715. package/src/watchers/project-watcher.test-helpers.js +106 -50
  716. package/src/watchers/workspace-package-watch-roots.d.ts +9 -0
  717. package/src/watchers/workspace-package-watch-roots.js +44 -0
  718. package/src/adapters/abstract/application-adapter.d.ts +0 -194
  719. package/src/adapters/abstract/application-adapter.js +0 -121
  720. package/src/adapters/abstract/router-adapter.d.ts +0 -26
  721. package/src/adapters/abstract/router-adapter.js +0 -5
  722. package/src/adapters/abstract/server-adapter.d.ts +0 -69
  723. package/src/adapters/abstract/server-adapter.js +0 -15
  724. package/src/adapters/bun/client-bridge.d.ts +0 -34
  725. package/src/adapters/bun/client-bridge.js +0 -48
  726. package/src/adapters/bun/create-app.d.ts +0 -60
  727. package/src/adapters/bun/create-app.js +0 -140
  728. package/src/adapters/bun/hmr-manager.d.ts +0 -47
  729. package/src/adapters/bun/hmr-manager.js +0 -58
  730. package/src/adapters/bun/index.d.ts +0 -2
  731. package/src/adapters/bun/index.js +0 -8
  732. package/src/adapters/bun/runtime-host.d.ts +0 -52
  733. package/src/adapters/bun/runtime-host.js +0 -56
  734. package/src/adapters/bun/server-adapter.d.ts +0 -223
  735. package/src/adapters/bun/server-adapter.js +0 -450
  736. package/src/adapters/bun/static-preview-host.d.ts +0 -28
  737. package/src/adapters/bun/static-preview-host.js +0 -45
  738. package/src/adapters/index.d.ts +0 -2
  739. package/src/adapters/index.js +0 -8
  740. package/src/adapters/node/node-hmr-manager.d.ts +0 -52
  741. package/src/adapters/node/node-hmr-manager.js +0 -49
  742. package/src/adapters/node/server-adapter-dependencies.d.ts +0 -19
  743. package/src/adapters/node/server-adapter-dependencies.js +0 -18
  744. package/src/adapters/node/static-content-server.d.ts +0 -60
  745. package/src/adapters/node/static-content-server.js +0 -194
  746. package/src/adapters/node/static-preview-host.d.ts +0 -55
  747. package/src/adapters/node/static-preview-host.js +0 -68
  748. package/src/adapters/shared/api-response.js +0 -96
  749. package/src/adapters/shared/application-adapter.d.ts +0 -18
  750. package/src/adapters/shared/application-adapter.js +0 -90
  751. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  752. package/src/adapters/shared/define-api-handler.js +0 -15
  753. package/src/adapters/shared/explicit-static-render-preparation.js +0 -26
  754. package/src/adapters/shared/explicit-static-route-matcher.js +0 -101
  755. package/src/adapters/shared/file-route-middleware-pipeline.js +0 -90
  756. package/src/adapters/shared/fs-server-response-factory.d.ts +0 -23
  757. package/src/adapters/shared/fs-server-response-factory.js +0 -81
  758. package/src/adapters/shared/fs-server-response-matcher.js +0 -186
  759. package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +0 -55
  760. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  761. package/src/adapters/shared/hmr-html-response.d.ts +0 -22
  762. package/src/adapters/shared/hmr-html-response.js +0 -33
  763. package/src/adapters/shared/render-context.js +0 -93
  764. package/src/adapters/shared/runtime-app-bootstrap.d.ts +0 -26
  765. package/src/adapters/shared/runtime-app-bootstrap.js +0 -46
  766. package/src/adapters/shared/runtime-host.js +0 -0
  767. package/src/adapters/shared/server-adapter.d.ts +0 -108
  768. package/src/adapters/shared/server-adapter.js +0 -436
  769. package/src/adapters/shared/server-route-handler.js +0 -111
  770. package/src/adapters/shared/server-static-builder.d.ts +0 -71
  771. package/src/adapters/shared/server-static-builder.js +0 -100
  772. package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
  773. package/src/adapters/shared/shared-hmr-manager.js +0 -241
  774. package/src/adapters/shared/static-preview-host.d.ts +0 -10
  775. package/src/adapters/shared/static-preview-host.js +0 -0
  776. package/src/build/browser-runtime-manifest.js +0 -61
  777. package/src/build/browser-runtime-plugin-helpers.d.ts +0 -26
  778. package/src/build/browser-runtime-plugin-helpers.js +0 -14
  779. package/src/build/browser-runtime-plugin.d.ts +0 -78
  780. package/src/build/browser-runtime-plugin.js +0 -173
  781. package/src/build/build-manifest.d.ts +0 -33
  782. package/src/build/build-manifest.js +0 -49
  783. package/src/build/build-types.d.ts +0 -57
  784. package/src/build/build-types.js +0 -0
  785. package/src/build/rolldown-adapter-helpers.d.ts +0 -58
  786. package/src/build/rolldown-adapter-helpers.js +0 -265
  787. package/src/build/rolldown-build-adapter.d.ts +0 -28
  788. package/src/build/rolldown-build-adapter.js +0 -65
  789. package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
  790. package/src/build/rolldown-dev-build-adapter.js +0 -166
  791. package/src/build/rolldown-plugin-bridge.d.ts +0 -59
  792. package/src/build/rolldown-plugin-bridge.js +0 -199
  793. package/src/build/runtime-build-executor.d.ts +0 -21
  794. package/src/build/runtime-build-executor.js +0 -19
  795. package/src/build/runtime-build-output-normalizer.d.ts +0 -3
  796. package/src/build/runtime-build-output-normalizer.js +0 -111
  797. package/src/build/serialized-build-executor.d.ts +0 -64
  798. package/src/build/serialized-build-executor.js +0 -63
  799. package/src/build/server-side-css-shim-plugin.js +0 -35
  800. package/src/config/config-builder.d.ts +0 -266
  801. package/src/config/config-builder.js +0 -603
  802. package/src/dev/host-runtime.d.ts +0 -10
  803. package/src/dev/host-runtime.js +0 -24
  804. package/src/dev/sc-server.d.ts +0 -30
  805. package/src/dev/sc-server.js +0 -111
  806. package/src/eco/eco.types.js +0 -0
  807. package/src/eco/eco.utils.d.ts +0 -1
  808. package/src/eco/eco.utils.js +0 -10
  809. package/src/eco/lazy-injector-map.d.ts +0 -8
  810. package/src/eco/lazy-injector-map.js +0 -70
  811. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  812. package/src/hmr/hmr.test.e2e.js +0 -43
  813. package/src/integrations/ghtml/ghtml-renderer.d.ts +0 -16
  814. package/src/integrations/ghtml/ghtml-renderer.js +0 -57
  815. package/src/integrations/ghtml/ghtml.constants.d.ts +0 -1
  816. package/src/integrations/ghtml/ghtml.constants.js +0 -4
  817. package/src/integrations/ghtml/ghtml.plugin.d.ts +0 -16
  818. package/src/integrations/ghtml/ghtml.plugin.js +0 -20
  819. package/src/plugins/runtime-capability.d.ts +0 -9
  820. package/src/plugins/runtime-capability.js +0 -0
  821. package/src/plugins/source-transform.d.ts +0 -46
  822. package/src/plugins/source-transform.js +0 -71
  823. package/src/route-renderer/orchestration/component-render-context.d.ts +0 -97
  824. package/src/route-renderer/orchestration/component-render-context.js +0 -147
  825. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
  826. package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
  827. package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +0 -110
  828. package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +0 -233
  829. package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
  830. package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
  831. package/src/route-renderer/orchestration/ownership-validation.service.d.ts +0 -29
  832. package/src/route-renderer/orchestration/ownership-validation.service.js +0 -53
  833. package/src/route-renderer/orchestration/processed-asset-dedupe.js +0 -27
  834. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
  835. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
  836. package/src/route-renderer/orchestration/render-output.utils.js +0 -171
  837. package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +0 -156
  838. package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
  839. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  840. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  841. package/src/services/README.md +0 -28
  842. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +0 -3
  843. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +0 -56
  844. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +0 -103
  845. package/src/services/assets/asset-processing-service/asset-processing.service.js +0 -285
  846. package/src/services/assets/asset-processing-service/asset.factory.js +0 -82
  847. package/src/services/assets/asset-processing-service/assets.types.js +0 -0
  848. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -49
  849. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -41
  850. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +0 -30
  851. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +0 -65
  852. package/src/services/assets/asset-processing-service/index.js +0 -6
  853. package/src/services/assets/asset-processing-service/page-package.js +0 -80
  854. package/src/services/assets/asset-processing-service/processor.interface.d.ts +0 -22
  855. package/src/services/assets/asset-processing-service/processor.interface.js +0 -6
  856. package/src/services/assets/asset-processing-service/processor.registry.d.ts +0 -8
  857. package/src/services/assets/asset-processing-service/processor.registry.js +0 -15
  858. package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +0 -24
  859. package/src/services/assets/asset-processing-service/processors/base/base-processor.js +0 -65
  860. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -22
  861. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +0 -136
  862. package/src/services/assets/asset-processing-service/processors/index.js +0 -5
  863. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +0 -6
  864. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +0 -120
  865. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -9
  866. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +0 -97
  867. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +0 -126
  868. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +0 -59
  869. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +0 -69
  870. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -18
  871. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +0 -45
  872. package/src/services/assets/browser-bundle.service.d.ts +0 -73
  873. package/src/services/assets/browser-bundle.service.js +0 -41
  874. package/src/services/cache/cache.types.js +0 -0
  875. package/src/services/cache/index.d.ts +0 -7
  876. package/src/services/cache/index.js +0 -7
  877. package/src/services/cache/memory-cache-store.js +0 -98
  878. package/src/services/cache/page-cache-service.js +0 -152
  879. package/src/services/cache/page-request-cache-coordinator.service.js +0 -109
  880. package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
  881. package/src/services/html/html-rewriter-provider.service.js +0 -68
  882. package/src/services/html/html-transformer.service.d.ts +0 -96
  883. package/src/services/html/html-transformer.service.js +0 -287
  884. package/src/services/invalidation/development-invalidation.service.d.ts +0 -74
  885. package/src/services/invalidation/development-invalidation.service.js +0 -190
  886. package/src/services/module-loading/app-module-loader.service.d.ts +0 -7
  887. package/src/services/module-loading/app-module-loader.service.js +0 -0
  888. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +0 -24
  889. package/src/services/module-loading/app-server-module-transpiler.service.js +0 -130
  890. package/src/services/module-loading/host-module-loader-registry.d.ts +0 -4
  891. package/src/services/module-loading/host-module-loader-registry.js +0 -15
  892. package/src/services/module-loading/module-loading-types.d.ts +0 -2
  893. package/src/services/module-loading/module-loading-types.js +0 -0
  894. package/src/services/module-loading/page-module-import.service.js +0 -193
  895. package/src/services/module-loading/server-module-transpiler.service.d.ts +0 -63
  896. package/src/services/module-loading/server-module-transpiler.service.js +0 -64
  897. package/src/services/module-loading/source-module-support.d.ts +0 -5
  898. package/src/services/module-loading/source-module-support.js +0 -8
  899. package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
  900. package/src/services/runtime-state/dev-graph.service.js +0 -162
  901. package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +0 -41
  902. package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -85
  903. package/src/services/runtime-state/server-invalidation-state.service.d.ts +0 -26
  904. package/src/services/runtime-state/server-invalidation-state.service.js +0 -35
  905. package/src/services/validation/schema-validation-service.d.ts +0 -122
  906. package/src/services/validation/schema-validation-service.js +0 -101
  907. package/src/services/validation/standard-schema.types.d.ts +0 -65
  908. package/src/services/validation/standard-schema.types.js +0 -0
  909. package/src/types/internal-types.d.ts +0 -232
  910. package/src/types/internal-types.js +0 -0
  911. package/src/utils/hash.d.ts +0 -1
  912. package/src/utils/hash.js +0 -7
  913. package/src/utils/html.d.ts +0 -1
  914. package/src/utils/html.js +0 -4
  915. package/src/utils/path-utils.module.d.ts +0 -5
  916. package/src/utils/path-utils.module.js +0 -14
  917. /package/src/{hmr/hmr.postcss.test.e2e.d.ts → adapters/shared/runtime/runtime-host.js} +0 -0
  918. /package/src/{services/assets → assets}/asset-processing-service/asset.factory.d.ts +0 -0
  919. /package/src/{hmr/hmr.test.e2e.d.ts → assets/asset-processing-service/assets.types.js} +0 -0
  920. /package/src/{services/assets → assets}/asset-processing-service/processors/index.d.ts +0 -0
@@ -0,0 +1,173 @@
1
+ import { escapeHtmlAttribute } from '../utils/html-escaping.js';
2
+ import { HtmlRewriter, rewriteFirstElement } from './html-rewriter.js';
3
+ import { buildProcessedAssetDedupeKey, dedupeProcessedAssets } from '../assets/processed-asset-dedupe.js';
4
+ /**
5
+ * Rewrites rendered HTML with processed assets and per-render document contributions.
6
+ *
7
+ * @remarks
8
+ * Asset deduplication currently comes from the higher Build layer; #556 tracks moving this generic
9
+ * operation to a lower shared utility.
10
+ */
11
+ export class HtmlTransformerService {
12
+ formatAttributes(attrs) {
13
+ if (!attrs)
14
+ return '';
15
+ return ` ${Object.entries(attrs)
16
+ .map(([key, value]) => `${key}="${escapeHtmlAttribute(value)}"`)
17
+ .join(' ')}`;
18
+ }
19
+ generateScriptTag(dep) {
20
+ return dep.inline
21
+ ? `<script${this.formatAttributes(dep.attributes)}>${dep.content}</script>`
22
+ : `<script src="${escapeHtmlAttribute(String(dep.srcUrl))}"${this.formatAttributes(dep.attributes)}></script>`;
23
+ }
24
+ generateStylesheetTag(dep) {
25
+ return dep.inline
26
+ ? `<style${this.formatAttributes(dep.attributes)}>${dep.content}</style>`
27
+ : `<link rel="stylesheet" href="${escapeHtmlAttribute(String(dep.srcUrl))}"${this.formatAttributes(dep.attributes)}>`;
28
+ }
29
+ buildDependencyTags(dependencies) {
30
+ return dependencies
31
+ .map((dep) => dep.kind === 'script' ? this.generateScriptTag(dep) : this.generateStylesheetTag(dep))
32
+ .join('');
33
+ }
34
+ joinContributions(contributions, placement) {
35
+ return contributions
36
+ .filter((item) => item.placement === placement)
37
+ .map((item) => item.html)
38
+ .join('');
39
+ }
40
+ /**
41
+ * Sets attributes on the first `<html>` start tag.
42
+ */
43
+ applyAttributesToHtmlElement(html, attributes) {
44
+ return stampAttributes(html, attributes, (element) => element.tagName === 'html');
45
+ }
46
+ /**
47
+ * Sets attributes on the element that directly follows the `<body>` start tag.
48
+ *
49
+ * @remarks
50
+ * Nothing is stamped when text or a comment comes first (whitespace aside).
51
+ */
52
+ applyAttributesToFirstBodyElement(html, attributes) {
53
+ let insideBody = false;
54
+ return stampAttributes(html, attributes, (element) => {
55
+ if (insideBody)
56
+ return true;
57
+ insideBody = element.tagName === 'body';
58
+ return false;
59
+ }, { leadingOnly: true });
60
+ }
61
+ /**
62
+ * Removes duplicate processed assets while preserving first-seen order.
63
+ *
64
+ * @remarks
65
+ * Dedupe keys include structural asset fields and HTML attributes so repeated
66
+ * orchestration passes can merge assets safely without collapsing distinct tag
67
+ * variants.
68
+ */
69
+ dedupeProcessedAssets(assets) {
70
+ return dedupeProcessedAssets(assets);
71
+ }
72
+ /**
73
+ * Injects page assets and document contributions into a streaming HTML response.
74
+ */
75
+ transform(res, input = {}) {
76
+ return this.createRewriter(input.contributions ?? [], input.pagePackage).transform(res);
77
+ }
78
+ /**
79
+ * Injects page assets and document contributions into a complete HTML string.
80
+ */
81
+ injectPageAssets(html, input = {}) {
82
+ return this.createRewriter(input.contributions ?? [], input.pagePackage).transform(html);
83
+ }
84
+ /**
85
+ * @remarks
86
+ * Each slot is inserted as one joined string, so contributions and assets keep
87
+ * their array order even though repeated `prepend` calls insert in reverse.
88
+ * Documents without a `<head>` or `<body>` element, or whose element never
89
+ * closes, skip the matching head or body injections (lol-html semantics).
90
+ */
91
+ createRewriter(contributions, pagePackage) {
92
+ const { head, body } = this.groupDependenciesByPosition(pagePackage);
93
+ const slots = {
94
+ head: {
95
+ prepend: this.joinContributions(contributions, 'head-prepend'),
96
+ append: `${this.buildDependencyTags(head)}${this.joinContributions(contributions, 'head-append')}`,
97
+ },
98
+ body: {
99
+ prepend: this.joinContributions(contributions, 'body-prepend'),
100
+ append: `${this.buildDependencyTags(body)}${this.joinContributions(contributions, 'body-append')}`,
101
+ },
102
+ };
103
+ const rewriter = new HtmlRewriter();
104
+ for (const [tagName, slot] of Object.entries(slots)) {
105
+ if (!slot.prepend && !slot.append)
106
+ continue;
107
+ rewriter.on(tagName, {
108
+ element(element) {
109
+ if (slot.prepend)
110
+ element.prepend(slot.prepend, { html: true });
111
+ if (slot.append)
112
+ element.append(slot.append, { html: true });
113
+ },
114
+ });
115
+ }
116
+ return rewriter;
117
+ }
118
+ /**
119
+ * Splits processed assets into head and body injection groups.
120
+ */
121
+ groupDependenciesByPosition(pagePackage) {
122
+ const dependencies = pagePackage ? this.resolvePagePackageHtmlDependencies(pagePackage) : [];
123
+ return dependencies.reduce((acc, dep) => {
124
+ if (dep.kind === 'script') {
125
+ if (dep.excludeFromHtml)
126
+ return acc;
127
+ const position = dep.position || 'body';
128
+ acc[position].push(dep);
129
+ }
130
+ else if (dep.kind === 'stylesheet') {
131
+ acc.head.push(dep);
132
+ }
133
+ return acc;
134
+ }, { head: [], body: [] });
135
+ }
136
+ resolvePagePackageHtmlDependencies(pagePackage) {
137
+ if (!pagePackage.pageBrowserGraph) {
138
+ return pagePackage.htmlAssets;
139
+ }
140
+ const chunkKeys = new Set(pagePackage.pageBrowserGraph.chunkAssets.map((asset) => buildProcessedAssetDedupeKey(asset)));
141
+ const graphKeys = new Set([...pagePackage.pageBrowserGraph.entryAssets, ...pagePackage.pageBrowserGraph.chunkAssets].map((asset) => buildProcessedAssetDedupeKey(asset)));
142
+ const nonGraphHtmlAssets = pagePackage.htmlAssets.filter((asset) => !graphKeys.has(buildProcessedAssetDedupeKey(asset)));
143
+ const entryHtmlAssets = pagePackage.pageBrowserGraph.entryAssets.filter((asset) => !chunkKeys.has(buildProcessedAssetDedupeKey(asset)));
144
+ return dedupeProcessedAssets([...nonGraphHtmlAssets, ...entryHtmlAssets]);
145
+ }
146
+ }
147
+ /**
148
+ * Sets attributes on the element a fragment or document starts with.
149
+ *
150
+ * @remarks
151
+ * Nothing is stamped when text or a comment comes first (whitespace aside),
152
+ * so a Lit render that opens with `<!--lit-part-->` keeps its markup.
153
+ */
154
+ export function applyAttributesToFirstElement(html, attributes) {
155
+ return stampAttributes(html, attributes, () => true, { leadingOnly: true });
156
+ }
157
+ /**
158
+ * Sets `attributes` on the first element that `isTarget` accepts.
159
+ *
160
+ * @remarks
161
+ * Entries with an empty name are skipped. An empty value is kept and rendered as
162
+ * `name=""`, so presence markers such as `data-eco-island` survive. An attribute
163
+ * the element already has is replaced rather than duplicated.
164
+ */
165
+ function stampAttributes(html, attributes, isTarget, options) {
166
+ const entries = Object.entries(attributes).filter(([name]) => name.length > 0);
167
+ if (entries.length === 0)
168
+ return html;
169
+ return rewriteFirstElement(html, isTarget, (element) => {
170
+ for (const [name, value] of entries)
171
+ element.setAttribute(name, value);
172
+ }, options);
173
+ }
@@ -0,0 +1,104 @@
1
+ # HTML Pages
2
+
3
+ **Layer:** Rendering.
4
+
5
+ This directory owns `.html` Filesystem Routes: plain HTML files under `src/pages/` rendered inside the application's Html shell with the app's default Cache Strategy. HTML Pages need no package, plugin call, or config field.
6
+
7
+ ## Ownership
8
+
9
+ `finalizeEcoPagesConfig()` appends the internal `html-pages` Integration after user Integrations, unless a user Integration already declares `.html`. Appending last keeps the first-extension fallback for missing semantic templates unchanged for existing apps. There is no public plugin factory.
10
+
11
+ | File | Role |
12
+ | ----------------------------- | --------------------------------------------------------------------------------------------------------------------- |
13
+ | `html-pages.plugin.ts` | `HtmlPagesPlugin`: owns `.html` with `HtmlPageRenderer`, implements `compilePageModule`, sets `acceptsParams = false` |
14
+ | `html-page-template.ts` | Compiles a Page or Html shell file into template parts, asset declarations, head nodes, metadata, and social tags |
15
+ | `html-page-module.ts` | Builds the Page or shell module in-process and owns the built-in shell |
16
+ | `html-page-renderer.ts` | `StringMarkupRenderer` subclass: emits assets in place, uses the shared shell render, reconciles the head |
17
+ | `html-page-document.ts` | Reconciles Page head tags and `<html>`/`<body>` attributes onto the finalized document |
18
+ | `html-page-module-scripts.ts` | Collects every HTML Page's and the shell's module scripts, then maps each script to its URL |
19
+ | `html-page-classic-script.ts` | Validates a classic `<script src>` and marks it `classic`: module-only code, JSX and compile helpers are rejected |
20
+
21
+ Parsing uses `html/html-source-parser.ts`, a positional parser built on the same tokenizer as `HtmlRewriter` (`html/html-tokenizer.ts`).
22
+
23
+ ## Module loading
24
+
25
+ Core never checks for HTML Pages by name. It finds a file's owning Integration with `findIntegrationForFile()` (the longest registered extension) and asks it:
26
+
27
+ - `PageModuleImportService.loadModule()` calls the owner's `compilePageModule()` before bundling. `HtmlPagesPlugin.compilePageModule()` compiles files under the pages directory and `src/includes/html.html` with `loadHtmlPageModule()`, and throws for any other `.html` file; an Integration that implements the hook compiles every file core loads for it. Bun and Node load HTML Pages the same way, and the import cache still keys modules by file hash.
28
+ - `isPagesUnifiedGraphPage()` leaves out Pages whose owner implements `compilePageModule`, so HTML Pages stay out of the production unified graph.
29
+ - Route discovery rejects `[param]` filenames whose owner sets `acceptsParams` to `false`, because HTML Pages have no `staticPaths`.
30
+
31
+ Each component carries its compiled template on an interned symbol, read with `getCompiledHtmlTemplate()`. Calling the component directly throws, because rendering needs the owning renderer's asset pipeline. A Page component also exposes `metadata`, built from its head tags and merged over `defaultMetadata`, so static export and the Sitemap read it like an `eco.page()` Page.
32
+
33
+ The Page and `html.html` components register their local asset files as discovered watch files on their identity. `collectRenderShellSourcePaths()` adds identity watch files to rendered HTML cache dependencies, so editing a referenced stylesheet or script invalidates every route the Page or shell renders into, including routes owned by other Integrations that use `html.html`.
34
+
35
+ ## Compilation
36
+
37
+ A Page is read into three parts:
38
+
39
+ - **Head nodes**: children of the Page `<head>`. Without one, the leading `<title>`, `<meta>`, `<link>`, `<style>`, `<script>`, `<base>` and `<template>` elements form the head, as the HTML parsing rules do: the doctype, whitespace and comments are skipped, and the first other element, `<noscript>` or text ends it. Head nodes have a singleton key for `<title>`, `<base>`, `<meta charset>`, keyed `<meta>` (by the value of the first of `name`, `property` and `http-equiv` it has, so `property="twitter:title"` and `name="twitter:title"` are the same tag), and `<link rel="canonical">`. A second `<head>` is an error. When the Page has a `<title>` or a description `<meta>`, the compiler appends `og:title`, `og:description`, `twitter:title`, and `twitter:description` from them, unless the Page writes that tag itself. Other social tags, such as `og:image`, `og:type`, and `twitter:card`, are never derived.
40
+ - **Body markup**: everything outside the head (the `<head>` element or the leading head elements), with the doctype and the `<html>` and `<body>` start and end tags removed.
41
+ - **Root attributes**: the attributes of the Page `<html>` and `<body>` elements.
42
+
43
+ An Html shell must contain `<html>` with `<head>` and `<body>` and exactly one `<!-- eco:children -->` comment, which becomes the children slot. Its doctype is dropped because the renderer always emits one.
44
+
45
+ Processed asset tags become slots:
46
+
47
+ | Tag | Processing |
48
+ | ---------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
49
+ | `<link rel="stylesheet">` with a relative `href` | `FileStylesheetProcessor`; production names the file from a hash of the processed CSS |
50
+ | `<style>` with no `type`, or `type="text/css"` | `ContentStylesheetProcessor` inline; `processingOrigin` is `<file>.css`; a `</style` in the output is escaped as `<\/style` |
51
+ | `<script type="module">` with a relative `src` | Static production export includes every HTML Page's and shell module script in the app-wide browser build; `ecopages start` restores those URLs from the build manifest after checking the recorded browser sources and outputs; otherwise without HMR, one shared multi-entry build (`html-page-module-scripts.ts`); with HMR, `FileScriptProcessor` and the HMR manager; a side-effect `.css` import is an error (see Rendering) |
52
+ | classic `<script>` with a relative `src` | `FileScriptProcessor` with `classic: true`: compiled on its own in script mode, ignoring `tsconfig.json`, and minified in production without renaming top-level names or dropping legal comments; never bundled, outside the HMR pipeline (in development, editing one reloads the page, except under `src/includes/` or `src/views/`, where edits refresh the page in place), and emitted under the source path and name (`.ts` becomes `.js`), without a content hash. JSX files, module syntax, relative `import()`, top-level `await` and code that needs a compile helper (such as a decorator) are errors |
53
+ | `<link rel="preload">` or `rel="modulepreload"` with a relative `href` | Not processed itself: at render it takes the URL of the asset with the same file and the kind it preloads (`modulepreload` a module script, `as="style"` a stylesheet, `as="script"` a classic script) in the Page or the shell (the shared build's URL, or the HMR URL); with none, it stays as written and a development warning names it |
54
+
55
+ With [`@ecopages/browser-router`](../../../browser-router/README.md#scripts-on-navigation), a classic script in the Page body runs again on every navigation that renders it, so its top-level `const`, `let` and `class` declarations would be declared twice and throw. Such scripts should use `var` or functions, or wrap the code in a block or an IIFE; a module script runs once per URL.
56
+
57
+ `processingOrigin` sits beside the HTML file and ends in `.css` because processors resolve relative imports against it and filter by extension.
58
+
59
+ Relative paths, with or without `./`, resolve against the containing file and must stay inside the source directory, except a preload `href`, which then matches no processed file; query strings and fragments are ignored for the lookup. A processed tag with `integrity` is an error, and so is a preload hint with `integrity` that matches a processed file; an unmatched one stays as written with the usual warning. Tags with external or root-relative URLs, inline scripts, and scripts with a non-JavaScript `type` stay literal.
60
+
61
+ An inline `<script type="module">` that imports a relative specifier (`./` or `../`), statically, by re-export, or by a dynamic `import()` of a string literal, is a compile error naming the file and asking to move the code to a file. It is not sent through the inline content-script path (`AssetFactory.createInlineContentScript()`): that path builds each script alone from an entry file in the work directory, so a relative import would resolve against the wrong directory, and a module the script shares with the Page's module scripts would be a second copy that runs again, the duplication the shared build exists to avoid. Bare and root-relative imports, and non-literal dynamic imports, stay literal.
62
+
63
+ In development, a relative URL left literal logs a warning once per file revision: `src`, `srcset`, `imagesrcset`, `href` (except on `<a>`, `<area>`, `<base>`, and preload links), `xlink:href` (except on `<a>`, `<area>`, and `<base>`), `poster`, `<object data>`, and `url()` or an `image-set()` string in a `style` attribute, outside comments. The `content` of `og:image`, `og:image:url`, `og:image:secure_url`, `twitter:image`, and `twitter:image:src` warns unless it is an absolute URL, because link preview crawlers need one.
64
+
65
+ Two warnings depend on rendering and are logged by the renderer through `warnHtmlTemplateRender()`, once per URL or preload `href` and revision of the file, building the message only when it logs: a relative URL that processed `<style>` output still holds, and a preload hint that matches no processed file. The preload warning names the fix: the right `rel` or `as` when the file is processed as another kind; for a preload of a stylesheet or script, the other HTML files that load the file (found with `findHtmlFilesLoading()`, which compiles every HTML file, so it runs only in development and at most once per file revision), asking a Page to load the file too and a shell to move the preload to those Pages; otherwise a move to the public directory. Within one `emitAssets()` call, a preload and its target share one URL lookup, so the file is processed once.
66
+
67
+ Compile-time warning hashes and render-time warning keys live on the owning `AppRuntime`. Each app warns once per file revision; two apps loading the same HTML file keep their warning history separate.
68
+
69
+ ## Rendering
70
+
71
+ `HtmlPageRenderer.renderHtmlPage()` processes the Page's asset declarations and splices each emitted URL (or processed CSS) into the tag as written, so every other attribute is preserved. A missing local file, or an asset the pipeline cannot process, throws an error naming the HTML file. A local file declared by both the shell and the Page is emitted once, by the shell; within a file, the first declaration wins. The body markup then renders through the shared document-shell composition, so an `html.html`, built-in, JSX, or React shell wraps it the same way. When the rendered shell has no `<body>` (JSX shells that leave it to Layouts), the Page markup is wrapped in one.
72
+
73
+ Without HMR, module scripts are not processed one by one. The shared build includes every module script of every HTML Page and the `html.html` shell with code splitting, so a module several scripts import, on one Page or across Pages, is one chunk with one URL, and a script has the same URL on every Page; the browser runs each once, also across browser-router navigations. Static production export places those scripts in the app-wide browser build, where they share a build group with Page Browser Graph entries from other Integrations only when their bundle options are compatible. `ecopages start` restores the HTML module-script URLs from the build manifest after checking that the HTML files and all source files recorded by the browser build still match the export. Outside that export, production builds once; development reuses the build while the HTML files, scripts, and local modules visited by the stylesheet scan keep the same contents; an edit inside a package is not detected. An HTML file that does not compile is left out of the build, so only its own render fails; a script that does not build fails the build, and so every HTML Page with a module script, until the next render builds again.
74
+
75
+ A module script cannot add a stylesheet to the Page: the PostCSS Processor turns a CSS file into a module exporting the CSS string, and without a CSS Processor the bundler rejects it. So `scanModuleScript()` scans a module script and the local modules it imports, statically or dynamically, for a side-effect stylesheet import: an import or re-export that binds nothing (`import './styles.css'`, `export * from './styles.css'`) of a file ending in `.css`, local or in a package (`import 'swiper/css'`). The shared build leaves such a script out, and rendering an HTML file that loads it, with or without HMR, throws an error naming the HTML file, the stylesheet, and the importing module when it is not the script itself, with paths relative to the app root. For a stylesheet under `src` it suggests `<link rel="stylesheet" href="…">` in the HTML file; for one outside `src`, as in a package, it says to copy the file under `src` and link it. Other HTML Pages still render. The scan does not follow type-only imports or scan packages, and skips the stylesheet imports the component meta transform moves into Component Dependencies. `import styles from './styles.css'`, which binds the CSS string, is allowed; without a CSS Processor it still fails the whole build. With HMR, the scan result is reused while the files it visited keep their size and modification time.
76
+
77
+ When no `src/includes/html.*` exists, `HtmlPageRenderer.getHtmlTemplate()` returns the built-in shell (`lang="en"`, charset, viewport, children slot). Pages owned by other Integrations keep the existing missing-template error. A Page owned by another Integration whose shell is `html.html` delegates the shell to this renderer through the foreign-child path; `renderComponent()` renders it with its assets emitted in place.
78
+
79
+ ## Head reconciliation
80
+
81
+ The renderer retains the Page head for the active render and its `finalizeDocument` hook reconciles it after Integration and core head contributions are in the document. A direct `HtmlPageRenderer.render()` call, outside a route render, reconciles the HTML it returns the same way:
82
+
83
+ - A Page singleton, including a derived social tag, replaces the shell tag with the same key, in place; repeated keys, such as a light and a dark `theme-color`, match in source order, and a Page copy with no shell match is appended. This includes the core robots tag built from `metadata.robots`.
84
+ - A Page `<meta charset>` matching the shell is dropped; a different encoding is an error naming the Page. A Page charset or `<base>` without a shell copy is inserted at the start of `<head>`.
85
+ - Every other Page head node is inserted before `</head>` in source order.
86
+ - Page `<html>` and `<body>` attributes replace shell values, except `class`, whose tokens are joined.
87
+
88
+ Reconciliation runs only for HTML Pages; other routes keep their head output.
89
+
90
+ ## Discovery rules
91
+
92
+ `RouteRegistry` rejects a dynamic `.html` filename (no `staticPaths` source). It also rejects any two Page files that produce the same Template Route, for every Integration, such as `about.html` with `about.tsx` or `about/index.html`.
93
+
94
+ ## Tests
95
+
96
+ - `html-page-template.test.ts`: extraction, metadata, social tags, asset classification, preload hints, relative-URL and social image warnings, CSS URL extraction, inline module scripts with relative imports, compile errors
97
+ - `html-page-document.test.ts`: head reconciliation and root attribute merging
98
+ - `html-page-module.test.ts`: which `.html` files core loads, warnings once per file revision, inline module script import errors, metadata merge, shell compile errors
99
+ - `html-pages.plugin.test.ts`: which files `compilePageModule()` compiles or rejects
100
+ - `html-page-renderer.test.ts`: built-in shell, JSX shells without `<body>`, delegated shells, asset dedupe, preload hints (Page and shell stylesheets, shared-build and HMR module script URLs, kind mismatches, `integrity`, unmatched warnings for a Page and the shell), relative `url()` in processed `<style>`, warned again after an edit, missing assets, head on a direct `render()`, the shared module-script build (one chunk per shared module, stable URLs, no other Page's code, rebuild after an edit, a fix, or a new script, a broken Page left out, entries that differ only by extension)
101
+ - `html-page-classic-script.test.ts`: the classic script rule, including a real build of a TypeScript classic script run as a classic script
102
+ - `html/html-source-parser.test.ts`: source offsets, raw text, implicit head close
103
+ - `router/server/route-registry.test.ts`: duplicate routes and dynamic `.html` filenames
104
+ - `e2e/fixtures/html-pages`: static export, Sitemap, `404.html`, browser-router navigation, and a custom element shared by several Pages' scripts defined once
@@ -0,0 +1,15 @@
1
+ import type { ScriptAsset } from '../assets/asset-processing-service/assets.types.js';
2
+ /**
3
+ * Picks how a local `<script src>` without `type="module"` is emitted, and rejects a file that
4
+ * cannot be one.
5
+ *
6
+ * @remarks
7
+ * Classic scripts keep classic semantics, as Parcel does: the browser runs them where they
8
+ * are written, and their top-level functions and variables are globals other scripts use.
9
+ * Each file is compiled on its own as a script (see `compileClassicScript`). Compiling here as
10
+ * well as in the asset pipeline lets the error name the HTML file.
11
+ *
12
+ * @throws When the file cannot be a classic script. The message names the HTML file, and asks
13
+ * for `type="module"` when that would make it work.
14
+ */
15
+ export declare function resolveClassicScriptOptions(file: string, reference: string, filepath: string): Pick<ScriptAsset, 'classic'>;
@@ -0,0 +1,25 @@
1
+ import { fileSystem } from '@ecopages/file-system';
2
+ import { compileClassicScript } from '../assets/asset-processing-service/processors/script/classic-script-compiler.js';
3
+ /**
4
+ * Picks how a local `<script src>` without `type="module"` is emitted, and rejects a file that
5
+ * cannot be one.
6
+ *
7
+ * @remarks
8
+ * Classic scripts keep classic semantics, as Parcel does: the browser runs them where they
9
+ * are written, and their top-level functions and variables are globals other scripts use.
10
+ * Each file is compiled on its own as a script (see `compileClassicScript`). Compiling here as
11
+ * well as in the asset pipeline lets the error name the HTML file.
12
+ *
13
+ * @throws When the file cannot be a classic script. The message names the HTML file, and asks
14
+ * for `type="module"` when that would make it work.
15
+ */
16
+ export function resolveClassicScriptOptions(file, reference, filepath) {
17
+ const compiled = compileClassicScript(filepath, fileSystem.readFileSync(filepath).toString(), { minify: false });
18
+ if ('problem' in compiled) {
19
+ const { reason, needsModule } = compiled.problem;
20
+ throw new Error(needsModule
21
+ ? `[ecopages] ${file}: "${reference}" ${reason}, which a classic script cannot. Add type="module" to its <script> tag.`
22
+ : `[ecopages] ${file}: "${reference}" ${reason}`);
23
+ }
24
+ return { classic: true };
25
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The parts of a rendered HTML Page that land outside the shell's children slot.
3
+ */
4
+ export type RenderedHtmlPageHead = {
5
+ file: string;
6
+ /** Rendered Page head nodes in source order; deduplicated assets render as `''`. */
7
+ nodes: Array<{
8
+ html: string;
9
+ key?: string;
10
+ charset?: string;
11
+ }>;
12
+ /** Values as written in the Page; the rewriter only escapes `"` when it re-serializes them. */
13
+ htmlAttributes: Record<string, string>;
14
+ bodyAttributes: Record<string, string>;
15
+ };
16
+ /**
17
+ * Applies a Page's head tags and root attributes to the rendered document.
18
+ *
19
+ * @remarks
20
+ * Runs on the finalized document, after Integration and core head
21
+ * contributions, so it treats an `html.html`, JSX, or React shell the same way.
22
+ * A Page singleton (`<title>`, `<base>`, a keyed `<meta>`, the canonical link)
23
+ * replaces the shell tag with the same identity in place; repeated identities,
24
+ * such as a light and a dark `theme-color`, match in source order. A Page
25
+ * `<meta charset>` matching the shell's is dropped; a Page charset or `<base>`
26
+ * the shell lacks goes at the start of `<head>`. Every other Page head node is
27
+ * inserted before `</head>` in source order. A document without `<head>` gets no
28
+ * Page head nodes. Page `<html>` and `<body>` attributes replace shell values,
29
+ * except `class`, whose tokens are joined.
30
+ *
31
+ * @throws When the Page `<meta charset>` names a different encoding than the shell.
32
+ */
33
+ export declare function reconcileHtmlPageDocument(html: string, page: RenderedHtmlPageHead): string;
@@ -0,0 +1,100 @@
1
+ import { rewriteFirstElement } from '../html/html-rewriter.js';
2
+ import { findElements, getAttribute, parseHtml } from '../html/html-source-parser.js';
3
+ import { getHeadTagKey } from './html-page-template.js';
4
+ /** Singletons that must precede the tags they affect, so a Page copy without a shell copy goes at the start of `<head>`. */
5
+ const EARLY_HEAD_KEYS = new Set(['charset', 'base']);
6
+ function applyEdits(html, edits) {
7
+ let result = html;
8
+ for (const edit of [...edits].sort((left, right) => right.start - left.start || right.end - left.end)) {
9
+ result = `${result.slice(0, edit.start)}${edit.html}${result.slice(edit.end)}`;
10
+ }
11
+ return result;
12
+ }
13
+ /** Shell head tags by identity, in source order, so repeated keys such as two `theme-color` metas match in order. */
14
+ function collectShellHeadTags(head) {
15
+ const shellTags = new Map();
16
+ for (const child of head.children) {
17
+ if (child.type !== 'element')
18
+ continue;
19
+ const key = getHeadTagKey(child);
20
+ if (!key)
21
+ continue;
22
+ const tags = shellTags.get(key) ?? [];
23
+ tags.push(child);
24
+ shellTags.set(key, tags);
25
+ }
26
+ return shellTags;
27
+ }
28
+ function assertMatchingCharset(page, pageCharset, shellTag) {
29
+ const shellCharset = getAttribute(shellTag, 'charset')?.value.trim().toLowerCase();
30
+ if (shellCharset !== pageCharset) {
31
+ throw new Error(`[ecopages] ${page.file}: <meta charset="${pageCharset}"> conflicts with the HTML template charset "${shellCharset}".`);
32
+ }
33
+ }
34
+ function reconcileHead(html, page) {
35
+ const head = findElements(parseHtml(html), (element) => element.tagName === 'head')[0];
36
+ if (!head)
37
+ return html;
38
+ const shellTags = collectShellHeadTags(head);
39
+ const edits = [];
40
+ let early = '';
41
+ let appended = '';
42
+ for (const node of page.nodes) {
43
+ if (!node.html)
44
+ continue;
45
+ const { key } = node;
46
+ const shellTag = key ? shellTags.get(key)?.shift() : undefined;
47
+ if (shellTag && key === 'charset') {
48
+ assertMatchingCharset(page, node.charset, shellTag);
49
+ }
50
+ else if (shellTag) {
51
+ edits.push({ start: shellTag.start, end: shellTag.end, html: node.html });
52
+ }
53
+ else if (key && EARLY_HEAD_KEYS.has(key)) {
54
+ early += node.html;
55
+ }
56
+ else {
57
+ appended += node.html;
58
+ }
59
+ }
60
+ if (early)
61
+ edits.push({ start: head.startTagEnd, end: head.startTagEnd, html: early });
62
+ if (appended)
63
+ edits.push({ start: head.contentEnd, end: head.contentEnd, html: appended });
64
+ return applyEdits(html, edits);
65
+ }
66
+ function mergeRootAttributes(html, tagName, attributes) {
67
+ if (Object.keys(attributes).length === 0)
68
+ return html;
69
+ return rewriteFirstElement(html, (element) => element.tagName === tagName, (element) => {
70
+ for (const [name, value] of Object.entries(attributes)) {
71
+ if (name !== 'class') {
72
+ element.setAttribute(name, value);
73
+ continue;
74
+ }
75
+ const classes = `${element.getAttribute('class') ?? ''} ${value}`.split(/\s+/).filter(Boolean);
76
+ element.setAttribute('class', [...new Set(classes)].join(' '));
77
+ }
78
+ });
79
+ }
80
+ /**
81
+ * Applies a Page's head tags and root attributes to the rendered document.
82
+ *
83
+ * @remarks
84
+ * Runs on the finalized document, after Integration and core head
85
+ * contributions, so it treats an `html.html`, JSX, or React shell the same way.
86
+ * A Page singleton (`<title>`, `<base>`, a keyed `<meta>`, the canonical link)
87
+ * replaces the shell tag with the same identity in place; repeated identities,
88
+ * such as a light and a dark `theme-color`, match in source order. A Page
89
+ * `<meta charset>` matching the shell's is dropped; a Page charset or `<base>`
90
+ * the shell lacks goes at the start of `<head>`. Every other Page head node is
91
+ * inserted before `</head>` in source order. A document without `<head>` gets no
92
+ * Page head nodes. Page `<html>` and `<body>` attributes replace shell values,
93
+ * except `class`, whose tokens are joined.
94
+ *
95
+ * @throws When the Page `<meta charset>` names a different encoding than the shell.
96
+ */
97
+ export function reconcileHtmlPageDocument(html, page) {
98
+ const reconciled = reconcileHead(html, page);
99
+ return mergeRootAttributes(mergeRootAttributes(reconciled, 'html', page.htmlAttributes), 'body', page.bodyAttributes);
100
+ }
@@ -0,0 +1,86 @@
1
+ import type { EcoPagesAppConfig } from '../config/internal-types.js';
2
+ type ModuleScriptBuild = {
3
+ fingerprint: string;
4
+ files: string[];
5
+ urls: Promise<ReadonlyMap<string, string>>;
6
+ };
7
+ export type HtmlPageModuleScriptBuildInputs = {
8
+ htmlFiles: string[];
9
+ scripts: string[];
10
+ files: string[];
11
+ fingerprint: string;
12
+ };
13
+ /**
14
+ * Per-app HTML Page module-script build and scan state owned by {@link AppRuntime}.
15
+ */
16
+ export type HtmlPageModuleScriptState = {
17
+ build: ModuleScriptBuild | null;
18
+ scans: Map<string, ModuleScriptScan>;
19
+ };
20
+ export declare function createHtmlPageModuleScriptState(): HtmlPageModuleScriptState;
21
+ /**
22
+ * Returns the URL of every `<script type="module">` of every HTML Page and the Html shell, keyed
23
+ * by the real path of the script file.
24
+ *
25
+ * @remarks
26
+ * All of them are built in one multi-entry build with code splitting, as Vite and Astro build the
27
+ * pages of a site together. A module several scripts import, on one Page, in the shell, or on
28
+ * different Pages, packages included, is then one chunk with one URL and runs once, and a script
29
+ * keeps its URL on every Page, so the browser router does not run it again after a client
30
+ * navigation. Separate builds each inline such a module, or name its chunk after their other
31
+ * entries.
32
+ *
33
+ * Production builds once. Otherwise the build is reused while the HTML files, the scripts they
34
+ * reference, and the local modules {@link scanModuleScript} visits from them keep their contents;
35
+ * an edit to a package is not detected. An HTML file that
36
+ * does not compile is left out, so only its own render fails. A script that imports a stylesheet
37
+ * is left out too, so only the HTML files that load it fail. A script that does not build fails
38
+ * the whole build, so every HTML Page with a module script fails to render; a failed build is not
39
+ * kept, so the next render builds again.
40
+ */
41
+ export declare function getHtmlPageModuleScriptUrls(appConfig: EcoPagesAppConfig): Promise<ReadonlyMap<string, string>>;
42
+ /** Collects the HTML module-script files for the production app browser build. */
43
+ export declare function collectHtmlPageModuleScriptBuildInputs(appConfig: EcoPagesAppConfig): HtmlPageModuleScriptBuildInputs;
44
+ /** Reuses URLs emitted by the app-wide production browser build. */
45
+ export declare function setPrebuiltHtmlPageModuleScriptUrls(appConfig: EcoPagesAppConfig, urls: ReadonlyMap<string, string>): void;
46
+ /** Returns the URLs installed by the app-wide browser build, if it has run. */
47
+ export declare function getPrebuiltHtmlPageModuleScriptUrls(appConfig: EcoPagesAppConfig): Promise<ReadonlyMap<string, string>>;
48
+ type StylesheetImport = {
49
+ importer: string;
50
+ stylesheet: string;
51
+ };
52
+ type ModuleScriptScan = {
53
+ files: string[];
54
+ stylesheetImport?: StylesheetImport;
55
+ fingerprint: string;
56
+ };
57
+ /**
58
+ * Finds a side-effect stylesheet import, such as `import './styles.css'`, `import 'swiper/css'`,
59
+ * or `export * from './styles.css'`, in `script` or a local module it imports, statically or
60
+ * dynamically, and lists the files it visited.
61
+ *
62
+ * @remarks
63
+ * Such an import never reaches the Page: the PostCSS Processor turns the file into a module that
64
+ * exports the CSS as a string, and without a CSS Processor the bundler rejects it. An import that
65
+ * binds that string, as `import styles from './styles.css'`, is left alone; without a CSS
66
+ * Processor it still fails the build. Type-only imports are not followed, and imports the
67
+ * component meta transform moves into Component Dependencies are not reported.
68
+ *
69
+ * Relative and tsconfig-alias imports are followed; packages are not scanned, but a side-effect
70
+ * import of a package stylesheet is reported. The result is kept while the visited files keep
71
+ * their contents. The scan stops at the first stylesheet import, so the visited
72
+ * files then include every file whose edit can remove it.
73
+ */
74
+ export declare function scanModuleScript(appConfig: EcoPagesAppConfig, script: string): {
75
+ files: string[];
76
+ stylesheetImport?: StylesheetImport;
77
+ };
78
+ /**
79
+ * Returns the HTML files, Pages and the `html.html` shell, whose stylesheet or script tags load
80
+ * `filepath`, other than `exclude`.
81
+ *
82
+ * @remarks
83
+ * Compiles every HTML file, so the renderer calls it only to word a development warning.
84
+ */
85
+ export declare function findHtmlFilesLoading(appConfig: EcoPagesAppConfig, filepath: string, exclude: string): string[];
86
+ export {};