@ecopages/core 0.6.0 → 0.7.0
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 +8 -143
- package/package.json +16 -3
- package/src/adapters/node/dev-session.js +2 -1
- package/src/adapters/node/node-client-bridge.d.ts +5 -7
- package/src/adapters/node/node-client-bridge.js +4 -14
- package/src/adapters/node/server-adapter.d.ts +4 -2
- package/src/adapters/node/server-adapter.js +13 -12
- package/src/adapters/shared/hmr/client-bridge.d.ts +25 -0
- package/src/adapters/shared/hmr/client-bridge.js +35 -0
- package/src/adapters/shared/hmr/dev-transform-entrypoint-registry.js +1 -1
- package/src/adapters/shared/hmr/hmr-manager.d.ts +9 -2
- package/src/adapters/shared/hmr/hmr-manager.js +36 -6
- package/src/adapters/shared/http/dist-file-handler.js +3 -7
- package/src/adapters/shared/http/response-headers.d.ts +29 -0
- package/src/adapters/shared/http/response-headers.js +89 -0
- package/src/adapters/shared/runtime/copy-runtime-public-dir.js +1 -1
- package/src/adapters/shared/runtime/runtime-server-lifecycle.d.ts +3 -2
- package/src/adapters/shared/runtime/runtime-server-lifecycle.js +4 -3
- package/src/adapters/shared/runtime/server-request-pipeline.js +4 -4
- package/src/adapters/shared/runtime/server-static-builder.d.ts +19 -8
- package/src/adapters/shared/runtime/server-static-builder.js +23 -4
- package/src/adapters/shared/ws/node-http-websocket-upgrades.d.ts +1 -1
- package/src/adapters/shared/ws/node-http-websocket-upgrades.js +23 -16
- package/src/assets/app-browser-client-build.d.ts +5 -12
- package/src/assets/app-browser-client-build.js +121 -336
- package/src/assets/asset-processing-service/app-browser-client-bundle.d.ts +4 -0
- package/src/assets/asset-processing-service/app-browser-client-bundle.js +6 -0
- package/src/assets/asset-processing-service/asset-dependency-keys.d.ts +28 -8
- package/src/assets/asset-processing-service/asset-dependency-keys.js +104 -29
- package/src/assets/asset-processing-service/asset-processing.service.d.ts +60 -2
- package/src/assets/asset-processing-service/asset-processing.service.js +189 -58
- package/src/assets/asset-processing-service/bundleable-script.d.ts +3 -0
- package/src/assets/asset-processing-service/bundleable-script.js +4 -0
- package/src/assets/asset-processing-service/grouped-content-bundles.d.ts +2 -2
- package/src/assets/asset-processing-service/grouped-content-bundles.js +5 -10
- package/src/assets/asset-processing-service/index.d.ts +0 -3
- package/src/assets/asset-processing-service/index.js +0 -3
- package/src/assets/asset-processing-service/last-good-output.d.ts +21 -0
- package/src/assets/asset-processing-service/last-good-output.js +32 -0
- package/src/assets/asset-processing-service/page-package.js +1 -4
- package/src/assets/asset-processing-service/processed-asset-ledger.d.ts +63 -0
- package/src/assets/asset-processing-service/processed-asset-ledger.js +101 -0
- package/src/assets/asset-processing-service/processors/base/base-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/base/base-script-processor.js +1 -1
- package/src/assets/asset-processing-service/processors/script/content-script.processor.d.ts +24 -0
- package/src/assets/asset-processing-service/processors/script/content-script.processor.js +59 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.d.ts +8 -4
- package/src/assets/asset-processing-service/processors/script/file-script.processor.js +18 -6
- package/src/assets/asset-processing-service/processors/script/node-module-script.processor.js +2 -3
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.d.ts +34 -0
- package/src/assets/asset-processing-service/processors/stylesheet/app-stylesheet-imports.js +115 -0
- package/src/assets/asset-processing-service/processors/stylesheet/content-stylesheet.processor.js +2 -2
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.d.ts +39 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-module-types.js +150 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.d.ts +84 -0
- package/src/assets/asset-processing-service/processors/stylesheet/css-scanner.js +379 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.d.ts +16 -0
- package/src/assets/asset-processing-service/processors/stylesheet/file-stylesheet.processor.js +50 -24
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.d.ts +33 -0
- package/src/assets/asset-processing-service/processors/stylesheet/import-order.js +67 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.d.ts +44 -0
- package/src/assets/asset-processing-service/processors/stylesheet/package-stylesheet.js +149 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.d.ts +31 -0
- package/src/assets/asset-processing-service/processors/stylesheet/processed-stylesheet-cache.js +59 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.d.ts +20 -0
- package/src/assets/asset-processing-service/processors/stylesheet/source-relative-stylesheet.js +51 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.d.ts +2 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-failure.js +5 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.d.ts +37 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-module.js +48 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.d.ts +25 -1
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-processor-pipeline.js +56 -15
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.d.ts +9 -0
- package/src/assets/asset-processing-service/processors/stylesheet/stylesheet-warnings.js +21 -0
- package/src/assets/browser-asset-output.js +1 -1
- package/src/assets/hashed-browser-asset.js +1 -1
- package/src/assets/{browser-runtime-asset-page-cache.d.ts → page-script-page-cache.d.ts} +3 -3
- package/src/assets/{browser-runtime-asset-page-cache.js → page-script-page-cache.js} +3 -3
- package/src/build/app-build-manifest-runtime.d.ts +23 -11
- package/src/build/app-build-manifest-runtime.js +52 -13
- package/src/build/browser/jsx-ownership-plugins.d.ts +4 -1
- package/src/build/browser/jsx-ownership-plugins.js +6 -0
- package/src/build/build-adapter.d.ts +1 -1
- package/src/build/build-adapter.js +1 -1
- package/src/build/build-graph.d.ts +4 -2
- package/src/build/build-graph.js +12 -46
- package/src/build/cache/build-input-dependency-index.d.ts +0 -19
- package/src/build/cache/build-input-dependency-index.js +1 -34
- package/src/build/cache/pages-unified-graph-build.js +7 -43
- package/src/build/cache/server-module-entries.d.ts +1 -1
- package/src/build/cache/server-module-entries.js +9 -9
- package/src/build/contracts/build-contracts.d.ts +59 -12
- package/src/build/contracts/build-manifest.d.ts +3 -6
- package/src/build/contracts/build-manifest.js +2 -12
- package/src/build/contracts/content-virtual-modules.js +1 -3
- package/src/build/copy-server-files.js +1 -1
- package/src/build/preserve-import-meta-transform.d.ts +3 -1
- package/src/build/preserve-import-meta-transform.js +7 -4
- package/src/build/production-asset-ledger.d.ts +36 -0
- package/src/build/production-asset-ledger.js +104 -0
- package/src/build/production-dist-complete.js +12 -13
- package/src/build/production-route-list.js +1 -1
- package/src/build/rolldown/app-package-declarations.js +1 -1
- package/src/build/rolldown/entry-module-closures.d.ts +5 -1
- package/src/build/rolldown/entry-module-closures.js +21 -8
- package/src/build/rolldown/rolldown-adapter-helpers.d.ts +19 -8
- package/src/build/rolldown/rolldown-adapter-helpers.js +82 -45
- package/src/build/rolldown/rolldown-build-adapter.js +10 -13
- package/src/build/rolldown/rolldown-module-id.d.ts +18 -0
- package/src/build/rolldown/rolldown-module-id.js +29 -0
- package/src/build/rolldown/rolldown-plugin-bridge.d.ts +24 -60
- package/src/build/rolldown/rolldown-plugin-bridge.js +201 -373
- package/src/build/rolldown/stylesheet-module-plugin.d.ts +34 -0
- package/src/build/rolldown/stylesheet-module-plugin.js +160 -0
- package/src/build/rolldown/worker-entries-plugin.d.ts +13 -0
- package/src/build/rolldown/worker-entries-plugin.js +57 -0
- package/src/build/runtime/build-environment-options.js +13 -3
- package/src/build/runtime/build-request-identity.js +1 -1
- package/src/build/runtime/build-request-policy.d.ts +7 -12
- package/src/build/runtime/build-request-policy.js +63 -17
- package/src/build/server/imported-view-plugin.d.ts +1 -0
- package/src/build/server/imported-view-plugin.js +6 -4
- package/src/build/server/page-module-import.service.d.ts +1 -2
- package/src/build/server/page-module-import.service.js +4 -6
- package/src/build/server/resolve-static-view.js +3 -2
- package/src/build/server/route-module-build-cache-registry.js +1 -1
- package/src/build/server/route-module-build-cache.store.js +1 -1
- package/src/build/server/route-module-build-manifest.js +1 -1
- package/src/build/server/route-module-dependency-hasher.d.ts +1 -1
- package/src/build/server/route-module-dependency-hasher.js +2 -2
- package/src/build/server/server-modules-manifest.d.ts +3 -5
- package/src/build/server/server-modules-manifest.js +6 -21
- package/src/build/server/view-module.d.ts +12 -0
- package/src/build/server/view-module.js +23 -0
- package/src/build/server/view-reference.d.ts +16 -5
- package/src/build/server/view-reference.js +25 -14
- package/src/build/server-bundle-deploy-manifest.d.ts +1 -1
- package/src/build/server-bundle-deploy-manifest.js +2 -2
- package/src/build/server-bundle-publication.d.ts +7 -1
- package/src/build/server-bundle-publication.js +11 -4
- package/src/build/server-module.js +1 -1
- package/src/build/worker-urls.d.ts +60 -0
- package/src/build/worker-urls.js +197 -0
- package/src/build.d.ts +7 -5
- package/src/build.js +7 -5
- package/src/cache/module-parse-cache.js +2 -2
- package/src/client/navigation-attributes.d.ts +8 -0
- package/src/client/navigation-attributes.js +8 -0
- package/src/client/navigation-scripts/global-scripts.d.ts +14 -0
- package/src/client/navigation-scripts/global-scripts.js +65 -0
- package/src/client/navigation-scripts/index.d.ts +1 -0
- package/src/client/navigation-scripts/index.js +1 -0
- package/src/client.d.ts +2 -2
- package/src/client.js +2 -2
- package/src/config/assembly/app-runtime.d.ts +45 -5
- package/src/config/assembly/app-runtime.js +11 -2
- package/src/config/assembly/finalize-config.js +13 -5
- package/src/config/config-module-files.js +10 -6
- package/src/config/index.d.ts +2 -1
- package/src/config/internal-types.d.ts +3 -0
- package/src/config/load-eco-config.js +8 -5
- package/src/config/resolve-eco-config-path.js +3 -3
- package/src/config/server-config-bundle.js +1 -1
- package/src/config/user-config-types.d.ts +54 -1
- package/src/config/write-types.js +4 -1
- package/src/css-imports.d.ts +12 -0
- package/src/declarations.d.ts +2 -0
- package/src/dev/development-restart-watch-paths.js +1 -1
- package/src/dev/development-restart.js +1 -1
- package/src/dev/invalidation/development-invalidation.service.d.ts +6 -1
- package/src/dev/invalidation/development-invalidation.service.js +18 -2
- package/src/dev/stylesheets/development-stylesheet.service.d.ts +149 -0
- package/src/dev/stylesheets/development-stylesheet.service.js +350 -0
- package/src/dev/transform-server/dev-transform-bundler.d.ts +12 -3
- package/src/dev/transform-server/dev-transform-bundler.js +32 -21
- package/src/dev/transform-server/dev-transform-externalize-plugin.d.ts +3 -5
- package/src/dev/transform-server/dev-transform-externalize-plugin.js +8 -9
- package/src/dev/transform-server/dev-transform-import-rewriter.d.ts +15 -2
- package/src/dev/transform-server/dev-transform-import-rewriter.js +204 -35
- package/src/dev/transform-server/dev-transform-install-stamp.d.ts +17 -0
- package/src/dev/transform-server/dev-transform-install-stamp.js +79 -0
- package/src/dev/transform-server/dev-transform-server.d.ts +38 -2
- package/src/dev/transform-server/dev-transform-server.js +96 -33
- package/src/dev/transform-server/dev-transform-url.d.ts +4 -2
- package/src/dev/transform-server/dev-transform-url.js +13 -12
- package/src/dev/transform-server/dev-transform-vendor-registry.d.ts +178 -21
- package/src/dev/transform-server/dev-transform-vendor-registry.js +675 -99
- package/src/dev/transform-server/index.d.ts +1 -1
- package/src/dev-toolbar/dev-toolbar-package.js +4 -4
- package/src/eco/component-render-output.d.ts +6 -1
- package/src/eco/component-render-output.js +32 -7
- package/src/eco/discovered-dependencies.d.ts +30 -11
- package/src/eco/discovered-dependencies.js +25 -13
- package/src/eco/discovered-dependency-paths.d.ts +36 -0
- package/src/eco/discovered-dependency-paths.js +58 -0
- package/src/eco/eco.browser.js +8 -12
- package/src/eco/eco.js +0 -30
- package/src/eco/mdx-page-metadata.d.ts +14 -0
- package/src/eco/mdx-page-metadata.js +15 -0
- package/src/eco/page-layout-normalization.d.ts +6 -2
- package/src/eco/page-layout-normalization.js +9 -6
- package/src/env.js +17 -0
- package/src/hmr/client/hmr-runtime.js +14 -13
- package/src/hmr/dev-client-runtime.d.ts +5 -2
- package/src/hmr/dev-client-runtime.js +14 -4
- package/src/hmr/hmr-entrypoint-output.js +1 -1
- package/src/hmr/hmr-strategy.d.ts +2 -2
- package/src/hmr/hmr-strategy.js +2 -2
- package/src/hmr/strategies/js-hmr-strategy.d.ts +4 -1
- package/src/hmr/strategies/js-hmr-strategy.js +7 -6
- package/src/hmr/strategies/template-source-hmr-strategy.d.ts +25 -0
- package/src/hmr/strategies/template-source-hmr-strategy.js +36 -0
- package/src/html-pages/html-page-module-scripts.d.ts +2 -1
- package/src/html-pages/html-page-module-scripts.js +37 -14
- package/src/html-pages/html-page-module.js +1 -1
- package/src/html-pages/html-page-renderer.js +7 -6
- package/src/html-pages/html-page-template.d.ts +0 -5
- package/src/html-pages/html-page-template.js +3 -15
- package/src/html-pages/html-pages.plugin.js +2 -2
- package/src/integration.d.ts +8 -6
- package/src/integration.js +5 -3
- package/src/page-cache/html-page-cache-dependency-index.js +1 -1
- package/src/page-cache/page-cache-service.js +1 -1
- package/src/plugins/alias-resolver-plugin.d.ts +7 -0
- package/src/plugins/alias-resolver-plugin.js +16 -6
- package/src/plugins/component-import-discovery.d.ts +178 -7
- package/src/plugins/component-import-discovery.js +696 -112
- package/src/plugins/eco-component-meta-plugin.d.ts +47 -6
- package/src/plugins/eco-component-meta-plugin.js +227 -59
- package/src/plugins/foreign-jsx-override-plugin.d.ts +14 -1
- package/src/plugins/foreign-jsx-override-plugin.js +18 -8
- package/src/plugins/integration-plugin.d.ts +47 -11
- package/src/plugins/integration-plugin.js +57 -8
- package/src/plugins/processor.d.ts +72 -7
- package/src/plugins/processor.js +44 -9
- package/src/plugins/stylesheet-kinds.d.ts +57 -0
- package/src/plugins/stylesheet-kinds.js +114 -0
- package/src/plugins/tsconfig-import-resolver.d.ts +49 -3
- package/src/plugins/tsconfig-import-resolver.js +120 -6
- package/src/processor-contract.d.ts +66 -0
- package/src/processor-contract.js +389 -0
- package/src/processor.d.ts +6 -1
- package/src/processor.js +6 -1
- package/src/route-renderer/error-pages/default-error-pages.d.ts +1 -0
- package/src/route-renderer/error-pages/default-error-pages.js +27 -7
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.d.ts +8 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preload-invalidation.js +12 -0
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.d.ts +77 -24
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-script-preloader.js +97 -32
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-server-module-importer.js +1 -1
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.d.ts +9 -0
- package/src/route-renderer/orchestration/document-shell/document-shell-render.service.js +16 -2
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.d.ts +35 -0
- package/src/route-renderer/orchestration/document-shell/layout-children-not-rendered-error.js +53 -0
- package/src/route-renderer/orchestration/foreign-child/render-session.d.ts +4 -8
- package/src/route-renderer/orchestration/foreign-child/render-session.js +2 -5
- package/src/route-renderer/orchestration/integration-renderer.d.ts +171 -64
- package/src/route-renderer/orchestration/integration-renderer.js +293 -332
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.d.ts +8 -5
- package/src/route-renderer/orchestration/ownership-graph/component-graph-collectors.js +27 -25
- package/src/route-renderer/orchestration/ownership-graph/component-graph.d.ts +0 -6
- package/src/route-renderer/orchestration/page-browser-graph/global-injector-assets.service.js +3 -3
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.d.ts +12 -25
- package/src/route-renderer/orchestration/page-browser-graph/grouped-graph-build-plan.js +1 -14
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.d.ts +0 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph-session.js +1 -87
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.d.ts +8 -16
- package/src/route-renderer/orchestration/page-browser-graph/page-browser-graph.service.js +25 -271
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.d.ts +0 -24
- package/src/route-renderer/orchestration/page-browser-graph/route-instance-key.js +0 -67
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.d.ts +28 -15
- package/src/route-renderer/orchestration/route-pipeline/route-render-orchestrator.js +63 -41
- package/src/route-renderer/page-loading/component-dependency-collection.d.ts +4 -1
- package/src/route-renderer/page-loading/component-dependency-collection.js +51 -15
- package/src/route-renderer/page-loading/dependency-resolver.d.ts +10 -0
- package/src/route-renderer/page-loading/dependency-resolver.js +27 -6
- package/src/route-renderer/page-loading/file-scoped-dependency-components.d.ts +4 -2
- package/src/route-renderer/page-loading/file-scoped-dependency-components.js +22 -17
- package/src/route-renderer/page-loading/lazy-entry-collection.d.ts +5 -0
- package/src/route-renderer/page-loading/lazy-entry-collection.js +6 -4
- package/src/route-renderer/page-loading/page-dependency-bundling.d.ts +5 -2
- package/src/route-renderer/page-loading/page-dependency-bundling.js +15 -31
- package/src/route-renderer/page-loading/page-module-loader.d.ts +13 -2
- package/src/route-renderer/page-loading/page-module-loader.js +23 -5
- package/src/route-renderer/route-renderer.d.ts +1 -1
- package/src/router/client/navigation-commit.d.ts +2 -0
- package/src/router/client/navigation-commit.js +20 -3
- package/src/router/client/navigation-coordinator.d.ts +18 -0
- package/src/router/client/navigation-coordinator.js +14 -0
- package/src/router/client/navigation-head-order.fixture.css +3 -0
- package/src/router/client/navigation-head.d.ts +2 -1
- package/src/router/client/navigation-head.fixture.css +3 -0
- package/src/router/client/navigation-head.js +222 -39
- package/src/router/client/navigation-lifecycle.d.ts +8 -1
- package/src/router/client/navigation-lifecycle.js +6 -3
- package/src/router/client/navigation-pipeline.d.ts +1 -0
- package/src/router/client/navigation-pipeline.js +1 -0
- package/src/router/server/route-registry.d.ts +3 -2
- package/src/router/server/route-registry.js +6 -5
- package/src/static-site-generator/production-page-browser-graph-prebuild.d.ts +30 -18
- package/src/static-site-generator/production-page-browser-graph-prebuild.js +82 -143
- package/src/static-site-generator/static-site-generator.d.ts +37 -4
- package/src/static-site-generator/static-site-generator.js +99 -51
- package/src/types/asset-types.d.ts +19 -1
- package/src/types/build-types.d.ts +53 -35
- package/src/types/component-identity.d.ts +8 -0
- package/src/types/contracts.d.ts +69 -21
- package/src/types/dev-transform-types.d.ts +33 -6
- package/src/types/eco-api-types.d.ts +13 -18
- package/src/types/integration-types.d.ts +1 -1
- package/src/types/public-types.d.ts +1 -1
- package/src/utils/additional-watch-paths.js +3 -5
- package/src/utils/entry-command-flags.d.ts +23 -0
- package/src/utils/entry-command-flags.js +24 -0
- package/src/utils/package-path.d.ts +42 -0
- package/src/utils/package-path.js +114 -0
- package/src/utils/parse-cli-args.d.ts +18 -1
- package/src/utils/parse-cli-args.js +54 -37
- package/src/utils/path-containment.js +3 -10
- package/src/utils/resolve-work-dir.js +2 -2
- package/src/utils/root-relative-path.js +2 -2
- package/src/utils/server-bundle-context.d.ts +5 -0
- package/src/utils/server-bundle-context.js +7 -1
- package/src/utils/server-utils.module.js +1 -1
- package/src/watchers/project-watcher-ignore.js +3 -3
- package/src/watchers/project-watcher.d.ts +14 -2
- package/src/watchers/project-watcher.js +37 -6
- package/src/watchers/workspace-package-watch-roots.js +2 -2
- package/src/assets/app-browser-client-manifest.d.ts +0 -66
- package/src/assets/app-browser-client-manifest.js +0 -260
- package/src/assets/asset-processing-service/asset-package-role.d.ts +0 -2
- package/src/assets/asset-processing-service/asset-package-role.js +0 -3
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.d.ts +0 -58
- package/src/assets/asset-processing-service/browser-runtime-asset.factory.js +0 -61
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.d.ts +0 -79
- package/src/assets/asset-processing-service/browser-runtime-entry-resolution.js +0 -200
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.d.ts +0 -24
- package/src/assets/asset-processing-service/browser-runtime-entry.factory.js +0 -67
- package/src/build/browser/browser-runtime-manifest.d.ts +0 -35
- package/src/build/browser/browser-runtime-manifest.js +0 -65
- package/src/build/browser/browser-runtime-plugin-helpers.d.ts +0 -14
- package/src/build/browser/browser-runtime-plugin-helpers.js +0 -21
- package/src/build/browser/browser-runtime-plugin.d.ts +0 -54
- package/src/build/browser/browser-runtime-plugin.js +0 -76
- package/src/build/rolldown/server-side-css-shim-plugin.d.ts +0 -28
- package/src/build/rolldown/server-side-css-shim-plugin.js +0 -59
- package/src/dev/transform-server/dev-transform-module-kind.d.ts +0 -13
- package/src/dev/transform-server/dev-transform-module-kind.js +0 -17
- package/src/dev/transform-server/dev-transform-runtime-specifiers.d.ts +0 -5
- package/src/dev/transform-server/dev-transform-runtime-specifiers.js +0 -16
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.d.ts +0 -15
- package/src/route-renderer/orchestration/custom-element-scripts/custom-element-ssr-preload-entrypoint.js +0 -65
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.d.ts +0 -21
- package/src/route-renderer/orchestration/page-browser-graph/missing-production-browser-graph.js +0 -31
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { DevTransformServer } from './dev-transform-server.js';
|
|
2
2
|
export type { DevTransformServerOptions } from './dev-transform-server.js';
|
|
3
3
|
export { DevTransformBundler } from './dev-transform-bundler.js';
|
|
4
|
-
export type { DevTransformBundleContributor, DevTransformBundleResult } from './types.js';
|
|
4
|
+
export type { DevTransformBundleContributor, DevTransformBundleResult, DevTransformVendorEntries } from './types.js';
|
|
5
5
|
export { DevTransformVendorRegistry } from './dev-transform-vendor-registry.js';
|
|
6
6
|
export { resolveDevTransformModuleUrl, DEV_TRANSFORM_URL_PREFIX } from './dev-transform-url.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
|
-
import path from '
|
|
2
|
+
import { path } from '@ecopages/file-system/path';
|
|
3
3
|
import { fileSystem } from '@ecopages/file-system';
|
|
4
4
|
const SOURCE_CLIENT_FILE = 'src/bootstrap.ts';
|
|
5
5
|
const COMPILED_CLIENT_FILE = 'src/bootstrap.js';
|
|
@@ -18,7 +18,7 @@ export function getDevToolbarPackageSpec(appConfig) {
|
|
|
18
18
|
*/
|
|
19
19
|
export function resolveDevToolbarPackageRoot(rootDir, packageSpec) {
|
|
20
20
|
const require = createRequire(path.join(rootDir, 'package.json'));
|
|
21
|
-
let dir = path.dirname(require.resolve(packageSpec));
|
|
21
|
+
let dir = path.dirname(path.fromNative(require.resolve(packageSpec)));
|
|
22
22
|
while (dir !== path.dirname(dir)) {
|
|
23
23
|
if (fileSystem.exists(path.join(dir, 'package.json'))) {
|
|
24
24
|
return dir;
|
|
@@ -43,7 +43,7 @@ export function resolveDevToolbarClient(rootDir, packageSpec) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
try {
|
|
46
|
-
return { entryPath: require.resolve(packageSpec) };
|
|
46
|
+
return { entryPath: path.fromNative(require.resolve(packageSpec)) };
|
|
47
47
|
}
|
|
48
48
|
catch {
|
|
49
49
|
return undefined;
|
|
@@ -66,7 +66,7 @@ export function resolveDevToolbarPackageEntry(rootDir, packageSpec) {
|
|
|
66
66
|
const client = resolveDevToolbarClient(rootDir, packageSpec);
|
|
67
67
|
if (!client) {
|
|
68
68
|
const require = createRequire(path.join(rootDir, 'package.json'));
|
|
69
|
-
return require.resolve(packageSpec);
|
|
69
|
+
return path.fromNative(require.resolve(packageSpec));
|
|
70
70
|
}
|
|
71
71
|
return client.entryPath;
|
|
72
72
|
}
|
|
@@ -39,6 +39,10 @@ export declare function isMarkupNodeLike(value: unknown): value is MarkupNodeLik
|
|
|
39
39
|
* When no eligible opening tag is found the original string is returned
|
|
40
40
|
* unchanged so callers never receive a broken fragment.
|
|
41
41
|
*
|
|
42
|
+
* An array (a JSX fragment) keeps its shape: the trigger goes on the first
|
|
43
|
+
* element found in document order, skipping text, `null`, booleans and nested
|
|
44
|
+
* arrays that hold no element, and later siblings are returned untouched.
|
|
45
|
+
*
|
|
42
46
|
* @remarks
|
|
43
47
|
* `@ecopages/jsx` beta.8+ keeps attribute names in `parts`, so template
|
|
44
48
|
* `strings[0]` is often just the opening tag name (`<html`) with no trailing
|
|
@@ -50,5 +54,6 @@ export declare function isMarkupNodeLike(value: unknown): value is MarkupNodeLik
|
|
|
50
54
|
export declare function addTriggerAttribute(content: string, triggerId: string): string;
|
|
51
55
|
export declare function addTriggerAttribute<T extends TemplateContentShape>(content: T, triggerId: string): T;
|
|
52
56
|
export declare function addTriggerAttribute<T extends MarkupNodeLikeShape>(content: T, triggerId: string): T;
|
|
53
|
-
export declare function addTriggerAttribute(content:
|
|
57
|
+
export declare function addTriggerAttribute<T extends readonly unknown[]>(content: T, triggerId: string): T;
|
|
58
|
+
export declare function addTriggerAttribute(content: unknown, triggerId: string): unknown;
|
|
54
59
|
export {};
|
|
@@ -101,23 +101,48 @@ function injectTriggerAttributeIntoString(content, triggerId) {
|
|
|
101
101
|
}
|
|
102
102
|
const insertAt = i + 1 + nameEnd;
|
|
103
103
|
if (openingTagHasTriggerAttribute(str, insertAt)) {
|
|
104
|
-
return str;
|
|
104
|
+
return { content: str, reachedElement: true };
|
|
105
105
|
}
|
|
106
|
-
return
|
|
106
|
+
return {
|
|
107
|
+
content: `${str.slice(0, insertAt)} data-eco-trigger="${triggerId}"${str.slice(insertAt)}`,
|
|
108
|
+
reachedElement: true,
|
|
109
|
+
};
|
|
107
110
|
}
|
|
108
111
|
break;
|
|
109
112
|
}
|
|
110
|
-
return str;
|
|
113
|
+
return { content: str, reachedElement: false };
|
|
111
114
|
}
|
|
112
|
-
|
|
115
|
+
function stampContent(content, triggerId) {
|
|
116
|
+
if (Array.isArray(content)) {
|
|
117
|
+
let reachedElement = false;
|
|
118
|
+
const stamped = content.map((item) => {
|
|
119
|
+
if (reachedElement)
|
|
120
|
+
return item;
|
|
121
|
+
const result = stampContent(item, triggerId);
|
|
122
|
+
reachedElement = result.reachedElement;
|
|
123
|
+
return result.reachedElement ? result.content : item;
|
|
124
|
+
});
|
|
125
|
+
return { content: stamped, reachedElement };
|
|
126
|
+
}
|
|
113
127
|
if (isTemplateContentShape(content)) {
|
|
114
128
|
if (content.strings.length === 0) {
|
|
115
|
-
return String(content);
|
|
129
|
+
return { content: String(content), reachedElement: false };
|
|
116
130
|
}
|
|
117
|
-
|
|
131
|
+
const first = injectTriggerAttributeIntoString(content.strings[0] ?? '', triggerId);
|
|
132
|
+
return {
|
|
133
|
+
content: cloneTemplateContentWithUpdatedFirstString(content, first.content),
|
|
134
|
+
reachedElement: first.reachedElement,
|
|
135
|
+
};
|
|
118
136
|
}
|
|
119
137
|
if (isMarkupNodeLikeShape(content) && typeof content.outerHTML === 'string') {
|
|
120
|
-
|
|
138
|
+
const outer = injectTriggerAttributeIntoString(content.outerHTML, triggerId);
|
|
139
|
+
return {
|
|
140
|
+
content: cloneMarkupNodeLikeWithUpdatedOuterHtml(content, outer.content),
|
|
141
|
+
reachedElement: outer.reachedElement,
|
|
142
|
+
};
|
|
121
143
|
}
|
|
122
144
|
return injectTriggerAttributeIntoString(String(content), triggerId);
|
|
123
145
|
}
|
|
146
|
+
export function addTriggerAttribute(content, triggerId) {
|
|
147
|
+
return stampContent(content, triggerId).content;
|
|
148
|
+
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import type { EcoComponentConfig } from '../types/contracts.js';
|
|
2
2
|
import type { ComponentIdentity } from './component-identity.js';
|
|
3
|
+
/**
|
|
4
|
+
* What the component meta transform discovered for one declaration.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* A local file is named relative to the app root with forward slashes, and a package stylesheet by its package
|
|
8
|
+
* path (`some-lib/css/style.css`), so an emitted module holds no path of the machine that built it.
|
|
9
|
+
* `resolveDiscoveredStylesheets` and `resolveDiscoveredWatchFiles` turn them into real paths at load.
|
|
10
|
+
*/
|
|
3
11
|
export type DiscoveredDependencies = {
|
|
4
12
|
components: () => unknown[];
|
|
13
|
+
/** Side-effect stylesheets the declaring module imports itself. */
|
|
5
14
|
stylesheets: string[];
|
|
15
|
+
/** Side-effect stylesheets of the plain local modules the declaring module imports. */
|
|
16
|
+
plainModuleStylesheets?: string[];
|
|
17
|
+
/** The entries of `stylesheets` and `plainModuleStylesheets` whose import named a package: package paths. */
|
|
18
|
+
packageStylesheets?: string[];
|
|
6
19
|
watchFiles?: string[];
|
|
7
20
|
};
|
|
8
21
|
/**
|
|
9
|
-
* Records discovered Components, inferred styles, and
|
|
22
|
+
* Records discovered Components, inferred styles, and watch paths on identity.
|
|
10
23
|
*
|
|
11
24
|
* @remarks
|
|
12
25
|
* Styles and watch hops are stored on the identity object through interned symbols so
|
|
@@ -15,22 +28,28 @@ export type DiscoveredDependencies = {
|
|
|
15
28
|
*/
|
|
16
29
|
export declare function registerDiscoveredDependencies(identity: ComponentIdentity, discovered: DiscoveredDependencies): void;
|
|
17
30
|
/**
|
|
18
|
-
* Inferred
|
|
31
|
+
* Inferred stylesheets registered for this component identity, split by where the import sits, as discovery
|
|
32
|
+
* wrote them (see {@link DiscoveredDependencies}).
|
|
19
33
|
*
|
|
20
34
|
* @remarks
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* so
|
|
24
|
-
*
|
|
35
|
+
* `imported` are the declaring module's own side-effect imports; `plainModules` come from the plain local
|
|
36
|
+
* modules it imports. `packages` lists those of either whose import named a package. Provenance stays on
|
|
37
|
+
* identity so copying or merging `config.dependencies` cannot turn inferred styles into explicit ones. Paths are stored on the identity object so collection still
|
|
38
|
+
* sees them when server modules bundle a separate copy of `eco`. The collector prefers explicit entries
|
|
39
|
+
* across the whole graph by resolved path.
|
|
25
40
|
*/
|
|
26
|
-
export declare function
|
|
41
|
+
export declare function getDiscoveredStylesheets(config: EcoComponentConfig | undefined): {
|
|
42
|
+
imported: readonly string[];
|
|
43
|
+
plainModules: readonly string[];
|
|
44
|
+
packages: readonly string[];
|
|
45
|
+
};
|
|
27
46
|
/**
|
|
28
|
-
*
|
|
47
|
+
* Watch paths discovery recorded for this component identity.
|
|
29
48
|
*
|
|
30
49
|
* @remarks
|
|
31
|
-
* Barrel
|
|
32
|
-
* lets a barrel retarget invalidate HTML and Page Browser Graph caches
|
|
33
|
-
* editing the importing Page.
|
|
50
|
+
* Barrel hops and walked plain modules are not Component identity files. Collecting them as watch paths
|
|
51
|
+
* lets a barrel retarget or a plain module's import edit invalidate HTML and Page Browser Graph caches
|
|
52
|
+
* without editing the importing Page.
|
|
34
53
|
*/
|
|
35
54
|
export declare function getDiscoveredWatchFiles(config: EcoComponentConfig | undefined): readonly string[];
|
|
36
55
|
/**
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
const discoveries = new WeakMap();
|
|
2
2
|
const INFERRED_STYLESHEETS = Symbol.for('ecopages.identity.inferredStylesheets');
|
|
3
|
+
const PLAIN_MODULE_STYLESHEETS = Symbol.for('ecopages.identity.plainModuleStylesheets');
|
|
4
|
+
const PACKAGE_STYLESHEETS = Symbol.for('ecopages.identity.packageStylesheets');
|
|
3
5
|
const DISCOVERED_WATCH_FILES = Symbol.for('ecopages.identity.watchFiles');
|
|
4
6
|
function discoveryRecord(identity) {
|
|
5
7
|
return identity;
|
|
6
8
|
}
|
|
7
9
|
/**
|
|
8
|
-
* Records discovered Components, inferred styles, and
|
|
10
|
+
* Records discovered Components, inferred styles, and watch paths on identity.
|
|
9
11
|
*
|
|
10
12
|
* @remarks
|
|
11
13
|
* Styles and watch hops are stored on the identity object through interned symbols so
|
|
@@ -16,30 +18,40 @@ export function registerDiscoveredDependencies(identity, discovered) {
|
|
|
16
18
|
discoveries.set(identity, discovered);
|
|
17
19
|
const record = discoveryRecord(identity);
|
|
18
20
|
record[INFERRED_STYLESHEETS] = discovered.stylesheets;
|
|
21
|
+
record[PLAIN_MODULE_STYLESHEETS] = discovered.plainModuleStylesheets;
|
|
22
|
+
record[PACKAGE_STYLESHEETS] = discovered.packageStylesheets;
|
|
19
23
|
record[DISCOVERED_WATCH_FILES] = discovered.watchFiles;
|
|
20
24
|
}
|
|
21
25
|
/**
|
|
22
|
-
* Inferred
|
|
26
|
+
* Inferred stylesheets registered for this component identity, split by where the import sits, as discovery
|
|
27
|
+
* wrote them (see {@link DiscoveredDependencies}).
|
|
23
28
|
*
|
|
24
29
|
* @remarks
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* so
|
|
28
|
-
*
|
|
30
|
+
* `imported` are the declaring module's own side-effect imports; `plainModules` come from the plain local
|
|
31
|
+
* modules it imports. `packages` lists those of either whose import named a package. Provenance stays on
|
|
32
|
+
* identity so copying or merging `config.dependencies` cannot turn inferred styles into explicit ones. Paths are stored on the identity object so collection still
|
|
33
|
+
* sees them when server modules bundle a separate copy of `eco`. The collector prefers explicit entries
|
|
34
|
+
* across the whole graph by resolved path.
|
|
29
35
|
*/
|
|
30
|
-
export function
|
|
36
|
+
export function getDiscoveredStylesheets(config) {
|
|
31
37
|
const identity = config?.identity;
|
|
32
38
|
if (!identity)
|
|
33
|
-
return [];
|
|
34
|
-
|
|
39
|
+
return { imported: [], plainModules: [], packages: [] };
|
|
40
|
+
const record = discoveryRecord(identity);
|
|
41
|
+
const discovered = discoveries.get(identity);
|
|
42
|
+
return {
|
|
43
|
+
imported: record[INFERRED_STYLESHEETS] ?? discovered?.stylesheets ?? [],
|
|
44
|
+
plainModules: record[PLAIN_MODULE_STYLESHEETS] ?? discovered?.plainModuleStylesheets ?? [],
|
|
45
|
+
packages: record[PACKAGE_STYLESHEETS] ?? discovered?.packageStylesheets ?? [],
|
|
46
|
+
};
|
|
35
47
|
}
|
|
36
48
|
/**
|
|
37
|
-
*
|
|
49
|
+
* Watch paths discovery recorded for this component identity.
|
|
38
50
|
*
|
|
39
51
|
* @remarks
|
|
40
|
-
* Barrel
|
|
41
|
-
* lets a barrel retarget invalidate HTML and Page Browser Graph caches
|
|
42
|
-
* editing the importing Page.
|
|
52
|
+
* Barrel hops and walked plain modules are not Component identity files. Collecting them as watch paths
|
|
53
|
+
* lets a barrel retarget or a plain module's import edit invalidate HTML and Page Browser Graph caches
|
|
54
|
+
* without editing the importing Page.
|
|
43
55
|
*/
|
|
44
56
|
export function getDiscoveredWatchFiles(config) {
|
|
45
57
|
const identity = config?.identity;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { EcoComponentConfig } from '../types/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Writes a package stylesheet as discovery stores it: the folder of the importing module, relative to the app
|
|
4
|
+
* root, then the package path (`src/components|some-lib@1.2.0/css/style.css`).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* The folder is where the package resolves from, as Node resolves it, and `|` never appears in either part.
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatPackageStylesheetEntry(importerDir: string, packagePath: string): string;
|
|
10
|
+
/** The inferred stylesheets of one declaration as real paths of this app. */
|
|
11
|
+
export type ResolvedDiscoveredStylesheets = {
|
|
12
|
+
imported: string[];
|
|
13
|
+
plainModules: string[];
|
|
14
|
+
/** The package path of each entry of `imported` or `plainModules` that a package import named. */
|
|
15
|
+
packagePaths: ReadonlyMap<string, string>;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolves the stylesheets discovery recorded for a declaration against `rootDir`.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* A local stylesheet is stored relative to the app root and a package one by the folder of its importing module
|
|
22
|
+
* and its package path ({@link formatPackageStylesheetEntry}). {@link resolvePackagePath} finds it from that folder
|
|
23
|
+
* in the package installed now, so a moved build, another store layout or a linked workspace package's own
|
|
24
|
+
* dependency resolves the file where it is, not where the build saw it.
|
|
25
|
+
*/
|
|
26
|
+
export declare function resolveDiscoveredStylesheets(config: EcoComponentConfig | undefined, rootDir: string): ResolvedDiscoveredStylesheets;
|
|
27
|
+
/**
|
|
28
|
+
* Every inferred stylesheet of a declaration that development watches, as real paths.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* A package stylesheet installed under `node_modules` is left out, as the development watcher ignores that
|
|
32
|
+
* directory; one in a linked workspace package stays a watch path.
|
|
33
|
+
*/
|
|
34
|
+
export declare function resolveInferredStylesheets(config: EcoComponentConfig | undefined, rootDir: string): string[];
|
|
35
|
+
/** The watch files discovery recorded for a declaration, as paths of this app. */
|
|
36
|
+
export declare function resolveDiscoveredWatchFiles(config: EcoComponentConfig | undefined, rootDir: string): string[];
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
|
+
import { resolvePackagePath } from '../utils/package-path.js';
|
|
3
|
+
import { getDiscoveredStylesheets, getDiscoveredWatchFiles } from './discovered-dependencies.js';
|
|
4
|
+
const PACKAGE_ENTRY_SEPARATOR = '|';
|
|
5
|
+
/**
|
|
6
|
+
* Writes a package stylesheet as discovery stores it: the folder of the importing module, relative to the app
|
|
7
|
+
* root, then the package path (`src/components|some-lib@1.2.0/css/style.css`).
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The folder is where the package resolves from, as Node resolves it, and `|` never appears in either part.
|
|
11
|
+
*/
|
|
12
|
+
export function formatPackageStylesheetEntry(importerDir, packagePath) {
|
|
13
|
+
return `${importerDir}${PACKAGE_ENTRY_SEPARATOR}${packagePath}`;
|
|
14
|
+
}
|
|
15
|
+
function parsePackageStylesheetEntry(entry) {
|
|
16
|
+
const separator = entry.lastIndexOf(PACKAGE_ENTRY_SEPARATOR);
|
|
17
|
+
return separator === -1
|
|
18
|
+
? { importerDir: '', packagePath: entry }
|
|
19
|
+
: { importerDir: entry.slice(0, separator), packagePath: entry.slice(separator + 1) };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolves the stylesheets discovery recorded for a declaration against `rootDir`.
|
|
23
|
+
*
|
|
24
|
+
* @remarks
|
|
25
|
+
* A local stylesheet is stored relative to the app root and a package one by the folder of its importing module
|
|
26
|
+
* and its package path ({@link formatPackageStylesheetEntry}). {@link resolvePackagePath} finds it from that folder
|
|
27
|
+
* in the package installed now, so a moved build, another store layout or a linked workspace package's own
|
|
28
|
+
* dependency resolves the file where it is, not where the build saw it.
|
|
29
|
+
*/
|
|
30
|
+
export function resolveDiscoveredStylesheets(config, rootDir) {
|
|
31
|
+
const { imported, plainModules, packages } = getDiscoveredStylesheets(config);
|
|
32
|
+
const packageEntries = new Set(packages);
|
|
33
|
+
const packagePaths = new Map();
|
|
34
|
+
const resolve = (entry) => {
|
|
35
|
+
if (!packageEntries.has(entry))
|
|
36
|
+
return path.resolve(rootDir, entry);
|
|
37
|
+
const { importerDir, packagePath } = parsePackageStylesheetEntry(entry);
|
|
38
|
+
const file = resolvePackagePath(path.resolve(rootDir, importerDir), packagePath);
|
|
39
|
+
packagePaths.set(file, packagePath);
|
|
40
|
+
return file;
|
|
41
|
+
};
|
|
42
|
+
return { imported: imported.map(resolve), plainModules: plainModules.map(resolve), packagePaths };
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Every inferred stylesheet of a declaration that development watches, as real paths.
|
|
46
|
+
*
|
|
47
|
+
* @remarks
|
|
48
|
+
* A package stylesheet installed under `node_modules` is left out, as the development watcher ignores that
|
|
49
|
+
* directory; one in a linked workspace package stays a watch path.
|
|
50
|
+
*/
|
|
51
|
+
export function resolveInferredStylesheets(config, rootDir) {
|
|
52
|
+
const { imported, plainModules } = resolveDiscoveredStylesheets(config, rootDir);
|
|
53
|
+
return [...imported, ...plainModules].filter((file) => !file.split('/').includes('node_modules'));
|
|
54
|
+
}
|
|
55
|
+
/** The watch files discovery recorded for a declaration, as paths of this app. */
|
|
56
|
+
export function resolveDiscoveredWatchFiles(config, rootDir) {
|
|
57
|
+
return getDiscoveredWatchFiles(config).map((file) => path.resolve(rootDir, file));
|
|
58
|
+
}
|
package/src/eco/eco.browser.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { applyPageLayoutConfig, mergeLayoutDependencies, normalizePageLayouts } from './page-layout-normalization.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a browser component that renders inline for every caller.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* A Component another Integration owns still renders its own result here. The React integration gives its own
|
|
7
|
+
* modules a boundary for such a Component when it builds them, so the factory does not know which Integration
|
|
8
|
+
* calls it.
|
|
9
|
+
*/
|
|
2
10
|
function createComponentFactory(options) {
|
|
3
11
|
const component = ((props) => options.render(props));
|
|
4
12
|
component.config = {
|
|
@@ -60,22 +68,10 @@ function page(options) {
|
|
|
60
68
|
}
|
|
61
69
|
return pageComponent;
|
|
62
70
|
}
|
|
63
|
-
function metadata(fn) {
|
|
64
|
-
return fn;
|
|
65
|
-
}
|
|
66
|
-
function staticPaths(fn) {
|
|
67
|
-
return fn;
|
|
68
|
-
}
|
|
69
|
-
function staticProps(fn) {
|
|
70
|
-
return fn;
|
|
71
|
-
}
|
|
72
71
|
export const eco = {
|
|
73
72
|
component,
|
|
74
73
|
embed,
|
|
75
74
|
html,
|
|
76
75
|
layout,
|
|
77
76
|
page,
|
|
78
|
-
metadata,
|
|
79
|
-
staticPaths,
|
|
80
|
-
staticProps,
|
|
81
77
|
};
|
package/src/eco/eco.js
CHANGED
|
@@ -149,33 +149,6 @@ function page(options) {
|
|
|
149
149
|
pageComponent.middleware = middleware;
|
|
150
150
|
return pageComponent;
|
|
151
151
|
}
|
|
152
|
-
/**
|
|
153
|
-
* Type-safe wrapper for metadata functions.
|
|
154
|
-
*
|
|
155
|
-
* @param fn Metadata factory function.
|
|
156
|
-
* @returns The same function.
|
|
157
|
-
*/
|
|
158
|
-
function metadata(fn) {
|
|
159
|
-
return fn;
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* Type-safe wrapper for static paths functions.
|
|
163
|
-
*
|
|
164
|
-
* @param fn Static paths function.
|
|
165
|
-
* @returns The same function.
|
|
166
|
-
*/
|
|
167
|
-
function staticPaths(fn) {
|
|
168
|
-
return fn;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Type-safe wrapper for static props functions.
|
|
172
|
-
*
|
|
173
|
-
* @param fn Static props function.
|
|
174
|
-
* @returns The same function.
|
|
175
|
-
*/
|
|
176
|
-
function staticProps(fn) {
|
|
177
|
-
return fn;
|
|
178
|
-
}
|
|
179
152
|
/**
|
|
180
153
|
* The eco namespace - provides factories for components and pages
|
|
181
154
|
*/
|
|
@@ -185,7 +158,4 @@ export const eco = {
|
|
|
185
158
|
html,
|
|
186
159
|
layout,
|
|
187
160
|
page,
|
|
188
|
-
metadata,
|
|
189
|
-
staticPaths,
|
|
190
|
-
staticProps,
|
|
191
161
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { GetMetadata } from '../types/contracts.js';
|
|
2
|
+
/**
|
|
3
|
+
* Moves an MDX module's `getMetadata` export onto its Page as `metadata`.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* MDX cannot call `eco.page(...)`, so its metadata export is the one module-level data export that
|
|
7
|
+
* stays. Core reads page data from the Page only, so the integration moves the export before core
|
|
8
|
+
* sees the module and leaves no `getMetadata` key behind.
|
|
9
|
+
*/
|
|
10
|
+
export declare function moveMdxMetadataOntoPage<T extends {
|
|
11
|
+
default: unknown;
|
|
12
|
+
}>(pageModule: T & {
|
|
13
|
+
getMetadata?: GetMetadata;
|
|
14
|
+
}): Omit<T, 'getMetadata'>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Moves an MDX module's `getMetadata` export onto its Page as `metadata`.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* MDX cannot call `eco.page(...)`, so its metadata export is the one module-level data export that
|
|
6
|
+
* stays. Core reads page data from the Page only, so the integration moves the export before core
|
|
7
|
+
* sees the module and leaves no `getMetadata` key behind.
|
|
8
|
+
*/
|
|
9
|
+
export function moveMdxMetadataOntoPage(pageModule) {
|
|
10
|
+
const { getMetadata, ...rest } = pageModule;
|
|
11
|
+
if (getMetadata) {
|
|
12
|
+
rest.default.metadata = getMetadata;
|
|
13
|
+
}
|
|
14
|
+
return rest;
|
|
15
|
+
}
|
|
@@ -2,9 +2,13 @@ import type { EcoComponentConfig, EcoComponentDependencies, EcoPageLayoutEntry,
|
|
|
2
2
|
/**
|
|
3
3
|
* Normalizes `layout` page options to an outer→inner stack of layout entries.
|
|
4
4
|
*/
|
|
5
|
-
export declare function normalizePageLayouts<E>(layout?: EcoPageLayouts<E>): EcoPageLayoutEntry
|
|
5
|
+
export declare function normalizePageLayouts<E>(layout?: EcoPageLayouts<E>): EcoPageLayoutEntry[];
|
|
6
6
|
/**
|
|
7
|
-
* Merges layout components into `dependencies.components` without duplicates.
|
|
7
|
+
* Merges `eco.layout()` components into `dependencies.components` without duplicates.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* A plain layout function carries no `config`, so it stays out: it is composed, not rendered as a declared
|
|
11
|
+
* dependency, and the assets it imports reach the page through plain-module discovery.
|
|
8
12
|
*/
|
|
9
13
|
export declare function mergeLayoutDependencies(dependencies: EcoComponentDependencies | undefined, layoutEntries: EcoPageLayoutEntry[]): EcoComponentDependencies | undefined;
|
|
10
14
|
/**
|
|
@@ -16,20 +16,23 @@ export function normalizePageLayouts(layout) {
|
|
|
16
16
|
props: spec.props,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
return {
|
|
20
|
-
component: spec,
|
|
21
|
-
};
|
|
19
|
+
return { component: spec };
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
/**
|
|
25
|
-
* Merges layout components into `dependencies.components` without duplicates.
|
|
23
|
+
* Merges `eco.layout()` components into `dependencies.components` without duplicates.
|
|
24
|
+
*
|
|
25
|
+
* @remarks
|
|
26
|
+
* A plain layout function carries no `config`, so it stays out: it is composed, not rendered as a declared
|
|
27
|
+
* dependency, and the assets it imports reach the page through plain-module discovery.
|
|
26
28
|
*/
|
|
27
29
|
export function mergeLayoutDependencies(dependencies, layoutEntries) {
|
|
28
|
-
|
|
30
|
+
const declaredLayouts = layoutEntries.filter((entry) => entry.component.config !== undefined);
|
|
31
|
+
if (declaredLayouts.length === 0) {
|
|
29
32
|
return dependencies;
|
|
30
33
|
}
|
|
31
34
|
const mergedComponents = [...(dependencies?.components ?? [])];
|
|
32
|
-
for (const entry of
|
|
35
|
+
for (const entry of declaredLayouts) {
|
|
33
36
|
if (!mergedComponents.includes(entry.component)) {
|
|
34
37
|
mergedComponents.push(entry.component);
|
|
35
38
|
}
|
package/src/env.js
CHANGED
|
@@ -15,6 +15,23 @@ export function isEcopagesEnvDisabled(name, environment) {
|
|
|
15
15
|
export function getNodeEnvironment(environment) {
|
|
16
16
|
return environment === undefined ? process.env.NODE_ENV : environment[nodeEnvironmentVariable];
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Sets the runtime mode of this process and returns a function that restores the previous one.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* For tests that check behavior by runtime mode and run under a runner with no environment stubbing of its own,
|
|
23
|
+
* such as the Processor contract cases.
|
|
24
|
+
*/
|
|
25
|
+
export function setNodeEnvironment(mode) {
|
|
26
|
+
const previous = process.env[nodeEnvironmentVariable];
|
|
27
|
+
process.env[nodeEnvironmentVariable] = mode;
|
|
28
|
+
return () => {
|
|
29
|
+
if (previous === undefined)
|
|
30
|
+
delete process.env[nodeEnvironmentVariable];
|
|
31
|
+
else
|
|
32
|
+
process.env[nodeEnvironmentVariable] = previous;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
18
35
|
export function isDevelopmentRuntime(environment) {
|
|
19
36
|
return getNodeEnvironment(environment) === 'development';
|
|
20
37
|
}
|
|
@@ -119,21 +119,22 @@ import { resetBuildErrors, reportBuildError } from './build-error-presentation.j
|
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
-
*
|
|
123
|
-
*
|
|
122
|
+
* Re-fetches the stylesheet links whose pathname is `href`, the exact href the server sent, through a `t` query.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* Both sides go through `URL`, so a path with a space or a non-ASCII character compares percent-encoded on both.
|
|
124
126
|
*/
|
|
125
|
-
function refreshStylesheet(
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
console.log('[ecopages] CSS updated:', filename);
|
|
135
|
-
}
|
|
127
|
+
function refreshStylesheet(href) {
|
|
128
|
+
const pathname = new URL(href, location.href).pathname;
|
|
129
|
+
document.querySelectorAll('link[rel="stylesheet"]').forEach((link) => {
|
|
130
|
+
const url = new URL(link.href, location.href);
|
|
131
|
+
if (url.pathname !== pathname)
|
|
132
|
+
return;
|
|
133
|
+
url.searchParams.set('t', Date.now().toString());
|
|
134
|
+
link.href = url.toString();
|
|
135
|
+
console.log('[ecopages] CSS updated:', href);
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
|
+
getEcoNavigationRuntime(window).enableReloadStatePreservation();
|
|
138
139
|
connect();
|
|
139
140
|
})();
|
|
@@ -30,10 +30,13 @@ export declare function bundleDevClientRuntime(runtime: DevClientRuntime, browse
|
|
|
30
30
|
/** Serves the bundle of a runtime, or returns `null` when it was not emitted. */
|
|
31
31
|
export declare function readDevClientRuntime(runtime: DevClientRuntime): Response | null;
|
|
32
32
|
/**
|
|
33
|
-
* Loads each runtime from an HTML response with a module script before `</html
|
|
33
|
+
* Loads each runtime from an HTML response with a module script at the start of `<head>`, or before `</html>`
|
|
34
|
+
* when the document has no head.
|
|
34
35
|
*
|
|
35
36
|
* @remarks
|
|
36
37
|
* A runtime already imported by the document is skipped, because a response can pass through more than one
|
|
37
|
-
* development layer before it reaches the client.
|
|
38
|
+
* development layer before it reaches the client. Module scripts run in document order, so the runtimes run
|
|
39
|
+
* before the page's scripts: the HMR client asks the navigation runtime to preserve reload state before a page
|
|
40
|
+
* script changes the markup the router records.
|
|
38
41
|
*/
|
|
39
42
|
export declare function injectDevClientRuntimes(response: Response, runtimes: readonly DevClientRuntime[]): Promise<Response>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import path from '
|
|
1
|
+
import { path } from '@ecopages/file-system/path';
|
|
2
2
|
import { fileSystem } from '@ecopages/file-system';
|
|
3
3
|
import { removeStaleHmrEntrypointOutput } from './hmr-entrypoint-output.js';
|
|
4
4
|
/** Absolute path of the bundle a runtime emits. */
|
|
@@ -51,12 +51,22 @@ export function readDevClientRuntime(runtime) {
|
|
|
51
51
|
},
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
function insertDevClientScripts(html, scripts) {
|
|
55
|
+
const headStart = /<head(?:\s[^>]*)?>/i;
|
|
56
|
+
if (headStart.test(html)) {
|
|
57
|
+
return html.replace(headStart, (head) => `${head}${scripts}`);
|
|
58
|
+
}
|
|
59
|
+
return html.replace(/<\/html>/i, `${scripts}</html>`);
|
|
60
|
+
}
|
|
54
61
|
/**
|
|
55
|
-
* Loads each runtime from an HTML response with a module script before `</html
|
|
62
|
+
* Loads each runtime from an HTML response with a module script at the start of `<head>`, or before `</html>`
|
|
63
|
+
* when the document has no head.
|
|
56
64
|
*
|
|
57
65
|
* @remarks
|
|
58
66
|
* A runtime already imported by the document is skipped, because a response can pass through more than one
|
|
59
|
-
* development layer before it reaches the client.
|
|
67
|
+
* development layer before it reaches the client. Module scripts run in document order, so the runtimes run
|
|
68
|
+
* before the page's scripts: the HMR client asks the navigation runtime to preserve reload state before a page
|
|
69
|
+
* script changes the markup the router records.
|
|
60
70
|
*/
|
|
61
71
|
export async function injectDevClientRuntimes(response, runtimes) {
|
|
62
72
|
if (runtimes.length === 0) {
|
|
@@ -70,7 +80,7 @@ export async function injectDevClientRuntimes(response, runtimes) {
|
|
|
70
80
|
.filter((specifier) => !html.includes(specifier))
|
|
71
81
|
.map((specifier) => `<script type="module">${specifier};</script>`)
|
|
72
82
|
.join('');
|
|
73
|
-
return new Response(scripts ?
|
|
83
|
+
return new Response(scripts ? insertDevClientScripts(html, scripts) : html, {
|
|
74
84
|
status: response.status,
|
|
75
85
|
statusText: response.statusText,
|
|
76
86
|
headers,
|