@ecopages/core 0.2.0-beta.0 → 0.2.0-beta.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.
- package/package.json +117 -3
- package/src/adapters/abstract/application-adapter.d.ts +73 -1
- package/src/adapters/abstract/application-adapter.js +89 -0
- package/src/adapters/abstract/server-adapter.d.ts +3 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +60 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +61 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +5 -3
- package/src/adapters/bun/create-app.js +44 -39
- package/src/adapters/bun/hmr-manager.d.ts +2 -1
- package/src/adapters/bun/hmr-manager.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +81 -20
- package/src/adapters/bun/server-adapter.js +220 -78
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -0
- package/src/adapters/create-app.js +10 -1
- package/src/adapters/node/create-app.d.ts +4 -0
- package/src/adapters/node/create-app.js +38 -9
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/node-hmr-manager.d.ts +2 -1
- package/src/adapters/node/node-hmr-manager.js +2 -2
- package/src/adapters/node/server-adapter-dependencies.js +2 -0
- package/src/adapters/node/server-adapter.d.ts +55 -19
- package/src/adapters/node/server-adapter.js +140 -132
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/shared/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/shared/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -1
- package/src/adapters/shared/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/port-manager.d.ts +116 -0
- package/src/adapters/shared/port-manager.js +196 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +2 -1
- package/src/adapters/shared/runtime-app-bootstrap.js +3 -6
- package/src/adapters/shared/runtime-server-lifecycle.d.ts +38 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +39 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +12 -4
- package/src/adapters/shared/server-route-handler.d.ts +4 -1
- package/src/adapters/shared/server-route-handler.js +5 -2
- package/src/adapters/shared/server-static-builder.d.ts +31 -23
- package/src/adapters/shared/server-static-builder.js +126 -43
- package/src/adapters/shared/shared-hmr-manager.d.ts +12 -0
- package/src/adapters/shared/shared-hmr-manager.js +64 -7
- package/src/adapters/shared/static-preview-host.d.ts +5 -0
- package/src/adapters/shared/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/websocket-lifecycle.js +55 -0
- package/src/build/README.md +77 -14
- package/src/build/app-build-manifest-runtime.d.ts +10 -0
- package/src/build/app-build-manifest-runtime.js +90 -0
- package/src/build/build-adapter.d.ts +17 -319
- package/src/build/build-adapter.js +28 -94
- package/src/build/build-contracts.d.ts +97 -0
- package/src/build/build-contracts.js +0 -0
- package/src/build/build-input-fingerprint.d.ts +28 -0
- package/src/build/build-input-fingerprint.js +31 -0
- package/src/build/build-profile-options.d.ts +7 -0
- package/src/build/build-profile-options.js +37 -0
- package/src/build/build-runtime.d.ts +24 -0
- package/src/build/build-runtime.js +65 -0
- package/src/build/deduping-build-executor.d.ts +28 -0
- package/src/build/deduping-build-executor.js +56 -0
- package/src/build/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/jsx-ownership-plugins.js +41 -0
- package/src/build/pages-unified-graph-build.d.ts +31 -0
- package/src/build/pages-unified-graph-build.js +206 -0
- package/src/build/parallel-build-executor.d.ts +21 -0
- package/src/build/parallel-build-executor.js +52 -0
- package/src/build/production-build-cache.d.ts +20 -0
- package/src/build/production-build-cache.js +63 -0
- package/src/build/rolldown-adapter-helpers.d.ts +3 -6
- package/src/build/rolldown-adapter-helpers.js +71 -6
- package/src/build/rolldown-build-adapter.d.ts +2 -6
- package/src/build/rolldown-build-adapter.js +3 -3
- package/src/build/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/rolldown-plugin-bridge.d.ts +15 -1
- package/src/build/rolldown-plugin-bridge.js +20 -5
- package/src/build/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown-source-transform-pass.js +58 -0
- package/src/build/runtime-build-executor.d.ts +8 -15
- package/src/build/runtime-build-executor.js +12 -15
- package/src/build/runtime-build-output-normalizer.d.ts +7 -0
- package/src/build/runtime-build-output-normalizer.js +94 -2
- package/src/build/server-entry-build-cache.d.ts +44 -0
- package/src/build/server-entry-build-cache.js +161 -0
- package/src/config/config-builder.d.ts +12 -7
- package/src/config/config-builder.js +12 -9
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +19 -9
- package/src/plugins/integration-plugin.js +7 -4
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +19 -4
- package/src/plugins/processor.js +22 -4
- package/src/plugins/source-transform.d.ts +31 -0
- package/src/plugins/source-transform.js +23 -1
- package/src/route-renderer/GRAPH.md +8 -8
- package/src/route-renderer/README.md +30 -28
- package/src/route-renderer/orchestration/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/component-graph.d.ts +36 -0
- package/src/route-renderer/orchestration/component-graph.js +90 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +3 -10
- package/src/route-renderer/orchestration/component-render-context.js +3 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +1 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +5 -31
- package/src/route-renderer/orchestration/document-shell-render.service.d.ts +54 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +54 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +59 -29
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +164 -35
- package/src/route-renderer/orchestration/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +18 -54
- package/src/route-renderer/orchestration/integration-renderer.js +108 -194
- package/src/route-renderer/orchestration/integration-route-render-adapter.d.ts +38 -0
- package/src/route-renderer/orchestration/integration-route-render-adapter.js +27 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +4 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +11 -1
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.d.ts +25 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.js +174 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +2 -0
- package/src/route-renderer/orchestration/render-output.utils.js +4 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.d.ts +17 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.js +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.d.ts +24 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +52 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +5 -38
- package/src/route-renderer/orchestration/route-render-orchestrator.js +51 -459
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +54 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +27 -7
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +32 -14
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/browser-bundle.service.d.ts +3 -1
- package/src/services/assets/browser-bundle.service.js +17 -5
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +4 -4
- package/src/services/invalidation/development-invalidation.service.d.ts +10 -1
- package/src/services/invalidation/development-invalidation.service.js +31 -2
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +5 -17
- package/src/services/module-loading/page-module-import.service.d.ts +4 -1
- package/src/services/module-loading/page-module-import.service.js +61 -41
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +61 -0
- package/src/services/module-loading/route-module-build-manifest.js +116 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +121 -0
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/static-site-generator/README.md +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +22 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +17 -20
- package/src/static-site-generator/static-site-generator.js +188 -85
- package/src/types/internal-types.d.ts +12 -9
- package/src/types/public-types.d.ts +87 -22
- package/src/utils/parse-cli-args.d.ts +1 -0
- package/src/utils/parse-cli-args.js +3 -0
- package/src/utils/resolve-entry-file.d.ts +72 -0
- package/src/utils/resolve-entry-file.js +41 -0
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +50 -20
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/hmr/hmr.postcss.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.d.ts +0 -1
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { parseArgs } from "node:util";
|
|
2
|
+
import { getRuntimeArgv } from "./runtime.js";
|
|
3
|
+
const DEFAULT_ENTRY_FILE = "app.ts";
|
|
4
|
+
const ENTRY_FILE_ENV = "ECOPAGES_ENTRY_FILE";
|
|
5
|
+
const entryFileOptions = {
|
|
6
|
+
"entry-file": { type: "string", short: "e" }
|
|
7
|
+
};
|
|
8
|
+
const ENTRY_FILE_FLAG = "entry-file";
|
|
9
|
+
function resolveEntryFile({
|
|
10
|
+
entryFile,
|
|
11
|
+
env = process.env,
|
|
12
|
+
argv = getRuntimeArgv()
|
|
13
|
+
} = {}) {
|
|
14
|
+
if (entryFile && entryFile.length > 0) return entryFile;
|
|
15
|
+
const fromEnv = env[ENTRY_FILE_ENV];
|
|
16
|
+
if (fromEnv && fromEnv.length > 0) return fromEnv;
|
|
17
|
+
const fromFlag = readEntryFileFlag(argv);
|
|
18
|
+
if (fromFlag) return fromFlag;
|
|
19
|
+
return DEFAULT_ENTRY_FILE;
|
|
20
|
+
}
|
|
21
|
+
function readEntryFileFlag(argv = getRuntimeArgv()) {
|
|
22
|
+
const { values } = parseArgs({
|
|
23
|
+
args: argv.slice(1),
|
|
24
|
+
options: { ...entryFileOptions },
|
|
25
|
+
strict: false
|
|
26
|
+
});
|
|
27
|
+
const raw = values[ENTRY_FILE_FLAG];
|
|
28
|
+
return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
29
|
+
}
|
|
30
|
+
const SERVER_BUNDLE_DIR = ".server";
|
|
31
|
+
const SERVER_BUNDLE_FILENAME = "app.mjs";
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_ENTRY_FILE,
|
|
34
|
+
ENTRY_FILE_ENV,
|
|
35
|
+
ENTRY_FILE_FLAG,
|
|
36
|
+
SERVER_BUNDLE_DIR,
|
|
37
|
+
SERVER_BUNDLE_FILENAME,
|
|
38
|
+
entryFileOptions,
|
|
39
|
+
readEntryFileFlag,
|
|
40
|
+
resolveEntryFile
|
|
41
|
+
};
|
|
@@ -13,6 +13,8 @@ export interface ProjectWatcherConfig {
|
|
|
13
13
|
refreshRouterRoutesCallback: () => Promise<void>;
|
|
14
14
|
hmrManager: IHmrManager;
|
|
15
15
|
bridge: IClientBridge;
|
|
16
|
+
/** When true, the host dev server owns browser dev-client bootstrap. */
|
|
17
|
+
hostOwnsDevClient?: boolean;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* ProjectWatcher handles file system changes for hot module replacement (HMR).
|
|
@@ -42,11 +44,12 @@ export declare class ProjectWatcher {
|
|
|
42
44
|
private refreshRouterRoutesCallback;
|
|
43
45
|
private hmrManager;
|
|
44
46
|
private bridge;
|
|
47
|
+
private readonly hostOwnsDevClient;
|
|
45
48
|
private readonly invalidationService;
|
|
46
49
|
private watcher;
|
|
47
50
|
private lastHandledChange;
|
|
48
51
|
private changeQueue;
|
|
49
|
-
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge }: ProjectWatcherConfig);
|
|
52
|
+
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient }: ProjectWatcherConfig);
|
|
50
53
|
/**
|
|
51
54
|
* Uncaches modules in the source directory to ensure fresh imports.
|
|
52
55
|
* This is necessary for hot module replacement to work correctly.
|
|
@@ -55,6 +58,7 @@ export declare class ProjectWatcher {
|
|
|
55
58
|
private uncacheModules;
|
|
56
59
|
private isRouteSourceFile;
|
|
57
60
|
private isIncludeSourceFile;
|
|
61
|
+
private requestBrowserReload;
|
|
58
62
|
/**
|
|
59
63
|
* Handles public directory file changes by copying only the changed file.
|
|
60
64
|
* @param filePath - Absolute path of the changed file
|
|
@@ -70,7 +74,7 @@ export declare class ProjectWatcher {
|
|
|
70
74
|
* Follows 5-rule priority:
|
|
71
75
|
* 0. Public directory match? -> copy file and reload
|
|
72
76
|
* 1. additionalWatchPaths match? -> reload
|
|
73
|
-
* 2. Include template source? ->
|
|
77
|
+
* 2. Include template source? -> current-page refresh via HMR after processor notifications are deferred
|
|
74
78
|
* 3. Processor-owned asset? -> processor already handled it via notification, skip HMR
|
|
75
79
|
* 4. Otherwise -> HMR strategies
|
|
76
80
|
*
|
|
@@ -133,4 +137,12 @@ export declare class ProjectWatcher {
|
|
|
133
137
|
* rapid file changes efficiently.
|
|
134
138
|
*/
|
|
135
139
|
createWatcherSubscription(): Promise<FSWatcher>;
|
|
140
|
+
/**
|
|
141
|
+
* Closes the active filesystem watcher subscription.
|
|
142
|
+
*
|
|
143
|
+
* @remarks
|
|
144
|
+
* Safe to call multiple times. Used when tearing down dev servers in tests
|
|
145
|
+
* and other short-lived Ecopages runtimes.
|
|
146
|
+
*/
|
|
147
|
+
close(): Promise<void>;
|
|
136
148
|
}
|
|
@@ -16,15 +16,17 @@ class ProjectWatcher {
|
|
|
16
16
|
refreshRouterRoutesCallback;
|
|
17
17
|
hmrManager;
|
|
18
18
|
bridge;
|
|
19
|
+
hostOwnsDevClient;
|
|
19
20
|
invalidationService;
|
|
20
21
|
watcher = null;
|
|
21
22
|
lastHandledChange = /* @__PURE__ */ new Map();
|
|
22
23
|
changeQueue = Promise.resolve();
|
|
23
|
-
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge }) {
|
|
24
|
+
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient }) {
|
|
24
25
|
this.appConfig = config;
|
|
25
26
|
this.refreshRouterRoutesCallback = refreshRouterRoutesCallback;
|
|
26
27
|
this.hmrManager = hmrManager;
|
|
27
28
|
this.bridge = bridge;
|
|
29
|
+
this.hostOwnsDevClient = hostOwnsDevClient === true;
|
|
28
30
|
this.invalidationService = new DevelopmentInvalidationService(config);
|
|
29
31
|
this.triggerRouterRefresh = this.triggerRouterRefresh.bind(this);
|
|
30
32
|
this.handleError = this.handleError.bind(this);
|
|
@@ -51,6 +53,12 @@ class ProjectWatcher {
|
|
|
51
53
|
isIncludeSourceFile(filePath) {
|
|
52
54
|
return this.invalidationService.isIncludeSourceFile(filePath);
|
|
53
55
|
}
|
|
56
|
+
requestBrowserReload() {
|
|
57
|
+
if (this.hostOwnsDevClient) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.bridge.reload();
|
|
61
|
+
}
|
|
54
62
|
/**
|
|
55
63
|
* Handles public directory file changes by copying only the changed file.
|
|
56
64
|
* @param filePath - Absolute path of the changed file
|
|
@@ -64,10 +72,10 @@ class ProjectWatcher {
|
|
|
64
72
|
fileSystem.ensureDir(destDir);
|
|
65
73
|
await fileSystem.copyFileAsync(filePath, destPath);
|
|
66
74
|
}
|
|
67
|
-
this.
|
|
75
|
+
this.requestBrowserReload();
|
|
68
76
|
} catch (error) {
|
|
69
77
|
appLogger.error(`Failed to copy public file: ${error instanceof Error ? error.message : String(error)}`);
|
|
70
|
-
this.
|
|
78
|
+
this.requestBrowserReload();
|
|
71
79
|
}
|
|
72
80
|
}
|
|
73
81
|
/**
|
|
@@ -83,7 +91,7 @@ class ProjectWatcher {
|
|
|
83
91
|
* Follows 5-rule priority:
|
|
84
92
|
* 0. Public directory match? -> copy file and reload
|
|
85
93
|
* 1. additionalWatchPaths match? -> reload
|
|
86
|
-
* 2. Include template source? ->
|
|
94
|
+
* 2. Include template source? -> current-page refresh via HMR after processor notifications are deferred
|
|
87
95
|
* 3. Processor-owned asset? -> processor already handled it via notification, skip HMR
|
|
88
96
|
* 4. Otherwise -> HMR strategies
|
|
89
97
|
*
|
|
@@ -117,15 +125,17 @@ class ProjectWatcher {
|
|
|
117
125
|
if (plan.refreshRoutes) {
|
|
118
126
|
await this.refreshRouterRoutesCallback();
|
|
119
127
|
}
|
|
120
|
-
if (plan.
|
|
121
|
-
this.
|
|
128
|
+
if (plan.reloadBrowser) {
|
|
129
|
+
this.requestBrowserReload();
|
|
122
130
|
return;
|
|
123
131
|
}
|
|
124
|
-
|
|
125
|
-
if (plan.
|
|
126
|
-
this.
|
|
132
|
+
const deferProcessorNotifications = plan.category === "include-source" || plan.category === "explicit-server-view";
|
|
133
|
+
if (deferProcessorNotifications && plan.delegateToHmr) {
|
|
134
|
+
await this.hmrManager.handleFileChange(filePath);
|
|
135
|
+
void this.notifyProcessors(filePath, event);
|
|
127
136
|
return;
|
|
128
137
|
}
|
|
138
|
+
await this.notifyProcessors(filePath, event);
|
|
129
139
|
if (plan.processorHandledAsset) {
|
|
130
140
|
return;
|
|
131
141
|
}
|
|
@@ -231,30 +241,36 @@ class ProjectWatcher {
|
|
|
231
241
|
if (this.watcher) {
|
|
232
242
|
return this.watcher;
|
|
233
243
|
}
|
|
234
|
-
const processorPaths =
|
|
244
|
+
const processorPaths = /* @__PURE__ */ new Set();
|
|
235
245
|
for (const processor of this.appConfig.processors.values()) {
|
|
236
246
|
const watchConfig = processor.getWatchConfig();
|
|
237
247
|
if (!watchConfig) continue;
|
|
238
|
-
|
|
248
|
+
for (const watchPath of watchConfig.paths) {
|
|
249
|
+
processorPaths.add(watchPath);
|
|
250
|
+
}
|
|
239
251
|
}
|
|
240
252
|
if (fileSystem.exists(this.appConfig.absolutePaths.includesDir)) {
|
|
241
|
-
processorPaths.
|
|
253
|
+
processorPaths.add(this.appConfig.absolutePaths.includesDir);
|
|
242
254
|
}
|
|
243
255
|
if (fileSystem.exists(this.appConfig.absolutePaths.srcDir)) {
|
|
244
|
-
processorPaths.
|
|
245
|
-
}
|
|
246
|
-
if (fileSystem.exists(this.appConfig.absolutePaths.pagesDir)) {
|
|
247
|
-
processorPaths.push(this.appConfig.absolutePaths.pagesDir);
|
|
256
|
+
processorPaths.add(this.appConfig.absolutePaths.srcDir);
|
|
248
257
|
}
|
|
249
258
|
if (fileSystem.exists(this.appConfig.absolutePaths.publicDir)) {
|
|
250
|
-
processorPaths.
|
|
259
|
+
processorPaths.add(this.appConfig.absolutePaths.publicDir);
|
|
251
260
|
}
|
|
252
|
-
|
|
253
|
-
processorPaths.
|
|
261
|
+
for (const watchPath of this.appConfig.additionalWatchPaths) {
|
|
262
|
+
processorPaths.add(watchPath);
|
|
254
263
|
}
|
|
255
|
-
|
|
264
|
+
const ignored = [
|
|
265
|
+
"**/node_modules/**",
|
|
266
|
+
"**/.git/**",
|
|
267
|
+
path.join(this.appConfig.absolutePaths.workDir, "**"),
|
|
268
|
+
path.join(this.appConfig.absolutePaths.distDir, "**")
|
|
269
|
+
];
|
|
270
|
+
this.watcher = chokidar.watch(Array.from(processorPaths), {
|
|
256
271
|
ignoreInitial: true,
|
|
257
272
|
ignorePermissionErrors: true,
|
|
273
|
+
ignored,
|
|
258
274
|
awaitWriteFinish: {
|
|
259
275
|
stabilityThreshold: 50,
|
|
260
276
|
pollInterval: 50
|
|
@@ -269,6 +285,20 @@ class ProjectWatcher {
|
|
|
269
285
|
}
|
|
270
286
|
return this.watcher;
|
|
271
287
|
}
|
|
288
|
+
/**
|
|
289
|
+
* Closes the active filesystem watcher subscription.
|
|
290
|
+
*
|
|
291
|
+
* @remarks
|
|
292
|
+
* Safe to call multiple times. Used when tearing down dev servers in tests
|
|
293
|
+
* and other short-lived Ecopages runtimes.
|
|
294
|
+
*/
|
|
295
|
+
async close() {
|
|
296
|
+
if (!this.watcher) {
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
await this.watcher.close();
|
|
300
|
+
this.watcher = null;
|
|
301
|
+
}
|
|
272
302
|
}
|
|
273
303
|
export {
|
|
274
304
|
ProjectWatcher
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DevEngine-backed build adapter for cached incremental rebuilds.
|
|
3
|
-
*
|
|
4
|
-
* @remarks
|
|
5
|
-
* Wraps Rolldown's experimental `DevEngine` to provide cached incremental
|
|
6
|
-
* rebuilds. Unlike the standard `RolldownBuildAdapter` which creates a new
|
|
7
|
-
* bundler for every build, this adapter keeps a `DevEngine` instance alive
|
|
8
|
-
* and reuses the internal module graph, resolver cache, and transform cache
|
|
9
|
-
* across builds.
|
|
10
|
-
*
|
|
11
|
-
* The adapter is designed for the HMR rebuild path where the same entrypoints
|
|
12
|
-
* are rebuilt repeatedly with small changes. For one-off production builds,
|
|
13
|
-
* use `RolldownBuildAdapter` instead.
|
|
14
|
-
*
|
|
15
|
-
* The first build creates the engine and runs it. Subsequent builds with the
|
|
16
|
-
* same plugin/target/format triple reuse the cached engine and call
|
|
17
|
-
* `triggerFullBuild()`. The cache key incorporates the context root, plugin
|
|
18
|
-
* names, target, and format; when any of those change, the cached engine is
|
|
19
|
-
* closed and a new one is created.
|
|
20
|
-
*
|
|
21
|
-
* Call `close()` to release the cached engine and free resources.
|
|
22
|
-
*
|
|
23
|
-
* @module
|
|
24
|
-
*/
|
|
25
|
-
import type { BuildAdapter, BuildOptions, BuildResult, BuildTranspileOptions, BuildTranspileProfile } from './build-adapter.js';
|
|
26
|
-
/**
|
|
27
|
-
* Build adapter backed by Rolldown's DevEngine for cached incremental rebuilds.
|
|
28
|
-
*/
|
|
29
|
-
export declare class RolldownDevBuildAdapter implements BuildAdapter {
|
|
30
|
-
/**
|
|
31
|
-
* `'rolldown-dev'` (not `'rolldown'`) so {@link getBuildAdapterOwnership}
|
|
32
|
-
* round-trips correctly and `createBuildAdapter({ ownership })` can
|
|
33
|
-
* re-select this class.
|
|
34
|
-
*/
|
|
35
|
-
readonly ownership: "rolldown-dev";
|
|
36
|
-
private cachedEngine;
|
|
37
|
-
private engineInstanceCount;
|
|
38
|
-
private readonly pendingBuilds;
|
|
39
|
-
private readonly appRootRequireCache;
|
|
40
|
-
/**
|
|
41
|
-
* Stable key over the inputs that affect the engine configuration.
|
|
42
|
-
* Plugin order is intentionally not part of the key: two plugin
|
|
43
|
-
* sets with the same names are interchangeable for caching.
|
|
44
|
-
*/
|
|
45
|
-
private getCacheKey;
|
|
46
|
-
/**
|
|
47
|
-
* Returns the cached engine, creating a new one when the cache
|
|
48
|
-
* key changes. On a cache miss the prior engine is closed and
|
|
49
|
-
* {@link engineInstanceCount} is incremented.
|
|
50
|
-
*/
|
|
51
|
-
private getOrCreateEngine;
|
|
52
|
-
/**
|
|
53
|
-
* Triggers a build on the cached engine and returns the next
|
|
54
|
-
* `RolldownOutput` delivered to `onOutput`.
|
|
55
|
-
*
|
|
56
|
-
* First call after engine creation invokes `engine.run`; subsequent
|
|
57
|
-
* calls invoke `engine.triggerFullBuild` and reuse the cached
|
|
58
|
-
* module graph, resolver, and transform caches.
|
|
59
|
-
*
|
|
60
|
-
* If the trigger itself throws, the queued build is removed so
|
|
61
|
-
* the next `build()` does not consume a stale slot.
|
|
62
|
-
*/
|
|
63
|
-
private runBuild;
|
|
64
|
-
/** Throws on error; see {@link build} for the no-throw variant. */
|
|
65
|
-
buildOrThrow(options: BuildOptions): Promise<BuildResult>;
|
|
66
|
-
build(options: BuildOptions): Promise<BuildResult>;
|
|
67
|
-
resolve(importPath: string, rootDir: string): string;
|
|
68
|
-
getTranspileOptions(profile: BuildTranspileProfile): BuildTranspileOptions;
|
|
69
|
-
/**
|
|
70
|
-
* Closes the cached DevEngine and rejects any in-flight builds
|
|
71
|
-
* with `'DevBuildAdapter closed'`.
|
|
72
|
-
*
|
|
73
|
-
* @remarks
|
|
74
|
-
* Not on the {@link BuildAdapter} interface, so it is only
|
|
75
|
-
* reachable through the concrete class. The adapter is meant to
|
|
76
|
-
* live for the process lifetime; this is for explicit teardown.
|
|
77
|
-
*/
|
|
78
|
-
close(): Promise<void>;
|
|
79
|
-
/** Test-only: number of engines created over the adapter's lifetime. */
|
|
80
|
-
getEngineInstanceCountForTests(): number;
|
|
81
|
-
}
|
|
82
|
-
export declare function createRolldownDevBuildAdapter(): RolldownDevBuildAdapter;
|
|
@@ -1,166 +0,0 @@
|
|
|
1
|
-
import { createRequire } from "node:module";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { dev } from "rolldown/experimental";
|
|
4
|
-
import {
|
|
5
|
-
buildResultFromRolldownOutput,
|
|
6
|
-
resolveRolldownOptions,
|
|
7
|
-
rewriteBrowserRuntimeImportsInOutputs,
|
|
8
|
-
toBuildLogs,
|
|
9
|
-
transpileProfileToOptions
|
|
10
|
-
} from "./rolldown-adapter-helpers.js";
|
|
11
|
-
const moduleRequire = createRequire(import.meta.url);
|
|
12
|
-
class RolldownDevBuildAdapter {
|
|
13
|
-
/**
|
|
14
|
-
* `'rolldown-dev'` (not `'rolldown'`) so {@link getBuildAdapterOwnership}
|
|
15
|
-
* round-trips correctly and `createBuildAdapter({ ownership })` can
|
|
16
|
-
* re-select this class.
|
|
17
|
-
*/
|
|
18
|
-
ownership = "rolldown-dev";
|
|
19
|
-
cachedEngine;
|
|
20
|
-
engineInstanceCount = 0;
|
|
21
|
-
pendingBuilds = [];
|
|
22
|
-
appRootRequireCache = /* @__PURE__ */ new Map();
|
|
23
|
-
/**
|
|
24
|
-
* Stable key over the inputs that affect the engine configuration.
|
|
25
|
-
* Plugin order is intentionally not part of the key: two plugin
|
|
26
|
-
* sets with the same names are interchangeable for caching.
|
|
27
|
-
*/
|
|
28
|
-
getCacheKey(plugins, contextRoot, target, format) {
|
|
29
|
-
const pluginNames = plugins.map((p) => p.name).join(":");
|
|
30
|
-
return `${contextRoot}::${pluginNames}::${target ?? "default"}::${format ?? "esm"}`;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Returns the cached engine, creating a new one when the cache
|
|
34
|
-
* key changes. On a cache miss the prior engine is closed and
|
|
35
|
-
* {@link engineInstanceCount} is incremented.
|
|
36
|
-
*/
|
|
37
|
-
async getOrCreateEngine(options, contextRoot) {
|
|
38
|
-
const bundlePlugins = options.plugins ?? [];
|
|
39
|
-
const cacheKey = this.getCacheKey(bundlePlugins, contextRoot, options.target, options.format);
|
|
40
|
-
if (this.cachedEngine) {
|
|
41
|
-
const existingKey = this.getCacheKey(
|
|
42
|
-
this.cachedEngine.bundlePlugins,
|
|
43
|
-
this.cachedEngine.contextRoot,
|
|
44
|
-
options.target,
|
|
45
|
-
options.format
|
|
46
|
-
);
|
|
47
|
-
if (existingKey === cacheKey) {
|
|
48
|
-
return this.cachedEngine;
|
|
49
|
-
}
|
|
50
|
-
await this.cachedEngine.engine.close();
|
|
51
|
-
this.cachedEngine = void 0;
|
|
52
|
-
}
|
|
53
|
-
const outdir = path.resolve(options.outdir ?? "dist/assets");
|
|
54
|
-
const { inputOptions, outputOptions } = resolveRolldownOptions(
|
|
55
|
-
options,
|
|
56
|
-
contextRoot,
|
|
57
|
-
outdir,
|
|
58
|
-
this.appRootRequireCache
|
|
59
|
-
);
|
|
60
|
-
const engine = await dev(inputOptions, outputOptions, {
|
|
61
|
-
rebuildStrategy: "never",
|
|
62
|
-
onOutput: (result) => {
|
|
63
|
-
if (result instanceof Error) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const next = this.pendingBuilds.shift();
|
|
67
|
-
if (next) {
|
|
68
|
-
next.resolve(result);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
this.cachedEngine = {
|
|
73
|
-
engine,
|
|
74
|
-
engineStarted: false,
|
|
75
|
-
contextRoot,
|
|
76
|
-
bundlePlugins
|
|
77
|
-
};
|
|
78
|
-
this.engineInstanceCount += 1;
|
|
79
|
-
return this.cachedEngine;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Triggers a build on the cached engine and returns the next
|
|
83
|
-
* `RolldownOutput` delivered to `onOutput`.
|
|
84
|
-
*
|
|
85
|
-
* First call after engine creation invokes `engine.run`; subsequent
|
|
86
|
-
* calls invoke `engine.triggerFullBuild` and reuse the cached
|
|
87
|
-
* module graph, resolver, and transform caches.
|
|
88
|
-
*
|
|
89
|
-
* If the trigger itself throws, the queued build is removed so
|
|
90
|
-
* the next `build()` does not consume a stale slot.
|
|
91
|
-
*/
|
|
92
|
-
async runBuild(cached) {
|
|
93
|
-
const outputPromise = new Promise((resolve, reject) => {
|
|
94
|
-
this.pendingBuilds.push({ resolve, reject });
|
|
95
|
-
});
|
|
96
|
-
try {
|
|
97
|
-
if (!cached.engineStarted) {
|
|
98
|
-
cached.engineStarted = true;
|
|
99
|
-
await cached.engine.run();
|
|
100
|
-
} else {
|
|
101
|
-
cached.engine.triggerFullBuild();
|
|
102
|
-
}
|
|
103
|
-
} catch (error) {
|
|
104
|
-
this.pendingBuilds.shift();
|
|
105
|
-
throw error;
|
|
106
|
-
}
|
|
107
|
-
return outputPromise;
|
|
108
|
-
}
|
|
109
|
-
/** Throws on error; see {@link build} for the no-throw variant. */
|
|
110
|
-
async buildOrThrow(options) {
|
|
111
|
-
const contextRoot = options.root ? path.resolve(options.root) : process.cwd();
|
|
112
|
-
const outdir = path.resolve(options.outdir ?? "dist/assets");
|
|
113
|
-
const plugins = options.plugins ?? [];
|
|
114
|
-
const cached = await this.getOrCreateEngine(options, contextRoot);
|
|
115
|
-
const output = await this.runBuild(cached);
|
|
116
|
-
const baseResult = buildResultFromRolldownOutput(output, outdir, contextRoot);
|
|
117
|
-
return rewriteBrowserRuntimeImportsInOutputs(baseResult, contextRoot, plugins);
|
|
118
|
-
}
|
|
119
|
-
async build(options) {
|
|
120
|
-
try {
|
|
121
|
-
return await this.buildOrThrow(options);
|
|
122
|
-
} catch (error) {
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
logs: toBuildLogs(error),
|
|
126
|
-
outputs: []
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
resolve(importPath, rootDir) {
|
|
131
|
-
return moduleRequire.resolve(importPath, { paths: [rootDir] });
|
|
132
|
-
}
|
|
133
|
-
getTranspileOptions(profile) {
|
|
134
|
-
return transpileProfileToOptions(profile);
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Closes the cached DevEngine and rejects any in-flight builds
|
|
138
|
-
* with `'DevBuildAdapter closed'`.
|
|
139
|
-
*
|
|
140
|
-
* @remarks
|
|
141
|
-
* Not on the {@link BuildAdapter} interface, so it is only
|
|
142
|
-
* reachable through the concrete class. The adapter is meant to
|
|
143
|
-
* live for the process lifetime; this is for explicit teardown.
|
|
144
|
-
*/
|
|
145
|
-
async close() {
|
|
146
|
-
if (this.cachedEngine) {
|
|
147
|
-
await this.cachedEngine.engine.close();
|
|
148
|
-
this.cachedEngine = void 0;
|
|
149
|
-
}
|
|
150
|
-
while (this.pendingBuilds.length > 0) {
|
|
151
|
-
const pending = this.pendingBuilds.shift();
|
|
152
|
-
pending?.reject(new Error("DevBuildAdapter closed"));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/** Test-only: number of engines created over the adapter's lifetime. */
|
|
156
|
-
getEngineInstanceCountForTests() {
|
|
157
|
-
return this.engineInstanceCount;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
function createRolldownDevBuildAdapter() {
|
|
161
|
-
return new RolldownDevBuildAdapter();
|
|
162
|
-
}
|
|
163
|
-
export {
|
|
164
|
-
RolldownDevBuildAdapter,
|
|
165
|
-
createRolldownDevBuildAdapter
|
|
166
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
const FIXTURE_DIR = resolve(process.cwd(), "packages/core/__fixtures__/app");
|
|
6
|
-
const TEST_CSS_FILE = resolve(FIXTURE_DIR, "src/pages/postcss-hmr.css");
|
|
7
|
-
test.describe("HMR E2E PostCSS", () => {
|
|
8
|
-
test("should hot-update processor-owned CSS without a full page reload", async ({ page }) => {
|
|
9
|
-
const originalCss = readFileSync(TEST_CSS_FILE, "utf-8");
|
|
10
|
-
const title = page.locator(".postcss-title").first();
|
|
11
|
-
try {
|
|
12
|
-
await page.goto("/postcss-hmr", { waitUntil: "networkidle" });
|
|
13
|
-
await expect(title).toBeVisible();
|
|
14
|
-
const initialColor = await title.evaluate((el) => getComputedStyle(el).color);
|
|
15
|
-
expect(initialColor).toBeTruthy();
|
|
16
|
-
await page.evaluate(() => {
|
|
17
|
-
window.__postcssReloadProbe = "before-change";
|
|
18
|
-
});
|
|
19
|
-
const modifiedCss = originalCss.replace(".postcss-title {", ".postcss-title {\n color: rgb(255, 0, 0);");
|
|
20
|
-
await writeFile(TEST_CSS_FILE, modifiedCss, { flush: true });
|
|
21
|
-
await expect.poll(async () => title.evaluate((el) => getComputedStyle(el).color), { timeout: 1e4 }).toBe("rgb(255, 0, 0)");
|
|
22
|
-
await expect(
|
|
23
|
-
page.evaluate(
|
|
24
|
-
() => window.__postcssReloadProbe ?? null
|
|
25
|
-
)
|
|
26
|
-
).resolves.toBe("before-change");
|
|
27
|
-
} finally {
|
|
28
|
-
await writeFile(TEST_CSS_FILE, originalCss, { flush: true });
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/hmr/hmr.test.e2e.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import { writeFile } from "node:fs/promises";
|
|
4
|
-
import { resolve } from "node:path";
|
|
5
|
-
const FIXTURE_DIR = resolve(process.cwd(), "packages/core/__fixtures__/app");
|
|
6
|
-
const TEST_CSS_FILE = resolve(FIXTURE_DIR, "src/pages/index.css");
|
|
7
|
-
test.describe("HMR E2E", () => {
|
|
8
|
-
test("should load page with .main-title element", async ({ page }) => {
|
|
9
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
10
|
-
const title = page.locator(".main-title").first();
|
|
11
|
-
await expect(title).toBeVisible();
|
|
12
|
-
});
|
|
13
|
-
test("should connect to HMR WebSocket", async ({ page }) => {
|
|
14
|
-
const socketPromise = page.waitForEvent("websocket", {
|
|
15
|
-
predicate: (socket2) => socket2.url().endsWith("/_hmr"),
|
|
16
|
-
timeout: 1e4
|
|
17
|
-
});
|
|
18
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
19
|
-
const socket = await socketPromise;
|
|
20
|
-
expect(socket.url()).toMatch(/\/_hmr$/);
|
|
21
|
-
});
|
|
22
|
-
test("should fall back to a full page reload when raw CSS file changes", async ({ page }) => {
|
|
23
|
-
const originalCss = readFileSync(TEST_CSS_FILE, "utf-8");
|
|
24
|
-
const title = page.locator(".main-title").first();
|
|
25
|
-
try {
|
|
26
|
-
await page.goto("/", { waitUntil: "networkidle" });
|
|
27
|
-
await expect(title).toBeVisible();
|
|
28
|
-
const initialColor = await title.evaluate((el) => getComputedStyle(el).color);
|
|
29
|
-
expect(initialColor).toBeTruthy();
|
|
30
|
-
const modifiedCss = originalCss.replace(".main-title {", ".main-title {\n color: rgb(255, 0, 0);");
|
|
31
|
-
const reloadPromise = page.waitForEvent("framenavigated", {
|
|
32
|
-
predicate: (frame) => frame === page.mainFrame(),
|
|
33
|
-
timeout: 1e4
|
|
34
|
-
});
|
|
35
|
-
await writeFile(TEST_CSS_FILE, modifiedCss, { flush: true });
|
|
36
|
-
await reloadPromise;
|
|
37
|
-
await page.waitForLoadState("networkidle");
|
|
38
|
-
await expect.poll(async () => title.evaluate((el) => getComputedStyle(el).color), { timeout: 1e4 }).toBe("rgb(255, 0, 0)");
|
|
39
|
-
} finally {
|
|
40
|
-
await writeFile(TEST_CSS_FILE, originalCss, { flush: true });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { OwnershipPlan, OwnershipValidationError, EcoComponent } from '../../types/public-types.js';
|
|
2
|
-
type OwnershipPlanBuildInput = {
|
|
3
|
-
routeFile: string;
|
|
4
|
-
currentIntegrationName: string;
|
|
5
|
-
HtmlTemplate: EcoComponent;
|
|
6
|
-
Layout?: EcoComponent;
|
|
7
|
-
Page: EcoComponent;
|
|
8
|
-
validationErrors?: OwnershipValidationError[];
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Builds a declared ownership plan from the component dependency graph.
|
|
12
|
-
*
|
|
13
|
-
* The plan reflects the declared component dependency graph for one route after
|
|
14
|
-
* route-root ownership validation has already run. It records ownership shape,
|
|
15
|
-
* foreign-edge counts, and any validation errors supplied by an earlier
|
|
16
|
-
* validation pass.
|
|
17
|
-
*/
|
|
18
|
-
export declare class OwnershipPlanningService {
|
|
19
|
-
/**
|
|
20
|
-
* Builds the structural ownership plan for one route render.
|
|
21
|
-
*/
|
|
22
|
-
buildPlan(input: OwnershipPlanBuildInput): OwnershipPlan;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { mapDeclaredOwnershipGraph } from "./declared-ownership-graph.js";
|
|
2
|
-
class OwnershipPlanningService {
|
|
3
|
-
/**
|
|
4
|
-
* Builds the structural ownership plan for one route render.
|
|
5
|
-
*/
|
|
6
|
-
buildPlan(input) {
|
|
7
|
-
const validationErrors = input.validationErrors ?? [];
|
|
8
|
-
const rendererNames = /* @__PURE__ */ new Set([input.currentIntegrationName]);
|
|
9
|
-
let foreignEdgeCount = 0;
|
|
10
|
-
const roots = [
|
|
11
|
-
{ component: input.HtmlTemplate, source: "html-template" },
|
|
12
|
-
...input.Layout ? [{ component: input.Layout, source: "layout" }] : [],
|
|
13
|
-
{ component: input.Page, source: "page" }
|
|
14
|
-
];
|
|
15
|
-
const children = mapDeclaredOwnershipGraph({
|
|
16
|
-
roots,
|
|
17
|
-
currentIntegrationName: input.currentIntegrationName,
|
|
18
|
-
mapNode: ({ component, source, integrationName, componentId, isForeignToParent }, children2) => {
|
|
19
|
-
const componentMeta = component.config?.__eco;
|
|
20
|
-
rendererNames.add(integrationName);
|
|
21
|
-
if (isForeignToParent) {
|
|
22
|
-
foreignEdgeCount += 1;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
id: componentId,
|
|
26
|
-
source,
|
|
27
|
-
ownership: {
|
|
28
|
-
integrationName,
|
|
29
|
-
componentId,
|
|
30
|
-
componentFile: componentMeta?.file,
|
|
31
|
-
isPageEntry: source === "page",
|
|
32
|
-
isForeignToParent
|
|
33
|
-
},
|
|
34
|
-
children: children2,
|
|
35
|
-
declaredDependenciesValid: true
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
const root = {
|
|
40
|
-
id: `route:${input.routeFile}`,
|
|
41
|
-
source: "route",
|
|
42
|
-
ownership: {
|
|
43
|
-
integrationName: input.currentIntegrationName,
|
|
44
|
-
componentId: `route:${input.routeFile}`,
|
|
45
|
-
componentFile: input.routeFile,
|
|
46
|
-
isPageEntry: false,
|
|
47
|
-
isForeignToParent: false
|
|
48
|
-
},
|
|
49
|
-
children,
|
|
50
|
-
declaredDependenciesValid: validationErrors.length === 0
|
|
51
|
-
};
|
|
52
|
-
return {
|
|
53
|
-
root,
|
|
54
|
-
rendererNames: Array.from(rendererNames),
|
|
55
|
-
foreignEdgeCount,
|
|
56
|
-
hasValidationErrors: validationErrors.length > 0,
|
|
57
|
-
validationErrors
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
export {
|
|
62
|
-
OwnershipPlanningService
|
|
63
|
-
};
|