every-plugin 0.6.1 → 0.7.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/dist/_virtual/rolldown_runtime.cjs +17 -7
- package/dist/_virtual/rolldown_runtime.mjs +17 -7
- package/dist/build/rspack/dev-server-middleware.cjs +3 -3
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +3 -3
- package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
- package/dist/build/rspack/module-federation.cjs +0 -5
- package/dist/build/rspack/module-federation.cjs.map +1 -1
- package/dist/build/rspack/module-federation.mjs +0 -5
- package/dist/build/rspack/module-federation.mjs.map +1 -1
- package/dist/build/rspack/plugin.cjs +2 -1
- package/dist/build/rspack/plugin.cjs.map +1 -1
- package/dist/build/rspack/plugin.mjs +2 -1
- package/dist/build/rspack/plugin.mjs.map +1 -1
- package/dist/errors.cjs +75 -51
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +8 -0
- package/dist/errors.d.cts.map +1 -1
- package/dist/errors.d.mts +8 -0
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +75 -51
- package/dist/errors.mjs.map +1 -1
- package/dist/package.cjs +10 -10
- package/dist/package.cjs.map +1 -1
- package/dist/package.mjs +10 -10
- package/dist/package.mjs.map +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.d.mts +4 -4
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/runtime/index.cjs +1 -1
- package/dist/runtime/index.mjs +1 -1
- package/dist/runtime/services/module-federation.service.cjs +24 -33
- package/dist/runtime/services/module-federation.service.cjs.map +1 -1
- package/dist/runtime/services/module-federation.service.d.cts +2 -3
- package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
- package/dist/runtime/services/module-federation.service.d.mts +2 -3
- package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
- package/dist/runtime/services/module-federation.service.mjs +24 -33
- package/dist/runtime/services/module-federation.service.mjs.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
- package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
- package/dist/runtime/services/plugin.service.d.cts +1 -1
- package/dist/runtime/services/plugin.service.d.mts +1 -1
- package/dist/runtime/services/secrets.service.cjs +1 -1
- package/dist/runtime/services/secrets.service.mjs +1 -1
- package/dist/types.d.cts +10 -10
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +15 -15
- package/dist/types.d.mts.map +1 -1
- package/package.json +22 -22
package/dist/plugin.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { Context, Implementer, Router } from "@orpc/server";
|
|
1
2
|
import { Effect, Scope } from "effect";
|
|
2
|
-
import { Context as Context$1, Implementer, Router } from "@orpc/server";
|
|
3
3
|
import { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
|
|
4
4
|
|
|
5
5
|
//#region src/plugin.d.ts
|
|
@@ -14,7 +14,7 @@ type PluginConfigFor<V extends AnySchema, S extends AnySchema> = {
|
|
|
14
14
|
/**
|
|
15
15
|
* Loaded plugin with static binding property
|
|
16
16
|
*/
|
|
17
|
-
interface LoadedPluginWithBinding<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TContext extends Context
|
|
17
|
+
interface LoadedPluginWithBinding<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TContext extends Context = Record<never, never>> {
|
|
18
18
|
new (): Plugin<TContract, TVariables, TSecrets, TContext>;
|
|
19
19
|
binding: {
|
|
20
20
|
contract: TContract;
|
|
@@ -26,7 +26,7 @@ interface LoadedPluginWithBinding<TContract extends AnyContractRouter, TVariable
|
|
|
26
26
|
/**
|
|
27
27
|
* Plugin interface
|
|
28
28
|
*/
|
|
29
|
-
interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TContext extends Context
|
|
29
|
+
interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySchema, TSecrets extends AnySchema, TContext extends Context = Record<never, never>> {
|
|
30
30
|
readonly id: string;
|
|
31
31
|
readonly contract: TContract;
|
|
32
32
|
readonly configSchema: PluginConfigFor<TVariables, TSecrets>;
|
|
@@ -46,7 +46,7 @@ interface Plugin<TContract extends AnyContractRouter, TVariables extends AnySche
|
|
|
46
46
|
/**
|
|
47
47
|
* Factory function to create plugins
|
|
48
48
|
*/
|
|
49
|
-
declare function createPlugin<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TContext extends Context
|
|
49
|
+
declare function createPlugin<V extends AnySchema, S extends AnySchema, TContract extends AnyContractRouter, TContext extends Context = Record<never, never>>(config: {
|
|
50
50
|
variables: V;
|
|
51
51
|
secrets: S;
|
|
52
52
|
contract: TContract;
|
package/dist/plugin.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAQA;AAAsC,KAA1B,eAA0B,CAAA,UAAA,SAAA,EAAA,UAAqB,SAArB,CAAA,GAAA;EAAqB,SAAA,EAC/C,CAD+C;EAC/C,OAAA,EACF,CADE;CACF;;AAMV;;AAEoB,UAFH,uBAEG,CAAA,kBADD,iBACC,EAAA,mBAAA,SAAA,EAAA,iBACF,SADE,EAAA,iBAEF,
|
|
1
|
+
{"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAQA;AAAsC,KAA1B,eAA0B,CAAA,UAAA,SAAA,EAAA,UAAqB,SAArB,CAAA,GAAA;EAAqB,SAAA,EAC/C,CAD+C;EAC/C,OAAA,EACF,CADE;CACF;;AAMV;;AAEoB,UAFH,uBAEG,CAAA,kBADD,iBACC,EAAA,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;EAMxB,UAAA,CAAA,EAAA,CAAA,MAAY,EAAA;IACjB,SAAA,EASY,iBATZ,CAS8B,CAT9B,CAAA;IACA,OAAA,EAQ2C,iBAR3C,CAQ6D,CAR7D,CAAA;EACQ,CAAA,EAAA,GAQb,MAAA,CAAO,MARM,CAQC,QARD,EAQW,KARX,EAQkB,KAAA,CAAM,KARxB,CAAA;EACD,YAAA,EAAA,CAAA,OAAA,EASP,QATO,EAAA,OAAA,EAUP,WAVO,CAUK,SAVL,EAUgB,QAVhB,EAU0B,QAV1B,CAAA,EAAA,GAWZ,MAXY,CAWL,SAXK,EAAA,GAAA,CAAA;EAAU,QAAA,CAAA,EAAA,CAAA,GAAA,EAYV,QAZU,EAAA,GAYG,MAAA,CAAO,MAZV,CAAA,IAAA,EAYuB,KAZvB,EAAA,KAAA,CAAA;CAEhB,CAAA,EAwEiB,uBAxEjB,CAwEyC,SAxEzC,EAwEoD,CAxEpD,EAwEuD,CAxEvD,EAwE0D,QAxE1D,CAAA"}
|
package/dist/plugin.mjs
CHANGED
package/dist/runtime/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_errors = require('./errors.cjs');
|
|
3
3
|
const require_plugin_service = require('./services/plugin.service.cjs');
|
|
4
|
-
let effect = require("effect");
|
|
5
4
|
let __orpc_server = require("@orpc/server");
|
|
5
|
+
let effect = require("effect");
|
|
6
6
|
|
|
7
7
|
//#region src/runtime/index.ts
|
|
8
8
|
var PluginRuntime = class {
|
package/dist/runtime/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "./errors.mjs";
|
|
2
2
|
import { PluginService } from "./services/plugin.service.mjs";
|
|
3
|
-
import { Cause, Effect, Exit, Hash, ManagedRuntime, Option } from "effect";
|
|
4
3
|
import { createRouterClient } from "@orpc/server";
|
|
4
|
+
import { Cause, Effect, Exit, Hash, ManagedRuntime, Option } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/runtime/index.ts
|
|
7
7
|
var PluginRuntime = class {
|
|
@@ -7,6 +7,10 @@ let __module_federation_enhanced_runtime = require("@module-federation/enhanced/
|
|
|
7
7
|
let __module_federation_runtime_core = require("@module-federation/runtime-core");
|
|
8
8
|
|
|
9
9
|
//#region src/runtime/services/module-federation.service.ts
|
|
10
|
+
function getMajorVersionRange(version$1) {
|
|
11
|
+
const match = version$1.match(/^[\^~]?(\d+)/);
|
|
12
|
+
return `^${match ? match[1] : "0"}.0.0`;
|
|
13
|
+
}
|
|
10
14
|
const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync(() => {
|
|
11
15
|
try {
|
|
12
16
|
let instance = (0, __module_federation_enhanced_runtime.getInstance)();
|
|
@@ -19,8 +23,8 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
|
|
|
19
23
|
version: require_package.version,
|
|
20
24
|
shareConfig: {
|
|
21
25
|
singleton: true,
|
|
22
|
-
requiredVersion:
|
|
23
|
-
eager:
|
|
26
|
+
requiredVersion: getMajorVersionRange(require_package.version),
|
|
27
|
+
eager: false,
|
|
24
28
|
strictVersion: false
|
|
25
29
|
}
|
|
26
30
|
},
|
|
@@ -28,8 +32,8 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
|
|
|
28
32
|
version: require_package.dependencies.effect,
|
|
29
33
|
shareConfig: {
|
|
30
34
|
singleton: true,
|
|
31
|
-
requiredVersion:
|
|
32
|
-
eager:
|
|
35
|
+
requiredVersion: getMajorVersionRange(require_package.dependencies.effect),
|
|
36
|
+
eager: false,
|
|
33
37
|
strictVersion: false
|
|
34
38
|
}
|
|
35
39
|
},
|
|
@@ -37,8 +41,8 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
|
|
|
37
41
|
version: require_package.dependencies.zod,
|
|
38
42
|
shareConfig: {
|
|
39
43
|
singleton: true,
|
|
40
|
-
requiredVersion:
|
|
41
|
-
eager:
|
|
44
|
+
requiredVersion: getMajorVersionRange(require_package.dependencies.zod),
|
|
45
|
+
eager: false,
|
|
42
46
|
strictVersion: false
|
|
43
47
|
}
|
|
44
48
|
},
|
|
@@ -46,8 +50,8 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
|
|
|
46
50
|
version: require_package.dependencies["@orpc/contract"],
|
|
47
51
|
shareConfig: {
|
|
48
52
|
singleton: true,
|
|
49
|
-
requiredVersion:
|
|
50
|
-
eager:
|
|
53
|
+
requiredVersion: getMajorVersionRange(require_package.dependencies["@orpc/contract"]),
|
|
54
|
+
eager: false,
|
|
51
55
|
strictVersion: false
|
|
52
56
|
}
|
|
53
57
|
},
|
|
@@ -55,8 +59,8 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
|
|
|
55
59
|
version: require_package.dependencies["@orpc/server"],
|
|
56
60
|
shareConfig: {
|
|
57
61
|
singleton: true,
|
|
58
|
-
requiredVersion:
|
|
59
|
-
eager:
|
|
62
|
+
requiredVersion: getMajorVersionRange(require_package.dependencies["@orpc/server"]),
|
|
63
|
+
eager: false,
|
|
60
64
|
strictVersion: false
|
|
61
65
|
}
|
|
62
66
|
}
|
|
@@ -74,30 +78,11 @@ var ModuleFederationService = class extends effect.Effect.Service()("ModuleFeder
|
|
|
74
78
|
return {
|
|
75
79
|
registerRemote: (pluginId, url) => effect.Effect.gen(function* () {
|
|
76
80
|
console.log(`[MF] Registering ${pluginId}`);
|
|
77
|
-
const
|
|
78
|
-
const manifestCheck = yield* effect.Effect.tryPromise({
|
|
79
|
-
try: async () => {
|
|
80
|
-
return (await fetch(manifestUrl, { method: "HEAD" })).ok;
|
|
81
|
-
},
|
|
82
|
-
catch: () => false
|
|
83
|
-
});
|
|
84
|
-
let entryUrl;
|
|
85
|
-
let isManifestMode = false;
|
|
86
|
-
if (manifestCheck) {
|
|
87
|
-
entryUrl = manifestUrl;
|
|
88
|
-
isManifestMode = true;
|
|
89
|
-
console.log(`[MF] Using MF 2.0 manifest mode for ${pluginId}`);
|
|
90
|
-
} else {
|
|
91
|
-
console.log(`[MF] ⚠️ Manifest not found, falling back to MF 1.5 mode for ${pluginId}`);
|
|
92
|
-
entryUrl = url;
|
|
93
|
-
isManifestMode = false;
|
|
94
|
-
}
|
|
95
|
-
const remoteName = isManifestMode ? pluginId : require_runtime_services_normalize.getNormalizedRemoteName(pluginId);
|
|
81
|
+
const remoteName = require_runtime_services_normalize.getNormalizedRemoteName(pluginId);
|
|
96
82
|
yield* effect.Effect.try({
|
|
97
83
|
try: () => mf.registerRemotes([{
|
|
98
84
|
name: remoteName,
|
|
99
|
-
entry:
|
|
100
|
-
...isManifestMode && { alias: pluginId }
|
|
85
|
+
entry: url
|
|
101
86
|
}]),
|
|
102
87
|
catch: (error) => new require_errors.ModuleFederationError({
|
|
103
88
|
pluginId,
|
|
@@ -105,7 +90,7 @@ var ModuleFederationService = class extends effect.Effect.Service()("ModuleFeder
|
|
|
105
90
|
cause: error instanceof Error ? error : new Error(String(error))
|
|
106
91
|
})
|
|
107
92
|
});
|
|
108
|
-
console.log(`[MF] ✅ Registered ${pluginId}
|
|
93
|
+
console.log(`[MF] ✅ Registered ${pluginId}`);
|
|
109
94
|
}),
|
|
110
95
|
loadRemoteConstructor: (pluginId, url) => effect.Effect.gen(function* () {
|
|
111
96
|
const remoteName = require_runtime_services_normalize.getNormalizedRemoteName(pluginId);
|
|
@@ -115,7 +100,13 @@ var ModuleFederationService = class extends effect.Effect.Service()("ModuleFeder
|
|
|
115
100
|
try: async () => {
|
|
116
101
|
const container = await mf.loadRemote(modulePath);
|
|
117
102
|
if (!container) throw new Error(`No container returned for ${modulePath}`);
|
|
118
|
-
|
|
103
|
+
let Constructor;
|
|
104
|
+
if (typeof container === "function") Constructor = container;
|
|
105
|
+
else if (container.default) Constructor = container.default;
|
|
106
|
+
else {
|
|
107
|
+
Constructor = Object.values(container).find((exp) => typeof exp === "function" && exp.binding !== void 0);
|
|
108
|
+
if (!Constructor) Constructor = Object.values(container).find((exp) => typeof exp === "function" && exp.prototype?.constructor === exp);
|
|
109
|
+
}
|
|
119
110
|
if (!Constructor || typeof Constructor !== "function") {
|
|
120
111
|
const containerInfo = typeof container === "object" ? `Available exports: ${Object.keys(container).join(", ")}` : `Container type: ${typeof container}`;
|
|
121
112
|
throw new Error(`No valid plugin constructor found for '${pluginId}'.\nSupported patterns:\n - export const YourPlugin = createPlugin({...})\n - export default createPlugin({...})\n${containerInfo}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.cjs","names":["Effect","entryUrl: string","getNormalizedRemoteName","ModuleFederationError"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import {\n\tcreateInstance,\n\tgetInstance,\n} from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = \n | (new () => AnyPlugin)\n | { default: new () => AnyPlugin };\n\nimport pkg from \"../../../package.json\";\n\nconst createModuleFederationInstance = Effect.cached(\n\tEffect.sync(() => {\n\t\ttry {\n\t\t\tlet instance = getInstance();\n\n\t\t\tif (!instance) {\n\t\t\t\tinstance = createInstance({\n\t\t\t\t\tname: \"host\",\n\t\t\t\t\tremotes: [],\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t\"every-plugin\": {\n\t\t\t\t\t\t\tversion: pkg.version,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: `^${pkg.version}`,\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow bidirectional version compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\teffect: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.effect,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^3.18.0\", // Allow any 3.18.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzod: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.zod,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^4.1.0\", // Allow any 4.1.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/contract\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/contract\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/server\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/server\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tsetGlobalFederationInstance(instance);\n\t\t\t}\n\n\t\t\treturn instance;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize Module Federation: ${error}`);\n\t\t}\n\t}),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\"ModuleFederationService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst mf = yield* Effect.flatten(createModuleFederationInstance);\n\n\t\treturn {\n\t\t\tregisterRemote: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconsole.log(`[MF] Registering ${pluginId}`);\n\n\t\t\t\t\tconst manifestUrl = url.endsWith('/')\n\t\t\t\t\t\t? `${url}mf-manifest.json`\n\t\t\t\t\t\t: `${url}/mf-manifest.json`;\n\n\t\t\t\t\t// Check if manifest is available (MF 2.0 with manifests)\n\t\t\t\t\tconst manifestCheck = yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\t\tconst response = await fetch(manifestUrl, { method: \"HEAD\" });\n\t\t\t\t\t\t\treturn response.ok;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: () => false,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet entryUrl: string;\n\t\t\t\t\tlet isManifestMode = false;\n\n\t\t\t\t\tif (manifestCheck) {\n\t\t\t\t\t\t// MF 2.0 manifest mode - use manifest URL\n\t\t\t\t\t\tentryUrl = manifestUrl;\n\t\t\t\t\t\tisManifestMode = true;\n\t\t\t\t\t\tconsole.log(`[MF] Using MF 2.0 manifest mode for ${pluginId}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback to MF 1.5 direct mode - assume URL points to remoteEntry.js\n\t\t\t\t\t\tconsole.log(`[MF] ⚠️ Manifest not found, falling back to MF 1.5 mode for ${pluginId}`);\n\t\t\t\t\t\tentryUrl = url;\n\t\t\t\t\t\tisManifestMode = false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For MF 2.0, the name can be the pluginId (alias)\n\t\t\t\t\t// The manifest will contain the actual container name\n\t\t\t\t\tconst remoteName = isManifestMode ? pluginId : getNormalizedRemoteName(pluginId);\n\n\t\t\t\t\tyield* Effect.try({\n\t\t\t\t\t\ttry: () => mf.registerRemotes([{\n\t\t\t\t\t\t\tname: remoteName,\n\t\t\t\t\t\t\tentry: entryUrl,\n\t\t\t\t\t\t\t...(isManifestMode && { alias: pluginId }) // Explicit alias for clarity\n\t\t\t\t\t\t}]),\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.log(`[MF] ✅ Registered ${pluginId} (${isManifestMode ? 'MF 2.0' : 'MF 1.5'})`);\n\t\t\t\t}),\n\n\t\t\tloadRemoteConstructor: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\t\t\t\t\tconsole.log(`[MF] Loading remote ${remoteName}`);\n\t\t\t\t\tconst modulePath = `${remoteName}/plugin`;\n\n\t\t\t\t\treturn yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\n\t\t\t\t\t\t\tconst container = await mf.loadRemote<RemoteModule>(modulePath);\n\t\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\t\tthrow new Error(`No container returned for ${modulePath}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Support multiple export patterns: direct function, default export, named exports\n\t\t\t\t\t\t\tconst Constructor =\n\t\t\t\t\t\t\t\ttypeof container === \"function\"\n\t\t\t\t\t\t\t\t\t? container // Direct function export\n\t\t\t\t\t\t\t\t\t: container.default\n\t\t\t\t\t\t\t\t\t? container.default // Default export\n\t\t\t\t\t\t\t\t\t: Object.values(container).find( // Named export fallback\n\t\t\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!Constructor || typeof Constructor !== \"function\") {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Available exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No valid plugin constructor found for '${pluginId}'.\\n` +\n\t\t\t\t\t\t\t\t\t`Supported patterns:\\n` +\n\t\t\t\t\t\t\t\t\t` - export const YourPlugin = createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t` - export default createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Validate it looks like a plugin constructor (has binding property)\n\t\t\t\t\t\t\tif (!(Constructor as any).binding) {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Found exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Invalid plugin constructor for '${pluginId}'. ` +\n\t\t\t\t\t\t\t\t\t`The exported value must be created with createPlugin(). ` +\n\t\t\t\t\t\t\t\t\t`Found a function but it's missing the required 'binding' property.\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n\t\t\t\t\t\t\treturn Constructor;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {}\n"],"mappings":";;;;;;;;;AAgBA,MAAM,iCAAiCA,cAAO,OAC7CA,cAAO,WAAW;AACjB,KAAI;EACH,IAAI,kEAAwB;AAE5B,MAAI,CAAC,UAAU;AACd,uEAA0B;IACzB,MAAM;IACN,SAAS,EAAE;IACX,QAAQ;KACP,gBAAgB;MACf;MACA,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,KAAK;MACJ,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,kBAAkB;MACjB,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,gBAAgB;MACf,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD;IACD,CAAC;AAEF,qEAA4B,SAAS;;AAGtC,SAAO;UACC,OAAO;AACf,QAAM,IAAI,MAAM,2CAA2C,QAAQ;;EAEnE,CACF;AAED,IAAa,0BAAb,cAA6CA,cAAO,SAAkC,CAAC,2BAA2B,EACjH,QAAQA,cAAO,IAAI,aAAa;CAC/B,MAAM,KAAK,OAAOA,cAAO,QAAQ,+BAA+B;AAEhE,QAAO;EACN,iBAAiB,UAAkB,QAClCA,cAAO,IAAI,aAAa;AACvB,WAAQ,IAAI,oBAAoB,WAAW;GAE3C,MAAM,cAA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AI,CAAC,eAAe,OAAO,gBAAgB,YAAY;MACtD,MAAM,gBAAgB,OAAO,cAAc,WACxC,sBAAsB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACvD,mBAAmB,OAAO;AAE7B,YAAM,IAAI,MACT,0CAA0C,SAAS,sHAIhD,gBACH;;AAIF,SAAI,CAAE,YAAoB,SAAS;MAClC,MAAM,gBAAgB,OAAO,cAAc,WACxC,kBAAkB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACnD,mBAAmB,OAAO;AAE7B,YAAM,IAAI,MACT,mCAAmC,SAAS,iIAGzC,gBACH;;AAGF,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAER,QAAQ,UACP,IAAIG,qCAAsB;KACzB;KACA,WAAW;KACX,OACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KAC1D,CAAC;IACH,CAAC;IACD;EACH;EACA,EACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"module-federation.service.cjs","names":["version","Effect","getNormalizedRemoteName","ModuleFederationError","Constructor: any"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import {\n\tcreateInstance,\n\tgetInstance,\n} from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = \n | (new () => AnyPlugin)\n | { default: new () => AnyPlugin };\n\nimport pkg from \"../../../package.json\";\n\nfunction getMajorVersionRange(version: string): string {\n\tconst match = version.match(/^[\\^~]?(\\d+)/);\n\tconst major = match ? match[1] : '0';\n\treturn `^${major}.0.0`;\n}\n\nconst createModuleFederationInstance = Effect.cached(\n\tEffect.sync(() => {\n\t\ttry {\n\t\t\tlet instance = getInstance();\n\n\t\t\tif (!instance) {\n\t\t\t\tinstance = createInstance({\n\t\t\t\t\tname: \"host\",\n\t\t\t\t\tremotes: [],\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t\"every-plugin\": {\n\t\t\t\t\t\t\tversion: pkg.version,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.version),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\teffect: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.effect,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies.effect),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzod: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.zod,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies.zod),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/contract\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/contract\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies[\"@orpc/contract\"]),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/server\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/server\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies[\"@orpc/server\"]),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tsetGlobalFederationInstance(instance);\n\t\t\t}\n\n\t\t\treturn instance;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize Module Federation: ${error}`);\n\t\t}\n\t}),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\"ModuleFederationService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst mf = yield* Effect.flatten(createModuleFederationInstance);\n\n\t\treturn {\n\t\t\tregisterRemote: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconsole.log(`[MF] Registering ${pluginId}`);\n\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\n\t\t\t\t\tyield* Effect.try({\n\t\t\t\t\t\ttry: () => mf.registerRemotes([{\n\t\t\t\t\t\t\tname: remoteName,\n\t\t\t\t\t\t\tentry: url,\n\t\t\t\t\t\t}]),\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.log(`[MF] ✅ Registered ${pluginId}`);\n\t\t\t\t}),\n\n\t\t\tloadRemoteConstructor: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\t\t\t\t\tconsole.log(`[MF] Loading remote ${remoteName}`);\n\t\t\t\t\tconst modulePath = `${remoteName}/plugin`;\n\n\t\t\t\t\treturn yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\n\t\t\t\t\t\t\tconst container = await mf.loadRemote<RemoteModule>(modulePath);\n\t\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\t\tthrow new Error(`No container returned for ${modulePath}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Support multiple export patterns: direct function, default export, named exports\n\t\t\t\t\t\t\tlet Constructor: any;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (typeof container === \"function\") {\n\t\t\t\t\t\t\t\t// Direct function export\n\t\t\t\t\t\t\t\tConstructor = container;\n\t\t\t\t\t\t\t} else if (container.default) {\n\t\t\t\t\t\t\t\t// Default export\n\t\t\t\t\t\t\t\tConstructor = container.default;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Named export fallback - prioritize exports with 'binding' property (plugin classes)\n\t\t\t\t\t\t\t\tConstructor = Object.values(container).find(\n\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && (exp as any).binding !== undefined\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t// Fallback to any function export if no binding found\n\t\t\t\t\t\t\t\tif (!Constructor) {\n\t\t\t\t\t\t\t\t\tConstructor = Object.values(container).find(\n\t\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!Constructor || typeof Constructor !== \"function\") {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Available exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No valid plugin constructor found for '${pluginId}'.\\n` +\n\t\t\t\t\t\t\t\t\t`Supported patterns:\\n` +\n\t\t\t\t\t\t\t\t\t` - export const YourPlugin = createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t` - export default createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Validate it looks like a plugin constructor (has binding property)\n\t\t\t\t\t\t\tif (!(Constructor as any).binding) {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Found exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Invalid plugin constructor for '${pluginId}'. ` +\n\t\t\t\t\t\t\t\t\t`The exported value must be created with createPlugin(). ` +\n\t\t\t\t\t\t\t\t\t`Found a function but it's missing the required 'binding' property.\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n\t\t\t\t\t\t\treturn Constructor;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {}\n"],"mappings":";;;;;;;;;AAgBA,SAAS,qBAAqB,WAAyB;CACtD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;;IAER,QAAQ,UACP,IAAID,qCAAsB;KACzB;KACA,WAAW;KACX,OACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KAC1D,CAAC;IACH,CAAC;IACD;EACH;EACA,EACF,CAAC,CAAC"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { AnyPlugin } from "../../types.cjs";
|
|
2
1
|
import { ModuleFederationError } from "../errors.cjs";
|
|
3
2
|
import { Effect } from "effect";
|
|
4
3
|
|
|
5
4
|
//#region src/runtime/services/module-federation.service.d.ts
|
|
6
5
|
declare const ModuleFederationService_base: Effect.Service.Class<ModuleFederationService, "ModuleFederationService", {
|
|
7
6
|
readonly effect: Effect.Effect<{
|
|
8
|
-
registerRemote: (pluginId: string, url: string) => Effect.Effect<void,
|
|
9
|
-
loadRemoteConstructor: (pluginId: string, url: string) => Effect.Effect<
|
|
7
|
+
registerRemote: (pluginId: string, url: string) => Effect.Effect<void, ModuleFederationError, never>;
|
|
8
|
+
loadRemoteConstructor: (pluginId: string, url: string) => Effect.Effect<any, ModuleFederationError, never>;
|
|
10
9
|
}, never, never>;
|
|
11
10
|
}>;
|
|
12
11
|
declare class ModuleFederationService extends ModuleFederationService_base {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":[],"mappings":";;;;cAOkD;;IAAA,cAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAAA,EAAA,MAAA,EAAA,GAwFD,MAAA,CAAA,MAxFC,CAAA,IAAA,EAwFD,qBAxFC,EAAA,KAAA,CAAA;8DA+GM,MAAA,CAAA,YAAA;EAvBP,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA;CAAA,CAAA;AAuBO,cA5B3C,uBAAA,SAAgC,4BAAA,CA4BW"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { AnyPlugin } from "../../types.mjs";
|
|
2
1
|
import { ModuleFederationError } from "../errors.mjs";
|
|
3
2
|
import { Effect } from "effect";
|
|
4
3
|
|
|
5
4
|
//#region src/runtime/services/module-federation.service.d.ts
|
|
6
5
|
declare const ModuleFederationService_base: Effect.Service.Class<ModuleFederationService, "ModuleFederationService", {
|
|
7
6
|
readonly effect: Effect.Effect<{
|
|
8
|
-
registerRemote: (pluginId: string, url: string) => Effect.Effect<void,
|
|
9
|
-
loadRemoteConstructor: (pluginId: string, url: string) => Effect.Effect<
|
|
7
|
+
registerRemote: (pluginId: string, url: string) => Effect.Effect<void, ModuleFederationError, never>;
|
|
8
|
+
loadRemoteConstructor: (pluginId: string, url: string) => Effect.Effect<any, ModuleFederationError, never>;
|
|
10
9
|
}, never, never>;
|
|
11
10
|
}>;
|
|
12
11
|
declare class ModuleFederationService extends ModuleFederationService_base {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":[],"mappings":";;;;cAOkD;;IAAA,cAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAAA,EAAA,MAAA,EAAA,GAwFD,MAAA,CAAA,MAxFC,CAAA,IAAA,EAwFD,qBAxFC,EAAA,KAAA,CAAA;8DA+GM,MAAA,CAAA,YAAA;EAvBP,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA;CAAA,CAAA;AAuBO,cA5B3C,uBAAA,SAAgC,4BAAA,CA4BW"}
|
|
@@ -6,6 +6,10 @@ import { createInstance, getInstance } from "@module-federation/enhanced/runtime
|
|
|
6
6
|
import { setGlobalFederationInstance } from "@module-federation/runtime-core";
|
|
7
7
|
|
|
8
8
|
//#region src/runtime/services/module-federation.service.ts
|
|
9
|
+
function getMajorVersionRange(version$1) {
|
|
10
|
+
const match = version$1.match(/^[\^~]?(\d+)/);
|
|
11
|
+
return `^${match ? match[1] : "0"}.0.0`;
|
|
12
|
+
}
|
|
9
13
|
const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
10
14
|
try {
|
|
11
15
|
let instance = getInstance();
|
|
@@ -18,8 +22,8 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
|
18
22
|
version,
|
|
19
23
|
shareConfig: {
|
|
20
24
|
singleton: true,
|
|
21
|
-
requiredVersion:
|
|
22
|
-
eager:
|
|
25
|
+
requiredVersion: getMajorVersionRange(version),
|
|
26
|
+
eager: false,
|
|
23
27
|
strictVersion: false
|
|
24
28
|
}
|
|
25
29
|
},
|
|
@@ -27,8 +31,8 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
|
27
31
|
version: dependencies.effect,
|
|
28
32
|
shareConfig: {
|
|
29
33
|
singleton: true,
|
|
30
|
-
requiredVersion:
|
|
31
|
-
eager:
|
|
34
|
+
requiredVersion: getMajorVersionRange(dependencies.effect),
|
|
35
|
+
eager: false,
|
|
32
36
|
strictVersion: false
|
|
33
37
|
}
|
|
34
38
|
},
|
|
@@ -36,8 +40,8 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
|
36
40
|
version: dependencies.zod,
|
|
37
41
|
shareConfig: {
|
|
38
42
|
singleton: true,
|
|
39
|
-
requiredVersion:
|
|
40
|
-
eager:
|
|
43
|
+
requiredVersion: getMajorVersionRange(dependencies.zod),
|
|
44
|
+
eager: false,
|
|
41
45
|
strictVersion: false
|
|
42
46
|
}
|
|
43
47
|
},
|
|
@@ -45,8 +49,8 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
|
45
49
|
version: dependencies["@orpc/contract"],
|
|
46
50
|
shareConfig: {
|
|
47
51
|
singleton: true,
|
|
48
|
-
requiredVersion: "
|
|
49
|
-
eager:
|
|
52
|
+
requiredVersion: getMajorVersionRange(dependencies["@orpc/contract"]),
|
|
53
|
+
eager: false,
|
|
50
54
|
strictVersion: false
|
|
51
55
|
}
|
|
52
56
|
},
|
|
@@ -54,8 +58,8 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
|
|
|
54
58
|
version: dependencies["@orpc/server"],
|
|
55
59
|
shareConfig: {
|
|
56
60
|
singleton: true,
|
|
57
|
-
requiredVersion: "
|
|
58
|
-
eager:
|
|
61
|
+
requiredVersion: getMajorVersionRange(dependencies["@orpc/server"]),
|
|
62
|
+
eager: false,
|
|
59
63
|
strictVersion: false
|
|
60
64
|
}
|
|
61
65
|
}
|
|
@@ -73,30 +77,11 @@ var ModuleFederationService = class extends Effect.Service()("ModuleFederationSe
|
|
|
73
77
|
return {
|
|
74
78
|
registerRemote: (pluginId, url) => Effect.gen(function* () {
|
|
75
79
|
console.log(`[MF] Registering ${pluginId}`);
|
|
76
|
-
const
|
|
77
|
-
const manifestCheck = yield* Effect.tryPromise({
|
|
78
|
-
try: async () => {
|
|
79
|
-
return (await fetch(manifestUrl, { method: "HEAD" })).ok;
|
|
80
|
-
},
|
|
81
|
-
catch: () => false
|
|
82
|
-
});
|
|
83
|
-
let entryUrl;
|
|
84
|
-
let isManifestMode = false;
|
|
85
|
-
if (manifestCheck) {
|
|
86
|
-
entryUrl = manifestUrl;
|
|
87
|
-
isManifestMode = true;
|
|
88
|
-
console.log(`[MF] Using MF 2.0 manifest mode for ${pluginId}`);
|
|
89
|
-
} else {
|
|
90
|
-
console.log(`[MF] ⚠️ Manifest not found, falling back to MF 1.5 mode for ${pluginId}`);
|
|
91
|
-
entryUrl = url;
|
|
92
|
-
isManifestMode = false;
|
|
93
|
-
}
|
|
94
|
-
const remoteName = isManifestMode ? pluginId : getNormalizedRemoteName(pluginId);
|
|
80
|
+
const remoteName = getNormalizedRemoteName(pluginId);
|
|
95
81
|
yield* Effect.try({
|
|
96
82
|
try: () => mf.registerRemotes([{
|
|
97
83
|
name: remoteName,
|
|
98
|
-
entry:
|
|
99
|
-
...isManifestMode && { alias: pluginId }
|
|
84
|
+
entry: url
|
|
100
85
|
}]),
|
|
101
86
|
catch: (error) => new ModuleFederationError({
|
|
102
87
|
pluginId,
|
|
@@ -104,7 +89,7 @@ var ModuleFederationService = class extends Effect.Service()("ModuleFederationSe
|
|
|
104
89
|
cause: error instanceof Error ? error : new Error(String(error))
|
|
105
90
|
})
|
|
106
91
|
});
|
|
107
|
-
console.log(`[MF] ✅ Registered ${pluginId}
|
|
92
|
+
console.log(`[MF] ✅ Registered ${pluginId}`);
|
|
108
93
|
}),
|
|
109
94
|
loadRemoteConstructor: (pluginId, url) => Effect.gen(function* () {
|
|
110
95
|
const remoteName = getNormalizedRemoteName(pluginId);
|
|
@@ -114,7 +99,13 @@ var ModuleFederationService = class extends Effect.Service()("ModuleFederationSe
|
|
|
114
99
|
try: async () => {
|
|
115
100
|
const container = await mf.loadRemote(modulePath);
|
|
116
101
|
if (!container) throw new Error(`No container returned for ${modulePath}`);
|
|
117
|
-
|
|
102
|
+
let Constructor;
|
|
103
|
+
if (typeof container === "function") Constructor = container;
|
|
104
|
+
else if (container.default) Constructor = container.default;
|
|
105
|
+
else {
|
|
106
|
+
Constructor = Object.values(container).find((exp) => typeof exp === "function" && exp.binding !== void 0);
|
|
107
|
+
if (!Constructor) Constructor = Object.values(container).find((exp) => typeof exp === "function" && exp.prototype?.constructor === exp);
|
|
108
|
+
}
|
|
118
109
|
if (!Constructor || typeof Constructor !== "function") {
|
|
119
110
|
const containerInfo = typeof container === "object" ? `Available exports: ${Object.keys(container).join(", ")}` : `Container type: ${typeof container}`;
|
|
120
111
|
throw new Error(`No valid plugin constructor found for '${pluginId}'.\nSupported patterns:\n - export const YourPlugin = createPlugin({...})\n - export default createPlugin({...})\n${containerInfo}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-federation.service.mjs","names":["pkg.version","entryUrl: string"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import {\n\tcreateInstance,\n\tgetInstance,\n} from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = \n | (new () => AnyPlugin)\n | { default: new () => AnyPlugin };\n\nimport pkg from \"../../../package.json\";\n\nconst createModuleFederationInstance = Effect.cached(\n\tEffect.sync(() => {\n\t\ttry {\n\t\t\tlet instance = getInstance();\n\n\t\t\tif (!instance) {\n\t\t\t\tinstance = createInstance({\n\t\t\t\t\tname: \"host\",\n\t\t\t\t\tremotes: [],\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t\"every-plugin\": {\n\t\t\t\t\t\t\tversion: pkg.version,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: `^${pkg.version}`,\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow bidirectional version compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\teffect: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.effect,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^3.18.0\", // Allow any 3.18.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzod: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.zod,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^4.1.0\", // Allow any 4.1.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/contract\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/contract\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/server\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/server\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: \"^1.8.0\", // Allow any 1.8.x patch version\n\t\t\t\t\t\t\t\teager: true,\n\t\t\t\t\t\t\t\tstrictVersion: false, // Allow version flexibility for compatibility\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tsetGlobalFederationInstance(instance);\n\t\t\t}\n\n\t\t\treturn instance;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize Module Federation: ${error}`);\n\t\t}\n\t}),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\"ModuleFederationService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst mf = yield* Effect.flatten(createModuleFederationInstance);\n\n\t\treturn {\n\t\t\tregisterRemote: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconsole.log(`[MF] Registering ${pluginId}`);\n\n\t\t\t\t\tconst manifestUrl = url.endsWith('/')\n\t\t\t\t\t\t? `${url}mf-manifest.json`\n\t\t\t\t\t\t: `${url}/mf-manifest.json`;\n\n\t\t\t\t\t// Check if manifest is available (MF 2.0 with manifests)\n\t\t\t\t\tconst manifestCheck = yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\t\t\t\t\t\t\tconst response = await fetch(manifestUrl, { method: \"HEAD\" });\n\t\t\t\t\t\t\treturn response.ok;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: () => false,\n\t\t\t\t\t});\n\n\t\t\t\t\tlet entryUrl: string;\n\t\t\t\t\tlet isManifestMode = false;\n\n\t\t\t\t\tif (manifestCheck) {\n\t\t\t\t\t\t// MF 2.0 manifest mode - use manifest URL\n\t\t\t\t\t\tentryUrl = manifestUrl;\n\t\t\t\t\t\tisManifestMode = true;\n\t\t\t\t\t\tconsole.log(`[MF] Using MF 2.0 manifest mode for ${pluginId}`);\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Fallback to MF 1.5 direct mode - assume URL points to remoteEntry.js\n\t\t\t\t\t\tconsole.log(`[MF] ⚠️ Manifest not found, falling back to MF 1.5 mode for ${pluginId}`);\n\t\t\t\t\t\tentryUrl = url;\n\t\t\t\t\t\tisManifestMode = false;\n\t\t\t\t\t}\n\n\t\t\t\t\t// For MF 2.0, the name can be the pluginId (alias)\n\t\t\t\t\t// The manifest will contain the actual container name\n\t\t\t\t\tconst remoteName = isManifestMode ? pluginId : getNormalizedRemoteName(pluginId);\n\n\t\t\t\t\tyield* Effect.try({\n\t\t\t\t\t\ttry: () => mf.registerRemotes([{\n\t\t\t\t\t\t\tname: remoteName,\n\t\t\t\t\t\t\tentry: entryUrl,\n\t\t\t\t\t\t\t...(isManifestMode && { alias: pluginId }) // Explicit alias for clarity\n\t\t\t\t\t\t}]),\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.log(`[MF] ✅ Registered ${pluginId} (${isManifestMode ? 'MF 2.0' : 'MF 1.5'})`);\n\t\t\t\t}),\n\n\t\t\tloadRemoteConstructor: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\t\t\t\t\tconsole.log(`[MF] Loading remote ${remoteName}`);\n\t\t\t\t\tconst modulePath = `${remoteName}/plugin`;\n\n\t\t\t\t\treturn yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\n\t\t\t\t\t\t\tconst container = await mf.loadRemote<RemoteModule>(modulePath);\n\t\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\t\tthrow new Error(`No container returned for ${modulePath}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Support multiple export patterns: direct function, default export, named exports\n\t\t\t\t\t\t\tconst Constructor =\n\t\t\t\t\t\t\t\ttypeof container === \"function\"\n\t\t\t\t\t\t\t\t\t? container // Direct function export\n\t\t\t\t\t\t\t\t\t: container.default\n\t\t\t\t\t\t\t\t\t? container.default // Default export\n\t\t\t\t\t\t\t\t\t: Object.values(container).find( // Named export fallback\n\t\t\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp\n\t\t\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\tif (!Constructor || typeof Constructor !== \"function\") {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Available exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No valid plugin constructor found for '${pluginId}'.\\n` +\n\t\t\t\t\t\t\t\t\t`Supported patterns:\\n` +\n\t\t\t\t\t\t\t\t\t` - export const YourPlugin = createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t` - export default createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Validate it looks like a plugin constructor (has binding property)\n\t\t\t\t\t\t\tif (!(Constructor as any).binding) {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Found exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Invalid plugin constructor for '${pluginId}'. ` +\n\t\t\t\t\t\t\t\t\t`The exported value must be created with createPlugin(). ` +\n\t\t\t\t\t\t\t\t\t`Found a function but it's missing the required 'binding' property.\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n\t\t\t\t\t\t\treturn Constructor;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {}\n"],"mappings":";;;;;;;;AAgBA,MAAM,iCAAiC,OAAO,OAC7C,OAAO,WAAW;AACjB,KAAI;EACH,IAAI,WAAW,aAAa;AAE5B,MAAI,CAAC,UAAU;AACd,cAAW,eAAe;IACzB,MAAM;IACN,SAAS,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F,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAER,QAAQ,UACP,IAAI,sBAAsB;KACzB;KACA,WAAW;KACX,OACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KAC1D,CAAC;IACH,CAAC;IACD;EACH;EACA,EACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"module-federation.service.mjs","names":["version","pkg.version","Constructor: any"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import {\n\tcreateInstance,\n\tgetInstance,\n} from \"@module-federation/enhanced/runtime\";\nimport { setGlobalFederationInstance } from \"@module-federation/runtime-core\";\nimport { Effect } from \"effect\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = \n | (new () => AnyPlugin)\n | { default: new () => AnyPlugin };\n\nimport pkg from \"../../../package.json\";\n\nfunction getMajorVersionRange(version: string): string {\n\tconst match = version.match(/^[\\^~]?(\\d+)/);\n\tconst major = match ? match[1] : '0';\n\treturn `^${major}.0.0`;\n}\n\nconst createModuleFederationInstance = Effect.cached(\n\tEffect.sync(() => {\n\t\ttry {\n\t\t\tlet instance = getInstance();\n\n\t\t\tif (!instance) {\n\t\t\t\tinstance = createInstance({\n\t\t\t\t\tname: \"host\",\n\t\t\t\t\tremotes: [],\n\t\t\t\t\tshared: {\n\t\t\t\t\t\t\"every-plugin\": {\n\t\t\t\t\t\t\tversion: pkg.version,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.version),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\teffect: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.effect,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies.effect),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tzod: {\n\t\t\t\t\t\t\tversion: pkg.dependencies.zod,\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies.zod),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/contract\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/contract\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies[\"@orpc/contract\"]),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"@orpc/server\": {\n\t\t\t\t\t\t\tversion: pkg.dependencies[\"@orpc/server\"],\n\t\t\t\t\t\t\tshareConfig: {\n\t\t\t\t\t\t\t\tsingleton: true,\n\t\t\t\t\t\t\t\trequiredVersion: getMajorVersionRange(pkg.dependencies[\"@orpc/server\"]),\n\t\t\t\t\t\t\t\teager: false,\n\t\t\t\t\t\t\t\tstrictVersion: false,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t});\n\n\t\t\t\tsetGlobalFederationInstance(instance);\n\t\t\t}\n\n\t\t\treturn instance;\n\t\t} catch (error) {\n\t\t\tthrow new Error(`Failed to initialize Module Federation: ${error}`);\n\t\t}\n\t}),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\"ModuleFederationService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst mf = yield* Effect.flatten(createModuleFederationInstance);\n\n\t\treturn {\n\t\t\tregisterRemote: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconsole.log(`[MF] Registering ${pluginId}`);\n\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\n\t\t\t\t\tyield* Effect.try({\n\t\t\t\t\t\ttry: () => mf.registerRemotes([{\n\t\t\t\t\t\t\tname: remoteName,\n\t\t\t\t\t\t\tentry: url,\n\t\t\t\t\t\t}]),\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\n\t\t\t\t\tconsole.log(`[MF] ✅ Registered ${pluginId}`);\n\t\t\t\t}),\n\n\t\t\tloadRemoteConstructor: (pluginId: string, url: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst remoteName = getNormalizedRemoteName(pluginId);\n\t\t\t\t\tconsole.log(`[MF] Loading remote ${remoteName}`);\n\t\t\t\t\tconst modulePath = `${remoteName}/plugin`;\n\n\t\t\t\t\treturn yield* Effect.tryPromise({\n\t\t\t\t\t\ttry: async () => {\n\n\t\t\t\t\t\t\tconst container = await mf.loadRemote<RemoteModule>(modulePath);\n\t\t\t\t\t\t\tif (!container) {\n\t\t\t\t\t\t\t\tthrow new Error(`No container returned for ${modulePath}`);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Support multiple export patterns: direct function, default export, named exports\n\t\t\t\t\t\t\tlet Constructor: any;\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\tif (typeof container === \"function\") {\n\t\t\t\t\t\t\t\t// Direct function export\n\t\t\t\t\t\t\t\tConstructor = container;\n\t\t\t\t\t\t\t} else if (container.default) {\n\t\t\t\t\t\t\t\t// Default export\n\t\t\t\t\t\t\t\tConstructor = container.default;\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Named export fallback - prioritize exports with 'binding' property (plugin classes)\n\t\t\t\t\t\t\t\tConstructor = Object.values(container).find(\n\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && (exp as any).binding !== undefined\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t// Fallback to any function export if no binding found\n\t\t\t\t\t\t\t\tif (!Constructor) {\n\t\t\t\t\t\t\t\t\tConstructor = Object.values(container).find(\n\t\t\t\t\t\t\t\t\t\t(exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!Constructor || typeof Constructor !== \"function\") {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Available exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`No valid plugin constructor found for '${pluginId}'.\\n` +\n\t\t\t\t\t\t\t\t\t`Supported patterns:\\n` +\n\t\t\t\t\t\t\t\t\t` - export const YourPlugin = createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t` - export default createPlugin({...})\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Validate it looks like a plugin constructor (has binding property)\n\t\t\t\t\t\t\tif (!(Constructor as any).binding) {\n\t\t\t\t\t\t\t\tconst containerInfo = typeof container === \"object\"\n\t\t\t\t\t\t\t\t\t? `Found exports: ${Object.keys(container).join(', ')}`\n\t\t\t\t\t\t\t\t\t: `Container type: ${typeof container}`;\n\n\t\t\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\t\t`Invalid plugin constructor for '${pluginId}'. ` +\n\t\t\t\t\t\t\t\t\t`The exported value must be created with createPlugin(). ` +\n\t\t\t\t\t\t\t\t\t`Found a function but it's missing the required 'binding' property.\\n` +\n\t\t\t\t\t\t\t\t\t`${containerInfo}`,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconsole.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n\t\t\t\t\t\t\treturn Constructor;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcatch: (error): ModuleFederationError =>\n\t\t\t\t\t\t\tnew ModuleFederationError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tremoteUrl: url,\n\t\t\t\t\t\t\t\tcause:\n\t\t\t\t\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}),\n\t\t};\n\t}),\n}) {}\n"],"mappings":";;;;;;;;AAgBA,SAAS,qBAAqB,WAAyB;CACtD,MAAM,QAAQA,UAAQ,MAAM,eAAe;AAE3C,QAAO,IADO,QAAQ,MAAM,KAAK,IAChB;;AAGlB,MAAM,iCAAiC,OAAO,OAC7C,OAAO,WAAW;AACjB,KAAI;EACH,IAAI,WAAW,aAAa;AAE5B,MAAI,CAAC,UAAU;AACd,cAAW,eAAe;IACzB,MAAM;IACN,SAAS,EAAE;IACX,QAAQ;KACP,gBAAgB;MACNC;MACT,aAAa;OACZ,WAAW;OACX,iBAAiB,qBAAqBA,QAAY;OAClD,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,sBAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB,k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MAAM,YAAY,MAAM,GAAG,WAAyB,WAAW;AAC/D,SAAI,CAAC,UACJ,OAAM,IAAI,MAAM,6BAA6B,aAAa;KAI3D,IAAIC;AAEJ,SAAI,OAAO,cAAc,WAExB,eAAc;cACJ,UAAU,QAEpB,eAAc,UAAU;UAClB;AAEN,oBAAc,OAAO,OAAO,UAAU,CAAC,MACrC,QAAQ,OAAO,QAAQ,cAAe,IAAY,YAAY,OAC/D;AAGD,UAAI,CAAC,YACJ,eAAc,OAAO,OAAO,UAAU,CAAC,MACrC,QAAQ,OAAO,QAAQ,cAAc,IAAI,WAAW,gBAAgB,IACrE;;AAIH,SAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY;MACtD,MAAM,gBAAgB,OAAO,cAAc,WACxC,sBAAsB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACvD,mBAAmB,OAAO;AAE7B,YAAM,IAAI,MACT,0CAA0C,SAAS,sHAIhD,gBACH;;AAIF,SAAI,CAAE,YAAoB,SAAS;MAClC,MAAM,gBAAgB,OAAO,cAAc,WACxC,kBAAkB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACnD,mBAAmB,OAAO;AAE7B,YAAM,IAAI,MACT,mCAAmC,SAAS,iIAGzC,gBACH;;AAGF,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAER,QAAQ,UACP,IAAI,sBAAsB;KACzB;KACA,WAAW;KACX,OACC,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KAC1D,CAAC;IACH,CAAC;IACD;EACH;EACA,EACF,CAAC,CAAC"}
|
|
@@ -26,7 +26,7 @@ declare class RegistryService extends RegistryService_base {}
|
|
|
26
26
|
declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService, "PluginLoaderService", {
|
|
27
27
|
readonly effect: Effect.Effect<{
|
|
28
28
|
loadPlugin: (pluginId: string) => Effect.Effect<{
|
|
29
|
-
ctor:
|
|
29
|
+
ctor: any;
|
|
30
30
|
metadata: PluginMetadata;
|
|
31
31
|
}, PluginRuntimeError, never>;
|
|
32
32
|
instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) => Effect.Effect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAemD;cAEtC,iBAAA,SAA0B,sBAAA;cAGhC;cAEM,YAAA,SAAqB,iBAAA;cAG3B;EARM,SAAA,MAAA,eAAkB,CAAA;IAGxB,GAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAakB,MAAA,CAAA,MAblB,CAAA;;gBAmCK;;;gBAUD;IA3CE,CAAA,oBAAa,EAAQ,KAAA,CAAA;IAG3B,SAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GA4CwB,MAAA,CAAA,MA5CxB,CA4CwB,oBA5CxB,GAAA,IAAA,EAAA,KAAA,EAAA,KAAA,CAAA;;;AA8BK,cA5BC,eAAA,SAAwB,oBAAA,CA4BzB;cAkBN;EAxCmB,SAAA,MAAA,eAAA,CAAA;IAoCM,UAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAkBC,MAAA,CAAA,MAlBD,CAAA;MAAA,IAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAemD;cAEtC,iBAAA,SAA0B,sBAAA;cAGhC;cAEM,YAAA,SAAqB,iBAAA;cAG3B;EARM,SAAA,MAAA,eAAkB,CAAA;IAGxB,GAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAakB,MAAA,CAAA,MAblB,CAAA;;gBAmCK;;;gBAUD;IA3CE,CAAA,oBAAa,EAAQ,KAAA,CAAA;IAG3B,SAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GA4CwB,MAAA,CAAA,MA5CxB,CA4CwB,oBA5CxB,GAAA,IAAA,EAAA,KAAA,EAAA,KAAA,CAAA;;;AA8BK,cA5BC,eAAA,SAAwB,oBAAA,CA4BzB;cAkBN;EAxCmB,SAAA,MAAA,eAAA,CAAA;IAoCM,UAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAkBC,MAAA,CAAA,MAlBD,CAAA;MAAA,IAAA,EAAA,GAAA;;;kCAiEE,2CAEf,aAAa,OAAE,MAAA,CAAA;;;IA7GpB,CAAA,oBAAgB,EAAA,KAAQ,CAAA;IA8C/B,gBAAA,EAAA,CAAA,UAsF0B,SAtF1B,CAAA,CAAA,cAAA,EAuFc,cAvFd,CAuF6B,CAvF7B,CAAA,EAAA,MAAA,EAAA;iBAwFmB,iBAAiB;eAA0C,iBAAiB;UAA+B,MAAA,CAAA;MA1EpG,MAAA,GAAA;MA+CC,QAAA,gBAAA;MAEF,MAAA,EAAA;QAAb,SAAA,mBAAA,EAAA,CAAA,cAAA,CAAA,CAAA,WAAA,CAAA,CAAA;;;;MAAe,KAAA,sBAAA;IAuBD,CAAA,oBAAA,EAAA,KAAA,CAAA;EACG,CAAA,EAAA,KAAA,yBAAA,iBAAA,kBAAA,CAAA;CAAf,CAAA;AACsB,cAtF7B,mBAAA,SAA4B,wBAAA,CAsFC"}
|
|
@@ -26,7 +26,7 @@ declare class RegistryService extends RegistryService_base {}
|
|
|
26
26
|
declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService, "PluginLoaderService", {
|
|
27
27
|
readonly effect: Effect.Effect<{
|
|
28
28
|
loadPlugin: (pluginId: string) => Effect.Effect<{
|
|
29
|
-
ctor:
|
|
29
|
+
ctor: any;
|
|
30
30
|
metadata: PluginMetadata;
|
|
31
31
|
}, PluginRuntimeError, never>;
|
|
32
32
|
instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) => Effect.Effect<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAemD;cAEtC,iBAAA,SAA0B,sBAAA;cAGhC;cAEM,YAAA,SAAqB,iBAAA;cAG3B;EARM,SAAA,MAAA,eAAkB,CAAA;IAGxB,GAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAakB,MAAA,CAAA,MAblB,CAAA;;gBAmCK;;;gBAUD;IA3CE,CAAA,oBAAa,EAAQ,KAAA,CAAA;IAG3B,SAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GA4CwB,MAAA,CAAA,MA5CxB,CA4CwB,oBA5CxB,GAAA,IAAA,EAAA,KAAA,EAAA,KAAA,CAAA;;;AA8BK,cA5BC,eAAA,SAAwB,oBAAA,CA4BzB;cAkBN;EAxCmB,SAAA,MAAA,eAAA,CAAA;IAoCM,UAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAkBC,MAAA,CAAA,MAlBD,CAAA;MAAA,IAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAemD;cAEtC,iBAAA,SAA0B,sBAAA;cAGhC;cAEM,YAAA,SAAqB,iBAAA;cAG3B;EARM,SAAA,MAAA,eAAkB,CAAA;IAGxB,GAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAakB,MAAA,CAAA,MAblB,CAAA;;gBAmCK;;;gBAUD;IA3CE,CAAA,oBAAa,EAAQ,KAAA,CAAA;IAG3B,SAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GA4CwB,MAAA,CAAA,MA5CxB,CA4CwB,oBA5CxB,GAAA,IAAA,EAAA,KAAA,EAAA,KAAA,CAAA;;;AA8BK,cA5BC,eAAA,SAAwB,oBAAA,CA4BzB;cAkBN;EAxCmB,SAAA,MAAA,eAAA,CAAA;IAoCM,UAAA,EAAA,CAAA,QAAA,EAAA,MAAA,EAAA,GAkBC,MAAA,CAAA,MAlBD,CAAA;MAAA,IAAA,EAAA,GAAA;;;kCAiEE,2CAEf,aAAa,OAAE,MAAA,CAAA;;;IA7GpB,CAAA,oBAAgB,EAAA,KAAQ,CAAA;IA8C/B,gBAAA,EAAA,CAAA,UAsF0B,SAtF1B,CAAA,CAAA,cAAA,EAuFc,cAvFd,CAuF6B,CAvF7B,CAAA,EAAA,MAAA,EAAA;iBAwFmB,iBAAiB;eAA0C,iBAAiB;UAA+B,MAAA,CAAA;MA1EpG,MAAA,GAAA;MA+CC,QAAA,gBAAA;MAEF,MAAA,EAAA;QAAb,SAAA,mBAAA,EAAA,CAAA,cAAA,CAAA,CAAA,WAAA,CAAA,CAAA;;;;MAAe,KAAA,sBAAA;IAuBD,CAAA,oBAAA,EAAA,KAAA,CAAA;EACG,CAAA,EAAA,KAAA,yBAAA,iBAAA,kBAAA,CAAA;CAAf,CAAA;AACsB,cAtF7B,mBAAA,SAA4B,wBAAA,CAsFC"}
|
|
@@ -10,7 +10,7 @@ import * as _orpc_contract0 from "@orpc/contract";
|
|
|
10
10
|
declare const PluginService_base: Effect.Service.Class<PluginService, "PluginService", {
|
|
11
11
|
readonly scoped: Effect.Effect<{
|
|
12
12
|
loadPlugin: (pluginId: string) => Effect.Effect<{
|
|
13
|
-
ctor:
|
|
13
|
+
ctor: any;
|
|
14
14
|
metadata: PluginMetadata;
|
|
15
15
|
}, PluginRuntimeError, never>;
|
|
16
16
|
instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) => Effect.Effect<{
|
|
@@ -10,7 +10,7 @@ import * as _orpc_contract0 from "@orpc/contract";
|
|
|
10
10
|
declare const PluginService_base: Effect.Service.Class<PluginService, "PluginService", {
|
|
11
11
|
readonly scoped: Effect.Effect<{
|
|
12
12
|
loadPlugin: (pluginId: string) => Effect.Effect<{
|
|
13
|
-
ctor:
|
|
13
|
+
ctor: any;
|
|
14
14
|
metadata: PluginMetadata;
|
|
15
15
|
}, PluginRuntimeError, never>;
|
|
16
16
|
instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) => Effect.Effect<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_errors = require('../errors.cjs');
|
|
3
|
-
let effect = require("effect");
|
|
4
3
|
let zod = require("zod");
|
|
4
|
+
let effect = require("effect");
|
|
5
5
|
|
|
6
6
|
//#region src/runtime/services/secrets.service.ts
|
|
7
7
|
const configSchema = zod.z.object({ secrets: zod.z.record(zod.z.string(), zod.z.unknown()) }).loose();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PluginRuntimeError } from "../errors.mjs";
|
|
2
|
-
import { Context, Effect } from "effect";
|
|
3
2
|
import { z } from "zod";
|
|
3
|
+
import { Context, Effect } from "effect";
|
|
4
4
|
|
|
5
5
|
//#region src/runtime/services/secrets.service.ts
|
|
6
6
|
const configSchema = z.object({ secrets: z.record(z.string(), z.unknown()) }).loose();
|
package/dist/types.d.cts
CHANGED
|
@@ -56,7 +56,7 @@ type ExtractPluginType<E> = E extends {
|
|
|
56
56
|
/**
|
|
57
57
|
* Infer registry types from plugin entries with module constructors
|
|
58
58
|
*/
|
|
59
|
-
type InferRegistryFromEntries<R
|
|
59
|
+
type InferRegistryFromEntries<R extends Record<string, PluginRegistryEntry>> = { [K in keyof R]: R[K] extends {
|
|
60
60
|
module: infer M;
|
|
61
61
|
} ? M : K extends keyof RegisteredPlugins ? RegisteredPlugins[K] : never };
|
|
62
62
|
/**
|
|
@@ -105,7 +105,7 @@ type PluginClientType<T> = RouterClient<PluginRouterType<T>>;
|
|
|
105
105
|
* @param K - The plugin key
|
|
106
106
|
* @param R - The registry type (defaults to RegisteredPlugins for module augmentation pattern)
|
|
107
107
|
*/
|
|
108
|
-
type RegisteredPlugin<K$1 extends keyof R
|
|
108
|
+
type RegisteredPlugin<K$1 extends keyof R, R = RegisteredPlugins> = R[K$1] extends {
|
|
109
109
|
binding: infer B;
|
|
110
110
|
} ? B extends {
|
|
111
111
|
contract: infer C extends AnyContractRouter;
|
|
@@ -177,7 +177,7 @@ interface InitializedPlugin<T extends AnyPlugin = AnyPlugin> {
|
|
|
177
177
|
/**
|
|
178
178
|
* Helper type to detect type errors when looking up RegisteredPlugins
|
|
179
179
|
*/
|
|
180
|
-
type VerifyPluginBinding<K$1 extends keyof R
|
|
180
|
+
type VerifyPluginBinding<K$1 extends keyof R, R = RegisteredPlugins> = R[K$1] extends {
|
|
181
181
|
binding: infer B;
|
|
182
182
|
} ? B extends {
|
|
183
183
|
contract: AnyContractRouter;
|
|
@@ -190,12 +190,12 @@ type VerifyPluginBinding<K$1 extends keyof R$1, R$1 = RegisteredPlugins> = R$1[K
|
|
|
190
190
|
* @param K - The plugin key
|
|
191
191
|
* @param R - The registry type (defaults to RegisteredPlugins for module augmentation pattern)
|
|
192
192
|
*/
|
|
193
|
-
type UsePluginResult<K$1 extends keyof R
|
|
194
|
-
readonly client: PluginClientType<R
|
|
195
|
-
readonly router: PluginRouterType<R
|
|
193
|
+
type UsePluginResult<K$1 extends keyof R, R = RegisteredPlugins> = VerifyPluginBinding<K$1, R> extends true ? {
|
|
194
|
+
readonly client: PluginClientType<R[K$1]>;
|
|
195
|
+
readonly router: PluginRouterType<R[K$1]>;
|
|
196
196
|
readonly metadata: PluginMetadata;
|
|
197
|
-
readonly initialized: InitializedPlugin<RegisteredPlugin<K$1, R
|
|
198
|
-
} : VerifyPluginBinding<K$1, R
|
|
197
|
+
readonly initialized: InitializedPlugin<RegisteredPlugin<K$1, R>>;
|
|
198
|
+
} : VerifyPluginBinding<K$1, R>;
|
|
199
199
|
/**
|
|
200
200
|
* Runtime options
|
|
201
201
|
*/
|
|
@@ -242,8 +242,8 @@ declare namespace EveryPlugin {
|
|
|
242
242
|
/**
|
|
243
243
|
* Plugin runtime configuration with support for both module and remote entries
|
|
244
244
|
*/
|
|
245
|
-
interface PluginRuntimeConfig<R
|
|
246
|
-
registry: R
|
|
245
|
+
interface PluginRuntimeConfig<R extends Record<string, PluginRegistryEntry> = Record<string, PluginRegistryEntry>> {
|
|
246
|
+
registry: R;
|
|
247
247
|
secrets?: SecretsConfig;
|
|
248
248
|
options?: RuntimeOptions;
|
|
249
249
|
}
|