every-plugin 2.10.0 → 3.0.0-rc.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/bin/every-plugin-serve.mjs +12 -0
- package/bin/every-plugin.mjs +59 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/build/artifact-names.cjs +119 -0
- package/dist/build/artifact-names.cjs.map +1 -0
- package/dist/build/artifact-names.d.cts +68 -0
- package/dist/build/artifact-names.d.cts.map +1 -0
- package/dist/build/artifact-names.d.mts +68 -0
- package/dist/build/artifact-names.d.mts.map +1 -0
- package/dist/build/artifact-names.mjs +102 -0
- package/dist/build/artifact-names.mjs.map +1 -0
- package/dist/build/contract-types.cjs +89 -0
- package/dist/build/contract-types.cjs.map +1 -0
- package/dist/build/contract-types.mjs +81 -0
- package/dist/build/contract-types.mjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.cjs +37 -0
- package/dist/build/rspack/build-report-plugin.cjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.cts +18 -0
- package/dist/build/rspack/build-report-plugin.d.cts.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.mts +18 -0
- package/dist/build/rspack/build-report-plugin.d.mts.map +1 -0
- package/dist/build/rspack/build-report-plugin.mjs +37 -0
- package/dist/build/rspack/build-report-plugin.mjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs +47 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs +47 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs.map +1 -0
- package/dist/build/rspack/compose.cjs +69 -0
- package/dist/build/rspack/compose.cjs.map +1 -0
- package/dist/build/rspack/compose.d.cts +20 -0
- package/dist/build/rspack/compose.d.cts.map +1 -0
- package/dist/build/rspack/compose.d.mts +20 -0
- package/dist/build/rspack/compose.d.mts.map +1 -0
- package/dist/build/rspack/compose.mjs +65 -0
- package/dist/build/rspack/compose.mjs.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +11 -11
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +11 -10
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
- package/dist/build/rspack/generated-config.cjs +35 -0
- package/dist/build/rspack/generated-config.cjs.map +1 -0
- package/dist/build/rspack/generated-config.mjs +32 -0
- package/dist/build/rspack/generated-config.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +8 -5
- package/dist/build/rspack/index.d.cts +5 -3
- package/dist/build/rspack/index.d.mts +5 -3
- package/dist/build/rspack/index.mjs +5 -3
- package/dist/build/rspack/module-federation.cjs +2 -2
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +44 -69
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +4 -13
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +4 -13
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +44 -69
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs +7 -5
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs +7 -6
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/ui/factory.cjs +88 -0
- package/dist/build/ui/factory.cjs.map +1 -0
- package/dist/build/ui/factory.d.cts +11 -0
- package/dist/build/ui/factory.d.cts.map +1 -0
- package/dist/build/ui/factory.d.mts +11 -0
- package/dist/build/ui/factory.d.mts.map +1 -0
- package/dist/build/ui/factory.mjs +80 -0
- package/dist/build/ui/factory.mjs.map +1 -0
- package/dist/build/ui/generated-config.cjs +118 -0
- package/dist/build/ui/generated-config.cjs.map +1 -0
- package/dist/build/ui/generated-config.d.cts +33 -0
- package/dist/build/ui/generated-config.d.cts.map +1 -0
- package/dist/build/ui/generated-config.d.mts +33 -0
- package/dist/build/ui/generated-config.d.mts.map +1 -0
- package/dist/build/ui/generated-config.mjs +111 -0
- package/dist/build/ui/generated-config.mjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs +61 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs +58 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs.map +1 -0
- package/dist/build/ui/index.cjs +90 -0
- package/dist/build/ui/index.cjs.map +1 -0
- package/dist/build/ui/index.d.cts +29 -0
- package/dist/build/ui/index.d.cts.map +1 -0
- package/dist/build/ui/index.d.mts +29 -0
- package/dist/build/ui/index.d.mts.map +1 -0
- package/dist/build/ui/index.mjs +68 -0
- package/dist/build/ui/index.mjs.map +1 -0
- package/dist/build/ui/manifest-plugin.cjs +37 -0
- package/dist/build/ui/manifest-plugin.cjs.map +1 -0
- package/dist/build/ui/manifest-plugin.d.cts +19 -0
- package/dist/build/ui/manifest-plugin.d.cts.map +1 -0
- package/dist/build/ui/manifest-plugin.d.mts +19 -0
- package/dist/build/ui/manifest-plugin.d.mts.map +1 -0
- package/dist/build/ui/manifest-plugin.mjs +37 -0
- package/dist/build/ui/manifest-plugin.mjs.map +1 -0
- package/dist/build/ui/rsbuild-config.cjs +203 -0
- package/dist/build/ui/rsbuild-config.cjs.map +1 -0
- package/dist/build/ui/rsbuild-config.d.cts +45 -0
- package/dist/build/ui/rsbuild-config.d.cts.map +1 -0
- package/dist/build/ui/rsbuild-config.d.mts +45 -0
- package/dist/build/ui/rsbuild-config.d.mts.map +1 -0
- package/dist/build/ui/rsbuild-config.mjs +200 -0
- package/dist/build/ui/rsbuild-config.mjs.map +1 -0
- package/dist/build/ui/stubs.cjs +107 -0
- package/dist/build/ui/stubs.cjs.map +1 -0
- package/dist/build/ui/stubs.d.cts +25 -0
- package/dist/build/ui/stubs.d.cts.map +1 -0
- package/dist/build/ui/stubs.d.mts +25 -0
- package/dist/build/ui/stubs.d.mts.map +1 -0
- package/dist/build/ui/stubs.mjs +106 -0
- package/dist/build/ui/stubs.mjs.map +1 -0
- package/dist/cli.cjs +83 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +6 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +6 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +82 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/dev/serve.cjs +390 -0
- package/dist/dev/serve.cjs.map +1 -0
- package/dist/dev/serve.d.cts +23 -0
- package/dist/dev/serve.d.cts.map +1 -0
- package/dist/dev/serve.d.mts +23 -0
- package/dist/dev/serve.d.mts.map +1 -0
- package/dist/dev/serve.mjs +384 -0
- package/dist/dev/serve.mjs.map +1 -0
- package/dist/dev/watch-kill.cjs +39 -0
- package/dist/dev/watch-kill.cjs.map +1 -0
- package/dist/dev/watch-kill.mjs +38 -0
- package/dist/dev/watch-kill.mjs.map +1 -0
- package/dist/effect-helpers.cjs +23 -0
- package/dist/effect-helpers.cjs.map +1 -0
- package/dist/effect-helpers.d.cts +20 -0
- package/dist/effect-helpers.d.cts.map +1 -0
- package/dist/effect-helpers.d.mts +20 -0
- package/dist/effect-helpers.d.mts.map +1 -0
- package/dist/effect-helpers.mjs +22 -0
- package/dist/effect-helpers.mjs.map +1 -0
- package/dist/errors.cjs +49 -69
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +13 -96
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +13 -96
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +16 -34
- package/dist/errors.mjs.map +1 -1
- package/dist/identity.cjs +19 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +33 -0
- package/dist/identity.d.cts.map +1 -0
- package/dist/identity.d.mts +33 -0
- package/dist/identity.d.mts.map +1 -0
- package/dist/identity.mjs +16 -0
- package/dist/identity.mjs.map +1 -0
- package/dist/index.cjs +8 -5
- package/dist/index.d.cts +8 -6
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +6 -4
- package/dist/plugin.cjs +12 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +44 -25
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +45 -26
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +15 -29
- package/dist/plugin.mjs.map +1 -1
- package/dist/remote-entry.cjs +103 -0
- package/dist/remote-entry.cjs.map +1 -0
- package/dist/remote-entry.d.cts +53 -0
- package/dist/remote-entry.d.cts.map +1 -0
- package/dist/remote-entry.d.mts +53 -0
- package/dist/remote-entry.d.mts.map +1 -0
- package/dist/remote-entry.mjs +98 -0
- package/dist/remote-entry.mjs.map +1 -0
- package/dist/runtime/errors.cjs +140 -34
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +42 -7
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +42 -7
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +136 -31
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +95 -23
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +16 -0
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +16 -0
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +98 -26
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +3 -78
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts +3 -49
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts +3 -49
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +5 -78
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +63 -12
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +4 -13
- package/dist/runtime/services/module-federation.service.d.mts +4 -13
- package/dist/runtime/services/module-federation.service.mjs +63 -14
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs +2 -22
- package/dist/runtime/services/normalize.d.cts +2 -21
- package/dist/runtime/services/normalize.d.mts +2 -21
- package/dist/runtime/services/normalize.mjs +2 -21
- package/dist/runtime/services/plugin-lifecycle.service.cjs +9 -11
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.mjs +10 -13
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +30 -29
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +6 -53
- package/dist/runtime/services/plugin-loader.service.d.mts +6 -53
- package/dist/runtime/services/plugin-loader.service.mjs +29 -30
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +10 -12
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +14 -36
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +14 -36
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs +14 -18
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs +12 -12
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts +3 -15
- package/dist/runtime/services/secrets.service.d.mts +3 -15
- package/dist/runtime/services/secrets.service.mjs +12 -13
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/services/shared-identity.cjs +40 -0
- package/dist/runtime/services/shared-identity.cjs.map +1 -0
- package/dist/runtime/services/shared-identity.mjs +38 -0
- package/dist/runtime/services/shared-identity.mjs.map +1 -0
- package/dist/runtime/validation.cjs +2 -2
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs +2 -2
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/shared-deps-spec.cjs +384 -0
- package/dist/shared-deps-spec.cjs.map +1 -0
- package/dist/shared-deps-spec.d.cts +182 -0
- package/dist/shared-deps-spec.d.cts.map +1 -0
- package/dist/shared-deps-spec.d.mts +182 -0
- package/dist/shared-deps-spec.d.mts.map +1 -0
- package/dist/shared-deps-spec.mjs +368 -0
- package/dist/shared-deps-spec.mjs.map +1 -0
- package/dist/types.d.cts +22 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +22 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/ui/manifest/construct.cjs +268 -0
- package/dist/ui/manifest/construct.cjs.map +1 -0
- package/dist/ui/manifest/construct.d.cts +48 -0
- package/dist/ui/manifest/construct.d.cts.map +1 -0
- package/dist/ui/manifest/construct.d.mts +48 -0
- package/dist/ui/manifest/construct.d.mts.map +1 -0
- package/dist/ui/manifest/construct.mjs +268 -0
- package/dist/ui/manifest/construct.mjs.map +1 -0
- package/dist/ui/manifest/contract.cjs +34 -0
- package/dist/ui/manifest/contract.cjs.map +1 -0
- package/dist/ui/manifest/contract.d.cts +26 -0
- package/dist/ui/manifest/contract.d.cts.map +1 -0
- package/dist/ui/manifest/contract.d.mts +26 -0
- package/dist/ui/manifest/contract.d.mts.map +1 -0
- package/dist/ui/manifest/contract.mjs +26 -0
- package/dist/ui/manifest/contract.mjs.map +1 -0
- package/dist/ui/manifest/descriptor.cjs +64 -0
- package/dist/ui/manifest/descriptor.cjs.map +1 -0
- package/dist/ui/manifest/descriptor.d.cts +60 -0
- package/dist/ui/manifest/descriptor.d.cts.map +1 -0
- package/dist/ui/manifest/descriptor.d.mts +60 -0
- package/dist/ui/manifest/descriptor.d.mts.map +1 -0
- package/dist/ui/manifest/descriptor.mjs +61 -0
- package/dist/ui/manifest/descriptor.mjs.map +1 -0
- package/dist/ui/manifest/generator.cjs +128 -0
- package/dist/ui/manifest/generator.cjs.map +1 -0
- package/dist/ui/manifest/generator.d.cts +41 -0
- package/dist/ui/manifest/generator.d.cts.map +1 -0
- package/dist/ui/manifest/generator.d.mts +41 -0
- package/dist/ui/manifest/generator.d.mts.map +1 -0
- package/dist/ui/manifest/generator.mjs +125 -0
- package/dist/ui/manifest/generator.mjs.map +1 -0
- package/dist/ui/manifest/index.cjs +35 -0
- package/dist/ui/manifest/index.d.cts +9 -0
- package/dist/ui/manifest/index.d.mts +9 -0
- package/dist/ui/manifest/index.mjs +9 -0
- package/dist/ui/manifest/manifest-schema.cjs +97 -0
- package/dist/ui/manifest/manifest-schema.cjs.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.cts +132 -0
- package/dist/ui/manifest/manifest-schema.d.cts.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.mts +132 -0
- package/dist/ui/manifest/manifest-schema.d.mts.map +1 -0
- package/dist/ui/manifest/manifest-schema.mjs +90 -0
- package/dist/ui/manifest/manifest-schema.mjs.map +1 -0
- package/dist/ui/manifest/mount-registry.cjs +52 -0
- package/dist/ui/manifest/mount-registry.cjs.map +1 -0
- package/dist/ui/manifest/mount-registry.d.cts +61 -0
- package/dist/ui/manifest/mount-registry.d.cts.map +1 -0
- package/dist/ui/manifest/mount-registry.d.mts +61 -0
- package/dist/ui/manifest/mount-registry.d.mts.map +1 -0
- package/dist/ui/manifest/mount-registry.mjs +48 -0
- package/dist/ui/manifest/mount-registry.mjs.map +1 -0
- package/dist/ui/manifest/nav.cjs +13 -0
- package/dist/ui/manifest/nav.cjs.map +1 -0
- package/dist/ui/manifest/nav.d.cts +34 -0
- package/dist/ui/manifest/nav.d.cts.map +1 -0
- package/dist/ui/manifest/nav.d.mts +34 -0
- package/dist/ui/manifest/nav.d.mts.map +1 -0
- package/dist/ui/manifest/nav.mjs +13 -0
- package/dist/ui/manifest/nav.mjs.map +1 -0
- package/dist/ui/manifest/route-config.cjs +33 -0
- package/dist/ui/manifest/route-config.cjs.map +1 -0
- package/dist/ui/manifest/route-config.d.cts +40 -0
- package/dist/ui/manifest/route-config.d.cts.map +1 -0
- package/dist/ui/manifest/route-config.d.mts +40 -0
- package/dist/ui/manifest/route-config.d.mts.map +1 -0
- package/dist/ui/manifest/route-config.mjs +33 -0
- package/dist/ui/manifest/route-config.mjs.map +1 -0
- package/dist/version-manifest.cjs +65 -0
- package/dist/version-manifest.cjs.map +1 -0
- package/dist/version-manifest.d.cts +52 -0
- package/dist/version-manifest.d.cts.map +1 -0
- package/dist/version-manifest.d.mts +52 -0
- package/dist/version-manifest.d.mts.map +1 -0
- package/dist/version-manifest.mjs +63 -0
- package/dist/version-manifest.mjs.map +1 -0
- package/package.json +165 -68
- package/skills/plugin-client/SKILL.md +24 -5
- package/skills/plugin-development/SKILL.md +79 -47
- package/skills/plugin-testing/SKILL.md +41 -12
- package/src/build/artifact-names.ts +117 -0
- package/src/build/contract-types.ts +101 -0
- package/src/build/rspack/build-report-plugin.ts +34 -0
- package/src/build/rspack/chunk-completeness-plugin.ts +57 -0
- package/src/build/rspack/compose.ts +87 -0
- package/src/build/rspack/fix-mf-data-uri-plugin.ts +23 -12
- package/src/build/rspack/generated-config.ts +35 -0
- package/src/build/rspack/index.ts +10 -5
- package/src/build/rspack/module-federation.ts +1 -1
- package/src/build/rspack/plugin.ts +103 -105
- package/src/build/rspack/utils.ts +8 -2
- package/src/build/ui/factory.ts +96 -0
- package/src/build/ui/generated-config.ts +133 -0
- package/src/build/ui/hash-artifacts-plugin.ts +79 -0
- package/src/build/ui/index.ts +98 -0
- package/src/build/ui/manifest-plugin.ts +54 -0
- package/src/build/ui/rsbuild-config.ts +256 -0
- package/src/build/ui/stubs.ts +103 -0
- package/src/cli.ts +100 -0
- package/src/dev/serve.ts +477 -0
- package/src/dev/watch-kill.ts +58 -0
- package/src/effect-helpers.ts +25 -0
- package/src/errors.ts +16 -18
- package/src/identity.ts +36 -0
- package/src/index.ts +4 -0
- package/src/plugin.ts +70 -92
- package/src/remote-entry.ts +171 -0
- package/src/runtime/errors.ts +186 -27
- package/src/runtime/index.ts +132 -43
- package/src/runtime/mf-config.ts +12 -107
- package/src/runtime/services/module-federation.service.ts +221 -117
- package/src/runtime/services/normalize.ts +1 -18
- package/src/runtime/services/plugin-lifecycle.service.ts +66 -75
- package/src/runtime/services/plugin-loader.service.ts +239 -212
- package/src/runtime/services/plugin.service.ts +61 -43
- package/src/runtime/services/secrets.service.ts +20 -15
- package/src/runtime/services/shared-identity.ts +68 -0
- package/src/runtime/validation.ts +5 -7
- package/src/shared-deps-spec.ts +478 -0
- package/src/types.ts +22 -48
- package/src/ui/manifest/construct.ts +403 -0
- package/src/ui/manifest/contract.ts +33 -0
- package/src/ui/manifest/descriptor.ts +96 -0
- package/src/ui/manifest/generator.ts +238 -0
- package/src/ui/manifest/index.ts +55 -0
- package/src/ui/manifest/manifest-schema.ts +107 -0
- package/src/ui/manifest/mount-registry.ts +50 -0
- package/src/ui/manifest/nav.ts +43 -0
- package/src/ui/manifest/route-config.ts +82 -0
- package/src/version-manifest.ts +88 -0
- package/dist/build/rspack/dev-server-middleware.cjs +0 -194
- package/dist/build/rspack/dev-server-middleware.cjs.map +0 -1
- package/dist/build/rspack/dev-server-middleware.mjs +0 -193
- package/dist/build/rspack/dev-server-middleware.mjs.map +0 -1
- package/dist/build/shared-deps.cjs +0 -83
- package/dist/build/shared-deps.cjs.map +0 -1
- package/dist/build/shared-deps.d.cts +0 -67
- package/dist/build/shared-deps.d.cts.map +0 -1
- package/dist/build/shared-deps.d.mts +0 -67
- package/dist/build/shared-deps.d.mts.map +0 -1
- package/dist/build/shared-deps.mjs +0 -79
- package/dist/build/shared-deps.mjs.map +0 -1
- package/dist/effect.cjs +0 -9
- package/dist/effect.d.cts +0 -1
- package/dist/effect.d.mts +0 -1
- package/dist/effect.mjs +0 -3
- package/dist/orpc-openapi.cjs +0 -17
- package/dist/orpc-openapi.d.cts +0 -2
- package/dist/orpc-openapi.d.mts +0 -2
- package/dist/orpc-openapi.mjs +0 -5
- package/dist/orpc.cjs +0 -46
- package/dist/orpc.d.cts +0 -7
- package/dist/orpc.d.mts +0 -7
- package/dist/orpc.mjs +0 -11
- package/dist/package.cjs +0 -23
- package/dist/package.cjs.map +0 -1
- package/dist/package.mjs +0 -17
- package/dist/package.mjs.map +0 -1
- package/dist/runtime/services/module-federation.service.d.cts.map +0 -1
- package/dist/runtime/services/module-federation.service.d.mts.map +0 -1
- package/dist/runtime/services/normalize.cjs.map +0 -1
- package/dist/runtime/services/normalize.d.cts.map +0 -1
- package/dist/runtime/services/normalize.d.mts.map +0 -1
- package/dist/runtime/services/normalize.mjs.map +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +0 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +0 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +0 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +0 -1
- package/dist/runtime/services/secrets.service.d.cts.map +0 -1
- package/dist/runtime/services/secrets.service.d.mts.map +0 -1
- package/dist/testing/index.cjs +0 -57
- package/dist/testing/index.cjs.map +0 -1
- package/dist/testing/index.d.cts +0 -54
- package/dist/testing/index.d.cts.map +0 -1
- package/dist/testing/index.d.mts +0 -54
- package/dist/testing/index.d.mts.map +0 -1
- package/dist/testing/index.mjs +0 -55
- package/dist/testing/index.mjs.map +0 -1
- package/dist/zod-core.cjs +0 -9
- package/dist/zod-core.d.cts +0 -1
- package/dist/zod-core.d.mts +0 -1
- package/dist/zod-core.mjs +0 -3
- package/dist/zod.cjs +0 -11
- package/dist/zod.d.cts +0 -2
- package/dist/zod.d.mts +0 -2
- package/dist/zod.mjs +0 -3
- package/src/build/rspack/dev-server-middleware.ts +0 -250
- package/src/build/shared-deps.ts +0 -102
- package/src/effect.ts +0 -1
- package/src/orpc-openapi.ts +0 -2
- package/src/orpc.ts +0 -9
- package/src/testing/index.ts +0 -87
- package/src/testing/mocks/module-federation.service.ts +0 -41
- package/src/zod-core.ts +0 -1
- package/src/zod.ts +0 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CORE_UI_PLUGIN_KEY } from "../../ui/manifest/contract.mjs";
|
|
2
|
+
import { createUiRsbuildConfig } from "./rsbuild-config.mjs";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
|
|
6
|
+
//#region src/build/ui/factory.ts
|
|
7
|
+
/**
|
|
8
|
+
* The core ui's rsbuild factory — the workspace-form counterpart of
|
|
9
|
+
* `createUiRsbuildConfig` (folder-form plugin uis). The config object the
|
|
10
|
+
* generated `.every-plugin/ui.rsbuild.config.generated.mjs` materializes:
|
|
11
|
+
* the APP_NAME/APP_ACCOUNT defines come from the authored config through
|
|
12
|
+
* `readAuthoredConfigInput` (everything-dev/config), which the generated
|
|
13
|
+
* file loads in the workspace's own module graph.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* The platform skill family ships inside the framework packages' npm tarballs
|
|
17
|
+
* (`files: ["skills"]`), so resolving them from `node_modules` gives the core
|
|
18
|
+
* ui the same copies in the parent workspace (pnpm symlinks) and every
|
|
19
|
+
* generated child repo (published tarball). Served at `/skills/<pkg>/<skill>`.
|
|
20
|
+
*/
|
|
21
|
+
const SKILL_PACKAGES = [
|
|
22
|
+
"everything-dev",
|
|
23
|
+
"every-plugin",
|
|
24
|
+
"better-near-auth"
|
|
25
|
+
];
|
|
26
|
+
function platformSkillCopies(workspaceRoot) {
|
|
27
|
+
return SKILL_PACKAGES.flatMap((name) => {
|
|
28
|
+
const from = path.join(workspaceRoot, "node_modules", name, "skills");
|
|
29
|
+
return fs.existsSync(from) ? [{
|
|
30
|
+
from,
|
|
31
|
+
to: `./skills/${name}`,
|
|
32
|
+
globOptions: { ignore: ["**/_artifacts/**"] }
|
|
33
|
+
}] : [];
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The core ui's MF build surface — entry points and the declared exposes
|
|
38
|
+
* (ADR 0008 §2). Entries and the bootstrap exposes resolve to GENERATED
|
|
39
|
+
* stubs (ADR 0023); only surfaces with consumers are declared: the browser
|
|
40
|
+
* bootstrap, the shared component barrel, the SSR router module, the
|
|
41
|
+
* composition engine, and the generated route config.
|
|
42
|
+
*/
|
|
43
|
+
const CORE_UI_WEB_ENTRY = "./src/entry.gen.ts";
|
|
44
|
+
const CORE_UI_WEB_EXPOSES = {
|
|
45
|
+
"./Hydrate": "./src/hydrate.gen.tsx",
|
|
46
|
+
"./components": "./src/components/index.ts"
|
|
47
|
+
};
|
|
48
|
+
const CORE_UI_NODE_ENTRY = "./src/router.server.gen.tsx";
|
|
49
|
+
const CORE_UI_NODE_EXPOSES = {
|
|
50
|
+
"./Router": "./src/router.server.gen.tsx",
|
|
51
|
+
"./compose": "./src/compose.gen.ts",
|
|
52
|
+
"./routeConfig": "./src/routeConfig.gen.ts"
|
|
53
|
+
};
|
|
54
|
+
function createCoreUiRsbuildConfig({ domain, account } = {}) {
|
|
55
|
+
const workspaceRoot = process.cwd();
|
|
56
|
+
const pkg = JSON.parse(fs.readFileSync(path.join(workspaceRoot, "package.json"), "utf-8"));
|
|
57
|
+
return createUiRsbuildConfig({
|
|
58
|
+
workspaceRoot,
|
|
59
|
+
pkg,
|
|
60
|
+
role: "provider",
|
|
61
|
+
manifestName: "ui",
|
|
62
|
+
devPort: 3003,
|
|
63
|
+
webEntry: CORE_UI_WEB_ENTRY,
|
|
64
|
+
webExposes: CORE_UI_WEB_EXPOSES,
|
|
65
|
+
nodeEntry: CORE_UI_NODE_ENTRY,
|
|
66
|
+
nodeExposes: CORE_UI_NODE_EXPOSES,
|
|
67
|
+
copy: [{
|
|
68
|
+
from: path.join(workspaceRoot, "public"),
|
|
69
|
+
to: "./"
|
|
70
|
+
}, ...platformSkillCopies(workspaceRoot)],
|
|
71
|
+
define: {
|
|
72
|
+
"import.meta.env.APP_NAME": JSON.stringify(domain),
|
|
73
|
+
"import.meta.env.APP_ACCOUNT": JSON.stringify(account)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
export { CORE_UI_NODE_ENTRY, CORE_UI_NODE_EXPOSES, CORE_UI_WEB_ENTRY, CORE_UI_WEB_EXPOSES, createCoreUiRsbuildConfig, platformSkillCopies };
|
|
80
|
+
//# sourceMappingURL=factory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.mjs","names":[],"sources":["../../../src/build/ui/factory.ts"],"sourcesContent":["/**\n * The core ui's rsbuild factory — the workspace-form counterpart of\n * `createUiRsbuildConfig` (folder-form plugin uis). The config object the\n * generated `.every-plugin/ui.rsbuild.config.generated.mjs` materializes:\n * the APP_NAME/APP_ACCOUNT defines come from the authored config through\n * `readAuthoredConfigInput` (everything-dev/config), which the generated\n * file loads in the workspace's own module graph.\n */\n\nimport fs from \"node:fs\";\nimport path from \"node:path\";\nimport { CORE_UI_PLUGIN_KEY } from \"../../ui/manifest/contract\";\nimport { createUiRsbuildConfig } from \"./rsbuild-config\";\n\n/**\n * The platform skill family ships inside the framework packages' npm tarballs\n * (`files: [\"skills\"]`), so resolving them from `node_modules` gives the core\n * ui the same copies in the parent workspace (pnpm symlinks) and every\n * generated child repo (published tarball). Served at `/skills/<pkg>/<skill>`.\n */\nconst SKILL_PACKAGES = [\"everything-dev\", \"every-plugin\", \"better-near-auth\"] as const;\n\nexport function platformSkillCopies(workspaceRoot: string): Array<{\n from: string;\n to: string;\n globOptions: { ignore: string[] };\n}> {\n return SKILL_PACKAGES.flatMap((name) => {\n const from = path.join(workspaceRoot, \"node_modules\", name, \"skills\");\n return fs.existsSync(from)\n ? [\n {\n from,\n to: `./skills/${name}`,\n globOptions: { ignore: [\"**/_artifacts/**\"] },\n },\n ]\n : [];\n });\n}\n\nexport interface CoreUiRsbuildConfigInput {\n /** Authored config domain — stamped as `import.meta.env.APP_NAME`. */\n domain?: string;\n /** Authored config account — stamped as `import.meta.env.APP_ACCOUNT`. */\n account?: string;\n}\n\n/**\n * The core ui's MF build surface — entry points and the declared exposes\n * (ADR 0008 §2). Entries and the bootstrap exposes resolve to GENERATED\n * stubs (ADR 0023); only surfaces with consumers are declared: the browser\n * bootstrap, the shared component barrel, the SSR router module, the\n * composition engine, and the generated route config.\n */\nexport const CORE_UI_WEB_ENTRY = \"./src/entry.gen.ts\";\n\nexport const CORE_UI_WEB_EXPOSES: Record<string, string> = {\n \"./Hydrate\": \"./src/hydrate.gen.tsx\",\n \"./components\": \"./src/components/index.ts\",\n};\n\nexport const CORE_UI_NODE_ENTRY = \"./src/router.server.gen.tsx\";\n\nexport const CORE_UI_NODE_EXPOSES: Record<string, string> = {\n \"./Router\": \"./src/router.server.gen.tsx\",\n \"./compose\": \"./src/compose.gen.ts\",\n \"./routeConfig\": \"./src/routeConfig.gen.ts\",\n};\n\nexport function createCoreUiRsbuildConfig({ domain, account }: CoreUiRsbuildConfigInput = {}) {\n const workspaceRoot = process.cwd();\n const pkg = JSON.parse(fs.readFileSync(path.join(workspaceRoot, \"package.json\"), \"utf-8\")) as {\n name: string;\n };\n\n return createUiRsbuildConfig({\n workspaceRoot,\n pkg,\n role: \"provider\",\n manifestName: CORE_UI_PLUGIN_KEY,\n devPort: 3003,\n webEntry: CORE_UI_WEB_ENTRY,\n webExposes: CORE_UI_WEB_EXPOSES,\n nodeEntry: CORE_UI_NODE_ENTRY,\n nodeExposes: CORE_UI_NODE_EXPOSES,\n copy: [\n { from: path.join(workspaceRoot, \"public\"), to: \"./\" },\n ...platformSkillCopies(workspaceRoot),\n ],\n define: {\n \"import.meta.env.APP_NAME\": JSON.stringify(domain),\n \"import.meta.env.APP_ACCOUNT\": JSON.stringify(account),\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,iBAAiB;CAAC;CAAkB;CAAgB;AAAkB;AAE5E,SAAgB,oBAAoB,eAIjC;CACD,OAAO,eAAe,SAAS,SAAS;EACtC,MAAM,OAAO,KAAK,KAAK,eAAe,gBAAgB,MAAM,QAAQ;EACpE,OAAO,GAAG,WAAW,IAAI,IACrB,CACE;GACE;GACA,IAAI,YAAY;GAChB,aAAa,EAAE,QAAQ,CAAC,kBAAkB,EAAE;EAC9C,CACF,IACA,CAAC;CACP,CAAC;AACH;;;;;;;;AAgBA,MAAa,oBAAoB;AAEjC,MAAa,sBAA8C;CACzD,aAAa;CACb,gBAAgB;AAClB;AAEA,MAAa,qBAAqB;AAElC,MAAa,uBAA+C;CAC1D,YAAY;CACZ,aAAa;CACb,iBAAiB;AACnB;AAEA,SAAgB,0BAA0B,EAAE,QAAQ,YAAsC,CAAC,GAAG;CAC5F,MAAM,gBAAgB,QAAQ,IAAI;CAClC,MAAM,MAAM,KAAK,MAAM,GAAG,aAAa,KAAK,KAAK,eAAe,cAAc,GAAG,OAAO,CAAC;CAIzF,OAAO,sBAAsB;EAC3B;EACA;EACA,MAAM;EACN;EACA,SAAS;EACT,UAAU;EACV,YAAY;EACZ,WAAW;EACX,aAAa;EACb,MAAM,CACJ;GAAE,MAAM,KAAK,KAAK,eAAe,QAAQ;GAAG,IAAI;EAAK,GACrD,GAAG,oBAAoB,aAAa,CACtC;EACA,QAAQ;GACN,4BAA4B,KAAK,UAAU,MAAM;GACjD,+BAA+B,KAAK,UAAU,OAAO;EACvD;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_compose = require('../rspack/compose.cjs');
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
7
|
+
|
|
8
|
+
//#region src/build/ui/generated-config.ts
|
|
9
|
+
const UI_DIR = "ui";
|
|
10
|
+
const GENERATED_CONFIG_DIR = ".every-plugin";
|
|
11
|
+
const GENERATED_UI_CONFIG = "ui.rsbuild.config.generated.mjs";
|
|
12
|
+
/**
|
|
13
|
+
* Folder-form UI source: a `ui/` directory with route files but no own
|
|
14
|
+
* package.json — the plugin workspace owns the build (single-workspace
|
|
15
|
+
* plugin, one dev process, one deploy train). Workspace-form ui sources
|
|
16
|
+
* (own package.json + scripts) are NOT managed here.
|
|
17
|
+
*/
|
|
18
|
+
function hasFolderFormUi(cwd) {
|
|
19
|
+
const uiDir = node_path.default.join(cwd, UI_DIR);
|
|
20
|
+
return node_fs.default.existsSync(node_path.default.join(uiDir, "src", "routes")) && !node_fs.default.existsSync(node_path.default.join(uiDir, "package.json"));
|
|
21
|
+
}
|
|
22
|
+
function generatedUiConfig(pluginId) {
|
|
23
|
+
return `import path from "node:path";
|
|
24
|
+
import { createUiRsbuildConfig } from "every-plugin/build/ui";
|
|
25
|
+
import pkg from "../package.json";
|
|
26
|
+
|
|
27
|
+
const workspaceRoot = path.resolve(import.meta.dirname, "..", "ui");
|
|
28
|
+
|
|
29
|
+
export default createUiRsbuildConfig({
|
|
30
|
+
workspaceRoot,
|
|
31
|
+
pkg,
|
|
32
|
+
role: "consumer",
|
|
33
|
+
manifestName: ${JSON.stringify(pluginId)},
|
|
34
|
+
devPort: Number(process.env.BOS_UI_PORT) || 0,
|
|
35
|
+
webEntry: "./ui/src/routeConfig.gen.ts",
|
|
36
|
+
webExposes: { "./routeConfig": "./ui/src/routeConfig.gen.ts" },
|
|
37
|
+
nodeEntry: "./ui/src/routeConfig.gen.ts",
|
|
38
|
+
nodeExposes: { "./routeConfig": "./ui/src/routeConfig.gen.ts" },
|
|
39
|
+
routesDirectory: "./ui/src/routes",
|
|
40
|
+
});
|
|
41
|
+
`;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Canonical config-layout derivation: the composition key for a plugin
|
|
45
|
+
* workspace — the `<key>` of the `plugins/<key>` directory relative to the
|
|
46
|
+
* nearest `bos.config.json`. The dev server and the generated ui config
|
|
47
|
+
* both key off this; no consumer keeps a private copy.
|
|
48
|
+
*/
|
|
49
|
+
function pluginLayoutKey(cwd) {
|
|
50
|
+
const bosConfigPath = require_compose.findBosConfigPath(cwd);
|
|
51
|
+
const [workspaceGroup, layoutKey] = (bosConfigPath ? node_path.default.relative(node_path.default.dirname(bosConfigPath), cwd) : void 0)?.split(node_path.default.sep) ?? [];
|
|
52
|
+
return workspaceGroup === "plugins" && layoutKey ? layoutKey : null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Synthesize the rsbuild config for a folder-form ui source (the plugin
|
|
56
|
+
* build contract, not per-plugin config — mirrors the rspack generated
|
|
57
|
+
* config). Returns the config file path, or null when the workspace has no
|
|
58
|
+
* folder-form ui source.
|
|
59
|
+
*/
|
|
60
|
+
function ensureGeneratedUiRsbuildConfig(cwd) {
|
|
61
|
+
if (!hasFolderFormUi(cwd)) return null;
|
|
62
|
+
const pluginId = pluginLayoutKey(cwd);
|
|
63
|
+
if (!pluginId) throw new Error(`[every-plugin] cannot derive the ui's composition key from ${cwd} — no authored config (bos.app.ts / bos.config.json) found above a plugins/<key> directory. The manifest name is the layout key; the container name is never a fallback.`);
|
|
64
|
+
const outDir = node_path.default.join(cwd, GENERATED_CONFIG_DIR);
|
|
65
|
+
node_fs.default.mkdirSync(outDir, { recursive: true });
|
|
66
|
+
const outPath = node_path.default.join(outDir, GENERATED_UI_CONFIG);
|
|
67
|
+
const next = generatedUiConfig(pluginId);
|
|
68
|
+
if (!node_fs.default.existsSync(outPath) || node_fs.default.readFileSync(outPath, "utf8") !== next) node_fs.default.writeFileSync(outPath, next);
|
|
69
|
+
return outPath;
|
|
70
|
+
}
|
|
71
|
+
const CORE_UI_MARKERS = {
|
|
72
|
+
routes: "src/routes",
|
|
73
|
+
contract: "src/contract.ts"
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Workspace-form core ui: the workspace IS the ui (own package.json, route
|
|
77
|
+
* tree) and is not plugin-shaped — the /api counterpart of the plugin
|
|
78
|
+
* workspace form. The entry stub is NOT a marker: it is generated
|
|
79
|
+
* (ADR 0023), so a fresh clone has no bootstrap stubs until the first
|
|
80
|
+
* generation pass.
|
|
81
|
+
*/
|
|
82
|
+
function hasCoreUiWorkspace(cwd = process.cwd()) {
|
|
83
|
+
return node_fs.default.existsSync(node_path.default.join(cwd, CORE_UI_MARKERS.routes)) && !node_fs.default.existsSync(node_path.default.join(cwd, CORE_UI_MARKERS.contract)) && !node_fs.default.existsSync(node_path.default.join(cwd, "plugin.dev.ts"));
|
|
84
|
+
}
|
|
85
|
+
function generatedCoreUiConfig() {
|
|
86
|
+
return `import { defineConfig } from "@rsbuild/core";
|
|
87
|
+
import { readAuthoredConfigInput } from "everything-dev/config";
|
|
88
|
+
import { createCoreUiRsbuildConfig } from "every-plugin/build/ui";
|
|
89
|
+
|
|
90
|
+
export default defineConfig(async () =>
|
|
91
|
+
createCoreUiRsbuildConfig(await readAuthoredConfigInput()),
|
|
92
|
+
);
|
|
93
|
+
`;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Synthesize the rsbuild config for a workspace-form core ui with no local
|
|
97
|
+
* `rsbuild.config.ts` — the /api generated-config model. A local file is an
|
|
98
|
+
* override and wins untouched. Returns the workspace-relative config path,
|
|
99
|
+
* or null when the workspace is not a core ui (or has a local config).
|
|
100
|
+
*/
|
|
101
|
+
function ensureGeneratedCoreUiRsbuildConfig(cwd = process.cwd()) {
|
|
102
|
+
if (!hasCoreUiWorkspace(cwd)) return null;
|
|
103
|
+
if (node_fs.default.existsSync(node_path.default.join(cwd, "rsbuild.config.ts"))) return null;
|
|
104
|
+
const outDir = node_path.default.join(cwd, GENERATED_CONFIG_DIR);
|
|
105
|
+
node_fs.default.mkdirSync(outDir, { recursive: true });
|
|
106
|
+
const outPath = node_path.default.join(outDir, GENERATED_UI_CONFIG);
|
|
107
|
+
node_fs.default.writeFileSync(outPath, generatedCoreUiConfig());
|
|
108
|
+
console.log("[every-plugin] rsbuild.config.ts not found — using the core ui build factory.");
|
|
109
|
+
return node_path.default.join(GENERATED_CONFIG_DIR, GENERATED_UI_CONFIG);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
exports.ensureGeneratedCoreUiRsbuildConfig = ensureGeneratedCoreUiRsbuildConfig;
|
|
114
|
+
exports.ensureGeneratedUiRsbuildConfig = ensureGeneratedUiRsbuildConfig;
|
|
115
|
+
exports.hasCoreUiWorkspace = hasCoreUiWorkspace;
|
|
116
|
+
exports.hasFolderFormUi = hasFolderFormUi;
|
|
117
|
+
exports.pluginLayoutKey = pluginLayoutKey;
|
|
118
|
+
//# sourceMappingURL=generated-config.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-config.cjs","names":["path","fs","findBosConfigPath"],"sources":["../../../src/build/ui/generated-config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { findBosConfigPath } from \"../rspack/compose\";\n\nconst UI_DIR = \"ui\";\nconst GENERATED_CONFIG_DIR = \".every-plugin\";\nconst GENERATED_UI_CONFIG = \"ui.rsbuild.config.generated.mjs\";\n\n/**\n * Folder-form UI source: a `ui/` directory with route files but no own\n * package.json — the plugin workspace owns the build (single-workspace\n * plugin, one dev process, one deploy train). Workspace-form ui sources\n * (own package.json + scripts) are NOT managed here.\n */\nexport function hasFolderFormUi(cwd: string): boolean {\n const uiDir = path.join(cwd, UI_DIR);\n return (\n fs.existsSync(path.join(uiDir, \"src\", \"routes\")) &&\n !fs.existsSync(path.join(uiDir, \"package.json\"))\n );\n}\n\nfunction generatedUiConfig(pluginId: string): string {\n return `import path from \"node:path\";\nimport { createUiRsbuildConfig } from \"every-plugin/build/ui\";\nimport pkg from \"../package.json\";\n\nconst workspaceRoot = path.resolve(import.meta.dirname, \"..\", \"ui\");\n\nexport default createUiRsbuildConfig({\n workspaceRoot,\n pkg,\n role: \"consumer\",\n manifestName: ${JSON.stringify(pluginId)},\n devPort: Number(process.env.BOS_UI_PORT) || 0,\n webEntry: \"./ui/src/routeConfig.gen.ts\",\n webExposes: { \"./routeConfig\": \"./ui/src/routeConfig.gen.ts\" },\n nodeEntry: \"./ui/src/routeConfig.gen.ts\",\n nodeExposes: { \"./routeConfig\": \"./ui/src/routeConfig.gen.ts\" },\n routesDirectory: \"./ui/src/routes\",\n});\n`;\n}\n\n/**\n * Canonical config-layout derivation: the composition key for a plugin\n * workspace — the `<key>` of the `plugins/<key>` directory relative to the\n * nearest `bos.config.json`. The dev server and the generated ui config\n * both key off this; no consumer keeps a private copy.\n */\nexport function pluginLayoutKey(cwd: string): string | null {\n const bosConfigPath = findBosConfigPath(cwd);\n const relativeWorkspace = bosConfigPath\n ? path.relative(path.dirname(bosConfigPath), cwd)\n : undefined;\n const [workspaceGroup, layoutKey] = relativeWorkspace?.split(path.sep) ?? [];\n return workspaceGroup === \"plugins\" && layoutKey ? layoutKey : null;\n}\n\n/**\n * Synthesize the rsbuild config for a folder-form ui source (the plugin\n * build contract, not per-plugin config — mirrors the rspack generated\n * config). Returns the config file path, or null when the workspace has no\n * folder-form ui source.\n */\nexport function ensureGeneratedUiRsbuildConfig(cwd: string): string | null {\n if (!hasFolderFormUi(cwd)) return null;\n // The manifest's name derives ONLY from the plugins/<key> layout key\n // (ADR 0008 §2) — a non-derivable key fails the build loudly, never the\n // container-name fallback that mis-keyed manifests.\n const pluginId = pluginLayoutKey(cwd);\n if (!pluginId) {\n throw new Error(\n `[every-plugin] cannot derive the ui's composition key from ${cwd} — no authored config (bos.app.ts / bos.config.json) found above a plugins/<key> directory. The manifest name is the layout key; the container name is never a fallback.`,\n );\n }\n const outDir = path.join(cwd, GENERATED_CONFIG_DIR);\n fs.mkdirSync(outDir, { recursive: true });\n const outPath = path.join(outDir, GENERATED_UI_CONFIG);\n const next = generatedUiConfig(pluginId);\n if (!fs.existsSync(outPath) || fs.readFileSync(outPath, \"utf8\") !== next) {\n fs.writeFileSync(outPath, next);\n }\n return outPath;\n}\n\nconst CORE_UI_MARKERS = {\n routes: \"src/routes\",\n contract: \"src/contract.ts\",\n};\n\n/**\n * Workspace-form core ui: the workspace IS the ui (own package.json, route\n * tree) and is not plugin-shaped — the /api counterpart of the plugin\n * workspace form. The entry stub is NOT a marker: it is generated\n * (ADR 0023), so a fresh clone has no bootstrap stubs until the first\n * generation pass.\n */\nexport function hasCoreUiWorkspace(cwd: string = process.cwd()): boolean {\n return (\n fs.existsSync(path.join(cwd, CORE_UI_MARKERS.routes)) &&\n !fs.existsSync(path.join(cwd, CORE_UI_MARKERS.contract)) &&\n !fs.existsSync(path.join(cwd, \"plugin.dev.ts\"))\n );\n}\n\nfunction generatedCoreUiConfig(): string {\n return `import { defineConfig } from \"@rsbuild/core\";\nimport { readAuthoredConfigInput } from \"everything-dev/config\";\nimport { createCoreUiRsbuildConfig } from \"every-plugin/build/ui\";\n\nexport default defineConfig(async () =>\n createCoreUiRsbuildConfig(await readAuthoredConfigInput()),\n);\n`;\n}\n\n/**\n * Synthesize the rsbuild config for a workspace-form core ui with no local\n * `rsbuild.config.ts` — the /api generated-config model. A local file is an\n * override and wins untouched. Returns the workspace-relative config path,\n * or null when the workspace is not a core ui (or has a local config).\n */\nexport function ensureGeneratedCoreUiRsbuildConfig(cwd: string = process.cwd()): string | null {\n if (!hasCoreUiWorkspace(cwd)) return null;\n if (fs.existsSync(path.join(cwd, \"rsbuild.config.ts\"))) return null;\n const outDir = path.join(cwd, GENERATED_CONFIG_DIR);\n fs.mkdirSync(outDir, { recursive: true });\n const outPath = path.join(outDir, GENERATED_UI_CONFIG);\n fs.writeFileSync(outPath, generatedCoreUiConfig());\n console.log(\"[every-plugin] rsbuild.config.ts not found — using the core ui build factory.\");\n return path.join(GENERATED_CONFIG_DIR, GENERATED_UI_CONFIG);\n}\n"],"mappings":";;;;;;;;AAIA,MAAM,SAAS;AACf,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;;;;;;;AAQ5B,SAAgB,gBAAgB,KAAsB;CACpD,MAAM,QAAQA,kBAAK,KAAK,KAAK,MAAM;CACnC,OACEC,gBAAG,WAAWD,kBAAK,KAAK,OAAO,OAAO,QAAQ,CAAC,KAC/C,CAACC,gBAAG,WAAWD,kBAAK,KAAK,OAAO,cAAc,CAAC;AAEnD;AAEA,SAAS,kBAAkB,UAA0B;CACnD,OAAO;;;;;;;;;;kBAUS,KAAK,UAAU,QAAQ,EAAE;;;;;;;;;AAS3C;;;;;;;AAQA,SAAgB,gBAAgB,KAA4B;CAC1D,MAAM,gBAAgBE,kCAAkB,GAAG;CAI3C,MAAM,CAAC,gBAAgB,cAHG,gBACtBF,kBAAK,SAASA,kBAAK,QAAQ,aAAa,GAAG,GAAG,IAC9C,OACiD,EAAE,MAAMA,kBAAK,GAAG,KAAK,CAAC;CAC3E,OAAO,mBAAmB,aAAa,YAAY,YAAY;AACjE;;;;;;;AAQA,SAAgB,+BAA+B,KAA4B;CACzE,IAAI,CAAC,gBAAgB,GAAG,GAAG,OAAO;CAIlC,MAAM,WAAW,gBAAgB,GAAG;CACpC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,8DAA8D,IAAI,yKACpE;CAEF,MAAM,SAASA,kBAAK,KAAK,KAAK,oBAAoB;CAClD,gBAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAUA,kBAAK,KAAK,QAAQ,mBAAmB;CACrD,MAAM,OAAO,kBAAkB,QAAQ;CACvC,IAAI,CAACC,gBAAG,WAAW,OAAO,KAAKA,gBAAG,aAAa,SAAS,MAAM,MAAM,MAClE,gBAAG,cAAc,SAAS,IAAI;CAEhC,OAAO;AACT;AAEA,MAAM,kBAAkB;CACtB,QAAQ;CACR,UAAU;AACZ;;;;;;;;AASA,SAAgB,mBAAmB,MAAc,QAAQ,IAAI,GAAY;CACvE,OACEA,gBAAG,WAAWD,kBAAK,KAAK,KAAK,gBAAgB,MAAM,CAAC,KACpD,CAACC,gBAAG,WAAWD,kBAAK,KAAK,KAAK,gBAAgB,QAAQ,CAAC,KACvD,CAACC,gBAAG,WAAWD,kBAAK,KAAK,KAAK,eAAe,CAAC;AAElD;AAEA,SAAS,wBAAgC;CACvC,OAAO;;;;;;;;AAQT;;;;;;;AAQA,SAAgB,mCAAmC,MAAc,QAAQ,IAAI,GAAkB;CAC7F,IAAI,CAAC,mBAAmB,GAAG,GAAG,OAAO;CACrC,IAAIC,gBAAG,WAAWD,kBAAK,KAAK,KAAK,mBAAmB,CAAC,GAAG,OAAO;CAC/D,MAAM,SAASA,kBAAK,KAAK,KAAK,oBAAoB;CAClD,gBAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAUA,kBAAK,KAAK,QAAQ,mBAAmB;CACrD,gBAAG,cAAc,SAAS,sBAAsB,CAAC;CACjD,QAAQ,IAAI,+EAA+E;CAC3F,OAAOA,kBAAK,KAAK,sBAAsB,mBAAmB;AAC5D"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/build/ui/generated-config.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Folder-form UI source: a `ui/` directory with route files but no own
|
|
4
|
+
* package.json — the plugin workspace owns the build (single-workspace
|
|
5
|
+
* plugin, one dev process, one deploy train). Workspace-form ui sources
|
|
6
|
+
* (own package.json + scripts) are NOT managed here.
|
|
7
|
+
*/
|
|
8
|
+
declare function hasFolderFormUi(cwd: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Synthesize the rsbuild config for a folder-form ui source (the plugin
|
|
11
|
+
* build contract, not per-plugin config — mirrors the rspack generated
|
|
12
|
+
* config). Returns the config file path, or null when the workspace has no
|
|
13
|
+
* folder-form ui source.
|
|
14
|
+
*/
|
|
15
|
+
declare function ensureGeneratedUiRsbuildConfig(cwd: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Workspace-form core ui: the workspace IS the ui (own package.json, route
|
|
18
|
+
* tree) and is not plugin-shaped — the /api counterpart of the plugin
|
|
19
|
+
* workspace form. The entry stub is NOT a marker: it is generated
|
|
20
|
+
* (ADR 0023), so a fresh clone has no bootstrap stubs until the first
|
|
21
|
+
* generation pass.
|
|
22
|
+
*/
|
|
23
|
+
declare function hasCoreUiWorkspace(cwd?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Synthesize the rsbuild config for a workspace-form core ui with no local
|
|
26
|
+
* `rsbuild.config.ts` — the /api generated-config model. A local file is an
|
|
27
|
+
* override and wins untouched. Returns the workspace-relative config path,
|
|
28
|
+
* or null when the workspace is not a core ui (or has a local config).
|
|
29
|
+
*/
|
|
30
|
+
declare function ensureGeneratedCoreUiRsbuildConfig(cwd?: string): string | null;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ensureGeneratedCoreUiRsbuildConfig, ensureGeneratedUiRsbuildConfig, hasCoreUiWorkspace, hasFolderFormUi };
|
|
33
|
+
//# sourceMappingURL=generated-config.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-config.d.cts","names":[],"sources":["../../../src/build/ui/generated-config.ts"],"mappings":";;;;;;;iBAcgB,gBAAgB;;;;;;;iBAmDhB,+BAA+B;;;;;;;;iBAiC/B,mBAAmB;;;;;;;iBAyBnB,mCAAmC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/build/ui/generated-config.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Folder-form UI source: a `ui/` directory with route files but no own
|
|
4
|
+
* package.json — the plugin workspace owns the build (single-workspace
|
|
5
|
+
* plugin, one dev process, one deploy train). Workspace-form ui sources
|
|
6
|
+
* (own package.json + scripts) are NOT managed here.
|
|
7
|
+
*/
|
|
8
|
+
declare function hasFolderFormUi(cwd: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Synthesize the rsbuild config for a folder-form ui source (the plugin
|
|
11
|
+
* build contract, not per-plugin config — mirrors the rspack generated
|
|
12
|
+
* config). Returns the config file path, or null when the workspace has no
|
|
13
|
+
* folder-form ui source.
|
|
14
|
+
*/
|
|
15
|
+
declare function ensureGeneratedUiRsbuildConfig(cwd: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Workspace-form core ui: the workspace IS the ui (own package.json, route
|
|
18
|
+
* tree) and is not plugin-shaped — the /api counterpart of the plugin
|
|
19
|
+
* workspace form. The entry stub is NOT a marker: it is generated
|
|
20
|
+
* (ADR 0023), so a fresh clone has no bootstrap stubs until the first
|
|
21
|
+
* generation pass.
|
|
22
|
+
*/
|
|
23
|
+
declare function hasCoreUiWorkspace(cwd?: string): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Synthesize the rsbuild config for a workspace-form core ui with no local
|
|
26
|
+
* `rsbuild.config.ts` — the /api generated-config model. A local file is an
|
|
27
|
+
* override and wins untouched. Returns the workspace-relative config path,
|
|
28
|
+
* or null when the workspace is not a core ui (or has a local config).
|
|
29
|
+
*/
|
|
30
|
+
declare function ensureGeneratedCoreUiRsbuildConfig(cwd?: string): string | null;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { ensureGeneratedCoreUiRsbuildConfig, ensureGeneratedUiRsbuildConfig, hasCoreUiWorkspace, hasFolderFormUi };
|
|
33
|
+
//# sourceMappingURL=generated-config.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-config.d.mts","names":[],"sources":["../../../src/build/ui/generated-config.ts"],"mappings":";;;;;;;iBAcgB,gBAAgB;;;;;;;iBAmDhB,+BAA+B;;;;;;;;iBAiC/B,mBAAmB;;;;;;;iBAyBnB,mCAAmC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { findBosConfigPath } from "../rspack/compose.mjs";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/build/ui/generated-config.ts
|
|
6
|
+
const UI_DIR = "ui";
|
|
7
|
+
const GENERATED_CONFIG_DIR = ".every-plugin";
|
|
8
|
+
const GENERATED_UI_CONFIG = "ui.rsbuild.config.generated.mjs";
|
|
9
|
+
/**
|
|
10
|
+
* Folder-form UI source: a `ui/` directory with route files but no own
|
|
11
|
+
* package.json — the plugin workspace owns the build (single-workspace
|
|
12
|
+
* plugin, one dev process, one deploy train). Workspace-form ui sources
|
|
13
|
+
* (own package.json + scripts) are NOT managed here.
|
|
14
|
+
*/
|
|
15
|
+
function hasFolderFormUi(cwd) {
|
|
16
|
+
const uiDir = path.join(cwd, UI_DIR);
|
|
17
|
+
return fs.existsSync(path.join(uiDir, "src", "routes")) && !fs.existsSync(path.join(uiDir, "package.json"));
|
|
18
|
+
}
|
|
19
|
+
function generatedUiConfig(pluginId) {
|
|
20
|
+
return `import path from "node:path";
|
|
21
|
+
import { createUiRsbuildConfig } from "every-plugin/build/ui";
|
|
22
|
+
import pkg from "../package.json";
|
|
23
|
+
|
|
24
|
+
const workspaceRoot = path.resolve(import.meta.dirname, "..", "ui");
|
|
25
|
+
|
|
26
|
+
export default createUiRsbuildConfig({
|
|
27
|
+
workspaceRoot,
|
|
28
|
+
pkg,
|
|
29
|
+
role: "consumer",
|
|
30
|
+
manifestName: ${JSON.stringify(pluginId)},
|
|
31
|
+
devPort: Number(process.env.BOS_UI_PORT) || 0,
|
|
32
|
+
webEntry: "./ui/src/routeConfig.gen.ts",
|
|
33
|
+
webExposes: { "./routeConfig": "./ui/src/routeConfig.gen.ts" },
|
|
34
|
+
nodeEntry: "./ui/src/routeConfig.gen.ts",
|
|
35
|
+
nodeExposes: { "./routeConfig": "./ui/src/routeConfig.gen.ts" },
|
|
36
|
+
routesDirectory: "./ui/src/routes",
|
|
37
|
+
});
|
|
38
|
+
`;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Canonical config-layout derivation: the composition key for a plugin
|
|
42
|
+
* workspace — the `<key>` of the `plugins/<key>` directory relative to the
|
|
43
|
+
* nearest `bos.config.json`. The dev server and the generated ui config
|
|
44
|
+
* both key off this; no consumer keeps a private copy.
|
|
45
|
+
*/
|
|
46
|
+
function pluginLayoutKey(cwd) {
|
|
47
|
+
const bosConfigPath = findBosConfigPath(cwd);
|
|
48
|
+
const [workspaceGroup, layoutKey] = (bosConfigPath ? path.relative(path.dirname(bosConfigPath), cwd) : void 0)?.split(path.sep) ?? [];
|
|
49
|
+
return workspaceGroup === "plugins" && layoutKey ? layoutKey : null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Synthesize the rsbuild config for a folder-form ui source (the plugin
|
|
53
|
+
* build contract, not per-plugin config — mirrors the rspack generated
|
|
54
|
+
* config). Returns the config file path, or null when the workspace has no
|
|
55
|
+
* folder-form ui source.
|
|
56
|
+
*/
|
|
57
|
+
function ensureGeneratedUiRsbuildConfig(cwd) {
|
|
58
|
+
if (!hasFolderFormUi(cwd)) return null;
|
|
59
|
+
const pluginId = pluginLayoutKey(cwd);
|
|
60
|
+
if (!pluginId) throw new Error(`[every-plugin] cannot derive the ui's composition key from ${cwd} — no authored config (bos.app.ts / bos.config.json) found above a plugins/<key> directory. The manifest name is the layout key; the container name is never a fallback.`);
|
|
61
|
+
const outDir = path.join(cwd, GENERATED_CONFIG_DIR);
|
|
62
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
63
|
+
const outPath = path.join(outDir, GENERATED_UI_CONFIG);
|
|
64
|
+
const next = generatedUiConfig(pluginId);
|
|
65
|
+
if (!fs.existsSync(outPath) || fs.readFileSync(outPath, "utf8") !== next) fs.writeFileSync(outPath, next);
|
|
66
|
+
return outPath;
|
|
67
|
+
}
|
|
68
|
+
const CORE_UI_MARKERS = {
|
|
69
|
+
routes: "src/routes",
|
|
70
|
+
contract: "src/contract.ts"
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Workspace-form core ui: the workspace IS the ui (own package.json, route
|
|
74
|
+
* tree) and is not plugin-shaped — the /api counterpart of the plugin
|
|
75
|
+
* workspace form. The entry stub is NOT a marker: it is generated
|
|
76
|
+
* (ADR 0023), so a fresh clone has no bootstrap stubs until the first
|
|
77
|
+
* generation pass.
|
|
78
|
+
*/
|
|
79
|
+
function hasCoreUiWorkspace(cwd = process.cwd()) {
|
|
80
|
+
return fs.existsSync(path.join(cwd, CORE_UI_MARKERS.routes)) && !fs.existsSync(path.join(cwd, CORE_UI_MARKERS.contract)) && !fs.existsSync(path.join(cwd, "plugin.dev.ts"));
|
|
81
|
+
}
|
|
82
|
+
function generatedCoreUiConfig() {
|
|
83
|
+
return `import { defineConfig } from "@rsbuild/core";
|
|
84
|
+
import { readAuthoredConfigInput } from "everything-dev/config";
|
|
85
|
+
import { createCoreUiRsbuildConfig } from "every-plugin/build/ui";
|
|
86
|
+
|
|
87
|
+
export default defineConfig(async () =>
|
|
88
|
+
createCoreUiRsbuildConfig(await readAuthoredConfigInput()),
|
|
89
|
+
);
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Synthesize the rsbuild config for a workspace-form core ui with no local
|
|
94
|
+
* `rsbuild.config.ts` — the /api generated-config model. A local file is an
|
|
95
|
+
* override and wins untouched. Returns the workspace-relative config path,
|
|
96
|
+
* or null when the workspace is not a core ui (or has a local config).
|
|
97
|
+
*/
|
|
98
|
+
function ensureGeneratedCoreUiRsbuildConfig(cwd = process.cwd()) {
|
|
99
|
+
if (!hasCoreUiWorkspace(cwd)) return null;
|
|
100
|
+
if (fs.existsSync(path.join(cwd, "rsbuild.config.ts"))) return null;
|
|
101
|
+
const outDir = path.join(cwd, GENERATED_CONFIG_DIR);
|
|
102
|
+
fs.mkdirSync(outDir, { recursive: true });
|
|
103
|
+
const outPath = path.join(outDir, GENERATED_UI_CONFIG);
|
|
104
|
+
fs.writeFileSync(outPath, generatedCoreUiConfig());
|
|
105
|
+
console.log("[every-plugin] rsbuild.config.ts not found — using the core ui build factory.");
|
|
106
|
+
return path.join(GENERATED_CONFIG_DIR, GENERATED_UI_CONFIG);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//#endregion
|
|
110
|
+
export { ensureGeneratedCoreUiRsbuildConfig, ensureGeneratedUiRsbuildConfig, hasCoreUiWorkspace, hasFolderFormUi, pluginLayoutKey };
|
|
111
|
+
//# sourceMappingURL=generated-config.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-config.mjs","names":[],"sources":["../../../src/build/ui/generated-config.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { findBosConfigPath } from \"../rspack/compose\";\n\nconst UI_DIR = \"ui\";\nconst GENERATED_CONFIG_DIR = \".every-plugin\";\nconst GENERATED_UI_CONFIG = \"ui.rsbuild.config.generated.mjs\";\n\n/**\n * Folder-form UI source: a `ui/` directory with route files but no own\n * package.json — the plugin workspace owns the build (single-workspace\n * plugin, one dev process, one deploy train). Workspace-form ui sources\n * (own package.json + scripts) are NOT managed here.\n */\nexport function hasFolderFormUi(cwd: string): boolean {\n const uiDir = path.join(cwd, UI_DIR);\n return (\n fs.existsSync(path.join(uiDir, \"src\", \"routes\")) &&\n !fs.existsSync(path.join(uiDir, \"package.json\"))\n );\n}\n\nfunction generatedUiConfig(pluginId: string): string {\n return `import path from \"node:path\";\nimport { createUiRsbuildConfig } from \"every-plugin/build/ui\";\nimport pkg from \"../package.json\";\n\nconst workspaceRoot = path.resolve(import.meta.dirname, \"..\", \"ui\");\n\nexport default createUiRsbuildConfig({\n workspaceRoot,\n pkg,\n role: \"consumer\",\n manifestName: ${JSON.stringify(pluginId)},\n devPort: Number(process.env.BOS_UI_PORT) || 0,\n webEntry: \"./ui/src/routeConfig.gen.ts\",\n webExposes: { \"./routeConfig\": \"./ui/src/routeConfig.gen.ts\" },\n nodeEntry: \"./ui/src/routeConfig.gen.ts\",\n nodeExposes: { \"./routeConfig\": \"./ui/src/routeConfig.gen.ts\" },\n routesDirectory: \"./ui/src/routes\",\n});\n`;\n}\n\n/**\n * Canonical config-layout derivation: the composition key for a plugin\n * workspace — the `<key>` of the `plugins/<key>` directory relative to the\n * nearest `bos.config.json`. The dev server and the generated ui config\n * both key off this; no consumer keeps a private copy.\n */\nexport function pluginLayoutKey(cwd: string): string | null {\n const bosConfigPath = findBosConfigPath(cwd);\n const relativeWorkspace = bosConfigPath\n ? path.relative(path.dirname(bosConfigPath), cwd)\n : undefined;\n const [workspaceGroup, layoutKey] = relativeWorkspace?.split(path.sep) ?? [];\n return workspaceGroup === \"plugins\" && layoutKey ? layoutKey : null;\n}\n\n/**\n * Synthesize the rsbuild config for a folder-form ui source (the plugin\n * build contract, not per-plugin config — mirrors the rspack generated\n * config). Returns the config file path, or null when the workspace has no\n * folder-form ui source.\n */\nexport function ensureGeneratedUiRsbuildConfig(cwd: string): string | null {\n if (!hasFolderFormUi(cwd)) return null;\n // The manifest's name derives ONLY from the plugins/<key> layout key\n // (ADR 0008 §2) — a non-derivable key fails the build loudly, never the\n // container-name fallback that mis-keyed manifests.\n const pluginId = pluginLayoutKey(cwd);\n if (!pluginId) {\n throw new Error(\n `[every-plugin] cannot derive the ui's composition key from ${cwd} — no authored config (bos.app.ts / bos.config.json) found above a plugins/<key> directory. The manifest name is the layout key; the container name is never a fallback.`,\n );\n }\n const outDir = path.join(cwd, GENERATED_CONFIG_DIR);\n fs.mkdirSync(outDir, { recursive: true });\n const outPath = path.join(outDir, GENERATED_UI_CONFIG);\n const next = generatedUiConfig(pluginId);\n if (!fs.existsSync(outPath) || fs.readFileSync(outPath, \"utf8\") !== next) {\n fs.writeFileSync(outPath, next);\n }\n return outPath;\n}\n\nconst CORE_UI_MARKERS = {\n routes: \"src/routes\",\n contract: \"src/contract.ts\",\n};\n\n/**\n * Workspace-form core ui: the workspace IS the ui (own package.json, route\n * tree) and is not plugin-shaped — the /api counterpart of the plugin\n * workspace form. The entry stub is NOT a marker: it is generated\n * (ADR 0023), so a fresh clone has no bootstrap stubs until the first\n * generation pass.\n */\nexport function hasCoreUiWorkspace(cwd: string = process.cwd()): boolean {\n return (\n fs.existsSync(path.join(cwd, CORE_UI_MARKERS.routes)) &&\n !fs.existsSync(path.join(cwd, CORE_UI_MARKERS.contract)) &&\n !fs.existsSync(path.join(cwd, \"plugin.dev.ts\"))\n );\n}\n\nfunction generatedCoreUiConfig(): string {\n return `import { defineConfig } from \"@rsbuild/core\";\nimport { readAuthoredConfigInput } from \"everything-dev/config\";\nimport { createCoreUiRsbuildConfig } from \"every-plugin/build/ui\";\n\nexport default defineConfig(async () =>\n createCoreUiRsbuildConfig(await readAuthoredConfigInput()),\n);\n`;\n}\n\n/**\n * Synthesize the rsbuild config for a workspace-form core ui with no local\n * `rsbuild.config.ts` — the /api generated-config model. A local file is an\n * override and wins untouched. Returns the workspace-relative config path,\n * or null when the workspace is not a core ui (or has a local config).\n */\nexport function ensureGeneratedCoreUiRsbuildConfig(cwd: string = process.cwd()): string | null {\n if (!hasCoreUiWorkspace(cwd)) return null;\n if (fs.existsSync(path.join(cwd, \"rsbuild.config.ts\"))) return null;\n const outDir = path.join(cwd, GENERATED_CONFIG_DIR);\n fs.mkdirSync(outDir, { recursive: true });\n const outPath = path.join(outDir, GENERATED_UI_CONFIG);\n fs.writeFileSync(outPath, generatedCoreUiConfig());\n console.log(\"[every-plugin] rsbuild.config.ts not found — using the core ui build factory.\");\n return path.join(GENERATED_CONFIG_DIR, GENERATED_UI_CONFIG);\n}\n"],"mappings":";;;;;AAIA,MAAM,SAAS;AACf,MAAM,uBAAuB;AAC7B,MAAM,sBAAsB;;;;;;;AAQ5B,SAAgB,gBAAgB,KAAsB;CACpD,MAAM,QAAQ,KAAK,KAAK,KAAK,MAAM;CACnC,OACE,GAAG,WAAW,KAAK,KAAK,OAAO,OAAO,QAAQ,CAAC,KAC/C,CAAC,GAAG,WAAW,KAAK,KAAK,OAAO,cAAc,CAAC;AAEnD;AAEA,SAAS,kBAAkB,UAA0B;CACnD,OAAO;;;;;;;;;;kBAUS,KAAK,UAAU,QAAQ,EAAE;;;;;;;;;AAS3C;;;;;;;AAQA,SAAgB,gBAAgB,KAA4B;CAC1D,MAAM,gBAAgB,kBAAkB,GAAG;CAI3C,MAAM,CAAC,gBAAgB,cAHG,gBACtB,KAAK,SAAS,KAAK,QAAQ,aAAa,GAAG,GAAG,IAC9C,OACiD,EAAE,MAAM,KAAK,GAAG,KAAK,CAAC;CAC3E,OAAO,mBAAmB,aAAa,YAAY,YAAY;AACjE;;;;;;;AAQA,SAAgB,+BAA+B,KAA4B;CACzE,IAAI,CAAC,gBAAgB,GAAG,GAAG,OAAO;CAIlC,MAAM,WAAW,gBAAgB,GAAG;CACpC,IAAI,CAAC,UACH,MAAM,IAAI,MACR,8DAA8D,IAAI,yKACpE;CAEF,MAAM,SAAS,KAAK,KAAK,KAAK,oBAAoB;CAClD,GAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAU,KAAK,KAAK,QAAQ,mBAAmB;CACrD,MAAM,OAAO,kBAAkB,QAAQ;CACvC,IAAI,CAAC,GAAG,WAAW,OAAO,KAAK,GAAG,aAAa,SAAS,MAAM,MAAM,MAClE,GAAG,cAAc,SAAS,IAAI;CAEhC,OAAO;AACT;AAEA,MAAM,kBAAkB;CACtB,QAAQ;CACR,UAAU;AACZ;;;;;;;;AASA,SAAgB,mBAAmB,MAAc,QAAQ,IAAI,GAAY;CACvE,OACE,GAAG,WAAW,KAAK,KAAK,KAAK,gBAAgB,MAAM,CAAC,KACpD,CAAC,GAAG,WAAW,KAAK,KAAK,KAAK,gBAAgB,QAAQ,CAAC,KACvD,CAAC,GAAG,WAAW,KAAK,KAAK,KAAK,eAAe,CAAC;AAElD;AAEA,SAAS,wBAAgC;CACvC,OAAO;;;;;;;;AAQT;;;;;;;AAQA,SAAgB,mCAAmC,MAAc,QAAQ,IAAI,GAAkB;CAC7F,IAAI,CAAC,mBAAmB,GAAG,GAAG,OAAO;CACrC,IAAI,GAAG,WAAW,KAAK,KAAK,KAAK,mBAAmB,CAAC,GAAG,OAAO;CAC/D,MAAM,SAAS,KAAK,KAAK,KAAK,oBAAoB;CAClD,GAAG,UAAU,QAAQ,EAAE,WAAW,KAAK,CAAC;CACxC,MAAM,UAAU,KAAK,KAAK,QAAQ,mBAAmB;CACrD,GAAG,cAAc,SAAS,sBAAsB,CAAC;CACjD,QAAQ,IAAI,+EAA+E;CAC3F,OAAO,KAAK,KAAK,sBAAsB,mBAAmB;AAC5D"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
|
|
2
|
+
const require_build_artifact_names = require('../artifact-names.cjs');
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
node_fs = require_runtime.__toESM(node_fs, 1);
|
|
5
|
+
let node_path = require("node:path");
|
|
6
|
+
node_path = require_runtime.__toESM(node_path, 1);
|
|
7
|
+
|
|
8
|
+
//#region src/build/ui/hash-artifacts-plugin.ts
|
|
9
|
+
function listFiles(dir, out = []) {
|
|
10
|
+
for (const entry of node_fs.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
11
|
+
const full = node_path.default.join(dir, entry.name);
|
|
12
|
+
if (entry.isDirectory()) listFiles(full, out);
|
|
13
|
+
else out.push(node_path.default.relative(dir, full).split(node_path.default.sep).join("/"));
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Emits the additive hashed copies for one environment's dist root (ticket:
|
|
19
|
+
* atomic-deploys 01). The entry itself is hashed by the build (filename
|
|
20
|
+
* template); this plugin adds immutable hashed copies of the fixed-name
|
|
21
|
+
* browser artifacts (mf-manifest.json at the root, style.css under
|
|
22
|
+
* static/css), and `build-report.json` for the deploy leg. Idempotent under
|
|
23
|
+
* watch: same bytes → same hashed names.
|
|
24
|
+
*/
|
|
25
|
+
function hashArtifactsPlugin(options) {
|
|
26
|
+
return {
|
|
27
|
+
name: "hash-artifacts",
|
|
28
|
+
setup(api) {
|
|
29
|
+
api.onAfterEnvironmentCompile(() => {
|
|
30
|
+
const distRoot = options.distRoot;
|
|
31
|
+
if (!node_fs.default.existsSync(distRoot)) return;
|
|
32
|
+
const resolveExisting = (name) => {
|
|
33
|
+
return [node_path.default.join(distRoot, name), node_path.default.join(distRoot, "static", "css", name)].find((candidate) => node_fs.default.existsSync(candidate)) ?? null;
|
|
34
|
+
};
|
|
35
|
+
const assetNames = listFiles(distRoot);
|
|
36
|
+
if (!require_build_artifact_names.findHashedEntry(assetNames, options.entryBase)) return;
|
|
37
|
+
const contents = {};
|
|
38
|
+
for (const fixedName of [require_build_artifact_names.MF_MANIFEST_FILENAME, require_build_artifact_names.STYLE_FILENAME]) {
|
|
39
|
+
const from = resolveExisting(fixedName);
|
|
40
|
+
if (from) contents[fixedName] = node_fs.default.readFileSync(from, "utf8");
|
|
41
|
+
}
|
|
42
|
+
const plan = require_build_artifact_names.planArtifactCopies({
|
|
43
|
+
assetNames,
|
|
44
|
+
entryBase: options.entryBase,
|
|
45
|
+
contents
|
|
46
|
+
});
|
|
47
|
+
if (!plan) return;
|
|
48
|
+
for (const copy of plan.copies) {
|
|
49
|
+
const from = resolveExisting(copy.from);
|
|
50
|
+
if (!from) throw new Error(`[hash-artifacts] planned copy source missing: ${copy.from}`);
|
|
51
|
+
node_fs.default.copyFileSync(from, node_path.default.join(distRoot, copy.to));
|
|
52
|
+
}
|
|
53
|
+
node_fs.default.writeFileSync(node_path.default.join(distRoot, "build-report.json"), `${JSON.stringify(require_build_artifact_names.BuildEntryReportSchema.parse(plan.report), null, 2)}\n`);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
//#endregion
|
|
60
|
+
exports.hashArtifactsPlugin = hashArtifactsPlugin;
|
|
61
|
+
//# sourceMappingURL=hash-artifacts-plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-artifacts-plugin.cjs","names":["fs","path","findHashedEntry","MF_MANIFEST_FILENAME","STYLE_FILENAME","planArtifactCopies","BuildEntryReportSchema"],"sources":["../../../src/build/ui/hash-artifacts-plugin.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { RsbuildPlugin } from \"@rsbuild/core\";\nimport {\n BuildEntryReportSchema,\n findHashedEntry,\n MF_MANIFEST_FILENAME,\n planArtifactCopies,\n STYLE_FILENAME,\n} from \"../artifact-names\";\n\nexport interface HashArtifactsPluginOptions {\n /** The container entry's base name in this environment's dist root. */\n entryBase: string;\n /** Absolute dist root this environment wrote (web: `dist`, node: `dist/ssr`). */\n distRoot: string;\n}\n\nfunction listFiles(dir: string, out: string[] = []): string[] {\n for (const entry of fs\n .readdirSync(dir, { withFileTypes: true })\n .sort((a, b) => a.name.localeCompare(b.name))) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) listFiles(full, out);\n else out.push(path.relative(dir, full).split(path.sep).join(\"/\"));\n }\n return out;\n}\n\n/**\n * Emits the additive hashed copies for one environment's dist root (ticket:\n * atomic-deploys 01). The entry itself is hashed by the build (filename\n * template); this plugin adds immutable hashed copies of the fixed-name\n * browser artifacts (mf-manifest.json at the root, style.css under\n * static/css), and `build-report.json` for the deploy leg. Idempotent under\n * watch: same bytes → same hashed names.\n */\nexport function hashArtifactsPlugin(options: HashArtifactsPluginOptions): RsbuildPlugin {\n return {\n name: \"hash-artifacts\",\n setup(api) {\n api.onAfterEnvironmentCompile(() => {\n const distRoot = options.distRoot;\n if (!fs.existsSync(distRoot)) return;\n\n const resolveExisting = (name: string): string | null => {\n const candidates = [\n path.join(distRoot, name),\n path.join(distRoot, \"static\", \"css\", name),\n ];\n return candidates.find((candidate) => fs.existsSync(candidate)) ?? null;\n };\n\n const assetNames = listFiles(distRoot);\n const entry = findHashedEntry(assetNames, options.entryBase);\n if (!entry) return;\n\n const contents: Record<string, string> = {};\n for (const fixedName of [MF_MANIFEST_FILENAME, STYLE_FILENAME]) {\n const from = resolveExisting(fixedName);\n if (from) contents[fixedName] = fs.readFileSync(from, \"utf8\");\n }\n\n const plan = planArtifactCopies({ assetNames, entryBase: options.entryBase, contents });\n if (!plan) return;\n\n for (const copy of plan.copies) {\n const from = resolveExisting(copy.from);\n if (!from) throw new Error(`[hash-artifacts] planned copy source missing: ${copy.from}`);\n fs.copyFileSync(from, path.join(distRoot, copy.to));\n }\n fs.writeFileSync(\n path.join(distRoot, \"build-report.json\"),\n `${JSON.stringify(BuildEntryReportSchema.parse(plan.report), null, 2)}\\n`,\n );\n });\n },\n };\n}\n"],"mappings":";;;;;;;;AAkBA,SAAS,UAAU,KAAa,MAAgB,CAAC,GAAa;CAC5D,KAAK,MAAM,SAASA,gBACjB,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,CAAC,CACzC,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,GAAG;EAC/C,MAAM,OAAOC,kBAAK,KAAK,KAAK,MAAM,IAAI;EACtC,IAAI,MAAM,YAAY,GAAG,UAAU,MAAM,GAAG;OACvC,IAAI,KAAKA,kBAAK,SAAS,KAAK,IAAI,CAAC,CAAC,MAAMA,kBAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;CAClE;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,oBAAoB,SAAoD;CACtF,OAAO;EACL,MAAM;EACN,MAAM,KAAK;GACT,IAAI,gCAAgC;IAClC,MAAM,WAAW,QAAQ;IACzB,IAAI,CAACD,gBAAG,WAAW,QAAQ,GAAG;IAE9B,MAAM,mBAAmB,SAAgC;KAKvD,OAAO,CAHLC,kBAAK,KAAK,UAAU,IAAI,GACxBA,kBAAK,KAAK,UAAU,UAAU,OAAO,IAAI,CAE3B,CAAC,CAAC,MAAM,cAAcD,gBAAG,WAAW,SAAS,CAAC,KAAK;IACrE;IAEA,MAAM,aAAa,UAAU,QAAQ;IAErC,IAAI,CADUE,6CAAgB,YAAY,QAAQ,SACzC,GAAG;IAEZ,MAAM,WAAmC,CAAC;IAC1C,KAAK,MAAM,aAAa,CAACC,mDAAsBC,2CAAc,GAAG;KAC9D,MAAM,OAAO,gBAAgB,SAAS;KACtC,IAAI,MAAM,SAAS,aAAaJ,gBAAG,aAAa,MAAM,MAAM;IAC9D;IAEA,MAAM,OAAOK,gDAAmB;KAAE;KAAY,WAAW,QAAQ;KAAW;IAAS,CAAC;IACtF,IAAI,CAAC,MAAM;IAEX,KAAK,MAAM,QAAQ,KAAK,QAAQ;KAC9B,MAAM,OAAO,gBAAgB,KAAK,IAAI;KACtC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,iDAAiD,KAAK,MAAM;KACvF,gBAAG,aAAa,MAAMJ,kBAAK,KAAK,UAAU,KAAK,EAAE,CAAC;IACpD;IACA,gBAAG,cACDA,kBAAK,KAAK,UAAU,mBAAmB,GACvC,GAAG,KAAK,UAAUK,oDAAuB,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE,GACxE;GACF,CAAC;EACH;CACF;AACF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RsbuildPlugin } from "@rsbuild/core";
|
|
2
|
+
//#region src/build/ui/hash-artifacts-plugin.d.ts
|
|
3
|
+
interface HashArtifactsPluginOptions {
|
|
4
|
+
/** The container entry's base name in this environment's dist root. */
|
|
5
|
+
entryBase: string;
|
|
6
|
+
/** Absolute dist root this environment wrote (web: `dist`, node: `dist/ssr`). */
|
|
7
|
+
distRoot: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Emits the additive hashed copies for one environment's dist root (ticket:
|
|
11
|
+
* atomic-deploys 01). The entry itself is hashed by the build (filename
|
|
12
|
+
* template); this plugin adds immutable hashed copies of the fixed-name
|
|
13
|
+
* browser artifacts (mf-manifest.json at the root, style.css under
|
|
14
|
+
* static/css), and `build-report.json` for the deploy leg. Idempotent under
|
|
15
|
+
* watch: same bytes → same hashed names.
|
|
16
|
+
*/
|
|
17
|
+
declare function hashArtifactsPlugin(options: HashArtifactsPluginOptions): RsbuildPlugin;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { HashArtifactsPluginOptions, hashArtifactsPlugin };
|
|
20
|
+
//# sourceMappingURL=hash-artifacts-plugin.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-artifacts-plugin.d.cts","names":[],"sources":["../../../src/build/ui/hash-artifacts-plugin.ts"],"mappings":";;UAWiB;;EAEf;;EAEA;;;;;;;;;;iBAsBc,oBAAoB,SAAS,6BAA6B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RsbuildPlugin } from "@rsbuild/core";
|
|
2
|
+
//#region src/build/ui/hash-artifacts-plugin.d.ts
|
|
3
|
+
interface HashArtifactsPluginOptions {
|
|
4
|
+
/** The container entry's base name in this environment's dist root. */
|
|
5
|
+
entryBase: string;
|
|
6
|
+
/** Absolute dist root this environment wrote (web: `dist`, node: `dist/ssr`). */
|
|
7
|
+
distRoot: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Emits the additive hashed copies for one environment's dist root (ticket:
|
|
11
|
+
* atomic-deploys 01). The entry itself is hashed by the build (filename
|
|
12
|
+
* template); this plugin adds immutable hashed copies of the fixed-name
|
|
13
|
+
* browser artifacts (mf-manifest.json at the root, style.css under
|
|
14
|
+
* static/css), and `build-report.json` for the deploy leg. Idempotent under
|
|
15
|
+
* watch: same bytes → same hashed names.
|
|
16
|
+
*/
|
|
17
|
+
declare function hashArtifactsPlugin(options: HashArtifactsPluginOptions): RsbuildPlugin;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { HashArtifactsPluginOptions, hashArtifactsPlugin };
|
|
20
|
+
//# sourceMappingURL=hash-artifacts-plugin.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-artifacts-plugin.d.mts","names":[],"sources":["../../../src/build/ui/hash-artifacts-plugin.ts"],"mappings":";;UAWiB;;EAEf;;EAEA;;;;;;;;;;iBAsBc,oBAAoB,SAAS,6BAA6B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { BuildEntryReportSchema, MF_MANIFEST_FILENAME, STYLE_FILENAME, findHashedEntry, planArtifactCopies } from "../artifact-names.mjs";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/build/ui/hash-artifacts-plugin.ts
|
|
6
|
+
function listFiles(dir, out = []) {
|
|
7
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8
|
+
const full = path.join(dir, entry.name);
|
|
9
|
+
if (entry.isDirectory()) listFiles(full, out);
|
|
10
|
+
else out.push(path.relative(dir, full).split(path.sep).join("/"));
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Emits the additive hashed copies for one environment's dist root (ticket:
|
|
16
|
+
* atomic-deploys 01). The entry itself is hashed by the build (filename
|
|
17
|
+
* template); this plugin adds immutable hashed copies of the fixed-name
|
|
18
|
+
* browser artifacts (mf-manifest.json at the root, style.css under
|
|
19
|
+
* static/css), and `build-report.json` for the deploy leg. Idempotent under
|
|
20
|
+
* watch: same bytes → same hashed names.
|
|
21
|
+
*/
|
|
22
|
+
function hashArtifactsPlugin(options) {
|
|
23
|
+
return {
|
|
24
|
+
name: "hash-artifacts",
|
|
25
|
+
setup(api) {
|
|
26
|
+
api.onAfterEnvironmentCompile(() => {
|
|
27
|
+
const distRoot = options.distRoot;
|
|
28
|
+
if (!fs.existsSync(distRoot)) return;
|
|
29
|
+
const resolveExisting = (name) => {
|
|
30
|
+
return [path.join(distRoot, name), path.join(distRoot, "static", "css", name)].find((candidate) => fs.existsSync(candidate)) ?? null;
|
|
31
|
+
};
|
|
32
|
+
const assetNames = listFiles(distRoot);
|
|
33
|
+
if (!findHashedEntry(assetNames, options.entryBase)) return;
|
|
34
|
+
const contents = {};
|
|
35
|
+
for (const fixedName of [MF_MANIFEST_FILENAME, STYLE_FILENAME]) {
|
|
36
|
+
const from = resolveExisting(fixedName);
|
|
37
|
+
if (from) contents[fixedName] = fs.readFileSync(from, "utf8");
|
|
38
|
+
}
|
|
39
|
+
const plan = planArtifactCopies({
|
|
40
|
+
assetNames,
|
|
41
|
+
entryBase: options.entryBase,
|
|
42
|
+
contents
|
|
43
|
+
});
|
|
44
|
+
if (!plan) return;
|
|
45
|
+
for (const copy of plan.copies) {
|
|
46
|
+
const from = resolveExisting(copy.from);
|
|
47
|
+
if (!from) throw new Error(`[hash-artifacts] planned copy source missing: ${copy.from}`);
|
|
48
|
+
fs.copyFileSync(from, path.join(distRoot, copy.to));
|
|
49
|
+
}
|
|
50
|
+
fs.writeFileSync(path.join(distRoot, "build-report.json"), `${JSON.stringify(BuildEntryReportSchema.parse(plan.report), null, 2)}\n`);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
//#endregion
|
|
57
|
+
export { hashArtifactsPlugin };
|
|
58
|
+
//# sourceMappingURL=hash-artifacts-plugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hash-artifacts-plugin.mjs","names":[],"sources":["../../../src/build/ui/hash-artifacts-plugin.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { RsbuildPlugin } from \"@rsbuild/core\";\nimport {\n BuildEntryReportSchema,\n findHashedEntry,\n MF_MANIFEST_FILENAME,\n planArtifactCopies,\n STYLE_FILENAME,\n} from \"../artifact-names\";\n\nexport interface HashArtifactsPluginOptions {\n /** The container entry's base name in this environment's dist root. */\n entryBase: string;\n /** Absolute dist root this environment wrote (web: `dist`, node: `dist/ssr`). */\n distRoot: string;\n}\n\nfunction listFiles(dir: string, out: string[] = []): string[] {\n for (const entry of fs\n .readdirSync(dir, { withFileTypes: true })\n .sort((a, b) => a.name.localeCompare(b.name))) {\n const full = path.join(dir, entry.name);\n if (entry.isDirectory()) listFiles(full, out);\n else out.push(path.relative(dir, full).split(path.sep).join(\"/\"));\n }\n return out;\n}\n\n/**\n * Emits the additive hashed copies for one environment's dist root (ticket:\n * atomic-deploys 01). The entry itself is hashed by the build (filename\n * template); this plugin adds immutable hashed copies of the fixed-name\n * browser artifacts (mf-manifest.json at the root, style.css under\n * static/css), and `build-report.json` for the deploy leg. Idempotent under\n * watch: same bytes → same hashed names.\n */\nexport function hashArtifactsPlugin(options: HashArtifactsPluginOptions): RsbuildPlugin {\n return {\n name: \"hash-artifacts\",\n setup(api) {\n api.onAfterEnvironmentCompile(() => {\n const distRoot = options.distRoot;\n if (!fs.existsSync(distRoot)) return;\n\n const resolveExisting = (name: string): string | null => {\n const candidates = [\n path.join(distRoot, name),\n path.join(distRoot, \"static\", \"css\", name),\n ];\n return candidates.find((candidate) => fs.existsSync(candidate)) ?? null;\n };\n\n const assetNames = listFiles(distRoot);\n const entry = findHashedEntry(assetNames, options.entryBase);\n if (!entry) return;\n\n const contents: Record<string, string> = {};\n for (const fixedName of [MF_MANIFEST_FILENAME, STYLE_FILENAME]) {\n const from = resolveExisting(fixedName);\n if (from) contents[fixedName] = fs.readFileSync(from, \"utf8\");\n }\n\n const plan = planArtifactCopies({ assetNames, entryBase: options.entryBase, contents });\n if (!plan) return;\n\n for (const copy of plan.copies) {\n const from = resolveExisting(copy.from);\n if (!from) throw new Error(`[hash-artifacts] planned copy source missing: ${copy.from}`);\n fs.copyFileSync(from, path.join(distRoot, copy.to));\n }\n fs.writeFileSync(\n path.join(distRoot, \"build-report.json\"),\n `${JSON.stringify(BuildEntryReportSchema.parse(plan.report), null, 2)}\\n`,\n );\n });\n },\n };\n}\n"],"mappings":";;;;;AAkBA,SAAS,UAAU,KAAa,MAAgB,CAAC,GAAa;CAC5D,KAAK,MAAM,SAAS,GACjB,YAAY,KAAK,EAAE,eAAe,KAAK,CAAC,CAAC,CACzC,MAAM,GAAG,MAAM,EAAE,KAAK,cAAc,EAAE,IAAI,CAAC,GAAG;EAC/C,MAAM,OAAO,KAAK,KAAK,KAAK,MAAM,IAAI;EACtC,IAAI,MAAM,YAAY,GAAG,UAAU,MAAM,GAAG;OACvC,IAAI,KAAK,KAAK,SAAS,KAAK,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,GAAG,CAAC;CAClE;CACA,OAAO;AACT;;;;;;;;;AAUA,SAAgB,oBAAoB,SAAoD;CACtF,OAAO;EACL,MAAM;EACN,MAAM,KAAK;GACT,IAAI,gCAAgC;IAClC,MAAM,WAAW,QAAQ;IACzB,IAAI,CAAC,GAAG,WAAW,QAAQ,GAAG;IAE9B,MAAM,mBAAmB,SAAgC;KAKvD,OAAO,CAHL,KAAK,KAAK,UAAU,IAAI,GACxB,KAAK,KAAK,UAAU,UAAU,OAAO,IAAI,CAE3B,CAAC,CAAC,MAAM,cAAc,GAAG,WAAW,SAAS,CAAC,KAAK;IACrE;IAEA,MAAM,aAAa,UAAU,QAAQ;IAErC,IAAI,CADU,gBAAgB,YAAY,QAAQ,SACzC,GAAG;IAEZ,MAAM,WAAmC,CAAC;IAC1C,KAAK,MAAM,aAAa,CAAC,sBAAsB,cAAc,GAAG;KAC9D,MAAM,OAAO,gBAAgB,SAAS;KACtC,IAAI,MAAM,SAAS,aAAa,GAAG,aAAa,MAAM,MAAM;IAC9D;IAEA,MAAM,OAAO,mBAAmB;KAAE;KAAY,WAAW,QAAQ;KAAW;IAAS,CAAC;IACtF,IAAI,CAAC,MAAM;IAEX,KAAK,MAAM,QAAQ,KAAK,QAAQ;KAC9B,MAAM,OAAO,gBAAgB,KAAK,IAAI;KACtC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,iDAAiD,KAAK,MAAM;KACvF,GAAG,aAAa,MAAM,KAAK,KAAK,UAAU,KAAK,EAAE,CAAC;IACpD;IACA,GAAG,cACD,KAAK,KAAK,UAAU,mBAAmB,GACvC,GAAG,KAAK,UAAU,uBAAuB,MAAM,KAAK,MAAM,GAAG,MAAM,CAAC,EAAE,GACxE;GACF,CAAC;EACH;CACF;AACF"}
|