every-plugin 2.10.1 → 3.0.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/every-plugin-serve.mjs +12 -0
- package/bin/every-plugin.mjs +59 -0
- package/dist/_virtual/_rolldown/runtime.cjs +1 -2
- package/dist/build/artifact-names.cjs +119 -0
- package/dist/build/artifact-names.cjs.map +1 -0
- package/dist/build/artifact-names.d.cts +68 -0
- package/dist/build/artifact-names.d.cts.map +1 -0
- package/dist/build/artifact-names.d.mts +68 -0
- package/dist/build/artifact-names.d.mts.map +1 -0
- package/dist/build/artifact-names.mjs +102 -0
- package/dist/build/artifact-names.mjs.map +1 -0
- package/dist/build/contract-types.cjs +89 -0
- package/dist/build/contract-types.cjs.map +1 -0
- package/dist/build/contract-types.mjs +81 -0
- package/dist/build/contract-types.mjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.cjs +37 -0
- package/dist/build/rspack/build-report-plugin.cjs.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.cts +18 -0
- package/dist/build/rspack/build-report-plugin.d.cts.map +1 -0
- package/dist/build/rspack/build-report-plugin.d.mts +18 -0
- package/dist/build/rspack/build-report-plugin.d.mts.map +1 -0
- package/dist/build/rspack/build-report-plugin.mjs +37 -0
- package/dist/build/rspack/build-report-plugin.mjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs +47 -0
- package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs +47 -0
- package/dist/build/rspack/chunk-completeness-plugin.mjs.map +1 -0
- package/dist/build/rspack/compose.cjs +69 -0
- package/dist/build/rspack/compose.cjs.map +1 -0
- package/dist/build/rspack/compose.d.cts +20 -0
- package/dist/build/rspack/compose.d.cts.map +1 -0
- package/dist/build/rspack/compose.d.mts +20 -0
- package/dist/build/rspack/compose.d.mts.map +1 -0
- package/dist/build/rspack/compose.mjs +65 -0
- package/dist/build/rspack/compose.mjs.map +1 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +11 -11
- package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +2 -0
- package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +11 -10
- package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
- package/dist/build/rspack/generated-config.cjs +35 -0
- package/dist/build/rspack/generated-config.cjs.map +1 -0
- package/dist/build/rspack/generated-config.mjs +32 -0
- package/dist/build/rspack/generated-config.mjs.map +1 -0
- package/dist/build/rspack/index.cjs +8 -5
- package/dist/build/rspack/index.d.cts +5 -3
- package/dist/build/rspack/index.d.mts +5 -3
- package/dist/build/rspack/index.mjs +5 -3
- package/dist/build/rspack/module-federation.cjs +2 -2
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +1 -1
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +44 -69
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.d.cts +4 -13
- package/dist/build/rspack/plugin.d.cts.map +1 -1
- package/dist/build/rspack/plugin.d.mts +4 -13
- package/dist/build/rspack/plugin.d.mts.map +1 -1
- package/dist/build/rspack/plugin.mjs +44 -69
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/build/rspack/utils.cjs +7 -5
- package/dist/build/rspack/utils.cjs.map +1 -1
- package/dist/build/rspack/utils.mjs +7 -6
- package/dist/build/rspack/utils.mjs.map +1 -1
- package/dist/build/ui/factory.cjs +88 -0
- package/dist/build/ui/factory.cjs.map +1 -0
- package/dist/build/ui/factory.d.cts +11 -0
- package/dist/build/ui/factory.d.cts.map +1 -0
- package/dist/build/ui/factory.d.mts +11 -0
- package/dist/build/ui/factory.d.mts.map +1 -0
- package/dist/build/ui/factory.mjs +80 -0
- package/dist/build/ui/factory.mjs.map +1 -0
- package/dist/build/ui/generated-config.cjs +118 -0
- package/dist/build/ui/generated-config.cjs.map +1 -0
- package/dist/build/ui/generated-config.d.cts +33 -0
- package/dist/build/ui/generated-config.d.cts.map +1 -0
- package/dist/build/ui/generated-config.d.mts +33 -0
- package/dist/build/ui/generated-config.d.mts.map +1 -0
- package/dist/build/ui/generated-config.mjs +111 -0
- package/dist/build/ui/generated-config.mjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs +61 -0
- package/dist/build/ui/hash-artifacts-plugin.cjs.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.cts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts +20 -0
- package/dist/build/ui/hash-artifacts-plugin.d.mts.map +1 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs +58 -0
- package/dist/build/ui/hash-artifacts-plugin.mjs.map +1 -0
- package/dist/build/ui/index.cjs +90 -0
- package/dist/build/ui/index.cjs.map +1 -0
- package/dist/build/ui/index.d.cts +29 -0
- package/dist/build/ui/index.d.cts.map +1 -0
- package/dist/build/ui/index.d.mts +29 -0
- package/dist/build/ui/index.d.mts.map +1 -0
- package/dist/build/ui/index.mjs +68 -0
- package/dist/build/ui/index.mjs.map +1 -0
- package/dist/build/ui/manifest-plugin.cjs +37 -0
- package/dist/build/ui/manifest-plugin.cjs.map +1 -0
- package/dist/build/ui/manifest-plugin.d.cts +19 -0
- package/dist/build/ui/manifest-plugin.d.cts.map +1 -0
- package/dist/build/ui/manifest-plugin.d.mts +19 -0
- package/dist/build/ui/manifest-plugin.d.mts.map +1 -0
- package/dist/build/ui/manifest-plugin.mjs +37 -0
- package/dist/build/ui/manifest-plugin.mjs.map +1 -0
- package/dist/build/ui/rsbuild-config.cjs +203 -0
- package/dist/build/ui/rsbuild-config.cjs.map +1 -0
- package/dist/build/ui/rsbuild-config.d.cts +45 -0
- package/dist/build/ui/rsbuild-config.d.cts.map +1 -0
- package/dist/build/ui/rsbuild-config.d.mts +45 -0
- package/dist/build/ui/rsbuild-config.d.mts.map +1 -0
- package/dist/build/ui/rsbuild-config.mjs +200 -0
- package/dist/build/ui/rsbuild-config.mjs.map +1 -0
- package/dist/build/ui/stubs.cjs +107 -0
- package/dist/build/ui/stubs.cjs.map +1 -0
- package/dist/build/ui/stubs.d.cts +25 -0
- package/dist/build/ui/stubs.d.cts.map +1 -0
- package/dist/build/ui/stubs.d.mts +25 -0
- package/dist/build/ui/stubs.d.mts.map +1 -0
- package/dist/build/ui/stubs.mjs +106 -0
- package/dist/build/ui/stubs.mjs.map +1 -0
- package/dist/cli.cjs +83 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +6 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +6 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +82 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/dev/serve.cjs +390 -0
- package/dist/dev/serve.cjs.map +1 -0
- package/dist/dev/serve.d.cts +23 -0
- package/dist/dev/serve.d.cts.map +1 -0
- package/dist/dev/serve.d.mts +23 -0
- package/dist/dev/serve.d.mts.map +1 -0
- package/dist/dev/serve.mjs +384 -0
- package/dist/dev/serve.mjs.map +1 -0
- package/dist/dev/watch-kill.cjs +39 -0
- package/dist/dev/watch-kill.cjs.map +1 -0
- package/dist/dev/watch-kill.mjs +38 -0
- package/dist/dev/watch-kill.mjs.map +1 -0
- package/dist/effect-helpers.cjs +23 -0
- package/dist/effect-helpers.cjs.map +1 -0
- package/dist/effect-helpers.d.cts +20 -0
- package/dist/effect-helpers.d.cts.map +1 -0
- package/dist/effect-helpers.d.mts +20 -0
- package/dist/effect-helpers.d.mts.map +1 -0
- package/dist/effect-helpers.mjs +22 -0
- package/dist/effect-helpers.mjs.map +1 -0
- package/dist/errors.cjs +49 -69
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +13 -96
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +13 -96
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +16 -34
- package/dist/errors.mjs.map +1 -1
- package/dist/identity.cjs +19 -0
- package/dist/identity.cjs.map +1 -0
- package/dist/identity.d.cts +33 -0
- package/dist/identity.d.cts.map +1 -0
- package/dist/identity.d.mts +33 -0
- package/dist/identity.d.mts.map +1 -0
- package/dist/identity.mjs +16 -0
- package/dist/identity.mjs.map +1 -0
- package/dist/index.cjs +8 -5
- package/dist/index.d.cts +8 -6
- package/dist/index.d.mts +8 -6
- package/dist/index.mjs +6 -4
- package/dist/plugin.cjs +12 -26
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +44 -25
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +45 -26
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +15 -29
- package/dist/plugin.mjs.map +1 -1
- package/dist/remote-entry.cjs +103 -0
- package/dist/remote-entry.cjs.map +1 -0
- package/dist/remote-entry.d.cts +53 -0
- package/dist/remote-entry.d.cts.map +1 -0
- package/dist/remote-entry.d.mts +53 -0
- package/dist/remote-entry.d.mts.map +1 -0
- package/dist/remote-entry.mjs +98 -0
- package/dist/remote-entry.mjs.map +1 -0
- package/dist/runtime/errors.cjs +140 -34
- package/dist/runtime/errors.cjs.map +1 -1
- package/dist/runtime/errors.d.cts +42 -7
- package/dist/runtime/errors.d.cts.map +1 -1
- package/dist/runtime/errors.d.mts +42 -7
- package/dist/runtime/errors.d.mts.map +1 -1
- package/dist/runtime/errors.mjs +136 -31
- package/dist/runtime/errors.mjs.map +1 -1
- package/dist/runtime/index.cjs +95 -23
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +16 -0
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +16 -0
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +98 -26
- package/dist/runtime/index.mjs.map +1 -1
- package/dist/runtime/mf-config.cjs +3 -78
- package/dist/runtime/mf-config.cjs.map +1 -1
- package/dist/runtime/mf-config.d.cts +3 -49
- package/dist/runtime/mf-config.d.cts.map +1 -1
- package/dist/runtime/mf-config.d.mts +3 -49
- package/dist/runtime/mf-config.d.mts.map +1 -1
- package/dist/runtime/mf-config.mjs +5 -78
- package/dist/runtime/mf-config.mjs.map +1 -1
- package/dist/runtime/services/module-federation.service.cjs +63 -12
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +4 -13
- package/dist/runtime/services/module-federation.service.d.mts +4 -13
- package/dist/runtime/services/module-federation.service.mjs +63 -14
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/normalize.cjs +2 -22
- package/dist/runtime/services/normalize.d.cts +2 -21
- package/dist/runtime/services/normalize.d.mts +2 -21
- package/dist/runtime/services/normalize.mjs +2 -21
- package/dist/runtime/services/plugin-lifecycle.service.cjs +9 -11
- package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-lifecycle.service.d.cts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.d.mts +3 -16
- package/dist/runtime/services/plugin-lifecycle.service.mjs +10 -13
- package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.cjs +30 -29
- package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +6 -53
- package/dist/runtime/services/plugin-loader.service.d.mts +6 -53
- package/dist/runtime/services/plugin-loader.service.mjs +29 -30
- package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
- package/dist/runtime/services/plugin.service.cjs +10 -12
- package/dist/runtime/services/plugin.service.cjs.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +14 -36
- package/dist/runtime/services/plugin.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin.service.d.mts +14 -36
- package/dist/runtime/services/plugin.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.mjs +14 -18
- package/dist/runtime/services/plugin.service.mjs.map +1 -1
- package/dist/runtime/services/secrets.service.cjs +12 -12
- package/dist/runtime/services/secrets.service.cjs.map +1 -1
- package/dist/runtime/services/secrets.service.d.cts +3 -15
- package/dist/runtime/services/secrets.service.d.mts +3 -15
- package/dist/runtime/services/secrets.service.mjs +12 -13
- package/dist/runtime/services/secrets.service.mjs.map +1 -1
- package/dist/runtime/services/shared-identity.cjs +40 -0
- package/dist/runtime/services/shared-identity.cjs.map +1 -0
- package/dist/runtime/services/shared-identity.mjs +38 -0
- package/dist/runtime/services/shared-identity.mjs.map +1 -0
- package/dist/runtime/validation.cjs +2 -2
- package/dist/runtime/validation.cjs.map +1 -1
- package/dist/runtime/validation.mjs +2 -2
- package/dist/runtime/validation.mjs.map +1 -1
- package/dist/shared-deps-spec.cjs +384 -0
- package/dist/shared-deps-spec.cjs.map +1 -0
- package/dist/shared-deps-spec.d.cts +182 -0
- package/dist/shared-deps-spec.d.cts.map +1 -0
- package/dist/shared-deps-spec.d.mts +182 -0
- package/dist/shared-deps-spec.d.mts.map +1 -0
- package/dist/shared-deps-spec.mjs +368 -0
- package/dist/shared-deps-spec.mjs.map +1 -0
- package/dist/types.d.cts +22 -41
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +22 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/ui/manifest/construct.cjs +268 -0
- package/dist/ui/manifest/construct.cjs.map +1 -0
- package/dist/ui/manifest/construct.d.cts +48 -0
- package/dist/ui/manifest/construct.d.cts.map +1 -0
- package/dist/ui/manifest/construct.d.mts +48 -0
- package/dist/ui/manifest/construct.d.mts.map +1 -0
- package/dist/ui/manifest/construct.mjs +268 -0
- package/dist/ui/manifest/construct.mjs.map +1 -0
- package/dist/ui/manifest/contract.cjs +34 -0
- package/dist/ui/manifest/contract.cjs.map +1 -0
- package/dist/ui/manifest/contract.d.cts +26 -0
- package/dist/ui/manifest/contract.d.cts.map +1 -0
- package/dist/ui/manifest/contract.d.mts +26 -0
- package/dist/ui/manifest/contract.d.mts.map +1 -0
- package/dist/ui/manifest/contract.mjs +26 -0
- package/dist/ui/manifest/contract.mjs.map +1 -0
- package/dist/ui/manifest/descriptor.cjs +64 -0
- package/dist/ui/manifest/descriptor.cjs.map +1 -0
- package/dist/ui/manifest/descriptor.d.cts +60 -0
- package/dist/ui/manifest/descriptor.d.cts.map +1 -0
- package/dist/ui/manifest/descriptor.d.mts +60 -0
- package/dist/ui/manifest/descriptor.d.mts.map +1 -0
- package/dist/ui/manifest/descriptor.mjs +61 -0
- package/dist/ui/manifest/descriptor.mjs.map +1 -0
- package/dist/ui/manifest/generator.cjs +128 -0
- package/dist/ui/manifest/generator.cjs.map +1 -0
- package/dist/ui/manifest/generator.d.cts +41 -0
- package/dist/ui/manifest/generator.d.cts.map +1 -0
- package/dist/ui/manifest/generator.d.mts +41 -0
- package/dist/ui/manifest/generator.d.mts.map +1 -0
- package/dist/ui/manifest/generator.mjs +125 -0
- package/dist/ui/manifest/generator.mjs.map +1 -0
- package/dist/ui/manifest/index.cjs +35 -0
- package/dist/ui/manifest/index.d.cts +9 -0
- package/dist/ui/manifest/index.d.mts +9 -0
- package/dist/ui/manifest/index.mjs +9 -0
- package/dist/ui/manifest/manifest-schema.cjs +97 -0
- package/dist/ui/manifest/manifest-schema.cjs.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.cts +132 -0
- package/dist/ui/manifest/manifest-schema.d.cts.map +1 -0
- package/dist/ui/manifest/manifest-schema.d.mts +132 -0
- package/dist/ui/manifest/manifest-schema.d.mts.map +1 -0
- package/dist/ui/manifest/manifest-schema.mjs +90 -0
- package/dist/ui/manifest/manifest-schema.mjs.map +1 -0
- package/dist/ui/manifest/mount-registry.cjs +52 -0
- package/dist/ui/manifest/mount-registry.cjs.map +1 -0
- package/dist/ui/manifest/mount-registry.d.cts +61 -0
- package/dist/ui/manifest/mount-registry.d.cts.map +1 -0
- package/dist/ui/manifest/mount-registry.d.mts +61 -0
- package/dist/ui/manifest/mount-registry.d.mts.map +1 -0
- package/dist/ui/manifest/mount-registry.mjs +48 -0
- package/dist/ui/manifest/mount-registry.mjs.map +1 -0
- package/dist/ui/manifest/nav.cjs +13 -0
- package/dist/ui/manifest/nav.cjs.map +1 -0
- package/dist/ui/manifest/nav.d.cts +34 -0
- package/dist/ui/manifest/nav.d.cts.map +1 -0
- package/dist/ui/manifest/nav.d.mts +34 -0
- package/dist/ui/manifest/nav.d.mts.map +1 -0
- package/dist/ui/manifest/nav.mjs +13 -0
- package/dist/ui/manifest/nav.mjs.map +1 -0
- package/dist/ui/manifest/route-config.cjs +33 -0
- package/dist/ui/manifest/route-config.cjs.map +1 -0
- package/dist/ui/manifest/route-config.d.cts +40 -0
- package/dist/ui/manifest/route-config.d.cts.map +1 -0
- package/dist/ui/manifest/route-config.d.mts +40 -0
- package/dist/ui/manifest/route-config.d.mts.map +1 -0
- package/dist/ui/manifest/route-config.mjs +33 -0
- package/dist/ui/manifest/route-config.mjs.map +1 -0
- package/dist/version-manifest.cjs +65 -0
- package/dist/version-manifest.cjs.map +1 -0
- package/dist/version-manifest.d.cts +52 -0
- package/dist/version-manifest.d.cts.map +1 -0
- package/dist/version-manifest.d.mts +52 -0
- package/dist/version-manifest.d.mts.map +1 -0
- package/dist/version-manifest.mjs +63 -0
- package/dist/version-manifest.mjs.map +1 -0
- package/package.json +165 -68
- package/skills/plugin-client/SKILL.md +24 -5
- package/skills/plugin-development/SKILL.md +79 -47
- package/skills/plugin-testing/SKILL.md +41 -12
- package/src/build/artifact-names.ts +117 -0
- package/src/build/contract-types.ts +101 -0
- package/src/build/rspack/build-report-plugin.ts +34 -0
- package/src/build/rspack/chunk-completeness-plugin.ts +57 -0
- package/src/build/rspack/compose.ts +87 -0
- package/src/build/rspack/fix-mf-data-uri-plugin.ts +23 -12
- package/src/build/rspack/generated-config.ts +35 -0
- package/src/build/rspack/index.ts +10 -5
- package/src/build/rspack/module-federation.ts +1 -1
- package/src/build/rspack/plugin.ts +103 -105
- package/src/build/rspack/utils.ts +8 -2
- package/src/build/ui/factory.ts +96 -0
- package/src/build/ui/generated-config.ts +133 -0
- package/src/build/ui/hash-artifacts-plugin.ts +79 -0
- package/src/build/ui/index.ts +98 -0
- package/src/build/ui/manifest-plugin.ts +54 -0
- package/src/build/ui/rsbuild-config.ts +256 -0
- package/src/build/ui/stubs.ts +103 -0
- package/src/cli.ts +100 -0
- package/src/dev/serve.ts +477 -0
- package/src/dev/watch-kill.ts +58 -0
- package/src/effect-helpers.ts +25 -0
- package/src/errors.ts +16 -18
- package/src/identity.ts +36 -0
- package/src/index.ts +4 -0
- package/src/plugin.ts +70 -92
- package/src/remote-entry.ts +171 -0
- package/src/runtime/errors.ts +186 -27
- package/src/runtime/index.ts +132 -43
- package/src/runtime/mf-config.ts +12 -107
- package/src/runtime/services/module-federation.service.ts +221 -117
- package/src/runtime/services/normalize.ts +1 -18
- package/src/runtime/services/plugin-lifecycle.service.ts +66 -75
- package/src/runtime/services/plugin-loader.service.ts +239 -212
- package/src/runtime/services/plugin.service.ts +61 -43
- package/src/runtime/services/secrets.service.ts +20 -15
- package/src/runtime/services/shared-identity.ts +68 -0
- package/src/runtime/validation.ts +5 -7
- package/src/shared-deps-spec.ts +478 -0
- package/src/types.ts +22 -48
- package/src/ui/manifest/construct.ts +403 -0
- package/src/ui/manifest/contract.ts +33 -0
- package/src/ui/manifest/descriptor.ts +96 -0
- package/src/ui/manifest/generator.ts +238 -0
- package/src/ui/manifest/index.ts +55 -0
- package/src/ui/manifest/manifest-schema.ts +107 -0
- package/src/ui/manifest/mount-registry.ts +50 -0
- package/src/ui/manifest/nav.ts +43 -0
- package/src/ui/manifest/route-config.ts +82 -0
- package/src/version-manifest.ts +88 -0
- package/dist/build/rspack/dev-server-middleware.cjs +0 -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/runtime/errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ORPCError } from "@orpc/
|
|
1
|
+
import { ORPCError } from "@orpc/server";
|
|
2
2
|
import { Cause, Data } from "effect";
|
|
3
3
|
import type { z } from "zod";
|
|
4
4
|
|
|
@@ -7,8 +7,11 @@ export class PluginRuntimeError extends Data.TaggedError("PluginRuntimeError")<{
|
|
|
7
7
|
readonly operation?: string;
|
|
8
8
|
readonly procedureName?: string;
|
|
9
9
|
readonly cause?: Error;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
}> {
|
|
11
|
+
override get message() {
|
|
12
|
+
return this.cause?.message ?? "Plugin operation failed";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
12
15
|
|
|
13
16
|
export class ModuleFederationError extends Data.TaggedError("ModuleFederationError")<{
|
|
14
17
|
readonly pluginId: string;
|
|
@@ -22,6 +25,22 @@ export class ValidationError extends Data.TaggedError("ValidationError")<{
|
|
|
22
25
|
readonly zodError: z.ZodError;
|
|
23
26
|
}> {}
|
|
24
27
|
|
|
28
|
+
const stringifyUnknown = (value: unknown): string => {
|
|
29
|
+
if (value === null) return "null";
|
|
30
|
+
if (value === undefined) return "undefined";
|
|
31
|
+
if (value instanceof Error) return value.message;
|
|
32
|
+
if (typeof value === "string") return value;
|
|
33
|
+
if (typeof value === "number" || typeof value === "bigint" || typeof value === "boolean") {
|
|
34
|
+
return `${value}`;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value === "symbol") return value.description ?? "";
|
|
37
|
+
try {
|
|
38
|
+
return JSON.stringify(value) ?? "[Unserializable value]";
|
|
39
|
+
} catch {
|
|
40
|
+
return "[Unserializable value]";
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
25
44
|
const extractErrorMessage = (error: unknown): string => {
|
|
26
45
|
if (!error) return "Unknown error";
|
|
27
46
|
|
|
@@ -40,7 +59,26 @@ const extractErrorMessage = (error: unknown): string => {
|
|
|
40
59
|
return String((error as any).message);
|
|
41
60
|
}
|
|
42
61
|
|
|
43
|
-
return
|
|
62
|
+
return stringifyUnknown(error);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The deepest Error along the cause chain — the original throw site. Wrapper
|
|
67
|
+
* errors (PluginRuntimeError, ModuleFederationError) carry their own stacks
|
|
68
|
+
* (the wrapping frames); diagnosis needs the cause's stack (the actual
|
|
69
|
+
* failing module inside the evaluated remote entry).
|
|
70
|
+
*/
|
|
71
|
+
export const deepestErrorStack = (error: unknown): string | undefined => {
|
|
72
|
+
let current = error;
|
|
73
|
+
let deepest: string | undefined;
|
|
74
|
+
let hops = 0;
|
|
75
|
+
while (current instanceof Error && hops < 8) {
|
|
76
|
+
if (current.stack) deepest = current.stack;
|
|
77
|
+
current = (current as { cause?: unknown }).cause as unknown;
|
|
78
|
+
hops += 1;
|
|
79
|
+
}
|
|
80
|
+
if (current instanceof Error && current.stack) deepest = current.stack;
|
|
81
|
+
return deepest;
|
|
44
82
|
};
|
|
45
83
|
|
|
46
84
|
const formatValidationIssue = (issue: any, index: number, maxDisplay: number): string => {
|
|
@@ -73,7 +111,7 @@ const formatDataPreview = (data: unknown, maxLength = 100): string => {
|
|
|
73
111
|
|
|
74
112
|
return `${str.slice(0, maxLength)}...`;
|
|
75
113
|
} catch {
|
|
76
|
-
return
|
|
114
|
+
return stringifyUnknown(data).slice(0, maxLength);
|
|
77
115
|
}
|
|
78
116
|
};
|
|
79
117
|
|
|
@@ -116,9 +154,31 @@ const formatORPCValidationError = (error: any): string[] | null => {
|
|
|
116
154
|
return lines;
|
|
117
155
|
};
|
|
118
156
|
|
|
157
|
+
const formatUnknownError = (error: any): string | null => {
|
|
158
|
+
if (!error) return null;
|
|
159
|
+
const message = extractErrorMessage(error);
|
|
160
|
+
const lines: string[] = [];
|
|
161
|
+
lines.push(`\n╭─ Unhandled error ${"─".repeat(37)}`);
|
|
162
|
+
for (const line of message.split("\n")) {
|
|
163
|
+
lines.push(`│ ${line}`);
|
|
164
|
+
}
|
|
165
|
+
const stack = error instanceof Error ? error.stack?.split("\n").slice(1, 6) : undefined;
|
|
166
|
+
if (stack && stack.length > 0) {
|
|
167
|
+
lines.push(`│`);
|
|
168
|
+
for (const line of stack) {
|
|
169
|
+
lines.push(`│ ${line.trim()}`);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
lines.push(`╰${"─".repeat(50)}\n`);
|
|
173
|
+
return lines.join("\n");
|
|
174
|
+
};
|
|
175
|
+
|
|
119
176
|
export const formatORPCError = (error: any): string | null => {
|
|
120
177
|
if (!(error instanceof ORPCError)) {
|
|
121
|
-
return null
|
|
178
|
+
// Unknown errors used to return null, leaving internal failures (e.g. a
|
|
179
|
+
// storage backend throw) invisible in host logs while oRPC serialized
|
|
180
|
+
// them client-side as a bare INTERNAL_SERVER_ERROR.
|
|
181
|
+
return formatUnknownError(error);
|
|
122
182
|
}
|
|
123
183
|
|
|
124
184
|
const validationLines = formatORPCValidationError(error);
|
|
@@ -128,7 +188,6 @@ export const formatORPCError = (error: any): string | null => {
|
|
|
128
188
|
|
|
129
189
|
const lines: string[] = [];
|
|
130
190
|
const code = error.code || "UNKNOWN";
|
|
131
|
-
const status = error.status || 500;
|
|
132
191
|
const message = error.message || "An error occurred";
|
|
133
192
|
|
|
134
193
|
lines.push(`\n╭─ oRPC Error ${"─".repeat(40)}`);
|
|
@@ -136,7 +195,7 @@ export const formatORPCError = (error: any): string | null => {
|
|
|
136
195
|
for (const line of messageLines) {
|
|
137
196
|
lines.push(`│ ${line}`);
|
|
138
197
|
}
|
|
139
|
-
lines.push(`│ Code: ${code}
|
|
198
|
+
lines.push(`│ Code: ${code}`);
|
|
140
199
|
lines.push(`│`);
|
|
141
200
|
|
|
142
201
|
if (error.data) {
|
|
@@ -187,23 +246,126 @@ export const formatORPCError = (error: any): string | null => {
|
|
|
187
246
|
return lines.join("\n");
|
|
188
247
|
};
|
|
189
248
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
249
|
+
export type PluginFailureKind =
|
|
250
|
+
| "mf"
|
|
251
|
+
| "integrity"
|
|
252
|
+
| "config"
|
|
253
|
+
| "validation"
|
|
254
|
+
| "network"
|
|
255
|
+
| "unknown";
|
|
256
|
+
|
|
257
|
+
export interface PluginFailureClassification {
|
|
258
|
+
kind: PluginFailureKind;
|
|
259
|
+
retryable: boolean;
|
|
260
|
+
message: string;
|
|
261
|
+
suggestion?: string;
|
|
262
|
+
}
|
|
194
263
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
264
|
+
/**
|
|
265
|
+
* Structured report of one plugin-load failure, built by a loader (the host's
|
|
266
|
+
* plugin boot, the dev server) from a `PluginFailureClassification` plus
|
|
267
|
+
* loader context. This is the shape health endpoints and dashboards consume —
|
|
268
|
+
* keep it serializable.
|
|
269
|
+
*/
|
|
270
|
+
export interface PluginLoadFailureInfo {
|
|
271
|
+
/** loader-side key (host entry key, dev plugin id) */
|
|
272
|
+
pluginKey: string;
|
|
273
|
+
pluginUrl?: string;
|
|
274
|
+
/** failing runtime stage when the cause is stage-attributed */
|
|
275
|
+
operation?: string;
|
|
276
|
+
kind: string;
|
|
277
|
+
retryable: boolean;
|
|
278
|
+
message: string;
|
|
279
|
+
suggestion?: string;
|
|
280
|
+
/** loader context: which env secret the plugin's DB binding expects */
|
|
281
|
+
dbSecret?: string;
|
|
282
|
+
dbUrlMasked?: string;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const NETWORK_RETRYABLE_PATTERNS = ["ETIMEDOUT", "ECONNRESET", "timeout", "503", "429"] as const;
|
|
286
|
+
const NETWORK_DEAD_PATTERNS = ["ECONNREFUSED", "ENOTFOUND", "EHOSTUNREACH"] as const;
|
|
287
|
+
const RETRYABLE_ORPC_CODES = new Set([
|
|
288
|
+
"TOO_MANY_REQUESTS",
|
|
289
|
+
"SERVICE_UNAVAILABLE",
|
|
290
|
+
"BAD_GATEWAY",
|
|
291
|
+
"GATEWAY_TIMEOUT",
|
|
292
|
+
"TIMEOUT",
|
|
293
|
+
]);
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* One classification for plugin lifecycle failures across MF / validation /
|
|
297
|
+
* network sources. This is the recovery policy — nothing in the runtime
|
|
298
|
+
* retries on it today by design (the host degrades and runs without a failed
|
|
299
|
+
* plugin); consumers (host bootstrap messages, the dev server retry loop)
|
|
300
|
+
* read kind / retryable / suggestion to decide what to tell the author.
|
|
301
|
+
*/
|
|
302
|
+
export const classifyPluginFailure = (error: unknown): PluginFailureClassification => {
|
|
303
|
+
let current: unknown = extractFromFiberFailure(error);
|
|
304
|
+
let hops = 0;
|
|
305
|
+
while (current && typeof current === "object" && hops < 8) {
|
|
306
|
+
if (current instanceof ModuleFederationError) {
|
|
307
|
+
return {
|
|
308
|
+
kind: "mf",
|
|
309
|
+
retryable: false,
|
|
310
|
+
message: extractErrorMessage(current),
|
|
311
|
+
suggestion:
|
|
312
|
+
"Run bos mf check — the deployed plugin bundle is likely stale (sharedDep / pluginVersion skew), then redeploy the plugin and bos publish --deploy --packages local",
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (current instanceof ValidationError) {
|
|
316
|
+
return {
|
|
317
|
+
kind: "validation",
|
|
318
|
+
retryable: false,
|
|
319
|
+
message: `${current.stage}: ${extractErrorMessage(current.zodError)}`,
|
|
320
|
+
suggestion: `Fix the plugin's ${current.stage} schema at plugins/${current.pluginId}`,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
if (current instanceof ORPCError) {
|
|
324
|
+
const retryableByCode = RETRYABLE_ORPC_CODES.has(current.code);
|
|
325
|
+
return {
|
|
326
|
+
kind: "network",
|
|
327
|
+
retryable: retryableByCode,
|
|
328
|
+
message: current.message,
|
|
329
|
+
suggestion: retryableByCode
|
|
330
|
+
? "The plugin procedure failed transiently — retry the call"
|
|
331
|
+
: undefined,
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
current = (current as { cause?: unknown }).cause;
|
|
335
|
+
hops += 1;
|
|
206
336
|
}
|
|
337
|
+
|
|
338
|
+
const message = extractErrorMessage(error);
|
|
339
|
+
const lower = message.toLowerCase();
|
|
340
|
+
|
|
341
|
+
if (NETWORK_RETRYABLE_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {
|
|
342
|
+
return {
|
|
343
|
+
kind: "network",
|
|
344
|
+
retryable: true,
|
|
345
|
+
message,
|
|
346
|
+
suggestion: "The remote may be temporarily unavailable — retry after redeploying the plugin",
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
if (NETWORK_DEAD_PATTERNS.some((p) => lower.includes(p.toLowerCase()))) {
|
|
350
|
+
return {
|
|
351
|
+
kind: "network",
|
|
352
|
+
retryable: false,
|
|
353
|
+
message,
|
|
354
|
+
suggestion:
|
|
355
|
+
"The plugin host is unreachable — check plugins.<id> entry URLs in bos.config.json",
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
if (lower.includes("integrity") || lower.includes("sri")) {
|
|
359
|
+
return {
|
|
360
|
+
kind: "integrity",
|
|
361
|
+
retryable: true,
|
|
362
|
+
message,
|
|
363
|
+
suggestion:
|
|
364
|
+
"The deployed bundle content does not match its recorded integrity — redeploy the plugin so bos.config.json is republished with a fresh hash",
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return { kind: "unknown", retryable: false, message };
|
|
207
369
|
};
|
|
208
370
|
|
|
209
371
|
// Convert ORPC errors from plugin procedures to PluginRuntimeError
|
|
@@ -217,7 +379,6 @@ export const wrapORPCError = (
|
|
|
217
379
|
pluginId,
|
|
218
380
|
operation,
|
|
219
381
|
procedureName,
|
|
220
|
-
retryable: isRetryableORPCCode(orpcError.code),
|
|
221
382
|
cause: orpcError as Error,
|
|
222
383
|
});
|
|
223
384
|
};
|
|
@@ -235,7 +396,7 @@ export const extractFromFiberFailure = (error: unknown): unknown => {
|
|
|
235
396
|
|
|
236
397
|
if (cause && typeof cause === "object" && "_tag" in cause) {
|
|
237
398
|
try {
|
|
238
|
-
const squashed = Cause.squash(cause as Cause.Cause<unknown>);
|
|
399
|
+
const squashed = Cause.squash(cause as unknown as Cause.Cause<unknown>);
|
|
239
400
|
if (squashed instanceof ORPCError) {
|
|
240
401
|
return squashed;
|
|
241
402
|
}
|
|
@@ -259,7 +420,6 @@ export const toPluginRuntimeError = (
|
|
|
259
420
|
pluginId?: string,
|
|
260
421
|
procedureName?: string,
|
|
261
422
|
operation?: string,
|
|
262
|
-
defaultRetryable = false,
|
|
263
423
|
): PluginRuntimeError => {
|
|
264
424
|
if (error instanceof ORPCError) {
|
|
265
425
|
return wrapORPCError(error, pluginId, procedureName, operation);
|
|
@@ -273,7 +433,6 @@ export const toPluginRuntimeError = (
|
|
|
273
433
|
pluginId,
|
|
274
434
|
operation,
|
|
275
435
|
procedureName,
|
|
276
|
-
retryable: defaultRetryable || isRetryableError(extractErrorMessage(error)),
|
|
277
436
|
cause: error instanceof Error ? error : new Error(extractErrorMessage(error)),
|
|
278
437
|
});
|
|
279
438
|
};
|
package/src/runtime/index.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import "@orpc/experimental-effect/extensions/effect";
|
|
2
|
+
import "@orpc/openapi/extensions/route";
|
|
3
|
+
|
|
1
4
|
import { createRouterClient } from "@orpc/server";
|
|
2
|
-
import { Cause, Effect, Exit,
|
|
5
|
+
import { Cause, Effect, Exit, ManagedRuntime, Option } from "effect";
|
|
6
|
+
import { DEV_ENTRY_FILENAME } from "../build/artifact-names";
|
|
3
7
|
import type {
|
|
4
8
|
AnyPlugin,
|
|
5
9
|
AnyPluginConstructor,
|
|
@@ -16,25 +20,94 @@ import type {
|
|
|
16
20
|
RegisteredPlugins,
|
|
17
21
|
UsePluginResult,
|
|
18
22
|
} from "../types";
|
|
19
|
-
import { PluginRuntimeError } from "./errors";
|
|
20
|
-
import { PluginService } from "./services/plugin.service";
|
|
23
|
+
import { PluginRuntimeError, toPluginRuntimeError } from "./errors";
|
|
24
|
+
import { PluginService, PluginServiceLive } from "./services/plugin.service";
|
|
25
|
+
|
|
26
|
+
const MAX_CACHE_KEY_DEPTH = 32;
|
|
21
27
|
|
|
22
28
|
export class PluginRuntime<R = RegisteredPlugins> {
|
|
23
29
|
readonly __registryType?: R;
|
|
24
30
|
|
|
25
|
-
private pluginCache = new Map<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
private pluginCache = new Map<string, Promise<InitializedPlugin<AnyPlugin>>>();
|
|
32
|
+
private routerCache = new Map<string, PluginRouterType<any>>();
|
|
33
|
+
private cacheLeafIds = new WeakMap<object, number>();
|
|
34
|
+
private nextCacheLeafId = 0;
|
|
29
35
|
|
|
30
36
|
constructor(
|
|
31
37
|
private runtime: ManagedRuntime.ManagedRuntime<PluginService, never>,
|
|
32
38
|
private registry: PluginRegistry,
|
|
33
39
|
) {}
|
|
34
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Cache key for plugin instances: JSON-equal configs share one plugin
|
|
43
|
+
* instance (variables and secrets originate from bos.config.json, so they
|
|
44
|
+
* are JSON values). Values outside the JSON domain follow Effect's Hash
|
|
45
|
+
* semantics — symbols key by description, functions and class instances by
|
|
46
|
+
* reference identity — and the host creates its pluginsClient map once per
|
|
47
|
+
* boot, making identity the correct equivalence for function-bearing
|
|
48
|
+
* configs.
|
|
49
|
+
*/
|
|
35
50
|
private generateCacheKey(pluginId: string, config: unknown): string {
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
return `${pluginId}:${this.canonicalizeConfig(config, 0, new Set())}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private canonicalizeConfig(value: unknown, depth: number, ancestors: Set<object>): string {
|
|
55
|
+
switch (typeof value) {
|
|
56
|
+
case "undefined":
|
|
57
|
+
return "undefined";
|
|
58
|
+
case "string":
|
|
59
|
+
return `string:${JSON.stringify(value)}`;
|
|
60
|
+
case "number":
|
|
61
|
+
return `number:${Object.is(value, -0) ? "-0" : String(value)}`;
|
|
62
|
+
case "bigint":
|
|
63
|
+
return `bigint:${value.toString()}`;
|
|
64
|
+
case "boolean":
|
|
65
|
+
return `boolean:${value}`;
|
|
66
|
+
case "symbol":
|
|
67
|
+
return `symbol:${String(value)}`;
|
|
68
|
+
case "function":
|
|
69
|
+
return `ref:${this.getCacheLeafId(value)}`;
|
|
70
|
+
case "object": {
|
|
71
|
+
if (value === null) return "null";
|
|
72
|
+
if (ancestors.has(value) || depth >= MAX_CACHE_KEY_DEPTH) {
|
|
73
|
+
return `ref:${this.getCacheLeafId(value)}`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (Array.isArray(value)) {
|
|
77
|
+
ancestors.add(value);
|
|
78
|
+
const serialized = `[${value
|
|
79
|
+
.map((item) => this.canonicalizeConfig(item, depth + 1, ancestors))
|
|
80
|
+
.join(",")}]`;
|
|
81
|
+
ancestors.delete(value);
|
|
82
|
+
return serialized;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const prototype = Object.getPrototypeOf(value);
|
|
86
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
87
|
+
return `ref:${this.getCacheLeafId(value)}`;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const record = value as Record<string, unknown>;
|
|
91
|
+
ancestors.add(value);
|
|
92
|
+
const serialized = `{${Object.keys(record)
|
|
93
|
+
.sort()
|
|
94
|
+
.map(
|
|
95
|
+
(key) =>
|
|
96
|
+
`${JSON.stringify(key)}:${this.canonicalizeConfig(record[key], depth + 1, ancestors)}`,
|
|
97
|
+
)
|
|
98
|
+
.join(",")}}`;
|
|
99
|
+
ancestors.delete(value);
|
|
100
|
+
return serialized;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private getCacheLeafId(value: object): number {
|
|
106
|
+
const existing = this.cacheLeafIds.get(value);
|
|
107
|
+
if (existing !== undefined) return existing;
|
|
108
|
+
const id = this.nextCacheLeafId++;
|
|
109
|
+
this.cacheLeafIds.set(value, id);
|
|
110
|
+
return id;
|
|
38
111
|
}
|
|
39
112
|
|
|
40
113
|
private validatePluginId(pluginId: string): Effect.Effect<string, PluginRuntimeError> {
|
|
@@ -44,7 +117,6 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
44
117
|
pluginId: String(pluginId),
|
|
45
118
|
operation: "validate-plugin-id",
|
|
46
119
|
cause: new Error(`Plugin ID '${String(pluginId)}' not found in registry.`),
|
|
47
|
-
retryable: false,
|
|
48
120
|
}),
|
|
49
121
|
);
|
|
50
122
|
}
|
|
@@ -55,7 +127,7 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
55
127
|
const exit = await this.runtime.runPromiseExit(effect);
|
|
56
128
|
|
|
57
129
|
if (Exit.isFailure(exit)) {
|
|
58
|
-
const error = Cause.
|
|
130
|
+
const error = Cause.findErrorOption(exit.cause);
|
|
59
131
|
if (Option.isSome(error)) {
|
|
60
132
|
throw error.value;
|
|
61
133
|
}
|
|
@@ -74,7 +146,7 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
74
146
|
|
|
75
147
|
let cachedPlugin = this.pluginCache.get(cacheKey);
|
|
76
148
|
if (!cachedPlugin) {
|
|
77
|
-
const operation = Effect.gen(this, function* () {
|
|
149
|
+
const operation = Effect.gen({ self: this }, function* () {
|
|
78
150
|
const pluginService = yield* PluginService;
|
|
79
151
|
const validatedId = yield* this.validatePluginId(pluginId);
|
|
80
152
|
|
|
@@ -85,27 +157,45 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
85
157
|
yield* pluginService.registerPlugin(initialized);
|
|
86
158
|
|
|
87
159
|
return initialized;
|
|
88
|
-
})
|
|
160
|
+
});
|
|
89
161
|
|
|
90
|
-
cachedPlugin =
|
|
162
|
+
cachedPlugin = this.runPromise(operation);
|
|
91
163
|
this.pluginCache.set(cacheKey, cachedPlugin);
|
|
92
164
|
}
|
|
93
165
|
|
|
94
166
|
let initialized: InitializedPlugin<AnyPlugin>;
|
|
95
167
|
try {
|
|
96
|
-
initialized = await
|
|
168
|
+
initialized = await cachedPlugin;
|
|
97
169
|
} catch (error) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
170
|
+
if (this.pluginCache.get(cacheKey) === cachedPlugin) {
|
|
171
|
+
this.pluginCache.delete(cacheKey);
|
|
172
|
+
this.routerCache.delete(cacheKey);
|
|
173
|
+
}
|
|
101
174
|
throw error;
|
|
102
175
|
}
|
|
103
176
|
|
|
104
177
|
// Construct the router once per plugin instance, not per client/request.
|
|
105
|
-
|
|
178
|
+
let router = this.routerCache.get(cacheKey);
|
|
179
|
+
if (!router) {
|
|
180
|
+
try {
|
|
181
|
+
router = initialized.plugin.createRouter(plugins ?? {}) as PluginRouterType<R[K]>;
|
|
182
|
+
this.routerCache.set(cacheKey, router);
|
|
183
|
+
} catch (error) {
|
|
184
|
+
await this.evictPlugin(pluginId, config, plugins);
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
106
188
|
|
|
107
|
-
// Create client factory that accepts request context
|
|
108
|
-
|
|
189
|
+
// Create client factory that accepts request context. The plugin's
|
|
190
|
+
// Effect context is injected so `.effect()` handlers resolve services
|
|
191
|
+
// on in-process (server-side / SSR) calls.
|
|
192
|
+
const createClient = (context?: any) =>
|
|
193
|
+
createRouterClient(router, {
|
|
194
|
+
context: {
|
|
195
|
+
...context,
|
|
196
|
+
"effect/context": initialized.effectContext,
|
|
197
|
+
},
|
|
198
|
+
});
|
|
109
199
|
|
|
110
200
|
return {
|
|
111
201
|
createClient: createClient as any,
|
|
@@ -121,7 +211,7 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
121
211
|
const effect = Effect.gen(function* () {
|
|
122
212
|
const pluginService = yield* PluginService;
|
|
123
213
|
return yield* pluginService.loadPlugin(pluginId);
|
|
124
|
-
})
|
|
214
|
+
});
|
|
125
215
|
return this.runPromise(effect) as Promise<LoadedPlugin<RegisteredPlugin<K, R>>>;
|
|
126
216
|
}
|
|
127
217
|
|
|
@@ -132,7 +222,7 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
132
222
|
const effect = Effect.gen(function* () {
|
|
133
223
|
const pluginService = yield* PluginService;
|
|
134
224
|
return yield* pluginService.instantiatePlugin(pluginId, loadedPlugin);
|
|
135
|
-
})
|
|
225
|
+
});
|
|
136
226
|
return this.runPromise(effect) as Promise<PluginInstance<RegisteredPlugin<K, R>>>;
|
|
137
227
|
}
|
|
138
228
|
|
|
@@ -146,17 +236,22 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
146
236
|
const initialized = yield* pluginService.initializePlugin(instance, config, plugins);
|
|
147
237
|
yield* pluginService.registerPlugin(initialized);
|
|
148
238
|
return initialized;
|
|
149
|
-
})
|
|
239
|
+
});
|
|
150
240
|
return this.runPromise(effect);
|
|
151
241
|
}
|
|
152
242
|
|
|
153
243
|
async shutdown(): Promise<void> {
|
|
154
244
|
const effect = Effect.gen(function* () {
|
|
155
245
|
const pluginService = yield* PluginService;
|
|
156
|
-
yield* pluginService.cleanup
|
|
246
|
+
yield* pluginService.cleanup;
|
|
157
247
|
});
|
|
158
|
-
|
|
159
|
-
|
|
248
|
+
try {
|
|
249
|
+
await this.runPromise(effect);
|
|
250
|
+
} finally {
|
|
251
|
+
this.pluginCache.clear();
|
|
252
|
+
this.routerCache.clear();
|
|
253
|
+
await this.runtime.dispose();
|
|
254
|
+
}
|
|
160
255
|
}
|
|
161
256
|
|
|
162
257
|
async evictPlugin<K extends keyof R & string>(
|
|
@@ -166,30 +261,24 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
166
261
|
): Promise<void> {
|
|
167
262
|
const cacheKey = this.generateCacheKey(pluginId, { ...config, __plugins: plugins ?? {} });
|
|
168
263
|
|
|
169
|
-
const effect = Effect.gen(this, function* () {
|
|
264
|
+
const effect = Effect.gen({ self: this }, function* () {
|
|
170
265
|
const pluginService = yield* PluginService;
|
|
171
266
|
const cachedPlugin = this.pluginCache.get(cacheKey);
|
|
172
267
|
|
|
173
268
|
if (cachedPlugin) {
|
|
174
269
|
this.pluginCache.delete(cacheKey);
|
|
270
|
+
this.routerCache.delete(cacheKey);
|
|
175
271
|
|
|
176
|
-
const pluginResult = yield*
|
|
272
|
+
const pluginResult = yield* Effect.tryPromise({
|
|
273
|
+
try: () => cachedPlugin,
|
|
274
|
+
catch: (error) => toPluginRuntimeError(error, pluginId, undefined, "evict-plugin"),
|
|
275
|
+
}).pipe(Effect.orElseSucceed(() => null));
|
|
177
276
|
|
|
178
277
|
if (pluginResult) {
|
|
179
|
-
yield* pluginService
|
|
180
|
-
.shutdownPlugin(pluginResult)
|
|
181
|
-
.pipe(
|
|
182
|
-
Effect.catchAll((error) =>
|
|
183
|
-
Effect.logWarning(`Failed to shutdown evicted plugin ${pluginId}`, error),
|
|
184
|
-
),
|
|
185
|
-
);
|
|
278
|
+
yield* pluginService.shutdownPlugin(pluginResult);
|
|
186
279
|
}
|
|
187
280
|
}
|
|
188
|
-
})
|
|
189
|
-
Effect.catchAll((error) =>
|
|
190
|
-
Effect.logWarning(`Plugin eviction failed for ${pluginId}`, error),
|
|
191
|
-
),
|
|
192
|
-
);
|
|
281
|
+
});
|
|
193
282
|
|
|
194
283
|
return this.runPromise(effect);
|
|
195
284
|
}
|
|
@@ -202,7 +291,7 @@ export class PluginRuntime<R = RegisteredPlugins> {
|
|
|
202
291
|
function normalizeRemoteUrl(url: string): string {
|
|
203
292
|
if (!url) return url;
|
|
204
293
|
if (url.endsWith(".js") || url.endsWith(".json")) return url;
|
|
205
|
-
return `${url.endsWith("/") ? url.slice(0, -1) : url}
|
|
294
|
+
return `${url.endsWith("/") ? url.slice(0, -1) : url}/${DEV_ENTRY_FILENAME}`;
|
|
206
295
|
}
|
|
207
296
|
|
|
208
297
|
/**
|
|
@@ -270,7 +359,7 @@ export function createPluginRuntime<TRegistry extends Record<string, PluginRegis
|
|
|
270
359
|
const normalizedRegistry = normalizeRegistry(config.registry);
|
|
271
360
|
const pluginMap = extractPluginMap(config.registry);
|
|
272
361
|
|
|
273
|
-
const layer =
|
|
362
|
+
const layer = PluginServiceLive(normalizedRegistry, secrets, pluginMap);
|
|
274
363
|
const runtime = ManagedRuntime.make(layer);
|
|
275
364
|
|
|
276
365
|
return new PluginRuntime(runtime, normalizedRegistry) as PluginRuntime<
|