@ecopages/core 0.2.0-beta.2 → 0.2.0-beta.21
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 +1 -1
- package/package.json +163 -3
- package/src/adapters/abstract/application-adapter.d.ts +104 -5
- package/src/adapters/abstract/application-adapter.js +125 -1
- package/src/adapters/abstract/server-adapter.d.ts +6 -2
- package/src/adapters/abstract/ws-pattern-matcher.d.ts +60 -0
- package/src/adapters/abstract/ws-pattern-matcher.js +61 -0
- package/src/adapters/bun/client-bridge.d.ts +1 -0
- package/src/adapters/bun/client-bridge.js +3 -0
- package/src/adapters/bun/create-app.d.ts +6 -4
- package/src/adapters/bun/create-app.js +65 -43
- package/src/adapters/bun/server-adapter.d.ts +90 -22
- package/src/adapters/bun/server-adapter.js +266 -84
- package/src/adapters/bun/static-preview-host.js +25 -20
- package/src/adapters/create-app.d.ts +13 -11
- package/src/adapters/create-app.js +2 -51
- package/src/adapters/index.d.ts +1 -1
- package/src/adapters/index.js +1 -2
- package/src/adapters/node/create-app.d.ts +5 -1
- package/src/adapters/node/create-app.js +51 -12
- package/src/adapters/node/node-client-bridge.d.ts +1 -0
- package/src/adapters/node/node-client-bridge.js +3 -0
- package/src/adapters/node/server-adapter-dependencies.js +4 -0
- package/src/adapters/node/server-adapter.d.ts +62 -20
- package/src/adapters/node/server-adapter.js +160 -131
- package/src/adapters/node/static-content-server.d.ts +1 -0
- package/src/adapters/node/static-content-server.js +10 -2
- package/src/adapters/node/static-preview-host.js +27 -12
- package/src/adapters/shared/bun-user-websocket-lifecycle.d.ts +22 -0
- package/src/adapters/shared/bun-user-websocket-lifecycle.js +96 -0
- package/src/adapters/shared/copy-runtime-public-dir.d.ts +6 -0
- package/src/adapters/shared/copy-runtime-public-dir.js +24 -0
- package/src/adapters/shared/fs-server-response-matcher.d.ts +2 -0
- package/src/adapters/shared/fs-server-response-matcher.js +40 -18
- package/src/adapters/shared/hmr-entrypoint-registrar.d.ts +21 -30
- package/src/adapters/shared/hmr-entrypoint-registrar.js +49 -54
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/hmr-html-response.js +4 -1
- package/src/adapters/shared/node-http-websocket-upgrades.d.ts +21 -0
- package/src/adapters/shared/node-http-websocket-upgrades.js +100 -0
- package/src/adapters/shared/port-manager.d.ts +116 -0
- package/src/adapters/shared/port-manager.js +196 -0
- package/src/adapters/shared/runtime-app-bootstrap.d.ts +2 -1
- package/src/adapters/shared/runtime-app-bootstrap.js +3 -6
- package/src/adapters/shared/runtime-server-lifecycle.d.ts +46 -0
- package/src/adapters/shared/runtime-server-lifecycle.js +50 -0
- package/src/adapters/shared/server-adapter.d.ts +2 -1
- package/src/adapters/shared/server-adapter.js +13 -6
- package/src/adapters/shared/server-route-handler.d.ts +4 -1
- package/src/adapters/shared/server-route-handler.js +5 -2
- package/src/adapters/shared/server-static-builder.d.ts +23 -32
- package/src/adapters/shared/server-static-builder.js +100 -73
- package/src/adapters/shared/shared-hmr-manager.d.ts +45 -11
- package/src/adapters/shared/shared-hmr-manager.js +204 -58
- package/src/adapters/shared/static-preview-host.d.ts +5 -0
- package/src/adapters/shared/websocket-lifecycle.d.ts +24 -0
- package/src/adapters/shared/websocket-lifecycle.js +55 -0
- package/src/build/README.md +77 -14
- package/src/build/app-build-manifest-runtime.d.ts +9 -0
- package/src/build/app-build-manifest-runtime.js +87 -0
- package/src/build/build-adapter.d.ts +17 -319
- package/src/build/build-adapter.js +28 -94
- package/src/build/build-contracts.d.ts +97 -0
- package/src/build/build-contracts.js +0 -0
- package/src/build/build-input-fingerprint.d.ts +28 -0
- package/src/build/build-input-fingerprint.js +31 -0
- package/src/build/build-profile-options.d.ts +7 -0
- package/src/build/build-profile-options.js +37 -0
- package/src/build/build-runtime.d.ts +24 -0
- package/src/build/build-runtime.js +65 -0
- package/src/build/deduping-build-executor.d.ts +28 -0
- package/src/build/deduping-build-executor.js +56 -0
- package/src/build/jsx-ownership-plugins.d.ts +24 -0
- package/src/build/jsx-ownership-plugins.js +41 -0
- package/src/build/pages-unified-graph-build.d.ts +31 -0
- package/src/build/pages-unified-graph-build.js +206 -0
- package/src/build/parallel-build-executor.d.ts +21 -0
- package/src/build/parallel-build-executor.js +52 -0
- package/src/build/production-build-cache.d.ts +20 -0
- package/src/build/production-build-cache.js +63 -0
- package/src/build/rolldown-adapter-helpers.d.ts +3 -6
- package/src/build/rolldown-adapter-helpers.js +71 -6
- package/src/build/rolldown-build-adapter.d.ts +2 -6
- package/src/build/rolldown-build-adapter.js +3 -3
- package/src/build/rolldown-build-invocation-metrics.d.ts +12 -0
- package/src/build/rolldown-build-invocation-metrics.js +43 -0
- package/src/build/rolldown-plugin-bridge.d.ts +15 -1
- package/src/build/rolldown-plugin-bridge.js +20 -5
- package/src/build/rolldown-source-transform-pass.d.ts +15 -0
- package/src/build/rolldown-source-transform-pass.js +58 -0
- package/src/build/runtime-build-executor.d.ts +8 -15
- package/src/build/runtime-build-executor.js +12 -15
- package/src/build/runtime-build-output-normalizer.d.ts +7 -0
- package/src/build/runtime-build-output-normalizer.js +94 -2
- package/src/build/server-entry-build-cache.d.ts +44 -0
- package/src/build/server-entry-build-cache.js +161 -0
- package/src/client/navigation-scripts/classification.d.ts +16 -0
- package/src/client/navigation-scripts/classification.js +41 -0
- package/src/client/navigation-scripts/index.d.ts +3 -0
- package/src/client/navigation-scripts/index.js +23 -0
- package/src/client/navigation-scripts/navigation-scripts.test.browser.js +65 -0
- package/src/client/navigation-scripts/registry.d.ts +11 -0
- package/src/client/navigation-scripts/registry.js +12 -0
- package/src/client/navigation-scripts/rerun-queue.d.ts +37 -0
- package/src/client/navigation-scripts/rerun-queue.js +73 -0
- package/src/client/scroll.d.ts +17 -0
- package/src/client/scroll.js +25 -0
- package/src/client/scroll.test.browser.js +37 -0
- package/src/client/view-transitions.d.ts +16 -0
- package/src/client/view-transitions.js +63 -0
- package/src/config/config-builder.d.ts +12 -7
- package/src/config/config-builder.js +12 -9
- package/src/dev/client-bridge-registry.d.ts +5 -0
- package/src/dev/client-bridge-registry.js +15 -0
- package/src/dev/dev-client-ownership.d.ts +7 -0
- package/src/dev/dev-client-ownership.js +6 -0
- package/src/dev/hmr-manager-registry.d.ts +8 -0
- package/src/dev/hmr-manager-registry.js +15 -0
- package/src/dev/host-runtime.d.ts +3 -0
- package/src/dev/host-runtime.js +7 -0
- package/src/dev/runtime-server-started-message.d.ts +2 -0
- package/src/dev/runtime-server-started-message.js +6 -0
- package/src/eco/README.md +11 -0
- package/src/eco/eco-declared-component.d.ts +14 -0
- package/src/eco/eco-declared-component.js +16 -0
- package/src/eco/eco.browser.js +5 -6
- package/src/eco/eco.js +5 -6
- package/src/eco/eco.types.d.ts +2 -2
- package/src/eco/page-layout-normalization.d.ts +21 -0
- package/src/eco/page-layout-normalization.js +59 -0
- package/src/errors/index.d.ts +1 -0
- package/src/errors/index.js +7 -1
- package/src/errors/undeclared-component-dependency-error.d.ts +11 -0
- package/src/errors/undeclared-component-dependency-error.js +17 -0
- package/src/hmr/client/hmr-runtime.js +5 -2
- package/src/hmr/hmr-entrypoint-output.d.ts +43 -0
- package/src/hmr/hmr-entrypoint-output.js +53 -0
- package/src/hmr/hmr-strategy.d.ts +15 -0
- package/src/hmr/hmr-strategy.js +19 -0
- package/src/hmr/strategies/js-hmr-strategy.d.ts +3 -5
- package/src/hmr/strategies/js-hmr-strategy.js +67 -19
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.d.ts +17 -0
- package/src/hmr/strategies/server-rendered-template-hmr-strategy.js +29 -0
- package/src/integrations/ghtml/ghtml-renderer.d.ts +2 -6
- package/src/integrations/ghtml/ghtml-renderer.js +2 -51
- package/src/integrations/ghtml/ghtml.plugin.d.ts +3 -16
- package/src/integrations/ghtml/ghtml.plugin.js +7 -14
- package/src/plugins/define-integration.d.ts +26 -0
- package/src/plugins/define-integration.js +19 -0
- package/src/plugins/eco-component-meta-plugin.js +5 -8
- package/src/plugins/foreign-jsx-override-plugin.js +4 -6
- package/src/plugins/integration-plugin.d.ts +19 -9
- package/src/plugins/integration-plugin.js +7 -4
- package/src/plugins/jsx-import-source.utils.d.ts +8 -0
- package/src/plugins/jsx-import-source.utils.js +26 -0
- package/src/plugins/processor.d.ts +19 -4
- package/src/plugins/processor.js +22 -4
- package/src/plugins/source-transform.d.ts +31 -0
- package/src/plugins/source-transform.js +23 -1
- package/src/route-renderer/GRAPH.md +8 -8
- package/src/route-renderer/README.md +30 -28
- package/src/route-renderer/orchestration/component-graph-collectors.d.ts +10 -0
- package/src/route-renderer/orchestration/component-graph-collectors.js +143 -0
- package/src/route-renderer/orchestration/component-graph.d.ts +36 -0
- package/src/route-renderer/orchestration/component-graph.js +98 -0
- package/src/route-renderer/orchestration/component-render-context.d.ts +3 -10
- package/src/route-renderer/orchestration/component-render-context.js +3 -1
- package/src/route-renderer/orchestration/declared-ownership-graph.d.ts +1 -18
- package/src/route-renderer/orchestration/declared-ownership-graph.js +5 -31
- package/src/route-renderer/orchestration/document-shell-render.service.d.ts +90 -0
- package/src/route-renderer/orchestration/document-shell-render.service.js +120 -0
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts +59 -29
- package/src/route-renderer/orchestration/foreign-subtree-execution.service.js +164 -35
- package/src/route-renderer/orchestration/global-injector-assets.service.d.ts +7 -0
- package/src/route-renderer/orchestration/global-injector-assets.service.js +32 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +18 -54
- package/src/route-renderer/orchestration/integration-renderer.js +113 -195
- package/src/route-renderer/orchestration/integration-route-render-adapter.d.ts +38 -0
- package/src/route-renderer/orchestration/integration-route-render-adapter.js +27 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.d.ts +20 -0
- package/src/route-renderer/orchestration/layout-shell-props.service.js +31 -0
- package/src/route-renderer/orchestration/ownership-validation.service.d.ts +5 -0
- package/src/route-renderer/orchestration/ownership-validation.service.js +29 -1
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.d.ts +9 -0
- package/src/route-renderer/orchestration/page-browser-graph-contribution.loader.js +7 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.d.ts +25 -0
- package/src/route-renderer/orchestration/page-browser-graph.service.js +174 -0
- package/src/route-renderer/orchestration/render-output.utils.d.ts +2 -0
- package/src/route-renderer/orchestration/render-output.utils.js +4 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.d.ts +17 -0
- package/src/route-renderer/orchestration/route-html-finalization.service.js +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.d.ts +26 -0
- package/src/route-renderer/orchestration/route-prepared-options.builder.js +54 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.d.ts +4 -0
- package/src/route-renderer/orchestration/route-prepared-options.utils.js +33 -0
- package/src/route-renderer/orchestration/route-render-orchestrator.d.ts +8 -39
- package/src/route-renderer/orchestration/route-render-orchestrator.js +53 -461
- package/src/route-renderer/orchestration/string-markup-renderer.d.ts +14 -0
- package/src/route-renderer/orchestration/string-markup-renderer.js +55 -0
- package/src/route-renderer/page-loading/component-dependency-collection.js +5 -2
- package/src/router/client/link-intent.d.ts +11 -21
- package/src/router/client/link-intent.js +10 -0
- package/src/router/client/link-intent.test.browser.js +12 -1
- package/src/router/client/link-navigation-policy.d.ts +45 -0
- package/src/router/client/link-navigation-policy.js +101 -0
- package/src/router/client/link-navigation-policy.test.browser.d.ts +1 -0
- package/src/router/client/link-navigation-policy.test.browser.js +92 -0
- package/src/router/client/navigation-coordinator.d.ts +1 -1
- package/src/router/client/navigation-coordinator.js +12 -2
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.js +1 -0
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +4 -2
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.js +27 -7
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +0 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +18 -15
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +17 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -31
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +0 -3
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +2 -30
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +2 -0
- package/src/services/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +43 -0
- package/src/services/assets/browser-bundle.service.d.ts +3 -1
- package/src/services/assets/browser-bundle.service.js +17 -5
- package/src/services/html/html-transformer.service.d.ts +1 -1
- package/src/services/html/html-transformer.service.js +4 -4
- package/src/services/invalidation/development-invalidation.service.d.ts +20 -2
- package/src/services/invalidation/development-invalidation.service.js +56 -2
- package/src/services/module-loading/README.md +49 -0
- package/src/services/module-loading/app-server-module-transpiler.service.js +5 -17
- package/src/services/module-loading/page-module-import.service.d.ts +5 -1
- package/src/services/module-loading/page-module-import.service.js +96 -45
- package/src/services/module-loading/route-module-build-cache-registry.d.ts +24 -0
- package/src/services/module-loading/route-module-build-cache-registry.js +37 -0
- package/src/services/module-loading/route-module-build-cache.d.ts +4 -0
- package/src/services/module-loading/route-module-build-cache.js +38 -0
- package/src/services/module-loading/route-module-build-cache.store.d.ts +57 -0
- package/src/services/module-loading/route-module-build-cache.store.js +207 -0
- package/src/services/module-loading/route-module-build-manifest.d.ts +61 -0
- package/src/services/module-loading/route-module-build-manifest.js +116 -0
- package/src/services/module-loading/route-module-dependency-hasher.d.ts +81 -0
- package/src/services/module-loading/route-module-dependency-hasher.js +122 -0
- package/src/services/module-loading/server-module-transpiler.service.js +1 -1
- package/src/static-site-generator/README.md +33 -0
- package/src/static-site-generator/static-build-invalidation.d.ts +10 -0
- package/src/static-site-generator/static-build-invalidation.js +59 -0
- package/src/static-site-generator/static-export-context.d.ts +22 -0
- package/src/static-site-generator/static-export-context.js +0 -0
- package/src/static-site-generator/static-site-generator.d.ts +17 -20
- package/src/static-site-generator/static-site-generator.js +188 -85
- package/src/types/internal-types.d.ts +16 -9
- package/src/types/public-types.d.ts +144 -40
- package/src/utils/parse-cli-args.d.ts +2 -0
- package/src/utils/parse-cli-args.js +6 -0
- package/src/utils/server-utils.module.d.ts +3 -2
- package/src/utils/server-utils.module.js +5 -6
- package/src/utils/static-file-extensions.d.ts +12 -0
- package/src/utils/static-file-extensions.js +48 -0
- package/src/watchers/project-watcher-ignore.d.ts +11 -0
- package/src/watchers/project-watcher-ignore.js +16 -0
- package/src/watchers/project-watcher.d.ts +26 -3
- package/src/watchers/project-watcher.js +132 -30
- package/src/watchers/project-watcher.test-helpers.js +5 -5
- package/src/build/rolldown-dev-build-adapter.d.ts +0 -82
- package/src/build/rolldown-dev-build-adapter.js +0 -166
- package/src/hmr/hmr.postcss.test.e2e.js +0 -31
- package/src/hmr/hmr.test.e2e.js +0 -43
- package/src/route-renderer/orchestration/ownership-planning.service.d.ts +0 -24
- package/src/route-renderer/orchestration/ownership-planning.service.js +0 -63
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.d.ts +0 -91
- package/src/route-renderer/orchestration/queued-foreign-subtree-resolution.service.js +0 -170
- /package/src/{hmr/hmr.postcss.test.e2e.d.ts → client/navigation-scripts/navigation-scripts.test.browser.d.ts} +0 -0
- /package/src/{hmr/hmr.test.e2e.d.ts → client/scroll.test.browser.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -227,7 +227,7 @@ import { defineApiHandler, defineGroupHandler, eco } from '@ecopages/core';
|
|
|
227
227
|
```
|
|
228
228
|
|
|
229
229
|
> [!NOTE]
|
|
230
|
-
> `createApp`
|
|
230
|
+
> Use `createApp()` from `@ecopages/core/create-app` as the application entrypoint.
|
|
231
231
|
|
|
232
232
|
### Runtime Escape Hatches
|
|
233
233
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.21",
|
|
4
4
|
"description": "Core package for Ecopages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"repository": {
|
|
15
15
|
"type": "git",
|
|
16
|
-
"url": "https://github.com/ecopages/ecopages.git",
|
|
16
|
+
"url": "git+https://github.com/ecopages/ecopages.git",
|
|
17
17
|
"directory": "packages/core"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@ecopages/file-system": "0.2.0-beta.
|
|
20
|
+
"@ecopages/file-system": "0.2.0-beta.21",
|
|
21
21
|
"@ecopages/logger": "^0.2.3",
|
|
22
22
|
"@ecopages/scripts-injector": "^0.1.5",
|
|
23
23
|
"@oxc-project/runtime": "0.134.0",
|
|
@@ -45,11 +45,27 @@
|
|
|
45
45
|
"types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
|
|
46
46
|
"default": "./src/route-renderer/orchestration/integration-renderer.js"
|
|
47
47
|
},
|
|
48
|
+
"./route-renderer/string-markup-renderer": {
|
|
49
|
+
"types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
|
|
50
|
+
"default": "./src/route-renderer/orchestration/string-markup-renderer.js"
|
|
51
|
+
},
|
|
52
|
+
"./route-renderer/route-renderer": {
|
|
53
|
+
"types": "./src/route-renderer/route-renderer.d.ts",
|
|
54
|
+
"default": "./src/route-renderer/route-renderer.js"
|
|
55
|
+
},
|
|
48
56
|
"./route-renderer/component-render-context": {
|
|
49
57
|
"import": "./src/route-renderer/orchestration/component-render-context.js",
|
|
50
58
|
"types": "./src/route-renderer/orchestration/component-render-context.d.ts",
|
|
51
59
|
"default": "./src/route-renderer/orchestration/component-render-context.js"
|
|
52
60
|
},
|
|
61
|
+
"./route-renderer/orchestration/foreign-subtree-execution.service": {
|
|
62
|
+
"types": "./src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts",
|
|
63
|
+
"default": "./src/route-renderer/orchestration/foreign-subtree-execution.service.js"
|
|
64
|
+
},
|
|
65
|
+
"./route-renderer/orchestration/document-shell-render.service": {
|
|
66
|
+
"types": "./src/route-renderer/orchestration/document-shell-render.service.d.ts",
|
|
67
|
+
"default": "./src/route-renderer/orchestration/document-shell-render.service.js"
|
|
68
|
+
},
|
|
53
69
|
"./router/navigation-coordinator": {
|
|
54
70
|
"types": "./src/router/client/navigation-coordinator.d.ts",
|
|
55
71
|
"default": "./src/router/client/navigation-coordinator.js"
|
|
@@ -58,11 +74,31 @@
|
|
|
58
74
|
"types": "./src/router/client/link-intent.d.ts",
|
|
59
75
|
"default": "./src/router/client/link-intent.js"
|
|
60
76
|
},
|
|
77
|
+
"./router/link-navigation-policy": {
|
|
78
|
+
"types": "./src/router/client/link-navigation-policy.d.ts",
|
|
79
|
+
"default": "./src/router/client/link-navigation-policy.js"
|
|
80
|
+
},
|
|
81
|
+
"./client/scroll": {
|
|
82
|
+
"types": "./src/client/scroll.d.ts",
|
|
83
|
+
"default": "./src/client/scroll.js"
|
|
84
|
+
},
|
|
85
|
+
"./client/view-transitions": {
|
|
86
|
+
"types": "./src/client/view-transitions.d.ts",
|
|
87
|
+
"default": "./src/client/view-transitions.js"
|
|
88
|
+
},
|
|
89
|
+
"./client/navigation-scripts": {
|
|
90
|
+
"types": "./src/client/navigation-scripts/index.d.ts",
|
|
91
|
+
"default": "./src/client/navigation-scripts/index.js"
|
|
92
|
+
},
|
|
61
93
|
"./eco": {
|
|
62
94
|
"browser": "./src/eco/eco.browser.js",
|
|
63
95
|
"types": "./src/eco/eco.d.ts",
|
|
64
96
|
"default": "./src/eco/eco.js"
|
|
65
97
|
},
|
|
98
|
+
"./eco/page-layout-normalization": {
|
|
99
|
+
"types": "./src/eco/page-layout-normalization.d.ts",
|
|
100
|
+
"default": "./src/eco/page-layout-normalization.js"
|
|
101
|
+
},
|
|
66
102
|
"./declarations": {
|
|
67
103
|
"types": "./src/declarations.d.ts"
|
|
68
104
|
},
|
|
@@ -93,6 +129,18 @@
|
|
|
93
129
|
"types": "./src/dev/host-runtime.d.ts",
|
|
94
130
|
"default": "./src/dev/host-runtime.js"
|
|
95
131
|
},
|
|
132
|
+
"./dev/client-bridge-registry": {
|
|
133
|
+
"types": "./src/dev/client-bridge-registry.d.ts",
|
|
134
|
+
"default": "./src/dev/client-bridge-registry.js"
|
|
135
|
+
},
|
|
136
|
+
"./dev/hmr-manager-registry": {
|
|
137
|
+
"types": "./src/dev/hmr-manager-registry.d.ts",
|
|
138
|
+
"default": "./src/dev/hmr-manager-registry.js"
|
|
139
|
+
},
|
|
140
|
+
"./dev/dev-client-ownership": {
|
|
141
|
+
"types": "./src/dev/dev-client-ownership.d.ts",
|
|
142
|
+
"default": "./src/dev/dev-client-ownership.js"
|
|
143
|
+
},
|
|
96
144
|
"./services/asset-processing-service": {
|
|
97
145
|
"types": "./src/services/assets/asset-processing-service/index.d.ts",
|
|
98
146
|
"default": "./src/services/assets/asset-processing-service/index.js"
|
|
@@ -105,6 +153,10 @@
|
|
|
105
153
|
"types": "./src/plugins/integration-plugin.d.ts",
|
|
106
154
|
"default": "./src/plugins/integration-plugin.js"
|
|
107
155
|
},
|
|
156
|
+
"./plugins/define-integration": {
|
|
157
|
+
"types": "./src/plugins/define-integration.d.ts",
|
|
158
|
+
"default": "./src/plugins/define-integration.js"
|
|
159
|
+
},
|
|
108
160
|
"./plugins/source-transform": {
|
|
109
161
|
"types": "./src/plugins/source-transform.d.ts",
|
|
110
162
|
"default": "./src/plugins/source-transform.js"
|
|
@@ -117,6 +169,26 @@
|
|
|
117
169
|
"types": "./src/build/build-adapter.d.ts",
|
|
118
170
|
"default": "./src/build/build-adapter.js"
|
|
119
171
|
},
|
|
172
|
+
"./build/runtime-build-executor": {
|
|
173
|
+
"types": "./src/build/runtime-build-executor.d.ts",
|
|
174
|
+
"default": "./src/build/runtime-build-executor.js"
|
|
175
|
+
},
|
|
176
|
+
"./build/build-runtime": {
|
|
177
|
+
"types": "./src/build/build-runtime.d.ts",
|
|
178
|
+
"default": "./src/build/build-runtime.js"
|
|
179
|
+
},
|
|
180
|
+
"./build/build-contracts": {
|
|
181
|
+
"types": "./src/build/build-contracts.d.ts",
|
|
182
|
+
"default": "./src/build/build-contracts.js"
|
|
183
|
+
},
|
|
184
|
+
"./build/production-build-cache": {
|
|
185
|
+
"types": "./src/build/production-build-cache.d.ts",
|
|
186
|
+
"default": "./src/build/production-build-cache.js"
|
|
187
|
+
},
|
|
188
|
+
"./build/server-entry-build-cache": {
|
|
189
|
+
"types": "./src/build/server-entry-build-cache.d.ts",
|
|
190
|
+
"default": "./src/build/server-entry-build-cache.js"
|
|
191
|
+
},
|
|
120
192
|
"./build/runtime-build-output-normalizer": {
|
|
121
193
|
"types": "./src/build/runtime-build-output-normalizer.d.ts",
|
|
122
194
|
"default": "./src/build/runtime-build-output-normalizer.js"
|
|
@@ -129,6 +201,10 @@
|
|
|
129
201
|
"types": "./src/build/browser-runtime-plugin.d.ts",
|
|
130
202
|
"default": "./src/build/browser-runtime-plugin.js"
|
|
131
203
|
},
|
|
204
|
+
"./build/jsx-ownership-plugins": {
|
|
205
|
+
"types": "./src/build/jsx-ownership-plugins.d.ts",
|
|
206
|
+
"default": "./src/build/jsx-ownership-plugins.js"
|
|
207
|
+
},
|
|
132
208
|
"./cache": {
|
|
133
209
|
"types": "./src/cache/index.d.ts",
|
|
134
210
|
"default": "./src/cache/index.js"
|
|
@@ -137,6 +213,10 @@
|
|
|
137
213
|
"types": "./src/plugins/foreign-jsx-override-plugin.d.ts",
|
|
138
214
|
"default": "./src/plugins/foreign-jsx-override-plugin.js"
|
|
139
215
|
},
|
|
216
|
+
"./plugins/jsx-import-source.utils": {
|
|
217
|
+
"types": "./src/plugins/jsx-import-source.utils.d.ts",
|
|
218
|
+
"default": "./src/plugins/jsx-import-source.utils.js"
|
|
219
|
+
},
|
|
140
220
|
"./html": {
|
|
141
221
|
"import": "./src/utils/html.js",
|
|
142
222
|
"default": "./src/utils/html.js",
|
|
@@ -174,11 +254,27 @@
|
|
|
174
254
|
"types": "./src/route-renderer/orchestration/integration-renderer.d.ts",
|
|
175
255
|
"default": "./src/route-renderer/orchestration/integration-renderer.js"
|
|
176
256
|
},
|
|
257
|
+
"./route-renderer/string-markup-renderer.ts": {
|
|
258
|
+
"types": "./src/route-renderer/orchestration/string-markup-renderer.d.ts",
|
|
259
|
+
"default": "./src/route-renderer/orchestration/string-markup-renderer.js"
|
|
260
|
+
},
|
|
261
|
+
"./route-renderer/route-renderer.ts": {
|
|
262
|
+
"types": "./src/route-renderer/route-renderer.d.ts",
|
|
263
|
+
"default": "./src/route-renderer/route-renderer.js"
|
|
264
|
+
},
|
|
177
265
|
"./route-renderer/component-render-context.ts": {
|
|
178
266
|
"import": "./src/route-renderer/orchestration/component-render-context.js",
|
|
179
267
|
"types": "./src/route-renderer/orchestration/component-render-context.d.ts",
|
|
180
268
|
"default": "./src/route-renderer/orchestration/component-render-context.js"
|
|
181
269
|
},
|
|
270
|
+
"./route-renderer/orchestration/foreign-subtree-execution.service.ts": {
|
|
271
|
+
"types": "./src/route-renderer/orchestration/foreign-subtree-execution.service.d.ts",
|
|
272
|
+
"default": "./src/route-renderer/orchestration/foreign-subtree-execution.service.js"
|
|
273
|
+
},
|
|
274
|
+
"./route-renderer/orchestration/document-shell-render.service.ts": {
|
|
275
|
+
"types": "./src/route-renderer/orchestration/document-shell-render.service.d.ts",
|
|
276
|
+
"default": "./src/route-renderer/orchestration/document-shell-render.service.js"
|
|
277
|
+
},
|
|
182
278
|
"./router/navigation-coordinator.ts": {
|
|
183
279
|
"types": "./src/router/client/navigation-coordinator.d.ts",
|
|
184
280
|
"default": "./src/router/client/navigation-coordinator.js"
|
|
@@ -187,11 +283,31 @@
|
|
|
187
283
|
"types": "./src/router/client/link-intent.d.ts",
|
|
188
284
|
"default": "./src/router/client/link-intent.js"
|
|
189
285
|
},
|
|
286
|
+
"./router/link-navigation-policy.ts": {
|
|
287
|
+
"types": "./src/router/client/link-navigation-policy.d.ts",
|
|
288
|
+
"default": "./src/router/client/link-navigation-policy.js"
|
|
289
|
+
},
|
|
290
|
+
"./client/scroll.ts": {
|
|
291
|
+
"types": "./src/client/scroll.d.ts",
|
|
292
|
+
"default": "./src/client/scroll.js"
|
|
293
|
+
},
|
|
294
|
+
"./client/view-transitions.ts": {
|
|
295
|
+
"types": "./src/client/view-transitions.d.ts",
|
|
296
|
+
"default": "./src/client/view-transitions.js"
|
|
297
|
+
},
|
|
298
|
+
"./client/navigation-scripts.ts": {
|
|
299
|
+
"types": "./src/client/navigation-scripts/index.d.ts",
|
|
300
|
+
"default": "./src/client/navigation-scripts/index.js"
|
|
301
|
+
},
|
|
190
302
|
"./eco.ts": {
|
|
191
303
|
"browser": "./src/eco/eco.browser.js",
|
|
192
304
|
"types": "./src/eco/eco.d.ts",
|
|
193
305
|
"default": "./src/eco/eco.js"
|
|
194
306
|
},
|
|
307
|
+
"./eco/page-layout-normalization.ts": {
|
|
308
|
+
"types": "./src/eco/page-layout-normalization.d.ts",
|
|
309
|
+
"default": "./src/eco/page-layout-normalization.js"
|
|
310
|
+
},
|
|
195
311
|
"./declarations.ts": {
|
|
196
312
|
"types": "./src/declarations.d.ts"
|
|
197
313
|
},
|
|
@@ -222,6 +338,18 @@
|
|
|
222
338
|
"types": "./src/dev/host-runtime.d.ts",
|
|
223
339
|
"default": "./src/dev/host-runtime.js"
|
|
224
340
|
},
|
|
341
|
+
"./dev/client-bridge-registry.ts": {
|
|
342
|
+
"types": "./src/dev/client-bridge-registry.d.ts",
|
|
343
|
+
"default": "./src/dev/client-bridge-registry.js"
|
|
344
|
+
},
|
|
345
|
+
"./dev/hmr-manager-registry.ts": {
|
|
346
|
+
"types": "./src/dev/hmr-manager-registry.d.ts",
|
|
347
|
+
"default": "./src/dev/hmr-manager-registry.js"
|
|
348
|
+
},
|
|
349
|
+
"./dev/dev-client-ownership.ts": {
|
|
350
|
+
"types": "./src/dev/dev-client-ownership.d.ts",
|
|
351
|
+
"default": "./src/dev/dev-client-ownership.js"
|
|
352
|
+
},
|
|
225
353
|
"./services/asset-processing-service.ts": {
|
|
226
354
|
"types": "./src/services/assets/asset-processing-service/index.d.ts",
|
|
227
355
|
"default": "./src/services/assets/asset-processing-service/index.js"
|
|
@@ -234,6 +362,10 @@
|
|
|
234
362
|
"types": "./src/plugins/integration-plugin.d.ts",
|
|
235
363
|
"default": "./src/plugins/integration-plugin.js"
|
|
236
364
|
},
|
|
365
|
+
"./plugins/define-integration.ts": {
|
|
366
|
+
"types": "./src/plugins/define-integration.d.ts",
|
|
367
|
+
"default": "./src/plugins/define-integration.js"
|
|
368
|
+
},
|
|
237
369
|
"./plugins/source-transform.ts": {
|
|
238
370
|
"types": "./src/plugins/source-transform.d.ts",
|
|
239
371
|
"default": "./src/plugins/source-transform.js"
|
|
@@ -246,6 +378,26 @@
|
|
|
246
378
|
"types": "./src/build/build-adapter.d.ts",
|
|
247
379
|
"default": "./src/build/build-adapter.js"
|
|
248
380
|
},
|
|
381
|
+
"./build/runtime-build-executor.ts": {
|
|
382
|
+
"types": "./src/build/runtime-build-executor.d.ts",
|
|
383
|
+
"default": "./src/build/runtime-build-executor.js"
|
|
384
|
+
},
|
|
385
|
+
"./build/build-runtime.ts": {
|
|
386
|
+
"types": "./src/build/build-runtime.d.ts",
|
|
387
|
+
"default": "./src/build/build-runtime.js"
|
|
388
|
+
},
|
|
389
|
+
"./build/build-contracts.ts": {
|
|
390
|
+
"types": "./src/build/build-contracts.d.ts",
|
|
391
|
+
"default": "./src/build/build-contracts.js"
|
|
392
|
+
},
|
|
393
|
+
"./build/production-build-cache.ts": {
|
|
394
|
+
"types": "./src/build/production-build-cache.d.ts",
|
|
395
|
+
"default": "./src/build/production-build-cache.js"
|
|
396
|
+
},
|
|
397
|
+
"./build/server-entry-build-cache.ts": {
|
|
398
|
+
"types": "./src/build/server-entry-build-cache.d.ts",
|
|
399
|
+
"default": "./src/build/server-entry-build-cache.js"
|
|
400
|
+
},
|
|
249
401
|
"./build/runtime-build-output-normalizer.ts": {
|
|
250
402
|
"types": "./src/build/runtime-build-output-normalizer.d.ts",
|
|
251
403
|
"default": "./src/build/runtime-build-output-normalizer.js"
|
|
@@ -258,6 +410,10 @@
|
|
|
258
410
|
"types": "./src/build/browser-runtime-plugin.d.ts",
|
|
259
411
|
"default": "./src/build/browser-runtime-plugin.js"
|
|
260
412
|
},
|
|
413
|
+
"./build/jsx-ownership-plugins.ts": {
|
|
414
|
+
"types": "./src/build/jsx-ownership-plugins.d.ts",
|
|
415
|
+
"default": "./src/build/jsx-ownership-plugins.js"
|
|
416
|
+
},
|
|
261
417
|
"./cache.ts": {
|
|
262
418
|
"types": "./src/cache/index.d.ts",
|
|
263
419
|
"default": "./src/cache/index.js"
|
|
@@ -266,6 +422,10 @@
|
|
|
266
422
|
"types": "./src/plugins/foreign-jsx-override-plugin.d.ts",
|
|
267
423
|
"default": "./src/plugins/foreign-jsx-override-plugin.js"
|
|
268
424
|
},
|
|
425
|
+
"./plugins/jsx-import-source.utils.ts": {
|
|
426
|
+
"types": "./src/plugins/jsx-import-source.utils.d.ts",
|
|
427
|
+
"default": "./src/plugins/jsx-import-source.utils.js"
|
|
428
|
+
},
|
|
269
429
|
"./html.ts": {
|
|
270
430
|
"import": "./src/utils/html.js",
|
|
271
431
|
"default": "./src/utils/html.js",
|
|
@@ -9,6 +9,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
11
|
import type { ApiHandler, ApiHandlerContext, ErrorHandler, Middleware, RouteOptions, StaticRoute, ViewLoader } from '../../types/public-types.js';
|
|
12
|
+
import type { EcopagesWebSocketHandler } from '../../types/public-types.js';
|
|
13
|
+
import { type EcopagesRuntimeLabel } from '../../dev/runtime-server-started-message.js';
|
|
12
14
|
import { type ReturnParseCliArgs } from '../../utils/parse-cli-args.js';
|
|
13
15
|
/**
|
|
14
16
|
* Runtime bootstrap options layered on top of the app config.
|
|
@@ -25,6 +27,21 @@ export interface ApplicationRuntimeOptions {
|
|
|
25
27
|
* adapter auto-detects a host module loader from the global scope.
|
|
26
28
|
*/
|
|
27
29
|
embedded?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* When true, full-page reload signaling is owned by the host dev server
|
|
32
|
+
* (for example Vite's `full-reload` websocket event) instead of the Ecopages
|
|
33
|
+
* client bridge.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated Prefer `devClientOwner: 'host'`.
|
|
36
|
+
*/
|
|
37
|
+
delegateBrowserReloadToHost?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Selects which layer injects browser dev-client bootstrap (HMR runtime, reload).
|
|
40
|
+
*
|
|
41
|
+
* `host` disables core injection and reload signaling so embedded hosts like
|
|
42
|
+
* Vite own the full dev-client surface.
|
|
43
|
+
*/
|
|
44
|
+
devClientOwner?: 'core' | 'host';
|
|
28
45
|
/**
|
|
29
46
|
* Explicit source module loader for request-time imports.
|
|
30
47
|
*
|
|
@@ -33,6 +50,18 @@ export interface ApplicationRuntimeOptions {
|
|
|
33
50
|
*/
|
|
34
51
|
hostModuleLoader?: SourceModuleLoader;
|
|
35
52
|
}
|
|
53
|
+
export interface AppStartInfo {
|
|
54
|
+
origin: string;
|
|
55
|
+
}
|
|
56
|
+
export type OnAppStartCallback = (info: AppStartInfo) => void;
|
|
57
|
+
/** @deprecated Use {@link AppStartInfo}. */
|
|
58
|
+
export type ApplicationListeningInfo = AppStartInfo;
|
|
59
|
+
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
60
|
+
export type StartCallback = OnAppStartCallback;
|
|
61
|
+
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
62
|
+
export type ListenCallback = OnAppStartCallback;
|
|
63
|
+
/** @deprecated Use {@link OnAppStartCallback}. */
|
|
64
|
+
export type ApplicationListeningCallback = OnAppStartCallback;
|
|
36
65
|
/**
|
|
37
66
|
* Configuration options for application adapters
|
|
38
67
|
*/
|
|
@@ -49,8 +78,12 @@ export interface ApplicationAdapterOptions {
|
|
|
49
78
|
/**
|
|
50
79
|
* Common interface for application adapters
|
|
51
80
|
*/
|
|
52
|
-
export interface ApplicationAdapter<T = any> {
|
|
53
|
-
|
|
81
|
+
export interface ApplicationAdapter<T = any> extends AsyncDisposable {
|
|
82
|
+
/** Boot the server. Pass a callback to run when the runtime is ready (optional). */
|
|
83
|
+
start(onAppStart?: OnAppStartCallback): Promise<T | void>;
|
|
84
|
+
/** Invoked by embedded hosts once the app can take traffic. */
|
|
85
|
+
handleListening(origin: string): void;
|
|
86
|
+
stop(force?: boolean): Promise<void>;
|
|
54
87
|
}
|
|
55
88
|
/**
|
|
56
89
|
* Handler function type for route handlers
|
|
@@ -72,7 +105,14 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
72
105
|
protected apiHandlers: ApiHandler[];
|
|
73
106
|
protected staticRoutes: StaticRoute[];
|
|
74
107
|
protected errorHandler?: ErrorHandler;
|
|
75
|
-
|
|
108
|
+
/**
|
|
109
|
+
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
110
|
+
* Both Bun and Node adapters read this map to register upgrade routes.
|
|
111
|
+
*/
|
|
112
|
+
protected websocketHandlers: Map<string, EcopagesWebSocketHandler<any, any>>;
|
|
113
|
+
private onAppStartCallback?;
|
|
114
|
+
protected readonly runtimeLabel: EcopagesRuntimeLabel;
|
|
115
|
+
constructor(options: TOptions, runtimeLabel: EcopagesRuntimeLabel);
|
|
76
116
|
private clearDistFolder;
|
|
77
117
|
/**
|
|
78
118
|
* Register a GET route handler.
|
|
@@ -160,6 +200,46 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
160
200
|
* Get all registered static routes
|
|
161
201
|
*/
|
|
162
202
|
getStaticRoutes(): StaticRoute[];
|
|
203
|
+
/**
|
|
204
|
+
* Register a WebSocket handler for the given path pattern.
|
|
205
|
+
*
|
|
206
|
+
* The runtime adapter handles the HTTP→WebSocket upgrade for this path
|
|
207
|
+
* and routes lifecycle events to `handler`.
|
|
208
|
+
*
|
|
209
|
+
* Supports dynamic segments via `:param` syntax. The handler receives
|
|
210
|
+
* typed `params` and `search` fields, and a typed `context` produced by
|
|
211
|
+
* the optional `context()` factory.
|
|
212
|
+
*
|
|
213
|
+
* One pattern registration matches infinite path variations. For example,
|
|
214
|
+
* `app.websocket('/ws/chat/:roomId', handler)` matches `/ws/chat/abc`,
|
|
215
|
+
* `/ws/chat/xyz`, etc. Each connection receives its own `params.roomId`.
|
|
216
|
+
*
|
|
217
|
+
* Works across both Bun and Node runtimes — no runtime-specific imports needed.
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* app.websocket<ChatContext, { roomId: string }>('/ws/chat/:roomId', {
|
|
222
|
+
* async context({ params, search }) {
|
|
223
|
+
* return { username: search.username ?? 'anonymous', roomId: params.roomId };
|
|
224
|
+
* },
|
|
225
|
+
* onConnect(socket) {
|
|
226
|
+
* socket.send(`Welcome to room ${socket.context.roomId}`);
|
|
227
|
+
* },
|
|
228
|
+
* onMessage(socket, message) {
|
|
229
|
+
* if (message.kind === 'text') {
|
|
230
|
+
* socket.send(message.text);
|
|
231
|
+
* }
|
|
232
|
+
* },
|
|
233
|
+
* });
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
websocket<TContext = unknown, TParams extends Record<string, string> = Record<string, string>>(path: string, handler: EcopagesWebSocketHandler<TContext, TParams>): this;
|
|
237
|
+
/**
|
|
238
|
+
* Get the registered WebSocket handlers map.
|
|
239
|
+
*
|
|
240
|
+
* @returns The map of WebSocket route patterns to handlers
|
|
241
|
+
*/
|
|
242
|
+
getWebsocketHandlers(): Map<string, EcopagesWebSocketHandler<any, any>>;
|
|
163
243
|
/**
|
|
164
244
|
* Register a global error handler for all routes.
|
|
165
245
|
* Useful for logging, monitoring integration, and custom error formatting.
|
|
@@ -182,9 +262,28 @@ export declare abstract class AbstractApplicationAdapter<TOptions extends Applic
|
|
|
182
262
|
*/
|
|
183
263
|
protected abstract initializeServerAdapter(): Promise<any>;
|
|
184
264
|
/**
|
|
185
|
-
*
|
|
265
|
+
* Boot the server. When `onAppStart` is passed, it runs once the runtime can take traffic.
|
|
266
|
+
* Embedded apps only register the callback — the host (for example Vite) boots the port.
|
|
267
|
+
*/
|
|
268
|
+
start(onAppStart?: OnAppStartCallback): Promise<TServer | void>;
|
|
269
|
+
/** Runtime-specific server boot (dev, preview, build). */
|
|
270
|
+
protected abstract bootServer(): Promise<TServer | void>;
|
|
271
|
+
protected logServerStarted(origin: string): void;
|
|
272
|
+
/**
|
|
273
|
+
* Invoked by embedded hosts (for example Vite) once the app can take traffic.
|
|
274
|
+
*/
|
|
275
|
+
handleListening(origin: string): void;
|
|
276
|
+
protected notifyListening(origin: string): void;
|
|
277
|
+
/**
|
|
278
|
+
* Stops the application server and releases runtime resources.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* Subclasses override this to shut down bound servers, watchers, and other
|
|
282
|
+
* dev-time resources. The default implementation is a no-op so embedded
|
|
283
|
+
* adapters that never call `start()` can still be used with `await using`.
|
|
186
284
|
*/
|
|
187
|
-
|
|
285
|
+
stop(_force?: boolean): Promise<void>;
|
|
286
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
188
287
|
/**
|
|
189
288
|
* Handles a standard Web request without requiring a bound network server.
|
|
190
289
|
* This is the primary interoperability surface for embedding Ecopages inside
|
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
import { getHostModuleLoader } from "../../services/module-loading/host-module-loader-registry.js";
|
|
7
7
|
import { invariant } from "../../utils/invariant.js";
|
|
8
8
|
import { fileSystem } from "@ecopages/file-system";
|
|
9
|
+
import {
|
|
10
|
+
formatRuntimeServerStartedMessage
|
|
11
|
+
} from "../../dev/runtime-server-started-message.js";
|
|
9
12
|
import { parseCliArgs } from "../../utils/parse-cli-args.js";
|
|
10
13
|
class AbstractApplicationAdapter {
|
|
11
14
|
appConfig;
|
|
@@ -15,10 +18,24 @@ class AbstractApplicationAdapter {
|
|
|
15
18
|
apiHandlers = [];
|
|
16
19
|
staticRoutes = [];
|
|
17
20
|
errorHandler;
|
|
18
|
-
|
|
21
|
+
/**
|
|
22
|
+
* App-level WebSocket handlers keyed by URL path pattern (e.g. '/ws/chat/:id').
|
|
23
|
+
* Both Bun and Node adapters read this map to register upgrade routes.
|
|
24
|
+
*/
|
|
25
|
+
websocketHandlers = /* @__PURE__ */ new Map();
|
|
26
|
+
onAppStartCallback;
|
|
27
|
+
runtimeLabel;
|
|
28
|
+
constructor(options, runtimeLabel) {
|
|
29
|
+
this.runtimeLabel = runtimeLabel;
|
|
19
30
|
this.appConfig = options.appConfig;
|
|
20
31
|
this.serverOptions = options.serverOptions || {};
|
|
21
32
|
this.runtimeOptions = options.runtime ?? {};
|
|
33
|
+
if (options.runtime) {
|
|
34
|
+
this.appConfig.runtime = {
|
|
35
|
+
...this.appConfig.runtime ?? {},
|
|
36
|
+
...options.runtime
|
|
37
|
+
};
|
|
38
|
+
}
|
|
22
39
|
this.cliArgs = parseCliArgs({ embeddedRuntime: this.runtimeOptions.embedded });
|
|
23
40
|
const hostModuleLoader = this.runtimeOptions.hostModuleLoader ?? (this.runtimeOptions.embedded ? getHostModuleLoader() : void 0);
|
|
24
41
|
if (hostModuleLoader) {
|
|
@@ -93,6 +110,71 @@ class AbstractApplicationAdapter {
|
|
|
93
110
|
getStaticRoutes() {
|
|
94
111
|
return this.staticRoutes;
|
|
95
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Register a WebSocket handler for the given path pattern.
|
|
115
|
+
*
|
|
116
|
+
* The runtime adapter handles the HTTP→WebSocket upgrade for this path
|
|
117
|
+
* and routes lifecycle events to `handler`.
|
|
118
|
+
*
|
|
119
|
+
* Supports dynamic segments via `:param` syntax. The handler receives
|
|
120
|
+
* typed `params` and `search` fields, and a typed `context` produced by
|
|
121
|
+
* the optional `context()` factory.
|
|
122
|
+
*
|
|
123
|
+
* One pattern registration matches infinite path variations. For example,
|
|
124
|
+
* `app.websocket('/ws/chat/:roomId', handler)` matches `/ws/chat/abc`,
|
|
125
|
+
* `/ws/chat/xyz`, etc. Each connection receives its own `params.roomId`.
|
|
126
|
+
*
|
|
127
|
+
* Works across both Bun and Node runtimes — no runtime-specific imports needed.
|
|
128
|
+
*
|
|
129
|
+
* @example
|
|
130
|
+
* ```typescript
|
|
131
|
+
* app.websocket<ChatContext, { roomId: string }>('/ws/chat/:roomId', {
|
|
132
|
+
* async context({ params, search }) {
|
|
133
|
+
* return { username: search.username ?? 'anonymous', roomId: params.roomId };
|
|
134
|
+
* },
|
|
135
|
+
* onConnect(socket) {
|
|
136
|
+
* socket.send(`Welcome to room ${socket.context.roomId}`);
|
|
137
|
+
* },
|
|
138
|
+
* onMessage(socket, message) {
|
|
139
|
+
* if (message.kind === 'text') {
|
|
140
|
+
* socket.send(message.text);
|
|
141
|
+
* }
|
|
142
|
+
* },
|
|
143
|
+
* });
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
websocket(path, handler) {
|
|
147
|
+
invariant(
|
|
148
|
+
typeof path === "string" && path.startsWith("/"),
|
|
149
|
+
`app.websocket(): path must be a string starting with "/", got "${path}".`
|
|
150
|
+
);
|
|
151
|
+
const segments = path.split("/").filter(Boolean);
|
|
152
|
+
const paramNames = /* @__PURE__ */ new Set();
|
|
153
|
+
for (const segment of segments) {
|
|
154
|
+
if (segment.startsWith(":")) {
|
|
155
|
+
const paramName = segment.slice(1);
|
|
156
|
+
invariant(
|
|
157
|
+
paramName.length > 0,
|
|
158
|
+
`app.websocket(): invalid pattern "${path}" \u2014 empty param name in segment ":${paramName}".`
|
|
159
|
+
);
|
|
160
|
+
invariant(
|
|
161
|
+
!paramNames.has(paramName),
|
|
162
|
+
`app.websocket(): invalid pattern "${path}" \u2014 duplicate param name ":${paramName}".`
|
|
163
|
+
);
|
|
164
|
+
paramNames.add(paramName);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
this.websocketHandlers.set(path, handler);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Get the registered WebSocket handlers map.
|
|
172
|
+
*
|
|
173
|
+
* @returns The map of WebSocket route patterns to handlers
|
|
174
|
+
*/
|
|
175
|
+
getWebsocketHandlers() {
|
|
176
|
+
return this.websocketHandlers;
|
|
177
|
+
}
|
|
96
178
|
/**
|
|
97
179
|
* Register a global error handler for all routes.
|
|
98
180
|
* Useful for logging, monitoring integration, and custom error formatting.
|
|
@@ -115,6 +197,48 @@ class AbstractApplicationAdapter {
|
|
|
115
197
|
getErrorHandler() {
|
|
116
198
|
return this.errorHandler;
|
|
117
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Boot the server. When `onAppStart` is passed, it runs once the runtime can take traffic.
|
|
202
|
+
* Embedded apps only register the callback — the host (for example Vite) boots the port.
|
|
203
|
+
*/
|
|
204
|
+
async start(onAppStart) {
|
|
205
|
+
if (onAppStart) {
|
|
206
|
+
this.onAppStartCallback = onAppStart;
|
|
207
|
+
}
|
|
208
|
+
if (this.runtimeOptions.embedded) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
return this.bootServer();
|
|
212
|
+
}
|
|
213
|
+
logServerStarted(origin) {
|
|
214
|
+
appLogger.info(formatRuntimeServerStartedMessage(this.runtimeLabel, origin));
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Invoked by embedded hosts (for example Vite) once the app can take traffic.
|
|
218
|
+
*/
|
|
219
|
+
handleListening(origin) {
|
|
220
|
+
this.notifyListening(origin);
|
|
221
|
+
}
|
|
222
|
+
notifyListening(origin) {
|
|
223
|
+
const normalizedOrigin = origin.replace(/\/$/, "");
|
|
224
|
+
if (!this.onAppStartCallback) {
|
|
225
|
+
this.logServerStarted(normalizedOrigin);
|
|
226
|
+
}
|
|
227
|
+
this.onAppStartCallback?.({ origin: normalizedOrigin });
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Stops the application server and releases runtime resources.
|
|
231
|
+
*
|
|
232
|
+
* @remarks
|
|
233
|
+
* Subclasses override this to shut down bound servers, watchers, and other
|
|
234
|
+
* dev-time resources. The default implementation is a no-op so embedded
|
|
235
|
+
* adapters that never call `start()` can still be used with `await using`.
|
|
236
|
+
*/
|
|
237
|
+
async stop(_force = true) {
|
|
238
|
+
}
|
|
239
|
+
async [Symbol.asyncDispose]() {
|
|
240
|
+
await this.stop(true);
|
|
241
|
+
}
|
|
118
242
|
}
|
|
119
243
|
export {
|
|
120
244
|
AbstractApplicationAdapter
|
|
@@ -31,7 +31,10 @@ export interface ServerAdapterResult {
|
|
|
31
31
|
}) => any;
|
|
32
32
|
buildStatic: (options?: {
|
|
33
33
|
preview?: boolean;
|
|
34
|
-
|
|
34
|
+
force?: boolean;
|
|
35
|
+
}) => Promise<string | undefined>;
|
|
36
|
+
servePreviewOnly: () => Promise<string | undefined>;
|
|
37
|
+
dispose(): Promise<void>;
|
|
35
38
|
}
|
|
36
39
|
/**
|
|
37
40
|
* Abstract base class for server adapters across different runtimes
|
|
@@ -57,7 +60,8 @@ export declare abstract class AbstractServerAdapter<TOptions extends ServerAdapt
|
|
|
57
60
|
*/
|
|
58
61
|
abstract buildStatic(options?: {
|
|
59
62
|
preview?: boolean;
|
|
60
|
-
|
|
63
|
+
force?: boolean;
|
|
64
|
+
}): Promise<string | undefined>;
|
|
61
65
|
/**
|
|
62
66
|
* Factory method to create a server adapter with runtime-specific functionality
|
|
63
67
|
*/
|