every-plugin 0.6.2 → 0.8.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 +1 -1
- package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
- package/dist/build/rspack/dev-server-middleware.mjs +1 -1
- 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 +11 -10
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +16 -14
- package/dist/plugin.d.cts.map +1 -1
- package/dist/plugin.d.mts +17 -15
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin.mjs +11 -10
- package/dist/plugin.mjs.map +1 -1
- package/dist/runtime/index.cjs +7 -5
- package/dist/runtime/index.cjs.map +1 -1
- package/dist/runtime/index.d.cts +1 -1
- package/dist/runtime/index.d.cts.map +1 -1
- package/dist/runtime/index.d.mts +1 -1
- package/dist/runtime/index.d.mts.map +1 -1
- package/dist/runtime/index.mjs +7 -5
- package/dist/runtime/index.mjs.map +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 +29 -21
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +29 -21
- package/dist/types.d.mts.map +1 -1
- package/package.json +22 -22
|
@@ -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,aAA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AI,aAAa;GACvB,MAAM,aAAaE,2DAAwB,SAAS;AACpD,WAAQ,IAAI,uBAAuB,aAAa;GAChD,MAAM,aAAa,GAAG,WAAW;AAEjC,UAAO,OAAOF,cAAO,WAAW;IAC/B,KAAK,YAAY;KAEhB,MAAM,YAAY,MAAM,GAAG,WAAyB,WAAW;AAC/D,SAAI,CAAC,UACJ,OAAM,IAAI,MAAM,6BAA6B,aAAa;KAI3D,MAAM,cACL,OAAO,cAAc,aAClB,YACA,UAAU,UACV,UAAU,UACV,OAAO,OAAO,UAAU,CAAC,MACxB,QAAQ,OAAO,QAAQ,cAAc,IAAI,WAAW,gBAAgB,IACrE;AAEJ,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,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,MAAM,QAAQA,UAAQ,MAAM,eAAe;AAE3C,QAAO,IADO,QAAQ,MAAM,KAAK,IAChB;;AAGlB,MAAM,iCAAiCC,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,6CAAiC;OAClD,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB,kDAAsC,OAAO;OAC9D,OAAO;OACP,eAAe;OACf;MACD;KACD,KAAK;MACJ,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB,kDAAsC,IAAI;OAC3D,OAAO;OACP,eAAe;OACf;MACD;KACD,kBAAkB;MACjB,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB,kDAAsC,kBAAkB;OACzE,OAAO;OACP,eAAe;OACf;MACD;KACD,gBAAgB;MACf,sCAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB,kDAAsC,gBAAgB;OACvE,OAAO;OACP,eAAe;OACf;MACD;KACD;IACD,CAAC;AAEF,qEAA4B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AAe,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,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,EAAE;IACX,QAAQ;KACP,gBAAgB;MACNA;MACT,aAAa;OACZ,WAAW;OACX,iBAAiB,IAAIA;OACrB,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,sBAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,KAAK;MACJ,sBAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,kBAAkB;MACjB,sBAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD,gBAAgB;MACf,sBAA0B;MAC1B,aAAa;OACZ,WAAW;OACX,iBAAiB;OACjB,OAAO;OACP,eAAe;OACf;MACD;KACD;IACD,CAAC;AAEF,+BAA4B,SAAS;;AAGtC,SAAO;UACC,OAAO;AACf,QAAM,IAAI,MAAM,2CAA2C,QAAQ;;EAEnE,CACF;AAED,IAAa,0BAAb,cAA6C,OAAO,SAAkC,CAAC,2BAA2B,EACjH,QAAQ,OAAO,IAAI,aAAa;CAC/B,MAAM,KAAK,OAAO,OAAO,QAAQ,+BAA+B;AAEhE,QAAO;EACN,iBAAiB,UAAkB,QAClC,OAAO,IAAI,aAAa;AACvB,WAAQ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WAAW,gBAAgB,IACrE;AAEJ,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"}
|
|
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;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D,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;M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A4B,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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "./plugin.cjs";
|
|
2
2
|
import { Scope } from "effect";
|
|
3
3
|
import { AnyContractRouter, AnySchema, InferSchemaInput, InferSchemaOutput } from "@orpc/contract";
|
|
4
|
-
import {
|
|
4
|
+
import { Router, RouterClient } from "@orpc/server";
|
|
5
5
|
|
|
6
6
|
//#region src/types.d.ts
|
|
7
7
|
|
|
@@ -21,7 +21,7 @@ interface RegisteredPlugins {}
|
|
|
21
21
|
/**
|
|
22
22
|
* Base type for any plugin instance.
|
|
23
23
|
*/
|
|
24
|
-
type AnyPlugin = Plugin<AnyContractRouter, AnySchema, AnySchema, any>;
|
|
24
|
+
type AnyPlugin = Plugin<AnyContractRouter, AnySchema, AnySchema, AnySchema, any>;
|
|
25
25
|
/**
|
|
26
26
|
* Loaded plugin constructor with binding information
|
|
27
27
|
*/
|
|
@@ -31,7 +31,7 @@ type AnyPluginConstructor = {
|
|
|
31
31
|
contract: AnyContractRouter;
|
|
32
32
|
variables: AnySchema;
|
|
33
33
|
secrets: AnySchema;
|
|
34
|
-
context:
|
|
34
|
+
context: AnySchema;
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
37
|
/**
|
|
@@ -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
|
/**
|
|
@@ -84,11 +84,11 @@ type PluginSecrets<T> = T extends {
|
|
|
84
84
|
};
|
|
85
85
|
} ? S : never;
|
|
86
86
|
/**
|
|
87
|
-
* Extract context type from plugin binding
|
|
87
|
+
* Extract context schema type from plugin binding
|
|
88
88
|
*/
|
|
89
89
|
type PluginContext<T> = T extends {
|
|
90
90
|
binding: {
|
|
91
|
-
context: infer C extends
|
|
91
|
+
context: infer C extends AnySchema;
|
|
92
92
|
};
|
|
93
93
|
} ? C : never;
|
|
94
94
|
/**
|
|
@@ -105,14 +105,22 @@ 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;
|
|
112
112
|
variables: infer V extends AnySchema;
|
|
113
113
|
secrets: infer S extends AnySchema;
|
|
114
|
-
context: infer
|
|
115
|
-
} ? Plugin<C, V, S,
|
|
114
|
+
context: infer TRequestContext extends AnySchema;
|
|
115
|
+
} ? Plugin<C, V, S, TRequestContext, any> : never : never;
|
|
116
|
+
/**
|
|
117
|
+
* Extract plugin constructor type from registry entry
|
|
118
|
+
*/
|
|
119
|
+
type PluginConstructor<K$1 extends keyof R, R = RegisteredPlugins> = RegisteredPlugin<K$1, R>;
|
|
120
|
+
/**
|
|
121
|
+
* Extract context input type from plugin binding (for client creation)
|
|
122
|
+
*/
|
|
123
|
+
type PluginContextInput<T> = InferSchemaInput<PluginContext<T>>;
|
|
116
124
|
/**
|
|
117
125
|
* Extract config input type from plugin binding
|
|
118
126
|
*/
|
|
@@ -121,9 +129,9 @@ type PluginConfigInput<T> = {
|
|
|
121
129
|
secrets: InferSchemaInput<PluginSecrets<T>>;
|
|
122
130
|
};
|
|
123
131
|
/**
|
|
124
|
-
* Extract context type from plugin instance
|
|
132
|
+
* Extract deps context type from plugin instance (used for initialization)
|
|
125
133
|
*/
|
|
126
|
-
type ContextOf<T extends AnyPlugin> = T extends Plugin<AnyContractRouter, AnySchema, AnySchema, infer
|
|
134
|
+
type ContextOf<T extends AnyPlugin> = T extends Plugin<AnyContractRouter, AnySchema, AnySchema, AnySchema, infer TDeps> ? TDeps : never;
|
|
127
135
|
/**
|
|
128
136
|
* Plugin metadata for remote loading
|
|
129
137
|
*/
|
|
@@ -177,25 +185,25 @@ interface InitializedPlugin<T extends AnyPlugin = AnyPlugin> {
|
|
|
177
185
|
/**
|
|
178
186
|
* Helper type to detect type errors when looking up RegisteredPlugins
|
|
179
187
|
*/
|
|
180
|
-
type VerifyPluginBinding<K$1 extends keyof R
|
|
188
|
+
type VerifyPluginBinding<K$1 extends keyof R, R = RegisteredPlugins> = R[K$1] extends {
|
|
181
189
|
binding: infer B;
|
|
182
190
|
} ? B extends {
|
|
183
191
|
contract: AnyContractRouter;
|
|
184
192
|
variables: AnySchema;
|
|
185
193
|
secrets: AnySchema;
|
|
186
|
-
context:
|
|
194
|
+
context: AnySchema;
|
|
187
195
|
} ? true : `❌ Plugin "${K$1 & string}" is not properly registered. Ensure it extends plugin binding layout { contract, variables, secrets, context }.` : `❌ Plugin "${K$1 & string}" is not properly registered. Missing binding property.`;
|
|
188
196
|
/**
|
|
189
197
|
* Result of runtime.usePlugin() call
|
|
190
198
|
* @param K - The plugin key
|
|
191
199
|
* @param R - The registry type (defaults to RegisteredPlugins for module augmentation pattern)
|
|
192
200
|
*/
|
|
193
|
-
type UsePluginResult<K$1 extends keyof R
|
|
194
|
-
readonly
|
|
195
|
-
readonly router: PluginRouterType<R
|
|
201
|
+
type UsePluginResult<K$1 extends keyof R, R = RegisteredPlugins> = VerifyPluginBinding<K$1, R> extends true ? {
|
|
202
|
+
readonly createClient: (context?: PluginContextInput<R[K$1]>) => PluginClientType<R[K$1]>;
|
|
203
|
+
readonly router: PluginRouterType<R[K$1]>;
|
|
196
204
|
readonly metadata: PluginMetadata;
|
|
197
|
-
readonly initialized: InitializedPlugin<RegisteredPlugin<K$1, R
|
|
198
|
-
} : VerifyPluginBinding<K$1, R
|
|
205
|
+
readonly initialized: InitializedPlugin<RegisteredPlugin<K$1, R>>;
|
|
206
|
+
} : VerifyPluginBinding<K$1, R>;
|
|
199
207
|
/**
|
|
200
208
|
* Runtime options
|
|
201
209
|
*/
|
|
@@ -242,8 +250,8 @@ declare namespace EveryPlugin {
|
|
|
242
250
|
/**
|
|
243
251
|
* Plugin runtime configuration with support for both module and remote entries
|
|
244
252
|
*/
|
|
245
|
-
interface PluginRuntimeConfig<R
|
|
246
|
-
registry: R
|
|
253
|
+
interface PluginRuntimeConfig<R extends Record<string, PluginRegistryEntry> = Record<string, PluginRegistryEntry>> {
|
|
254
|
+
registry: R;
|
|
247
255
|
secrets?: SecretsConfig;
|
|
248
256
|
options?: RuntimeOptions;
|
|
249
257
|
}
|
|
@@ -257,5 +265,5 @@ interface LegacyPluginRuntimeConfig {
|
|
|
257
265
|
options?: RuntimeOptions;
|
|
258
266
|
}
|
|
259
267
|
//#endregion
|
|
260
|
-
export { AnyPlugin, AnyPluginConstructor, ContextOf, EveryPlugin, ExtractPluginType, InferRegistryFromEntries, InitializedPlugin, LegacyPluginRuntimeConfig, LoadedPlugin, PluginClientType, PluginConfigInput, PluginContext, PluginContract, PluginInstance, PluginMetadata, PluginMetadataRegistry, PluginRegistry, PluginRegistryEntry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugin, RegisteredPlugins, RuntimeOptions, SecretsConfig, UsePluginResult };
|
|
268
|
+
export { AnyPlugin, AnyPluginConstructor, ContextOf, EveryPlugin, ExtractPluginType, InferRegistryFromEntries, InitializedPlugin, LegacyPluginRuntimeConfig, LoadedPlugin, PluginClientType, PluginConfigInput, PluginConstructor, PluginContext, PluginContextInput, PluginContract, PluginInstance, PluginMetadata, PluginMetadataRegistry, PluginRegistry, PluginRegistryEntry, PluginRouterType, PluginRuntimeConfig, PluginSecrets, PluginVariables, RegisteredPlugin, RegisteredPlugins, RuntimeOptions, SecretsConfig, UsePluginResult };
|
|
261
269
|
//# sourceMappingURL=types.d.cts.map
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkBA;AAKA
|
|
1
|
+
{"version":3,"file":"types.d.cts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAkBA;AAKA;;;;;;;AAKA;;AAGY,UAbK,iBAAA,CAaL;;;;AAUA,KAlBA,SAAA,GAAY,MAkBO,CAlBA,iBAmBlB,EAnBqC,SAmBjB,EAnB4B,SAmB5B,EAnBuC,SAmBvC,EAAA,GAAA,CAAA;AAMjC;AAKA;;AAA+C,KAzBnC,oBAAA,GAyBmC;EAClC,MAAA,EAzBL,SAyBK;EAAI,OAAA,EAAA;IAAE,QAAA,EAvBP,iBAuBO;IACjB,SAAA,EAvBW,SAuBX;IAAgB,OAAA,EAtBP,SAsBO;IAAoB,OAAA,EArB3B,SAqB2B;EAAkB,CAAA;CAAC;AAMzD;AAKA;AAKA;AAKY,KAnCA,mBAAA,GAmCmB;EAMnB,MAAA,EAxCC,oBAwCe;EAA4B,MAAA,CAAA,EAAA,MAAA;EAAf,OAAA,CAAA,EAAA,MAAA;EAAP,WAAA,CAAA,EAAA,MAAA;CAAM,GAAA;EAK5B,MAAA,EAAA,MAAA;EAAoD,OAAA,CAAA,EAAA,MAAA;EAAjB,WAAA,CAAA,EAAA,MAAA;CAAb;;AAOlC;;AAAoD,KA9CxC,iBA8CwC,CAAA,CAAA,CAAA,GA9CjB,CA8CiB,SAAA;EAClD,MAAA,EAAA,KAAA,EAAA;CAAE,GAAA,CAAA,GAAA,KAAA;;;;AAKuC,KA/C/B,wBA+C+B,CAAA,UA/CI,MA+CJ,CAAA,MAAA,EA/CmB,mBA+CnB,CAAA,CAAA,GAAA,QAEhC,MAhDE,CAgDF,GAhDM,CAgDN,CAhDQ,CAgDR,CAAA,SAAA;EAAG,MAAA,EAAA,KAAA,EAAA;AAAG,CAAA,GAAA,CAAA,GA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