@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
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import type { SourceModuleLoader } from '../../services/module-loading/module-loading-types.js';
|
|
10
10
|
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
11
|
-
import type { ApiHandler, ApiHandlerContext, ErrorHandler, Middleware, RouteOptions, StaticRoute, ViewLoader, EcopagesRouteInfo } from '../../types/public-types.js';
|
|
11
|
+
import type { ApiHandler, ApiHandlerContext, ErrorHandler, Middleware, RouteOptions, StaticRoute, ViewLoader, ErrorPageLoaders, ErrorPageTemplateProps, EcopagesRouteInfo } from '../../types/public-types.js';
|
|
12
12
|
import type { EcopagesWebSocketHandler } from '../../types/public-types.js';
|
|
13
|
+
import { type HttpErrorPageStatus } from '../../errors/http-error-page-contract.js';
|
|
13
14
|
import { type EcopagesRuntimeLabel } from '../../dev/runtime-server-started-message.js';
|
|
14
15
|
import { type ReturnParseCliArgs } from '../../utils/parse-cli-args.js';
|
|
15
16
|
/**
|
|
@@ -55,14 +56,6 @@ export interface AppStartInfo {
|
|
|
55
56
|
routes: EcopagesRouteInfo[];
|
|
56
57
|
}
|
|
57
58
|
export type OnAppStartCallback = (info: AppStartInfo) => void;
|
|
58
|
-
/** @deprecated Use {@link AppStartInfo}. */
|
|
59
|
-
export type ApplicationListeningInfo = AppStartInfo;
|
|
60
|
-
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
61
|
-
export type StartCallback = OnAppStartCallback;
|
|
62
|
-
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
63
|
-
export type ListenCallback = OnAppStartCallback;
|
|
64
|
-
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
65
|
-
export type ApplicationListeningCallback = OnAppStartCallback;
|
|
66
59
|
/**
|
|
67
60
|
* Configuration options for application adapters
|
|
68
61
|
*/
|
|
@@ -70,11 +63,6 @@ export interface ApplicationAdapterOptions {
|
|
|
70
63
|
appConfig: EcoPagesAppConfig;
|
|
71
64
|
serverOptions?: Record<string, any>;
|
|
72
65
|
runtime?: ApplicationRuntimeOptions;
|
|
73
|
-
/**
|
|
74
|
-
* Options for clearing the output directory before starting the server
|
|
75
|
-
* @default false
|
|
76
|
-
*/
|
|
77
|
-
clearOutput?: boolean;
|
|
78
66
|
}
|
|
79
67
|
/**
|
|
80
68
|
* Common interface for application adapters
|
|
@@ -105,6 +93,7 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
105
93
|
protected runtimeOptions: ApplicationRuntimeOptions;
|
|
106
94
|
protected apiHandlers: ApiHandler[];
|
|
107
95
|
protected staticRoutes: StaticRoute[];
|
|
96
|
+
protected errorPageLoaders: ErrorPageLoaders;
|
|
108
97
|
protected errorHandler?: ErrorHandler;
|
|
109
98
|
/**
|
|
110
99
|
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
@@ -114,7 +103,6 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
114
103
|
private onAppStartCallback?;
|
|
115
104
|
protected readonly runtimeLabel: EcopagesRuntimeLabel;
|
|
116
105
|
constructor(options: TOptions, runtimeLabel: EcopagesRuntimeLabel);
|
|
117
|
-
private clearDistFolder;
|
|
118
106
|
/**
|
|
119
107
|
* Register a GET route handler.
|
|
120
108
|
*
|
|
@@ -178,29 +166,41 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
178
166
|
middleware?: readonly Middleware<TRequest, TServer, any>[];
|
|
179
167
|
}): this;
|
|
180
168
|
abstract group(group: RouteGroupDefinition<TRequest, TServer>): this;
|
|
181
|
-
/**
|
|
182
|
-
* Get all registered API handlers
|
|
183
|
-
*/
|
|
184
|
-
getApiHandlers(): ApiHandler[];
|
|
185
169
|
/**
|
|
186
170
|
* Register a view for static generation at build time.
|
|
187
171
|
* The view must have staticPaths defined for dynamic routes.
|
|
188
172
|
*
|
|
189
|
-
*
|
|
173
|
+
* String and URL inputs load through the server-module transpiler so HMR and
|
|
174
|
+
* component identity transforms remain active in development.
|
|
190
175
|
*
|
|
191
176
|
* @param path - URL path pattern (e.g., '/posts/:slug')
|
|
192
|
-
* @param loader - A function
|
|
177
|
+
* @param loader - A view loader function, source path, or URL for the eco.page view module
|
|
193
178
|
* @example
|
|
194
179
|
* ```typescript
|
|
195
|
-
* app.static('/login',
|
|
196
|
-
* app.static('/posts/:slug',
|
|
180
|
+
* app.static('/login', './src/views/login.kita')
|
|
181
|
+
* app.static('/posts/:slug', './src/views/post-view.kita')
|
|
197
182
|
* ```
|
|
198
183
|
*/
|
|
199
|
-
static<P>(path: string, loader: ViewLoader<P>): this;
|
|
184
|
+
static<P>(path: string, loader: ViewLoader<P> | string | URL): this;
|
|
185
|
+
private resolveViewLoader;
|
|
186
|
+
/**
|
|
187
|
+
* Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
|
|
188
|
+
* file exists.
|
|
189
|
+
*/
|
|
190
|
+
errorPage(status: HttpErrorPageStatus, loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
191
|
+
badRequest(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
192
|
+
unauthorized(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
193
|
+
forbidden(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
194
|
+
/**
|
|
195
|
+
* Registers the not-found page used when no filesystem `pages/404.*` file exists.
|
|
196
|
+
*/
|
|
197
|
+
notFound(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
198
|
+
conflict(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
200
199
|
/**
|
|
201
|
-
*
|
|
200
|
+
* Registers the server-error page used when no filesystem `pages/500.*` file exists.
|
|
202
201
|
*/
|
|
203
|
-
|
|
202
|
+
serverError(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
203
|
+
getErrorPageLoaders(): ErrorPageLoaders;
|
|
204
204
|
/**
|
|
205
205
|
* Register a WebSocket handler for the given path pattern.
|
|
206
206
|
*
|
|
@@ -235,16 +235,16 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
235
235
|
* ```
|
|
236
236
|
*/
|
|
237
237
|
websocket<TContext = unknown, TParams extends Record<string, string> = Record<string, string>>(path: string, handler: EcopagesWebSocketHandler<TContext, TParams>): this;
|
|
238
|
-
/**
|
|
239
|
-
* Get the registered WebSocket handlers map.
|
|
240
|
-
*
|
|
241
|
-
* @returns The map of WebSocket route patterns to handlers
|
|
242
|
-
*/
|
|
243
|
-
getWebsocketHandlers(): Map<string, EcopagesWebSocketHandler<any, any>>;
|
|
244
238
|
/**
|
|
245
239
|
* Register a global error handler for all routes.
|
|
246
240
|
* Useful for logging, monitoring integration, and custom error formatting.
|
|
247
241
|
*
|
|
242
|
+
* @remarks
|
|
243
|
+
* It receives errors thrown by API handlers and their middleware, and errors
|
|
244
|
+
* that escape the request pipeline. Page render failures render the error
|
|
245
|
+
* page instead and do not reach it. Client disconnects answer 499 without
|
|
246
|
+
* calling it.
|
|
247
|
+
*
|
|
248
248
|
* @example
|
|
249
249
|
* ```typescript
|
|
250
250
|
* app.onError(async (error, ctx) => {
|
|
@@ -254,10 +254,6 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
254
254
|
* ```
|
|
255
255
|
*/
|
|
256
256
|
onError(handler: ErrorHandler<TRequest, TServer>): this;
|
|
257
|
-
/**
|
|
258
|
-
* Get the registered error handler
|
|
259
|
-
*/
|
|
260
|
-
getErrorHandler(): ErrorHandler | undefined;
|
|
261
257
|
/**
|
|
262
258
|
* Initialize the server adapter based on the runtime
|
|
263
259
|
*/
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { appLogger } from '../../global/app-logger.js';
|
|
10
10
|
import { getAppModuleLoader, setAppHostModuleLoader, } from '../../services/module-loading/app-server-module-transpiler.service.js';
|
|
11
|
+
import { createViewModuleLoader } from '../../services/module-loading/view-module-loader.js';
|
|
11
12
|
import { getHostModuleLoader } from '../../services/module-loading/host-module-loader-registry.js';
|
|
12
13
|
import { invariant } from '../../utils/invariant.js';
|
|
13
|
-
import {
|
|
14
|
+
import { ERROR_PAGE_KIND_BY_STATUS } from '../../errors/http-error-page-contract.js';
|
|
14
15
|
import { formatRuntimeServerStartedMessage, } from '../../dev/runtime-server-started-message.js';
|
|
15
16
|
import { parseCliArgs } from '../../utils/parse-cli-args.js';
|
|
16
17
|
import { startupTrace } from '../../diagnostics/startup-trace.js';
|
|
18
|
+
import { ECOPAGES_DEV_RESTART_REASON_ENV } from '../../dev/development-restart.js';
|
|
17
19
|
/**
|
|
18
20
|
* Abstract base class for application adapters across different runtimes
|
|
19
21
|
*/
|
|
@@ -24,6 +26,7 @@ export class AbstractApplicationAdapter {
|
|
|
24
26
|
runtimeOptions;
|
|
25
27
|
apiHandlers = [];
|
|
26
28
|
staticRoutes = [];
|
|
29
|
+
errorPageLoaders = {};
|
|
27
30
|
errorHandler;
|
|
28
31
|
/**
|
|
29
32
|
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
@@ -50,24 +53,6 @@ export class AbstractApplicationAdapter {
|
|
|
50
53
|
}
|
|
51
54
|
getAppModuleLoader(this.appConfig);
|
|
52
55
|
startupTrace.markConfigReady();
|
|
53
|
-
if (options.clearOutput) {
|
|
54
|
-
this.clearDistFolder().catch((error) => {
|
|
55
|
-
appLogger.error('Error clearing dist folder', error);
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
async clearDistFolder() {
|
|
60
|
-
const distPath = this.appConfig.absolutePaths.distDir;
|
|
61
|
-
const distExists = fileSystem.exists(distPath);
|
|
62
|
-
if (!distExists)
|
|
63
|
-
return;
|
|
64
|
-
try {
|
|
65
|
-
await fileSystem.removeAsync(distPath);
|
|
66
|
-
appLogger.debug(`Cleared dist folder: ${distPath}`);
|
|
67
|
-
}
|
|
68
|
-
catch (error) {
|
|
69
|
-
appLogger.error(`Error clearing dist folder: ${distPath}`, error);
|
|
70
|
-
}
|
|
71
56
|
}
|
|
72
57
|
/**
|
|
73
58
|
* Internal method to add route handlers to the API handlers array
|
|
@@ -84,35 +69,67 @@ export class AbstractApplicationAdapter {
|
|
|
84
69
|
});
|
|
85
70
|
return this;
|
|
86
71
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Get all registered API handlers
|
|
89
|
-
*/
|
|
90
|
-
getApiHandlers() {
|
|
91
|
-
return this.apiHandlers;
|
|
92
|
-
}
|
|
93
72
|
/**
|
|
94
73
|
* Register a view for static generation at build time.
|
|
95
74
|
* The view must have staticPaths defined for dynamic routes.
|
|
96
75
|
*
|
|
97
|
-
*
|
|
76
|
+
* String and URL inputs load through the server-module transpiler so HMR and
|
|
77
|
+
* component identity transforms remain active in development.
|
|
98
78
|
*
|
|
99
79
|
* @param path - URL path pattern (e.g., '/posts/:slug')
|
|
100
|
-
* @param loader - A function
|
|
80
|
+
* @param loader - A view loader function, source path, or URL for the eco.page view module
|
|
101
81
|
* @example
|
|
102
82
|
* ```typescript
|
|
103
|
-
* app.static('/login',
|
|
104
|
-
* app.static('/posts/:slug',
|
|
83
|
+
* app.static('/login', './src/views/login.kita')
|
|
84
|
+
* app.static('/posts/:slug', './src/views/post-view.kita')
|
|
105
85
|
* ```
|
|
106
86
|
*/
|
|
107
87
|
static(path, loader) {
|
|
108
|
-
this.
|
|
88
|
+
const resolvedLoader = this.resolveViewLoader(loader);
|
|
89
|
+
this.staticRoutes.push({ path, loader: resolvedLoader });
|
|
109
90
|
return this;
|
|
110
91
|
}
|
|
92
|
+
resolveViewLoader(loader) {
|
|
93
|
+
return typeof loader === 'string' || loader instanceof URL
|
|
94
|
+
? createViewModuleLoader(this.appConfig, loader)
|
|
95
|
+
: loader;
|
|
96
|
+
}
|
|
111
97
|
/**
|
|
112
|
-
*
|
|
98
|
+
* Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
|
|
99
|
+
* file exists.
|
|
113
100
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
errorPage(status, loader) {
|
|
102
|
+
const kind = ERROR_PAGE_KIND_BY_STATUS[status];
|
|
103
|
+
const resolvedLoader = this.resolveViewLoader(loader);
|
|
104
|
+
this.errorPageLoaders = { ...this.errorPageLoaders, [kind]: resolvedLoader };
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
badRequest(loader) {
|
|
108
|
+
return this.errorPage(400, loader);
|
|
109
|
+
}
|
|
110
|
+
unauthorized(loader) {
|
|
111
|
+
return this.errorPage(401, loader);
|
|
112
|
+
}
|
|
113
|
+
forbidden(loader) {
|
|
114
|
+
return this.errorPage(403, loader);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Registers the not-found page used when no filesystem `pages/404.*` file exists.
|
|
118
|
+
*/
|
|
119
|
+
notFound(loader) {
|
|
120
|
+
return this.errorPage(404, loader);
|
|
121
|
+
}
|
|
122
|
+
conflict(loader) {
|
|
123
|
+
return this.errorPage(409, loader);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Registers the server-error page used when no filesystem `pages/500.*` file exists.
|
|
127
|
+
*/
|
|
128
|
+
serverError(loader) {
|
|
129
|
+
return this.errorPage(500, loader);
|
|
130
|
+
}
|
|
131
|
+
getErrorPageLoaders() {
|
|
132
|
+
return this.errorPageLoaders;
|
|
116
133
|
}
|
|
117
134
|
/**
|
|
118
135
|
* Register a WebSocket handler for the given path pattern.
|
|
@@ -166,18 +183,16 @@ export class AbstractApplicationAdapter {
|
|
|
166
183
|
this.websocketHandlers.set(path, handler);
|
|
167
184
|
return this;
|
|
168
185
|
}
|
|
169
|
-
/**
|
|
170
|
-
* Get the registered WebSocket handlers map.
|
|
171
|
-
*
|
|
172
|
-
* @returns The map of WebSocket route patterns to handlers
|
|
173
|
-
*/
|
|
174
|
-
getWebsocketHandlers() {
|
|
175
|
-
return this.websocketHandlers;
|
|
176
|
-
}
|
|
177
186
|
/**
|
|
178
187
|
* Register a global error handler for all routes.
|
|
179
188
|
* Useful for logging, monitoring integration, and custom error formatting.
|
|
180
189
|
*
|
|
190
|
+
* @remarks
|
|
191
|
+
* It receives errors thrown by API handlers and their middleware, and errors
|
|
192
|
+
* that escape the request pipeline. Page render failures render the error
|
|
193
|
+
* page instead and do not reach it. Client disconnects answer 499 without
|
|
194
|
+
* calling it.
|
|
195
|
+
*
|
|
181
196
|
* @example
|
|
182
197
|
* ```typescript
|
|
183
198
|
* app.onError(async (error, ctx) => {
|
|
@@ -190,12 +205,6 @@ export class AbstractApplicationAdapter {
|
|
|
190
205
|
this.errorHandler = handler;
|
|
191
206
|
return this;
|
|
192
207
|
}
|
|
193
|
-
/**
|
|
194
|
-
* Get the registered error handler
|
|
195
|
-
*/
|
|
196
|
-
getErrorHandler() {
|
|
197
|
-
return this.errorHandler;
|
|
198
|
-
}
|
|
199
208
|
/**
|
|
200
209
|
* Boot the server. When `onAppStart` is passed, it runs once the runtime can take traffic.
|
|
201
210
|
* Embedded apps only register the callback — the host (for example Vite) boots the port.
|
|
@@ -221,6 +230,11 @@ export class AbstractApplicationAdapter {
|
|
|
221
230
|
async notifyListening(origin) {
|
|
222
231
|
const normalizedOrigin = origin.replace(/\/$/, '');
|
|
223
232
|
startupTrace.markServerListening();
|
|
233
|
+
const restartReason = process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
|
|
234
|
+
if (restartReason) {
|
|
235
|
+
appLogger.info(`Development server restarted (${restartReason}).`);
|
|
236
|
+
delete process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
|
|
237
|
+
}
|
|
224
238
|
if (!this.onAppStartCallback) {
|
|
225
239
|
this.logServerStarted(normalizedOrigin);
|
|
226
240
|
return;
|
|
@@ -4,59 +4,77 @@ export function normalizeSegmentPath(pathname) {
|
|
|
4
4
|
}
|
|
5
5
|
return pathname;
|
|
6
6
|
}
|
|
7
|
+
function tryMatchCatchAllSegment(patternSegment, state) {
|
|
8
|
+
if (!patternSegment.startsWith('[...') || !patternSegment.endsWith(']')) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const paramName = patternSegment.slice(4, -1);
|
|
12
|
+
state.params[paramName] = state.pathSegments.slice(state.pathIndex);
|
|
13
|
+
return state.params;
|
|
14
|
+
}
|
|
15
|
+
function tryMatchDynamicSegment(patternSegment, pathSegment, state) {
|
|
16
|
+
if (patternSegment.startsWith(':')) {
|
|
17
|
+
state.params[patternSegment.slice(1)] = pathSegment;
|
|
18
|
+
state.patternIndex++;
|
|
19
|
+
state.pathIndex++;
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (patternSegment.startsWith('[') && patternSegment.endsWith(']')) {
|
|
23
|
+
state.params[patternSegment.slice(1, -1)] = pathSegment;
|
|
24
|
+
state.patternIndex++;
|
|
25
|
+
state.pathIndex++;
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
function matchTrailingCatchAll(state) {
|
|
31
|
+
const remaining = state.patternSegments.slice(state.patternIndex);
|
|
32
|
+
const catchAll = remaining[0];
|
|
33
|
+
if (remaining.length !== 1 || (catchAll !== '*' && !(catchAll.startsWith('[...') && catchAll.endsWith(']')))) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
if (catchAll.startsWith('[...')) {
|
|
37
|
+
const paramName = catchAll.slice(4, -1);
|
|
38
|
+
state.params[paramName] = [];
|
|
39
|
+
}
|
|
40
|
+
return state.params;
|
|
41
|
+
}
|
|
7
42
|
export function matchApiPathPattern(pattern, pathname) {
|
|
8
43
|
const normalizedPattern = normalizeSegmentPath(pattern);
|
|
9
44
|
const normalizedPathname = normalizeSegmentPath(pathname);
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
45
|
+
const state = {
|
|
46
|
+
patternSegments: normalizedPattern.split('/').filter(Boolean),
|
|
47
|
+
pathSegments: normalizedPathname.split('/').filter(Boolean),
|
|
48
|
+
params: {},
|
|
49
|
+
patternIndex: 0,
|
|
50
|
+
pathIndex: 0,
|
|
51
|
+
};
|
|
52
|
+
while (state.patternIndex < state.patternSegments.length && state.pathIndex < state.pathSegments.length) {
|
|
53
|
+
const patternSegment = state.patternSegments[state.patternIndex];
|
|
54
|
+
const pathSegment = state.pathSegments[state.pathIndex];
|
|
18
55
|
if (patternSegment === '*') {
|
|
19
|
-
return params;
|
|
20
|
-
}
|
|
21
|
-
if (patternSegment.startsWith('[...') && patternSegment.endsWith(']')) {
|
|
22
|
-
const paramName = patternSegment.slice(4, -1);
|
|
23
|
-
params[paramName] = pathSegments.slice(pathIndex);
|
|
24
|
-
return params;
|
|
56
|
+
return state.params;
|
|
25
57
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
pathIndex++;
|
|
30
|
-
continue;
|
|
58
|
+
const catchAllMatch = tryMatchCatchAllSegment(patternSegment, state);
|
|
59
|
+
if (catchAllMatch) {
|
|
60
|
+
return catchAllMatch;
|
|
31
61
|
}
|
|
32
|
-
if (patternSegment
|
|
33
|
-
params[patternSegment.slice(1, -1)] = pathSegment;
|
|
34
|
-
patternIndex++;
|
|
35
|
-
pathIndex++;
|
|
62
|
+
if (tryMatchDynamicSegment(patternSegment, pathSegment, state)) {
|
|
36
63
|
continue;
|
|
37
64
|
}
|
|
38
65
|
if (patternSegment !== pathSegment) {
|
|
39
66
|
return null;
|
|
40
67
|
}
|
|
41
|
-
patternIndex++;
|
|
42
|
-
pathIndex++;
|
|
68
|
+
state.patternIndex++;
|
|
69
|
+
state.pathIndex++;
|
|
43
70
|
}
|
|
44
|
-
if (patternIndex < patternSegments.length) {
|
|
45
|
-
|
|
46
|
-
const catchAll = remaining[0];
|
|
47
|
-
if (remaining.length === 1 && (catchAll === '*' || (catchAll.startsWith('[...') && catchAll.endsWith(']')))) {
|
|
48
|
-
if (catchAll.startsWith('[...')) {
|
|
49
|
-
const paramName = catchAll.slice(4, -1);
|
|
50
|
-
params[paramName] = [];
|
|
51
|
-
}
|
|
52
|
-
return params;
|
|
53
|
-
}
|
|
54
|
-
return null;
|
|
71
|
+
if (state.patternIndex < state.patternSegments.length) {
|
|
72
|
+
return matchTrailingCatchAll(state);
|
|
55
73
|
}
|
|
56
|
-
if (pathIndex < pathSegments.length) {
|
|
74
|
+
if (state.pathIndex < state.pathSegments.length) {
|
|
57
75
|
return null;
|
|
58
76
|
}
|
|
59
|
-
return params;
|
|
77
|
+
return state.params;
|
|
60
78
|
}
|
|
61
79
|
export function scoreApiPathPattern(pattern) {
|
|
62
80
|
const segments = normalizeSegmentPath(pattern).split('/').filter(Boolean);
|
|
@@ -36,6 +36,13 @@ export interface ServerAdapterResult {
|
|
|
36
36
|
}) => Promise<string | undefined>;
|
|
37
37
|
servePreviewOnly: () => Promise<string | undefined>;
|
|
38
38
|
dispose(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Updates listen metadata after the runtime binds its actual port.
|
|
41
|
+
*/
|
|
42
|
+
applyBoundPort: (input: {
|
|
43
|
+
port: number;
|
|
44
|
+
runtimeOrigin: string;
|
|
45
|
+
}) => void;
|
|
39
46
|
/**
|
|
40
47
|
* Lists static-generation routes for app-start consumers.
|
|
41
48
|
*
|
|
@@ -55,6 +62,13 @@ export declare abstract class AbstractServerAdapter<TOptions extends ServerAdapt
|
|
|
55
62
|
protected serveOptions: TOptions['serveOptions'];
|
|
56
63
|
protected runtimeOrigin: string;
|
|
57
64
|
constructor(options: TOptions);
|
|
65
|
+
/**
|
|
66
|
+
* Updates listen metadata after the runtime binds its actual port.
|
|
67
|
+
*/
|
|
68
|
+
applyBoundPort(input: {
|
|
69
|
+
port: number;
|
|
70
|
+
runtimeOrigin: string;
|
|
71
|
+
}): void;
|
|
58
72
|
/**
|
|
59
73
|
* Initialize the server adapter
|
|
60
74
|
*/
|
|
@@ -20,4 +20,14 @@ export class AbstractServerAdapter {
|
|
|
20
20
|
this.serveOptions = options.serveOptions || {};
|
|
21
21
|
this.runtimeOrigin = options.runtimeOrigin;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Updates listen metadata after the runtime binds its actual port.
|
|
25
|
+
*/
|
|
26
|
+
applyBoundPort(input) {
|
|
27
|
+
this.runtimeOrigin = input.runtimeOrigin;
|
|
28
|
+
this.serveOptions = {
|
|
29
|
+
...this.serveOptions,
|
|
30
|
+
port: input.port,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
23
33
|
}
|
|
@@ -4,9 +4,4 @@ export type WebSocketRouteMatch = {
|
|
|
4
4
|
params: Record<string, string>;
|
|
5
5
|
kind: string;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* Pattern matcher for WebSocket route paths.
|
|
9
|
-
*/
|
|
10
|
-
export declare function matchWebSocketPath(pattern: string, pathname: string): Record<string, string> | null;
|
|
11
|
-
export declare function scoreWebSocketPattern(pattern: string): number;
|
|
12
7
|
export declare function findWebSocketRoute(handlers: Map<string, EcopagesWebSocketHandler<any, any>>, pathname: string): WebSocketRouteMatch | null;
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
import { matchColonSegmentPath, scoreColonSegmentPath } from './segment-path-matcher.js';
|
|
2
|
-
/**
|
|
3
|
-
* Pattern matcher for WebSocket route paths.
|
|
4
|
-
*/
|
|
5
|
-
export function matchWebSocketPath(pattern, pathname) {
|
|
6
|
-
return matchColonSegmentPath(pattern, pathname);
|
|
7
|
-
}
|
|
8
|
-
export function scoreWebSocketPattern(pattern) {
|
|
9
|
-
return scoreColonSegmentPath(pattern);
|
|
10
|
-
}
|
|
11
2
|
export function findWebSocketRoute(handlers, pathname) {
|
|
12
3
|
let best = null;
|
|
13
4
|
let index = 0;
|
|
@@ -10,8 +10,9 @@
|
|
|
10
10
|
import type { Server } from 'bun';
|
|
11
11
|
import type { ApiHandlerContext, EcopagesRouteInfo, RouteGroupBuilder } from '../../types/public-types.js';
|
|
12
12
|
import { SharedApplicationAdapter } from '../shared/runtime/application-adapter.js';
|
|
13
|
+
import type { WebSocketUpgradeOptions } from '../shared/ws/node-http-websocket-upgrades.js';
|
|
13
14
|
import type { RuntimeHost } from '../shared/runtime/runtime-host.js';
|
|
14
|
-
import type {
|
|
15
|
+
import type { ResolvedEcopagesAppOptions } from '../create-app.js';
|
|
15
16
|
import { type BunServerAdapterResult } from './server-adapter.js';
|
|
16
17
|
/**
|
|
17
18
|
* Bun-specific route group builder that properly infers route params from path patterns.
|
|
@@ -27,31 +28,30 @@ export type BunRouteGroupBuilder<WebSocketData = undefined, TContext extends Api
|
|
|
27
28
|
* This class extends the {@link AbstractApplicationAdapter}
|
|
28
29
|
* and provides methods for handling HTTP requests and managing the server.
|
|
29
30
|
*/
|
|
30
|
-
export declare class BunEcopagesApp<WebSocketData = undefined> extends SharedApplicationAdapter<
|
|
31
|
+
export declare class BunEcopagesApp<WebSocketData = undefined> extends SharedApplicationAdapter<ResolvedEcopagesAppOptions, Server<WebSocketData>, Request> {
|
|
31
32
|
serverAdapter: BunServerAdapterResult | undefined;
|
|
32
33
|
private server;
|
|
33
34
|
private stopped;
|
|
34
35
|
private readonly runtimeHost;
|
|
35
|
-
constructor(options:
|
|
36
|
+
constructor(options: ResolvedEcopagesAppOptions, dependencies: {
|
|
36
37
|
runtimeHost: RuntimeHost<Server<WebSocketData>, Bun.Serve.Options<WebSocketData>>;
|
|
37
38
|
});
|
|
38
39
|
fetch(request: Request): Promise<Response>;
|
|
39
|
-
attachWebSocketUpgrades(httpServer: import('node:http').Server, options?:
|
|
40
|
-
passthroughUnmatched?: boolean;
|
|
41
|
-
}): Promise<void>;
|
|
42
|
-
/**
|
|
43
|
-
* Complete the initialization of the server adapter by processing dynamic routes
|
|
44
|
-
* @param server The Bun server instance
|
|
45
|
-
*/
|
|
46
|
-
completeInitialization(server: Server<WebSocketData>): Promise<void>;
|
|
40
|
+
attachWebSocketUpgrades(httpServer: import('node:http').Server, options?: WebSocketUpgradeOptions): Promise<void>;
|
|
47
41
|
/**
|
|
48
42
|
* Initialize the Bun server adapter
|
|
49
43
|
*/
|
|
50
44
|
protected initializeServerAdapter(): Promise<BunServerAdapterResult>;
|
|
45
|
+
private ensureServerAdapterReady;
|
|
46
|
+
private bootPreviewServeOnly;
|
|
47
|
+
private bootStaticWithoutRuntimeServer;
|
|
51
48
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
49
|
+
* Starts the Bun application server, or runs the preview/build flow when the
|
|
50
|
+
* CLI requested one.
|
|
51
|
+
*
|
|
52
|
+
* @remarks
|
|
53
|
+
* HMR endpoints and Bun's `development` serve mode follow the `dev` flag only,
|
|
54
|
+
* matching the options `completeInitialization()` reloads the server with.
|
|
55
55
|
*/
|
|
56
56
|
protected bootServer(): Promise<Server<WebSocketData> | void>;
|
|
57
57
|
stop(force?: boolean): Promise<void>;
|
|
@@ -60,4 +60,4 @@ export declare class BunEcopagesApp<WebSocketData = undefined> extends SharedApp
|
|
|
60
60
|
/**
|
|
61
61
|
* Factory function to create a Bun application
|
|
62
62
|
*/
|
|
63
|
-
export declare function createApp<WebSocketData = undefined>(options:
|
|
63
|
+
export declare function createApp<WebSocketData = undefined>(options: ResolvedEcopagesAppOptions): Promise<BunEcopagesApp<WebSocketData>>;
|