@ecopages/core 0.2.0-beta.1 → 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 +107 -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 +14 -29
- package/src/adapters/shared/server-static-builder.js +91 -70
- 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/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
|
@@ -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
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import type { ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
|
|
2
|
-
import type { BaseIntegrationContext, ForeignSubtreeRenderPayload, ComponentRenderInput, EcoComponent } from '../../types/public-types.js';
|
|
3
|
-
import type { ForeignChildRuntime } from './component-render-context.js';
|
|
4
|
-
export type QueuedForeignChildDecisionInput = {
|
|
5
|
-
currentIntegration: string;
|
|
6
|
-
targetIntegration?: string;
|
|
7
|
-
component: EcoComponent;
|
|
8
|
-
props: Record<string, unknown>;
|
|
9
|
-
};
|
|
10
|
-
export type QueuedForeignSubtreeResolution = {
|
|
11
|
-
token: string;
|
|
12
|
-
component: EcoComponent;
|
|
13
|
-
props: Record<string, unknown>;
|
|
14
|
-
componentInstanceId: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Shared mutable state for one renderer-owned queued foreign-subtree runtime.
|
|
18
|
-
*
|
|
19
|
-
* Renderers that cannot resolve foreign children inline can enqueue transport
|
|
20
|
-
* tokens during their initial render, then resolve those tokens against the
|
|
21
|
-
* owning renderer before returning final HTML.
|
|
22
|
-
*/
|
|
23
|
-
export type QueuedForeignSubtreeResolutionContext = {
|
|
24
|
-
rendererCache: Map<string, unknown>;
|
|
25
|
-
componentInstanceScope?: string;
|
|
26
|
-
nextForeignSubtreeId: number;
|
|
27
|
-
queuedResolutions: QueuedForeignSubtreeResolution[];
|
|
28
|
-
};
|
|
29
|
-
type QueuedForeignSubtreeIntegrationContext = BaseIntegrationContext & Record<string, unknown>;
|
|
30
|
-
type QueuedForeignSubtreeChildRenderResult = {
|
|
31
|
-
assets: ProcessedAsset[];
|
|
32
|
-
html?: string;
|
|
33
|
-
children?: unknown;
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* Lower-level queue orchestration for renderer-owned foreign-child runtimes that emit
|
|
37
|
-
* temporary transport tokens during one render pass.
|
|
38
|
-
*
|
|
39
|
-
* The service keeps three responsibilities in one place:
|
|
40
|
-
* - storing per-render queue state on the active integration context
|
|
41
|
-
* - creating a `ForeignChildRuntime` that enqueues foreign children
|
|
42
|
-
* - resolving queued tokens back through the owning renderer before final HTML
|
|
43
|
-
* leaves the current renderer
|
|
44
|
-
*
|
|
45
|
-
* The deeper Foreign Subtree execution module composes this queue helper with
|
|
46
|
-
* renderer-cache delegation and active render-context execution. This service
|
|
47
|
-
* stays focused on queue bookkeeping, recursion, cycle detection, and asset merging.
|
|
48
|
-
*/
|
|
49
|
-
export declare class QueuedForeignSubtreeResolutionService {
|
|
50
|
-
/**
|
|
51
|
-
* Reads the queued foreign-subtree runtime state previously attached to one render.
|
|
52
|
-
*/
|
|
53
|
-
getRuntimeContext<TContext extends QueuedForeignSubtreeResolutionContext>(input: ComponentRenderInput, runtimeContextKey: string): TContext | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Creates the runtime hook used by `runWithComponentRenderContext()` for one
|
|
56
|
-
* renderer-owned queue.
|
|
57
|
-
*
|
|
58
|
-
* When the renderer decides a foreign child must be handed off, the runtime returns
|
|
59
|
-
* a resolved transport token instead of rendering the foreign component inline.
|
|
60
|
-
*/
|
|
61
|
-
createRuntime<TContext extends QueuedForeignSubtreeResolutionContext>(options: {
|
|
62
|
-
renderInput: ComponentRenderInput;
|
|
63
|
-
rendererCache: Map<string, unknown>;
|
|
64
|
-
runtimeContextKey: string;
|
|
65
|
-
tokenPrefix: string;
|
|
66
|
-
shouldQueueForeignChild: (input: QueuedForeignChildDecisionInput) => boolean;
|
|
67
|
-
createRuntimeContext?: (integrationContext: QueuedForeignSubtreeIntegrationContext, rendererCache: Map<string, unknown>) => TContext;
|
|
68
|
-
}): ForeignChildRuntime;
|
|
69
|
-
/**
|
|
70
|
-
* Resolves every queued transport token in one renderer-owned HTML fragment.
|
|
71
|
-
*
|
|
72
|
-
* The caller supplies framework-specific child rendering, while this service
|
|
73
|
-
* handles recursive token replacement, cycle detection, root-attribute
|
|
74
|
-
* application, and merged asset collection.
|
|
75
|
-
*/
|
|
76
|
-
resolveQueuedHtml<TContext extends QueuedForeignSubtreeResolutionContext>(options: {
|
|
77
|
-
html: string;
|
|
78
|
-
runtimeContext?: TContext;
|
|
79
|
-
queueLabel: string;
|
|
80
|
-
renderQueuedChildren: (children: unknown, runtimeContext: TContext, queuedResolutionsByToken: Map<string, QueuedForeignSubtreeResolution>, resolveToken: (token: string) => Promise<string>) => Promise<QueuedForeignSubtreeChildRenderResult>;
|
|
81
|
-
resolveForeignSubtree: (input: ComponentRenderInput, rendererCache: Map<string, unknown>) => Promise<ForeignSubtreeRenderPayload | undefined>;
|
|
82
|
-
applyAttributesToFirstElement: (html: string, attributes: Record<string, string>) => string;
|
|
83
|
-
dedupeProcessedAssets: (assets: ProcessedAsset[]) => ProcessedAsset[];
|
|
84
|
-
}): Promise<{
|
|
85
|
-
assets: ProcessedAsset[];
|
|
86
|
-
html: string;
|
|
87
|
-
}>;
|
|
88
|
-
private createForeignSubtreeToken;
|
|
89
|
-
private ensureRuntimeContext;
|
|
90
|
-
}
|
|
91
|
-
export {};
|