@ecopages/core 0.2.0-rc.1 → 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 +50 -41
- package/package.json +50 -145
- 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/segment-path-matcher.js +56 -38
- 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 +15 -15
- package/src/adapters/bun/create-app.js +52 -67
- 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 +27 -5
- package/src/adapters/shared/runtime/server-adapter.js +44 -30
- 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 +9 -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 +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/contracts/content-virtual-modules.d.ts +3 -1
- package/src/build/contracts/content-virtual-modules.js +8 -0
- package/src/build/rolldown/rolldown-adapter-helpers.js +41 -25
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- 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/css-imports.d.ts +4 -0
- package/src/declarations.d.ts +11 -5
- package/src/dev/README.md +6 -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/dev/transform-server/dev-transform-server.d.ts +6 -0
- package/src/dev/transform-server/dev-transform-server.js +16 -5
- package/src/eco/README.md +73 -5
- package/src/eco/component-identity.d.ts +3 -2
- package/src/eco/component-identity.js +5 -2
- package/src/eco/discovered-dependencies.d.ts +45 -0
- package/src/eco/discovered-dependencies.js +87 -0
- package/src/eco/eco.js +6 -0
- package/src/eco/eco.types.d.ts +18 -2
- package/src/eco/lazy-injector-map.js +57 -41
- package/src/eco/page-dependency-contributions.d.ts +19 -0
- package/src/eco/page-dependency-contributions.js +52 -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/hmr/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +2 -0
- package/src/index.browser.js +2 -0
- package/src/index.d.ts +5 -3
- package/src/index.js +5 -3
- package/src/islands/README.md +5 -1
- package/src/islands/island-host.d.ts +0 -9
- package/src/islands/island-host.js +1 -13
- package/src/plugins/README.md +8 -1
- package/src/plugins/component-import-discovery.d.ts +19 -0
- package/src/plugins/component-import-discovery.js +241 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +3 -1
- package/src/plugins/eco-component-meta-plugin.js +120 -18
- package/src/plugins/integration-plugin.d.ts +0 -1
- package/src/plugins/integration-plugin.js +0 -4
- package/src/plugins/processor.d.ts +10 -2
- package/src/plugins/processor.js +4 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +3 -1
- package/src/plugins/tsconfig-import-resolver.js +4 -2
- package/src/route-renderer/GRAPH.md +1 -1
- package/src/route-renderer/README.md +15 -2
- 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 +9 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +16 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +34 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +80 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +190 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts +17 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +41 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +10 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +46 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +7 -2
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +3 -4
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.d.ts +11 -2
- package/src/route-renderer/orchestration/foreign-child/foreign-subtree-execution.service.js +10 -2
- package/src/route-renderer/orchestration/integration-renderer.d.ts +9 -11
- package/src/route-renderer/orchestration/integration-renderer.js +43 -40
- package/src/route-renderer/orchestration/integration-renderer.test-fixtures.js +1 -1
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +2 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +2 -68
- package/src/route-renderer/orchestration/ownership-graph/component-graph.js +55 -39
- 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/orchestration/page-browser-graph/page-browser-graph.service.d.ts +6 -0
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +59 -36
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +8 -10
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +1 -1
- package/src/route-renderer/orchestration/string-markup-renderer.js +2 -1
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +6 -2
- package/src/route-renderer/page-loading/component-dependency-collection.js +113 -68
- package/src/route-renderer/page-loading/ecopages-virtual-imports.js +41 -28
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +10 -3
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +62 -25
- package/src/route-renderer/page-loading/page-dependency-bundling.js +14 -8
- package/src/route-renderer/page-loading/resolved-page-dependencies.d.ts +1 -2
- package/src/route-renderer/page-loading/resolved-page-dependencies.js +8 -7
- package/src/route-renderer/route-renderer.d.ts +9 -0
- package/src/route-renderer/route-renderer.js +18 -0
- package/src/router/README.md +7 -1
- package/src/router/server/route-registry.d.ts +13 -0
- package/src/router/server/route-registry.js +46 -32
- package/src/services/README.md +6 -1
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +36 -9
- package/src/services/assets/asset-processing-service/browser-runtime-entry-resolution.js +122 -37
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +2 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +13 -2
- package/src/services/assets/asset-processing-service/page-package.js +42 -39
- 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 +26 -39
- package/src/services/html/html-transformer.service.js +81 -153
- package/src/services/invalidation/development-invalidation.service.d.ts +9 -20
- package/src/services/invalidation/development-invalidation.service.js +35 -41
- package/src/services/module-loading/README.md +17 -14
- 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 +1 -1
- package/src/services/module-loading/collection-server-module-build.service.js +5 -5
- 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/page-module-import.service.d.ts +8 -0
- package/src/services/module-loading/page-module-import.service.js +62 -28
- 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/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/services/validation/schema-validation-service.d.ts +1 -0
- package/src/services/validation/schema-validation-service.js +23 -36
- package/src/static-site-generator/README.md +6 -1
- package/src/static-site-generator/static-site-generator.d.ts +7 -2
- package/src/static-site-generator/static-site-generator.js +90 -49
- package/src/types/internal-types.d.ts +6 -39
- package/src/types/public-types.d.ts +29 -131
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -16
- package/src/watchers/project-watcher.js +86 -61
- 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
|
@@ -5,10 +5,12 @@ import type { BuildRuntime } from '../build/runtime/build-runtime.js';
|
|
|
5
5
|
import type { AnyIntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
6
6
|
import type { Processor } from '../plugins/processor.js';
|
|
7
7
|
import type { EcoSourceTransform } from '../plugins/source-transform.js';
|
|
8
|
-
import type { PageMetadataProps, SitemapConfig } from './public-types.js';
|
|
9
|
-
|
|
8
|
+
import type { ComponentRenderInput, EcoComponent, PageMetadataProps, SitemapConfig } from './public-types.js';
|
|
9
|
+
/** Internal render input carrying route-resolved dependency roots. */
|
|
10
|
+
export type InternalComponentRenderInput = ComponentRenderInput & {
|
|
11
|
+
foreignChildRoots?: ReadonlyArray<EcoComponent | Partial<EcoComponent>>;
|
|
12
|
+
};
|
|
10
13
|
import type { CacheConfig } from '../services/cache/cache.types.js';
|
|
11
|
-
import type { DevGraphService } from '../services/runtime-state/dev-graph.service.js';
|
|
12
14
|
import type { AppModuleLoader } from '../services/module-loading/app-module-loader.service.js';
|
|
13
15
|
import type { SourceModuleLoader } from '../services/module-loading/module-loading-types.js';
|
|
14
16
|
import type { EntrypointDependencyGraph } from '../services/runtime-state/entrypoint-dependency-graph.service.js';
|
|
@@ -117,8 +119,6 @@ export type EcoPagesAppConfig = {
|
|
|
117
119
|
defaultMetadata: PageMetadataProps;
|
|
118
120
|
/** Integrations plugins */
|
|
119
121
|
integrations: AnyIntegrationPlugin[];
|
|
120
|
-
/** Integrations dependencies */
|
|
121
|
-
integrationsDependencies: IntegrationDependencyConfig[];
|
|
122
122
|
/** Derived Paths */
|
|
123
123
|
absolutePaths: {
|
|
124
124
|
config: string;
|
|
@@ -132,6 +132,7 @@ export type EcoPagesAppConfig = {
|
|
|
132
132
|
publicDir: string;
|
|
133
133
|
srcDir: string;
|
|
134
134
|
htmlTemplatePath: string;
|
|
135
|
+
errorPageTemplatePaths?: Record<400 | 401 | 403 | 404 | 409 | 500, string>;
|
|
135
136
|
error404TemplatePath: string;
|
|
136
137
|
error500TemplatePath: string;
|
|
137
138
|
};
|
|
@@ -165,7 +166,6 @@ export type EcoPagesAppConfig = {
|
|
|
165
166
|
buildOwnership?: BuildOwnership;
|
|
166
167
|
buildAdapter?: BuildAdapter;
|
|
167
168
|
buildManifest?: AppBuildManifest;
|
|
168
|
-
devGraphService?: DevGraphService;
|
|
169
169
|
entrypointDependencyGraph?: EntrypointDependencyGraph;
|
|
170
170
|
pageBrowserGraphSession?: SessionPageBrowserGraphCache;
|
|
171
171
|
hostModuleLoader?: SourceModuleLoader;
|
|
@@ -218,15 +218,6 @@ export type EcoPagesAppConfig = {
|
|
|
218
218
|
unsafe?: Record<string, unknown>;
|
|
219
219
|
};
|
|
220
220
|
};
|
|
221
|
-
export type IntegrationDependencyConfig = {
|
|
222
|
-
integration: string;
|
|
223
|
-
kind: 'script' | 'stylesheet';
|
|
224
|
-
position?: 'head' | 'body';
|
|
225
|
-
srcUrl: string;
|
|
226
|
-
filePath: string;
|
|
227
|
-
/** @todo inline dependencies not implemented yet */
|
|
228
|
-
inline?: boolean;
|
|
229
|
-
};
|
|
230
221
|
/**
|
|
231
222
|
* The possible kinds of a route.
|
|
232
223
|
*/
|
|
@@ -244,18 +235,6 @@ export type MatchResult = {
|
|
|
244
235
|
query: Record<string, string>;
|
|
245
236
|
params: Record<string, string | string[]>;
|
|
246
237
|
};
|
|
247
|
-
/**
|
|
248
|
-
* Represents a route in EcoPages.
|
|
249
|
-
*/
|
|
250
|
-
export type Route = {
|
|
251
|
-
kind: RouteKind;
|
|
252
|
-
filePath: string;
|
|
253
|
-
pathname: string;
|
|
254
|
-
};
|
|
255
|
-
/**
|
|
256
|
-
* Represents the routes in EcoPages.
|
|
257
|
-
*/
|
|
258
|
-
export type Routes = Record<string, Route>;
|
|
259
238
|
/**
|
|
260
239
|
* Represents the options for the file system server.
|
|
261
240
|
*/
|
|
@@ -263,16 +242,4 @@ export type FileSystemServerOptions = {
|
|
|
263
242
|
watchMode: boolean;
|
|
264
243
|
port?: number | string;
|
|
265
244
|
};
|
|
266
|
-
/**
|
|
267
|
-
* Represents the file system server adapter.
|
|
268
|
-
*/
|
|
269
|
-
export interface EcoPagesFileSystemServerAdapter<ServerInstanceOptions = unknown> {
|
|
270
|
-
startServer(serverOptions: ServerInstanceOptions): {
|
|
271
|
-
router: RouteRegistry;
|
|
272
|
-
server: unknown;
|
|
273
|
-
} | Promise<{
|
|
274
|
-
router: RouteRegistry;
|
|
275
|
-
server: unknown;
|
|
276
|
-
}>;
|
|
277
|
-
}
|
|
278
245
|
export type { ClientBridgeEvent, DefaultHmrContext, HmrFileChangeOptions, IHmrManager, IClientBridge, } from './public-types.js';
|
|
@@ -11,7 +11,7 @@ import type { InteractionEventsString as ScriptsInjectorInteractionEventsString
|
|
|
11
11
|
import type { EntrypointDependencyGraph } from '../services/runtime-state/entrypoint-dependency-graph.service.js';
|
|
12
12
|
import type { DevTransformBundleContributor } from '../dev/transform-server/types.js';
|
|
13
13
|
export type { EcoPagesAppConfig } from './internal-types.js';
|
|
14
|
-
export type { EcoPageComponent, GetPageDependencies, GetPageDependenciesContext, PageDependenciesResult, } from '../eco/eco.types.js';
|
|
14
|
+
export type { EcoPageComponent, FileOwnedDependencyContribution, GetPageDependencies, GetPageDependenciesContext, PageDependenciesResult, } from '../eco/eco.types.js';
|
|
15
15
|
export type { ProcessedAsset } from '../services/assets/asset-processing-service/assets.types.js';
|
|
16
16
|
/**
|
|
17
17
|
* Runtime-agnostic incoming WebSocket frame.
|
|
@@ -367,10 +367,7 @@ export type EcoChildren = string | Promise<string> | number | bigint | boolean |
|
|
|
367
367
|
strings: readonly string[];
|
|
368
368
|
values?: readonly EcoChildren[];
|
|
369
369
|
};
|
|
370
|
-
|
|
371
|
-
* Represents the input configuration for EcoPages.
|
|
372
|
-
*/
|
|
373
|
-
export type EcoPagesConfig = Omit<Partial<EcoPagesAppConfig>, 'baseUrl' | 'derivedPaths' | 'templatesExt' | 'integrationsDependencies'> & Pick<EcoPagesAppConfig, 'baseUrl' | 'rootDir'>;
|
|
370
|
+
export type { EcoPagesUserConfig } from '../config/user-config-types.js';
|
|
374
371
|
export type EcoComponentConfig = {
|
|
375
372
|
/** Canonical integration, module, and stable component attribution. */
|
|
376
373
|
identity?: ComponentIdentity;
|
|
@@ -645,27 +642,22 @@ export type EcoLayoutComponent<T = EcoPagesElement> = EcoComponent<LayoutProps<T
|
|
|
645
642
|
*/
|
|
646
643
|
export type EcoHtmlComponent<T = EcoPagesElement> = EcoComponent<HtmlTemplateProps, T>;
|
|
647
644
|
/**
|
|
648
|
-
* Props
|
|
649
|
-
*
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
message: string;
|
|
655
|
-
stack?: string;
|
|
656
|
-
}
|
|
657
|
-
/**
|
|
658
|
-
* Props type for the semantic `500.*` page template.
|
|
659
|
-
* @remarks In development, the page-pipeline passes `message` and `stack` from the
|
|
660
|
-
* thrown error when rendering this page after a failure. In production those
|
|
661
|
-
* fields are omitted so stacks are not serialized into HTML. Direct visits to
|
|
662
|
-
* `/500` also omit them. Semantic error templates receive safe empty
|
|
645
|
+
* Props passed to semantic HTML error pages (`pages/{status}.*` and `app.*()` loaders).
|
|
646
|
+
*
|
|
647
|
+
* @remarks
|
|
648
|
+
* `status` is the HTTP status being rendered. `message` is the public `HttpError`
|
|
649
|
+
* text for 4xx page-pipeline failures; unmatched URLs omit it. `stack` is only
|
|
650
|
+
* passed for 5xx pages in development. Semantic error pages receive safe empty
|
|
663
651
|
* `pageLocals` rather than request-scoped locals.
|
|
664
652
|
*/
|
|
665
|
-
export interface
|
|
653
|
+
export interface ErrorPageTemplateProps extends Omit<HtmlTemplateProps, 'children'> {
|
|
654
|
+
status: number;
|
|
666
655
|
message?: string;
|
|
667
656
|
stack?: string;
|
|
668
657
|
}
|
|
658
|
+
export type Error403TemplateProps = ErrorPageTemplateProps;
|
|
659
|
+
export type Error404TemplateProps = ErrorPageTemplateProps;
|
|
660
|
+
export type Error500TemplateProps = ErrorPageTemplateProps;
|
|
669
661
|
/**
|
|
670
662
|
* Represents the parameters for a page.
|
|
671
663
|
* The keys are strings, and the values can be either a string or an array of strings.
|
|
@@ -764,23 +756,6 @@ export type EcoPageFile<T = unknown> = T & {
|
|
|
764
756
|
getMetadata?: GetMetadata;
|
|
765
757
|
cache?: CacheStrategy;
|
|
766
758
|
};
|
|
767
|
-
/**
|
|
768
|
-
* Represents a CSS processor.
|
|
769
|
-
*/
|
|
770
|
-
export interface CssProcessor {
|
|
771
|
-
/**
|
|
772
|
-
* Processes a CSS file at the specified path.
|
|
773
|
-
* @param path - The path to the CSS file.
|
|
774
|
-
* @returns A promise that resolves to the processed CSS as a string.
|
|
775
|
-
*/
|
|
776
|
-
processPath: (path: string, options?: any) => Promise<string>;
|
|
777
|
-
/**
|
|
778
|
-
* Processes a CSS string or buffer.
|
|
779
|
-
* @param contents - The CSS contents as a string or buffer.
|
|
780
|
-
* @returns A promise that resolves to the processed CSS as a string.
|
|
781
|
-
*/
|
|
782
|
-
processStringOrBuffer: (contents: string | Buffer, options?: any) => Promise<string>;
|
|
783
|
-
}
|
|
784
759
|
/**
|
|
785
760
|
* The options for the route renderer.
|
|
786
761
|
*/
|
|
@@ -818,57 +793,6 @@ export type RouteRenderResult = {
|
|
|
818
793
|
/** Source paths observed during render preparation for HTML cache invalidation. */
|
|
819
794
|
sourceDependencyPaths?: readonly string[];
|
|
820
795
|
};
|
|
821
|
-
/**
|
|
822
|
-
* Represents the dependencies required for an integration plugin.
|
|
823
|
-
* It combines the base integration plugin dependencies with specific integration plugin dependencies.
|
|
824
|
-
*/
|
|
825
|
-
export type IntegrationPluginDependencies = BaseIntegrationPluginDependencies & SpecificIntegrationPluginDependencies;
|
|
826
|
-
type BaseIntegrationPluginDependencies = {
|
|
827
|
-
inline?: boolean;
|
|
828
|
-
};
|
|
829
|
-
/**
|
|
830
|
-
* Represents the dependencies required for a specific integration plugin.
|
|
831
|
-
* It can be one of the following types:
|
|
832
|
-
* {@link ScriptImportIntegrationPluginDependencies}
|
|
833
|
-
* {@link ScriptContentIntegrationPluginDependencies}
|
|
834
|
-
* {@link StylesheetImportIntegrationPluginDependencies}
|
|
835
|
-
* {@link StylesheetContentIntegrationPluginDependencies}
|
|
836
|
-
*/
|
|
837
|
-
type SpecificIntegrationPluginDependencies = ScriptImportIntegrationPluginDependencies | ScriptContentIntegrationPluginDependencies | StylesheetImportIntegrationPluginDependencies | StylesheetContentIntegrationPluginDependencies;
|
|
838
|
-
/**
|
|
839
|
-
* Script dependencies for an integration plugin with an import path.
|
|
840
|
-
*/
|
|
841
|
-
type ScriptImportIntegrationPluginDependencies = {
|
|
842
|
-
kind: 'script';
|
|
843
|
-
importPath: string;
|
|
844
|
-
position?: 'head' | 'body';
|
|
845
|
-
/** @default true */
|
|
846
|
-
minify?: boolean;
|
|
847
|
-
};
|
|
848
|
-
/**
|
|
849
|
-
* Script dependencies for an integration plugin with content.
|
|
850
|
-
*/
|
|
851
|
-
type ScriptContentIntegrationPluginDependencies = {
|
|
852
|
-
kind: 'script';
|
|
853
|
-
content: string;
|
|
854
|
-
position?: 'head' | 'body';
|
|
855
|
-
/** @default true */
|
|
856
|
-
minify?: boolean;
|
|
857
|
-
};
|
|
858
|
-
/**
|
|
859
|
-
* Stylesheet dependencies for an integration plugin with an import path.
|
|
860
|
-
*/
|
|
861
|
-
type StylesheetImportIntegrationPluginDependencies = {
|
|
862
|
-
kind: 'stylesheet';
|
|
863
|
-
importPath: string;
|
|
864
|
-
};
|
|
865
|
-
/**
|
|
866
|
-
* Stylesheet dependencies for an integration plugin with content.
|
|
867
|
-
*/
|
|
868
|
-
type StylesheetContentIntegrationPluginDependencies = {
|
|
869
|
-
kind: 'stylesheet';
|
|
870
|
-
content: string;
|
|
871
|
-
};
|
|
872
796
|
/**
|
|
873
797
|
* The options for the integration renderer.
|
|
874
798
|
*/
|
|
@@ -1021,18 +945,6 @@ export interface ComponentRenderResult {
|
|
|
1021
945
|
rootAttributes?: Record<string, string>;
|
|
1022
946
|
assets?: ProcessedAsset[];
|
|
1023
947
|
}
|
|
1024
|
-
/**
|
|
1025
|
-
* Represents a deep required type for a given object
|
|
1026
|
-
*/
|
|
1027
|
-
export type DeepRequired<T> = Required<{
|
|
1028
|
-
[K in keyof T]: T[K] extends Required<T[K]> ? T[K] : DeepRequired<T[K]>;
|
|
1029
|
-
}>;
|
|
1030
|
-
/**
|
|
1031
|
-
* The Prettify helper is a utility type that takes an object type and makes the hover overlay more readable.
|
|
1032
|
-
*/
|
|
1033
|
-
export type Prettify<T> = {
|
|
1034
|
-
[K in keyof T]: T[K];
|
|
1035
|
-
} & {};
|
|
1036
948
|
/**
|
|
1037
949
|
* Services available to API handlers.
|
|
1038
950
|
*/
|
|
@@ -1436,35 +1348,6 @@ export interface RouteSchema {
|
|
|
1436
1348
|
* Helper type to extract inferred types from a schema, with fallback to unknown.
|
|
1437
1349
|
*/
|
|
1438
1350
|
export type InferSchemaOutput<T> = T extends StandardSchema ? InferOutput<T> : unknown;
|
|
1439
|
-
/**
|
|
1440
|
-
* Context with typed body/query/headers based on the provided schema.
|
|
1441
|
-
*/
|
|
1442
|
-
export type TypedApiHandlerContext<TSchema extends RouteSchema, TRequest extends Request = Request, TServer = any> = Omit<ApiHandlerContext<TRequest, TServer>, 'body' | 'query' | 'headers'> & {
|
|
1443
|
-
body: InferSchemaOutput<TSchema['body']>;
|
|
1444
|
-
query: InferSchemaOutput<TSchema['query']>;
|
|
1445
|
-
headers: InferSchemaOutput<TSchema['headers']>;
|
|
1446
|
-
params: InferSchemaOutput<TSchema['params']>;
|
|
1447
|
-
};
|
|
1448
|
-
/**
|
|
1449
|
-
* Options for the group method.
|
|
1450
|
-
*
|
|
1451
|
-
* @typeParam TContext - Extended context type that middleware provides to handlers
|
|
1452
|
-
*
|
|
1453
|
-
* @example Group with auth middleware extending context
|
|
1454
|
-
* ```typescript
|
|
1455
|
-
* type AuthContext = ApiHandlerContext<BunRequest<string>, Server> & { user: User };
|
|
1456
|
-
*
|
|
1457
|
-
* app.group<AuthContext>('/api', (r) => {
|
|
1458
|
-
* r.get('/profile', (ctx) => {
|
|
1459
|
-
* // ctx.user is properly typed!
|
|
1460
|
-
* return ctx.json({ name: ctx.user.name });
|
|
1461
|
-
* });
|
|
1462
|
-
* }, { middleware: [authMiddleware] });
|
|
1463
|
-
* ```
|
|
1464
|
-
*/
|
|
1465
|
-
export interface GroupOptions<TRequest extends Request = Request, TServer = any, TContext extends ApiHandlerContext<TRequest, TServer> = ApiHandlerContext<TRequest, TServer>> {
|
|
1466
|
-
middleware?: Middleware<TRequest, TServer, TContext>[];
|
|
1467
|
-
}
|
|
1468
1351
|
/**
|
|
1469
1352
|
* Context type that combines schema-typed fields with an extended base context.
|
|
1470
1353
|
* Used by RouteGroupBuilder to merge schema validation types with middleware-extended context.
|
|
@@ -1509,7 +1392,9 @@ export interface RouteGroupBuilder<TRequest extends Request = Request, TServer =
|
|
|
1509
1392
|
}
|
|
1510
1393
|
/**
|
|
1511
1394
|
* A function that dynamically imports a view module.
|
|
1512
|
-
* Used by app.static()
|
|
1395
|
+
* Used by `app.static()` and the HTML error-page helpers (`app.notFound()`,
|
|
1396
|
+
* `app.forbidden()`, `app.serverError()`, `app.errorPage()`, …) to enable HMR
|
|
1397
|
+
* in development.
|
|
1513
1398
|
*/
|
|
1514
1399
|
export type ViewLoader<P = any> = () => Promise<{
|
|
1515
1400
|
default: EcoPageComponent<P>;
|
|
@@ -1522,3 +1407,16 @@ export interface StaticRoute<P = any> {
|
|
|
1522
1407
|
path: string;
|
|
1523
1408
|
loader: ViewLoader<P>;
|
|
1524
1409
|
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Lazy view loaders registered through `app.errorPage()` and the named
|
|
1412
|
+
* `app.badRequest()` / `app.unauthorized()` / `app.forbidden()` /
|
|
1413
|
+
* `app.notFound()` / `app.conflict()` / `app.serverError()` helpers.
|
|
1414
|
+
*/
|
|
1415
|
+
export type ErrorPageLoaders = {
|
|
1416
|
+
badRequest?: ViewLoader<ErrorPageTemplateProps>;
|
|
1417
|
+
unauthorized?: ViewLoader<ErrorPageTemplateProps>;
|
|
1418
|
+
forbidden?: ViewLoader<ErrorPageTemplateProps>;
|
|
1419
|
+
notFound?: ViewLoader<ErrorPageTemplateProps>;
|
|
1420
|
+
conflict?: ViewLoader<ErrorPageTemplateProps>;
|
|
1421
|
+
serverError?: ViewLoader<ErrorPageTemplateProps>;
|
|
1422
|
+
};
|
|
@@ -16,6 +16,32 @@ function getEmbeddedRuntimeCommandOptions() {
|
|
|
16
16
|
}
|
|
17
17
|
const ECOPAGES_BIN_FILES = ['ecopages.ts', 'ecopages.js', 'cli.js'];
|
|
18
18
|
const ECOPAGES_AVAILABLE_COMMANDS = ['dev', 'build', 'start', 'preview'];
|
|
19
|
+
function resolveEcopagesSubcommand(runtimeArgv) {
|
|
20
|
+
const ecopagesIndex = runtimeArgv.findIndex((arg) => ECOPAGES_BIN_FILES.some((filename) => arg.endsWith(filename)));
|
|
21
|
+
if (ecopagesIndex === -1) {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
if (ecopagesIndex < runtimeArgv.length - 1 &&
|
|
25
|
+
ECOPAGES_AVAILABLE_COMMANDS.some((cmd) => runtimeArgv[ecopagesIndex + 1] === cmd)) {
|
|
26
|
+
return runtimeArgv[ecopagesIndex + 1];
|
|
27
|
+
}
|
|
28
|
+
return 'start';
|
|
29
|
+
}
|
|
30
|
+
function deriveCliCommandFlags(command, values) {
|
|
31
|
+
const isStartCommand = command === 'start' || (!values.dev && !values.build && !values.preview);
|
|
32
|
+
const isDevCommand = command === 'dev' || !!values.dev;
|
|
33
|
+
const isBuildCommand = command === 'build' || !!values.build;
|
|
34
|
+
const isPreviewCommand = command === 'preview' || !!values.preview;
|
|
35
|
+
return { isStartCommand, isDevCommand, isBuildCommand, isPreviewCommand };
|
|
36
|
+
}
|
|
37
|
+
function applyNodeEnvForCliCommand(isDevCommand) {
|
|
38
|
+
if (isDevCommand) {
|
|
39
|
+
process.env.NODE_ENV ??= 'development';
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
process.env.NODE_ENV = 'production';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
19
45
|
/**
|
|
20
46
|
* Parses command line arguments for the server.
|
|
21
47
|
* It returns {@link ReturnParseCliArgs}
|
|
@@ -39,22 +65,8 @@ export function parseCliArgs(options = {}) {
|
|
|
39
65
|
},
|
|
40
66
|
allowPositionals: true,
|
|
41
67
|
});
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
const isAvailableCommand = ecopagesIndex !== -1;
|
|
45
|
-
if (isAvailableCommand) {
|
|
46
|
-
command =
|
|
47
|
-
ecopagesIndex < runtimeArgv.length - 1 &&
|
|
48
|
-
ECOPAGES_AVAILABLE_COMMANDS.some((cmd) => {
|
|
49
|
-
return runtimeArgv[ecopagesIndex + 1] === cmd;
|
|
50
|
-
})
|
|
51
|
-
? runtimeArgv[ecopagesIndex + 1]
|
|
52
|
-
: 'start';
|
|
53
|
-
}
|
|
54
|
-
const isStartCommand = command === 'start' || (!values.dev && !values.build && !values.preview);
|
|
55
|
-
const isDevCommand = command === 'dev' || !!values.dev;
|
|
56
|
-
const isBuildCommand = command === 'build' || !!values.build;
|
|
57
|
-
const isPreviewCommand = command === 'preview' || !!values.preview;
|
|
68
|
+
const command = resolveEcopagesSubcommand(runtimeArgv);
|
|
69
|
+
const { isStartCommand, isDevCommand, isBuildCommand, isPreviewCommand } = deriveCliCommandFlags(command, values);
|
|
58
70
|
const parsedCommandOptions = {
|
|
59
71
|
preview: isPreviewCommand,
|
|
60
72
|
build: isBuildCommand,
|
|
@@ -66,11 +78,6 @@ export function parseCliArgs(options = {}) {
|
|
|
66
78
|
hostname: values.hostname,
|
|
67
79
|
reactFastRefresh: values['react-fast-refresh'],
|
|
68
80
|
};
|
|
69
|
-
|
|
70
|
-
process.env.NODE_ENV ??= 'development';
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
process.env.NODE_ENV = 'production';
|
|
74
|
-
}
|
|
81
|
+
applyNodeEnvForCliCommand(isDevCommand);
|
|
75
82
|
return parsedCommandOptions;
|
|
76
83
|
}
|
|
@@ -17,6 +17,10 @@ export interface ProjectWatcherConfig {
|
|
|
17
17
|
hostOwnsDevClient?: boolean;
|
|
18
18
|
/** Delay before a change event is processed; 0 disables debouncing. */
|
|
19
19
|
changeDebounceMs?: number;
|
|
20
|
+
/** Applies a config or dotenv change through the owning runtime lifecycle. */
|
|
21
|
+
onRestartRequest?: (filePath: string) => Promise<void>;
|
|
22
|
+
/** Whether an entry watcher already owns changes to the config module. */
|
|
23
|
+
entryWatcherOwnsConfig?: boolean;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
26
|
* ProjectWatcher handles file system changes for hot module replacement (HMR).
|
|
@@ -49,11 +53,14 @@ export declare class ProjectWatcher {
|
|
|
49
53
|
private readonly hostOwnsDevClient;
|
|
50
54
|
private readonly invalidationService;
|
|
51
55
|
private readonly changeDebounceMs;
|
|
56
|
+
private readonly onRestartRequest?;
|
|
57
|
+
private readonly entryWatcherOwnsConfig;
|
|
58
|
+
private restartRequestScheduled;
|
|
52
59
|
private watcher;
|
|
53
60
|
private closed;
|
|
54
61
|
private pendingChangeEvents;
|
|
55
62
|
private changeQueue;
|
|
56
|
-
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient, changeDebounceMs, }: ProjectWatcherConfig);
|
|
63
|
+
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient, changeDebounceMs, onRestartRequest, entryWatcherOwnsConfig, }: ProjectWatcherConfig);
|
|
57
64
|
/**
|
|
58
65
|
* Uncaches modules in the source directory to ensure fresh imports.
|
|
59
66
|
* This is necessary for hot module replacement to work correctly.
|
|
@@ -61,7 +68,6 @@ export declare class ProjectWatcher {
|
|
|
61
68
|
*/
|
|
62
69
|
private uncacheModules;
|
|
63
70
|
private isRouteSourceFile;
|
|
64
|
-
private isIncludeSourceFile;
|
|
65
71
|
private requestBrowserReload;
|
|
66
72
|
/**
|
|
67
73
|
* Handles public directory file changes by copying only the changed file.
|
|
@@ -92,6 +98,12 @@ export declare class ProjectWatcher {
|
|
|
92
98
|
* @param event - The type of file system event
|
|
93
99
|
*/
|
|
94
100
|
private handleFileChange;
|
|
101
|
+
private invalidatePageCachesForChange;
|
|
102
|
+
private applyRouteAndServerInvalidation;
|
|
103
|
+
private shouldDeferProcessorNotifications;
|
|
104
|
+
private handleDeferredHmrFileChange;
|
|
105
|
+
private handleStandardHmrFileChange;
|
|
106
|
+
private handleRuntimeRestart;
|
|
95
107
|
private processFileChange;
|
|
96
108
|
/**
|
|
97
109
|
* Re-imports server modules before HMR broadcast so reload/refetch does not
|
|
@@ -107,20 +119,6 @@ export declare class ProjectWatcher {
|
|
|
107
119
|
*/
|
|
108
120
|
private notifyProcessors;
|
|
109
121
|
private getProcessorHandler;
|
|
110
|
-
/**
|
|
111
|
-
* Checks if a file is in the public directory.
|
|
112
|
-
*/
|
|
113
|
-
private isPublicDirFile;
|
|
114
|
-
/**
|
|
115
|
-
* Checks if file path matches any additionalWatchPaths patterns.
|
|
116
|
-
*/
|
|
117
|
-
private matchesAdditionalWatchPaths;
|
|
118
|
-
/**
|
|
119
|
-
* Checks if a file is owned by a processor as an asset input.
|
|
120
|
-
* Ownership requires declared asset capabilities; watch config only drives
|
|
121
|
-
* {@link notifyProcessors} notifications.
|
|
122
|
-
*/
|
|
123
|
-
private isHandledByProcessor;
|
|
124
122
|
/**
|
|
125
123
|
* Triggers router refresh for page directory changes.
|
|
126
124
|
* This ensures the router is updated when pages are added or removed.
|
|
@@ -9,6 +9,7 @@ import { getAppPageBrowserGraphSession } from '../route-renderer/orchestration/p
|
|
|
9
9
|
import { isRegisteredDevTransformEntrypoint } from '../hmr/hmr-entrypoint-output.js';
|
|
10
10
|
import { resolveInternalExecutionDir } from '../utils/resolve-work-dir.js';
|
|
11
11
|
import { createProjectWatcherIgnorePredicate } from './project-watcher-ignore.js';
|
|
12
|
+
import { resolveRuntimeRestartWatchPaths } from '../dev/development-restart-watch-paths.js';
|
|
12
13
|
/**
|
|
13
14
|
* ProjectWatcher handles file system changes for hot module replacement (HMR).
|
|
14
15
|
* It uses chokidar to watch for file changes and triggers appropriate actions:
|
|
@@ -40,11 +41,14 @@ export class ProjectWatcher {
|
|
|
40
41
|
hostOwnsDevClient;
|
|
41
42
|
invalidationService;
|
|
42
43
|
changeDebounceMs;
|
|
44
|
+
onRestartRequest;
|
|
45
|
+
entryWatcherOwnsConfig;
|
|
46
|
+
restartRequestScheduled = false;
|
|
43
47
|
watcher = null;
|
|
44
48
|
closed = false;
|
|
45
49
|
pendingChangeEvents = new Map();
|
|
46
50
|
changeQueue = Promise.resolve();
|
|
47
|
-
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient, changeDebounceMs, }) {
|
|
51
|
+
constructor({ config, refreshRouterRoutesCallback, hmrManager, bridge, hostOwnsDevClient, changeDebounceMs, onRestartRequest, entryWatcherOwnsConfig, }) {
|
|
48
52
|
this.appConfig = config;
|
|
49
53
|
this.refreshRouterRoutesCallback = refreshRouterRoutesCallback;
|
|
50
54
|
this.hmrManager = hmrManager;
|
|
@@ -55,6 +59,8 @@ export class ProjectWatcher {
|
|
|
55
59
|
changeDebounceMs ??
|
|
56
60
|
(envDebounceMs !== undefined && envDebounceMs !== '' ? Number(envDebounceMs) : undefined) ??
|
|
57
61
|
ProjectWatcher.duplicateChangeWindowMs;
|
|
62
|
+
this.onRestartRequest = onRestartRequest;
|
|
63
|
+
this.entryWatcherOwnsConfig = entryWatcherOwnsConfig === true;
|
|
58
64
|
this.invalidationService = new DevelopmentInvalidationService(config);
|
|
59
65
|
this.triggerRouterRefresh = this.triggerRouterRefresh.bind(this);
|
|
60
66
|
this.handleError = this.handleError.bind(this);
|
|
@@ -80,9 +86,6 @@ export class ProjectWatcher {
|
|
|
80
86
|
isRouteSourceFile(filePath) {
|
|
81
87
|
return this.invalidationService.isRouteSourceFile(filePath);
|
|
82
88
|
}
|
|
83
|
-
isIncludeSourceFile(filePath) {
|
|
84
|
-
return this.invalidationService.isIncludeSourceFile(filePath);
|
|
85
|
-
}
|
|
86
89
|
requestBrowserReload() {
|
|
87
90
|
if (this.hostOwnsDevClient) {
|
|
88
91
|
return;
|
|
@@ -155,64 +158,100 @@ export class ProjectWatcher {
|
|
|
155
158
|
this.pendingChangeEvents.set(filePath, { event, timer });
|
|
156
159
|
return Promise.resolve();
|
|
157
160
|
}
|
|
161
|
+
async invalidatePageCachesForChange(plan, resolvedFilePath) {
|
|
162
|
+
if (shouldClearAllPageHtmlCache(plan.category)) {
|
|
163
|
+
await clearAppPageCache(this.appConfig);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await invalidateAppPageCacheBySourcePaths(this.appConfig, [resolvedFilePath]);
|
|
167
|
+
}
|
|
168
|
+
async applyRouteAndServerInvalidation(plan, filePath, resolvedFilePath, event, isRegisteredDevTransformEdit) {
|
|
169
|
+
if (plan.refreshRoutes && (event === 'unlink' || event === 'add')) {
|
|
170
|
+
getAppPageBrowserGraphSession(this.appConfig).invalidateByRouteFile(resolvedFilePath);
|
|
171
|
+
}
|
|
172
|
+
if (plan.invalidateServerModules && !isRegisteredDevTransformEdit) {
|
|
173
|
+
this.invalidationService.invalidateServerModules([filePath]);
|
|
174
|
+
}
|
|
175
|
+
if (plan.refreshRoutes) {
|
|
176
|
+
await this.refreshRouterRoutesCallback();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
shouldDeferProcessorNotifications(plan, isRegisteredDevTransformEdit) {
|
|
180
|
+
return (plan.category === 'include-source' ||
|
|
181
|
+
plan.category === 'explicit-server-view' ||
|
|
182
|
+
isRegisteredDevTransformEdit);
|
|
183
|
+
}
|
|
184
|
+
async handleDeferredHmrFileChange(filePath, resolvedFilePath, event, plan, graphPreparation) {
|
|
185
|
+
await this.prewarmBeforeHmr(resolvedFilePath, plan);
|
|
186
|
+
await this.hmrManager.handleFileChange(filePath, {
|
|
187
|
+
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
188
|
+
});
|
|
189
|
+
await this.notifyProcessors(filePath, event);
|
|
190
|
+
}
|
|
191
|
+
async handleStandardHmrFileChange(filePath, event, plan, graphPreparation) {
|
|
192
|
+
await this.notifyProcessors(filePath, event);
|
|
193
|
+
if (plan.processorHandledAsset) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
if (plan.delegateToHmr) {
|
|
197
|
+
await this.hmrManager.handleFileChange(filePath, {
|
|
198
|
+
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
handleRuntimeRestart(filePath) {
|
|
203
|
+
const onRestartRequest = this.onRestartRequest;
|
|
204
|
+
if (!onRestartRequest) {
|
|
205
|
+
appLogger.warn(`Configuration or environment file changed (${filePath}). Restart the development server to apply it.`);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (this.restartRequestScheduled) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
this.restartRequestScheduled = true;
|
|
212
|
+
void this.changeQueue
|
|
213
|
+
.then(() => onRestartRequest(filePath))
|
|
214
|
+
.catch((error) => this.handleError(error))
|
|
215
|
+
.finally(() => {
|
|
216
|
+
this.restartRequestScheduled = false;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
158
219
|
async processFileChange(filePath, event) {
|
|
159
220
|
try {
|
|
160
221
|
const plan = this.invalidationService.planFileChange(filePath);
|
|
222
|
+
if (plan.category === 'runtime-restart') {
|
|
223
|
+
if (this.entryWatcherOwnsConfig && this.invalidationService.isConfigModuleFile(filePath)) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
this.handleRuntimeRestart(filePath);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
161
229
|
if (plan.category === 'public-asset') {
|
|
162
230
|
await this.handlePublicDirFileChange(filePath);
|
|
163
231
|
return;
|
|
164
232
|
}
|
|
165
233
|
this.uncacheModules();
|
|
166
234
|
const resolvedFilePath = path.resolve(filePath);
|
|
167
|
-
|
|
168
|
-
await clearAppPageCache(this.appConfig);
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
await invalidateAppPageCacheBySourcePaths(this.appConfig, [resolvedFilePath]);
|
|
172
|
-
}
|
|
235
|
+
await this.invalidatePageCachesForChange(plan, resolvedFilePath);
|
|
173
236
|
const graphPreparation = this.hmrManager.isEnabled()
|
|
174
237
|
? prepareHmrFileChange(this.appConfig, resolvedFilePath)
|
|
175
238
|
: undefined;
|
|
176
|
-
if (plan.refreshRoutes && (event === 'unlink' || event === 'add')) {
|
|
177
|
-
getAppPageBrowserGraphSession(this.appConfig).invalidateByRouteFile(resolvedFilePath);
|
|
178
|
-
}
|
|
179
239
|
const isRegisteredDevTransformEdit = isRegisteredDevTransformEntrypoint(this.hmrManager.getRegisteredEntrypoints(), resolvedFilePath);
|
|
180
|
-
|
|
181
|
-
this.invalidationService.invalidateServerModules([filePath]);
|
|
182
|
-
}
|
|
183
|
-
if (plan.refreshRoutes) {
|
|
184
|
-
await this.refreshRouterRoutesCallback();
|
|
185
|
-
}
|
|
240
|
+
await this.applyRouteAndServerInvalidation(plan, filePath, resolvedFilePath, event, isRegisteredDevTransformEdit);
|
|
186
241
|
if (plan.reloadBrowser) {
|
|
242
|
+
await this.notifyProcessors(filePath, event);
|
|
187
243
|
this.requestBrowserReload();
|
|
188
244
|
return;
|
|
189
245
|
}
|
|
190
|
-
const deferProcessorNotifications = plan
|
|
191
|
-
plan.category === 'explicit-server-view' ||
|
|
192
|
-
isRegisteredDevTransformEdit;
|
|
246
|
+
const deferProcessorNotifications = this.shouldDeferProcessorNotifications(plan, isRegisteredDevTransformEdit);
|
|
193
247
|
if (deferProcessorNotifications && plan.delegateToHmr) {
|
|
194
|
-
await this.
|
|
195
|
-
await this.hmrManager.handleFileChange(filePath, {
|
|
196
|
-
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
197
|
-
});
|
|
198
|
-
await this.notifyProcessors(filePath, event);
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
await this.notifyProcessors(filePath, event);
|
|
202
|
-
if (plan.processorHandledAsset) {
|
|
248
|
+
await this.handleDeferredHmrFileChange(filePath, resolvedFilePath, event, plan, graphPreparation);
|
|
203
249
|
return;
|
|
204
250
|
}
|
|
205
|
-
|
|
206
|
-
await this.hmrManager.handleFileChange(filePath, {
|
|
207
|
-
graphIdentities: graphPreparation?.affectedGraphIdentities,
|
|
208
|
-
});
|
|
209
|
-
}
|
|
251
|
+
await this.handleStandardHmrFileChange(filePath, event, plan, graphPreparation);
|
|
210
252
|
}
|
|
211
253
|
catch (error) {
|
|
212
|
-
|
|
213
|
-
this.bridge.error(error.message);
|
|
214
|
-
this.handleError(error);
|
|
215
|
-
}
|
|
254
|
+
this.handleError(error);
|
|
216
255
|
}
|
|
217
256
|
}
|
|
218
257
|
/**
|
|
@@ -284,26 +323,6 @@ export class ProjectWatcher {
|
|
|
284
323
|
return watchConfig.onDelete;
|
|
285
324
|
}
|
|
286
325
|
}
|
|
287
|
-
/**
|
|
288
|
-
* Checks if a file is in the public directory.
|
|
289
|
-
*/
|
|
290
|
-
isPublicDirFile(filePath) {
|
|
291
|
-
return this.invalidationService.isPublicDirFile(filePath);
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Checks if file path matches any additionalWatchPaths patterns.
|
|
295
|
-
*/
|
|
296
|
-
matchesAdditionalWatchPaths(filePath) {
|
|
297
|
-
return this.invalidationService.matchesAdditionalWatchPaths(filePath);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Checks if a file is owned by a processor as an asset input.
|
|
301
|
-
* Ownership requires declared asset capabilities; watch config only drives
|
|
302
|
-
* {@link notifyProcessors} notifications.
|
|
303
|
-
*/
|
|
304
|
-
isHandledByProcessor(filePath) {
|
|
305
|
-
return this.invalidationService.isProcessorOwnedAsset(filePath);
|
|
306
|
-
}
|
|
307
326
|
/**
|
|
308
327
|
* Triggers router refresh for page directory changes.
|
|
309
328
|
* This ensures the router is updated when pages are added or removed.
|
|
@@ -364,7 +383,13 @@ export class ProjectWatcher {
|
|
|
364
383
|
processorPaths.add(this.appConfig.absolutePaths.publicDir);
|
|
365
384
|
}
|
|
366
385
|
for (const watchPath of this.appConfig.additionalWatchPaths) {
|
|
367
|
-
|
|
386
|
+
const resolvedWatchPath = path.isAbsolute(watchPath) || watchPath.includes('*')
|
|
387
|
+
? watchPath
|
|
388
|
+
: path.resolve(this.appConfig.rootDir, watchPath);
|
|
389
|
+
processorPaths.add(resolvedWatchPath);
|
|
390
|
+
}
|
|
391
|
+
for (const restartPath of resolveRuntimeRestartWatchPaths(this.appConfig)) {
|
|
392
|
+
processorPaths.add(restartPath);
|
|
368
393
|
}
|
|
369
394
|
const ignored = createProjectWatcherIgnorePredicate(this.appConfig.absolutePaths);
|
|
370
395
|
this.watcher = chokidar.watch(Array.from(processorPaths), {
|