@dxos/app-framework 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6

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 (421) hide show
  1. package/.storybook/main.mts +1 -3
  2. package/dist/lib/browser/{capability-7PCNSWBT.mjs → capability-4NSF2SOO.mjs} +16 -11
  3. package/dist/lib/browser/capability-4NSF2SOO.mjs.map +7 -0
  4. package/dist/lib/browser/capability-EB3UKSKA.mjs +35 -0
  5. package/dist/lib/browser/capability-EB3UKSKA.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-FMZN33N4.mjs → chunk-27FZETIA.mjs} +324 -181
  7. package/dist/lib/browser/chunk-27FZETIA.mjs.map +7 -0
  8. package/dist/lib/browser/chunk-CV7I2AAB.mjs +80 -0
  9. package/dist/lib/browser/chunk-CV7I2AAB.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-6Y7PZV72.mjs → chunk-FL2XTEJH.mjs} +3 -4
  11. package/dist/lib/browser/chunk-FL2XTEJH.mjs.map +7 -0
  12. package/dist/lib/browser/chunk-H7OMDDGW.mjs +42 -0
  13. package/dist/lib/browser/chunk-H7OMDDGW.mjs.map +7 -0
  14. package/dist/lib/browser/chunk-HDQXX5DC.mjs +157 -0
  15. package/dist/lib/browser/chunk-HDQXX5DC.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-I34GF4NG.mjs +34 -0
  17. package/dist/lib/browser/chunk-I34GF4NG.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-KNBRTZVK.mjs +892 -0
  19. package/dist/lib/browser/chunk-KNBRTZVK.mjs.map +7 -0
  20. package/dist/lib/browser/{chunk-7IQHKD4U.mjs → chunk-NO7R7QHA.mjs} +4 -7
  21. package/dist/lib/browser/chunk-NO7R7QHA.mjs.map +7 -0
  22. package/dist/lib/browser/{chunk-TCLLRCS3.mjs → chunk-P2E7VMRF.mjs} +10 -7
  23. package/dist/lib/browser/chunk-P2E7VMRF.mjs.map +7 -0
  24. package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-QSXYHXCE.mjs} +3 -2
  25. package/dist/lib/browser/chunk-QSXYHXCE.mjs.map +7 -0
  26. package/dist/lib/browser/chunk-RFSO3JRG.mjs +1 -0
  27. package/dist/lib/browser/chunk-TGX63LTL.mjs +8 -0
  28. package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-TGX63LTL.mjs.map} +1 -1
  29. package/dist/lib/browser/cli/index.mjs +90 -0
  30. package/dist/lib/browser/cli/index.mjs.map +7 -0
  31. package/dist/lib/browser/common/activation-events.mjs +24 -0
  32. package/dist/lib/browser/common/capabilities.mjs +46 -0
  33. package/dist/lib/browser/core/activation-event.mjs +1 -1
  34. package/dist/lib/browser/core/capability.mjs +1 -1
  35. package/dist/lib/browser/core/plugin-manager.mjs +4 -4
  36. package/dist/lib/browser/core/plugin.mjs +6 -4
  37. package/dist/lib/browser/core/url-loader.mjs +12 -0
  38. package/dist/lib/browser/index.mjs +40 -131
  39. package/dist/lib/browser/index.mjs.map +4 -4
  40. package/dist/lib/browser/invoker-capability-P7KPBTP3.mjs +43 -0
  41. package/dist/lib/browser/invoker-capability-P7KPBTP3.mjs.map +7 -0
  42. package/dist/lib/browser/meta.json +1 -1
  43. package/dist/lib/browser/testing/index.mjs +56 -34
  44. package/dist/lib/browser/testing/index.mjs.map +3 -3
  45. package/dist/lib/browser/{react → ui}/index.mjs +19 -21
  46. package/dist/lib/browser/ui/index.mjs.map +7 -0
  47. package/dist/lib/node-esm/{capability-CFLQ2QQU.mjs → capability-CB3MNEI3.mjs} +16 -11
  48. package/dist/lib/node-esm/capability-CB3MNEI3.mjs.map +7 -0
  49. package/dist/lib/node-esm/capability-CMROGK7R.mjs +36 -0
  50. package/dist/lib/node-esm/capability-CMROGK7R.mjs.map +7 -0
  51. package/dist/lib/node-esm/{chunk-STMXUEPO.mjs → chunk-37NG7SIN.mjs} +3 -4
  52. package/dist/lib/node-esm/chunk-37NG7SIN.mjs.map +7 -0
  53. package/dist/lib/node-esm/chunk-7JPKC7OM.mjs +893 -0
  54. package/dist/lib/node-esm/chunk-7JPKC7OM.mjs.map +7 -0
  55. package/dist/lib/node-esm/chunk-7PPVTBYR.mjs +81 -0
  56. package/dist/lib/node-esm/chunk-7PPVTBYR.mjs.map +7 -0
  57. package/dist/lib/node-esm/chunk-BQ56U4QX.mjs +43 -0
  58. package/dist/lib/node-esm/chunk-BQ56U4QX.mjs.map +7 -0
  59. package/dist/lib/node-esm/{chunk-GT6OKM5I.mjs → chunk-CG6UBBZZ.mjs} +10 -7
  60. package/dist/lib/node-esm/chunk-CG6UBBZZ.mjs.map +7 -0
  61. package/dist/lib/node-esm/chunk-EL3R25OQ.mjs +2 -0
  62. package/dist/lib/node-esm/chunk-EL3R25OQ.mjs.map +7 -0
  63. package/dist/lib/node-esm/{chunk-663A54LQ.mjs → chunk-EXYTXQ47.mjs} +4 -7
  64. package/dist/lib/node-esm/chunk-EXYTXQ47.mjs.map +7 -0
  65. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-FKE4Z3D6.mjs} +2 -2
  66. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-FKE4Z3D6.mjs.map} +1 -1
  67. package/dist/lib/node-esm/chunk-OXXXRCQX.mjs +158 -0
  68. package/dist/lib/node-esm/chunk-OXXXRCQX.mjs.map +7 -0
  69. package/dist/lib/node-esm/chunk-WZCSOX5Q.mjs +35 -0
  70. package/dist/lib/node-esm/chunk-WZCSOX5Q.mjs.map +7 -0
  71. package/dist/lib/node-esm/{chunk-XYQTBFPA.mjs → chunk-YH44RHP6.mjs} +324 -181
  72. package/dist/lib/node-esm/chunk-YH44RHP6.mjs.map +7 -0
  73. package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-ZZ7CKK6W.mjs} +3 -2
  74. package/dist/lib/node-esm/chunk-ZZ7CKK6W.mjs.map +7 -0
  75. package/dist/lib/node-esm/cli/index.mjs +91 -0
  76. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  77. package/dist/lib/node-esm/common/activation-events.mjs +25 -0
  78. package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
  79. package/dist/lib/node-esm/common/capabilities.mjs +47 -0
  80. package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
  81. package/dist/lib/node-esm/core/activation-event.mjs +1 -1
  82. package/dist/lib/node-esm/core/capability.mjs +1 -1
  83. package/dist/lib/node-esm/core/plugin-manager.mjs +4 -4
  84. package/dist/lib/node-esm/core/plugin.mjs +6 -4
  85. package/dist/lib/node-esm/core/url-loader.mjs +13 -0
  86. package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
  87. package/dist/lib/node-esm/index.mjs +40 -131
  88. package/dist/lib/node-esm/index.mjs.map +4 -4
  89. package/dist/lib/node-esm/invoker-capability-3C5H46ZY.mjs +44 -0
  90. package/dist/lib/node-esm/invoker-capability-3C5H46ZY.mjs.map +7 -0
  91. package/dist/lib/node-esm/meta.json +1 -1
  92. package/dist/lib/node-esm/testing/index.mjs +56 -34
  93. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  94. package/dist/lib/node-esm/{react → ui}/index.mjs +19 -21
  95. package/dist/lib/node-esm/ui/index.mjs.map +7 -0
  96. package/dist/plugin/node-esm/index.mjs +384 -0
  97. package/dist/plugin/node-esm/index.mjs.map +7 -0
  98. package/dist/plugin/node-esm/meta.json +1 -0
  99. package/dist/types/src/{cli.d.ts → cli/cli.d.ts} +2 -2
  100. package/dist/types/src/cli/cli.d.ts.map +1 -0
  101. package/dist/types/src/cli/index.d.ts +2 -0
  102. package/dist/types/src/cli/index.d.ts.map +1 -0
  103. package/dist/types/src/common/activation-events.d.ts +27 -0
  104. package/dist/types/src/common/activation-events.d.ts.map +1 -0
  105. package/dist/types/src/common/capabilities.d.ts +110 -0
  106. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  107. package/dist/types/src/common/index.d.ts +4 -9
  108. package/dist/types/src/common/index.d.ts.map +1 -1
  109. package/dist/types/src/common/operations.d.ts +8 -369
  110. package/dist/types/src/common/operations.d.ts.map +1 -1
  111. package/dist/types/src/common/translations.d.ts +0 -9
  112. package/dist/types/src/common/translations.d.ts.map +1 -1
  113. package/dist/types/src/core/activation-event.d.ts +1 -1
  114. package/dist/types/src/core/activation-event.d.ts.map +1 -1
  115. package/dist/types/src/core/capability.d.ts +7 -7
  116. package/dist/types/src/core/capability.d.ts.map +1 -1
  117. package/dist/types/src/core/index.d.ts +1 -0
  118. package/dist/types/src/core/index.d.ts.map +1 -1
  119. package/dist/types/src/core/plugin-manager.d.ts +9 -2
  120. package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
  121. package/dist/types/src/core/plugin.d.ts +6 -1
  122. package/dist/types/src/core/plugin.d.ts.map +1 -1
  123. package/dist/types/src/core/url-loader.d.ts +25 -0
  124. package/dist/types/src/core/url-loader.d.ts.map +1 -0
  125. package/dist/types/src/core/url-loader.test.d.ts +2 -0
  126. package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
  127. package/dist/types/src/index.d.ts +1 -3
  128. package/dist/types/src/index.d.ts.map +1 -1
  129. package/dist/types/src/plugin-operation/history/capability.d.ts +1 -1
  130. package/dist/types/src/plugin-operation/history/errors.d.ts +30 -3
  131. package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -1
  132. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +11 -3
  133. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
  134. package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
  135. package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -1
  136. package/dist/types/src/plugin-operation/testing.d.ts +26 -77
  137. package/dist/types/src/plugin-operation/testing.d.ts.map +1 -1
  138. package/dist/types/src/plugin-runtime/capability.d.ts +2 -2
  139. package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
  140. package/dist/types/src/testing/withPluginManager.d.ts +1 -1
  141. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  142. package/dist/types/src/{react → ui/components/App}/App.d.ts +3 -2
  143. package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
  144. package/dist/types/src/{react/Surface.stories.d.ts → ui/components/App/App.stories.d.ts} +7 -2
  145. package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
  146. package/dist/types/src/ui/components/App/index.d.ts +2 -0
  147. package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
  148. package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
  149. package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerProvider.d.ts +1 -1
  150. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
  151. package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
  152. package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
  153. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +12 -0
  154. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
  155. package/dist/types/src/{react/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -1
  156. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
  157. package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
  158. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
  159. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
  160. package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
  161. package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
  162. package/dist/types/src/ui/components/Surface/index.d.ts +26 -0
  163. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
  164. package/dist/types/src/{common/surface.d.ts → ui/components/Surface/types.d.ts} +20 -18
  165. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
  166. package/dist/types/src/ui/components/index.d.ts +4 -0
  167. package/dist/types/src/ui/components/index.d.ts.map +1 -0
  168. package/dist/types/src/ui/hooks/index.d.ts +6 -0
  169. package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
  170. package/dist/types/src/{react → ui/hooks}/useApp.d.ts +26 -9
  171. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
  172. package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
  173. package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
  174. package/dist/types/src/{react → ui/hooks}/useCapabilities.d.ts +6 -1
  175. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
  176. package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
  177. package/dist/types/src/{react/common.d.ts → ui/hooks/useSettingsState.d.ts} +1 -5
  178. package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
  179. package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
  180. package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
  181. package/dist/types/src/ui/index.d.ts +3 -0
  182. package/dist/types/src/ui/index.d.ts.map +1 -0
  183. package/dist/types/src/vite-plugin/composer-plugin.d.ts +18 -0
  184. package/dist/types/src/vite-plugin/composer-plugin.d.ts.map +1 -0
  185. package/dist/types/src/vite-plugin/import-map-plugin.d.ts +16 -0
  186. package/dist/types/src/vite-plugin/import-map-plugin.d.ts.map +1 -0
  187. package/dist/types/src/vite-plugin/index.d.ts +3 -0
  188. package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
  189. package/dist/types/src/vite-plugin/packages.d.ts +7 -0
  190. package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
  191. package/dist/types/tsconfig.tsbuildinfo +1 -1
  192. package/moon.yml +20 -6
  193. package/package.json +91 -64
  194. package/src/{cli.ts → cli/cli.ts} +10 -10
  195. package/src/{playground/debug → cli}/index.ts +1 -1
  196. package/src/common/activation-events.ts +44 -0
  197. package/src/common/capabilities.ts +172 -0
  198. package/src/common/index.ts +4 -9
  199. package/src/common/operations.ts +6 -382
  200. package/src/common/translations.ts +0 -12
  201. package/src/context.ts +1 -1
  202. package/src/core/activation-event.ts +5 -2
  203. package/src/core/capability-manager.ts +1 -1
  204. package/src/core/capability.ts +11 -10
  205. package/src/core/index.ts +1 -0
  206. package/src/core/plugin-manager.test.ts +313 -44
  207. package/src/core/plugin-manager.ts +344 -157
  208. package/src/core/plugin.ts +10 -2
  209. package/src/core/url-loader.test.ts +79 -0
  210. package/src/core/url-loader.ts +148 -0
  211. package/src/index.ts +1 -3
  212. package/src/plugin-operation/OperationPlugin.ts +5 -5
  213. package/src/plugin-operation/history/capability.ts +5 -5
  214. package/src/plugin-operation/history/errors.ts +2 -6
  215. package/src/plugin-operation/history/history-tracker.test.ts +36 -42
  216. package/src/plugin-operation/history/undo-mapping.ts +6 -3
  217. package/src/plugin-operation/history/undo-registry.test.ts +3 -3
  218. package/src/plugin-operation/invoker-capability.ts +21 -7
  219. package/src/plugin-operation/meta.ts +1 -1
  220. package/src/plugin-operation/testing.ts +25 -45
  221. package/src/plugin-runtime/RuntimePlugin.ts +4 -4
  222. package/src/plugin-runtime/capability.ts +5 -5
  223. package/src/plugin-runtime/meta.ts +1 -1
  224. package/src/testing/service.ts +6 -6
  225. package/src/testing/withPluginManager.stories.tsx +6 -6
  226. package/src/testing/withPluginManager.tsx +46 -19
  227. package/src/ui/components/App/App.stories.tsx +92 -0
  228. package/src/{react → ui/components/App}/App.tsx +9 -11
  229. package/src/{playground/layout → ui/components/App}/index.ts +1 -1
  230. package/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.tsx +13 -14
  231. package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +1 -1
  232. package/src/ui/components/PluginManager/index.ts +5 -0
  233. package/src/{react/Surface.stories.tsx → ui/components/Surface/SurfaceComponent.stories.tsx} +28 -24
  234. package/src/{react/Surface.tsx → ui/components/Surface/SurfaceComponent.tsx} +48 -58
  235. package/src/{react → ui/components/Surface}/SurfaceInfo.tsx +2 -2
  236. package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
  237. package/src/ui/components/Surface/context.ts +12 -0
  238. package/src/ui/components/Surface/index.ts +35 -0
  239. package/src/{common/surface.ts → ui/components/Surface/types.ts} +22 -25
  240. package/src/ui/components/index.ts +7 -0
  241. package/src/ui/hooks/index.ts +9 -0
  242. package/src/ui/hooks/useApp.test.tsx +159 -0
  243. package/src/{react → ui/hooks}/useApp.tsx +110 -30
  244. package/src/{react → ui/hooks}/useCapabilities.ts +9 -5
  245. package/src/{react/common.ts → ui/hooks/useSettingsState.ts} +0 -11
  246. package/src/ui/hooks/useSurface.ts +13 -0
  247. package/src/ui/index.ts +6 -0
  248. package/src/vite-plugin/composer-plugin.ts +128 -0
  249. package/src/vite-plugin/import-map-plugin.ts +315 -0
  250. package/src/vite-plugin/index.ts +6 -0
  251. package/src/vite-plugin/packages.ts +29 -0
  252. package/tsconfig.json +4 -28
  253. package/tsconfig.node.json +2 -4
  254. package/typedoc.json +2 -4
  255. package/vitest.config.ts +1 -1
  256. package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs +0 -149
  257. package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs.map +0 -7
  258. package/dist/lib/browser/capability-7PCNSWBT.mjs.map +0 -7
  259. package/dist/lib/browser/capability-KP3PFEXD.mjs +0 -31
  260. package/dist/lib/browser/capability-KP3PFEXD.mjs.map +0 -7
  261. package/dist/lib/browser/chunk-6Y7PZV72.mjs.map +0 -7
  262. package/dist/lib/browser/chunk-7IQHKD4U.mjs.map +0 -7
  263. package/dist/lib/browser/chunk-BLQJSGL3.mjs +0 -732
  264. package/dist/lib/browser/chunk-BLQJSGL3.mjs.map +0 -7
  265. package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
  266. package/dist/lib/browser/chunk-FMZN33N4.mjs.map +0 -7
  267. package/dist/lib/browser/chunk-H4WPA7U7.mjs +0 -77
  268. package/dist/lib/browser/chunk-H4WPA7U7.mjs.map +0 -7
  269. package/dist/lib/browser/chunk-PKQT6C53.mjs.map +0 -7
  270. package/dist/lib/browser/chunk-TCLLRCS3.mjs.map +0 -7
  271. package/dist/lib/browser/chunk-XYNO72GQ.mjs +0 -746
  272. package/dist/lib/browser/chunk-XYNO72GQ.mjs.map +0 -7
  273. package/dist/lib/browser/common/index.mjs +0 -38
  274. package/dist/lib/browser/invoker-capability-SZRSTHEH.mjs +0 -32
  275. package/dist/lib/browser/invoker-capability-SZRSTHEH.mjs.map +0 -7
  276. package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs +0 -64
  277. package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs.map +0 -7
  278. package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs +0 -150
  279. package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs.map +0 -7
  280. package/dist/lib/node-esm/capability-CFLQ2QQU.mjs.map +0 -7
  281. package/dist/lib/node-esm/capability-RCUNM2M7.mjs +0 -32
  282. package/dist/lib/node-esm/capability-RCUNM2M7.mjs.map +0 -7
  283. package/dist/lib/node-esm/chunk-663A54LQ.mjs.map +0 -7
  284. package/dist/lib/node-esm/chunk-6WXBT3EC.mjs +0 -747
  285. package/dist/lib/node-esm/chunk-6WXBT3EC.mjs.map +0 -7
  286. package/dist/lib/node-esm/chunk-7OWSHPYK.mjs.map +0 -7
  287. package/dist/lib/node-esm/chunk-GQEBIGKD.mjs +0 -733
  288. package/dist/lib/node-esm/chunk-GQEBIGKD.mjs.map +0 -7
  289. package/dist/lib/node-esm/chunk-GT6OKM5I.mjs.map +0 -7
  290. package/dist/lib/node-esm/chunk-STMXUEPO.mjs.map +0 -7
  291. package/dist/lib/node-esm/chunk-XR6NMKEP.mjs +0 -78
  292. package/dist/lib/node-esm/chunk-XR6NMKEP.mjs.map +0 -7
  293. package/dist/lib/node-esm/chunk-XYQTBFPA.mjs.map +0 -7
  294. package/dist/lib/node-esm/common/index.mjs +0 -39
  295. package/dist/lib/node-esm/invoker-capability-PNMA5JOS.mjs +0 -33
  296. package/dist/lib/node-esm/invoker-capability-PNMA5JOS.mjs.map +0 -7
  297. package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs +0 -65
  298. package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs.map +0 -7
  299. package/dist/types/src/cli.d.ts.map +0 -1
  300. package/dist/types/src/common/activation-event.d.ts +0 -66
  301. package/dist/types/src/common/activation-event.d.ts.map +0 -1
  302. package/dist/types/src/common/capability.d.ts +0 -265
  303. package/dist/types/src/common/capability.d.ts.map +0 -1
  304. package/dist/types/src/common/collaboration.d.ts +0 -26
  305. package/dist/types/src/common/collaboration.d.ts.map +0 -1
  306. package/dist/types/src/common/file.d.ts +0 -14
  307. package/dist/types/src/common/file.d.ts.map +0 -1
  308. package/dist/types/src/common/graph.d.ts +0 -21
  309. package/dist/types/src/common/graph.d.ts.map +0 -1
  310. package/dist/types/src/common/plugin.d.ts +0 -201
  311. package/dist/types/src/common/plugin.d.ts.map +0 -1
  312. package/dist/types/src/common/surface.d.ts.map +0 -1
  313. package/dist/types/src/playground/debug/Debug.d.ts +0 -8
  314. package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
  315. package/dist/types/src/playground/debug/index.d.ts +0 -2
  316. package/dist/types/src/playground/debug/index.d.ts.map +0 -1
  317. package/dist/types/src/playground/debug/plugin.d.ts +0 -3
  318. package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
  319. package/dist/types/src/playground/generator/Main.d.ts +0 -8
  320. package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
  321. package/dist/types/src/playground/generator/Toolbar.d.ts +0 -8
  322. package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
  323. package/dist/types/src/playground/generator/generator.d.ts +0 -19
  324. package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
  325. package/dist/types/src/playground/generator/index.d.ts +0 -3
  326. package/dist/types/src/playground/generator/index.d.ts.map +0 -1
  327. package/dist/types/src/playground/generator/plugin.d.ts +0 -3
  328. package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
  329. package/dist/types/src/playground/layout/Layout.d.ts +0 -10
  330. package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
  331. package/dist/types/src/playground/layout/index.d.ts +0 -2
  332. package/dist/types/src/playground/layout/index.d.ts.map +0 -1
  333. package/dist/types/src/playground/layout/plugin.d.ts +0 -3
  334. package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
  335. package/dist/types/src/playground/logger/Toolbar.d.ts +0 -8
  336. package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
  337. package/dist/types/src/playground/logger/index.d.ts +0 -2
  338. package/dist/types/src/playground/logger/index.d.ts.map +0 -1
  339. package/dist/types/src/playground/logger/plugin.d.ts +0 -3
  340. package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
  341. package/dist/types/src/playground/logger/schema.d.ts +0 -27
  342. package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
  343. package/dist/types/src/playground/playground.stories.d.ts +0 -11
  344. package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
  345. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -3
  346. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  347. package/dist/types/src/plugin-settings/actions.d.ts +0 -61
  348. package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
  349. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -6
  350. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
  351. package/dist/types/src/plugin-settings/index.d.ts +0 -3
  352. package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
  353. package/dist/types/src/plugin-settings/meta.d.ts +0 -3
  354. package/dist/types/src/plugin-settings/meta.d.ts.map +0 -1
  355. package/dist/types/src/plugin-settings/operation-resolver.d.ts +0 -6
  356. package/dist/types/src/plugin-settings/operation-resolver.d.ts.map +0 -1
  357. package/dist/types/src/plugin-settings/translations.d.ts +0 -11
  358. package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
  359. package/dist/types/src/react/App.d.ts.map +0 -1
  360. package/dist/types/src/react/App.stories.d.ts.map +0 -1
  361. package/dist/types/src/react/DefaultFallback.d.ts +0 -8
  362. package/dist/types/src/react/DefaultFallback.d.ts.map +0 -1
  363. package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
  364. package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
  365. package/dist/types/src/react/PluginManagerContext.stories.d.ts.map +0 -1
  366. package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
  367. package/dist/types/src/react/Surface.d.ts +0 -14
  368. package/dist/types/src/react/Surface.d.ts.map +0 -1
  369. package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
  370. package/dist/types/src/react/SurfaceInfo.d.ts.map +0 -1
  371. package/dist/types/src/react/common.d.ts.map +0 -1
  372. package/dist/types/src/react/index.d.ts +0 -9
  373. package/dist/types/src/react/index.d.ts.map +0 -1
  374. package/dist/types/src/react/types.d.ts +0 -12
  375. package/dist/types/src/react/types.d.ts.map +0 -1
  376. package/dist/types/src/react/useApp.d.ts.map +0 -1
  377. package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
  378. package/dist/types/src/react/useLoading.d.ts.map +0 -1
  379. package/dist/types/src/react/useOperationResolver.d.ts +0 -19
  380. package/dist/types/src/react/useOperationResolver.d.ts.map +0 -1
  381. package/src/common/activation-event.ts +0 -99
  382. package/src/common/capability.ts +0 -343
  383. package/src/common/collaboration.ts +0 -31
  384. package/src/common/file.ts +0 -22
  385. package/src/common/graph.ts +0 -30
  386. package/src/common/plugin.ts +0 -364
  387. package/src/playground/debug/Debug.tsx +0 -49
  388. package/src/playground/debug/plugin.ts +0 -16
  389. package/src/playground/generator/Main.tsx +0 -80
  390. package/src/playground/generator/Toolbar.tsx +0 -57
  391. package/src/playground/generator/generator.ts +0 -48
  392. package/src/playground/generator/index.ts +0 -6
  393. package/src/playground/generator/plugin.ts +0 -21
  394. package/src/playground/layout/Layout.tsx +0 -37
  395. package/src/playground/layout/plugin.ts +0 -18
  396. package/src/playground/logger/Toolbar.tsx +0 -33
  397. package/src/playground/logger/index.ts +0 -5
  398. package/src/playground/logger/plugin.ts +0 -42
  399. package/src/playground/logger/schema.ts +0 -22
  400. package/src/playground/playground.stories.tsx +0 -54
  401. package/src/plugin-settings/SettingsPlugin.ts +0 -19
  402. package/src/plugin-settings/actions.ts +0 -64
  403. package/src/plugin-settings/app-graph-builder.ts +0 -140
  404. package/src/plugin-settings/index.ts +0 -6
  405. package/src/plugin-settings/meta.ts +0 -10
  406. package/src/plugin-settings/operation-resolver.ts +0 -55
  407. package/src/plugin-settings/translations.ts +0 -19
  408. package/src/react/App.stories.tsx +0 -63
  409. package/src/react/DefaultFallback.tsx +0 -26
  410. package/src/react/ErrorBoundary.tsx +0 -56
  411. package/src/react/index.ts +0 -14
  412. package/src/react/types.ts +0 -27
  413. package/src/react/useOperationResolver.ts +0 -40
  414. /package/dist/lib/{node-esm/react/index.mjs.map → browser/chunk-RFSO3JRG.mjs.map} +0 -0
  415. /package/dist/lib/{node-esm/common/index.mjs.map → browser/common/activation-events.mjs.map} +0 -0
  416. /package/dist/lib/browser/{react/index.mjs.map → common/capabilities.mjs.map} +0 -0
  417. /package/dist/lib/browser/{common/index.mjs.map → core/url-loader.mjs.map} +0 -0
  418. /package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.d.ts +0 -0
  419. /package/dist/types/src/{react → ui/components/Surface}/SurfaceInfo.d.ts +0 -0
  420. /package/dist/types/src/{react → ui/hooks}/useLoading.d.ts +0 -0
  421. /package/src/{react → ui/hooks}/useLoading.tsx +0 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/core/plugin-manager.ts", "../../../src/core/capability-manager.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, Registry } from '@effect-atom/atom-react';\nimport * as Array from 'effect/Array';\nimport * as Cause from 'effect/Cause';\nimport * as Deferred from 'effect/Deferred';\nimport * as Duration from 'effect/Duration';\nimport * as Effect from 'effect/Effect';\nimport * as Fiber from 'effect/Fiber';\nimport * as Function from 'effect/Function';\nimport * as HashSet from 'effect/HashSet';\nimport * as PubSub from 'effect/PubSub';\nimport * as Ref from 'effect/Ref';\n\nimport { runAndForwardErrors } from '@dxos/effect';\nimport { Performance } from '@dxos/effect';\nimport { log } from '@dxos/log';\n\nimport * as ActivationEvent from './activation-event';\nimport * as Capability from './capability';\nimport * as CapabilityManager from './capability-manager';\nimport * as Plugin from './plugin';\n\n/**\n * Identifier denoting a Manager.\n */\nexport const ManagerTypeId: unique symbol = Symbol.for('@dxos/app-framework/Manager');\nexport type ManagerTypeId = typeof ManagerTypeId;\n\nexport type ManagerOptions = {\n pluginLoader: (id: string) => Effect.Effect<Plugin.Plugin, Error>;\n plugins?: Plugin.Plugin[];\n core?: string[];\n enabled?: string[];\n registry?: Registry.Registry;\n};\n\nexport type ActivationMessage = {\n event: string;\n state: 'activating' | 'activated' | 'error';\n /** Module ID when the message pertains to a specific module activation. */\n module?: string;\n error?: Error;\n};\n\n/**\n * Interface for the Plugin Manager.\n */\nexport interface PluginManager {\n readonly [ManagerTypeId]: ManagerTypeId;\n readonly activation: PubSub.PubSub<ActivationMessage>;\n readonly capabilities: CapabilityManager.CapabilityManager;\n readonly registry: Registry.Registry;\n\n readonly plugins: Atom.Atom<readonly Plugin.Plugin[]>;\n readonly core: Atom.Atom<readonly string[]>;\n readonly enabled: Atom.Atom<readonly string[]>;\n readonly modules: Atom.Atom<readonly Plugin.PluginModule[]>;\n readonly active: Atom.Atom<readonly string[]>;\n readonly eventsFired: Atom.Atom<readonly string[]>;\n readonly pendingReset: Atom.Atom<readonly string[]>;\n\n getPlugins(): readonly Plugin.Plugin[];\n getCore(): readonly string[];\n getEnabled(): readonly string[];\n getModules(): readonly Plugin.PluginModule[];\n getActive(): readonly string[];\n getEventsFired(): readonly string[];\n getPendingReset(): readonly string[];\n\n add(id: string): Effect.Effect<boolean, Error>;\n enable(id: string): Effect.Effect<boolean, Error>;\n remove(id: string): boolean;\n disable(id: string): Effect.Effect<boolean, Error>;\n // TODO(wittjosiah): Improve error typing.\n activate(\n event: ActivationEvent.ActivationEvent | string,\n params?: { before?: string; after?: string },\n ): Effect.Effect<boolean, Error>;\n deactivate(id: string): Effect.Effect<boolean, Error>;\n reset(event: ActivationEvent.ActivationEvent | string): Effect.Effect<boolean, Error>;\n\n /**\n * Shuts down the manager by deactivating all active modules in reverse activation order,\n * clearing all capabilities, and resetting lifecycle bookkeeping.\n * Plugins, core, enabled, and modules remain intact so the manager can be reused.\n */\n shutdown(): Effect.Effect<boolean, Error>;\n}\n\n/**\n * Type guard to check if a value is a PluginManager.\n */\nexport const isManager = (value: unknown): value is PluginManager => {\n return typeof value === 'object' && value !== null && ManagerTypeId in value;\n};\n\n/**\n * Internal implementation of PluginManager.\n */\nclass ManagerImpl implements PluginManager {\n readonly [ManagerTypeId]: ManagerTypeId = ManagerTypeId;\n readonly activation = Effect.runSync(PubSub.unbounded<ActivationMessage>());\n readonly capabilities: CapabilityManager.CapabilityManager;\n readonly registry: Registry.Registry;\n\n private readonly _pluginsAtom: Atom.Writable<Plugin.Plugin[]>;\n private readonly _coreAtom: Atom.Writable<string[]>;\n private readonly _enabledAtom: Atom.Writable<string[]>;\n private readonly _modulesAtom: Atom.Writable<Plugin.PluginModule[]>;\n private readonly _activeAtom: Atom.Writable<string[]>;\n private readonly _eventsFiredAtom: Atom.Writable<string[]>;\n private readonly _pendingResetAtom: Atom.Writable<string[]>;\n private readonly _pluginLoader: ManagerOptions['pluginLoader'];\n private readonly _capabilities = new Map<string, Capability.Any[]>();\n private readonly _moduleMemoMap = new Map<Plugin.PluginModule['id'], Deferred.Deferred<Capability.Any[], Error>>();\n private readonly _moduleSemaphores = new Map<Plugin.PluginModule['id'], Effect.Semaphore>();\n private readonly _activatingEvents = Effect.runSync(Ref.make<string[]>([]));\n private readonly _activatingModules = Effect.runSync(Ref.make<string[]>([]));\n private readonly _inFlightFibers = Effect.runSync(Ref.make<Array<Fiber.Fiber<unknown, unknown>>>([]));\n private readonly _shutdownSemaphore = Effect.runSync(Effect.makeSemaphore(1));\n private readonly _shuttingDown = Effect.runSync(Ref.make(false));\n\n constructor({\n pluginLoader,\n plugins = [],\n core = plugins.map(({ meta }) => meta.id),\n enabled = [],\n registry,\n }: ManagerOptions) {\n this.registry = registry ?? Registry.make();\n this.capabilities = CapabilityManager.make({\n registry: this.registry,\n });\n\n this._pluginLoader = pluginLoader;\n this._pluginsAtom = Atom.make(plugins).pipe(Atom.keepAlive);\n this._coreAtom = Atom.make(core).pipe(Atom.keepAlive);\n this._enabledAtom = Atom.make(enabled).pipe(Atom.keepAlive);\n this._modulesAtom = Atom.make<Plugin.PluginModule[]>([]).pipe(Atom.keepAlive);\n this._activeAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n this._eventsFiredAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n this._pendingResetAtom = Atom.make<string[]>([]).pipe(Atom.keepAlive);\n plugins.forEach((plugin) => this._addPlugin(plugin));\n void Effect.all([...core, ...enabled].map((id) => this.enable(id))).pipe(runAndForwardErrors);\n }\n\n get plugins(): Atom.Atom<readonly Plugin.Plugin[]> {\n return this._pluginsAtom;\n }\n\n get core(): Atom.Atom<readonly string[]> {\n return this._coreAtom;\n }\n\n /**\n * Ids of plugins that are currently enabled.\n */\n get enabled(): Atom.Atom<readonly string[]> {\n return this._enabledAtom;\n }\n\n /**\n * Modules of plugins which are currently enabled.\n */\n get modules(): Atom.Atom<readonly Plugin.PluginModule[]> {\n return this._modulesAtom;\n }\n\n /**\n * Ids of modules which are currently active.\n */\n get active(): Atom.Atom<readonly string[]> {\n return this._activeAtom;\n }\n\n /**\n * Ids of events which have been fired.\n */\n get eventsFired(): Atom.Atom<readonly string[]> {\n return this._eventsFiredAtom;\n }\n\n /**\n * Ids of modules which are pending reset.\n */\n get pendingReset(): Atom.Atom<readonly string[]> {\n return this._pendingResetAtom;\n }\n\n getPlugins(): readonly Plugin.Plugin[] {\n return this._get(this._pluginsAtom);\n }\n\n getCore(): readonly string[] {\n return this._get(this._coreAtom);\n }\n\n getEnabled(): readonly string[] {\n return this._get(this._enabledAtom);\n }\n\n getModules(): readonly Plugin.PluginModule[] {\n return this._get(this._modulesAtom);\n }\n\n getActive(): readonly string[] {\n return this._get(this._activeAtom);\n }\n\n getEventsFired(): readonly string[] {\n return this._get(this._eventsFiredAtom);\n }\n\n getPendingReset(): readonly string[] {\n return this._get(this._pendingResetAtom);\n }\n\n /**\n * Adds a plugin to the manager via the plugin loader.\n * @param id The id of the plugin.\n */\n add(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('add plugin', { id });\n const plugin = yield* this._pluginLoader(id);\n this._addPlugin(plugin);\n return yield* this.enable(plugin.meta.id);\n });\n }\n\n /**\n * Enables a plugin.\n * @param id The id of the plugin.\n */\n enable(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('enable plugin', { id });\n const plugin = this._getPlugin(id);\n if (!plugin) {\n return false;\n }\n\n this._update(this._enabledAtom, (enabled) => (enabled.includes(id) ? enabled : [...enabled, id]));\n\n plugin.modules.forEach((module) => {\n this._addModule(module);\n this._setPendingResetByModule(module);\n });\n\n log('pending reset', { events: [...this.getPendingReset()] });\n yield* Effect.all(\n this.getPendingReset().map((event) => this.activate(event)),\n { concurrency: 'unbounded' },\n );\n\n return true;\n });\n }\n\n /**\n * Removes a plugin from the manager.\n * @param id The id of the plugin.\n */\n remove(id: string): boolean {\n log('remove plugin', { id });\n const result = this.disable(id);\n if (!result) {\n return false;\n }\n\n this._removePlugin(id);\n return true;\n }\n\n /**\n * Disables a plugin.\n * @param id The id of the plugin.\n */\n disable(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n log('disable plugin', { id });\n if (this._get(this._coreAtom).includes(id)) {\n return false;\n }\n\n const plugin = this._getPlugin(id);\n if (!plugin) {\n return false;\n }\n\n const enabledIndex = this._get(this._enabledAtom).findIndex((enabled) => enabled === id);\n if (enabledIndex !== -1) {\n this._update(this._enabledAtom, (enabled) => enabled.filter((item) => item !== id));\n yield* this.deactivate(id);\n\n plugin.modules.forEach((module) => {\n this._removeModule(module.id);\n });\n }\n\n return true;\n });\n }\n\n /**\n * Activates plugins based on the activation event.\n * @param event The activation event.\n * @returns Whether the activation was successful.\n */\n activate(\n event: ActivationEvent.ActivationEvent | string,\n params?: { before?: string; after?: string },\n ): Effect.Effect<boolean, Error> {\n const key = typeof event === 'string' ? event : ActivationEvent.eventKey(event);\n return Effect.gen(this, function* () {\n if (yield* this._isShuttingDown()) {\n log('skipping activation during shutdown', { key, ...params });\n return false;\n }\n\n return yield* Effect.withFiberRuntime<boolean, Error>((fiber) =>\n this._activateEvent(key, params, fiber).pipe(\n together(\n Effect.sleep(Duration.seconds(15)).pipe(\n Effect.andThen(Effect.sync(() => log.warn('event activation is taking a long time', { event: key }))),\n ),\n ),\n Performance.addTrackEntry({\n name: typeof event === 'string' ? event : ActivationEvent.eventKey(event),\n devtools: {\n dataType: 'track-entry',\n track: 'Event Activation',\n trackGroup: 'Composer',\n color: 'primary',\n },\n }),\n ),\n );\n });\n }\n\n /**\n * Deactivates all of the modules for a plugin.\n * @param id The id of the plugin.\n * @returns Whether the deactivation was successful.\n */\n deactivate(id: string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const plugin = this._getPlugin(id);\n if (!plugin) {\n return false;\n }\n\n const modules = plugin.modules;\n const results = yield* Effect.all(\n modules.map((module) => this._deactivateModule(module)),\n { concurrency: 'unbounded' },\n );\n return results.every((result) => result);\n });\n }\n\n /**\n * Re-activates the modules that were activated by the event.\n * @param event The activation event.\n * @returns Whether the reset was successful.\n */\n reset(event: ActivationEvent.ActivationEvent | string): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const key = typeof event === 'string' ? event : ActivationEvent.eventKey(event);\n log('reset', { key });\n const modules = this._getActiveModulesByEvent(key);\n const results = yield* Effect.all(\n modules.map((module) => this._deactivateModule(module)),\n { concurrency: 'unbounded' },\n );\n\n if (results.every((result) => result)) {\n return yield* this.activate(key);\n } else {\n return false;\n }\n });\n }\n\n shutdown(): Effect.Effect<boolean, Error> {\n return this._shutdownSemaphore.withPermits(1)(\n Effect.gen(this, function* () {\n yield* Ref.set(this._shuttingDown, true);\n log('shutdown');\n\n yield* this._interruptInFlightActivations();\n\n const activeIds = [...this._get(this._activeAtom)].reverse();\n const allModules = this._get(this._modulesAtom);\n const modulesToDeactivate = activeIds\n .map((id) => allModules.find((module) => module.id === id))\n .filter((module): module is Plugin.PluginModule => module != null);\n\n for (const module of modulesToDeactivate) {\n yield* this._deactivateModule(module);\n }\n\n this._set(this._eventsFiredAtom, []);\n this._set(this._pendingResetAtom, []);\n this._moduleMemoMap.clear();\n yield* Ref.set(this._activatingEvents, []);\n yield* Ref.set(this._activatingModules, []);\n\n log('shutdown complete');\n return true;\n }).pipe(Effect.ensuring(Ref.set(this._shuttingDown, false))),\n );\n }\n\n //\n // State helpers\n //\n\n private _get<T>(atom: Atom.Atom<T>): T {\n return this.registry.get(atom);\n }\n\n private _set<T>(atom: Atom.Writable<T>, value: T): void {\n this.registry.set(atom, value);\n }\n\n private _update<T>(atom: Atom.Writable<T>, updater: (current: T) => T): void {\n this._set(atom, updater(this._get(atom)));\n }\n\n private _isShuttingDown(): Effect.Effect<boolean> {\n return Ref.get(this._shuttingDown);\n }\n\n private _getPlugin(id: string): Plugin.Plugin | undefined {\n return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);\n }\n\n private _getActiveModules(): Plugin.PluginModule[] {\n const active = this._get(this._activeAtom);\n return this._get(this._modulesAtom).filter((module) => active.includes(module.id));\n }\n\n private _getInactiveModules(): Plugin.PluginModule[] {\n const active = this._get(this._activeAtom);\n return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));\n }\n\n private _getActiveModulesByEvent(key: string): Plugin.PluginModule[] {\n return this._getActiveModules().filter((module) =>\n ActivationEvent.getEvents(module.activatesOn).map(ActivationEvent.eventKey).includes(key),\n );\n }\n\n private _getInactiveModulesByEvent(key: string): Plugin.PluginModule[] {\n return this._getInactiveModules().filter((module) =>\n ActivationEvent.getEvents(module.activatesOn).map(ActivationEvent.eventKey).includes(key),\n );\n }\n\n private _setPendingResetByModule(module: Plugin.PluginModule): void {\n const activationEvents = ActivationEvent.getEvents(module.activatesOn)\n .map(ActivationEvent.eventKey)\n .filter((key) => this._get(this._eventsFiredAtom).includes(key));\n\n const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {\n const pending = this._get(this._pendingResetAtom);\n return !pending.includes(event);\n });\n if (pendingReset.length > 0) {\n log('pending reset', { events: pendingReset });\n this._update(this._pendingResetAtom, (current) => [...current, ...pendingReset]);\n }\n }\n\n private _clearPendingReset(key: string): void {\n const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);\n if (pendingIndex !== -1) {\n this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));\n }\n }\n\n //\n // Fiber helpers\n //\n\n private _interruptInFlightActivations(): Effect.Effect<void> {\n return Effect.gen(this, function* () {\n const inFlightFibers = yield* Ref.get(this._inFlightFibers);\n yield* Effect.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {\n concurrency: 'unbounded',\n });\n });\n }\n\n private _trackFiber(\n ref: Ref.Ref<Array<Fiber.Fiber<unknown, unknown>>>,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<void> {\n return Ref.update(ref, (fibers) => [...fibers, fiber]);\n }\n\n private _untrackFiber(\n ref: Ref.Ref<Array<Fiber.Fiber<unknown, unknown>>>,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<void> {\n return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));\n }\n\n //\n // Registration helpers\n //\n\n private _addPlugin(plugin: Plugin.Plugin): void {\n log('add plugin', { id: plugin.meta.id });\n // TODO(wittjosiah): Find a way to add a warning for duplicate plugins that doesn't cause log spam.\n this._update(this._pluginsAtom, (plugins) => (plugins.includes(plugin) ? plugins : [...plugins, plugin]));\n }\n\n private _removePlugin(id: string): void {\n log('remove plugin', { id });\n this._update(this._pluginsAtom, (plugins) => plugins.filter((plugin) => plugin.meta.id !== id));\n }\n\n private _addModule(module: Plugin.PluginModule): void {\n log('add module', { id: module.id });\n // TODO(wittjosiah): Find a way to add a warning for duplicate modules that doesn't cause log spam.\n this._update(this._modulesAtom, (modules) => (modules.includes(module) ? modules : [...modules, module]));\n }\n\n private _removeModule(id: string): void {\n log('remove module', { id });\n this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));\n }\n\n //\n // Activation helpers\n //\n\n private _activateEvent(\n key: string,\n params: { before?: string; after?: string } | undefined,\n fiber: Fiber.Fiber<unknown, unknown>,\n ): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n yield* this._trackFiber(this._inFlightFibers, fiber);\n log('activating', { key, ...params });\n yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));\n this._clearPendingReset(key);\n\n const activatingEvents = yield* this._activatingEvents;\n const activatingModules = yield* this._activatingModules;\n const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);\n if (modules.length === 0) {\n log('no modules to activate', { key });\n if (!this._get(this._eventsFiredAtom).includes(key)) {\n this._update(this._eventsFiredAtom, (events) => [...events, key]);\n }\n return false;\n }\n\n return yield* this._activateModulesForEvent(key, modules, activatingEvents);\n }).pipe(\n Effect.ensuring(\n Effect.all([\n this._untrackFiber(this._inFlightFibers, fiber),\n Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key)),\n ]),\n ),\n );\n }\n\n private _activateModulesForEvent(\n key: string,\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): Effect.Effect<boolean, Error> {\n const activatingModuleIds = modules.map((module) => module.id);\n return Effect.gen(this, function* () {\n yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));\n\n log('activating modules', { key, modules: activatingModuleIds });\n performance.mark(`event:${key}:start`);\n yield* PubSub.publish(this.activation, { event: key, state: 'activating' });\n\n yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), 'before');\n\n const capabilities = yield* this._loadCapabilitiesForModules(key, modules);\n yield* this._contributeCapabilitiesForModules(modules, capabilities);\n\n yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), 'after');\n\n if (!this._get(this._eventsFiredAtom).includes(key)) {\n this._update(this._eventsFiredAtom, (events) => [...events, key]);\n }\n\n performance.mark(`event:${key}:end`);\n performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);\n yield* PubSub.publish(this.activation, { event: key, state: 'activated' });\n log('activated', { key });\n\n return true;\n }).pipe(\n Effect.ensuring(\n Ref.update(this._activatingModules, (activating) =>\n Array.filter(activating, (module) => !activatingModuleIds.includes(module)),\n ),\n ),\n );\n }\n\n private _getModulesForActivation(\n key: string,\n activatingEvents: string[],\n activatingModules: string[],\n ): Plugin.PluginModule[] {\n return this._getInactiveModulesByEvent(key).filter((module) => {\n const allOf = ActivationEvent.isAllOf(module.activatesOn);\n if (!allOf) {\n return true;\n }\n\n // Check to see if all of the events in the `allOf` have been fired.\n // An event can be considered \"fired\" if it is in the `eventsFired` list or if it is currently being activated.\n const events = ActivationEvent.getEvents(module.activatesOn).filter(\n (event) => ActivationEvent.eventKey(event) !== key,\n );\n return (\n events.every(\n (event) =>\n this._get(this._eventsFiredAtom).includes(ActivationEvent.eventKey(event)) ||\n activatingEvents.includes(ActivationEvent.eventKey(event)),\n ) && !activatingModules.includes(module.id)\n );\n });\n }\n\n private _getBeforeEvents(\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): ActivationEvent.ActivationEvent[] {\n return Function.pipe(\n modules,\n Array.flatMap((module) => module.activatesBefore ?? []),\n HashSet.fromIterable,\n HashSet.toValues,\n Array.filter((event) => !activatingEvents.includes(ActivationEvent.eventKey(event))),\n );\n }\n\n private _getAfterEvents(\n modules: Plugin.PluginModule[],\n activatingEvents: string[],\n ): ActivationEvent.ActivationEvent[] {\n return Function.pipe(\n modules,\n Array.flatMap((module) => module.activatesAfter ?? []),\n HashSet.fromIterable,\n HashSet.toValues,\n Array.filter((event) => !activatingEvents.includes(ActivationEvent.eventKey(event))),\n );\n }\n\n private _activateRelatedEvents(\n key: string,\n events: ActivationEvent.ActivationEvent[],\n phase: 'before' | 'after',\n ): Effect.Effect<void, Error> {\n const logLabel = phase === 'before' ? 'activatesBefore' : 'activatesAfter';\n const eventKey = phase === 'before' ? 'beforeEvents' : 'afterEvents';\n return Function.pipe(\n events,\n Array.map((event) => this.activate(event, phase === 'before' ? { before: key } : { after: key })),\n Effect.allWith({ concurrency: 'unbounded' }),\n together(\n Effect.sleep(Duration.seconds(10)).pipe(\n Effect.andThen(\n Effect.sync(() =>\n log.warn(`${logLabel} is taking a long time`, {\n event: key,\n [eventKey]: events.map(ActivationEvent.eventKey),\n }),\n ),\n ),\n ),\n ),\n Effect.asVoid,\n );\n }\n\n //\n // Module lifecycle helpers\n //\n\n private _loadCapabilitiesForModules(\n key: string,\n modules: Plugin.PluginModule[],\n ): Effect.Effect<Capability.Any[][], Error> {\n return Function.pipe(\n modules,\n Array.map((mod) => this._loadModule(mod)),\n Effect.allWith({ concurrency: 'unbounded' }),\n Effect.catchAll((error) => {\n return Effect.gen(this, function* () {\n yield* PubSub.publish(this.activation, { event: key, state: 'error', error });\n return yield* Effect.fail(error);\n });\n }),\n );\n }\n\n private _contributeCapabilitiesForModules(\n modules: Plugin.PluginModule[],\n capabilities: Capability.Any[][],\n ): Effect.Effect<void, Error> {\n return Function.pipe(\n modules,\n Array.zip(capabilities),\n Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),\n // TODO(wittjosiah): This currently can't be run in parallel.\n // Running this with concurrency causes races with `allOf` activation events.\n Effect.all,\n Effect.asVoid,\n );\n }\n\n private _getModuleSemaphore(moduleId: Plugin.PluginModule['id']): Effect.Semaphore {\n let semaphore = this._moduleSemaphores.get(moduleId);\n if (!semaphore) {\n semaphore = Effect.runSync(Effect.makeSemaphore(1));\n this._moduleSemaphores.set(moduleId, semaphore);\n }\n return semaphore;\n }\n\n private _loadModule = (module: Plugin.PluginModule): Effect.Effect<Capability.Any[], Error> =>\n Effect.gen(this, function* () {\n const semaphore = this._getModuleSemaphore(module.id);\n\n // Atomically check-and-set under per-module semaphore to prevent race conditions.\n const deferredToAwait = yield* Effect.gen(this, function* () {\n const existing = this._moduleMemoMap.get(module.id);\n if (existing) {\n return existing;\n }\n\n // First caller - create deferred, store it, and start loading in background.\n const deferred = yield* Deferred.make<Capability.Any[], Error>();\n this._moduleMemoMap.set(module.id, deferred);\n\n const loadEffect = Effect.gen(this, function* () {\n log('loading module', { module: module.id });\n performance.mark(`module:${module.id}:start`);\n yield* PubSub.publish(this.activation, { event: '', state: 'activating', module: module.id });\n const [duration, capabilities] = yield* module\n .activate()\n .pipe(\n Effect.provideService(Capability.Service, this.capabilities),\n Effect.provideService(Plugin.Service, this),\n Effect.timed,\n );\n const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [capabilities];\n const elapsed = Duration.toMillis(duration);\n performance.mark(`module:${module.id}:end`);\n performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);\n yield* PubSub.publish(this.activation, { event: '', state: 'activated', module: module.id });\n log('loaded module', {\n module: module.id,\n elapsed,\n failed: false,\n });\n return normalized as Capability.Any[];\n }).pipe(\n Effect.withSpan('PluginManager._loadModule'),\n together(\n Effect.sleep(Duration.seconds(10)).pipe(\n Effect.andThen(\n Effect.sync(() => log.warn(`module is taking a long time to activate`, { module: module.id })),\n ),\n ),\n ),\n Performance.addTrackEntry({\n name: module.id,\n devtools: {\n dataType: 'track-entry',\n track: 'Module Activation',\n trackGroup: 'Composer',\n color: 'primary',\n },\n }),\n );\n\n // Fork the load to run in background, completing the deferred when done.\n const fiber = yield* Effect.forkDaemon(\n loadEffect.pipe(\n Effect.tap((result) => Deferred.succeed(deferred, result)),\n Effect.catchAllCause((cause) => {\n const error = Cause.squash(cause);\n log.error('module failed to activate', {\n module: module.id,\n error: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n isDefect: !Cause.isFailure(cause),\n });\n return Deferred.fail(deferred, error instanceof Error ? error : new Error(String(error)));\n }),\n ),\n );\n yield* this._trackFiber(this._inFlightFibers, fiber);\n yield* Effect.forkDaemon(\n Fiber.await(fiber).pipe(Effect.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))),\n );\n\n return deferred;\n }).pipe(semaphore.withPermits(1));\n\n // Wait for result outside the semaphore so multiple waiters can proceed concurrently.\n return yield* Deferred.await(deferredToAwait);\n });\n\n private _contributeCapabilities(\n module: Plugin.PluginModule,\n capabilities: Capability.Any[],\n ): Effect.Effect<void, Error> {\n return Effect.gen(this, function* () {\n capabilities.forEach((capability) => {\n this.capabilities.contribute({ module: module.id, ...capability });\n });\n this._update(this._activeAtom, (active) => [...active, module.id]);\n this._capabilities.set(module.id, capabilities);\n });\n }\n\n private _deactivateModule(module: Plugin.PluginModule): Effect.Effect<boolean, Error> {\n return Effect.gen(this, function* () {\n const id = module.id;\n log('deactivating', { id });\n this._moduleMemoMap.delete(id);\n\n const capabilities = this._capabilities.get(id);\n if (capabilities) {\n for (const capability of capabilities) {\n this.capabilities.remove(capability.interface, capability.implementation);\n const program = capability.deactivate?.() ?? Effect.succeed(undefined);\n yield* program;\n }\n this._capabilities.delete(id);\n }\n\n const activeIndex = this._get(this._activeAtom).findIndex((event) => event === id);\n if (activeIndex !== -1) {\n this._update(this._activeAtom, (active) => active.filter((event) => event !== id));\n }\n\n log('deactivated', { id });\n return true;\n });\n }\n}\n\n/**\n * Creates a new Plugin Manager instance.\n */\nexport const make = (options: ManagerOptions): PluginManager => new ManagerImpl(options);\n\n/**\n * Runs an effect concurrently with another effect.\n * If the first effect completes, the second effect is interrupted.\n */\n// TODO(dmaretskyi): Effect.race > Effect.asVoid\nconst together =\n <R1>(togetherEffect: Effect.Effect<void, never, R1>) =>\n <A, E, R2>(effect: Effect.Effect<A, E, R2>): Effect.Effect<A, E, R1 | R2> =>\n Effect.gen(function* () {\n const togetherFiber = yield* Effect.fork(togetherEffect);\n const result = yield* effect;\n yield* Fiber.interrupt(togetherFiber);\n return result;\n });\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Deferred from 'effect/Deferred';\nimport * as Effect from 'effect/Effect';\n\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport type * as Capability from './capability';\n\ntype CapabilityEntry<T> = {\n moduleId: string;\n implementation: T;\n};\n\n/**\n * Options for creating a capability manager.\n * @internal\n */\nexport type CapabilityManagerOptions = {\n registry: Registry.Registry;\n};\n\n/**\n * Interface for the Capability Manager.\n * Provides methods for contributing, removing, and accessing capabilities.\n */\nexport interface CapabilityManager {\n contribute<T>(args: { module: string; interface: Capability.InterfaceDef<T>; implementation: T }): void;\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void;\n\n /**\n * Get the Atom reference to the available capabilities for a given interface.\n * Primarily useful for deriving other Atom values based on the capabilities or\n * for subscribing to changes in the capabilities.\n * @returns An atom reference to the available capabilities.\n */\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]>;\n\n /**\n * Get capabilities from the capability manager.\n * @returns An array of capabilities.\n */\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[];\n\n /**\n * Requests a single capability from the capability manager.\n * @returns The capability.\n * @throws If no capability is found.\n */\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T;\n\n /**\n * Waits for a capability to be available.\n * @returns The capability.\n */\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T, Error>;\n}\n\n/**\n * Internal implementation of CapabilityManager.\n */\nclass CapabilityManagerImpl implements CapabilityManager {\n private readonly _registry: Registry.Registry;\n\n private readonly _capabilityEntries = Atom.family<string, Atom.Writable<CapabilityEntry<unknown>[]>>(() => {\n return Atom.make<CapabilityEntry<unknown>[]>([]).pipe(Atom.keepAlive);\n });\n\n readonly _capabilities = Atom.family<string, Atom.Atom<unknown[]>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilityEntries(id));\n return current.map((c) => c.implementation);\n }).pipe(Atom.keepAlive);\n });\n\n readonly _capability = Atom.family<string, Atom.Atom<unknown>>((id: string) => {\n return Atom.make((get) => {\n const current = get(this._capabilities(id));\n invariant(current.length > 0, `No capability found for ${id}`);\n return current[0];\n });\n });\n\n constructor({ registry }: CapabilityManagerOptions) {\n this._registry = registry;\n }\n\n contribute<T>({\n module: moduleId,\n interface: interfaceDef,\n implementation,\n }: {\n module: string;\n interface: Capability.InterfaceDef<T>;\n implementation: T;\n }): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n const isDuplicate = current.some((c) => c.moduleId === moduleId && c.implementation === implementation);\n if (isDuplicate) {\n log('capability already contributed, skipping', { id: interfaceDef.identifier, moduleId });\n return;\n }\n\n const entry: CapabilityEntry<T> = { moduleId, implementation };\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), [...current, entry]);\n log('capability contributed', {\n id: interfaceDef.identifier,\n moduleId,\n count: current.length,\n });\n }\n\n remove<T>(interfaceDef: Capability.InterfaceDef<T>, implementation: T): void {\n const current = this._registry.get(this._capabilityEntries(interfaceDef.identifier));\n if (current.length === 0) {\n return;\n }\n\n const next = current.filter((c) => c.implementation !== implementation);\n if (next.length !== current.length) {\n this._registry.set(this._capabilityEntries(interfaceDef.identifier), next);\n log('capability removed', { id: interfaceDef.identifier, count: current.length });\n } else {\n log.warn('capability not removed', { id: interfaceDef.identifier });\n }\n }\n\n atom<T>(interfaceDef: Capability.InterfaceDef<T>): Atom.Atom<T[]> {\n // NOTE: This the type-checking for capabilities is done at the time of contribution.\n return this._capabilities(interfaceDef.identifier) as Atom.Atom<T[]>;\n }\n\n getAll<T>(interfaceDef: Capability.InterfaceDef<T>): T[] {\n return this._registry.get(this.atom(interfaceDef));\n }\n\n get<T>(interfaceDef: Capability.InterfaceDef<T>): T {\n const capabilities = this.getAll(interfaceDef);\n invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`);\n return capabilities[0];\n }\n\n waitFor<T>(interfaceDef: Capability.InterfaceDef<T>): Effect.Effect<T, Error> {\n return Effect.gen(this, function* () {\n const [capability] = this.getAll(interfaceDef);\n if (capability) {\n return capability;\n }\n\n const deferred = yield* Deferred.make<T, Error>();\n const cancel = this._registry.subscribe(this.atom(interfaceDef), (capabilities) => {\n if (capabilities.length > 0) {\n Effect.runSync(Deferred.succeed(deferred, capabilities[0]));\n }\n });\n const result = yield* Deferred.await(deferred);\n cancel();\n return result;\n });\n }\n}\n\n/**\n * Creates a new Capability Manager instance.\n */\nexport const make = (options: CapabilityManagerOptions): CapabilityManager => new CapabilityManagerImpl(options);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AAAA;;;;cAAAA;;AAIA,SAASC,QAAAA,OAAMC,gBAAgB;AAC/B,YAAYC,WAAW;AACvB,YAAYC,WAAW;AACvB,YAAYC,eAAc;AAC1B,YAAYC,cAAc;AAC1B,YAAYC,aAAY;AACxB,YAAYC,WAAW;AACvB,YAAYC,cAAc;AAC1B,YAAYC,aAAa;AACzB,YAAYC,YAAY;AACxB,YAAYC,SAAS;AAErB,SAASC,2BAA2B;AACpC,SAASC,mBAAmB;AAC5B,SAASC,OAAAA,YAAW;;;AClBpB;;cAAAC;;AAIA,SAASC,YAA2B;AACpC,YAAYC,cAAc;AAC1B,YAAYC,YAAY;AAExB,SAASC,iBAAiB;AAC1B,SAASC,WAAW;;AAyDpB,IAAMC,wBAAN,MAAMA;EACaC;EAEAC,qBAAqBP,KAAKQ,OAA0D,MAAA;AACnG,WAAOR,KAAKD,KAAiC,CAAA,CAAE,EAAEU,KAAKT,KAAKU,S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fiber", "Function", "HashSet", "PubSub", "Ref", "runAndForwardErrors", "Performance", "log", "make", "Atom", "Deferred", "Effect", "invariant", "log", "CapabilityManagerImpl", "_registry", "_capabilityEntries", "family", "pipe", "keepAlive", "_capabilities", "id", "get", "current", "map", "c", "implementation", "_capability", "length", "registry", "contribute", "module", "moduleId", "interface", "interfaceDef", "identifier", "isDuplicate", "some", "entry", "set", "count", "remove", "next", "filter", "warn", "atom", "getAll", "capabilities", "waitFor", "gen", "capability", "deferred", "cancel", "subscribe", "runSync", "succeed", "result", "await", "options", "ManagerTypeId", "Symbol", "for", "isManager", "value", "ManagerImpl", "activation", "runSync", "unbounded", "capabilities", "registry", "_pluginsAtom", "_coreAtom", "_enabledAtom", "_modulesAtom", "_activeAtom", "_eventsFiredAtom", "_pendingResetAtom", "_pluginLoader", "_capabilities", "Map", "_moduleMemoMap", "_moduleSemaphores", "_activatingEvents", "make", "_activatingModules", "_inFlightFibers", "_shutdownSemaphore", "makeSemaphore", "_shuttingDown", "pluginLoader", "plugins", "core", "map", "meta", "id", "enabled", "Registry", "Atom", "pipe", "keepAlive", "forEach", "plugin", "_addPlugin", "all", "enable", "runAndForwardErrors", "modules", "active", "eventsFired", "pendingReset", "getPlugins", "_get", "getCore", "getEnabled", "getModules", "getActive", "getEventsFired", "getPendingReset", "add", "gen", "log", "_getPlugin", "_update", "includes", "module", "_addModule", "_setPendingResetByModule", "events", "event", "activate", "concurrency", "remove", "result", "disable", "_removePlugin", "enabledIndex", "findIndex", "filter", "item", "deactivate", "_removeModule", "params", "key", "eventKey", "_isShuttingDown", "withFiberRuntime", "fiber", "_activateEvent", "together", "sleep", "seconds", "andThen", "sync", "warn", "Performance", "addTrackEntry", "name", "devtools", "dataType", "track", "trackGroup", "color", "results", "_deactivateModule", "every", "reset", "_getActiveModulesByEvent", "shutdown", "withPermits", "set", "_interruptInFlightActivations", "activeIds", "reverse", "allModules", "modulesToDeactivate", "find", "_set", "clear", "ensuring", "atom", "get", "updater", "_getActiveModules", "_getInactiveModules", "getEvents", "activatesOn", "_getInactiveModulesByEvent", "activationEvents", "fromIterable", "Set", "pending", "length", "current", "_clearPendingReset", "pendingIndex", "inFlightFibers", "interrupt", "_trackFiber", "ref", "update", "fibers", "_untrackFiber", "trackedFiber", "activating", "append", "activatingEvents", "activatingModules", "_getModulesForActivation", "_activateModulesForEvent", "activatingModuleIds", "appendAll", "performance", "mark", "publish", "state", "_activateRelatedEvents", "_getBeforeEvents", "_loadCapabilitiesForModules", "_contributeCapabilitiesForModules", "_getAfterEvents", "measure", "allOf", "isAllOf", "flatMap", "activatesBefore", "toValues", "activatesAfter", "phase", "logLabel", "before", "after", "allWith", "asVoid", "mod", "_loadModule", "catchAll", "error", "fail", "zip", "capabilitySet", "_contributeCapabilities", "_getModuleSemaphore", "moduleId", "semaphore", "deferredToAwait", "existing", "deferred", "loadEffect", "duration", "provideService", "Service", "timed", "normalized", "isArray", "elapsed", "toMillis", "failed", "withSpan", "forkDaemon", "tap", "succeed", "catchAllCause", "cause", "squash", "Error", "message", "String", "stack", "undefined", "isDefect", "isFailure", "await", "capability", "contribute", "delete", "interface", "implementation", "program", "activeIndex", "options", "togetherEffect", "effect", "togetherFiber", "fork"]
7
+ }
@@ -0,0 +1,80 @@
1
+ import {
2
+ capability_exports
3
+ } from "./chunk-FL2XTEJH.mjs";
4
+ import {
5
+ __export
6
+ } from "./chunk-J5LGTIGS.mjs";
7
+
8
+ // src/common/capabilities.ts
9
+ var capabilities_exports = {};
10
+ __export(capabilities_exports, {
11
+ AtomRegistry: () => AtomRegistry,
12
+ Command: () => Command,
13
+ HistoryTracker: () => HistoryTracker,
14
+ Layer: () => Layer,
15
+ ManagedRuntime: () => ManagedRuntime,
16
+ Null: () => Null,
17
+ OperationHandler: () => OperationHandler,
18
+ OperationInvoker: () => OperationInvoker,
19
+ PluginManager: () => PluginManager,
20
+ ReactContext: () => ReactContext,
21
+ ReactRoot: () => ReactRoot,
22
+ ReactSurface: () => ReactSurface,
23
+ UndoMapping: () => UndoMapping,
24
+ UndoRegistry: () => UndoRegistry,
25
+ getAtomValue: () => getAtomValue,
26
+ subscribeAtom: () => subscribeAtom,
27
+ updateAtomValue: () => updateAtomValue
28
+ });
29
+ import * as Effect from "effect/Effect";
30
+ var Null = capability_exports.make("org.dxos.app-framework.capability.null");
31
+ var PluginManager = capability_exports.make("org.dxos.app-framework.capability.plugin-manager");
32
+ var AtomRegistry = capability_exports.make("org.dxos.app-framework.capability.atom-registry");
33
+ var ReactContext = capability_exports.make("org.dxos.app-framework.capability.react-context");
34
+ var ReactRoot = capability_exports.make("org.dxos.app-framework.capability.react-root");
35
+ var ReactSurface = capability_exports.make("org.dxos.app-framework.common.react-surface");
36
+ var Command = capability_exports.make("org.dxos.app-framework.capability.command");
37
+ var Layer = capability_exports.make("org.dxos.app-framework.capability.layer");
38
+ var ManagedRuntime = capability_exports.make("org.dxos.app-framework.capability.managed-runtime");
39
+ var OperationHandler = capability_exports.make("org.dxos.app-framework.capability.operation-handler");
40
+ var UndoMapping = capability_exports.make("org.dxos.app-framework.capability.undo-mapping");
41
+ var OperationInvoker = capability_exports.make("org.dxos.app-framework.capability.operation-invoker");
42
+ var UndoRegistry = capability_exports.make("org.dxos.app-framework.capability.undo-registry");
43
+ var HistoryTracker = capability_exports.make("org.dxos.app-framework.capability.history-tracker");
44
+ var getAtomValue = (atomCapability) => Effect.gen(function* () {
45
+ const registry = yield* capability_exports.get(AtomRegistry);
46
+ const atom = yield* capability_exports.get(atomCapability);
47
+ return registry.get(atom);
48
+ });
49
+ var updateAtomValue = (atomCapability, fn) => Effect.gen(function* () {
50
+ const registry = yield* capability_exports.get(AtomRegistry);
51
+ const atom = yield* capability_exports.get(atomCapability);
52
+ registry.set(atom, fn(registry.get(atom)));
53
+ });
54
+ var subscribeAtom = (atomCapability, callback) => Effect.gen(function* () {
55
+ const registry = yield* capability_exports.get(AtomRegistry);
56
+ const atom = yield* capability_exports.get(atomCapability);
57
+ return registry.subscribe(atom, () => callback(registry.get(atom)));
58
+ });
59
+
60
+ export {
61
+ Null,
62
+ PluginManager,
63
+ AtomRegistry,
64
+ ReactContext,
65
+ ReactRoot,
66
+ ReactSurface,
67
+ Command,
68
+ Layer,
69
+ ManagedRuntime,
70
+ OperationHandler,
71
+ UndoMapping,
72
+ OperationInvoker,
73
+ UndoRegistry,
74
+ HistoryTracker,
75
+ getAtomValue,
76
+ updateAtomValue,
77
+ subscribeAtom,
78
+ capabilities_exports
79
+ };
80
+ //# sourceMappingURL=chunk-CV7I2AAB.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/common/capabilities.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport type * as Command$ from '@effect/cli/Command';\nimport { type Atom, type Registry } from '@effect-atom/atom-react';\nimport * as Effect from 'effect/Effect';\nimport type * as Layer$ from 'effect/Layer';\nimport type * as ManagedRuntime$ from 'effect/ManagedRuntime';\nimport type { FC, PropsWithChildren } from 'react';\n\nimport type { OperationInvoker as OperationInvoker$, OperationHandlerSet } from '@dxos/operation';\n\nimport { Capability as Capability$, type PluginManager as PluginManager$ } from '../core';\nimport type {\n HistoryTracker as HistoryTracker$,\n UndoMapping as UndoMapping$,\n UndoRegistry as UndoRegistry$,\n} from '../plugin-operation';\nimport type { Surface } from '../ui';\n\n/**\n * Null capability.\n * @category Capability\n */\nexport const Null = Capability$.make<null>('org.dxos.app-framework.capability.null');\n\n/**\n * @category Capability\n */\nexport const PluginManager = Capability$.make<PluginManager$.PluginManager>(\n 'org.dxos.app-framework.capability.plugin-manager',\n);\n\n/**\n * @category Capability\n */\nexport const AtomRegistry = Capability$.make<Registry.Registry>('org.dxos.app-framework.capability.atom-registry');\n\nexport type ReactContext = Readonly<{\n id: string;\n dependsOn?: string[];\n context: FC<PropsWithChildren>;\n}>;\n\n/**\n * @category Capability\n */\nexport const ReactContext = Capability$.make<ReactContext>('org.dxos.app-framework.capability.react-context');\n\nexport type ReactRoot = Readonly<{ id: string; root: FC<PropsWithChildren> }>;\n\n/**\n * @category Capability\n */\nexport const ReactRoot = Capability$.make<ReactRoot>('org.dxos.app-framework.capability.react-root');\n\n/**\n * Surface definitions that can be either React components or Web Components.\n */\nexport type ReactSurface = Surface.Definition | readonly Surface.Definition[];\n\n/**\n * @category Capability\n */\nexport const ReactSurface = Capability$.make<ReactSurface>('org.dxos.app-framework.common.react-surface');\n\nexport type AnyCommand = Command$.Command<any, any, any, any>;\n\n/**\n * @category Capability\n */\nexport const Command = Capability$.make<AnyCommand>('org.dxos.app-framework.capability.command');\n\n/**\n * @category Capability\n */\nexport const Layer = Capability$.make<Layer$.Layer<any, any, any>>('org.dxos.app-framework.capability.layer');\n\nexport type ManagedRuntime = ManagedRuntime$.ManagedRuntime<any, any>;\n\n/**\n * @category Capability\n */\nexport const ManagedRuntime = Capability$.make<ManagedRuntime>('org.dxos.app-framework.capability.managed-runtime');\n\n//\n// Operation System Capabilities\n//\n\nexport const OperationHandler = Capability$.make<OperationHandlerSet.OperationHandlerSet>(\n 'org.dxos.app-framework.capability.operation-handler',\n);\n\nexport type UndoMapping = UndoMapping$.UndoMapping;\n\n/**\n * Undo mapping registration - contributed by plugins.\n * @category Capability\n */\nexport const UndoMapping = Capability$.make<UndoMapping[]>('org.dxos.app-framework.capability.undo-mapping');\n\nexport type OperationInvoker = OperationInvoker$.OperationInvoker;\n\n/**\n * Operation invoker - provided by OperationPlugin.\n * @category Capability\n */\nexport const OperationInvoker = Capability$.make<OperationInvoker>(\n 'org.dxos.app-framework.capability.operation-invoker',\n);\n\nexport type UndoRegistry = UndoRegistry$.UndoRegistry;\n\n/**\n * Undo registry - provided by OperationPlugin.\n * @category Capability\n */\nexport const UndoRegistry = Capability$.make<UndoRegistry>('org.dxos.app-framework.capability.undo-registry');\n\nexport type HistoryTracker = HistoryTracker$.HistoryTracker;\n\n/**\n * History tracker - provided by OperationPlugin.\n * @category Capability\n */\nexport const HistoryTracker = Capability$.make<HistoryTracker>('org.dxos.app-framework.capability.history-tracker');\n\n//\n// Atom Capability Helpers\n//\n\n/**\n * Get the current value of an atom capability.\n * @example const settings = yield* Capabilities.getAtomValue(ThreadCapabilities.Settings);\n */\nexport const getAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n): Effect.Effect<T, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.get(atom);\n });\n\n/**\n * Update an atom capability value (requires writable atom).\n * @example yield* Capabilities.updateAtomValue(ThreadCapabilities.Settings, (s) => ({ ...s, foo: true }));\n */\nexport const updateAtomValue = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Writable<T>>,\n fn: (current: T) => T,\n): Effect.Effect<void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n registry.set(atom, fn(registry.get(atom)));\n });\n\n/**\n * Subscribe to an atom capability.\n * @example const unsubscribe = yield* Capabilities.subscribeAtom(ThreadCapabilities.Settings, (value) => ...);\n */\nexport const subscribeAtom = <T>(\n atomCapability: Capability$.InterfaceDef<Atom.Atom<T>>,\n callback: (value: T) => void,\n): Effect.Effect<() => void, Error, Capability$.Service> =>\n Effect.gen(function* () {\n const registry = yield* Capability$.get(AtomRegistry);\n const atom = yield* Capability$.get(atomCapability);\n return registry.subscribe(atom, () => callback(registry.get(atom)));\n });\n"],
5
+ "mappings": ";;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;AAMA,YAAYA,YAAY;AAmBjB,IAAMC,OAAOC,mBAAYC,KAAW,wCAAA;AAKpC,IAAMC,gBAAgBF,mBAAYC,KACvC,kDAAA;AAMK,IAAME,eAAeH,mBAAYC,KAAwB,iDAAA;AAWzD,IAAMG,eAAeJ,mBAAYC,KAAmB,iDAAA;AAOpD,IAAMI,YAAYL,mBAAYC,KAAgB,8CAAA;AAU9C,IAAMK,eAAeN,mBAAYC,KAAmB,6CAAA;AAOpD,IAAMM,UAAUP,mBAAYC,KAAiB,2CAAA;AAK7C,IAAMO,QAAQR,mBAAYC,KAAkC,yCAAA;AAO5D,IAAMQ,iBAAiBT,mBAAYC,KAAqB,mDAAA;AAMxD,IAAMS,mBAAmBV,mBAAYC,KAC1C,qDAAA;AASK,IAAMU,cAAcX,mBAAYC,KAAoB,gDAAA;AAQpD,IAAMW,mBAAmBZ,mBAAYC,KAC1C,qDAAA;AASK,IAAMY,eAAeb,mBAAYC,KAAmB,iDAAA;AAQpD,IAAMa,iBAAiBd,mBAAYC,KAAqB,mDAAA;AAUxD,IAAMc,eAAe,CAC1BC,mBAEOC,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpC,SAAOE,SAASC,IAAIC,IAAAA;AACtB,CAAA;AAMK,IAAMC,kBAAkB,CAC7BL,gBACAM,OAEOL,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpCE,WAASK,IAAIH,MAAME,GAAGJ,SAASC,IAAIC,IAAAA,CAAAA,CAAAA;AACrC,CAAA;AAMK,IAAMI,gBAAgB,CAC3BR,gBACAS,aAEOR,WAAI,aAAA;AACT,QAAMC,WAAW,OAAOlB,mBAAYmB,IAAIhB,YAAAA;AACxC,QAAMiB,OAAO,OAAOpB,mBAAYmB,IAAIH,cAAAA;AACpC,SAAOE,SAASQ,UAAUN,MAAM,MAAMK,SAASP,SAASC,IAAIC,IAAAA,CAAAA,CAAAA;AAC9D,CAAA;",
6
+ "names": ["Effect", "Null", "Capability$", "make", "PluginManager", "AtomRegistry", "ReactContext", "ReactRoot", "ReactSurface", "Command", "Layer", "ManagedRuntime", "OperationHandler", "UndoMapping", "OperationInvoker", "UndoRegistry", "HistoryTracker", "getAtomValue", "atomCapability", "gen", "registry", "get", "atom", "updateAtomValue", "fn", "set", "subscribeAtom", "callback", "subscribe"]
7
+ }
@@ -28,8 +28,7 @@ var get = (interfaceDef) => Effect.flatMap(Service, (manager) => Effect.try({
28
28
  var getAll = (interfaceDef) => Effect.map(Service, (manager) => manager.getAll(interfaceDef));
29
29
  var waitFor = (interfaceDef) => Effect.flatMap(Service, (manager) => manager.waitFor(interfaceDef));
30
30
  var atom = (interfaceDef) => Effect.map(Service, (manager) => manager.atom(interfaceDef));
31
- var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
32
- var ModuleTag = Symbol.for("@dxos/app-framework/ModuleTag");
31
+ var ModuleTag = /* @__PURE__ */ Symbol.for("@dxos/app-framework/ModuleTag");
33
32
  var make = (identifier) => {
34
33
  return {
35
34
  identifier
@@ -44,7 +43,7 @@ var contributes = (interfaceDef, implementation, deactivate) => {
44
43
  };
45
44
  var lazy = (name, c) => {
46
45
  const lazyFn = (props) => Effect.gen(function* () {
47
- const { default: getCapability } = yield* Effect.tryPromise(() => c());
46
+ const { default: getCapability } = yield* Effect.promise(() => c());
48
47
  const result = yield* getCapability(props);
49
48
  const normalized = result == null ? [] : Array.isArray(result) ? Array.from(result) : [
50
49
  result
@@ -74,4 +73,4 @@ export {
74
73
  makeModule,
75
74
  capability_exports
76
75
  };
77
- //# sourceMappingURL=chunk-6Y7PZV72.mjs.map
76
+ //# sourceMappingURL=chunk-FL2XTEJH.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/core/capability.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom } from '@effect-atom/atom-react';\nimport * as Context from 'effect/Context';\nimport * as Effect from 'effect/Effect';\n\nimport type * as CapabilityManager from './capability-manager';\nimport type * as Plugin from './plugin';\n\n//\n// Capability Service Layer\n//\n\n/**\n * Effect Context.Tag for accessing CapabilityManager via the Effect layer system.\n * This allows capability modules to access the capability manager without having it passed as an argument.\n */\nexport class Service extends Context.Tag('@dxos/app-framework/CapabilityManager')<\n Service,\n CapabilityManager.CapabilityManager\n>() {}\n\n/**\n * Get a single capability from the capability manager.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation.\n * @throws If no capability is found.\n */\n// TODO(wittjosiah): Add custom tagged errors (Data.TaggedError) for app-framework to enable\n// type-safe error handling with Effect. Consider CapabilityNotFoundError, ModuleActivationError, etc.\nexport const get = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) =>\n Effect.try({\n try: () => manager.get(interfaceDef),\n catch: (error) => (error instanceof Error ? error : new Error(String(error))),\n }),\n );\n\n/**\n * Get all capabilities from the capability manager for a given interface.\n * @param interfaceDef The interface definition of the capability.\n * @returns An array of capability implementations.\n */\nexport const getAll = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T[], never, Service> =>\n Effect.map(Service, (manager) => manager.getAll(interfaceDef));\n\n/**\n * Wait for a capability to be available.\n * @param interfaceDef The interface definition of the capability.\n * @returns The capability implementation once available.\n */\nexport const waitFor = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<T, Error, Service> =>\n Effect.flatMap(Service, (manager) => manager.waitFor(interfaceDef));\n\n/**\n * Get the Atom reference to capabilities for reactive access.\n * @param interfaceDef The interface definition of the capability.\n * @returns An Atom containing the array of capability implementations.\n */\nexport const atom = <T>(interfaceDef: InterfaceDef<T>): Effect.Effect<Atom.Atom<T[]>, never, Service> =>\n Effect.map(Service, (manager) => manager.atom(interfaceDef));\n\nconst InterfaceDefTypeId: unique symbol = Symbol.for('InterfaceDefTypeId');\n\n/**\n * Symbol used to tag lazy capability functions with their module ID.\n */\nexport const ModuleTag: unique symbol = Symbol.for('@dxos/app-framework/ModuleTag');\n\n/**\n * The interface definition of a capability.\n */\nexport type InterfaceDef<T> = {\n [InterfaceDefTypeId]: T;\n identifier: string;\n};\n\nexport namespace InterfaceDef {\n export type Implementation<I extends InterfaceDef<any>> = I extends InterfaceDef<infer T> ? T : never;\n}\n\n/**\n * Helper to define the interface of a capability.\n */\nexport const make = <T>(identifier: string) => {\n return { identifier } as InterfaceDef<T>;\n};\n\n/**\n * A unique string identifier with a Typescript type associated with it.\n * When a capability is contributed to the application an implementation of the interface is provided.\n */\nexport type Capability<T> = {\n /**\n * The interface definition of the capability.\n */\n readonly interface: InterfaceDef<T>;\n\n /**\n * The implementation of the capability.\n */\n readonly implementation: T;\n\n /**\n * Called when the capability is deactivated.\n */\n readonly deactivate?: () => Effect.Effect<void, Error>;\n};\n\nexport type Any = Capability<any>;\n\n/**\n * Union type representing all valid return types for a capability module.\n * Supports single capabilities, arrays, and tuples of different capability types.\n */\nexport type ModuleReturn = void | Any | Any[] | readonly Any[] | [Any, ...Any[]] | readonly [Any, ...Any[]];\n\n/**\n * Helper to define the implementation of a capability.\n */\n// TODO(dmaretskyi): Make the return type non-generic so capabilities are non-discernable.\nexport const contributes = <I extends InterfaceDef<any>>(\n interfaceDef: I,\n implementation: Capability<InterfaceDef.Implementation<I>>['implementation'],\n deactivate?: Capability<InterfaceDef.Implementation<I>>['deactivate'],\n): Capability<I> => {\n return {\n interface: interfaceDef,\n implementation,\n deactivate,\n } satisfies Capability<I>;\n};\n\ntype LoadCapability<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | never>;\n}>;\ntype LoadCapabilities<Props, Capabilities extends ModuleReturn = ModuleReturn> = () => Promise<{\n default: (props: Props) => Effect.Effect<Capabilities, Error, Service | Plugin.Service | never>;\n}>;\n\ntype NormalizeReturn<R> = R extends readonly (infer A)[]\n ? A[]\n : R extends (infer A)[]\n ? A[]\n : R extends Any\n ? [R]\n : Any[];\n\nexport type LazyCapability<Props = void, Capabilities extends ModuleReturn = ModuleReturn, E extends Error = Error> = (\n props: Props,\n) => Effect.Effect<NormalizeReturn<Capabilities>, E, Service | Plugin.Service | never>;\n\n/**\n * Helper to define a lazily loaded implementation of a capability.\n * Supports single capabilities, arrays, and tuples of different capability types.\n * @param name The export name (e.g., 'AppGraphBuilder') - used to auto-compute module IDs.\n * @param loader The lazy loader function.\n * @returns A lazy capability function with ModuleTag symbol attached.\n */\nexport const lazy = <T = void, R extends ModuleReturn = ModuleReturn>(\n name: string,\n c: LoadCapability<T, R> | LoadCapabilities<T, R>,\n): LazyCapability<T, R> => {\n const lazyFn: LazyCapability<T, R> = (props: T) =>\n Effect.gen(function* () {\n const { default: getCapability } = yield* Effect.promise(() => c());\n const result = yield* getCapability(props);\n const normalized = result == null ? [] : Array.isArray(result) ? Array.from(result) : [result];\n return normalized as NormalizeReturn<R>;\n });\n\n return Object.assign(lazyFn, { [ModuleTag]: name });\n};\n\n/**\n * Gets the module tag (export name) from a lazy capability function.\n * @param capability The lazy capability function.\n * @returns The module tag if present, undefined otherwise.\n */\n// TODO(wittjosiah): Stricter type for capability.\nexport const getModuleTag = (capability: unknown): string | undefined => {\n return capability && typeof capability === 'function' && ModuleTag in capability\n ? String(capability[ModuleTag])\n : undefined;\n};\n\n/**\n * Helper to define a capability module with explicit typing.\n * Wraps the default export function to provide better type inference and make the pattern explicit.\n *\n * This helper provides explicit typing for the module activation function,\n * making it clear that the function should:\n * - Access CapabilityManager via the Effect layer system (Capability.get, Capability.getAll, etc.)\n * - Return a capability, array of capabilities, or tuple of different capability types (sync or async)\n *\n * Supports returning multiple capabilities of different types as a tuple, which will be normalized\n * to an array at runtime for compatibility with the plugin system.\n *\n * @example\n * ```ts\n * // Module without options - single capability\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * const client = yield* Capability.get(ClientCapabilities.Client);\n * return contributes(Capabilities.SettingsStore, store);\n * })\n * );\n *\n * // Module with multiple capabilities\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* () {\n * return [\n * contributes(Capabilities.SettingsStore, store),\n * contributes(Capabilities.Translations, translations),\n * ];\n * })\n * );\n *\n * // Module with required options (context accessed via layer)\n * export default Capability.makeModule(\n * Effect.fnUntraced(function* (props: { observability: boolean }) {\n * const invoker = yield* Capability.get(Capabilities.OperationInvoker);\n * return contributes(Capabilities.IntentResolver, ...);\n * })\n * );\n * ```\n */\nexport const makeModule = <\n TProps = void,\n TReturn extends ModuleReturn = ModuleReturn,\n E extends Error = Error,\n R extends Service | Plugin.Service | never = Service,\n>(\n fn: (props: TProps) => Effect.Effect<TReturn, E, R>,\n): ((props: TProps) => Effect.Effect<TReturn, E, R>) => fn;\n"],
5
+ "mappings": ";;;;;AAAA;;;;;;;;;;;;;;AAKA,YAAYA,aAAa;AACzB,YAAYC,YAAY;AAajB,IAAMC,UAAN,cAA8BC,YAAI,uCAAA,EAAA,EAAA;AAGpC;AAUE,IAAMC,MAAM,CAAIC,iBACdC,eAAQJ,SAAS,CAACK,YAChBC,WAAI;EACTA,KAAK,MAAMD,QAAQH,IAAIC,YAAAA;EACvBI,OAAO,CAACC,UAAWA,iBAAiBC,QAAQD,QAAQ,IAAIC,MAAMC,OAAOF,KAAAA,CAAAA;AACvE,CAAA,CAAA;AAQG,IAAMG,SAAS,CAAIR,iBACjBS,WAAIZ,SAAS,CAACK,YAAYA,QAAQM,OAAOR,YAAAA,CAAAA;AAO3C,IAAMU,UAAU,CAAIV,iBAClBC,eAAQJ,SAAS,CAACK,YAAYA,QAAQQ,QAAQV,YAAAA,CAAAA;AAOhD,IAAMW,OAAO,CAAIX,iBACfS,WAAIZ,SAAS,CAACK,YAAYA,QAAQS,KAAKX,YAAAA,CAAAA;AAOzC,IAAMY,YAA2BC,uBAAOC,IAAI,+BAAA;AAiB5C,IAAMC,OAAO,CAAIC,eAAAA;AACtB,SAAO;IAAEA;EAAW;AACtB;AAmCO,IAAMC,cAAc,CACzBC,cACAC,gBACAC,eAAAA;AAEA,SAAO;IACLC,WAAWH;IACXC;IACAC;EACF;AACF;AA4BO,IAAME,OAAO,CAClBC,MACAC,MAAAA;AAEA,QAAMC,SAA+B,CAACC,UAC7BC,WAAI,aAAA;AACT,UAAM,EAAEC,SAASC,cAAa,IAAK,OAAcC,eAAQ,MAAMN,EAAAA,CAAAA;AAC/D,UAAMO,SAAS,OAAOF,cAAcH,KAAAA;AACpC,UAAMM,aAAaD,UAAU,OAAO,CAAA,IAAKE,MAAMC,QAAQH,MAAAA,IAAUE,MAAME,KAAKJ,MAAAA,IAAU;MAACA;;AACvF,WAAOC;EACT,CAAA;AAEF,SAAOI,OAAOC,OAAOZ,QAAQ;IAAE,CAACb,SAAAA,GAAYW;EAAK,CAAA;AACnD;AAQO,IAAMe,eAAe,CAACC,eAAAA;AAC3B,SAAOA,cAAc,OAAOA,eAAe,cAAc3B,aAAa2B,aAClEC,OAAOD,WAAW3B,SAAAA,CAAU,IAC5B6B;AACN;AA2CO,IAAMC,aAAa,CAMxBC,OACsDA;",
6
+ "names": ["Context", "Effect", "Service", "Tag", "get", "interfaceDef", "flatMap", "manager", "try", "catch", "error", "Error", "String", "getAll", "map", "waitFor", "atom", "ModuleTag", "Symbol", "for", "make", "identifier", "contributes", "interfaceDef", "implementation", "deactivate", "interface", "lazy", "name", "c", "lazyFn", "props", "gen", "default", "getCapability", "promise", "result", "normalized", "Array", "isArray", "from", "Object", "assign", "getModuleTag", "capability", "String", "undefined", "makeModule", "fn"]
7
+ }
@@ -0,0 +1,42 @@
1
+ import {
2
+ capability_exports
3
+ } from "./chunk-FL2XTEJH.mjs";
4
+
5
+ // src/common/translations.ts
6
+ import * as Schema from "effect/Schema";
7
+ var Label = Schema.Union(Schema.String, Schema.mutable(Schema.Tuple(Schema.String, Schema.mutable(Schema.Struct({
8
+ ns: Schema.String,
9
+ count: Schema.optional(Schema.Number),
10
+ defaultValue: Schema.optional(Schema.String)
11
+ })))));
12
+
13
+ // src/common/operations.ts
14
+ import * as Schema2 from "effect/Schema";
15
+ import { Operation } from "@dxos/operation";
16
+ var UNDO_NAMESPACE = "org.dxos.app-framework.undo";
17
+ (function(UndoOperation2) {
18
+ UndoOperation2.ShowUndo = Operation.make({
19
+ meta: {
20
+ key: `${UNDO_NAMESPACE}.operation.show-undo`,
21
+ name: "Show Undo",
22
+ description: "Show an undo toast notification."
23
+ },
24
+ executionMode: "sync",
25
+ services: [
26
+ capability_exports.Service
27
+ ],
28
+ input: Schema2.Struct({
29
+ message: Schema2.optional(Label.annotations({
30
+ description: "The message to display in the undo toast."
31
+ }))
32
+ }),
33
+ output: Schema2.Void
34
+ });
35
+ })(UndoOperation || (UndoOperation = {}));
36
+ var UndoOperation;
37
+
38
+ export {
39
+ Label,
40
+ UndoOperation
41
+ };
42
+ //# sourceMappingURL=chunk-H7OMDDGW.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/common/translations.ts", "../../../src/common/operations.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\n/**\n * A Label represents translatable text - either a simple string or a tuple of [key, options].\n */\nexport const Label = Schema.Union(\n Schema.String,\n Schema.mutable(\n Schema.Tuple(\n Schema.String,\n Schema.mutable(\n Schema.Struct({\n ns: Schema.String,\n count: Schema.optional(Schema.Number),\n defaultValue: Schema.optional(Schema.String),\n }),\n ),\n ),\n ),\n);\nexport type Label = Schema.Schema.Type<typeof Label>;\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Schema from 'effect/Schema';\n\nimport { Operation } from '@dxos/operation';\n\nimport { Capability } from '../core';\n\nimport { Label } from './translations';\n\nconst UNDO_NAMESPACE = 'org.dxos.app-framework.undo';\n\n/**\n * Operations related to undo/history functionality.\n */\nexport namespace UndoOperation {\n /**\n * Show an undo toast notification.\n * Fired by HistoryTracker when an undoable operation is tracked.\n */\n export const ShowUndo = Operation.make({\n meta: {\n key: `${UNDO_NAMESPACE}.operation.show-undo`,\n name: 'Show Undo',\n description: 'Show an undo toast notification.',\n },\n executionMode: 'sync',\n services: [Capability.Service],\n input: Schema.Struct({\n message: Schema.optional(Label.annotations({ description: 'The message to display in the undo toast.' })),\n }),\n output: Schema.Void,\n });\n}\n"],
5
+ "mappings": ";;;;;AAIA,YAAYA,YAAY;AAKjB,IAAMC,QAAeC,aACnBC,eACAC,eACEC,aACEF,eACAC,eACEE,cAAO;EACZC,IAAWJ;EACXK,OAAcC,gBAAgBC,aAAM;EACpCC,cAAqBF,gBAAgBN,aAAM;AAC7C,CAAA,CAAA,CAAA,CAAA,CAAA;;;ACfR,YAAYS,aAAY;AAExB,SAASC,iBAAiB;AAM1B,IAAMC,iBAAiB;UAKNC,gBAAAA;iBAKFC,WAAWC,UAAUC,KAAK;IACrCC,MAAM;MACJC,KAAK,GAAGN,cAAAA;MACRO,MAAM;MACNC,aAAa;IACf;IACAC,eAAe;IACfC,UAAU;MAACC,mBAAWC;;IACtBC,OAAcC,eAAO;MACnBC,SAAgBC,iBAASC,MAAMC,YAAY;QAAEV,aAAa;MAA4C,CAAA,CAAA;IACxG,CAAA;IACAW,QAAeC;EACjB,CAAA;AACF,GAlBiBnB,kBAAAA,gBAAAA,CAAAA,EAAAA;;",
6
+ "names": ["Schema", "Label", "Union", "String", "mutable", "Tuple", "Struct", "ns", "count", "optional", "Number", "defaultValue", "Schema", "Operation", "UNDO_NAMESPACE", "UndoOperation", "ShowUndo", "Operation", "make", "meta", "key", "name", "description", "executionMode", "services", "Capability", "Service", "input", "Struct", "message", "optional", "Label", "annotations", "output", "Void"]
7
+ }
@@ -0,0 +1,157 @@
1
+ import {
2
+ isPlugin
3
+ } from "./chunk-P2E7VMRF.mjs";
4
+ import {
5
+ __export
6
+ } from "./chunk-J5LGTIGS.mjs";
7
+
8
+ // src/core/url-loader.ts
9
+ var url_loader_exports = {};
10
+ __export(url_loader_exports, {
11
+ make: () => make,
12
+ preload: () => preload
13
+ });
14
+ import * as Effect from "effect/Effect";
15
+ import { log } from "@dxos/log";
16
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/url-loader.ts";
17
+ var DEFAULT_KEY = "org.dxos.composer.remote-plugins";
18
+ var defaultStorage = () => ({
19
+ get: (key) => localStorage.getItem(key),
20
+ set: (key, value) => localStorage.setItem(key, value)
21
+ });
22
+ var getPersistedRemotePlugins = (storage, key) => {
23
+ try {
24
+ const parsed = JSON.parse(storage.get(key) ?? "[]");
25
+ if (!Array.isArray(parsed)) {
26
+ return [];
27
+ }
28
+ return parsed.filter((entry) => typeof entry === "object" && entry !== null && typeof entry.id === "string" && typeof entry.url === "string");
29
+ } catch {
30
+ return [];
31
+ }
32
+ };
33
+ var persistRemotePlugin = (storage, key, entry) => {
34
+ try {
35
+ const entries = getPersistedRemotePlugins(storage, key).filter((existing) => existing.id !== entry.id);
36
+ entries.push(entry);
37
+ storage.set(key, JSON.stringify(entries));
38
+ } catch (error) {
39
+ log.warn("failed to persist remote plugin entry", {
40
+ entry,
41
+ error
42
+ }, {
43
+ F: __dxlog_file,
44
+ L: 57,
45
+ S: void 0,
46
+ C: (f, a) => f(...a)
47
+ });
48
+ }
49
+ };
50
+ var isUrl = (locator) => {
51
+ try {
52
+ const url = new URL(locator);
53
+ return url.protocol === "http:" || url.protocol === "https:";
54
+ } catch {
55
+ return false;
56
+ }
57
+ };
58
+ var normalizePluginExport = (mod) => {
59
+ const exported = mod.default;
60
+ if (isPlugin(exported)) {
61
+ return exported;
62
+ }
63
+ if (typeof exported === "function") {
64
+ const result = exported();
65
+ if (isPlugin(result)) {
66
+ return result;
67
+ }
68
+ }
69
+ throw new Error("Remote module default export is not a Plugin or a zero-arg plugin factory.");
70
+ };
71
+ var loadRemotePlugin = async (url) => {
72
+ log.info("loading remote plugin", {
73
+ url
74
+ }, {
75
+ F: __dxlog_file,
76
+ L: 85,
77
+ S: void 0,
78
+ C: (f, a) => f(...a)
79
+ });
80
+ const mod = await import(
81
+ /* @vite-ignore */
82
+ url
83
+ );
84
+ const plugin = normalizePluginExport(mod);
85
+ if (!plugin.meta.id || !plugin.meta.name) {
86
+ throw new Error(`Remote plugin at ${url} is missing required meta.id or meta.name.`);
87
+ }
88
+ return plugin;
89
+ };
90
+ var preload = async (options = {}) => {
91
+ const storage = options.storage ?? defaultStorage();
92
+ const key = options.key ?? DEFAULT_KEY;
93
+ const entries = getPersistedRemotePlugins(storage, key);
94
+ if (entries.length === 0) {
95
+ return [];
96
+ }
97
+ log.info("preloading remote plugins", {
98
+ count: entries.length
99
+ }, {
100
+ F: __dxlog_file,
101
+ L: 105,
102
+ S: void 0,
103
+ C: (f, a) => f(...a)
104
+ });
105
+ const results = await Promise.allSettled(entries.map((entry) => loadRemotePlugin(entry.url)));
106
+ const plugins = [];
107
+ for (let index = 0; index < results.length; index++) {
108
+ const result = results[index];
109
+ if (result.status === "fulfilled") {
110
+ plugins.push(result.value);
111
+ } else {
112
+ log.warn("failed to preload remote plugin", {
113
+ entry: entries[index],
114
+ error: result.reason
115
+ }, {
116
+ F: __dxlog_file,
117
+ L: 113,
118
+ S: void 0,
119
+ C: (f, a) => f(...a)
120
+ });
121
+ }
122
+ }
123
+ return plugins;
124
+ };
125
+ var make = (builtinPlugins, options = {}) => {
126
+ const storage = options.storage ?? defaultStorage();
127
+ const key = options.key ?? DEFAULT_KEY;
128
+ return (locator) => Effect.gen(function* () {
129
+ const builtin = builtinPlugins.find((plugin2) => plugin2.meta.id === locator);
130
+ if (builtin) {
131
+ return builtin;
132
+ }
133
+ if (!isUrl(locator)) {
134
+ return yield* Effect.fail(new Error(`Plugin not found and locator is not a URL: ${locator}`));
135
+ }
136
+ const plugin = yield* Effect.tryPromise({
137
+ try: () => loadRemotePlugin(locator),
138
+ catch: (error) => new Error(`Failed to load remote plugin from ${locator}: ${error}`)
139
+ });
140
+ const duplicate = builtinPlugins.find((existing) => existing.meta.id === plugin.meta.id);
141
+ if (duplicate) {
142
+ return yield* Effect.fail(new Error(`Remote plugin ${plugin.meta.id} conflicts with built-in plugin of the same id.`));
143
+ }
144
+ persistRemotePlugin(storage, key, {
145
+ id: plugin.meta.id,
146
+ url: locator
147
+ });
148
+ return plugin;
149
+ });
150
+ };
151
+
152
+ export {
153
+ preload,
154
+ make,
155
+ url_loader_exports
156
+ };
157
+ //# sourceMappingURL=chunk-HDQXX5DC.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/core/url-loader.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2026 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { log } from '@dxos/log';\n\nimport * as Plugin from './plugin';\n\nconst DEFAULT_KEY = 'org.dxos.composer.remote-plugins';\n\n/**\n * Abstraction over key-value storage (defaults to localStorage).\n */\nexport type Storage = {\n get(key: string): string | null;\n set(key: string, value: string): void;\n};\n\n/**\n * Options for configuring the URL loader.\n */\nexport type Options = {\n storage?: Storage;\n key?: string;\n};\n\ntype RemotePluginEntry = { id: string; url: string };\n\nconst defaultStorage = (): Storage => ({\n get: (key) => localStorage.getItem(key),\n set: (key, value) => localStorage.setItem(key, value),\n});\n\nconst getPersistedRemotePlugins = (storage: Storage, key: string): RemotePluginEntry[] => {\n try {\n const parsed: unknown = JSON.parse(storage.get(key) ?? '[]');\n if (!Array.isArray(parsed)) {\n return [];\n }\n return parsed.filter(\n (entry): entry is RemotePluginEntry =>\n typeof entry === 'object' && entry !== null && typeof entry.id === 'string' && typeof entry.url === 'string',\n );\n } catch {\n return [];\n }\n};\n\nconst persistRemotePlugin = (storage: Storage, key: string, entry: RemotePluginEntry): void => {\n try {\n const entries = getPersistedRemotePlugins(storage, key).filter((existing) => existing.id !== entry.id);\n entries.push(entry);\n storage.set(key, JSON.stringify(entries));\n } catch (error) {\n log.warn('failed to persist remote plugin entry', { entry, error });\n }\n};\n\nconst isUrl = (locator: string): boolean => {\n try {\n const url = new URL(locator);\n return url.protocol === 'http:' || url.protocol === 'https:';\n } catch {\n return false;\n }\n};\n\nconst normalizePluginExport = (mod: Record<string, unknown>): Plugin.Plugin => {\n const exported = mod.default;\n if (Plugin.isPlugin(exported)) {\n return exported;\n }\n if (typeof exported === 'function') {\n const result = (exported as () => unknown)();\n if (Plugin.isPlugin(result)) {\n return result;\n }\n }\n throw new Error('Remote module default export is not a Plugin or a zero-arg plugin factory.');\n};\n\nconst loadRemotePlugin = async (url: string): Promise<Plugin.Plugin> => {\n log.info('loading remote plugin', { url });\n const mod = await import(/* @vite-ignore */ url);\n const plugin = normalizePluginExport(mod);\n if (!plugin.meta.id || !plugin.meta.name) {\n throw new Error(`Remote plugin at ${url} is missing required meta.id or meta.name.`);\n }\n return plugin;\n};\n\n/**\n * Preloads previously persisted remote plugins from storage.\n */\nexport const preload = async (options: Options = {}): Promise<Plugin.Plugin[]> => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n\n const entries = getPersistedRemotePlugins(storage, key);\n if (entries.length === 0) {\n return [];\n }\n log.info('preloading remote plugins', { count: entries.length });\n const results = await Promise.allSettled(entries.map((entry) => loadRemotePlugin(entry.url)));\n const plugins: Plugin.Plugin[] = [];\n for (let index = 0; index < results.length; index++) {\n const result = results[index];\n if (result.status === 'fulfilled') {\n plugins.push(result.value);\n } else {\n log.warn('failed to preload remote plugin', { entry: entries[index], error: result.reason });\n }\n }\n return plugins;\n};\n\n/**\n * Creates a plugin loader that resolves built-in plugins by ID or loads remote plugins from URLs.\n */\nexport const make = (builtinPlugins: Plugin.Plugin[], options: Options = {}) => {\n const storage = options.storage ?? defaultStorage();\n const key = options.key ?? DEFAULT_KEY;\n\n return (locator: string): Effect.Effect<Plugin.Plugin, Error> =>\n Effect.gen(function* () {\n const builtin = builtinPlugins.find((plugin) => plugin.meta.id === locator);\n if (builtin) {\n return builtin;\n }\n if (!isUrl(locator)) {\n return yield* Effect.fail(new Error(`Plugin not found and locator is not a URL: ${locator}`));\n }\n const plugin = yield* Effect.tryPromise({\n try: () => loadRemotePlugin(locator),\n catch: (error) => new Error(`Failed to load remote plugin from ${locator}: ${error}`),\n });\n const duplicate = builtinPlugins.find((existing) => existing.meta.id === plugin.meta.id);\n if (duplicate) {\n return yield* Effect.fail(\n new Error(`Remote plugin ${plugin.meta.id} conflicts with built-in plugin of the same id.`),\n );\n }\n persistRemotePlugin(storage, key, { id: plugin.meta.id, url: locator });\n return plugin;\n });\n};\n"],
5
+ "mappings": ";;;;;;;;AAAA;;;;;AAIA,YAAYA,YAAY;AAExB,SAASC,WAAW;;AAIpB,IAAMC,cAAc;AAoBpB,IAAMC,iBAAiB,OAAgB;EACrCC,KAAK,CAACC,QAAQC,aAAaC,QAAQF,GAAAA;EACnCG,KAAK,CAACH,KAAKI,UAAUH,aAAaI,QAAQL,KAAKI,KAAAA;AACjD;AAEA,IAAME,4BAA4B,CAACC,SAAkBP,QAAAA;AACnD,MAAI;AACF,UAAMQ,SAAkBC,KAAKC,MAAMH,QAAQR,IAAIC,GAAAA,KAAQ,IAAA;AACvD,QAAI,CAACW,MAAMC,QAAQJ,MAAAA,GAAS;AAC1B,aAAO,CAAA;IACT;AACA,WAAOA,OAAOK,OACZ,CAACC,UACC,OAAOA,UAAU,YAAYA,UAAU,QAAQ,OAAOA,MAAMC,OAAO,YAAY,OAAOD,MAAME,QAAQ,QAAA;EAE1G,QAAQ;AACN,WAAO,CAAA;EACT;AACF;AAEA,IAAMC,sBAAsB,CAACV,SAAkBP,KAAac,UAAAA;AAC1D,MAAI;AACF,UAAMI,UAAUZ,0BAA0BC,SAASP,GAAAA,EAAKa,OAAO,CAACM,aAAaA,SAASJ,OAAOD,MAAMC,EAAE;AACrGG,YAAQE,KAAKN,KAAAA;AACbP,YAAQJ,IAAIH,KAAKS,KAAKY,UAAUH,OAAAA,CAAAA;EAClC,SAASI,OAAO;AACdC,QAAIC,KAAK,yCAAyC;MAAEV;MAAOQ;IAAM,GAAA;;;;;;EACnE;AACF;AAEA,IAAMG,QAAQ,CAACC,YAAAA;AACb,MAAI;AACF,UAAMV,MAAM,IAAIW,IAAID,OAAAA;AACpB,WAAOV,IAAIY,aAAa,WAAWZ,IAAIY,aAAa;EACtD,QAAQ;AACN,WAAO;EACT;AACF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,OAAOI,QAAQgC,KAAAA;QAAQ5B,OAAOY,OAAOkB;MAAO,GAAA;;;;;;IAC5F;EACF;AACA,SAAOH;AACT;AAKO,IAAMI,OAAO,CAACC,gBAAiCZ,UAAmB,CAAC,MAAC;AACzE,QAAMnC,UAAUmC,QAAQnC,WAAWT,eAAAA;AACnC,QAAME,MAAM0C,QAAQ1C,OAAOH;AAE3B,SAAO,CAAC6B,YACC6B,WAAI,aAAA;AACT,UAAMC,UAAUF,eAAeG,KAAK,CAACnB,YAAWA,QAAOC,KAAKxB,OAAOW,OAAAA;AACnE,QAAI8B,SAAS;AACX,aAAOA;IACT;AACA,QAAI,CAAC/B,MAAMC,OAAAA,GAAU;AACnB,aAAO,OAAcgC,YAAK,IAAIvB,MAAM,8CAA8CT,OAAAA,EAAS,CAAA;IAC7F;AACA,UAAMY,SAAS,OAAcqB,kBAAW;MACtCC,KAAK,MAAMxB,iBAAiBV,OAAAA;MAC5BmC,OAAO,CAACvC,UAAU,IAAIa,MAAM,qCAAqCT,OAAAA,KAAYJ,KAAAA,EAAO;IACtF,CAAA;AACA,UAAMwC,YAAYR,eAAeG,KAAK,CAACtC,aAAaA,SAASoB,KAAKxB,OAAOuB,OAAOC,KAAKxB,EAAE;AACvF,QAAI+C,WAAW;AACb,aAAO,OAAcJ,YACnB,IAAIvB,MAAM,iBAAiBG,OAAOC,KAAKxB,EAAE,iDAAiD,CAAA;IAE9F;AACAE,wBAAoBV,SAASP,KAAK;MAAEe,IAAIuB,OAAOC,KAAKxB;MAAIC,KAAKU;IAAQ,CAAA;AACrE,WAAOY;EACT,CAAA;AACJ;",
6
+ "names": ["Effect", "log", "DEFAULT_KEY", "defaultStorage", "get", "key", "localStorage", "getItem", "set", "value", "setItem", "getPersistedRemotePlugins", "storage", "parsed", "JSON", "parse", "Array", "isArray", "filter", "entry", "id", "url", "persistRemotePlugin", "entries", "existing", "push", "stringify", "error", "log", "warn", "isUrl", "locator", "URL", "protocol", "normalizePluginExport", "mod", "exported", "default", "isPlugin", "result", "Error", "loadRemotePlugin", "info", "plugin", "meta", "name", "preload", "options", "length", "count", "results", "Promise", "allSettled", "map", "plugins", "index", "status", "reason", "make", "builtinPlugins", "gen", "builtin", "find", "fail", "tryPromise", "try", "catch", "duplicate"]
7
+ }
@@ -0,0 +1,34 @@
1
+ import {
2
+ activation_event_exports
3
+ } from "./chunk-QSXYHXCE.mjs";
4
+ import {
5
+ __export
6
+ } from "./chunk-J5LGTIGS.mjs";
7
+
8
+ // src/common/activation-events.ts
9
+ var activation_events_exports = {};
10
+ __export(activation_events_exports, {
11
+ ManagedRuntimeReady: () => ManagedRuntimeReady,
12
+ OperationInvokerReady: () => OperationInvokerReady,
13
+ SetupLayer: () => SetupLayer,
14
+ SetupOperationHandler: () => SetupOperationHandler,
15
+ SetupReactSurface: () => SetupReactSurface,
16
+ Startup: () => Startup
17
+ });
18
+ var Startup = activation_event_exports.make("org.dxos.app-framework.event.startup");
19
+ var SetupReactSurface = activation_event_exports.make("org.dxos.app-framework.event.setup-react-surface");
20
+ var SetupOperationHandler = activation_event_exports.make("org.dxos.app-framework.event.setup-operation-handler");
21
+ var SetupLayer = activation_event_exports.make("org.dxos.app-framework.event.setup-layer");
22
+ var OperationInvokerReady = activation_event_exports.make("org.dxos.app-framework.event.operation-invoker-ready");
23
+ var ManagedRuntimeReady = activation_event_exports.make("org.dxos.app-framework.event.managed-runtime-ready");
24
+
25
+ export {
26
+ Startup,
27
+ SetupReactSurface,
28
+ SetupOperationHandler,
29
+ SetupLayer,
30
+ OperationInvokerReady,
31
+ ManagedRuntimeReady,
32
+ activation_events_exports
33
+ };
34
+ //# sourceMappingURL=chunk-I34GF4NG.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/common/activation-events.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { ActivationEvent as ActivationEvent$ } from '../core';\n\n/**\n * Fired when the app is started.\n */\nexport const Startup = ActivationEvent$.make('org.dxos.app-framework.event.startup');\n\n//\n// Dependent Events\n//\n\n/**\n * Fired to load any newly available surfaces.\n */\nexport const SetupReactSurface = ActivationEvent$.make('org.dxos.app-framework.event.setup-react-surface');\n\n/**\n * Fired before the operation invoker is activated.\n */\nexport const SetupOperationHandler = ActivationEvent$.make('org.dxos.app-framework.event.setup-operation-handler');\n\n/**\n * Fired before the managed runtime is created.\n * Plugins should contribute their Layer capabilities before this event.\n */\nexport const SetupLayer = ActivationEvent$.make('org.dxos.app-framework.event.setup-layer');\n\n//\n// Triggered Events\n//\n\n/**\n * Fired after the operation invoker is ready.\n */\nexport const OperationInvokerReady = ActivationEvent$.make('org.dxos.app-framework.event.operation-invoker-ready');\n\n/**\n * Fired after the managed runtime is ready.\n */\nexport const ManagedRuntimeReady = ActivationEvent$.make('org.dxos.app-framework.event.managed-runtime-ready');\n"],
5
+ "mappings": ";;;;;;;;AAAA;;;;;;;;;AASO,IAAMA,UAAUC,yBAAiBC,KAAK,sCAAA;AAStC,IAAMC,oBAAoBF,yBAAiBC,KAAK,kDAAA;AAKhD,IAAME,wBAAwBH,yBAAiBC,KAAK,sDAAA;AAMpD,IAAMG,aAAaJ,yBAAiBC,KAAK,0CAAA;AASzC,IAAMI,wBAAwBL,yBAAiBC,KAAK,sDAAA;AAKpD,IAAMK,sBAAsBN,yBAAiBC,KAAK,oDAAA;",
6
+ "names": ["Startup", "ActivationEvent$", "make", "SetupReactSurface", "SetupOperationHandler", "SetupLayer", "OperationInvokerReady", "ManagedRuntimeReady"]
7
+ }