@dxos/app-framework 0.8.4-main.40e3dcdf1b → 0.8.4-main.43cb759274

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 (389) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/browser/{capability-LF3OXSCV.mjs → capability-JCUNWZ66.mjs} +12 -11
  4. package/dist/lib/browser/capability-JCUNWZ66.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-WEBSGU5L.mjs → chunk-2ZIYRDAF.mjs} +20 -5
  6. package/dist/lib/browser/chunk-2ZIYRDAF.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-5GY3YOEL.mjs +28 -0
  8. package/dist/lib/browser/chunk-5GY3YOEL.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-272IPLHQ.mjs → chunk-66IXTIVK.mjs} +3 -2
  10. package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-7MBI66M7.mjs +587 -0
  12. package/dist/lib/browser/chunk-7MBI66M7.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-BMLCIFZW.mjs +1467 -0
  14. package/dist/lib/browser/chunk-BMLCIFZW.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-7M4467QR.mjs → chunk-DC3WRPBV.mjs} +100 -18
  16. package/dist/lib/browser/chunk-DC3WRPBV.mjs.map +7 -0
  17. package/dist/lib/browser/{chunk-JGWCBVKJ.mjs → chunk-E5DTDNDY.mjs} +28 -55
  18. package/dist/lib/browser/chunk-E5DTDNDY.mjs.map +7 -0
  19. package/dist/lib/browser/{chunk-TGX63LTL.mjs → chunk-FJ4765WW.mjs} +1 -1
  20. package/dist/lib/browser/{chunk-TGX63LTL.mjs.map → chunk-FJ4765WW.mjs.map} +2 -2
  21. package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
  22. package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
  23. package/dist/lib/browser/{chunk-YNFPIQGB.mjs → chunk-IW44C7UL.mjs} +9 -2
  24. package/dist/lib/browser/chunk-IW44C7UL.mjs.map +7 -0
  25. package/dist/lib/browser/chunk-KZUDO43J.mjs +422 -0
  26. package/dist/lib/browser/chunk-KZUDO43J.mjs.map +7 -0
  27. package/dist/lib/browser/chunk-Q2GLJTVV.mjs +12 -0
  28. package/dist/lib/browser/chunk-Q2GLJTVV.mjs.map +7 -0
  29. package/dist/lib/browser/chunk-VBG5F5UF.mjs +476 -0
  30. package/dist/lib/browser/chunk-VBG5F5UF.mjs.map +7 -0
  31. package/dist/lib/browser/cli/index.mjs +15 -30
  32. package/dist/lib/browser/cli/index.mjs.map +3 -3
  33. package/dist/lib/browser/common/activation-events.mjs +11 -14
  34. package/dist/lib/browser/common/capabilities.mjs +19 -8
  35. package/dist/lib/browser/core/activation-event.mjs +1 -1
  36. package/dist/lib/browser/core/capability.mjs +5 -1
  37. package/dist/lib/browser/core/plugin-manager.mjs +8 -4
  38. package/dist/lib/browser/core/plugin.mjs +18 -4
  39. package/dist/lib/browser/core/url-loader.mjs +24 -0
  40. package/dist/lib/browser/index.mjs +51 -54
  41. package/dist/lib/browser/index.mjs.map +4 -4
  42. package/dist/lib/browser/meta.json +1 -1
  43. package/dist/lib/browser/process-manager-capability-4FUA4TRP.mjs +89 -0
  44. package/dist/lib/browser/process-manager-capability-4FUA4TRP.mjs.map +7 -0
  45. package/dist/lib/browser/testing/index.mjs +198 -54
  46. package/dist/lib/browser/testing/index.mjs.map +4 -4
  47. package/dist/lib/browser/testing/react.mjs +78 -0
  48. package/dist/lib/browser/testing/react.mjs.map +7 -0
  49. package/dist/lib/browser/ui/index.mjs +22 -15
  50. package/dist/lib/node-esm/{capability-SA6LPYGL.mjs → capability-7TCQK7ZP.mjs} +12 -11
  51. package/dist/lib/node-esm/capability-7TCQK7ZP.mjs.map +7 -0
  52. package/dist/lib/node-esm/{chunk-FKE4Z3D6.mjs → chunk-37Z53PXZ.mjs} +1 -1
  53. package/dist/lib/node-esm/{chunk-FKE4Z3D6.mjs.map → chunk-37Z53PXZ.mjs.map} +2 -2
  54. package/dist/lib/node-esm/chunk-4BX2AE47.mjs +1468 -0
  55. package/dist/lib/node-esm/chunk-4BX2AE47.mjs.map +7 -0
  56. package/dist/lib/node-esm/{chunk-SB5ODNPX.mjs → chunk-CTKEZHKF.mjs} +9 -2
  57. package/dist/lib/node-esm/chunk-CTKEZHKF.mjs.map +7 -0
  58. package/dist/lib/node-esm/chunk-FPW45EZH.mjs +14 -0
  59. package/dist/lib/node-esm/chunk-FPW45EZH.mjs.map +7 -0
  60. package/dist/lib/node-esm/chunk-GEWHMHM7.mjs +588 -0
  61. package/dist/lib/node-esm/chunk-GEWHMHM7.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-KFZEB6BV.mjs +29 -0
  63. package/dist/lib/node-esm/chunk-KFZEB6BV.mjs.map +7 -0
  64. package/dist/lib/node-esm/{chunk-3D66SZHP.mjs → chunk-KSH4OVMY.mjs} +28 -55
  65. package/dist/lib/node-esm/chunk-KSH4OVMY.mjs.map +7 -0
  66. package/dist/lib/node-esm/{chunk-SQICGJBW.mjs → chunk-QBUGLR4H.mjs} +20 -5
  67. package/dist/lib/node-esm/chunk-QBUGLR4H.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs +70 -0
  69. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-XGBUKRCK.mjs +423 -0
  71. package/dist/lib/node-esm/chunk-XGBUKRCK.mjs.map +7 -0
  72. package/dist/lib/node-esm/{chunk-JHFY3HTS.mjs → chunk-XIGPWXCQ.mjs} +100 -18
  73. package/dist/lib/node-esm/chunk-XIGPWXCQ.mjs.map +7 -0
  74. package/dist/lib/node-esm/{chunk-6REV5DE7.mjs → chunk-XOCUANHO.mjs} +3 -2
  75. package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
  76. package/dist/lib/node-esm/chunk-Y7JKXNDU.mjs +477 -0
  77. package/dist/lib/node-esm/chunk-Y7JKXNDU.mjs.map +7 -0
  78. package/dist/lib/node-esm/cli/index.mjs +15 -30
  79. package/dist/lib/node-esm/cli/index.mjs.map +3 -3
  80. package/dist/lib/node-esm/common/activation-events.mjs +11 -14
  81. package/dist/lib/node-esm/common/capabilities.mjs +19 -8
  82. package/dist/lib/node-esm/core/activation-event.mjs +1 -1
  83. package/dist/lib/node-esm/core/capability.mjs +5 -1
  84. package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
  85. package/dist/lib/node-esm/core/plugin.mjs +18 -4
  86. package/dist/lib/node-esm/core/url-loader.mjs +25 -0
  87. package/dist/lib/node-esm/index.mjs +51 -54
  88. package/dist/lib/node-esm/index.mjs.map +4 -4
  89. package/dist/lib/node-esm/meta.json +1 -1
  90. package/dist/lib/node-esm/process-manager-capability-F23D62RN.mjs +90 -0
  91. package/dist/lib/node-esm/process-manager-capability-F23D62RN.mjs.map +7 -0
  92. package/dist/lib/node-esm/testing/index.mjs +198 -54
  93. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  94. package/dist/lib/node-esm/testing/react.mjs +79 -0
  95. package/dist/lib/node-esm/testing/react.mjs.map +7 -0
  96. package/dist/lib/node-esm/ui/index.mjs +22 -15
  97. package/dist/plugin/node-esm/index.mjs +971 -0
  98. package/dist/plugin/node-esm/index.mjs.map +7 -0
  99. package/dist/plugin/node-esm/meta.json +1 -0
  100. package/dist/types/src/cli/cli.d.ts +1 -3
  101. package/dist/types/src/cli/cli.d.ts.map +1 -1
  102. package/dist/types/src/common/activation-events.d.ts +10 -13
  103. package/dist/types/src/common/activation-events.d.ts.map +1 -1
  104. package/dist/types/src/common/annotations.d.ts +1 -0
  105. package/dist/types/src/common/annotations.d.ts.map +1 -0
  106. package/dist/types/src/common/capabilities.d.ts +113 -12
  107. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  108. package/dist/types/src/common/index.d.ts +0 -1
  109. package/dist/types/src/common/index.d.ts.map +1 -1
  110. package/dist/types/src/common/translations.d.ts +1 -1
  111. package/dist/types/src/core/activation-event.d.ts +4 -4
  112. package/dist/types/src/core/activation-event.d.ts.map +1 -1
  113. package/dist/types/src/core/capability-manager.d.ts +9 -0
  114. package/dist/types/src/core/capability-manager.d.ts.map +1 -1
  115. package/dist/types/src/core/capability.d.ts +13 -2
  116. package/dist/types/src/core/capability.d.ts.map +1 -1
  117. package/dist/types/src/core/edge-registry-plugin-provider.d.ts +30 -0
  118. package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -0
  119. package/dist/types/src/core/index.d.ts +6 -0
  120. package/dist/types/src/core/index.d.ts.map +1 -1
  121. package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
  122. package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
  123. package/dist/types/src/core/plugin-manager.d.ts +238 -7
  124. package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
  125. package/dist/types/src/core/plugin-manifest.d.ts +101 -0
  126. package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
  127. package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
  128. package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
  129. package/dist/types/src/core/plugin.d.ts +213 -11
  130. package/dist/types/src/core/plugin.d.ts.map +1 -1
  131. package/dist/types/src/core/registry.d.ts +107 -0
  132. package/dist/types/src/core/registry.d.ts.map +1 -0
  133. package/dist/types/src/core/url-loader.d.ts +127 -0
  134. package/dist/types/src/core/url-loader.d.ts.map +1 -0
  135. package/dist/types/src/core/url-loader.test.d.ts +2 -0
  136. package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
  137. package/dist/types/src/helpers.d.ts.map +1 -1
  138. package/dist/types/src/index.d.ts +1 -2
  139. package/dist/types/src/index.d.ts.map +1 -1
  140. package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts +3 -0
  141. package/dist/types/src/plugin-process-manager/ProcessManagerPlugin.d.ts.map +1 -0
  142. package/dist/types/src/plugin-process-manager/history/capability.d.ts.map +1 -0
  143. package/dist/types/src/plugin-process-manager/history/errors.d.ts +32 -0
  144. package/dist/types/src/plugin-process-manager/history/errors.d.ts.map +1 -0
  145. package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts +32 -0
  146. package/dist/types/src/plugin-process-manager/history/history-tracker.d.ts.map +1 -0
  147. package/dist/types/src/plugin-process-manager/history/history-tracker.test.d.ts.map +1 -0
  148. package/dist/types/src/plugin-process-manager/history/index.d.ts.map +1 -0
  149. package/dist/types/src/{plugin-operation → plugin-process-manager}/history/types.d.ts +1 -1
  150. package/dist/types/src/plugin-process-manager/history/types.d.ts.map +1 -0
  151. package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.d.ts +2 -2
  152. package/dist/types/src/plugin-process-manager/history/undo-mapping.d.ts.map +1 -0
  153. package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.d.ts +1 -1
  154. package/dist/types/src/plugin-process-manager/history/undo-registry.d.ts.map +1 -0
  155. package/dist/types/src/plugin-process-manager/history/undo-registry.test.d.ts.map +1 -0
  156. package/dist/types/src/plugin-process-manager/index.d.ts +3 -0
  157. package/dist/types/src/plugin-process-manager/index.d.ts.map +1 -0
  158. package/dist/types/src/plugin-process-manager/meta.d.ts +3 -0
  159. package/dist/types/src/plugin-process-manager/meta.d.ts.map +1 -0
  160. package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts +8 -0
  161. package/dist/types/src/plugin-process-manager/process-manager-capability.d.ts.map +1 -0
  162. package/dist/types/src/plugin-process-manager/testing.d.ts +59 -0
  163. package/dist/types/src/plugin-process-manager/testing.d.ts.map +1 -0
  164. package/dist/types/src/testing/harness.d.ts +79 -0
  165. package/dist/types/src/testing/harness.d.ts.map +1 -0
  166. package/dist/types/src/testing/index.d.ts +1 -0
  167. package/dist/types/src/testing/index.d.ts.map +1 -1
  168. package/dist/types/src/testing/react.d.ts +27 -0
  169. package/dist/types/src/testing/react.d.ts.map +1 -0
  170. package/dist/types/src/testing/react.test.d.ts +2 -0
  171. package/dist/types/src/testing/react.test.d.ts.map +1 -0
  172. package/dist/types/src/testing/service.d.ts.map +1 -1
  173. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  174. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
  175. package/dist/types/src/ui/components/App/App.d.ts +36 -3
  176. package/dist/types/src/ui/components/App/App.d.ts.map +1 -1
  177. package/dist/types/src/ui/components/App/App.stories.d.ts +2 -2
  178. package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -1
  179. package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -1
  180. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +16 -4
  181. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
  182. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
  183. package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -1
  184. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
  185. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
  186. package/dist/types/src/ui/components/Surface/index.d.ts +22 -6
  187. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
  188. package/dist/types/src/ui/components/Surface/types.d.ts +110 -9
  189. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
  190. package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
  191. package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
  192. package/dist/types/src/ui/hooks/index.d.ts +1 -1
  193. package/dist/types/src/ui/hooks/index.d.ts.map +1 -1
  194. package/dist/types/src/ui/hooks/useApp.d.ts +42 -12
  195. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
  196. package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
  197. package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
  198. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -1
  199. package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -1
  200. package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts +30 -0
  201. package/dist/types/src/ui/hooks/useProcessManagerRuntime.d.ts.map +1 -0
  202. package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -1
  203. package/dist/types/src/vite-plugin/boot-loader/index.d.ts +2 -0
  204. package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
  205. package/dist/types/src/vite-plugin/boot-loader/loader.d.ts +54 -0
  206. package/dist/types/src/vite-plugin/boot-loader/loader.d.ts.map +1 -0
  207. package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
  208. package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
  209. package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
  210. package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
  211. package/dist/types/src/vite-plugin/index.d.ts +5 -0
  212. package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
  213. package/dist/types/src/vite-plugin/manifest.d.ts +41 -0
  214. package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
  215. package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
  216. package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
  217. package/dist/types/src/vite-plugin/packages.d.ts +13 -0
  218. package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
  219. package/dist/types/tsconfig.tsbuildinfo +1 -1
  220. package/moon.yml +15 -0
  221. package/package.json +61 -57
  222. package/src/cli/cli.ts +2 -7
  223. package/src/common/activation-events.ts +10 -15
  224. package/src/common/annotations.ts +3 -0
  225. package/src/common/capabilities.ts +147 -16
  226. package/src/common/index.ts +0 -1
  227. package/src/common/translations.ts +1 -1
  228. package/src/core/activation-event.ts +4 -1
  229. package/src/core/capability-manager.test.ts +4 -1
  230. package/src/core/capability-manager.ts +44 -2
  231. package/src/core/capability.ts +20 -2
  232. package/src/core/edge-registry-plugin-provider.ts +92 -0
  233. package/src/core/index.ts +6 -0
  234. package/src/core/plugin-asset-cache.ts +60 -0
  235. package/src/core/plugin-manager.test.ts +1103 -19
  236. package/src/core/plugin-manager.ts +1176 -199
  237. package/src/core/plugin-manifest.test.ts +75 -0
  238. package/src/core/plugin-manifest.ts +134 -0
  239. package/src/core/plugin.ts +235 -17
  240. package/src/core/registry.ts +163 -0
  241. package/src/core/url-loader.test.ts +222 -0
  242. package/src/core/url-loader.ts +388 -0
  243. package/src/index.ts +1 -2
  244. package/src/plugin-process-manager/ProcessManagerPlugin.ts +24 -0
  245. package/src/{plugin-operation → plugin-process-manager}/history/capability.ts +1 -2
  246. package/src/plugin-process-manager/history/errors.ts +7 -0
  247. package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.ts +61 -88
  248. package/src/{plugin-operation → plugin-process-manager}/history/history-tracker.ts +33 -18
  249. package/src/{plugin-operation → plugin-process-manager}/history/types.ts +1 -1
  250. package/src/{plugin-operation → plugin-process-manager}/history/undo-mapping.ts +2 -2
  251. package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.ts +6 -5
  252. package/src/{plugin-operation → plugin-process-manager}/history/undo-registry.ts +1 -1
  253. package/src/{plugin-operation → plugin-process-manager}/index.ts +1 -1
  254. package/src/plugin-process-manager/meta.ts +16 -0
  255. package/src/plugin-process-manager/process-manager-capability.ts +178 -0
  256. package/src/{plugin-operation → plugin-process-manager}/testing.ts +32 -50
  257. package/src/testing/harness.ts +247 -0
  258. package/src/testing/index.ts +1 -0
  259. package/src/testing/react.test.tsx +50 -0
  260. package/src/testing/react.tsx +113 -0
  261. package/src/testing/service.ts +2 -2
  262. package/src/testing/withPluginManager.stories.tsx +1 -2
  263. package/src/testing/withPluginManager.tsx +47 -21
  264. package/src/ui/components/App/App.stories.tsx +12 -20
  265. package/src/ui/components/App/App.tsx +97 -10
  266. package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +13 -17
  267. package/src/ui/components/Surface/SurfaceComponent.stories.tsx +17 -16
  268. package/src/ui/components/Surface/SurfaceComponent.tsx +111 -55
  269. package/src/ui/components/Surface/SurfaceInfo.tsx +0 -1
  270. package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
  271. package/src/ui/components/Surface/index.ts +35 -1
  272. package/src/ui/components/Surface/types.test.ts +126 -0
  273. package/src/ui/components/Surface/types.ts +185 -12
  274. package/src/ui/hooks/index.ts +1 -1
  275. package/src/ui/hooks/useApp.test.tsx +161 -0
  276. package/src/ui/hooks/useApp.tsx +215 -24
  277. package/src/ui/hooks/useCapabilities.ts +1 -0
  278. package/src/ui/hooks/useLoading.tsx +14 -6
  279. package/src/ui/hooks/useProcessManagerRuntime.ts +78 -0
  280. package/src/vite-plugin/boot-loader/BootLoader.solid-stories.tsx +198 -0
  281. package/src/vite-plugin/boot-loader/index.ts +5 -0
  282. package/src/vite-plugin/boot-loader/loader-app/Loader.tsx +166 -0
  283. package/src/vite-plugin/boot-loader/loader-app/boot-loader.css +311 -0
  284. package/src/vite-plugin/boot-loader/loader-app/bridge.ts +25 -0
  285. package/src/vite-plugin/boot-loader/loader-app/entry.tsx +21 -0
  286. package/src/vite-plugin/boot-loader/loader-app/mount.tsx +70 -0
  287. package/src/vite-plugin/boot-loader/loader-app/store.test.ts +137 -0
  288. package/src/vite-plugin/boot-loader/loader-app/store.ts +149 -0
  289. package/src/vite-plugin/boot-loader/loader-app/tsconfig.json +11 -0
  290. package/src/vite-plugin/boot-loader/loader-app/types.ts +78 -0
  291. package/src/vite-plugin/boot-loader/loader.ts +193 -0
  292. package/src/vite-plugin/composer/index.ts +306 -0
  293. package/src/vite-plugin/import-map/index.ts +527 -0
  294. package/src/vite-plugin/index.ts +10 -0
  295. package/src/vite-plugin/manifest.test.ts +55 -0
  296. package/src/vite-plugin/manifest.ts +63 -0
  297. package/src/vite-plugin/packages.ts +187 -0
  298. package/tsconfig.json +26 -3
  299. package/tsconfig.node.json +1 -1
  300. package/vitest.config.ts +1 -1
  301. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  302. package/dist/lib/browser/capability-6YMUBS54.mjs +0 -37
  303. package/dist/lib/browser/capability-6YMUBS54.mjs.map +0 -7
  304. package/dist/lib/browser/capability-LF3OXSCV.mjs.map +0 -7
  305. package/dist/lib/browser/chunk-272IPLHQ.mjs.map +0 -7
  306. package/dist/lib/browser/chunk-2UI6ACB5.mjs +0 -824
  307. package/dist/lib/browser/chunk-2UI6ACB5.mjs.map +0 -7
  308. package/dist/lib/browser/chunk-7M4467QR.mjs.map +0 -7
  309. package/dist/lib/browser/chunk-JGWCBVKJ.mjs.map +0 -7
  310. package/dist/lib/browser/chunk-M5IC326L.mjs +0 -34
  311. package/dist/lib/browser/chunk-M5IC326L.mjs.map +0 -7
  312. package/dist/lib/browser/chunk-NQPYE365.mjs +0 -703
  313. package/dist/lib/browser/chunk-NQPYE365.mjs.map +0 -7
  314. package/dist/lib/browser/chunk-TIEBZMTF.mjs +0 -44
  315. package/dist/lib/browser/chunk-TIEBZMTF.mjs.map +0 -7
  316. package/dist/lib/browser/chunk-WEBSGU5L.mjs.map +0 -7
  317. package/dist/lib/browser/chunk-YAFEA4GV.mjs +0 -1
  318. package/dist/lib/browser/chunk-YNFPIQGB.mjs.map +0 -7
  319. package/dist/lib/browser/invoker-capability-4AUGUMM5.mjs +0 -36
  320. package/dist/lib/browser/invoker-capability-4AUGUMM5.mjs.map +0 -7
  321. package/dist/lib/node-esm/capability-R5O2OYX4.mjs +0 -38
  322. package/dist/lib/node-esm/capability-R5O2OYX4.mjs.map +0 -7
  323. package/dist/lib/node-esm/capability-SA6LPYGL.mjs.map +0 -7
  324. package/dist/lib/node-esm/chunk-3D66SZHP.mjs.map +0 -7
  325. package/dist/lib/node-esm/chunk-6REV5DE7.mjs.map +0 -7
  326. package/dist/lib/node-esm/chunk-FHWPWQRJ.mjs +0 -704
  327. package/dist/lib/node-esm/chunk-FHWPWQRJ.mjs.map +0 -7
  328. package/dist/lib/node-esm/chunk-JHFY3HTS.mjs.map +0 -7
  329. package/dist/lib/node-esm/chunk-JIVXIJ2T.mjs +0 -825
  330. package/dist/lib/node-esm/chunk-JIVXIJ2T.mjs.map +0 -7
  331. package/dist/lib/node-esm/chunk-NHXBSAQR.mjs +0 -35
  332. package/dist/lib/node-esm/chunk-NHXBSAQR.mjs.map +0 -7
  333. package/dist/lib/node-esm/chunk-SB5ODNPX.mjs.map +0 -7
  334. package/dist/lib/node-esm/chunk-SCDGIGGU.mjs +0 -45
  335. package/dist/lib/node-esm/chunk-SCDGIGGU.mjs.map +0 -7
  336. package/dist/lib/node-esm/chunk-SQICGJBW.mjs.map +0 -7
  337. package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +0 -2
  338. package/dist/lib/node-esm/invoker-capability-3YDIVDWV.mjs +0 -37
  339. package/dist/lib/node-esm/invoker-capability-3YDIVDWV.mjs.map +0 -7
  340. package/dist/types/src/common/operations.d.ts +0 -33
  341. package/dist/types/src/common/operations.d.ts.map +0 -1
  342. package/dist/types/src/plugin-operation/OperationPlugin.d.ts +0 -3
  343. package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +0 -1
  344. package/dist/types/src/plugin-operation/history/capability.d.ts.map +0 -1
  345. package/dist/types/src/plugin-operation/history/errors.d.ts +0 -5
  346. package/dist/types/src/plugin-operation/history/errors.d.ts.map +0 -1
  347. package/dist/types/src/plugin-operation/history/history-tracker.d.ts +0 -18
  348. package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +0 -1
  349. package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +0 -1
  350. package/dist/types/src/plugin-operation/history/index.d.ts.map +0 -1
  351. package/dist/types/src/plugin-operation/history/types.d.ts.map +0 -1
  352. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +0 -1
  353. package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +0 -1
  354. package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +0 -1
  355. package/dist/types/src/plugin-operation/index.d.ts +0 -3
  356. package/dist/types/src/plugin-operation/index.d.ts.map +0 -1
  357. package/dist/types/src/plugin-operation/invoker-capability.d.ts +0 -6
  358. package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +0 -1
  359. package/dist/types/src/plugin-operation/meta.d.ts +0 -3
  360. package/dist/types/src/plugin-operation/meta.d.ts.map +0 -1
  361. package/dist/types/src/plugin-operation/testing.d.ts +0 -109
  362. package/dist/types/src/plugin-operation/testing.d.ts.map +0 -1
  363. package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +0 -3
  364. package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +0 -1
  365. package/dist/types/src/plugin-runtime/capability.d.ts +0 -6
  366. package/dist/types/src/plugin-runtime/capability.d.ts.map +0 -1
  367. package/dist/types/src/plugin-runtime/index.d.ts +0 -2
  368. package/dist/types/src/plugin-runtime/index.d.ts.map +0 -1
  369. package/dist/types/src/plugin-runtime/meta.d.ts +0 -3
  370. package/dist/types/src/plugin-runtime/meta.d.ts.map +0 -1
  371. package/dist/types/src/ui/hooks/useOperationResolver.d.ts +0 -19
  372. package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +0 -1
  373. package/src/common/operations.ts +0 -38
  374. package/src/plugin-operation/OperationPlugin.ts +0 -25
  375. package/src/plugin-operation/history/errors.ts +0 -11
  376. package/src/plugin-operation/invoker-capability.ts +0 -40
  377. package/src/plugin-operation/meta.ts +0 -11
  378. package/src/plugin-runtime/RuntimePlugin.ts +0 -20
  379. package/src/plugin-runtime/capability.ts +0 -53
  380. package/src/plugin-runtime/index.ts +0 -5
  381. package/src/plugin-runtime/meta.ts +0 -11
  382. package/src/ui/hooks/useOperationResolver.ts +0 -40
  383. /package/dist/lib/browser/{chunk-YAFEA4GV.mjs.map → core/url-loader.mjs.map} +0 -0
  384. /package/dist/lib/node-esm/{chunk-Z4TJPSMP.mjs.map → core/url-loader.mjs.map} +0 -0
  385. /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/capability.d.ts +0 -0
  386. /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/history-tracker.test.d.ts +0 -0
  387. /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/index.d.ts +0 -0
  388. /package/dist/types/src/{plugin-operation → plugin-process-manager}/history/undo-registry.test.d.ts +0 -0
  389. /package/src/{plugin-operation → plugin-process-manager}/history/index.ts +0 -0
@@ -0,0 +1,1468 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+ import {
3
+ eventKey,
4
+ getEvents,
5
+ isAllOf
6
+ } from "./chunk-XOCUANHO.mjs";
7
+ import {
8
+ LazyPluginError,
9
+ PluginDependencyError,
10
+ Service as Service2,
11
+ isLazy,
12
+ resolveLazy
13
+ } from "./chunk-XIGPWXCQ.mjs";
14
+ import {
15
+ Service
16
+ } from "./chunk-CTKEZHKF.mjs";
17
+ import {
18
+ __export
19
+ } from "./chunk-HSLMI22Q.mjs";
20
+
21
+ // src/core/plugin-manager.ts
22
+ var plugin_manager_exports = {};
23
+ __export(plugin_manager_exports, {
24
+ ManagerTypeId: () => ManagerTypeId,
25
+ PluginInitializationError: () => PluginInitializationError,
26
+ PluginTimeoutError: () => PluginTimeoutError,
27
+ isManager: () => isManager,
28
+ make: () => make5
29
+ });
30
+ import { Atom as Atom3, Registry } from "@effect-atom/atom-react";
31
+ import * as Array from "effect/Array";
32
+ import * as Cause from "effect/Cause";
33
+ import * as Deferred2 from "effect/Deferred";
34
+ import * as Duration from "effect/Duration";
35
+ import * as Effect3 from "effect/Effect";
36
+ import * as Fiber from "effect/Fiber";
37
+ import * as Function from "effect/Function";
38
+ import * as HashSet from "effect/HashSet";
39
+ import * as PubSub from "effect/PubSub";
40
+ import * as Ref from "effect/Ref";
41
+ import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
42
+ import { Performance } from "@dxos/effect";
43
+ import { BaseError } from "@dxos/errors";
44
+ import { log as log3 } from "@dxos/log";
45
+
46
+ // src/core/capability-manager.ts
47
+ var capability_manager_exports = {};
48
+ __export(capability_manager_exports, {
49
+ make: () => make2
50
+ });
51
+ import { Atom } from "@effect-atom/atom-react";
52
+ import * as Deferred from "effect/Deferred";
53
+ import * as Effect from "effect/Effect";
54
+ import { invariant } from "@dxos/invariant";
55
+ import { log } from "@dxos/log";
56
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
57
+ var CapabilityManagerImpl = class {
58
+ _registry;
59
+ _registeredIdentifiers = /* @__PURE__ */ new Set();
60
+ _capabilityEntries = Atom.family(() => {
61
+ return Atom.make([]).pipe(Atom.keepAlive);
62
+ });
63
+ _capabilities = Atom.family((id) => {
64
+ return Atom.make((get2) => {
65
+ const current = get2(this._capabilityEntries(id));
66
+ return current.map((c) => c.implementation);
67
+ }).pipe(Atom.keepAlive);
68
+ });
69
+ _capabilitiesByModule = Atom.family((id) => {
70
+ return Atom.make((get2) => {
71
+ const entries = get2(this._capabilityEntries(id));
72
+ const result = {};
73
+ for (const entry of entries) {
74
+ (result[entry.moduleId] ??= []).push(entry.implementation);
75
+ }
76
+ return result;
77
+ }).pipe(Atom.keepAlive);
78
+ });
79
+ _capability = Atom.family((id) => {
80
+ return Atom.make((get2) => {
81
+ const current = get2(this._capabilities(id));
82
+ invariant(current.length > 0, `No capability found for ${id}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 36, S: this, A: ["current.length > 0", "`No capability found for ${id}`"] });
83
+ return current[0];
84
+ });
85
+ });
86
+ constructor({ registry }) {
87
+ this._registry = registry;
88
+ }
89
+ contribute({ module: moduleId, interface: interfaceDef, implementation }) {
90
+ const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
91
+ const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);
92
+ if (isDuplicate) {
93
+ log("capability already contributed, skipping", {
94
+ id: interfaceDef.identifier,
95
+ moduleId
96
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 47, S: this });
97
+ return;
98
+ }
99
+ const entry = {
100
+ moduleId,
101
+ implementation
102
+ };
103
+ this._registry.set(this._capabilityEntries(interfaceDef.identifier), [
104
+ ...current,
105
+ entry
106
+ ]);
107
+ this._registeredIdentifiers.add(interfaceDef.identifier);
108
+ log("capability contributed", {
109
+ id: interfaceDef.identifier,
110
+ moduleId,
111
+ count: current.length
112
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 62, S: this });
113
+ }
114
+ remove(interfaceDef, implementation) {
115
+ const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
116
+ if (current.length === 0) {
117
+ return;
118
+ }
119
+ const next = current.filter((c) => c.implementation !== implementation);
120
+ if (next.length !== current.length) {
121
+ this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
122
+ if (next.length === 0) {
123
+ this._registeredIdentifiers.delete(interfaceDef.identifier);
124
+ }
125
+ log("capability removed", {
126
+ id: interfaceDef.identifier,
127
+ count: current.length
128
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
129
+ } else {
130
+ log.warn("capability not removed", {
131
+ id: interfaceDef.identifier
132
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 84, S: this });
133
+ }
134
+ }
135
+ atom(interfaceDef) {
136
+ return this._capabilities(interfaceDef.identifier);
137
+ }
138
+ getAll(interfaceDef) {
139
+ return this._registry.get(this.atom(interfaceDef));
140
+ }
141
+ get(interfaceDef) {
142
+ const capabilities = this.getAll(interfaceDef);
143
+ if (capabilities.length === 0) {
144
+ log("capability not available", {
145
+ requested: interfaceDef.identifier,
146
+ registered: this.listRegisteredIdentifiers()
147
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 99, S: this });
148
+ invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 103, S: this, A: ["capabilities.length > 0", "`No capability found for ${interfaceDef.identifier}`"] });
149
+ }
150
+ return capabilities[0];
151
+ }
152
+ listRegisteredIdentifiers() {
153
+ return [
154
+ ...this._registeredIdentifiers
155
+ ].sort();
156
+ }
157
+ waitFor(interfaceDef) {
158
+ return Effect.gen(this, function* () {
159
+ const [capability] = this.getAll(interfaceDef);
160
+ if (capability) {
161
+ return capability;
162
+ }
163
+ const deferred = yield* Deferred.make();
164
+ const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
165
+ if (capabilities.length > 0) {
166
+ Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
167
+ }
168
+ });
169
+ const result = yield* Deferred.await(deferred);
170
+ cancel();
171
+ return result;
172
+ });
173
+ }
174
+ atomByModule(interfaceDef) {
175
+ return this._capabilitiesByModule(interfaceDef.identifier);
176
+ }
177
+ };
178
+ var make2 = (options) => new CapabilityManagerImpl(options);
179
+
180
+ // src/core/registry.ts
181
+ var registry_exports = {};
182
+ __export(registry_exports, {
183
+ Manager: () => Manager
184
+ });
185
+ import { Atom as Atom2 } from "@effect-atom/atom-react";
186
+ import * as Effect2 from "effect/Effect";
187
+ import { runAndForwardErrors } from "@dxos/effect";
188
+ import { log as log2 } from "@dxos/log";
189
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/registry.ts";
190
+ var NULL_PROVIDER = {
191
+ listPlugins: () => Effect2.succeed([]),
192
+ listVersions: () => Effect2.fail(new Error("No plugin registry provider configured")),
193
+ getPlugin: () => Effect2.fail(new Error("No plugin registry provider configured"))
194
+ };
195
+ var Manager = class {
196
+ plugins;
197
+ #provider;
198
+ constructor(provider, atomRegistry) {
199
+ this.#provider = provider ?? NULL_PROVIDER;
200
+ const initialLoading = provider !== void 0;
201
+ this.plugins = Atom2.make({
202
+ entries: [],
203
+ loading: initialLoading,
204
+ error: null
205
+ }).pipe(Atom2.keepAlive);
206
+ if (provider !== void 0) {
207
+ void runAndForwardErrors(provider.listPlugins().pipe(Effect2.match({
208
+ onSuccess: (entries) => atomRegistry.set(this.plugins, {
209
+ entries,
210
+ loading: false,
211
+ error: null
212
+ }),
213
+ onFailure: (error) => {
214
+ log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 49, S: this });
215
+ atomRegistry.set(this.plugins, {
216
+ entries: [],
217
+ loading: false,
218
+ error
219
+ });
220
+ }
221
+ })));
222
+ }
223
+ }
224
+ /** Forwards to the underlying provider. */
225
+ listPlugins() {
226
+ return this.#provider.listPlugins();
227
+ }
228
+ /** Forwards to the underlying provider. */
229
+ listVersions(repo) {
230
+ return this.#provider.listVersions(repo);
231
+ }
232
+ /** Forwards to the underlying provider. */
233
+ getPlugin(repo, version) {
234
+ return this.#provider.getPlugin(repo, version);
235
+ }
236
+ };
237
+
238
+ // src/core/plugin-manager.ts
239
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
240
+ var PluginInitializationError = class extends BaseError.extend("PluginInitializationError", "Plugin manager initialization failed") {
241
+ };
242
+ var PluginTimeoutError = class extends BaseError.extend("PluginTimeoutError", "Plugin operation timed out") {
243
+ };
244
+ var DEFAULT_LOAD_TIMEOUT = Duration.seconds(30);
245
+ var DEFAULT_ACTIVATION_TIMEOUT = Duration.seconds(30);
246
+ var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
247
+ var isManager = (value) => {
248
+ return typeof value === "object" && value !== null && ManagerTypeId in value;
249
+ };
250
+ var ManagerImpl = class {
251
+ [ManagerTypeId] = ManagerTypeId;
252
+ activation = Effect3.runSync(PubSub.unbounded());
253
+ capabilities;
254
+ registry;
255
+ pluginRegistry;
256
+ _pluginsAtom;
257
+ _coreAtom;
258
+ _enabledAtom;
259
+ _modulesAtom;
260
+ _activeAtom;
261
+ _eventsFiredAtom;
262
+ _pendingResetAtom;
263
+ _failedAtom;
264
+ _pluginLoader;
265
+ _onRemove;
266
+ _loadTimeout;
267
+ _activationTimeout;
268
+ _capabilities = /* @__PURE__ */ new Map();
269
+ _moduleMemoMap = /* @__PURE__ */ new Map();
270
+ _moduleSemaphores = /* @__PURE__ */ new Map();
271
+ // Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without
272
+ // this, two callers entering `enable(id)` before the swap completes would
273
+ // each invoke `mod.default(options)` and produce distinct module objects,
274
+ // defeating `_addModule`'s reference-equality dedupe and racing the
275
+ // `_pluginsAtom` swap.
276
+ _resolvingPlugins = /* @__PURE__ */ new Map();
277
+ // Tracks dev-source plugins (loaded via a Vite dev server) keyed by id.
278
+ // When `shadow` is present, the entry has displaced an existing plugin —
279
+ // `remove` reinstates it and re-enables iff `wasEnabled`. Entries without a
280
+ // shadow are dev plugins with no underlying registry/builtin to restore.
281
+ // The atom mirrors the map's keys for UI subscribers (they don't need the
282
+ // shadow internals); the two stay in sync via {@link _markDev}/{@link _unmarkDev}.
283
+ _devPlugins = /* @__PURE__ */ new Map();
284
+ _devPluginIdsAtom;
285
+ _activatingEvents = Effect3.runSync(Ref.make([]));
286
+ _activatingModules = Effect3.runSync(Ref.make([]));
287
+ _inFlightFibers = Effect3.runSync(Ref.make([]));
288
+ _shutdownSemaphore = Effect3.runSync(Effect3.makeSemaphore(1));
289
+ _shuttingDown = Effect3.runSync(Ref.make(false));
290
+ // Tracks the constructor-launched core/enabled `enable()` calls so that
291
+ // `activate` can wait for module registration before dispatching events.
292
+ // Lazy plugins make `enable` asynchronous (a dynamic `import()` happens
293
+ // inside it), so without this synchronization an `activate` triggered
294
+ // immediately after `make` could fire on an empty module set. Failures
295
+ // are wrapped in `PluginInitializationError` so awaiters get a tagged
296
+ // error rather than the wide `Error` produced by the underlying chain.
297
+ _initialization = Effect3.runSync(Deferred2.make());
298
+ constructor({ pluginLoader, plugins = [], enabled = [], registry, pluginRegistryProvider, onRemove, loadTimeout = DEFAULT_LOAD_TIMEOUT, activationTimeout = DEFAULT_ACTIVATION_TIMEOUT }) {
299
+ const core = plugins.filter(({ meta }) => meta.tags?.includes("system")).map(({ meta }) => meta.id);
300
+ this.registry = registry ?? Registry.make();
301
+ this.capabilities = make2({
302
+ registry: this.registry
303
+ });
304
+ this.pluginRegistry = new Manager(pluginRegistryProvider, this.registry);
305
+ this._pluginLoader = pluginLoader;
306
+ this._onRemove = onRemove;
307
+ this._loadTimeout = loadTimeout;
308
+ this._activationTimeout = activationTimeout;
309
+ this._pluginsAtom = Atom3.make(plugins).pipe(Atom3.keepAlive);
310
+ this._coreAtom = Atom3.make(core).pipe(Atom3.keepAlive);
311
+ this._enabledAtom = Atom3.make(enabled).pipe(Atom3.keepAlive);
312
+ this._modulesAtom = Atom3.make([]).pipe(Atom3.keepAlive);
313
+ this._activeAtom = Atom3.make([]).pipe(Atom3.keepAlive);
314
+ this._eventsFiredAtom = Atom3.make([]).pipe(Atom3.keepAlive);
315
+ this._pendingResetAtom = Atom3.make([]).pipe(Atom3.keepAlive);
316
+ this._failedAtom = Atom3.make([]).pipe(Atom3.keepAlive);
317
+ this._devPluginIdsAtom = Atom3.make([]).pipe(Atom3.keepAlive);
318
+ plugins.forEach((plugin) => this._addPlugin(plugin));
319
+ const initialIds = [
320
+ .../* @__PURE__ */ new Set([
321
+ ...core,
322
+ ...enabled
323
+ ])
324
+ ];
325
+ void Effect3.all(initialIds.map((id) => this.enable(id))).pipe(Effect3.mapError((cause) => new PluginInitializationError({
326
+ cause
327
+ })), Effect3.tap(() => Deferred2.succeed(this._initialization, void 0)), Effect3.tapErrorCause((cause) => Deferred2.failCause(this._initialization, cause))).pipe(runAndForwardErrors2);
328
+ }
329
+ get plugins() {
330
+ return this._pluginsAtom;
331
+ }
332
+ get core() {
333
+ return this._coreAtom;
334
+ }
335
+ /**
336
+ * Ids of plugins that are currently enabled.
337
+ */
338
+ get enabled() {
339
+ return this._enabledAtom;
340
+ }
341
+ /**
342
+ * Modules of plugins which are currently enabled.
343
+ */
344
+ get modules() {
345
+ return this._modulesAtom;
346
+ }
347
+ /**
348
+ * Ids of modules which are currently active.
349
+ */
350
+ get active() {
351
+ return this._activeAtom;
352
+ }
353
+ /**
354
+ * Ids of events which have been fired.
355
+ */
356
+ get eventsFired() {
357
+ return this._eventsFiredAtom;
358
+ }
359
+ /**
360
+ * Ids of modules which are pending reset.
361
+ */
362
+ get pendingReset() {
363
+ return this._pendingResetAtom;
364
+ }
365
+ /**
366
+ * Plugins that failed to load or activate.
367
+ */
368
+ get failed() {
369
+ return this._failedAtom;
370
+ }
371
+ /**
372
+ * Ids of currently-registered plugins that came from a dev source.
373
+ */
374
+ get devPluginIds() {
375
+ return this._devPluginIdsAtom;
376
+ }
377
+ getPlugins() {
378
+ return this._get(this._pluginsAtom);
379
+ }
380
+ getCore() {
381
+ return this._get(this._coreAtom);
382
+ }
383
+ getEnabled() {
384
+ return this._get(this._enabledAtom);
385
+ }
386
+ getModules() {
387
+ return this._get(this._modulesAtom);
388
+ }
389
+ getActive() {
390
+ return this._get(this._activeAtom);
391
+ }
392
+ getEventsFired() {
393
+ return this._get(this._eventsFiredAtom);
394
+ }
395
+ getPendingReset() {
396
+ return this._get(this._pendingResetAtom);
397
+ }
398
+ getFailed() {
399
+ return this._get(this._failedAtom);
400
+ }
401
+ getDevPluginIds() {
402
+ return this._get(this._devPluginIdsAtom);
403
+ }
404
+ /**
405
+ * Marks `id` as dev-sourced. If the plugin displaced an existing one, pass
406
+ * the shadow snapshot so `remove` can restore it. Repeat calls (e.g. a dev
407
+ * plugin reload) preserve the original shadow target — restoration always
408
+ * unwinds back to the real underlying plugin, never an intermediate dev build.
409
+ */
410
+ _markDev(id, shadow) {
411
+ if (this._devPlugins.has(id)) {
412
+ return;
413
+ }
414
+ this._devPlugins.set(id, {
415
+ shadow
416
+ });
417
+ this._update(this._devPluginIdsAtom, (ids) => ids.includes(id) ? ids : [
418
+ ...ids,
419
+ id
420
+ ]);
421
+ }
422
+ /** Drops the dev-plugin entry and returns its shadow data (if any) for restoration. */
423
+ _unmarkDev(id) {
424
+ const entry = this._devPlugins.get(id);
425
+ this._devPlugins.delete(id);
426
+ this._update(this._devPluginIdsAtom, (ids) => ids.filter((existing) => existing !== id));
427
+ return entry?.shadow;
428
+ }
429
+ getDependencies(id, opts) {
430
+ const transitive = opts?.transitive !== false;
431
+ if (!transitive) {
432
+ return this._directDependencies(id);
433
+ }
434
+ const walk = this._computeDependencyClosure(id);
435
+ return walk.order.filter((depId) => depId !== id);
436
+ }
437
+ getDependents(id, opts) {
438
+ return this._collectDependents(id, {
439
+ transitive: opts?.transitive !== false,
440
+ enabledOnly: opts?.enabledOnly === true
441
+ });
442
+ }
443
+ clearFailure(id) {
444
+ const current = this._get(this._failedAtom);
445
+ if (!current.some((failure) => failure.id === id)) {
446
+ return false;
447
+ }
448
+ this._set(this._failedAtom, current.filter((failure) => failure.id !== id));
449
+ return true;
450
+ }
451
+ /**
452
+ * Adds a plugin to the manager via the plugin loader.
453
+ * The plugin is registered but not enabled; call `enable` separately to activate it.
454
+ * @param id The id of the plugin.
455
+ */
456
+ add(id) {
457
+ return Effect3.gen(this, function* () {
458
+ log3("add plugin", {
459
+ id
460
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 262, S: this });
461
+ const { plugin, dev = false } = yield* this._pluginLoader(id);
462
+ const pluginId = plugin.meta.id;
463
+ const existing = this._getPlugin(pluginId);
464
+ if (dev && existing && existing !== plugin) {
465
+ const wasEnabled = this._get(this._enabledAtom).includes(pluginId);
466
+ if (wasEnabled) {
467
+ yield* this.disable(pluginId);
468
+ }
469
+ this._markDev(pluginId, {
470
+ plugin: existing,
471
+ wasEnabled
472
+ });
473
+ this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === pluginId ? plugin : p));
474
+ } else {
475
+ this._addPlugin(plugin);
476
+ if (dev) {
477
+ this._markDev(pluginId);
478
+ }
479
+ }
480
+ return plugin;
481
+ });
482
+ }
483
+ /**
484
+ * Enables a plugin.
485
+ * @param id The id of the plugin.
486
+ * @param opts See {@link PluginManager.enable}.
487
+ */
488
+ enable(id, opts) {
489
+ const resolveDependencies = opts?.resolveDependencies !== false;
490
+ return Effect3.gen(this, function* () {
491
+ log3("enable plugin", {
492
+ id,
493
+ resolveDependencies
494
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 301, S: this });
495
+ if (!resolveDependencies) {
496
+ return yield* this._enableOne(id);
497
+ }
498
+ if (!this._getPlugin(id) && !this._getCatalogEntry(id)) {
499
+ return yield* this._enableOne(id);
500
+ }
501
+ const walk = this._computeDependencyClosure(id);
502
+ if (walk.cycle) {
503
+ this._recordFailure(id, "load", new PluginDependencyError({
504
+ context: {
505
+ id,
506
+ reason: "cycle",
507
+ path: walk.cycle
508
+ }
509
+ }));
510
+ return false;
511
+ }
512
+ if (walk.missing.length > 0) {
513
+ this._recordFailure(id, "load", new PluginDependencyError({
514
+ context: {
515
+ id,
516
+ reason: "missing",
517
+ missing: walk.missing
518
+ }
519
+ }));
520
+ return false;
521
+ }
522
+ let queue = walk.toInstall.slice();
523
+ const installed = /* @__PURE__ */ new Set();
524
+ while (queue.length > 0) {
525
+ const next = queue.shift();
526
+ if (installed.has(next) || this._getPlugin(next)) {
527
+ continue;
528
+ }
529
+ const installResult = yield* this.add(next).pipe(Effect3.either);
530
+ if (installResult._tag === "Left") {
531
+ this._recordFailure(id, "load", new PluginDependencyError({
532
+ context: {
533
+ id,
534
+ reason: "install-failed",
535
+ dependency: next
536
+ },
537
+ cause: installResult.left
538
+ }));
539
+ return false;
540
+ }
541
+ installed.add(next);
542
+ const rewalk = this._computeDependencyClosure(id);
543
+ if (rewalk.cycle) {
544
+ this._recordFailure(id, "load", new PluginDependencyError({
545
+ context: {
546
+ id,
547
+ reason: "cycle",
548
+ path: rewalk.cycle
549
+ }
550
+ }));
551
+ return false;
552
+ }
553
+ if (rewalk.missing.length > 0) {
554
+ this._recordFailure(id, "load", new PluginDependencyError({
555
+ context: {
556
+ id,
557
+ reason: "missing",
558
+ missing: rewalk.missing
559
+ }
560
+ }));
561
+ return false;
562
+ }
563
+ queue = rewalk.toInstall.filter((depId) => !installed.has(depId));
564
+ }
565
+ const order = this._computeDependencyClosure(id).order;
566
+ let succeeded = false;
567
+ for (const depId of order) {
568
+ const ok = yield* this._enableOne(depId);
569
+ if (depId === id) {
570
+ succeeded = ok;
571
+ }
572
+ }
573
+ return succeeded;
574
+ });
575
+ }
576
+ /**
577
+ * Enables a single plugin without consulting its declared dependencies.
578
+ * Used by {@link enable} as the leaf step after closure resolution, and
579
+ * directly when callers pass `{ resolveDependencies: false }`.
580
+ *
581
+ * The underlying operations (`_addModule`, `_setPendingResetByModule`,
582
+ * `activate`) are all idempotent, so this method is safe to call multiple
583
+ * times for the same id. The constructor's bootstrap path relies on this:
584
+ * the persisted `enabled` ids are written into `_enabledAtom` up front, so
585
+ * the very first `enable(id)` for those plugins sees `alreadyEnabled`-style
586
+ * state but still needs to perform the module registration and activation.
587
+ */
588
+ _enableOne(id) {
589
+ return Effect3.gen(this, function* () {
590
+ const stub = this._getPlugin(id);
591
+ if (!stub) {
592
+ return false;
593
+ }
594
+ this.clearFailure(id);
595
+ const plugin = yield* this._resolveLazyPlugin(stub);
596
+ this._update(this._enabledAtom, (enabled) => enabled.includes(id) ? enabled : [
597
+ ...enabled,
598
+ id
599
+ ]);
600
+ plugin.modules.forEach((module) => {
601
+ this._addModule(module);
602
+ this._setPendingResetByModule(module);
603
+ });
604
+ log3("pending reset", {
605
+ events: [
606
+ ...this.getPendingReset()
607
+ ]
608
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 428, S: this });
609
+ yield* Effect3.all(this.getPendingReset().map((event) => this.activate(event)), {
610
+ concurrency: "unbounded"
611
+ });
612
+ return true;
613
+ });
614
+ }
615
+ /**
616
+ * Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its
617
+ * loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged
618
+ * when the plugin is already resolved, so callers can `yield*` this
619
+ * unconditionally. The lazy stub carries `meta` synchronously but its
620
+ * `modules` list is empty until the loader resolves; the swap ensures
621
+ * subsequent enable/disable operations see the resolved plugin.
622
+ *
623
+ * Concurrent calls for the same id are coalesced via `_resolvingPlugins`:
624
+ * the first caller starts the resolution, every subsequent caller awaits
625
+ * the same `Deferred`. On failure we publish a `lazy:<id>` error message
626
+ * and skip the atom swap so the failure is observable to the activation
627
+ * subscriber and a retry can be attempted.
628
+ */
629
+ _resolveLazyPlugin(plugin) {
630
+ return Effect3.gen(this, function* () {
631
+ if (!isLazy(plugin)) {
632
+ return plugin;
633
+ }
634
+ const id = plugin.meta.id;
635
+ const existing = this._resolvingPlugins.get(id);
636
+ if (existing) {
637
+ return yield* Deferred2.await(existing);
638
+ }
639
+ const deferred = yield* Deferred2.make();
640
+ this._resolvingPlugins.set(id, deferred);
641
+ return yield* Effect3.gen(this, function* () {
642
+ log3("resolving lazy plugin", {
643
+ id
644
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 465, S: this });
645
+ yield* PubSub.publish(this.activation, {
646
+ event: "",
647
+ state: "activating",
648
+ module: `lazy:${id}`
649
+ });
650
+ const resolvedPlugin = yield* resolveLazy(plugin).pipe(
651
+ // Cap how long a remote import can hang. Without this the host can
652
+ // sit on a pending dynamic `import()` indefinitely if the plugin's
653
+ // server is unreachable, which stalls every caller awaiting
654
+ // `enable(id)` and (transitively) the manager's initialization.
655
+ Effect3.timeoutFail({
656
+ duration: this._loadTimeout,
657
+ onTimeout: () => new LazyPluginError({
658
+ context: {
659
+ id,
660
+ reason: "load-failed"
661
+ },
662
+ cause: new PluginTimeoutError({
663
+ context: {
664
+ id,
665
+ phase: "load"
666
+ }
667
+ })
668
+ })
669
+ })
670
+ );
671
+ this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === id ? resolvedPlugin : p));
672
+ yield* PubSub.publish(this.activation, {
673
+ event: "",
674
+ state: "activated",
675
+ module: `lazy:${id}`
676
+ });
677
+ return resolvedPlugin;
678
+ }).pipe(Effect3.tapError((error) => Effect3.gen(this, function* () {
679
+ yield* PubSub.publish(this.activation, {
680
+ event: "",
681
+ state: "error",
682
+ module: `lazy:${id}`,
683
+ error
684
+ });
685
+ this._recordFailure(id, "load", error);
686
+ this._scheduleAutoDisable(id);
687
+ })), Effect3.tap((value) => Deferred2.succeed(deferred, value)), Effect3.tapErrorCause((cause) => Deferred2.failCause(deferred, cause)), Effect3.ensuring(Effect3.sync(() => this._resolvingPlugins.delete(id))));
688
+ });
689
+ }
690
+ /**
691
+ * Removes a plugin from the manager.
692
+ * @param id The id of the plugin.
693
+ * @param opts See {@link PluginManager.remove}.
694
+ */
695
+ remove(id, opts) {
696
+ return Effect3.gen(this, function* () {
697
+ log3("remove plugin", {
698
+ id
699
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 517, S: this });
700
+ const wasDev = this._devPlugins.has(id);
701
+ const disabled = yield* this.disable(id, opts);
702
+ if (!disabled) {
703
+ return false;
704
+ }
705
+ this._removePlugin(id);
706
+ if (this._onRemove) {
707
+ this._runForkedFiber(this._onRemove(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("plugin remove hook failed", {
708
+ id,
709
+ error
710
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 527, S: this }))), Effect3.ignore));
711
+ }
712
+ if (wasDev) {
713
+ const shadow = this._unmarkDev(id);
714
+ if (shadow) {
715
+ this._addPlugin(shadow.plugin);
716
+ if (shadow.wasEnabled) {
717
+ yield* this.enable(id);
718
+ }
719
+ }
720
+ }
721
+ return true;
722
+ });
723
+ }
724
+ /**
725
+ * Disables a plugin.
726
+ * @param id The id of the plugin.
727
+ * @param opts See {@link PluginManager.disable}.
728
+ */
729
+ disable(id, { cascade = true } = {}) {
730
+ return Effect3.gen(this, function* () {
731
+ log3("disable plugin", {
732
+ id,
733
+ cascade
734
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 555, S: this });
735
+ if (this._get(this._coreAtom).includes(id)) {
736
+ return false;
737
+ }
738
+ const plugin = this._getPlugin(id);
739
+ if (!plugin) {
740
+ return false;
741
+ }
742
+ if (cascade) {
743
+ const enabledDependents = this._collectDependents(id, {
744
+ transitive: true,
745
+ enabledOnly: true
746
+ });
747
+ if (enabledDependents.length > 0) {
748
+ const coreDependent = enabledDependents.find((dependentId) => this._get(this._coreAtom).includes(dependentId));
749
+ if (coreDependent) {
750
+ return yield* Effect3.fail(new PluginDependencyError({
751
+ context: {
752
+ id,
753
+ reason: "core-dependent",
754
+ coreDependent
755
+ }
756
+ }));
757
+ }
758
+ for (const dependentId of enabledDependents) {
759
+ yield* this._disableOne(dependentId);
760
+ }
761
+ }
762
+ }
763
+ yield* this._disableOne(id);
764
+ return true;
765
+ });
766
+ }
767
+ /**
768
+ * Disables a single plugin without consulting its dependents. Used by
769
+ * {@link disable} after the dependents pass has run (or been skipped via
770
+ * `cascade: false`).
771
+ */
772
+ _disableOne(id) {
773
+ return Effect3.gen(this, function* () {
774
+ if (this._get(this._coreAtom).includes(id)) {
775
+ return false;
776
+ }
777
+ const plugin = this._getPlugin(id);
778
+ if (!plugin) {
779
+ return false;
780
+ }
781
+ const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);
782
+ if (enabledIndex !== -1) {
783
+ this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));
784
+ yield* this.deactivate(id);
785
+ plugin.modules.forEach((module) => {
786
+ this._removeModule(module.id);
787
+ });
788
+ }
789
+ return true;
790
+ });
791
+ }
792
+ /**
793
+ * Activates plugins based on the activation event.
794
+ * @param event The activation event.
795
+ * @returns Whether the activation was successful.
796
+ */
797
+ activate(event, params) {
798
+ const key = typeof event === "string" ? event : eventKey(event);
799
+ return Effect3.gen(this, function* () {
800
+ if (yield* this._isShuttingDown()) {
801
+ log3("skipping activation during shutdown", {
802
+ key,
803
+ ...params
804
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 626, S: this });
805
+ return false;
806
+ }
807
+ yield* Deferred2.await(this._initialization);
808
+ return yield* Effect3.withFiberRuntime((fiber) => this._activateEvent(key, params, fiber).pipe(together(Effect3.sleep(Duration.seconds(15)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn("event activation is taking a long time", {
809
+ event: key
810
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 637, S: this }))))), Performance.addTrackEntry({
811
+ name: typeof event === "string" ? event : eventKey(event),
812
+ devtools: {
813
+ dataType: "track-entry",
814
+ track: "Event Activation",
815
+ trackGroup: "Composer",
816
+ color: "primary"
817
+ }
818
+ })));
819
+ });
820
+ }
821
+ /**
822
+ * Deactivates all of the modules for a plugin.
823
+ * @param id The id of the plugin.
824
+ * @returns Whether the deactivation was successful.
825
+ */
826
+ deactivate(id) {
827
+ return Effect3.gen(this, function* () {
828
+ const plugin = this._getPlugin(id);
829
+ if (!plugin) {
830
+ return false;
831
+ }
832
+ const modules = plugin.modules;
833
+ const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
834
+ concurrency: "unbounded"
835
+ });
836
+ return results.every((result) => result);
837
+ });
838
+ }
839
+ /**
840
+ * Re-activates the modules that were activated by the event.
841
+ * @param event The activation event.
842
+ * @returns Whether the reset was successful.
843
+ */
844
+ reset(event) {
845
+ return Effect3.gen(this, function* () {
846
+ const key = typeof event === "string" ? event : eventKey(event);
847
+ log3("reset", {
848
+ key
849
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 674, S: this });
850
+ const modules = this._getActiveModulesByEvent(key);
851
+ const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
852
+ concurrency: "unbounded"
853
+ });
854
+ if (results.every((result) => result)) {
855
+ return yield* this.activate(key);
856
+ } else {
857
+ return false;
858
+ }
859
+ });
860
+ }
861
+ shutdown() {
862
+ return this._shutdownSemaphore.withPermits(1)(Effect3.gen(this, function* () {
863
+ yield* Ref.set(this._shuttingDown, true);
864
+ log3("shutdown", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 691, S: this });
865
+ yield* this._interruptInFlightActivations();
866
+ const activeIds = [
867
+ ...this._get(this._activeAtom)
868
+ ].reverse();
869
+ const allModules = this._get(this._modulesAtom);
870
+ const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
871
+ for (const module of modulesToDeactivate) {
872
+ yield* this._deactivateModule(module);
873
+ }
874
+ this._set(this._eventsFiredAtom, []);
875
+ this._set(this._pendingResetAtom, []);
876
+ this._moduleMemoMap.clear();
877
+ yield* Ref.set(this._activatingEvents, []);
878
+ yield* Ref.set(this._activatingModules, []);
879
+ log3("shutdown complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 706, S: this });
880
+ return true;
881
+ }).pipe(Effect3.ensuring(Ref.set(this._shuttingDown, false))));
882
+ }
883
+ //
884
+ // State helpers
885
+ //
886
+ _get(atom) {
887
+ return this.registry.get(atom);
888
+ }
889
+ _set(atom, value) {
890
+ this.registry.set(atom, value);
891
+ }
892
+ _update(atom, updater) {
893
+ this._set(atom, updater(this._get(atom)));
894
+ }
895
+ _isShuttingDown() {
896
+ return Ref.get(this._shuttingDown);
897
+ }
898
+ _getPlugin(id) {
899
+ return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
900
+ }
901
+ _getPluginIdForModule(moduleId) {
902
+ return this._get(this._pluginsAtom).find((plugin) => plugin.modules.some((module) => module.id === moduleId))?.meta.id;
903
+ }
904
+ /** Looks up an id in the cached registry catalog, returning the entry or `undefined`. */
905
+ _getCatalogEntry(id) {
906
+ return this._get(this.pluginRegistry.plugins).entries.find((entry) => entry.id === id);
907
+ }
908
+ /**
909
+ * Returns the direct `dependsOn` declarations for an id, drawing from the
910
+ * registered plugin's meta when available and falling back to the registry
911
+ * catalog entry. Unknown ids return an empty list (callers detect "missing"
912
+ * separately).
913
+ */
914
+ _directDependencies(id) {
915
+ const plugin = this._getPlugin(id);
916
+ if (plugin) {
917
+ return [
918
+ ...plugin.meta.dependsOn ?? []
919
+ ];
920
+ }
921
+ const catalog = this._getCatalogEntry(id);
922
+ return catalog?.dependsOn ? [
923
+ ...catalog.dependsOn
924
+ ] : [];
925
+ }
926
+ /**
927
+ * Computes the transitive dependency closure for an id.
928
+ *
929
+ * Walks {@link _directDependencies} (registered plugins ∪ catalog entries).
930
+ * Returns:
931
+ * - `order`: closure including the root in dependency-first topological order.
932
+ * - `missing`: ids in the closure that are neither registered nor in the catalog.
933
+ * - `toInstall`: ids in the closure that are in the catalog but not yet registered.
934
+ * - `cycle`: when a cycle is detected, the cycle path; otherwise `undefined`.
935
+ */
936
+ _computeDependencyClosure(id) {
937
+ const order = [];
938
+ const visited = /* @__PURE__ */ new Set();
939
+ const onStack = /* @__PURE__ */ new Set();
940
+ const stackPath = [];
941
+ const missing = [];
942
+ const toInstall = [];
943
+ let cycle;
944
+ const knownIds = /* @__PURE__ */ new Set([
945
+ ...this._get(this._pluginsAtom).map((plugin) => plugin.meta.id),
946
+ ...this._get(this.pluginRegistry.plugins).entries.map((entry) => entry.id)
947
+ ]);
948
+ const visit = (currentId) => {
949
+ if (cycle) {
950
+ return;
951
+ }
952
+ if (visited.has(currentId)) {
953
+ return;
954
+ }
955
+ if (onStack.has(currentId)) {
956
+ const cycleStart = stackPath.indexOf(currentId);
957
+ cycle = [
958
+ ...stackPath.slice(cycleStart),
959
+ currentId
960
+ ];
961
+ return;
962
+ }
963
+ onStack.add(currentId);
964
+ stackPath.push(currentId);
965
+ if (!knownIds.has(currentId)) {
966
+ missing.push(currentId);
967
+ } else if (!this._getPlugin(currentId)) {
968
+ toInstall.push(currentId);
969
+ }
970
+ for (const depId of this._directDependencies(currentId)) {
971
+ visit(depId);
972
+ if (cycle) {
973
+ break;
974
+ }
975
+ }
976
+ onStack.delete(currentId);
977
+ stackPath.pop();
978
+ if (!cycle) {
979
+ visited.add(currentId);
980
+ order.push(currentId);
981
+ }
982
+ };
983
+ visit(id);
984
+ return {
985
+ order,
986
+ missing,
987
+ toInstall,
988
+ cycle
989
+ };
990
+ }
991
+ /**
992
+ * Walks the reverse `dependsOn` edges across registered plugins. With
993
+ * `enabledOnly`, filters the result to currently-enabled ids. Returns
994
+ * dependents in dependents-before-deps order so callers (cascade-disable)
995
+ * can iterate and tear down leaves first.
996
+ */
997
+ _collectDependents(id, opts) {
998
+ const direct = this._get(this._pluginsAtom).filter((plugin) => plugin.meta.dependsOn?.some((dep) => dep === id)).map((plugin) => plugin.meta.id);
999
+ if (!opts.transitive) {
1000
+ return opts.enabledOnly ? direct.filter((dependentId) => this._get(this._enabledAtom).includes(dependentId)) : direct;
1001
+ }
1002
+ const result = [];
1003
+ const visited = /* @__PURE__ */ new Set();
1004
+ const visit = (currentId) => {
1005
+ if (visited.has(currentId)) {
1006
+ return;
1007
+ }
1008
+ visited.add(currentId);
1009
+ const parents = this._get(this._pluginsAtom).filter((plugin) => plugin.meta.dependsOn?.some((dep) => dep === currentId)).map((plugin) => plugin.meta.id);
1010
+ for (const parentId of parents) {
1011
+ visit(parentId);
1012
+ if (parentId !== id && !result.includes(parentId)) {
1013
+ result.push(parentId);
1014
+ }
1015
+ }
1016
+ };
1017
+ visit(id);
1018
+ return opts.enabledOnly ? result.filter((dependentId) => this._get(this._enabledAtom).includes(dependentId)) : result;
1019
+ }
1020
+ /**
1021
+ * Records a failure for a plugin. Latest failure wins so the registry UI
1022
+ * always sees the most recent reason. Walks the `cause` chain when checking
1023
+ * for timeouts: lazy-load timeouts arrive wrapped in `LazyPluginError` (the
1024
+ * timeout is the cause), but the operator-visible reason should still be
1025
+ * `'timeout'`.
1026
+ */
1027
+ _recordFailure(id, phase, error) {
1028
+ const reason = isTimeoutCause(error) ? "timeout" : "error";
1029
+ const failure = {
1030
+ id,
1031
+ phase,
1032
+ reason,
1033
+ error,
1034
+ timestamp: Date.now()
1035
+ };
1036
+ log3.warn("plugin failed", {
1037
+ id,
1038
+ phase,
1039
+ reason,
1040
+ error: error.message
1041
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 858, S: this });
1042
+ this._update(this._failedAtom, (current) => [
1043
+ ...current.filter((entry) => entry.id !== id),
1044
+ failure
1045
+ ]);
1046
+ }
1047
+ /**
1048
+ * Fire-and-forget disable of a failed plugin. Forked because a failure can
1049
+ * happen mid-activation chain — yielding a `disable` inline would deadlock
1050
+ * on the shared semaphores. Core plugins are skipped (the host opted into
1051
+ * them being non-removable; the failure record is enough signal).
1052
+ */
1053
+ _scheduleAutoDisable(id) {
1054
+ if (this._get(this._coreAtom).includes(id)) {
1055
+ return;
1056
+ }
1057
+ if (!this._get(this._enabledAtom).includes(id)) {
1058
+ return;
1059
+ }
1060
+ this._runForkedFiber(this.disable(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("auto-disable failed", {
1061
+ id,
1062
+ error
1063
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 881, S: this }))), Effect3.ignore));
1064
+ }
1065
+ _getActiveModules() {
1066
+ const active = this._get(this._activeAtom);
1067
+ return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
1068
+ }
1069
+ _getInactiveModules() {
1070
+ const active = this._get(this._activeAtom);
1071
+ return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
1072
+ }
1073
+ _getActiveModulesByEvent(key) {
1074
+ return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
1075
+ }
1076
+ _getInactiveModulesByEvent(key) {
1077
+ return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
1078
+ }
1079
+ _setPendingResetByModule(module) {
1080
+ const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
1081
+ const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
1082
+ const pending = this._get(this._pendingResetAtom);
1083
+ return !pending.includes(event);
1084
+ });
1085
+ if (pendingReset.length > 0) {
1086
+ log3("pending reset", {
1087
+ events: pendingReset
1088
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 907, S: this });
1089
+ this._update(this._pendingResetAtom, (current) => [
1090
+ ...current,
1091
+ ...pendingReset
1092
+ ]);
1093
+ }
1094
+ }
1095
+ _clearPendingReset(key) {
1096
+ const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
1097
+ if (pendingIndex !== -1) {
1098
+ this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
1099
+ }
1100
+ }
1101
+ //
1102
+ // Fiber helpers
1103
+ //
1104
+ _interruptInFlightActivations() {
1105
+ return Effect3.gen(this, function* () {
1106
+ const inFlightFibers = yield* Ref.get(this._inFlightFibers);
1107
+ yield* Effect3.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
1108
+ concurrency: "unbounded"
1109
+ });
1110
+ });
1111
+ }
1112
+ _trackFiber(ref, fiber) {
1113
+ return Ref.update(ref, (fibers) => [
1114
+ ...fibers,
1115
+ fiber
1116
+ ]);
1117
+ }
1118
+ _untrackFiber(ref, fiber) {
1119
+ return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
1120
+ }
1121
+ /**
1122
+ * Spawns an effect on the default runtime and registers the resulting fiber in
1123
+ * `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry
1124
+ * points like {@link remove} where there is no enclosing Effect to fork from;
1125
+ * inside an Effect chain prefer the existing track/await/untrack pattern.
1126
+ */
1127
+ _runForkedFiber(effect) {
1128
+ const fiber = Effect3.runFork(effect);
1129
+ Effect3.runSync(this._trackFiber(this._inFlightFibers, fiber));
1130
+ Effect3.runFork(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
1131
+ }
1132
+ //
1133
+ // Registration helpers
1134
+ //
1135
+ _addPlugin(plugin) {
1136
+ log3("add plugin", {
1137
+ id: plugin.meta.id
1138
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 956, S: this });
1139
+ this._update(this._pluginsAtom, (plugins) => plugins.includes(plugin) ? plugins : [
1140
+ ...plugins,
1141
+ plugin
1142
+ ]);
1143
+ }
1144
+ _removePlugin(id) {
1145
+ log3("remove plugin", {
1146
+ id
1147
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 966, S: this });
1148
+ this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));
1149
+ }
1150
+ _addModule(module) {
1151
+ log3("add module", {
1152
+ id: module.id
1153
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 972, S: this });
1154
+ this._update(this._modulesAtom, (modules) => modules.includes(module) ? modules : [
1155
+ ...modules,
1156
+ module
1157
+ ]);
1158
+ }
1159
+ _removeModule(id) {
1160
+ log3("remove module", {
1161
+ id
1162
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 982, S: this });
1163
+ this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
1164
+ }
1165
+ //
1166
+ // Activation helpers
1167
+ //
1168
+ _activateEvent(key, params, fiber) {
1169
+ return Effect3.gen(this, function* () {
1170
+ yield* this._trackFiber(this._inFlightFibers, fiber);
1171
+ log3("activating", {
1172
+ key,
1173
+ ...params
1174
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 993, S: this });
1175
+ yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
1176
+ this._clearPendingReset(key);
1177
+ const activatingEvents = yield* this._activatingEvents;
1178
+ const activatingModules = yield* this._activatingModules;
1179
+ const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
1180
+ if (modules.length === 0) {
1181
+ log3("no modules to activate", {
1182
+ key
1183
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1003, S: this });
1184
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
1185
+ this._update(this._eventsFiredAtom, (events) => [
1186
+ ...events,
1187
+ key
1188
+ ]);
1189
+ }
1190
+ return false;
1191
+ }
1192
+ return yield* this._activateModulesForEvent(key, modules, activatingEvents);
1193
+ }).pipe(Effect3.ensuring(Effect3.all([
1194
+ this._untrackFiber(this._inFlightFibers, fiber),
1195
+ Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
1196
+ ])));
1197
+ }
1198
+ _activateModulesForEvent(key, modules, activatingEvents) {
1199
+ const activatingModuleIds = modules.map((module) => module.id);
1200
+ return Effect3.gen(this, function* () {
1201
+ yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
1202
+ log3.info("activation wave", {
1203
+ event: key,
1204
+ modules: activatingModuleIds
1205
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1024, S: this });
1206
+ performance.mark(`event:${key}:start`);
1207
+ yield* PubSub.publish(this.activation, {
1208
+ event: key,
1209
+ state: "activating"
1210
+ });
1211
+ yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
1212
+ const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
1213
+ yield* this._contributeCapabilitiesForModules(modules, capabilities);
1214
+ yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
1215
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
1216
+ this._update(this._eventsFiredAtom, (events) => [
1217
+ ...events,
1218
+ key
1219
+ ]);
1220
+ }
1221
+ performance.mark(`event:${key}:end`);
1222
+ performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
1223
+ yield* PubSub.publish(this.activation, {
1224
+ event: key,
1225
+ state: "activated"
1226
+ });
1227
+ log3("activated", {
1228
+ key
1229
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1049, S: this });
1230
+ return true;
1231
+ }).pipe(Effect3.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
1232
+ }
1233
+ _getModulesForActivation(key, activatingEvents, activatingModules) {
1234
+ return this._getInactiveModulesByEvent(key).filter((module) => {
1235
+ const allOf = isAllOf(module.activatesOn);
1236
+ if (!allOf) {
1237
+ return true;
1238
+ }
1239
+ const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
1240
+ return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
1241
+ });
1242
+ }
1243
+ _getBeforeEvents(modules, activatingEvents) {
1244
+ return Function.pipe(modules, Array.flatMap((module) => module.firesBeforeActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
1245
+ }
1246
+ _getAfterEvents(modules, activatingEvents) {
1247
+ return Function.pipe(modules, Array.flatMap((module) => module.firesAfterActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
1248
+ }
1249
+ _activateRelatedEvents(key, events, phase) {
1250
+ const logLabel = phase === "before" ? "firesBeforeActivation" : "firesAfterActivation";
1251
+ const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
1252
+ return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
1253
+ before: key
1254
+ } : {
1255
+ after: key
1256
+ })), Effect3.allWith({
1257
+ concurrency: "unbounded"
1258
+ }), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`${logLabel} is taking a long time`, {
1259
+ event: key,
1260
+ [eventKey2]: events.map(eventKey)
1261
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1082, S: this }))))), Effect3.asVoid);
1262
+ }
1263
+ //
1264
+ // Module lifecycle helpers
1265
+ //
1266
+ _loadCapabilitiesForModules(key, modules) {
1267
+ return Function.pipe(modules, Array.map((mod) => this._loadModule(mod, key)), Effect3.allWith({
1268
+ concurrency: "unbounded"
1269
+ }), Effect3.catchAll((error) => {
1270
+ return Effect3.gen(this, function* () {
1271
+ yield* PubSub.publish(this.activation, {
1272
+ event: key,
1273
+ state: "error",
1274
+ error
1275
+ });
1276
+ return yield* Effect3.fail(error);
1277
+ });
1278
+ }));
1279
+ }
1280
+ _contributeCapabilitiesForModules(modules, capabilities) {
1281
+ return Function.pipe(
1282
+ modules,
1283
+ Array.zip(capabilities),
1284
+ Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
1285
+ Effect3.all,
1286
+ Effect3.asVoid
1287
+ );
1288
+ }
1289
+ _getModuleSemaphore(moduleId) {
1290
+ let semaphore = this._moduleSemaphores.get(moduleId);
1291
+ if (!semaphore) {
1292
+ semaphore = Effect3.runSync(Effect3.makeSemaphore(1));
1293
+ this._moduleSemaphores.set(moduleId, semaphore);
1294
+ }
1295
+ return semaphore;
1296
+ }
1297
+ // `parentEvent` is the activation event that first triggered this module
1298
+ // load — included in `activating`/`activated` PubSub messages so subscribers
1299
+ // (e.g. the boot loader's status listener) can associate a module with its
1300
+ // triggering event in the trace. The same module may be referenced by
1301
+ // multiple events, but module loads are memoized via `_moduleMemoMap`, so
1302
+ // only the first event to need it will appear here; later events await the
1303
+ // cached deferred without re-publishing.
1304
+ _loadModule = (module, parentEvent) => Effect3.gen(this, function* () {
1305
+ const semaphore = this._getModuleSemaphore(module.id);
1306
+ const deferredToAwait = yield* Effect3.gen(this, function* () {
1307
+ const existing = this._moduleMemoMap.get(module.id);
1308
+ if (existing) {
1309
+ return existing;
1310
+ }
1311
+ const deferred = yield* Deferred2.make();
1312
+ this._moduleMemoMap.set(module.id, deferred);
1313
+ const loadEffect = Effect3.gen(this, function* () {
1314
+ log3("loading module", {
1315
+ module: module.id,
1316
+ parentEvent
1317
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1140, S: this });
1318
+ performance.mark(`module:${module.id}:start`);
1319
+ yield* PubSub.publish(this.activation, {
1320
+ event: parentEvent,
1321
+ state: "activating",
1322
+ module: module.id
1323
+ });
1324
+ const pluginId = this._getPluginIdForModule(module.id);
1325
+ const [duration, capabilities] = yield* module.activate().pipe(
1326
+ Effect3.provideService(Service, this.capabilities),
1327
+ Effect3.provideService(Service2, this),
1328
+ // Cap activation so a single misbehaving module can't hold the
1329
+ // event chain open. On timeout the failure is recorded against
1330
+ // the plugin and surfaced as `PluginTimeoutError`.
1331
+ Effect3.timeoutFail({
1332
+ duration: this._activationTimeout,
1333
+ onTimeout: () => new PluginTimeoutError({
1334
+ context: {
1335
+ id: pluginId ?? module.id,
1336
+ module: module.id,
1337
+ phase: "activation"
1338
+ }
1339
+ })
1340
+ }),
1341
+ Effect3.timed
1342
+ );
1343
+ const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
1344
+ capabilities
1345
+ ];
1346
+ const elapsed = Duration.toMillis(duration);
1347
+ performance.mark(`module:${module.id}:end`);
1348
+ performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
1349
+ yield* PubSub.publish(this.activation, {
1350
+ event: parentEvent,
1351
+ state: "activated",
1352
+ module: module.id
1353
+ });
1354
+ log3("loaded module", {
1355
+ module: module.id,
1356
+ parentEvent,
1357
+ elapsed,
1358
+ failed: false
1359
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1175, S: this });
1360
+ return normalized;
1361
+ }).pipe(Effect3.withSpan("PluginManager._loadModule"), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`module is taking a long time to activate`, {
1362
+ module: module.id
1363
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1182, S: this }))))), Performance.addTrackEntry({
1364
+ name: module.id,
1365
+ devtools: {
1366
+ dataType: "track-entry",
1367
+ track: "Module Activation",
1368
+ trackGroup: "Composer",
1369
+ color: "primary"
1370
+ }
1371
+ }));
1372
+ const fiber = yield* Effect3.forkDaemon(loadEffect.pipe(Effect3.tap((result) => Deferred2.succeed(deferred, result)), Effect3.catchAllCause((cause) => {
1373
+ const error = Cause.squash(cause);
1374
+ const errorMessage = error instanceof Error ? error.message : String(error);
1375
+ const missingCapability = errorMessage.match(/No capability found for ([^\s\[]+)/)?.[1];
1376
+ log3.error("module failed to activate", {
1377
+ module: module.id,
1378
+ parentEvent,
1379
+ missingCapability,
1380
+ registeredCapabilities: this.capabilities.listRegisteredIdentifiers(),
1381
+ error: errorMessage,
1382
+ stack: error instanceof Error ? error.stack : void 0,
1383
+ isDefect: !Cause.isFailure(cause)
1384
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1198, S: this });
1385
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
1386
+ const pluginId = this._getPluginIdForModule(module.id);
1387
+ if (pluginId !== void 0) {
1388
+ this._recordFailure(pluginId, "activation", normalizedError);
1389
+ this._scheduleAutoDisable(pluginId);
1390
+ }
1391
+ return Deferred2.fail(deferred, normalizedError);
1392
+ })));
1393
+ yield* this._trackFiber(this._inFlightFibers, fiber);
1394
+ yield* Effect3.forkDaemon(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
1395
+ return deferred;
1396
+ }).pipe(semaphore.withPermits(1));
1397
+ return yield* Deferred2.await(deferredToAwait);
1398
+ });
1399
+ _contributeCapabilities(module, capabilities) {
1400
+ return Effect3.gen(this, function* () {
1401
+ capabilities.forEach((capability) => {
1402
+ this.capabilities.contribute({
1403
+ module: module.id,
1404
+ ...capability
1405
+ });
1406
+ });
1407
+ this._update(this._activeAtom, (active) => [
1408
+ ...active,
1409
+ module.id
1410
+ ]);
1411
+ this._capabilities.set(module.id, capabilities);
1412
+ });
1413
+ }
1414
+ _deactivateModule(module) {
1415
+ return Effect3.gen(this, function* () {
1416
+ const id = module.id;
1417
+ log3("deactivating", {
1418
+ id
1419
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1240, S: this });
1420
+ this._moduleMemoMap.delete(id);
1421
+ const capabilities = this._capabilities.get(id);
1422
+ if (capabilities) {
1423
+ for (const capability of capabilities) {
1424
+ this.capabilities.remove(capability.interface, capability.implementation);
1425
+ const program = capability.deactivate?.() ?? Effect3.succeed(void 0);
1426
+ yield* program;
1427
+ }
1428
+ this._capabilities.delete(id);
1429
+ }
1430
+ const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);
1431
+ if (activeIndex !== -1) {
1432
+ this._update(this._activeAtom, (active) => active.filter((event) => event !== id));
1433
+ }
1434
+ log3("deactivated", {
1435
+ id
1436
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 1257, S: this });
1437
+ return true;
1438
+ });
1439
+ }
1440
+ };
1441
+ var make5 = (options) => new ManagerImpl(options);
1442
+ var isTimeoutCause = (error, depth = 0) => {
1443
+ if (depth > 5 || !(error instanceof Error)) {
1444
+ return false;
1445
+ }
1446
+ if (PluginTimeoutError.is(error)) {
1447
+ return true;
1448
+ }
1449
+ return isTimeoutCause(error.cause, depth + 1);
1450
+ };
1451
+ var together = (togetherEffect) => (effect) => Effect3.gen(function* () {
1452
+ const togetherFiber = yield* Effect3.fork(togetherEffect);
1453
+ const result = yield* effect;
1454
+ yield* Fiber.interrupt(togetherFiber);
1455
+ return result;
1456
+ });
1457
+
1458
+ export {
1459
+ capability_manager_exports,
1460
+ registry_exports,
1461
+ PluginInitializationError,
1462
+ PluginTimeoutError,
1463
+ ManagerTypeId,
1464
+ isManager,
1465
+ make5 as make,
1466
+ plugin_manager_exports
1467
+ };
1468
+ //# sourceMappingURL=chunk-4BX2AE47.mjs.map