every-plugin 2.10.1 → 3.0.0-rc.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) hide show
  1. package/bin/every-plugin-serve.mjs +12 -0
  2. package/bin/every-plugin.mjs +59 -0
  3. package/dist/_virtual/_rolldown/runtime.cjs +1 -2
  4. package/dist/build/artifact-names.cjs +119 -0
  5. package/dist/build/artifact-names.cjs.map +1 -0
  6. package/dist/build/artifact-names.d.cts +68 -0
  7. package/dist/build/artifact-names.d.cts.map +1 -0
  8. package/dist/build/artifact-names.d.mts +68 -0
  9. package/dist/build/artifact-names.d.mts.map +1 -0
  10. package/dist/build/artifact-names.mjs +102 -0
  11. package/dist/build/artifact-names.mjs.map +1 -0
  12. package/dist/build/contract-types.cjs +89 -0
  13. package/dist/build/contract-types.cjs.map +1 -0
  14. package/dist/build/contract-types.mjs +81 -0
  15. package/dist/build/contract-types.mjs.map +1 -0
  16. package/dist/build/rspack/build-report-plugin.cjs +37 -0
  17. package/dist/build/rspack/build-report-plugin.cjs.map +1 -0
  18. package/dist/build/rspack/build-report-plugin.d.cts +18 -0
  19. package/dist/build/rspack/build-report-plugin.d.cts.map +1 -0
  20. package/dist/build/rspack/build-report-plugin.d.mts +18 -0
  21. package/dist/build/rspack/build-report-plugin.d.mts.map +1 -0
  22. package/dist/build/rspack/build-report-plugin.mjs +37 -0
  23. package/dist/build/rspack/build-report-plugin.mjs.map +1 -0
  24. package/dist/build/rspack/chunk-completeness-plugin.cjs +59 -0
  25. package/dist/build/rspack/chunk-completeness-plugin.cjs.map +1 -0
  26. package/dist/build/rspack/chunk-completeness-plugin.mjs +59 -0
  27. package/dist/build/rspack/chunk-completeness-plugin.mjs.map +1 -0
  28. package/dist/build/rspack/compose.cjs +69 -0
  29. package/dist/build/rspack/compose.cjs.map +1 -0
  30. package/dist/build/rspack/compose.d.cts +20 -0
  31. package/dist/build/rspack/compose.d.cts.map +1 -0
  32. package/dist/build/rspack/compose.d.mts +20 -0
  33. package/dist/build/rspack/compose.d.mts.map +1 -0
  34. package/dist/build/rspack/compose.mjs +65 -0
  35. package/dist/build/rspack/compose.mjs.map +1 -0
  36. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs +11 -11
  37. package/dist/build/rspack/fix-mf-data-uri-plugin.cjs.map +1 -1
  38. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts +2 -0
  39. package/dist/build/rspack/fix-mf-data-uri-plugin.d.cts.map +1 -1
  40. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts +2 -0
  41. package/dist/build/rspack/fix-mf-data-uri-plugin.d.mts.map +1 -1
  42. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs +11 -10
  43. package/dist/build/rspack/fix-mf-data-uri-plugin.mjs.map +1 -1
  44. package/dist/build/rspack/generated-config.cjs +35 -0
  45. package/dist/build/rspack/generated-config.cjs.map +1 -0
  46. package/dist/build/rspack/generated-config.mjs +32 -0
  47. package/dist/build/rspack/generated-config.mjs.map +1 -0
  48. package/dist/build/rspack/index.cjs +8 -5
  49. package/dist/build/rspack/index.d.cts +5 -3
  50. package/dist/build/rspack/index.d.mts +5 -3
  51. package/dist/build/rspack/index.mjs +5 -3
  52. package/dist/build/rspack/module-federation.cjs +2 -2
  53. package/dist/build/rspack/module-federation.cjs.map +1 -1
  54. package/dist/build/rspack/module-federation.mjs +1 -1
  55. package/dist/build/rspack/module-federation.mjs.map +1 -1
  56. package/dist/build/rspack/plugin.cjs +44 -69
  57. package/dist/build/rspack/plugin.cjs.map +1 -1
  58. package/dist/build/rspack/plugin.d.cts +4 -13
  59. package/dist/build/rspack/plugin.d.cts.map +1 -1
  60. package/dist/build/rspack/plugin.d.mts +4 -13
  61. package/dist/build/rspack/plugin.d.mts.map +1 -1
  62. package/dist/build/rspack/plugin.mjs +44 -69
  63. package/dist/build/rspack/plugin.mjs.map +1 -1
  64. package/dist/build/rspack/utils.cjs +7 -5
  65. package/dist/build/rspack/utils.cjs.map +1 -1
  66. package/dist/build/rspack/utils.mjs +7 -6
  67. package/dist/build/rspack/utils.mjs.map +1 -1
  68. package/dist/build/ui/factory.cjs +88 -0
  69. package/dist/build/ui/factory.cjs.map +1 -0
  70. package/dist/build/ui/factory.d.cts +11 -0
  71. package/dist/build/ui/factory.d.cts.map +1 -0
  72. package/dist/build/ui/factory.d.mts +11 -0
  73. package/dist/build/ui/factory.d.mts.map +1 -0
  74. package/dist/build/ui/factory.mjs +80 -0
  75. package/dist/build/ui/factory.mjs.map +1 -0
  76. package/dist/build/ui/generated-config.cjs +122 -0
  77. package/dist/build/ui/generated-config.cjs.map +1 -0
  78. package/dist/build/ui/generated-config.d.cts +33 -0
  79. package/dist/build/ui/generated-config.d.cts.map +1 -0
  80. package/dist/build/ui/generated-config.d.mts +33 -0
  81. package/dist/build/ui/generated-config.d.mts.map +1 -0
  82. package/dist/build/ui/generated-config.mjs +114 -0
  83. package/dist/build/ui/generated-config.mjs.map +1 -0
  84. package/dist/build/ui/hash-artifacts-plugin.cjs +61 -0
  85. package/dist/build/ui/hash-artifacts-plugin.cjs.map +1 -0
  86. package/dist/build/ui/hash-artifacts-plugin.d.cts +20 -0
  87. package/dist/build/ui/hash-artifacts-plugin.d.cts.map +1 -0
  88. package/dist/build/ui/hash-artifacts-plugin.d.mts +20 -0
  89. package/dist/build/ui/hash-artifacts-plugin.d.mts.map +1 -0
  90. package/dist/build/ui/hash-artifacts-plugin.mjs +58 -0
  91. package/dist/build/ui/hash-artifacts-plugin.mjs.map +1 -0
  92. package/dist/build/ui/index.cjs +90 -0
  93. package/dist/build/ui/index.cjs.map +1 -0
  94. package/dist/build/ui/index.d.cts +29 -0
  95. package/dist/build/ui/index.d.cts.map +1 -0
  96. package/dist/build/ui/index.d.mts +29 -0
  97. package/dist/build/ui/index.d.mts.map +1 -0
  98. package/dist/build/ui/index.mjs +68 -0
  99. package/dist/build/ui/index.mjs.map +1 -0
  100. package/dist/build/ui/manifest-plugin.cjs +37 -0
  101. package/dist/build/ui/manifest-plugin.cjs.map +1 -0
  102. package/dist/build/ui/manifest-plugin.d.cts +19 -0
  103. package/dist/build/ui/manifest-plugin.d.cts.map +1 -0
  104. package/dist/build/ui/manifest-plugin.d.mts +19 -0
  105. package/dist/build/ui/manifest-plugin.d.mts.map +1 -0
  106. package/dist/build/ui/manifest-plugin.mjs +37 -0
  107. package/dist/build/ui/manifest-plugin.mjs.map +1 -0
  108. package/dist/build/ui/rsbuild-config.cjs +203 -0
  109. package/dist/build/ui/rsbuild-config.cjs.map +1 -0
  110. package/dist/build/ui/rsbuild-config.d.cts +45 -0
  111. package/dist/build/ui/rsbuild-config.d.cts.map +1 -0
  112. package/dist/build/ui/rsbuild-config.d.mts +45 -0
  113. package/dist/build/ui/rsbuild-config.d.mts.map +1 -0
  114. package/dist/build/ui/rsbuild-config.mjs +200 -0
  115. package/dist/build/ui/rsbuild-config.mjs.map +1 -0
  116. package/dist/build/ui/stubs.cjs +107 -0
  117. package/dist/build/ui/stubs.cjs.map +1 -0
  118. package/dist/build/ui/stubs.d.cts +25 -0
  119. package/dist/build/ui/stubs.d.cts.map +1 -0
  120. package/dist/build/ui/stubs.d.mts +25 -0
  121. package/dist/build/ui/stubs.d.mts.map +1 -0
  122. package/dist/build/ui/stubs.mjs +106 -0
  123. package/dist/build/ui/stubs.mjs.map +1 -0
  124. package/dist/cli.cjs +83 -0
  125. package/dist/cli.cjs.map +1 -0
  126. package/dist/cli.d.cts +6 -0
  127. package/dist/cli.d.cts.map +1 -0
  128. package/dist/cli.d.mts +6 -0
  129. package/dist/cli.d.mts.map +1 -0
  130. package/dist/cli.mjs +82 -0
  131. package/dist/cli.mjs.map +1 -0
  132. package/dist/client.cjs +69 -0
  133. package/dist/client.cjs.map +1 -0
  134. package/dist/client.d.cts +15 -0
  135. package/dist/client.d.cts.map +1 -0
  136. package/dist/client.d.mts +15 -0
  137. package/dist/client.d.mts.map +1 -0
  138. package/dist/client.mjs +68 -0
  139. package/dist/client.mjs.map +1 -0
  140. package/dist/dev/host.cjs +149 -0
  141. package/dist/dev/host.cjs.map +1 -0
  142. package/dist/dev/host.d.cts +32 -0
  143. package/dist/dev/host.d.cts.map +1 -0
  144. package/dist/dev/host.d.mts +32 -0
  145. package/dist/dev/host.d.mts.map +1 -0
  146. package/dist/dev/host.mjs +148 -0
  147. package/dist/dev/host.mjs.map +1 -0
  148. package/dist/dev/serve.cjs +295 -0
  149. package/dist/dev/serve.cjs.map +1 -0
  150. package/dist/dev/serve.d.cts +23 -0
  151. package/dist/dev/serve.d.cts.map +1 -0
  152. package/dist/dev/serve.d.mts +23 -0
  153. package/dist/dev/serve.d.mts.map +1 -0
  154. package/dist/dev/serve.mjs +289 -0
  155. package/dist/dev/serve.mjs.map +1 -0
  156. package/dist/dev/watch-kill.cjs +39 -0
  157. package/dist/dev/watch-kill.cjs.map +1 -0
  158. package/dist/dev/watch-kill.mjs +38 -0
  159. package/dist/dev/watch-kill.mjs.map +1 -0
  160. package/dist/effect-helpers.cjs +23 -0
  161. package/dist/effect-helpers.cjs.map +1 -0
  162. package/dist/effect-helpers.d.cts +20 -0
  163. package/dist/effect-helpers.d.cts.map +1 -0
  164. package/dist/effect-helpers.d.mts +20 -0
  165. package/dist/effect-helpers.d.mts.map +1 -0
  166. package/dist/effect-helpers.mjs +22 -0
  167. package/dist/effect-helpers.mjs.map +1 -0
  168. package/dist/errors.cjs +50 -69
  169. package/dist/errors.cjs.map +1 -1
  170. package/dist/errors.d.cts +13 -96
  171. package/dist/errors.d.cts.map +1 -1
  172. package/dist/errors.d.mts +13 -96
  173. package/dist/errors.d.mts.map +1 -1
  174. package/dist/errors.mjs +16 -34
  175. package/dist/errors.mjs.map +1 -1
  176. package/dist/identity.cjs +19 -0
  177. package/dist/identity.cjs.map +1 -0
  178. package/dist/identity.d.cts +33 -0
  179. package/dist/identity.d.cts.map +1 -0
  180. package/dist/identity.d.mts +33 -0
  181. package/dist/identity.d.mts.map +1 -0
  182. package/dist/identity.mjs +16 -0
  183. package/dist/identity.mjs.map +1 -0
  184. package/dist/index.cjs +11 -5
  185. package/dist/index.d.cts +9 -6
  186. package/dist/index.d.mts +9 -6
  187. package/dist/index.mjs +7 -4
  188. package/dist/plugin.cjs +13 -26
  189. package/dist/plugin.cjs.map +1 -1
  190. package/dist/plugin.d.cts +64 -25
  191. package/dist/plugin.d.cts.map +1 -1
  192. package/dist/plugin.d.mts +64 -25
  193. package/dist/plugin.d.mts.map +1 -1
  194. package/dist/plugin.mjs +16 -29
  195. package/dist/plugin.mjs.map +1 -1
  196. package/dist/remote-entry.cjs +102 -0
  197. package/dist/remote-entry.cjs.map +1 -0
  198. package/dist/remote-entry.d.cts +52 -0
  199. package/dist/remote-entry.d.cts.map +1 -0
  200. package/dist/remote-entry.d.mts +52 -0
  201. package/dist/remote-entry.d.mts.map +1 -0
  202. package/dist/remote-entry.mjs +98 -0
  203. package/dist/remote-entry.mjs.map +1 -0
  204. package/dist/runtime/errors.cjs +159 -33
  205. package/dist/runtime/errors.cjs.map +1 -1
  206. package/dist/runtime/errors.d.cts +64 -7
  207. package/dist/runtime/errors.d.cts.map +1 -1
  208. package/dist/runtime/errors.d.mts +64 -7
  209. package/dist/runtime/errors.d.mts.map +1 -1
  210. package/dist/runtime/errors.mjs +154 -30
  211. package/dist/runtime/errors.mjs.map +1 -1
  212. package/dist/runtime/index.cjs +95 -23
  213. package/dist/runtime/index.cjs.map +1 -1
  214. package/dist/runtime/index.d.cts +16 -0
  215. package/dist/runtime/index.d.cts.map +1 -1
  216. package/dist/runtime/index.d.mts +16 -0
  217. package/dist/runtime/index.d.mts.map +1 -1
  218. package/dist/runtime/index.mjs +98 -26
  219. package/dist/runtime/index.mjs.map +1 -1
  220. package/dist/runtime/mf-config.cjs +3 -78
  221. package/dist/runtime/mf-config.cjs.map +1 -1
  222. package/dist/runtime/mf-config.d.cts +3 -49
  223. package/dist/runtime/mf-config.d.cts.map +1 -1
  224. package/dist/runtime/mf-config.d.mts +3 -49
  225. package/dist/runtime/mf-config.d.mts.map +1 -1
  226. package/dist/runtime/mf-config.mjs +5 -78
  227. package/dist/runtime/mf-config.mjs.map +1 -1
  228. package/dist/runtime/services/module-federation.service.cjs +57 -12
  229. package/dist/runtime/services/module-federation.service.cjs.map +1 -1
  230. package/dist/runtime/services/module-federation.service.d.cts +4 -13
  231. package/dist/runtime/services/module-federation.service.d.mts +4 -13
  232. package/dist/runtime/services/module-federation.service.mjs +57 -14
  233. package/dist/runtime/services/module-federation.service.mjs.map +1 -1
  234. package/dist/runtime/services/normalize.cjs +2 -22
  235. package/dist/runtime/services/normalize.d.cts +2 -21
  236. package/dist/runtime/services/normalize.d.mts +2 -21
  237. package/dist/runtime/services/normalize.mjs +2 -21
  238. package/dist/runtime/services/plugin-lifecycle.service.cjs +9 -11
  239. package/dist/runtime/services/plugin-lifecycle.service.cjs.map +1 -1
  240. package/dist/runtime/services/plugin-lifecycle.service.d.cts +3 -16
  241. package/dist/runtime/services/plugin-lifecycle.service.d.mts +3 -16
  242. package/dist/runtime/services/plugin-lifecycle.service.mjs +10 -13
  243. package/dist/runtime/services/plugin-lifecycle.service.mjs.map +1 -1
  244. package/dist/runtime/services/plugin-loader.service.cjs +59 -30
  245. package/dist/runtime/services/plugin-loader.service.cjs.map +1 -1
  246. package/dist/runtime/services/plugin-loader.service.d.cts +6 -53
  247. package/dist/runtime/services/plugin-loader.service.d.mts +6 -53
  248. package/dist/runtime/services/plugin-loader.service.mjs +58 -31
  249. package/dist/runtime/services/plugin-loader.service.mjs.map +1 -1
  250. package/dist/runtime/services/plugin.service.cjs +10 -12
  251. package/dist/runtime/services/plugin.service.cjs.map +1 -1
  252. package/dist/runtime/services/plugin.service.d.cts +14 -36
  253. package/dist/runtime/services/plugin.service.d.cts.map +1 -1
  254. package/dist/runtime/services/plugin.service.d.mts +14 -36
  255. package/dist/runtime/services/plugin.service.d.mts.map +1 -1
  256. package/dist/runtime/services/plugin.service.mjs +14 -18
  257. package/dist/runtime/services/plugin.service.mjs.map +1 -1
  258. package/dist/runtime/services/secrets.service.cjs +12 -12
  259. package/dist/runtime/services/secrets.service.cjs.map +1 -1
  260. package/dist/runtime/services/secrets.service.d.cts +3 -15
  261. package/dist/runtime/services/secrets.service.d.mts +3 -15
  262. package/dist/runtime/services/secrets.service.mjs +12 -13
  263. package/dist/runtime/services/secrets.service.mjs.map +1 -1
  264. package/dist/runtime/services/shared-identity.cjs +40 -0
  265. package/dist/runtime/services/shared-identity.cjs.map +1 -0
  266. package/dist/runtime/services/shared-identity.mjs +38 -0
  267. package/dist/runtime/services/shared-identity.mjs.map +1 -0
  268. package/dist/runtime/validation.cjs +2 -2
  269. package/dist/runtime/validation.cjs.map +1 -1
  270. package/dist/runtime/validation.mjs +2 -2
  271. package/dist/runtime/validation.mjs.map +1 -1
  272. package/dist/shared-deps-spec.cjs +384 -0
  273. package/dist/shared-deps-spec.cjs.map +1 -0
  274. package/dist/shared-deps-spec.d.cts +182 -0
  275. package/dist/shared-deps-spec.d.cts.map +1 -0
  276. package/dist/shared-deps-spec.d.mts +182 -0
  277. package/dist/shared-deps-spec.d.mts.map +1 -0
  278. package/dist/shared-deps-spec.mjs +368 -0
  279. package/dist/shared-deps-spec.mjs.map +1 -0
  280. package/dist/types.d.cts +47 -41
  281. package/dist/types.d.cts.map +1 -1
  282. package/dist/types.d.mts +47 -41
  283. package/dist/types.d.mts.map +1 -1
  284. package/dist/ui/manifest/construct.cjs +319 -0
  285. package/dist/ui/manifest/construct.cjs.map +1 -0
  286. package/dist/ui/manifest/construct.d.cts +48 -0
  287. package/dist/ui/manifest/construct.d.cts.map +1 -0
  288. package/dist/ui/manifest/construct.d.mts +48 -0
  289. package/dist/ui/manifest/construct.d.mts.map +1 -0
  290. package/dist/ui/manifest/construct.mjs +319 -0
  291. package/dist/ui/manifest/construct.mjs.map +1 -0
  292. package/dist/ui/manifest/contract.cjs +34 -0
  293. package/dist/ui/manifest/contract.cjs.map +1 -0
  294. package/dist/ui/manifest/contract.d.cts +26 -0
  295. package/dist/ui/manifest/contract.d.cts.map +1 -0
  296. package/dist/ui/manifest/contract.d.mts +26 -0
  297. package/dist/ui/manifest/contract.d.mts.map +1 -0
  298. package/dist/ui/manifest/contract.mjs +26 -0
  299. package/dist/ui/manifest/contract.mjs.map +1 -0
  300. package/dist/ui/manifest/descriptor.cjs +64 -0
  301. package/dist/ui/manifest/descriptor.cjs.map +1 -0
  302. package/dist/ui/manifest/descriptor.d.cts +60 -0
  303. package/dist/ui/manifest/descriptor.d.cts.map +1 -0
  304. package/dist/ui/manifest/descriptor.d.mts +60 -0
  305. package/dist/ui/manifest/descriptor.d.mts.map +1 -0
  306. package/dist/ui/manifest/descriptor.mjs +61 -0
  307. package/dist/ui/manifest/descriptor.mjs.map +1 -0
  308. package/dist/ui/manifest/generator.cjs +128 -0
  309. package/dist/ui/manifest/generator.cjs.map +1 -0
  310. package/dist/ui/manifest/generator.d.cts +41 -0
  311. package/dist/ui/manifest/generator.d.cts.map +1 -0
  312. package/dist/ui/manifest/generator.d.mts +41 -0
  313. package/dist/ui/manifest/generator.d.mts.map +1 -0
  314. package/dist/ui/manifest/generator.mjs +125 -0
  315. package/dist/ui/manifest/generator.mjs.map +1 -0
  316. package/dist/ui/manifest/index.cjs +35 -0
  317. package/dist/ui/manifest/index.d.cts +9 -0
  318. package/dist/ui/manifest/index.d.mts +9 -0
  319. package/dist/ui/manifest/index.mjs +9 -0
  320. package/dist/ui/manifest/manifest-schema.cjs +97 -0
  321. package/dist/ui/manifest/manifest-schema.cjs.map +1 -0
  322. package/dist/ui/manifest/manifest-schema.d.cts +132 -0
  323. package/dist/ui/manifest/manifest-schema.d.cts.map +1 -0
  324. package/dist/ui/manifest/manifest-schema.d.mts +132 -0
  325. package/dist/ui/manifest/manifest-schema.d.mts.map +1 -0
  326. package/dist/ui/manifest/manifest-schema.mjs +90 -0
  327. package/dist/ui/manifest/manifest-schema.mjs.map +1 -0
  328. package/dist/ui/manifest/mount-registry.cjs +52 -0
  329. package/dist/ui/manifest/mount-registry.cjs.map +1 -0
  330. package/dist/ui/manifest/mount-registry.d.cts +61 -0
  331. package/dist/ui/manifest/mount-registry.d.cts.map +1 -0
  332. package/dist/ui/manifest/mount-registry.d.mts +61 -0
  333. package/dist/ui/manifest/mount-registry.d.mts.map +1 -0
  334. package/dist/ui/manifest/mount-registry.mjs +48 -0
  335. package/dist/ui/manifest/mount-registry.mjs.map +1 -0
  336. package/dist/ui/manifest/nav.cjs +13 -0
  337. package/dist/ui/manifest/nav.cjs.map +1 -0
  338. package/dist/ui/manifest/nav.d.cts +34 -0
  339. package/dist/ui/manifest/nav.d.cts.map +1 -0
  340. package/dist/ui/manifest/nav.d.mts +34 -0
  341. package/dist/ui/manifest/nav.d.mts.map +1 -0
  342. package/dist/ui/manifest/nav.mjs +13 -0
  343. package/dist/ui/manifest/nav.mjs.map +1 -0
  344. package/dist/ui/manifest/route-config.cjs +33 -0
  345. package/dist/ui/manifest/route-config.cjs.map +1 -0
  346. package/dist/ui/manifest/route-config.d.cts +40 -0
  347. package/dist/ui/manifest/route-config.d.cts.map +1 -0
  348. package/dist/ui/manifest/route-config.d.mts +40 -0
  349. package/dist/ui/manifest/route-config.d.mts.map +1 -0
  350. package/dist/ui/manifest/route-config.mjs +33 -0
  351. package/dist/ui/manifest/route-config.mjs.map +1 -0
  352. package/dist/version-manifest.cjs +77 -0
  353. package/dist/version-manifest.cjs.map +1 -0
  354. package/dist/version-manifest.d.cts +62 -0
  355. package/dist/version-manifest.d.cts.map +1 -0
  356. package/dist/version-manifest.d.mts +62 -0
  357. package/dist/version-manifest.d.mts.map +1 -0
  358. package/dist/version-manifest.mjs +75 -0
  359. package/dist/version-manifest.mjs.map +1 -0
  360. package/package.json +182 -68
  361. package/skills/plugin-client/SKILL.md +34 -9
  362. package/skills/plugin-development/SKILL.md +79 -47
  363. package/skills/plugin-testing/SKILL.md +42 -12
  364. package/src/build/artifact-names.ts +117 -0
  365. package/src/build/contract-types.ts +101 -0
  366. package/src/build/rspack/build-report-plugin.ts +34 -0
  367. package/src/build/rspack/chunk-completeness-plugin.ts +66 -0
  368. package/src/build/rspack/compose.ts +87 -0
  369. package/src/build/rspack/fix-mf-data-uri-plugin.ts +23 -12
  370. package/src/build/rspack/generated-config.ts +35 -0
  371. package/src/build/rspack/index.ts +10 -5
  372. package/src/build/rspack/module-federation.ts +1 -1
  373. package/src/build/rspack/plugin.ts +103 -105
  374. package/src/build/rspack/utils.ts +8 -2
  375. package/src/build/ui/factory.ts +96 -0
  376. package/src/build/ui/generated-config.ts +137 -0
  377. package/src/build/ui/hash-artifacts-plugin.ts +79 -0
  378. package/src/build/ui/index.ts +98 -0
  379. package/src/build/ui/manifest-plugin.ts +54 -0
  380. package/src/build/ui/rsbuild-config.ts +256 -0
  381. package/src/build/ui/stubs.ts +103 -0
  382. package/src/cli.ts +100 -0
  383. package/src/client.ts +111 -0
  384. package/src/dev/host.ts +235 -0
  385. package/src/dev/serve.ts +359 -0
  386. package/src/dev/watch-kill.ts +58 -0
  387. package/src/effect-helpers.ts +25 -0
  388. package/src/errors.ts +17 -18
  389. package/src/identity.ts +36 -0
  390. package/src/index.ts +13 -0
  391. package/src/plugin.ts +94 -91
  392. package/src/remote-entry.ts +170 -0
  393. package/src/runtime/errors.ts +229 -26
  394. package/src/runtime/index.ts +132 -43
  395. package/src/runtime/mf-config.ts +12 -107
  396. package/src/runtime/services/module-federation.service.ts +218 -117
  397. package/src/runtime/services/normalize.ts +1 -18
  398. package/src/runtime/services/plugin-lifecycle.service.ts +66 -75
  399. package/src/runtime/services/plugin-loader.service.ts +280 -209
  400. package/src/runtime/services/plugin.service.ts +61 -43
  401. package/src/runtime/services/secrets.service.ts +20 -15
  402. package/src/runtime/services/shared-identity.ts +68 -0
  403. package/src/runtime/validation.ts +5 -7
  404. package/src/shared-deps-spec.ts +478 -0
  405. package/src/types.ts +62 -50
  406. package/src/ui/manifest/construct.ts +456 -0
  407. package/src/ui/manifest/contract.ts +33 -0
  408. package/src/ui/manifest/descriptor.ts +96 -0
  409. package/src/ui/manifest/generator.ts +238 -0
  410. package/src/ui/manifest/index.ts +55 -0
  411. package/src/ui/manifest/manifest-schema.ts +107 -0
  412. package/src/ui/manifest/mount-registry.ts +50 -0
  413. package/src/ui/manifest/nav.ts +43 -0
  414. package/src/ui/manifest/route-config.ts +82 -0
  415. package/src/version-manifest.ts +106 -0
  416. package/dist/build/rspack/dev-server-middleware.cjs +0 -248
  417. package/dist/build/rspack/dev-server-middleware.cjs.map +0 -1
  418. package/dist/build/rspack/dev-server-middleware.mjs +0 -247
  419. package/dist/build/rspack/dev-server-middleware.mjs.map +0 -1
  420. package/dist/build/shared-deps.cjs +0 -83
  421. package/dist/build/shared-deps.cjs.map +0 -1
  422. package/dist/build/shared-deps.d.cts +0 -67
  423. package/dist/build/shared-deps.d.cts.map +0 -1
  424. package/dist/build/shared-deps.d.mts +0 -67
  425. package/dist/build/shared-deps.d.mts.map +0 -1
  426. package/dist/build/shared-deps.mjs +0 -79
  427. package/dist/build/shared-deps.mjs.map +0 -1
  428. package/dist/effect.cjs +0 -9
  429. package/dist/effect.d.cts +0 -1
  430. package/dist/effect.d.mts +0 -1
  431. package/dist/effect.mjs +0 -3
  432. package/dist/orpc-openapi.cjs +0 -17
  433. package/dist/orpc-openapi.d.cts +0 -2
  434. package/dist/orpc-openapi.d.mts +0 -2
  435. package/dist/orpc-openapi.mjs +0 -5
  436. package/dist/orpc.cjs +0 -46
  437. package/dist/orpc.d.cts +0 -7
  438. package/dist/orpc.d.mts +0 -7
  439. package/dist/orpc.mjs +0 -11
  440. package/dist/package.cjs +0 -23
  441. package/dist/package.cjs.map +0 -1
  442. package/dist/package.mjs +0 -17
  443. package/dist/package.mjs.map +0 -1
  444. package/dist/runtime/services/module-federation.service.d.cts.map +0 -1
  445. package/dist/runtime/services/module-federation.service.d.mts.map +0 -1
  446. package/dist/runtime/services/normalize.cjs.map +0 -1
  447. package/dist/runtime/services/normalize.d.cts.map +0 -1
  448. package/dist/runtime/services/normalize.d.mts.map +0 -1
  449. package/dist/runtime/services/normalize.mjs.map +0 -1
  450. package/dist/runtime/services/plugin-lifecycle.service.d.cts.map +0 -1
  451. package/dist/runtime/services/plugin-lifecycle.service.d.mts.map +0 -1
  452. package/dist/runtime/services/plugin-loader.service.d.cts.map +0 -1
  453. package/dist/runtime/services/plugin-loader.service.d.mts.map +0 -1
  454. package/dist/runtime/services/secrets.service.d.cts.map +0 -1
  455. package/dist/runtime/services/secrets.service.d.mts.map +0 -1
  456. package/dist/testing/index.cjs +0 -57
  457. package/dist/testing/index.cjs.map +0 -1
  458. package/dist/testing/index.d.cts +0 -54
  459. package/dist/testing/index.d.cts.map +0 -1
  460. package/dist/testing/index.d.mts +0 -54
  461. package/dist/testing/index.d.mts.map +0 -1
  462. package/dist/testing/index.mjs +0 -55
  463. package/dist/testing/index.mjs.map +0 -1
  464. package/dist/zod-core.cjs +0 -9
  465. package/dist/zod-core.d.cts +0 -1
  466. package/dist/zod-core.d.mts +0 -1
  467. package/dist/zod-core.mjs +0 -3
  468. package/dist/zod.cjs +0 -11
  469. package/dist/zod.d.cts +0 -2
  470. package/dist/zod.d.mts +0 -2
  471. package/dist/zod.mjs +0 -3
  472. package/src/build/rspack/dev-server-middleware.ts +0 -324
  473. package/src/build/shared-deps.ts +0 -102
  474. package/src/effect.ts +0 -1
  475. package/src/orpc-openapi.ts +0 -2
  476. package/src/orpc.ts +0 -9
  477. package/src/testing/index.ts +0 -87
  478. package/src/testing/mocks/module-federation.service.ts +0 -41
  479. package/src/zod-core.ts +0 -1
  480. package/src/zod.ts +0 -3
package/src/plugin.ts CHANGED
@@ -1,9 +1,12 @@
1
1
  import type { AnyContractRouter, AnySchema, InferSchemaOutput } from "@orpc/contract";
2
- import { ORPCError } from "@orpc/contract";
3
- import type { Implementer, Router } from "@orpc/server";
4
- import { implement, onError } from "@orpc/server";
5
- import { Context, Effect, type Context as EffectContext, type Layer, type Scope } from "effect";
6
- import { extractFromFiberFailure, formatORPCError } from "./runtime/errors";
2
+ import type { WithEffectContext } from "@orpc/experimental-effect";
3
+ import "@orpc/experimental-effect/extensions/effect";
4
+ import type { ContractedRouter, Implementer } from "@orpc/server";
5
+ import { implement } from "@orpc/server";
6
+ import type { Scope } from "effect";
7
+ import { Context, Effect, Layer } from "effect";
8
+ import type { PluginWarningInfo } from "./runtime/errors";
9
+ import { type PluginRuntimeError, toPluginRuntimeError } from "./runtime/errors";
7
10
 
8
11
  type ContextOutput<T> = T extends AnySchema ? InferSchemaOutput<T> : Record<string, never>;
9
12
 
@@ -17,28 +20,39 @@ export type PluginConfigFor<
17
20
  context: TRequestContext;
18
21
  };
19
22
 
20
- type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
23
+ export type PluginInitializeInput<V extends AnySchema, S extends AnySchema> = {
24
+ /**
25
+ * The framework-assigned plugin id — the same key the host uses for secret
26
+ * injection and per-plugin database namespacing. Arrives as a value so
27
+ * plugin code never needs the ambient `PluginIdTag`.
28
+ */
29
+ pluginId: string;
21
30
  variables: InferSchemaOutput<V>;
22
31
  secrets: InferSchemaOutput<S>;
23
32
  };
24
33
 
25
34
  /**
26
- * Tools provided to plugin initialize/services for building long-lived scoped resources.
35
+ * A plugin's own config-derived warnings, evaluated once with the validated
36
+ * config after initialization. Declaring `warnings` opts the plugin out of
37
+ * the loader's default missing-secret warning — these messages replace it.
27
38
  */
28
- type ServiceOf<T> = T extends EffectContext.Tag<any, infer S> ? S : never;
39
+ export type PluginWarningsFn<V extends AnySchema, S extends AnySchema> = (
40
+ config: PluginInitializeInput<V, S>,
41
+ ) => PluginWarningInfo[] | string[];
29
42
 
30
- export type PluginServicesTools = {
31
- buildService: <T>(tag: T, layer: Layer.Layer<any, any, any>) => Effect.Effect<ServiceOf<T>>;
32
- };
43
+ export class PluginIdTag extends Context.Service<PluginIdTag, string>()("PluginId") {}
33
44
 
34
- export class PluginIdTag extends Context.Tag("PluginId")<PluginIdTag, string>() {}
45
+ /**
46
+ * The `initialize` effect's environment: the plugin lifecycle scope plus the
47
+ * framework-assigned plugin id.
48
+ */
49
+ export type PluginEnv = Scope.Scope | PluginIdTag;
35
50
 
36
51
  type PluginDefinition<
37
52
  V extends AnySchema,
38
53
  S extends AnySchema,
39
54
  TContract extends AnyContractRouter,
40
55
  TRequestContext extends AnySchema | undefined,
41
- TDeps extends Record<string, any>,
42
56
  P extends Record<string, unknown>,
43
57
  > = {
44
58
  variables: V;
@@ -46,20 +60,42 @@ type PluginDefinition<
46
60
  contract: TContract;
47
61
  context?: TRequestContext;
48
62
  /**
49
- * Initialize the plugin and build dependencies.
50
- * A third argument `tools` is provided for building long-lived scoped resources
51
- * (e.g. database pools) via `tools.buildService(tag, layer)`.
63
+ * Optional tag under which `initialize` exposes the plugin's services.
64
+ * The host uses it to read services (e.g. the auth plugin's Better Auth
65
+ * handler) from the built Effect context without importing the plugin
66
+ * module statically.
67
+ */
68
+ servicesTag?: Context.Key<any, any>;
69
+ /**
70
+ * Optional warnings function evaluated once with the validated config after
71
+ * initialization. Returns structured non-fatal warnings (e.g. an optional
72
+ * secret was not set, so the feature depending on it is disabled).
73
+ * Declaring it opts out of the loader's default missing-secret warning.
74
+ */
75
+ warnings?: PluginWarningsFn<V, S>;
76
+ /**
77
+ * Initialize the plugin by returning an Effect `Layer`.
78
+ *
79
+ * The runtime builds the Layer against the plugin's lifecycle scope —
80
+ * scoped resources (db pools, repositories, caches, publishers) release
81
+ * when the plugin shuts down. Services are provided to `.effect()`
82
+ * handlers via the oRPC context (`yield* Tag`).
52
83
  */
53
84
  initialize?: (
54
85
  config: PluginInitializeInput<V, S>,
55
86
  plugins: P,
56
- tools: PluginServicesTools,
57
- ) => Effect.Effect<TDeps, Error, Scope.Scope>;
87
+ ) => Effect.Effect<Layer.Layer<any, Error, PluginEnv>, Error, PluginEnv>;
88
+ /**
89
+ * Creates the strongly-typed oRPC router for this plugin.
90
+ * Services come from the Effect context — access them with
91
+ * `yield* Tag` in `.effect()` handlers, or
92
+ * `Context.get(context["effect/context"], Tag)` in plain handlers.
93
+ * Sibling plugin entries in `plugins` carry `{ client, router }`.
94
+ */
58
95
  createRouter: (
59
- deps: TDeps,
60
- builder: Implementer<TContract, ContextOutput<TRequestContext>, ContextOutput<TRequestContext>>,
61
- ) => Router<TContract, any>;
62
- shutdown?: (deps: TDeps) => Effect.Effect<void, Error, never>;
96
+ builder: Implementer<TContract, ContextOutput<TRequestContext> & WithEffectContext<any>>,
97
+ plugins: P,
98
+ ) => ContractedRouter<TContract, any>;
63
99
  };
64
100
 
65
101
  /**
@@ -70,14 +106,14 @@ export interface LoadedPluginWithBinding<
70
106
  TVariables extends AnySchema,
71
107
  TSecrets extends AnySchema,
72
108
  TRequestContext extends AnySchema | undefined,
73
- TDeps extends Record<string, any> = Record<never, never>,
74
109
  > {
75
- new (): Plugin<TContract, TVariables, TSecrets, TRequestContext, TDeps>;
110
+ new (): Plugin<TContract, TVariables, TSecrets, TRequestContext>;
76
111
  binding: {
77
112
  contract: TContract;
78
113
  variables: TVariables;
79
114
  secrets: TSecrets;
80
115
  context: TRequestContext;
116
+ servicesTag?: Context.Key<any, any>;
81
117
  };
82
118
  }
83
119
 
@@ -89,27 +125,26 @@ export interface Plugin<
89
125
  TVariables extends AnySchema,
90
126
  TSecrets extends AnySchema,
91
127
  TRequestContext extends AnySchema | undefined,
92
- TDeps extends Record<string, any> = Record<never, never>,
93
128
  > {
94
129
  readonly id: string;
95
130
  readonly contract: TContract;
96
131
  readonly configSchema: PluginConfigFor<TVariables, TSecrets, TRequestContext>;
132
+ readonly servicesTag?: Context.Key<any, any>;
133
+ readonly warnings?: PluginWarningsFn<TVariables, TSecrets>;
97
134
 
98
135
  initialize(
99
136
  config: PluginInitializeInput<TVariables, TSecrets>,
100
137
  plugins: Record<string, unknown>,
101
- tools: PluginServicesTools,
102
- ): Effect.Effect<TDeps, unknown, Scope.Scope>;
103
-
104
- shutdown(): Effect.Effect<void, never>;
138
+ ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv>;
105
139
 
106
140
  /**
107
141
  * Creates the strongly-typed oRPC router for this plugin.
108
142
  * The router's procedure types are inferred directly from the contract.
109
- * @param deps The initialized plugin dependencies
143
+ * @param plugins Sibling plugin entries (`{ client, router }`) for
144
+ * cross-plugin composition
110
145
  * @returns A router with procedures matching the plugin's contract
111
146
  */
112
- createRouter(deps: TDeps): Router<TContract, any>;
147
+ createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any>;
113
148
  }
114
149
 
115
150
  export interface CreatePluginFn {
@@ -118,11 +153,10 @@ export interface CreatePluginFn {
118
153
  S extends AnySchema,
119
154
  TContract extends AnyContractRouter,
120
155
  TRequestContext extends AnySchema | undefined = undefined,
121
- TDeps extends Record<string, any> = Record<never, never>,
122
156
  P extends Record<string, unknown> = Record<string, never>,
123
157
  >(
124
- config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,
125
- ): LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;
158
+ config: PluginDefinition<V, S, TContract, TRequestContext, P>,
159
+ ): LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
126
160
 
127
161
  withPlugins: <P extends Record<string, unknown>>() => CreatePluginWithPlugins<P>;
128
162
  }
@@ -132,84 +166,54 @@ export const createPlugin: CreatePluginFn = function createPlugin<
132
166
  S extends AnySchema,
133
167
  TContract extends AnyContractRouter,
134
168
  TRequestContext extends AnySchema | undefined = undefined,
135
- TDeps extends Record<string, any> = Record<never, never>,
136
169
  P extends Record<string, unknown> = Record<string, never>,
137
- >(config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>) {
170
+ >(config: PluginDefinition<V, S, TContract, TRequestContext, P>) {
138
171
  const configSchema: PluginConfigFor<V, S, TRequestContext> = {
139
172
  variables: config.variables,
140
173
  secrets: config.secrets,
141
174
  context: config.context as TRequestContext,
142
175
  };
143
176
 
144
- class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext, TDeps> {
177
+ class CreatedPlugin implements Plugin<TContract, V, S, TRequestContext> {
145
178
  /** set during instantiation - registry key */
146
179
  id!: string;
147
180
  readonly contract = config.contract;
148
181
  readonly configSchema = configSchema;
149
-
150
- private _deps: TDeps | null = null;
182
+ readonly servicesTag = config.servicesTag;
183
+ readonly warnings = config.warnings;
151
184
 
152
185
  initialize(
153
186
  pluginConfig: PluginInitializeInput<V, S>,
154
187
  plugins: Record<string, unknown> = {},
155
- tools: PluginServicesTools,
156
- ): Effect.Effect<TDeps, unknown, Scope.Scope> {
157
- const init = config.initialize ?? (() => Effect.succeed({} as TDeps));
158
-
159
- return init(pluginConfig, plugins as P, tools).pipe(
160
- Effect.tap((deps) =>
161
- Effect.sync(() => {
162
- this._deps = deps;
163
- }),
188
+ ): Effect.Effect<Layer.Layer<any, Error, PluginEnv>, PluginRuntimeError, PluginEnv> {
189
+ const init = config.initialize;
190
+ if (!init) {
191
+ return Effect.succeed(Layer.empty as unknown as Layer.Layer<any, Error, PluginEnv>);
192
+ }
193
+
194
+ return init(pluginConfig, plugins as P).pipe(
195
+ Effect.mapError((error) =>
196
+ toPluginRuntimeError(error, this.id, undefined, "initialize-plugin"),
164
197
  ),
165
- Effect.map(() => this._deps as TDeps),
166
- Effect.mapError((error) => error as unknown),
167
198
  );
168
199
  }
169
200
 
170
- shutdown(): Effect.Effect<void, never> {
171
- const self = this;
172
- return Effect.gen(function* () {
173
- if (config.shutdown && self._deps) {
174
- yield* config
175
- .shutdown(self._deps)
176
- .pipe(
177
- Effect.catchAll((error) =>
178
- Effect.logWarning(`Plugin shutdown hook failed for ${self.id}`, error),
179
- ),
180
- );
181
- }
182
- self._deps = null;
183
- });
184
- }
185
-
186
- createRouter(deps: TDeps): Router<TContract, any> {
187
- const base = implement(config.contract).$context<ContextOutput<TRequestContext>>();
188
- const errorMiddleware = onError((error: unknown) => {
189
- const unwrapped = extractFromFiberFailure(error);
190
-
191
- if (unwrapped !== error && unwrapped instanceof ORPCError) {
192
- throw unwrapped;
193
- }
194
-
195
- const formatted = formatORPCError(error);
196
- if (formatted) console.error(formatted);
197
- throw error;
198
- }) as any;
199
-
200
- const builder = (base as any).use(errorMiddleware);
201
- const router = config.createRouter(deps, builder as any);
202
- return router as Router<TContract, any>;
201
+ createRouter(plugins: Record<string, unknown>): ContractedRouter<TContract, any> {
202
+ const builder = implement(config.contract).$context<
203
+ ContextOutput<TRequestContext> & WithEffectContext<any>
204
+ >();
205
+ return config.createRouter(builder as any, plugins as P) as ContractedRouter<TContract, any>;
203
206
  }
204
207
  }
205
208
 
206
209
  const PluginConstructor = CreatedPlugin as unknown as {
207
- new (): Plugin<TContract, V, S, TRequestContext, TDeps>;
210
+ new (): Plugin<TContract, V, S, TRequestContext>;
208
211
  binding: {
209
212
  contract: TContract;
210
213
  variables: V;
211
214
  secrets: S;
212
215
  context: TRequestContext;
216
+ servicesTag?: Context.Key<any, any>;
213
217
  };
214
218
  };
215
219
 
@@ -218,9 +222,10 @@ export const createPlugin: CreatePluginFn = function createPlugin<
218
222
  variables: config.variables,
219
223
  secrets: config.secrets,
220
224
  context: config.context as TRequestContext,
225
+ servicesTag: config.servicesTag,
221
226
  };
222
227
 
223
- return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;
228
+ return PluginConstructor as LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
224
229
  };
225
230
 
226
231
  export type CreatePluginWithPlugins<P extends Record<string, unknown>> = <
@@ -228,10 +233,9 @@ export type CreatePluginWithPlugins<P extends Record<string, unknown>> = <
228
233
  S extends AnySchema,
229
234
  TContract extends AnyContractRouter,
230
235
  TRequestContext extends AnySchema | undefined = undefined,
231
- TDeps extends Record<string, any> = Record<never, never>,
232
236
  >(
233
- config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,
234
- ) => LoadedPluginWithBinding<TContract, V, S, TRequestContext, TDeps>;
237
+ config: PluginDefinition<V, S, TContract, TRequestContext, P>,
238
+ ) => LoadedPluginWithBinding<TContract, V, S, TRequestContext>;
235
239
 
236
240
  export function withPlugins<P extends Record<string, unknown>>(): CreatePluginWithPlugins<P> {
237
241
  return <
@@ -239,10 +243,9 @@ export function withPlugins<P extends Record<string, unknown>>(): CreatePluginWi
239
243
  S extends AnySchema,
240
244
  TContract extends AnyContractRouter,
241
245
  TRequestContext extends AnySchema | undefined = undefined,
242
- TDeps extends Record<string, any> = Record<never, never>,
243
246
  >(
244
- config: PluginDefinition<V, S, TContract, TRequestContext, TDeps, P>,
245
- ) => createPlugin<V, S, TContract, TRequestContext, TDeps, P>(config as any);
247
+ config: PluginDefinition<V, S, TContract, TRequestContext, P>,
248
+ ) => createPlugin<V, S, TContract, TRequestContext, P>(config as any);
246
249
  }
247
250
 
248
251
  createPlugin.withPlugins = withPlugins;
@@ -0,0 +1,170 @@
1
+ /**
2
+ * Remote-entry loading resilience — the ONE contract every MF consumer in
3
+ * the dev stack shares (plugin dev serves, the host's plugin loader).
4
+ *
5
+ * Two failure classes it exists for:
6
+ * 1. Cold compile: remoteEntry.js 404s until the remote's first build —
7
+ * the 404 body gets eval'd as JS ("Unexpected identifier 'Found'").
8
+ * 2. Watch-rebuild poisoning: a failed entry load is memoized forever in
9
+ * `globalThis.__GLOBAL_LOADING_REMOTE_ENTRY__` (runtime-core never evicts
10
+ * rejections), so retries without a purge await the same failure.
11
+ */
12
+ import { Duration, Effect, Schedule } from "effect";
13
+ import type { PluginRuntimeError } from "./runtime/errors";
14
+ import {
15
+ classifyPluginFailure,
16
+ deepestErrorStack,
17
+ type PluginFailureClassification,
18
+ toPluginRuntimeError,
19
+ } from "./runtime/errors";
20
+
21
+ const POLL_INTERVAL_MS = 300;
22
+ const DEFAULT_TIMEOUT_MS = 120_000;
23
+ const RETRY_BASE_DELAY_MS = 500;
24
+ const RETRY_MAX_DELAY_MS = 5_000;
25
+
26
+ const sleep = (ms: number): Promise<void> => new Promise((resolve) => setTimeout(resolve, ms));
27
+
28
+ /**
29
+ * Deletes the failed remote's keys from the process-global entry-load cache.
30
+ * Deleting a RESOLVED entry would force a wasteful re-eval, so only call
31
+ * this from failure paths.
32
+ */
33
+ export const purgeRemoteEntryCache = (remoteUrl: string): void => {
34
+ const globalLoading = (globalThis as Record<string, unknown>).__GLOBAL_LOADING_REMOTE_ENTRY__ as
35
+ | Record<string, unknown>
36
+ | undefined;
37
+ if (!globalLoading) return;
38
+ for (const key of Object.keys(globalLoading)) {
39
+ if (key.endsWith(`:${remoteUrl}`)) delete globalLoading[key];
40
+ }
41
+ };
42
+
43
+ export const isRemoteEntryBody = (body: string): boolean =>
44
+ !/not found|<(!doctype|html)/i.test(body.slice(0, 64));
45
+
46
+ export const waitForRemoteEntryReady = async (
47
+ label: string,
48
+ url: string,
49
+ timeoutMs = DEFAULT_TIMEOUT_MS,
50
+ ): Promise<void> => {
51
+ const deadline = Date.now() + timeoutMs;
52
+ let announced = false;
53
+ while (Date.now() < deadline) {
54
+ const res = await fetch(url).catch(() => null);
55
+ if (res?.ok && isRemoteEntryBody(await res.text().catch(() => ""))) return;
56
+ if (!announced) {
57
+ announced = true;
58
+ console.log(`⏳ waiting for ${label} to compile (remote entry not ready)…`);
59
+ }
60
+ await sleep(POLL_INTERVAL_MS);
61
+ }
62
+ throw new Error(`${label} remote entry never became ready at ${url}`);
63
+ };
64
+
65
+ export interface PluginLoadAttemptInfo {
66
+ attempt: number;
67
+ classification: PluginFailureClassification;
68
+ }
69
+
70
+ export interface PluginLoadRetryOptions<T> {
71
+ /** short plugin key for log prefixes (host entry key or plugin id) */
72
+ label: string;
73
+ remoteUrl: string;
74
+ load: () => Promise<T>;
75
+ /** wall-clock budget for the retry loop */
76
+ timeoutMs?: number;
77
+ /**
78
+ * Budget for the readiness poll (cold-compile wait) — defaults to the
79
+ * retry budget, preserving the historical behavior. Pass `0` to skip the
80
+ * poll (useful when the caller stubs `load` and does not need network).
81
+ */
82
+ readinessTimeoutMs?: number;
83
+ /**
84
+ * Observes every failed attempt (including non-retryable ones that end the
85
+ * loop). Defaults to classification-deduped console.error under the
86
+ * `[Plugins]` prefix.
87
+ */
88
+ onAttempt?: ((error: unknown, info: PluginLoadAttemptInfo) => void) | undefined;
89
+ }
90
+
91
+ /**
92
+ * The one plugin-load retry policy: poll the remote entry until it is actually
93
+ * served, then load with capped exponential backoff — purging the poisoned
94
+ * global entry cache between attempts so each retry genuinely re-fetches.
95
+ *
96
+ * Recovery policy is `classifyPluginFailure().retryable`: transient network
97
+ * conditions retry until the wall-clock budget runs out; permanent failures
98
+ * (MF identity skew, schema validation, dead remotes, TLS verification) fail
99
+ * fast on the first attempt instead of burning the budget silently.
100
+ *
101
+ * Fails with the ORIGINAL error from `load` — the host builds
102
+ * `PluginBootstrapError.cause` from it and classification walks it.
103
+ */
104
+ export const loadRemoteWithRetry = <T>(
105
+ options: PluginLoadRetryOptions<T>,
106
+ ): Effect.Effect<T, PluginRuntimeError> => {
107
+ const {
108
+ label,
109
+ remoteUrl,
110
+ load,
111
+ timeoutMs = DEFAULT_TIMEOUT_MS,
112
+ readinessTimeoutMs,
113
+ onAttempt,
114
+ } = options;
115
+ const readinessTimeout = readinessTimeoutMs ?? timeoutMs;
116
+
117
+ const schedule = Schedule.exponential(Duration.millis(RETRY_BASE_DELAY_MS)).pipe(
118
+ Schedule.modifyDelay(({ output }) =>
119
+ Effect.succeed(
120
+ Duration.toMillis(output) > RETRY_MAX_DELAY_MS
121
+ ? Duration.millis(RETRY_MAX_DELAY_MS)
122
+ : output,
123
+ ),
124
+ ),
125
+ Schedule.upTo({ duration: Duration.millis(timeoutMs) }),
126
+ );
127
+
128
+ let attempt = 0;
129
+ let lastSignature: string | undefined;
130
+ const reportFailure = (error: unknown): void => {
131
+ attempt += 1;
132
+ purgeRemoteEntryCache(remoteUrl);
133
+ const classification = classifyPluginFailure(error);
134
+ if (onAttempt) {
135
+ onAttempt(error, { attempt, classification });
136
+ return;
137
+ }
138
+ const signature = `${classification.kind}::${classification.message}`;
139
+ if (signature === lastSignature) return;
140
+ lastSignature = signature;
141
+ // The message alone is rarely enough, and the wrapper's own stack points
142
+ // at the wrapping frames — log the DEEPEST cause's stack (the original
143
+ // throw site inside the evaluated remote entry).
144
+ const stack = deepestErrorStack(error);
145
+ console.error(
146
+ `[Plugins][${label}] ❌ ${classification.kind} failure (attempt ${attempt}): ${classification.message}` +
147
+ (classification.suggestion ? `\n[Plugins][${label}] → ${classification.suggestion}` : "") +
148
+ (stack ? `\n[Plugins][${label}] ${stack}` : ""),
149
+ );
150
+ };
151
+
152
+ const loadWithRetry = Effect.tryPromise({
153
+ try: load,
154
+ catch: (error) => toPluginRuntimeError(error, label, undefined, "remote-entry-load"),
155
+ }).pipe(
156
+ Effect.tapError((error) => Effect.sync(() => reportFailure(error))),
157
+ Effect.retry({ schedule, while: (error) => classifyPluginFailure(error).retryable }),
158
+ );
159
+
160
+ // readinessTimeoutMs: 0 skips the cold-compile poll (tests stub `load` and
161
+ // must not race a 1ms wall-clock window against the event loop).
162
+ if (readinessTimeout === 0) {
163
+ return loadWithRetry;
164
+ }
165
+
166
+ return Effect.tryPromise({
167
+ try: () => waitForRemoteEntryReady(label, remoteUrl, readinessTimeout),
168
+ catch: (error) => toPluginRuntimeError(error, label, undefined, "remote-entry-readiness"),
169
+ }).pipe(Effect.flatMap(() => loadWithRetry));
170
+ };