every-plugin 2.10.1 → 3.0.0-rc.10
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 +59 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs +59 -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 +122 -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 +114 -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/client.cjs +69 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +15 -0
- package/dist/client.d.cts.map +1 -0
- package/dist/client.d.mts +15 -0
- package/dist/client.d.mts.map +1 -0
- package/dist/client.mjs +68 -0
- package/dist/client.mjs.map +1 -0
- package/dist/dev/host.cjs +149 -0
- package/dist/dev/host.cjs.map +1 -0
- package/dist/dev/host.d.cts +32 -0
- package/dist/dev/host.d.cts.map +1 -0
- package/dist/dev/host.d.mts +32 -0
- package/dist/dev/host.d.mts.map +1 -0
- package/dist/dev/host.mjs +148 -0
- package/dist/dev/host.mjs.map +1 -0
- package/dist/dev/serve.cjs +295 -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 +289 -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 +11 -5
- package/dist/index.d.cts +9 -6
- package/dist/index.d.mts +9 -6
- package/dist/index.mjs +7 -4
- package/dist/plugin.cjs +13 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +64 -25
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +64 -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 +102 -0
- package/dist/remote-entry.cjs.map +1 -0
- package/dist/remote-entry.d.cts +52 -0
- package/dist/remote-entry.d.cts.map +1 -0
- package/dist/remote-entry.d.mts +52 -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 +59 -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 +58 -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 +47 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +47 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/ui/manifest/construct.cjs +319 -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 +319 -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 +77 -0
- package/dist/version-manifest.cjs.map +1 -0
- package/dist/version-manifest.d.cts +62 -0
- package/dist/version-manifest.d.cts.map +1 -0
- package/dist/version-manifest.d.mts +62 -0
- package/dist/version-manifest.d.mts.map +1 -0
- package/dist/version-manifest.mjs +75 -0
- package/dist/version-manifest.mjs.map +1 -0
- package/package.json +182 -68
- package/skills/plugin-client/SKILL.md +34 -9
- package/skills/plugin-development/SKILL.md +79 -47
- package/skills/plugin-testing/SKILL.md +42 -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 +66 -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 +137 -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/client.ts +111 -0
- package/src/dev/host.ts +235 -0
- package/src/dev/serve.ts +359 -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 +13 -0
- package/src/plugin.ts +94 -91
- package/src/remote-entry.ts +170 -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 +280 -209
- 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 +62 -50
- package/src/ui/manifest/construct.ts +456 -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 +106 -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
package/src/dev/serve.ts
ADDED
|
@@ -0,0 +1,359 @@
|
|
|
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 {
|
|
11
|
+
ensureGeneratedUiRsbuildConfig,
|
|
12
|
+
pluginLayoutKey,
|
|
13
|
+
uiDistDirFor,
|
|
14
|
+
} from "../build/ui/generated-config";
|
|
15
|
+
import { PLUGIN_ERROR_STATUS_MAP } from "../errors";
|
|
16
|
+
import { loadRemoteWithRetry } from "../remote-entry";
|
|
17
|
+
import { startDirectModuleHost } from "./host";
|
|
18
|
+
import { killChildEscalating, watchParentDeath } from "./watch-kill";
|
|
19
|
+
|
|
20
|
+
const corsHeaders = {
|
|
21
|
+
"Access-Control-Allow-Origin": "*",
|
|
22
|
+
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, PATCH, OPTIONS",
|
|
23
|
+
"Access-Control-Allow-Headers": "X-Requested-With, content-type, Authorization",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const applyCorsHeaders = (res: http.ServerResponse) => {
|
|
27
|
+
Object.entries(corsHeaders).forEach(([key, value]) => {
|
|
28
|
+
res.setHeader(key, value);
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const normalizePrefix = (prefix?: string): string => {
|
|
33
|
+
if (!prefix) return "";
|
|
34
|
+
const cleaned = prefix.replace(/^\/+|\/+$/g, "");
|
|
35
|
+
return cleaned ? `/${cleaned}` : "";
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const readRuntimeConfigFromEnv = (): any => {
|
|
39
|
+
const raw = process.env.BOS_RUNTIME_CONFIG;
|
|
40
|
+
if (!raw) return null;
|
|
41
|
+
try {
|
|
42
|
+
return JSON.parse(raw);
|
|
43
|
+
} catch {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const collectSiblingRemotes = (runtimeConfig: any, pluginId: string) => {
|
|
49
|
+
const siblings: Record<string, { remote: string }> = {};
|
|
50
|
+
|
|
51
|
+
const isApi = pluginId === "api" || runtimeConfig?.api?.name === pluginId;
|
|
52
|
+
|
|
53
|
+
const ownKey = runtimeConfig?.plugins?.[pluginId] ? pluginId : null;
|
|
54
|
+
let dependsOn: string[] = [];
|
|
55
|
+
if (ownKey) {
|
|
56
|
+
dependsOn = runtimeConfig.plugins[ownKey].dependsOn ?? [];
|
|
57
|
+
} else if (isApi) {
|
|
58
|
+
dependsOn = runtimeConfig?.api?.dependsOn ?? [];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
for (const depId of dependsOn) {
|
|
62
|
+
const dep = runtimeConfig?.plugins?.[depId];
|
|
63
|
+
if (!dep || dep.source !== "local" || !dep.url) continue;
|
|
64
|
+
if (depId === pluginId) continue;
|
|
65
|
+
const base = dep.url.replace(/\/$/, "");
|
|
66
|
+
siblings[depId] = { remote: `${base}/${DEV_ENTRY_FILENAME}` };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return { siblings, dependsOn };
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const loadPluginWithRetry = (
|
|
73
|
+
runtime: any,
|
|
74
|
+
pluginId: string,
|
|
75
|
+
remoteUrl: string,
|
|
76
|
+
options: Record<string, unknown> = { variables: {}, secrets: {} },
|
|
77
|
+
pluginsMap?: Record<string, unknown>,
|
|
78
|
+
timeoutMs = 90000,
|
|
79
|
+
): Promise<any> =>
|
|
80
|
+
Effect.runPromise(
|
|
81
|
+
loadRemoteWithRetry({
|
|
82
|
+
label: pluginId,
|
|
83
|
+
remoteUrl,
|
|
84
|
+
load: () => runtime.usePlugin(pluginId, options, pluginsMap),
|
|
85
|
+
timeoutMs,
|
|
86
|
+
}),
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const sendText = (res: http.ServerResponse, status: number, text: string) => {
|
|
90
|
+
res.statusCode = status;
|
|
91
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
92
|
+
res.end(text);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
export interface PluginDevServeOptions {
|
|
96
|
+
cwd?: string;
|
|
97
|
+
port?: number;
|
|
98
|
+
watch?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface PluginDevServerHandle {
|
|
102
|
+
port: number;
|
|
103
|
+
close: () => Promise<void>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The dev server's plugin id — the workspace's npm package name, the same
|
|
108
|
+
* value the host passes as `runtimeId`. Both initialize sites must agree:
|
|
109
|
+
* `registerRemote` derives the MF remote name from it, and the plugin's
|
|
110
|
+
* database layer derives its migration slug from it, so a pre-normalized
|
|
111
|
+
* remote name here would migrate into a different schema than the host
|
|
112
|
+
* expects. plugin.dev.ts no longer carries a pluginId field.
|
|
113
|
+
*/
|
|
114
|
+
export const resolveDevPluginId = (cwd: string): string => getPluginInfo(cwd).name;
|
|
115
|
+
|
|
116
|
+
export async function startPluginDevServer(
|
|
117
|
+
options: PluginDevServeOptions = {},
|
|
118
|
+
): Promise<PluginDevServerHandle> {
|
|
119
|
+
process.env.BOS_DEV_SERVER = "1";
|
|
120
|
+
const cwd = options.cwd ?? process.cwd();
|
|
121
|
+
const pluginInfo = getPluginInfo(cwd);
|
|
122
|
+
const devConfig = loadDevConfig(path.join(cwd, "plugin.dev.ts"));
|
|
123
|
+
const pluginId = resolveDevPluginId(cwd);
|
|
124
|
+
const compositionKey = pluginLayoutKey(cwd) ?? pluginId;
|
|
125
|
+
const port = options.port ?? (Number(process.env.PORT) || devConfig?.port || 3999);
|
|
126
|
+
const rpcPrefix = normalizePrefix(devConfig?.prefix);
|
|
127
|
+
|
|
128
|
+
const distDir = path.join(cwd, "dist");
|
|
129
|
+
const serveStatic = sirv(distDir, { dev: true });
|
|
130
|
+
|
|
131
|
+
// No-watch mode (BOS_NO_WATCH=1): build once, serve the built output.
|
|
132
|
+
// Regression/CI stacks need no hot reload — watchers are the stack's
|
|
133
|
+
// heaviest processes and stall runs freeze under their accumulated
|
|
134
|
+
// footprint. One-shot builds exit; steady state is small static servers.
|
|
135
|
+
const noWatch = options.watch === false || process.env.BOS_NO_WATCH === "1";
|
|
136
|
+
|
|
137
|
+
const runOnce = (cmd: string, args: string[]) =>
|
|
138
|
+
new Promise<void>((resolve, reject) => {
|
|
139
|
+
const child = spawn(cmd, args, { cwd, stdio: "inherit", env: process.env });
|
|
140
|
+
child.on("error", reject);
|
|
141
|
+
child.on("exit", (code) => {
|
|
142
|
+
if (code === 0) resolve();
|
|
143
|
+
else reject(new Error(`❌ ${cmd} ${args.join(" ")} exited with ${code}`));
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
let watcher: ReturnType<typeof spawn> | null = null;
|
|
148
|
+
if (noWatch) {
|
|
149
|
+
const generatedConfig = ensureGeneratedRspackConfig(cwd);
|
|
150
|
+
await runOnce("rspack", generatedConfig ? ["build", "--config", generatedConfig] : ["build"]);
|
|
151
|
+
} else if (options.watch !== false) {
|
|
152
|
+
const generatedConfig = ensureGeneratedRspackConfig(cwd);
|
|
153
|
+
watcher = spawn(
|
|
154
|
+
"rspack",
|
|
155
|
+
generatedConfig ? ["build", "--watch", "--config", generatedConfig] : ["build", "--watch"],
|
|
156
|
+
{
|
|
157
|
+
cwd,
|
|
158
|
+
stdio: "inherit",
|
|
159
|
+
env: process.env,
|
|
160
|
+
},
|
|
161
|
+
);
|
|
162
|
+
watcher.on("error", (error) => {
|
|
163
|
+
console.error(`❌ Failed to spawn rspack build --watch: ${error.message}`);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
let uiWatcher: ReturnType<typeof spawn> | null = null;
|
|
168
|
+
let uiStaticServer: http.Server | null = null;
|
|
169
|
+
const uiPort = process.env.BOS_UI_PORT;
|
|
170
|
+
const uiConfig = ensureGeneratedUiRsbuildConfig(cwd);
|
|
171
|
+
if (uiConfig && noWatch && uiPort) {
|
|
172
|
+
// Folder-form ui: one-shot build, then serve the ui source root's dist
|
|
173
|
+
// (the factory's absolute distPath target) statically on the ui port.
|
|
174
|
+
await runOnce("rsbuild", ["build", "--config", uiConfig]);
|
|
175
|
+
const uiDistDir = uiDistDirFor(cwd);
|
|
176
|
+
if (!fs.existsSync(path.join(uiDistDir, DEV_ENTRY_FILENAME))) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
`❌ UI dist is missing at ${uiDistDir} after the rsbuild one-shot — build output layout mismatch?`,
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
const serveUiStatic = sirv(uiDistDir, { dev: true });
|
|
182
|
+
uiStaticServer = http.createServer((req, res) => {
|
|
183
|
+
applyCorsHeaders(res);
|
|
184
|
+
serveUiStatic(req, res, () => {
|
|
185
|
+
sendText(res, 404, "Not Found");
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
await new Promise<void>((resolve, reject) => {
|
|
189
|
+
uiStaticServer!.once("error", reject);
|
|
190
|
+
uiStaticServer!.listen(Number(uiPort), () => resolve());
|
|
191
|
+
});
|
|
192
|
+
console.log(`├─ 🎨 UI: http://localhost:${uiPort} (built, no watch)`);
|
|
193
|
+
} else if (uiConfig) {
|
|
194
|
+
uiWatcher = spawn("rsbuild", ["dev", "--config", uiConfig], {
|
|
195
|
+
cwd,
|
|
196
|
+
stdio: "inherit",
|
|
197
|
+
env: uiPort ? { ...process.env, PORT: uiPort } : process.env,
|
|
198
|
+
});
|
|
199
|
+
uiWatcher.on("error", (error) => {
|
|
200
|
+
console.error(`❌ Failed to spawn rsbuild ui dev: ${error.message}`);
|
|
201
|
+
});
|
|
202
|
+
console.log(`├─ 🎨 UI: ${uiPort ? `http://localhost:${uiPort}` : "(rsbuild auto port)"}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const handlers: { rpc: any; api: any } = { rpc: null, api: null };
|
|
206
|
+
const effectContextHolder: { context: unknown } = { context: null };
|
|
207
|
+
let runtime: { shutdown: () => Promise<void> } | null = null;
|
|
208
|
+
const host = await startDirectModuleHost({
|
|
209
|
+
name: pluginInfo.normalizedName,
|
|
210
|
+
version: pluginInfo.version,
|
|
211
|
+
handlers,
|
|
212
|
+
effectContext: () => effectContextHolder.context,
|
|
213
|
+
port,
|
|
214
|
+
staticHandler: serveStatic,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
console.log(`🚀 ${pluginInfo.name} dev server listening on port ${host.port}`);
|
|
218
|
+
console.log(`├─ 📡 RPC: http://localhost:${host.port}/api/rpc${rpcPrefix}`);
|
|
219
|
+
console.log(`├─ 📖 Docs: http://localhost:${host.port}/api`);
|
|
220
|
+
console.log(`└─ 💚 Health: http://localhost:${host.port}/`);
|
|
221
|
+
|
|
222
|
+
const load = async () => {
|
|
223
|
+
try {
|
|
224
|
+
// Import framework internals directly. A package self-import can resolve
|
|
225
|
+
// the published entry while this source-first dev server is running,
|
|
226
|
+
// which leaves the runtime exports unavailable on Windows.
|
|
227
|
+
const { createPluginRuntime } = await import("../runtime");
|
|
228
|
+
const { RPCHandler } = await import("@orpc/server/fetch");
|
|
229
|
+
const { OpenAPIHandler } = await import("@orpc/openapi/fetch");
|
|
230
|
+
const { OpenAPIGenerator } = await import("@orpc/openapi");
|
|
231
|
+
const { OpenAPIReferenceHandlerPlugin } = await import("@orpc/openapi/plugins");
|
|
232
|
+
const { ZodToJsonSchemaConverter } = await import("@orpc/zod");
|
|
233
|
+
const { onError } = await import("@orpc/server");
|
|
234
|
+
const { formatORPCError } = await import("../errors");
|
|
235
|
+
|
|
236
|
+
const runtimeConfig = readRuntimeConfigFromEnv();
|
|
237
|
+
const { siblings, dependsOn } = collectSiblingRemotes(runtimeConfig, compositionKey);
|
|
238
|
+
|
|
239
|
+
if (dependsOn.length > 0) {
|
|
240
|
+
console.log(`🔗 Loading sibling plugin(s): ${dependsOn.join(", ")}`);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const registry: Record<string, { remote: string }> = {
|
|
244
|
+
[pluginId]: {
|
|
245
|
+
remote: `http://localhost:${host.port}/${DEV_ENTRY_FILENAME}`,
|
|
246
|
+
},
|
|
247
|
+
...siblings,
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const mfRuntime = createPluginRuntime({ registry });
|
|
251
|
+
runtime = mfRuntime;
|
|
252
|
+
|
|
253
|
+
const pluginsMap: Record<string, unknown> = {};
|
|
254
|
+
const siblingEffectContexts: unknown[] = [];
|
|
255
|
+
for (const depId of Object.keys(siblings)) {
|
|
256
|
+
const dep = await loadPluginWithRetry(mfRuntime, depId, siblings[depId]!.remote);
|
|
257
|
+
pluginsMap[depId] = { client: dep.createClient, router: dep.router };
|
|
258
|
+
if (dep.initialized?.effectContext) {
|
|
259
|
+
siblingEffectContexts.push(dep.initialized.effectContext);
|
|
260
|
+
}
|
|
261
|
+
console.log(`✅ Loaded dependency plugin: ${depId}`);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const loaded: any = await loadPluginWithRetry(
|
|
265
|
+
mfRuntime,
|
|
266
|
+
pluginId,
|
|
267
|
+
registry[pluginId]!.remote,
|
|
268
|
+
(devConfig?.config ?? { variables: {}, secrets: {} }) as Record<string, unknown>,
|
|
269
|
+
Object.keys(pluginsMap).length > 0 ? pluginsMap : undefined,
|
|
270
|
+
);
|
|
271
|
+
|
|
272
|
+
const { Context } = await import("effect");
|
|
273
|
+
effectContextHolder.context = [loaded.initialized?.effectContext, ...siblingEffectContexts]
|
|
274
|
+
.filter(Boolean)
|
|
275
|
+
.reduce((acc: any, ctx: any) => Context.merge(acc, ctx), Context.empty());
|
|
276
|
+
|
|
277
|
+
handlers.rpc = new RPCHandler(loaded.router, {
|
|
278
|
+
errorStatusMap: PLUGIN_ERROR_STATUS_MAP,
|
|
279
|
+
interceptors: [
|
|
280
|
+
onError((error: any) => {
|
|
281
|
+
const formatted = formatORPCError(error);
|
|
282
|
+
if (formatted) console.error(formatted);
|
|
283
|
+
}),
|
|
284
|
+
],
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
const generator = new OpenAPIGenerator({ converters: [new ZodToJsonSchemaConverter()] });
|
|
288
|
+
|
|
289
|
+
handlers.api = new OpenAPIHandler(loaded.router, {
|
|
290
|
+
errorStatusMap: PLUGIN_ERROR_STATUS_MAP,
|
|
291
|
+
plugins: [
|
|
292
|
+
new OpenAPIReferenceHandlerPlugin({
|
|
293
|
+
spec: () => generator.generate(loaded.router, { version: "3.1.1" }),
|
|
294
|
+
}),
|
|
295
|
+
],
|
|
296
|
+
interceptors: [
|
|
297
|
+
onError((error: any) => {
|
|
298
|
+
const formatted = formatORPCError(error);
|
|
299
|
+
if (formatted) console.error(formatted);
|
|
300
|
+
}),
|
|
301
|
+
],
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
console.log(`✅ Plugin ready: ${pluginId}`);
|
|
305
|
+
} catch (error) {
|
|
306
|
+
console.error(`❌ Failed to load plugin ${pluginId}:`, error);
|
|
307
|
+
console.error(" Server stays up; fix the build and retry via rebuild.");
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
void load();
|
|
312
|
+
|
|
313
|
+
const close = async () => {
|
|
314
|
+
handlers.rpc = null;
|
|
315
|
+
handlers.api = null;
|
|
316
|
+
effectContextHolder.context = null;
|
|
317
|
+
for (const child of [watcher, uiWatcher]) {
|
|
318
|
+
if (child) {
|
|
319
|
+
await killChildEscalating(child);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
if (uiStaticServer) {
|
|
323
|
+
await new Promise<void>((resolve) => uiStaticServer.close(() => resolve()));
|
|
324
|
+
}
|
|
325
|
+
await host.close();
|
|
326
|
+
if (runtime) await runtime.shutdown().catch(() => {});
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
process.once("SIGINT", async () => {
|
|
330
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
331
|
+
await close();
|
|
332
|
+
clearTimeout(timeout);
|
|
333
|
+
process.exit(0);
|
|
334
|
+
});
|
|
335
|
+
process.once("SIGTERM", async () => {
|
|
336
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
337
|
+
await close();
|
|
338
|
+
clearTimeout(timeout);
|
|
339
|
+
process.exit(0);
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
watchParentDeath(async () => {
|
|
343
|
+
const timeout = setTimeout(() => process.exit(0), 3000);
|
|
344
|
+
await close();
|
|
345
|
+
clearTimeout(timeout);
|
|
346
|
+
process.exit(0);
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
return { port, close };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const invokedAsCli = import.meta.main || (process.argv[1] ?? "").includes("every-plugin-serve");
|
|
353
|
+
|
|
354
|
+
if (invokedAsCli) {
|
|
355
|
+
startPluginDevServer().catch((error) => {
|
|
356
|
+
console.error("❌ Plugin dev server fatal error:", error);
|
|
357
|
+
process.exit(1);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
interface KillableChild {
|
|
2
|
+
pid?: number | undefined;
|
|
3
|
+
kill: (signal?: NodeJS.Signals) => void;
|
|
4
|
+
exitCode: number | null;
|
|
5
|
+
killed: boolean;
|
|
6
|
+
addListener: (event: "exit", listener: () => void) => unknown;
|
|
7
|
+
removeListener: (event: "exit", listener: () => void) => unknown;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const waitForExit = (child: KillableChild, timeoutMs: number): Promise<boolean> =>
|
|
11
|
+
new Promise((resolve) => {
|
|
12
|
+
if (child.exitCode !== null) {
|
|
13
|
+
resolve(true);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const onExit = () => {
|
|
17
|
+
clearTimeout(timer);
|
|
18
|
+
resolve(true);
|
|
19
|
+
};
|
|
20
|
+
const timer = setTimeout(() => {
|
|
21
|
+
child.removeListener("exit", onExit);
|
|
22
|
+
resolve(false);
|
|
23
|
+
}, timeoutMs);
|
|
24
|
+
child.addListener("exit", onExit);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const killChildEscalating = async (
|
|
28
|
+
child: KillableChild,
|
|
29
|
+
terminateMs = 2000,
|
|
30
|
+
): Promise<void> => {
|
|
31
|
+
if (child.exitCode !== null || child.killed) return;
|
|
32
|
+
child.kill("SIGTERM");
|
|
33
|
+
const exited = await waitForExit(child, terminateMs);
|
|
34
|
+
if (!exited) child.kill("SIGKILL");
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export interface WatchParentDeathOptions {
|
|
38
|
+
intervalMs?: number;
|
|
39
|
+
getPpid?: () => number;
|
|
40
|
+
onParentDeath?: () => void | Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const watchParentDeath = (
|
|
44
|
+
onParentDeath: () => void | Promise<void>,
|
|
45
|
+
opts?: Omit<WatchParentDeathOptions, "onParentDeath">,
|
|
46
|
+
): { stop: () => void } => {
|
|
47
|
+
const getPpid = opts?.getPpid ?? (() => process.ppid);
|
|
48
|
+
const intervalMs = opts?.intervalMs ?? 200;
|
|
49
|
+
const initialPpid = getPpid();
|
|
50
|
+
const timer = setInterval(() => {
|
|
51
|
+
if (getPpid() !== initialPpid) {
|
|
52
|
+
clearInterval(timer);
|
|
53
|
+
void onParentDeath();
|
|
54
|
+
}
|
|
55
|
+
}, intervalMs);
|
|
56
|
+
timer.unref?.();
|
|
57
|
+
return { stop: () => clearInterval(timer) };
|
|
58
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Context, Effect, Layer, type Scope } from "effect";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Builds a layer with the current scope and returns the built context.
|
|
5
|
+
*
|
|
6
|
+
* Resources are released when the plugin's scope closes. Use inside
|
|
7
|
+
* `initialize` for multi-service layers; resolve individual services from
|
|
8
|
+
* the returned context with `Context.get`.
|
|
9
|
+
*/
|
|
10
|
+
export const buildScopedContext = <A, E, R>(
|
|
11
|
+
layer: Layer.Layer<A, E, R>,
|
|
12
|
+
): Effect.Effect<Context.Context<A>, E, Scope.Scope | R> =>
|
|
13
|
+
Effect.flatMap(Effect.scope, (scope) => Layer.buildWithScope(layer, scope));
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Builds a layer with the current scope and resolves one service from it.
|
|
17
|
+
*
|
|
18
|
+
* Equivalent to `buildScopedContext` + `Context.get` for single-service
|
|
19
|
+
* layers: `const db = yield* buildScoped(DatabaseTag, DatabaseLive(url))`.
|
|
20
|
+
*/
|
|
21
|
+
export const buildScoped = <Identifier, Shape, E, R>(
|
|
22
|
+
tag: Context.Service<Identifier, Shape>,
|
|
23
|
+
layer: Layer.Layer<Identifier, E, R>,
|
|
24
|
+
): Effect.Effect<Shape, E, Scope.Scope | R> =>
|
|
25
|
+
buildScopedContext(layer).pipe(Effect.map((context) => Context.get(context, tag)));
|
package/src/errors.ts
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Error pattern constants for categorizing infrastructure errors
|
|
5
|
-
*/
|
|
6
|
-
export const ERROR_PATTERNS = {
|
|
7
|
-
CONNECTION_REFUSED: ["ECONNREFUSED"],
|
|
8
|
-
HOST_NOT_FOUND: ["ENOTFOUND", "EHOSTUNREACH"],
|
|
9
|
-
TIMEOUT: ["ETIMEDOUT", "ESOCKETTIMEDOUT", "timeout"],
|
|
10
|
-
CONNECTION_RESET: ["ECONNRESET", "EPIPE"],
|
|
11
|
-
PERMISSION: ["EACCES", "EPERM", "permission denied"],
|
|
12
|
-
AUTH: ["401", "unauthorized", "authentication failed"],
|
|
13
|
-
RATE_LIMITED: ["429", "too many requests", "rate limit"],
|
|
14
|
-
SERVICE_UNAVAILABLE: ["503", "service unavailable"],
|
|
15
|
-
} as const;
|
|
1
|
+
import { COMMON_ERROR_STATUS_MAP } from "@orpc/server";
|
|
2
|
+
import { z } from "zod";
|
|
16
3
|
|
|
17
4
|
/**
|
|
18
5
|
* Common error schemas for plugin contracts.
|
|
@@ -124,14 +111,26 @@ export const PluginErrors = {
|
|
|
124
111
|
} as const;
|
|
125
112
|
|
|
126
113
|
/**
|
|
127
|
-
*
|
|
114
|
+
* Error-code -> HTTP-status map for handlers.
|
|
115
|
+
*
|
|
116
|
+
* oRPC v2 resolves statuses at the handler boundary via `errorStatusMap`
|
|
117
|
+
* (default `COMMON_ERROR_STATUS_MAP`, where TIMEOUT is 408). Providing a
|
|
118
|
+
* map REPLACES the default entirely, so the standard codes must be spread
|
|
119
|
+
* back in. These custom entries preserve the v1 wire behavior:
|
|
120
|
+
* TIMEOUT -> 504, CONNECTION_ERROR -> 502.
|
|
128
121
|
*/
|
|
129
|
-
export const
|
|
122
|
+
export const PLUGIN_ERROR_STATUS_MAP: Record<string, number> = {
|
|
123
|
+
...COMMON_ERROR_STATUS_MAP,
|
|
124
|
+
TIMEOUT: 504,
|
|
125
|
+
CONNECTION_ERROR: 502,
|
|
126
|
+
} as const;
|
|
130
127
|
|
|
128
|
+
export type { PluginLoadFailureInfo, PluginWarningInfo } from "./runtime/errors";
|
|
131
129
|
export {
|
|
130
|
+
classifyPluginFailure,
|
|
131
|
+
defaultMissingSecretWarnings,
|
|
132
132
|
extractFromFiberFailure,
|
|
133
133
|
formatORPCError,
|
|
134
|
-
isRetryableORPCCode,
|
|
135
134
|
ModuleFederationError,
|
|
136
135
|
PluginRuntimeError,
|
|
137
136
|
toPluginRuntimeError,
|
package/src/identity.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin identity: every name a plugin workspace carries, derived from one
|
|
3
|
+
* input. Two seams live here:
|
|
4
|
+
*
|
|
5
|
+
* - `remoteName`/`containerName` absorb the framework's two normalizers (the
|
|
6
|
+
* Module Federation remote name and the UI container name) — runtime,
|
|
7
|
+
* build, and host consumers delegate to these instead of keeping private
|
|
8
|
+
* copies, so a name can never disagree across contexts.
|
|
9
|
+
* - `identity` derives the full name set from the config layout key (the
|
|
10
|
+
* `plugins/<key>` attachment in `bos.config.json`): the key itself (the
|
|
11
|
+
* composition key), the npm package name under the scaffold convention,
|
|
12
|
+
* and the two normalized build names.
|
|
13
|
+
*
|
|
14
|
+
* Normalization rules:
|
|
15
|
+
* - remote: lowercase, strip a single leading '@', replace '/' with '_',
|
|
16
|
+
* preserve hyphens and other characters
|
|
17
|
+
* ("@scope/my-plugin" → "scope_my-plugin")
|
|
18
|
+
* - container: replace every character outside [A-Za-z0-9_] with '_'
|
|
19
|
+
* ("@everything-dev/auth-plugin" → "_everything_dev_auth_plugin")
|
|
20
|
+
*/
|
|
21
|
+
export interface PluginIdentity {
|
|
22
|
+
key: string;
|
|
23
|
+
npm: string;
|
|
24
|
+
remote: string;
|
|
25
|
+
container: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const remoteName = (name: string): string =>
|
|
29
|
+
name.toLowerCase().replace(/^@/, "").replace(/\//g, "_");
|
|
30
|
+
|
|
31
|
+
export const containerName = (pkgName: string): string => pkgName.replace(/[^A-Za-z0-9_]/g, "_");
|
|
32
|
+
|
|
33
|
+
export const identity = (key: string): PluginIdentity => {
|
|
34
|
+
const npm = `@everything-dev/${key}-plugin`;
|
|
35
|
+
return { key, npm, remote: remoteName(npm), container: containerName(npm) };
|
|
36
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import "@orpc/openapi/extensions/route";
|
|
2
|
+
|
|
3
|
+
export * from "./client";
|
|
4
|
+
export * from "./effect-helpers";
|
|
1
5
|
export * from "./errors";
|
|
2
6
|
export * from "./plugin";
|
|
3
7
|
export * from "./runtime";
|
|
@@ -10,16 +14,25 @@ export type {
|
|
|
10
14
|
EveryPlugin,
|
|
11
15
|
InitializedPlugin,
|
|
12
16
|
LoadedPlugin,
|
|
17
|
+
ModuleClientEntry,
|
|
18
|
+
ModuleEndpoint,
|
|
19
|
+
ModuleSurface,
|
|
20
|
+
ModuleTransport,
|
|
21
|
+
PluginClientEntry,
|
|
13
22
|
PluginClientType,
|
|
14
23
|
PluginConfigInput,
|
|
15
24
|
PluginContext,
|
|
16
25
|
PluginContract,
|
|
26
|
+
PluginEndpoint,
|
|
17
27
|
PluginInstance,
|
|
18
28
|
PluginMetadata,
|
|
19
29
|
PluginRegistry,
|
|
20
30
|
PluginRouterType,
|
|
21
31
|
PluginRuntimeConfig,
|
|
22
32
|
PluginSecrets,
|
|
33
|
+
PluginServicesEntry,
|
|
34
|
+
PluginSurface,
|
|
35
|
+
PluginTransport,
|
|
23
36
|
PluginVariables,
|
|
24
37
|
RegisteredPlugins,
|
|
25
38
|
SecretsConfig,
|