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

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 (368) hide show
  1. package/.storybook/main.mts +1 -3
  2. package/dist/lib/browser/capability-5OFLR7J4.mjs +34 -0
  3. package/dist/lib/browser/capability-5OFLR7J4.mjs.map +7 -0
  4. package/dist/lib/browser/{capability-7PCNSWBT.mjs → capability-ZHQDZRP5.mjs} +15 -11
  5. package/dist/lib/browser/capability-ZHQDZRP5.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-PKQT6C53.mjs → chunk-272IPLHQ.mjs} +1 -1
  7. package/dist/lib/browser/{chunk-PKQT6C53.mjs.map → chunk-272IPLHQ.mjs.map} +1 -1
  8. package/dist/lib/browser/{chunk-FMZN33N4.mjs → chunk-3VXJONTI.mjs} +304 -178
  9. package/dist/lib/browser/chunk-3VXJONTI.mjs.map +7 -0
  10. package/dist/lib/browser/{chunk-XYNO72GQ.mjs → chunk-7AL6SKIV.mjs} +459 -477
  11. package/dist/lib/browser/chunk-7AL6SKIV.mjs.map +7 -0
  12. package/dist/lib/browser/{chunk-TCLLRCS3.mjs → chunk-GH3M2LIW.mjs} +10 -7
  13. package/dist/lib/browser/chunk-GH3M2LIW.mjs.map +7 -0
  14. package/dist/lib/browser/{chunk-7IQHKD4U.mjs → chunk-JGWCBVKJ.mjs} +2 -2
  15. package/dist/lib/browser/chunk-JGWCBVKJ.mjs.map +7 -0
  16. package/dist/lib/browser/chunk-M5IC326L.mjs +34 -0
  17. package/dist/lib/browser/chunk-M5IC326L.mjs.map +7 -0
  18. package/dist/lib/browser/chunk-TGX63LTL.mjs +8 -0
  19. package/dist/lib/browser/{chunk-FHQTHCX7.mjs.map → chunk-TGX63LTL.mjs.map} +1 -1
  20. package/dist/lib/browser/chunk-TIEBZMTF.mjs +44 -0
  21. package/dist/lib/browser/chunk-TIEBZMTF.mjs.map +7 -0
  22. package/dist/lib/browser/chunk-WEBSGU5L.mjs +80 -0
  23. package/dist/lib/browser/chunk-WEBSGU5L.mjs.map +7 -0
  24. package/dist/lib/browser/chunk-YAFEA4GV.mjs +1 -0
  25. package/dist/lib/browser/{chunk-6Y7PZV72.mjs → chunk-YNFPIQGB.mjs} +2 -3
  26. package/dist/lib/browser/{chunk-6Y7PZV72.mjs.map → chunk-YNFPIQGB.mjs.map} +3 -3
  27. package/dist/lib/browser/cli/index.mjs +89 -0
  28. package/dist/lib/browser/cli/index.mjs.map +7 -0
  29. package/dist/lib/browser/common/activation-events.mjs +23 -0
  30. package/dist/lib/browser/common/capabilities.mjs +45 -0
  31. package/dist/lib/browser/core/activation-event.mjs +1 -1
  32. package/dist/lib/browser/core/capability.mjs +1 -1
  33. package/dist/lib/browser/core/plugin-manager.mjs +4 -4
  34. package/dist/lib/browser/core/plugin.mjs +6 -4
  35. package/dist/lib/browser/index.mjs +37 -132
  36. package/dist/lib/browser/index.mjs.map +4 -4
  37. package/dist/lib/browser/{invoker-capability-SZRSTHEH.mjs → invoker-capability-YTTQ2OBB.mjs} +16 -12
  38. package/dist/lib/browser/invoker-capability-YTTQ2OBB.mjs.map +7 -0
  39. package/dist/lib/browser/meta.json +1 -1
  40. package/dist/lib/browser/testing/index.mjs +55 -34
  41. package/dist/lib/browser/testing/index.mjs.map +3 -3
  42. package/dist/lib/browser/{react → ui}/index.mjs +18 -19
  43. package/dist/lib/node-esm/capability-CRHZKL6T.mjs +35 -0
  44. package/dist/lib/node-esm/capability-CRHZKL6T.mjs.map +7 -0
  45. package/dist/lib/node-esm/{capability-CFLQ2QQU.mjs → capability-W5C5464H.mjs} +15 -11
  46. package/dist/lib/node-esm/capability-W5C5464H.mjs.map +7 -0
  47. package/dist/lib/node-esm/{chunk-663A54LQ.mjs → chunk-3D66SZHP.mjs} +2 -2
  48. package/dist/lib/node-esm/chunk-3D66SZHP.mjs.map +7 -0
  49. package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs → chunk-6REV5DE7.mjs} +1 -1
  50. package/dist/lib/node-esm/{chunk-7OWSHPYK.mjs.map → chunk-6REV5DE7.mjs.map} +1 -1
  51. package/dist/lib/node-esm/{chunk-XYQTBFPA.mjs → chunk-CMDON4NG.mjs} +304 -178
  52. package/dist/lib/node-esm/chunk-CMDON4NG.mjs.map +7 -0
  53. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs → chunk-FKE4Z3D6.mjs} +2 -2
  54. package/dist/lib/node-esm/{chunk-UEWJDI2L.mjs.map → chunk-FKE4Z3D6.mjs.map} +1 -1
  55. package/dist/lib/node-esm/{chunk-6WXBT3EC.mjs → chunk-I7FZT4A7.mjs} +459 -477
  56. package/dist/lib/node-esm/chunk-I7FZT4A7.mjs.map +7 -0
  57. package/dist/lib/node-esm/{chunk-GT6OKM5I.mjs → chunk-LHCJGNXK.mjs} +10 -7
  58. package/dist/lib/node-esm/chunk-LHCJGNXK.mjs.map +7 -0
  59. package/dist/lib/node-esm/chunk-NHXBSAQR.mjs +35 -0
  60. package/dist/lib/node-esm/chunk-NHXBSAQR.mjs.map +7 -0
  61. package/dist/lib/node-esm/{chunk-STMXUEPO.mjs → chunk-SB5ODNPX.mjs} +2 -3
  62. package/dist/lib/node-esm/{chunk-STMXUEPO.mjs.map → chunk-SB5ODNPX.mjs.map} +3 -3
  63. package/dist/lib/node-esm/chunk-SCDGIGGU.mjs +45 -0
  64. package/dist/lib/node-esm/chunk-SCDGIGGU.mjs.map +7 -0
  65. package/dist/lib/node-esm/chunk-SQICGJBW.mjs +81 -0
  66. package/dist/lib/node-esm/chunk-SQICGJBW.mjs.map +7 -0
  67. package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs +2 -0
  68. package/dist/lib/node-esm/chunk-Z4TJPSMP.mjs.map +7 -0
  69. package/dist/lib/node-esm/cli/index.mjs +90 -0
  70. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  71. package/dist/lib/node-esm/common/activation-events.mjs +24 -0
  72. package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
  73. package/dist/lib/node-esm/common/capabilities.mjs +46 -0
  74. package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
  75. package/dist/lib/node-esm/core/activation-event.mjs +1 -1
  76. package/dist/lib/node-esm/core/capability.mjs +1 -1
  77. package/dist/lib/node-esm/core/plugin-manager.mjs +4 -4
  78. package/dist/lib/node-esm/core/plugin.mjs +6 -4
  79. package/dist/lib/node-esm/index.mjs +37 -132
  80. package/dist/lib/node-esm/index.mjs.map +4 -4
  81. package/dist/lib/node-esm/{invoker-capability-PNMA5JOS.mjs → invoker-capability-BU26474T.mjs} +16 -12
  82. package/dist/lib/node-esm/invoker-capability-BU26474T.mjs.map +7 -0
  83. package/dist/lib/node-esm/meta.json +1 -1
  84. package/dist/lib/node-esm/testing/index.mjs +55 -34
  85. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  86. package/dist/lib/node-esm/{react → ui}/index.mjs +18 -19
  87. package/dist/lib/node-esm/ui/index.mjs.map +7 -0
  88. package/dist/types/src/{cli.d.ts → cli/cli.d.ts} +2 -2
  89. package/dist/types/src/cli/cli.d.ts.map +1 -0
  90. package/dist/types/src/cli/index.d.ts +2 -0
  91. package/dist/types/src/cli/index.d.ts.map +1 -0
  92. package/dist/types/src/common/activation-events.d.ts +27 -0
  93. package/dist/types/src/common/activation-events.d.ts.map +1 -0
  94. package/dist/types/src/common/capabilities.d.ts +115 -0
  95. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  96. package/dist/types/src/common/index.d.ts +4 -9
  97. package/dist/types/src/common/index.d.ts.map +1 -1
  98. package/dist/types/src/common/operations.d.ts +1 -348
  99. package/dist/types/src/common/operations.d.ts.map +1 -1
  100. package/dist/types/src/common/translations.d.ts +0 -9
  101. package/dist/types/src/common/translations.d.ts.map +1 -1
  102. package/dist/types/src/core/activation-event.d.ts +1 -1
  103. package/dist/types/src/core/capability.d.ts +7 -7
  104. package/dist/types/src/core/capability.d.ts.map +1 -1
  105. package/dist/types/src/core/plugin-manager.d.ts +6 -0
  106. package/dist/types/src/core/plugin-manager.d.ts.map +1 -1
  107. package/dist/types/src/core/plugin.d.ts +6 -1
  108. package/dist/types/src/core/plugin.d.ts.map +1 -1
  109. package/dist/types/src/index.d.ts +1 -3
  110. package/dist/types/src/index.d.ts.map +1 -1
  111. package/dist/types/src/plugin-operation/history/capability.d.ts +1 -1
  112. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +11 -3
  113. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -1
  114. package/dist/types/src/plugin-operation/invoker-capability.d.ts +1 -1
  115. package/dist/types/src/plugin-runtime/capability.d.ts +2 -2
  116. package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -1
  117. package/dist/types/src/testing/withPluginManager.d.ts +1 -1
  118. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  119. package/dist/types/src/{react → ui/components/App}/App.d.ts +1 -1
  120. package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
  121. package/dist/types/src/{react/Surface.stories.d.ts → ui/components/App/App.stories.d.ts} +7 -2
  122. package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
  123. package/dist/types/src/ui/components/App/index.d.ts +2 -0
  124. package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
  125. package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
  126. package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerProvider.d.ts +1 -1
  127. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
  128. package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
  129. package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
  130. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +12 -0
  131. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
  132. package/dist/types/src/{react/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -1
  133. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
  134. package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
  135. package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
  136. package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
  137. package/dist/types/src/ui/components/Surface/index.d.ts +20 -0
  138. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
  139. package/dist/types/src/{common/surface.d.ts → ui/components/Surface/types.d.ts} +20 -18
  140. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
  141. package/dist/types/src/ui/components/index.d.ts +4 -0
  142. package/dist/types/src/ui/components/index.d.ts.map +1 -0
  143. package/dist/types/src/ui/hooks/index.d.ts +7 -0
  144. package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
  145. package/dist/types/src/{react → ui/hooks}/useApp.d.ts +14 -9
  146. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
  147. package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
  148. package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
  149. package/dist/types/src/{react → ui/hooks}/useCapabilities.d.ts +6 -1
  150. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
  151. package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
  152. package/dist/types/src/{react → ui/hooks}/useOperationResolver.d.ts +2 -2
  153. package/dist/types/src/ui/hooks/useOperationResolver.d.ts.map +1 -0
  154. package/dist/types/src/{react/common.d.ts → ui/hooks/useSettingsState.d.ts} +1 -5
  155. package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
  156. package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
  157. package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
  158. package/dist/types/src/ui/index.d.ts +3 -0
  159. package/dist/types/src/ui/index.d.ts.map +1 -0
  160. package/dist/types/tsconfig.tsbuildinfo +1 -1
  161. package/moon.yml +6 -6
  162. package/package.json +72 -64
  163. package/src/{cli.ts → cli/cli.ts} +10 -10
  164. package/src/{playground/debug → cli}/index.ts +1 -1
  165. package/src/common/activation-events.ts +44 -0
  166. package/src/common/capabilities.ts +178 -0
  167. package/src/common/index.ts +4 -9
  168. package/src/common/operations.ts +2 -376
  169. package/src/common/translations.ts +0 -12
  170. package/src/context.ts +1 -1
  171. package/src/core/activation-event.ts +1 -1
  172. package/src/core/capability.ts +9 -9
  173. package/src/core/plugin-manager.test.ts +292 -44
  174. package/src/core/plugin-manager.ts +326 -154
  175. package/src/core/plugin.ts +10 -2
  176. package/src/index.ts +1 -3
  177. package/src/plugin-operation/OperationPlugin.ts +5 -5
  178. package/src/plugin-operation/history/capability.ts +5 -5
  179. package/src/plugin-operation/history/undo-mapping.ts +6 -3
  180. package/src/plugin-operation/invoker-capability.ts +5 -5
  181. package/src/plugin-operation/meta.ts +1 -1
  182. package/src/plugin-runtime/RuntimePlugin.ts +4 -4
  183. package/src/plugin-runtime/capability.ts +5 -5
  184. package/src/plugin-runtime/meta.ts +1 -1
  185. package/src/testing/service.ts +6 -6
  186. package/src/testing/withPluginManager.stories.tsx +6 -6
  187. package/src/testing/withPluginManager.tsx +46 -19
  188. package/src/ui/components/App/App.stories.tsx +92 -0
  189. package/src/{react → ui/components/App}/App.tsx +6 -9
  190. package/src/{playground/layout → ui/components/App}/index.ts +1 -1
  191. package/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.tsx +13 -14
  192. package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +1 -1
  193. package/src/ui/components/PluginManager/index.ts +5 -0
  194. package/src/{react/Surface.stories.tsx → ui/components/Surface/SurfaceComponent.stories.tsx} +18 -16
  195. package/src/{react/Surface.tsx → ui/components/Surface/SurfaceComponent.tsx} +36 -56
  196. package/src/{react → ui/components/Surface}/SurfaceInfo.tsx +2 -2
  197. package/src/ui/components/Surface/context.ts +12 -0
  198. package/src/ui/components/Surface/index.ts +20 -0
  199. package/src/{common/surface.ts → ui/components/Surface/types.ts} +22 -25
  200. package/src/ui/components/index.ts +7 -0
  201. package/src/ui/hooks/index.ts +10 -0
  202. package/src/ui/hooks/useApp.test.tsx +159 -0
  203. package/src/{react → ui/hooks}/useApp.tsx +39 -29
  204. package/src/{react → ui/hooks}/useCapabilities.ts +9 -5
  205. package/src/{react → ui/hooks}/useOperationResolver.ts +5 -5
  206. package/src/{react/common.ts → ui/hooks/useSettingsState.ts} +0 -11
  207. package/src/ui/hooks/useSurface.ts +13 -0
  208. package/src/ui/index.ts +6 -0
  209. package/tsconfig.json +2 -29
  210. package/tsconfig.node.json +1 -3
  211. package/typedoc.json +2 -4
  212. package/vitest.config.ts +1 -1
  213. package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs +0 -149
  214. package/dist/lib/browser/app-graph-builder-M2VPYQC6.mjs.map +0 -7
  215. package/dist/lib/browser/capability-7PCNSWBT.mjs.map +0 -7
  216. package/dist/lib/browser/capability-KP3PFEXD.mjs +0 -31
  217. package/dist/lib/browser/capability-KP3PFEXD.mjs.map +0 -7
  218. package/dist/lib/browser/chunk-7IQHKD4U.mjs.map +0 -7
  219. package/dist/lib/browser/chunk-BLQJSGL3.mjs +0 -732
  220. package/dist/lib/browser/chunk-BLQJSGL3.mjs.map +0 -7
  221. package/dist/lib/browser/chunk-FHQTHCX7.mjs +0 -8
  222. package/dist/lib/browser/chunk-FMZN33N4.mjs.map +0 -7
  223. package/dist/lib/browser/chunk-H4WPA7U7.mjs +0 -77
  224. package/dist/lib/browser/chunk-H4WPA7U7.mjs.map +0 -7
  225. package/dist/lib/browser/chunk-TCLLRCS3.mjs.map +0 -7
  226. package/dist/lib/browser/chunk-XYNO72GQ.mjs.map +0 -7
  227. package/dist/lib/browser/common/index.mjs +0 -38
  228. package/dist/lib/browser/invoker-capability-SZRSTHEH.mjs.map +0 -7
  229. package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs +0 -64
  230. package/dist/lib/browser/operation-resolver-6MP2MYOY.mjs.map +0 -7
  231. package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs +0 -150
  232. package/dist/lib/node-esm/app-graph-builder-LROHGJEM.mjs.map +0 -7
  233. package/dist/lib/node-esm/capability-CFLQ2QQU.mjs.map +0 -7
  234. package/dist/lib/node-esm/capability-RCUNM2M7.mjs +0 -32
  235. package/dist/lib/node-esm/capability-RCUNM2M7.mjs.map +0 -7
  236. package/dist/lib/node-esm/chunk-663A54LQ.mjs.map +0 -7
  237. package/dist/lib/node-esm/chunk-6WXBT3EC.mjs.map +0 -7
  238. package/dist/lib/node-esm/chunk-GQEBIGKD.mjs +0 -733
  239. package/dist/lib/node-esm/chunk-GQEBIGKD.mjs.map +0 -7
  240. package/dist/lib/node-esm/chunk-GT6OKM5I.mjs.map +0 -7
  241. package/dist/lib/node-esm/chunk-XR6NMKEP.mjs +0 -78
  242. package/dist/lib/node-esm/chunk-XR6NMKEP.mjs.map +0 -7
  243. package/dist/lib/node-esm/chunk-XYQTBFPA.mjs.map +0 -7
  244. package/dist/lib/node-esm/common/index.mjs +0 -39
  245. package/dist/lib/node-esm/invoker-capability-PNMA5JOS.mjs.map +0 -7
  246. package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs +0 -65
  247. package/dist/lib/node-esm/operation-resolver-7YWDMTNU.mjs.map +0 -7
  248. package/dist/types/src/cli.d.ts.map +0 -1
  249. package/dist/types/src/common/activation-event.d.ts +0 -66
  250. package/dist/types/src/common/activation-event.d.ts.map +0 -1
  251. package/dist/types/src/common/capability.d.ts +0 -265
  252. package/dist/types/src/common/capability.d.ts.map +0 -1
  253. package/dist/types/src/common/collaboration.d.ts +0 -26
  254. package/dist/types/src/common/collaboration.d.ts.map +0 -1
  255. package/dist/types/src/common/file.d.ts +0 -14
  256. package/dist/types/src/common/file.d.ts.map +0 -1
  257. package/dist/types/src/common/graph.d.ts +0 -21
  258. package/dist/types/src/common/graph.d.ts.map +0 -1
  259. package/dist/types/src/common/plugin.d.ts +0 -201
  260. package/dist/types/src/common/plugin.d.ts.map +0 -1
  261. package/dist/types/src/common/surface.d.ts.map +0 -1
  262. package/dist/types/src/playground/debug/Debug.d.ts +0 -8
  263. package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
  264. package/dist/types/src/playground/debug/index.d.ts +0 -2
  265. package/dist/types/src/playground/debug/index.d.ts.map +0 -1
  266. package/dist/types/src/playground/debug/plugin.d.ts +0 -3
  267. package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
  268. package/dist/types/src/playground/generator/Main.d.ts +0 -8
  269. package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
  270. package/dist/types/src/playground/generator/Toolbar.d.ts +0 -8
  271. package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
  272. package/dist/types/src/playground/generator/generator.d.ts +0 -19
  273. package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
  274. package/dist/types/src/playground/generator/index.d.ts +0 -3
  275. package/dist/types/src/playground/generator/index.d.ts.map +0 -1
  276. package/dist/types/src/playground/generator/plugin.d.ts +0 -3
  277. package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
  278. package/dist/types/src/playground/layout/Layout.d.ts +0 -10
  279. package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
  280. package/dist/types/src/playground/layout/index.d.ts +0 -2
  281. package/dist/types/src/playground/layout/index.d.ts.map +0 -1
  282. package/dist/types/src/playground/layout/plugin.d.ts +0 -3
  283. package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
  284. package/dist/types/src/playground/logger/Toolbar.d.ts +0 -8
  285. package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
  286. package/dist/types/src/playground/logger/index.d.ts +0 -2
  287. package/dist/types/src/playground/logger/index.d.ts.map +0 -1
  288. package/dist/types/src/playground/logger/plugin.d.ts +0 -3
  289. package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
  290. package/dist/types/src/playground/logger/schema.d.ts +0 -27
  291. package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
  292. package/dist/types/src/playground/playground.stories.d.ts +0 -11
  293. package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
  294. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -3
  295. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  296. package/dist/types/src/plugin-settings/actions.d.ts +0 -61
  297. package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
  298. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -6
  299. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
  300. package/dist/types/src/plugin-settings/index.d.ts +0 -3
  301. package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
  302. package/dist/types/src/plugin-settings/meta.d.ts +0 -3
  303. package/dist/types/src/plugin-settings/meta.d.ts.map +0 -1
  304. package/dist/types/src/plugin-settings/operation-resolver.d.ts +0 -6
  305. package/dist/types/src/plugin-settings/operation-resolver.d.ts.map +0 -1
  306. package/dist/types/src/plugin-settings/translations.d.ts +0 -11
  307. package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
  308. package/dist/types/src/react/App.d.ts.map +0 -1
  309. package/dist/types/src/react/App.stories.d.ts.map +0 -1
  310. package/dist/types/src/react/DefaultFallback.d.ts +0 -8
  311. package/dist/types/src/react/DefaultFallback.d.ts.map +0 -1
  312. package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
  313. package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
  314. package/dist/types/src/react/PluginManagerContext.stories.d.ts.map +0 -1
  315. package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
  316. package/dist/types/src/react/Surface.d.ts +0 -14
  317. package/dist/types/src/react/Surface.d.ts.map +0 -1
  318. package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
  319. package/dist/types/src/react/SurfaceInfo.d.ts.map +0 -1
  320. package/dist/types/src/react/common.d.ts.map +0 -1
  321. package/dist/types/src/react/index.d.ts +0 -9
  322. package/dist/types/src/react/index.d.ts.map +0 -1
  323. package/dist/types/src/react/types.d.ts +0 -12
  324. package/dist/types/src/react/types.d.ts.map +0 -1
  325. package/dist/types/src/react/useApp.d.ts.map +0 -1
  326. package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
  327. package/dist/types/src/react/useLoading.d.ts.map +0 -1
  328. package/dist/types/src/react/useOperationResolver.d.ts.map +0 -1
  329. package/src/common/activation-event.ts +0 -99
  330. package/src/common/capability.ts +0 -343
  331. package/src/common/collaboration.ts +0 -31
  332. package/src/common/file.ts +0 -22
  333. package/src/common/graph.ts +0 -30
  334. package/src/common/plugin.ts +0 -364
  335. package/src/playground/debug/Debug.tsx +0 -49
  336. package/src/playground/debug/plugin.ts +0 -16
  337. package/src/playground/generator/Main.tsx +0 -80
  338. package/src/playground/generator/Toolbar.tsx +0 -57
  339. package/src/playground/generator/generator.ts +0 -48
  340. package/src/playground/generator/index.ts +0 -6
  341. package/src/playground/generator/plugin.ts +0 -21
  342. package/src/playground/layout/Layout.tsx +0 -37
  343. package/src/playground/layout/plugin.ts +0 -18
  344. package/src/playground/logger/Toolbar.tsx +0 -33
  345. package/src/playground/logger/index.ts +0 -5
  346. package/src/playground/logger/plugin.ts +0 -42
  347. package/src/playground/logger/schema.ts +0 -22
  348. package/src/playground/playground.stories.tsx +0 -54
  349. package/src/plugin-settings/SettingsPlugin.ts +0 -19
  350. package/src/plugin-settings/actions.ts +0 -64
  351. package/src/plugin-settings/app-graph-builder.ts +0 -140
  352. package/src/plugin-settings/index.ts +0 -6
  353. package/src/plugin-settings/meta.ts +0 -10
  354. package/src/plugin-settings/operation-resolver.ts +0 -55
  355. package/src/plugin-settings/translations.ts +0 -19
  356. package/src/react/App.stories.tsx +0 -63
  357. package/src/react/DefaultFallback.tsx +0 -26
  358. package/src/react/ErrorBoundary.tsx +0 -56
  359. package/src/react/index.ts +0 -14
  360. package/src/react/types.ts +0 -27
  361. /package/dist/lib/{node-esm/react/index.mjs.map → browser/chunk-YAFEA4GV.mjs.map} +0 -0
  362. /package/dist/lib/{node-esm/common/index.mjs.map → browser/common/activation-events.mjs.map} +0 -0
  363. /package/dist/lib/browser/{react/index.mjs.map → common/capabilities.mjs.map} +0 -0
  364. /package/dist/lib/browser/{common → ui}/index.mjs.map +0 -0
  365. /package/dist/types/src/{react → ui/components/PluginManager}/PluginManagerContext.stories.d.ts +0 -0
  366. /package/dist/types/src/{react → ui/components/Surface}/SurfaceInfo.d.ts +0 -0
  367. /package/dist/types/src/{react → ui/hooks}/useLoading.d.ts +0 -0
  368. /package/src/{react → ui/hooks}/useLoading.tsx +0 -0
@@ -3,47 +3,40 @@
3
3
  //
4
4
 
5
5
  import React, {
6
- type Context,
7
6
  Fragment,
8
7
  type NamedExoticComponent,
9
8
  type RefAttributes,
10
9
  Suspense,
11
- createContext,
12
10
  forwardRef,
13
11
  memo,
14
- useContext,
15
12
  useEffect,
16
13
  useMemo,
17
14
  useRef,
18
15
  } from 'react';
19
16
 
20
- import { raise } from '@dxos/debug';
21
17
  import { log } from '@dxos/log';
18
+ import { ErrorBoundary } from '@dxos/react-error-boundary';
22
19
  import { useDefaultValue } from '@dxos/react-hooks';
23
20
  import { byPosition } from '@dxos/util';
24
21
 
25
- import * as Common from '../common';
26
- import { type CapabilityManager } from '../core';
22
+ import { Capabilities } from '../../../common';
23
+ import { type CapabilityManager } from '../../../core';
24
+ import { useCapabilities } from '../../hooks';
27
25
 
28
- import { ErrorBoundary } from './ErrorBoundary';
26
+ import { SurfaceContext } from './context';
29
27
  import { SurfaceInfo } from './SurfaceInfo';
30
- import { useCapabilities } from './useCapabilities';
28
+ import { type Definition, type Props, type WebComponentDefinition } from './types';
31
29
 
32
30
  const DEFAULT_PLACEHOLDER = <Fragment />;
33
31
 
34
32
  const DEBUG = import.meta.env.VITE_DEBUG;
35
33
 
36
- export type SurfaceContext = Pick<Common.SurfaceProps, 'id' | 'role' | 'data'>;
37
-
38
- // TODO(burdon): Use @radix-ui/react-context
39
- const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);
40
-
41
34
  /**
42
35
  * Wrapper component for rendering Web Component surfaces.
43
36
  * Handles creation, prop setting, and cleanup of Web Components.
44
37
  */
45
38
  const WebComponentWrapper = memo(
46
- forwardRef<HTMLElement, Common.SurfaceProps & { definition: Common.WebComponentSurfaceDefinition }>(
39
+ forwardRef<HTMLElement, Props & { definition: WebComponentDefinition }>(
47
40
  ({ id, role, data, limit, definition, ...rest }, forwardedRef) => {
48
41
  const containerRef = useRef<HTMLDivElement>(null);
49
42
  const elementRef = useRef<HTMLElement | null>(null);
@@ -54,7 +47,9 @@ const WebComponentWrapper = memo(
54
47
 
55
48
  // Create element only once
56
49
  useEffect(() => {
57
- if (!containerRef.current || elementRef.current) return;
50
+ if (!containerRef.current || elementRef.current) {
51
+ return;
52
+ }
58
53
 
59
54
  // Create the Web Component
60
55
  const element = document.createElement(definition.tagName);
@@ -91,7 +86,9 @@ const WebComponentWrapper = memo(
91
86
  // This runs on every render to ensure all props (including those in `rest`) are kept up to date
92
87
  useEffect(() => {
93
88
  const element = elementRef.current;
94
- if (!element) return;
89
+ if (!element) {
90
+ return;
91
+ }
95
92
 
96
93
  // Update properties on the existing Web Component
97
94
  Object.assign(element, propsRef.current);
@@ -107,15 +104,16 @@ WebComponentWrapper.displayName = 'WebComponentWrapper';
107
104
  /**
108
105
  * Wrapper component that provides context for a surface.
109
106
  */
107
+ // TODO(burdon): Allow DebugPlugin to provide different fallback using react-ui ErrorFallback.
110
108
  const SurfaceContextProvider = memo(
111
- forwardRef<HTMLElement, Common.SurfaceProps & { definition: Common.SurfaceDefinition }>(
112
- ({ id, role, data, limit, fallback = DefaultFallback, definition, ...rest }, forwardedRef) => {
109
+ forwardRef<HTMLElement, Props & { definition: Definition }>(
110
+ ({ id, role, data, limit, fallback = ErrorFallback, definition, ...rest }, forwardedRef) => {
113
111
  const contextValue = useMemo(() => ({ id, role, data }), [id, role, data]);
114
112
 
115
113
  // Handle Web Component surfaces
116
114
  if (definition.kind === 'web-component') {
117
115
  return (
118
- <ErrorBoundary data={data} fallback={fallback}>
116
+ <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
119
117
  <SurfaceContext.Provider value={contextValue}>
120
118
  <WebComponentWrapper
121
119
  id={id}
@@ -138,7 +136,7 @@ const SurfaceContextProvider = memo(
138
136
  const debug = DEBUG || '__DX_DEBUG__' in window;
139
137
  if (debug) {
140
138
  return (
141
- <ErrorBoundary data={data} fallback={fallback}>
139
+ <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
142
140
  <div role='none' className='contents' data-id={id} data-role={role}>
143
141
  <SurfaceContext.Provider value={contextValue}>
144
142
  <SurfaceInfo ref={forwardedRef}>
@@ -151,7 +149,7 @@ const SurfaceContextProvider = memo(
151
149
  }
152
150
 
153
151
  return (
154
- <ErrorBoundary data={data} fallback={fallback}>
152
+ <ErrorBoundary name='surface' resetKeys={[data]} FallbackComponent={fallback}>
155
153
  <div role='none' className='contents' data-id={id} data-role={role}>
156
154
  <SurfaceContext.Provider value={contextValue}>
157
155
  <Component id={id} role={role} data={data} limit={limit} {...rest} ref={forwardedRef} />
@@ -165,15 +163,11 @@ const SurfaceContextProvider = memo(
165
163
 
166
164
  SurfaceContextProvider.displayName = 'SurfaceContextProvider';
167
165
 
168
- export const useSurface = (): SurfaceContext => {
169
- const context = useContext(SurfaceContext) ?? raise(new Error('Missing SurfaceContext'));
170
- return context;
171
- };
172
-
173
166
  /**
174
167
  * A surface is a named region of the screen that can be populated by plugins.
175
168
  */
176
- export const Surface: NamedExoticComponent<Common.SurfaceProps & RefAttributes<HTMLElement>> = memo(
169
+ // TODO(burdon): Remove `ref` since relying on this would be error prone.
170
+ export const SurfaceComponent: NamedExoticComponent<Props & RefAttributes<HTMLElement>> = memo(
177
171
  forwardRef(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
178
172
  const data = useDefaultValue(dataProp, () => ({}));
179
173
 
@@ -211,12 +205,19 @@ export const Surface: NamedExoticComponent<Common.SurfaceProps & RefAttributes<H
211
205
  }),
212
206
  );
213
207
 
214
- Surface.displayName = 'Surface';
208
+ SurfaceComponent.displayName = 'Surface';
215
209
 
216
- const findCandidates = (
217
- surfaces: Common.SurfaceDefinition[],
218
- { role, data }: Pick<Common.SurfaceProps, 'role' | 'data'>,
219
- ) => {
210
+ // TODO(burdon): Make user facing, with telemetry.
211
+ const ErrorFallback = ({ error }: Props) => {
212
+ const { message } = error instanceof Error ? error : { message: String(error) };
213
+ return (
214
+ <div role='alert' data-testid='error-boundary-fallback'>
215
+ <h1 className='flex gap-2 text-sm mt-2 text-info-text'>{message}</h1>
216
+ </div>
217
+ );
218
+ };
219
+
220
+ const findCandidates = (surfaces: Definition[], { role, data }: Pick<Props, 'role' | 'data'>) => {
220
221
  return Object.values(surfaces)
221
222
  .filter((definition) =>
222
223
  Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,
@@ -225,32 +226,11 @@ const findCandidates = (
225
226
  .toSorted(byPosition);
226
227
  };
227
228
 
228
- // TODO(burdon): Make user facing, with telemetry.
229
- // TODO(burdon): Change based on dev/prod mode; infer subject type, id.
230
- const DefaultFallback = ({ data, error, dev }: { data: any; error: Error; dev?: boolean }) => {
231
- if (dev) {
232
- return (
233
- <div className='flex flex-col gap-4 p-4 is-full overflow-y-auto'>
234
- <h1 className='flex gap-2 text-sm mbs-2'>{error.message}</h1>
235
- <pre className='overflow-auto text-xs text-description'>{JSON.stringify(data, null, 2)}</pre>
236
- </div>
237
- );
238
- }
239
-
240
- return (
241
- <div className='flex flex-col gap-4 p-4 is-full overflow-y-auto border border-roseFill'>
242
- <h1 className='flex gap-2 text-sm mbs-2 text-rose-500'>{error.message}</h1>
243
- <pre className='overflow-auto text-xs text-description'>{error.stack}</pre>
244
- <pre className='overflow-auto text-xs text-description'>{JSON.stringify(data, null, 2)}</pre>
245
- </div>
246
- );
247
- };
248
-
249
229
  /**
250
230
  * @internal
251
231
  */
252
232
  export const useSurfaces = () => {
253
- const surfaces = useCapabilities(Common.Capability.ReactSurface);
233
+ const surfaces = useCapabilities(Capabilities.ReactSurface);
254
234
  return useMemo(() => surfaces.flat(), [surfaces]);
255
235
  };
256
236
 
@@ -259,9 +239,9 @@ export const useSurfaces = () => {
259
239
  */
260
240
  export const isSurfaceAvailable = (
261
241
  capabilityManager: CapabilityManager.CapabilityManager,
262
- { role, data }: Pick<Common.SurfaceProps, 'role' | 'data'>,
242
+ { role, data }: Pick<Props, 'role' | 'data'>,
263
243
  ) => {
264
- const surfaces = capabilityManager.getAll(Common.Capability.ReactSurface);
244
+ const surfaces = capabilityManager.getAll(Capabilities.ReactSurface);
265
245
  const candidates = findCandidates(surfaces.flat(), { role, data });
266
246
  return candidates.length > 0;
267
247
  };
@@ -16,7 +16,7 @@ import { createPortal } from 'react-dom';
16
16
  import { addEventListener, combine } from '@dxos/async';
17
17
  import { useMergeRefs } from '@dxos/react-hooks';
18
18
 
19
- import { useSurface } from './Surface';
19
+ import { useSurface } from '../../hooks';
20
20
 
21
21
  export type SurfaceInfoProps = {
22
22
  children: ReactElement<{ ref?: Ref<HTMLElement> }>;
@@ -76,7 +76,7 @@ export const SurfaceInfo = forwardRef<HTMLElement, SurfaceInfoProps>(({ children
76
76
  >
77
77
  {expand ? (
78
78
  <div
79
- className='absolute inset-0 bg-deckSurface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'
79
+ className='absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto'
80
80
  onPointerDown={(ev) => ev.stopPropagation()}
81
81
  onClick={(ev) => {
82
82
  ev.stopPropagation();
@@ -0,0 +1,12 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Context, createContext } from 'react';
6
+
7
+ import { type Props } from './types';
8
+
9
+ export type SurfaceContext = Pick<Props, 'id' | 'role' | 'data'>;
10
+
11
+ // TODO(burdon): Use @radix-ui/react-context
12
+ export const SurfaceContext: Context<SurfaceContext | undefined> = createContext<SurfaceContext | undefined>(undefined);
@@ -0,0 +1,20 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // TODO(wittjosiah): Cleanup to avoid re-naming.
6
+ import { SurfaceContext } from './context';
7
+ import { SurfaceComponent, isSurfaceAvailable } from './SurfaceComponent';
8
+ import { type Definition as SurfaceDefinition, create as createSurface, createWeb as createWebSurface } from './types';
9
+
10
+ export namespace Surface {
11
+ export type Definition = SurfaceDefinition;
12
+ export const create = createSurface;
13
+ export const createWeb = createWebSurface;
14
+
15
+ export type Context = SurfaceContext;
16
+ export const Context = SurfaceContext;
17
+
18
+ export const Surface = SurfaceComponent;
19
+ export const isAvailable = isSurfaceAvailable;
20
+ }
@@ -2,41 +2,39 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import type { PropsWithChildren, ReactNode, RefCallback } from 'react';
5
+ import type { FC, PropsWithChildren, ReactNode, RefCallback } from 'react';
6
6
 
7
7
  import type { MakeOptional, Position } from '@dxos/util';
8
8
 
9
- import type { ErrorBoundary } from '../react';
10
-
11
9
  /**
12
- * SurfaceProps are the props that are passed to the Surface component.
10
+ * Props that are passed to the Surface component.
13
11
  */
14
- export type SurfaceProps<T extends Record<string, any> = Record<string, unknown>> = {
12
+ export type Props<T extends Record<string, any> = Record<string, unknown>> = {
15
13
  /**
16
14
  * If specified, the Surface will be wrapped in an error boundary.
17
15
  * The fallback component will be rendered if an error occurs.
18
16
  */
19
- fallback?: ErrorBoundary['props']['fallback'];
17
+ fallback?: FC<{ error: Error; data?: any }>;
20
18
 
21
19
  /**
22
20
  * If specified, the Surface will be wrapped in a suspense boundary.
23
21
  * The placeholder component will be rendered while the surface component is loading.
24
22
  */
25
23
  placeholder?: ReactNode;
26
- } & MakeOptional<CoreSurfaceProps<T>, 'id' | 'data'> &
24
+ } & MakeOptional<CoreProps<T>, 'id' | 'data'> &
27
25
  /**
28
26
  * Additional props to pass to the component.
29
27
  * These props are not used by Surface itself but may be used by components which resolve the surface.
30
28
  * Exclude known prop names to prevent overriding well-defined props.
31
29
  */
32
30
  {
33
- [K in keyof Record<string, any>]: K extends keyof CoreSurfaceProps<T> | 'fallback' | 'placeholder' ? never : any;
31
+ [K in keyof Record<string, any>]: K extends keyof CoreProps<T> | 'fallback' | 'placeholder' ? never : any;
34
32
  };
35
33
 
36
34
  /**
37
35
  * NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
38
36
  */
39
- export type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
37
+ export type CoreProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
40
38
  /**
41
39
  * ID for debugging.
42
40
  */
@@ -59,33 +57,34 @@ export type CoreSurfaceProps<T extends Record<string, any> = Record<string, unkn
59
57
  limit?: number | undefined;
60
58
  }>;
61
59
 
62
- export type SurfaceComponentProps<T extends Record<string, any> = Record<string, any>> = CoreSurfaceProps<T> & {
60
+ // TODO(burdon): Remove ref since relying on this would be error prone.
61
+ export type ComponentProps<T extends Record<string, any> = Record<string, any>> = CoreProps<T> & {
63
62
  ref?: RefCallback<HTMLElement>;
64
63
  } & Record<string, any>;
65
64
 
66
65
  /**
67
66
  * React component used to render a surface once is has matched.
68
67
  */
69
- export type SurfaceComponent<T extends Record<string, any> = Record<string, any>> = (
70
- props: SurfaceComponentProps<T>,
68
+ export type ComponentFunction<T extends Record<string, any> = Record<string, any>> = (
69
+ props: ComponentProps<T>,
71
70
  ) => ReactNode;
72
71
 
73
72
  /**
74
- * Definition of when a React SurfaceComponent should be rendered.
73
+ * Definition of when a React component surface should be rendered.
75
74
  */
76
- export type ReactSurfaceDefinition<T extends Record<string, any> = any> = Readonly<{
75
+ export type ReactDefinition<T extends Record<string, any> = any> = Readonly<{
77
76
  kind: 'react';
78
77
  id: string;
79
78
  role: string | string[];
80
79
  position?: Position;
81
- component: SurfaceComponent<T>;
80
+ component: ComponentFunction<T>;
82
81
  filter?: (data: Record<string, unknown>) => data is T;
83
82
  }>;
84
83
 
85
84
  /**
86
85
  * Definition of when a Web Component surface should be rendered.
87
86
  */
88
- export type WebComponentSurfaceDefinition<T extends Record<string, any> = any> = Readonly<{
87
+ export type WebComponentDefinition<T extends Record<string, any> = any> = Readonly<{
89
88
  kind: 'web-component';
90
89
  id: string;
91
90
  role: string | string[];
@@ -101,20 +100,18 @@ export type WebComponentSurfaceDefinition<T extends Record<string, any> = any> =
101
100
  /**
102
101
  * Definition of when a surface (React or Web Component) should be rendered.
103
102
  */
104
- export type SurfaceDefinition<T extends Record<string, any> = any> =
105
- | ReactSurfaceDefinition<T>
106
- | WebComponentSurfaceDefinition<T>;
103
+ export type Definition<T extends Record<string, any> = any> = ReactDefinition<T> | WebComponentDefinition<T>;
107
104
 
108
105
  /**
109
106
  * Creates a React surface definition.
110
107
  */
111
- export const createSurface = <T extends Record<string, any> = any>(
112
- definition: Omit<ReactSurfaceDefinition<T>, 'kind'>,
113
- ): ReactSurfaceDefinition<T> => ({ ...definition, kind: 'react' });
108
+ export const create = <T extends Record<string, any> = any>(
109
+ definition: Omit<ReactDefinition<T>, 'kind'>,
110
+ ): ReactDefinition<T> => ({ ...definition, kind: 'react' });
114
111
 
115
112
  /**
116
113
  * Creates a Web Component surface definition.
117
114
  */
118
- export const createWebSurface = <T extends Record<string, any> = any>(
119
- definition: Omit<WebComponentSurfaceDefinition<T>, 'kind'>,
120
- ): WebComponentSurfaceDefinition<T> => ({ ...definition, kind: 'web-component' });
115
+ export const createWeb = <T extends Record<string, any> = any>(
116
+ definition: Omit<WebComponentDefinition<T>, 'kind'>,
117
+ ): WebComponentDefinition<T> => ({ ...definition, kind: 'web-component' });
@@ -0,0 +1,7 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './App';
6
+ export * from './PluginManager';
7
+ export * from './Surface';
@@ -0,0 +1,10 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './useApp';
6
+ export * from './useCapabilities';
7
+ export * from './useLoading';
8
+ export * from './useOperationResolver';
9
+ export * from './useSettingsState';
10
+ export * from './useSurface';
@@ -0,0 +1,159 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { assert, describe, it } from '@effect/vitest';
6
+ import { render, waitFor } from '@testing-library/react';
7
+ import * as Effect from 'effect/Effect';
8
+ import React from 'react';
9
+
10
+ import { ActivationEvents, Capabilities } from '../../common';
11
+ import { Capability, Plugin, PluginManager } from '../../core';
12
+ import { useApp } from './useApp';
13
+
14
+ const String = Capability.make<{ string: string }>('org.dxos.test.string');
15
+ const testMeta = { id: 'org.dxos.plugin.test', name: 'Test' };
16
+
17
+ const pluginLoader = (plugins: Plugin.Plugin[]) =>
18
+ Effect.fn(function* (id: string) {
19
+ const plugin = plugins.find((plugin) => plugin.meta.id === id);
20
+ if (!plugin) {
21
+ return yield* Effect.fail(new Error(`Plugin not found: ${id}`));
22
+ }
23
+ return plugin;
24
+ });
25
+
26
+ const TestHost = ({ manager }: { manager: PluginManager.PluginManager }) => {
27
+ const App = useApp({ pluginManager: manager });
28
+ return <App />;
29
+ };
30
+
31
+ describe('useApp cleanup integration', () => {
32
+ it.effect('external manager is not shut down when useApp does not own it', () =>
33
+ Effect.gen(function* () {
34
+ const plugin = Plugin.define(testMeta).pipe(
35
+ Plugin.addModule({
36
+ id: 'Hello',
37
+ activatesOn: ActivationEvents.Startup,
38
+ activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
39
+ }),
40
+ Plugin.make,
41
+ )();
42
+
43
+ const manager = PluginManager.make({
44
+ pluginLoader: pluginLoader([plugin]),
45
+ plugins: [plugin],
46
+ });
47
+
48
+ manager.capabilities.contribute({
49
+ interface: Capabilities.PluginManager,
50
+ implementation: manager,
51
+ module: 'org.dxos.app-framework.plugin-manager',
52
+ });
53
+ manager.capabilities.contribute({
54
+ interface: Capabilities.AtomRegistry,
55
+ implementation: manager.registry,
56
+ module: 'org.dxos.app-framework.atom-registry',
57
+ });
58
+
59
+ const view = yield* Effect.promise(() => Promise.resolve(render(<TestHost manager={manager} />)));
60
+ yield* Effect.promise(() =>
61
+ waitFor(() => {
62
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
63
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
64
+ assert.strictEqual(manager.capabilities.getAll(String).length, 1);
65
+ assert.isTrue(manager.getActive().length > 0);
66
+ }),
67
+ );
68
+
69
+ yield* Effect.promise(() => Promise.resolve(view.unmount()));
70
+ yield* Effect.promise(() =>
71
+ waitFor(() => {
72
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
73
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
74
+ assert.strictEqual(manager.capabilities.getAll(String).length, 1);
75
+ assert.isTrue(manager.getActive().length > 0);
76
+ }),
77
+ );
78
+
79
+ yield* manager.shutdown();
80
+
81
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.PluginManager).length, 1);
82
+ assert.strictEqual(manager.capabilities.getAll(Capabilities.AtomRegistry).length, 1);
83
+ assert.strictEqual(manager.capabilities.getAll(String).length, 0);
84
+ assert.deepStrictEqual(manager.getActive(), []);
85
+ }),
86
+ );
87
+
88
+ it.effect('shutdown deactivates modules and clears bookkeeping', () =>
89
+ Effect.gen(function* () {
90
+ const plugin = Plugin.define(testMeta).pipe(
91
+ Plugin.addModule({
92
+ id: 'Hello',
93
+ activatesOn: ActivationEvents.Startup,
94
+ activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
95
+ }),
96
+ Plugin.make,
97
+ )();
98
+
99
+ const manager = PluginManager.make({
100
+ pluginLoader: pluginLoader([plugin]),
101
+ plugins: [plugin],
102
+ });
103
+
104
+ manager.capabilities.contribute({
105
+ interface: Capabilities.PluginManager,
106
+ implementation: manager,
107
+ module: 'org.dxos.app-framework.plugin-manager',
108
+ });
109
+ manager.capabilities.contribute({
110
+ interface: Capabilities.AtomRegistry,
111
+ implementation: manager.registry,
112
+ module: 'org.dxos.app-framework.atom-registry',
113
+ });
114
+ yield* manager.activate(ActivationEvents.Startup);
115
+
116
+ assert.strictEqual(manager.capabilities.getAll(String).length, 1);
117
+ assert.isTrue(manager.getActive().length > 0);
118
+
119
+ yield* manager.shutdown();
120
+
121
+ assert.strictEqual(manager.capabilities.getAll(String).length, 0);
122
+ assert.deepStrictEqual(manager.getActive(), []);
123
+ assert.deepStrictEqual(manager.getEventsFired(), []);
124
+ }),
125
+ );
126
+
127
+ it.effect('shutdown is idempotent when called multiple times', () =>
128
+ Effect.gen(function* () {
129
+ const plugin = Plugin.define(testMeta).pipe(
130
+ Plugin.addModule({
131
+ id: 'Hello',
132
+ activatesOn: ActivationEvents.Startup,
133
+ activate: () => Effect.succeed(Capability.contributes(String, { string: 'hello' })),
134
+ }),
135
+ Plugin.make,
136
+ )();
137
+
138
+ const manager = PluginManager.make({
139
+ pluginLoader: pluginLoader([plugin]),
140
+ plugins: [plugin],
141
+ });
142
+
143
+ manager.capabilities.contribute({
144
+ interface: Capabilities.PluginManager,
145
+ implementation: manager,
146
+ module: 'org.dxos.app-framework.plugin-manager',
147
+ });
148
+ yield* manager.activate(ActivationEvents.Startup);
149
+
150
+ yield* manager.shutdown();
151
+ assert.deepStrictEqual(manager.getActive(), []);
152
+
153
+ // Second shutdown should succeed without error.
154
+ const result = yield* manager.shutdown();
155
+ assert.isTrue(result);
156
+ assert.deepStrictEqual(manager.getActive(), []);
157
+ }),
158
+ );
159
+ });