@ecopages/core 0.2.0-rc.8 → 0.2.0
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 +39 -38
- package/package.json +22 -152
- package/src/adapters/README.md +11 -3
- package/src/adapters/abstract/application-adapter.d.ts +32 -36
- package/src/adapters/abstract/application-adapter.js +61 -47
- package/src/adapters/abstract/server-adapter.d.ts +14 -0
- package/src/adapters/abstract/server-adapter.js +10 -0
- 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 +12 -16
- package/src/adapters/bun/create-app.js +25 -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 +15 -21
- package/src/adapters/bun/server-adapter.js +33 -67
- 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 +63 -8
- package/src/adapters/create-app.js +62 -5
- package/src/adapters/node/create-app.d.ts +8 -12
- package/src/adapters/node/create-app.js +22 -14
- package/src/adapters/node/runtime-host.d.ts +10 -10
- package/src/adapters/node/runtime-host.js +13 -8
- 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 +30 -32
- package/src/adapters/node/server-adapter.js +59 -65
- 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/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -9
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -33
- package/src/adapters/shared/http/fs-server-response-matcher.d.ts +24 -24
- package/src/adapters/shared/http/fs-server-response-matcher.js +59 -83
- package/src/adapters/shared/runtime/application-adapter.d.ts +1 -0
- package/src/adapters/shared/runtime/application-adapter.js +12 -0
- package/src/adapters/shared/runtime/bind-runtime-server.d.ts +17 -0
- package/src/adapters/shared/runtime/bind-runtime-server.js +50 -0
- 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/port-manager-default-prompt.d.ts +6 -0
- package/src/adapters/shared/runtime/port-manager-default-prompt.js +41 -0
- package/src/adapters/shared/runtime/port-manager.d.ts +3 -3
- package/src/adapters/shared/runtime/port-manager.js +14 -45
- 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 +26 -5
- package/src/adapters/shared/runtime/server-adapter.js +35 -8
- package/src/adapters/shared/runtime/server-route-handler.js +11 -3
- package/src/adapters/shared/runtime/server-static-builder.d.ts +9 -3
- package/src/adapters/shared/runtime/server-static-builder.js +59 -37
- 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 +12 -8
- 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 +35 -0
- package/src/build/cache/output-imports.js +87 -0
- package/src/build/cache/pages-unified-graph-build.d.ts +15 -1
- package/src/build/cache/pages-unified-graph-build.js +73 -22
- 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 +25 -3
- package/src/build/cache/server-entry-build-cache.js +129 -13
- 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/build-request-policy.js +1 -1
- package/src/build/runtime/deduping-build-executor.d.ts +0 -1
- package/src/build/runtime/deduping-build-executor.js +0 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- 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 +17 -2
- package/src/config/apply-user-config.d.ts +8 -0
- package/src/config/apply-user-config.js +68 -0
- package/src/config/config-builder.d.ts +11 -1
- package/src/config/config-builder.js +53 -12
- package/src/config/constants.d.ts +4 -4
- package/src/config/constants.js +4 -4
- package/src/config/define-config.d.ts +9 -0
- package/src/config/define-config.js +10 -0
- package/src/config/index.d.ts +5 -0
- package/src/config/index.js +4 -0
- package/src/config/is-finalized-app-config.d.ts +6 -0
- package/src/config/is-finalized-app-config.js +11 -0
- package/src/config/load-eco-config.d.ts +21 -0
- package/src/config/load-eco-config.js +107 -0
- package/src/config/resolve-eco-config-path.d.ts +32 -0
- package/src/config/resolve-eco-config-path.js +58 -0
- package/src/config/server-config-bundle.d.ts +25 -0
- package/src/config/server-config-bundle.js +148 -0
- package/src/config/user-config-types.d.ts +170 -0
- package/src/config/user-config-types.js +1 -0
- package/src/dev/README.md +4 -0
- package/src/dev/development-restart-watch-paths.d.ts +13 -0
- package/src/dev/development-restart-watch-paths.js +37 -0
- package/src/dev/development-restart.d.ts +13 -0
- package/src/dev/development-restart.js +21 -0
- 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/eco/eco.js +4 -0
- package/src/errors/http-error-page-contract.d.ts +77 -0
- package/src/errors/http-error-page-contract.js +106 -0
- 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/plugins/processor.d.ts +6 -2
- package/src/route-renderer/README.md +4 -0
- package/src/{adapters/shared/http/explicit-static-render-preparation.d.ts → route-renderer/explicit-view-render-preparation.d.ts} +3 -3
- package/src/route-renderer/orchestration/custom-element-scripts/README.md +2 -2
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +14 -2
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +12 -5
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +19 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +1 -4
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +25 -24
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +18 -20
- package/src/route-renderer/orchestration/integration-renderer.d.ts +24 -7
- package/src/route-renderer/orchestration/integration-renderer.js +44 -33
- 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/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/services/README.md +2 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -6
- package/src/services/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +39 -0
- package/src/services/error-pages/default-error-pages.js +199 -0
- package/src/services/error-pages/error-page-renderer.d.ts +58 -0
- package/src/services/error-pages/error-page-renderer.js +146 -0
- package/src/services/error-pages/semantic-error-page-exporter.d.ts +23 -0
- package/src/services/error-pages/semantic-error-page-exporter.js +35 -0
- 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 +29 -42
- package/src/services/html/html-transformer.service.js +85 -157
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +26 -39
- package/src/services/module-loading/README.md +20 -15
- 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 +2 -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 +8 -0
- package/src/services/module-loading/route-module-build-cache.store.js +25 -7
- package/src/services/module-loading/route-module-build-manifest.d.ts +12 -1
- package/src/services/module-loading/route-module-build-manifest.js +7 -3
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +3 -2
- package/src/services/module-loading/route-module-dependency-hasher.js +13 -1
- 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/module-loading/view-module-loader.d.ts +10 -0
- package/src/services/module-loading/view-module-loader.js +46 -0
- 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/static-site-generator/README.md +12 -8
- package/src/static-site-generator/static-site-generator.d.ts +3 -2
- package/src/static-site-generator/static-site-generator.js +17 -3
- package/src/types/internal-types.d.ts +1 -38
- package/src/types/public-types.d.ts +28 -130
- package/src/watchers/project-watcher.d.ts +9 -16
- package/src/watchers/project-watcher.js +35 -28
- 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/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
+
import { build, getAppBuildAdapter } from '../build/build-adapter.js';
|
|
4
|
+
import { parseModuleSource } from '../cache/module-parse-cache.js';
|
|
5
|
+
import { createServerBuildRequest } from '../build/runtime/build-request-policy.js';
|
|
6
|
+
import { requireBuildRuntime } from '../build/runtime/build-runtime.js';
|
|
7
|
+
import { getServerBundleOutputPaths } from '../build/cache/server-entry-build-cache.js';
|
|
8
|
+
export const EMITTED_ECO_CONFIG_FILENAME = 'eco.config.mjs';
|
|
9
|
+
function isAstNode(value) {
|
|
10
|
+
return typeof value === 'object' && value !== null;
|
|
11
|
+
}
|
|
12
|
+
function walkAst(value, visit) {
|
|
13
|
+
if (Array.isArray(value)) {
|
|
14
|
+
for (const child of value)
|
|
15
|
+
walkAst(child, visit);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!isAstNode(value))
|
|
19
|
+
return;
|
|
20
|
+
visit(value);
|
|
21
|
+
for (const child of Object.values(value))
|
|
22
|
+
walkAst(child, visit);
|
|
23
|
+
}
|
|
24
|
+
function isImportMeta(node) {
|
|
25
|
+
if (!isAstNode(node) || node.type !== 'MetaProperty')
|
|
26
|
+
return false;
|
|
27
|
+
return (isAstNode(node.meta) &&
|
|
28
|
+
node.meta.type === 'Identifier' &&
|
|
29
|
+
node.meta.name === 'import' &&
|
|
30
|
+
isAstNode(node.property) &&
|
|
31
|
+
node.property.type === 'Identifier' &&
|
|
32
|
+
node.property.name === 'meta');
|
|
33
|
+
}
|
|
34
|
+
function collectImportMetaEdits(code, id, serverOutdir) {
|
|
35
|
+
const program = parseModuleSource(id, code, { sourceType: 'module' }).program;
|
|
36
|
+
const fileDir = path.dirname(id);
|
|
37
|
+
const relativeDir = path.relative(serverOutdir, fileDir).replaceAll('\\', '/');
|
|
38
|
+
const relativeFile = relativeDir ? `${relativeDir}/${path.basename(id)}` : `./${path.basename(id)}`;
|
|
39
|
+
const edits = [];
|
|
40
|
+
let needsNodePath = false;
|
|
41
|
+
const identifiers = new Set();
|
|
42
|
+
walkAst(program, (node) => {
|
|
43
|
+
if (node.type === 'Identifier' && typeof node.name === 'string')
|
|
44
|
+
identifiers.add(node.name);
|
|
45
|
+
});
|
|
46
|
+
let pathBinding = '__ecoConfigPath';
|
|
47
|
+
while (identifiers.has(pathBinding))
|
|
48
|
+
pathBinding = `_${pathBinding}`;
|
|
49
|
+
walkAst(program, (node) => {
|
|
50
|
+
if (node.type !== 'MemberExpression' && node.type !== 'StaticMemberExpression')
|
|
51
|
+
return;
|
|
52
|
+
if (!isImportMeta(node.object) || !isAstNode(node.property) || node.property.type !== 'Identifier')
|
|
53
|
+
return;
|
|
54
|
+
if (typeof node.start !== 'number' || typeof node.end !== 'number')
|
|
55
|
+
return;
|
|
56
|
+
if (node.property.name === 'dirname' || node.property.name === 'dir') {
|
|
57
|
+
needsNodePath = true;
|
|
58
|
+
edits.push({
|
|
59
|
+
start: node.start,
|
|
60
|
+
end: node.end,
|
|
61
|
+
replacement: `${pathBinding}.resolve(import.meta.dirname, ${JSON.stringify(relativeDir || '.')})`,
|
|
62
|
+
});
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (node.property.name === 'url') {
|
|
66
|
+
edits.push({
|
|
67
|
+
start: node.start,
|
|
68
|
+
end: node.end,
|
|
69
|
+
replacement: `new URL(${JSON.stringify(relativeFile)}, import.meta.url).href`,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
return { edits, needsNodePath, pathBinding };
|
|
74
|
+
}
|
|
75
|
+
function applySourceEdits(code, edits) {
|
|
76
|
+
let transformed = code;
|
|
77
|
+
for (const edit of edits.sort((left, right) => right.start - left.start)) {
|
|
78
|
+
transformed = `${transformed.slice(0, edit.start)}${edit.replacement}${transformed.slice(edit.end)}`;
|
|
79
|
+
}
|
|
80
|
+
return transformed;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates a source transform that preserves source module directory semantics
|
|
84
|
+
* when `eco.config.ts` is relocated into `dist/.server/eco.config.mjs`.
|
|
85
|
+
*/
|
|
86
|
+
export function createPreserveImportMetaTransform(serverOutdir) {
|
|
87
|
+
return {
|
|
88
|
+
name: 'preserve-import-meta-for-server-config',
|
|
89
|
+
filter: /\.[cm]?[jt]sx?$/,
|
|
90
|
+
transform(code, id) {
|
|
91
|
+
if (!code.includes('import.meta')) {
|
|
92
|
+
return undefined;
|
|
93
|
+
}
|
|
94
|
+
const { edits, needsNodePath, pathBinding } = collectImportMetaEdits(code, id, serverOutdir);
|
|
95
|
+
if (edits.length === 0)
|
|
96
|
+
return undefined;
|
|
97
|
+
const transformed = applySourceEdits(code, edits);
|
|
98
|
+
return {
|
|
99
|
+
code: needsNodePath ? `import * as ${pathBinding} from 'node:path';\n${transformed}` : transformed,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Compiles the selected Ecopages config module for production server startup.
|
|
106
|
+
*/
|
|
107
|
+
export async function bundleEcoConfigModule(appConfig, options = {}) {
|
|
108
|
+
const configSourcePath = appConfig.absolutePaths?.config;
|
|
109
|
+
if (!configSourcePath || !fileSystem.exists(configSourcePath)) {
|
|
110
|
+
return undefined;
|
|
111
|
+
}
|
|
112
|
+
const { serverOutdir } = getServerBundleOutputPaths(appConfig);
|
|
113
|
+
const outputDir = options.outputDir ?? serverOutdir;
|
|
114
|
+
const runtimeDir = options.runtimeDir ?? serverOutdir;
|
|
115
|
+
const emittedConfigPath = path.join(outputDir, EMITTED_ECO_CONFIG_FILENAME);
|
|
116
|
+
fileSystem.ensureDir(outputDir);
|
|
117
|
+
const buildOptions = createServerBuildRequest(appConfig, {
|
|
118
|
+
profile: 'server-entry',
|
|
119
|
+
entrypoints: [configSourcePath],
|
|
120
|
+
outdir: outputDir,
|
|
121
|
+
naming: EMITTED_ECO_CONFIG_FILENAME,
|
|
122
|
+
sourcemap: 'hidden',
|
|
123
|
+
sourceTransforms: [createPreserveImportMetaTransform(runtimeDir)],
|
|
124
|
+
});
|
|
125
|
+
const result = await build(buildOptions, requireBuildRuntime(appConfig).getProfile('server-entry'));
|
|
126
|
+
if (!result.success) {
|
|
127
|
+
const errorMessages = result.logs.map((log) => log.message).join('\n');
|
|
128
|
+
throw new Error(`Failed to bundle Ecopages config module:\n${errorMessages}`);
|
|
129
|
+
}
|
|
130
|
+
if (!fileSystem.exists(emittedConfigPath)) {
|
|
131
|
+
throw new Error(`Ecopages config bundle missing at ${emittedConfigPath}`);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
emittedConfigPath,
|
|
135
|
+
buildResult: result,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* @remarks
|
|
140
|
+
* Ensures build ownership allows app-owned bundling before emitting config artifacts.
|
|
141
|
+
*/
|
|
142
|
+
export function assertCanBundleServerConfig(appConfig) {
|
|
143
|
+
const buildAdapter = getAppBuildAdapter(appConfig);
|
|
144
|
+
if (buildAdapter.ownership === 'vite-host') {
|
|
145
|
+
throw new Error('Cannot bundle the server config: build ownership is "vite-host". ' +
|
|
146
|
+
'The host runtime is expected to produce its own server bundle.');
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { BuildOwnership } from '../build/build-adapter.js';
|
|
2
|
+
import type { EcoBuildPlugin } from '../build/contracts/build-types.js';
|
|
3
|
+
import type { AnyIntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
4
|
+
import type { AnyProcessor } from '../plugins/processor.js';
|
|
5
|
+
import type { EcoSourceTransform } from '../plugins/source-transform.js';
|
|
6
|
+
import type { CacheConfig } from '../services/cache/cache.types.js';
|
|
7
|
+
import type { EcoPagesAppConfig, RobotsPreference } from '../types/internal-types.js';
|
|
8
|
+
import type { PageMetadataProps, SitemapConfig } from '../types/public-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Author-owned Ecopages configuration declared in `eco.config.ts`.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* Author this object using `defineConfig({ ... })` in `eco.config.ts`.
|
|
14
|
+
* This type excludes resolved absolute paths, derived integration extensions, and runtime
|
|
15
|
+
* services attached during {@link ConfigBuilder.build}.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { defineConfig } from '@ecopages/core/config';
|
|
20
|
+
* import { ecopagesJsxPlugin } from '@ecopages/ecopages-jsx';
|
|
21
|
+
*
|
|
22
|
+
* export default defineConfig({
|
|
23
|
+
* integrations: [ecopagesJsxPlugin()],
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export type EcoPagesUserConfig = {
|
|
28
|
+
/**
|
|
29
|
+
* Absolute or relative path to the project root directory.
|
|
30
|
+
*
|
|
31
|
+
* @default process.cwd()
|
|
32
|
+
*/
|
|
33
|
+
rootDir?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Canonical base URL for production deployment (e.g. `https://example.com`).
|
|
36
|
+
*
|
|
37
|
+
* @default 'http://localhost:3000'
|
|
38
|
+
*/
|
|
39
|
+
baseUrl?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Directory containing application source code, relative to `rootDir`.
|
|
42
|
+
*
|
|
43
|
+
* @default 'src'
|
|
44
|
+
*/
|
|
45
|
+
srcDir?: string;
|
|
46
|
+
/**
|
|
47
|
+
* Directory for static public assets copied directly to `distDir`, relative to `rootDir`.
|
|
48
|
+
*
|
|
49
|
+
* @default 'public'
|
|
50
|
+
*/
|
|
51
|
+
publicDir?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Directory containing page route files and semantic HTML error pages (`400.ts` through `500.ts`), relative to `srcDir`.
|
|
54
|
+
*
|
|
55
|
+
* @default 'pages'
|
|
56
|
+
*/
|
|
57
|
+
pagesDir?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Directory containing reusable includes or the semantic `html.*` document shell, relative to `srcDir`.
|
|
60
|
+
*
|
|
61
|
+
* @default 'includes'
|
|
62
|
+
*/
|
|
63
|
+
includesDir?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Directory containing layout components, relative to `srcDir`.
|
|
66
|
+
*
|
|
67
|
+
* @default 'layouts'
|
|
68
|
+
*/
|
|
69
|
+
layoutsDir?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Output directory for the production build, relative to `rootDir`.
|
|
72
|
+
*
|
|
73
|
+
* @default 'dist'
|
|
74
|
+
*/
|
|
75
|
+
distDir?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Internal scratch and cache directory for build artifacts and virtual modules, relative to `rootDir`.
|
|
78
|
+
*
|
|
79
|
+
* @default '.eco'
|
|
80
|
+
*/
|
|
81
|
+
workDir?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Directory containing island and client components, relative to `srcDir`.
|
|
84
|
+
*
|
|
85
|
+
* @default 'components'
|
|
86
|
+
*/
|
|
87
|
+
componentsDir?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Configuration for automatic `robots.txt` generation.
|
|
90
|
+
*/
|
|
91
|
+
robotsTxt?: {
|
|
92
|
+
preferences: RobotsPreference;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Configuration for automatic `sitemap.xml` generation.
|
|
96
|
+
*/
|
|
97
|
+
sitemap?: SitemapConfig;
|
|
98
|
+
/**
|
|
99
|
+
* Additional file or directory paths to watch during development.
|
|
100
|
+
*/
|
|
101
|
+
additionalWatchPaths?: string[];
|
|
102
|
+
/**
|
|
103
|
+
* URL route paths to prewarm in the background when the development server starts.
|
|
104
|
+
*/
|
|
105
|
+
devPrewarmPaths?: string[];
|
|
106
|
+
/**
|
|
107
|
+
* URL route paths that must complete prewarming before the dev server reports ready.
|
|
108
|
+
*/
|
|
109
|
+
devPrewarmBeforeReadyPaths?: string[];
|
|
110
|
+
/**
|
|
111
|
+
* Default fallback HTML `<head>` metadata (title, description, OpenGraph tags) applied across all pages.
|
|
112
|
+
*/
|
|
113
|
+
defaultMetadata?: PageMetadataProps;
|
|
114
|
+
/**
|
|
115
|
+
* Integration plugins enabling template rendering (e.g. JSX, MDX, Lit, React).
|
|
116
|
+
*/
|
|
117
|
+
integrations?: AnyIntegrationPlugin[];
|
|
118
|
+
/**
|
|
119
|
+
* PostCSS, Tailwind, or custom asset processors applied to imported styles and assets.
|
|
120
|
+
*/
|
|
121
|
+
processors?: AnyProcessor[];
|
|
122
|
+
/**
|
|
123
|
+
* Custom Rolldown/Vite build loaders and asset transforms.
|
|
124
|
+
*/
|
|
125
|
+
loaders?: EcoBuildPlugin[];
|
|
126
|
+
/**
|
|
127
|
+
* AST transforms applied to source files before compilation (e.g. island script extraction).
|
|
128
|
+
*/
|
|
129
|
+
sourceTransforms?: EcoSourceTransform[];
|
|
130
|
+
/**
|
|
131
|
+
* Cache policy configuration for page and asset build outputs.
|
|
132
|
+
*/
|
|
133
|
+
cache?: CacheConfig;
|
|
134
|
+
/**
|
|
135
|
+
* Development toolbar configuration and toggle options.
|
|
136
|
+
*/
|
|
137
|
+
devToolbar?: EcoPagesAppConfig['devToolbar'];
|
|
138
|
+
/**
|
|
139
|
+
* Experimental runtime or compiler feature flags.
|
|
140
|
+
*/
|
|
141
|
+
experimental?: EcoPagesAppConfig['experimental'];
|
|
142
|
+
/**
|
|
143
|
+
* Build pipeline ownership mode.
|
|
144
|
+
*
|
|
145
|
+
* @default 'rolldown'
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Set to `'vite-host'` when running inside Vite (`@ecopages/vite-plugin`), where Vite
|
|
149
|
+
* owns client and server module transforms.
|
|
150
|
+
*/
|
|
151
|
+
buildOwnership?: BuildOwnership;
|
|
152
|
+
};
|
|
153
|
+
export type LoadedEcoPagesUserConfig = {
|
|
154
|
+
config: EcoPagesUserConfig;
|
|
155
|
+
configFilePath: string;
|
|
156
|
+
};
|
|
157
|
+
export type FinalizeEcoPagesConfigOptions = {
|
|
158
|
+
buildOwnership?: BuildOwnership;
|
|
159
|
+
/**
|
|
160
|
+
* Working directory used when `rootDir` is omitted.
|
|
161
|
+
*
|
|
162
|
+
* @default process.cwd()
|
|
163
|
+
*/
|
|
164
|
+
cwd?: string;
|
|
165
|
+
};
|
|
166
|
+
export type LoadEcoPagesConfigOptions = {
|
|
167
|
+
configFile?: string;
|
|
168
|
+
cwd?: string;
|
|
169
|
+
buildOwnership?: BuildOwnership;
|
|
170
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/src/dev/README.md
CHANGED
|
@@ -24,3 +24,7 @@ Disable per project with `devToolbar: { enabled: false }`, or per process with `
|
|
|
24
24
|
Server wiring: [dev-toolbar/README.md](../dev-toolbar/README.md) (`DevToolbarHost`, manifest, runtime bundling, HTML injection). Bring-your-own toolbars export `src/bootstrap.ts` and use the same `devToolbar.package` config key.
|
|
25
25
|
|
|
26
26
|
Dev transform requests retry when their source changes or is invalidated during compilation. Concurrent requests share one in-flight compile per source, including across source and global invalidation; stale attempts release their slot before retrying. Only results for the current source snapshot enter the module cache, so rapid edits cannot label stale browser code with a newer source hash.
|
|
27
|
+
|
|
28
|
+
## Process restarts
|
|
29
|
+
|
|
30
|
+
The Project Watcher classifies the resolved `eco.config` module and supported project dotenv paths separately from HMR. Under the CLI, those changes request a graceful runtime stop and a supervised child-process restart so config modules and environment values are loaded from scratch. Embedded hosts are warned without core terminating their process. Runtime entry watchers own config-module changes when `dev:watch` is active, while the Project Watcher continues to own dotenv changes.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
|
+
/** Returns whether `filePath` is a supported project-level dotenv file. */
|
|
3
|
+
export declare function isDevEnvFilePath(filePath: string, rootDir?: string, nodeEnv?: string | undefined): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Absolute paths to project-level dotenv files under `rootDir`.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* The paths need not exist yet. Watching every supported name allows creating
|
|
9
|
+
* or removing a dotenv file to restart the development process too.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveDevEnvFilePaths(rootDir?: string, nodeEnv?: string | undefined): string[];
|
|
12
|
+
/** Absolute paths that should restart the development server when changed. */
|
|
13
|
+
export declare function resolveRuntimeRestartWatchPaths(appConfig: EcoPagesAppConfig): string[];
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { getDevEnvFileNames } from './development-restart.js';
|
|
3
|
+
/** Returns whether `filePath` is a supported project-level dotenv file. */
|
|
4
|
+
export function isDevEnvFilePath(filePath, rootDir, nodeEnv = process.env.NODE_ENV) {
|
|
5
|
+
if (!rootDir) {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const resolvedPath = path.resolve(filePath);
|
|
9
|
+
if (path.dirname(resolvedPath) !== path.resolve(rootDir)) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return getDevEnvFileNames(nodeEnv).includes(path.basename(resolvedPath));
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Absolute paths to project-level dotenv files under `rootDir`.
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* The paths need not exist yet. Watching every supported name allows creating
|
|
19
|
+
* or removing a dotenv file to restart the development process too.
|
|
20
|
+
*/
|
|
21
|
+
export function resolveDevEnvFilePaths(rootDir, nodeEnv = process.env.NODE_ENV) {
|
|
22
|
+
if (!rootDir) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
return getDevEnvFileNames(nodeEnv).map((envFile) => path.resolve(rootDir, envFile));
|
|
26
|
+
}
|
|
27
|
+
/** Absolute paths that should restart the development server when changed. */
|
|
28
|
+
export function resolveRuntimeRestartWatchPaths(appConfig) {
|
|
29
|
+
const paths = [];
|
|
30
|
+
if (appConfig.absolutePaths?.config) {
|
|
31
|
+
paths.push(appConfig.absolutePaths.config);
|
|
32
|
+
}
|
|
33
|
+
for (const envPath of resolveDevEnvFilePaths(appConfig.rootDir)) {
|
|
34
|
+
paths.push(envPath);
|
|
35
|
+
}
|
|
36
|
+
return paths;
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Process exit code the CLI supervisor treats as a development restart request. */
|
|
2
|
+
export declare const ECOPAGES_DEV_RESTART_EXIT_CODE = 100;
|
|
3
|
+
/** Env var carrying a short restart reason for the next child process startup log. */
|
|
4
|
+
export declare const ECOPAGES_DEV_RESTART_REASON_ENV = "ECOPAGES_DEV_RESTART_REASON";
|
|
5
|
+
/**
|
|
6
|
+
* When set, the CLI entry watcher (`bun --watch` or `node --watch`) owns hard restarts;
|
|
7
|
+
* core skips a second config-file exit for the same change.
|
|
8
|
+
*/
|
|
9
|
+
export declare const ECOPAGES_ENTRY_WATCH_ENV = "ECOPAGES_ENTRY_WATCH";
|
|
10
|
+
/** Returns whether the runtime's entry watcher owns config-module restarts. */
|
|
11
|
+
export declare function entryWatcherOwnsConfig(env?: NodeJS.ProcessEnv): boolean;
|
|
12
|
+
/** Relative dotenv filenames loaded by the CLI, in precedence order. */
|
|
13
|
+
export declare function getDevEnvFileNames(nodeEnv?: string | undefined): string[];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Process exit code the CLI supervisor treats as a development restart request. */
|
|
2
|
+
export const ECOPAGES_DEV_RESTART_EXIT_CODE = 100;
|
|
3
|
+
/** Env var carrying a short restart reason for the next child process startup log. */
|
|
4
|
+
export const ECOPAGES_DEV_RESTART_REASON_ENV = 'ECOPAGES_DEV_RESTART_REASON';
|
|
5
|
+
/**
|
|
6
|
+
* When set, the CLI entry watcher (`bun --watch` or `node --watch`) owns hard restarts;
|
|
7
|
+
* core skips a second config-file exit for the same change.
|
|
8
|
+
*/
|
|
9
|
+
export const ECOPAGES_ENTRY_WATCH_ENV = 'ECOPAGES_ENTRY_WATCH';
|
|
10
|
+
/** Returns whether the runtime's entry watcher owns config-module restarts. */
|
|
11
|
+
export function entryWatcherOwnsConfig(env = process.env) {
|
|
12
|
+
return env[ECOPAGES_ENTRY_WATCH_ENV] === '1';
|
|
13
|
+
}
|
|
14
|
+
/** Relative dotenv filenames loaded by the CLI, in precedence order. */
|
|
15
|
+
export function getDevEnvFileNames(nodeEnv = process.env.NODE_ENV) {
|
|
16
|
+
const envFiles = ['.env', '.env.local'];
|
|
17
|
+
if (nodeEnv) {
|
|
18
|
+
envFiles.push(`.env.${nodeEnv}`, `.env.${nodeEnv}.local`);
|
|
19
|
+
}
|
|
20
|
+
return envFiles;
|
|
21
|
+
}
|
|
@@ -6,7 +6,6 @@ export interface DevelopmentHostRuntime {
|
|
|
6
6
|
registerHostModuleLoader(loader: HostRuntimeModuleLoader): void;
|
|
7
7
|
planFileChange(filePath: string): DevelopmentInvalidationPlan;
|
|
8
8
|
invalidateServerModules(changedFiles?: string[]): void;
|
|
9
|
-
resetRuntimeState(changedFiles?: string[]): void;
|
|
10
9
|
broadcastClientEvent(event: ClientBridgeEvent): void;
|
|
11
10
|
isServerRenderedTemplatePlan(plan: DevelopmentInvalidationPlan): boolean;
|
|
12
11
|
}
|
package/src/dev/host-runtime.js
CHANGED
|
@@ -13,9 +13,6 @@ export function createDevelopmentHostRuntime(appConfig) {
|
|
|
13
13
|
invalidateServerModules(changedFiles) {
|
|
14
14
|
invalidationService.invalidateServerModules(changedFiles);
|
|
15
15
|
},
|
|
16
|
-
resetRuntimeState(changedFiles) {
|
|
17
|
-
invalidationService.resetRuntimeState(changedFiles);
|
|
18
|
-
},
|
|
19
16
|
broadcastClientEvent(event) {
|
|
20
17
|
getAppDevClientBridge(appConfig)?.broadcast(event);
|
|
21
18
|
},
|
package/src/dev/sc-server.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Server } from 'bun';
|
|
|
2
2
|
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
3
3
|
type StaticContentServerOptions = {
|
|
4
4
|
port?: number;
|
|
5
|
+
hostname?: string;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* Static content server for production builds.
|
|
@@ -16,7 +17,9 @@ export declare class StaticContentServer {
|
|
|
16
17
|
options?: StaticContentServerOptions;
|
|
17
18
|
});
|
|
18
19
|
private shouldServeGzip;
|
|
19
|
-
|
|
20
|
+
/**
|
|
21
|
+
* Serves the generated 404 page when present, or a plain-text fallback.
|
|
22
|
+
*/
|
|
20
23
|
private sendNotFoundPage;
|
|
21
24
|
private serveFromDir;
|
|
22
25
|
fetch(request: Request): Promise<Response>;
|
package/src/dev/sc-server.js
CHANGED
|
@@ -20,23 +20,18 @@ export class StaticContentServer {
|
|
|
20
20
|
shouldServeGzip(contentType) {
|
|
21
21
|
return ['text/javascript', 'text/css'].includes(contentType);
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const error404TemplatePath =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return new Response(STATUS_MESSAGE[404], {
|
|
33
|
-
status: 404,
|
|
34
|
-
});
|
|
23
|
+
/**
|
|
24
|
+
* Serves the generated 404 page when present, or a plain-text fallback.
|
|
25
|
+
*/
|
|
26
|
+
sendNotFoundPage() {
|
|
27
|
+
const error404TemplatePath = join(this.appConfig.absolutePaths.distDir, '404.html');
|
|
28
|
+
if (!fileSystem.exists(error404TemplatePath)) {
|
|
29
|
+
return new Response(STATUS_MESSAGE[404], { status: 404 });
|
|
35
30
|
}
|
|
36
|
-
|
|
31
|
+
return new Response(fileSystem.readFileAsBuffer(error404TemplatePath), {
|
|
32
|
+
status: 404,
|
|
37
33
|
headers: { 'Content-Type': 'text/html' },
|
|
38
34
|
});
|
|
39
|
-
return response;
|
|
40
35
|
}
|
|
41
36
|
async serveFromDir({ path, request }) {
|
|
42
37
|
const { absolutePaths } = this.appConfig;
|
|
@@ -84,20 +79,16 @@ export class StaticContentServer {
|
|
|
84
79
|
let reqPath = new URL(request.url).pathname;
|
|
85
80
|
if (reqPath === '/')
|
|
86
81
|
reqPath = '/index.html';
|
|
87
|
-
|
|
82
|
+
return this.serveFromDir({
|
|
88
83
|
path: reqPath,
|
|
89
84
|
request,
|
|
90
85
|
});
|
|
91
|
-
if (response)
|
|
92
|
-
return response;
|
|
93
|
-
return new Response(STATUS_MESSAGE[404], {
|
|
94
|
-
status: 404,
|
|
95
|
-
});
|
|
96
86
|
}
|
|
97
87
|
startServer() {
|
|
98
88
|
this.server = getRequiredBunRuntime().serve({
|
|
99
89
|
fetch: this.fetch.bind(this),
|
|
100
90
|
port: this.options.port,
|
|
91
|
+
hostname: this.options.hostname,
|
|
101
92
|
});
|
|
102
93
|
}
|
|
103
94
|
stop() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
|
-
import {
|
|
3
|
+
import { parseModuleSource } from '../../cache/module-parse-cache.js';
|
|
4
4
|
import { isBarePackageImportSpecifier, resolveProjectModulePath } from '../../plugins/tsconfig-import-resolver.js';
|
|
5
5
|
import { resolveRuntimeSpecifierPublicPath } from '../../build/browser/browser-runtime-manifest.js';
|
|
6
6
|
import { resolveDevTransformModuleUrl } from './dev-transform-url.js';
|
|
@@ -41,7 +41,7 @@ export async function rewriteModuleImports(options) {
|
|
|
41
41
|
const normalizedSource = path.resolve(options.sourcePath);
|
|
42
42
|
const dependencies = new Set();
|
|
43
43
|
const specifierNodes = [];
|
|
44
|
-
const parseResult =
|
|
44
|
+
const parseResult = parseModuleSource(normalizedSource, options.code, {
|
|
45
45
|
sourceType: 'module',
|
|
46
46
|
lang: path.extname(normalizedSource).endsWith('x') ? 'tsx' : 'ts',
|
|
47
47
|
});
|
package/src/eco/eco.js
CHANGED
|
@@ -96,6 +96,10 @@ function embed(component, props, children) {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
* Creates a document shell component.
|
|
99
|
+
*
|
|
100
|
+
* @remarks
|
|
101
|
+
* Pass one generic for the renderable (`eco.html<JsxRenderable>()`,
|
|
102
|
+
* `eco.html<ReactNode>()`). Props are {@link HtmlTemplateProps}.
|
|
99
103
|
*/
|
|
100
104
|
function html(options) {
|
|
101
105
|
return createComponentFactory(options);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP statuses that own a semantic HTML error page (`pages/{status}.*` and
|
|
3
|
+
* matching `app.*()` loaders).
|
|
4
|
+
*/
|
|
5
|
+
export declare const HTTP_ERROR_PAGE_STATUSES: readonly [400, 401, 403, 404, 409, 500];
|
|
6
|
+
export type HttpErrorPageStatus = (typeof HTTP_ERROR_PAGE_STATUSES)[number];
|
|
7
|
+
export type ErrorPageKind = 'badRequest' | 'unauthorized' | 'forbidden' | 'notFound' | 'conflict' | 'serverError';
|
|
8
|
+
export declare const ERROR_PAGE_KIND_BY_STATUS: {
|
|
9
|
+
readonly 400: "badRequest";
|
|
10
|
+
readonly 401: "unauthorized";
|
|
11
|
+
readonly 403: "forbidden";
|
|
12
|
+
readonly 404: "notFound";
|
|
13
|
+
readonly 409: "conflict";
|
|
14
|
+
readonly 500: "serverError";
|
|
15
|
+
};
|
|
16
|
+
export declare const ERROR_PAGE_STATUS_BY_KIND: {
|
|
17
|
+
readonly badRequest: 400;
|
|
18
|
+
readonly unauthorized: 401;
|
|
19
|
+
readonly forbidden: 403;
|
|
20
|
+
readonly notFound: 404;
|
|
21
|
+
readonly conflict: 409;
|
|
22
|
+
readonly serverError: 500;
|
|
23
|
+
};
|
|
24
|
+
export declare const SEMANTIC_ERROR_PAGE_PATHNAMES: readonly `/${HttpErrorPageStatus}`[];
|
|
25
|
+
/**
|
|
26
|
+
* Built-in copy and CSS modifier suffix for each semantic HTML error page.
|
|
27
|
+
*/
|
|
28
|
+
export declare const ERROR_PAGE_COPY: {
|
|
29
|
+
readonly 400: {
|
|
30
|
+
readonly title: "Bad Request";
|
|
31
|
+
readonly message: "The request could not be understood.";
|
|
32
|
+
readonly modifier: "bad-request";
|
|
33
|
+
};
|
|
34
|
+
readonly 401: {
|
|
35
|
+
readonly title: "Unauthorized";
|
|
36
|
+
readonly message: "Authentication is required to access this page.";
|
|
37
|
+
readonly modifier: "unauthorized";
|
|
38
|
+
};
|
|
39
|
+
readonly 403: {
|
|
40
|
+
readonly title: "Forbidden";
|
|
41
|
+
readonly message: "You do not have permission to access this page.";
|
|
42
|
+
readonly modifier: "forbidden";
|
|
43
|
+
};
|
|
44
|
+
readonly 404: {
|
|
45
|
+
readonly title: "Not Found";
|
|
46
|
+
readonly message: "The page you requested could not be found.";
|
|
47
|
+
readonly modifier: "not-found";
|
|
48
|
+
};
|
|
49
|
+
readonly 409: {
|
|
50
|
+
readonly title: "Conflict";
|
|
51
|
+
readonly message: "The request could not be completed due to a conflict.";
|
|
52
|
+
readonly modifier: "conflict";
|
|
53
|
+
};
|
|
54
|
+
readonly 500: {
|
|
55
|
+
readonly title: "Something went wrong";
|
|
56
|
+
readonly message: "An error occurred while handling this request.";
|
|
57
|
+
readonly modifier: "server-error";
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type PageFailureClassification = {
|
|
61
|
+
status: number;
|
|
62
|
+
kind: ErrorPageKind | undefined;
|
|
63
|
+
logAsServerError: boolean;
|
|
64
|
+
};
|
|
65
|
+
export declare function isHttpErrorPageStatus(status: number): status is HttpErrorPageStatus;
|
|
66
|
+
export declare function isHttpErrorStatus(status: number): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Resolves the semantic page kind for an HTTP status.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Factory statuses map 1:1. Other 5xx statuses reuse the server-error page
|
|
72
|
+
* with the original status. Other 4xx statuses have no custom page and use a
|
|
73
|
+
* built-in document.
|
|
74
|
+
*/
|
|
75
|
+
export declare function kindForStatus(status: number): ErrorPageKind | undefined;
|
|
76
|
+
export declare function classifyPageFailure(error: unknown): PageFailureClassification;
|
|
77
|
+
export declare function shouldLogPageFailure(error: unknown): boolean;
|