@ecopages/core 0.2.0-beta.3 → 0.2.0-beta.31

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 (433) hide show
  1. package/README.md +38 -9
  2. package/package.json +241 -30
  3. package/src/adapters/README.md +6 -2
  4. package/src/adapters/abstract/application-adapter.d.ts +123 -6
  5. package/src/adapters/abstract/application-adapter.js +151 -1
  6. package/src/adapters/abstract/segment-path-matcher.d.ts +6 -0
  7. package/src/adapters/abstract/segment-path-matcher.js +149 -0
  8. package/src/adapters/abstract/server-adapter.d.ts +16 -2
  9. package/src/adapters/abstract/ws-pattern-matcher.d.ts +12 -0
  10. package/src/adapters/abstract/ws-pattern-matcher.js +30 -0
  11. package/src/adapters/bun/bun-user-websocket-lifecycle.d.ts +22 -0
  12. package/src/adapters/bun/bun-user-websocket-lifecycle.js +96 -0
  13. package/src/adapters/bun/client-bridge.d.ts +1 -0
  14. package/src/adapters/bun/client-bridge.js +3 -0
  15. package/src/adapters/bun/create-app.d.ts +9 -6
  16. package/src/adapters/bun/create-app.js +76 -45
  17. package/src/adapters/bun/hmr-manager.d.ts +1 -1
  18. package/src/adapters/bun/hmr-manager.js +1 -1
  19. package/src/adapters/bun/index.d.ts +1 -1
  20. package/src/adapters/bun/index.js +25 -2
  21. package/src/adapters/bun/runtime-host.d.ts +1 -1
  22. package/src/adapters/bun/runtime-host.js +1 -1
  23. package/src/adapters/bun/server-adapter.d.ts +92 -41
  24. package/src/adapters/bun/server-adapter.js +256 -117
  25. package/src/adapters/bun/static-preview-host.d.ts +1 -1
  26. package/src/adapters/bun/static-preview-host.js +25 -20
  27. package/src/adapters/create-app.d.ts +13 -11
  28. package/src/adapters/create-app.js +2 -51
  29. package/src/adapters/index.d.ts +2 -2
  30. package/src/adapters/index.js +26 -4
  31. package/src/adapters/node/create-app.d.ts +8 -3
  32. package/src/adapters/node/create-app.js +61 -13
  33. package/src/adapters/node/node-client-bridge.d.ts +1 -0
  34. package/src/adapters/node/node-client-bridge.js +3 -0
  35. package/src/adapters/node/node-hmr-manager.d.ts +1 -1
  36. package/src/adapters/node/node-hmr-manager.js +1 -1
  37. package/src/adapters/node/runtime-host.d.ts +1 -1
  38. package/src/adapters/node/runtime-host.js +1 -1
  39. package/src/adapters/node/server-adapter-dependencies.js +4 -0
  40. package/src/adapters/node/server-adapter.d.ts +64 -23
  41. package/src/adapters/node/server-adapter.js +169 -142
  42. package/src/adapters/node/static-content-server.d.ts +1 -0
  43. package/src/adapters/node/static-content-server.js +10 -2
  44. package/src/adapters/node/static-preview-host.d.ts +1 -1
  45. package/src/adapters/node/static-preview-host.js +27 -12
  46. package/src/adapters/shared/{hmr-entrypoint-registrar.d.ts → hmr/hmr-entrypoint-registrar.d.ts} +31 -30
  47. package/src/adapters/shared/hmr/hmr-entrypoint-registrar.js +106 -0
  48. package/src/adapters/shared/{hmr-html-response.d.ts → hmr/hmr-html-response.d.ts} +2 -2
  49. package/src/adapters/shared/{hmr-html-response.js → hmr/hmr-html-response.js} +4 -1
  50. package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +101 -0
  51. package/src/adapters/shared/hmr/shared-hmr-manager.js +432 -0
  52. package/src/adapters/shared/http/api-request-pipeline.d.ts +23 -0
  53. package/src/adapters/shared/http/api-request-pipeline.js +129 -0
  54. package/src/adapters/shared/{api-response.d.ts → http/api-response.d.ts} +1 -1
  55. package/src/adapters/shared/{api-response.js → http/api-response.js} +6 -23
  56. package/src/adapters/shared/http/create-body-response.d.ts +12 -0
  57. package/src/adapters/shared/http/create-body-response.js +23 -0
  58. package/src/adapters/shared/http/define-api-handler.d.ts +90 -0
  59. package/src/adapters/shared/http/define-api-handler.js +63 -0
  60. package/src/adapters/shared/{explicit-static-render-preparation.d.ts → http/explicit-static-render-preparation.d.ts} +3 -3
  61. package/src/adapters/shared/{explicit-static-route-matcher.d.ts → http/explicit-static-route-matcher.d.ts} +3 -9
  62. package/src/adapters/shared/{explicit-static-route-matcher.js → http/explicit-static-route-matcher.js} +3 -38
  63. package/src/adapters/shared/{file-route-middleware-pipeline.d.ts → http/file-route-middleware-pipeline.d.ts} +2 -2
  64. package/src/adapters/shared/{file-route-middleware-pipeline.js → http/file-route-middleware-pipeline.js} +10 -22
  65. package/src/adapters/shared/{fs-server-response-factory.d.ts → http/fs-server-response-factory.d.ts} +7 -2
  66. package/src/adapters/shared/{fs-server-response-factory.js → http/fs-server-response-factory.js} +22 -2
  67. package/src/adapters/shared/{fs-server-response-matcher.d.ts → http/fs-server-response-matcher.d.ts} +25 -5
  68. package/src/adapters/shared/{fs-server-response-matcher.js → http/fs-server-response-matcher.js} +109 -27
  69. package/src/adapters/shared/http/run-middleware-chain.d.ts +5 -0
  70. package/src/adapters/shared/http/run-middleware-chain.js +17 -0
  71. package/src/adapters/shared/{application-adapter.d.ts → runtime/application-adapter.d.ts} +2 -2
  72. package/src/adapters/shared/{application-adapter.js → runtime/application-adapter.js} +1 -1
  73. package/src/adapters/shared/runtime/copy-runtime-public-dir.d.ts +6 -0
  74. package/src/adapters/shared/runtime/copy-runtime-public-dir.js +24 -0
  75. package/src/adapters/shared/runtime/port-manager.d.ts +116 -0
  76. package/src/adapters/shared/runtime/port-manager.js +196 -0
  77. package/src/adapters/shared/{render-context.d.ts → runtime/render-context.d.ts} +2 -2
  78. package/src/adapters/shared/{render-context.js → runtime/render-context.js} +8 -17
  79. package/src/adapters/shared/{runtime-app-bootstrap.d.ts → runtime/runtime-app-bootstrap.d.ts} +4 -3
  80. package/src/adapters/shared/{runtime-app-bootstrap.js → runtime/runtime-app-bootstrap.js} +4 -7
  81. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +46 -0
  82. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +57 -0
  83. package/src/adapters/shared/{server-adapter.d.ts → runtime/server-adapter.d.ts} +23 -49
  84. package/src/adapters/shared/runtime/server-adapter.js +226 -0
  85. package/src/adapters/shared/{server-route-handler.d.ts → runtime/server-route-handler.d.ts} +6 -33
  86. package/src/adapters/shared/{server-route-handler.js → runtime/server-route-handler.js} +5 -43
  87. package/src/adapters/shared/{server-static-builder.d.ts → runtime/server-static-builder.d.ts} +27 -35
  88. package/src/adapters/shared/runtime/server-static-builder.js +191 -0
  89. package/src/adapters/shared/{static-preview-host.d.ts → runtime/static-preview-host.d.ts} +6 -1
  90. package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +21 -0
  91. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +100 -0
  92. package/src/adapters/shared/ws/websocket-lifecycle.d.ts +24 -0
  93. package/src/adapters/shared/ws/websocket-lifecycle.js +55 -0
  94. package/src/build/README.md +140 -31
  95. package/src/build/app-build-manifest-runtime.d.ts +39 -0
  96. package/src/build/app-build-manifest-runtime.js +124 -0
  97. package/src/build/{browser-runtime-plugin.d.ts → browser/browser-runtime-plugin.d.ts} +1 -1
  98. package/src/build/{browser-runtime-plugin.js → browser/browser-runtime-plugin.js} +1 -1
  99. package/src/build/browser/jsx-ownership-plugins.d.ts +24 -0
  100. package/src/build/browser/jsx-ownership-plugins.js +41 -0
  101. package/src/build/browser/lit-static-render-worker-context.d.ts +2 -0
  102. package/src/build/browser/lit-static-render-worker-context.js +6 -0
  103. package/src/build/build-adapter.d.ts +29 -334
  104. package/src/build/build-adapter.js +32 -133
  105. package/src/build/cache/build-input-fingerprint.d.ts +28 -0
  106. package/src/build/cache/build-input-fingerprint.js +31 -0
  107. package/src/build/cache/cache-constants.d.ts +4 -0
  108. package/src/build/cache/cache-constants.js +6 -0
  109. package/src/build/cache/cache-keys.d.ts +22 -0
  110. package/src/build/cache/cache-keys.js +63 -0
  111. package/src/build/cache/dev-browser-script-cache.d.ts +34 -0
  112. package/src/build/cache/dev-browser-script-cache.js +90 -0
  113. package/src/build/cache/pages-unified-graph-build.d.ts +31 -0
  114. package/src/build/cache/pages-unified-graph-build.js +198 -0
  115. package/src/build/cache/production-build-cache.d.ts +20 -0
  116. package/src/build/cache/production-build-cache.js +63 -0
  117. package/src/build/cache/server-entry-build-cache.d.ts +43 -0
  118. package/src/build/cache/server-entry-build-cache.js +165 -0
  119. package/src/build/contracts/build-contracts.d.ts +96 -0
  120. package/src/build/contracts/build-manifest.d.ts +90 -0
  121. package/src/build/{build-manifest.js → contracts/build-manifest.js} +2 -2
  122. package/src/build/contracts/build-types.js +0 -0
  123. package/src/build/{rolldown-adapter-helpers.d.ts → rolldown/rolldown-adapter-helpers.d.ts} +23 -9
  124. package/src/build/{rolldown-adapter-helpers.js → rolldown/rolldown-adapter-helpers.js} +99 -13
  125. package/src/build/{rolldown-build-adapter.d.ts → rolldown/rolldown-build-adapter.d.ts} +3 -7
  126. package/src/build/{rolldown-build-adapter.js → rolldown/rolldown-build-adapter.js} +3 -3
  127. package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +12 -0
  128. package/src/build/rolldown/rolldown-build-invocation-metrics.js +43 -0
  129. package/src/build/{rolldown-plugin-bridge.d.ts → rolldown/rolldown-plugin-bridge.d.ts} +16 -2
  130. package/src/build/{rolldown-plugin-bridge.js → rolldown/rolldown-plugin-bridge.js} +21 -6
  131. package/src/build/rolldown/rolldown-source-transform-pass.d.ts +15 -0
  132. package/src/build/rolldown/rolldown-source-transform-pass.js +61 -0
  133. package/src/build/rolldown/runtime-build-output-normalizer.d.ts +10 -0
  134. package/src/build/rolldown/runtime-build-output-normalizer.js +201 -0
  135. package/src/build/runtime/build-profile-options.d.ts +7 -0
  136. package/src/build/runtime/build-profile-options.js +37 -0
  137. package/src/build/runtime/build-request-identity.d.ts +17 -0
  138. package/src/build/runtime/build-request-identity.js +54 -0
  139. package/src/build/runtime/build-request-policy.d.ts +59 -0
  140. package/src/build/runtime/build-request-policy.js +46 -0
  141. package/src/build/runtime/build-runtime.d.ts +28 -0
  142. package/src/build/runtime/build-runtime.js +65 -0
  143. package/src/build/runtime/deduping-build-executor.d.ts +21 -0
  144. package/src/build/runtime/deduping-build-executor.js +34 -0
  145. package/src/build/runtime/parallel-build-executor.d.ts +21 -0
  146. package/src/build/runtime/parallel-build-executor.js +52 -0
  147. package/src/build/{serialized-build-executor.d.ts → runtime/serialized-build-executor.d.ts} +1 -1
  148. package/src/client/navigation-scripts/classification.d.ts +16 -0
  149. package/src/client/navigation-scripts/classification.js +41 -0
  150. package/src/client/navigation-scripts/index.d.ts +3 -0
  151. package/src/client/navigation-scripts/index.js +23 -0
  152. package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
  153. package/src/client/navigation-scripts/registry.d.ts +11 -0
  154. package/src/client/navigation-scripts/registry.js +12 -0
  155. package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
  156. package/src/client/navigation-scripts/rerun-queue.js +73 -0
  157. package/src/client/scroll.d.ts +17 -0
  158. package/src/client/scroll.js +25 -0
  159. package/src/client/scroll.test.browser.js +37 -0
  160. package/src/client/view-transitions.d.ts +16 -0
  161. package/src/client/view-transitions.js +63 -0
  162. package/src/config/config-builder.d.ts +25 -10
  163. package/src/config/config-builder.js +53 -11
  164. package/src/config/constants.d.ts +1 -0
  165. package/src/config/constants.js +2 -1
  166. package/src/dev/client-bridge-registry.d.ts +5 -0
  167. package/src/dev/client-bridge-registry.js +15 -0
  168. package/src/dev/dev-client-ownership.d.ts +7 -0
  169. package/src/dev/dev-client-ownership.js +6 -0
  170. package/src/dev/hmr-manager-registry.d.ts +8 -0
  171. package/src/dev/hmr-manager-registry.js +15 -0
  172. package/src/dev/host-runtime.d.ts +3 -0
  173. package/src/dev/host-runtime.js +7 -0
  174. package/src/dev/runtime-server-started-message.d.ts +2 -0
  175. package/src/dev/runtime-server-started-message.js +6 -0
  176. package/src/diagnostics/request-build-dedupe.d.ts +18 -0
  177. package/src/diagnostics/request-build-dedupe.js +33 -0
  178. package/src/diagnostics/startup-trace.d.ts +72 -0
  179. package/src/diagnostics/startup-trace.js +253 -0
  180. package/src/eco/README.md +11 -0
  181. package/src/eco/eco-declared-component.d.ts +14 -0
  182. package/src/eco/eco-declared-component.js +16 -0
  183. package/src/eco/eco.browser.js +5 -6
  184. package/src/eco/eco.js +7 -8
  185. package/src/eco/eco.types.d.ts +14 -3
  186. package/src/eco/eco.utils.d.ts +1 -1
  187. package/src/eco/eco.utils.js +1 -1
  188. package/src/eco/page-layout-normalization.d.ts +21 -0
  189. package/src/eco/page-layout-normalization.js +59 -0
  190. package/src/env.d.ts +2 -0
  191. package/src/errors/index.d.ts +1 -0
  192. package/src/errors/index.js +7 -1
  193. package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
  194. package/src/errors/undeclared-component-dependency-error.js +17 -0
  195. package/src/hmr/client/hmr-runtime.js +7 -4
  196. package/src/hmr/hmr-entrypoint-output.d.ts +49 -0
  197. package/src/hmr/hmr-entrypoint-output.js +60 -0
  198. package/src/hmr/hmr-file-change-prep.d.ts +10 -0
  199. package/src/hmr/hmr-file-change-prep.js +17 -0
  200. package/src/hmr/hmr-strategy.d.ts +15 -0
  201. package/src/hmr/hmr-strategy.js +19 -0
  202. package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
  203. package/src/hmr/strategies/js-hmr-strategy.js +72 -19
  204. package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
  205. package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
  206. package/src/index.d.ts +2 -1
  207. package/src/index.js +28 -2
  208. package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
  209. package/src/integrations/ghtml/ghtml-renderer.js +2 -51
  210. package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
  211. package/src/integrations/ghtml/ghtml.plugin.js +7 -14
  212. package/src/plugins/alias-resolver-cache.d.ts +6 -9
  213. package/src/plugins/alias-resolver-plugin.d.ts +3 -3
  214. package/src/plugins/alias-resolver-plugin.js +38 -51
  215. package/src/plugins/define-integration.d.ts +26 -0
  216. package/src/plugins/define-integration.js +19 -0
  217. package/src/plugins/eco-component-meta-plugin.d.ts +1 -1
  218. package/src/plugins/eco-component-meta-plugin.js +5 -8
  219. package/src/plugins/foreign-jsx-override-plugin.d.ts +1 -1
  220. package/src/plugins/foreign-jsx-override-plugin.js +4 -6
  221. package/src/plugins/integration-plugin.d.ts +43 -14
  222. package/src/plugins/integration-plugin.js +18 -5
  223. package/src/plugins/jsx-import-source.utils.d.ts +8 -0
  224. package/src/plugins/jsx-import-source.utils.js +26 -0
  225. package/src/plugins/processor.d.ts +61 -12
  226. package/src/plugins/processor.js +24 -5
  227. package/src/plugins/source-transform.d.ts +32 -1
  228. package/src/plugins/source-transform.js +23 -1
  229. package/src/plugins/tsconfig-import-resolver.d.ts +18 -0
  230. package/src/plugins/tsconfig-import-resolver.js +159 -0
  231. package/src/route-renderer/GRAPH.md +26 -32
  232. package/src/route-renderer/README.md +38 -31
  233. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +107 -0
  234. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +148 -0
  235. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +20 -0
  236. package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +31 -0
  237. package/src/route-renderer/orchestration/{component-render-context.d.ts → foreign-child/component-render-context.d.ts} +8 -15
  238. package/src/route-renderer/orchestration/{component-render-context.js → foreign-child/component-render-context.js} +4 -2
  239. package/src/route-renderer/orchestration/{render-output.utils.d.ts → foreign-child/foreign-child-output.utils.d.ts} +17 -7
  240. package/src/route-renderer/orchestration/{render-output.utils.js → foreign-child/foreign-child-output.utils.js} +35 -26
  241. package/src/route-renderer/orchestration/{foreign-subtree-execution.service.d.ts → foreign-child/foreign-subtree-execution.service.d.ts} +64 -34
  242. package/src/route-renderer/orchestration/{foreign-subtree-execution.service.js → foreign-child/foreign-subtree-execution.service.js} +170 -37
  243. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.d.ts +19 -0
  244. package/src/route-renderer/orchestration/foreign-child/owning-renderer-resolution.js +35 -0
  245. package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -143
  246. package/src/route-renderer/orchestration/integration-renderer.js +163 -402
  247. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +75 -0
  248. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +177 -0
  249. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +10 -0
  250. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +143 -0
  251. package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +34 -0
  252. package/src/route-renderer/orchestration/ownership-graph/component-graph.js +96 -0
  253. package/src/route-renderer/orchestration/{ownership-validation.service.d.ts → ownership-graph/ownership-validation.service.d.ts} +7 -2
  254. package/src/route-renderer/orchestration/{ownership-validation.service.js → ownership-graph/ownership-validation.service.js} +30 -3
  255. package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.d.ts +7 -0
  256. package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +32 -0
  257. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.loader.d.ts +9 -0
  258. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-contribution.loader.js +7 -0
  259. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts +12 -0
  260. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js +29 -0
  261. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +106 -0
  262. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +436 -0
  263. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +31 -0
  264. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +229 -0
  265. package/src/route-renderer/orchestration/{processed-asset-dedupe.d.ts → page-browser-graph/processed-asset-dedupe.d.ts} +1 -1
  266. package/src/route-renderer/orchestration/route-pipeline/integration-route-render-adapter.d.ts +31 -0
  267. package/src/route-renderer/orchestration/route-pipeline/integration-route-render-adapter.js +25 -0
  268. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.d.ts +6 -0
  269. package/src/route-renderer/orchestration/route-pipeline/marker-artifact.utils.js +27 -0
  270. package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.d.ts +15 -0
  271. package/src/route-renderer/orchestration/route-pipeline/robots-meta.contribution.js +36 -0
  272. package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.d.ts +20 -0
  273. package/src/route-renderer/orchestration/route-pipeline/route-html-finalization.service.js +24 -0
  274. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.d.ts +25 -0
  275. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.builder.js +49 -0
  276. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.d.ts +4 -0
  277. package/src/route-renderer/orchestration/route-pipeline/route-prepared-options.utils.js +33 -0
  278. package/src/route-renderer/orchestration/{route-render-orchestrator.d.ts → route-pipeline/route-render-orchestrator.d.ts} +13 -53
  279. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +162 -0
  280. package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
  281. package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
  282. package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
  283. package/src/route-renderer/page-loading/ecopages-virtual-imports.d.ts +6 -0
  284. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +7 -2
  285. package/src/route-renderer/page-loading/module-declaration-aggregation.js +4 -0
  286. package/src/router/client/link-intent.d.ts +11 -21
  287. package/src/router/client/link-intent.js +10 -0
  288. package/src/router/client/link-intent.test.browser.js +12 -1
  289. package/src/router/client/link-navigation-policy.d.ts +45 -0
  290. package/src/router/client/link-navigation-policy.js +101 -0
  291. package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
  292. package/src/router/client/link-navigation-policy.test.browser.js +92 -0
  293. package/src/router/client/navigation-coordinator.d.ts +1 -1
  294. package/src/router/client/navigation-coordinator.js +12 -2
  295. package/src/services/assets/asset-processing-service/asset-dependency-keys.d.ts +13 -0
  296. package/src/services/assets/asset-processing-service/asset-dependency-keys.js +3 -0
  297. package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +6 -1
  298. package/src/services/assets/asset-processing-service/asset-processing.service.js +44 -5
  299. package/src/services/assets/asset-processing-service/assets.types.d.ts +1 -1
  300. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +2 -1
  301. package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
  302. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +52 -0
  303. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +78 -0
  304. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
  305. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +28 -13
  306. package/src/services/assets/asset-processing-service/finalize-processed-asset.d.ts +3 -0
  307. package/src/services/assets/asset-processing-service/finalize-processed-asset.js +7 -0
  308. package/src/services/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -1
  309. package/src/services/assets/asset-processing-service/grouped-content-bundles.js +38 -12
  310. package/src/services/assets/asset-processing-service/index.d.ts +2 -0
  311. package/src/services/assets/asset-processing-service/index.js +2 -0
  312. package/src/services/assets/asset-processing-service/inline-content-script-body.d.ts +11 -0
  313. package/src/services/assets/asset-processing-service/inline-content-script-body.js +17 -0
  314. package/src/services/assets/asset-processing-service/materialize-content-script-asset.d.ts +9 -0
  315. package/src/services/assets/asset-processing-service/materialize-content-script-asset.js +18 -0
  316. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +0 -2
  317. package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -15
  318. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +8 -0
  319. package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +73 -68
  320. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -1
  321. package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
  322. package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
  323. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
  324. package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
  325. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
  326. package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
  327. package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
  328. package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
  329. package/src/services/assets/asset-processing-service/resolve-integration-plugin.d.ts +4 -0
  330. package/src/services/assets/asset-processing-service/resolve-integration-plugin.js +17 -0
  331. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.d.ts +0 -1
  332. package/src/services/assets/asset-processing-service/ungrouped-dependency-processing.js +5 -10
  333. package/src/services/assets/browser-bundle.service.d.ts +28 -30
  334. package/src/services/assets/browser-bundle.service.js +28 -19
  335. package/src/services/html/html-transformer.service.d.ts +1 -1
  336. package/src/services/html/html-transformer.service.js +5 -5
  337. package/src/services/invalidation/development-invalidation.service.d.ts +25 -2
  338. package/src/services/invalidation/development-invalidation.service.js +64 -11
  339. package/src/services/module-loading/README.md +49 -0
  340. package/src/services/module-loading/app-server-module-transpiler.service.d.ts +8 -0
  341. package/src/services/module-loading/app-server-module-transpiler.service.js +3 -21
  342. package/src/services/module-loading/page-module-import.service.d.ts +6 -2
  343. package/src/services/module-loading/page-module-import.service.js +110 -47
  344. package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
  345. package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
  346. package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
  347. package/src/services/module-loading/route-module-build-cache.js +38 -0
  348. package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
  349. package/src/services/module-loading/route-module-build-cache.store.js +207 -0
  350. package/src/services/module-loading/route-module-build-manifest.d.ts +54 -0
  351. package/src/services/module-loading/route-module-build-manifest.js +85 -0
  352. package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
  353. package/src/services/module-loading/route-module-dependency-hasher.js +122 -0
  354. package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -1
  355. package/src/services/module-loading/server-module-transpiler.service.js +1 -1
  356. package/src/services/validation/schema-validation-service.d.ts +1 -4
  357. package/src/services/validation/schema-validation-service.js +12 -13
  358. package/src/services/validation/standard-schema.types.d.ts +9 -62
  359. package/src/services/validation/validate-standard-schema.d.ts +7 -0
  360. package/src/services/validation/validate-standard-schema.js +14 -0
  361. package/src/static-site-generator/README.md +41 -0
  362. package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +28 -0
  363. package/src/static-site-generator/production-page-browser-graph-prebuild.js +22 -0
  364. package/src/static-site-generator/sitemap-routes.d.ts +14 -0
  365. package/src/static-site-generator/sitemap-routes.js +31 -0
  366. package/src/static-site-generator/sitemap.d.ts +15 -0
  367. package/src/static-site-generator/sitemap.js +33 -0
  368. package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
  369. package/src/static-site-generator/static-build-invalidation.js +59 -0
  370. package/src/static-site-generator/static-export-context.d.ts +30 -0
  371. package/src/static-site-generator/static-export-context.js +0 -0
  372. package/src/static-site-generator/static-site-generator.d.ts +43 -25
  373. package/src/static-site-generator/static-site-generator.js +381 -106
  374. package/src/types/internal-types.d.ts +39 -13
  375. package/src/types/public-types.d.ts +289 -52
  376. package/src/utils/ecopages-route-info.d.ts +26 -0
  377. package/src/utils/ecopages-route-info.js +26 -0
  378. package/src/utils/html-escaping.d.ts +7 -0
  379. package/src/utils/html-escaping.js +5 -1
  380. package/src/utils/parse-cli-args.d.ts +2 -0
  381. package/src/utils/parse-cli-args.js +6 -0
  382. package/src/utils/path-pattern.d.ts +23 -0
  383. package/src/utils/path-pattern.js +27 -0
  384. package/src/utils/server-utils.module.d.ts +3 -2
  385. package/src/utils/server-utils.module.js +5 -6
  386. package/src/utils/static-file-extensions.d.ts +12 -0
  387. package/src/utils/static-file-extensions.js +48 -0
  388. package/src/watchers/project-watcher-ignore.d.ts +11 -0
  389. package/src/watchers/project-watcher-ignore.js +16 -0
  390. package/src/watchers/project-watcher.d.ts +29 -6
  391. package/src/watchers/project-watcher.js +146 -34
  392. package/src/watchers/project-watcher.test-helpers.js +5 -5
  393. package/src/adapters/shared/define-api-handler.d.ts +0 -25
  394. package/src/adapters/shared/define-api-handler.js +0 -15
  395. package/src/adapters/shared/hmr-entrypoint-registrar.js +0 -87
  396. package/src/adapters/shared/server-adapter.js +0 -436
  397. package/src/adapters/shared/server-static-builder.js +0 -162
  398. package/src/adapters/shared/shared-hmr-manager.d.ts +0 -59
  399. package/src/adapters/shared/shared-hmr-manager.js +0 -241
  400. package/src/build/build-manifest.d.ts +0 -33
  401. package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
  402. package/src/build/rolldown-dev-build-adapter.js +0 -166
  403. package/src/build/runtime-build-executor.d.ts +0 -21
  404. package/src/build/runtime-build-executor.js +0 -19
  405. package/src/build/runtime-build-output-normalizer.d.ts +0 -3
  406. package/src/build/runtime-build-output-normalizer.js +0 -111
  407. package/src/hmr/hmr.postcss.test.e2e.js +0 -31
  408. package/src/hmr/hmr.test.e2e.js +0 -43
  409. package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +0 -18
  410. package/src/route-renderer/orchestration/declared-ownership-graph.js +0 -34
  411. package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
  412. package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
  413. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
  414. package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
  415. package/src/route-renderer/orchestration/route-render-orchestrator.js +0 -577
  416. package/src/route-renderer/orchestration/template-serialization.d.ts +0 -38
  417. package/src/route-renderer/orchestration/template-serialization.js +0 -45
  418. /package/src/adapters/shared/{explicit-static-render-preparation.js → http/explicit-static-render-preparation.js} +0 -0
  419. /package/src/adapters/shared/{runtime-host.d.ts → runtime/runtime-host.d.ts} +0 -0
  420. /package/src/adapters/shared/{runtime-host.js → runtime/runtime-host.js} +0 -0
  421. /package/src/adapters/shared/{static-preview-host.js → runtime/static-preview-host.js} +0 -0
  422. /package/src/build/{browser-runtime-manifest.d.ts → browser/browser-runtime-manifest.d.ts} +0 -0
  423. /package/src/build/{browser-runtime-manifest.js → browser/browser-runtime-manifest.js} +0 -0
  424. /package/src/build/{browser-runtime-plugin-helpers.d.ts → browser/browser-runtime-plugin-helpers.d.ts} +0 -0
  425. /package/src/build/{browser-runtime-plugin-helpers.js → browser/browser-runtime-plugin-helpers.js} +0 -0
  426. /package/src/build/{build-types.js → contracts/build-contracts.js} +0 -0
  427. /package/src/build/{build-types.d.ts → contracts/build-types.d.ts} +0 -0
  428. /package/src/build/{server-side-css-shim-plugin.d.ts → rolldown/server-side-css-shim-plugin.d.ts} +0 -0
  429. /package/src/build/{server-side-css-shim-plugin.js → rolldown/server-side-css-shim-plugin.js} +0 -0
  430. /package/src/build/{serialized-build-executor.js → runtime/serialized-build-executor.js} +0 -0
  431. /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
  432. /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
  433. /package/src/route-renderer/orchestration/{processed-asset-dedupe.js → page-browser-graph/processed-asset-dedupe.js} +0 -0
@@ -176,8 +176,8 @@ function createEcoNavigationRuntime() {
176
176
  if (!registration?.reloadCurrentPage) {
177
177
  continue;
178
178
  }
179
- await registration.reloadCurrentPage(request);
180
- return true;
179
+ const handled = await registration.reloadCurrentPage(request);
180
+ return handled !== false;
181
181
  }
182
182
  return false;
183
183
  },
@@ -198,6 +198,16 @@ function createEcoNavigationRuntime() {
198
198
  await runtime.cleanupOwner(owner);
199
199
  }
200
200
  };
201
+ if (typeof window !== "undefined") {
202
+ window.addEventListener("pageshow", (event) => {
203
+ if (event.persisted) {
204
+ runtime.cancelCurrentNavigationTransaction();
205
+ }
206
+ });
207
+ window.addEventListener("pagehide", () => {
208
+ runtime.cancelCurrentNavigationTransaction();
209
+ });
210
+ }
201
211
  return runtime;
202
212
  }
203
213
  function getEcoNavigationRuntime(windowObject = window) {
@@ -1,3 +1,16 @@
1
1
  import type { AssetDefinition } from './assets.types.js';
2
+ /**
3
+ * Stable identity for dependency deduplication and {@link AssetProcessingService} cache lookups.
4
+ *
5
+ * @remarks
6
+ * Script dependencies include a build signature derived from bundle flags, grouped-bundle
7
+ * metadata, and selected `bundleOptions` fields (`naming`, `external`, `minify`, plugin names).
8
+ * HTML-affecting script `attributes` are hashed into the key so dedupe and cache reuse do not
9
+ * collapse declarations that would emit different `<script>` tags. Full plugin objects and
10
+ * `NODE_ENV` are excluded from the key.
11
+ *
12
+ * Runtime minify in {@link ContentScriptProcessor} still follows `NODE_ENV` via
13
+ * `isProduction`, not `bundleOptions.minify`.
14
+ */
2
15
  export declare function getAssetDependencyKey(dep: AssetDefinition): string;
3
16
  export declare function deduplicateAssetDependencies(deps: AssetDefinition[]): AssetDefinition[];
@@ -34,6 +34,9 @@ function getAssetDependencyKey(dep) {
34
34
  if ("packageRole" in dep && dep.packageRole) {
35
35
  parts.push(`package:${dep.packageRole}`);
36
36
  }
37
+ if (dep.kind === "script" && dep.attributes) {
38
+ parts.push(`attrs:${generateHash(JSON.stringify(dep.attributes))}`);
39
+ }
37
40
  const scriptBuildSignature = getScriptDependencyBuildSignature(dep);
38
41
  if (scriptBuildSignature) {
39
42
  parts.push(`build:${scriptBuildSignature}`);
@@ -39,9 +39,12 @@ export declare class AssetProcessingService {
39
39
  * @remarks
40
40
  * Dependencies are deduplicated before processor execution so repeated
41
41
  * declarations across the render tree reuse the same emitted outputs and cache
42
- * entries.
42
+ * entries. Returned asset order is unspecified — consumers must re-associate
43
+ * outputs with inputs via dependency metadata such as `groupedBundle`, not by
44
+ * array index alignment with the input list.
43
45
  */
44
46
  processDependencies(deps: AssetDefinition[], key: string): Promise<ProcessedAsset[]>;
47
+ private prepareDependenciesForProcessing;
45
48
  /**
46
49
  * Processes deduplicated dependencies grouped by processor type.
47
50
  *
@@ -80,6 +83,8 @@ export declare class AssetProcessingService {
80
83
  * Returns the cached processed asset for a dependency key when available.
81
84
  */
82
85
  private getCachedAsset;
86
+ private getCachedContentScriptAsset;
87
+ private resolveCachedContentScriptFilepath;
83
88
  /**
84
89
  * Stores one processed asset in the dependency cache.
85
90
  */
@@ -4,12 +4,19 @@ import { appLogger } from "../../../global/app-logger.js";
4
4
  import { fileSystem } from "@ecopages/file-system";
5
5
  import { deduplicateAssetDependencies, getAssetDependencyKey } from "./asset-dependency-keys.js";
6
6
  import {
7
+ ensureGroupedContentScriptsBundle,
7
8
  partitionGroupedContentScriptDependencies,
8
9
  processGroupedDependencyBundles
9
10
  } from "./grouped-content-bundles.js";
11
+ import { resolveIntegrationPluginForProcessingKey } from "./resolve-integration-plugin.js";
10
12
  import { isHmrAware } from "./processor.interface.js";
11
13
  import { ProcessorRegistry } from "./processor.registry.js";
12
14
  import { processUngroupedDependency } from "./ungrouped-dependency-processing.js";
15
+ import { materializeContentScriptAsset } from "./materialize-content-script-asset.js";
16
+ import {
17
+ getDevBrowserScriptCacheEntry,
18
+ setDevBrowserScriptCacheEntry
19
+ } from "../../../build/cache/dev-browser-script-cache.js";
13
20
  import {
14
21
  ContentScriptProcessor,
15
22
  ContentStylesheetProcessor,
@@ -62,16 +69,24 @@ class AssetProcessingService {
62
69
  * @remarks
63
70
  * Dependencies are deduplicated before processor execution so repeated
64
71
  * declarations across the render tree reuse the same emitted outputs and cache
65
- * entries.
72
+ * entries. Returned asset order is unspecified — consumers must re-associate
73
+ * outputs with inputs via dependency metadata such as `groupedBundle`, not by
74
+ * array index alignment with the input list.
66
75
  */
67
76
  async processDependencies(deps, key) {
68
77
  const depsDir = path.join(this.config.absolutePaths.distDir, RESOLVED_ASSETS_DIR);
69
78
  fileSystem.ensureDir(depsDir);
70
79
  const dedupedDeps = deduplicateAssetDependencies(deps);
71
- const results = await this.processDependenciesParallel(dedupedDeps, key);
80
+ const preparedDeps = this.prepareDependenciesForProcessing(dedupedDeps, key);
81
+ ensureGroupedContentScriptsBundle(preparedDeps);
82
+ const results = await this.processDependenciesParallel(preparedDeps);
72
83
  await this.optimizeDependencies(results);
73
84
  return results;
74
85
  }
86
+ prepareDependenciesForProcessing(deps, processingKey) {
87
+ const plugin = resolveIntegrationPluginForProcessingKey(this.config, processingKey);
88
+ return plugin?.prepareAssetDependencies?.(deps) ?? deps;
89
+ }
75
90
  /**
76
91
  * Processes deduplicated dependencies grouped by processor type.
77
92
  *
@@ -80,14 +95,13 @@ class AssetProcessingService {
80
95
  * pair, while still allowing the overall dependency set to resolve in
81
96
  * parallel.
82
97
  */
83
- async processDependenciesParallel(deps, key) {
98
+ async processDependenciesParallel(deps) {
84
99
  const grouped = this.groupDependenciesByType(deps);
85
100
  const groupPromises = Object.entries(grouped).map(async ([, typeDeps]) => {
86
101
  const { groupedBundleDeps, ungroupedDeps } = partitionGroupedContentScriptDependencies(typeDeps);
87
102
  const typePromises = ungroupedDeps.map(
88
103
  (dep) => processUngroupedDependency({
89
104
  dep,
90
- key,
91
105
  depKey: getAssetDependencyKey(dep),
92
106
  getCachedAsset: (assetDep, depKey) => this.getCachedAsset(assetDep, depKey),
93
107
  getProcessor: (assetDep) => this.registry.getProcessor(assetDep.kind, assetDep.source),
@@ -109,7 +123,6 @@ class AssetProcessingService {
109
123
  );
110
124
  const groupedResults = await processGroupedDependencyBundles({
111
125
  bundles: Array.from(groupedBundleDeps.values()),
112
- key,
113
126
  getCachedAsset: (dep, depKey) => this.getCachedAsset(dep, depKey),
114
127
  getDependencyKey: getAssetDependencyKey,
115
128
  getGroupedProcessor: () => this.registry.getProcessor("script", "content"),
@@ -229,6 +242,9 @@ class AssetProcessingService {
229
242
  if (process.env.NODE_ENV !== "production" && dep.source === "file" && dep.kind === "stylesheet") {
230
243
  return null;
231
244
  }
245
+ if (dep.kind === "script" && dep.source === "content") {
246
+ return this.getCachedContentScriptAsset(dep, depKey);
247
+ }
232
248
  const cached = this.cache.get(depKey);
233
249
  if (!cached) {
234
250
  return null;
@@ -239,11 +255,34 @@ class AssetProcessingService {
239
255
  }
240
256
  return cached.asset;
241
257
  }
258
+ getCachedContentScriptAsset(dep, depKey) {
259
+ const filepath = this.resolveCachedContentScriptFilepath(depKey) ?? getDevBrowserScriptCacheEntry(this.config, depKey)?.filepath;
260
+ if (!filepath) {
261
+ return null;
262
+ }
263
+ const materialized = materializeContentScriptAsset(dep, filepath);
264
+ this.cache.set(depKey, { asset: materialized });
265
+ return materialized;
266
+ }
267
+ resolveCachedContentScriptFilepath(depKey) {
268
+ const cached = this.cache.get(depKey);
269
+ if (!cached?.asset.filepath) {
270
+ return void 0;
271
+ }
272
+ if (!fileSystem.exists(cached.asset.filepath)) {
273
+ this.cache.delete(depKey);
274
+ return void 0;
275
+ }
276
+ return cached.asset.filepath;
277
+ }
242
278
  /**
243
279
  * Stores one processed asset in the dependency cache.
244
280
  */
245
281
  setCachedAsset(dep, depKey, asset) {
246
282
  this.cache.set(depKey, { asset });
283
+ if (dep.kind === "script" && dep.source === "content") {
284
+ setDevBrowserScriptCacheEntry(this.config, depKey, asset);
285
+ }
247
286
  }
248
287
  /**
249
288
  * Clears all cached processed assets.
@@ -1,4 +1,4 @@
1
- import type { EcoBuildPlugin } from '../../../build/build-types.js';
1
+ import type { EcoBuildPlugin } from '../../../build/contracts/build-types.js';
2
2
  export type AssetSource = 'content' | 'file' | 'node-module';
3
3
  export type AssetKind = 'script' | 'stylesheet';
4
4
  export type AssetPosition = 'head' | 'body';
@@ -1,4 +1,4 @@
1
- import type { EcoBuildPlugin } from '../../../build/build-types.js';
1
+ import type { EcoBuildPlugin } from '../../../build/contracts/build-types.js';
2
2
  import type { AssetDefinition } from './assets.types.js';
3
3
  import { type BrowserRuntimeEntryModuleConfig } from './browser-runtime-entry.factory.js';
4
4
  export declare const BROWSER_RUNTIME_SCRIPT_ATTRIBUTES: {
@@ -45,6 +45,7 @@ export declare function createBrowserRuntimeModuleAsset(options: {
45
45
  fileName: string;
46
46
  cacheDirName?: string;
47
47
  rootDir?: string;
48
+ workDir?: string;
48
49
  bundleOptions?: {
49
50
  define?: Record<string, string>;
50
51
  minify?: boolean;
@@ -31,6 +31,7 @@ function createBrowserRuntimeModuleAsset(options) {
31
31
  modules: options.modules,
32
32
  fileName: `${options.name}-entry.mjs`,
33
33
  rootDir: options.rootDir,
34
+ workDir: options.workDir,
34
35
  cacheDirName: options.cacheDirName
35
36
  });
36
37
  return createBrowserRuntimeScriptAsset({
@@ -0,0 +1,52 @@
1
+ import type { createRequire } from 'node:module';
2
+ export type BrowserRuntimeDefaultExportPolicy = 'emit-default' | 'skip-default';
3
+ type RequireFromRoot = ReturnType<typeof createRequire>;
4
+ /**
5
+ * Resolves a package specifier to its ESM entry file path from the app root.
6
+ */
7
+ export declare function resolvePackageEsmEntryPath(specifier: string, rootDir: string): string | undefined;
8
+ /**
9
+ * Builds a relative import path from a generated runtime entry file to a resolved module path.
10
+ */
11
+ export declare function toRelativeEntryImport(entryDir: string, resolvedPath: string): string;
12
+ /**
13
+ * Resolves a browser runtime entry import to an ESM file path when possible.
14
+ *
15
+ * @remarks
16
+ * `createRequire().resolve()` follows the `require` export condition and can
17
+ * land on `.cjs` entrypoints. Browser vendor bundles then emit runtime
18
+ * `require()` calls for React externals. Prefer Node's ESM resolver first, then
19
+ * a `.cjs` → `.js` sibling fallback.
20
+ */
21
+ export declare function resolveBrowserRuntimeEntryImport(options: {
22
+ specifier: string;
23
+ requireFromRoot: RequireFromRoot;
24
+ entryDir: string;
25
+ rootDir: string;
26
+ }): string;
27
+ /**
28
+ * Decides whether a generated runtime entry should re-export a default binding.
29
+ *
30
+ * @remarks
31
+ * ESM-only packages such as `@tanstack/react-query` expose named exports only.
32
+ * Legacy CJS packages such as `react` assign `module.exports` directly and have
33
+ * no `.default` under `require()`, but still need a default re-export for
34
+ * `import React from 'react'` in browser bundles.
35
+ *
36
+ * ESM source inspection is a best-effort fast path; when it is inconclusive the
37
+ * policy falls back to the shape returned by `require()`.
38
+ */
39
+ export declare function inferBrowserRuntimeDefaultExportPolicy(options: {
40
+ specifier: string;
41
+ requireFromRoot: RequireFromRoot;
42
+ rootDir: string;
43
+ }): BrowserRuntimeDefaultExportPolicy;
44
+ /**
45
+ * Reads the named runtime exports that should be re-exported from a generated runtime entry module.
46
+ *
47
+ * @remarks
48
+ * Default exports are handled separately because generated runtime entry files need to emit a
49
+ * synthetic default binding only when the caller explicitly asks for it.
50
+ */
51
+ export declare function listBrowserRuntimeModuleExportNames(specifier: string, requireFromRoot: RequireFromRoot): string[];
52
+ export {};
@@ -0,0 +1,78 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { pathToFileURL, fileURLToPath } from "node:url";
4
+ import { isBarePackageImportSpecifier } from "../../../plugins/tsconfig-import-resolver.js";
5
+ function resolvePackageEsmEntryPath(specifier, rootDir) {
6
+ try {
7
+ return fileURLToPath(import.meta.resolve(specifier, pathToFileURL(path.join(rootDir, "package.json")).href));
8
+ } catch {
9
+ return void 0;
10
+ }
11
+ }
12
+ function toRelativeEntryImport(entryDir, resolvedPath) {
13
+ let relativePath = path.relative(entryDir, resolvedPath).replace(/\\/g, "/");
14
+ if (!relativePath.startsWith(".")) {
15
+ relativePath = `./${relativePath}`;
16
+ }
17
+ return relativePath;
18
+ }
19
+ function resolveBrowserRuntimeEntryImport(options) {
20
+ const { specifier, requireFromRoot, entryDir, rootDir } = options;
21
+ if (specifier.startsWith("node:") || specifier.startsWith("file:")) {
22
+ return specifier;
23
+ }
24
+ if (specifier.startsWith(".")) {
25
+ const resolvedPath2 = requireFromRoot.resolve(specifier);
26
+ return toRelativeEntryImport(entryDir, resolvedPath2);
27
+ }
28
+ if (isBarePackageImportSpecifier(specifier, rootDir)) {
29
+ const esmResolvedPath = resolvePackageEsmEntryPath(specifier, rootDir);
30
+ if (esmResolvedPath) {
31
+ return toRelativeEntryImport(entryDir, esmResolvedPath);
32
+ }
33
+ }
34
+ const resolvedPath = requireFromRoot.resolve(specifier);
35
+ const esmSibling = resolvedPath.endsWith(".cjs") ? `${resolvedPath.slice(0, -4)}.js` : resolvedPath.endsWith(".cts") ? `${resolvedPath.slice(0, -4)}.ts` : void 0;
36
+ if (esmSibling && fs.existsSync(esmSibling)) {
37
+ return toRelativeEntryImport(entryDir, esmSibling);
38
+ }
39
+ return toRelativeEntryImport(entryDir, resolvedPath);
40
+ }
41
+ function inferBrowserRuntimeDefaultExportPolicy(options) {
42
+ const { specifier, requireFromRoot, rootDir } = options;
43
+ const esmPath = resolvePackageEsmEntryPath(specifier, rootDir);
44
+ if (esmPath && fs.existsSync(esmPath)) {
45
+ const source = fs.readFileSync(esmPath, "utf8");
46
+ if (/\bexport\s+default\b/.test(source)) {
47
+ return "emit-default";
48
+ }
49
+ if (/\bexport\s+(?:[\w*{]|const|let|var|function|class)/.test(source)) {
50
+ return "skip-default";
51
+ }
52
+ }
53
+ try {
54
+ const moduleExports = requireFromRoot(specifier);
55
+ if (moduleExports.default !== void 0) {
56
+ return "emit-default";
57
+ }
58
+ return moduleExports.__esModule === true ? "skip-default" : "emit-default";
59
+ } catch {
60
+ return "skip-default";
61
+ }
62
+ }
63
+ function listBrowserRuntimeModuleExportNames(specifier, requireFromRoot) {
64
+ let moduleExports;
65
+ try {
66
+ moduleExports = requireFromRoot(specifier);
67
+ } catch {
68
+ return [];
69
+ }
70
+ return Object.keys(moduleExports).filter((name) => name !== "__esModule" && name !== "default").filter((name) => /^[$A-Z_a-z][$\w]*$/.test(name)).sort();
71
+ }
72
+ export {
73
+ inferBrowserRuntimeDefaultExportPolicy,
74
+ listBrowserRuntimeModuleExportNames,
75
+ resolveBrowserRuntimeEntryImport,
76
+ resolvePackageEsmEntryPath,
77
+ toRelativeEntryImport
78
+ };
@@ -9,12 +9,14 @@ export type BrowserRuntimeEntryModuleConfig = {
9
9
  * @remarks
10
10
  * Integrations use this helper when they need a browser runtime asset composed
11
11
  * from multiple bare specifiers but do not want to own temporary file assembly
12
- * logic themselves. The generated file lives under a cache directory inside the
13
- * consuming app root so repeated runs can reuse the same location.
12
+ * logic themselves. The generated file lives under the app work directory so
13
+ * repeated runs can reuse the same location without placing sources inside
14
+ * `node_modules`, which can cause bundlers to externalize bare imports.
14
15
  */
15
16
  export declare function createBrowserRuntimeEntryModule(options: {
16
17
  modules: BrowserRuntimeEntryModuleConfig[];
17
18
  fileName: string;
18
19
  rootDir?: string;
20
+ workDir?: string;
19
21
  cacheDirName?: string;
20
22
  }): string;
@@ -1,41 +1,56 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { createRequire } from "node:module";
4
+ import { DEFAULT_ECOPAGES_WORK_DIR } from "../../../config/constants.js";
5
+ import {
6
+ inferBrowserRuntimeDefaultExportPolicy,
7
+ listBrowserRuntimeModuleExportNames,
8
+ resolveBrowserRuntimeEntryImport
9
+ } from "./browser-runtime-entry-resolution.js";
4
10
  function createBrowserRuntimeEntryModule(options) {
11
+ if (options.modules.some((module) => !module.specifier.startsWith("node:")) && !options.rootDir) {
12
+ throw new Error("createBrowserRuntimeEntryModule requires rootDir to resolve package specifiers");
13
+ }
5
14
  const rootDir = options.rootDir ?? process.cwd();
15
+ const workDir = options.workDir ?? path.join(rootDir, DEFAULT_ECOPAGES_WORK_DIR);
6
16
  const artifactsDir = path.join(
7
- rootDir,
8
- "node_modules",
9
- ".cache",
17
+ workDir,
18
+ ".browser-runtime-entries",
10
19
  options.cacheDirName ?? "ecopages-browser-runtime"
11
20
  );
12
21
  fs.mkdirSync(artifactsDir, { recursive: true });
13
22
  const requireFromRoot = createRequire(path.join(rootDir, "package.json"));
14
23
  const seenExports = /* @__PURE__ */ new Set();
15
24
  const statements = [];
25
+ const filePath = path.join(artifactsDir, options.fileName);
26
+ const entryDir = path.dirname(filePath);
16
27
  for (const module of options.modules) {
17
- if (module.defaultExport) {
18
- statements.push(`import __ecopages_default_export__ from '${module.specifier}';`);
28
+ const importSpecifier = resolveBrowserRuntimeEntryImport({
29
+ specifier: module.specifier,
30
+ requireFromRoot,
31
+ entryDir,
32
+ rootDir
33
+ });
34
+ if (module.defaultExport && inferBrowserRuntimeDefaultExportPolicy({ specifier: module.specifier, requireFromRoot, rootDir }) === "emit-default") {
35
+ statements.push(`import __ecopages_default_export__ from '${importSpecifier}';`);
19
36
  statements.push("export default __ecopages_default_export__;");
20
37
  }
21
- const exportNames = getModuleExportNames(module.specifier, requireFromRoot).filter(
38
+ const exportNames = listBrowserRuntimeModuleExportNames(module.specifier, requireFromRoot).filter(
22
39
  (name) => !seenExports.has(name)
23
40
  );
24
41
  if (exportNames.length > 0) {
25
- statements.push(`export { ${exportNames.join(", ")} } from '${module.specifier}';`);
42
+ statements.push(`export { ${exportNames.join(", ")} } from '${importSpecifier}';`);
26
43
  for (const exportName of exportNames) {
27
44
  seenExports.add(exportName);
28
45
  }
29
46
  }
30
47
  }
31
- const filePath = path.join(artifactsDir, options.fileName);
32
- fs.writeFileSync(filePath, statements.join("\n"), "utf-8");
48
+ const content = statements.join("\n");
49
+ if (!fs.existsSync(filePath) || fs.readFileSync(filePath, "utf-8") !== content) {
50
+ fs.writeFileSync(filePath, content, "utf-8");
51
+ }
33
52
  return filePath;
34
53
  }
35
- function getModuleExportNames(specifier, requireFromRoot) {
36
- const moduleExports = requireFromRoot(specifier);
37
- return Object.keys(moduleExports).filter((name) => name !== "__esModule" && name !== "default").filter((name) => /^[$A-Z_a-z][$\w]*$/.test(name)).sort();
38
- }
39
54
  export {
40
55
  createBrowserRuntimeEntryModule
41
56
  };
@@ -0,0 +1,3 @@
1
+ import type { ProcessedAsset } from './assets.types.js';
2
+ /** Applies the public source URL to one processed asset when available. */
3
+ export declare function finalizeProcessedAsset(processed: ProcessedAsset, resolveProcessedAssetSrcUrl: (processed: ProcessedAsset) => string | undefined): ProcessedAsset;
@@ -0,0 +1,7 @@
1
+ function finalizeProcessedAsset(processed, resolveProcessedAssetSrcUrl) {
2
+ const srcUrl = resolveProcessedAssetSrcUrl(processed);
3
+ return srcUrl ? { ...processed, srcUrl } : processed;
4
+ }
5
+ export {
6
+ finalizeProcessedAsset
7
+ };
@@ -1,4 +1,6 @@
1
1
  import type { AssetDefinition, ProcessedAsset } from './assets.types.js';
2
+ /** Forces grouped content scripts to run through the bundler in production builds. */
3
+ export declare function ensureGroupedContentScriptsBundle(dependencies: AssetDefinition[]): void;
2
4
  /**
3
5
  * Splits grouped content-script dependencies from ordinary dependencies so callers can
4
6
  * route them through `processGrouped` without changing ordering for the remaining assets.
@@ -12,7 +14,6 @@ type GroupedBundleProcessor = {
12
14
  };
13
15
  type ProcessGroupedDependencyBundlesOptions = {
14
16
  bundles: AssetDefinition[][];
15
- key: string;
16
17
  getCachedAsset: (dep: AssetDefinition, depKey: string) => ProcessedAsset | null;
17
18
  getDependencyKey: (dep: AssetDefinition) => string;
18
19
  getGroupedProcessor: () => GroupedBundleProcessor | undefined;
@@ -1,3 +1,21 @@
1
+ import { isDevelopmentRuntime } from "../../../utils/runtime.js";
2
+ import { finalizeProcessedAsset } from "./finalize-processed-asset.js";
3
+ function getGroupedBundleAssetKey(groupedBundle) {
4
+ return `${groupedBundle.id}:${groupedBundle.entryName}`;
5
+ }
6
+ function ensureGroupedContentScriptsBundle(dependencies) {
7
+ if (isDevelopmentRuntime()) {
8
+ return;
9
+ }
10
+ for (const dependency of dependencies) {
11
+ if (dependency.kind !== "script" || dependency.source !== "content" || !dependency.groupedBundle?.id) {
12
+ continue;
13
+ }
14
+ if (dependency.bundle === false) {
15
+ dependency.bundle = true;
16
+ }
17
+ }
18
+ }
1
19
  function partitionGroupedContentScriptDependencies(typeDeps) {
2
20
  const groupedBundleDeps = /* @__PURE__ */ new Map();
3
21
  const ungroupedDeps = [];
@@ -18,7 +36,6 @@ function partitionGroupedContentScriptDependencies(typeDeps) {
18
36
  async function processGroupedDependencyBundles(options) {
19
37
  const {
20
38
  bundles,
21
- key,
22
39
  getCachedAsset,
23
40
  getDependencyKey,
24
41
  getGroupedProcessor,
@@ -29,7 +46,7 @@ async function processGroupedDependencyBundles(options) {
29
46
  const groupedPromises = bundles.map(async (bundleDeps) => {
30
47
  const cachedResults = bundleDeps.map((dep) => {
31
48
  const cached = getCachedAsset(dep, getDependencyKey(dep));
32
- return cached ? { key, ...cached } : null;
49
+ return cached ? finalizeProcessedAsset(cached, resolveProcessedAssetSrcUrl) : null;
33
50
  });
34
51
  if (cachedResults.every((result) => result !== null)) {
35
52
  return cachedResults.filter((result) => result !== null);
@@ -40,17 +57,25 @@ async function processGroupedDependencyBundles(options) {
40
57
  }
41
58
  try {
42
59
  const processedResults = await processor.processGrouped(bundleDeps);
43
- return processedResults.map((processed, index) => {
44
- const dep = bundleDeps[index];
60
+ const processedByEntryKey = /* @__PURE__ */ new Map();
61
+ for (const processed of processedResults) {
62
+ if (!processed.groupedBundle) {
63
+ continue;
64
+ }
65
+ processedByEntryKey.set(getGroupedBundleAssetKey(processed.groupedBundle), processed);
66
+ }
67
+ return bundleDeps.flatMap((dep) => {
68
+ if (dep.kind !== "script" || dep.source !== "content" || !dep.groupedBundle) {
69
+ return [];
70
+ }
71
+ const processed = processedByEntryKey.get(getGroupedBundleAssetKey(dep.groupedBundle));
72
+ if (!processed) {
73
+ return [];
74
+ }
45
75
  const depKey = getDependencyKey(dep);
46
- const srcUrl = resolveProcessedAssetSrcUrl(processed);
47
- const processedWithKey = {
48
- key,
49
- ...processed,
50
- srcUrl
51
- };
52
- setCachedAsset(dep, depKey, processedWithKey);
53
- return processedWithKey;
76
+ const finalized = finalizeProcessedAsset(processed, resolveProcessedAssetSrcUrl);
77
+ setCachedAsset(dep, depKey, finalized);
78
+ return [finalized];
54
79
  });
55
80
  } catch (error) {
56
81
  logError(error);
@@ -60,6 +85,7 @@ async function processGroupedDependencyBundles(options) {
60
85
  return (await Promise.all(groupedPromises)).flat();
61
86
  }
62
87
  export {
88
+ ensureGroupedContentScriptsBundle,
63
89
  partitionGroupedContentScriptDependencies,
64
90
  processGroupedDependencyBundles
65
91
  };
@@ -1,6 +1,8 @@
1
1
  export * from './asset.factory.js';
2
+ export * from './grouped-content-bundles.js';
2
3
  export * from './page-package.js';
3
4
  export * from './asset-processing.service.js';
4
5
  export * from './assets.types.js';
5
6
  export * from './browser-runtime-asset.factory.js';
6
7
  export * from './browser-runtime-entry.factory.js';
8
+ export * from './browser-runtime-entry-resolution.js';
@@ -1,6 +1,8 @@
1
1
  export * from "./asset.factory.js";
2
+ export * from "./grouped-content-bundles.js";
2
3
  export * from "./page-package.js";
3
4
  export * from "./asset-processing.service.js";
4
5
  export * from "./assets.types.js";
5
6
  export * from "./browser-runtime-asset.factory.js";
6
7
  export * from "./browser-runtime-entry.factory.js";
8
+ export * from "./browser-runtime-entry-resolution.js";
@@ -0,0 +1,11 @@
1
+ import type { ContentScriptAsset } from './assets.types.js';
2
+ /**
3
+ * Resolves the script body to embed when a content script is marked inline.
4
+ *
5
+ * @remarks
6
+ * `inline` means embed in HTML, not "use declaration source." When bundling has
7
+ * already run, only the output file is valid browser script; `dep.content` may
8
+ * still contain build-time import paths. Processor emission and cache
9
+ * materialization must share this rule so they cannot drift.
10
+ */
11
+ export declare function resolveInlineContentScriptBody(dep: Pick<ContentScriptAsset, 'inline' | 'bundle' | 'content'>, filepath: string): string | undefined;
@@ -0,0 +1,17 @@
1
+ import { fileSystem } from "@ecopages/file-system";
2
+ import { appLogger } from "../../../global/app-logger.js";
3
+ function resolveInlineContentScriptBody(dep, filepath) {
4
+ if (!dep.inline) {
5
+ return void 0;
6
+ }
7
+ if (dep.bundle !== false && fileSystem.exists(filepath)) {
8
+ return fileSystem.readFileSync(filepath);
9
+ }
10
+ if (dep.bundle !== false) {
11
+ appLogger.warn(`Missing bundled inline script output at ${filepath}; falling back to declaration source.`);
12
+ }
13
+ return dep.content;
14
+ }
15
+ export {
16
+ resolveInlineContentScriptBody
17
+ };
@@ -0,0 +1,9 @@
1
+ import type { ContentScriptAsset, ProcessedAsset } from './assets.types.js';
2
+ /**
3
+ * @remarks
4
+ * {@link AssetProcessingService} cache and dev disk cache entries usually keep
5
+ * only an output path. Dependency declarations still carry the metadata HTML and
6
+ * page-browser graph assembly need (`groupedBundle`, attributes, roles), so cache
7
+ * hits must be rehydrated from both sources rather than returned verbatim.
8
+ */
9
+ export declare function materializeContentScriptAsset(dep: ContentScriptAsset, filepath: string): ProcessedAsset;
@@ -0,0 +1,18 @@
1
+ import { resolveInlineContentScriptBody } from "./inline-content-script-body.js";
2
+ function materializeContentScriptAsset(dep, filepath) {
3
+ return {
4
+ filepath,
5
+ kind: "script",
6
+ inline: dep.inline ?? false,
7
+ content: resolveInlineContentScriptBody(dep, filepath),
8
+ position: dep.position,
9
+ attributes: dep.attributes,
10
+ excludeFromHtml: dep.excludeFromHtml,
11
+ packageRole: dep.packageRole,
12
+ groupedBundle: dep.groupedBundle,
13
+ bundledSourceFilepaths: dep.bundledSourceFilepaths
14
+ };
15
+ }
16
+ export {
17
+ materializeContentScriptAsset
18
+ };
@@ -1,5 +1,4 @@
1
1
  import type { EcoPagesAppConfig } from '../../../../../types/internal-types.js';
2
- import type { EcoBuildPlugin } from '../../../../../build/build-types.js';
3
2
  import type { ScriptAsset } from '../../assets.types.js';
4
3
  import { BaseProcessor } from './base-processor.js';
5
4
  import { type BrowserBundleGroupedEntry } from '../../../browser-bundle.service.js';
@@ -10,7 +9,6 @@ export declare abstract class BaseScriptProcessor<T extends ScriptAsset> extends
10
9
  });
11
10
  protected shouldBundle(dep: T): boolean;
12
11
  protected getBundlerOptions(dep: T): Record<string, any>;
13
- protected collectBuildPlugins(excludePluginNames?: string[]): EcoBuildPlugin[];
14
12
  protected bundleScript({ entrypoint, outdir, excludeAppBuildPlugins, plugins: additionalPlugins, ...rest }: {
15
13
  entrypoint: string;
16
14
  outdir: string;