every-plugin 0.9.0 → 2.2.3

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.
Files changed (179) hide show
  1. package/dist/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +15 -1
  2. package/dist/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +15 -2
  3. package/dist/build/rspack/dev-server-middleware.cjs +15 -4
  4. package/dist/build/rspack/dev-server-middleware.cjs.map +1 -1
  5. package/dist/build/rspack/dev-server-middleware.mjs +15 -4
  6. package/dist/build/rspack/dev-server-middleware.mjs.map +1 -1
  7. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +44 -0
  8. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -0
  9. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +11 -0
  10. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -0
  11. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +11 -0
  12. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -0
  13. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +43 -0
  14. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -0
  15. package/dist/build/rspack/index.cjs +8 -4
  16. package/dist/build/rspack/index.d.cts +3 -2
  17. package/dist/build/rspack/index.d.mts +3 -2
  18. package/dist/build/rspack/index.mjs +3 -2
  19. package/dist/build/rspack/module-federation.cjs +3 -3
  20. package/dist/build/rspack/module-federation.cjs.map +1 -1
  21. package/dist/build/rspack/module-federation.mjs +1 -1
  22. package/dist/build/rspack/module-federation.mjs.map +1 -1
  23. package/dist/build/rspack/plugin.cjs +83 -5
  24. package/dist/build/rspack/plugin.cjs.map +1 -1
  25. package/dist/build/rspack/plugin.d.cts +12 -1
  26. package/dist/build/rspack/plugin.d.cts.map +1 -1
  27. package/dist/build/rspack/plugin.d.mts +12 -1
  28. package/dist/build/rspack/plugin.d.mts.map +1 -1
  29. package/dist/build/rspack/plugin.mjs +80 -5
  30. package/dist/build/rspack/plugin.mjs.map +1 -1
  31. package/dist/build/rspack/utils.cjs +5 -4
  32. package/dist/build/rspack/utils.cjs.map +1 -1
  33. package/dist/build/rspack/utils.mjs +3 -2
  34. package/dist/build/rspack/utils.mjs.map +1 -1
  35. package/dist/build/shared-deps.cjs +50 -42
  36. package/dist/build/shared-deps.cjs.map +1 -1
  37. package/dist/build/shared-deps.d.cts +27 -2
  38. package/dist/build/shared-deps.d.cts.map +1 -1
  39. package/dist/build/shared-deps.d.mts +27 -2
  40. package/dist/build/shared-deps.d.mts.map +1 -1
  41. package/dist/build/shared-deps.mjs +48 -43
  42. package/dist/build/shared-deps.mjs.map +1 -1
  43. package/dist/errors.cjs +1 -0
  44. package/dist/errors.cjs.map +1 -1
  45. package/dist/errors.d.cts.map +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs.map +1 -1
  48. package/dist/index.cjs +2 -0
  49. package/dist/index.d.cts +2 -2
  50. package/dist/index.d.mts +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/orpc-client.cjs +17 -0
  53. package/dist/orpc-client.d.cts +2 -0
  54. package/dist/orpc-client.d.mts +2 -0
  55. package/dist/orpc-client.mjs +5 -0
  56. package/dist/orpc-openapi.cjs +17 -0
  57. package/dist/orpc-openapi.d.cts +2 -0
  58. package/dist/orpc-openapi.d.mts +2 -0
  59. package/dist/orpc-openapi.mjs +5 -0
  60. package/dist/orpc.cjs +8 -7
  61. package/dist/plugin.cjs +9 -7
  62. package/dist/plugin.cjs.map +1 -1
  63. package/dist/plugin.d.cts +23 -24
  64. package/dist/plugin.d.cts.map +1 -1
  65. package/dist/plugin.d.mts +23 -24
  66. package/dist/plugin.d.mts.map +1 -1
  67. package/dist/plugin.mjs +8 -7
  68. package/dist/plugin.mjs.map +1 -1
  69. package/dist/runtime/errors.cjs +2 -2
  70. package/dist/runtime/errors.cjs.map +1 -1
  71. package/dist/runtime/errors.d.cts +4 -4
  72. package/dist/runtime/errors.d.cts.map +1 -1
  73. package/dist/runtime/errors.d.mts +4 -4
  74. package/dist/runtime/errors.d.mts.map +1 -1
  75. package/dist/runtime/errors.mjs +1 -1
  76. package/dist/runtime/errors.mjs.map +1 -1
  77. package/dist/runtime/index.cjs +41 -37
  78. package/dist/runtime/index.cjs.map +1 -1
  79. package/dist/runtime/index.d.cts +3 -3
  80. package/dist/runtime/index.d.cts.map +1 -1
  81. package/dist/runtime/index.d.mts +3 -3
  82. package/dist/runtime/index.d.mts.map +1 -1
  83. package/dist/runtime/index.mjs +12 -9
  84. package/dist/runtime/index.mjs.map +1 -1
  85. package/dist/runtime/mf-config.cjs +33 -0
  86. package/dist/runtime/mf-config.cjs.map +1 -0
  87. package/dist/runtime/mf-config.d.cts +41 -0
  88. package/dist/runtime/mf-config.d.cts.map +1 -0
  89. package/dist/runtime/mf-config.d.mts +41 -0
  90. package/dist/runtime/mf-config.d.mts.map +1 -0
  91. package/dist/runtime/mf-config.mjs +29 -0
  92. package/dist/runtime/mf-config.mjs.map +1 -0
  93. package/dist/runtime/services/module-federation.service.cjs +19 -56
  94. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  95. package/dist/runtime/services/module-federation.service.d.cts.map +1 -1
  96. package/dist/runtime/services/module-federation.service.d.mts.map +1 -1
  97. package/dist/runtime/services/module-federation.service.mjs +18 -55
  98. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  99. package/dist/runtime/services/normalize.cjs +3 -2
  100. package/dist/runtime/services/normalize.cjs.map +1 -1
  101. package/dist/runtime/services/normalize.mjs +2 -2
  102. package/dist/runtime/services/normalize.mjs.map +1 -1
  103. package/dist/runtime/services/plugin-lifecycle.service.cjs +1 -1
  104. package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
  105. package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +1 -1
  106. package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +1 -1
  107. package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
  108. package/dist/runtime/services/plugin-loader.service.cjs +3 -3
  109. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  110. package/dist/runtime/services/plugin-loader.service.d.cts +1 -1
  111. package/dist/runtime/services/plugin-loader.service.d.cts.map +1 -1
  112. package/dist/runtime/services/plugin-loader.service.d.mts +1 -1
  113. package/dist/runtime/services/plugin-loader.service.d.mts.map +1 -1
  114. package/dist/runtime/services/plugin-loader.service.mjs +2 -2
  115. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  116. package/dist/runtime/services/plugin.service.cjs +1 -1
  117. package/dist/runtime/services/plugin.service.cjs.map +1 -1
  118. package/dist/runtime/services/plugin.service.d.cts +6 -7
  119. package/dist/runtime/services/plugin.service.d.cts.map +1 -1
  120. package/dist/runtime/services/plugin.service.d.mts +6 -7
  121. package/dist/runtime/services/plugin.service.d.mts.map +1 -1
  122. package/dist/runtime/services/plugin.service.mjs.map +1 -1
  123. package/dist/runtime/services/secrets.service.cjs +1 -1
  124. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  125. package/dist/runtime/services/secrets.service.d.cts.map +1 -1
  126. package/dist/runtime/services/secrets.service.d.mts.map +1 -1
  127. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  128. package/dist/runtime/validation.cjs +1 -1
  129. package/dist/runtime/validation.cjs.map +1 -1
  130. package/dist/runtime/validation.mjs.map +1 -1
  131. package/dist/testing/index.cjs +2 -1
  132. package/dist/testing/index.cjs.map +1 -1
  133. package/dist/testing/index.d.cts +0 -2
  134. package/dist/testing/index.d.cts.map +1 -1
  135. package/dist/testing/index.d.mts +0 -2
  136. package/dist/testing/index.d.mts.map +1 -1
  137. package/dist/testing/index.mjs +1 -1
  138. package/dist/testing/index.mjs.map +1 -1
  139. package/dist/types.d.cts +6 -6
  140. package/dist/types.d.cts.map +1 -1
  141. package/dist/types.d.mts +6 -6
  142. package/dist/types.d.mts.map +1 -1
  143. package/dist/zod.cjs +4 -3
  144. package/dist/zod.mjs +2 -2
  145. package/package.json +200 -182
  146. package/src/build/rspack/dev-server-middleware.ts +233 -0
  147. package/src/build/rspack/fix-mf-data-uri-plugin.ts +49 -0
  148. package/src/build/rspack/index.ts +14 -0
  149. package/src/build/rspack/module-federation.ts +6 -0
  150. package/src/build/rspack/plugin.ts +252 -0
  151. package/src/build/rspack/utils.ts +60 -0
  152. package/src/build/shared-deps.ts +79 -0
  153. package/src/effect.ts +1 -0
  154. package/src/errors.ts +140 -0
  155. package/src/index.ts +26 -0
  156. package/src/orpc-client.ts +2 -0
  157. package/src/orpc-openapi.ts +2 -0
  158. package/src/orpc.ts +9 -0
  159. package/src/plugin.ts +220 -0
  160. package/src/runtime/errors.ts +332 -0
  161. package/src/runtime/index.ts +258 -0
  162. package/src/runtime/mf-config.ts +39 -0
  163. package/src/runtime/services/module-federation.service.ts +181 -0
  164. package/src/runtime/services/normalize.ts +18 -0
  165. package/src/runtime/services/plugin-lifecycle.service.ts +86 -0
  166. package/src/runtime/services/plugin-loader.service.ts +254 -0
  167. package/src/runtime/services/plugin.service.ts +66 -0
  168. package/src/runtime/services/secrets.service.ts +74 -0
  169. package/src/runtime/services.ts +5 -0
  170. package/src/runtime/validation.ts +23 -0
  171. package/src/testing/index.ts +87 -0
  172. package/src/testing/mocks/module-federation.service.ts +41 -0
  173. package/src/types.ts +309 -0
  174. package/src/zod-core.ts +4 -0
  175. package/src/zod.ts +1 -0
  176. package/dist/package.cjs +0 -45
  177. package/dist/package.cjs.map +0 -1
  178. package/dist/package.mjs +0 -27
  179. package/dist/package.mjs.map +0 -1
@@ -1,13 +1,17 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
2
  const require_errors = require('../errors.cjs');
3
- const require_package = require('../../package.cjs');
4
- const require_shared_deps = require('../../build/shared-deps.cjs');
3
+ const require_runtime_mf_config = require('../mf-config.cjs');
5
4
  const require_runtime_services_normalize = require('./normalize.cjs');
6
5
  let effect = require("effect");
7
6
  let _module_federation_enhanced_runtime = require("@module-federation/enhanced/runtime");
8
7
  let _module_federation_runtime_core = require("@module-federation/runtime-core");
9
8
 
10
9
  //#region src/runtime/services/module-federation.service.ts
10
+ const sharedModuleLoaders = {
11
+ "every-plugin": () => Promise.resolve().then(() => require("../../index.cjs")),
12
+ effect: () => import("effect"),
13
+ zod: () => import("zod")
14
+ };
11
15
  const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync(() => {
12
16
  try {
13
17
  let instance = (0, _module_federation_enhanced_runtime.getInstance)();
@@ -15,58 +19,15 @@ const createModuleFederationInstance = effect.Effect.cached(effect.Effect.sync((
15
19
  instance = (0, _module_federation_enhanced_runtime.createInstance)({
16
20
  name: "host",
17
21
  remotes: [],
18
- shared: {
19
- "every-plugin": {
20
- version: require_package.version,
21
- get: () => Promise.resolve().then(() => require("../../index.cjs")).then((mod) => () => mod),
22
- shareConfig: {
23
- singleton: true,
24
- requiredVersion: require_shared_deps.getMajorMinorVersion(require_package.version),
25
- eager: false,
26
- strictVersion: false
27
- }
28
- },
29
- effect: {
30
- version: require_package.peerDependencies.effect,
31
- get: () => import("effect").then((mod) => () => mod),
32
- shareConfig: {
33
- singleton: true,
34
- requiredVersion: require_shared_deps.getMajorMinorVersion(require_package.peerDependencies.effect),
35
- eager: false,
36
- strictVersion: false
37
- }
38
- },
39
- zod: {
40
- version: require_package.peerDependencies.zod,
41
- get: () => import("zod").then((mod) => () => mod),
42
- shareConfig: {
43
- singleton: true,
44
- requiredVersion: require_shared_deps.getMajorMinorVersion(require_package.peerDependencies.zod),
45
- eager: false,
46
- strictVersion: false
47
- }
48
- },
49
- "@orpc/contract": {
50
- version: require_package.dependencies["@orpc/contract"],
51
- get: () => import("@orpc/contract").then((mod) => () => mod),
52
- shareConfig: {
53
- singleton: true,
54
- requiredVersion: require_shared_deps.getMajorMinorVersion(require_package.dependencies["@orpc/contract"]),
55
- eager: false,
56
- strictVersion: false
57
- }
58
- },
59
- "@orpc/server": {
60
- version: require_package.dependencies["@orpc/server"],
61
- get: () => import("@orpc/server").then((mod) => () => mod),
62
- shareConfig: {
63
- singleton: true,
64
- requiredVersion: require_shared_deps.getMajorMinorVersion(require_package.dependencies["@orpc/server"]),
65
- eager: false,
66
- strictVersion: false
67
- }
68
- }
69
- }
22
+ shared: Object.fromEntries(Object.entries(require_runtime_mf_config.MF_SHARED_DEPS).map(([name, config]) => {
23
+ const load = sharedModuleLoaders[name];
24
+ if (!load) throw new Error(`Missing shared module loader for ${name}`);
25
+ return [name, {
26
+ version: config.version,
27
+ get: () => load().then((mod) => () => mod),
28
+ shareConfig: config.shareConfig
29
+ }];
30
+ }))
70
31
  });
71
32
  (0, _module_federation_runtime_core.setGlobalFederationInstance)(instance);
72
33
  }
@@ -81,10 +42,12 @@ var ModuleFederationService = class extends effect.Effect.Service()("ModuleFeder
81
42
  registerRemote: (pluginId, url) => effect.Effect.gen(function* () {
82
43
  console.log(`[MF] Registering ${pluginId}`);
83
44
  const remoteName = require_runtime_services_normalize.getNormalizedRemoteName(pluginId);
45
+ const type = url.endsWith("/mf-manifest.json") ? "manifest" : url.endsWith("/remoteEntry.js") ? "script" : void 0;
84
46
  yield* effect.Effect.try({
85
47
  try: () => mf.registerRemotes([{
86
48
  name: remoteName,
87
- entry: url
49
+ entry: url,
50
+ ...type ? { type } : {}
88
51
  }]),
89
52
  catch: (error) => new require_errors.ModuleFederationError({
90
53
  pluginId,
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.service.cjs","names":["Effect","getMajorMinorVersion","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 { getMajorMinorVersion } from \"../../build/shared-deps\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule =\n\t| (new () => AnyPlugin)\n\t| { 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\tget: () => import(\"every-plugin\").then(mod => () => mod),\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: getMajorMinorVersion(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.peerDependencies.effect,\n\t\t\t\t\t\t\tget: () => import(\"effect\").then(mod => () => mod),\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: getMajorMinorVersion(pkg.peerDependencies.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.peerDependencies.zod,\n\t\t\t\t\t\t\tget: () => import(\"zod\").then(mod => () => mod),\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: getMajorMinorVersion(pkg.peerDependencies.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\tget: () => import(\"@orpc/contract\").then(mod => () => mod),\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: getMajorMinorVersion(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\tget: () => import(\"@orpc/server\").then(mod => () => mod),\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: getMajorMinorVersion(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\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\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":";;;;;;;;;;AAiBA,MAAM,iCAAiCA,cAAO,OAC7CA,cAAO,WAAW;AACjB,KAAI;EACH,IAAI,iEAAwB;AAE5B,MAAI,CAAC,UAAU;AACd,sEAA0B;IACzB,MAAM;IACN,SAAS,EAAE;IACX,QAAQ;KACP,gBAAgB;MACf;MACA,gDAAW,oBAAuB,MAAK,cAAa,IAAI;MACxD,aAAa;OACZ,WAAW;OACX,iBAAiBC,iEAAiC;OAClD,OAAO;OACP,eAAe;OACf;MACD;KACD,QAAQ;MACP,0CAA8B;MAC9B,WAAW,OAAO,UAAU,MAAK,cAAa,IAAI;MAClD,aAAa;OACZ,WAAW;OACX,iBAAiBA,0EAA0C,OAAO;OAClE,OAAO;OACP,eAAe;OACf;MACD;KACD,KAAK;MACJ,0CAA8B;MAC9B,WAAW,OAAO,OAAO,MAAK,cAAa,IAAI;MAC/C,aAAa;OACZ,WAAW;OACX,iBAAiBA,0EAA0C,IAAI;OAC/D,OAAO;OACP,eAAe;OACf;MACD;KACD,kBAAkB;MACjB,sCAA0B;MAC1B,WAAW,OAAO,kBAAkB,MAAK,cAAa,IAAI;MAC1D,aAAa;OACZ,WAAW;OACX,iBAAiBA,sEAAsC,kBAAkB;OACzE,OAAO;OACP,eAAe;OACf;MACD;KACD,g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C,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,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":["Effect","MF_SHARED_DEPS","getNormalizedRemoteName","ModuleFederationError"],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import { createInstance, getInstance } 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 { MF_SHARED_DEPS, type SharedDepName } from \"../mf-config\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = (new () => AnyPlugin) | { default: new () => AnyPlugin };\n\nconst sharedModuleLoaders = {\n \"every-plugin\": () => import(\"every-plugin\"),\n effect: () => import(\"effect\"),\n zod: () => import(\"zod\"),\n} satisfies Record<SharedDepName, () => Promise<unknown>>;\n\nconst createModuleFederationInstance = Effect.cached(\n Effect.sync(() => {\n try {\n let instance = getInstance();\n\n if (!instance) {\n const shared = Object.fromEntries(\n (\n Object.entries(MF_SHARED_DEPS) as [\n SharedDepName,\n (typeof MF_SHARED_DEPS)[SharedDepName],\n ][]\n ).map(([name, config]) => {\n const load = sharedModuleLoaders[name];\n\n if (!load) {\n throw new Error(`Missing shared module loader for ${name}`);\n }\n\n return [\n name,\n {\n version: config.version,\n get: () => load().then((mod) => () => mod),\n shareConfig: config.shareConfig,\n },\n ];\n }),\n );\n\n instance = createInstance({\n name: \"host\",\n remotes: [],\n shared,\n });\n\n setGlobalFederationInstance(instance);\n }\n\n return instance;\n } catch (error) {\n throw new Error(`Failed to initialize Module Federation: ${error}`);\n }\n }),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\n \"ModuleFederationService\",\n {\n effect: Effect.gen(function* () {\n const mf = yield* Effect.flatten(createModuleFederationInstance);\n\n return {\n registerRemote: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n console.log(`[MF] Registering ${pluginId}`);\n\n const remoteName = getNormalizedRemoteName(pluginId);\n const type = url.endsWith(\"/mf-manifest.json\")\n ? (\"manifest\" as const)\n : url.endsWith(\"/remoteEntry.js\")\n ? (\"script\" as const)\n : undefined;\n\n yield* Effect.try({\n try: () =>\n mf.registerRemotes([\n {\n name: remoteName,\n entry: url,\n ...(type ? { type } : {}),\n },\n ]),\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n\n console.log(`[MF] ✅ Registered ${pluginId}`);\n }),\n\n loadRemoteConstructor: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n const remoteName = getNormalizedRemoteName(pluginId);\n console.log(`[MF] Loading remote ${remoteName}`);\n const modulePath = `${remoteName}/plugin`;\n\n return yield* Effect.tryPromise({\n try: async () => {\n const container = await mf.loadRemote<RemoteModule>(modulePath);\n if (!container) {\n throw new Error(`No container returned for ${modulePath}`);\n }\n\n // Support multiple export patterns: direct function, default export, named exports\n let Constructor: any;\n\n if (typeof container === \"function\") {\n // Direct function export\n Constructor = container;\n } else if (container.default) {\n // Default export\n Constructor = container.default;\n } else {\n // Named export fallback - prioritize exports with 'binding' property (plugin classes)\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && (exp as any).binding !== undefined,\n );\n\n // Fallback to any function export if no binding found\n if (!Constructor) {\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp,\n );\n }\n }\n\n if (!Constructor || typeof Constructor !== \"function\") {\n const containerInfo =\n typeof container === \"object\"\n ? `Available exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `No valid plugin constructor found for '${pluginId}'.\\n` +\n `Supported patterns:\\n` +\n ` - export const YourPlugin = createPlugin({...})\\n` +\n ` - export default createPlugin({...})\\n` +\n `${containerInfo}`,\n );\n }\n\n // Validate it looks like a plugin constructor (has binding property)\n if (!(Constructor as any).binding) {\n const containerInfo =\n typeof container === \"object\"\n ? `Found exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `Invalid plugin constructor for '${pluginId}'. ` +\n `The exported value must be created with createPlugin(). ` +\n `Found a function but it's missing the required 'binding' property.\\n` +\n `${containerInfo}`,\n );\n }\n\n console.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n return Constructor;\n },\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;;AAUA,MAAM,sBAAsB;CAC1B,2DAAsB;CACtB,cAAc,OAAO;CACrB,WAAW,OAAO;CACnB;AAED,MAAM,iCAAiCA,cAAO,OAC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AwB,SAAS;AACpD,WAAQ,IAAI,uBAAuB,aAAa;GAChD,MAAM,aAAa,GAAG,WAAW;AAEjC,UAAO,OAAOF,cAAO,WAAW;IAC9B,KAAK,YAAY;KACf,MAAM,YAAY,MAAM,GAAG,WAAyB,WAAW;AAC/D,SAAI,CAAC,UACH,OAAM,IAAI,MAAM,6BAA6B,aAAa;KAI5D,IAAI;AAEJ,SAAI,OAAO,cAAc,WAEvB,eAAc;cACL,UAAU,QAEnB,eAAc,UAAU;UACnB;AAEL,oBAAc,OAAO,OAAO,UAAU,CAAC,MACpC,QAAQ,OAAO,QAAQ,cAAe,IAAY,YAAY,OAChE;AAGD,UAAI,CAAC,YACH,eAAc,OAAO,OAAO,UAAU,CAAC,MACpC,QAAQ,OAAO,QAAQ,cAAc,IAAI,WAAW,gBAAgB,IACtE;;AAIL,SAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY;MACrD,MAAM,gBACJ,OAAO,cAAc,WACjB,sBAAsB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACvD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,0CAA0C,SAAS,sHAI9C,gBACN;;AAIH,SAAI,CAAE,YAAoB,SAAS;MACjC,MAAM,gBACJ,OAAO,cAAc,WACjB,kBAAkB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACnD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,mCAAmC,SAAS,iIAGvC,gBACN;;AAGH,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAET,QAAQ,UACN,IAAIG,qCAAsB;KACxB;KACA,WAAW;KACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KACjE,CAAC;IACL,CAAC;IACF;EACL;EACD,EACH,CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAQkD,4BAAA;;uCAuFd,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CAuBN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cA5B3C,uBAAA,SAAgC,4BAAA"}
1
+ {"version":3,"file":"module-federation.service.d.cts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;uCAiET,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CA+BN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cAtChD,uBAAA,SAAgC,4BAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAQkD,4BAAA;;uCAuFd,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CAuBN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cA5B3C,uBAAA,SAAgC,4BAAA"}
1
+ {"version":3,"file":"module-federation.service.d.mts","names":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"mappings":";;;;cAIkD,4BAAA;;uCAiET,GAAA,aAAa,MAAA,CAAA,MAAA,OAAA,qBAAA;8CA+BN,GAAA,aAAa,MAAA,CAAA,MAAA,MAAA,qBAAA;EAAA;AAAA;AAAA,cAtChD,uBAAA,SAAgC,4BAAA"}
@@ -1,12 +1,16 @@
1
1
  import { ModuleFederationError } from "../errors.mjs";
2
- import { dependencies, peerDependencies, version } from "../../package.mjs";
3
- import { getMajorMinorVersion } from "../../build/shared-deps.mjs";
2
+ import { MF_SHARED_DEPS } from "../mf-config.mjs";
4
3
  import { getNormalizedRemoteName } from "./normalize.mjs";
5
4
  import { Effect } from "effect";
6
5
  import { createInstance, getInstance } from "@module-federation/enhanced/runtime";
7
6
  import { setGlobalFederationInstance } from "@module-federation/runtime-core";
8
7
 
9
8
  //#region src/runtime/services/module-federation.service.ts
9
+ const sharedModuleLoaders = {
10
+ "every-plugin": () => import("../../index.mjs"),
11
+ effect: () => import("effect"),
12
+ zod: () => import("zod")
13
+ };
10
14
  const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
11
15
  try {
12
16
  let instance = getInstance();
@@ -14,58 +18,15 @@ const createModuleFederationInstance = Effect.cached(Effect.sync(() => {
14
18
  instance = createInstance({
15
19
  name: "host",
16
20
  remotes: [],
17
- shared: {
18
- "every-plugin": {
19
- version,
20
- get: () => import("../../index.mjs").then((mod) => () => mod),
21
- shareConfig: {
22
- singleton: true,
23
- requiredVersion: getMajorMinorVersion(version),
24
- eager: false,
25
- strictVersion: false
26
- }
27
- },
28
- effect: {
29
- version: peerDependencies.effect,
30
- get: () => import("effect").then((mod) => () => mod),
31
- shareConfig: {
32
- singleton: true,
33
- requiredVersion: getMajorMinorVersion(peerDependencies.effect),
34
- eager: false,
35
- strictVersion: false
36
- }
37
- },
38
- zod: {
39
- version: peerDependencies.zod,
40
- get: () => import("zod").then((mod) => () => mod),
41
- shareConfig: {
42
- singleton: true,
43
- requiredVersion: getMajorMinorVersion(peerDependencies.zod),
44
- eager: false,
45
- strictVersion: false
46
- }
47
- },
48
- "@orpc/contract": {
49
- version: dependencies["@orpc/contract"],
50
- get: () => import("@orpc/contract").then((mod) => () => mod),
51
- shareConfig: {
52
- singleton: true,
53
- requiredVersion: getMajorMinorVersion(dependencies["@orpc/contract"]),
54
- eager: false,
55
- strictVersion: false
56
- }
57
- },
58
- "@orpc/server": {
59
- version: dependencies["@orpc/server"],
60
- get: () => import("@orpc/server").then((mod) => () => mod),
61
- shareConfig: {
62
- singleton: true,
63
- requiredVersion: getMajorMinorVersion(dependencies["@orpc/server"]),
64
- eager: false,
65
- strictVersion: false
66
- }
67
- }
68
- }
21
+ shared: Object.fromEntries(Object.entries(MF_SHARED_DEPS).map(([name, config]) => {
22
+ const load = sharedModuleLoaders[name];
23
+ if (!load) throw new Error(`Missing shared module loader for ${name}`);
24
+ return [name, {
25
+ version: config.version,
26
+ get: () => load().then((mod) => () => mod),
27
+ shareConfig: config.shareConfig
28
+ }];
29
+ }))
69
30
  });
70
31
  setGlobalFederationInstance(instance);
71
32
  }
@@ -80,10 +41,12 @@ var ModuleFederationService = class extends Effect.Service()("ModuleFederationSe
80
41
  registerRemote: (pluginId, url) => Effect.gen(function* () {
81
42
  console.log(`[MF] Registering ${pluginId}`);
82
43
  const remoteName = getNormalizedRemoteName(pluginId);
44
+ const type = url.endsWith("/mf-manifest.json") ? "manifest" : url.endsWith("/remoteEntry.js") ? "script" : void 0;
83
45
  yield* Effect.try({
84
46
  try: () => mf.registerRemotes([{
85
47
  name: remoteName,
86
- entry: url
48
+ entry: url,
49
+ ...type ? { type } : {}
87
50
  }]),
88
51
  catch: (error) => new ModuleFederationError({
89
52
  pluginId,
@@ -1 +1 @@
1
- {"version":3,"file":"module-federation.service.mjs","names":["pkg.version"],"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 { getMajorMinorVersion } from \"../../build/shared-deps\";\nimport type { AnyPlugin } from \"../../types\";\nimport { ModuleFederationError } from \"../errors\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule =\n\t| (new () => AnyPlugin)\n\t| { 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\tget: () => import(\"every-plugin\").then(mod => () => mod),\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: getMajorMinorVersion(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.peerDependencies.effect,\n\t\t\t\t\t\t\tget: () => import(\"effect\").then(mod => () => mod),\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: getMajorMinorVersion(pkg.peerDependencies.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.peerDependencies.zod,\n\t\t\t\t\t\t\tget: () => import(\"zod\").then(mod => () => mod),\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: getMajorMinorVersion(pkg.peerDependencies.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\tget: () => import(\"@orpc/contract\").then(mod => () => mod),\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: getMajorMinorVersion(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\tget: () => import(\"@orpc/server\").then(mod => () => mod),\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: getMajorMinorVersion(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\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\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"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AkB,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":[],"sources":["../../../src/runtime/services/module-federation.service.ts"],"sourcesContent":["import { createInstance, getInstance } 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 { MF_SHARED_DEPS, type SharedDepName } from \"../mf-config\";\nimport { getNormalizedRemoteName } from \"./normalize\";\n\ntype RemoteModule = (new () => AnyPlugin) | { default: new () => AnyPlugin };\n\nconst sharedModuleLoaders = {\n \"every-plugin\": () => import(\"every-plugin\"),\n effect: () => import(\"effect\"),\n zod: () => import(\"zod\"),\n} satisfies Record<SharedDepName, () => Promise<unknown>>;\n\nconst createModuleFederationInstance = Effect.cached(\n Effect.sync(() => {\n try {\n let instance = getInstance();\n\n if (!instance) {\n const shared = Object.fromEntries(\n (\n Object.entries(MF_SHARED_DEPS) as [\n SharedDepName,\n (typeof MF_SHARED_DEPS)[SharedDepName],\n ][]\n ).map(([name, config]) => {\n const load = sharedModuleLoaders[name];\n\n if (!load) {\n throw new Error(`Missing shared module loader for ${name}`);\n }\n\n return [\n name,\n {\n version: config.version,\n get: () => load().then((mod) => () => mod),\n shareConfig: config.shareConfig,\n },\n ];\n }),\n );\n\n instance = createInstance({\n name: \"host\",\n remotes: [],\n shared,\n });\n\n setGlobalFederationInstance(instance);\n }\n\n return instance;\n } catch (error) {\n throw new Error(`Failed to initialize Module Federation: ${error}`);\n }\n }),\n);\n\nexport class ModuleFederationService extends Effect.Service<ModuleFederationService>()(\n \"ModuleFederationService\",\n {\n effect: Effect.gen(function* () {\n const mf = yield* Effect.flatten(createModuleFederationInstance);\n\n return {\n registerRemote: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n console.log(`[MF] Registering ${pluginId}`);\n\n const remoteName = getNormalizedRemoteName(pluginId);\n const type = url.endsWith(\"/mf-manifest.json\")\n ? (\"manifest\" as const)\n : url.endsWith(\"/remoteEntry.js\")\n ? (\"script\" as const)\n : undefined;\n\n yield* Effect.try({\n try: () =>\n mf.registerRemotes([\n {\n name: remoteName,\n entry: url,\n ...(type ? { type } : {}),\n },\n ]),\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n\n console.log(`[MF] ✅ Registered ${pluginId}`);\n }),\n\n loadRemoteConstructor: (pluginId: string, url: string) =>\n Effect.gen(function* () {\n const remoteName = getNormalizedRemoteName(pluginId);\n console.log(`[MF] Loading remote ${remoteName}`);\n const modulePath = `${remoteName}/plugin`;\n\n return yield* Effect.tryPromise({\n try: async () => {\n const container = await mf.loadRemote<RemoteModule>(modulePath);\n if (!container) {\n throw new Error(`No container returned for ${modulePath}`);\n }\n\n // Support multiple export patterns: direct function, default export, named exports\n let Constructor: any;\n\n if (typeof container === \"function\") {\n // Direct function export\n Constructor = container;\n } else if (container.default) {\n // Default export\n Constructor = container.default;\n } else {\n // Named export fallback - prioritize exports with 'binding' property (plugin classes)\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && (exp as any).binding !== undefined,\n );\n\n // Fallback to any function export if no binding found\n if (!Constructor) {\n Constructor = Object.values(container).find(\n (exp) => typeof exp === \"function\" && exp.prototype?.constructor === exp,\n );\n }\n }\n\n if (!Constructor || typeof Constructor !== \"function\") {\n const containerInfo =\n typeof container === \"object\"\n ? `Available exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `No valid plugin constructor found for '${pluginId}'.\\n` +\n `Supported patterns:\\n` +\n ` - export const YourPlugin = createPlugin({...})\\n` +\n ` - export default createPlugin({...})\\n` +\n `${containerInfo}`,\n );\n }\n\n // Validate it looks like a plugin constructor (has binding property)\n if (!(Constructor as any).binding) {\n const containerInfo =\n typeof container === \"object\"\n ? `Found exports: ${Object.keys(container).join(\", \")}`\n : `Container type: ${typeof container}`;\n\n throw new Error(\n `Invalid plugin constructor for '${pluginId}'. ` +\n `The exported value must be created with createPlugin(). ` +\n `Found a function but it's missing the required 'binding' property.\\n` +\n `${containerInfo}`,\n );\n }\n\n console.log(`[MF] ✅ Loaded constructor for ${pluginId}`);\n return Constructor;\n },\n catch: (error): ModuleFederationError =>\n new ModuleFederationError({\n pluginId,\n remoteUrl: url,\n cause: error instanceof Error ? error : new Error(String(error)),\n }),\n });\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;AAUA,MAAM,sBAAsB;CAC1B,sBAAsB,OAAO;CAC7B,cAAc,OAAO;CACrB,WAAW,OAAO;CACnB;AAED,MAAM,iCAAiC,OAAO,OAC5C,OAAO,WAAW;AAChB,KAAI;EACF,IAAI,WAAW,aAAa;AAE5B,MAAI,CAAC,UAAU;AAyBb,cAAW,eAAe;IACxB,MAAM;IACN,SAAS,EAAE;IACX,QA3Ba,OAAO,YAElB,OAAO,QAAQ,eAAe,CAI9B,KAAK,CAAC,MAAM,YAAY;KACxB,MAAM,OAAO,oBAAoB;AAEjC,SAAI,CAAC,KACH,OAAM,IAAI,MAAM,oCAAoC,OAAO;AAG7D,YAAO,CACL,MACA;MACE,SAAS,OAAO;MAChB,WAAW,MAAM,CAAC,MAAM,cAAc,IAAI;MAC1C,aAAa,OAAO;MACrB,CACF;MACD,CACH;IAMA,CAAC;AAEF,+BAA4B,SAAS;;AAGvC,SAAO;UACA,OAAO;AACd,QAAM,IAAI,M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IAAI,WAAW,gBAAgB,IACtE;;AAIL,SAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY;MACrD,MAAM,gBACJ,OAAO,cAAc,WACjB,sBAAsB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACvD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,0CAA0C,SAAS,sHAI9C,gBACN;;AAIH,SAAI,CAAE,YAAoB,SAAS;MACjC,MAAM,gBACJ,OAAO,cAAc,WACjB,kBAAkB,OAAO,KAAK,UAAU,CAAC,KAAK,KAAK,KACnD,mBAAmB,OAAO;AAEhC,YAAM,IAAI,MACR,mCAAmC,SAAS,iIAGvC,gBACN;;AAGH,aAAQ,IAAI,iCAAiC,WAAW;AACxD,YAAO;;IAET,QAAQ,UACN,IAAI,sBAAsB;KACxB;KACA,WAAW;KACX,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,MAAM,CAAC;KACjE,CAAC;IACL,CAAC;IACF;EACL;EACD,EACH,CACF,CAAC"}
@@ -1,15 +1,16 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1
2
 
2
3
  //#region src/runtime/services/normalize.ts
3
4
  /**
4
5
  * Normalizes a package name into the module federation remote name.
5
6
  * This function must produce identical results in both runtime and build contexts.
6
- *
7
+ *
7
8
  * Normalization rules:
8
9
  * - Convert to lowercase
9
10
  * - Strip a single leading '@' symbol
10
11
  * - Replace '/' with '_'
11
12
  * - Preserve hyphens and other characters
12
- *
13
+ *
13
14
  * Examples:
14
15
  * - "@scope/my-plugin" → "scope_my-plugin"
15
16
  * - "@SCOPE/Foo/Bar" → "scope_foo_bar"
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.cjs","names":[],"sources":["../../../src/runtime/services/normalize.ts"],"sourcesContent":["/**\n * Normalizes a package name into the module federation remote name.\n * This function must produce identical results in both runtime and build contexts.\n * \n * Normalization rules:\n * - Convert to lowercase\n * - Strip a single leading '@' symbol\n * - Replace '/' with '_'\n * - Preserve hyphens and other characters\n * \n * Examples:\n * - \"@scope/my-plugin\" → \"scope_my-plugin\"\n * - \"@SCOPE/Foo/Bar\" → \"scope_foo_bar\"\n * - \"foo/bar\" → \"foo_bar\"\n * - \"simple-plugin\" → \"simple-plugin\"\n */\nexport const getNormalizedRemoteName = (name: string): string =>\n name.toLowerCase().replace(/^@/, \"\").replace(/\\//g, \"_\");\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,MAAa,2BAA2B,SACtC,KAAK,aAAa,CAAC,QAAQ,MAAM,GAAG,CAAC,QAAQ,OAAO,IAAI"}
1
+ {"version":3,"file":"normalize.cjs","names":[],"sources":["../../../src/runtime/services/normalize.ts"],"sourcesContent":["/**\n * Normalizes a package name into the module federation remote name.\n * This function must produce identical results in both runtime and build contexts.\n *\n * Normalization rules:\n * - Convert to lowercase\n * - Strip a single leading '@' symbol\n * - Replace '/' with '_'\n * - Preserve hyphens and other characters\n *\n * Examples:\n * - \"@scope/my-plugin\" → \"scope_my-plugin\"\n * - \"@SCOPE/Foo/Bar\" → \"scope_foo_bar\"\n * - \"foo/bar\" → \"foo_bar\"\n * - \"simple-plugin\" → \"simple-plugin\"\n */\nexport const getNormalizedRemoteName = (name: string): string =>\n name.toLowerCase().replace(/^@/, \"\").replace(/\\//g, \"_\");\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAgBA,MAAa,2BAA2B,SACtC,KAAK,aAAa,CAAC,QAAQ,MAAM,GAAG,CAAC,QAAQ,OAAO,IAAI"}
@@ -2,13 +2,13 @@
2
2
  /**
3
3
  * Normalizes a package name into the module federation remote name.
4
4
  * This function must produce identical results in both runtime and build contexts.
5
- *
5
+ *
6
6
  * Normalization rules:
7
7
  * - Convert to lowercase
8
8
  * - Strip a single leading '@' symbol
9
9
  * - Replace '/' with '_'
10
10
  * - Preserve hyphens and other characters
11
- *
11
+ *
12
12
  * Examples:
13
13
  * - "@scope/my-plugin" → "scope_my-plugin"
14
14
  * - "@SCOPE/Foo/Bar" → "scope_foo_bar"
@@ -1 +1 @@
1
- {"version":3,"file":"normalize.mjs","names":[],"sources":["../../../src/runtime/services/normalize.ts"],"sourcesContent":["/**\n * Normalizes a package name into the module federation remote name.\n * This function must produce identical results in both runtime and build contexts.\n * \n * Normalization rules:\n * - Convert to lowercase\n * - Strip a single leading '@' symbol\n * - Replace '/' with '_'\n * - Preserve hyphens and other characters\n * \n * Examples:\n * - \"@scope/my-plugin\" → \"scope_my-plugin\"\n * - \"@SCOPE/Foo/Bar\" → \"scope_foo_bar\"\n * - \"foo/bar\" → \"foo_bar\"\n * - \"simple-plugin\" → \"simple-plugin\"\n */\nexport const getNormalizedRemoteName = (name: string): string =>\n name.toLowerCase().replace(/^@/, \"\").replace(/\\//g, \"_\");\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,2BAA2B,SACtC,KAAK,aAAa,CAAC,QAAQ,MAAM,GAAG,CAAC,QAAQ,OAAO,IAAI"}
1
+ {"version":3,"file":"normalize.mjs","names":[],"sources":["../../../src/runtime/services/normalize.ts"],"sourcesContent":["/**\n * Normalizes a package name into the module federation remote name.\n * This function must produce identical results in both runtime and build contexts.\n *\n * Normalization rules:\n * - Convert to lowercase\n * - Strip a single leading '@' symbol\n * - Replace '/' with '_'\n * - Preserve hyphens and other characters\n *\n * Examples:\n * - \"@scope/my-plugin\" → \"scope_my-plugin\"\n * - \"@SCOPE/Foo/Bar\" → \"scope_foo_bar\"\n * - \"foo/bar\" → \"foo_bar\"\n * - \"simple-plugin\" → \"simple-plugin\"\n */\nexport const getNormalizedRemoteName = (name: string): string =>\n name.toLowerCase().replace(/^@/, \"\").replace(/\\//g, \"_\");\n"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,MAAa,2BAA2B,SACtC,KAAK,aAAa,CAAC,QAAQ,MAAM,GAAG,CAAC,QAAQ,OAAO,IAAI"}
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
2
  const require_errors = require('../errors.cjs');
3
3
  let effect = require("effect");
4
4
 
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-lifecycle.service.cjs","names":["Effect","Ref","toPluginRuntimeError"],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Ref } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\"PluginLifecycleService\", {\n effect: Effect.gen(function* () {\n const activePlugins = yield* Ref.make(new Set<InitializedPlugin<AnyPlugin>>());\n\n return {\n register: <T extends AnyPlugin>(plugin: InitializedPlugin<T>) =>\n Ref.update(activePlugins, plugins =>\n new Set(plugins).add(plugin as InitializedPlugin<AnyPlugin>)\n ),\n\n unregister: (plugin: InitializedPlugin<AnyPlugin>) =>\n Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n }),\n\n shutdown: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n // Remove from active plugins\n yield* Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n });\n\n // Shutdown the plugin\n yield* plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"shutdown-plugin\", false)\n )\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n\n // Shutdown all active plugins concurrently\n yield* Effect.forEach(\n plugins,\n plugin =>\n plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"cleanup-shutdown\", false)\n ),\n Effect.catchAll(error =>\n Effect.logError(\n `Failed to shutdown plugin ${plugin.plugin.id} during cleanup`,\n error,\n { pluginId: plugin.plugin.id }\n )\n )\n ),\n { concurrency: \"unbounded\" }\n );\n\n // Clear the active plugins set\n yield* Ref.set(activePlugins, new Set());\n }).pipe(\n Effect.catchAll(() => Effect.void) // Convert errors to void for cleanup\n ),\n };\n }),\n}) { }\n"],"mappings":";;;;;AAIA,IAAa,yBAAb,cAA4CA,cAAO,SAAiC,CAAC,0BAA0B,EAC7G,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAOC,WAAI,qBAAK,IAAI,KAAmC,CAAC;AAE9E,QAAO;EACL,WAAgC,WAC9BA,WAAI,OAAO,gBAAe,YACxB,IAAI,IAAI,QAAQ,CAAC,IAAI,OAAuC,CAC7D;EAEH,aAAa,WACXA,WAAI,OAAO,gBAAe,YAAW;GACnC,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,UAAO,OAAO,OAAO;AACrB,UAAO;IACP;EAEJ,WAAW,WACTD,cAAO,IAAI,aAAa;AAEtB,UAAOC,WAAI,OAAO,gBAAe,YAAW;IAC1C,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,WAAO,OAAO,OAAO;AACrB,WAAO;KACP;AAGF,UAAO,OAAO,OAAO,UAAU,CAAC,KAC9BD,cAAO,UAAS,UACdE,oCAAqB,OAAO,OAAO,OAAO,IAAI,QAAW,mBAAmB,MAAM,CACnF,CACF;IACD;EAEJ,eACEF,cAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAOC,WAAI,IAAI,cAAc;AAG7C,UAAOD,cAAO,QACZ,UACA,WACE,OAAO,OAAO,UAAU,CAAC,KACvBA,cAAO,UAAS,UACdE,oCAAqB,OAAO,OAAO,OAAO,IAAI,QAAW,oBAAoB,MAAM,CACpF,EACDF,cAAO,UAAS,UACdA,cAAO,SACL,6BAA6B,OAAO,OAAO,GAAG,kBAC9C,OACA,EAAE,UAAU,OAAO,OAAO,IAAI,CAC/B,CACF,CACF,EACH,EAAE,aAAa,aAAa,CAC7B;AAGD,UAAOC,WAAI,IAAI,+BAAe,IAAI,KAAK,CAAC;IACxC,CAAC,KACDD,cAAO,eAAeA,cAAO,KAAK,CACnC;EACJ;EACD,EACH,CAAC,CAAC"}
1
+ {"version":3,"file":"plugin-lifecycle.service.cjs","names":["Effect","Ref","toPluginRuntimeError"],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Ref } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\n effect: Effect.gen(function* () {\n const activePlugins = yield* Ref.make(new Set<InitializedPlugin<AnyPlugin>>());\n\n return {\n register: <T extends AnyPlugin>(plugin: InitializedPlugin<T>) =>\n Ref.update(activePlugins, (plugins) =>\n new Set(plugins).add(plugin as InitializedPlugin<AnyPlugin>),\n ),\n\n unregister: (plugin: InitializedPlugin<AnyPlugin>) =>\n Ref.update(activePlugins, (plugins) => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n }),\n\n shutdown: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n // Remove from active plugins\n yield* Ref.update(activePlugins, (plugins) => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n });\n\n // Shutdown the plugin\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n\n // Shutdown all active plugins concurrently\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n plugin.plugin.shutdown().pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"cleanup-shutdown\",\n false,\n ),\n ),\n Effect.catchAll((error) =>\n Effect.logError(\n `Failed to shutdown plugin ${plugin.plugin.id} during cleanup`,\n error,\n { pluginId: plugin.plugin.id },\n ),\n ),\n ),\n { concurrency: \"unbounded\" },\n );\n\n // Clear the active plugins set\n yield* Ref.set(activePlugins, new Set());\n }).pipe(\n Effect.catchAll(() => Effect.void), // Convert errors to void for cleanup\n ),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;AAIA,IAAa,yBAAb,cAA4CA,cAAO,SAAiC,CAClF,0BACA,EACE,QAAQA,cAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAOC,WAAI,qBAAK,IAAI,KAAmC,CAAC;AAE9E,QAAO;EACL,WAAgC,WAC9BA,WAAI,OAAO,gBAAgB,YACzB,IAAI,IAAI,QAAQ,CAAC,IAAI,OAAuC,CAC7D;EAEH,aAAa,WACXA,WAAI,OAAO,gBAAgB,YAAY;GACrC,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,UAAO,OAAO,OAAO;AACrB,UAAO;IACP;EAEJ,WAAW,WACTD,cAAO,IAAI,aAAa;AAEtB,UAAOC,WAAI,OAAO,gBAAgB,YAAY;IAC5C,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,WAAO,OAAO,OAAO;AACrB,WAAO;KACP;AAGF,UAAO,OAAO,OACX,UAAU,CACV,KACCD,cAAO,UAAU,UACfE,oCACE,OACA,OAAO,OAAO,IACd,QACA,mBACA,MACD,CACF,CACF;IACH;EAEJ,eACEF,cAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAOC,WAAI,IAAI,cAAc;AAG7C,UAAOD,cAAO,QACZ,UACC,WACC,OAAO,OAAO,UAAU,CAAC,KACvBA,cAAO,UAAU,UACfE,oCACE,OACA,OAAO,OAAO,IACd,QACA,oBACA,MACD,CACF,EACDF,cAAO,UAAU,UACfA,cAAO,SACL,6BAA6B,OAAO,OAAO,GAAG,kBAC9C,OACA,EAAE,UAAU,OAAO,OAAO,IAAI,CAC/B,CACF,CACF,EACH,EAAE,aAAa,aAAa,CAC7B;AAGD,UAAOC,WAAI,IAAI,+BAAe,IAAI,KAAK,CAAC;IACxC,CAAC,KACDD,cAAO,eAAeA,cAAO,KAAK,CACnC;EACJ;EACD,EACH,CACF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-lifecycle.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;cACgE,2BAAA;;yBAQrC,SAAA,EAAS,MAAA,EAAU,iBAAA,CAAkB,CAAA,MAAE,MAAA,CAAA,MAAA;yBAKvC,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA;uBAO9B,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA,OAAX,kBAAA;;;;cAjB7B,sBAAA,SAA+B,2BAAA"}
1
+ {"version":3,"file":"plugin-lifecycle.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;cACgE,2BAAA;;yBAUnC,SAAA,EAAS,MAAA,EAAU,iBAAA,CAAkB,CAAA,MAAE,MAAA,CAAA,MAAA;yBAKvC,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA;uBAO9B,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA,OAAX,kBAAA;;;;cAnB/B,sBAAA,SAA+B,2BAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-lifecycle.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;cACgE,2BAAA;;yBAQrC,SAAA,EAAS,MAAA,EAAU,iBAAA,CAAkB,CAAA,MAAE,MAAA,CAAA,MAAA;yBAKvC,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA;uBAO9B,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA,OAAX,kBAAA;;;;cAjB7B,sBAAA,SAA+B,2BAAA"}
1
+ {"version":3,"file":"plugin-lifecycle.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"mappings":";;;;;cACgE,2BAAA;;yBAUnC,SAAA,EAAS,MAAA,EAAU,iBAAA,CAAkB,CAAA,MAAE,MAAA,CAAA,MAAA;yBAKvC,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA;uBAO9B,iBAAA,CAAkB,SAAA,MAAU,MAAA,CAAA,MAAA,OAAX,kBAAA;;;;cAnB/B,sBAAA,SAA+B,2BAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-lifecycle.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Ref } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\"PluginLifecycleService\", {\n effect: Effect.gen(function* () {\n const activePlugins = yield* Ref.make(new Set<InitializedPlugin<AnyPlugin>>());\n\n return {\n register: <T extends AnyPlugin>(plugin: InitializedPlugin<T>) =>\n Ref.update(activePlugins, plugins =>\n new Set(plugins).add(plugin as InitializedPlugin<AnyPlugin>)\n ),\n\n unregister: (plugin: InitializedPlugin<AnyPlugin>) =>\n Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n }),\n\n shutdown: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n // Remove from active plugins\n yield* Ref.update(activePlugins, plugins => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n });\n\n // Shutdown the plugin\n yield* plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"shutdown-plugin\", false)\n )\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n\n // Shutdown all active plugins concurrently\n yield* Effect.forEach(\n plugins,\n plugin =>\n plugin.plugin.shutdown().pipe(\n Effect.mapError(error =>\n toPluginRuntimeError(error, plugin.plugin.id, undefined, \"cleanup-shutdown\", false)\n ),\n Effect.catchAll(error =>\n Effect.logError(\n `Failed to shutdown plugin ${plugin.plugin.id} during cleanup`,\n error,\n { pluginId: plugin.plugin.id }\n )\n )\n ),\n { concurrency: \"unbounded\" }\n );\n\n // Clear the active plugins set\n yield* Ref.set(activePlugins, new Set());\n }).pipe(\n Effect.catchAll(() => Effect.void) // Convert errors to void for cleanup\n ),\n };\n }),\n}) { }\n"],"mappings":";;;;AAIA,IAAa,yBAAb,cAA4C,OAAO,SAAiC,CAAC,0BAA0B,EAC7G,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAO,IAAI,qBAAK,IAAI,KAAmC,CAAC;AAE9E,QAAO;EACL,WAAgC,WAC9B,IAAI,OAAO,gBAAe,YACxB,IAAI,IAAI,QAAQ,CAAC,IAAI,OAAuC,CAC7D;EAEH,aAAa,WACX,IAAI,OAAO,gBAAe,YAAW;GACnC,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,UAAO,OAAO,OAAO;AACrB,UAAO;IACP;EAEJ,WAAW,WACT,OAAO,IAAI,aAAa;AAEtB,UAAO,IAAI,OAAO,gBAAe,YAAW;IAC1C,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,WAAO,OAAO,OAAO;AACrB,WAAO;KACP;AAGF,UAAO,OAAO,OAAO,UAAU,CAAC,KAC9B,OAAO,UAAS,UACd,qBAAqB,OAAO,OAAO,OAAO,IAAI,QAAW,mBAAmB,MAAM,CACnF,CACF;IACD;EAEJ,eACE,OAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAO,IAAI,IAAI,cAAc;AAG7C,UAAO,OAAO,QACZ,UACA,WACE,OAAO,OAAO,UAAU,CAAC,KACvB,OAAO,UAAS,UACd,qBAAqB,OAAO,OAAO,OAAO,IAAI,QAAW,oBAAoB,MAAM,CACpF,EACD,OAAO,UAAS,UACd,OAAO,SACL,6BAA6B,OAAO,OAAO,GAAG,kBAC9C,OACA,EAAE,UAAU,OAAO,OAAO,IAAI,CAC/B,CACF,CACF,EACH,EAAE,aAAa,aAAa,CAC7B;AAGD,UAAO,IAAI,IAAI,+BAAe,IAAI,KAAK,CAAC;IACxC,CAAC,KACD,OAAO,eAAe,OAAO,KAAK,CACnC;EACJ;EACD,EACH,CAAC,CAAC"}
1
+ {"version":3,"file":"plugin-lifecycle.service.mjs","names":[],"sources":["../../../src/runtime/services/plugin-lifecycle.service.ts"],"sourcesContent":["import { Effect, Ref } from \"effect\";\nimport type { AnyPlugin, InitializedPlugin } from \"../../types\";\nimport { toPluginRuntimeError } from \"../errors\";\n\nexport class PluginLifecycleService extends Effect.Service<PluginLifecycleService>()(\n \"PluginLifecycleService\",\n {\n effect: Effect.gen(function* () {\n const activePlugins = yield* Ref.make(new Set<InitializedPlugin<AnyPlugin>>());\n\n return {\n register: <T extends AnyPlugin>(plugin: InitializedPlugin<T>) =>\n Ref.update(activePlugins, (plugins) =>\n new Set(plugins).add(plugin as InitializedPlugin<AnyPlugin>),\n ),\n\n unregister: (plugin: InitializedPlugin<AnyPlugin>) =>\n Ref.update(activePlugins, (plugins) => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n }),\n\n shutdown: (plugin: InitializedPlugin<AnyPlugin>) =>\n Effect.gen(function* () {\n // Remove from active plugins\n yield* Ref.update(activePlugins, (plugins) => {\n const newSet = new Set(plugins);\n newSet.delete(plugin);\n return newSet;\n });\n\n // Shutdown the plugin\n yield* plugin.plugin\n .shutdown()\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"shutdown-plugin\",\n false,\n ),\n ),\n );\n }),\n\n cleanup: () =>\n Effect.gen(function* () {\n const plugins = yield* Ref.get(activePlugins);\n\n // Shutdown all active plugins concurrently\n yield* Effect.forEach(\n plugins,\n (plugin) =>\n plugin.plugin.shutdown().pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(\n error,\n plugin.plugin.id,\n undefined,\n \"cleanup-shutdown\",\n false,\n ),\n ),\n Effect.catchAll((error) =>\n Effect.logError(\n `Failed to shutdown plugin ${plugin.plugin.id} during cleanup`,\n error,\n { pluginId: plugin.plugin.id },\n ),\n ),\n ),\n { concurrency: \"unbounded\" },\n );\n\n // Clear the active plugins set\n yield* Ref.set(activePlugins, new Set());\n }).pipe(\n Effect.catchAll(() => Effect.void), // Convert errors to void for cleanup\n ),\n };\n }),\n },\n) {}\n"],"mappings":";;;;AAIA,IAAa,yBAAb,cAA4C,OAAO,SAAiC,CAClF,0BACA,EACE,QAAQ,OAAO,IAAI,aAAa;CAC9B,MAAM,gBAAgB,OAAO,IAAI,qBAAK,IAAI,KAAmC,CAAC;AAE9E,QAAO;EACL,WAAgC,WAC9B,IAAI,OAAO,gBAAgB,YACzB,IAAI,IAAI,QAAQ,CAAC,IAAI,OAAuC,CAC7D;EAEH,aAAa,WACX,IAAI,OAAO,gBAAgB,YAAY;GACrC,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,UAAO,OAAO,OAAO;AACrB,UAAO;IACP;EAEJ,WAAW,WACT,OAAO,IAAI,aAAa;AAEtB,UAAO,IAAI,OAAO,gBAAgB,YAAY;IAC5C,MAAM,SAAS,IAAI,IAAI,QAAQ;AAC/B,WAAO,OAAO,OAAO;AACrB,WAAO;KACP;AAGF,UAAO,OAAO,OACX,UAAU,CACV,KACC,OAAO,UAAU,UACf,qBACE,OACA,OAAO,OAAO,IACd,QACA,mBACA,MACD,CACF,CACF;IACH;EAEJ,eACE,OAAO,IAAI,aAAa;GACtB,MAAM,UAAU,OAAO,IAAI,IAAI,cAAc;AAG7C,UAAO,OAAO,QACZ,UACC,WACC,OAAO,OAAO,UAAU,CAAC,KACvB,OAAO,UAAU,UACf,qBACE,OACA,OAAO,OAAO,IACd,QACA,oBACA,MACD,CACF,EACD,OAAO,UAAU,UACf,OAAO,SACL,6BAA6B,OAAO,OAAO,GAAG,kBAC9C,OACA,EAAE,UAAU,OAAO,OAAO,IAAI,CAC/B,CACF,CACF,EACH,EAAE,aAAa,aAAa,CAC7B;AAGD,UAAO,IAAI,IAAI,+BAAe,IAAI,KAAK,CAAC;IACxC,CAAC,KACD,OAAO,eAAe,OAAO,KAAK,CACnC;EACJ;EACD,EACH,CACF,CAAC"}
@@ -1,4 +1,4 @@
1
- const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
2
  const require_errors = require('../errors.cjs');
3
3
  const require_module_federation_service = require('./module-federation.service.cjs');
4
4
  const require_validation = require('../validation.cjs');
@@ -81,7 +81,7 @@ var PluginLoaderService = class extends effect.Effect.Service()("PluginLoaderSer
81
81
  metadata: loadedPlugin.metadata
82
82
  };
83
83
  }),
84
- initializePlugin: (pluginInstance, config) => effect.Effect.gen(function* () {
84
+ initializePlugin: (pluginInstance, config, plugins) => effect.Effect.gen(function* () {
85
85
  const { plugin } = pluginInstance;
86
86
  const validatedVariables = yield* require_validation.validate(plugin.configSchema.variables, config.variables, plugin.id, "config").pipe(effect.Effect.mapError((validationError) => new require_errors.PluginRuntimeError({
87
87
  pluginId: plugin.id,
@@ -109,7 +109,7 @@ var PluginLoaderService = class extends effect.Effect.Service()("PluginLoaderSer
109
109
  const context = yield* plugin.initialize({
110
110
  variables: _variables,
111
111
  secrets: hydratedConfig.secrets
112
- }).pipe(effect.Effect.provideService(effect.Scope.Scope, scope), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
112
+ }, plugins ?? {}).pipe(effect.Effect.provideService(effect.Scope.Scope, scope), effect.Effect.mapError((error) => require_errors.toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
113
113
  return {
114
114
  plugin,
115
115
  metadata: pluginInstance.metadata,
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-loader.service.cjs","names":["Context","Effect","PluginRuntimeError","ModuleFederationService","SecretsService","toPluginRuntimeError","validate","Scope"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport type {\n\tAnyPlugin,\n\tAnyPluginConstructor,\n\tInitializedPlugin,\n\tLoadedPlugin,\n\tPluginInstance,\n\tPluginMetadata,\n\tPluginRegistry\n} from \"../../types\";\nimport { PluginRuntimeError, toPluginRuntimeError } from \"../errors\";\nimport { validate } from \"../validation\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { SecretsService } from \"./secrets.service\";\n\nexport class PluginRegistryTag extends Context.Tag(\"PluginRegistry\")<\n\tPluginRegistryTag,\n\tPluginRegistry\n>() { }\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n\tPluginMapTag,\n\tRecord<string, AnyPluginConstructor>\n>() { }\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst registry = yield* PluginRegistryTag;\n\t\tconst pluginMap = yield* PluginMapTag;\n\n\t\treturn {\n\t\t\tget: (pluginId: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst entry = registry[pluginId];\n\t\t\t\t\t\n\t\t\t\t\tif (!entry) {\n\t\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\toperation: \"validate-plugin-id\",\n\t\t\t\t\t\t\t\tcause: new Error(`Plugin ${pluginId} not found in registry`),\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\"module\" in entry) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tconstructor: entry.module,\n\t\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\t\tremoteUrl: entry.remote || \"\",\n\t\t\t\t\t\t\t\tversion: entry.version,\n\t\t\t\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\t\t\t} as PluginMetadata,\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tconstructor: null,\n\t\t\t\t\t\tmetadata: {\n\t\t\t\t\t\t\tremoteUrl: entry.remote,\n\t\t\t\t\t\t\tversion: entry.version,\n\t\t\t\t\t\t\tdescription: entry.description,\n\t\t\t\t\t\t} as PluginMetadata,\n\t\t\t\t\t};\n\t\t\t\t}),\n\n\t\t\tgetModule: (pluginId: string) =>\n\t\t\t\tEffect.succeed(pluginMap[pluginId] || null),\n\t\t};\n\t}),\n}) { }\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\"PluginLoaderService\", {\n\teffect: Effect.gen(function* () {\n\t\tconst moduleFederationService = yield* ModuleFederationService;\n\t\tconst secretsService = yield* SecretsService;\n\t\tconst registryService = yield* RegistryService;\n\n\t\tconst resolveUrl = (baseUrl: string, version?: string): string =>\n\t\t\tversion && version !== \"latest\"\n\t\t\t\t? baseUrl.replace(\"@latest\", `@${version}`)\n\t\t\t\t: baseUrl;\n\n\t\treturn {\n\t\t\tloadPlugin: (pluginId: string) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst entry = yield* registryService.get(pluginId);\n\n\t\t\t\t\tif (entry.constructor) {\n\t\t\t\t\t\tyield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\t\t\t\t\t\t\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tctor: entry.constructor,\n\t\t\t\t\t\t\tmetadata: entry.metadata,\n\t\t\t\t\t\t} satisfies LoadedPlugin;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst url = entry.metadata.remoteUrl;\n\t\t\t\t\tif (!url) {\n\t\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\toperation: \"load-plugin\",\n\t\t\t\t\t\t\t\tcause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\tconst resolvedUrl = resolveUrl(url);\n\n\t\t\t\t\tyield* moduleFederationService.registerRemote(pluginId, resolvedUrl).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\tyield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n\t\t\t\t\tconst ctor = yield* moduleFederationService.loadRemoteConstructor(pluginId, resolvedUrl).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tctor,\n\t\t\t\t\t\tmetadata: entry.metadata,\n\t\t\t\t\t} satisfies LoadedPlugin;\n\t\t\t\t}),\n\n\t\t\tinstantiatePlugin: <T extends AnyPlugin>(\n\t\t\t\tpluginId: string,\n\t\t\t\tloadedPlugin: LoadedPlugin<T>,\n\t\t\t) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(\n\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\tpluginId,\n\t\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t\t\"instantiate-plugin\",\n\t\t\t\t\t\t\t\tfalse,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t(instance.id as string) = pluginId;\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tplugin: instance,\n\t\t\t\t\t\tmetadata: loadedPlugin.metadata,\n\t\t\t\t\t} satisfies PluginInstance<T>;\n\t\t\t\t}),\n\n\t\t\tinitializePlugin: <T extends AnyPlugin>(\n\t\t\t\tpluginInstance: PluginInstance<T>,\n\t\t\t\tconfig: { variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>; secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]> },\n\t\t\t) =>\n\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\tconst { plugin } = pluginInstance;\n\n\t\t\t\t\t// Validate and hydrate config\n\t\t\t\t\tconst validatedVariables = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.variables as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"variables\"]>>,\n\t\t\t\t\t\tconfig.variables,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-config\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Validate secrets\n\t\t\t\t\tconst validatedSecrets = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.secrets as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>>,\n\t\t\t\t\t\tconfig.secrets,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-secrets\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Hydrate secrets in variables\n\t\t\t\t\tconst hydratedConfig = yield* secretsService.hydrateSecrets({\n\t\t\t\t\t\tvariables: validatedVariables,\n\t\t\t\t\t\tsecrets: validatedSecrets,\n\t\t\t\t\t});\n\n\t\t\t\t\tconst _variables = yield* validate(\n\t\t\t\t\t\tplugin.configSchema.variables as z.ZodSchema<InferSchemaOutput<T[\"configSchema\"][\"variables\"]>>,\n\t\t\t\t\t\thydratedConfig.variables,\n\t\t\t\t\t\tplugin.id,\n\t\t\t\t\t\t\"config\",\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tEffect.mapError((validationError) =>\n\t\t\t\t\t\t\tnew PluginRuntimeError({\n\t\t\t\t\t\t\t\tpluginId: plugin.id,\n\t\t\t\t\t\t\t\toperation: \"validate-hydrated-config\",\n\t\t\t\t\t\t\t\tcause: validationError.zodError,\n\t\t\t\t\t\t\t\tretryable: false,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\n\t\t\t\t\t// Create a long-lived scope for this plugin instance\n\t\t\t\t\tconst scope = yield* Scope.make();\n\n\t\t\t\t\t// Initialize plugin within the scope\n\t\t\t\t\tconst context = yield* plugin.initialize({ variables: _variables, secrets: hydratedConfig.secrets }).pipe(\n\t\t\t\t\t\tEffect.provideService(Scope.Scope, scope),\n\t\t\t\t\t\tEffect.mapError((error) =>\n\t\t\t\t\t\t\ttoPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\n\t\t\t\t\treturn {\n\t\t\t\t\t\tplugin,\n\t\t\t\t\t\tmetadata: pluginInstance.metadata,\n\t\t\t\t\t\tconfig: { variables: _variables, secrets: hydratedConfig.secrets },\n\t\t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AW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACX,CAAC,CACF,CACD;GAGD,MAAM,mBAAmB,OAAOI,4BAC/B,OAAO,aAAa,SACpB,OAAO,SACP,OAAO,IACP,SACA,CAAC,KACDL,cAAO,UAAU,oBAChB,IAAIC,kCAAmB;IACtB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACX,CAAC,CACF,CACD;GAGD,MAAM,iBAAiB,OAAO,eAAe,eAAe;IAC3D,WAAW;IACX,SAAS;IACT,CAAC;GAEF,MAAM,aAAa,OAAOI,4BACzB,OAAO,aAAa,WACpB,eAAe,WACf,OAAO,IACP,SACA,CAAC,KACDL,cAAO,UAAU,oBAChB,IAAIC,kCAAmB;IACtB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACX,CAAC,CACF,CACD;GAGD,MAAM,QAAQ,OAAOK,aAAM,MAAM;GAGjC,MAAM,UAAU,OAAO,OAAO,WAAW;IAAE,WAAW;IAAY,SAAS,eAAe;IAAS,CAAC,CAAC,KACpGN,cAAO,eAAeM,aAAM,OAAO,MAAM,EACzCN,cAAO,UAAU,UAChBI,oCAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,MAAM,CAC7E,CACD;AAED,UAAO;IACN;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;KAAS;IAClE;IACA;IACA;IACA;EACH;EACA,EACF,CAAC,CAAC"}
1
+ {"version":3,"file":"plugin-loader.service.cjs","names":["Context","Effect","PluginRuntimeError","ModuleFederationService","SecretsService","toPluginRuntimeError","validate","Scope"],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"sourcesContent":["import type { InferSchemaInput, InferSchemaOutput } from \"@orpc/contract\";\nimport { Context, Effect, Scope } from \"effect\";\nimport type { z } from \"zod\";\nimport type {\n AnyPlugin,\n AnyPluginConstructor,\n InitializedPlugin,\n LoadedPlugin,\n PluginInstance,\n PluginMetadata,\n PluginRegistry,\n} from \"../../types\";\nimport { PluginRuntimeError, toPluginRuntimeError } from \"../errors\";\nimport { validate } from \"../validation\";\nimport { ModuleFederationService } from \"./module-federation.service\";\nimport { SecretsService } from \"./secrets.service\";\n\nexport class PluginRegistryTag extends Context.Tag(\"PluginRegistry\")<\n PluginRegistryTag,\n PluginRegistry\n>() {}\n\nexport class PluginMapTag extends Context.Tag(\"PluginMap\")<\n PluginMapTag,\n Record<string, AnyPluginConstructor>\n>() {}\n\nexport class RegistryService extends Effect.Service<RegistryService>()(\"RegistryService\", {\n effect: Effect.gen(function* () {\n const registry = yield* PluginRegistryTag;\n const pluginMap = yield* PluginMapTag;\n\n return {\n get: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = registry[pluginId];\n\n if (!entry) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"validate-plugin-id\",\n cause: new Error(`Plugin ${pluginId} not found in registry`),\n retryable: false,\n }),\n );\n }\n\n if (\"module\" in entry) {\n return {\n constructor: entry.module,\n metadata: {\n remoteUrl: entry.remote || \"\",\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }\n\n return {\n constructor: null,\n metadata: {\n remoteUrl: entry.remote,\n version: entry.version,\n description: entry.description,\n } as PluginMetadata,\n };\n }),\n\n getModule: (pluginId: string) => Effect.succeed(pluginMap[pluginId] || null),\n };\n }),\n}) {}\n\nexport class PluginLoaderService extends Effect.Service<PluginLoaderService>()(\n \"PluginLoaderService\",\n {\n effect: Effect.gen(function* () {\n const moduleFederationService = yield* ModuleFederationService;\n const secretsService = yield* SecretsService;\n const registryService = yield* RegistryService;\n\n const resolveUrl = (baseUrl: string, version?: string): string =>\n version && version !== \"latest\" ? baseUrl.replace(\"@latest\", `@${version}`) : baseUrl;\n\n return {\n loadPlugin: (pluginId: string) =>\n Effect.gen(function* () {\n const entry = yield* registryService.get(pluginId);\n\n if (entry.constructor) {\n yield* Effect.logDebug(\"Loading plugin from direct module\", { pluginId });\n\n return {\n ctor: entry.constructor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }\n\n const url = entry.metadata.remoteUrl;\n if (!url) {\n return yield* Effect.fail(\n new PluginRuntimeError({\n pluginId,\n operation: \"load-plugin\",\n cause: new Error(`Plugin ${pluginId} has no module or remote URL configured`),\n retryable: false,\n }),\n );\n }\n\n const resolvedUrl = resolveUrl(url);\n\n yield* moduleFederationService\n .registerRemote(pluginId, resolvedUrl)\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"register-remote\", true),\n ),\n );\n\n yield* Effect.logDebug(\"Loading plugin from remote\", { pluginId, url: resolvedUrl });\n\n const ctor = yield* moduleFederationService\n .loadRemoteConstructor(pluginId, resolvedUrl)\n .pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"load-remote\", false),\n ),\n );\n\n return {\n ctor,\n metadata: entry.metadata,\n } satisfies LoadedPlugin;\n }),\n\n instantiatePlugin: <T extends AnyPlugin>(pluginId: string, loadedPlugin: LoadedPlugin<T>) =>\n Effect.gen(function* () {\n const instance = yield* Effect.try(() => new loadedPlugin.ctor()).pipe(\n Effect.mapError((error) =>\n toPluginRuntimeError(error, pluginId, undefined, \"instantiate-plugin\", false),\n ),\n );\n\n (instance.id as string) = pluginId;\n\n return {\n plugin: instance,\n metadata: loadedPlugin.metadata,\n } satisfies PluginInstance<T>;\n }),\n\n initializePlugin: <T extends AnyPlugin>(\n pluginInstance: PluginInstance<T>,\n config: {\n variables: InferSchemaInput<T[\"configSchema\"][\"variables\"]>;\n secrets: InferSchemaInput<T[\"configSchema\"][\"secrets\"]>;\n },\n plugins?: Record<string, unknown>,\n ) =>\n Effect.gen(function* () {\n const { plugin } = pluginInstance;\n\n // Validate and hydrate config\n const validatedVariables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n config.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Validate secrets\n const validatedSecrets = yield* validate(\n plugin.configSchema.secrets as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"secrets\"]>\n >,\n config.secrets,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-secrets\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Hydrate secrets in variables\n const hydratedConfig = yield* secretsService.hydrateSecrets({\n variables: validatedVariables,\n secrets: validatedSecrets,\n });\n\n const _variables = yield* validate(\n plugin.configSchema.variables as z.ZodSchema<\n InferSchemaOutput<T[\"configSchema\"][\"variables\"]>\n >,\n hydratedConfig.variables,\n plugin.id,\n \"config\",\n ).pipe(\n Effect.mapError(\n (validationError) =>\n new PluginRuntimeError({\n pluginId: plugin.id,\n operation: \"validate-hydrated-config\",\n cause: validationError.zodError,\n retryable: false,\n }),\n ),\n );\n\n // Create a long-lived scope for this plugin instance\n const scope = yield* Scope.make();\n\n // Initialize plugin within the scope\n const context = yield* plugin\n .initialize({ variables: _variables, secrets: hydratedConfig.secrets }, plugins ?? {})\n .pipe(\n Effect.provideService(Scope.Scope, scope),\n Effect.mapError((error) =>\n toPluginRuntimeError(error, plugin.id, undefined, \"initialize-plugin\", false),\n ),\n );\n\n return {\n plugin,\n metadata: pluginInstance.metadata,\n config: { variables: _variables, secrets: hydratedConfig.secrets },\n context,\n scope,\n } satisfies InitializedPlugin<T>;\n }),\n };\n }),\n },\n) {}\n"],"mappings":";;;;;;;;AAiBA,IAAa,oBAAb,cAAuCA,eAAQ,IAAI,iBAAiB,EAGjE,CAAC;AAEJ,IAAa,eAAb,cAAkCA,eAAQ,IAAI,YAAY,EAGvD,CAAC;AAEJ,IAAa,kBAAb,cAAqCC,cAAO,SAA0B,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AM,iBAAiB,OAAO,eAAe,eAAe;IAC1D,WAAW;IACX,SAAS;IACV,CAAC;GAEF,MAAM,aAAa,OAAOI,4BACxB,OAAO,aAAa,WAGpB,eAAe,WACf,OAAO,IACP,SACD,CAAC,KACAL,cAAO,UACJ,oBACC,IAAIC,kCAAmB;IACrB,UAAU,OAAO;IACjB,WAAW;IACX,OAAO,gBAAgB;IACvB,WAAW;IACZ,CAAC,CACL,CACF;GAGD,MAAM,QAAQ,OAAOK,aAAM,MAAM;GAGjC,MAAM,UAAU,OAAO,OACpB,WAAW;IAAE,WAAW;IAAY,SAAS,eAAe;IAAS,EAAE,WAAW,EAAE,CAAC,CACrF,KACCN,cAAO,eAAeM,aAAM,OAAO,MAAM,EACzCN,cAAO,UAAU,UACfI,oCAAqB,OAAO,OAAO,IAAI,QAAW,qBAAqB,MAAM,CAC9E,CACF;AAEH,UAAO;IACL;IACA,UAAU,eAAe;IACzB,QAAQ;KAAE,WAAW;KAAY,SAAS,eAAe;KAAS;IAClE;IACA;IACD;IACD;EACL;EACD,EACH,CACF,CAAC"}
@@ -36,7 +36,7 @@ declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService
36
36
  initializePlugin: <T extends AnyPlugin>(pluginInstance: PluginInstance<T>, config: {
37
37
  variables: InferSchemaInput<T["configSchema"]["variables"]>;
38
38
  secrets: InferSchemaInput<T["configSchema"]["secrets"]>;
39
- }) => Effect.Effect<{
39
+ }, plugins?: Record<string, unknown>) => Effect.Effect<{
40
40
  plugin: T;
41
41
  metadata: PluginMetadata;
42
42
  config: {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAemD,sBAAA;cAEtC,iBAAA,SAA0B,sBAAA;AAAA,cAGhC,iBAAA;cAEM,YAAA,SAAqB,iBAAA;AAAA,cAG3B,oBAAA;;+BAQkB,MAAA,CAAA,MAAA;;gBAsBb,cAAA;IAAA;;gBAUD,cAAA;IAAA;qCAIoB,MAAA,CAAA,MAAA,CAAA,oBAAA;EAAA;;cA1ClB,eAAA,SAAwB,oBAAA;AAAA,cA8C/B,wBAAA;;sCAc0B,MAAA,CAAA,MAAA;;;;kCA+CC,SAAA,EAAS,QAAA,UACtB,YAAA,EACF,YAAA,CAAa,CAAA,MAAE,MAAA,CAAA,MAAA;;;;iCAuBD,SAAA,EAAS,cAAA,EACrB,cAAA,CAAe,CAAA,GAAE,MAAA;MACvB,SAAA,EAAW,gBAAA,CAAiB,CAAA;MAAiC,OAAA,EAAS,gBAAA,CAAiB,CAAA;IAAA,MAA+B,MAAA,CAAA,MAAA;;;;;;;;;;;;cAtFvH,mBAAA,SAA4B,wBAAA"}
1
+ {"version":3,"file":"plugin-loader.service.d.cts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAemD,sBAAA;cAEtC,iBAAA,SAA0B,sBAAA;AAAA,cAGjC,iBAAA;cAEO,YAAA,SAAqB,iBAAA;AAAA,cAG5B,oBAAA;;+BAQsB,MAAA,CAAA,MAAA;;gBAsBT,cAAA;IAAA;;gBAUF,cAAA;IAAA;qCAIiB,MAAA,CAAA,MAAA,CAAA,oBAAA;EAAA;;cA1CrB,eAAA,SAAwB,oBAAA;AAAA,cA6ChC,wBAAA;;sCAcgC,MAAA,CAAA,MAAA;;;;kCAmDC,SAAA,EAAS,QAAA,UAAkB,YAAA,EAAgB,YAAA,CAAa,CAAA,MAAE,MAAA,CAAA,MAAA;;;;iCAgB3D,SAAA,EAAS,cAAA,EACpB,cAAA,CAAe,CAAA,GAAE,MAAA;MAE/B,SAAA,EAAW,gBAAA,CAAiB,CAAA;MAC5B,OAAA,EAAS,gBAAA,CAAiB,CAAA;IAAA,GAC3B,OAAA,GACS,MAAA,sBAAuB,MAAA,CAAA,MAAA;;;;;;;;;;;;cArF9B,mBAAA,SAA4B,wBAAA"}
@@ -36,7 +36,7 @@ declare const PluginLoaderService_base: Effect.Service.Class<PluginLoaderService
36
36
  initializePlugin: <T extends AnyPlugin>(pluginInstance: PluginInstance<T>, config: {
37
37
  variables: InferSchemaInput<T["configSchema"]["variables"]>;
38
38
  secrets: InferSchemaInput<T["configSchema"]["secrets"]>;
39
- }) => Effect.Effect<{
39
+ }, plugins?: Record<string, unknown>) => Effect.Effect<{
40
40
  plugin: T;
41
41
  metadata: PluginMetadata;
42
42
  config: {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAemD,sBAAA;cAEtC,iBAAA,SAA0B,sBAAA;AAAA,cAGhC,iBAAA;cAEM,YAAA,SAAqB,iBAAA;AAAA,cAG3B,oBAAA;;+BAQkB,MAAA,CAAA,MAAA;;gBAsBb,cAAA;IAAA;;gBAUD,cAAA;IAAA;qCAIoB,MAAA,CAAA,MAAA,CAAA,oBAAA;EAAA;;cA1ClB,eAAA,SAAwB,oBAAA;AAAA,cA8C/B,wBAAA;;sCAc0B,MAAA,CAAA,MAAA;;;;kCA+CC,SAAA,EAAS,QAAA,UACtB,YAAA,EACF,YAAA,CAAa,CAAA,MAAE,MAAA,CAAA,MAAA;;;;iCAuBD,SAAA,EAAS,cAAA,EACrB,cAAA,CAAe,CAAA,GAAE,MAAA;MACvB,SAAA,EAAW,gBAAA,CAAiB,CAAA;MAAiC,OAAA,EAAS,gBAAA,CAAiB,CAAA;IAAA,MAA+B,MAAA,CAAA,MAAA;;;;;;;;;;;;cAtFvH,mBAAA,SAA4B,wBAAA"}
1
+ {"version":3,"file":"plugin-loader.service.d.mts","names":[],"sources":["../../../src/runtime/services/plugin-loader.service.ts"],"mappings":";;;;;;;;cAemD,sBAAA;cAEtC,iBAAA,SAA0B,sBAAA;AAAA,cAGjC,iBAAA;cAEO,YAAA,SAAqB,iBAAA;AAAA,cAG5B,oBAAA;;+BAQsB,MAAA,CAAA,MAAA;;gBAsBT,cAAA;IAAA;;gBAUF,cAAA;IAAA;qCAIiB,MAAA,CAAA,MAAA,CAAA,oBAAA;EAAA;;cA1CrB,eAAA,SAAwB,oBAAA;AAAA,cA6ChC,wBAAA;;sCAcgC,MAAA,CAAA,MAAA;;;;kCAmDC,SAAA,EAAS,QAAA,UAAkB,YAAA,EAAgB,YAAA,CAAa,CAAA,MAAE,MAAA,CAAA,MAAA;;;;iCAgB3D,SAAA,EAAS,cAAA,EACpB,cAAA,CAAe,CAAA,GAAE,MAAA;MAE/B,SAAA,EAAW,gBAAA,CAAiB,CAAA;MAC5B,OAAA,EAAS,gBAAA,CAAiB,CAAA;IAAA,GAC3B,OAAA,GACS,MAAA,sBAAuB,MAAA,CAAA,MAAA;;;;;;;;;;;;cArF9B,mBAAA,SAA4B,wBAAA"}
@@ -80,7 +80,7 @@ var PluginLoaderService = class extends Effect.Service()("PluginLoaderService",
80
80
  metadata: loadedPlugin.metadata
81
81
  };
82
82
  }),
83
- initializePlugin: (pluginInstance, config) => Effect.gen(function* () {
83
+ initializePlugin: (pluginInstance, config, plugins) => Effect.gen(function* () {
84
84
  const { plugin } = pluginInstance;
85
85
  const validatedVariables = yield* validate(plugin.configSchema.variables, config.variables, plugin.id, "config").pipe(Effect.mapError((validationError) => new PluginRuntimeError({
86
86
  pluginId: plugin.id,
@@ -108,7 +108,7 @@ var PluginLoaderService = class extends Effect.Service()("PluginLoaderService",
108
108
  const context = yield* plugin.initialize({
109
109
  variables: _variables,
110
110
  secrets: hydratedConfig.secrets
111
- }).pipe(Effect.provideService(Scope.Scope, scope), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
111
+ }, plugins ?? {}).pipe(Effect.provideService(Scope.Scope, scope), Effect.mapError((error) => toPluginRuntimeError(error, plugin.id, void 0, "initialize-plugin", false)));
112
112
  return {
113
113
  plugin,
114
114
  metadata: pluginInstance.metadata,