@ecopages/core 0.3.0 → 0.3.1

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 (176) hide show
  1. package/README.md +2 -2
  2. package/package.json +3 -3
  3. package/src/adapters/node/create-app.d.ts +29 -11
  4. package/src/adapters/node/create-app.js +78 -67
  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 +23 -6
  9. package/src/adapters/node/runtime-host.js +27 -8
  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 +9 -5
  13. package/src/adapters/shared/hmr/hmr-manager.js +38 -54
  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 +5 -11
  22. package/src/adapters/shared/runtime/port-manager.d.ts +2 -11
  23. package/src/adapters/shared/runtime/port-manager.js +3 -28
  24. package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +6 -9
  25. package/src/adapters/shared/runtime/runtime-server-lifecycle.js +2 -5
  26. package/src/adapters/shared/runtime/server-request-pipeline.d.ts +1 -3
  27. package/src/adapters/shared/runtime/server-request-pipeline.js +1 -5
  28. package/src/adapters/shared/runtime/server-static-builder.d.ts +3 -3
  29. package/src/adapters/shared/runtime/server-static-builder.js +3 -3
  30. package/src/adapters/shared/ws/node-http-websocket-upgrades.js +2 -1
  31. package/src/adapters/shared/ws/websocket-lifecycle.d.ts +5 -6
  32. package/src/adapters/shared/ws/websocket-lifecycle.js +1 -2
  33. package/src/build/build-adapter.d.ts +2 -19
  34. package/src/build/build-adapter.js +0 -21
  35. package/src/build/cache/cache-keys.d.ts +0 -3
  36. package/src/build/cache/cache-keys.js +0 -14
  37. package/src/build/cache/pages-unified-graph-build.js +2 -17
  38. package/src/build/contracts/build-contracts.d.ts +0 -3
  39. package/src/build/rolldown/rolldown-build-adapter.d.ts +0 -1
  40. package/src/build/rolldown/rolldown-build-adapter.js +1 -2
  41. package/src/build/rolldown/rolldown-build-invocation-metrics.d.ts +1 -2
  42. package/src/build/rolldown/rolldown-build-invocation-metrics.js +5 -12
  43. package/src/build/runtime/build-queue.d.ts +8 -13
  44. package/src/build/runtime/build-queue.js +6 -17
  45. package/src/build/server/app-module-loader.service.d.ts +1 -1
  46. package/src/build/server/app-module-loader.service.js +0 -2
  47. package/src/build/server/page-module-import.service.d.ts +2 -3
  48. package/src/build/server/page-module-import.service.js +3 -4
  49. package/src/build/server-bundle-deploy-manifest.d.ts +5 -0
  50. package/src/build/server-bundle-deploy-manifest.js +15 -1
  51. package/src/build.d.ts +2 -2
  52. package/src/build.js +2 -2
  53. package/src/config/assembly/app-runtime.d.ts +2 -2
  54. package/src/config/assembly/app-runtime.js +2 -2
  55. package/src/config/assembly/finalize-config.d.ts +4 -4
  56. package/src/config/assembly/finalize-config.js +4 -5
  57. package/src/config/internal-types.d.ts +0 -7
  58. package/src/config/user-config-types.d.ts +0 -4
  59. package/src/diagnostics/request-pipeline-metrics.d.ts +3 -3
  60. package/src/diagnostics/request-pipeline-metrics.js +4 -4
  61. package/src/errors/http-error.d.ts +2 -2
  62. package/src/errors/http-error.js +4 -4
  63. package/src/hmr/client/hmr-runtime.js +16 -7
  64. package/src/hmr/client/module-update.d.ts +7 -0
  65. package/src/hmr/client/module-update.js +21 -4
  66. package/src/hmr/hmr-strategy.d.ts +0 -3
  67. package/src/hmr/hmr-strategy.js +0 -3
  68. package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -3
  69. package/src/hmr/strategies/js-hmr-strategy.js +3 -6
  70. package/src/plugins/alias-resolver-cache.d.ts +4 -3
  71. package/src/plugins/alias-resolver-cache.js +4 -3
  72. package/src/plugins/eco-component-meta-plugin.d.ts +10 -1
  73. package/src/plugins/eco-component-meta-plugin.js +66 -10
  74. package/src/plugins/foreign-jsx-override-plugin.js +2 -1
  75. package/src/route-renderer/error-pages/default-error-pages.js +2 -1
  76. package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -1
  77. package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +0 -1
  78. package/src/route-renderer/orchestration/integration-renderer.d.ts +10 -5
  79. package/src/route-renderer/orchestration/integration-renderer.js +13 -14
  80. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -6
  81. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +0 -6
  82. package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +10 -32
  83. package/src/route-renderer/page-loading/page-module-loader.js +1 -1
  84. package/src/route-renderer/route-renderer.d.ts +2 -5
  85. package/src/route-renderer/route-renderer.js +2 -4
  86. package/src/router/client/link-navigation-policy.d.ts +4 -1
  87. package/src/router/client/link-navigation-policy.js +20 -6
  88. package/src/router/server/route-registry.d.ts +0 -1
  89. package/src/router/server/route-registry.js +2 -11
  90. package/src/router/server/segment-path-matcher.d.ts +12 -0
  91. package/src/router/server/segment-path-matcher.js +30 -0
  92. package/src/static-site-generator/static-site-generator.d.ts +0 -5
  93. package/src/static-site-generator/static-site-generator.js +2 -15
  94. package/src/types/contracts.d.ts +17 -27
  95. package/src/types/public-types.d.ts +1 -1
  96. package/src/utils/format-error-chain.d.ts +9 -0
  97. package/src/utils/format-error-chain.js +20 -0
  98. package/src/utils/invariant.d.ts +6 -1
  99. package/src/utils/invariant.js +7 -2
  100. package/src/watchers/project-watcher.d.ts +20 -1
  101. package/src/watchers/project-watcher.js +40 -9
  102. package/src/watchers/workspace-package-watch-roots.js +5 -5
  103. package/src/adapters/README.md +0 -58
  104. package/src/adapters/shared/hmr/hmr-manager.test-helpers.d.ts +0 -28
  105. package/src/adapters/shared/hmr/hmr-manager.test-helpers.js +0 -53
  106. package/src/adapters/shared/runtime/runtime-host.d.ts +0 -15
  107. package/src/adapters/shared/runtime/runtime-host.js +0 -1
  108. package/src/assets/README.md +0 -35
  109. package/src/build/README.md +0 -298
  110. package/src/build/server/README.md +0 -50
  111. package/src/cache/README.md +0 -5
  112. package/src/client/README.md +0 -5
  113. package/src/client/navigation-scripts/navigation-scripts.test.browser.d.ts +0 -1
  114. package/src/client/navigation-scripts/navigation-scripts.test.browser.js +0 -111
  115. package/src/client/scroll.test.browser.d.ts +0 -1
  116. package/src/client/scroll.test.browser.js +0 -31
  117. package/src/client/view-transitions.test.browser.d.ts +0 -1
  118. package/src/client/view-transitions.test.browser.js +0 -53
  119. package/src/config/README.md +0 -58
  120. package/src/config/constants.d.ts +0 -1
  121. package/src/config/constants.js +0 -1
  122. package/src/dev/README.md +0 -61
  123. package/src/dev/invalidation/README.md +0 -11
  124. package/src/dev-toolbar/README.md +0 -66
  125. package/src/diagnostics/README.md +0 -11
  126. package/src/eco/README.md +0 -776
  127. package/src/errors/README.md +0 -5
  128. package/src/global/README.md +0 -5
  129. package/src/hmr/README.md +0 -64
  130. package/src/hmr/client/build-error-overlay.test.browser.d.ts +0 -1
  131. package/src/hmr/client/build-error-overlay.test.browser.js +0 -48
  132. package/src/hmr/client/hmr-runtime.test.browser.d.ts +0 -1
  133. package/src/hmr/client/hmr-runtime.test.browser.js +0 -32
  134. package/src/hmr/entrypoint-dependency-graph.d.ts +0 -12
  135. package/src/hmr/entrypoint-dependency-graph.js +0 -27
  136. package/src/hmr/hmr-file-change-prep.d.ts +0 -9
  137. package/src/hmr/hmr-file-change-prep.js +0 -11
  138. package/src/html/README.md +0 -15
  139. package/src/html-pages/README.md +0 -104
  140. package/src/islands/README.md +0 -44
  141. package/src/page-cache/README.md +0 -17
  142. package/src/plugins/README.md +0 -53
  143. package/src/route-renderer/GRAPH.md +0 -142
  144. package/src/route-renderer/README.md +0 -160
  145. package/src/route-renderer/error-pages/README.md +0 -11
  146. package/src/route-renderer/orchestration/custom-element-scripts/README.md +0 -15
  147. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.d.ts +0 -39
  148. package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +0 -94
  149. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.d.ts +0 -35
  150. package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.test-fixtures.js +0 -69
  151. package/src/router/README.md +0 -160
  152. package/src/router/client/link-intent.test.browser.d.ts +0 -1
  153. package/src/router/client/link-intent.test.browser.js +0 -33
  154. package/src/router/client/link-navigation-policy.test.browser.d.ts +0 -1
  155. package/src/router/client/link-navigation-policy.test.browser.js +0 -142
  156. package/src/router/client/navigation-commit.test.browser.d.ts +0 -1
  157. package/src/router/client/navigation-commit.test.browser.js +0 -116
  158. package/src/router/client/navigation-document.test.browser.d.ts +0 -1
  159. package/src/router/client/navigation-document.test.browser.js +0 -77
  160. package/src/router/client/navigation-head.test.browser.d.ts +0 -1
  161. package/src/router/client/navigation-head.test.browser.js +0 -101
  162. package/src/router/client/navigation-lifecycle.test.browser.d.ts +0 -1
  163. package/src/router/client/navigation-lifecycle.test.browser.js +0 -97
  164. package/src/router/client/navigation-view-transition.test.browser.d.ts +0 -1
  165. package/src/router/client/navigation-view-transition.test.browser.js +0 -189
  166. package/src/router/client/staged-stylesheets.test-fixtures.d.ts +0 -18
  167. package/src/router/client/staged-stylesheets.test-fixtures.js +0 -31
  168. package/src/static-site-generator/README.md +0 -67
  169. package/src/static-site-generator/static-site-generator.test-utils.d.ts +0 -2
  170. package/src/static-site-generator/static-site-generator.test-utils.js +0 -41
  171. package/src/types/README.md +0 -5
  172. package/src/utils/README.md +0 -7
  173. package/src/validation/README.md +0 -9
  174. package/src/watchers/README.md +0 -15
  175. package/src/watchers/project-watcher.test-helpers.d.ts +0 -60
  176. package/src/watchers/project-watcher.test-helpers.js +0 -108
@@ -53,16 +53,31 @@ export class ProjectWatcher {
53
53
  pendingFlushResolvers = [];
54
54
  changeQueue = Promise.resolve();
55
55
  closePromise;
56
+ /**
57
+ * Reads `ECOPAGES_WATCH_CHANGE_DEBOUNCE_MS`.
58
+ *
59
+ * @remarks
60
+ * A value that is not a non-negative number would otherwise become `NaN` or a negative delay, which timers
61
+ * treat as about 1 ms and so silently turn debouncing off. It is ignored with a warning instead, so the
62
+ * default window applies.
63
+ */
64
+ static resolveEnvDebounceMs() {
65
+ const raw = getEcopagesEnv('ECOPAGES_WATCH_CHANGE_DEBOUNCE_MS');
66
+ if (raw === undefined || raw.trim() === '')
67
+ return undefined;
68
+ const parsed = Number(raw);
69
+ if (Number.isFinite(parsed) && parsed >= 0)
70
+ return parsed;
71
+ appLogger.warn(`Ignoring ECOPAGES_WATCH_CHANGE_DEBOUNCE_MS="${raw}": expected a non-negative number of milliseconds. Using ${ProjectWatcher.duplicateChangeWindowMs} ms.`);
72
+ return undefined;
73
+ }
56
74
  constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, changeDebounceMs, onRestartRequest, entryWatcherOwnsConfig, }) {
57
75
  this.appConfig = config;
58
76
  this.refreshRouterRoutesCallback = refreshRouterRoutesCallback;
59
77
  this.hmrManager = hmrManager;
60
78
  this.bridge = bridge;
61
- const envDebounceMs = getEcopagesEnv('ECOPAGES_WATCH_CHANGE_DEBOUNCE_MS');
62
79
  this.changeDebounceMs =
63
- changeDebounceMs ??
64
- (envDebounceMs !== undefined && envDebounceMs !== '' ? Number(envDebounceMs) : undefined) ??
65
- ProjectWatcher.duplicateChangeWindowMs;
80
+ changeDebounceMs ?? ProjectWatcher.resolveEnvDebounceMs() ?? ProjectWatcher.duplicateChangeWindowMs;
66
81
  this.onRestartRequest = onRestartRequest;
67
82
  this.entryWatcherOwnsConfig = entryWatcherOwnsConfig === true;
68
83
  this.invalidationService = getDevelopmentInvalidationService(config);
@@ -72,14 +87,24 @@ export class ProjectWatcher {
72
87
  requestBrowserReload() {
73
88
  this.bridge.reload();
74
89
  }
75
- async copyPublicDirFile(filePath) {
90
+ /**
91
+ * Mirrors one public file change into dist.
92
+ *
93
+ * @remarks
94
+ * A deleted source is removed from dist, otherwise the stale copy keeps being served by the dev server.
95
+ */
96
+ async syncPublicDirFile(filePath, kind) {
76
97
  try {
77
98
  const relativePath = path.relative(this.appConfig.absolutePaths.publicDir, filePath);
78
99
  const destPath = path.join(this.appConfig.absolutePaths.distDir, relativePath);
100
+ if (kind === 'deleted') {
101
+ await fileSystem.removeAsync(destPath);
102
+ return;
103
+ }
79
104
  await copyRuntimePublicFile(filePath, destPath);
80
105
  }
81
106
  catch (error) {
82
- appLogger.error(`Failed to copy public file: ${formatErrorWithStack(error)}`);
107
+ appLogger.error(`Failed to sync public file: ${formatErrorWithStack(error)}`);
83
108
  }
84
109
  }
85
110
  /**
@@ -256,7 +281,7 @@ export class ProjectWatcher {
256
281
  async copyPublicAssets(files) {
257
282
  for (const file of files) {
258
283
  if (file.plan.category === 'public-asset') {
259
- await this.copyPublicDirFile(file.filePath);
284
+ await this.syncPublicDirFile(file.filePath, file.kind);
260
285
  }
261
286
  }
262
287
  }
@@ -284,7 +309,7 @@ export class ProjectWatcher {
284
309
  await watchConfig.onChanges(changes);
285
310
  }
286
311
  catch (error) {
287
- appLogger.error(`Processor ${processor.name} failed to handle file changes`, error instanceof Error ? error : new Error(String(error)));
312
+ this.reportError(`Processor ${processor.name} failed to handle file changes`, error);
288
313
  }
289
314
  }
290
315
  }
@@ -312,10 +337,16 @@ export class ProjectWatcher {
312
337
  * @param {unknown} error - The error to handle
313
338
  */
314
339
  handleError(error) {
340
+ this.reportError('Watcher error', error);
341
+ }
342
+ /**
343
+ * Logs an error and shows it in the browser error overlay.
344
+ */
345
+ reportError(context, error) {
315
346
  if (error instanceof Error) {
316
347
  this.hmrManager.broadcast({ type: 'error', message: error.message });
317
348
  }
318
- appLogger.error(`Watcher error: ${formatErrorWithStack(error)}`);
349
+ appLogger.error(`${context}: ${formatErrorWithStack(error)}`);
319
350
  }
320
351
  /**
321
352
  * @remarks
@@ -1,5 +1,5 @@
1
- import { existsSync, readFileSync, realpathSync } from 'node:fs';
2
1
  import path from 'node:path';
2
+ import { fileSystem } from '@ecopages/file-system';
3
3
  import { isPathStrictlyInside } from '../utils/path-containment.js';
4
4
  /**
5
5
  * @remarks
@@ -10,9 +10,9 @@ import { isPathStrictlyInside } from '../utils/path-containment.js';
10
10
  */
11
11
  export function resolveWorkspacePackageWatchRoots(rootDir) {
12
12
  const manifestPath = path.join(rootDir, 'package.json');
13
- if (!existsSync(manifestPath))
13
+ if (!fileSystem.exists(manifestPath))
14
14
  return [];
15
- const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'));
15
+ const manifest = JSON.parse(fileSystem.readFileSync(manifestPath));
16
16
  const names = new Set([
17
17
  ...Object.keys(manifest.dependencies ?? {}),
18
18
  ...Object.keys(manifest.devDependencies ?? {}),
@@ -25,8 +25,8 @@ export function resolveWorkspacePackageWatchRoots(rootDir) {
25
25
  let directory = path.resolve(rootDir);
26
26
  while (true) {
27
27
  const installed = path.join(directory, 'node_modules', name);
28
- if (existsSync(path.join(installed, 'package.json'))) {
29
- const realRoot = realpathSync(installed);
28
+ if (fileSystem.exists(path.join(installed, 'package.json'))) {
29
+ const realRoot = fileSystem.realpath(installed);
30
30
  if (!realRoot.split(path.sep).includes('node_modules'))
31
31
  roots.add(realRoot);
32
32
  break;
@@ -1,58 +0,0 @@
1
- # Runtime Adapters
2
-
3
- **Layer:** Application assembly.
4
-
5
- This directory contains the runtime-host integration layer for Ecopages.
6
-
7
- ## Purpose
8
-
9
- `createApp()` resolves the config and command-line mode once, then returns the concrete `EcopagesApp`. The app owns route registration and moves through `idle`, `starting`, `ready`, `stopping`, and `stopped` phases. Concurrent `start()` and `fetch()` calls share the app's readiness promise. After `stop()`, a later `start()` or `fetch()` creates a fresh server adapter. The app owns one `NodeServerAdapter`, which binds the Node HTTP host and composes `ServerRequestPipeline` for route handling.
10
-
11
- Watch mode creates a `DevSession` after the Node server binds. That session owns the Project Watcher, `HmrManager`, client bridge, background Page prewarm, and the Dev Toolbar runtime. Its single `dispose()` stops those resources before Integration teardown. Production and request-only use do not create a DevSession.
12
-
13
- They are responsible for:
14
-
15
- - binding and stopping the Node HTTP server
16
- - delegating startup into framework-owned loaders and services
17
- - bridging runtime-specific request/response or HMR transport details
18
- - keeping host/runtime transport details out of generic core orchestration
19
-
20
- Shutdown cancels queued Page prewarming, waits for active prewarm renders and for Integration `setup()` calls still in flight, then calls `teardown()` for activated Integrations and clears their activation state. Cleanup attempts each resource even when an earlier step fails, then reports the errors. This releases runtime resources such as Lit workers after background renders finish using them.
21
-
22
- If shutdown rejects while a standalone development restart is stopping the server, the adapter logs the rejection details, including nested cleanup errors and their causes, and still exits with the restart code: the process ends either way, and the CLI starts a fresh server.
23
-
24
- They are not responsible for:
25
-
26
- - deciding plugin lifecycle ordering
27
- - owning server-module semantics
28
- - owning browser bundling policy
29
- - owning route rendering semantics
30
-
31
- ## Main Areas
32
-
33
- - `node/`: `EcopagesApp`, concrete `NodeServerAdapter`, watch-only `DevSession`, HTTP request bridge, and HMR transport
34
- - `shared/`: runtime-neutral adapter helpers, clustered by concern:
35
- - `shared/http/` — API response builders, the shared `serveDistFile()` request handler, middleware runner, define-api helpers, explicit-static and filesystem matchers. The dist handler owns file lookup, path validation, HEAD and 405 behavior, ETags, conditional 304, gzip negotiation, and `Cache-Control` for both the runtime fallback and preview. In watch mode stable non-HTML files use `no-cache`; in production only recorded content-hashed outputs are `immutable`, and `.html` and every other file is revalidated (`public, max-age=0, must-revalidate`). A `.gz` variant is sent only to a client that accepts gzip, and any gzip-eligible file that has one carries `Vary: Accept-Encoding`. `FileSystemServerResponseFactory` only wraps rendered route and error-page bodies.
36
- - `shared/hmr/` — HMR HTML inject helpers, concrete `HmrManager`, and entrypoint registrar. `HmrManager` assigns `appRuntime.hmr` for the dev session, owns per-session script entrypoint change handlers (`onScriptEntrypointChanged`), and clears both on `stop()`. Missing-file events are skipped and their entrypoint registrations are cleared. In watch mode every HTML response is marked `no-store`
37
- - `shared/runtime/` — `ServerRequestPipeline`, route handler, static builder, port/bootstrap utilities (`PortManager` on dev and preview bind, Clack confirm on TTY port collisions), and the public asset copy helper used at startup, during static export, and by the watcher. Preview binds `serveDistFile()` through the same `RuntimeHost` transport used by the app server. Before `EcopagesApp.start()` reports readiness, watch mode waits for best-effort Integration warmup attempts and the watcher's initial filesystem subscription; all warmup attempts settle before failures are logged. Non-watch network startup activates Integrations before releasing request readiness. In production, startup also restores listed route browser graphs from the production build manifest and verifies their source files and outputs. Request-only `app.fetch()` activates only Integrations used by the request. Declared prewarm paths (`devPrewarmPaths`, including those Processors append in `setup()`) are de-duplicated and rendered in the background without delaying readiness; a path that fails to render is skipped and logged at debug level.
38
- - `shared/ws/` — WinterCG WebSocket lifecycle helpers and Node HTTP upgrade bridge
39
-
40
- ## Ownership Boundary
41
-
42
- The adapter layer is transport-oriented.
43
-
44
- Core-owned modules still own:
45
-
46
- - config finalization
47
- - build-manifest assembly
48
- - server loading
49
- - invalidation classification
50
- - route rendering orchestration
51
-
52
- The error-pages module owns semantic error-page source selection and rendering. The filesystem response matcher classifies page failures, logs rendering failures, coordinates built-in fallback, and wraps the final body in an HTTP response.
53
-
54
- ## Shared Request Contracts
55
-
56
- - API handler errors and errors that escape `ServerRequestPipeline.handleSharedRequest` resolve through `ApiRequestPipeline.handleError`: a thrown `Response`, then a client abort (499), then `app.onError`, then `HttpError`, then a 500 logged with its stack. `app.fetch()` therefore always resolves with a `Response`. Page render failures render the error page instead and do not reach `app.onError`.
57
- - On Node, `attachNodeHttpWebSocketUpgrades` owns the unmatched-upgrade policy. `/_hmr` (dev only) and user routes are handled; anything else is destroyed.
58
- - HMR endpoints follow the `dev` flag only.
@@ -1,28 +0,0 @@
1
- import type { EcoPagesAppConfig } from '../../../config/internal-types.js';
2
- import type { ClientBridgeEvent } from '../../../types/contracts.js';
3
- import { HmrManager } from './hmr-manager.js';
4
- /**
5
- * Creates a directory under `os.tmpdir()` that is removed when the test finishes.
6
- */
7
- export declare function createTempRoot(prefix: string): string;
8
- /**
9
- * Writes a source file, creating its directories, and returns its path.
10
- */
11
- export declare function writeSourceFile(rootDir: string, relativePath: string, source: string): string;
12
- /**
13
- * Starts a Node HMR manager over `config` with a bridge that records what it broadcasts.
14
- *
15
- * @remarks
16
- * `subscriberCount` is what the bridge reports as connected browsers. The manager stops when the test finishes.
17
- */
18
- export declare function startHmrManager(config: EcoPagesAppConfig, subscriberCount?: number): {
19
- manager: HmrManager;
20
- broadcasts: ClientBridgeEvent[];
21
- };
22
- /**
23
- * Starts a Node HMR manager over a default app config rooted at `rootDir`.
24
- */
25
- export declare function startHmrManagerAt(rootDir: string, subscriberCount?: number): Promise<{
26
- manager: HmrManager;
27
- broadcasts: ClientBridgeEvent[];
28
- }>;
@@ -1,53 +0,0 @@
1
- import fs from 'node:fs';
2
- import os from 'node:os';
3
- import path from 'node:path';
4
- import { onTestFinished } from 'vitest';
5
- import { finalizeEcoPagesConfig } from '../../../config/assembly/finalize-config.js';
6
- import { HmrManager } from './hmr-manager.js';
7
- /**
8
- * Creates a directory under `os.tmpdir()` that is removed when the test finishes.
9
- */
10
- export function createTempRoot(prefix) {
11
- const root = fs.mkdtempSync(path.join(os.tmpdir(), `${prefix}-`));
12
- onTestFinished(() => {
13
- fs.rmSync(root, { recursive: true, force: true });
14
- });
15
- return root;
16
- }
17
- /**
18
- * Writes a source file, creating its directories, and returns its path.
19
- */
20
- export function writeSourceFile(rootDir, relativePath, source) {
21
- const filePath = path.join(rootDir, relativePath);
22
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
23
- fs.writeFileSync(filePath, source, 'utf8');
24
- return filePath;
25
- }
26
- /**
27
- * Starts a Node HMR manager over `config` with a bridge that records what it broadcasts.
28
- *
29
- * @remarks
30
- * `subscriberCount` is what the bridge reports as connected browsers. The manager stops when the test finishes.
31
- */
32
- export function startHmrManager(config, subscriberCount = 0) {
33
- const broadcasts = [];
34
- const bridge = {
35
- subscriberCount,
36
- broadcast: (event) => {
37
- broadcasts.push(event);
38
- },
39
- reload: () => { },
40
- cssUpdate: () => { },
41
- update: () => { },
42
- error: () => { },
43
- };
44
- const manager = new HmrManager({ appConfig: config, bridge });
45
- onTestFinished(() => manager.stop());
46
- return { manager, broadcasts };
47
- }
48
- /**
49
- * Starts a Node HMR manager over a default app config rooted at `rootDir`.
50
- */
51
- export async function startHmrManagerAt(rootDir, subscriberCount = 0) {
52
- return startHmrManager(await finalizeEcoPagesConfig({ rootDir }), subscriberCount);
53
- }
@@ -1,15 +0,0 @@
1
- export interface RuntimeHost<TServer, TServeOptions> {
2
- start(options: RuntimeHostStartOptions<TServeOptions>): Promise<TServer>;
3
- stop(server: TServer, options?: {
4
- force?: boolean;
5
- }): Promise<void>;
6
- getOrigin(server: TServer, fallbackServeOptions: TServeOptions): string;
7
- }
8
- /**
9
- * @remarks
10
- * Request handling travels inside `serveOptions`, as Bun's `fetch` does, so each
11
- * runtime host receives only the callbacks it actually calls.
12
- */
13
- export interface RuntimeHostStartOptions<TServeOptions> {
14
- serveOptions: TServeOptions;
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,35 +0,0 @@
1
- # Asset Processing
2
-
3
- **Layer:** Build.
4
-
5
- This directory owns shared browser-build coordination and processed-asset pipelines.
6
-
7
- Asset processing reads per-app state from the `AppRuntime` installed during config finalization. Each Integration owns an `AssetProcessingService` and its processed-asset cache. App-wide browser builds use the shared build queue, so static export can combine route assets before SSR requests.
8
-
9
- ## Purpose
10
-
11
- Asset processing centralizes app-wide browser builds and processor-owned asset transformations.
12
-
13
- Typical responsibilities include:
14
-
15
- - asset factories, processors, and the processed-asset cache
16
- - app-wide browser build coordination and runtime asset declarations
17
-
18
- ## Main Areas
19
-
20
- - `asset-processing-service/`: the only processed-asset cache, plus typed processors and asset factories. Dependency identity includes attributes, position, and package role; grouped results are reused only while their complete dependency sets match.
21
- - `app-browser-client-build.ts`: combines static-export renderer plans, route islands, lazy client entries, and HTML Page module scripts into compatible app-wide groups. `app-browser-client-manifest.ts` persists route associations so `ecopages start` can restore outputs before SSR requests. Non-exact route templates receive a parameter-free plan without running route data hooks; later params reuse its output when dependencies match, with request-time fallback for a new graph.
22
- - `browser-bundle.service.ts`: coordinates browser builds for assets and HMR. Production outputs record their content-addressed paths in `hashed-browser-asset.ts` for `immutable` file caching; development keeps source-relative names so CSS HMR can refresh the same URL.
23
-
24
- The asset-processing service owns the only processed-asset cache for its five processors. Dependency identity includes attributes, position and package role; file outputs retain their source path so development can verify freshness and invalidate imported inputs. Grouped and ungrouped processing share that cache, and a complete grouped result is reused only while its full dependency set matches. Integration-owned processing calls pass their Integration, whose optional `prepareAssetDependencies()` hook runs before dispatch; calls without an owning Integration pass `undefined`. The file-script processor reads the current HMR manager through the service getter rather than retaining a separately forwarded manager.
25
-
26
- Grouped script assets share one processing path for file and content entries and use exact entry facade output lookup, so Page names such as `blog` and `blog-post` cannot select one another's hydration output. Static export combines compatible grouped entries from every Integration and the HTML shell scripts into app-wide browser build groups, then attaches each emitted entry to its routes. The ordinary grouped cache reuses outputs only when the complete dependency-key set matches; entries from differently composed Page builds are never mixed. Grouped builds carry each entry's external modules, define values, and plugin instances; conflicting define values fail before bundling.
27
- In development, each applied change batch is announced on the shared build-input index, and every asset-processing service evicts the cached assets whose source or bundled inputs it touched. Shared layout styles are therefore not rebuilt for every navigated page, and a bundle is never served after one of its imports changed.
28
-
29
- Browser runtime module assets resolve bare package roots through their ESM import target. For legacy packages without an `exports` map, they prefer `package.json#module` over CJS `main`; CJS resolution is only a compatibility fallback. Generated entries use `export *` for ESM files and explicit named re-exports for CJS files (so bindings such as React `jsx` exist on the vendor). A default binding is added only when the selected entry exposes one. Runtime vendors are package-root contracts: subpath imports need their own vendor declaration or remain in the consuming bundle.
30
-
31
- Package entry lookup is rooted at the application directory, so a framework-local dependency with the same name cannot shadow the application's installed package. ESM export conditions are evaluated in the same order as the generated vendor import (`node`, `import`, then `default`).
32
-
33
- ## Design Rule
34
-
35
- Shared asset processing belongs here; framework-specific asset declarations stay with their Integration.