@ecopages/core 0.3.0 → 0.3.2

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 (201) hide show
  1. package/README.md +2 -2
  2. package/package.json +3 -3
  3. package/src/adapters/node/create-app.d.ts +40 -11
  4. package/src/adapters/node/create-app.js +95 -69
  5. package/src/adapters/node/dev-session.js +0 -1
  6. package/src/adapters/node/http-request-bridge.d.ts +4 -0
  7. package/src/adapters/node/http-request-bridge.js +9 -1
  8. package/src/adapters/node/runtime-host.d.ts +28 -6
  9. package/src/adapters/node/runtime-host.js +35 -9
  10. package/src/adapters/node/server-adapter.d.ts +10 -35
  11. package/src/adapters/node/server-adapter.js +21 -58
  12. package/src/adapters/shared/hmr/hmr-manager.d.ts +21 -7
  13. package/src/adapters/shared/hmr/hmr-manager.js +58 -70
  14. package/src/adapters/shared/http/api-request-pipeline.d.ts +3 -12
  15. package/src/adapters/shared/http/api-request-pipeline.js +7 -7
  16. package/src/adapters/shared/http/dist-file-handler.d.ts +16 -0
  17. package/src/adapters/shared/http/dist-file-handler.js +172 -0
  18. package/src/adapters/shared/http/explicit-static-route-matcher.js +2 -1
  19. package/src/adapters/shared/http/fs-server-response-matcher.js +3 -2
  20. package/src/adapters/shared/runtime/bind-runtime-server.d.ts +5 -7
  21. package/src/adapters/shared/runtime/bind-runtime-server.js +8 -12
  22. package/src/adapters/shared/runtime/copy-runtime-public-dir.js +10 -9
  23. package/src/adapters/shared/runtime/port-manager.d.ts +8 -11
  24. package/src/adapters/shared/runtime/port-manager.js +19 -30
  25. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +6 -9
  26. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +2 -5
  27. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +1 -3
  28. package/src/adapters/shared/runtime/server-request-pipeline.js +1 -5
  29. package/src/adapters/shared/runtime/server-static-builder.d.ts +3 -3
  30. package/src/adapters/shared/runtime/server-static-builder.js +3 -3
  31. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +2 -1
  32. package/src/adapters/shared/ws/websocket-lifecycle.d.ts +5 -6
  33. package/src/adapters/shared/ws/websocket-lifecycle.js +1 -2
  34. package/src/assets/app-browser-client-build.js +1 -2
  35. package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +8 -8
  36. package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +4 -4
  37. package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +12 -8
  38. package/src/assets/asset-processing-service/processors/script/file-script.processor.js +36 -16
  39. package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +11 -6
  40. package/src/assets/browser-asset-output.d.ts +19 -0
  41. package/src/assets/browser-asset-output.js +30 -0
  42. package/src/assets/hashed-browser-asset.d.ts +8 -6
  43. package/src/assets/hashed-browser-asset.js +8 -6
  44. package/src/build/build-adapter.d.ts +2 -19
  45. package/src/build/build-adapter.js +0 -21
  46. package/src/build/build-graph.js +2 -2
  47. package/src/build/cache/cache-keys.d.ts +0 -3
  48. package/src/build/cache/cache-keys.js +0 -14
  49. package/src/build/cache/pages-unified-graph-build.js +2 -17
  50. package/src/build/contracts/build-contracts.d.ts +0 -3
  51. package/src/build/preserve-import-meta-transform.js +2 -2
  52. package/src/build/rolldown/app-package-declarations.js +3 -3
  53. package/src/build/rolldown/rolldown-adapter-helpers.js +3 -3
  54. package/src/build/rolldown/rolldown-build-adapter.d.ts +0 -1
  55. package/src/build/rolldown/rolldown-build-adapter.js +1 -2
  56. package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +1 -2
  57. package/src/build/rolldown/rolldown-build-invocation-metrics.js +5 -12
  58. package/src/build/rolldown/server-side-css-shim-plugin.js +3 -3
  59. package/src/build/runtime/build-queue.d.ts +8 -13
  60. package/src/build/runtime/build-queue.js +6 -17
  61. package/src/build/server/app-module-loader.service.d.ts +1 -1
  62. package/src/build/server/app-module-loader.service.js +0 -2
  63. package/src/build/server/page-module-import.service.d.ts +2 -3
  64. package/src/build/server/page-module-import.service.js +3 -4
  65. package/src/build/server-bundle-deploy-manifest.d.ts +5 -0
  66. package/src/build/server-bundle-deploy-manifest.js +15 -1
  67. package/src/build/server-bundle-publication.js +4 -5
  68. package/src/build.d.ts +2 -2
  69. package/src/build.js +2 -2
  70. package/src/config/assembly/app-runtime.d.ts +2 -2
  71. package/src/config/assembly/app-runtime.js +2 -2
  72. package/src/config/assembly/finalize-config.d.ts +4 -4
  73. package/src/config/assembly/finalize-config.js +4 -5
  74. package/src/config/config-module-files.js +2 -3
  75. package/src/config/internal-types.d.ts +0 -7
  76. package/src/config/user-config-types.d.ts +0 -4
  77. package/src/diagnostics/request-pipeline-metrics.d.ts +3 -3
  78. package/src/diagnostics/request-pipeline-metrics.js +4 -4
  79. package/src/diagnostics/startup-trace.js +2 -5
  80. package/src/errors/http-error.d.ts +2 -2
  81. package/src/errors/http-error.js +4 -4
  82. package/src/hmr/client/hmr-runtime.js +16 -7
  83. package/src/hmr/client/module-update.d.ts +7 -0
  84. package/src/hmr/client/module-update.js +21 -4
  85. package/src/hmr/hmr-strategy.d.ts +0 -3
  86. package/src/hmr/hmr-strategy.js +0 -3
  87. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -3
  88. package/src/hmr/strategies/js-hmr-strategy.js +3 -6
  89. package/src/html-pages/html-page-module-scripts.js +4 -3
  90. package/src/html-pages/html-page-renderer.js +2 -3
  91. package/src/plugins/alias-resolver-cache.d.ts +4 -3
  92. package/src/plugins/alias-resolver-cache.js +4 -3
  93. package/src/plugins/component-import-discovery.js +4 -4
  94. package/src/plugins/eco-component-meta-plugin.d.ts +10 -1
  95. package/src/plugins/eco-component-meta-plugin.js +66 -10
  96. package/src/plugins/foreign-jsx-override-plugin.js +4 -3
  97. package/src/plugins/tsconfig-import-resolver.js +12 -12
  98. package/src/route-renderer/error-pages/default-error-pages.js +2 -1
  99. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -1
  100. package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +0 -1
  101. package/src/route-renderer/orchestration/integration-renderer.d.ts +10 -5
  102. package/src/route-renderer/orchestration/integration-renderer.js +13 -14
  103. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -23
  104. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +0 -29
  105. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +10 -32
  106. package/src/route-renderer/page-loading/ecopages-virtual-imports.js +2 -2
  107. package/src/route-renderer/page-loading/page-dependency-bundling.js +5 -5
  108. package/src/route-renderer/page-loading/page-module-loader.js +1 -1
  109. package/src/route-renderer/route-renderer.d.ts +2 -5
  110. package/src/route-renderer/route-renderer.js +2 -4
  111. package/src/router/client/link-navigation-policy.d.ts +4 -1
  112. package/src/router/client/link-navigation-policy.js +20 -6
  113. package/src/router/server/route-registry.d.ts +0 -1
  114. package/src/router/server/route-registry.js +3 -13
  115. package/src/router/server/segment-path-matcher.d.ts +12 -0
  116. package/src/router/server/segment-path-matcher.js +30 -0
  117. package/src/static-site-generator/static-site-generator.d.ts +0 -5
  118. package/src/static-site-generator/static-site-generator.js +2 -15
  119. package/src/types/contracts.d.ts +17 -27
  120. package/src/types/public-types.d.ts +1 -1
  121. package/src/utils/format-error-chain.d.ts +9 -0
  122. package/src/utils/format-error-chain.js +20 -0
  123. package/src/utils/invariant.d.ts +6 -1
  124. package/src/utils/invariant.js +7 -2
  125. package/src/watchers/project-watcher.d.ts +20 -1
  126. package/src/watchers/project-watcher.js +40 -9
  127. package/src/watchers/workspace-package-watch-roots.js +5 -5
  128. package/src/adapters/README.md +0 -58
  129. package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +0 -28
  130. package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +0 -53
  131. package/src/adapters/shared/runtime/runtime-host.d.ts +0 -15
  132. package/src/adapters/shared/runtime/runtime-host.js +0 -1
  133. package/src/assets/README.md +0 -35
  134. package/src/build/README.md +0 -298
  135. package/src/build/server/README.md +0 -50
  136. package/src/cache/README.md +0 -5
  137. package/src/client/README.md +0 -5
  138. package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +0 -1
  139. package/src/client/navigation-scripts/navigation-scripts.test.browser.js +0 -111
  140. package/src/client/scroll.test.browser.d.ts +0 -1
  141. package/src/client/scroll.test.browser.js +0 -31
  142. package/src/client/view-transitions.test.browser.d.ts +0 -1
  143. package/src/client/view-transitions.test.browser.js +0 -53
  144. package/src/config/README.md +0 -58
  145. package/src/config/constants.d.ts +0 -1
  146. package/src/config/constants.js +0 -1
  147. package/src/dev/README.md +0 -61
  148. package/src/dev/invalidation/README.md +0 -11
  149. package/src/dev-toolbar/README.md +0 -66
  150. package/src/diagnostics/README.md +0 -11
  151. package/src/eco/README.md +0 -776
  152. package/src/errors/README.md +0 -5
  153. package/src/global/README.md +0 -5
  154. package/src/hmr/README.md +0 -64
  155. package/src/hmr/client/build-error-overlay.test.browser.d.ts +0 -1
  156. package/src/hmr/client/build-error-overlay.test.browser.js +0 -48
  157. package/src/hmr/client/hmr-runtime.test.browser.d.ts +0 -1
  158. package/src/hmr/client/hmr-runtime.test.browser.js +0 -32
  159. package/src/hmr/entrypoint-dependency-graph.d.ts +0 -12
  160. package/src/hmr/entrypoint-dependency-graph.js +0 -27
  161. package/src/hmr/hmr-file-change-prep.d.ts +0 -9
  162. package/src/hmr/hmr-file-change-prep.js +0 -11
  163. package/src/html/README.md +0 -15
  164. package/src/html-pages/README.md +0 -104
  165. package/src/islands/README.md +0 -44
  166. package/src/page-cache/README.md +0 -17
  167. package/src/plugins/README.md +0 -53
  168. package/src/route-renderer/GRAPH.md +0 -142
  169. package/src/route-renderer/README.md +0 -160
  170. package/src/route-renderer/error-pages/README.md +0 -11
  171. package/src/route-renderer/orchestration/custom-element-scripts/README.md +0 -15
  172. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +0 -39
  173. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +0 -94
  174. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +0 -35
  175. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +0 -69
  176. package/src/router/README.md +0 -160
  177. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  178. package/src/router/client/link-intent.test.browser.js +0 -33
  179. package/src/router/client/link-navigation-policy.test.browser.d.ts +0 -1
  180. package/src/router/client/link-navigation-policy.test.browser.js +0 -142
  181. package/src/router/client/navigation-commit.test.browser.d.ts +0 -1
  182. package/src/router/client/navigation-commit.test.browser.js +0 -116
  183. package/src/router/client/navigation-document.test.browser.d.ts +0 -1
  184. package/src/router/client/navigation-document.test.browser.js +0 -77
  185. package/src/router/client/navigation-head.test.browser.d.ts +0 -1
  186. package/src/router/client/navigation-head.test.browser.js +0 -101
  187. package/src/router/client/navigation-lifecycle.test.browser.d.ts +0 -1
  188. package/src/router/client/navigation-lifecycle.test.browser.js +0 -97
  189. package/src/router/client/navigation-view-transition.test.browser.d.ts +0 -1
  190. package/src/router/client/navigation-view-transition.test.browser.js +0 -189
  191. package/src/router/client/staged-stylesheets.test-fixtures.d.ts +0 -18
  192. package/src/router/client/staged-stylesheets.test-fixtures.js +0 -31
  193. package/src/static-site-generator/README.md +0 -67
  194. package/src/static-site-generator/static-site-generator.test-utils.d.ts +0 -2
  195. package/src/static-site-generator/static-site-generator.test-utils.js +0 -41
  196. package/src/types/README.md +0 -5
  197. package/src/utils/README.md +0 -7
  198. package/src/validation/README.md +0 -9
  199. package/src/watchers/README.md +0 -15
  200. package/src/watchers/project-watcher.test-helpers.d.ts +0 -60
  201. package/src/watchers/project-watcher.test-helpers.js +0 -108
@@ -1,53 +0,0 @@
1
- import { afterEach, describe, expect, it } from 'vitest';
2
- import { applyViewTransitionNames, clearViewTransitionNames, ensureRootViewTransitionStyles, navigationHasNamedViewTransitions, } from './view-transitions.js';
3
- describe('navigationHasNamedViewTransitions', () => {
4
- afterEach(() => {
5
- document.body.replaceChildren();
6
- });
7
- it('checks current or incoming document for named transition markup', () => {
8
- expect(navigationHasNamedViewTransitions(document, document)).toBe(false);
9
- document.body.innerHTML = '<div data-view-transition="x"></div>';
10
- expect(navigationHasNamedViewTransitions(document, document)).toBe(true);
11
- document.body.replaceChildren();
12
- const incoming = new DOMParser().parseFromString('<html><body><div data-view-transition="hero"></div></body></html>', 'text/html');
13
- expect(navigationHasNamedViewTransitions(document, incoming)).toBe(true);
14
- });
15
- });
16
- describe('ensureRootViewTransitionStyles', () => {
17
- afterEach(() => {
18
- document.getElementById('eco-vt-root-styles')?.remove();
19
- document.getElementById('eco-vt-dynamic-styles')?.remove();
20
- document.body.replaceChildren();
21
- });
22
- it('opts the document out of the root view-transition group without !important', () => {
23
- ensureRootViewTransitionStyles();
24
- const style = document.getElementById('eco-vt-root-styles');
25
- expect(style).not.toBeNull();
26
- expect(style?.hasAttribute('data-eco-persist')).toBe(true);
27
- expect(style?.textContent).toContain('view-transition-name: none');
28
- expect(style?.textContent).not.toContain('!important');
29
- expect(getComputedStyle(document.documentElement).viewTransitionName).toBe('none');
30
- });
31
- it('reuses a single style element', () => {
32
- ensureRootViewTransitionStyles();
33
- ensureRootViewTransitionStyles();
34
- expect(document.querySelectorAll('#eco-vt-root-styles')).toHaveLength(1);
35
- });
36
- });
37
- describe('applyViewTransitionNames with root styles', () => {
38
- afterEach(() => {
39
- document.getElementById('eco-vt-root-styles')?.remove();
40
- document.getElementById('eco-vt-dynamic-styles')?.remove();
41
- document.body.replaceChildren();
42
- });
43
- it('keeps root styles when clearing named morph styles', () => {
44
- ensureRootViewTransitionStyles();
45
- document.body.innerHTML = '<div data-view-transition="hero"></div>';
46
- applyViewTransitionNames();
47
- expect(document.getElementById('eco-vt-dynamic-styles')?.textContent).toContain('view-transition-old(hero)');
48
- expect(document.getElementById('eco-vt-root-styles')?.textContent).toContain('view-transition-name: none');
49
- clearViewTransitionNames();
50
- expect(document.getElementById('eco-vt-dynamic-styles')?.textContent).toBe('');
51
- expect(document.getElementById('eco-vt-root-styles')?.textContent).toContain('view-transition-name: none');
52
- });
53
- });
@@ -1,58 +0,0 @@
1
- # Config Loading and Assembly
2
-
3
- **Layer:** Application assembly.
4
-
5
- This directory loads `eco.config.ts` and assembles the app configuration consumed by Ecopages.
6
-
7
- ## Purpose
8
-
9
- The config layer answers one question:
10
-
11
- How does one `eco.config.ts` become one stable, app-owned runtime/build configuration?
12
-
13
- It is responsible for:
14
-
15
- - validating integration, processor, and loader registration
16
- - rejecting overlapping build-plugin names per server/browser environment, with both contributor names in the error
17
- - appending the core [HTML Pages](../html-pages/README.md) Integration after user Integrations unless one of them declares `.html`, so `.html` routes work in every app
18
- - resolving semantic paths such as `html` and `404` templates from registered Integration extensions; more than one match for a basename (for example `html.tsx` and `html.html`) is an error
19
- - creating one `AppRuntime` for each finalized app config: the Rolldown build adapter, build manifest and queue, build-input index, unified pages graph manifest, Page Browser Graph session, server invalidation counter, module loader, route-module build caches, collection server artifacts, integration activation map, runtime-asset preparation and HMR-attachment flags, HTML Page module-script and warning state, custom-element preload scopes, request-pipeline metrics, and page cache. The Development Invalidation service is created lazily once and shared by the Project Watcher and HMR manager. `origin` starts as `baseUrl` and is updated once after the server binds. `hmr` starts as `null`, is populated when the dev session creates its HMR manager, and is cleared on stop. `pageCache` stays `null` until the server adapter stores one
20
-
21
- ## Main Files
22
-
23
- - `define-config.ts`: synchronous `defineConfig()` identity for `eco.config.ts` authoring
24
- - `load-eco-config.ts`: resolves and caches the config module import; a config factory runs for each app, then every call finalizes a new app config and `AppRuntime`. Object configs with plugin instances can create one app; export a factory to create multiple apps safely.
25
- - `config-module-files.ts`: when the config is loaded from source, lists it and the project files it imports as `absolutePaths.configModuleFiles`. Packages, files outside `rootDir` and imports that do not resolve stay out. Build-input fingerprints hash these files, and `ecopages dev` restarts when any of them change, so an edit to a plugin options module the config imports takes effect like an edit to the config itself. Components imported by the config lose hot reload.
26
- - `resolve-eco-config-path.ts`: `eco.config.ts` discovery (`configFile`, `ECOPAGES_CONFIG_FILE`, the `eco.config.mjs` beside a running `.server` entry, cwd default, and the emitted config beside the selected production bundle) and `resolveUserConfigRootDir()`
27
- - `user-config-types.ts`: TypeScript contracts for `EcoPagesUserConfig` and config loader options
28
- - `server-config-bundle.ts`: emits `dist/.server/eco.config.mjs` for production server startup; like every server build request, it keeps `import.meta` of bundled modules pointing at their sources (`build/preserve-import-meta-transform.ts`)
29
-
30
- `assembly/` turns the loaded user config into one app-owned runtime and finalized config:
31
-
32
- - `assembly/finalize-config.ts`: `finalizeEcoPagesConfig(userConfig, options)`, the only finalization path. Workspace packages and tests import it from `@ecopages/core/config`; the npm build drops every `./internal/*` subpath from the published package. It applies defaults (omitted `rootDir` resolves from `cwd`; `baseUrl` falls back to `ECOPAGES_BASE_URL`, then `http://localhost:3000`; `absolutePaths.config` defaults to `<rootDir>/eco.config.ts`), runs every validation, and installs runtime state
33
- - `assembly/app-runtime.ts`: `createAppRuntime(appConfig)` builds that runtime once at the end of finalization. It owns the runtime shape and `requireAppRuntime()` accessor. A config that skipped finalization makes the accessor throw `Missing app runtime`. The server adapter, route renderer factory, and static builder take this object in their constructors.
34
- - `assembly/finalize-config.test.ts` / `assembly/app-runtime.test.ts`: finalization and runtime coverage
35
- - `load-eco-config.test.ts`: config loading coverage
36
-
37
- ## Ownership Rules
38
-
39
- - Integrations and processors declare contributions.
40
- - `finalizeEcoPagesConfig()` in `assembly/` decides ordering, validates compatibility, and installs the Rolldown adapter on the finalized app config.
41
- - Each config load creates a new finalized app config and runtime. A config factory also creates fresh integrations, processors and loaders for each app; reusing an object config with plugin instances for another app throws. Runtime startup reuses that app's config/build state; it should not recompute manifest ownership.
42
- - `EcopagesApp` shares one readiness promise across concurrent `start()` and `fetch()` calls. `stop()` disposes its Node server adapter and watch session; a later `start()` or `fetch()` creates a new adapter while continuing to use the same finalized config's `AppRuntime`.
43
- - Production startup loads the emitted config artifact recorded by the server build, even when the source config is still present.
44
-
45
- App-owned Rolldown is the only build path. Finalization installs that adapter on every config.
46
-
47
- ## Output
48
-
49
- The result of this layer is a built `EcoPagesAppConfig` with resolved absolute paths and one `appConfig.appRuntime`.
50
-
51
- That built config is then consumed by server adapters, static generation, route rendering, and HMR.
52
-
53
- ## Tests and fixtures
54
-
55
- - Production apps call `createApp()` (loads `eco.config.ts`) or pass `appConfig`, `userConfig`, or `configFile` explicitly.
56
- - In development (`--dev`), adding, changing, or removing the resolved `eco.config` module, a project file it imports, or a supported project `.env` file triggers a supervised process restart (not in-process reload). The CLI re-merges dotenv files on respawn.
57
- - `@ecopages/testing` `createTestAppConfig()` finalizes each in-memory user config independently through `finalizeEcoPagesConfig`. `loadEcoPagesConfig()` caches only the imported config module by path; it finalizes a new app config and runtime for every call.
58
- - Core fixture helpers live in `packages/core/__fixtures__/app/test-app-config.ts` (`createFixtureAppConfig`, `createFixtureApp`).
@@ -1 +0,0 @@
1
- export * from '../constants.js';
@@ -1 +0,0 @@
1
- export * from '../constants.js';
package/src/dev/README.md DELETED
@@ -1,61 +0,0 @@
1
- **Layer:** Development and HMR.
2
-
3
- Development-only browser tooling is opt-in per application.
4
-
5
- ## Development invalidation
6
-
7
- The [invalidation service](invalidation/README.md) classifies file changes and marks affected development results dirty. Each `AppRuntime` owns one instance shared by the Project Watcher and HMR manager.
8
-
9
- ## Dev toolbar
10
-
11
- - `/_dev_toolbar.js` — browser bundle built by core from `devToolbar.package` (for example `@ecopages/dev-toolbar`)
12
- - `#__ECO_DEV_MANIFEST__` — per-page dependency graph payload for the Deps panel
13
- - Build errors — the reference toolbar claims HMR error presentation; custom clients use the [build error event contract](../dev-toolbar/README.md#build-error-presentation), with an in-page fallback for unclaimed errors
14
-
15
- Public docs: [Dev toolbar](/docs/core/dev-toolbar) (built-in apps, manifest fields).
16
-
17
- Configure in `eco.config.ts`:
18
-
19
- ```ts
20
- import { defineConfig } from '@ecopages/core/config';
21
- import { devToolbar } from '@ecopages/dev-toolbar/config';
22
-
23
- export default defineConfig({ devToolbar: devToolbar() });
24
- ```
25
-
26
- For a custom client package, use `defineDevTool` from `@ecopages/core/client`.
27
-
28
- Install the client package in the app project. Core resolves it from the application root and bundles it during watch mode.
29
-
30
- Disable per project with `devToolbar: { enabled: false }`, or per process with `ECOPAGES_DEV_TOOLBAR=false` or `0`.
31
-
32
- Server wiring: [dev-toolbar/README.md](../dev-toolbar/README.md) (manifest and the toolbar runtime entry that the HMR manager bundles, serves and injects). Bring-your-own toolbars export `src/bootstrap.ts` and use the same `devToolbar.package` config key.
33
-
34
- ### Dev transform
35
-
36
- Entrypoints may be files under `srcDir` or files in workspace-linked packages. Workspace files are served at `/assets/__eco_dev__/@fs/...` so a React island from a linked package can hydrate on another Integration's page. Module URLs encode filesystem characters such as spaces, percent signs, and query or fragment delimiters and decode them before resolving the source path.
37
-
38
- Dev transform requests retry when their source changes or is invalidated during compilation. Concurrent requests share one in-flight compile per source, including across source and global invalidation; stale attempts release their slot before retrying. Only results for the current source snapshot enter the module cache, so rapid edits cannot label stale browser code with a newer source hash. A failed compile of a snapshot that changed in the meantime is retried the same way, so it is neither returned nor reported.
39
-
40
- ### Build errors of served modules
41
-
42
- When a module fails to compile, `DevTransformServer` answers 500 with the error text, records the message under the module, and calls `onTransformError` with it. `HmrManager` broadcasts that message as an HMR `error` event, which the HMR client shows in the page ([hmr/README.md](../hmr/README.md#client-events)).
43
-
44
- - The failure is recorded under the requested module, but its cause can be another file and the module can be removed, so `HmrManager.handleFileChange()` clears every recorded failure. A module that still fails records its error again on its next request. A successful request also removes its module's failure.
45
- - The module request of a fresh page load can arrive before the page's HMR socket connects, and the broadcast then reaches no one. The Node HTTP host therefore calls `sendPendingBuildErrors()` right after subscribing a socket, which sends one `error` event per recorded failure.
46
-
47
- Bare browser imports are prebundled to `/assets/vendors/<name>.<specifier-hash>.js` on the first request of each dev process. The bundle contents stay in that process's memory; Core does not write them under `dist` or reuse them from disk. A process restart rebuilds them from the installed package graph, so a change to a transitive dependency takes effect even when the importing package's version and entry file stay the same. Every vendor file, including integration runtimes with unhashed names that are written under `dist`, is served with `Cache-Control: no-cache` and a content `ETag`; browsers revalidate on each load and receive `304` while the content is unchanged.
48
-
49
- ## Additional watch paths
50
-
51
- The Project Watcher resolves each `additionalWatchPaths` entry against the root directory. A plain path is watched as given and matches itself and everything inside it. An entry containing `*` is a glob: chokidar takes only literal paths, so the pattern is split at its first segment with a glob character. The static prefix, resolved against the root directory, is the base the watcher subscribes to (`content` for `content/**/*.md`, the root directory for `**/*.config.ts`), and the rest is matched with `path.matchesGlob` against paths relative to that base, so glob characters in the root directory path never reach the matcher. A path segment starting with `.` matches only a pattern segment starting with `.`. The watcher ignores files and dot-directories reached only through a glob base unless the glob can match them, and warns when a glob's base is the filesystem root. On Windows a pattern may separate segments with `\\` or `/`.
52
-
53
- The watcher never descends into `node_modules`, `.git`, the work directory or `distDir`. chokidar reports paths with `/` on every platform, so they are normalised before the check, which keeps these folders ignored on Windows.
54
-
55
- The Project Watcher waits up to 30 seconds for its filesystem subscription to become ready. A timeout or an error before readiness closes the subscription and rejects watcher startup. Its maximum-wait timer schedules sustained change batches within one second of the first event; serialized processing can begin later when earlier work is queued.
56
-
57
- ## Process restarts
58
-
59
- The Project Watcher classifies the resolved `eco.config` module, the project files it imports (`absolutePaths.configModuleFiles`), and supported project dotenv paths separately from HMR. Under the CLI, those changes request a graceful runtime stop and a supervised child-process restart so config modules and environment values are loaded from scratch. When the restarted child exits with an error, the CLI supervisor waits for the next change in the project or a linked workspace package and launches again instead of exiting. It watches from before the restarted child launches, skipping dependencies, VCS metadata and the default work and build directories (`resolveDevelopmentRecoveryWatch`), so a fix saved while the child was loading relaunches at once. A Project Watcher with no restart callback warns and returns. Runtime entry watchers own changes to `eco.config.ts` itself when `dev:watch` is active; the Project Watcher still owns dotenv files and files the config imports. Watcher errors retain their stacks in the log.
60
-
61
- During `ecopages dev`, linked package roots resolved from the application's declared dependencies are also watched. Adding, editing, or deleting a file requests a supervised restart, reloading server imports and rebuilding browser vendors. Their `node_modules` and dot entries are skipped. Vendor bundles live only in the running process, so the restarted process builds them from the current package files. See [Project Watcher](../watchers/README.md) for discovery and restart behavior.
@@ -1,11 +0,0 @@
1
- # Development Invalidation
2
-
3
- **Layer:** Development and HMR.
4
-
5
- File-change classification and the batch entry that marks development results dirty.
6
-
7
- `DevelopmentInvalidationService.planFileChange()` classifies one path and derives its flags from a category table. One lazily created service lives on each `AppRuntime`; the Project Watcher and HMR manager use the same instance. Config files classify as `runtime-restart`, except the config module itself becomes `entry-watched-config` when a runtime entry watcher owns it. Files imported by the config, dotenv files, and linked workspace package files remain `runtime-restart`. Route files are `route-source`; other server files and recorded build inputs are `source`. A file in the recorded closure of a server route module invalidates server modules whatever its category, including a public file or processor-owned asset the module reads. A `source` file in both a server route closure and a browser entrypoint closure also reloads the browser, so an edit to a module shared by server-rendered markup and an island refreshes both copies. Other categories keep their own reload and processing behavior. Browser builds return their plugin inputs and module closures on `BuildResult`, and route-module closures are bound to their source route. HTML entries register the route closure, browser graph, processed asset, and render-shell inputs they used, and the render shell includes the HTML template's imports. Any edit evicts only the entries that recorded the file. An `additionalWatchPaths` match clears every cached HTML document, because the framework cannot infer which pages read an arbitrary watched file. The Page Browser Graph and HMR entrypoint reverse lookups use the same index. The Project Watcher owns the trailing debounce (150 ms by default) and schedules sustained batches no later than one second after their first event; file and directory events share the window, and serialized processing can begin later if earlier work is queued. `applyDevFileChanges({ changed, created, deleted })` classifies a received batch once. Runtime-restart batches return the owning path without dirtying results. When an entry watcher owns the config module, it is classified as `entry-watched-config` and omitted from the applied files; the entry watcher handles it. Remaining files mark their affected results dirty, and rebuild happens on the next request that needs a result.
8
-
9
- `created` stays separate because new Page files refresh the Route Registry. For a non-restart batch with applied files, the Project Watcher calls `applyDevFileChanges` once and runs its batch-level browser update handling once. Matching Processors receive one `onChanges` callback for the batch. Restart batches return through the runtime lifecycle without applying invalidation, Processor notification, or browser update handling.
10
-
11
- See [watchers](../../watchers/README.md) and [core](../../../README.md).
@@ -1,66 +0,0 @@
1
- # Dev toolbar (core)
2
-
3
- **Layer:** Development and HMR.
4
-
5
- Server-side wiring for the development-only in-browser inspector. Public docs: [Dev toolbar](/docs/core/dev-toolbar).
6
-
7
- ## Boundaries
8
-
9
- | Layer | Owns |
10
- | ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
11
- | **Core** | Enablement, per-route `#__ECO_DEV_MANIFEST__`, the toolbar runtime entry the HMR manager bundles, serves and injects |
12
- | **Client package** (`devToolbar.package`) | Dock UI, panels, and any extra apps |
13
- | **Integrations** | Page rendering and browser assets — not toolbar dock apps |
14
-
15
- `@ecopages/dev-toolbar` is an optional peer. Core does not import it at runtime unless `devToolbar.package` is configured. The dev manifest contract (`dev-toolbar-manifest-contract.ts`) lives in core so apps and custom toolbar clients can type the payload without installing the reference toolbar package.
16
-
17
- ## Module map
18
-
19
- | File | Role |
20
- | ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
21
- | `dev-toolbar-runtime.ts` | Describes the toolbar bundle as a dev client runtime, with its log-only failure policy |
22
- | `dev-toolbar-manifest-contract.ts` | `#__ECO_DEV_MANIFEST__` id and payload types (public: `@ecopages/core/client`; mirrored in `@ecopages/dev-toolbar` for browser bundling) |
23
- | `dev-toolbar-manifest.ts` | Builds and serializes the per-page dev manifest and its HTML contribution |
24
- | `dev-toolbar-package.ts` | Resolves `devToolbar.package` bootstrap entry (`bootstrap.js`, then `.ts`) |
25
- | `dev-toolbar-config.ts` | `isDevToolbarEnabled` — watch mode, env var, package required |
26
- | `dev-toolbar-runtime-paths.ts` | `/_dev_toolbar.js` URL and work-dir paths |
27
- | `define-dev-tool.ts` | Config helper for bring-your-own client packages |
28
- | `build-error-contract.ts` | Public error, clear, and replay event names and error payload type for custom clients |
29
-
30
- ## Build error presentation
31
-
32
- `@ecopages/core/client` exports the window event names and `BuildErrorDetail` (`{ message: string }`). Custom clients listen for cancelable `ecopages:build-error` events and call `preventDefault()` synchronously only when they present the message. Unclaimed errors use the HMR runtime's in-page fallback, including when the toolbar is disabled or has not mounted.
33
-
34
- Listen for `ecopages:build-error-clear` to reset messages and badges on any non-error HMR event. Register both listeners before dispatching `ecopages:build-error-request`: it synchronously replays active messages and rebuilds the fallback only for unclaimed messages. Remove listeners when the client unmounts. Messages may repeat; clients should deduplicate by message. Error text includes watcher and route failures as well as module compilation failures.
35
-
36
- The reference toolbar opens its Build errors app automatically, reveals stealth mode, and displays a count badge. Closing the panel keeps errors available until the next HMR update. The HMR runtime retains active messages for replay independently of fallback dismissal.
37
-
38
- ## Injection sequence
39
-
40
- 1. Route HTML is finalized with `#__ECO_DEV_MANIFEST__` appended to `<body>` (`route-html-finalization.service.ts`).
41
- 2. The HMR manager bundles the configured client package to `/_dev_toolbar.js` during watch mode and serves it, next to the HMR client, through the same bundle, asset and injection routines (`shared-hmr-manager.ts`, `hmr/dev-client-runtime.ts`).
42
- 3. The server adapter asks the manager to load its runtimes from each HTML response (`injectDevClientRuntimes`), which adds `import '/_dev_toolbar.js'` before `</html>` only after the toolbar bundle was built.
43
-
44
- A package that is not installed or fails to bundle is logged as `Could not bundle the Dev Toolbar runtime` and leaves HMR on; only a failed HMR runtime bundle disables HMR. The toolbar is gated on HMR being enabled: when the HMR runtime fails to bundle, the Node runtime disables HMR for the session and the page gets neither the toolbar script nor the `#__ECO_DEV_MANIFEST__` payload.
45
-
46
- ## Config
47
-
48
- ```ts
49
- import { defineConfig } from '@ecopages/core/config';
50
- import { devToolbar } from '@ecopages/dev-toolbar/config';
51
-
52
- export default defineConfig({ devToolbar: devToolbar() });
53
- ```
54
-
55
- Bring-your-own client:
56
-
57
- ```ts
58
- import { defineConfig } from '@ecopages/core/config';
59
- import { defineDevTool } from '@ecopages/core/client';
60
-
61
- export default defineConfig({ devToolbar: defineDevTool('@acme/my-dev-toolbar') });
62
- ```
63
-
64
- Disable per project with `devToolbar: { enabled: false }`, or per process with `ECOPAGES_DEV_TOOLBAR=false` or `0`.
65
-
66
- Parent index: [dev/README.md](../dev/README.md).
@@ -1,11 +0,0 @@
1
- # Diagnostics
2
-
3
- **Layer:** Build.
4
-
5
- This directory owns opt-in counters for page-module loading, MDX transforms, collection builds, and route-render phases, plus the startup trace.
6
-
7
- `createAppRuntime()` creates a fresh metrics state for each app. Build and render instrumentation updates that state, and the response cache coordinator serializes the same app's snapshot into the `x-ecopages-pipeline-metrics` header when metrics are enabled. Two apps in one process therefore report independent counters.
8
-
9
- Set `ECOPAGES_REQUEST_PIPELINE_METRICS=true` (or `1`), `ECOPAGES_ROLLDOWN_BUILD_METRICS=true` (or `1`), or `ECOPAGES_LOGGER_DEBUG=true` (or `1`) to enable request-pipeline metrics. With all three unset, record functions return without updating counters.
10
-
11
- `startup-trace.ts` reports the same build parallelism used by the build queue and static export. The removed `ECOPAGES_DEV_BUILD_PARALLELISM` and `ECOPAGES_DEV_HMR_PARALLELISM` variables did not configure either path.