@ecopages/core 0.2.0-beta.29 → 0.2.0-beta.30
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 +36 -7
- package/package.json +2 -2
- package/src/adapters/README.md +6 -2
- package/src/adapters/abstract/segment-path-matcher.d.ts +6 -0
- package/src/adapters/abstract/segment-path-matcher.js +149 -0
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +2 -50
- package/src/adapters/abstract/ws-pattern-matcher.js +5 -36
- package/src/adapters/{shared → bun}/bun-user-websocket-lifecycle.js +1 -1
- package/src/adapters/bun/create-app.d.ts +2 -2
- package/src/adapters/bun/create-app.js +2 -2
- package/src/adapters/bun/hmr-manager.d.ts +1 -1
- package/src/adapters/bun/hmr-manager.js +1 -1
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +25 -2
- package/src/adapters/bun/runtime-host.d.ts +1 -1
- package/src/adapters/bun/runtime-host.js +1 -1
- package/src/adapters/bun/server-adapter.d.ts +8 -25
- package/src/adapters/bun/server-adapter.js +21 -65
- package/src/adapters/bun/static-preview-host.d.ts +1 -1
- package/src/adapters/bun/static-preview-host.js +1 -1
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +25 -2
- package/src/adapters/node/create-app.d.ts +2 -2
- package/src/adapters/node/create-app.js +2 -2
- package/src/adapters/node/node-hmr-manager.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.js +1 -1
- package/src/adapters/node/runtime-host.d.ts +1 -1
- package/src/adapters/node/runtime-host.js +1 -1
- package/src/adapters/node/server-adapter.d.ts +2 -3
- package/src/adapters/node/server-adapter.js +15 -18
- package/src/adapters/node/static-preview-host.d.ts +1 -1
- package/src/adapters/node/static-preview-host.js +1 -1
- package/src/adapters/shared/{hmr-entrypoint-registrar.d.ts → hmr/hmr-entrypoint-registrar.d.ts} +1 -1
- package/src/adapters/shared/{hmr-entrypoint-registrar.js → hmr/hmr-entrypoint-registrar.js} +1 -1
- package/src/adapters/shared/{hmr-html-response.d.ts → hmr/hmr-html-response.d.ts} +1 -1
- package/src/adapters/shared/{shared-hmr-manager.d.ts → hmr/shared-hmr-manager.d.ts} +9 -8
- package/src/adapters/shared/{shared-hmr-manager.js → hmr/shared-hmr-manager.js} +41 -15
- package/src/adapters/shared/http/api-request-pipeline.d.ts +23 -0
- package/src/adapters/shared/http/api-request-pipeline.js +129 -0
- package/src/adapters/shared/{api-response.d.ts → http/api-response.d.ts} +1 -1
- package/src/adapters/shared/{api-response.js → http/api-response.js} +6 -23
- package/src/adapters/shared/http/create-body-response.d.ts +12 -0
- package/src/adapters/shared/http/create-body-response.js +23 -0
- package/src/adapters/shared/http/define-api-handler.d.ts +90 -0
- package/src/adapters/shared/http/define-api-handler.js +63 -0
- package/src/adapters/shared/{explicit-static-render-preparation.d.ts → http/explicit-static-render-preparation.d.ts} +3 -3
- package/src/adapters/shared/{explicit-static-route-matcher.d.ts → http/explicit-static-route-matcher.d.ts} +3 -9
- package/src/adapters/shared/{explicit-static-route-matcher.js → http/explicit-static-route-matcher.js} +3 -38
- package/src/adapters/shared/{file-route-middleware-pipeline.d.ts → http/file-route-middleware-pipeline.d.ts} +2 -2
- package/src/adapters/shared/{file-route-middleware-pipeline.js → http/file-route-middleware-pipeline.js} +10 -22
- package/src/adapters/shared/{fs-server-response-factory.d.ts → http/fs-server-response-factory.d.ts} +2 -2
- package/src/adapters/shared/{fs-server-response-factory.js → http/fs-server-response-factory.js} +2 -2
- package/src/adapters/shared/{fs-server-response-matcher.d.ts → http/fs-server-response-matcher.d.ts} +5 -5
- package/src/adapters/shared/{fs-server-response-matcher.js → http/fs-server-response-matcher.js} +5 -5
- package/src/adapters/shared/http/run-middleware-chain.d.ts +5 -0
- package/src/adapters/shared/http/run-middleware-chain.js +17 -0
- package/src/adapters/shared/{application-adapter.d.ts → runtime/application-adapter.d.ts} +2 -2
- package/src/adapters/shared/{application-adapter.js → runtime/application-adapter.js} +1 -1
- package/src/adapters/shared/{render-context.d.ts → runtime/render-context.d.ts} +2 -2
- package/src/adapters/shared/{render-context.js → runtime/render-context.js} +8 -17
- package/src/adapters/shared/{runtime-app-bootstrap.d.ts → runtime/runtime-app-bootstrap.d.ts} +2 -2
- package/src/adapters/shared/{runtime-app-bootstrap.js → runtime/runtime-app-bootstrap.js} +1 -1
- package/src/adapters/shared/{runtime-server-lifecycle.d.ts → runtime/runtime-server-lifecycle.d.ts} +13 -13
- package/src/adapters/shared/{runtime-server-lifecycle.js → runtime/runtime-server-lifecycle.js} +22 -15
- package/src/adapters/shared/{server-adapter.d.ts → runtime/server-adapter.d.ts} +20 -48
- package/src/adapters/shared/runtime/server-adapter.js +226 -0
- package/src/adapters/shared/{server-route-handler.d.ts → runtime/server-route-handler.d.ts} +6 -36
- package/src/adapters/shared/{server-route-handler.js → runtime/server-route-handler.js} +6 -47
- package/src/adapters/shared/{server-static-builder.d.ts → runtime/server-static-builder.d.ts} +6 -6
- package/src/adapters/shared/{server-static-builder.js → runtime/server-static-builder.js} +8 -8
- package/src/adapters/shared/{static-preview-host.d.ts → runtime/static-preview-host.d.ts} +1 -1
- package/src/adapters/shared/{node-http-websocket-upgrades.d.ts → ws/node-http-websocket-upgrades.d.ts} +1 -1
- package/src/adapters/shared/{node-http-websocket-upgrades.js → ws/node-http-websocket-upgrades.js} +2 -2
- package/src/adapters/shared/{websocket-lifecycle.d.ts → ws/websocket-lifecycle.d.ts} +1 -1
- package/src/adapters/shared/{websocket-lifecycle.js → ws/websocket-lifecycle.js} +1 -1
- package/src/build/app-build-manifest-runtime.d.ts +4 -0
- package/src/build/app-build-manifest-runtime.js +19 -9
- package/src/index.d.ts +1 -1
- package/src/index.js +24 -1
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/types/internal-types.d.ts +8 -2
- package/src/types/public-types.d.ts +9 -1
- package/src/adapters/shared/define-api-handler.d.ts +0 -25
- package/src/adapters/shared/define-api-handler.js +0 -15
- package/src/adapters/shared/server-adapter.js +0 -452
- /package/src/adapters/{shared → bun}/bun-user-websocket-lifecycle.d.ts +0 -0
- /package/src/adapters/shared/{hmr-html-response.js → hmr/hmr-html-response.js} +0 -0
- /package/src/adapters/shared/{explicit-static-render-preparation.js → http/explicit-static-render-preparation.js} +0 -0
- /package/src/adapters/shared/{copy-runtime-public-dir.d.ts → runtime/copy-runtime-public-dir.d.ts} +0 -0
- /package/src/adapters/shared/{copy-runtime-public-dir.js → runtime/copy-runtime-public-dir.js} +0 -0
- /package/src/adapters/shared/{port-manager.d.ts → runtime/port-manager.d.ts} +0 -0
- /package/src/adapters/shared/{port-manager.js → runtime/port-manager.js} +0 -0
- /package/src/adapters/shared/{runtime-host.d.ts → runtime/runtime-host.d.ts} +0 -0
- /package/src/adapters/shared/{runtime-host.js → runtime/runtime-host.js} +0 -0
- /package/src/adapters/shared/{static-preview-host.js → runtime/static-preview-host.js} +0 -0
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { appLogger } from "
|
|
2
|
-
import { HttpError } from "
|
|
3
|
-
import { injectHmrRuntimeIntoHtmlResponse, isHtmlResponse, shouldInjectHmrHtmlResponse } from "./hmr-html-response.js";
|
|
1
|
+
import { appLogger } from "../../../global/app-logger.js";
|
|
2
|
+
import { HttpError } from "../../../errors/http-error.js";
|
|
4
3
|
class ServerRouteHandler {
|
|
5
4
|
router;
|
|
6
5
|
fileSystemResponseMatcher;
|
|
7
6
|
explicitStaticRouteMatcher;
|
|
8
|
-
watch;
|
|
9
7
|
hmrManager;
|
|
10
|
-
hostOwnsDevClient;
|
|
11
8
|
/**
|
|
12
9
|
* Creates a new ServerRouteHandler instance.
|
|
13
10
|
*
|
|
@@ -17,33 +14,12 @@ class ServerRouteHandler {
|
|
|
17
14
|
router,
|
|
18
15
|
fileSystemResponseMatcher,
|
|
19
16
|
explicitStaticRouteMatcher,
|
|
20
|
-
|
|
21
|
-
hmrManager,
|
|
22
|
-
hostOwnsDevClient = false
|
|
17
|
+
hmrManager
|
|
23
18
|
}) {
|
|
24
19
|
this.router = router;
|
|
25
20
|
this.fileSystemResponseMatcher = fileSystemResponseMatcher;
|
|
26
21
|
this.explicitStaticRouteMatcher = explicitStaticRouteMatcher;
|
|
27
|
-
this.watch = watch;
|
|
28
22
|
this.hmrManager = hmrManager;
|
|
29
|
-
this.hostOwnsDevClient = hostOwnsDevClient;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Determines if HMR script should be injected.
|
|
33
|
-
*
|
|
34
|
-
* @returns true if in watch mode and HMR manager is enabled
|
|
35
|
-
*/
|
|
36
|
-
shouldInjectHmrScript() {
|
|
37
|
-
return shouldInjectHmrHtmlResponse(this.watch, this.hmrManager, this.hostOwnsDevClient);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Checks if a response contains HTML content.
|
|
41
|
-
*
|
|
42
|
-
* @param response - The HTTP response to check
|
|
43
|
-
* @returns true if Content-Type header starts with 'text/html'
|
|
44
|
-
*/
|
|
45
|
-
isHtmlResponse(response) {
|
|
46
|
-
return isHtmlResponse(response);
|
|
47
23
|
}
|
|
48
24
|
/**
|
|
49
25
|
* Handles HTTP requests from the router adapter.
|
|
@@ -54,33 +30,16 @@ class ServerRouteHandler {
|
|
|
54
30
|
* 3. Fall back to static file serving from disk
|
|
55
31
|
*
|
|
56
32
|
* @param request - The incoming HTTP request
|
|
57
|
-
* @returns HTTP response
|
|
33
|
+
* @returns HTTP response for the matched route
|
|
58
34
|
*/
|
|
59
35
|
async handleResponse(request) {
|
|
60
36
|
const pathname = new URL(request.url).pathname;
|
|
61
37
|
const explicitMatch = this.explicitStaticRouteMatcher?.match(request.url);
|
|
62
38
|
if (explicitMatch) {
|
|
63
|
-
|
|
64
|
-
return this.maybeInjectHmrScript(response2);
|
|
39
|
+
return await this.explicitStaticRouteMatcher.handleMatch(explicitMatch);
|
|
65
40
|
}
|
|
66
41
|
const fsMatch = !pathname.includes(".") && this.router.matchRequest(request.url);
|
|
67
|
-
|
|
68
|
-
return this.maybeInjectHmrScript(response);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Injects HMR script into HTML responses in development mode.
|
|
72
|
-
*
|
|
73
|
-
* The script is inserted before the closing </html> tag to enable
|
|
74
|
-
* hot module reloading without full page refreshes.
|
|
75
|
-
*
|
|
76
|
-
* @param response - The HTTP response to potentially modify
|
|
77
|
-
* @returns Original response or modified response with HMR script
|
|
78
|
-
*/
|
|
79
|
-
async maybeInjectHmrScript(response) {
|
|
80
|
-
if (this.shouldInjectHmrScript() && this.isHtmlResponse(response)) {
|
|
81
|
-
return injectHmrRuntimeIntoHtmlResponse(response);
|
|
82
|
-
}
|
|
83
|
-
return response;
|
|
42
|
+
return await (fsMatch ? this.fileSystemResponseMatcher.handleMatch(fsMatch, request) : this.handleNoMatch(request));
|
|
84
43
|
}
|
|
85
44
|
/**
|
|
86
45
|
* Handles requests that do not match any routes.
|
package/src/adapters/shared/{server-static-builder.d.ts → runtime/server-static-builder.d.ts}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig, IHmrManager } from '
|
|
2
|
-
import type { EcoBuildPlugin } from '
|
|
3
|
-
import type { StaticRoute } from '
|
|
4
|
-
import type { RouteRegistry } from '
|
|
5
|
-
import type { StaticSiteGenerator } from '
|
|
6
|
-
import type { StaticGenerationRendererResolver } from '
|
|
1
|
+
import type { EcoPagesAppConfig, IHmrManager } from '../../../types/internal-types.js';
|
|
2
|
+
import type { EcoBuildPlugin } from '../../../build/contracts/build-types.js';
|
|
3
|
+
import type { StaticRoute } from '../../../types/public-types.js';
|
|
4
|
+
import type { RouteRegistry } from '../../../router/server/route-registry.js';
|
|
5
|
+
import type { StaticSiteGenerator } from '../../../static-site-generator/static-site-generator.js';
|
|
6
|
+
import type { StaticGenerationRendererResolver } from '../../../route-renderer/route-renderer.js';
|
|
7
7
|
export interface StaticBuildOptions {
|
|
8
8
|
baseUrl?: string;
|
|
9
9
|
force?: boolean;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { fileSystem } from "@ecopages/file-system";
|
|
3
|
-
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from "
|
|
4
|
-
import { appLogger } from "
|
|
5
|
-
import { build, getAppBuildAdapter, setupAppRuntimePlugins } from "
|
|
6
|
-
import { createServerBuildRequest } from "
|
|
7
|
-
import { requireBuildRuntime } from "
|
|
3
|
+
import { DEFAULT_ECOPAGES_HOSTNAME, DEFAULT_ECOPAGES_PORT } from "../../../config/constants.js";
|
|
4
|
+
import { appLogger } from "../../../global/app-logger.js";
|
|
5
|
+
import { build, getAppBuildAdapter, setupAppRuntimePlugins } from "../../../build/build-adapter.js";
|
|
6
|
+
import { createServerBuildRequest } from "../../../build/runtime/build-request-policy.js";
|
|
7
|
+
import { requireBuildRuntime } from "../../../build/runtime/build-runtime.js";
|
|
8
8
|
import { attachHmrToIntegrations } from "./runtime-server-lifecycle.js";
|
|
9
9
|
import {
|
|
10
10
|
getServerBundleOutputPaths,
|
|
11
11
|
lookupServerEntryBuildCache,
|
|
12
12
|
recordServerEntryBuildCache,
|
|
13
13
|
writeServerBundleDeployManifest
|
|
14
|
-
} from "
|
|
14
|
+
} from "../../../build/cache/server-entry-build-cache.js";
|
|
15
15
|
import {
|
|
16
16
|
clearProductionBuildCaches,
|
|
17
17
|
shouldResetStaticExportDirectory
|
|
18
|
-
} from "
|
|
19
|
-
import { resolveEntryFile, SERVER_BUNDLE_FILENAME } from "
|
|
18
|
+
} from "../../../static-site-generator/static-build-invalidation.js";
|
|
19
|
+
import { resolveEntryFile, SERVER_BUNDLE_FILENAME } from "../../../utils/resolve-entry-file.js";
|
|
20
20
|
class ServerStaticBuilder {
|
|
21
21
|
appConfig;
|
|
22
22
|
staticSiteGenerator;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../../types/internal-types.js';
|
|
2
2
|
export interface StaticPreviewHost {
|
|
3
3
|
start(options: StaticPreviewHostStartOptions): Promise<number | null>;
|
|
4
4
|
stop(force?: boolean): Promise<void>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Duplex } from 'node:stream';
|
|
2
2
|
import type { Server as NodeHttpServer, IncomingMessage } from 'node:http';
|
|
3
|
-
import type { EcopagesWebSocketHandler } from '
|
|
3
|
+
import type { EcopagesWebSocketHandler } from '../../../types/public-types.js';
|
|
4
4
|
export type NodeHttpWebSocketUpgradePreflight = (req: IncomingMessage, socket: Duplex, head: Buffer) => boolean;
|
|
5
5
|
export type AttachNodeHttpWebSocketUpgradesOptions = {
|
|
6
6
|
runtimeOrigin: string;
|
package/src/adapters/shared/{node-http-websocket-upgrades.js → ws/node-http-websocket-upgrades.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebSocketServer } from "ws";
|
|
2
|
-
import { appLogger } from "
|
|
3
|
-
import { findWebSocketRoute } from "
|
|
2
|
+
import { appLogger } from "../../../global/app-logger.js";
|
|
3
|
+
import { findWebSocketRoute } from "../../abstract/ws-pattern-matcher.js";
|
|
4
4
|
import { createEcopagesSocket, invokeWebSocketHandlerHook, toWebSocketCloseInfo } from "./websocket-lifecycle.js";
|
|
5
5
|
const attachedUpgradeServers = /* @__PURE__ */ new WeakSet();
|
|
6
6
|
function adaptNodeWebSocket(ws, kind, params, search, context) {
|
|
@@ -26,6 +26,10 @@ export declare function setupAppRuntimePlugins(options: {
|
|
|
26
26
|
}): Promise<void>;
|
|
27
27
|
/**
|
|
28
28
|
* Activates one integration's runtime setup on first use.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Concurrent callers share a single in-flight promise per integration name.
|
|
32
|
+
* Failed activations are evicted so a later caller can retry.
|
|
29
33
|
*/
|
|
30
34
|
export declare function ensureIntegrationRuntimeReady(options: {
|
|
31
35
|
appConfig: EcoPagesAppConfig;
|
|
@@ -90,22 +90,32 @@ async function setupAppRuntimePlugins(options) {
|
|
|
90
90
|
async function ensureIntegrationRuntimeReady(options) {
|
|
91
91
|
const runtime = options.appConfig.runtime ?? {};
|
|
92
92
|
options.appConfig.runtime = runtime;
|
|
93
|
-
runtime.
|
|
94
|
-
|
|
93
|
+
runtime.integrationActivations ??= /* @__PURE__ */ new Map();
|
|
94
|
+
const existing = runtime.integrationActivations.get(options.integrationName);
|
|
95
|
+
if (existing) {
|
|
96
|
+
await existing;
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
99
|
const integration = options.appConfig.integrations.find((plugin) => plugin.name === options.integrationName);
|
|
98
100
|
if (!integration) {
|
|
99
101
|
return;
|
|
100
102
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
const activation = (async () => {
|
|
104
|
+
integration.setConfig(options.appConfig);
|
|
105
|
+
integration.setRuntimeOrigin(options.runtimeOrigin);
|
|
106
|
+
await integration.setup();
|
|
107
|
+
const onRuntimePlugin = options.onRuntimePlugin ?? options.appConfig.runtime?.onRuntimePlugin;
|
|
108
|
+
for (const plugin of integration.plugins ?? []) {
|
|
109
|
+
onRuntimePlugin?.(plugin);
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
runtime.integrationActivations.set(options.integrationName, activation);
|
|
113
|
+
try {
|
|
114
|
+
await activation;
|
|
115
|
+
} catch (error) {
|
|
116
|
+
runtime.integrationActivations.delete(options.integrationName);
|
|
117
|
+
throw error;
|
|
107
118
|
}
|
|
108
|
-
runtime.activatedIntegrations.add(options.integrationName);
|
|
109
119
|
}
|
|
110
120
|
export {
|
|
111
121
|
collectConfiguredAppBuildManifestContributions,
|
package/src/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type * from './types/public-types.js';
|
|
2
2
|
export type * from './eco/eco.types.js';
|
|
3
3
|
export { eco } from './eco/eco.js';
|
|
4
|
-
export { defineApiHandler, defineGroupHandler, type GroupHandler } from './adapters/shared/define-api-handler.js';
|
|
4
|
+
export { defineApiHandler, defineGroupHandler, defineGet, definePost, definePut, defineDelete, definePatch, defineOptions, defineHead, json, html, redirect, type GroupHandler, } from './adapters/shared/http/define-api-handler.js';
|
|
5
5
|
export { createEcoBuildPluginFromSourceTransform, createVitePluginsFromAppSourceTransforms, getAppSourceTransforms, createVitePluginFromSourceTransform, normalizeTransformId, type EcoSourceTransform, type EcoSourceTransformResult, type EcoViteCompatiblePlugin, } from './plugins/source-transform.js';
|
|
6
6
|
export { createEcoComponentMetaTransform } from './plugins/eco-component-meta-plugin.js';
|
|
7
7
|
export { SchemaError, validateStandardSchema } from './services/validation/validate-standard-schema.js';
|
package/src/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { eco } from "./eco/eco.js";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
defineApiHandler,
|
|
4
|
+
defineGroupHandler,
|
|
5
|
+
defineGet,
|
|
6
|
+
definePost,
|
|
7
|
+
definePut,
|
|
8
|
+
defineDelete,
|
|
9
|
+
definePatch,
|
|
10
|
+
defineOptions,
|
|
11
|
+
defineHead,
|
|
12
|
+
json,
|
|
13
|
+
html,
|
|
14
|
+
redirect
|
|
15
|
+
} from "./adapters/shared/http/define-api-handler.js";
|
|
3
16
|
import {
|
|
4
17
|
createEcoBuildPluginFromSourceTransform,
|
|
5
18
|
createVitePluginsFromAppSourceTransforms,
|
|
@@ -16,9 +29,19 @@ export {
|
|
|
16
29
|
createVitePluginFromSourceTransform,
|
|
17
30
|
createVitePluginsFromAppSourceTransforms,
|
|
18
31
|
defineApiHandler,
|
|
32
|
+
defineDelete,
|
|
33
|
+
defineGet,
|
|
19
34
|
defineGroupHandler,
|
|
35
|
+
defineHead,
|
|
36
|
+
defineOptions,
|
|
37
|
+
definePatch,
|
|
38
|
+
definePost,
|
|
39
|
+
definePut,
|
|
20
40
|
eco,
|
|
21
41
|
getAppSourceTransforms,
|
|
42
|
+
html,
|
|
43
|
+
json,
|
|
22
44
|
normalizeTransformId,
|
|
45
|
+
redirect,
|
|
23
46
|
validateStandardSchema
|
|
24
47
|
};
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { availableParallelism } from "node:os";
|
|
3
3
|
import { appLogger } from "../global/app-logger.js";
|
|
4
4
|
import { fileSystem } from "@ecopages/file-system";
|
|
5
|
-
import { prepareExplicitStaticRender } from "../adapters/shared/explicit-static-render-preparation.js";
|
|
5
|
+
import { prepareExplicitStaticRender } from "../adapters/shared/http/explicit-static-render-preparation.js";
|
|
6
6
|
import { createRouteModuleStaticRenderCacheContext } from "./static-build-invalidation.js";
|
|
7
7
|
import {
|
|
8
8
|
getServerModuleBuildCacheOutdir,
|
|
@@ -175,8 +175,14 @@ export type EcoPagesAppConfig = {
|
|
|
175
175
|
runtimeAssetsPrepared?: boolean;
|
|
176
176
|
/** Registers integration runtime plugins when lazy activation completes. */
|
|
177
177
|
onRuntimePlugin?: (plugin: import('../build/contracts/build-types.js').EcoBuildPlugin) => void;
|
|
178
|
-
/**
|
|
179
|
-
|
|
178
|
+
/**
|
|
179
|
+
* In-flight or completed lazy integration activation promises, keyed by integration name.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* Concurrent callers (background prewarm + first render) share the same promise.
|
|
183
|
+
* Failed activations are removed so a later caller can retry.
|
|
184
|
+
*/
|
|
185
|
+
integrationActivations?: Map<string, Promise<void>>;
|
|
180
186
|
/** When `'host'`, the embedded dev server owns browser dev-client bootstrap. */
|
|
181
187
|
devClientOwner?: 'core' | 'host';
|
|
182
188
|
/** Integration hooks run when a registered `dependencies.scripts` entrypoint changes. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { ApiResponseBuilder } from '../adapters/shared/api-response.js';
|
|
2
|
+
import type { ApiResponseBuilder } from '../adapters/shared/http/api-response.js';
|
|
3
3
|
import type { BuildExecutor } from '../build/build-adapter.js';
|
|
4
4
|
import type { ForeignChildRuntime } from '../route-renderer/orchestration/foreign-child/component-render-context.js';
|
|
5
5
|
import type { EcoPageComponent } from '../eco/eco.types.js';
|
|
@@ -336,6 +336,14 @@ export interface IHmrManager {
|
|
|
336
336
|
* Gets the HMR dist directory.
|
|
337
337
|
*/
|
|
338
338
|
getDistDir(): string;
|
|
339
|
+
/**
|
|
340
|
+
* Returns the on-disk path to the bundled HMR runtime script.
|
|
341
|
+
*/
|
|
342
|
+
getRuntimePath(): string;
|
|
343
|
+
/**
|
|
344
|
+
* Serves a development HMR asset request when the URL matches a known HMR path.
|
|
345
|
+
*/
|
|
346
|
+
tryHandleAssetRequest(request: Request): Response | null;
|
|
339
347
|
/**
|
|
340
348
|
* Gets the default HMR context.
|
|
341
349
|
*/
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ApiHandler, ApiHandlerContext, Middleware, RouteSchema, TypedGroupHandlerContext } from '../../types/public-types.js';
|
|
2
|
-
type UniversalContext = ApiHandlerContext<Request, unknown>;
|
|
3
|
-
type SchemaHandlerContext<TSchema extends RouteSchema | undefined, TContext extends UniversalContext> = TSchema extends RouteSchema ? TypedGroupHandlerContext<TSchema, TContext> : TContext;
|
|
4
|
-
export declare function defineApiHandler<TPath extends string, TSchema extends RouteSchema | undefined = undefined, TContext extends UniversalContext = UniversalContext>(handler: Omit<ApiHandler<TPath, Request, unknown>, 'handler' | 'middleware' | 'schema'> & {
|
|
5
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
6
|
-
middleware?: Middleware<Request, unknown, TContext>[];
|
|
7
|
-
schema?: TSchema;
|
|
8
|
-
}): ApiHandler<TPath, Request, unknown>;
|
|
9
|
-
export interface GroupHandler<TPrefix extends string = string> {
|
|
10
|
-
prefix: TPrefix;
|
|
11
|
-
middleware?: readonly Middleware<Request, unknown, any>[];
|
|
12
|
-
routes: readonly ApiHandler<string, Request, unknown>[];
|
|
13
|
-
}
|
|
14
|
-
type GroupDefineHandler<TContext extends UniversalContext> = <const TPath extends string, TSchema extends RouteSchema | undefined = undefined>(handler: Omit<ApiHandler<TPath, Request, unknown>, 'handler' | 'middleware' | 'schema'> & {
|
|
15
|
-
path: TPath;
|
|
16
|
-
handler: (context: SchemaHandlerContext<TSchema, TContext>) => Promise<Response> | Response;
|
|
17
|
-
middleware?: Middleware<Request, unknown, TContext>[];
|
|
18
|
-
schema?: TSchema;
|
|
19
|
-
}) => ApiHandler<TPath, Request, unknown>;
|
|
20
|
-
export declare function defineGroupHandler<TPrefix extends string, TMiddleware extends readonly Middleware<Request, unknown, any>[] = [], TContext extends UniversalContext = TMiddleware extends readonly Middleware<Request, unknown, infer TGroupContext>[] ? TGroupContext : UniversalContext>(config: {
|
|
21
|
-
prefix: TPrefix;
|
|
22
|
-
middleware?: TMiddleware;
|
|
23
|
-
routes: (define: GroupDefineHandler<TContext>) => readonly ApiHandler<string, Request, unknown>[];
|
|
24
|
-
}): GroupHandler<TPrefix>;
|
|
25
|
-
export {};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
function defineApiHandler(handler) {
|
|
2
|
-
return handler;
|
|
3
|
-
}
|
|
4
|
-
function defineGroupHandler(config) {
|
|
5
|
-
const define = ((handler) => handler);
|
|
6
|
-
return {
|
|
7
|
-
prefix: config.prefix,
|
|
8
|
-
middleware: config.middleware,
|
|
9
|
-
routes: config.routes(define)
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
export {
|
|
13
|
-
defineApiHandler,
|
|
14
|
-
defineGroupHandler
|
|
15
|
-
};
|