every-plugin 2.10.1 → 3.0.0-rc.3
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 +50 -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 +9 -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 +13 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +57 -24
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +58 -25
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +16 -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 +159 -33
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +64 -7
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +64 -7
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +154 -30
- 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 +57 -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 +57 -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 +56 -30
- 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 +55 -31
- 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 +25 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +25 -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 +17 -18
- package/src/identity.ts +36 -0
- package/src/index.ts +4 -0
- package/src/plugin.ts +88 -91
- package/src/remote-entry.ts +171 -0
- package/src/runtime/errors.ts +229 -26
- package/src/runtime/index.ts +132 -43
- package/src/runtime/mf-config.ts +12 -107
- package/src/runtime/services/module-federation.service.ts +218 -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 +271 -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 +25 -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 -248
- package/dist/build/rspack/dev-server-middleware.cjs.map +0 -1
- package/dist/build/rspack/dev-server-middleware.mjs +0 -247
- 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 -324
- 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,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The core ui's generated bootstrap stubs — the mechanical files an app must
|
|
3
|
+
* never author or edit (ADR 0023): the web MF entry, the `./Hydrate`
|
|
4
|
+
* bootstrap, the SSR router module, the `./compose` expose, and the ambient
|
|
5
|
+
* globals. Emitted into the ui source root by the framework's code-artifact
|
|
6
|
+
* generation pass, regenerated from the installed package version, and
|
|
7
|
+
* gitignored (`*.gen.*`) — never synced, never hand-maintained.
|
|
8
|
+
*
|
|
9
|
+
* The generated hydrate/SSR stubs wire the app's AUTHORED seams into the
|
|
10
|
+
* framework machinery: the router policy factory (`src/router.tsx`) and the
|
|
11
|
+
* app override exports from `src/app.ts` (`apiConnectionError`, `appLocale`).
|
|
12
|
+
* The seam files are scaffolded once by `bos init` and owned by the app; the
|
|
13
|
+
* stubs themselves carry zero app-specific content.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
|
|
19
|
+
export const CORE_UI_STUBS: Record<string, string> = {
|
|
20
|
+
"src/entry.gen.ts": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
21
|
+
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
22
|
+
import "./styles.css";
|
|
23
|
+
import { runEntry } from "everything-dev/ui/entry";
|
|
24
|
+
|
|
25
|
+
runEntry(() => import("./hydrate.gen"));
|
|
26
|
+
`,
|
|
27
|
+
"src/hydrate.gen.tsx": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
28
|
+
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
29
|
+
import "./styles.css";
|
|
30
|
+
import { hydrate as coreHydrate } from "everything-dev/ui/hydrate";
|
|
31
|
+
import { apiConnectionError } from "./app";
|
|
32
|
+
import { createQueryClient, createRouter } from "./router";
|
|
33
|
+
|
|
34
|
+
export function hydrate() {
|
|
35
|
+
return coreHydrate({
|
|
36
|
+
routeConfig: () => import("./routeConfig.gen"),
|
|
37
|
+
manifest: () => import("./manifest.gen.json"),
|
|
38
|
+
createRouter,
|
|
39
|
+
createQueryClient,
|
|
40
|
+
apiConnectionError,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default hydrate;
|
|
45
|
+
`,
|
|
46
|
+
"src/router.server.gen.tsx": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
47
|
+
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
48
|
+
import { createServerRouterModule } from "everything-dev/ui/router-server";
|
|
49
|
+
import { appLocale } from "./app";
|
|
50
|
+
import { createQueryClient, createRouter } from "./router";
|
|
51
|
+
import { routeTree } from "./routeTree.gen";
|
|
52
|
+
|
|
53
|
+
const routerModule = createServerRouterModule({
|
|
54
|
+
defaultRouteTree: routeTree,
|
|
55
|
+
createRouter,
|
|
56
|
+
createQueryClient,
|
|
57
|
+
locale: appLocale,
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
export default routerModule;
|
|
61
|
+
`,
|
|
62
|
+
"src/compose.gen.ts": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
63
|
+
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
64
|
+
export type {
|
|
65
|
+
ConstructedTree,
|
|
66
|
+
ConstructInput,
|
|
67
|
+
ConstructPluginRef,
|
|
68
|
+
GateUser,
|
|
69
|
+
HostContext,
|
|
70
|
+
NavManifest,
|
|
71
|
+
PluginManifest,
|
|
72
|
+
ResolvedPlugin,
|
|
73
|
+
RouteConfigModule,
|
|
74
|
+
RouteOptionsBundle,
|
|
75
|
+
} from "everything-dev/ui/manifest";
|
|
76
|
+
export {
|
|
77
|
+
CORE_UI_PLUGIN_KEY,
|
|
78
|
+
ComposePayloadSchema,
|
|
79
|
+
constructTree,
|
|
80
|
+
} from "everything-dev/ui/manifest";
|
|
81
|
+
`,
|
|
82
|
+
"src/globals.gen.ts": `// GENERATED FILE — do not edit. Regenerated from the installed framework version
|
|
83
|
+
// by \`bos dev\` / \`bos build\` / \`bos typecheck\` (gitignored).
|
|
84
|
+
/// <reference types="@rsbuild/core/types" />
|
|
85
|
+
`,
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Emits the stub set into the ui source root. Returns the stub paths whose
|
|
90
|
+
* content actually changed (empty when everything is already current) — the
|
|
91
|
+
* same-content suppression keeps dev watchers from regen loops.
|
|
92
|
+
*/
|
|
93
|
+
export function emitCoreUiStubs(uiRoot: string): string[] {
|
|
94
|
+
const written: string[] = [];
|
|
95
|
+
for (const [relPath, content] of Object.entries(CORE_UI_STUBS)) {
|
|
96
|
+
const fullPath = join(uiRoot, relPath);
|
|
97
|
+
if (existsSync(fullPath) && readFileSync(fullPath, "utf-8") === content) continue;
|
|
98
|
+
mkdirSync(dirname(fullPath), { recursive: true });
|
|
99
|
+
writeFileSync(fullPath, content);
|
|
100
|
+
written.push(relPath);
|
|
101
|
+
}
|
|
102
|
+
return written;
|
|
103
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { generateContractTypes } from "./build/contract-types";
|
|
3
|
+
import { ensureGeneratedRspackConfig } from "./build/rspack/generated-config";
|
|
4
|
+
import {
|
|
5
|
+
ensureGeneratedCoreUiRsbuildConfig,
|
|
6
|
+
ensureGeneratedUiRsbuildConfig,
|
|
7
|
+
hasCoreUiWorkspace,
|
|
8
|
+
} from "./build/ui/generated-config";
|
|
9
|
+
|
|
10
|
+
function run(
|
|
11
|
+
cmd: string,
|
|
12
|
+
args: string[],
|
|
13
|
+
env: Record<string, string | undefined> = {},
|
|
14
|
+
): Promise<void> {
|
|
15
|
+
return new Promise((resolve, reject) => {
|
|
16
|
+
const child = spawn(cmd, args, {
|
|
17
|
+
stdio: "inherit",
|
|
18
|
+
env: { ...process.env, ...env },
|
|
19
|
+
shell: process.platform === "win32",
|
|
20
|
+
});
|
|
21
|
+
child.on("exit", (code) =>
|
|
22
|
+
code === 0
|
|
23
|
+
? resolve()
|
|
24
|
+
: reject(new Error(`${cmd} ${args.join(" ")} exited with code ${code}`)),
|
|
25
|
+
);
|
|
26
|
+
child.on("error", reject);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export async function emitContractTypes(): Promise<void> {
|
|
31
|
+
const status = await generateContractTypes();
|
|
32
|
+
if (status === "skipped") {
|
|
33
|
+
console.log("[every-plugin] No src/contract.ts — nothing to emit.");
|
|
34
|
+
} else {
|
|
35
|
+
console.log(`[every-plugin] Contract types ${status}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Workspace-form core ui build surface — the /api model applied to the ui:
|
|
41
|
+
* the generated config (or a local rsbuild.config.ts override) drives
|
|
42
|
+
* rsbuild; extra args pass through (`--environment web|node`).
|
|
43
|
+
*/
|
|
44
|
+
async function runCoreUi(args: string[]): Promise<void> {
|
|
45
|
+
const generatedConfig = ensureGeneratedCoreUiRsbuildConfig();
|
|
46
|
+
const [command = "build", ...rest] = args;
|
|
47
|
+
const configArgs = generatedConfig ? ["--config", generatedConfig] : [];
|
|
48
|
+
await run("rsbuild", [command, ...configArgs, ...rest], {});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function runRspack(): Promise<void> {
|
|
52
|
+
const generatedConfig = ensureGeneratedRspackConfig();
|
|
53
|
+
|
|
54
|
+
const args = generatedConfig ? ["build", "--config", generatedConfig] : ["build"];
|
|
55
|
+
await run("rspack", args, {});
|
|
56
|
+
|
|
57
|
+
const uiConfig = ensureGeneratedUiRsbuildConfig(process.cwd());
|
|
58
|
+
if (uiConfig) {
|
|
59
|
+
console.log("[every-plugin] Building folder-form ui source…");
|
|
60
|
+
await run("rsbuild", ["build", "--config", uiConfig], {});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function runCliCommand(raw: string, args: string[] = []): Promise<void> {
|
|
65
|
+
const command = raw.replace(/=.*/, "");
|
|
66
|
+
if (command === "dev") process.env.BOS_DEV_SERVER = "1";
|
|
67
|
+
// The core ui workspace form routes build/dev/preview through rsbuild;
|
|
68
|
+
// plugin workspaces keep the rspack/dev-server surface.
|
|
69
|
+
if (hasCoreUiWorkspace()) {
|
|
70
|
+
switch (command) {
|
|
71
|
+
case "build":
|
|
72
|
+
return runCoreUi(["build", ...args]);
|
|
73
|
+
case "preview":
|
|
74
|
+
return runCoreUi(["preview", ...args]);
|
|
75
|
+
case "dev":
|
|
76
|
+
return runCoreUi(["dev", ...args]);
|
|
77
|
+
default:
|
|
78
|
+
return Promise.reject(
|
|
79
|
+
new Error(`Unknown every-plugin command for a core ui workspace: ${raw}`),
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
switch (command) {
|
|
84
|
+
case "types":
|
|
85
|
+
return emitContractTypes();
|
|
86
|
+
case "build":
|
|
87
|
+
case "deploy":
|
|
88
|
+
return runRspack();
|
|
89
|
+
case "dev":
|
|
90
|
+
return (async () => {
|
|
91
|
+
const { startPluginDevServer } = await import("./dev/serve");
|
|
92
|
+
await startPluginDevServer();
|
|
93
|
+
return new Promise<void>(() => {});
|
|
94
|
+
})();
|
|
95
|
+
default:
|
|
96
|
+
return Promise.reject(
|
|
97
|
+
new Error(`Unknown every-plugin command: ${raw} (expected dev|types|build|deploy)`),
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
}
|
package/src/dev/serve.ts
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Effect } from "effect";
|
|
6
|
+
import sirv from "sirv";
|
|
7
|
+
import { DEV_ENTRY_FILENAME } from "../build/artifact-names";
|
|
8
|
+
import { ensureGeneratedRspackConfig } from "../build/rspack/generated-config";
|
|
9
|
+
import { getPluginInfo, loadDevConfig } from "../build/rspack/utils";
|
|
10
|
+
import { ensureGeneratedUiRsbuildConfig, pluginLayoutKey } from "../build/ui/generated-config";
|
|
11
|
+
import { PLUGIN_ERROR_STATUS_MAP } from "../errors";
|
|
12
|
+
import { loadRemoteWithRetry } from "../remote-entry";
|
|
13
|
+
import { killChildEscalating, watchParentDeath } from "./watch-kill";
|
|
14
|
+
|
|
15
|
+
const corsHeaders = {
|
|
16
|
+
"Access-Control-Allow-Origin": "*",
|
|
17
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
18
|
+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const applyCorsHeaders = (res: http.ServerResponse) => {
|
|
22
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
23
|
+
res.setHeader(key, value);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const normalizePrefix = (prefix?: string): string => {
|
|
28
|
+
if (!prefix) return "";
|
|
29
|
+
const cleaned = prefix.replace(/^\/+|\/+$/g, "");
|
|
30
|
+
return cleaned ? `/${cleaned}` : "";
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const readRuntimeConfigFromEnv = (): any => {
|
|
34
|
+
const raw = process.env.BOS_RUNTIME_CONFIG;
|
|
35
|
+
if (!raw) return null;
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(raw);
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const collectSiblingRemotes = (runtimeConfig: any, pluginId: string) => {
|
|
44
|
+
const siblings: Record<string, { remote: string }> = {};
|
|
45
|
+
|
|
46
|
+
const isApi = pluginId === "api" || runtimeConfig?.api?.name === pluginId;
|
|
47
|
+
|
|
48
|
+
const ownKey = runtimeConfig?.plugins?.[pluginId] ? pluginId : null;
|
|
49
|
+
let dependsOn: string[] = [];
|
|
50
|
+
if (ownKey) {
|
|
51
|
+
dependsOn = runtimeConfig.plugins[ownKey].dependsOn ?? [];
|
|
52
|
+
} else if (isApi) {
|
|
53
|
+
dependsOn = runtimeConfig?.api?.dependsOn ?? [];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const depId of dependsOn) {
|
|
57
|
+
const dep = runtimeConfig?.plugins?.[depId];
|
|
58
|
+
if (!dep || dep.source !== "local" || !dep.url) continue;
|
|
59
|
+
if (depId === pluginId) continue;
|
|
60
|
+
const base = dep.url.replace(/\/$/, "");
|
|
61
|
+
siblings[depId] = { remote: `${base}/${DEV_ENTRY_FILENAME}` };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return { siblings, dependsOn };
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const loadPluginWithRetry = (
|
|
68
|
+
runtime: any,
|
|
69
|
+
pluginId: string,
|
|
70
|
+
remoteUrl: string,
|
|
71
|
+
options: Record<string, unknown> = { variables: {}, secrets: {} },
|
|
72
|
+
pluginsMap?: Record<string, unknown>,
|
|
73
|
+
timeoutMs = 90000,
|
|
74
|
+
): Promise<any> =>
|
|
75
|
+
Effect.runPromise(
|
|
76
|
+
loadRemoteWithRetry({
|
|
77
|
+
label: pluginId,
|
|
78
|
+
remoteUrl,
|
|
79
|
+
load: () => runtime.usePlugin(pluginId, options, pluginsMap),
|
|
80
|
+
timeoutMs,
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
const sendJson = (res: http.ServerResponse, status: number, body: unknown) => {
|
|
85
|
+
res.statusCode = status;
|
|
86
|
+
res.setHeader("content-type", "application/json; charset=utf-8");
|
|
87
|
+
res.end(JSON.stringify(body));
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const sendText = (res: http.ServerResponse, status: number, text: string) => {
|
|
91
|
+
res.statusCode = status;
|
|
92
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
93
|
+
res.end(text);
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export interface PluginDevServeOptions {
|
|
97
|
+
cwd?: string;
|
|
98
|
+
port?: number;
|
|
99
|
+
watch?: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface PluginDevServerHandle {
|
|
103
|
+
port: number;
|
|
104
|
+
close: () => Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The dev server's plugin id — the workspace's npm package name, the same
|
|
109
|
+
* value the host passes as `runtimeId`. Both initialize sites must agree:
|
|
110
|
+
* `registerRemote` derives the MF remote name from it, and the plugin's
|
|
111
|
+
* database layer derives its migration slug from it, so a pre-normalized
|
|
112
|
+
* remote name here would migrate into a different schema than the host
|
|
113
|
+
* expects. plugin.dev.ts no longer carries a pluginId field.
|
|
114
|
+
*/
|
|
115
|
+
export const resolveDevPluginId = (cwd: string): string => getPluginInfo(cwd).name;
|
|
116
|
+
|
|
117
|
+
export async function startPluginDevServer(
|
|
118
|
+
options: PluginDevServeOptions = {},
|
|
119
|
+
): Promise<PluginDevServerHandle> {
|
|
120
|
+
process.env.BOS_DEV_SERVER = "1";
|
|
121
|
+
const cwd = options.cwd ?? process.cwd();
|
|
122
|
+
const pluginInfo = getPluginInfo(cwd);
|
|
123
|
+
const devConfig = loadDevConfig(path.join(cwd, "plugin.dev.ts"));
|
|
124
|
+
const pluginId = resolveDevPluginId(cwd);
|
|
125
|
+
const compositionKey = pluginLayoutKey(cwd) ?? pluginId;
|
|
126
|
+
const port = options.port ?? (Number(process.env.PORT) || devConfig?.port || 3999);
|
|
127
|
+
const rpcPrefix = normalizePrefix(devConfig?.prefix);
|
|
128
|
+
const rpcBase = `/api/rpc${rpcPrefix}`;
|
|
129
|
+
|
|
130
|
+
const distDir = path.join(cwd, "dist");
|
|
131
|
+
const serveStatic = sirv(distDir, { dev: true });
|
|
132
|
+
|
|
133
|
+
// No-watch mode (BOS_NO_WATCH=1): build once, serve the built output.
|
|
134
|
+
// Regression/CI stacks need no hot reload — watchers are the stack's
|
|
135
|
+
// heaviest processes and stall runs freeze under their accumulated
|
|
136
|
+
// footprint. One-shot builds exit; steady state is small static servers.
|
|
137
|
+
const noWatch = options.watch === false || process.env.BOS_NO_WATCH === "1";
|
|
138
|
+
|
|
139
|
+
const runOnce = (cmd: string, args: string[]) =>
|
|
140
|
+
new Promise<void>((resolve, reject) => {
|
|
141
|
+
const child = spawn(cmd, args, { cwd, stdio: "inherit", env: process.env });
|
|
142
|
+
child.on("error", reject);
|
|
143
|
+
child.on("exit", (code) => {
|
|
144
|
+
if (code === 0) resolve();
|
|
145
|
+
else reject(new Error(`❌ ${cmd} ${args.join(" ")} exited with ${code}`));
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
let watcher: ReturnType<typeof spawn> | null = null;
|
|
150
|
+
if (noWatch) {
|
|
151
|
+
const generatedConfig = ensureGeneratedRspackConfig(cwd);
|
|
152
|
+
await runOnce("rspack", generatedConfig ? ["build", "--config", generatedConfig] : ["build"]);
|
|
153
|
+
} else if (options.watch !== false) {
|
|
154
|
+
const generatedConfig = ensureGeneratedRspackConfig(cwd);
|
|
155
|
+
watcher = spawn(
|
|
156
|
+
"rspack",
|
|
157
|
+
generatedConfig ? ["build", "--watch", "--config", generatedConfig] : ["build", "--watch"],
|
|
158
|
+
{
|
|
159
|
+
cwd,
|
|
160
|
+
stdio: "inherit",
|
|
161
|
+
env: process.env,
|
|
162
|
+
},
|
|
163
|
+
);
|
|
164
|
+
watcher.on("error", (error) => {
|
|
165
|
+
console.error(`❌ Failed to spawn rspack build --watch: ${error.message}`);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let uiWatcher: ReturnType<typeof spawn> | null = null;
|
|
170
|
+
let uiStaticServer: http.Server | null = null;
|
|
171
|
+
const uiPort = process.env.BOS_UI_PORT;
|
|
172
|
+
const uiConfig = ensureGeneratedUiRsbuildConfig(cwd);
|
|
173
|
+
if (uiConfig && noWatch && uiPort) {
|
|
174
|
+
// Folder-form ui: one-shot build, then serve the ui source root's dist
|
|
175
|
+
// (the factory's absolute distPath target) statically on the ui port.
|
|
176
|
+
await runOnce("rsbuild", ["build", "--config", uiConfig]);
|
|
177
|
+
const uiDistDir =
|
|
178
|
+
path.basename(cwd) === "ui" ? path.join(cwd, "dist") : path.join(cwd, "ui", "dist");
|
|
179
|
+
if (!fs.existsSync(path.join(uiDistDir, DEV_ENTRY_FILENAME))) {
|
|
180
|
+
console.error(
|
|
181
|
+
`❌ UI dist is missing at ${uiDistDir} — the ui static server would serve 404s for every asset (build output layout mismatch?)`,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
const serveUiStatic = sirv(uiDistDir, { dev: true });
|
|
185
|
+
uiStaticServer = http.createServer((req, res) => {
|
|
186
|
+
applyCorsHeaders(res);
|
|
187
|
+
serveUiStatic(req, res, () => {
|
|
188
|
+
sendText(res, 404, "Not Found");
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
await new Promise<void>((resolve, reject) => {
|
|
192
|
+
uiStaticServer!.once("error", reject);
|
|
193
|
+
uiStaticServer!.listen(Number(uiPort), () => resolve());
|
|
194
|
+
});
|
|
195
|
+
console.log(`├─ 🎨 UI: http://localhost:${uiPort} (built, no watch)`);
|
|
196
|
+
} else if (uiConfig) {
|
|
197
|
+
uiWatcher = spawn("rsbuild", ["dev", "--config", uiConfig], {
|
|
198
|
+
cwd,
|
|
199
|
+
stdio: "inherit",
|
|
200
|
+
env: uiPort ? { ...process.env, PORT: uiPort } : process.env,
|
|
201
|
+
});
|
|
202
|
+
uiWatcher.on("error", (error) => {
|
|
203
|
+
console.error(`❌ Failed to spawn rsbuild ui dev: ${error.message}`);
|
|
204
|
+
});
|
|
205
|
+
console.log(`├─ 🎨 UI: ${uiPort ? `http://localhost:${uiPort}` : "(rsbuild auto port)"}`);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const handlers: { rpc: any; api: any } = { rpc: null, api: null };
|
|
209
|
+
const effectContextHolder: { context: unknown } = { context: null };
|
|
210
|
+
let runtime: { shutdown: () => Promise<void> } | null = null;
|
|
211
|
+
|
|
212
|
+
const pathnameOf = (req: http.IncomingMessage): string =>
|
|
213
|
+
((req.url ?? "/").split("?")[0] ?? "/").replace(/\/+$/, "") || "/";
|
|
214
|
+
|
|
215
|
+
const buildDevContext = (_req: http.IncomingMessage, webRequest: Request) => {
|
|
216
|
+
const rawClone =
|
|
217
|
+
webRequest.method === "GET" || webRequest.method === "HEAD" ? null : webRequest.clone();
|
|
218
|
+
let cachedRawBody: string | null = null;
|
|
219
|
+
return {
|
|
220
|
+
reqHeaders: webRequest.headers,
|
|
221
|
+
"effect/context": effectContextHolder.context,
|
|
222
|
+
getRawBody: async (): Promise<string> => {
|
|
223
|
+
if (cachedRawBody !== null) return cachedRawBody;
|
|
224
|
+
if (!rawClone) {
|
|
225
|
+
cachedRawBody = "";
|
|
226
|
+
return cachedRawBody;
|
|
227
|
+
}
|
|
228
|
+
cachedRawBody = await rawClone.text();
|
|
229
|
+
return cachedRawBody;
|
|
230
|
+
},
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const toWebRequest = (req: http.IncomingMessage): Request => {
|
|
235
|
+
const url = `http://localhost:${port}${req.url}`;
|
|
236
|
+
return new Request(url, {
|
|
237
|
+
method: req.method,
|
|
238
|
+
headers: req.headers,
|
|
239
|
+
body: req.method !== "GET" && req.method !== "HEAD" ? req : undefined,
|
|
240
|
+
duplex: req.method !== "GET" && req.method !== "HEAD" ? "half" : undefined,
|
|
241
|
+
} as RequestInit);
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const handleOrpc = async (
|
|
245
|
+
req: http.IncomingMessage,
|
|
246
|
+
res: http.ServerResponse,
|
|
247
|
+
handler: any,
|
|
248
|
+
prefix: string,
|
|
249
|
+
errorLabel: string,
|
|
250
|
+
) => {
|
|
251
|
+
try {
|
|
252
|
+
const webRequest = toWebRequest(req);
|
|
253
|
+
const result = await handler.handle(webRequest, {
|
|
254
|
+
prefix,
|
|
255
|
+
context: buildDevContext(req, webRequest),
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (result.response) {
|
|
259
|
+
res.statusCode = result.response.status;
|
|
260
|
+
result.response.headers.forEach((value: string, key: string) => {
|
|
261
|
+
res.setHeader(key, value);
|
|
262
|
+
});
|
|
263
|
+
const text = await result.response.text();
|
|
264
|
+
if (!res.getHeader("content-length")) {
|
|
265
|
+
res.setHeader("content-length", Buffer.byteLength(text).toString());
|
|
266
|
+
}
|
|
267
|
+
res.end(text);
|
|
268
|
+
} else {
|
|
269
|
+
sendText(res, 404, "Not Found");
|
|
270
|
+
}
|
|
271
|
+
} catch (error) {
|
|
272
|
+
console.error(`${errorLabel} error:`, error);
|
|
273
|
+
sendJson(res, 500, { error: (error as Error).message });
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const server = http.createServer((req, res) => {
|
|
278
|
+
applyCorsHeaders(res);
|
|
279
|
+
const pathname = pathnameOf(req);
|
|
280
|
+
|
|
281
|
+
if (req.method === "OPTIONS") {
|
|
282
|
+
res.statusCode = 200;
|
|
283
|
+
res.end();
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (pathname === "/" && (req.method === "GET" || req.method === "HEAD")) {
|
|
288
|
+
sendJson(res, 200, {
|
|
289
|
+
ok: true,
|
|
290
|
+
plugin: pluginInfo.normalizedName,
|
|
291
|
+
version: pluginInfo.version,
|
|
292
|
+
status: handlers.rpc ? "ready" : "loading",
|
|
293
|
+
endpoints: {
|
|
294
|
+
health: "/",
|
|
295
|
+
docs: "/api",
|
|
296
|
+
rpc: rpcBase,
|
|
297
|
+
},
|
|
298
|
+
});
|
|
299
|
+
return;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (pathname === "/health" && (req.method === "GET" || req.method === "HEAD")) {
|
|
303
|
+
sendText(res, 200, "OK");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (pathname.startsWith(`${rpcBase}/`)) {
|
|
308
|
+
if (!handlers.rpc) {
|
|
309
|
+
sendJson(res, 503, { error: "Plugin still loading..." });
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
handleOrpc(req, res, handlers.rpc, rpcBase, "RPC").catch(() => {});
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
if (pathname === "/api" || pathname.startsWith("/api/")) {
|
|
317
|
+
if (!handlers.api) {
|
|
318
|
+
sendJson(res, 503, { error: "Plugin still loading..." });
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
handleOrpc(req, res, handlers.api, "/api", "OpenAPI").catch(() => {});
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
serveStatic(req, res, () => {
|
|
326
|
+
sendText(res, 404, "Not Found");
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
await new Promise<void>((resolve, reject) => {
|
|
331
|
+
server.once("error", reject);
|
|
332
|
+
server.listen(port, () => resolve());
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
console.log(`🚀 ${pluginInfo.name} dev server listening on port ${port}`);
|
|
336
|
+
console.log(`├─ 📡 RPC: http://localhost:${port}/api/rpc${rpcPrefix}`);
|
|
337
|
+
console.log(`├─ 📖 Docs: http://localhost:${port}/api`);
|
|
338
|
+
console.log(`└─ 💚 Health: http://localhost:${port}/`);
|
|
339
|
+
|
|
340
|
+
const load = async () => {
|
|
341
|
+
try {
|
|
342
|
+
// Import framework internals directly. A package self-import can resolve
|
|
343
|
+
// the published entry while this source-first dev server is running,
|
|
344
|
+
// which leaves the runtime exports unavailable on Windows.
|
|
345
|
+
const { createPluginRuntime } = await import("../runtime");
|
|
346
|
+
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
347
|
+
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
348
|
+
const { OpenAPIGenerator } = await import("@orpc/openapi");
|
|
349
|
+
const { OpenAPIReferenceHandlerPlugin } = await import("@orpc/openapi/plugins");
|
|
350
|
+
const { ZodToJsonSchemaConverter } = await import("@orpc/zod");
|
|
351
|
+
const { onError } = await import("@orpc/server");
|
|
352
|
+
const { formatORPCError } = await import("../errors");
|
|
353
|
+
|
|
354
|
+
const runtimeConfig = readRuntimeConfigFromEnv();
|
|
355
|
+
const { siblings, dependsOn } = collectSiblingRemotes(runtimeConfig, compositionKey);
|
|
356
|
+
|
|
357
|
+
if (dependsOn.length > 0) {
|
|
358
|
+
console.log(`🔗 Loading sibling plugin(s): ${dependsOn.join(", ")}`);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const registry: Record<string, { remote: string }> = {
|
|
362
|
+
[pluginId]: {
|
|
363
|
+
remote: `http://localhost:${port}/${DEV_ENTRY_FILENAME}`,
|
|
364
|
+
},
|
|
365
|
+
...siblings,
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
const mfRuntime = createPluginRuntime({ registry });
|
|
369
|
+
runtime = mfRuntime;
|
|
370
|
+
|
|
371
|
+
const pluginsMap: Record<string, unknown> = {};
|
|
372
|
+
const siblingEffectContexts: unknown[] = [];
|
|
373
|
+
for (const depId of Object.keys(siblings)) {
|
|
374
|
+
const dep = await loadPluginWithRetry(mfRuntime, depId, siblings[depId]!.remote);
|
|
375
|
+
pluginsMap[depId] = { client: dep.createClient, router: dep.router };
|
|
376
|
+
if (dep.initialized?.effectContext) {
|
|
377
|
+
siblingEffectContexts.push(dep.initialized.effectContext);
|
|
378
|
+
}
|
|
379
|
+
console.log(`✅ Loaded dependency plugin: ${depId}`);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
const loaded: any = await loadPluginWithRetry(
|
|
383
|
+
mfRuntime,
|
|
384
|
+
pluginId,
|
|
385
|
+
registry[pluginId]!.remote,
|
|
386
|
+
(devConfig?.config ?? { variables: {}, secrets: {} }) as Record<string, unknown>,
|
|
387
|
+
Object.keys(pluginsMap).length > 0 ? pluginsMap : undefined,
|
|
388
|
+
);
|
|
389
|
+
|
|
390
|
+
const { Context } = await import("effect");
|
|
391
|
+
effectContextHolder.context = [loaded.initialized?.effectContext, ...siblingEffectContexts]
|
|
392
|
+
.filter(Boolean)
|
|
393
|
+
.reduce((acc: any, ctx: any) => Context.merge(acc, ctx), Context.empty());
|
|
394
|
+
|
|
395
|
+
handlers.rpc = new RPCHandler(loaded.router, {
|
|
396
|
+
errorStatusMap: PLUGIN_ERROR_STATUS_MAP,
|
|
397
|
+
interceptors: [
|
|
398
|
+
onError((error: any) => {
|
|
399
|
+
const formatted = formatORPCError(error);
|
|
400
|
+
if (formatted) console.error(formatted);
|
|
401
|
+
}),
|
|
402
|
+
],
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
const generator = new OpenAPIGenerator({ converters: [new ZodToJsonSchemaConverter()] });
|
|
406
|
+
|
|
407
|
+
handlers.api = new OpenAPIHandler(loaded.router, {
|
|
408
|
+
errorStatusMap: PLUGIN_ERROR_STATUS_MAP,
|
|
409
|
+
plugins: [
|
|
410
|
+
new OpenAPIReferenceHandlerPlugin({
|
|
411
|
+
spec: () => generator.generate(loaded.router, { version: "3.1.1" }),
|
|
412
|
+
}),
|
|
413
|
+
],
|
|
414
|
+
interceptors: [
|
|
415
|
+
onError((error: any) => {
|
|
416
|
+
const formatted = formatORPCError(error);
|
|
417
|
+
if (formatted) console.error(formatted);
|
|
418
|
+
}),
|
|
419
|
+
],
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
console.log(`✅ Plugin ready: ${pluginId}`);
|
|
423
|
+
} catch (error) {
|
|
424
|
+
console.error(`❌ Failed to load plugin ${pluginId}:`, error);
|
|
425
|
+
console.error(" Server stays up; fix the build and retry via rebuild.");
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
void load();
|
|
430
|
+
|
|
431
|
+
const close = async () => {
|
|
432
|
+
handlers.rpc = null;
|
|
433
|
+
handlers.api = null;
|
|
434
|
+
effectContextHolder.context = null;
|
|
435
|
+
for (const child of [watcher, uiWatcher]) {
|
|
436
|
+
if (child) {
|
|
437
|
+
await killChildEscalating(child);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (uiStaticServer) {
|
|
441
|
+
await new Promise<void>((resolve) => uiStaticServer.close(() => resolve()));
|
|
442
|
+
}
|
|
443
|
+
if (runtime) await runtime.shutdown().catch(() => {});
|
|
444
|
+
await new Promise<void>((resolve) => server.close(() => resolve()));
|
|
445
|
+
};
|
|
446
|
+
|
|
447
|
+
process.once("SIGINT", async () => {
|
|
448
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
449
|
+
await close();
|
|
450
|
+
clearTimeout(timeout);
|
|
451
|
+
process.exit(0);
|
|
452
|
+
});
|
|
453
|
+
process.once("SIGTERM", async () => {
|
|
454
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
455
|
+
await close();
|
|
456
|
+
clearTimeout(timeout);
|
|
457
|
+
process.exit(0);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
watchParentDeath(async () => {
|
|
461
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
462
|
+
await close();
|
|
463
|
+
clearTimeout(timeout);
|
|
464
|
+
process.exit(0);
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
return { port, close };
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
const invokedAsCli = import.meta.main || (process.argv[1] ?? "").includes("every-plugin-serve");
|
|
471
|
+
|
|
472
|
+
if (invokedAsCli) {
|
|
473
|
+
startPluginDevServer().catch((error) => {
|
|
474
|
+
console.error("❌ Plugin dev server fatal error:", error);
|
|
475
|
+
process.exit(1);
|
|
476
|
+
});
|
|
477
|
+
}
|