@ecopages/core 0.2.0-beta.2 → 0.2.0-beta.21
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/README.md +1 -1
- package/package.json +163 -3
- package/src/adapters/abstract/application-adapter.d.ts +104 -5
- package/src/adapters/abstract/application-adapter.js +125 -1
- package/src/adapters/abstract/server-adapter.d.ts +6 -2
- 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 +6 -4
- package/src/adapters/bun/create-app.js +65 -43
- package/src/adapters/bun/server-adapter.d.ts +90 -22
- package/src/adapters/bun/server-adapter.js +266 -84
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -11
- package/src/adapters/create-app.js +2 -51
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +1 -2
- package/src/adapters/node/create-app.d.ts +5 -1
- package/src/adapters/node/create-app.js +51 -12
- 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/server-adapter-dependencies.js +4 -0
- package/src/adapters/node/server-adapter.d.ts +62 -20
- package/src/adapters/node/server-adapter.js +160 -131
- 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/fs-server-response-matcher.d.ts +2 -0
- package/src/adapters/shared/fs-server-response-matcher.js +40 -18
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +21 -30
- package/src/adapters/shared/hmr-entrypoint-registrar.js +49 -54
- 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 +46 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +50 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +13 -6
- 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 +23 -32
- package/src/adapters/shared/server-static-builder.js +100 -73
- package/src/adapters/shared/shared-hmr-manager.d.ts +45 -11
- package/src/adapters/shared/shared-hmr-manager.js +204 -58
- 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 +9 -0
- package/src/build/app-build-manifest-runtime.js +87 -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/client/navigation-scripts/classification.d.ts +16 -0
- package/src/client/navigation-scripts/classification.js +41 -0
- package/src/client/navigation-scripts/index.d.ts +3 -0
- package/src/client/navigation-scripts/index.js +23 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
- package/src/client/navigation-scripts/registry.d.ts +11 -0
- package/src/client/navigation-scripts/registry.js +12 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
- package/src/client/navigation-scripts/rerun-queue.js +73 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +25 -0
- package/src/client/scroll.test.browser.js +37 -0
- package/src/client/view-transitions.d.ts +16 -0
- package/src/client/view-transitions.js +63 -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/hmr-manager-registry.d.ts +8 -0
- package/src/dev/hmr-manager-registry.js +15 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/dev/runtime-server-started-message.d.ts +2 -0
- package/src/dev/runtime-server-started-message.js +6 -0
- package/src/eco/README.md +11 -0
- package/src/eco/eco-declared-component.d.ts +14 -0
- package/src/eco/eco-declared-component.js +16 -0
- package/src/eco/eco.browser.js +5 -6
- package/src/eco/eco.js +5 -6
- package/src/eco/eco.types.d.ts +2 -2
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +59 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +7 -1
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/hmr-entrypoint-output.d.ts +43 -0
- package/src/hmr/hmr-entrypoint-output.js +53 -0
- package/src/hmr/hmr-strategy.d.ts +15 -0
- package/src/hmr/hmr-strategy.js +19 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
- package/src/hmr/strategies/js-hmr-strategy.js +67 -19
- 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 +98 -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 +90 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +120 -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 +113 -195
- 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/layout-shell-props.service.d.ts +20 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.js +31 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +5 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +29 -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 +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +54 -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 +8 -39
- package/src/route-renderer/orchestration/route-render-orchestrator.js +53 -461
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +10 -0
- package/src/router/client/link-intent.test.browser.js +12 -1
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +101 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +92 -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.d.ts +0 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
- 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 +20 -2
- package/src/services/invalidation/development-invalidation.service.js +56 -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 +5 -1
- package/src/services/module-loading/page-module-import.service.js +96 -45
- 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 +122 -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 +16 -9
- package/src/types/public-types.d.ts +144 -40
- package/src/utils/parse-cli-args.d.ts +2 -0
- package/src/utils/parse-cli-args.js +6 -0
- package/src/utils/server-utils.module.d.ts +3 -2
- package/src/utils/server-utils.module.js +5 -6
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +48 -0
- package/src/watchers/project-watcher-ignore.d.ts +11 -0
- package/src/watchers/project-watcher-ignore.js +16 -0
- package/src/watchers/project-watcher.d.ts +26 -3
- package/src/watchers/project-watcher.js +132 -30
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- 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.js +0 -31
- 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
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
|
@@ -1,56 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
IntegrationRenderer
|
|
3
|
-
} from "../../route-renderer/orchestration/integration-renderer.js";
|
|
1
|
+
import { StringMarkupRenderer } from "../../route-renderer/orchestration/string-markup-renderer.js";
|
|
4
2
|
import { GHTML_PLUGIN_NAME } from "./ghtml.constants.js";
|
|
5
|
-
class GhtmlRenderer extends
|
|
3
|
+
class GhtmlRenderer extends StringMarkupRenderer {
|
|
6
4
|
name = GHTML_PLUGIN_NAME;
|
|
7
|
-
async renderComponent(input) {
|
|
8
|
-
return this.renderStringComponentWithQueuedForeignSubtrees(
|
|
9
|
-
input,
|
|
10
|
-
input.component
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
async render({
|
|
14
|
-
params,
|
|
15
|
-
query,
|
|
16
|
-
props,
|
|
17
|
-
locals,
|
|
18
|
-
pageLocals,
|
|
19
|
-
metadata,
|
|
20
|
-
Page,
|
|
21
|
-
Layout,
|
|
22
|
-
HtmlTemplate
|
|
23
|
-
}) {
|
|
24
|
-
try {
|
|
25
|
-
return await this.renderPageWithDocumentShell({
|
|
26
|
-
page: {
|
|
27
|
-
component: Page,
|
|
28
|
-
props: { params, query, ...props, locals: pageLocals }
|
|
29
|
-
},
|
|
30
|
-
layout: Layout ? {
|
|
31
|
-
component: Layout,
|
|
32
|
-
props: locals ? { locals } : {}
|
|
33
|
-
} : void 0,
|
|
34
|
-
htmlTemplate: HtmlTemplate,
|
|
35
|
-
metadata,
|
|
36
|
-
pageProps: props ?? {}
|
|
37
|
-
});
|
|
38
|
-
} catch (error) {
|
|
39
|
-
throw this.createRenderError("Error rendering page", error);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async renderToResponse(view, props, ctx) {
|
|
43
|
-
try {
|
|
44
|
-
return await this.renderViewWithDocumentShell({
|
|
45
|
-
view,
|
|
46
|
-
props,
|
|
47
|
-
ctx,
|
|
48
|
-
layout: view.config?.layout
|
|
49
|
-
});
|
|
50
|
-
} catch (error) {
|
|
51
|
-
throw this.createRenderError("Error rendering view", error);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
5
|
}
|
|
55
6
|
export {
|
|
56
7
|
GhtmlRenderer
|
|
@@ -1,16 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* The Ghtml plugin class
|
|
5
|
-
* This plugin provides support for ghtml components in Ecopages
|
|
6
|
-
*/
|
|
7
|
-
export declare class GhtmlPlugin extends IntegrationPlugin {
|
|
8
|
-
renderer: typeof GhtmlRenderer;
|
|
9
|
-
constructor(options?: Omit<IntegrationPluginConfig, 'name'>);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Factory function to create a Ghtml plugin instance
|
|
13
|
-
* @param options Configuration options for the Ghtml plugin
|
|
14
|
-
* @returns A new GhtmlPlugin instance
|
|
15
|
-
*/
|
|
16
|
-
export declare function ghtmlPlugin(options?: Omit<IntegrationPluginConfig, 'name'>): GhtmlPlugin;
|
|
1
|
+
export declare const ghtmlPlugin: import("../../plugins/define-integration.js").DefinedIntegration<import("../../index.browser.js").EcoPagesElement>;
|
|
2
|
+
/** @deprecated Use {@link ghtmlPlugin.Plugin} or {@link ghtmlPlugin} instead. */
|
|
3
|
+
export declare const GhtmlPlugin: new (options?: Omit<import("../../plugins/integration-plugin.js").IntegrationPluginConfig, "name">) => import("../../plugins/integration-plugin.js").IntegrationPlugin<import("../../index.browser.js").EcoPagesElement>;
|
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineIntegration } from "../../plugins/define-integration.js";
|
|
2
2
|
import { GhtmlRenderer } from "./ghtml-renderer.js";
|
|
3
3
|
import { GHTML_PLUGIN_NAME } from "./ghtml.constants.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
...options
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function ghtmlPlugin(options) {
|
|
15
|
-
return new GhtmlPlugin(options);
|
|
16
|
-
}
|
|
4
|
+
const ghtmlPlugin = defineIntegration({
|
|
5
|
+
name: GHTML_PLUGIN_NAME,
|
|
6
|
+
extensions: [".ghtml.ts", ".ghtml.tsx", ".ghtml"],
|
|
7
|
+
renderer: GhtmlRenderer
|
|
8
|
+
});
|
|
9
|
+
const GhtmlPlugin = ghtmlPlugin.Plugin;
|
|
17
10
|
export {
|
|
18
11
|
GhtmlPlugin,
|
|
19
12
|
ghtmlPlugin
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
+
import type { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
|
|
3
|
+
import type { ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
4
|
+
import type { EcoPagesElement } from '../types/public-types.js';
|
|
5
|
+
import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer.js';
|
|
6
|
+
import { IntegrationPlugin, type IntegrationPluginConfig } from './integration-plugin.js';
|
|
7
|
+
type RendererClass<C> = new (options: {
|
|
8
|
+
appConfig: EcoPagesAppConfig;
|
|
9
|
+
assetProcessingService: AssetProcessingService;
|
|
10
|
+
resolvedIntegrationDependencies: ProcessedAsset[];
|
|
11
|
+
rendererModules?: unknown;
|
|
12
|
+
runtimeOrigin: string;
|
|
13
|
+
}) => IntegrationRenderer<C>;
|
|
14
|
+
export interface DefineIntegrationDefinition<C = EcoPagesElement> extends IntegrationPluginConfig {
|
|
15
|
+
renderer: RendererClass<C>;
|
|
16
|
+
}
|
|
17
|
+
export interface DefinedIntegration<C = EcoPagesElement> {
|
|
18
|
+
(options?: Omit<IntegrationPluginConfig, 'name'>): IntegrationPlugin<C>;
|
|
19
|
+
Plugin: new (options?: Omit<IntegrationPluginConfig, 'name'>) => IntegrationPlugin<C>;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Creates a typed integration plugin factory for integrations that only need
|
|
23
|
+
* declarative config and a renderer class.
|
|
24
|
+
*/
|
|
25
|
+
export declare function defineIntegration<C = EcoPagesElement>(definition: DefineIntegrationDefinition<C>): DefinedIntegration<C>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IntegrationPlugin } from "./integration-plugin.js";
|
|
2
|
+
function defineIntegration(definition) {
|
|
3
|
+
const { renderer, ...defaultConfig } = definition;
|
|
4
|
+
class DefinedIntegrationPlugin extends IntegrationPlugin {
|
|
5
|
+
renderer = renderer;
|
|
6
|
+
constructor(options) {
|
|
7
|
+
super({
|
|
8
|
+
...defaultConfig,
|
|
9
|
+
...options
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const factory = ((options) => new DefinedIntegrationPlugin(options));
|
|
14
|
+
factory.Plugin = DefinedIntegrationPlugin;
|
|
15
|
+
return factory;
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
defineIntegration
|
|
19
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cachedParseSync } from "../cache/module-parse-cache.js";
|
|
2
|
+
import { prependJsxImportSourceIfMissing } from "./jsx-import-source.utils.js";
|
|
2
3
|
import { rapidhash } from "../utils/hash.js";
|
|
3
4
|
import {
|
|
4
5
|
createEcoBuildPluginFromSourceTransform,
|
|
@@ -38,13 +39,6 @@ function detectIntegration(filePath, extensionToIntegration) {
|
|
|
38
39
|
}
|
|
39
40
|
return { name: "ghtml" };
|
|
40
41
|
}
|
|
41
|
-
function prependJsxImportSource(code, jsxImportSource) {
|
|
42
|
-
if (!jsxImportSource || code.includes("@jsxImportSource")) {
|
|
43
|
-
return code;
|
|
44
|
-
}
|
|
45
|
-
return `/** @jsxImportSource ${jsxImportSource} */
|
|
46
|
-
${code}`;
|
|
47
|
-
}
|
|
48
42
|
function createExtensionPattern(extensions) {
|
|
49
43
|
if (extensions.length === 0) {
|
|
50
44
|
throw new Error("[eco-component-meta-plugin] No extensions configured. At least one integration is required.");
|
|
@@ -67,7 +61,10 @@ function createEcoComponentMetaTransform(options) {
|
|
|
67
61
|
transform(code, id) {
|
|
68
62
|
const integration = detectIntegration(id, extensionToIntegration);
|
|
69
63
|
return {
|
|
70
|
-
code:
|
|
64
|
+
code: prependJsxImportSourceIfMissing(
|
|
65
|
+
injectEcoMeta(code, id, integration.name),
|
|
66
|
+
integration.jsxImportSource
|
|
67
|
+
)
|
|
71
68
|
};
|
|
72
69
|
}
|
|
73
70
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { createJsxImportSourcePragma, filterJsxSourceExtensions } from "./jsx-import-source.utils.js";
|
|
3
4
|
function createForeignJsxOverridePlugin(options) {
|
|
4
|
-
const extensions = options.foreignExtensions
|
|
5
|
-
const excludedExtensions = (options.excludeExtensions ?? [])
|
|
6
|
-
(ext) => ext.endsWith(".tsx") || ext.endsWith(".jsx")
|
|
7
|
-
);
|
|
5
|
+
const extensions = filterJsxSourceExtensions(options.foreignExtensions);
|
|
6
|
+
const excludedExtensions = filterJsxSourceExtensions(options.excludeExtensions ?? []);
|
|
8
7
|
if (extensions.length === 0) {
|
|
9
8
|
return {
|
|
10
9
|
name: options.name ?? "foreign-jsx-override",
|
|
@@ -12,8 +11,7 @@ function createForeignJsxOverridePlugin(options) {
|
|
|
12
11
|
}
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
|
-
const pragma =
|
|
16
|
-
`;
|
|
14
|
+
const pragma = createJsxImportSourcePragma(options.hostJsxImportSource);
|
|
17
15
|
const filter = new RegExp(`(${extensions.map((e) => e.replace(".", "\\.")).join("|")})$`);
|
|
18
16
|
return {
|
|
19
17
|
name: options.name ?? "foreign-jsx-override",
|
|
@@ -6,10 +6,12 @@ import type { EcoPagesElement } from '../types/public-types.js';
|
|
|
6
6
|
import type { IntegrationRenderer } from '../route-renderer/orchestration/integration-renderer.js';
|
|
7
7
|
import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
|
|
8
8
|
import type { AssetDefinition, ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
9
|
+
import type { StaticExportContext } from '../static-site-generator/static-export-context.js';
|
|
9
10
|
import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
|
|
10
11
|
export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
|
|
11
12
|
export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/build-types.js';
|
|
12
13
|
export type { PageBrowserGraphContribution, PageBrowserGraphContributionContext } from '../types/public-types.js';
|
|
14
|
+
export type { StaticExportContext } from '../static-site-generator/static-export-context.js';
|
|
13
15
|
export type { HtmlDocumentContribution, HtmlDocumentContributionContext, } from '../route-renderer/orchestration/integration-renderer.js';
|
|
14
16
|
/**
|
|
15
17
|
* Type-erased integration plugin stored in app-level registries.
|
|
@@ -47,13 +49,6 @@ export interface IntegrationPluginConfig {
|
|
|
47
49
|
* They are not specific to any particular page or component.
|
|
48
50
|
*/
|
|
49
51
|
integrationDependencies?: AssetDefinition[];
|
|
50
|
-
/**
|
|
51
|
-
* The strategy to use for static building.
|
|
52
|
-
* - 'render': Execute component function directly (faster, efficient).
|
|
53
|
-
* - 'fetch': Start server and fetch URL (slower, needed for some SSR like Lit).
|
|
54
|
-
* @default 'render'
|
|
55
|
-
*/
|
|
56
|
-
staticBuildStep?: 'render' | 'fetch';
|
|
57
52
|
/**
|
|
58
53
|
* Declares runtime-specific requirements that must be satisfied before the
|
|
59
54
|
* app can start with this integration enabled.
|
|
@@ -96,7 +91,6 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
96
91
|
readonly name: string;
|
|
97
92
|
readonly extensions: string[];
|
|
98
93
|
abstract renderer: RendererClass<C>;
|
|
99
|
-
readonly staticBuildStep: 'render' | 'fetch';
|
|
100
94
|
readonly runtimeCapability?: RuntimeCapabilityDeclaration;
|
|
101
95
|
readonly jsxImportSource?: string;
|
|
102
96
|
protected integrationDependencies: AssetDefinition[];
|
|
@@ -199,7 +193,6 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
199
193
|
* Renderers are cheap runtime objects. They receive the finalized app config,
|
|
200
194
|
* a fresh asset-processing service, integration-global processed assets, and
|
|
201
195
|
* any renderer module context supplied by the active runtime.
|
|
202
|
-
renderer.name ||= this.name;
|
|
203
196
|
*/
|
|
204
197
|
initializeRenderer(options?: {
|
|
205
198
|
rendererModules?: unknown;
|
|
@@ -213,6 +206,23 @@ export declare abstract class IntegrationPlugin<C = EcoPagesElement> {
|
|
|
213
206
|
* `setup()`.
|
|
214
207
|
*/
|
|
215
208
|
prepareBuildContributions(): Promise<void>;
|
|
209
|
+
/**
|
|
210
|
+
* Reports whether this integration's build inputs changed since the last
|
|
211
|
+
* incremental static build.
|
|
212
|
+
*/
|
|
213
|
+
didChange(): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Runs integration-specific setup before static page generation begins.
|
|
216
|
+
*
|
|
217
|
+
* @remarks
|
|
218
|
+
* Integrations that need build-scoped SSR preload or worker sessions should
|
|
219
|
+
* start them here rather than per-page inside the renderer.
|
|
220
|
+
*/
|
|
221
|
+
beforeStaticExport?(_context: StaticExportContext): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Releases resources started in {@link beforeStaticExport}.
|
|
224
|
+
*/
|
|
225
|
+
afterStaticExport?(_context: StaticExportContext): Promise<void>;
|
|
216
226
|
/**
|
|
217
227
|
* Performs runtime-only integration setup after config build has already
|
|
218
228
|
* sealed manifest contributions.
|
|
@@ -15,7 +15,6 @@ function assertIntegrationInvariant(condition, message) {
|
|
|
15
15
|
class IntegrationPlugin {
|
|
16
16
|
name;
|
|
17
17
|
extensions;
|
|
18
|
-
staticBuildStep;
|
|
19
18
|
runtimeCapability;
|
|
20
19
|
jsxImportSource;
|
|
21
20
|
integrationDependencies;
|
|
@@ -60,7 +59,6 @@ class IntegrationPlugin {
|
|
|
60
59
|
this.name = config.name;
|
|
61
60
|
this.extensions = config.extensions;
|
|
62
61
|
this.integrationDependencies = config.integrationDependencies || [];
|
|
63
|
-
this.staticBuildStep = config.staticBuildStep || "render";
|
|
64
62
|
this.runtimeCapability = config.runtimeCapability;
|
|
65
63
|
this.jsxImportSource = config.jsxImportSource;
|
|
66
64
|
}
|
|
@@ -152,7 +150,6 @@ class IntegrationPlugin {
|
|
|
152
150
|
* Renderers are cheap runtime objects. They receive the finalized app config,
|
|
153
151
|
* a fresh asset-processing service, integration-global processed assets, and
|
|
154
152
|
* any renderer module context supplied by the active runtime.
|
|
155
|
-
renderer.name ||= this.name;
|
|
156
153
|
*/
|
|
157
154
|
initializeRenderer(options) {
|
|
158
155
|
const renderer = new this.renderer(this.createRendererOptions(options));
|
|
@@ -169,6 +166,13 @@ class IntegrationPlugin {
|
|
|
169
166
|
*/
|
|
170
167
|
async prepareBuildContributions() {
|
|
171
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Reports whether this integration's build inputs changed since the last
|
|
171
|
+
* incremental static build.
|
|
172
|
+
*/
|
|
173
|
+
didChange() {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
172
176
|
/**
|
|
173
177
|
* Performs runtime-only integration setup after config build has already
|
|
174
178
|
* sealed manifest contributions.
|
|
@@ -180,7 +184,6 @@ class IntegrationPlugin {
|
|
|
180
184
|
this.integrationDependencies,
|
|
181
185
|
this.name
|
|
182
186
|
);
|
|
183
|
-
this.initializeRenderer();
|
|
184
187
|
}
|
|
185
188
|
/**
|
|
186
189
|
* Releases runtime resources owned by the integration.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
+
export declare function createJsxImportSourcePragma(jsxImportSource: string): string;
|
|
3
|
+
export declare function prependJsxImportSourceIfMissing(code: string, jsxImportSource: string | undefined): string;
|
|
4
|
+
export declare function isJsxSourceExtension(extension: string): boolean;
|
|
5
|
+
export declare function filterJsxSourceExtensions(extensions: string[]): string[];
|
|
6
|
+
export declare function collectJsxExtensions(integrations: NonNullable<EcoPagesAppConfig['integrations']>, options?: {
|
|
7
|
+
excludeIntegrationName?: string;
|
|
8
|
+
}): string[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function createJsxImportSourcePragma(jsxImportSource) {
|
|
2
|
+
return `/** @jsxImportSource ${jsxImportSource} */
|
|
3
|
+
`;
|
|
4
|
+
}
|
|
5
|
+
function prependJsxImportSourceIfMissing(code, jsxImportSource) {
|
|
6
|
+
if (!jsxImportSource || code.includes("@jsxImportSource")) {
|
|
7
|
+
return code;
|
|
8
|
+
}
|
|
9
|
+
return createJsxImportSourcePragma(jsxImportSource) + code;
|
|
10
|
+
}
|
|
11
|
+
function isJsxSourceExtension(extension) {
|
|
12
|
+
return extension.endsWith(".tsx") || extension.endsWith(".jsx");
|
|
13
|
+
}
|
|
14
|
+
function filterJsxSourceExtensions(extensions) {
|
|
15
|
+
return extensions.filter(isJsxSourceExtension);
|
|
16
|
+
}
|
|
17
|
+
function collectJsxExtensions(integrations, options) {
|
|
18
|
+
return integrations.filter((integration) => integration.jsxImportSource).filter((integration) => integration.name !== options?.excludeIntegrationName).flatMap((integration) => filterJsxSourceExtensions(integration.extensions));
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
collectJsxExtensions,
|
|
22
|
+
createJsxImportSourcePragma,
|
|
23
|
+
filterJsxSourceExtensions,
|
|
24
|
+
isJsxSourceExtension,
|
|
25
|
+
prependJsxImportSourceIfMissing
|
|
26
|
+
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { EcoBuildPlugin } from '../build/build-types.js';
|
|
2
2
|
import type { EcoPagesAppConfig, IClientBridge } from '../types/internal-types.js';
|
|
3
|
-
import type { AssetDefinition } from '../services/assets/asset-processing-service/assets.types.js';
|
|
4
3
|
import type { RuntimeCapabilityDeclaration } from './runtime-capability.js';
|
|
5
4
|
export type { RuntimeCapabilityDeclaration, RuntimeCapabilityTag } from './runtime-capability.js';
|
|
6
5
|
export type { EcoBuildLoader, EcoBuildOnLoadArgs, EcoBuildOnLoadResult, EcoBuildOnResolveArgs, EcoBuildOnResolveResult, EcoBuildPlugin, EcoBuildPluginBuilder, } from '../build/build-types.js';
|
|
@@ -59,7 +58,6 @@ export interface ProcessorContext {
|
|
|
59
58
|
*/
|
|
60
59
|
export declare abstract class Processor<TOptions = Record<string, unknown>> {
|
|
61
60
|
readonly name: string;
|
|
62
|
-
protected dependencies: AssetDefinition[];
|
|
63
61
|
protected context?: ProcessorContext;
|
|
64
62
|
protected options?: TOptions;
|
|
65
63
|
protected watchConfig?: ProcessorWatchConfig;
|
|
@@ -80,14 +78,31 @@ export declare abstract class Processor<TOptions = Record<string, unknown>> {
|
|
|
80
78
|
* warming or watcher registration should stay in `setup()`.
|
|
81
79
|
*/
|
|
82
80
|
prepareBuildContributions(): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Reports whether this processor's build inputs changed since the last
|
|
83
|
+
* incremental static build.
|
|
84
|
+
*
|
|
85
|
+
* @remarks
|
|
86
|
+
* No shipped processor overrides this today. Integrations and processors can
|
|
87
|
+
* opt in when they own build inputs that should invalidate incremental static
|
|
88
|
+
* exports without a full rebuild.
|
|
89
|
+
*/
|
|
90
|
+
didChange(): boolean;
|
|
83
91
|
abstract setup(): Promise<void>;
|
|
84
|
-
abstract teardown(): Promise<void>;
|
|
85
92
|
abstract process(input: unknown, filePath?: string): Promise<unknown>;
|
|
93
|
+
/**
|
|
94
|
+
* Releases runtime resources owned by the processor.
|
|
95
|
+
*
|
|
96
|
+
* @remarks
|
|
97
|
+
* Core does not call this hook today. Override only when a processor owns
|
|
98
|
+
* watchers, compiler handles, or other resources that outlive individual
|
|
99
|
+
* requests.
|
|
100
|
+
*/
|
|
101
|
+
teardown(): Promise<void>;
|
|
86
102
|
protected getCachePath(key: string): string;
|
|
87
103
|
protected readCache<T>(key: string): Promise<T | null>;
|
|
88
104
|
protected writeCache<T>(key: string, data: T): Promise<void>;
|
|
89
105
|
getWatchConfig(): ProcessorWatchConfig | undefined;
|
|
90
|
-
getDependencies(): AssetDefinition[];
|
|
91
106
|
getName(): string;
|
|
92
107
|
getAssetCapabilities(): ProcessorAssetCapability[];
|
|
93
108
|
matchesFileFilter(_filepath: string): boolean;
|
package/src/plugins/processor.js
CHANGED
|
@@ -16,7 +16,6 @@ function resolveGeneratedPath(type, options) {
|
|
|
16
16
|
}
|
|
17
17
|
class Processor {
|
|
18
18
|
name;
|
|
19
|
-
dependencies = [];
|
|
20
19
|
context;
|
|
21
20
|
options;
|
|
22
21
|
watchConfig;
|
|
@@ -54,6 +53,28 @@ class Processor {
|
|
|
54
53
|
*/
|
|
55
54
|
async prepareBuildContributions() {
|
|
56
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Reports whether this processor's build inputs changed since the last
|
|
58
|
+
* incremental static build.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* No shipped processor overrides this today. Integrations and processors can
|
|
62
|
+
* opt in when they own build inputs that should invalidate incremental static
|
|
63
|
+
* exports without a full rebuild.
|
|
64
|
+
*/
|
|
65
|
+
didChange() {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Releases runtime resources owned by the processor.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* Core does not call this hook today. Override only when a processor owns
|
|
73
|
+
* watchers, compiler handles, or other resources that outlive individual
|
|
74
|
+
* requests.
|
|
75
|
+
*/
|
|
76
|
+
async teardown() {
|
|
77
|
+
}
|
|
57
78
|
getCachePath(key) {
|
|
58
79
|
return `${this.context?.cache}/${key}`;
|
|
59
80
|
}
|
|
@@ -76,9 +97,6 @@ class Processor {
|
|
|
76
97
|
getWatchConfig() {
|
|
77
98
|
return this.watchConfig;
|
|
78
99
|
}
|
|
79
|
-
getDependencies() {
|
|
80
|
-
return this.dependencies;
|
|
81
|
-
}
|
|
82
100
|
getName() {
|
|
83
101
|
return this.name;
|
|
84
102
|
}
|
|
@@ -4,9 +4,21 @@ export interface EcoSourceTransformResult {
|
|
|
4
4
|
code: string;
|
|
5
5
|
map?: unknown;
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* Bundler-neutral source transform registered on {@link EcoPagesAppConfig.sourceTransforms}.
|
|
9
|
+
*
|
|
10
|
+
* @remarks
|
|
11
|
+
* Prefer this shape over a competing {@link EcoBuildPlugin} `onLoad` handler when
|
|
12
|
+
* the transform only rewrites module source. Browser/HMR builds run source
|
|
13
|
+
* transforms after first-wins `onLoad` plugins, so metadata injection and similar
|
|
14
|
+
* passes still run on rewritten output from boundary/runtime plugins.
|
|
15
|
+
*/
|
|
7
16
|
export interface EcoSourceTransform {
|
|
17
|
+
/** Stable transform name. Also used to dedupe loader plugins in browser builds. */
|
|
8
18
|
name: string;
|
|
19
|
+
/** File-path filter tested against {@link normalizeTransformId | normalized ids}. */
|
|
9
20
|
filter: RegExp;
|
|
21
|
+
/** Runs before default transforms, or after them when set to `post`. */
|
|
10
22
|
enforce?: 'pre' | 'post';
|
|
11
23
|
transform(code: string, id: string): EcoSourceTransformResult | string | undefined;
|
|
12
24
|
}
|
|
@@ -24,8 +36,27 @@ export declare function normalizeTransformId(id: string): string;
|
|
|
24
36
|
* Applies one source transform if the normalized id matches its filter.
|
|
25
37
|
*/
|
|
26
38
|
export declare function applySourceTransform(transform: EcoSourceTransform, code: string, id: string): EcoSourceTransformResult | string | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Applies app-owned source transforms in deterministic `pre` → default → `post` order.
|
|
41
|
+
*
|
|
42
|
+
* @remarks
|
|
43
|
+
* Used by the Rolldown plugin bridge after `onLoad` plugins produce final module
|
|
44
|
+
* contents. Transforms that do not match `filter` are skipped; matching transforms
|
|
45
|
+
* are chained left-to-right on the current source string.
|
|
46
|
+
*
|
|
47
|
+
* @param transforms - App-owned transforms, usually from {@link getAppSourceTransforms}.
|
|
48
|
+
* @param code - Current module source.
|
|
49
|
+
* @param id - Module id forwarded to each transform after query/hash normalization.
|
|
50
|
+
* @returns The transformed source, or the original `code` when no transform matches.
|
|
51
|
+
*/
|
|
52
|
+
export declare function applySourceTransforms(transforms: readonly EcoSourceTransform[], code: string, id: string): string;
|
|
27
53
|
/**
|
|
28
54
|
* Adapts a source transform into the existing Ecopages build-plugin contract.
|
|
55
|
+
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* Server-oriented builds and loader registration still use this adapter.
|
|
58
|
+
* Browser/HMR builds should register the transform in `appConfig.sourceTransforms`
|
|
59
|
+
* instead so the Rolldown bridge can run it after competing `onLoad` plugins.
|
|
29
60
|
*/
|
|
30
61
|
export declare function createEcoBuildPluginFromSourceTransform(transform: EcoSourceTransform): EcoBuildPlugin;
|
|
31
62
|
/**
|
|
@@ -13,6 +13,27 @@ function applySourceTransform(transform, code, id) {
|
|
|
13
13
|
}
|
|
14
14
|
return transform.transform(code, normalizedId);
|
|
15
15
|
}
|
|
16
|
+
const SOURCE_TRANSFORM_ENFORCE_ORDER = {
|
|
17
|
+
pre: 0,
|
|
18
|
+
default: 1,
|
|
19
|
+
post: 2
|
|
20
|
+
};
|
|
21
|
+
function getSourceTransformEnforceOrder(transform) {
|
|
22
|
+
return SOURCE_TRANSFORM_ENFORCE_ORDER[transform.enforce ?? "default"];
|
|
23
|
+
}
|
|
24
|
+
function applySourceTransforms(transforms, code, id) {
|
|
25
|
+
let current = code;
|
|
26
|
+
for (const transform of [...transforms].sort(
|
|
27
|
+
(left, right) => getSourceTransformEnforceOrder(left) - getSourceTransformEnforceOrder(right)
|
|
28
|
+
)) {
|
|
29
|
+
const result = applySourceTransform(transform, current, id);
|
|
30
|
+
if (!result) {
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
current = typeof result === "string" ? result : result.code;
|
|
34
|
+
}
|
|
35
|
+
return current;
|
|
36
|
+
}
|
|
16
37
|
function inferLoaderFromPath(filePath) {
|
|
17
38
|
const extension = path.extname(filePath).toLowerCase();
|
|
18
39
|
switch (extension) {
|
|
@@ -56,13 +77,14 @@ function createVitePluginFromSourceTransform(transform) {
|
|
|
56
77
|
};
|
|
57
78
|
}
|
|
58
79
|
function getAppSourceTransforms(appConfig) {
|
|
59
|
-
return Array.from(appConfig.sourceTransforms.values());
|
|
80
|
+
return appConfig.sourceTransforms ? Array.from(appConfig.sourceTransforms.values()) : [];
|
|
60
81
|
}
|
|
61
82
|
function createVitePluginsFromAppSourceTransforms(appConfig) {
|
|
62
83
|
return getAppSourceTransforms(appConfig).map((transform) => createVitePluginFromSourceTransform(transform));
|
|
63
84
|
}
|
|
64
85
|
export {
|
|
65
86
|
applySourceTransform,
|
|
87
|
+
applySourceTransforms,
|
|
66
88
|
createEcoBuildPluginFromSourceTransform,
|
|
67
89
|
createVitePluginFromSourceTransform,
|
|
68
90
|
createVitePluginsFromAppSourceTransforms,
|
|
@@ -33,15 +33,15 @@ flowchart TD
|
|
|
33
33
|
|
|
34
34
|
## 2) Route Render Flow
|
|
35
35
|
|
|
36
|
-
`IntegrationRenderer.execute()` delegates shared route orchestration to `
|
|
36
|
+
`IntegrationRenderer.execute()` delegates shared route orchestration to `RouteRenderOrchestrator`.
|
|
37
37
|
|
|
38
38
|
```mermaid
|
|
39
39
|
flowchart TD
|
|
40
|
-
A[IntegrationRenderer.execute] --> B[
|
|
40
|
+
A[IntegrationRenderer.execute] --> B[RouteRenderOrchestrator.prepareRenderOptions]
|
|
41
41
|
B --> C[resolvePageModule]
|
|
42
42
|
C --> D[ownershipValidationService.validate]
|
|
43
43
|
D --> E[resolvePageData]
|
|
44
|
-
E --> F[
|
|
44
|
+
E --> F[ownershipValidationService.validate + throwIfOwnershipInvalid]
|
|
45
45
|
F --> G[resolveDependencies]
|
|
46
46
|
G --> H[buildPageBrowserGraph]
|
|
47
47
|
H --> I{shouldRenderPageComponent?}
|
|
@@ -77,7 +77,7 @@ flowchart TD
|
|
|
77
77
|
D -- Yes --> E[render inline]
|
|
78
78
|
D -- No --> F[delegate to owning renderer]
|
|
79
79
|
F --> G[owning renderer renderComponentWithForeignChildren]
|
|
80
|
-
G --> H[owning renderer
|
|
80
|
+
G --> H[owning renderer renderComponentWithForeignChildren mapped via toForeignSubtreeRenderPayload]
|
|
81
81
|
H --> I[resolved html plus assets and attachment policy]
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -121,12 +121,12 @@ flowchart TD
|
|
|
121
121
|
The most useful reading order is:
|
|
122
122
|
|
|
123
123
|
1. `route-renderer.ts`
|
|
124
|
-
2. `orchestration/route-render-
|
|
124
|
+
2. `orchestration/route-render-orchestrator.ts`
|
|
125
125
|
3. `orchestration/integration-renderer.ts`
|
|
126
126
|
4. `orchestration/ownership-validation.service.ts`
|
|
127
127
|
5. `orchestration/ownership-planning.service.ts`
|
|
128
128
|
6. `orchestration/component-render-context.ts`
|
|
129
|
-
7. `orchestration/
|
|
129
|
+
7. `orchestration/foreign-subtree-execution.service.ts`
|
|
130
130
|
8. `page-loading/page-module-loader.ts`
|
|
131
131
|
9. `page-loading/dependency-resolver.ts`
|
|
132
132
|
10. `eco/eco.ts`
|
|
@@ -134,12 +134,12 @@ The most useful reading order is:
|
|
|
134
134
|
## 7) Key Files
|
|
135
135
|
|
|
136
136
|
- `packages/core/src/route-renderer/route-renderer.ts`
|
|
137
|
-
- `packages/core/src/route-renderer/orchestration/route-render-
|
|
137
|
+
- `packages/core/src/route-renderer/orchestration/route-render-orchestrator.ts`
|
|
138
138
|
- `packages/core/src/route-renderer/orchestration/integration-renderer.ts`
|
|
139
139
|
- `packages/core/src/route-renderer/orchestration/ownership-validation.service.ts`
|
|
140
140
|
- `packages/core/src/route-renderer/orchestration/ownership-planning.service.ts`
|
|
141
141
|
- `packages/core/src/route-renderer/orchestration/component-render-context.ts`
|
|
142
|
-
- `packages/core/src/route-renderer/orchestration/
|
|
142
|
+
- `packages/core/src/route-renderer/orchestration/foreign-subtree-execution.service.ts`
|
|
143
143
|
- `packages/core/src/route-renderer/page-loading/page-module-loader.ts`
|
|
144
144
|
- `packages/core/src/route-renderer/page-loading/dependency-resolver.ts`
|
|
145
145
|
- `packages/core/src/eco/eco.ts`
|