@dxos/app-framework 0.8.4-main.c85a9c8dae → 0.8.4-main.cb12b3f963

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 (325) hide show
  1. package/dist/lib/browser/{capability-7RLVE42K.mjs → capability-5RRH3WIB.mjs} +11 -10
  2. package/dist/lib/browser/capability-5RRH3WIB.mjs.map +7 -0
  3. package/dist/lib/browser/{capability-2GL5JAGJ.mjs → capability-LUKGKUQH.mjs} +10 -9
  4. package/dist/lib/browser/{chunk-5RJNZV7K.mjs → chunk-23D4SJUE.mjs} +11 -13
  5. package/dist/lib/browser/{chunk-5RJNZV7K.mjs.map → chunk-23D4SJUE.mjs.map} +3 -3
  6. package/dist/lib/browser/{chunk-YNFPIQGB.mjs → chunk-3JWJXGLK.mjs} +5 -2
  7. package/dist/lib/browser/chunk-3JWJXGLK.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-45CHLTBV.mjs +34 -0
  9. package/dist/lib/browser/chunk-45CHLTBV.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-66IXTIVK.mjs} +3 -2
  11. package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-CZ4BIAHH.mjs +422 -0
  13. package/dist/lib/browser/chunk-CZ4BIAHH.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
  15. package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-FJ4765WW.mjs.map} +3 -3
  16. package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
  17. package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-MX5DKEJH.mjs +584 -0
  19. package/dist/lib/browser/chunk-MX5DKEJH.mjs.map +7 -0
  20. package/dist/lib/browser/chunk-NBXPP7JR.mjs +1174 -0
  21. package/dist/lib/browser/chunk-NBXPP7JR.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-PC4NOADA.mjs +471 -0
  23. package/dist/lib/browser/chunk-PC4NOADA.mjs.map +7 -0
  24. package/dist/lib/browser/{chunk-REORGDJT.mjs → chunk-WBHCSOBW.mjs} +18 -18
  25. package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
  26. package/dist/lib/browser/{chunk-FNKT2QQ2.mjs → chunk-Z55LVAGN.mjs} +85 -17
  27. package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
  28. package/dist/lib/browser/{chunk-ZRWBPIZG.mjs → chunk-ZGJAZSNE.mjs} +9 -37
  29. package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
  30. package/dist/lib/browser/cli/index.mjs +16 -29
  31. package/dist/lib/browser/cli/index.mjs.map +3 -3
  32. package/dist/lib/browser/common/activation-events.mjs +9 -8
  33. package/dist/lib/browser/common/capabilities.mjs +9 -8
  34. package/dist/lib/browser/core/activation-event.mjs +1 -1
  35. package/dist/lib/browser/core/capability.mjs +3 -1
  36. package/dist/lib/browser/core/plugin-manager.mjs +8 -4
  37. package/dist/lib/browser/core/plugin.mjs +14 -4
  38. package/dist/lib/browser/core/url-loader.mjs +24 -0
  39. package/dist/lib/browser/index.mjs +37 -22
  40. package/dist/lib/browser/index.mjs.map +3 -3
  41. package/dist/lib/browser/{invoker-capability-BNLVNYHU.mjs → invoker-capability-K4GHUFXF.mjs} +22 -14
  42. package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs.map +7 -0
  43. package/dist/lib/browser/meta.json +1 -1
  44. package/dist/lib/browser/testing/index.mjs +184 -49
  45. package/dist/lib/browser/testing/index.mjs.map +4 -4
  46. package/dist/lib/browser/testing/react.mjs +78 -0
  47. package/dist/lib/browser/testing/react.mjs.map +7 -0
  48. package/dist/lib/browser/ui/index.mjs +18 -15
  49. package/dist/lib/node-esm/{capability-CHIMU6LX.mjs → capability-FCGZVIEG.mjs} +10 -9
  50. package/dist/lib/{browser/capability-2GL5JAGJ.mjs.map → node-esm/capability-FCGZVIEG.mjs.map} +1 -1
  51. package/dist/lib/node-esm/{capability-EVZK4REM.mjs → capability-JOIQ2MQE.mjs} +11 -10
  52. package/dist/lib/node-esm/capability-JOIQ2MQE.mjs.map +7 -0
  53. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-37Z53PXZ.mjs} +2 -2
  54. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-37Z53PXZ.mjs.map} +3 -3
  55. package/dist/lib/node-esm/chunk-42J2ZUQQ.mjs +472 -0
  56. package/dist/lib/node-esm/chunk-42J2ZUQQ.mjs.map +7 -0
  57. package/dist/lib/node-esm/chunk-6XW6LET6.mjs +35 -0
  58. package/dist/lib/node-esm/chunk-6XW6LET6.mjs.map +7 -0
  59. package/dist/lib/node-esm/{chunk-2A4PRBIX.mjs → chunk-D347W3KO.mjs} +9 -37
  60. package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
  61. package/dist/lib/node-esm/{chunk-CJCQS2YL.mjs → chunk-HTBJU5FX.mjs} +85 -17
  62. package/dist/lib/node-esm/chunk-HTBJU5FX.mjs.map +7 -0
  63. package/dist/lib/node-esm/chunk-M3HKPRPO.mjs +423 -0
  64. package/dist/lib/node-esm/chunk-M3HKPRPO.mjs.map +7 -0
  65. package/dist/lib/node-esm/chunk-MUVUQC3G.mjs +1175 -0
  66. package/dist/lib/node-esm/chunk-MUVUQC3G.mjs.map +7 -0
  67. package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs → chunk-SBS2YMPT.mjs} +11 -13
  68. package/dist/lib/node-esm/{chunk-VUIUFIGT.mjs.map → chunk-SBS2YMPT.mjs.map} +3 -3
  69. package/dist/lib/node-esm/{chunk-SB5ODNPX.mjs → chunk-SDJ4B2LU.mjs} +5 -2
  70. package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs.map +7 -0
  71. package/dist/lib/node-esm/{chunk-UFW652GS.mjs → chunk-WFSRZKBP.mjs} +18 -18
  72. package/dist/lib/node-esm/chunk-WFSRZKBP.mjs.map +7 -0
  73. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs +70 -0
  74. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +7 -0
  75. package/dist/lib/node-esm/chunk-WKTLE7MG.mjs +585 -0
  76. package/dist/lib/node-esm/chunk-WKTLE7MG.mjs.map +7 -0
  77. package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-XOCUANHO.mjs} +3 -2
  78. package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
  79. package/dist/lib/node-esm/cli/index.mjs +16 -29
  80. package/dist/lib/node-esm/cli/index.mjs.map +3 -3
  81. package/dist/lib/node-esm/common/activation-events.mjs +9 -8
  82. package/dist/lib/node-esm/common/capabilities.mjs +9 -8
  83. package/dist/lib/node-esm/core/activation-event.mjs +1 -1
  84. package/dist/lib/node-esm/core/capability.mjs +3 -1
  85. package/dist/lib/node-esm/core/plugin-manager.mjs +8 -4
  86. package/dist/lib/node-esm/core/plugin.mjs +14 -4
  87. package/dist/lib/node-esm/core/url-loader.mjs +25 -0
  88. package/dist/lib/node-esm/index.mjs +37 -22
  89. package/dist/lib/node-esm/index.mjs.map +3 -3
  90. package/dist/lib/node-esm/{invoker-capability-VF6SP44V.mjs → invoker-capability-XEPW5LMJ.mjs} +22 -14
  91. package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs.map +7 -0
  92. package/dist/lib/node-esm/meta.json +1 -1
  93. package/dist/lib/node-esm/testing/index.mjs +184 -49
  94. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  95. package/dist/lib/node-esm/testing/react.mjs +79 -0
  96. package/dist/lib/node-esm/testing/react.mjs.map +7 -0
  97. package/dist/lib/node-esm/ui/index.mjs +18 -15
  98. package/dist/plugin/node-esm/index.mjs +875 -0
  99. package/dist/plugin/node-esm/index.mjs.map +7 -0
  100. package/dist/plugin/node-esm/meta.json +1 -0
  101. package/dist/types/src/common/activation-events.d.ts +1 -1
  102. package/dist/types/src/common/activation-events.d.ts.map +1 -1
  103. package/dist/types/src/common/annotations.d.ts +1 -0
  104. package/dist/types/src/common/annotations.d.ts.map +1 -0
  105. package/dist/types/src/common/capabilities.d.ts +4 -8
  106. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  107. package/dist/types/src/common/operations.d.ts +8 -22
  108. package/dist/types/src/common/operations.d.ts.map +1 -1
  109. package/dist/types/src/core/activation-event.d.ts +5 -5
  110. package/dist/types/src/core/activation-event.d.ts.map +1 -1
  111. package/dist/types/src/core/capability-manager.d.ts +5 -0
  112. package/dist/types/src/core/capability-manager.d.ts.map +1 -1
  113. package/dist/types/src/core/capability.d.ts +8 -2
  114. package/dist/types/src/core/capability.d.ts.map +1 -1
  115. package/dist/types/src/core/edge-registry-plugin-provider.d.ts +30 -0
  116. package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -0
  117. package/dist/types/src/core/index.d.ts +6 -0
  118. package/dist/types/src/core/index.d.ts.map +1 -1
  119. package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
  120. package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
  121. package/dist/types/src/core/plugin-manager.d.ts +177 -4
  122. package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
  123. package/dist/types/src/core/plugin-manifest.d.ts +101 -0
  124. package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
  125. package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
  126. package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
  127. package/dist/types/src/core/plugin.d.ts +113 -7
  128. package/dist/types/src/core/plugin.d.ts.map +1 -1
  129. package/dist/types/src/core/registry.d.ts +101 -0
  130. package/dist/types/src/core/registry.d.ts.map +1 -0
  131. package/dist/types/src/core/url-loader.d.ts +127 -0
  132. package/dist/types/src/core/url-loader.d.ts.map +1 -0
  133. package/dist/types/src/core/url-loader.test.d.ts +2 -0
  134. package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
  135. package/dist/types/src/helpers.d.ts.map +1 -1
  136. package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +1 -1
  137. package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -1
  138. package/dist/types/src/plugin-operation/history/errors.d.ts +30 -3
  139. package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -1
  140. package/dist/types/src/plugin-operation/history/history-tracker.d.ts +1 -1
  141. package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -1
  142. package/dist/types/src/plugin-operation/history/types.d.ts +1 -1
  143. package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -1
  144. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +1 -1
  145. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
  146. package/dist/types/src/plugin-operation/history/undo-registry.d.ts +1 -1
  147. package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -1
  148. package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
  149. package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -1
  150. package/dist/types/src/plugin-operation/testing.d.ts +27 -77
  151. package/dist/types/src/plugin-operation/testing.d.ts.map +1 -1
  152. package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -1
  153. package/dist/types/src/plugin-runtime/capability.d.ts +1 -1
  154. package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
  155. package/dist/types/src/testing/harness.d.ts +67 -0
  156. package/dist/types/src/testing/harness.d.ts.map +1 -0
  157. package/dist/types/src/testing/index.d.ts +1 -0
  158. package/dist/types/src/testing/index.d.ts.map +1 -1
  159. package/dist/types/src/testing/react.d.ts +27 -0
  160. package/dist/types/src/testing/react.d.ts.map +1 -0
  161. package/dist/types/src/testing/react.test.d.ts +2 -0
  162. package/dist/types/src/testing/react.test.d.ts.map +1 -0
  163. package/dist/types/src/testing/service.d.ts.map +1 -1
  164. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  165. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
  166. package/dist/types/src/ui/components/App/App.d.ts +3 -2
  167. package/dist/types/src/ui/components/App/App.d.ts.map +1 -1
  168. package/dist/types/src/ui/components/App/App.stories.d.ts +2 -2
  169. package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -1
  170. package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts +64 -0
  171. package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +1 -0
  172. package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +19 -0
  173. package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +1 -0
  174. package/dist/types/src/ui/components/Placeholder/index.d.ts +2 -0
  175. package/dist/types/src/ui/components/Placeholder/index.d.ts.map +1 -0
  176. package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -1
  177. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +16 -4
  178. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -1
  179. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -1
  180. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
  181. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
  182. package/dist/types/src/ui/components/Surface/index.d.ts +22 -6
  183. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -1
  184. package/dist/types/src/ui/components/Surface/types.d.ts +110 -9
  185. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -1
  186. package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
  187. package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
  188. package/dist/types/src/ui/components/index.d.ts +1 -0
  189. package/dist/types/src/ui/components/index.d.ts.map +1 -1
  190. package/dist/types/src/ui/hooks/index.d.ts +0 -1
  191. package/dist/types/src/ui/hooks/index.d.ts.map +1 -1
  192. package/dist/types/src/ui/hooks/useApp.d.ts +43 -4
  193. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -1
  194. package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
  195. package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
  196. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -1
  197. package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -1
  198. package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -1
  199. package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +34 -0
  200. package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -0
  201. package/dist/types/src/vite-plugin/boot-loader/index.d.ts +52 -0
  202. package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
  203. package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
  204. package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
  205. package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
  206. package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
  207. package/dist/types/src/vite-plugin/index.d.ts +5 -0
  208. package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
  209. package/dist/types/src/vite-plugin/manifest.d.ts +41 -0
  210. package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
  211. package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
  212. package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
  213. package/dist/types/src/vite-plugin/packages.d.ts +13 -0
  214. package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
  215. package/dist/types/tsconfig.tsbuildinfo +1 -1
  216. package/moon.yml +15 -0
  217. package/package.json +48 -53
  218. package/src/cli/cli.ts +3 -3
  219. package/src/common/activation-events.ts +6 -6
  220. package/src/common/annotations.ts +3 -0
  221. package/src/common/capabilities.ts +18 -23
  222. package/src/common/operations.ts +7 -10
  223. package/src/context.ts +1 -1
  224. package/src/core/activation-event.ts +5 -2
  225. package/src/core/capability-manager.test.ts +1 -1
  226. package/src/core/capability-manager.ts +22 -1
  227. package/src/core/capability.ts +13 -2
  228. package/src/core/edge-registry-plugin-provider.ts +92 -0
  229. package/src/core/index.ts +6 -0
  230. package/src/core/plugin-asset-cache.ts +60 -0
  231. package/src/core/plugin-manager.test.ts +855 -29
  232. package/src/core/plugin-manager.ts +808 -188
  233. package/src/core/plugin-manifest.test.ts +75 -0
  234. package/src/core/plugin-manifest.ts +134 -0
  235. package/src/core/plugin.ts +144 -12
  236. package/src/core/registry.ts +157 -0
  237. package/src/core/url-loader.test.ts +221 -0
  238. package/src/core/url-loader.ts +388 -0
  239. package/src/plugin-operation/OperationPlugin.ts +2 -3
  240. package/src/plugin-operation/history/capability.ts +1 -2
  241. package/src/plugin-operation/history/errors.ts +2 -6
  242. package/src/plugin-operation/history/history-tracker.test.ts +37 -43
  243. package/src/plugin-operation/history/history-tracker.ts +1 -2
  244. package/src/plugin-operation/history/types.ts +1 -1
  245. package/src/plugin-operation/history/undo-mapping.ts +1 -1
  246. package/src/plugin-operation/history/undo-registry.test.ts +3 -4
  247. package/src/plugin-operation/history/undo-registry.ts +1 -1
  248. package/src/plugin-operation/invoker-capability.ts +19 -4
  249. package/src/plugin-operation/meta.ts +1 -1
  250. package/src/plugin-operation/testing.ts +26 -45
  251. package/src/plugin-runtime/RuntimePlugin.ts +2 -3
  252. package/src/plugin-runtime/meta.ts +1 -1
  253. package/src/testing/harness.ts +229 -0
  254. package/src/testing/index.ts +1 -0
  255. package/src/testing/react.test.tsx +48 -0
  256. package/src/testing/react.tsx +113 -0
  257. package/src/testing/service.ts +3 -3
  258. package/src/testing/withPluginManager.stories.tsx +1 -2
  259. package/src/testing/withPluginManager.tsx +40 -18
  260. package/src/ui/components/App/App.stories.tsx +5 -5
  261. package/src/ui/components/App/App.tsx +29 -5
  262. package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
  263. package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
  264. package/src/ui/components/Placeholder/index.ts +5 -0
  265. package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +8 -6
  266. package/src/ui/components/Surface/SurfaceComponent.stories.tsx +16 -15
  267. package/src/ui/components/Surface/SurfaceComponent.tsx +109 -53
  268. package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
  269. package/src/ui/components/Surface/index.ts +35 -1
  270. package/src/ui/components/Surface/types.test.ts +126 -0
  271. package/src/ui/components/Surface/types.ts +164 -12
  272. package/src/ui/components/index.ts +1 -0
  273. package/src/ui/hooks/index.ts +0 -1
  274. package/src/ui/hooks/useApp.test.tsx +159 -0
  275. package/src/ui/hooks/useApp.tsx +226 -15
  276. package/src/ui/hooks/useLoading.tsx +14 -6
  277. package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +263 -0
  278. package/src/vite-plugin/boot-loader/boot-loader.css +294 -0
  279. package/src/vite-plugin/boot-loader/boot-loader.js +274 -0
  280. package/src/vite-plugin/boot-loader/index.ts +112 -0
  281. package/src/vite-plugin/composer/index.ts +306 -0
  282. package/src/vite-plugin/import-map/index.ts +524 -0
  283. package/src/vite-plugin/index.ts +10 -0
  284. package/src/vite-plugin/manifest.test.ts +46 -0
  285. package/src/vite-plugin/manifest.ts +57 -0
  286. package/src/vite-plugin/packages.ts +188 -0
  287. package/tsconfig.json +19 -1
  288. package/tsconfig.node.json +1 -1
  289. package/vitest.config.ts +1 -1
  290. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  291. package/dist/lib/browser/capability-7RLVE42K.mjs.map +0 -7
  292. package/dist/lib/browser/chunk-4CTRO67U.mjs +0 -703
  293. package/dist/lib/browser/chunk-4CTRO67U.mjs.map +0 -7
  294. package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
  295. package/dist/lib/browser/chunk-FNKT2QQ2.mjs.map +0 -7
  296. package/dist/lib/browser/chunk-HE27PNNQ.mjs +0 -824
  297. package/dist/lib/browser/chunk-HE27PNNQ.mjs.map +0 -7
  298. package/dist/lib/browser/chunk-NPUEVX42.mjs +0 -34
  299. package/dist/lib/browser/chunk-NPUEVX42.mjs.map +0 -7
  300. package/dist/lib/browser/chunk-PKQT6C53.mjs.map +0 -7
  301. package/dist/lib/browser/chunk-REORGDJT.mjs.map +0 -7
  302. package/dist/lib/browser/chunk-YAFEA4GV.mjs +0 -1
  303. package/dist/lib/browser/chunk-YNFPIQGB.mjs.map +0 -7
  304. package/dist/lib/browser/chunk-ZRWBPIZG.mjs.map +0 -7
  305. package/dist/lib/browser/invoker-capability-BNLVNYHU.mjs.map +0 -7
  306. package/dist/lib/node-esm/capability-EVZK4REM.mjs.map +0 -7
  307. package/dist/lib/node-esm/chunk-2A4PRBIX.mjs.map +0 -7
  308. package/dist/lib/node-esm/chunk-7CPNAEGV.mjs +0 -704
  309. package/dist/lib/node-esm/chunk-7CPNAEGV.mjs.map +0 -7
  310. package/dist/lib/node-esm/chunk-7OWSHPYK.mjs.map +0 -7
  311. package/dist/lib/node-esm/chunk-CJCQS2YL.mjs.map +0 -7
  312. package/dist/lib/node-esm/chunk-DTCHT2X2.mjs +0 -825
  313. package/dist/lib/node-esm/chunk-DTCHT2X2.mjs.map +0 -7
  314. package/dist/lib/node-esm/chunk-JAZVHID3.mjs +0 -35
  315. package/dist/lib/node-esm/chunk-JAZVHID3.mjs.map +0 -7
  316. package/dist/lib/node-esm/chunk-SB5ODNPX.mjs.map +0 -7
  317. package/dist/lib/node-esm/chunk-UFW652GS.mjs.map +0 -7
  318. package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +0 -2
  319. package/dist/lib/node-esm/invoker-capability-VF6SP44V.mjs.map +0 -7
  320. package/dist/types/src/ui/hooks/useOperationResolver.d.ts +0 -19
  321. package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +0 -1
  322. package/src/ui/hooks/useOperationResolver.ts +0 -40
  323. /package/dist/lib/{node-esm/capability-CHIMU6LX.mjs.map → browser/capability-LUKGKUQH.mjs.map} +0 -0
  324. /package/dist/lib/browser/{chunk-YAFEA4GV.mjs.map → core/url-loader.mjs.map} +0 -0
  325. /package/dist/lib/node-esm/{chunk-Z4TJPSMP.mjs.map → core/url-loader.mjs.map} +0 -0
@@ -0,0 +1,1174 @@
1
+ import {
2
+ eventKey,
3
+ getEvents,
4
+ isAllOf
5
+ } from "./chunk-66IXTIVK.mjs";
6
+ import {
7
+ LazyPluginError,
8
+ Service as Service2,
9
+ isLazy,
10
+ resolveLazy
11
+ } from "./chunk-Z55LVAGN.mjs";
12
+ import {
13
+ Service
14
+ } from "./chunk-3JWJXGLK.mjs";
15
+ import {
16
+ __export
17
+ } from "./chunk-J5LGTIGS.mjs";
18
+
19
+ // src/core/plugin-manager.ts
20
+ var plugin_manager_exports = {};
21
+ __export(plugin_manager_exports, {
22
+ ManagerTypeId: () => ManagerTypeId,
23
+ PluginInitializationError: () => PluginInitializationError,
24
+ PluginTimeoutError: () => PluginTimeoutError,
25
+ isManager: () => isManager,
26
+ make: () => make5
27
+ });
28
+ import { Atom as Atom3, Registry } from "@effect-atom/atom-react";
29
+ import * as Array from "effect/Array";
30
+ import * as Cause from "effect/Cause";
31
+ import * as Deferred2 from "effect/Deferred";
32
+ import * as Duration from "effect/Duration";
33
+ import * as Effect3 from "effect/Effect";
34
+ import * as Fiber from "effect/Fiber";
35
+ import * as Function from "effect/Function";
36
+ import * as HashSet from "effect/HashSet";
37
+ import * as PubSub from "effect/PubSub";
38
+ import * as Ref from "effect/Ref";
39
+ import { runAndForwardErrors as runAndForwardErrors2 } from "@dxos/effect";
40
+ import { Performance } from "@dxos/effect";
41
+ import { BaseError } from "@dxos/errors";
42
+ import { log as log3 } from "@dxos/log";
43
+
44
+ // src/core/capability-manager.ts
45
+ var capability_manager_exports = {};
46
+ __export(capability_manager_exports, {
47
+ make: () => make2
48
+ });
49
+ import { Atom } from "@effect-atom/atom-react";
50
+ import * as Deferred from "effect/Deferred";
51
+ import * as Effect from "effect/Effect";
52
+ import { invariant } from "@dxos/invariant";
53
+ import { log } from "@dxos/log";
54
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capability-manager.ts";
55
+ var CapabilityManagerImpl = class {
56
+ _registry;
57
+ _capabilityEntries = Atom.family(() => {
58
+ return Atom.make([]).pipe(Atom.keepAlive);
59
+ });
60
+ _capabilities = Atom.family((id) => {
61
+ return Atom.make((get2) => {
62
+ const current = get2(this._capabilityEntries(id));
63
+ return current.map((c) => c.implementation);
64
+ }).pipe(Atom.keepAlive);
65
+ });
66
+ _capabilitiesByModule = Atom.family((id) => {
67
+ return Atom.make((get2) => {
68
+ const entries = get2(this._capabilityEntries(id));
69
+ const result = {};
70
+ for (const entry of entries) {
71
+ (result[entry.moduleId] ??= []).push(entry.implementation);
72
+ }
73
+ return result;
74
+ }).pipe(Atom.keepAlive);
75
+ });
76
+ _capability = Atom.family((id) => {
77
+ return Atom.make((get2) => {
78
+ const current = get2(this._capabilities(id));
79
+ invariant(current.length > 0, `No capability found for ${id}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 35, S: this, A: ["current.length > 0", "`No capability found for ${id}`"] });
80
+ return current[0];
81
+ });
82
+ });
83
+ constructor({ registry }) {
84
+ this._registry = registry;
85
+ }
86
+ contribute({ module: moduleId, interface: interfaceDef, implementation }) {
87
+ const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
88
+ const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);
89
+ if (isDuplicate) {
90
+ log("capability already contributed, skipping", {
91
+ id: interfaceDef.identifier,
92
+ moduleId
93
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 46, S: this });
94
+ return;
95
+ }
96
+ const entry = {
97
+ moduleId,
98
+ implementation
99
+ };
100
+ this._registry.set(this._capabilityEntries(interfaceDef.identifier), [
101
+ ...current,
102
+ entry
103
+ ]);
104
+ log("capability contributed", {
105
+ id: interfaceDef.identifier,
106
+ moduleId,
107
+ count: current.length
108
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 60, S: this });
109
+ }
110
+ remove(interfaceDef, implementation) {
111
+ const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));
112
+ if (current.length === 0) {
113
+ return;
114
+ }
115
+ const next = current.filter((c) => c.implementation !== implementation);
116
+ if (next.length !== current.length) {
117
+ this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);
118
+ log("capability removed", {
119
+ id: interfaceDef.identifier,
120
+ count: current.length
121
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 74, S: this });
122
+ } else {
123
+ log.warn("capability not removed", {
124
+ id: interfaceDef.identifier
125
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 79, S: this });
126
+ }
127
+ }
128
+ atom(interfaceDef) {
129
+ return this._capabilities(interfaceDef.identifier);
130
+ }
131
+ getAll(interfaceDef) {
132
+ return this._registry.get(this.atom(interfaceDef));
133
+ }
134
+ get(interfaceDef) {
135
+ const capabilities = this.getAll(interfaceDef);
136
+ invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 93, S: this, A: ["capabilities.length > 0", "`No capability found for ${interfaceDef.identifier}`"] });
137
+ return capabilities[0];
138
+ }
139
+ waitFor(interfaceDef) {
140
+ return Effect.gen(this, function* () {
141
+ const [capability] = this.getAll(interfaceDef);
142
+ if (capability) {
143
+ return capability;
144
+ }
145
+ const deferred = yield* Deferred.make();
146
+ const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {
147
+ if (capabilities.length > 0) {
148
+ Effect.runSync(Deferred.succeed(deferred, capabilities[0]));
149
+ }
150
+ });
151
+ const result = yield* Deferred.await(deferred);
152
+ cancel();
153
+ return result;
154
+ });
155
+ }
156
+ atomByModule(interfaceDef) {
157
+ return this._capabilitiesByModule(interfaceDef.identifier);
158
+ }
159
+ };
160
+ var make2 = (options) => new CapabilityManagerImpl(options);
161
+
162
+ // src/core/registry.ts
163
+ var registry_exports = {};
164
+ __export(registry_exports, {
165
+ Manager: () => Manager
166
+ });
167
+ import { Atom as Atom2 } from "@effect-atom/atom-react";
168
+ import * as Effect2 from "effect/Effect";
169
+ import { runAndForwardErrors } from "@dxos/effect";
170
+ import { log as log2 } from "@dxos/log";
171
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/registry.ts";
172
+ var NULL_PROVIDER = {
173
+ listPlugins: () => Effect2.succeed([]),
174
+ listVersions: () => Effect2.fail(new Error("No plugin registry provider configured")),
175
+ getPlugin: () => Effect2.fail(new Error("No plugin registry provider configured"))
176
+ };
177
+ var Manager = class {
178
+ plugins;
179
+ #provider;
180
+ constructor(provider, atomRegistry) {
181
+ this.#provider = provider ?? NULL_PROVIDER;
182
+ const initialLoading = provider !== void 0;
183
+ this.plugins = Atom2.make({
184
+ entries: [],
185
+ loading: initialLoading,
186
+ error: null
187
+ }).pipe(Atom2.keepAlive);
188
+ if (provider !== void 0) {
189
+ void runAndForwardErrors(provider.listPlugins().pipe(Effect2.match({
190
+ onSuccess: (entries) => atomRegistry.set(this.plugins, {
191
+ entries,
192
+ loading: false,
193
+ error: null
194
+ }),
195
+ onFailure: (error) => {
196
+ log2.catch(error, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 49, S: this });
197
+ atomRegistry.set(this.plugins, {
198
+ entries: [],
199
+ loading: false,
200
+ error
201
+ });
202
+ }
203
+ })));
204
+ }
205
+ }
206
+ /** Forwards to the underlying provider. */
207
+ listPlugins() {
208
+ return this.#provider.listPlugins();
209
+ }
210
+ /** Forwards to the underlying provider. */
211
+ listVersions(repo) {
212
+ return this.#provider.listVersions(repo);
213
+ }
214
+ /** Forwards to the underlying provider. */
215
+ getPlugin(repo, version) {
216
+ return this.#provider.getPlugin(repo, version);
217
+ }
218
+ };
219
+
220
+ // src/core/plugin-manager.ts
221
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
222
+ var PluginInitializationError = class extends BaseError.extend("PluginInitializationError", "Plugin manager initialization failed") {
223
+ };
224
+ var PluginTimeoutError = class extends BaseError.extend("PluginTimeoutError", "Plugin operation timed out") {
225
+ };
226
+ var DEFAULT_LOAD_TIMEOUT = Duration.seconds(30);
227
+ var DEFAULT_ACTIVATION_TIMEOUT = Duration.seconds(30);
228
+ var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
229
+ var isManager = (value) => {
230
+ return typeof value === "object" && value !== null && ManagerTypeId in value;
231
+ };
232
+ var ManagerImpl = class {
233
+ [ManagerTypeId] = ManagerTypeId;
234
+ activation = Effect3.runSync(PubSub.unbounded());
235
+ capabilities;
236
+ registry;
237
+ pluginRegistry;
238
+ _pluginsAtom;
239
+ _coreAtom;
240
+ _enabledAtom;
241
+ _modulesAtom;
242
+ _activeAtom;
243
+ _eventsFiredAtom;
244
+ _pendingResetAtom;
245
+ _failedAtom;
246
+ _pluginLoader;
247
+ _onRemove;
248
+ _loadTimeout;
249
+ _activationTimeout;
250
+ _capabilities = /* @__PURE__ */ new Map();
251
+ _moduleMemoMap = /* @__PURE__ */ new Map();
252
+ _moduleSemaphores = /* @__PURE__ */ new Map();
253
+ // Coalesces concurrent `_resolveLazyPlugin` calls per plugin id. Without
254
+ // this, two callers entering `enable(id)` before the swap completes would
255
+ // each invoke `mod.default(options)` and produce distinct module objects,
256
+ // defeating `_addModule`'s reference-equality dedupe and racing the
257
+ // `_pluginsAtom` swap.
258
+ _resolvingPlugins = /* @__PURE__ */ new Map();
259
+ // Tracks dev-source plugins (loaded via a Vite dev server) keyed by id.
260
+ // When `shadow` is present, the entry has displaced an existing plugin —
261
+ // `remove` reinstates it and re-enables iff `wasEnabled`. Entries without a
262
+ // shadow are dev plugins with no underlying registry/builtin to restore.
263
+ // The atom mirrors the map's keys for UI subscribers (they don't need the
264
+ // shadow internals); the two stay in sync via {@link _markDev}/{@link _unmarkDev}.
265
+ _devPlugins = /* @__PURE__ */ new Map();
266
+ _devPluginIdsAtom;
267
+ _activatingEvents = Effect3.runSync(Ref.make([]));
268
+ _activatingModules = Effect3.runSync(Ref.make([]));
269
+ _inFlightFibers = Effect3.runSync(Ref.make([]));
270
+ _shutdownSemaphore = Effect3.runSync(Effect3.makeSemaphore(1));
271
+ _shuttingDown = Effect3.runSync(Ref.make(false));
272
+ // Tracks the constructor-launched core/enabled `enable()` calls so that
273
+ // `activate` can wait for module registration before dispatching events.
274
+ // Lazy plugins make `enable` asynchronous (a dynamic `import()` happens
275
+ // inside it), so without this synchronization an `activate` triggered
276
+ // immediately after `make` could fire on an empty module set. Failures
277
+ // are wrapped in `PluginInitializationError` so awaiters get a tagged
278
+ // error rather than the wide `Error` produced by the underlying chain.
279
+ _initialization = Effect3.runSync(Deferred2.make());
280
+ constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry, pluginRegistryProvider, onRemove, loadTimeout = DEFAULT_LOAD_TIMEOUT, activationTimeout = DEFAULT_ACTIVATION_TIMEOUT }) {
281
+ this.registry = registry ?? Registry.make();
282
+ this.capabilities = make2({
283
+ registry: this.registry
284
+ });
285
+ this.pluginRegistry = new Manager(pluginRegistryProvider, this.registry);
286
+ this._pluginLoader = pluginLoader;
287
+ this._onRemove = onRemove;
288
+ this._loadTimeout = loadTimeout;
289
+ this._activationTimeout = activationTimeout;
290
+ this._pluginsAtom = Atom3.make(plugins).pipe(Atom3.keepAlive);
291
+ this._coreAtom = Atom3.make(core).pipe(Atom3.keepAlive);
292
+ this._enabledAtom = Atom3.make(enabled).pipe(Atom3.keepAlive);
293
+ this._modulesAtom = Atom3.make([]).pipe(Atom3.keepAlive);
294
+ this._activeAtom = Atom3.make([]).pipe(Atom3.keepAlive);
295
+ this._eventsFiredAtom = Atom3.make([]).pipe(Atom3.keepAlive);
296
+ this._pendingResetAtom = Atom3.make([]).pipe(Atom3.keepAlive);
297
+ this._failedAtom = Atom3.make([]).pipe(Atom3.keepAlive);
298
+ this._devPluginIdsAtom = Atom3.make([]).pipe(Atom3.keepAlive);
299
+ plugins.forEach((plugin) => this._addPlugin(plugin));
300
+ const initialIds = [
301
+ .../* @__PURE__ */ new Set([
302
+ ...core,
303
+ ...enabled
304
+ ])
305
+ ];
306
+ void Effect3.all(initialIds.map((id) => this.enable(id))).pipe(Effect3.mapError((cause) => new PluginInitializationError({
307
+ cause
308
+ })), Effect3.tap(() => Deferred2.succeed(this._initialization, void 0)), Effect3.tapErrorCause((cause) => Deferred2.failCause(this._initialization, cause))).pipe(runAndForwardErrors2);
309
+ }
310
+ get plugins() {
311
+ return this._pluginsAtom;
312
+ }
313
+ get core() {
314
+ return this._coreAtom;
315
+ }
316
+ /**
317
+ * Ids of plugins that are currently enabled.
318
+ */
319
+ get enabled() {
320
+ return this._enabledAtom;
321
+ }
322
+ /**
323
+ * Modules of plugins which are currently enabled.
324
+ */
325
+ get modules() {
326
+ return this._modulesAtom;
327
+ }
328
+ /**
329
+ * Ids of modules which are currently active.
330
+ */
331
+ get active() {
332
+ return this._activeAtom;
333
+ }
334
+ /**
335
+ * Ids of events which have been fired.
336
+ */
337
+ get eventsFired() {
338
+ return this._eventsFiredAtom;
339
+ }
340
+ /**
341
+ * Ids of modules which are pending reset.
342
+ */
343
+ get pendingReset() {
344
+ return this._pendingResetAtom;
345
+ }
346
+ /**
347
+ * Plugins that failed to load or activate.
348
+ */
349
+ get failed() {
350
+ return this._failedAtom;
351
+ }
352
+ /**
353
+ * Ids of currently-registered plugins that came from a dev source.
354
+ */
355
+ get devPluginIds() {
356
+ return this._devPluginIdsAtom;
357
+ }
358
+ getPlugins() {
359
+ return this._get(this._pluginsAtom);
360
+ }
361
+ getCore() {
362
+ return this._get(this._coreAtom);
363
+ }
364
+ getEnabled() {
365
+ return this._get(this._enabledAtom);
366
+ }
367
+ getModules() {
368
+ return this._get(this._modulesAtom);
369
+ }
370
+ getActive() {
371
+ return this._get(this._activeAtom);
372
+ }
373
+ getEventsFired() {
374
+ return this._get(this._eventsFiredAtom);
375
+ }
376
+ getPendingReset() {
377
+ return this._get(this._pendingResetAtom);
378
+ }
379
+ getFailed() {
380
+ return this._get(this._failedAtom);
381
+ }
382
+ getDevPluginIds() {
383
+ return this._get(this._devPluginIdsAtom);
384
+ }
385
+ /**
386
+ * Marks `id` as dev-sourced. If the plugin displaced an existing one, pass
387
+ * the shadow snapshot so `remove` can restore it. Repeat calls (e.g. a dev
388
+ * plugin reload) preserve the original shadow target — restoration always
389
+ * unwinds back to the real underlying plugin, never an intermediate dev build.
390
+ */
391
+ _markDev(id, shadow) {
392
+ if (this._devPlugins.has(id)) {
393
+ return;
394
+ }
395
+ this._devPlugins.set(id, {
396
+ shadow
397
+ });
398
+ this._update(this._devPluginIdsAtom, (ids) => ids.includes(id) ? ids : [
399
+ ...ids,
400
+ id
401
+ ]);
402
+ }
403
+ /** Drops the dev-plugin entry and returns its shadow data (if any) for restoration. */
404
+ _unmarkDev(id) {
405
+ const entry = this._devPlugins.get(id);
406
+ this._devPlugins.delete(id);
407
+ this._update(this._devPluginIdsAtom, (ids) => ids.filter((existing) => existing !== id));
408
+ return entry?.shadow;
409
+ }
410
+ clearFailure(id) {
411
+ const current = this._get(this._failedAtom);
412
+ if (!current.some((failure) => failure.id === id)) {
413
+ return false;
414
+ }
415
+ this._set(this._failedAtom, current.filter((failure) => failure.id !== id));
416
+ return true;
417
+ }
418
+ /**
419
+ * Adds a plugin to the manager via the plugin loader.
420
+ * The plugin is registered but not enabled; call `enable` separately to activate it.
421
+ * @param id The id of the plugin.
422
+ */
423
+ add(id) {
424
+ return Effect3.gen(this, function* () {
425
+ log3("add plugin", {
426
+ id
427
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 242, S: this });
428
+ const { plugin, dev = false } = yield* this._pluginLoader(id);
429
+ const pluginId = plugin.meta.id;
430
+ const existing = this._getPlugin(pluginId);
431
+ if (dev && existing && existing !== plugin) {
432
+ const wasEnabled = this._get(this._enabledAtom).includes(pluginId);
433
+ if (wasEnabled) {
434
+ yield* this.disable(pluginId);
435
+ }
436
+ this._markDev(pluginId, {
437
+ plugin: existing,
438
+ wasEnabled
439
+ });
440
+ this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === pluginId ? plugin : p));
441
+ } else {
442
+ this._addPlugin(plugin);
443
+ if (dev) {
444
+ this._markDev(pluginId);
445
+ }
446
+ }
447
+ return plugin;
448
+ });
449
+ }
450
+ /**
451
+ * Enables a plugin.
452
+ * @param id The id of the plugin.
453
+ */
454
+ enable(id) {
455
+ return Effect3.gen(this, function* () {
456
+ log3("enable plugin", {
457
+ id
458
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 279, S: this });
459
+ const stub = this._getPlugin(id);
460
+ if (!stub) {
461
+ return false;
462
+ }
463
+ this.clearFailure(id);
464
+ const plugin = yield* this._resolveLazyPlugin(stub);
465
+ this._update(this._enabledAtom, (enabled) => enabled.includes(id) ? enabled : [
466
+ ...enabled,
467
+ id
468
+ ]);
469
+ plugin.modules.forEach((module) => {
470
+ this._addModule(module);
471
+ this._setPendingResetByModule(module);
472
+ });
473
+ log3("pending reset", {
474
+ events: [
475
+ ...this.getPendingReset()
476
+ ]
477
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 298, S: this });
478
+ yield* Effect3.all(this.getPendingReset().map((event) => this.activate(event)), {
479
+ concurrency: "unbounded"
480
+ });
481
+ return true;
482
+ });
483
+ }
484
+ /**
485
+ * Resolves a lazy plugin stub (returned by {@link Plugin.lazy}) to its
486
+ * loaded form and swaps it into `_pluginsAtom`. Returns the input unchanged
487
+ * when the plugin is already resolved, so callers can `yield*` this
488
+ * unconditionally. The lazy stub carries `meta` synchronously but its
489
+ * `modules` list is empty until the loader resolves; the swap ensures
490
+ * subsequent enable/disable operations see the resolved plugin.
491
+ *
492
+ * Concurrent calls for the same id are coalesced via `_resolvingPlugins`:
493
+ * the first caller starts the resolution, every subsequent caller awaits
494
+ * the same `Deferred`. On failure we publish a `lazy:<id>` error message
495
+ * and skip the atom swap so the failure is observable to the activation
496
+ * subscriber and a retry can be attempted.
497
+ */
498
+ _resolveLazyPlugin(plugin) {
499
+ return Effect3.gen(this, function* () {
500
+ if (!isLazy(plugin)) {
501
+ return plugin;
502
+ }
503
+ const id = plugin.meta.id;
504
+ const existing = this._resolvingPlugins.get(id);
505
+ if (existing) {
506
+ return yield* Deferred2.await(existing);
507
+ }
508
+ const deferred = yield* Deferred2.make();
509
+ this._resolvingPlugins.set(id, deferred);
510
+ return yield* Effect3.gen(this, function* () {
511
+ log3("resolving lazy plugin", {
512
+ id
513
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 335, S: this });
514
+ yield* PubSub.publish(this.activation, {
515
+ event: "",
516
+ state: "activating",
517
+ module: `lazy:${id}`
518
+ });
519
+ const resolvedPlugin = yield* resolveLazy(plugin).pipe(
520
+ // Cap how long a remote import can hang. Without this the host can
521
+ // sit on a pending dynamic `import()` indefinitely if the plugin's
522
+ // server is unreachable, which stalls every caller awaiting
523
+ // `enable(id)` and (transitively) the manager's initialization.
524
+ Effect3.timeoutFail({
525
+ duration: this._loadTimeout,
526
+ onTimeout: () => new LazyPluginError({
527
+ context: {
528
+ id,
529
+ reason: "load-failed"
530
+ },
531
+ cause: new PluginTimeoutError({
532
+ context: {
533
+ id,
534
+ phase: "load"
535
+ }
536
+ })
537
+ })
538
+ })
539
+ );
540
+ this._update(this._pluginsAtom, (plugins) => plugins.map((p) => p.meta.id === id ? resolvedPlugin : p));
541
+ yield* PubSub.publish(this.activation, {
542
+ event: "",
543
+ state: "activated",
544
+ module: `lazy:${id}`
545
+ });
546
+ return resolvedPlugin;
547
+ }).pipe(Effect3.tapError((error) => Effect3.gen(this, function* () {
548
+ yield* PubSub.publish(this.activation, {
549
+ event: "",
550
+ state: "error",
551
+ module: `lazy:${id}`,
552
+ error
553
+ });
554
+ this._recordFailure(id, "load", error);
555
+ this._scheduleAutoDisable(id);
556
+ })), Effect3.tap((value) => Deferred2.succeed(deferred, value)), Effect3.tapErrorCause((cause) => Deferred2.failCause(deferred, cause)), Effect3.ensuring(Effect3.sync(() => this._resolvingPlugins.delete(id))));
557
+ });
558
+ }
559
+ /**
560
+ * Removes a plugin from the manager.
561
+ * @param id The id of the plugin.
562
+ */
563
+ remove(id) {
564
+ return Effect3.gen(this, function* () {
565
+ log3("remove plugin", {
566
+ id
567
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 386, S: this });
568
+ const wasDev = this._devPlugins.has(id);
569
+ const disabled = yield* this.disable(id);
570
+ if (!disabled) {
571
+ return false;
572
+ }
573
+ this._removePlugin(id);
574
+ if (this._onRemove) {
575
+ this._runForkedFiber(this._onRemove(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("plugin remove hook failed", {
576
+ id,
577
+ error
578
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 396, S: this }))), Effect3.ignore));
579
+ }
580
+ if (wasDev) {
581
+ const shadow = this._unmarkDev(id);
582
+ if (shadow) {
583
+ this._addPlugin(shadow.plugin);
584
+ if (shadow.wasEnabled) {
585
+ yield* this.enable(id);
586
+ }
587
+ }
588
+ }
589
+ return true;
590
+ });
591
+ }
592
+ /**
593
+ * Disables a plugin.
594
+ * @param id The id of the plugin.
595
+ */
596
+ disable(id) {
597
+ return Effect3.gen(this, function* () {
598
+ log3("disable plugin", {
599
+ id
600
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 423, S: this });
601
+ if (this._get(this._coreAtom).includes(id)) {
602
+ return false;
603
+ }
604
+ const plugin = this._getPlugin(id);
605
+ if (!plugin) {
606
+ return false;
607
+ }
608
+ const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);
609
+ if (enabledIndex !== -1) {
610
+ this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));
611
+ yield* this.deactivate(id);
612
+ plugin.modules.forEach((module) => {
613
+ this._removeModule(module.id);
614
+ });
615
+ }
616
+ return true;
617
+ });
618
+ }
619
+ /**
620
+ * Activates plugins based on the activation event.
621
+ * @param event The activation event.
622
+ * @returns Whether the activation was successful.
623
+ */
624
+ activate(event, params) {
625
+ const key = typeof event === "string" ? event : eventKey(event);
626
+ return Effect3.gen(this, function* () {
627
+ if (yield* this._isShuttingDown()) {
628
+ log3("skipping activation during shutdown", {
629
+ key,
630
+ ...params
631
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 452, S: this });
632
+ return false;
633
+ }
634
+ yield* Deferred2.await(this._initialization);
635
+ 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", {
636
+ event: key
637
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 463, S: this }))))), Performance.addTrackEntry({
638
+ name: typeof event === "string" ? event : eventKey(event),
639
+ devtools: {
640
+ dataType: "track-entry",
641
+ track: "Event Activation",
642
+ trackGroup: "Composer",
643
+ color: "primary"
644
+ }
645
+ })));
646
+ });
647
+ }
648
+ /**
649
+ * Deactivates all of the modules for a plugin.
650
+ * @param id The id of the plugin.
651
+ * @returns Whether the deactivation was successful.
652
+ */
653
+ deactivate(id) {
654
+ return Effect3.gen(this, function* () {
655
+ const plugin = this._getPlugin(id);
656
+ if (!plugin) {
657
+ return false;
658
+ }
659
+ const modules = plugin.modules;
660
+ const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
661
+ concurrency: "unbounded"
662
+ });
663
+ return results.every((result) => result);
664
+ });
665
+ }
666
+ /**
667
+ * Re-activates the modules that were activated by the event.
668
+ * @param event The activation event.
669
+ * @returns Whether the reset was successful.
670
+ */
671
+ reset(event) {
672
+ return Effect3.gen(this, function* () {
673
+ const key = typeof event === "string" ? event : eventKey(event);
674
+ log3("reset", {
675
+ key
676
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 500, S: this });
677
+ const modules = this._getActiveModulesByEvent(key);
678
+ const results = yield* Effect3.all(modules.map((module) => this._deactivateModule(module)), {
679
+ concurrency: "unbounded"
680
+ });
681
+ if (results.every((result) => result)) {
682
+ return yield* this.activate(key);
683
+ } else {
684
+ return false;
685
+ }
686
+ });
687
+ }
688
+ shutdown() {
689
+ return this._shutdownSemaphore.withPermits(1)(Effect3.gen(this, function* () {
690
+ yield* Ref.set(this._shuttingDown, true);
691
+ log3("shutdown", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 517, S: this });
692
+ yield* this._interruptInFlightActivations();
693
+ const activeIds = [
694
+ ...this._get(this._activeAtom)
695
+ ].reverse();
696
+ const allModules = this._get(this._modulesAtom);
697
+ const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
698
+ for (const module of modulesToDeactivate) {
699
+ yield* this._deactivateModule(module);
700
+ }
701
+ this._set(this._eventsFiredAtom, []);
702
+ this._set(this._pendingResetAtom, []);
703
+ this._moduleMemoMap.clear();
704
+ yield* Ref.set(this._activatingEvents, []);
705
+ yield* Ref.set(this._activatingModules, []);
706
+ log3("shutdown complete", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 532, S: this });
707
+ return true;
708
+ }).pipe(Effect3.ensuring(Ref.set(this._shuttingDown, false))));
709
+ }
710
+ //
711
+ // State helpers
712
+ //
713
+ _get(atom) {
714
+ return this.registry.get(atom);
715
+ }
716
+ _set(atom, value) {
717
+ this.registry.set(atom, value);
718
+ }
719
+ _update(atom, updater) {
720
+ this._set(atom, updater(this._get(atom)));
721
+ }
722
+ _isShuttingDown() {
723
+ return Ref.get(this._shuttingDown);
724
+ }
725
+ _getPlugin(id) {
726
+ return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
727
+ }
728
+ _getPluginIdForModule(moduleId) {
729
+ return this._get(this._pluginsAtom).find((plugin) => plugin.modules.some((module) => module.id === moduleId))?.meta.id;
730
+ }
731
+ /**
732
+ * Records a failure for a plugin. Latest failure wins so the registry UI
733
+ * always sees the most recent reason. Walks the `cause` chain when checking
734
+ * for timeouts: lazy-load timeouts arrive wrapped in `LazyPluginError` (the
735
+ * timeout is the cause), but the operator-visible reason should still be
736
+ * `'timeout'`.
737
+ */
738
+ _recordFailure(id, phase, error) {
739
+ const reason = isTimeoutCause(error) ? "timeout" : "error";
740
+ const failure = {
741
+ id,
742
+ phase,
743
+ reason,
744
+ error,
745
+ timestamp: Date.now()
746
+ };
747
+ log3.warn("plugin failed", {
748
+ id,
749
+ phase,
750
+ reason,
751
+ error: error.message
752
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 572, S: this });
753
+ this._update(this._failedAtom, (current) => [
754
+ ...current.filter((entry) => entry.id !== id),
755
+ failure
756
+ ]);
757
+ }
758
+ /**
759
+ * Fire-and-forget disable of a failed plugin. Forked because a failure can
760
+ * happen mid-activation chain — yielding a `disable` inline would deadlock
761
+ * on the shared semaphores. Core plugins are skipped (the host opted into
762
+ * them being non-removable; the failure record is enough signal).
763
+ */
764
+ _scheduleAutoDisable(id) {
765
+ if (this._get(this._coreAtom).includes(id)) {
766
+ return;
767
+ }
768
+ if (!this._get(this._enabledAtom).includes(id)) {
769
+ return;
770
+ }
771
+ this._runForkedFiber(this.disable(id).pipe(Effect3.tapError((error) => Effect3.sync(() => log3.warn("auto-disable failed", {
772
+ id,
773
+ error
774
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 595, S: this }))), Effect3.ignore));
775
+ }
776
+ _getActiveModules() {
777
+ const active = this._get(this._activeAtom);
778
+ return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
779
+ }
780
+ _getInactiveModules() {
781
+ const active = this._get(this._activeAtom);
782
+ return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
783
+ }
784
+ _getActiveModulesByEvent(key) {
785
+ return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
786
+ }
787
+ _getInactiveModulesByEvent(key) {
788
+ return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
789
+ }
790
+ _setPendingResetByModule(module) {
791
+ const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
792
+ const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
793
+ const pending = this._get(this._pendingResetAtom);
794
+ return !pending.includes(event);
795
+ });
796
+ if (pendingReset.length > 0) {
797
+ log3("pending reset", {
798
+ events: pendingReset
799
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 621, S: this });
800
+ this._update(this._pendingResetAtom, (current) => [
801
+ ...current,
802
+ ...pendingReset
803
+ ]);
804
+ }
805
+ }
806
+ _clearPendingReset(key) {
807
+ const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
808
+ if (pendingIndex !== -1) {
809
+ this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
810
+ }
811
+ }
812
+ //
813
+ // Fiber helpers
814
+ //
815
+ _interruptInFlightActivations() {
816
+ return Effect3.gen(this, function* () {
817
+ const inFlightFibers = yield* Ref.get(this._inFlightFibers);
818
+ yield* Effect3.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
819
+ concurrency: "unbounded"
820
+ });
821
+ });
822
+ }
823
+ _trackFiber(ref, fiber) {
824
+ return Ref.update(ref, (fibers) => [
825
+ ...fibers,
826
+ fiber
827
+ ]);
828
+ }
829
+ _untrackFiber(ref, fiber) {
830
+ return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
831
+ }
832
+ /**
833
+ * Spawns an effect on the default runtime and registers the resulting fiber in
834
+ * `_inFlightFibers` so {@link shutdown} can interrupt it. Used from sync entry
835
+ * points like {@link remove} where there is no enclosing Effect to fork from;
836
+ * inside an Effect chain prefer the existing track/await/untrack pattern.
837
+ */
838
+ _runForkedFiber(effect) {
839
+ const fiber = Effect3.runFork(effect);
840
+ Effect3.runSync(this._trackFiber(this._inFlightFibers, fiber));
841
+ Effect3.runFork(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
842
+ }
843
+ //
844
+ // Registration helpers
845
+ //
846
+ _addPlugin(plugin) {
847
+ log3("add plugin", {
848
+ id: plugin.meta.id
849
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 670, S: this });
850
+ this._update(this._pluginsAtom, (plugins) => plugins.includes(plugin) ? plugins : [
851
+ ...plugins,
852
+ plugin
853
+ ]);
854
+ }
855
+ _removePlugin(id) {
856
+ log3("remove plugin", {
857
+ id
858
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 680, S: this });
859
+ this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));
860
+ }
861
+ _addModule(module) {
862
+ log3("add module", {
863
+ id: module.id
864
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 686, S: this });
865
+ this._update(this._modulesAtom, (modules) => modules.includes(module) ? modules : [
866
+ ...modules,
867
+ module
868
+ ]);
869
+ }
870
+ _removeModule(id) {
871
+ log3("remove module", {
872
+ id
873
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 696, S: this });
874
+ this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
875
+ }
876
+ //
877
+ // Activation helpers
878
+ //
879
+ _activateEvent(key, params, fiber) {
880
+ return Effect3.gen(this, function* () {
881
+ yield* this._trackFiber(this._inFlightFibers, fiber);
882
+ log3("activating", {
883
+ key,
884
+ ...params
885
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 707, S: this });
886
+ yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
887
+ this._clearPendingReset(key);
888
+ const activatingEvents = yield* this._activatingEvents;
889
+ const activatingModules = yield* this._activatingModules;
890
+ const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
891
+ if (modules.length === 0) {
892
+ log3("no modules to activate", {
893
+ key
894
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 717, S: this });
895
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
896
+ this._update(this._eventsFiredAtom, (events) => [
897
+ ...events,
898
+ key
899
+ ]);
900
+ }
901
+ return false;
902
+ }
903
+ return yield* this._activateModulesForEvent(key, modules, activatingEvents);
904
+ }).pipe(Effect3.ensuring(Effect3.all([
905
+ this._untrackFiber(this._inFlightFibers, fiber),
906
+ Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
907
+ ])));
908
+ }
909
+ _activateModulesForEvent(key, modules, activatingEvents) {
910
+ const activatingModuleIds = modules.map((module) => module.id);
911
+ return Effect3.gen(this, function* () {
912
+ yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
913
+ log3("activating modules", {
914
+ key,
915
+ modules: activatingModuleIds
916
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 738, S: this });
917
+ performance.mark(`event:${key}:start`);
918
+ yield* PubSub.publish(this.activation, {
919
+ event: key,
920
+ state: "activating"
921
+ });
922
+ yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
923
+ const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
924
+ yield* this._contributeCapabilitiesForModules(modules, capabilities);
925
+ yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
926
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
927
+ this._update(this._eventsFiredAtom, (events) => [
928
+ ...events,
929
+ key
930
+ ]);
931
+ }
932
+ performance.mark(`event:${key}:end`);
933
+ performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
934
+ yield* PubSub.publish(this.activation, {
935
+ event: key,
936
+ state: "activated"
937
+ });
938
+ log3("activated", {
939
+ key
940
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 763, S: this });
941
+ return true;
942
+ }).pipe(Effect3.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
943
+ }
944
+ _getModulesForActivation(key, activatingEvents, activatingModules) {
945
+ return this._getInactiveModulesByEvent(key).filter((module) => {
946
+ const allOf = isAllOf(module.activatesOn);
947
+ if (!allOf) {
948
+ return true;
949
+ }
950
+ const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
951
+ return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
952
+ });
953
+ }
954
+ _getBeforeEvents(modules, activatingEvents) {
955
+ return Function.pipe(modules, Array.flatMap((module) => module.firesBeforeActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
956
+ }
957
+ _getAfterEvents(modules, activatingEvents) {
958
+ return Function.pipe(modules, Array.flatMap((module) => module.firesAfterActivation ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
959
+ }
960
+ _activateRelatedEvents(key, events, phase) {
961
+ const logLabel = phase === "before" ? "firesBeforeActivation" : "firesAfterActivation";
962
+ const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
963
+ return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
964
+ before: key
965
+ } : {
966
+ after: key
967
+ })), Effect3.allWith({
968
+ concurrency: "unbounded"
969
+ }), together(Effect3.sleep(Duration.seconds(10)).pipe(Effect3.andThen(Effect3.sync(() => log3.warn(`${logLabel} is taking a long time`, {
970
+ event: key,
971
+ [eventKey2]: events.map(eventKey)
972
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 796, S: this }))))), Effect3.asVoid);
973
+ }
974
+ //
975
+ // Module lifecycle helpers
976
+ //
977
+ _loadCapabilitiesForModules(key, modules) {
978
+ return Function.pipe(modules, Array.map((mod) => this._loadModule(mod, key)), Effect3.allWith({
979
+ concurrency: "unbounded"
980
+ }), Effect3.catchAll((error) => {
981
+ return Effect3.gen(this, function* () {
982
+ yield* PubSub.publish(this.activation, {
983
+ event: key,
984
+ state: "error",
985
+ error
986
+ });
987
+ return yield* Effect3.fail(error);
988
+ });
989
+ }));
990
+ }
991
+ _contributeCapabilitiesForModules(modules, capabilities) {
992
+ return Function.pipe(
993
+ modules,
994
+ Array.zip(capabilities),
995
+ Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
996
+ Effect3.all,
997
+ Effect3.asVoid
998
+ );
999
+ }
1000
+ _getModuleSemaphore(moduleId) {
1001
+ let semaphore = this._moduleSemaphores.get(moduleId);
1002
+ if (!semaphore) {
1003
+ semaphore = Effect3.runSync(Effect3.makeSemaphore(1));
1004
+ this._moduleSemaphores.set(moduleId, semaphore);
1005
+ }
1006
+ return semaphore;
1007
+ }
1008
+ // `parentEvent` is the activation event that first triggered this module
1009
+ // load — included in `activating`/`activated` PubSub messages so subscribers
1010
+ // (e.g. the boot loader's status listener) can associate a module with its
1011
+ // triggering event in the trace. The same module may be referenced by
1012
+ // multiple events, but module loads are memoized via `_moduleMemoMap`, so
1013
+ // only the first event to need it will appear here; later events await the
1014
+ // cached deferred without re-publishing.
1015
+ _loadModule = (module, parentEvent) => Effect3.gen(this, function* () {
1016
+ const semaphore = this._getModuleSemaphore(module.id);
1017
+ const deferredToAwait = yield* Effect3.gen(this, function* () {
1018
+ const existing = this._moduleMemoMap.get(module.id);
1019
+ if (existing) {
1020
+ return existing;
1021
+ }
1022
+ const deferred = yield* Deferred2.make();
1023
+ this._moduleMemoMap.set(module.id, deferred);
1024
+ const loadEffect = Effect3.gen(this, function* () {
1025
+ log3("loading module", {
1026
+ module: module.id,
1027
+ parentEvent
1028
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 854, S: this });
1029
+ performance.mark(`module:${module.id}:start`);
1030
+ yield* PubSub.publish(this.activation, {
1031
+ event: parentEvent,
1032
+ state: "activating",
1033
+ module: module.id
1034
+ });
1035
+ const pluginId = this._getPluginIdForModule(module.id);
1036
+ const [duration, capabilities] = yield* module.activate().pipe(
1037
+ Effect3.provideService(Service, this.capabilities),
1038
+ Effect3.provideService(Service2, this),
1039
+ // Cap activation so a single misbehaving module can't hold the
1040
+ // event chain open. On timeout the failure is recorded against
1041
+ // the plugin and surfaced as `PluginTimeoutError`.
1042
+ Effect3.timeoutFail({
1043
+ duration: this._activationTimeout,
1044
+ onTimeout: () => new PluginTimeoutError({
1045
+ context: {
1046
+ id: pluginId ?? module.id,
1047
+ module: module.id,
1048
+ phase: "activation"
1049
+ }
1050
+ })
1051
+ }),
1052
+ Effect3.timed
1053
+ );
1054
+ const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
1055
+ capabilities
1056
+ ];
1057
+ const elapsed = Duration.toMillis(duration);
1058
+ performance.mark(`module:${module.id}:end`);
1059
+ performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
1060
+ yield* PubSub.publish(this.activation, {
1061
+ event: parentEvent,
1062
+ state: "activated",
1063
+ module: module.id
1064
+ });
1065
+ log3("loaded module", {
1066
+ module: module.id,
1067
+ parentEvent,
1068
+ elapsed,
1069
+ failed: false
1070
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 889, S: this });
1071
+ return normalized;
1072
+ }).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`, {
1073
+ module: module.id
1074
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 896, S: this }))))), Performance.addTrackEntry({
1075
+ name: module.id,
1076
+ devtools: {
1077
+ dataType: "track-entry",
1078
+ track: "Module Activation",
1079
+ trackGroup: "Composer",
1080
+ color: "primary"
1081
+ }
1082
+ }));
1083
+ const fiber = yield* Effect3.forkDaemon(loadEffect.pipe(Effect3.tap((result) => Deferred2.succeed(deferred, result)), Effect3.catchAllCause((cause) => {
1084
+ const error = Cause.squash(cause);
1085
+ log3.error("module failed to activate", {
1086
+ module: module.id,
1087
+ error: error instanceof Error ? error.message : String(error),
1088
+ stack: error instanceof Error ? error.stack : void 0,
1089
+ isDefect: !Cause.isFailure(cause)
1090
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 910, S: this });
1091
+ const normalizedError = error instanceof Error ? error : new Error(String(error));
1092
+ const pluginId = this._getPluginIdForModule(module.id);
1093
+ if (pluginId !== void 0) {
1094
+ this._recordFailure(pluginId, "activation", normalizedError);
1095
+ this._scheduleAutoDisable(pluginId);
1096
+ }
1097
+ return Deferred2.fail(deferred, normalizedError);
1098
+ })));
1099
+ yield* this._trackFiber(this._inFlightFibers, fiber);
1100
+ yield* Effect3.forkDaemon(Fiber.await(fiber).pipe(Effect3.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
1101
+ return deferred;
1102
+ }).pipe(semaphore.withPermits(1));
1103
+ return yield* Deferred2.await(deferredToAwait);
1104
+ });
1105
+ _contributeCapabilities(module, capabilities) {
1106
+ return Effect3.gen(this, function* () {
1107
+ capabilities.forEach((capability) => {
1108
+ this.capabilities.contribute({
1109
+ module: module.id,
1110
+ ...capability
1111
+ });
1112
+ });
1113
+ this._update(this._activeAtom, (active) => [
1114
+ ...active,
1115
+ module.id
1116
+ ]);
1117
+ this._capabilities.set(module.id, capabilities);
1118
+ });
1119
+ }
1120
+ _deactivateModule(module) {
1121
+ return Effect3.gen(this, function* () {
1122
+ const id = module.id;
1123
+ log3("deactivating", {
1124
+ id
1125
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 949, S: this });
1126
+ this._moduleMemoMap.delete(id);
1127
+ const capabilities = this._capabilities.get(id);
1128
+ if (capabilities) {
1129
+ for (const capability of capabilities) {
1130
+ this.capabilities.remove(capability.interface, capability.implementation);
1131
+ const program = capability.deactivate?.() ?? Effect3.succeed(void 0);
1132
+ yield* program;
1133
+ }
1134
+ this._capabilities.delete(id);
1135
+ }
1136
+ const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);
1137
+ if (activeIndex !== -1) {
1138
+ this._update(this._activeAtom, (active) => active.filter((event) => event !== id));
1139
+ }
1140
+ log3("deactivated", {
1141
+ id
1142
+ }, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 966, S: this });
1143
+ return true;
1144
+ });
1145
+ }
1146
+ };
1147
+ var make5 = (options) => new ManagerImpl(options);
1148
+ var isTimeoutCause = (error, depth = 0) => {
1149
+ if (depth > 5 || !(error instanceof Error)) {
1150
+ return false;
1151
+ }
1152
+ if (PluginTimeoutError.is(error)) {
1153
+ return true;
1154
+ }
1155
+ return isTimeoutCause(error.cause, depth + 1);
1156
+ };
1157
+ var together = (togetherEffect) => (effect) => Effect3.gen(function* () {
1158
+ const togetherFiber = yield* Effect3.fork(togetherEffect);
1159
+ const result = yield* effect;
1160
+ yield* Fiber.interrupt(togetherFiber);
1161
+ return result;
1162
+ });
1163
+
1164
+ export {
1165
+ capability_manager_exports,
1166
+ registry_exports,
1167
+ PluginInitializationError,
1168
+ PluginTimeoutError,
1169
+ ManagerTypeId,
1170
+ isManager,
1171
+ make5 as make,
1172
+ plugin_manager_exports
1173
+ };
1174
+ //# sourceMappingURL=chunk-NBXPP7JR.mjs.map