@ecopages/core 0.2.0-alpha.9 → 0.2.1
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/CHANGELOG.md +18 -11
- package/README.md +23 -26
- package/package.json +76 -58
- package/src/adapters/README.md +2 -2
- package/src/adapters/abstract/application-adapter.d.ts +28 -2
- package/src/adapters/abstract/application-adapter.js +14 -2
- package/src/adapters/abstract/router-adapter.d.ts +1 -1
- package/src/adapters/abstract/server-adapter.d.ts +2 -2
- package/src/adapters/bun/client-bridge.d.ts +1 -1
- package/src/adapters/bun/create-app.d.ts +4 -12
- package/src/adapters/bun/create-app.js +4 -5
- package/src/adapters/bun/hmr-manager.d.ts +4 -4
- package/src/adapters/bun/hmr-manager.js +8 -8
- package/src/adapters/bun/index.d.ts +1 -1
- package/src/adapters/bun/index.js +2 -2
- package/src/adapters/bun/server-adapter.d.ts +5 -5
- package/src/adapters/bun/server-adapter.js +6 -5
- package/src/adapters/bun/server-lifecycle.d.ts +4 -4
- package/src/adapters/bun/server-lifecycle.js +2 -2
- package/src/{create-app.d.ts → adapters/create-app.d.ts} +9 -6
- package/src/{create-app.js → adapters/create-app.js} +4 -4
- package/src/adapters/index.d.ts +1 -5
- package/src/adapters/index.js +1 -7
- package/src/adapters/node/create-app.d.ts +6 -9
- package/src/adapters/node/create-app.js +12 -6
- package/src/adapters/node/node-client-bridge.d.ts +1 -1
- package/src/adapters/node/node-hmr-manager.d.ts +2 -2
- package/src/adapters/node/node-hmr-manager.js +3 -3
- package/src/adapters/node/server-adapter.d.ts +4 -4
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/node/static-content-server.d.ts +1 -1
- package/src/adapters/node/static-content-server.js +1 -1
- package/src/adapters/shared/application-adapter.d.ts +1 -1
- package/src/adapters/shared/define-api-handler.d.ts +1 -1
- package/src/adapters/shared/explicit-static-route-matcher.d.ts +2 -2
- package/src/adapters/shared/file-route-middleware-pipeline.d.ts +1 -1
- package/src/adapters/shared/fs-server-response-factory.d.ts +2 -2
- package/src/adapters/shared/fs-server-response-factory.js +1 -1
- package/src/adapters/shared/fs-server-response-matcher.d.ts +1 -1
- package/src/adapters/shared/hmr-entrypoint-registrar.js +1 -1
- package/src/adapters/shared/hmr-html-response.d.ts +1 -1
- package/src/adapters/shared/render-context.d.ts +2 -1
- package/src/adapters/shared/render-context.js +3 -1
- package/src/adapters/shared/runtime-bootstrap.d.ts +1 -1
- package/src/adapters/shared/runtime-bootstrap.js +1 -1
- package/src/adapters/shared/server-adapter.d.ts +1 -1
- package/src/adapters/shared/server-adapter.js +5 -1
- package/src/adapters/shared/server-route-handler.d.ts +4 -4
- package/src/adapters/shared/server-route-handler.js +3 -3
- package/src/adapters/shared/server-static-builder.d.ts +5 -5
- package/src/adapters/shared/server-static-builder.js +5 -4
- package/src/build/README.md +19 -13
- package/src/build/build-adapter.d.ts +67 -20
- package/src/build/build-adapter.js +420 -19
- package/src/build/dev-build-coordinator.d.ts +10 -12
- package/src/build/dev-build-coordinator.js +8 -15
- package/src/build/esbuild-build-adapter.d.ts +6 -0
- package/src/build/esbuild-build-adapter.js +94 -11
- package/src/build/runtime-build-executor.d.ts +5 -4
- package/src/build/runtime-build-executor.js +5 -3
- package/src/build/runtime-specifier-alias-plugin.js +19 -15
- package/src/build/runtime-specifier-aliases.d.ts +5 -0
- package/src/build/runtime-specifier-aliases.js +95 -0
- package/src/config/README.md +5 -2
- package/src/config/config-builder.d.ts +25 -2
- package/src/config/config-builder.js +44 -7
- package/src/declarations.d.ts +1 -1
- package/src/dev/sc-server.d.ts +1 -1
- package/src/dev/sc-server.js +1 -1
- package/src/eco/eco.browser.d.ts +2 -0
- package/src/eco/eco.browser.js +83 -0
- package/src/eco/eco.js +19 -48
- package/src/eco/eco.types.d.ts +1 -1
- package/src/eco/eco.utils.d.ts +1 -40
- package/src/eco/eco.utils.js +5 -35
- package/src/eco/global-injector-map.d.ts +1 -1
- package/src/eco/lazy-injector-map.d.ts +1 -1
- package/src/hmr/hmr-strategy.d.ts +16 -13
- package/src/hmr/hmr-strategy.js +22 -7
- package/src/hmr/strategies/default-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/default-hmr-strategy.js +1 -1
- package/src/hmr/strategies/js-hmr-strategy.d.ts +2 -2
- package/src/hmr/strategies/js-hmr-strategy.js +2 -2
- package/src/index.browser.d.ts +2 -2
- package/src/index.browser.js +1 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +15 -4
- package/src/integrations/ghtml/ghtml-renderer.d.ts +6 -1
- package/src/integrations/ghtml/ghtml-renderer.js +29 -28
- package/src/integrations/ghtml/ghtml.plugin.d.ts +2 -2
- package/src/integrations/ghtml/ghtml.plugin.js +2 -2
- package/src/plugins/README.md +1 -0
- package/src/plugins/eco-component-meta-plugin.d.ts +12 -1
- package/src/plugins/eco-component-meta-plugin.js +26 -20
- package/src/plugins/foreign-jsx-override-plugin.d.ts +31 -0
- package/src/plugins/foreign-jsx-override-plugin.js +35 -0
- package/src/plugins/integration-plugin.d.ts +99 -33
- package/src/plugins/integration-plugin.js +68 -21
- package/src/plugins/processor.d.ts +2 -2
- package/src/plugins/processor.js +2 -2
- package/src/plugins/source-transform.d.ts +46 -0
- package/src/plugins/source-transform.js +71 -0
- package/src/route-renderer/GRAPH.md +54 -84
- package/src/route-renderer/README.md +14 -20
- package/src/route-renderer/orchestration/component-render-context.d.ts +83 -0
- package/src/route-renderer/orchestration/component-render-context.js +147 -0
- package/src/route-renderer/orchestration/integration-renderer.d.ts +233 -76
- package/src/route-renderer/orchestration/integration-renderer.js +500 -143
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.d.ts +93 -0
- package/src/route-renderer/orchestration/queued-boundary-runtime.service.js +155 -0
- package/src/route-renderer/orchestration/render-execution.service.d.ts +11 -71
- package/src/route-renderer/orchestration/render-execution.service.js +65 -80
- package/src/{eco/eco.utils.ts → route-renderer/orchestration/render-output.utils.d.ts} +10 -53
- package/src/route-renderer/orchestration/render-output.utils.js +65 -0
- package/src/route-renderer/orchestration/render-preparation.service.d.ts +2 -8
- package/src/route-renderer/orchestration/render-preparation.service.js +10 -17
- package/src/route-renderer/orchestration/template-serialization.d.ts +38 -0
- package/src/route-renderer/orchestration/template-serialization.js +45 -0
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +2 -2
- package/src/route-renderer/page-loading/dependency-resolver.js +10 -8
- package/src/route-renderer/page-loading/page-module-loader.d.ts +6 -4
- package/src/route-renderer/page-loading/page-module-loader.js +7 -5
- package/src/route-renderer/route-renderer.d.ts +5 -3
- package/src/route-renderer/route-renderer.js +13 -3
- package/src/router/README.md +79 -8
- package/src/router/client/navigation-coordinator.js +2 -2
- package/src/router/server/fs-router-scanner.d.ts +1 -1
- package/src/router/server/fs-router-scanner.js +6 -1
- package/src/router/server/fs-router.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset-processing.service.d.ts +3 -3
- package/src/services/assets/asset-processing-service/asset-processing.service.js +6 -6
- package/src/services/assets/asset-processing-service/asset.factory.d.ts +1 -1
- package/src/services/assets/asset-processing-service/asset.factory.js +2 -2
- package/src/services/assets/asset-processing-service/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/index.js +5 -5
- package/src/services/assets/asset-processing-service/processor.interface.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processor.registry.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/base/base-processor.d.ts +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.js +2 -2
- package/src/services/assets/asset-processing-service/processors/index.d.ts +5 -5
- package/src/services/assets/asset-processing-service/processors/index.js +5 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.d.ts +4 -3
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.js +15 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.d.ts +3 -3
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +1 -1
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +2 -2
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +1 -1
- package/src/services/assets/browser-bundle.service.d.ts +1 -1
- package/src/services/assets/browser-bundle.service.js +2 -2
- package/src/services/html/html-rewriter-provider.service.js +4 -1
- package/src/services/html/html-transformer.service.d.ts +2 -2
- package/src/services/html/html-transformer.service.js +4 -10
- package/src/services/invalidation/development-invalidation.service.d.ts +1 -1
- package/src/services/invalidation/development-invalidation.service.js +1 -0
- package/src/services/module-loading/app-module-loader.service.d.ts +25 -0
- package/src/services/module-loading/app-module-loader.service.js +31 -0
- package/src/services/module-loading/app-server-module-transpiler.service.d.ts +9 -1
- package/src/services/module-loading/app-server-module-transpiler.service.js +77 -2
- package/src/services/module-loading/host-module-loader-registry.d.ts +4 -0
- package/src/services/module-loading/host-module-loader-registry.js +15 -0
- package/src/services/module-loading/module-loading-types.d.ts +2 -0
- package/src/{adapters/node/bootstrap-dependency-resolver.d.ts → services/module-loading/node-bootstrap-plugin.d.ts} +2 -24
- package/src/{adapters/node/bootstrap-dependency-resolver.js → services/module-loading/node-bootstrap-plugin.js} +42 -22
- package/src/services/module-loading/page-module-import.service.d.ts +4 -0
- package/src/services/module-loading/page-module-import.service.js +38 -9
- package/src/services/module-loading/server-module-transpiler.service.d.ts +3 -0
- package/src/services/module-loading/server-module-transpiler.service.js +4 -1
- package/src/services/runtime-state/dev-graph.service.d.ts +6 -6
- package/src/services/runtime-state/dev-graph.service.js +10 -10
- package/src/services/runtime-state/entrypoint-dependency-graph.service.d.ts +1 -1
- package/src/services/runtime-state/runtime-specifier-registry.service.d.ts +1 -1
- package/src/services/runtime-state/server-invalidation-state.service.d.ts +1 -1
- package/src/static-site-generator/static-site-generator.d.ts +2 -2
- package/src/static-site-generator/static-site-generator.js +1 -1
- package/src/{internal-types.d.ts → types/internal-types.d.ts} +24 -14
- package/src/{public-types.d.ts → types/public-types.d.ts} +30 -14
- package/src/types/public-types.js +0 -0
- package/src/utils/html-escaping.d.ts +7 -0
- package/src/utils/html-escaping.js +6 -0
- package/src/utils/locals-utils.d.ts +1 -1
- package/src/utils/parse-cli-args.d.ts +4 -1
- package/src/utils/parse-cli-args.js +16 -1
- package/src/utils/resolve-work-dir.js +1 -1
- package/src/watchers/project-watcher.d.ts +4 -4
- package/src/watchers/project-watcher.js +4 -10
- package/src/watchers/project-watcher.test-helpers.d.ts +2 -2
- package/src/adapters/abstract/application-adapter.ts +0 -337
- package/src/adapters/abstract/router-adapter.ts +0 -30
- package/src/adapters/abstract/server-adapter.ts +0 -79
- package/src/adapters/bun/client-bridge.ts +0 -62
- package/src/adapters/bun/create-app.ts +0 -189
- package/src/adapters/bun/hmr-manager.ts +0 -409
- package/src/adapters/bun/index.ts +0 -2
- package/src/adapters/bun/server-adapter.ts +0 -499
- package/src/adapters/bun/server-lifecycle.ts +0 -124
- package/src/adapters/index.ts +0 -6
- package/src/adapters/node/bootstrap-dependency-resolver.ts +0 -301
- package/src/adapters/node/create-app.ts +0 -179
- package/src/adapters/node/index.d.ts +0 -6
- package/src/adapters/node/index.js +0 -11
- package/src/adapters/node/index.ts +0 -16
- package/src/adapters/node/node-client-bridge.ts +0 -79
- package/src/adapters/node/node-hmr-manager.ts +0 -381
- package/src/adapters/node/runtime-adapter.d.ts +0 -46
- package/src/adapters/node/runtime-adapter.js +0 -306
- package/src/adapters/node/runtime-adapter.ts +0 -439
- package/src/adapters/node/server-adapter.ts +0 -488
- package/src/adapters/node/static-content-server.ts +0 -239
- package/src/adapters/node/write-runtime-manifest.d.ts +0 -26
- package/src/adapters/node/write-runtime-manifest.js +0 -12
- package/src/adapters/node/write-runtime-manifest.ts +0 -38
- package/src/adapters/shared/api-response.ts +0 -104
- package/src/adapters/shared/application-adapter.ts +0 -199
- package/src/adapters/shared/define-api-handler.ts +0 -66
- package/src/adapters/shared/explicit-static-route-matcher.ts +0 -140
- package/src/adapters/shared/file-route-middleware-pipeline.ts +0 -127
- package/src/adapters/shared/fs-server-response-factory.ts +0 -118
- package/src/adapters/shared/fs-server-response-matcher.ts +0 -205
- package/src/adapters/shared/hmr-entrypoint-registrar.ts +0 -149
- package/src/adapters/shared/hmr-html-response.ts +0 -52
- package/src/adapters/shared/render-context.ts +0 -120
- package/src/adapters/shared/runtime-bootstrap.ts +0 -79
- package/src/adapters/shared/server-adapter.ts +0 -489
- package/src/adapters/shared/server-route-handler.ts +0 -153
- package/src/adapters/shared/server-static-builder.ts +0 -166
- package/src/build/build-adapter.ts +0 -361
- package/src/build/build-manifest.ts +0 -54
- package/src/build/build-types.ts +0 -83
- package/src/build/dev-build-coordinator.ts +0 -221
- package/src/build/esbuild-build-adapter.ts +0 -559
- package/src/build/runtime-build-executor.ts +0 -34
- package/src/build/runtime-specifier-alias-plugin.ts +0 -58
- package/src/config/config-builder.ts +0 -706
- package/src/constants.ts +0 -54
- package/src/create-app.ts +0 -87
- package/src/dev/sc-server.ts +0 -143
- package/src/eco/component-render-context.d.ts +0 -105
- package/src/eco/component-render-context.js +0 -87
- package/src/eco/component-render-context.ts +0 -224
- package/src/eco/eco.ts +0 -242
- package/src/eco/eco.types.ts +0 -221
- package/src/eco/global-injector-map.ts +0 -112
- package/src/eco/lazy-injector-map.ts +0 -120
- package/src/eco/module-dependencies.ts +0 -75
- package/src/errors/http-error.ts +0 -72
- package/src/errors/index.ts +0 -2
- package/src/errors/locals-access-error.ts +0 -7
- package/src/global/app-logger.ts +0 -4
- package/src/hmr/client/hmr-runtime.ts +0 -152
- package/src/hmr/hmr-strategy.ts +0 -172
- package/src/hmr/hmr.postcss.test.e2e.ts +0 -41
- package/src/hmr/hmr.test.e2e.ts +0 -66
- package/src/hmr/strategies/default-hmr-strategy.ts +0 -60
- package/src/hmr/strategies/js-hmr-strategy.ts +0 -320
- package/src/index.browser.ts +0 -3
- package/src/index.ts +0 -5
- package/src/integrations/ghtml/ghtml-renderer.ts +0 -96
- package/src/integrations/ghtml/ghtml.plugin.ts +0 -32
- package/src/internal-types.ts +0 -232
- package/src/plugins/alias-resolver-plugin.ts +0 -63
- package/src/plugins/eco-component-meta-plugin.ts +0 -481
- package/src/plugins/integration-plugin.ts +0 -226
- package/src/plugins/processor.ts +0 -240
- package/src/plugins/runtime-capability.ts +0 -14
- package/src/public-types.ts +0 -1317
- package/src/route-renderer/component-graph/component-graph-executor.d.ts +0 -32
- package/src/route-renderer/component-graph/component-graph-executor.js +0 -31
- package/src/route-renderer/component-graph/component-graph-executor.ts +0 -84
- package/src/route-renderer/component-graph/component-graph.d.ts +0 -42
- package/src/route-renderer/component-graph/component-graph.js +0 -72
- package/src/route-renderer/component-graph/component-graph.ts +0 -159
- package/src/route-renderer/component-graph/component-marker.d.ts +0 -52
- package/src/route-renderer/component-graph/component-marker.js +0 -46
- package/src/route-renderer/component-graph/component-marker.ts +0 -117
- package/src/route-renderer/component-graph/component-reference.d.ts +0 -10
- package/src/route-renderer/component-graph/component-reference.js +0 -19
- package/src/route-renderer/component-graph/component-reference.ts +0 -29
- package/src/route-renderer/component-graph/marker-graph-resolver.d.ts +0 -77
- package/src/route-renderer/component-graph/marker-graph-resolver.js +0 -95
- package/src/route-renderer/component-graph/marker-graph-resolver.ts +0 -155
- package/src/route-renderer/orchestration/integration-renderer.ts +0 -790
- package/src/route-renderer/orchestration/render-execution.service.ts +0 -230
- package/src/route-renderer/orchestration/render-preparation.service.ts +0 -476
- package/src/route-renderer/page-loading/dependency-resolver.ts +0 -612
- package/src/route-renderer/page-loading/page-module-loader.ts +0 -181
- package/src/route-renderer/route-renderer.ts +0 -115
- package/src/router/client/link-intent.test.browser.ts +0 -51
- package/src/router/client/link-intent.ts +0 -92
- package/src/router/client/navigation-coordinator.ts +0 -433
- package/src/router/server/fs-router-scanner.ts +0 -219
- package/src/router/server/fs-router.ts +0 -122
- package/src/services/assets/asset-processing-service/asset-processing.service.ts +0 -401
- package/src/services/assets/asset-processing-service/asset.factory.ts +0 -105
- package/src/services/assets/asset-processing-service/assets.types.ts +0 -113
- package/src/services/assets/asset-processing-service/browser-runtime-asset.factory.ts +0 -95
- package/src/services/assets/asset-processing-service/browser-runtime-entry.factory.ts +0 -78
- package/src/services/assets/asset-processing-service/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processor.interface.ts +0 -27
- package/src/services/assets/asset-processing-service/processor.registry.ts +0 -18
- package/src/services/assets/asset-processing-service/processors/base/base-processor.ts +0 -82
- package/src/services/assets/asset-processing-service/processors/base/base-script-processor.ts +0 -95
- package/src/services/assets/asset-processing-service/processors/index.ts +0 -5
- package/src/services/assets/asset-processing-service/processors/script/content-script.processor.ts +0 -66
- package/src/services/assets/asset-processing-service/processors/script/file-script.processor.ts +0 -88
- package/src/services/assets/asset-processing-service/processors/script/node-module-script.processor.ts +0 -85
- package/src/services/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.ts +0 -27
- package/src/services/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.ts +0 -80
- package/src/services/assets/browser-bundle.service.ts +0 -53
- package/src/services/cache/cache.types.ts +0 -126
- package/src/services/cache/index.ts +0 -18
- package/src/services/cache/memory-cache-store.ts +0 -130
- package/src/services/cache/page-cache-service.ts +0 -202
- package/src/services/cache/page-request-cache-coordinator.service.ts +0 -131
- package/src/services/html/html-rewriter-provider.service.ts +0 -103
- package/src/services/html/html-transformer.service.ts +0 -279
- package/src/services/invalidation/development-invalidation.service.ts +0 -261
- package/src/services/module-loading/app-server-module-transpiler.service.ts +0 -52
- package/src/services/module-loading/page-module-import.service.ts +0 -200
- package/src/services/module-loading/server-loader.service.d.ts +0 -96
- package/src/services/module-loading/server-loader.service.js +0 -32
- package/src/services/module-loading/server-loader.service.ts +0 -130
- package/src/services/module-loading/server-module-transpiler.service.ts +0 -105
- package/src/services/runtime-manifest/node-runtime-manifest.service.d.ts +0 -35
- package/src/services/runtime-manifest/node-runtime-manifest.service.js +0 -60
- package/src/services/runtime-manifest/node-runtime-manifest.service.ts +0 -101
- package/src/services/runtime-state/dev-graph.service.ts +0 -217
- package/src/services/runtime-state/entrypoint-dependency-graph.service.ts +0 -136
- package/src/services/runtime-state/runtime-specifier-registry.service.ts +0 -96
- package/src/services/runtime-state/server-invalidation-state.service.ts +0 -68
- package/src/services/validation/schema-validation-service.ts +0 -204
- package/src/services/validation/standard-schema.types.ts +0 -68
- package/src/static-site-generator/static-site-generator.ts +0 -462
- package/src/utils/css.d.ts +0 -1
- package/src/utils/css.js +0 -7
- package/src/utils/css.ts +0 -5
- package/src/utils/deep-merge.ts +0 -47
- package/src/utils/hash.ts +0 -5
- package/src/utils/html.ts +0 -1
- package/src/utils/invariant.ts +0 -15
- package/src/utils/locals-utils.ts +0 -37
- package/src/utils/parse-cli-args.ts +0 -83
- package/src/utils/path-utils.module.ts +0 -14
- package/src/utils/resolve-work-dir.ts +0 -45
- package/src/utils/runtime.ts +0 -44
- package/src/utils/server-utils.module.ts +0 -67
- package/src/watchers/project-watcher.test-helpers.ts +0 -41
- package/src/watchers/project-watcher.ts +0 -363
- /package/src/{constants.d.ts → config/constants.d.ts} +0 -0
- /package/src/{constants.js → config/constants.js} +0 -0
- /package/src/{internal-types.js → services/module-loading/module-loading-types.js} +0 -0
- /package/src/{public-types.js → types/internal-types.js} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { buildInjectorMapScript } from "../../eco/lazy-injector-map.js";
|
|
2
|
+
function isThenable(value) {
|
|
3
|
+
return typeof value === "object" && value !== null && "then" in value && typeof value.then === "function";
|
|
4
|
+
}
|
|
5
|
+
function addTriggerAttribute(content, triggerId) {
|
|
6
|
+
const str = String(content);
|
|
7
|
+
let i = 0;
|
|
8
|
+
while (i < str.length) {
|
|
9
|
+
if (str[i] !== "<") {
|
|
10
|
+
i++;
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
const next = str[i + 1];
|
|
14
|
+
if (next === "!" || next === "?") {
|
|
15
|
+
const end = str.indexOf(">", i);
|
|
16
|
+
if (end === -1) break;
|
|
17
|
+
i = end + 1;
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (next && /[a-zA-Z]/.test(next)) {
|
|
21
|
+
const tagSlice = str.slice(i + 1);
|
|
22
|
+
const nameEnd = tagSlice.search(/[\s/>]/);
|
|
23
|
+
if (nameEnd === -1) break;
|
|
24
|
+
const insertAt = i + 1 + nameEnd;
|
|
25
|
+
return `${str.slice(0, insertAt)} data-eco-trigger="${triggerId}"${str.slice(insertAt)}`;
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
return str;
|
|
30
|
+
}
|
|
31
|
+
function wrapWithScriptsInjector(content, lazyGroups) {
|
|
32
|
+
const wrappedContent = String(content);
|
|
33
|
+
const injectorMapScript = buildInjectorMapScript(lazyGroups ?? []);
|
|
34
|
+
return `<scripts-injector><script type="ecopages/injector-map">${injectorMapScript}<\/script>${wrappedContent}<\/scripts-injector>`;
|
|
35
|
+
}
|
|
36
|
+
function decodeHtmlEntities(value) {
|
|
37
|
+
let decoded = value;
|
|
38
|
+
let previous;
|
|
39
|
+
do {
|
|
40
|
+
previous = decoded;
|
|
41
|
+
decoded = decoded.replaceAll(""", '"').replaceAll("'", "'").replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
42
|
+
} while (decoded !== previous);
|
|
43
|
+
return decoded;
|
|
44
|
+
}
|
|
45
|
+
function normalizeBoundaryArtifactHtml(html) {
|
|
46
|
+
return html.replace(
|
|
47
|
+
/&(?:amp;)?lt;eco-marker\b[\s\S]*?&(?:amp;)?gt;&(?:amp;)?lt;\/eco-marker&(?:amp;)?gt;/g,
|
|
48
|
+
(marker) => decodeHtmlEntities(marker)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function inspectBoundaryArtifactHtml(html) {
|
|
52
|
+
const normalizedHtml = normalizeBoundaryArtifactHtml(html);
|
|
53
|
+
return {
|
|
54
|
+
normalizedHtml,
|
|
55
|
+
hasUnresolvedBoundaryArtifacts: normalizedHtml.includes("<eco-marker")
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
addTriggerAttribute,
|
|
60
|
+
decodeHtmlEntities,
|
|
61
|
+
inspectBoundaryArtifactHtml,
|
|
62
|
+
isThenable,
|
|
63
|
+
normalizeBoundaryArtifactHtml,
|
|
64
|
+
wrapWithScriptsInjector
|
|
65
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
2
|
-
import type { ComponentRenderResult, EcoComponent, EcoPageComponent, EcoPageFile, EcoPagesElement, GetMetadata, GetStaticProps, HtmlTemplateProps, IntegrationRendererRenderOptions, PageMetadataProps, RouteRendererOptions } from '../../public-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
2
|
+
import type { ComponentRenderResult, EcoComponent, EcoPageComponent, EcoPageFile, EcoPagesElement, GetMetadata, GetStaticProps, HtmlTemplateProps, IntegrationRendererRenderOptions, PageMetadataProps, RouteRendererOptions } from '../../types/public-types.js';
|
|
3
3
|
import { type AssetProcessingService, type ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
|
|
4
|
-
import { type ComponentRenderBoundaryContext } from '../../eco/component-render-context.js';
|
|
5
4
|
type ResolvedPageModule = {
|
|
6
5
|
Page: EcoPageFile['default'] | EcoPageComponent<any>;
|
|
7
6
|
getStaticProps?: GetStaticProps<Record<string, unknown>>;
|
|
@@ -29,11 +28,6 @@ export interface RenderPreparationCallbacks {
|
|
|
29
28
|
component: EcoComponent;
|
|
30
29
|
props: Record<string, unknown>;
|
|
31
30
|
}): Promise<ComponentRenderResult>;
|
|
32
|
-
/**
|
|
33
|
-
* Returns the boundary policy context that should be active while rendering
|
|
34
|
-
* page-root component output during preparation.
|
|
35
|
-
*/
|
|
36
|
-
getComponentRenderBoundaryContext(): ComponentRenderBoundaryContext;
|
|
37
31
|
setProcessedDependencies(dependencies: ProcessedAsset[]): void;
|
|
38
32
|
dedupeProcessedAssets(assets: ProcessedAsset[]): ProcessedAsset[];
|
|
39
33
|
createPageLocalsProxy(filePath: string): RouteRendererOptions['locals'];
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
2
4
|
import {
|
|
3
5
|
AssetFactory
|
|
4
6
|
} from "../../services/assets/asset-processing-service/index.js";
|
|
5
7
|
import { buildGlobalInjectorBootstrapContent, buildGlobalInjectorMapScript } from "../../eco/global-injector-map.js";
|
|
6
|
-
import {
|
|
7
|
-
runWithComponentRenderContext
|
|
8
|
-
} from "../../eco/component-render-context.js";
|
|
9
|
-
const coreRequire = createRequire(import.meta.url);
|
|
10
8
|
class RenderPreparationService {
|
|
11
9
|
appConfig;
|
|
12
10
|
assetProcessingService;
|
|
@@ -51,13 +49,13 @@ class RenderPreparationService {
|
|
|
51
49
|
const allDependencies = [...resolvedDependencies, ...usedIntegrationDependencies, ...pageDeps];
|
|
52
50
|
let componentRender;
|
|
53
51
|
if (callbacks.shouldRenderPageComponent({ Page, Layout, options: routeOptions })) {
|
|
54
|
-
|
|
55
|
-
currentIntegrationName,
|
|
52
|
+
const pageRootRender = await this.renderPageRoot({
|
|
56
53
|
Page,
|
|
57
54
|
props,
|
|
58
55
|
routeOptions,
|
|
59
56
|
callbacks
|
|
60
57
|
});
|
|
58
|
+
componentRender = pageRootRender.componentRender;
|
|
61
59
|
if (componentRender.assets?.length) {
|
|
62
60
|
allDependencies.push(...componentRender.assets);
|
|
63
61
|
}
|
|
@@ -195,12 +193,8 @@ class RenderPreparationService {
|
|
|
195
193
|
* @returns Structured component render result.
|
|
196
194
|
*/
|
|
197
195
|
async renderPageRoot(input) {
|
|
198
|
-
|
|
199
|
-
{
|
|
200
|
-
currentIntegration: input.currentIntegrationName,
|
|
201
|
-
boundaryContext: input.callbacks.getComponentRenderBoundaryContext()
|
|
202
|
-
},
|
|
203
|
-
async () => input.callbacks.renderPageComponent({
|
|
196
|
+
return {
|
|
197
|
+
componentRender: await input.callbacks.renderPageComponent({
|
|
204
198
|
component: input.Page,
|
|
205
199
|
props: {
|
|
206
200
|
...input.props,
|
|
@@ -208,8 +202,7 @@ class RenderPreparationService {
|
|
|
208
202
|
query: input.routeOptions.query || {}
|
|
209
203
|
}
|
|
210
204
|
})
|
|
211
|
-
|
|
212
|
-
return execution.value;
|
|
205
|
+
};
|
|
213
206
|
}
|
|
214
207
|
/**
|
|
215
208
|
* Builds the runtime assets needed to bootstrap global lazy trigger execution.
|
|
@@ -218,7 +211,7 @@ class RenderPreparationService {
|
|
|
218
211
|
* @returns Processed assets that should be merged into the final dependency set.
|
|
219
212
|
*/
|
|
220
213
|
async buildGlobalInjectorAssets(triggers, currentIntegrationName) {
|
|
221
|
-
const globalInjectorImportPath =
|
|
214
|
+
const globalInjectorImportPath = createRequire(import.meta.url).resolve("@ecopages/scripts-injector/global");
|
|
222
215
|
const globalInjectorRuntimeAsset = AssetFactory.createNodeModuleScript({
|
|
223
216
|
position: "head",
|
|
224
217
|
name: "ecopages-scripts-injector-global",
|
|
@@ -275,7 +268,7 @@ class RenderPreparationService {
|
|
|
275
268
|
visitedConfigs.add(config);
|
|
276
269
|
const componentFile = config.__eco?.file;
|
|
277
270
|
if (componentFile) {
|
|
278
|
-
const componentDir =
|
|
271
|
+
const componentDir = path.dirname(componentFile);
|
|
279
272
|
for (const script of config.dependencies?.scripts ?? []) {
|
|
280
273
|
if (typeof script === "string" || !script.lazy || script.ssr !== true) {
|
|
281
274
|
continue;
|
|
@@ -299,7 +292,7 @@ class RenderPreparationService {
|
|
|
299
292
|
if (!script.src) {
|
|
300
293
|
continue;
|
|
301
294
|
}
|
|
302
|
-
const resolvedPath =
|
|
295
|
+
const resolvedPath = path.resolve(componentDir, script.src);
|
|
303
296
|
const key = `file:${resolvedPath}:${JSON.stringify(attributes)}`;
|
|
304
297
|
if (seenKeys.has(key)) {
|
|
305
298
|
continue;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal template-result shape that core can serialize generically.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* Core intentionally models only the transport shape used during deferred
|
|
6
|
+
* cross-integration child passing: alternating static string segments plus
|
|
7
|
+
* interpolated runtime values. Concrete runtime markers that identify a given
|
|
8
|
+
* framework's template payload must stay outside core and be registered by the
|
|
9
|
+
* owning integration package.
|
|
10
|
+
*/
|
|
11
|
+
export type SerializableTemplateShape = {
|
|
12
|
+
strings: readonly string[];
|
|
13
|
+
values?: readonly unknown[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Integration-owned adapter that teaches core how to serialize one deferred
|
|
17
|
+
* template payload shape.
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* The separation here is intentional: core owns the HTML serialization logic,
|
|
21
|
+
* but integrations own runtime-shape detection. That keeps package-specific
|
|
22
|
+
* markers such as framework template sentinels out of core while still letting
|
|
23
|
+
* deferred children round-trip through mixed renderer boundaries.
|
|
24
|
+
*/
|
|
25
|
+
export type DeferredTemplateSerializer<TTemplate extends SerializableTemplateShape = SerializableTemplateShape> = {
|
|
26
|
+
matches(value: unknown): value is TTemplate;
|
|
27
|
+
serialize(template: TTemplate, serializeValue: (value: unknown) => string | undefined): string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Serializes a generic template shape into HTML.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* This handles only HTML reconstruction semantics: quoted attribute values,
|
|
34
|
+
* boolean attributes, and omission of client-only event or property bindings.
|
|
35
|
+
* It does not decide whether an arbitrary value belongs to a framework-specific
|
|
36
|
+
* template runtime; integrations must make that decision before delegating here.
|
|
37
|
+
*/
|
|
38
|
+
export declare function serializeTemplateShape(template: SerializableTemplateShape, serializeValue: (value: unknown) => string | undefined): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { escapeHtmlAttribute } from "../../utils/html-escaping.js";
|
|
2
|
+
const ATTRIBUTE_TAIL_PATTERN = /(\s+)([@.?!]?)([^\s"'<>/=`@.?!]+)=$/;
|
|
3
|
+
function getSerializableTemplateAttribute(stringPart) {
|
|
4
|
+
const match = ATTRIBUTE_TAIL_PATTERN.exec(stringPart);
|
|
5
|
+
if (!match) return void 0;
|
|
6
|
+
return {
|
|
7
|
+
leading: stringPart.slice(0, match.index),
|
|
8
|
+
whitespace: match[1],
|
|
9
|
+
prefix: match[2],
|
|
10
|
+
name: match[3]
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function serializeTemplateShape(template, serializeValue) {
|
|
14
|
+
const values = template.values ?? [];
|
|
15
|
+
let html = "";
|
|
16
|
+
for (let index = 0; index < values.length; index += 1) {
|
|
17
|
+
const stringPart = template.strings[index] ?? "";
|
|
18
|
+
const serializedValue = serializeValue(values[index]);
|
|
19
|
+
const attribute = getSerializableTemplateAttribute(stringPart);
|
|
20
|
+
if (!attribute) {
|
|
21
|
+
html += stringPart;
|
|
22
|
+
html += serializedValue ?? "";
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
html += attribute.leading;
|
|
26
|
+
if (attribute.prefix === "@" || attribute.prefix === "!" || attribute.prefix === ".") {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (attribute.prefix === "?") {
|
|
30
|
+
if (serializedValue) {
|
|
31
|
+
html += `${attribute.whitespace}${attribute.name}`;
|
|
32
|
+
}
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (serializedValue === void 0) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
html += `${attribute.whitespace}${attribute.name}="${escapeHtmlAttribute(serializedValue)}"`;
|
|
39
|
+
}
|
|
40
|
+
html += template.strings[values.length] ?? "";
|
|
41
|
+
return html;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
serializeTemplateShape
|
|
45
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EcoComponent } from '../../public-types.js';
|
|
2
|
-
import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
1
|
+
import type { EcoComponent } from '../../types/public-types.js';
|
|
2
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
3
3
|
import type { AssetProcessingService, ProcessedAsset } from '../../services/assets/asset-processing-service/index.js';
|
|
4
4
|
export declare const DEPENDENCY_ERRORS: {
|
|
5
5
|
readonly INVALID_STYLESHEET_ENTRY: "Invalid stylesheet dependency entry: expected src or content";
|
|
@@ -34,7 +34,12 @@ function extractEcopagesVirtualImports(file) {
|
|
|
34
34
|
const namedImports = [];
|
|
35
35
|
for (const spec of node.specifiers ?? []) {
|
|
36
36
|
if (spec.type === "ImportSpecifier") {
|
|
37
|
-
|
|
37
|
+
let importedName = spec.local?.name;
|
|
38
|
+
if (spec.imported?.type === "Identifier") {
|
|
39
|
+
importedName = spec.imported.name;
|
|
40
|
+
} else if (spec.imported?.type === "Literal") {
|
|
41
|
+
importedName = spec.imported.value;
|
|
42
|
+
}
|
|
38
43
|
namedImports.push(importedName);
|
|
39
44
|
}
|
|
40
45
|
}
|
|
@@ -62,7 +67,7 @@ function createModuleScriptName(from, imports) {
|
|
|
62
67
|
return `module-${hash}`;
|
|
63
68
|
}
|
|
64
69
|
function createNamedImportModuleSource(from, imports) {
|
|
65
|
-
const namedImports = imports.join(", ");
|
|
70
|
+
const namedImports = [...new Set(imports)].sort().join(", ");
|
|
66
71
|
return `export { ${namedImports} } from '${from}';`;
|
|
67
72
|
}
|
|
68
73
|
function createNamespaceImportModuleSource(from) {
|
|
@@ -259,14 +264,11 @@ class DependencyResolverService {
|
|
|
259
264
|
}
|
|
260
265
|
scriptDependencyKeys.add(depKey2);
|
|
261
266
|
dependencies.push(
|
|
262
|
-
AssetFactory.
|
|
267
|
+
AssetFactory.createInlineContentScript({
|
|
263
268
|
position: "head",
|
|
264
269
|
content,
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
defer: "",
|
|
268
|
-
...attributes
|
|
269
|
-
}
|
|
270
|
+
bundle: false,
|
|
271
|
+
attributes
|
|
270
272
|
})
|
|
271
273
|
);
|
|
272
274
|
continue;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { EcoPageFile, GetMetadata, GetMetadataContext, GetStaticProps, PageMetadataProps, RouteRendererOptions, EcoPageComponent } from '../../public-types.js';
|
|
2
|
-
import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
1
|
+
import type { EcoPageFile, GetMetadata, GetMetadataContext, GetStaticProps, PageMetadataProps, RouteRendererOptions, EcoPageComponent } from '../../types/public-types.js';
|
|
2
|
+
import type { EcoPagesAppConfig } from '../../types/internal-types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Loads route page modules and normalizes their data hooks for rendering.
|
|
5
5
|
*
|
|
@@ -10,7 +10,7 @@ import type { EcoPagesAppConfig } from '../../internal-types.js';
|
|
|
10
10
|
* page props and metadata into one renderer-facing shape.
|
|
11
11
|
*/
|
|
12
12
|
export declare class PageModuleLoaderService {
|
|
13
|
-
private
|
|
13
|
+
private appModuleLoader;
|
|
14
14
|
private appConfig;
|
|
15
15
|
private runtimeOrigin;
|
|
16
16
|
/**
|
|
@@ -27,7 +27,9 @@ export declare class PageModuleLoaderService {
|
|
|
27
27
|
* The underlying transpiler keeps Bun and Node aligned on one framework-owned
|
|
28
28
|
* loading contract even though the runtime-specific execution transport differs.
|
|
29
29
|
*/
|
|
30
|
-
importPageFile(file: string
|
|
30
|
+
importPageFile(file: string, options?: {
|
|
31
|
+
bypassCache?: boolean;
|
|
32
|
+
}): Promise<EcoPageFile>;
|
|
31
33
|
/**
|
|
32
34
|
* Executes the page's static-props hook with Ecopages runtime context.
|
|
33
35
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { invariant } from "../../utils/invariant.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getAppModuleLoader } from "../../services/module-loading/app-server-module-transpiler.service.js";
|
|
3
3
|
import { resolveInternalExecutionDir } from "../../utils/resolve-work-dir.js";
|
|
4
4
|
class PageModuleLoaderService {
|
|
5
|
-
|
|
5
|
+
appModuleLoader;
|
|
6
6
|
appConfig;
|
|
7
7
|
runtimeOrigin;
|
|
8
8
|
/**
|
|
@@ -14,7 +14,7 @@ class PageModuleLoaderService {
|
|
|
14
14
|
constructor(appConfig, runtimeOrigin) {
|
|
15
15
|
this.appConfig = appConfig;
|
|
16
16
|
this.runtimeOrigin = runtimeOrigin;
|
|
17
|
-
this.
|
|
17
|
+
this.appModuleLoader = getAppModuleLoader(appConfig);
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Imports one page module through the shared server-side module loading path.
|
|
@@ -23,11 +23,13 @@ class PageModuleLoaderService {
|
|
|
23
23
|
* The underlying transpiler keeps Bun and Node aligned on one framework-owned
|
|
24
24
|
* loading contract even though the runtime-specific execution transport differs.
|
|
25
25
|
*/
|
|
26
|
-
async importPageFile(file) {
|
|
26
|
+
async importPageFile(file, options) {
|
|
27
27
|
try {
|
|
28
|
-
return await this.
|
|
28
|
+
return await this.appModuleLoader.importModule({
|
|
29
29
|
filePath: file,
|
|
30
|
+
rootDir: this.appConfig.rootDir,
|
|
30
31
|
outdir: `${resolveInternalExecutionDir(this.appConfig)}/.server-modules`,
|
|
32
|
+
bypassCache: options?.bypassCache,
|
|
31
33
|
transpileErrorMessage: (details) => `Error transpiling page file: ${details}`,
|
|
32
34
|
noOutputMessage: (targetFilePath) => `No transpiled output generated for page: ${targetFilePath}`
|
|
33
35
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig } from '../internal-types.js';
|
|
1
|
+
import type { EcoPagesAppConfig } from '../types/internal-types.js';
|
|
2
2
|
import type { IntegrationPlugin } from '../plugins/integration-plugin.js';
|
|
3
|
-
import type { RouteRenderResult, RouteRendererOptions } from '../public-types.js';
|
|
3
|
+
import type { RouteRenderResult, RouteRendererOptions } from '../types/public-types.js';
|
|
4
4
|
import type { IntegrationRenderer } from './orchestration/integration-renderer.js';
|
|
5
5
|
/**
|
|
6
6
|
* Thin wrapper around one initialized integration renderer.
|
|
@@ -32,12 +32,14 @@ export declare class RouteRenderer {
|
|
|
32
32
|
export declare class RouteRendererFactory {
|
|
33
33
|
private appConfig;
|
|
34
34
|
runtimeOrigin: string;
|
|
35
|
+
private rendererModules?;
|
|
35
36
|
private rendererCache;
|
|
36
37
|
/**
|
|
37
38
|
* Creates the route-renderer factory for one app/runtime instance.
|
|
38
39
|
*/
|
|
39
|
-
constructor({ appConfig, runtimeOrigin }: {
|
|
40
|
+
constructor({ appConfig, rendererModules, runtimeOrigin, }: {
|
|
40
41
|
appConfig: EcoPagesAppConfig;
|
|
42
|
+
rendererModules?: unknown;
|
|
41
43
|
runtimeOrigin: string;
|
|
42
44
|
});
|
|
43
45
|
/**
|
|
@@ -18,12 +18,18 @@ class RouteRenderer {
|
|
|
18
18
|
class RouteRendererFactory {
|
|
19
19
|
appConfig;
|
|
20
20
|
runtimeOrigin;
|
|
21
|
+
rendererModules;
|
|
21
22
|
rendererCache = /* @__PURE__ */ new Map();
|
|
22
23
|
/**
|
|
23
24
|
* Creates the route-renderer factory for one app/runtime instance.
|
|
24
25
|
*/
|
|
25
|
-
constructor({
|
|
26
|
+
constructor({
|
|
27
|
+
appConfig,
|
|
28
|
+
rendererModules,
|
|
29
|
+
runtimeOrigin
|
|
30
|
+
}) {
|
|
26
31
|
this.appConfig = appConfig;
|
|
32
|
+
this.rendererModules = rendererModules;
|
|
27
33
|
this.runtimeOrigin = runtimeOrigin;
|
|
28
34
|
}
|
|
29
35
|
/**
|
|
@@ -47,7 +53,9 @@ class RouteRendererFactory {
|
|
|
47
53
|
if (cached) {
|
|
48
54
|
return cached;
|
|
49
55
|
}
|
|
50
|
-
const renderer = integrationPlugin.initializeRenderer(
|
|
56
|
+
const renderer = integrationPlugin.initializeRenderer({
|
|
57
|
+
rendererModules: this.rendererModules
|
|
58
|
+
});
|
|
51
59
|
this.rendererCache.set(integrationName, renderer);
|
|
52
60
|
return renderer;
|
|
53
61
|
}
|
|
@@ -76,7 +84,9 @@ class RouteRendererFactory {
|
|
|
76
84
|
if (cached) {
|
|
77
85
|
return cached;
|
|
78
86
|
}
|
|
79
|
-
const renderer = integrationPlugin.initializeRenderer(
|
|
87
|
+
const renderer = integrationPlugin.initializeRenderer({
|
|
88
|
+
rendererModules: this.rendererModules
|
|
89
|
+
});
|
|
80
90
|
this.rendererCache.set(integrationPlugin.name, renderer);
|
|
81
91
|
return renderer;
|
|
82
92
|
}
|
package/src/router/README.md
CHANGED
|
@@ -8,19 +8,90 @@ The router layer determines what route is being handled and how the client runti
|
|
|
8
8
|
|
|
9
9
|
It is responsible for:
|
|
10
10
|
|
|
11
|
-
- filesystem route scanning and
|
|
12
|
-
-
|
|
13
|
-
-
|
|
11
|
+
- filesystem route scanning and classification (`exact`, `dynamic`, `catch-all`)
|
|
12
|
+
- matching incoming request URLs to discovered routes
|
|
13
|
+
- server-side static-path expansion for dynamic routes
|
|
14
|
+
- client-side navigation ownership and cross-runtime handoff
|
|
14
15
|
- keeping route discovery separate from rendering execution
|
|
15
16
|
|
|
16
|
-
##
|
|
17
|
+
## Directory Structure
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
```
|
|
20
|
+
router/
|
|
21
|
+
├── server/ # Server-side route scanning and matching
|
|
22
|
+
│ ├── fs-router-scanner.ts # Scans the filesystem and classifies routes
|
|
23
|
+
│ └── fs-router.ts # Matches request URLs to discovered routes
|
|
24
|
+
└── client/ # Browser-side navigation coordination
|
|
25
|
+
├── navigation-coordinator.ts # Singleton runtime coordinator
|
|
26
|
+
└── link-intent.ts # Shared anchor detection and intent recovery helpers
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## `server/`
|
|
30
|
+
|
|
31
|
+
### `FSRouterScanner`
|
|
32
|
+
|
|
33
|
+
Walks the pages directory and builds a `Routes` map keyed by route pathname.
|
|
34
|
+
|
|
35
|
+
File patterns determine route kind:
|
|
36
|
+
|
|
37
|
+
| Pattern | Kind | Example |
|
|
38
|
+
| --------------- | ----------- | ----------------- |
|
|
39
|
+
| `page.tsx` | `exact` | `/about` |
|
|
40
|
+
| `[slug].tsx` | `dynamic` | `/blog/[slug]` |
|
|
41
|
+
| `[...slug].tsx` | `catch-all` | `/docs/[...slug]` |
|
|
42
|
+
|
|
43
|
+
For `dynamic` routes, the scanner checks whether the page module exports `getStaticPaths`. If present, every returned path is expanded into a concrete `exact`-style route at scan time. In build mode, both `getStaticPaths` and `getStaticProps` are required or an invariant is thrown.
|
|
44
|
+
|
|
45
|
+
Catch-all routes are registered but skipped during static generation with a warning.
|
|
46
|
+
|
|
47
|
+
### `FSRouter`
|
|
48
|
+
|
|
49
|
+
Holds the scanned `Routes` map and exposes a `match(requestUrl)` method used by adapters.
|
|
50
|
+
|
|
51
|
+
Match priority:
|
|
52
|
+
|
|
53
|
+
1. `exact` — the pathname must equal the route pathname exactly.
|
|
54
|
+
2. `dynamic` — the clean (bracket-stripped) prefix must appear in the pathname, and the segment counts must match.
|
|
55
|
+
3. `catch-all` — the clean prefix must appear in the pathname.
|
|
56
|
+
|
|
57
|
+
Additional helpers:
|
|
58
|
+
|
|
59
|
+
- `getDynamicParams(route, pathname)` — extracts named and spread parameters from a matched dynamic or catch-all route.
|
|
60
|
+
- `getSearchParams(url)` — converts `URLSearchParams` to a plain object.
|
|
61
|
+
- `setOnReload(cb)` / `reload()` — re-scans routes and fires an optional callback, used during development HMR.
|
|
62
|
+
|
|
63
|
+
## `client/`
|
|
64
|
+
|
|
65
|
+
### Navigation Coordinator (`navigation-coordinator.ts`)
|
|
66
|
+
|
|
67
|
+
A singleton browser-side runtime stored on `window.__ECO_PAGES__.navigation`.
|
|
68
|
+
|
|
69
|
+
Access it with:
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { getEcoNavigationRuntime } from '@ecopages/core/router/client/navigation-coordinator';
|
|
73
|
+
const runtime = getEcoNavigationRuntime();
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
The coordinator is framework-agnostic. Browser runtimes (e.g. `browser-router`, `react-router`) register themselves and the coordinator arbitrates:
|
|
77
|
+
|
|
78
|
+
- **Ownership** — which runtime currently drives SPA navigation (`claimOwnership`, `releaseOwnership`, `setOwner`).
|
|
79
|
+
- **Document owner marker** — an HTML attribute (`data-eco-document-owner`) written into rendered markup so the coordinator can `adoptDocumentOwner` on the incoming page.
|
|
80
|
+
- **Navigation transactions** — each navigation begins a transaction with an `AbortSignal`; superseded navigations are automatically cancelled.
|
|
81
|
+
- **Cross-runtime handoff** — `requestHandoff` passes a pre-fetched `Document` to the target runtime without tearing down the current page prematurely.
|
|
82
|
+
- **Reload** — `reloadCurrentPage` delegates to whichever runtime currently owns the document.
|
|
83
|
+
- **Events** — `subscribe` lets runtimes react to `owner-change` and `registration-change` events.
|
|
84
|
+
|
|
85
|
+
### Link Intent (`link-intent.ts`)
|
|
86
|
+
|
|
87
|
+
Shared helpers for locating anchors and recovering stale navigation intent.
|
|
88
|
+
|
|
89
|
+
- `getAnchorFromNavigationEvent(event, linkSelector)` — finds the nearest matching anchor in the event's composed path, including across Shadow DOM boundaries.
|
|
90
|
+
- `recoverPendingNavigationHref(intent, hasInFlightNavigation, now, maxAgeMs?)` — resolves a previously captured pointer or hover target when the DOM changes before the click lands. Intents expire after `maxAgeMs` (default 1000 ms).
|
|
20
91
|
|
|
21
92
|
## Relationship To Rendering
|
|
22
93
|
|
|
23
|
-
The router layer answers which route should run
|
|
24
|
-
The route-renderer layer answers how that route gets rendered
|
|
94
|
+
The router layer answers **which route should run**.
|
|
95
|
+
The route-renderer layer answers **how that route gets rendered**.
|
|
25
96
|
|
|
26
97
|
Keeping those seams separate avoids mixing route ownership, module loading, and component orchestration into one service.
|
|
@@ -16,7 +16,7 @@ function getCandidateOwners(currentOwner, registrations, excludedOwner) {
|
|
|
16
16
|
}
|
|
17
17
|
return owners;
|
|
18
18
|
}
|
|
19
|
-
function createEcoNavigationRuntime(
|
|
19
|
+
function createEcoNavigationRuntime() {
|
|
20
20
|
const registrations = /* @__PURE__ */ new Map();
|
|
21
21
|
const listeners = /* @__PURE__ */ new Set();
|
|
22
22
|
let owner = "none";
|
|
@@ -204,7 +204,7 @@ function getEcoNavigationRuntime(windowObject = window) {
|
|
|
204
204
|
const runtimeWindow = windowObject;
|
|
205
205
|
runtimeWindow.__ECO_PAGES__ = runtimeWindow.__ECO_PAGES__ || {};
|
|
206
206
|
if (!runtimeWindow.__ECO_PAGES__.navigation) {
|
|
207
|
-
runtimeWindow.__ECO_PAGES__.navigation = createEcoNavigationRuntime(
|
|
207
|
+
runtimeWindow.__ECO_PAGES__.navigation = createEcoNavigationRuntime();
|
|
208
208
|
}
|
|
209
209
|
return runtimeWindow.__ECO_PAGES__.navigation;
|
|
210
210
|
}
|
|
@@ -113,7 +113,12 @@ class FSRouterScanner {
|
|
|
113
113
|
const filePath = path.join(this.dir, file);
|
|
114
114
|
const isCatchAll = filePath.includes("[...");
|
|
115
115
|
const isDynamic = !isCatchAll && filePath.includes("[") && filePath.includes("]");
|
|
116
|
-
|
|
116
|
+
let kind = "exact";
|
|
117
|
+
if (isCatchAll) {
|
|
118
|
+
kind = "catch-all";
|
|
119
|
+
} else if (isDynamic) {
|
|
120
|
+
kind = "dynamic";
|
|
121
|
+
}
|
|
117
122
|
return { route, routePath, filePath, kind };
|
|
118
123
|
}
|
|
119
124
|
async scan() {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MatchResult, Route, Routes } from '../../internal-types.js';
|
|
1
|
+
import type { MatchResult, Route, Routes } from '../../types/internal-types.js';
|
|
2
2
|
import type { FSRouterScanner } from './fs-router-scanner.js';
|
|
3
3
|
/**
|
|
4
4
|
* A class that manages the routes of the file system.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { EcoPagesAppConfig, IHmrManager } from '../../../internal-types';
|
|
2
|
-
import type { AssetDefinition, AssetKind, AssetSource, ProcessedAsset } from './assets.types';
|
|
3
|
-
import { ProcessorRegistry } from './processor.registry';
|
|
1
|
+
import type { EcoPagesAppConfig, IHmrManager } from '../../../types/internal-types.js';
|
|
2
|
+
import type { AssetDefinition, AssetKind, AssetSource, ProcessedAsset } from './assets.types.js';
|
|
3
|
+
import { ProcessorRegistry } from './processor.registry.js';
|
|
4
4
|
/**
|
|
5
5
|
* Processes declared component and page asset dependencies for one app instance.
|
|
6
6
|
*
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { RESOLVED_ASSETS_DIR } from "../../../constants";
|
|
3
|
-
import { appLogger } from "../../../global/app-logger";
|
|
4
|
-
import { rapidhash } from "../../../utils/hash";
|
|
2
|
+
import { RESOLVED_ASSETS_DIR } from "../../../config/constants.js";
|
|
3
|
+
import { appLogger } from "../../../global/app-logger.js";
|
|
4
|
+
import { rapidhash } from "../../../utils/hash.js";
|
|
5
5
|
import { fileSystem } from "@ecopages/file-system";
|
|
6
|
-
import { isHmrAware } from "./processor.interface";
|
|
7
|
-
import { ProcessorRegistry } from "./processor.registry";
|
|
6
|
+
import { isHmrAware } from "./processor.interface.js";
|
|
7
|
+
import { ProcessorRegistry } from "./processor.registry.js";
|
|
8
8
|
import {
|
|
9
9
|
ContentScriptProcessor,
|
|
10
10
|
ContentStylesheetProcessor,
|
|
11
11
|
FileScriptProcessor,
|
|
12
12
|
FileStylesheetProcessor,
|
|
13
13
|
NodeModuleScriptProcessor
|
|
14
|
-
} from "./processors";
|
|
14
|
+
} from "./processors/index.js";
|
|
15
15
|
class AssetProcessingService {
|
|
16
16
|
static RESOLVED_ASSETS_DIR = RESOLVED_ASSETS_DIR;
|
|
17
17
|
registry = new ProcessorRegistry();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentScriptAsset, ContentStylesheetAsset, FileScriptAsset, FileStylesheetAsset, InlineContentScriptAsset, InlineContentStylesheetAsset, InlineFileScriptAsset, JsonScriptAsset, NodeModuleScriptAsset } from './assets.types';
|
|
1
|
+
import type { ContentScriptAsset, ContentStylesheetAsset, FileScriptAsset, FileStylesheetAsset, InlineContentScriptAsset, InlineContentStylesheetAsset, InlineFileScriptAsset, JsonScriptAsset, NodeModuleScriptAsset } from './assets.types.js';
|
|
2
2
|
type CreateAssetOptions<T> = Omit<T, 'kind' | 'source' | 'inline'>;
|
|
3
3
|
export declare class AssetFactory {
|
|
4
4
|
static readonly RESOLVED_ASSETS_DIR = "assets";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RESOLVED_ASSETS_DIR, RESOLVED_ASSETS_VENDORS_DIR } from "../../../constants";
|
|
2
|
-
import { deepMerge } from "../../../utils/deep-merge";
|
|
1
|
+
import { RESOLVED_ASSETS_DIR, RESOLVED_ASSETS_VENDORS_DIR } from "../../../config/constants.js";
|
|
2
|
+
import { deepMerge } from "../../../utils/deep-merge.js";
|
|
3
3
|
class AssetFactory {
|
|
4
4
|
static RESOLVED_ASSETS_DIR = RESOLVED_ASSETS_DIR;
|
|
5
5
|
static RESOLVED_ASSETS_VENDORS_DIR = RESOLVED_ASSETS_VENDORS_DIR;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './asset.factory';
|
|
2
|
-
export * from './asset-processing.service';
|
|
3
|
-
export * from './assets.types';
|
|
4
|
-
export * from './browser-runtime-asset.factory';
|
|
5
|
-
export * from './browser-runtime-entry.factory';
|
|
1
|
+
export * from './asset.factory.js';
|
|
2
|
+
export * from './asset-processing.service.js';
|
|
3
|
+
export * from './assets.types.js';
|
|
4
|
+
export * from './browser-runtime-asset.factory.js';
|
|
5
|
+
export * from './browser-runtime-entry.factory.js';
|