@ecopages/core 0.2.0-rc.0 → 0.2.0-rc.10
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 +52 -33
- package/package.json +58 -4
- package/src/adapters/README.md +3 -1
- package/src/adapters/abstract/application-adapter.d.ts +28 -6
- package/src/adapters/abstract/application-adapter.js +58 -5
- 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/bun/create-app.d.ts +10 -6
- package/src/adapters/bun/create-app.js +64 -37
- package/src/adapters/bun/server-adapter.d.ts +6 -2
- package/src/adapters/bun/server-adapter.js +14 -1
- package/src/adapters/create-app.d.ts +62 -7
- package/src/adapters/create-app.js +61 -5
- package/src/adapters/node/create-app.d.ts +5 -5
- package/src/adapters/node/create-app.js +18 -5
- package/src/adapters/node/runtime-host.js +9 -4
- package/src/adapters/node/server-adapter.d.ts +5 -1
- package/src/adapters/node/server-adapter.js +16 -1
- package/src/adapters/shared/http/define-api-handler.d.ts +7 -49
- package/src/adapters/shared/http/explicit-static-route-matcher.js +5 -2
- package/src/adapters/shared/http/fs-server-response-factory.d.ts +2 -8
- package/src/adapters/shared/http/fs-server-response-factory.js +5 -30
- 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/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/server-adapter.d.ts +14 -5
- package/src/adapters/shared/runtime/server-adapter.js +22 -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/build/README.md +5 -1
- package/src/build/cache/server-entry-build-cache.d.ts +24 -1
- package/src/build/cache/server-entry-build-cache.js +125 -8
- 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 +56 -31
- package/src/build/rolldown/rolldown-plugin-bridge.js +25 -21
- package/src/build/rolldown/runtime-build-output-normalizer.js +3 -29
- package/src/build/runtime/build-request-policy.js +1 -1
- package/src/build/server-bundle-publication.d.ts +14 -0
- package/src/build/server-bundle-publication.js +49 -0
- package/src/config/README.md +17 -2
- package/src/config/apply-user-config.d.ts +6 -0
- package/src/config/apply-user-config.js +67 -0
- package/src/config/config-builder.d.ts +10 -1
- package/src/config/config-builder.js +51 -10
- package/src/config/constants.d.ts +4 -0
- package/src/config/constants.js +4 -0
- 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 +100 -0
- package/src/config/resolve-eco-config-path.d.ts +23 -0
- package/src/config/resolve-eco-config-path.js +47 -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 +164 -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/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/strategies/js-hmr-strategy.d.ts +2 -0
- package/src/hmr/strategies/js-hmr-strategy.js +24 -16
- package/src/index.browser.d.ts +3 -0
- package/src/index.browser.js +3 -0
- package/src/index.d.ts +4 -1
- package/src/index.js +4 -1
- package/src/islands/README.md +5 -1
- package/src/plugins/README.md +10 -2
- 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 +118 -16
- package/src/plugins/integration-plugin.d.ts +4 -9
- package/src/plugins/processor.d.ts +23 -2
- package/src/plugins/processor.js +25 -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 +16 -3
- 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 +2 -0
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts +13 -1
- package/src/route-renderer/orchestration/document-shell/layout-shell-props.service.js +15 -0
- 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 +11 -5
- package/src/route-renderer/orchestration/integration-renderer.js +42 -29
- 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.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 +10 -8
- 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 +5 -0
- 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/error-pages/README.md +9 -0
- package/src/services/error-pages/default-error-pages.d.ts +44 -0
- package/src/services/error-pages/default-error-pages.js +207 -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/invalidation/development-invalidation.service.d.ts +7 -1
- package/src/services/invalidation/development-invalidation.service.js +35 -3
- package/src/services/module-loading/README.md +16 -13
- package/src/services/module-loading/app-server-module-transpiler.service.js +2 -0
- package/src/services/module-loading/collection-server-module-build.service.d.ts +1 -0
- package/src/services/module-loading/collection-server-module-build.service.js +5 -2
- 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-dependency-hasher.js +13 -1
- 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/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 -1
- package/src/types/public-types.d.ts +34 -24
- package/src/utils/parse-cli-args.js +29 -22
- package/src/watchers/project-watcher.d.ts +14 -1
- package/src/watchers/project-watcher.js +85 -34
- /package/src/{adapters/shared/http/explicit-static-render-preparation.js → route-renderer/explicit-view-render-preparation.js} +0 -0
package/README.md
CHANGED
|
@@ -13,13 +13,16 @@ Ecopages is an extensible static site generator (SSG) built around a Bun-first c
|
|
|
13
13
|
|
|
14
14
|
## Current Architecture
|
|
15
15
|
|
|
16
|
+
Projects load shared ambient types through `@ecopages/core/declarations`. This entry references `src/css-imports.d.ts`, which keeps the wildcard CSS declaration in a standalone ambient file so side-effect CSS imports typecheck without per-project declarations.
|
|
17
|
+
|
|
16
18
|
The current core package is organized around app-owned runtime state and explicit service boundaries.
|
|
17
19
|
|
|
18
20
|
The important ownership rules are:
|
|
19
21
|
|
|
20
22
|
- `ConfigBuilder.build()` finalizes app-owned build and runtime services.
|
|
21
23
|
- Component identity attribution is one shared source transform for server, browser, and HMR compilation paths: after a lexical `eco.` gate, it uses Oxc to wrap supported factory options with `bindComponentIdentity()`, which factories retain as `config.identity`.
|
|
22
|
-
-
|
|
24
|
+
- Direct local Eco Component imports (including named `export { X } from` barrels) and relative side-effect CSS imports supply Dependencies by default through the shared transform and existing collector; explicit asset declarations override inference, and inferred styles stay keyed by identity until collection. See [eco](src/eco/README.md) and [Plugin Contracts](src/plugins/README.md).
|
|
25
|
+
- Browser bundling and server module loading are separate paths. SSR-enabled lazy scripts execute on the server before rendering and in the browser only on their configured trigger.
|
|
23
26
|
- runtime hosts stay thin and delegate framework work into core services.
|
|
24
27
|
- HMR and invalidation use shared graph-aware services instead of runtime-specific ad hoc wiring.
|
|
25
28
|
|
|
@@ -27,19 +30,19 @@ The important ownership rules are:
|
|
|
27
30
|
|
|
28
31
|
```mermaid
|
|
29
32
|
flowchart TD
|
|
30
|
-
A[eco.config.ts] --> B[
|
|
31
|
-
B --> C[
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
A[eco.config.ts] --> B[defineConfig / loadEcoPagesConfig]
|
|
34
|
+
B --> C[ConfigBuilder.build]
|
|
35
|
+
C --> D[App build adapter]
|
|
36
|
+
C --> E[App build manifest]
|
|
37
|
+
C --> F[Build executor]
|
|
38
|
+
C --> G[Dev graph service]
|
|
39
|
+
C --> H[Host module loader boundary]
|
|
40
|
+
H --> I[PageModuleImportService]
|
|
41
|
+
F --> I
|
|
42
|
+
F --> J[BrowserBundleService]
|
|
43
|
+
I --> K[Runtime app adapter]
|
|
44
|
+
K --> L[Bun adapter or Node adapter]
|
|
45
|
+
E --> J
|
|
43
46
|
```
|
|
44
47
|
|
|
45
48
|
### Development Invalidation And HMR Flow
|
|
@@ -50,7 +53,11 @@ flowchart TD
|
|
|
50
53
|
B --> C[DevelopmentInvalidationService]
|
|
51
54
|
C --> D{Change kind}
|
|
52
55
|
D -->|Route or server source| E[Invalidate server modules]
|
|
53
|
-
D -->|
|
|
56
|
+
D -->|Additional watch| E
|
|
57
|
+
D -->|Config or dotenv| R[Restart dev process]
|
|
58
|
+
E --> N[Notify processors]
|
|
59
|
+
N --> F[Reload browser]
|
|
60
|
+
D -->|Public asset| F
|
|
54
61
|
D -->|Processor-owned asset| G[Notify processor only]
|
|
55
62
|
D -->|HMR-eligible source| H[Core HMR manager]
|
|
56
63
|
H --> I[Strategy selection]
|
|
@@ -71,6 +78,8 @@ The manager/orchestration layer is core-owned, but framework-specific strategies
|
|
|
71
78
|
- `ConfigBuilder` seeds one app-owned build ownership path, adapter, manifest, executor, dev graph, and runtime registry.
|
|
72
79
|
- `BrowserBundleService` is the shared browser build seam used by HMR and asset-oriented browser output paths.
|
|
73
80
|
- `ServerModuleTranspiler` is the shared server-side source loading seam used by runtime bootstrap and HMR metadata loading.
|
|
81
|
+
- `RouteRegistry` gives exact and dynamic Pages priority over catch-alls, then selects the most specific matching catch-all prefix.
|
|
82
|
+
- Browser runtime package entries resolve from the application root with ESM import conditions, so framework-local packages cannot shadow app dependencies.
|
|
74
83
|
- `createApp()` stays the universal runtime entrypoint, while Vite and Nitro hosts own their advanced dev and build workflows.
|
|
75
84
|
- One bundled adapter is the default bundler. Vite-based apps route through the `ViteHostBuildAdapter` boundary marker instead.
|
|
76
85
|
|
|
@@ -80,10 +89,10 @@ Use this package README as the top-level map, then drill into the focused subsys
|
|
|
80
89
|
|
|
81
90
|
- `src/config/README.md`: config finalization and app-owned runtime/build state
|
|
82
91
|
- `src/plugins/README.md`: integration and processor authoring contracts
|
|
83
|
-
- `src/build/README.md`: build adapter, executor,
|
|
92
|
+
- `src/build/README.md`: build adapter, executor, development build coordination, and standalone Node server packaging
|
|
84
93
|
- `src/services/README.md`: cross-cutting runtime services and orchestration helpers
|
|
85
94
|
- `src/adapters/README.md`: Bun, Node, and shared adapter boundaries
|
|
86
|
-
- `src/dev/README.md`: dev transform server
|
|
95
|
+
- `src/dev/README.md`: dev transform server, on-demand client delivery, and invalidation during compilation
|
|
87
96
|
- `src/hmr/README.md`: HMR strategy and update-layer ownership
|
|
88
97
|
- `src/router/README.md`: route discovery, matching, and browser navigation coordination
|
|
89
98
|
- `src/route-renderer/README.md`: rendering orchestration and dependency resolution
|
|
@@ -112,34 +121,31 @@ The Ecopages architecture revolves around an `eco.config.ts` file and an applica
|
|
|
112
121
|
|
|
113
122
|
### 1. Configuration (`eco.config.ts`)
|
|
114
123
|
|
|
115
|
-
Configure your
|
|
124
|
+
Configure your integrations, processors, and default metadata:
|
|
116
125
|
|
|
117
126
|
```typescript
|
|
118
|
-
import {
|
|
127
|
+
import { defineConfig } from '@ecopages/core/config';
|
|
119
128
|
import { ecopagesJsxPlugin } from '@ecopages/ecopages-jsx';
|
|
120
129
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
.
|
|
124
|
-
|
|
130
|
+
export default defineConfig({
|
|
131
|
+
rootDir: import.meta.dirname,
|
|
132
|
+
baseUrl: process.env.ECOPAGES_BASE_URL ?? 'http://localhost:3000',
|
|
133
|
+
defaultMetadata: {
|
|
125
134
|
title: 'My Ecopages Site',
|
|
126
135
|
description: 'Built with Ecopages',
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
export default config;
|
|
136
|
+
},
|
|
137
|
+
integrations: [ecopagesJsxPlugin()],
|
|
138
|
+
});
|
|
132
139
|
```
|
|
133
140
|
|
|
134
141
|
### 2. Application Entry (`app.ts`)
|
|
135
142
|
|
|
136
|
-
Start the application using `createApp`. It
|
|
143
|
+
Start the application using `createApp`. It automatically resolves and loads `eco.config.ts` from the project root and selects the appropriate runtime adapter (Bun when available, Node otherwise):
|
|
137
144
|
|
|
138
145
|
```typescript
|
|
139
146
|
import { createApp } from '@ecopages/core/create-app';
|
|
140
|
-
import appConfig from './eco.config';
|
|
141
147
|
|
|
142
|
-
const app = await createApp(
|
|
148
|
+
const app = await createApp();
|
|
143
149
|
|
|
144
150
|
await app.start();
|
|
145
151
|
```
|
|
@@ -232,14 +238,26 @@ Standalone response helpers (`json`, `html`, `redirect`) share the same body emi
|
|
|
232
238
|
|
|
233
239
|
Register a prebuilt handler with `app.add()`. Use `app.get(path, handler)` only when defining the route inline in `app.ts`.
|
|
234
240
|
|
|
241
|
+
### 6. Error pages
|
|
242
|
+
|
|
243
|
+
Filesystem `src/pages/404.*` and `500.*` take precedence. For explicit-route apps, register views on the app:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
app.notFound('./src/views/not-found.kita');
|
|
247
|
+
app.serverError('./src/views/server-error.kita');
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
String and URL view paths passed to `app.static()`, `app.notFound()`, and `app.serverError()` load through the server-module transpiler. Raw dynamic `import()` skips component-identity transforms.
|
|
251
|
+
|
|
252
|
+
When no custom page is configured, built-in HTML defaults are served instead.
|
|
253
|
+
|
|
235
254
|
Attach the handler in your `app.ts` entry:
|
|
236
255
|
|
|
237
256
|
```typescript
|
|
238
257
|
import { createApp } from '@ecopages/core/create-app';
|
|
239
258
|
import { helloWorld } from './handlers/hello';
|
|
240
|
-
import appConfig from './eco.config';
|
|
241
259
|
|
|
242
|
-
const app = await createApp(
|
|
260
|
+
const app = await createApp();
|
|
243
261
|
|
|
244
262
|
app.add(helloWorld);
|
|
245
263
|
|
|
@@ -298,6 +316,7 @@ Use these entrypoints when implementing integrations, processors, or source tran
|
|
|
298
316
|
- `@ecopages/core/plugins/processor`
|
|
299
317
|
- `@ecopages/core/plugins/source-transform`
|
|
300
318
|
- `@ecopages/core/route-renderer/orchestration/integration-renderer`
|
|
319
|
+
- `@ecopages/core/route-renderer/orchestration/document-shell/layout-shell-props.service`
|
|
301
320
|
- `@ecopages/core/services/asset-processing-service`
|
|
302
321
|
- `@ecopages/core/hmr/hmr-strategy`
|
|
303
322
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.2.0-rc.
|
|
3
|
+
"version": "0.2.0-rc.10",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -10,6 +10,9 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"main": "./src/index.js",
|
|
12
12
|
"type": "module",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
13
16
|
"sideEffects": false,
|
|
14
17
|
"repository": {
|
|
15
18
|
"type": "git",
|
|
@@ -17,7 +20,8 @@
|
|
|
17
20
|
"directory": "packages/core"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@
|
|
23
|
+
"@clack/prompts": "^1.7.0",
|
|
24
|
+
"@ecopages/file-system": "0.2.0-rc.10",
|
|
21
25
|
"@ecopages/logger": "^0.2.3",
|
|
22
26
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
23
27
|
"@oxc-project/runtime": "0.141.0",
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
"@standard-schema/utils": "^0.3.0"
|
|
32
36
|
},
|
|
33
37
|
"peerDependencies": {
|
|
34
|
-
"@ecopages/dev-toolbar": "0.2.0-rc.
|
|
38
|
+
"@ecopages/dev-toolbar": "0.2.0-rc.10"
|
|
35
39
|
},
|
|
36
40
|
"peerDependenciesMeta": {
|
|
37
41
|
"@ecopages/dev-toolbar": {
|
|
@@ -54,6 +58,18 @@
|
|
|
54
58
|
"types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
|
|
55
59
|
"default": "./src/route-renderer/orchestration/integration-renderer.js"
|
|
56
60
|
},
|
|
61
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader": {
|
|
62
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts",
|
|
63
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js"
|
|
64
|
+
},
|
|
65
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer": {
|
|
66
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts",
|
|
67
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js"
|
|
68
|
+
},
|
|
69
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint": {
|
|
70
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts",
|
|
71
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js"
|
|
72
|
+
},
|
|
57
73
|
"./route-renderer/orchestration/string-markup-renderer": {
|
|
58
74
|
"types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
|
|
59
75
|
"default": "./src/route-renderer/orchestration/string-markup-renderer.js"
|
|
@@ -75,6 +91,10 @@
|
|
|
75
91
|
"types": "./src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts",
|
|
76
92
|
"default": "./src/route-renderer/orchestration/document-shell/document-shell-render.service.js"
|
|
77
93
|
},
|
|
94
|
+
"./route-renderer/orchestration/document-shell/layout-shell-props.service": {
|
|
95
|
+
"types": "./src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts",
|
|
96
|
+
"default": "./src/route-renderer/orchestration/document-shell/layout-shell-props.service.js"
|
|
97
|
+
},
|
|
78
98
|
"./route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils": {
|
|
79
99
|
"types": "./src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts",
|
|
80
100
|
"default": "./src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js"
|
|
@@ -134,6 +154,10 @@
|
|
|
134
154
|
"types": "./src/config/config-builder.d.ts",
|
|
135
155
|
"default": "./src/config/config-builder.js"
|
|
136
156
|
},
|
|
157
|
+
"./config": {
|
|
158
|
+
"types": "./src/config/index.d.ts",
|
|
159
|
+
"default": "./src/config/index.js"
|
|
160
|
+
},
|
|
137
161
|
"./constants": {
|
|
138
162
|
"types": "./src/config/constants.d.ts",
|
|
139
163
|
"default": "./src/config/constants.js"
|
|
@@ -178,6 +202,11 @@
|
|
|
178
202
|
"types": "./src/hmr/client/hmr-runtime.d.ts",
|
|
179
203
|
"default": "./src/hmr/client/hmr-runtime.js"
|
|
180
204
|
},
|
|
205
|
+
"./dev/development-restart": {
|
|
206
|
+
"import": "./src/dev/development-restart.js",
|
|
207
|
+
"types": "./src/dev/development-restart.d.ts",
|
|
208
|
+
"default": "./src/dev/development-restart.js"
|
|
209
|
+
},
|
|
181
210
|
"./dev/host-runtime": {
|
|
182
211
|
"types": "./src/dev/host-runtime.d.ts",
|
|
183
212
|
"default": "./src/dev/host-runtime.js"
|
|
@@ -342,6 +371,18 @@
|
|
|
342
371
|
"types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
|
|
343
372
|
"default": "./src/route-renderer/orchestration/integration-renderer.js"
|
|
344
373
|
},
|
|
374
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.ts": {
|
|
375
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts",
|
|
376
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js"
|
|
377
|
+
},
|
|
378
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.ts": {
|
|
379
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.d.ts",
|
|
380
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js"
|
|
381
|
+
},
|
|
382
|
+
"./route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.ts": {
|
|
383
|
+
"types": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts",
|
|
384
|
+
"default": "./src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js"
|
|
385
|
+
},
|
|
345
386
|
"./route-renderer/orchestration/string-markup-renderer.ts": {
|
|
346
387
|
"types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
|
|
347
388
|
"default": "./src/route-renderer/orchestration/string-markup-renderer.js"
|
|
@@ -363,6 +404,10 @@
|
|
|
363
404
|
"types": "./src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts",
|
|
364
405
|
"default": "./src/route-renderer/orchestration/document-shell/document-shell-render.service.js"
|
|
365
406
|
},
|
|
407
|
+
"./route-renderer/orchestration/document-shell/layout-shell-props.service.ts": {
|
|
408
|
+
"types": "./src/route-renderer/orchestration/document-shell/layout-shell-props.service.d.ts",
|
|
409
|
+
"default": "./src/route-renderer/orchestration/document-shell/layout-shell-props.service.js"
|
|
410
|
+
},
|
|
366
411
|
"./route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.ts": {
|
|
367
412
|
"types": "./src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.d.ts",
|
|
368
413
|
"default": "./src/route-renderer/orchestration/page-browser-graph/page-browser-graph-merge.utils.js"
|
|
@@ -422,6 +467,10 @@
|
|
|
422
467
|
"types": "./src/config/config-builder.d.ts",
|
|
423
468
|
"default": "./src/config/config-builder.js"
|
|
424
469
|
},
|
|
470
|
+
"./config.ts": {
|
|
471
|
+
"types": "./src/config/index.d.ts",
|
|
472
|
+
"default": "./src/config/index.js"
|
|
473
|
+
},
|
|
425
474
|
"./constants.ts": {
|
|
426
475
|
"types": "./src/config/constants.d.ts",
|
|
427
476
|
"default": "./src/config/constants.js"
|
|
@@ -466,6 +515,11 @@
|
|
|
466
515
|
"types": "./src/hmr/client/hmr-runtime.d.ts",
|
|
467
516
|
"default": "./src/hmr/client/hmr-runtime.js"
|
|
468
517
|
},
|
|
518
|
+
"./dev/development-restart.ts": {
|
|
519
|
+
"import": "./src/dev/development-restart.js",
|
|
520
|
+
"types": "./src/dev/development-restart.d.ts",
|
|
521
|
+
"default": "./src/dev/development-restart.js"
|
|
522
|
+
},
|
|
469
523
|
"./dev/host-runtime.ts": {
|
|
470
524
|
"types": "./src/dev/host-runtime.d.ts",
|
|
471
525
|
"default": "./src/dev/host-runtime.js"
|
|
@@ -623,4 +677,4 @@
|
|
|
623
677
|
}
|
|
624
678
|
},
|
|
625
679
|
"types": "./src/index.d.ts"
|
|
626
|
-
}
|
|
680
|
+
}
|
package/src/adapters/README.md
CHANGED
|
@@ -27,7 +27,7 @@ They are not responsible for:
|
|
|
27
27
|
- `shared/`: runtime-neutral adapter helpers used by both hosts, clustered by concern:
|
|
28
28
|
- `shared/http/` — API response builders, request pipeline, middleware runner, define-api helpers, explicit-static and filesystem matchers
|
|
29
29
|
- `shared/hmr/` — HMR HTML inject helpers, shared HMR manager, entrypoint registrar
|
|
30
|
-
- `shared/runtime/` — shared server adapter, route handler, application adapter, static builder, port/bootstrap utilities
|
|
30
|
+
- `shared/runtime/` — shared server adapter, route handler, application adapter, static builder, port/bootstrap utilities (`PortManager` on dev and preview bind, Clack confirm on TTY port collisions)
|
|
31
31
|
- `shared/ws/` — WinterCG WebSocket lifecycle helpers and Node HTTP upgrade bridge (Bun-specific user WS lifecycle lives under `bun/`)
|
|
32
32
|
|
|
33
33
|
## Ownership Boundary
|
|
@@ -41,3 +41,5 @@ Core services still own:
|
|
|
41
41
|
- server loading
|
|
42
42
|
- invalidation classification
|
|
43
43
|
- route rendering orchestration
|
|
44
|
+
|
|
45
|
+
Semantic 404/500 page selection and rendering belongs to `src/services/error-pages/`; adapters only turn its rendered body into runtime responses.
|
|
@@ -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
|
/**
|
|
@@ -105,6 +106,7 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
105
106
|
protected runtimeOptions: ApplicationRuntimeOptions;
|
|
106
107
|
protected apiHandlers: ApiHandler[];
|
|
107
108
|
protected staticRoutes: StaticRoute[];
|
|
109
|
+
protected errorPageLoaders: ErrorPageLoaders;
|
|
108
110
|
protected errorHandler?: ErrorHandler;
|
|
109
111
|
/**
|
|
110
112
|
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
@@ -186,21 +188,41 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
186
188
|
* Register a view for static generation at build time.
|
|
187
189
|
* The view must have staticPaths defined for dynamic routes.
|
|
188
190
|
*
|
|
189
|
-
*
|
|
191
|
+
* String and URL inputs load through the server-module transpiler so HMR and
|
|
192
|
+
* component identity transforms remain active in development.
|
|
190
193
|
*
|
|
191
194
|
* @param path - URL path pattern (e.g., '/posts/:slug')
|
|
192
|
-
* @param loader - A function
|
|
195
|
+
* @param loader - A view loader function, source path, or URL for the eco.page view module
|
|
193
196
|
* @example
|
|
194
197
|
* ```typescript
|
|
195
|
-
* app.static('/login',
|
|
196
|
-
* app.static('/posts/:slug',
|
|
198
|
+
* app.static('/login', './src/views/login.kita')
|
|
199
|
+
* app.static('/posts/:slug', './src/views/post-view.kita')
|
|
197
200
|
* ```
|
|
198
201
|
*/
|
|
199
|
-
static<P>(path: string, loader: ViewLoader<P>): this;
|
|
202
|
+
static<P>(path: string, loader: ViewLoader<P> | string | URL): this;
|
|
203
|
+
private resolveViewLoader;
|
|
200
204
|
/**
|
|
201
205
|
* Get all registered static routes
|
|
202
206
|
*/
|
|
203
207
|
getStaticRoutes(): StaticRoute[];
|
|
208
|
+
/**
|
|
209
|
+
* Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
|
|
210
|
+
* file exists.
|
|
211
|
+
*/
|
|
212
|
+
errorPage(status: HttpErrorPageStatus, loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
213
|
+
badRequest(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
214
|
+
unauthorized(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
215
|
+
forbidden(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
216
|
+
/**
|
|
217
|
+
* Registers the not-found page used when no filesystem `pages/404.*` file exists.
|
|
218
|
+
*/
|
|
219
|
+
notFound(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
220
|
+
conflict(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
221
|
+
/**
|
|
222
|
+
* Registers the server-error page used when no filesystem `pages/500.*` file exists.
|
|
223
|
+
*/
|
|
224
|
+
serverError(loader: ViewLoader<ErrorPageTemplateProps> | string | URL): this;
|
|
225
|
+
getErrorPageLoaders(): ErrorPageLoaders;
|
|
204
226
|
/**
|
|
205
227
|
* Register a WebSocket handler for the given path pattern.
|
|
206
228
|
*
|
|
@@ -8,12 +8,15 @@
|
|
|
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';
|
|
14
|
+
import { ERROR_PAGE_KIND_BY_STATUS } from '../../errors/http-error-page-contract.js';
|
|
13
15
|
import { fileSystem } from '@ecopages/file-system';
|
|
14
16
|
import { formatRuntimeServerStartedMessage, } from '../../dev/runtime-server-started-message.js';
|
|
15
17
|
import { parseCliArgs } from '../../utils/parse-cli-args.js';
|
|
16
18
|
import { startupTrace } from '../../diagnostics/startup-trace.js';
|
|
19
|
+
import { ECOPAGES_DEV_RESTART_REASON_ENV } from '../../dev/development-restart.js';
|
|
17
20
|
/**
|
|
18
21
|
* Abstract base class for application adapters across different runtimes
|
|
19
22
|
*/
|
|
@@ -24,6 +27,7 @@ export class AbstractApplicationAdapter {
|
|
|
24
27
|
runtimeOptions;
|
|
25
28
|
apiHandlers = [];
|
|
26
29
|
staticRoutes = [];
|
|
30
|
+
errorPageLoaders = {};
|
|
27
31
|
errorHandler;
|
|
28
32
|
/**
|
|
29
33
|
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
@@ -94,26 +98,70 @@ export class AbstractApplicationAdapter {
|
|
|
94
98
|
* Register a view for static generation at build time.
|
|
95
99
|
* The view must have staticPaths defined for dynamic routes.
|
|
96
100
|
*
|
|
97
|
-
*
|
|
101
|
+
* String and URL inputs load through the server-module transpiler so HMR and
|
|
102
|
+
* component identity transforms remain active in development.
|
|
98
103
|
*
|
|
99
104
|
* @param path - URL path pattern (e.g., '/posts/:slug')
|
|
100
|
-
* @param loader - A function
|
|
105
|
+
* @param loader - A view loader function, source path, or URL for the eco.page view module
|
|
101
106
|
* @example
|
|
102
107
|
* ```typescript
|
|
103
|
-
* app.static('/login',
|
|
104
|
-
* app.static('/posts/:slug',
|
|
108
|
+
* app.static('/login', './src/views/login.kita')
|
|
109
|
+
* app.static('/posts/:slug', './src/views/post-view.kita')
|
|
105
110
|
* ```
|
|
106
111
|
*/
|
|
107
112
|
static(path, loader) {
|
|
108
|
-
this.
|
|
113
|
+
const resolvedLoader = this.resolveViewLoader(loader);
|
|
114
|
+
this.staticRoutes.push({ path, loader: resolvedLoader });
|
|
109
115
|
return this;
|
|
110
116
|
}
|
|
117
|
+
resolveViewLoader(loader) {
|
|
118
|
+
return typeof loader === 'string' || loader instanceof URL
|
|
119
|
+
? createViewModuleLoader(this.appConfig, loader)
|
|
120
|
+
: loader;
|
|
121
|
+
}
|
|
111
122
|
/**
|
|
112
123
|
* Get all registered static routes
|
|
113
124
|
*/
|
|
114
125
|
getStaticRoutes() {
|
|
115
126
|
return this.staticRoutes;
|
|
116
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Registers a semantic HTML error page used when no filesystem `pages/{status}.*`
|
|
130
|
+
* file exists.
|
|
131
|
+
*/
|
|
132
|
+
errorPage(status, loader) {
|
|
133
|
+
const kind = ERROR_PAGE_KIND_BY_STATUS[status];
|
|
134
|
+
const resolvedLoader = this.resolveViewLoader(loader);
|
|
135
|
+
this.errorPageLoaders = { ...this.errorPageLoaders, [kind]: resolvedLoader };
|
|
136
|
+
return this;
|
|
137
|
+
}
|
|
138
|
+
badRequest(loader) {
|
|
139
|
+
return this.errorPage(400, loader);
|
|
140
|
+
}
|
|
141
|
+
unauthorized(loader) {
|
|
142
|
+
return this.errorPage(401, loader);
|
|
143
|
+
}
|
|
144
|
+
forbidden(loader) {
|
|
145
|
+
return this.errorPage(403, loader);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Registers the not-found page used when no filesystem `pages/404.*` file exists.
|
|
149
|
+
*/
|
|
150
|
+
notFound(loader) {
|
|
151
|
+
return this.errorPage(404, loader);
|
|
152
|
+
}
|
|
153
|
+
conflict(loader) {
|
|
154
|
+
return this.errorPage(409, loader);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Registers the server-error page used when no filesystem `pages/500.*` file exists.
|
|
158
|
+
*/
|
|
159
|
+
serverError(loader) {
|
|
160
|
+
return this.errorPage(500, loader);
|
|
161
|
+
}
|
|
162
|
+
getErrorPageLoaders() {
|
|
163
|
+
return this.errorPageLoaders;
|
|
164
|
+
}
|
|
117
165
|
/**
|
|
118
166
|
* Register a WebSocket handler for the given path pattern.
|
|
119
167
|
*
|
|
@@ -221,6 +269,11 @@ export class AbstractApplicationAdapter {
|
|
|
221
269
|
async notifyListening(origin) {
|
|
222
270
|
const normalizedOrigin = origin.replace(/\/$/, '');
|
|
223
271
|
startupTrace.markServerListening();
|
|
272
|
+
const restartReason = process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
|
|
273
|
+
if (restartReason) {
|
|
274
|
+
appLogger.info(`Development server restarted (${restartReason}).`);
|
|
275
|
+
delete process.env[ECOPAGES_DEV_RESTART_REASON_ENV];
|
|
276
|
+
}
|
|
224
277
|
if (!this.onAppStartCallback) {
|
|
225
278
|
this.logServerStarted(normalizedOrigin);
|
|
226
279
|
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
|
*/
|