@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
@@ -2,13 +2,13 @@ import {
2
2
  eventKey,
3
3
  getEvents,
4
4
  isAllOf
5
- } from "./chunk-PKQT6C53.mjs";
5
+ } from "./chunk-QSXYHXCE.mjs";
6
6
  import {
7
7
  Service as Service2
8
- } from "./chunk-TCLLRCS3.mjs";
8
+ } from "./chunk-P2E7VMRF.mjs";
9
9
  import {
10
10
  Service
11
- } from "./chunk-6Y7PZV72.mjs";
11
+ } from "./chunk-FL2XTEJH.mjs";
12
12
  import {
13
13
  __export
14
14
  } from "./chunk-J5LGTIGS.mjs";
@@ -32,6 +32,7 @@ import * as HashSet from "effect/HashSet";
32
32
  import * as PubSub from "effect/PubSub";
33
33
  import * as Ref from "effect/Ref";
34
34
  import { runAndForwardErrors } from "@dxos/effect";
35
+ import { Performance } from "@dxos/effect";
35
36
  import { log as log2 } from "@dxos/log";
36
37
 
37
38
  // src/core/capability-manager.ts
@@ -51,14 +52,14 @@ var CapabilityManagerImpl = class {
51
52
  return Atom.make([]).pipe(Atom.keepAlive);
52
53
  });
53
54
  _capabilities = Atom.family((id) => {
54
- return Atom.make((get) => {
55
- const current = get(this._capabilityEntries(id));
55
+ return Atom.make((get2) => {
56
+ const current = get2(this._capabilityEntries(id));
56
57
  return current.map((c) => c.implementation);
57
- });
58
+ }).pipe(Atom.keepAlive);
58
59
  });
59
60
  _capability = Atom.family((id) => {
60
- return Atom.make((get) => {
61
- const current = get(this._capabilities(id));
61
+ return Atom.make((get2) => {
62
+ const current = get2(this._capabilities(id));
62
63
  invariant(current.length > 0, `No capability found for ${id}`, {
63
64
  F: __dxlog_file,
64
65
  L: 84,
@@ -177,7 +178,7 @@ var make2 = (options) => new CapabilityManagerImpl(options);
177
178
 
178
179
  // src/core/plugin-manager.ts
179
180
  var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/plugin-manager.ts";
180
- var ManagerTypeId = Symbol.for("@dxos/app-framework/Manager");
181
+ var ManagerTypeId = /* @__PURE__ */ Symbol.for("@dxos/app-framework/Manager");
181
182
  var isManager = (value) => {
182
183
  return typeof value === "object" && value !== null && ManagerTypeId in value;
183
184
  };
@@ -199,6 +200,9 @@ var ManagerImpl = class {
199
200
  _moduleSemaphores = /* @__PURE__ */ new Map();
200
201
  _activatingEvents = Effect2.runSync(Ref.make([]));
201
202
  _activatingModules = Effect2.runSync(Ref.make([]));
203
+ _inFlightFibers = Effect2.runSync(Ref.make([]));
204
+ _shutdownSemaphore = Effect2.runSync(Effect2.makeSemaphore(1));
205
+ _shuttingDown = Effect2.runSync(Ref.make(false));
202
206
  constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
203
207
  this.registry = registry ?? Registry.make();
204
208
  this.capabilities = make2({
@@ -285,13 +289,13 @@ var ManagerImpl = class {
285
289
  id
286
290
  }, {
287
291
  F: __dxlog_file2,
288
- L: 210,
292
+ L: 227,
289
293
  S: this,
290
294
  C: (f, a) => f(...a)
291
295
  });
292
296
  const plugin = yield* this._pluginLoader(id);
293
297
  this._addPlugin(plugin);
294
- return yield* this.enable(id);
298
+ return yield* this.enable(plugin.meta.id);
295
299
  });
296
300
  }
297
301
  /**
@@ -304,7 +308,7 @@ var ManagerImpl = class {
304
308
  id
305
309
  }, {
306
310
  F: __dxlog_file2,
307
- L: 223,
311
+ L: 240,
308
312
  S: this,
309
313
  C: (f, a) => f(...a)
310
314
  });
@@ -326,7 +330,7 @@ var ManagerImpl = class {
326
330
  ]
327
331
  }, {
328
332
  F: __dxlog_file2,
329
- L: 236,
333
+ L: 253,
330
334
  S: this,
331
335
  C: (f, a) => f(...a)
332
336
  });
@@ -345,7 +349,7 @@ var ManagerImpl = class {
345
349
  id
346
350
  }, {
347
351
  F: __dxlog_file2,
348
- L: 251,
352
+ L: 268,
349
353
  S: this,
350
354
  C: (f, a) => f(...a)
351
355
  });
@@ -366,7 +370,7 @@ var ManagerImpl = class {
366
370
  id
367
371
  }, {
368
372
  F: __dxlog_file2,
369
- L: 267,
373
+ L: 284,
370
374
  S: this,
371
375
  C: (f, a) => f(...a)
372
376
  });
@@ -396,136 +400,35 @@ var ManagerImpl = class {
396
400
  activate(event, params) {
397
401
  const key = typeof event === "string" ? event : eventKey(event);
398
402
  return Effect2.gen(this, function* () {
399
- log2("activating", {
400
- key,
401
- ...params
402
- }, {
403
- F: __dxlog_file2,
404
- L: 302,
405
- S: this,
406
- C: (f, a) => f(...a)
407
- });
408
- yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
409
- const pendingIndex = this._get(this._pendingResetAtom).findIndex((event2) => event2 === key);
410
- if (pendingIndex !== -1) {
411
- this._update(this._pendingResetAtom, (pending) => pending.filter((event2) => event2 !== key));
412
- }
413
- const activatingEvents = yield* this._activatingEvents;
414
- const activatingModules = yield* this._activatingModules;
415
- const modules = this._getInactiveModulesByEvent(key).filter((module) => {
416
- const allOf = isAllOf(module.activatesOn);
417
- if (!allOf) {
418
- return true;
419
- }
420
- const events = getEvents(module.activatesOn).filter((event2) => eventKey(event2) !== key);
421
- return events.every((event2) => this._get(this._eventsFiredAtom).includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
422
- });
423
- yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
424
- if (modules.length === 0) {
425
- log2("no modules to activate", {
426
- key
403
+ if (yield* this._isShuttingDown()) {
404
+ log2("skipping activation during shutdown", {
405
+ key,
406
+ ...params
427
407
  }, {
428
408
  F: __dxlog_file2,
429
- L: 337,
409
+ L: 320,
430
410
  S: this,
431
411
  C: (f, a) => f(...a)
432
412
  });
433
- if (!this._get(this._eventsFiredAtom).includes(key)) {
434
- this._update(this._eventsFiredAtom, (events) => [
435
- ...events,
436
- key
437
- ]);
438
- }
439
413
  return false;
440
414
  }
441
- log2("activating modules", {
442
- key,
443
- modules: modules.map((module) => module.id)
444
- }, {
445
- F: __dxlog_file2,
446
- L: 344,
447
- S: this,
448
- C: (f, a) => f(...a)
449
- });
450
- yield* PubSub.publish(this.activation, {
451
- event: key,
452
- state: "activating"
453
- });
454
- const beforeEvents = Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))));
455
- yield* Function.pipe(beforeEvents, Array.map((event2) => this.activate(event2, {
456
- before: key
457
- })), Effect2.allWith({
458
- concurrency: "unbounded"
459
- }), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn("activatesBefore is taking a long time", {
460
- event: key,
461
- beforeEvents: beforeEvents.map(eventKey)
462
- }, {
463
- F: __dxlog_file2,
464
- L: 363,
465
- S: this,
466
- C: (f, a) => f(...a)
467
- }))))));
468
- const getCapabilities = yield* Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
469
- concurrency: "unbounded"
470
- }), Effect2.catchAll((error) => {
471
- return Effect2.gen(this, function* () {
472
- yield* PubSub.publish(this.activation, {
473
- event: key,
474
- state: "error",
475
- error
476
- });
477
- return yield* Effect2.fail(error);
478
- });
479
- }));
480
- yield* Function.pipe(
481
- modules,
482
- Array.zip(getCapabilities),
483
- Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
484
- Effect2.all
485
- );
486
- const afterEvents = Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))));
487
- yield* Function.pipe(afterEvents, Array.map((event2) => this.activate(event2, {
488
- after: key
489
- })), Effect2.allWith({
490
- concurrency: "unbounded"
491
- }), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn("activatesAfter is taking a long time", {
492
- event: key,
493
- afterEvents: afterEvents.map(eventKey)
494
- }, {
495
- F: __dxlog_file2,
496
- L: 412,
497
- S: this,
498
- C: (f, a) => f(...a)
499
- }))))));
500
- yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
501
- yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
502
- if (!this._get(this._eventsFiredAtom).includes(key)) {
503
- this._update(this._eventsFiredAtom, (events) => [
504
- ...events,
505
- key
506
- ]);
507
- }
508
- yield* PubSub.publish(this.activation, {
509
- event: key,
510
- state: "activated"
511
- });
512
- log2("activated", {
513
- key
415
+ return yield* Effect2.withFiberRuntime((fiber) => this._activateEvent(key, params, fiber).pipe(together(Effect2.sleep(Duration.seconds(15)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn("event activation is taking a long time", {
416
+ event: key
514
417
  }, {
515
418
  F: __dxlog_file2,
516
- L: 432,
419
+ L: 328,
517
420
  S: this,
518
421
  C: (f, a) => f(...a)
519
- });
520
- return true;
521
- }).pipe(together(Effect2.sleep(Duration.seconds(15)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn("event activation is taking a long time", {
522
- event: key
523
- }, {
524
- F: __dxlog_file2,
525
- L: 438,
526
- S: this,
527
- C: (f, a) => f(...a)
528
- }))))));
422
+ }))))), Performance.addTrackEntry({
423
+ name: typeof event === "string" ? event : eventKey(event),
424
+ devtools: {
425
+ dataType: "track-entry",
426
+ track: "Event Activation",
427
+ trackGroup: "Composer",
428
+ color: "primary"
429
+ }
430
+ })));
431
+ });
529
432
  }
530
433
  /**
531
434
  * Deactivates all of the modules for a plugin.
@@ -557,7 +460,7 @@ var ManagerImpl = class {
557
460
  key
558
461
  }, {
559
462
  F: __dxlog_file2,
560
- L: 473,
463
+ L: 374,
561
464
  S: this,
562
465
  C: (f, a) => f(...a)
563
466
  });
@@ -572,6 +475,41 @@ var ManagerImpl = class {
572
475
  }
573
476
  });
574
477
  }
478
+ shutdown() {
479
+ return this._shutdownSemaphore.withPermits(1)(Effect2.gen(this, function* () {
480
+ yield* Ref.set(this._shuttingDown, true);
481
+ log2("shutdown", void 0, {
482
+ F: __dxlog_file2,
483
+ L: 393,
484
+ S: this,
485
+ C: (f, a) => f(...a)
486
+ });
487
+ yield* this._interruptInFlightActivations();
488
+ const activeIds = [
489
+ ...this._get(this._activeAtom)
490
+ ].reverse();
491
+ const allModules = this._get(this._modulesAtom);
492
+ const modulesToDeactivate = activeIds.map((id) => allModules.find((module) => module.id === id)).filter((module) => module != null);
493
+ for (const module of modulesToDeactivate) {
494
+ yield* this._deactivateModule(module);
495
+ }
496
+ this._set(this._eventsFiredAtom, []);
497
+ this._set(this._pendingResetAtom, []);
498
+ this._moduleMemoMap.clear();
499
+ yield* Ref.set(this._activatingEvents, []);
500
+ yield* Ref.set(this._activatingModules, []);
501
+ log2("shutdown complete", void 0, {
502
+ F: __dxlog_file2,
503
+ L: 413,
504
+ S: this,
505
+ C: (f, a) => f(...a)
506
+ });
507
+ return true;
508
+ }).pipe(Effect2.ensuring(Ref.set(this._shuttingDown, false))));
509
+ }
510
+ //
511
+ // State helpers
512
+ //
575
513
  _get(atom) {
576
514
  return this.registry.get(atom);
577
515
  }
@@ -581,12 +519,82 @@ var ManagerImpl = class {
581
519
  _update(atom, updater) {
582
520
  this._set(atom, updater(this._get(atom)));
583
521
  }
522
+ _isShuttingDown() {
523
+ return Ref.get(this._shuttingDown);
524
+ }
525
+ _getPlugin(id) {
526
+ return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
527
+ }
528
+ _getActiveModules() {
529
+ const active = this._get(this._activeAtom);
530
+ return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
531
+ }
532
+ _getInactiveModules() {
533
+ const active = this._get(this._activeAtom);
534
+ return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
535
+ }
536
+ _getActiveModulesByEvent(key) {
537
+ return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
538
+ }
539
+ _getInactiveModulesByEvent(key) {
540
+ return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
541
+ }
542
+ _setPendingResetByModule(module) {
543
+ const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
544
+ const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
545
+ const pending = this._get(this._pendingResetAtom);
546
+ return !pending.includes(event);
547
+ });
548
+ if (pendingReset.length > 0) {
549
+ log2("pending reset", {
550
+ events: pendingReset
551
+ }, {
552
+ F: __dxlog_file2,
553
+ L: 475,
554
+ S: this,
555
+ C: (f, a) => f(...a)
556
+ });
557
+ this._update(this._pendingResetAtom, (current) => [
558
+ ...current,
559
+ ...pendingReset
560
+ ]);
561
+ }
562
+ }
563
+ _clearPendingReset(key) {
564
+ const pendingIndex = this._get(this._pendingResetAtom).findIndex((event) => event === key);
565
+ if (pendingIndex !== -1) {
566
+ this._update(this._pendingResetAtom, (pending) => pending.filter((event) => event !== key));
567
+ }
568
+ }
569
+ //
570
+ // Fiber helpers
571
+ //
572
+ _interruptInFlightActivations() {
573
+ return Effect2.gen(this, function* () {
574
+ const inFlightFibers = yield* Ref.get(this._inFlightFibers);
575
+ yield* Effect2.forEach(inFlightFibers, (fiber) => Fiber.interrupt(fiber), {
576
+ concurrency: "unbounded"
577
+ });
578
+ });
579
+ }
580
+ _trackFiber(ref, fiber) {
581
+ return Ref.update(ref, (fibers) => [
582
+ ...fibers,
583
+ fiber
584
+ ]);
585
+ }
586
+ _untrackFiber(ref, fiber) {
587
+ return Ref.update(ref, (fibers) => fibers.filter((trackedFiber) => trackedFiber !== fiber));
588
+ }
589
+ //
590
+ // Registration helpers
591
+ //
584
592
  _addPlugin(plugin) {
585
593
  log2("add plugin", {
586
594
  id: plugin.meta.id
587
595
  }, {
588
596
  F: __dxlog_file2,
589
- L: 501,
597
+ L: 519,
590
598
  S: this,
591
599
  C: (f, a) => f(...a)
592
600
  });
@@ -600,7 +608,7 @@ var ManagerImpl = class {
600
608
  id
601
609
  }, {
602
610
  F: __dxlog_file2,
603
- L: 507,
611
+ L: 525,
604
612
  S: this,
605
613
  C: (f, a) => f(...a)
606
614
  });
@@ -611,7 +619,7 @@ var ManagerImpl = class {
611
619
  id: module.id
612
620
  }, {
613
621
  F: __dxlog_file2,
614
- L: 512,
622
+ L: 530,
615
623
  S: this,
616
624
  C: (f, a) => f(...a)
617
625
  });
@@ -625,49 +633,160 @@ var ManagerImpl = class {
625
633
  id
626
634
  }, {
627
635
  F: __dxlog_file2,
628
- L: 518,
636
+ L: 536,
629
637
  S: this,
630
638
  C: (f, a) => f(...a)
631
639
  });
632
640
  this._update(this._modulesAtom, (modules) => modules.filter((module) => module.id !== id));
633
641
  }
634
- _getPlugin(id) {
635
- return this._get(this._pluginsAtom).find((plugin) => plugin.meta.id === id);
636
- }
637
- _getActiveModules() {
638
- const active = this._get(this._activeAtom);
639
- return this._get(this._modulesAtom).filter((module) => active.includes(module.id));
640
- }
641
- _getInactiveModules() {
642
- const active = this._get(this._activeAtom);
643
- return this._get(this._modulesAtom).filter((module) => !active.includes(module.id));
644
- }
645
- _getActiveModulesByEvent(key) {
646
- return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
647
- }
648
- _getInactiveModulesByEvent(key) {
649
- return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
650
- }
651
- _setPendingResetByModule(module) {
652
- const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._get(this._eventsFiredAtom).includes(key));
653
- const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => {
654
- const pending = this._get(this._pendingResetAtom);
655
- return !pending.includes(event);
656
- });
657
- if (pendingReset.length > 0) {
658
- log2("pending reset", {
659
- events: pendingReset
642
+ //
643
+ // Activation helpers
644
+ //
645
+ _activateEvent(key, params, fiber) {
646
+ return Effect2.gen(this, function* () {
647
+ yield* this._trackFiber(this._inFlightFibers, fiber);
648
+ log2("activating", {
649
+ key,
650
+ ...params
660
651
  }, {
661
652
  F: __dxlog_file2,
662
- L: 558,
653
+ L: 551,
663
654
  S: this,
664
655
  C: (f, a) => f(...a)
665
656
  });
666
- this._update(this._pendingResetAtom, (current) => [
667
- ...current,
668
- ...pendingReset
669
- ]);
670
- }
657
+ yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
658
+ this._clearPendingReset(key);
659
+ const activatingEvents = yield* this._activatingEvents;
660
+ const activatingModules = yield* this._activatingModules;
661
+ const modules = this._getModulesForActivation(key, activatingEvents, activatingModules);
662
+ if (modules.length === 0) {
663
+ log2("no modules to activate", {
664
+ key
665
+ }, {
666
+ F: __dxlog_file2,
667
+ L: 559,
668
+ S: this,
669
+ C: (f, a) => f(...a)
670
+ });
671
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
672
+ this._update(this._eventsFiredAtom, (events) => [
673
+ ...events,
674
+ key
675
+ ]);
676
+ }
677
+ return false;
678
+ }
679
+ return yield* this._activateModulesForEvent(key, modules, activatingEvents);
680
+ }).pipe(Effect2.ensuring(Effect2.all([
681
+ this._untrackFiber(this._inFlightFibers, fiber),
682
+ Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event) => event !== key))
683
+ ])));
684
+ }
685
+ _activateModulesForEvent(key, modules, activatingEvents) {
686
+ const activatingModuleIds = modules.map((module) => module.id);
687
+ return Effect2.gen(this, function* () {
688
+ yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, activatingModuleIds));
689
+ log2("activating modules", {
690
+ key,
691
+ modules: activatingModuleIds
692
+ }, {
693
+ F: __dxlog_file2,
694
+ L: 586,
695
+ S: this,
696
+ C: (f, a) => f(...a)
697
+ });
698
+ performance.mark(`event:${key}:start`);
699
+ yield* PubSub.publish(this.activation, {
700
+ event: key,
701
+ state: "activating"
702
+ });
703
+ yield* this._activateRelatedEvents(key, this._getBeforeEvents(modules, activatingEvents), "before");
704
+ const capabilities = yield* this._loadCapabilitiesForModules(key, modules);
705
+ yield* this._contributeCapabilitiesForModules(modules, capabilities);
706
+ yield* this._activateRelatedEvents(key, this._getAfterEvents(modules, activatingEvents), "after");
707
+ if (!this._get(this._eventsFiredAtom).includes(key)) {
708
+ this._update(this._eventsFiredAtom, (events) => [
709
+ ...events,
710
+ key
711
+ ]);
712
+ }
713
+ performance.mark(`event:${key}:end`);
714
+ performance.measure(`event:${key}`, `event:${key}:start`, `event:${key}:end`);
715
+ yield* PubSub.publish(this.activation, {
716
+ event: key,
717
+ state: "activated"
718
+ });
719
+ log2("activated", {
720
+ key
721
+ }, {
722
+ F: __dxlog_file2,
723
+ L: 604,
724
+ S: this,
725
+ C: (f, a) => f(...a)
726
+ });
727
+ return true;
728
+ }).pipe(Effect2.ensuring(Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !activatingModuleIds.includes(module)))));
729
+ }
730
+ _getModulesForActivation(key, activatingEvents, activatingModules) {
731
+ return this._getInactiveModulesByEvent(key).filter((module) => {
732
+ const allOf = isAllOf(module.activatesOn);
733
+ if (!allOf) {
734
+ return true;
735
+ }
736
+ const events = getEvents(module.activatesOn).filter((event) => eventKey(event) !== key);
737
+ return events.every((event) => this._get(this._eventsFiredAtom).includes(eventKey(event)) || activatingEvents.includes(eventKey(event))) && !activatingModules.includes(module.id);
738
+ });
739
+ }
740
+ _getBeforeEvents(modules, activatingEvents) {
741
+ return Function.pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
742
+ }
743
+ _getAfterEvents(modules, activatingEvents) {
744
+ return Function.pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event) => !activatingEvents.includes(eventKey(event))));
745
+ }
746
+ _activateRelatedEvents(key, events, phase) {
747
+ const logLabel = phase === "before" ? "activatesBefore" : "activatesAfter";
748
+ const eventKey2 = phase === "before" ? "beforeEvents" : "afterEvents";
749
+ return Function.pipe(events, Array.map((event) => this.activate(event, phase === "before" ? {
750
+ before: key
751
+ } : {
752
+ after: key
753
+ })), Effect2.allWith({
754
+ concurrency: "unbounded"
755
+ }), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`${logLabel} is taking a long time`, {
756
+ event: key,
757
+ [eventKey2]: events.map(eventKey)
758
+ }, {
759
+ F: __dxlog_file2,
760
+ L: 683,
761
+ S: this,
762
+ C: (f, a) => f(...a)
763
+ }))))), Effect2.asVoid);
764
+ }
765
+ //
766
+ // Module lifecycle helpers
767
+ //
768
+ _loadCapabilitiesForModules(key, modules) {
769
+ return Function.pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
770
+ concurrency: "unbounded"
771
+ }), Effect2.catchAll((error) => {
772
+ return Effect2.gen(this, function* () {
773
+ yield* PubSub.publish(this.activation, {
774
+ event: key,
775
+ state: "error",
776
+ error
777
+ });
778
+ return yield* Effect2.fail(error);
779
+ });
780
+ }));
781
+ }
782
+ _contributeCapabilitiesForModules(modules, capabilities) {
783
+ return Function.pipe(
784
+ modules,
785
+ Array.zip(capabilities),
786
+ Array.map(([module, capabilitySet]) => this._contributeCapabilities(module, capabilitySet)),
787
+ Effect2.all,
788
+ Effect2.asVoid
789
+ );
671
790
  }
672
791
  _getModuleSemaphore(moduleId) {
673
792
  let semaphore = this._moduleSemaphores.get(moduleId);
@@ -691,21 +810,35 @@ var ManagerImpl = class {
691
810
  module: module.id
692
811
  }, {
693
812
  F: __dxlog_file2,
694
- L: 588,
813
+ L: 756,
695
814
  S: this,
696
815
  C: (f, a) => f(...a)
697
816
  });
817
+ performance.mark(`module:${module.id}:start`);
818
+ yield* PubSub.publish(this.activation, {
819
+ event: "",
820
+ state: "activating",
821
+ module: module.id
822
+ });
698
823
  const [duration, capabilities] = yield* module.activate().pipe(Effect2.provideService(Service, this.capabilities), Effect2.provideService(Service2, this), Effect2.timed);
699
824
  const normalized = capabilities == null ? [] : Array.isArray(capabilities) ? capabilities : [
700
825
  capabilities
701
826
  ];
827
+ const elapsed = Duration.toMillis(duration);
828
+ performance.mark(`module:${module.id}:end`);
829
+ performance.measure(`module:${module.id}`, `module:${module.id}:start`, `module:${module.id}:end`);
830
+ yield* PubSub.publish(this.activation, {
831
+ event: "",
832
+ state: "activated",
833
+ module: module.id
834
+ });
702
835
  log2("loaded module", {
703
836
  module: module.id,
704
- elapsed: Duration.toMillis(duration),
837
+ elapsed,
705
838
  failed: false
706
839
  }, {
707
840
  F: __dxlog_file2,
708
- L: 597,
841
+ L: 771,
709
842
  S: this,
710
843
  C: (f, a) => f(...a)
711
844
  });
@@ -714,11 +847,19 @@ var ManagerImpl = class {
714
847
  module: module.id
715
848
  }, {
716
849
  F: __dxlog_file2,
717
- L: 608,
850
+ L: 782,
718
851
  S: this,
719
852
  C: (f, a) => f(...a)
720
- }))))));
721
- yield* Effect2.forkDaemon(loadEffect.pipe(Effect2.tap((result) => Deferred2.succeed(deferred, result)), Effect2.catchAllCause((cause) => {
853
+ }))))), Performance.addTrackEntry({
854
+ name: module.id,
855
+ devtools: {
856
+ dataType: "track-entry",
857
+ track: "Module Activation",
858
+ trackGroup: "Composer",
859
+ color: "primary"
860
+ }
861
+ }));
862
+ const fiber = yield* Effect2.forkDaemon(loadEffect.pipe(Effect2.tap((result) => Deferred2.succeed(deferred, result)), Effect2.catchAllCause((cause) => {
722
863
  const error = Cause.squash(cause);
723
864
  log2.error("module failed to activate", {
724
865
  module: module.id,
@@ -727,12 +868,14 @@ var ManagerImpl = class {
727
868
  isDefect: !Cause.isFailure(cause)
728
869
  }, {
729
870
  F: __dxlog_file2,
730
- L: 620,
871
+ L: 803,
731
872
  S: this,
732
873
  C: (f, a) => f(...a)
733
874
  });
734
875
  return Deferred2.fail(deferred, error instanceof Error ? error : new Error(String(error)));
735
876
  })));
877
+ yield* this._trackFiber(this._inFlightFibers, fiber);
878
+ yield* Effect2.forkDaemon(Fiber.await(fiber).pipe(Effect2.andThen(() => this._untrackFiber(this._inFlightFibers, fiber))));
736
879
  return deferred;
737
880
  }).pipe(semaphore.withPermits(1));
738
881
  return yield* Deferred2.await(deferredToAwait);
@@ -759,7 +902,7 @@ var ManagerImpl = class {
759
902
  id
760
903
  }, {
761
904
  F: __dxlog_file2,
762
- L: 654,
905
+ L: 841,
763
906
  S: this,
764
907
  C: (f, a) => f(...a)
765
908
  });
@@ -781,7 +924,7 @@ var ManagerImpl = class {
781
924
  id
782
925
  }, {
783
926
  F: __dxlog_file2,
784
- L: 672,
927
+ L: 859,
785
928
  S: this,
786
929
  C: (f, a) => f(...a)
787
930
  });
@@ -804,4 +947,4 @@ export {
804
947
  make5 as make,
805
948
  plugin_manager_exports
806
949
  };
807
- //# sourceMappingURL=chunk-FMZN33N4.mjs.map
950
+ //# sourceMappingURL=chunk-27FZETIA.mjs.map