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/plugin.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import type { WithEffectContext } from "@orpc/experimental-effect";
|
|
3
|
+
import "@orpc/experimental-effect/extensions/effect";
|
|
4
|
+
import type { ContractedRouter, Implementer } from "@orpc/server";
|
|
5
|
+
import { implement } from "@orpc/server";
|
|
6
|
+
import type { Scope } from "effect";
|
|
7
|
+
import { Context, Effect, Layer } from "effect";
|
|
8
|
+
import type { PluginWarningInfo } from "./runtime/errors";
|
|
9
|
+
import { type PluginRuntimeError, toPluginRuntimeError } from "./runtime/errors";
|
|
7
10
|
|
|
8
11
|
type ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;
|
|
9
12
|
|
|
@@ -17,28 +20,39 @@ export type PluginConfigFor<
|
|
|
17
20
|
context: TRequestContext;
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
|
|
23
|
+
export type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
|
|
24
|
+
/**
|
|
25
|
+
* The framework-assigned plugin id — the same key the host uses for secret
|
|
26
|
+
* injection and per-plugin database namespacing. Arrives as a value so
|
|
27
|
+
* plugin code never needs the ambient `PluginIdTag`.
|
|
28
|
+
*/
|
|
29
|
+
pluginId: string;
|
|
21
30
|
variables: InferSchemaOutput<V>;
|
|
22
31
|
secrets: InferSchemaOutput<S>;
|
|
23
32
|
};
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* A plugin's own config-derived warnings, evaluated once with the validated
|
|
36
|
+
* config after initialization. Declaring `warnings` opts the plugin out of
|
|
37
|
+
* the loader's default missing-secret warning — these messages replace it.
|
|
27
38
|
*/
|
|
28
|
-
type
|
|
39
|
+
export type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (
|
|
40
|
+
config: PluginInitializeInput<V, S>,
|
|
41
|
+
) => PluginWarningInfo[] | string[];
|
|
29
42
|
|
|
30
|
-
export
|
|
31
|
-
buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;
|
|
32
|
-
};
|
|
43
|
+
export class PluginIdTag extends Context.Service<PluginIdTag, string>()("PluginId") {}
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
/**
|
|
46
|
+
* The `initialize` effect's environment: the plugin lifecycle scope plus the
|
|
47
|
+
* framework-assigned plugin id.
|
|
48
|
+
*/
|
|
49
|
+
export type PluginEnv = Scope.Scope | PluginIdTag;
|
|
35
50
|
|
|
36
51
|
type PluginDefinition<
|
|
37
52
|
V extends AnySchema,
|
|
38
53
|
S extends AnySchema,
|
|
39
54
|
TContract extends AnyContractRouter,
|
|
40
55
|
TRequestContext extends AnySchema | undefined,
|
|
41
|
-
TDeps extends Record<string, any>,
|
|
42
56
|
P extends Record<string, unknown>,
|
|
43
57
|
> = {
|
|
44
58
|
variables: V;
|
|
@@ -46,20 +60,42 @@ type PluginDefinition<
|
|
|
46
60
|
contract: TContract;
|
|
47
61
|
context?: TRequestContext;
|
|
48
62
|
/**
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
63
|
+
* Optional tag under which `initialize` exposes the plugin's services.
|
|
64
|
+
* The host uses it to read services (e.g. the auth plugin's Better Auth
|
|
65
|
+
* handler) from the built Effect context without importing the plugin
|
|
66
|
+
* module statically.
|
|
67
|
+
*/
|
|
68
|
+
servicesTag?: Context.Key<any, any>;
|
|
69
|
+
/**
|
|
70
|
+
* Optional warnings function evaluated once with the validated config after
|
|
71
|
+
* initialization. Returns structured non-fatal warnings (e.g. an optional
|
|
72
|
+
* secret was not set, so the feature depending on it is disabled).
|
|
73
|
+
* Declaring it opts out of the loader's default missing-secret warning.
|
|
74
|
+
*/
|
|
75
|
+
warnings?: PluginWarningsFn<V, S>;
|
|
76
|
+
/**
|
|
77
|
+
* Initialize the plugin by returning an Effect `Layer`.
|
|
78
|
+
*
|
|
79
|
+
* The runtime builds the Layer against the plugin's lifecycle scope —
|
|
80
|
+
* scoped resources (db pools, repositories, caches, publishers) release
|
|
81
|
+
* when the plugin shuts down. Services are provided to `.effect()`
|
|
82
|
+
* handlers via the oRPC context (`yield* Tag`).
|
|
52
83
|
*/
|
|
53
84
|
initialize?: (
|
|
54
85
|
config: PluginInitializeInput<V, S>,
|
|
55
86
|
plugins: P,
|
|
56
|
-
|
|
57
|
-
|
|
87
|
+
) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;
|
|
88
|
+
/**
|
|
89
|
+
* Creates the strongly-typed oRPC router for this plugin.
|
|
90
|
+
* Services come from the Effect context — access them with
|
|
91
|
+
* `yield* Tag` in `.effect()` handlers, or
|
|
92
|
+
* `Context.get(context["effect/context"], Tag)` in plain handlers.
|
|
93
|
+
* Sibling plugin entries in `plugins` carry `{ client, router }`.
|
|
94
|
+
*/
|
|
58
95
|
createRouter: (
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
) =>
|
|
62
|
-
shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;
|
|
96
|
+
builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>,
|
|
97
|
+
plugins: P,
|
|
98
|
+
) => ContractedRouter<TContract, any>;
|
|
63
99
|
};
|
|
64
100
|
|
|
65
101
|
/**
|
|
@@ -70,14 +106,14 @@ export interface LoadedPluginWithBinding<
|
|
|
70
106
|
TVariables extends AnySchema,
|
|
71
107
|
TSecrets extends AnySchema,
|
|
72
108
|
TRequestContext extends AnySchema | undefined,
|
|
73
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
74
109
|
> {
|
|
75
|
-
new (): Plugin<TContract, TVariables, TSecrets, TRequestContext
|
|
110
|
+
new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;
|
|
76
111
|
binding: {
|
|
77
112
|
contract: TContract;
|
|
78
113
|
variables: TVariables;
|
|
79
114
|
secrets: TSecrets;
|
|
80
115
|
context: TRequestContext;
|
|
116
|
+
servicesTag?: Context.Key<any, any>;
|
|
81
117
|
};
|
|
82
118
|
}
|
|
83
119
|
|
|
@@ -89,27 +125,26 @@ export interface Plugin<
|
|
|
89
125
|
TVariables extends AnySchema,
|
|
90
126
|
TSecrets extends AnySchema,
|
|
91
127
|
TRequestContext extends AnySchema | undefined,
|
|
92
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
93
128
|
> {
|
|
94
129
|
readonly id: string;
|
|
95
130
|
readonly contract: TContract;
|
|
96
131
|
readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;
|
|
132
|
+
readonly servicesTag?: Context.Key<any, any>;
|
|
133
|
+
readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;
|
|
97
134
|
|
|
98
135
|
initialize(
|
|
99
136
|
config: PluginInitializeInput<TVariables, TSecrets>,
|
|
100
137
|
plugins: Record<string, unknown>,
|
|
101
|
-
|
|
102
|
-
): Effect.Effect<TDeps, unknown, Scope.Scope>;
|
|
103
|
-
|
|
104
|
-
shutdown(): Effect.Effect<void, never>;
|
|
138
|
+
): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;
|
|
105
139
|
|
|
106
140
|
/**
|
|
107
141
|
* Creates the strongly-typed oRPC router for this plugin.
|
|
108
142
|
* The router's procedure types are inferred directly from the contract.
|
|
109
|
-
* @param
|
|
143
|
+
* @param plugins Sibling plugin entries (`{ client, router }`) for
|
|
144
|
+
* cross-plugin composition
|
|
110
145
|
* @returns A router with procedures matching the plugin's contract
|
|
111
146
|
*/
|
|
112
|
-
createRouter(
|
|
147
|
+
createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any>;
|
|
113
148
|
}
|
|
114
149
|
|
|
115
150
|
export interface CreatePluginFn {
|
|
@@ -118,11 +153,10 @@ export interface CreatePluginFn {
|
|
|
118
153
|
S extends AnySchema,
|
|
119
154
|
TContract extends AnyContractRouter,
|
|
120
155
|
TRequestContext extends AnySchema | undefined = undefined,
|
|
121
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
122
156
|
P extends Record<string, unknown> = Record<string, never>,
|
|
123
157
|
>(
|
|
124
|
-
config: PluginDefinition<V, S, TContract, TRequestContext,
|
|
125
|
-
): LoadedPluginWithBinding<TContract, V, S, TRequestContext
|
|
158
|
+
config: PluginDefinition<V, S, TContract, TRequestContext, P>,
|
|
159
|
+
): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
126
160
|
|
|
127
161
|
withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;
|
|
128
162
|
}
|
|
@@ -132,84 +166,54 @@ export const createPlugin: CreatePluginFn = function createPlugin<
|
|
|
132
166
|
S extends AnySchema,
|
|
133
167
|
TContract extends AnyContractRouter,
|
|
134
168
|
TRequestContext extends AnySchema | undefined = undefined,
|
|
135
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
136
169
|
P extends Record<string, unknown> = Record<string, never>,
|
|
137
|
-
>(config: PluginDefinition<V, S, TContract, TRequestContext,
|
|
170
|
+
>(config: PluginDefinition<V, S, TContract, TRequestContext, P>) {
|
|
138
171
|
const configSchema: PluginConfigFor<V, S, TRequestContext> = {
|
|
139
172
|
variables: config.variables,
|
|
140
173
|
secrets: config.secrets,
|
|
141
174
|
context: config.context as TRequestContext,
|
|
142
175
|
};
|
|
143
176
|
|
|
144
|
-
class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext
|
|
177
|
+
class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext> {
|
|
145
178
|
/** set during instantiation - registry key */
|
|
146
179
|
id!: string;
|
|
147
180
|
readonly contract = config.contract;
|
|
148
181
|
readonly configSchema = configSchema;
|
|
149
|
-
|
|
150
|
-
|
|
182
|
+
readonly servicesTag = config.servicesTag;
|
|
183
|
+
readonly warnings = config.warnings;
|
|
151
184
|
|
|
152
185
|
initialize(
|
|
153
186
|
pluginConfig: PluginInitializeInput<V, S>,
|
|
154
187
|
plugins: Record<string, unknown> = {},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
188
|
+
): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv> {
|
|
189
|
+
const init = config.initialize;
|
|
190
|
+
if (!init) {
|
|
191
|
+
return Effect.succeed(Layer.empty as unknown as Layer.Layer<any, Error, PluginEnv>);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return init(pluginConfig, plugins as P).pipe(
|
|
195
|
+
Effect.mapError((error) =>
|
|
196
|
+
toPluginRuntimeError(error, this.id, undefined, "initialize-plugin"),
|
|
164
197
|
),
|
|
165
|
-
Effect.map(() => this._deps as TDeps),
|
|
166
|
-
Effect.mapError((error) => error as unknown),
|
|
167
198
|
);
|
|
168
199
|
}
|
|
169
200
|
|
|
170
|
-
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
.shutdown(self._deps)
|
|
176
|
-
.pipe(
|
|
177
|
-
Effect.catchAll((error) =>
|
|
178
|
-
Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),
|
|
179
|
-
),
|
|
180
|
-
);
|
|
181
|
-
}
|
|
182
|
-
self._deps = null;
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
createRouter(deps: TDeps): Router<TContract, any> {
|
|
187
|
-
const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();
|
|
188
|
-
const errorMiddleware = onError((error: unknown) => {
|
|
189
|
-
const unwrapped = extractFromFiberFailure(error);
|
|
190
|
-
|
|
191
|
-
if (unwrapped !== error && unwrapped instanceof ORPCError) {
|
|
192
|
-
throw unwrapped;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const formatted = formatORPCError(error);
|
|
196
|
-
if (formatted) console.error(formatted);
|
|
197
|
-
throw error;
|
|
198
|
-
}) as any;
|
|
199
|
-
|
|
200
|
-
const builder = (base as any).use(errorMiddleware);
|
|
201
|
-
const router = config.createRouter(deps, builder as any);
|
|
202
|
-
return router as Router<TContract, any>;
|
|
201
|
+
createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any> {
|
|
202
|
+
const builder = implement(config.contract).$context<
|
|
203
|
+
ContextOutput<TRequestContext> & WithEffectContext<any>
|
|
204
|
+
>();
|
|
205
|
+
return config.createRouter(builder as any, plugins as P) as ContractedRouter<TContract, any>;
|
|
203
206
|
}
|
|
204
207
|
}
|
|
205
208
|
|
|
206
209
|
const PluginConstructor = CreatedPlugin as unknown as {
|
|
207
|
-
new (): Plugin<TContract, V, S, TRequestContext
|
|
210
|
+
new (): Plugin<TContract, V, S, TRequestContext>;
|
|
208
211
|
binding: {
|
|
209
212
|
contract: TContract;
|
|
210
213
|
variables: V;
|
|
211
214
|
secrets: S;
|
|
212
215
|
context: TRequestContext;
|
|
216
|
+
servicesTag?: Context.Key<any, any>;
|
|
213
217
|
};
|
|
214
218
|
};
|
|
215
219
|
|
|
@@ -218,9 +222,10 @@ export const createPlugin: CreatePluginFn = function createPlugin<
|
|
|
218
222
|
variables: config.variables,
|
|
219
223
|
secrets: config.secrets,
|
|
220
224
|
context: config.context as TRequestContext,
|
|
225
|
+
servicesTag: config.servicesTag,
|
|
221
226
|
};
|
|
222
227
|
|
|
223
|
-
return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext
|
|
228
|
+
return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
224
229
|
};
|
|
225
230
|
|
|
226
231
|
export type CreatePluginWithPlugins<P extends Record<string, unknown>> = <
|
|
@@ -228,10 +233,9 @@ export type CreatePluginWithPlugins<P extends Record<string, unknown>> = <
|
|
|
228
233
|
S extends AnySchema,
|
|
229
234
|
TContract extends AnyContractRouter,
|
|
230
235
|
TRequestContext extends AnySchema | undefined = undefined,
|
|
231
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
232
236
|
>(
|
|
233
|
-
config: PluginDefinition<V, S, TContract, TRequestContext,
|
|
234
|
-
) => LoadedPluginWithBinding<TContract, V, S, TRequestContext
|
|
237
|
+
config: PluginDefinition<V, S, TContract, TRequestContext, P>,
|
|
238
|
+
) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
|
|
235
239
|
|
|
236
240
|
export function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {
|
|
237
241
|
return <
|
|
@@ -239,10 +243,9 @@ export function withPlugins<P extends Record<string, unknown>>(): CreatePluginWi
|
|
|
239
243
|
S extends AnySchema,
|
|
240
244
|
TContract extends AnyContractRouter,
|
|
241
245
|
TRequestContext extends AnySchema | undefined = undefined,
|
|
242
|
-
TDeps extends Record<string, any> = Record<never, never>,
|
|
243
246
|
>(
|
|
244
|
-
config: PluginDefinition<V, S, TContract, TRequestContext,
|
|
245
|
-
) => createPlugin<V, S, TContract, TRequestContext,
|
|
247
|
+
config: PluginDefinition<V, S, TContract, TRequestContext, P>,
|
|
248
|
+
) => createPlugin<V, S, TContract, TRequestContext, P>(config as any);
|
|
246
249
|
}
|
|
247
250
|
|
|
248
251
|
createPlugin.withPlugins = withPlugins;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remote-entry loading resilience — the ONE contract every MF consumer in
|
|
3
|
+
* the dev stack shares (plugin dev serves, the host's plugin loader).
|
|
4
|
+
*
|
|
5
|
+
* Two failure classes it exists for:
|
|
6
|
+
* 1. Cold compile: remoteEntry.js 404s until the remote's first build —
|
|
7
|
+
* the 404 body gets eval'd as JS ("Unexpected identifier 'Found'").
|
|
8
|
+
* 2. Watch-rebuild poisoning: a failed entry load is memoized forever in
|
|
9
|
+
* `globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__` (runtime-core never evicts
|
|
10
|
+
* rejections), so retries without a purge await the same failure.
|
|
11
|
+
*/
|
|
12
|
+
import { Duration, Effect, Schedule } from "effect";
|
|
13
|
+
import type { PluginRuntimeError } from "./runtime/errors";
|
|
14
|
+
import {
|
|
15
|
+
classifyPluginFailure,
|
|
16
|
+
deepestErrorStack,
|
|
17
|
+
type PluginFailureClassification,
|
|
18
|
+
toPluginRuntimeError,
|
|
19
|
+
} from "./runtime/errors";
|
|
20
|
+
|
|
21
|
+
const POLL_INTERVAL_MS = 300;
|
|
22
|
+
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
23
|
+
const RETRY_BASE_DELAY_MS = 500;
|
|
24
|
+
const RETRY_MAX_DELAY_MS = 5_000;
|
|
25
|
+
|
|
26
|
+
const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Deletes the failed remote's keys from the process-global entry-load cache.
|
|
30
|
+
* Deleting a RESOLVED entry would force a wasteful re-eval, so only call
|
|
31
|
+
* this from failure paths.
|
|
32
|
+
*/
|
|
33
|
+
export const purgeRemoteEntryCache = (remoteUrl: string): void => {
|
|
34
|
+
const globalLoading = (globalThis as Record<string, unknown>).__GLOBAL_LOADING_REMOTE_ENTRY__ as
|
|
35
|
+
| Record<string, unknown>
|
|
36
|
+
| undefined;
|
|
37
|
+
if (!globalLoading) return;
|
|
38
|
+
for (const key of Object.keys(globalLoading)) {
|
|
39
|
+
if (key.endsWith(`:${remoteUrl}`)) delete globalLoading[key];
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const isRemoteEntryBody = (body: string): boolean =>
|
|
44
|
+
!/not found|<(!doctype|html)/i.test(body.slice(0, 64));
|
|
45
|
+
|
|
46
|
+
export const waitForRemoteEntryReady = async (
|
|
47
|
+
label: string,
|
|
48
|
+
url: string,
|
|
49
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
50
|
+
): Promise<void> => {
|
|
51
|
+
const deadline = Date.now() + timeoutMs;
|
|
52
|
+
let announced = false;
|
|
53
|
+
while (Date.now() < deadline) {
|
|
54
|
+
const res = await fetch(url).catch(() => null);
|
|
55
|
+
if (res?.ok && isRemoteEntryBody(await res.text().catch(() => ""))) return;
|
|
56
|
+
if (!announced) {
|
|
57
|
+
announced = true;
|
|
58
|
+
console.log(`⏳ waiting for ${label} to compile (remote entry not ready)…`);
|
|
59
|
+
}
|
|
60
|
+
await sleep(POLL_INTERVAL_MS);
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`${label} remote entry never became ready at ${url}`);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export interface PluginLoadAttemptInfo {
|
|
66
|
+
attempt: number;
|
|
67
|
+
classification: PluginFailureClassification;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface PluginLoadRetryOptions<T> {
|
|
71
|
+
/** short plugin key for log prefixes (host entry key or plugin id) */
|
|
72
|
+
label: string;
|
|
73
|
+
remoteUrl: string;
|
|
74
|
+
load: () => Promise<T>;
|
|
75
|
+
/** wall-clock budget for the retry loop */
|
|
76
|
+
timeoutMs?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Budget for the readiness poll (cold-compile wait) — defaults to the
|
|
79
|
+
* retry budget, preserving the historical behavior. Pass `0` to skip the
|
|
80
|
+
* poll (useful when the caller stubs `load` and does not need network).
|
|
81
|
+
*/
|
|
82
|
+
readinessTimeoutMs?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Observes every failed attempt (including non-retryable ones that end the
|
|
85
|
+
* loop). Defaults to classification-deduped console.error under the
|
|
86
|
+
* `[Plugins]` prefix.
|
|
87
|
+
*/
|
|
88
|
+
onAttempt?: ((error: unknown, info: PluginLoadAttemptInfo) => void) | undefined;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The one plugin-load retry policy: poll the remote entry until it is actually
|
|
93
|
+
* served, then load with capped exponential backoff — purging the poisoned
|
|
94
|
+
* global entry cache between attempts so each retry genuinely re-fetches.
|
|
95
|
+
*
|
|
96
|
+
* Recovery policy is `classifyPluginFailure().retryable`: transient network
|
|
97
|
+
* conditions retry until the wall-clock budget runs out; permanent failures
|
|
98
|
+
* (MF identity skew, schema validation, dead remotes, TLS verification) fail
|
|
99
|
+
* fast on the first attempt instead of burning the budget silently.
|
|
100
|
+
*
|
|
101
|
+
* Fails with the ORIGINAL error from `load` — the host builds
|
|
102
|
+
* `PluginBootstrapError.cause` from it and classification walks it.
|
|
103
|
+
*/
|
|
104
|
+
export const loadRemoteWithRetry = <T>(
|
|
105
|
+
options: PluginLoadRetryOptions<T>,
|
|
106
|
+
): Effect.Effect<T, PluginRuntimeError> => {
|
|
107
|
+
const {
|
|
108
|
+
label,
|
|
109
|
+
remoteUrl,
|
|
110
|
+
load,
|
|
111
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
112
|
+
readinessTimeoutMs,
|
|
113
|
+
onAttempt,
|
|
114
|
+
} = options;
|
|
115
|
+
const readinessTimeout = readinessTimeoutMs ?? timeoutMs;
|
|
116
|
+
|
|
117
|
+
const schedule = Schedule.exponential(Duration.millis(RETRY_BASE_DELAY_MS)).pipe(
|
|
118
|
+
Schedule.modifyDelay(({ output }) =>
|
|
119
|
+
Effect.succeed(
|
|
120
|
+
Duration.toMillis(output) > RETRY_MAX_DELAY_MS
|
|
121
|
+
? Duration.millis(RETRY_MAX_DELAY_MS)
|
|
122
|
+
: output,
|
|
123
|
+
),
|
|
124
|
+
),
|
|
125
|
+
Schedule.upTo({ duration: Duration.millis(timeoutMs) }),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
let attempt = 0;
|
|
129
|
+
let lastSignature: string | undefined;
|
|
130
|
+
const reportFailure = (error: unknown): void => {
|
|
131
|
+
attempt += 1;
|
|
132
|
+
purgeRemoteEntryCache(remoteUrl);
|
|
133
|
+
const classification = classifyPluginFailure(error);
|
|
134
|
+
if (onAttempt) {
|
|
135
|
+
onAttempt(error, { attempt, classification });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
const signature = `${classification.kind}::${classification.message}`;
|
|
139
|
+
if (signature === lastSignature) return;
|
|
140
|
+
lastSignature = signature;
|
|
141
|
+
// The message alone is rarely enough, and the wrapper's own stack points
|
|
142
|
+
// at the wrapping frames — log the DEEPEST cause's stack (the original
|
|
143
|
+
// throw site inside the evaluated remote entry).
|
|
144
|
+
const stack = deepestErrorStack(error);
|
|
145
|
+
console.error(
|
|
146
|
+
`[Plugins][${label}] ❌ ${classification.kind} failure (attempt ${attempt}): ${classification.message}` +
|
|
147
|
+
(classification.suggestion ? `\n[Plugins][${label}] → ${classification.suggestion}` : "") +
|
|
148
|
+
(stack ? `\n[Plugins][${label}] ${stack}` : ""),
|
|
149
|
+
);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const loadWithRetry = Effect.tryPromise({
|
|
153
|
+
try: load,
|
|
154
|
+
catch: (error) => toPluginRuntimeError(error, label, undefined, "remote-entry-load"),
|
|
155
|
+
}).pipe(
|
|
156
|
+
Effect.tapError((error) => Effect.sync(() => reportFailure(error))),
|
|
157
|
+
Effect.retry({ schedule, while: (error) => classifyPluginFailure(error).retryable }),
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// readinessTimeoutMs: 0 skips the cold-compile poll (tests stub `load` and
|
|
161
|
+
// must not race a 1ms wall-clock window against the event loop).
|
|
162
|
+
if (readinessTimeout === 0) {
|
|
163
|
+
return loadWithRetry;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return Effect.tryPromise({
|
|
167
|
+
try: () => waitForRemoteEntryReady(label, remoteUrl, readinessTimeout),
|
|
168
|
+
catch: (error) => toPluginRuntimeError(error, label, undefined, "remote-entry-readiness"),
|
|
169
|
+
}).pipe(Effect.flatMap(() => loadWithRetry));
|
|
170
|
+
};
|