@ecopages/core 0.2.0-rc.1 → 0.2.0-rc.10

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 (179) hide show
  1. package/README.md +50 -32
  2. package/package.json +50 -4
  3. package/src/adapters/README.md +3 -1
  4. package/src/adapters/abstract/application-adapter.d.ts +28 -6
  5. package/src/adapters/abstract/application-adapter.js +58 -5
  6. package/src/adapters/abstract/segment-path-matcher.js +56 -38
  7. package/src/adapters/abstract/server-adapter.d.ts +14 -0
  8. package/src/adapters/abstract/server-adapter.js +10 -0
  9. package/src/adapters/bun/create-app.d.ts +8 -4
  10. package/src/adapters/bun/create-app.js +64 -37
  11. package/src/adapters/bun/server-adapter.d.ts +6 -2
  12. package/src/adapters/bun/server-adapter.js +14 -1
  13. package/src/adapters/create-app.d.ts +62 -7
  14. package/src/adapters/create-app.js +61 -5
  15. package/src/adapters/node/create-app.d.ts +5 -5
  16. package/src/adapters/node/create-app.js +18 -5
  17. package/src/adapters/node/runtime-host.js +9 -4
  18. package/src/adapters/node/server-adapter.d.ts +5 -1
  19. package/src/adapters/node/server-adapter.js +16 -1
  20. package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
  21. package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
  22. package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
  23. package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
  24. package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
  25. package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
  26. package/src/adapters/shared/runtime/application-adapter.js +12 -0
  27. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
  28. package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
  29. package/src/adapters/shared/runtime/port-manager-default-prompt.d.ts +6 -0
  30. package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
  31. package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
  32. package/src/adapters/shared/runtime/port-manager.js +14 -45
  33. package/src/adapters/shared/runtime/server-adapter.d.ts +14 -5
  34. package/src/adapters/shared/runtime/server-adapter.js +22 -30
  35. package/src/adapters/shared/runtime/server-route-handler.js +11 -3
  36. package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
  37. package/src/adapters/shared/runtime/server-static-builder.js +59 -37
  38. package/src/build/README.md +4 -0
  39. package/src/build/cache/server-entry-build-cache.d.ts +24 -1
  40. package/src/build/cache/server-entry-build-cache.js +125 -8
  41. package/src/build/contracts/content-virtual-modules.d.ts +3 -1
  42. package/src/build/contracts/content-virtual-modules.js +8 -0
  43. package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
  44. package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
  45. package/src/build/runtime/build-request-policy.js +1 -1
  46. package/src/build/server-bundle-publication.d.ts +14 -0
  47. package/src/build/server-bundle-publication.js +49 -0
  48. package/src/config/README.md +17 -2
  49. package/src/config/apply-user-config.d.ts +6 -0
  50. package/src/config/apply-user-config.js +67 -0
  51. package/src/config/config-builder.d.ts +10 -1
  52. package/src/config/config-builder.js +51 -10
  53. package/src/config/constants.d.ts +4 -0
  54. package/src/config/constants.js +4 -0
  55. package/src/config/define-config.d.ts +9 -0
  56. package/src/config/define-config.js +10 -0
  57. package/src/config/index.d.ts +5 -0
  58. package/src/config/index.js +4 -0
  59. package/src/config/is-finalized-app-config.d.ts +6 -0
  60. package/src/config/is-finalized-app-config.js +11 -0
  61. package/src/config/load-eco-config.d.ts +21 -0
  62. package/src/config/load-eco-config.js +100 -0
  63. package/src/config/resolve-eco-config-path.d.ts +23 -0
  64. package/src/config/resolve-eco-config-path.js +47 -0
  65. package/src/config/server-config-bundle.d.ts +25 -0
  66. package/src/config/server-config-bundle.js +148 -0
  67. package/src/config/user-config-types.d.ts +164 -0
  68. package/src/config/user-config-types.js +1 -0
  69. package/src/css-imports.d.ts +4 -0
  70. package/src/declarations.d.ts +11 -5
  71. package/src/dev/README.md +6 -0
  72. package/src/dev/development-restart-watch-paths.d.ts +13 -0
  73. package/src/dev/development-restart-watch-paths.js +37 -0
  74. package/src/dev/development-restart.d.ts +13 -0
  75. package/src/dev/development-restart.js +21 -0
  76. package/src/dev/transform-server/dev-transform-server.d.ts +6 -0
  77. package/src/dev/transform-server/dev-transform-server.js +16 -5
  78. package/src/eco/README.md +73 -5
  79. package/src/eco/component-identity.d.ts +3 -2
  80. package/src/eco/component-identity.js +5 -2
  81. package/src/eco/discovered-dependencies.d.ts +45 -0
  82. package/src/eco/discovered-dependencies.js +87 -0
  83. package/src/eco/eco.js +6 -0
  84. package/src/eco/eco.types.d.ts +18 -2
  85. package/src/eco/lazy-injector-map.js +57 -41
  86. package/src/eco/page-dependency-contributions.d.ts +19 -0
  87. package/src/eco/page-dependency-contributions.js +52 -0
  88. package/src/errors/http-error-page-contract.d.ts +77 -0
  89. package/src/errors/http-error-page-contract.js +106 -0
  90. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -0
  91. package/src/hmr/strategies/js-hmr-strategy.js +24 -16
  92. package/src/index.browser.d.ts +3 -0
  93. package/src/index.browser.js +3 -0
  94. package/src/index.d.ts +4 -1
  95. package/src/index.js +4 -1
  96. package/src/islands/README.md +5 -1
  97. package/src/plugins/README.md +8 -1
  98. package/src/plugins/component-import-discovery.d.ts +19 -0
  99. package/src/plugins/component-import-discovery.js +241 -0
  100. package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
  101. package/src/plugins/eco-component-meta-plugin.js +118 -16
  102. package/src/plugins/processor.d.ts +10 -2
  103. package/src/plugins/processor.js +4 -0
  104. package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
  105. package/src/plugins/tsconfig-import-resolver.js +4 -2
  106. package/src/route-renderer/GRAPH.md +1 -1
  107. package/src/route-renderer/README.md +15 -2
  108. package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
  109. package/src/route-renderer/orchestration/custom-element-scripts/README.md +9 -0
  110. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
  111. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
  112. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
  113. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
  114. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
  115. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
  116. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
  117. package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
  118. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
  119. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +2 -0
  120. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
  121. package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
  122. package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -5
  123. package/src/route-renderer/orchestration/integration-renderer.js +42 -29
  124. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
  125. package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
  126. package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
  127. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
  128. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
  129. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
  130. package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
  131. package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
  132. package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
  133. package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
  134. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
  135. package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
  136. package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
  137. package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
  138. package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
  139. package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
  140. package/src/route-renderer/route-renderer.d.ts +9 -0
  141. package/src/route-renderer/route-renderer.js +18 -0
  142. package/src/router/README.md +7 -1
  143. package/src/router/server/route-registry.d.ts +13 -0
  144. package/src/router/server/route-registry.js +46 -32
  145. package/src/services/README.md +5 -0
  146. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
  147. package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
  148. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
  149. package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
  150. package/src/services/assets/asset-processing-service/page-package.js +42 -39
  151. package/src/services/error-pages/README.md +9 -0
  152. package/src/services/error-pages/default-error-pages.d.ts +44 -0
  153. package/src/services/error-pages/default-error-pages.js +207 -0
  154. package/src/services/error-pages/error-page-renderer.d.ts +58 -0
  155. package/src/services/error-pages/error-page-renderer.js +146 -0
  156. package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
  157. package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
  158. package/src/services/invalidation/development-invalidation.service.d.ts +7 -1
  159. package/src/services/invalidation/development-invalidation.service.js +35 -3
  160. package/src/services/module-loading/README.md +16 -13
  161. package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
  162. package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
  163. package/src/services/module-loading/collection-server-module-build.service.js +5 -2
  164. package/src/services/module-loading/page-module-import.service.d.ts +8 -0
  165. package/src/services/module-loading/page-module-import.service.js +62 -28
  166. package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
  167. package/src/services/module-loading/view-module-loader.d.ts +10 -0
  168. package/src/services/module-loading/view-module-loader.js +46 -0
  169. package/src/services/validation/schema-validation-service.d.ts +1 -0
  170. package/src/services/validation/schema-validation-service.js +23 -36
  171. package/src/static-site-generator/README.md +6 -1
  172. package/src/static-site-generator/static-site-generator.d.ts +7 -2
  173. package/src/static-site-generator/static-site-generator.js +90 -49
  174. package/src/types/internal-types.d.ts +6 -1
  175. package/src/types/public-types.d.ts +32 -22
  176. package/src/utils/parse-cli-args.js +29 -22
  177. package/src/watchers/project-watcher.d.ts +14 -1
  178. package/src/watchers/project-watcher.js +85 -34
  179. /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
package/README.md CHANGED
@@ -13,13 +13,16 @@ Ecopages is an extensible static site generator (SSG) built around a Bun-first c
13
13
 
14
14
  ## Current Architecture
15
15
 
16
+ Projects load shared ambient types through `@ecopages/core/declarations`. This entry references `src/css-imports.d.ts`, which keeps the wildcard CSS declaration in a standalone ambient file so side-effect CSS imports typecheck without per-project declarations.
17
+
16
18
  The current core package is organized around app-owned runtime state and explicit service boundaries.
17
19
 
18
20
  The important ownership rules are:
19
21
 
20
22
  - `ConfigBuilder.build()` finalizes app-owned build and runtime services.
21
23
  - Component identity attribution is one shared source transform for server, browser, and HMR compilation paths: after a lexical `eco.` gate, it uses Oxc to wrap supported factory options with `bindComponentIdentity()`, which factories retain as `config.identity`.
22
- - browser bundling and server module loading are explicit, separate paths.
24
+ - Direct local Eco Component imports (including named `export { X } from` barrels) and relative side-effect CSS imports supply Dependencies by default through the shared transform and existing collector; explicit asset declarations override inference, and inferred styles stay keyed by identity until collection. See [eco](src/eco/README.md) and [Plugin Contracts](src/plugins/README.md).
25
+ - Browser bundling and server module loading are separate paths. SSR-enabled lazy scripts execute on the server before rendering and in the browser only on their configured trigger.
23
26
  - runtime hosts stay thin and delegate framework work into core services.
24
27
  - HMR and invalidation use shared graph-aware services instead of runtime-specific ad hoc wiring.
25
28
 
@@ -27,19 +30,19 @@ The important ownership rules are:
27
30
 
28
31
  ```mermaid
29
32
  flowchart TD
30
- A[eco.config.ts] --> B[ConfigBuilder.build]
31
- B --> C[App build adapter]
32
- B --> D[App build manifest]
33
- B --> E[Build executor]
34
- B --> F[Dev graph service]
35
- B --> G[Host module loader boundary]
36
- G --> H[PageModuleImportService]
37
- E --> H
38
- E --> I
39
- E --> I[BrowserBundleService]
40
- H --> J[Runtime app adapter]
41
- J --> K[Bun adapter or Node adapter]
42
- D --> I
33
+ A[eco.config.ts] --> B[defineConfig / loadEcoPagesConfig]
34
+ B --> C[ConfigBuilder.build]
35
+ C --> D[App build adapter]
36
+ C --> E[App build manifest]
37
+ C --> F[Build executor]
38
+ C --> G[Dev graph service]
39
+ C --> H[Host module loader boundary]
40
+ H --> I[PageModuleImportService]
41
+ F --> I
42
+ F --> J[BrowserBundleService]
43
+ I --> K[Runtime app adapter]
44
+ K --> L[Bun adapter or Node adapter]
45
+ E --> J
43
46
  ```
44
47
 
45
48
  ### Development Invalidation And HMR Flow
@@ -50,7 +53,11 @@ flowchart TD
50
53
  B --> C[DevelopmentInvalidationService]
51
54
  C --> D{Change kind}
52
55
  D -->|Route or server source| E[Invalidate server modules]
53
- D -->|Public or include| F[Reload browser]
56
+ D -->|Additional watch| E
57
+ D -->|Config or dotenv| R[Restart dev process]
58
+ E --> N[Notify processors]
59
+ N --> F[Reload browser]
60
+ D -->|Public asset| F
54
61
  D -->|Processor-owned asset| G[Notify processor only]
55
62
  D -->|HMR-eligible source| H[Core HMR manager]
56
63
  H --> I[Strategy selection]
@@ -71,6 +78,8 @@ The manager/orchestration layer is core-owned, but framework-specific strategies
71
78
  - `ConfigBuilder` seeds one app-owned build ownership path, adapter, manifest, executor, dev graph, and runtime registry.
72
79
  - `BrowserBundleService` is the shared browser build seam used by HMR and asset-oriented browser output paths.
73
80
  - `ServerModuleTranspiler` is the shared server-side source loading seam used by runtime bootstrap and HMR metadata loading.
81
+ - `RouteRegistry` gives exact and dynamic Pages priority over catch-alls, then selects the most specific matching catch-all prefix.
82
+ - Browser runtime package entries resolve from the application root with ESM import conditions, so framework-local packages cannot shadow app dependencies.
74
83
  - `createApp()` stays the universal runtime entrypoint, while Vite and Nitro hosts own their advanced dev and build workflows.
75
84
  - One bundled adapter is the default bundler. Vite-based apps route through the `ViteHostBuildAdapter` boundary marker instead.
76
85
 
@@ -83,7 +92,7 @@ Use this package README as the top-level map, then drill into the focused subsys
83
92
  - `src/build/README.md`: build adapter, executor, development build coordination, and standalone Node server packaging
84
93
  - `src/services/README.md`: cross-cutting runtime services and orchestration helpers
85
94
  - `src/adapters/README.md`: Bun, Node, and shared adapter boundaries
86
- - `src/dev/README.md`: dev transform server and on-demand client delivery
95
+ - `src/dev/README.md`: dev transform server, on-demand client delivery, and invalidation during compilation
87
96
  - `src/hmr/README.md`: HMR strategy and update-layer ownership
88
97
  - `src/router/README.md`: route discovery, matching, and browser navigation coordination
89
98
  - `src/route-renderer/README.md`: rendering orchestration and dependency resolution
@@ -112,34 +121,31 @@ The Ecopages architecture revolves around an `eco.config.ts` file and an applica
112
121
 
113
122
  ### 1. Configuration (`eco.config.ts`)
114
123
 
115
- Configure your integratons, processors, and default metadata. Ecopages uses a builder pattern:
124
+ Configure your integrations, processors, and default metadata:
116
125
 
117
126
  ```typescript
118
- import { ConfigBuilder } from '@ecopages/core/config-builder';
127
+ import { defineConfig } from '@ecopages/core/config';
119
128
  import { ecopagesJsxPlugin } from '@ecopages/ecopages-jsx';
120
129
 
121
- const config = await new ConfigBuilder()
122
- .setRootDir(import.meta.dirname)
123
- .setBaseUrl(import.meta.env.ECOPAGES_BASE_URL ?? 'http://localhost:3000')
124
- .setDefaultMetadata({
130
+ export default defineConfig({
131
+ rootDir: import.meta.dirname,
132
+ baseUrl: process.env.ECOPAGES_BASE_URL ?? 'http://localhost:3000',
133
+ defaultMetadata: {
125
134
  title: 'My Ecopages Site',
126
135
  description: 'Built with Ecopages',
127
- })
128
- .setIntegrations([ecopagesJsxPlugin()])
129
- .build();
130
-
131
- export default config;
136
+ },
137
+ integrations: [ecopagesJsxPlugin()],
138
+ });
132
139
  ```
133
140
 
134
141
  ### 2. Application Entry (`app.ts`)
135
142
 
136
- Start the application using `createApp`. It will choose the Bun adapter when Bun is available and fall back to Node otherwise.
143
+ Start the application using `createApp`. It automatically resolves and loads `eco.config.ts` from the project root and selects the appropriate runtime adapter (Bun when available, Node otherwise):
137
144
 
138
145
  ```typescript
139
146
  import { createApp } from '@ecopages/core/create-app';
140
- import appConfig from './eco.config';
141
147
 
142
- const app = await createApp({ appConfig });
148
+ const app = await createApp();
143
149
 
144
150
  await app.start();
145
151
  ```
@@ -232,14 +238,26 @@ Standalone response helpers (`json`, `html`, `redirect`) share the same body emi
232
238
 
233
239
  Register a prebuilt handler with `app.add()`. Use `app.get(path, handler)` only when defining the route inline in `app.ts`.
234
240
 
241
+ ### 6. Error pages
242
+
243
+ Filesystem `src/pages/404.*` and `500.*` take precedence. For explicit-route apps, register views on the app:
244
+
245
+ ```typescript
246
+ app.notFound('./src/views/not-found.kita');
247
+ app.serverError('./src/views/server-error.kita');
248
+ ```
249
+
250
+ String and URL view paths passed to `app.static()`, `app.notFound()`, and `app.serverError()` load through the server-module transpiler. Raw dynamic `import()` skips component-identity transforms.
251
+
252
+ When no custom page is configured, built-in HTML defaults are served instead.
253
+
235
254
  Attach the handler in your `app.ts` entry:
236
255
 
237
256
  ```typescript
238
257
  import { createApp } from '@ecopages/core/create-app';
239
258
  import { helloWorld } from './handlers/hello';
240
- import appConfig from './eco.config';
241
259
 
242
- const app = await createApp({ appConfig });
260
+ const app = await createApp();
243
261
 
244
262
  app.add(helloWorld);
245
263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecopages/core",
3
- "version": "0.2.0-rc.1",
3
+ "version": "0.2.0-rc.10",
4
4
  "description": "Core package for Ecopages",
5
5
  "keywords": [
6
6
  "ecopages",
@@ -10,6 +10,9 @@
10
10
  "license": "MIT",
11
11
  "main": "./src/index.js",
12
12
  "type": "module",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
13
16
  "sideEffects": false,
14
17
  "repository": {
15
18
  "type": "git",
@@ -17,7 +20,8 @@
17
20
  "directory": "packages/core"
18
21
  },
19
22
  "dependencies": {
20
- "@ecopages/file-system": "0.2.0-rc.1",
23
+ "@clack/prompts": "^1.7.0",
24
+ "@ecopages/file-system": "0.2.0-rc.10",
21
25
  "@ecopages/logger": "^0.2.3",
22
26
  "@ecopages/scripts-injector": "^0.1.5",
23
27
  "@oxc-project/runtime": "0.141.0",
@@ -31,7 +35,7 @@
31
35
  "@standard-schema/utils": "^0.3.0"
32
36
  },
33
37
  "peerDependencies": {
34
- "@ecopages/dev-toolbar": "0.2.0-rc.1"
38
+ "@ecopages/dev-toolbar": "0.2.0-rc.10"
35
39
  },
36
40
  "peerDependenciesMeta": {
37
41
  "@ecopages/dev-toolbar": {
@@ -54,6 +58,18 @@
54
58
  "types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
55
59
  "default": "./src/route-renderer/orchestration/integration-renderer.js"
56
60
  },
61
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader": {
62
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts",
63
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js"
64
+ },
65
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer": {
66
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts",
67
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js"
68
+ },
69
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint": {
70
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts",
71
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js"
72
+ },
57
73
  "./route-renderer/orchestration/string-markup-renderer": {
58
74
  "types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
59
75
  "default": "./src/route-renderer/orchestration/string-markup-renderer.js"
@@ -138,6 +154,10 @@
138
154
  "types": "./src/config/config-builder.d.ts",
139
155
  "default": "./src/config/config-builder.js"
140
156
  },
157
+ "./config": {
158
+ "types": "./src/config/index.d.ts",
159
+ "default": "./src/config/index.js"
160
+ },
141
161
  "./constants": {
142
162
  "types": "./src/config/constants.d.ts",
143
163
  "default": "./src/config/constants.js"
@@ -182,6 +202,11 @@
182
202
  "types": "./src/hmr/client/hmr-runtime.d.ts",
183
203
  "default": "./src/hmr/client/hmr-runtime.js"
184
204
  },
205
+ "./dev/development-restart": {
206
+ "import": "./src/dev/development-restart.js",
207
+ "types": "./src/dev/development-restart.d.ts",
208
+ "default": "./src/dev/development-restart.js"
209
+ },
185
210
  "./dev/host-runtime": {
186
211
  "types": "./src/dev/host-runtime.d.ts",
187
212
  "default": "./src/dev/host-runtime.js"
@@ -346,6 +371,18 @@
346
371
  "types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
347
372
  "default": "./src/route-renderer/orchestration/integration-renderer.js"
348
373
  },
374
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.ts": {
375
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts",
376
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js"
377
+ },
378
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.ts": {
379
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts",
380
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js"
381
+ },
382
+ "./route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.ts": {
383
+ "types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts",
384
+ "default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js"
385
+ },
349
386
  "./route-renderer/orchestration/string-markup-renderer.ts": {
350
387
  "types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
351
388
  "default": "./src/route-renderer/orchestration/string-markup-renderer.js"
@@ -430,6 +467,10 @@
430
467
  "types": "./src/config/config-builder.d.ts",
431
468
  "default": "./src/config/config-builder.js"
432
469
  },
470
+ "./config.ts": {
471
+ "types": "./src/config/index.d.ts",
472
+ "default": "./src/config/index.js"
473
+ },
433
474
  "./constants.ts": {
434
475
  "types": "./src/config/constants.d.ts",
435
476
  "default": "./src/config/constants.js"
@@ -474,6 +515,11 @@
474
515
  "types": "./src/hmr/client/hmr-runtime.d.ts",
475
516
  "default": "./src/hmr/client/hmr-runtime.js"
476
517
  },
518
+ "./dev/development-restart.ts": {
519
+ "import": "./src/dev/development-restart.js",
520
+ "types": "./src/dev/development-restart.d.ts",
521
+ "default": "./src/dev/development-restart.js"
522
+ },
477
523
  "./dev/host-runtime.ts": {
478
524
  "types": "./src/dev/host-runtime.d.ts",
479
525
  "default": "./src/dev/host-runtime.js"
@@ -631,4 +677,4 @@
631
677
  }
632
678
  },
633
679
  "types": "./src/index.d.ts"
634
- }
680
+ }
@@ -27,7 +27,7 @@ They are not responsible for:
27
27
  - `shared/`: runtime-neutral adapter helpers used by both hosts, clustered by concern:
28
28
  - `shared/http/` — API response builders, request pipeline, middleware runner, define-api helpers, explicit-static and filesystem matchers
29
29
  - `shared/hmr/` — HMR HTML inject helpers, shared HMR manager, entrypoint registrar
30
- - `shared/runtime/` — shared server adapter, route handler, application adapter, static builder, port/bootstrap utilities
30
+ - `shared/runtime/` — shared server adapter, route handler, application adapter, static builder, port/bootstrap utilities (`PortManager` on dev and preview bind, Clack confirm on TTY port collisions)
31
31
  - `shared/ws/` — WinterCG WebSocket lifecycle helpers and Node HTTP upgrade bridge (Bun-specific user WS lifecycle lives under `bun/`)
32
32
 
33
33
  ## Ownership Boundary
@@ -41,3 +41,5 @@ Core services still own:
41
41
  - server loading
42
42
  - invalidation classification
43
43
  - route rendering orchestration
44
+
45
+ Semantic 404/500 page selection and rendering belongs to `src/services/error-pages/`; adapters only turn its rendered body into runtime responses.
@@ -8,8 +8,9 @@
8
8
  */
9
9
  import type { SourceModuleLoader } from '../../services/module-loading/module-loading-types.js';
10
10
  import type { EcoPagesAppConfig } from '../../types/internal-types.js';
11
- import type { ApiHandler, ApiHandlerContext, ErrorHandler, Middleware, RouteOptions, StaticRoute, ViewLoader, EcopagesRouteInfo } from '../../types/public-types.js';
11
+ import type { ApiHandler, ApiHandlerContext, ErrorHandler, Middleware, RouteOptions, StaticRoute, ViewLoader, ErrorPageLoaders, ErrorPageTemplateProps, EcopagesRouteInfo } from '../../types/public-types.js';
12
12
  import type { EcopagesWebSocketHandler } from '../../types/public-types.js';
13
+ import { type HttpErrorPageStatus } from '../../errors/http-error-page-contract.js';
13
14
  import { type EcopagesRuntimeLabel } from '../../dev/runtime-server-started-message.js';
14
15
  import { type ReturnParseCliArgs } from '../../utils/parse-cli-args.js';
15
16
  /**
@@ -105,6 +106,7 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
105
106
  protected runtimeOptions: ApplicationRuntimeOptions;
106
107
  protected apiHandlers: ApiHandler[];
107
108
  protected staticRoutes: StaticRoute[];
109
+ protected errorPageLoaders: ErrorPageLoaders;
108
110
  protected errorHandler?: ErrorHandler;
109
111
  /**
110
112
  * App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
@@ -186,21 +188,41 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
186
188
  * Register a view for static generation at build time.
187
189
  * The view must have staticPaths defined for dynamic routes.
188
190
  *
189
- * Uses a loader function to enable HMR in development.
191
+ * String and URL inputs load through the server-module transpiler so HMR and
192
+ * component identity transforms remain active in development.
190
193
  *
191
194
  * @param path - URL path pattern (e.g., '/posts/:slug')
192
- * @param loader - A function that dynamically imports the eco.page view module
195
+ * @param loader - A view loader function, source path, or URL for the eco.page view module
193
196
  * @example
194
197
  * ```typescript
195
- * app.static('/login', () => import('./src/views/login.kita'))
196
- * app.static('/posts/:slug', () => import('./src/views/post-view.kita'))
198
+ * app.static('/login', './src/views/login.kita')
199
+ * app.static('/posts/:slug', './src/views/post-view.kita')
197
200
  * ```
198
201
  */
199
- static<P>(path: string, loader: ViewLoader<P>): this;
202
+ static<P>(path: string, loader: ViewLoader<P> | string | URL): this;
203
+ private resolveViewLoader;
200
204
  /**
201
205
  * Get all registered static routes
202
206
  */
203
207
  getStaticRoutes(): StaticRoute[];
208
+ /**
209
+ * Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
210
+ * file exists.
211
+ */
212
+ errorPage(status: HttpErrorPageStatus, loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
213
+ badRequest(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
214
+ unauthorized(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
215
+ forbidden(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
216
+ /**
217
+ * Registers the not-found page used when no filesystem `pages/404.*` file exists.
218
+ */
219
+ notFound(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
220
+ conflict(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
221
+ /**
222
+ * Registers the server-error page used when no filesystem `pages/500.*` file exists.
223
+ */
224
+ serverError(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
225
+ getErrorPageLoaders(): ErrorPageLoaders;
204
226
  /**
205
227
  * Register a WebSocket handler for the given path pattern.
206
228
  *
@@ -8,12 +8,15 @@
8
8
  */
9
9
  import { appLogger } from '../../global/app-logger.js';
10
10
  import { getAppModuleLoader, setAppHostModuleLoader, } from '../../services/module-loading/app-server-module-transpiler.service.js';
11
+ import { createViewModuleLoader } from '../../services/module-loading/view-module-loader.js';
11
12
  import { getHostModuleLoader } from '../../services/module-loading/host-module-loader-registry.js';
12
13
  import { invariant } from '../../utils/invariant.js';
14
+ import { ERROR_PAGE_KIND_BY_STATUS } from '../../errors/http-error-page-contract.js';
13
15
  import { fileSystem } from '@ecopages/file-system';
14
16
  import { formatRuntimeServerStartedMessage, } from '../../dev/runtime-server-started-message.js';
15
17
  import { parseCliArgs } from '../../utils/parse-cli-args.js';
16
18
  import { startupTrace } from '../../diagnostics/startup-trace.js';
19
+ import { ECOPAGES_DEV_RESTART_REASON_ENV } from '../../dev/development-restart.js';
17
20
  /**
18
21
  * Abstract base class for application adapters across different runtimes
19
22
  */
@@ -24,6 +27,7 @@ export class AbstractApplicationAdapter {
24
27
  runtimeOptions;
25
28
  apiHandlers = [];
26
29
  staticRoutes = [];
30
+ errorPageLoaders = {};
27
31
  errorHandler;
28
32
  /**
29
33
  * App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
@@ -94,26 +98,70 @@ export class AbstractApplicationAdapter {
94
98
  * Register a view for static generation at build time.
95
99
  * The view must have staticPaths defined for dynamic routes.
96
100
  *
97
- * Uses a loader function to enable HMR in development.
101
+ * String and URL inputs load through the server-module transpiler so HMR and
102
+ * component identity transforms remain active in development.
98
103
  *
99
104
  * @param path - URL path pattern (e.g., '/posts/:slug')
100
- * @param loader - A function that dynamically imports the eco.page view module
105
+ * @param loader - A view loader function, source path, or URL for the eco.page view module
101
106
  * @example
102
107
  * ```typescript
103
- * app.static('/login', () => import('./src/views/login.kita'))
104
- * app.static('/posts/:slug', () => import('./src/views/post-view.kita'))
108
+ * app.static('/login', './src/views/login.kita')
109
+ * app.static('/posts/:slug', './src/views/post-view.kita')
105
110
  * ```
106
111
  */
107
112
  static(path, loader) {
108
- this.staticRoutes.push({ path, loader });
113
+ const resolvedLoader = this.resolveViewLoader(loader);
114
+ this.staticRoutes.push({ path, loader: resolvedLoader });
109
115
  return this;
110
116
  }
117
+ resolveViewLoader(loader) {
118
+ return typeof loader === 'string' || loader instanceof URL
119
+ ? createViewModuleLoader(this.appConfig, loader)
120
+ : loader;
121
+ }
111
122
  /**
112
123
  * Get all registered static routes
113
124
  */
114
125
  getStaticRoutes() {
115
126
  return this.staticRoutes;
116
127
  }
128
+ /**
129
+ * Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
130
+ * file exists.
131
+ */
132
+ errorPage(status, loader) {
133
+ const kind = ERROR_PAGE_KIND_BY_STATUS[status];
134
+ const resolvedLoader = this.resolveViewLoader(loader);
135
+ this.errorPageLoaders = { ...this.errorPageLoaders, [kind]: resolvedLoader };
136
+ return this;
137
+ }
138
+ badRequest(loader) {
139
+ return this.errorPage(400, loader);
140
+ }
141
+ unauthorized(loader) {
142
+ return this.errorPage(401, loader);
143
+ }
144
+ forbidden(loader) {
145
+ return this.errorPage(403, loader);
146
+ }
147
+ /**
148
+ * Registers the not-found page used when no filesystem `pages/404.*` file exists.
149
+ */
150
+ notFound(loader) {
151
+ return this.errorPage(404, loader);
152
+ }
153
+ conflict(loader) {
154
+ return this.errorPage(409, loader);
155
+ }
156
+ /**
157
+ * Registers the server-error page used when no filesystem `pages/500.*` file exists.
158
+ */
159
+ serverError(loader) {
160
+ return this.errorPage(500, loader);
161
+ }
162
+ getErrorPageLoaders() {
163
+ return this.errorPageLoaders;
164
+ }
117
165
  /**
118
166
  * Register a WebSocket handler for the given path pattern.
119
167
  *
@@ -221,6 +269,11 @@ export class AbstractApplicationAdapter {
221
269
  async notifyListening(origin) {
222
270
  const normalizedOrigin = origin.replace(/\/$/, '');
223
271
  startupTrace.markServerListening();
272
+ const restartReason = process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
273
+ if (restartReason) {
274
+ appLogger.info(`Development server restarted (${restartReason}).`);
275
+ delete process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
276
+ }
224
277
  if (!this.onAppStartCallback) {
225
278
  this.logServerStarted(normalizedOrigin);
226
279
  return;
@@ -4,59 +4,77 @@ export function normalizeSegmentPath(pathname) {
4
4
  }
5
5
  return pathname;
6
6
  }
7
+ function tryMatchCatchAllSegment(patternSegment, state) {
8
+ if (!patternSegment.startsWith('[...') || !patternSegment.endsWith(']')) {
9
+ return null;
10
+ }
11
+ const paramName = patternSegment.slice(4, -1);
12
+ state.params[paramName] = state.pathSegments.slice(state.pathIndex);
13
+ return state.params;
14
+ }
15
+ function tryMatchDynamicSegment(patternSegment, pathSegment, state) {
16
+ if (patternSegment.startsWith(':')) {
17
+ state.params[patternSegment.slice(1)] = pathSegment;
18
+ state.patternIndex++;
19
+ state.pathIndex++;
20
+ return true;
21
+ }
22
+ if (patternSegment.startsWith('[') && patternSegment.endsWith(']')) {
23
+ state.params[patternSegment.slice(1, -1)] = pathSegment;
24
+ state.patternIndex++;
25
+ state.pathIndex++;
26
+ return true;
27
+ }
28
+ return false;
29
+ }
30
+ function matchTrailingCatchAll(state) {
31
+ const remaining = state.patternSegments.slice(state.patternIndex);
32
+ const catchAll = remaining[0];
33
+ if (remaining.length !== 1 || (catchAll !== '*' && !(catchAll.startsWith('[...') && catchAll.endsWith(']')))) {
34
+ return null;
35
+ }
36
+ if (catchAll.startsWith('[...')) {
37
+ const paramName = catchAll.slice(4, -1);
38
+ state.params[paramName] = [];
39
+ }
40
+ return state.params;
41
+ }
7
42
  export function matchApiPathPattern(pattern, pathname) {
8
43
  const normalizedPattern = normalizeSegmentPath(pattern);
9
44
  const normalizedPathname = normalizeSegmentPath(pathname);
10
- const patternSegments = normalizedPattern.split('/').filter(Boolean);
11
- const pathSegments = normalizedPathname.split('/').filter(Boolean);
12
- const params = {};
13
- let patternIndex = 0;
14
- let pathIndex = 0;
15
- while (patternIndex < patternSegments.length && pathIndex < pathSegments.length) {
16
- const patternSegment = patternSegments[patternIndex];
17
- const pathSegment = pathSegments[pathIndex];
45
+ const state = {
46
+ patternSegments: normalizedPattern.split('/').filter(Boolean),
47
+ pathSegments: normalizedPathname.split('/').filter(Boolean),
48
+ params: {},
49
+ patternIndex: 0,
50
+ pathIndex: 0,
51
+ };
52
+ while (state.patternIndex < state.patternSegments.length && state.pathIndex < state.pathSegments.length) {
53
+ const patternSegment = state.patternSegments[state.patternIndex];
54
+ const pathSegment = state.pathSegments[state.pathIndex];
18
55
  if (patternSegment === '*') {
19
- return params;
20
- }
21
- if (patternSegment.startsWith('[...') && patternSegment.endsWith(']')) {
22
- const paramName = patternSegment.slice(4, -1);
23
- params[paramName] = pathSegments.slice(pathIndex);
24
- return params;
56
+ return state.params;
25
57
  }
26
- if (patternSegment.startsWith(':')) {
27
- params[patternSegment.slice(1)] = pathSegment;
28
- patternIndex++;
29
- pathIndex++;
30
- continue;
58
+ const catchAllMatch = tryMatchCatchAllSegment(patternSegment, state);
59
+ if (catchAllMatch) {
60
+ return catchAllMatch;
31
61
  }
32
- if (patternSegment.startsWith('[') && patternSegment.endsWith(']')) {
33
- params[patternSegment.slice(1, -1)] = pathSegment;
34
- patternIndex++;
35
- pathIndex++;
62
+ if (tryMatchDynamicSegment(patternSegment, pathSegment, state)) {
36
63
  continue;
37
64
  }
38
65
  if (patternSegment !== pathSegment) {
39
66
  return null;
40
67
  }
41
- patternIndex++;
42
- pathIndex++;
68
+ state.patternIndex++;
69
+ state.pathIndex++;
43
70
  }
44
- if (patternIndex < patternSegments.length) {
45
- const remaining = patternSegments.slice(patternIndex);
46
- const catchAll = remaining[0];
47
- if (remaining.length === 1 && (catchAll === '*' || (catchAll.startsWith('[...') && catchAll.endsWith(']')))) {
48
- if (catchAll.startsWith('[...')) {
49
- const paramName = catchAll.slice(4, -1);
50
- params[paramName] = [];
51
- }
52
- return params;
53
- }
54
- return null;
71
+ if (state.patternIndex < state.patternSegments.length) {
72
+ return matchTrailingCatchAll(state);
55
73
  }
56
- if (pathIndex < pathSegments.length) {
74
+ if (state.pathIndex < state.pathSegments.length) {
57
75
  return null;
58
76
  }
59
- return params;
77
+ return state.params;
60
78
  }
61
79
  export function scoreApiPathPattern(pattern) {
62
80
  const segments = normalizeSegmentPath(pattern).split('/').filter(Boolean);
@@ -36,6 +36,13 @@ export interface ServerAdapterResult {
36
36
  }) => Promise<string | undefined>;
37
37
  servePreviewOnly: () => Promise<string | undefined>;
38
38
  dispose(): Promise<void>;
39
+ /**
40
+ * Updates listen metadata after the runtime binds its actual port.
41
+ */
42
+ applyBoundPort: (input: {
43
+ port: number;
44
+ runtimeOrigin: string;
45
+ }) => void;
39
46
  /**
40
47
  * Lists static-generation routes for app-start consumers.
41
48
  *
@@ -55,6 +62,13 @@ export declare abstract class AbstractServerAdapter<TOptions extends ServerAdapt
55
62
  protected serveOptions: TOptions['serveOptions'];
56
63
  protected runtimeOrigin: string;
57
64
  constructor(options: TOptions);
65
+ /**
66
+ * Updates listen metadata after the runtime binds its actual port.
67
+ */
68
+ applyBoundPort(input: {
69
+ port: number;
70
+ runtimeOrigin: string;
71
+ }): void;
58
72
  /**
59
73
  * Initialize the server adapter
60
74
  */
@@ -20,4 +20,14 @@ export class AbstractServerAdapter {
20
20
  this.serveOptions = options.serveOptions || {};
21
21
  this.runtimeOrigin = options.runtimeOrigin;
22
22
  }
23
+ /**
24
+ * Updates listen metadata after the runtime binds its actual port.
25
+ */
26
+ applyBoundPort(input) {
27
+ this.runtimeOrigin = input.runtimeOrigin;
28
+ this.serveOptions = {
29
+ ...this.serveOptions,
30
+ port: input.port,
31
+ };
32
+ }
23
33
  }