@dxos/app-framework 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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