@ecopages/core 0.2.0-rc.10 → 0.2.0-rc.11
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 +0 -9
- package/package.json +3 -144
- package/src/adapters/README.md +8 -2
- package/src/adapters/abstract/application-adapter.d.ts +6 -32
- package/src/adapters/abstract/application-adapter.js +6 -45
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +0 -5
- package/src/adapters/abstract/ws-pattern-matcher.js +0 -9
- package/src/adapters/bun/create-app.d.ts +8 -12
- package/src/adapters/bun/create-app.js +13 -55
- package/src/adapters/bun/hmr-manager.d.ts +0 -1
- package/src/adapters/bun/hmr-manager.js +2 -4
- package/src/adapters/bun/server-adapter.d.ts +9 -19
- package/src/adapters/bun/server-adapter.js +19 -66
- package/src/adapters/bun/static-preview-host.d.ts +1 -0
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/create-app.d.ts +1 -1
- package/src/adapters/create-app.js +2 -1
- package/src/adapters/node/create-app.d.ts +4 -8
- package/src/adapters/node/create-app.js +7 -12
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +4 -4
- package/src/adapters/node/server-adapter-dependencies.d.ts +2 -10
- package/src/adapters/node/server-adapter-dependencies.js +8 -13
- package/src/adapters/node/server-adapter.d.ts +25 -31
- package/src/adapters/node/server-adapter.js +43 -64
- package/src/adapters/shared/hmr/shared-hmr-manager.d.ts +0 -4
- package/src/adapters/shared/hmr/shared-hmr-manager.js +0 -12
- package/src/adapters/shared/http/api-request-pipeline.d.ts +27 -1
- package/src/adapters/shared/http/api-request-pipeline.js +31 -16
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +0 -1
- package/src/adapters/shared/http/fs-server-response-factory.js +0 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.d.ts +1 -3
- package/src/adapters/shared/runtime/collect-dev-prewarm-plan.js +1 -4
- package/src/adapters/shared/runtime/runtime-app-bootstrap.d.ts +0 -10
- package/src/adapters/shared/runtime/runtime-app-bootstrap.js +0 -7
- package/src/adapters/shared/runtime/runtime-host.d.ts +5 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +1 -1
- package/src/adapters/shared/runtime/server-adapter.d.ts +13 -0
- package/src/adapters/shared/runtime/server-adapter.js +22 -0
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +9 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +8 -2
- package/src/build/README.md +5 -6
- package/src/build/cache/cache-constants.d.ts +0 -2
- package/src/build/cache/cache-constants.js +0 -2
- package/src/build/cache/cache-keys.d.ts +0 -2
- package/src/build/cache/cache-keys.js +0 -2
- package/src/build/cache/output-imports.d.ts +27 -0
- package/src/build/cache/output-imports.js +80 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +6 -1
- package/src/build/cache/pages-unified-graph-build.js +42 -17
- package/src/build/cache/production-build-cache.d.ts +2 -2
- package/src/build/cache/production-build-cache.js +2 -2
- package/src/build/cache/server-entry-build-cache.d.ts +1 -2
- package/src/build/cache/server-entry-build-cache.js +4 -5
- package/src/build/contracts/build-contracts.d.ts +1 -13
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -6
- package/src/build/runtime/build-request-identity.d.ts +2 -6
- package/src/build/runtime/build-request-identity.js +2 -8
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/cache/index.d.ts +1 -1
- package/src/cache/index.js +1 -1
- package/src/cache/module-parse-cache.d.ts +2 -29
- package/src/cache/module-parse-cache.js +6 -39
- package/src/config/README.md +3 -3
- package/src/config/apply-user-config.d.ts +3 -1
- package/src/config/apply-user-config.js +3 -2
- package/src/config/config-builder.d.ts +1 -0
- package/src/config/config-builder.js +2 -2
- package/src/config/constants.d.ts +0 -4
- package/src/config/constants.js +0 -4
- package/src/config/index.d.ts +1 -1
- package/src/config/index.js +1 -1
- package/src/config/load-eco-config.d.ts +1 -1
- package/src/config/load-eco-config.js +18 -11
- package/src/config/resolve-eco-config-path.d.ts +9 -0
- package/src/config/resolve-eco-config-path.js +11 -0
- package/src/config/server-config-bundle.js +2 -2
- package/src/config/user-config-types.d.ts +9 -3
- package/src/dev/host-runtime.d.ts +0 -1
- package/src/dev/host-runtime.js +0 -3
- package/src/dev/sc-server.d.ts +4 -1
- package/src/dev/sc-server.js +11 -20
- package/src/dev/transform-server/dev-transform-import-rewriter.js +2 -2
- package/src/hmr/hmr-file-change-prep.d.ts +0 -1
- package/src/hmr/hmr-file-change-prep.js +2 -5
- package/src/hmr/hmr-strategy.d.ts +3 -8
- package/src/hmr/hmr-strategy.js +3 -8
- package/src/index.browser.d.ts +1 -2
- package/src/index.browser.js +1 -2
- package/src/index.d.ts +5 -6
- package/src/index.js +5 -6
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/component-import-discovery.js +2 -2
- package/src/plugins/eco-component-meta-plugin.js +5 -5
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -4
- package/src/route-renderer/orchestration/integration-renderer.d.ts +0 -6
- package/src/route-renderer/orchestration/integration-renderer.js +1 -11
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +1 -1
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -1
- package/src/services/README.md +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/default-error-pages.d.ts +1 -6
- package/src/services/error-pages/default-error-pages.js +0 -8
- package/src/services/html/html-rewriter.d.ts +77 -0
- package/src/services/html/html-rewriter.js +751 -0
- package/src/services/html/html-rewriter.parity.test.bun.d.ts +1 -0
- package/src/services/html/html-rewriter.parity.test.bun.js +74 -0
- package/src/services/html/html-transformer.service.d.ts +26 -39
- package/src/services/html/html-transformer.service.js +81 -153
- package/src/services/invalidation/development-invalidation.service.d.ts +2 -19
- package/src/services/invalidation/development-invalidation.service.js +1 -39
- package/src/services/module-loading/README.md +1 -1
- package/src/services/module-loading/app-module-loader.service.d.ts +0 -2
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +1 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +0 -10
- package/src/services/module-loading/collection-server-module-build.service.d.ts +0 -1
- package/src/services/module-loading/collection-server-module-build.service.js +0 -3
- package/src/services/module-loading/host-module-loader-registry.d.ts +0 -1
- package/src/services/module-loading/host-module-loader-registry.js +0 -3
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache-registry.js +0 -4
- package/src/services/module-loading/route-module-build-cache.store.d.ts +3 -0
- package/src/services/module-loading/route-module-build-cache.store.js +18 -5
- package/src/services/module-loading/route-module-build-manifest.d.ts +6 -1
- package/src/services/module-loading/route-module-build-manifest.js +1 -2
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/server-module-transpiler.service.d.ts +1 -15
- package/src/services/module-loading/server-module-transpiler.service.js +0 -24
- package/src/services/runtime-state/entrypoint-dependency-graph.service.js +0 -12
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +4 -2
- package/src/services/runtime-state/server-invalidation-state.service.js +7 -14
- package/src/types/internal-types.d.ts +0 -38
- package/src/types/public-types.d.ts +0 -112
- package/src/watchers/project-watcher.d.ts +0 -15
- package/src/watchers/project-watcher.js +1 -27
- package/src/watchers/project-watcher.test-helpers.d.ts +10 -1
- package/src/watchers/project-watcher.test-helpers.js +12 -0
- package/src/adapters/abstract/router-adapter.d.ts +0 -26
- package/src/adapters/abstract/router-adapter.js +0 -13
- package/src/adapters/bun/index.d.ts +0 -2
- package/src/adapters/bun/index.js +0 -2
- package/src/adapters/index.d.ts +0 -2
- package/src/adapters/index.js +0 -2
- package/src/eco/eco.utils.d.ts +0 -1
- package/src/eco/eco.utils.js +0 -1
- package/src/services/cache/index.d.ts +0 -9
- package/src/services/cache/index.js +0 -8
- package/src/services/html/html-rewriter-provider.service.d.ts +0 -40
- package/src/services/html/html-rewriter-provider.service.js +0 -68
- package/src/services/module-loading/route-module-build-cache.d.ts +0 -4
- package/src/services/module-loading/route-module-build-cache.js +0 -3
- package/src/services/runtime-state/dev-graph.service.d.ts +0 -118
- package/src/services/runtime-state/dev-graph.service.js +0 -170
package/src/index.browser.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export type * from './eco/eco.types.js';
|
|
|
3
3
|
export { eco } from './eco/eco.browser.js';
|
|
4
4
|
export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
|
|
5
5
|
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
6
|
-
export {
|
|
7
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
6
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
package/src/index.browser.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { eco } from './eco/eco.browser.js';
|
|
2
2
|
export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
|
|
3
3
|
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
4
|
-
export {
|
|
5
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
4
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
package/src/index.d.ts
CHANGED
|
@@ -2,11 +2,10 @@ export type * from './types/public-types.js';
|
|
|
2
2
|
export type * from './eco/eco.types.js';
|
|
3
3
|
export { eco } from './eco/eco.js';
|
|
4
4
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, type GroupHandler, } from './adapters/shared/http/define-api-handler.js';
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
5
|
+
export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
|
|
6
|
+
export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
7
7
|
export { bindComponentIdentity, getComponentIdentity, type ComponentIdentity } from './eco/component-identity.js';
|
|
8
|
-
export { attachDiscoveredDependencies
|
|
9
|
-
export {
|
|
10
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
8
|
+
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
9
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
|
11
10
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
12
|
-
export { buildIslandHostAttributes,
|
|
11
|
+
export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
|
package/src/index.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
export { eco } from './eco/eco.js';
|
|
2
2
|
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, } from './adapters/shared/http/define-api-handler.js';
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
3
|
+
export { createVitePluginsFromAppSourceTransforms, createVitePluginFromSourceTransform, } from './plugins/source-transform.js';
|
|
4
|
+
export { attributeMdxComponentIdentity, createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
5
5
|
export { bindComponentIdentity, getComponentIdentity } from './eco/component-identity.js';
|
|
6
|
-
export { attachDiscoveredDependencies
|
|
7
|
-
export {
|
|
8
|
-
export { mergeLayoutDependencies } from './eco/page-layout-normalization.js';
|
|
6
|
+
export { attachDiscoveredDependencies } from './eco/discovered-dependencies.js';
|
|
7
|
+
export { mergePageDependencies } from './eco/page-dependency-contributions.js';
|
|
9
8
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
|
10
|
-
export { buildIslandHostAttributes,
|
|
9
|
+
export { buildIslandHostAttributes, finalizeIslandComponentRender } from './islands/island-host.js';
|
|
@@ -10,16 +10,7 @@ export type IslandHostAttributesInput = {
|
|
|
10
10
|
props?: Record<string, unknown>;
|
|
11
11
|
existing?: Record<string, string>;
|
|
12
12
|
};
|
|
13
|
-
/**
|
|
14
|
-
* @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
|
|
15
|
-
*/
|
|
16
|
-
export declare function mergeIslandHostAttributes(input: {
|
|
17
|
-
integrationName: string;
|
|
18
|
-
componentInstanceId: string;
|
|
19
|
-
existing?: Record<string, string>;
|
|
20
|
-
}): Record<string, string>;
|
|
21
13
|
export declare function buildIslandHostAttributes(input: IslandHostAttributesInput): Record<string, string>;
|
|
22
|
-
export declare function isIslandHostElement(element: Element): boolean;
|
|
23
14
|
export declare function componentRenderHasIslandBootstrap(assets: Array<{
|
|
24
15
|
kind: string;
|
|
25
16
|
}> | undefined): boolean;
|
|
@@ -6,7 +6,7 @@ export const ECO_ISLAND_PROPS_ATTRIBUTE = 'data-eco-props';
|
|
|
6
6
|
/**
|
|
7
7
|
* @remarks Presence marker for hydratable component hosts, similar in spirit to Astro's `astro-island`.
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
function mergeIslandHostAttributes(input) {
|
|
10
10
|
return {
|
|
11
11
|
...input.existing,
|
|
12
12
|
[ECO_ISLAND_HOST_ATTRIBUTE]: '',
|
|
@@ -24,18 +24,6 @@ export function buildIslandHostAttributes(input) {
|
|
|
24
24
|
}
|
|
25
25
|
return attributes;
|
|
26
26
|
}
|
|
27
|
-
export function isIslandHostElement(element) {
|
|
28
|
-
if (element.hasAttribute(ECO_ISLAND_HOST_ATTRIBUTE)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (element.hasAttribute(ECO_ISLAND_COMPONENT_KEY_ATTRIBUTE)) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
if (element.tagName.toLowerCase() === 'eco-island') {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
return element.hasAttribute(ECO_ISLAND_COMPONENT_ID_ATTRIBUTE) && element.hasAttribute(ECO_ISLAND_PROPS_ATTRIBUTE);
|
|
38
|
-
}
|
|
39
27
|
export function componentRenderHasIslandBootstrap(assets) {
|
|
40
28
|
return (assets ?? []).some((asset) => asset.kind === 'script');
|
|
41
29
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { existsSync, readFileSync, realpathSync } from 'node:fs';
|
|
3
|
-
import {
|
|
3
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
4
|
import { loadTsconfigPathPrefixes, matchesTsconfigPathPrefix, resolveProjectModulePath, } from './tsconfig-import-resolver.js';
|
|
5
5
|
function node(value) {
|
|
6
6
|
return typeof value === 'object' && value !== null ? value : undefined;
|
|
@@ -90,7 +90,7 @@ function indexModuleExports(file, cache) {
|
|
|
90
90
|
if (cached)
|
|
91
91
|
return cached;
|
|
92
92
|
const source = readFileSync(file, 'utf8');
|
|
93
|
-
const parsed =
|
|
93
|
+
const parsed = parseModuleSource(file, source, { sourceType: 'module' });
|
|
94
94
|
const body = nodes(parsed.program.body);
|
|
95
95
|
const { declared, factories } = collectDeclaredFactoryBindings(body);
|
|
96
96
|
const namedReexports = new Map();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { prependJsxImportSourceIfMissing } from './jsx-import-source.utils.js';
|
|
2
2
|
import { createEcoBuildPluginFromSourceTransform, createVitePluginFromSourceTransform } from './source-transform.js';
|
|
3
|
-
import {
|
|
3
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
4
4
|
import { rapidhash } from '../utils/hash.js';
|
|
5
5
|
import { discoverComponentImports } from './component-import-discovery.js';
|
|
6
6
|
function integrationForFile(filePath, config) {
|
|
@@ -98,7 +98,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
98
98
|
return contents;
|
|
99
99
|
let program;
|
|
100
100
|
try {
|
|
101
|
-
program =
|
|
101
|
+
program = parseModuleSource(filePath, contents, { sourceType: 'module' }).program;
|
|
102
102
|
}
|
|
103
103
|
catch {
|
|
104
104
|
return contents;
|
|
@@ -133,7 +133,7 @@ export function attributeComponentIdentity(contents, filePath, integration, proj
|
|
|
133
133
|
for (const edit of edits.sort((left, right) => right.start - left.start)) {
|
|
134
134
|
transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
|
|
135
135
|
}
|
|
136
|
-
return addIdentityBindingImport(transformed,
|
|
136
|
+
return addIdentityBindingImport(transformed, parseModuleSource(filePath, transformed, { sourceType: 'module' }).program);
|
|
137
137
|
}
|
|
138
138
|
function findMdxConfigDeclarator(program) {
|
|
139
139
|
for (const statement of nodes(program?.body)) {
|
|
@@ -180,7 +180,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
180
180
|
}
|
|
181
181
|
let program;
|
|
182
182
|
try {
|
|
183
|
-
program =
|
|
183
|
+
program = parseModuleSource(filePath, contents, { lang: 'jsx', sourceType: 'module' })
|
|
184
184
|
.program;
|
|
185
185
|
}
|
|
186
186
|
catch {
|
|
@@ -206,7 +206,7 @@ export function attributeMdxComponentIdentity(contents, filePath, integration, p
|
|
|
206
206
|
transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
|
|
207
207
|
}
|
|
208
208
|
transformed = `${transformed}\n${appended}`;
|
|
209
|
-
return addNamedImport(transformed,
|
|
209
|
+
return addNamedImport(transformed, parseModuleSource(filePath, transformed, { lang: 'jsx', sourceType: 'module' }).program, '@ecopages/core', ['bindComponentIdentity', 'attachDiscoveredDependencies']);
|
|
210
210
|
}
|
|
211
211
|
export function createEcoComponentMetaTransform(options) {
|
|
212
212
|
const extensions = options.config.integrations
|
|
@@ -25,7 +25,6 @@ export declare const INTEGRATION_PLUGIN_ERRORS: {
|
|
|
25
25
|
readonly NOT_INITIALIZED_WITH_ASSET_SERVICE: "Plugin not initialized with asset dependency service";
|
|
26
26
|
};
|
|
27
27
|
export declare function mergeIntegrationOptions<TDefaults, TOverrides>(defaults: TDefaults, overrides: TOverrides): TDefaults & TOverrides;
|
|
28
|
-
export declare function assertIntegrationInvariant(condition: boolean, message?: string): asserts condition;
|
|
29
28
|
/**
|
|
30
29
|
* Base configuration shared by all integration plugins.
|
|
31
30
|
*
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createBrowserRuntimeManifest, } from '../build/browser/browser-runtime-manifest.js';
|
|
2
2
|
import { AssetProcessingService } from '../services/assets/asset-processing-service/asset-processing.service.js';
|
|
3
3
|
import { deepMerge } from '../utils/deep-merge.js';
|
|
4
|
-
import { invariant } from '../utils/invariant.js';
|
|
5
4
|
export const INTEGRATION_PLUGIN_ERRORS = {
|
|
6
5
|
NOT_INITIALIZED_WITH_APP_CONFIG: 'Plugin not initialized with app config',
|
|
7
6
|
NOT_INITIALIZED_WITH_ASSET_SERVICE: 'Plugin not initialized with asset dependency service',
|
|
@@ -9,9 +8,6 @@ export const INTEGRATION_PLUGIN_ERRORS = {
|
|
|
9
8
|
export function mergeIntegrationOptions(defaults, overrides) {
|
|
10
9
|
return deepMerge(defaults, overrides);
|
|
11
10
|
}
|
|
12
|
-
export function assertIntegrationInvariant(condition, message) {
|
|
13
|
-
invariant(condition, message);
|
|
14
|
-
}
|
|
15
11
|
/**
|
|
16
12
|
* Base class for framework integrations.
|
|
17
13
|
*
|
|
@@ -150,8 +150,5 @@ export async function finalizeDocumentShellHtml(htmlTransformer, options) {
|
|
|
150
150
|
if (!shouldTransform) {
|
|
151
151
|
return html;
|
|
152
152
|
}
|
|
153
|
-
|
|
154
|
-
headers: { 'Content-Type': 'text/html' },
|
|
155
|
-
}), options.htmlContributions);
|
|
156
|
-
return await transformedResponse.text();
|
|
153
|
+
return htmlTransformer.transformHtml(html, options.htmlContributions);
|
|
157
154
|
}
|
|
@@ -325,7 +325,6 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
325
325
|
* other runtime coordination markers without relying on script sniffing.
|
|
326
326
|
*/
|
|
327
327
|
protected getDocumentAttributes(_renderOptions: IntegrationRendererRenderOptions<C>): Record<string, string> | undefined;
|
|
328
|
-
protected applyAttributesToFirstBodyElement(html: string, attributes: Record<string, string>): string;
|
|
329
328
|
protected applyAttributesToHtmlElement(html: string, attributes: Record<string, string>): string;
|
|
330
329
|
/**
|
|
331
330
|
* Returns declarative HTML fragments that core should inject into the final document.
|
|
@@ -424,9 +423,4 @@ export declare abstract class IntegrationRenderer<C = EcoPagesElement> {
|
|
|
424
423
|
renderInput: ComponentRenderInput;
|
|
425
424
|
rendererCache: Map<string, IntegrationRenderer<any>>;
|
|
426
425
|
}): ForeignChildRuntime;
|
|
427
|
-
/**
|
|
428
|
-
* Creates an explicit fail-fast runtime for tests or renderers that do not
|
|
429
|
-
* support cross-integration foreign-child execution.
|
|
430
|
-
*/
|
|
431
|
-
protected createFailFastForeignChildRuntime(): ForeignChildRuntime;
|
|
432
426
|
}
|
|
@@ -547,7 +547,7 @@ export class IntegrationRenderer {
|
|
|
547
547
|
applyAttributesToHtmlElement: (html, attributes) => this.applyAttributesToHtmlElement(html, attributes),
|
|
548
548
|
transformRouteResponse: async (response, htmlContributions, pagePackage) => {
|
|
549
549
|
const resolvedPagePackage = this.htmlTransformer.getPagePackage() ?? pagePackage;
|
|
550
|
-
const transformedResponse =
|
|
550
|
+
const transformedResponse = this.htmlTransformer.transform(response, htmlContributions, resolvedPagePackage);
|
|
551
551
|
return (transformedResponse.body ?? (await transformedResponse.text()));
|
|
552
552
|
},
|
|
553
553
|
});
|
|
@@ -670,9 +670,6 @@ export class IntegrationRenderer {
|
|
|
670
670
|
getDocumentAttributes(_renderOptions) {
|
|
671
671
|
return undefined;
|
|
672
672
|
}
|
|
673
|
-
applyAttributesToFirstBodyElement(html, attributes) {
|
|
674
|
-
return this.htmlTransformer.applyAttributesToFirstBodyElement(html, attributes);
|
|
675
|
-
}
|
|
676
673
|
applyAttributesToHtmlElement(html, attributes) {
|
|
677
674
|
return this.htmlTransformer.applyAttributesToHtmlElement(html, attributes);
|
|
678
675
|
}
|
|
@@ -809,11 +806,4 @@ export class IntegrationRenderer {
|
|
|
809
806
|
tokenPrefix: getForeignSubtreeTokenPrefix(this.name),
|
|
810
807
|
});
|
|
811
808
|
}
|
|
812
|
-
/**
|
|
813
|
-
* Creates an explicit fail-fast runtime for tests or renderers that do not
|
|
814
|
-
* support cross-integration foreign-child execution.
|
|
815
|
-
*/
|
|
816
|
-
createFailFastForeignChildRuntime() {
|
|
817
|
-
return this.foreignSubtreeExecutionService.createFailFastRuntime(this.name);
|
|
818
|
-
}
|
|
819
809
|
}
|
|
@@ -163,7 +163,7 @@ export class TestIntegrationRenderer extends IntegrationRenderer {
|
|
|
163
163
|
createForeignChildRuntime(options) {
|
|
164
164
|
this.ForeignChildRuntimeCreationCount += 1;
|
|
165
165
|
if (this.UseFailFastForeignChildRuntime) {
|
|
166
|
-
return this.
|
|
166
|
+
return this.foreignSubtreeExecutionService.createFailFastRuntime(this.name);
|
|
167
167
|
}
|
|
168
168
|
return super.createForeignChildRuntime(options);
|
|
169
169
|
}
|
|
@@ -110,7 +110,7 @@ export declare function getAppPageBrowserGraphSession(appConfig: EcoPagesAppConf
|
|
|
110
110
|
/**
|
|
111
111
|
* Invalidates graph records that depend on the changed file path.
|
|
112
112
|
*/
|
|
113
|
-
export declare function invalidatePageBrowserGraphSession(appConfig: EcoPagesAppConfig, filePath: string):
|
|
113
|
+
export declare function invalidatePageBrowserGraphSession(appConfig: EcoPagesAppConfig, filePath: string): void;
|
|
114
114
|
/**
|
|
115
115
|
* Returns graph identities affected by a source file change.
|
|
116
116
|
*/
|
|
@@ -474,7 +474,7 @@ export function getAppPageBrowserGraphSession(appConfig) {
|
|
|
474
474
|
* Invalidates graph records that depend on the changed file path.
|
|
475
475
|
*/
|
|
476
476
|
export function invalidatePageBrowserGraphSession(appConfig, filePath) {
|
|
477
|
-
|
|
477
|
+
getAppPageBrowserGraphSession(appConfig).invalidateByFilePath(filePath);
|
|
478
478
|
}
|
|
479
479
|
/**
|
|
480
480
|
* Returns graph identities affected by a source file change.
|
package/src/services/README.md
CHANGED
|
@@ -22,7 +22,7 @@ Typical responsibilities include:
|
|
|
22
22
|
- `invalidation/`: file-change classification and invalidation policy
|
|
23
23
|
- `runtime-state/`: app-owned invalidation state and dependency graphs
|
|
24
24
|
- `runtime-manifest/`: node runtime manifest derivation and persistence
|
|
25
|
-
- `html/`: final HTML dependency injection and rewriter
|
|
25
|
+
- `html/`: final HTML dependency injection and attribute stamping through `HtmlRewriter`, an in-house streaming rewriter with a subset of Bun's `HTMLRewriter` API that matches lol-html output (tag-name selectors; `before`/`prepend`/`append`/`after`; attributes). It runs the same way on Bun and Node, and `html-rewriter.parity.test.bun.ts` checks it against the native rewriter.
|
|
26
26
|
- `error-pages/`: shared semantic 404/500 source precedence, rendering, built-in documents, and static export artifacts
|
|
27
27
|
|
|
28
28
|
The asset-processing service caches emitted file assets by source identity in development as well as production.
|
|
@@ -22,7 +22,6 @@ import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
|
22
22
|
export type BrowserBundleOptions = {
|
|
23
23
|
entrypoints: string[] | Record<string, string>;
|
|
24
24
|
outdir?: string;
|
|
25
|
-
outbase?: string;
|
|
26
25
|
naming?: string;
|
|
27
26
|
conditions?: string[];
|
|
28
27
|
define?: Record<string, string>;
|
|
@@ -30,7 +29,6 @@ export type BrowserBundleOptions = {
|
|
|
30
29
|
treeshaking?: boolean;
|
|
31
30
|
splitting?: boolean;
|
|
32
31
|
root?: string;
|
|
33
|
-
bundle?: boolean;
|
|
34
32
|
externalPackages?: boolean;
|
|
35
33
|
external?: string[];
|
|
36
34
|
plugins?: EcoBuildPlugin[];
|
|
@@ -39,9 +37,6 @@ export type BrowserBundleOptions = {
|
|
|
39
37
|
excludeAppBuildPlugins?: string[];
|
|
40
38
|
};
|
|
41
39
|
type BrowserBundleGroupedOptions = Omit<BrowserBundleOptions, 'entrypoints'>;
|
|
42
|
-
export interface BrowserBundleExecutor {
|
|
43
|
-
bundle(options: BrowserBundleOptions): Promise<BuildResult>;
|
|
44
|
-
}
|
|
45
40
|
export type BrowserBundleGroupedEntry = {
|
|
46
41
|
entrypoint: string;
|
|
47
42
|
entryName: string;
|
|
@@ -54,7 +49,7 @@ export type BrowserBundleGroupedEntry = {
|
|
|
54
49
|
* the app-owned executor rather than direct backend calls. Assembles a complete
|
|
55
50
|
* request via {@link createBrowserBuildRequest} before scheduling.
|
|
56
51
|
*/
|
|
57
|
-
export declare class BrowserBundleService
|
|
52
|
+
export declare class BrowserBundleService {
|
|
58
53
|
private readonly appConfig;
|
|
59
54
|
constructor(appConfig: EcoPagesAppConfig);
|
|
60
55
|
/**
|
|
@@ -35,10 +35,5 @@ export type DefaultErrorPageDetails = {
|
|
|
35
35
|
* button. 4xx pages never serialize a stack.
|
|
36
36
|
*/
|
|
37
37
|
export declare function buildDefaultErrorHtml(status: number, details?: DefaultErrorPageDetails): string;
|
|
38
|
-
|
|
39
|
-
export declare function buildDefaultNotFoundHtml(): string;
|
|
40
|
-
export type DefaultServerErrorDetails = DefaultErrorPageDetails;
|
|
41
|
-
export declare function getDefaultServerErrorDetails(error: unknown): DefaultServerErrorDetails | undefined;
|
|
38
|
+
export declare function getDefaultServerErrorDetails(error: unknown): DefaultErrorPageDetails | undefined;
|
|
42
39
|
export declare function getPublicErrorMessage(error: unknown): string | undefined;
|
|
43
|
-
/** Self-contained HTML for the framework default server-error response. */
|
|
44
|
-
export declare function buildDefaultServerErrorHtml(details?: DefaultServerErrorDetails): string;
|
|
@@ -181,10 +181,6 @@ export function buildDefaultErrorHtml(status, details) {
|
|
|
181
181
|
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${escapeHtml(view.title)}</title><style>${sharedStyles}</style></head>
|
|
182
182
|
<body class="${names.root} ${view.modifierClass}"><main class="${names.content}"><p class="${names.status}" aria-hidden="true">ERROR ${view.status}</p><h1 class="${names.title}">${escapeHtml(view.title)}</h1><p class="${names.message}">${escapeHtml(view.bodyMessage)}</p>${detailsBlock}</main></body></html>`;
|
|
183
183
|
}
|
|
184
|
-
/** Self-contained HTML for the framework default not-found response. */
|
|
185
|
-
export function buildDefaultNotFoundHtml() {
|
|
186
|
-
return buildDefaultErrorHtml(404);
|
|
187
|
-
}
|
|
188
184
|
export function getDefaultServerErrorDetails(error) {
|
|
189
185
|
if (!isDevelopmentRuntime() || error === undefined) {
|
|
190
186
|
return undefined;
|
|
@@ -201,7 +197,3 @@ export function getPublicErrorMessage(error) {
|
|
|
201
197
|
}
|
|
202
198
|
return undefined;
|
|
203
199
|
}
|
|
204
|
-
/** Self-contained HTML for the framework default server-error response. */
|
|
205
|
-
export function buildDefaultServerErrorHtml(details) {
|
|
206
|
-
return buildDefaultErrorHtml(500, details);
|
|
207
|
-
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export type HtmlContentOptions = {
|
|
2
|
+
/** Insert `content` as raw markup. Otherwise it is inserted as escaped text. */
|
|
3
|
+
html?: boolean;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Element passed to {@link HtmlRewriterElementHandlers.element}; a subset of Bun's
|
|
7
|
+
* `HTMLRewriter` element API.
|
|
8
|
+
*/
|
|
9
|
+
export interface HtmlRewriterElement {
|
|
10
|
+
/** Lowercased tag name. */
|
|
11
|
+
readonly tagName: string;
|
|
12
|
+
/** Attribute name/value pairs, names lowercased. */
|
|
13
|
+
readonly attributes: IterableIterator<[string, string]>;
|
|
14
|
+
readonly selfClosing: boolean;
|
|
15
|
+
/** `false` for void elements (and self-closing foreign elements), which ignore `prepend`/`append`. */
|
|
16
|
+
readonly canHaveContent: boolean;
|
|
17
|
+
getAttribute(name: string): string | null;
|
|
18
|
+
hasAttribute(name: string): boolean;
|
|
19
|
+
setAttribute(name: string, value: string): HtmlRewriterElement;
|
|
20
|
+
removeAttribute(name: string): HtmlRewriterElement;
|
|
21
|
+
before(content: string, options?: HtmlContentOptions): HtmlRewriterElement;
|
|
22
|
+
/** Inserts right after the start tag; repeated calls insert in reverse call order. */
|
|
23
|
+
prepend(content: string, options?: HtmlContentOptions): HtmlRewriterElement;
|
|
24
|
+
/** Inserts right before the end tag; dropped when the element never closes. */
|
|
25
|
+
append(content: string, options?: HtmlContentOptions): HtmlRewriterElement;
|
|
26
|
+
/** Inserts after the end tag in reverse call order; dropped when the element never closes. */
|
|
27
|
+
after(content: string, options?: HtmlContentOptions): HtmlRewriterElement;
|
|
28
|
+
}
|
|
29
|
+
export interface HtmlRewriterElementHandlers {
|
|
30
|
+
element?(element: HtmlRewriterElement): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Streaming HTML rewriter implementing the subset of Bun's `HTMLRewriter` API that
|
|
34
|
+
* Ecopages uses, so the same rewrite runs on Bun and Node without a wasm build of
|
|
35
|
+
* lol-html.
|
|
36
|
+
*
|
|
37
|
+
* @remarks
|
|
38
|
+
* Supported selectors are tag names and `*`; anything else throws so an
|
|
39
|
+
* unsupported selector never silently matches nothing. Handlers are synchronous.
|
|
40
|
+
*
|
|
41
|
+
* Output follows lol-html (checked against Bun's native `HTMLRewriter`) on the
|
|
42
|
+
* behaviour Ecopages relies on: comments, doctypes and the content of raw-text
|
|
43
|
+
* elements (`script` with its escape states, `style`, `textarea`, `title`,
|
|
44
|
+
* `noscript`, `iframe`, `xmp`, `noembed`, `noframes`, `plaintext`) never produce
|
|
45
|
+
* tags; `>` inside quoted attribute values does not end a tag; tag matching is
|
|
46
|
+
* case-insensitive; untouched attributes keep their original text.
|
|
47
|
+
*
|
|
48
|
+
* There is no tree construction. An end tag closes the nearest open element with
|
|
49
|
+
* the same name, and `append`/`after` content of elements that it closes
|
|
50
|
+
* implicitly, or that are still open at the end of the document, is dropped.
|
|
51
|
+
*/
|
|
52
|
+
export declare class HtmlRewriter {
|
|
53
|
+
private readonly handlers;
|
|
54
|
+
on(selector: string, handlers: HtmlRewriterElementHandlers): this;
|
|
55
|
+
transform(input: string): string;
|
|
56
|
+
transform(input: Response): Response;
|
|
57
|
+
}
|
|
58
|
+
/** Attribute access on the element passed to {@link rewriteFirstElement}. */
|
|
59
|
+
export type HtmlRewriterAttributeTarget = Pick<HtmlRewriterElement, 'tagName' | 'attributes' | 'getAttribute' | 'hasAttribute' | 'setAttribute' | 'removeAttribute'>;
|
|
60
|
+
/**
|
|
61
|
+
* Rewrites the attributes of the first start tag that `isTarget` accepts and
|
|
62
|
+
* returns the rest of `html` unchanged.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* Uses the same tokenizer as {@link HtmlRewriter}, so tags inside comments, raw
|
|
66
|
+
* text and quoted attribute values never match. Scanning stops once the target
|
|
67
|
+
* is rewritten, so the cost grows with the markup before the target rather than
|
|
68
|
+
* with the whole document. Only attribute changes are offered: content placed
|
|
69
|
+
* with `append` or `after` needs the element's end tag, which is never reached.
|
|
70
|
+
*
|
|
71
|
+
* With `leadingOnly`, the target must directly follow the previous start tag
|
|
72
|
+
* (or the start of `html`), whitespace aside. When text, a comment or an end tag
|
|
73
|
+
* comes first, scanning stops and nothing is rewritten.
|
|
74
|
+
*/
|
|
75
|
+
export declare function rewriteFirstElement(html: string, isTarget: (element: HtmlRewriterAttributeTarget) => boolean, rewrite: (element: HtmlRewriterAttributeTarget) => void, options?: {
|
|
76
|
+
leadingOnly?: boolean;
|
|
77
|
+
}): string;
|