@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
@@ -1,41 +1,248 @@
1
1
  import {
2
2
  PluginManagerContext
3
- } from "./chunk-FHQTHCX7.mjs";
3
+ } from "./chunk-TGX63LTL.mjs";
4
4
  import {
5
- ActivationEvent,
6
- Capability
7
- } from "./chunk-BLQJSGL3.mjs";
5
+ capabilities_exports
6
+ } from "./chunk-WEBSGU5L.mjs";
7
+ import {
8
+ activation_events_exports
9
+ } from "./chunk-M5IC326L.mjs";
8
10
  import {
9
11
  plugin_manager_exports
10
- } from "./chunk-FMZN33N4.mjs";
12
+ } from "./chunk-3VXJONTI.mjs";
11
13
 
12
- // src/react/common.ts
13
- import { RegistryContext, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
14
- import { useCallback as useCallback2, useContext as useContext2 } from "react";
14
+ // src/ui/components/App/App.tsx
15
+ import React2 from "react";
15
16
 
16
- // src/react/useCapabilities.ts
17
- import { useAtomValue } from "@effect-atom/atom-react";
18
- import { useCallback } from "react";
19
- import { invariant } from "@dxos/invariant";
17
+ // src/helpers.ts
18
+ var topologicalSort = (nodes) => {
19
+ const getDependencies = (nodeId, seen = /* @__PURE__ */ new Set(), path = /* @__PURE__ */ new Set()) => {
20
+ if (path.has(nodeId)) {
21
+ throw new Error(`Circular dependency detected involving ${nodeId}`);
22
+ }
23
+ if (seen.has(nodeId)) {
24
+ return [];
25
+ }
26
+ const node = nodes.find((n) => n.id === nodeId);
27
+ if (!node) {
28
+ throw new Error(`Node ${nodeId} not found but is listed as a dependency`);
29
+ }
30
+ const newPath = /* @__PURE__ */ new Set([
31
+ ...path,
32
+ nodeId
33
+ ]);
34
+ const newSeen = /* @__PURE__ */ new Set([
35
+ ...seen,
36
+ nodeId
37
+ ]);
38
+ const dependsOn = node.dependsOn ?? [];
39
+ return [
40
+ ...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)),
41
+ nodeId
42
+ ];
43
+ };
44
+ const allDependencies = nodes.map((node) => node.id).flatMap((id) => getDependencies(id)).filter((id, index, self) => self.indexOf(id) === index);
45
+ return allDependencies.map((id) => nodes.find((node) => node.id === id)).filter((node) => node !== void 0);
46
+ };
20
47
 
21
- // src/react/PluginManagerProvider.ts
22
- import { createContext, useContext } from "react";
23
- import { raise } from "@dxos/debug";
24
- var PluginManagerContext2 = createContext(void 0);
25
- var usePluginManager = () => useContext(PluginManagerContext2) ?? raise(new Error("Missing PluginManagerContext"));
26
- var PluginManagerProvider = PluginManagerContext2.Provider;
48
+ // src/ui/hooks/useApp.tsx
49
+ import { RegistryContext } from "@effect-atom/atom-react";
50
+ import * as Effect from "effect/Effect";
51
+ import * as Fiber from "effect/Fiber";
52
+ import * as PubSub from "effect/PubSub";
53
+ import * as Queue from "effect/Queue";
54
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
55
+ import { runAndForwardErrors } from "@dxos/effect";
56
+ import { invariant } from "@dxos/invariant";
57
+ import { log } from "@dxos/log";
58
+ import { ErrorBoundary, ErrorFallback } from "@dxos/react-error-boundary";
59
+ import { useAsyncEffect, useDefaultValue } from "@dxos/react-hooks";
60
+ import { ContextProtocolProvider } from "@dxos/web-context-react";
61
+ var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/hooks/useApp.tsx";
62
+ var ENABLED_KEY = "org.dxos.app-framework.enabled";
63
+ var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, plugins: pluginsProp, core: coreProp, defaults: defaultsProp, setupEvents: setupEventsProp, placeholder, fallback = ErrorFallback, cacheEnabled = false, safeMode = false, debounce = 0, timeout = 3e4 }) => {
64
+ const plugins = useDefaultValue(pluginsProp, () => []);
65
+ const core = useDefaultValue(coreProp, () => plugins.map(({ meta }) => meta.id));
66
+ const defaults = useDefaultValue(defaultsProp, () => []);
67
+ const setupEvents = useDefaultValue(setupEventsProp, () => []);
68
+ const pluginLoader = useMemo(() => pluginLoaderProp ?? ((id) => Effect.sync(() => {
69
+ const plugin = plugins.find((plugin2) => plugin2.meta.id === id);
70
+ invariant(plugin, `Plugin not found: ${id}`, {
71
+ F: __dxlog_file,
72
+ L: 96,
73
+ S: void 0,
74
+ A: [
75
+ "plugin",
76
+ "`Plugin not found: ${id}`"
77
+ ]
78
+ });
79
+ return plugin;
80
+ })), [
81
+ pluginLoaderProp,
82
+ plugins
83
+ ]);
84
+ const readyRef = useRef(false);
85
+ const [ready, setReady] = useState(false);
86
+ const errorRef = useRef(null);
87
+ const [error, setError] = useState(null);
88
+ const cached = useMemo(() => JSON.parse(localStorage.getItem(ENABLED_KEY) ?? "[]"), []);
89
+ const enabled = useMemo(() => safeMode ? [] : cacheEnabled && cached.length > 0 ? cached : defaults, [
90
+ safeMode,
91
+ cacheEnabled,
92
+ cached,
93
+ defaults
94
+ ]);
95
+ const isExternalManager = !!pluginManager;
96
+ const manager = useMemo(() => {
97
+ const mgr = pluginManager ?? plugin_manager_exports.make({
98
+ pluginLoader,
99
+ plugins,
100
+ core,
101
+ enabled
102
+ });
103
+ log("useApp: useMemo created/reused manager", {
104
+ provided: !!pluginManager
105
+ }, {
106
+ F: __dxlog_file,
107
+ L: 115,
108
+ S: void 0,
109
+ C: (f, a) => f(...a)
110
+ });
111
+ return mgr;
112
+ }, [
113
+ pluginManager,
114
+ pluginLoader,
115
+ plugins,
116
+ core,
117
+ enabled
118
+ ]);
119
+ useEffect(() => {
120
+ if (!cacheEnabled) {
121
+ return;
122
+ }
123
+ return manager.registry.subscribe(manager.enabled, (value) => {
124
+ localStorage.setItem(ENABLED_KEY, JSON.stringify(value));
125
+ });
126
+ }, [
127
+ cacheEnabled,
128
+ manager
129
+ ]);
130
+ useEffect(() => {
131
+ setupDevtools(manager);
132
+ }, [
133
+ manager
134
+ ]);
135
+ useAsyncEffect(async () => {
136
+ log("useApp: effect mount", void 0, {
137
+ F: __dxlog_file,
138
+ L: 133,
139
+ S: void 0,
140
+ C: (f, a) => f(...a)
141
+ });
142
+ manager.capabilities.contribute({
143
+ interface: capabilities_exports.PluginManager,
144
+ implementation: manager,
145
+ module: "org.dxos.app-framework.plugin-manager"
146
+ });
147
+ manager.capabilities.contribute({
148
+ interface: capabilities_exports.AtomRegistry,
149
+ implementation: manager.registry,
150
+ module: "org.dxos.app-framework.atom-registry"
151
+ });
152
+ const fiber = Effect.gen(function* () {
153
+ const queue = yield* PubSub.subscribe(manager.activation);
154
+ const listener = yield* Effect.forkDaemon(Queue.take(queue).pipe(Effect.tap(({ event, state, error: error$ }) => Effect.sync(() => {
155
+ if (event === activation_events_exports.Startup.id && state === "activated") {
156
+ clearTimeout(timeoutId);
157
+ setReady(true);
158
+ readyRef.current = true;
159
+ }
160
+ if (error$ && !readyRef.current) {
161
+ setError(error$);
162
+ errorRef.current = error$;
163
+ }
164
+ })), Effect.forever));
165
+ yield* Effect.all([
166
+ ...setupEvents.map((event) => manager.activate(event)),
167
+ manager.activate(activation_events_exports.SetupReactSurface),
168
+ manager.activate(activation_events_exports.Startup)
169
+ ]);
170
+ return yield* Fiber.join(listener);
171
+ }).pipe(Effect.scoped, Effect.runFork);
172
+ const timeoutId = setTimeout(() => {
173
+ if (!readyRef.current && !errorRef.current) {
174
+ log.warn("startup timeout diagnostic", {
175
+ eventsFired: manager.getEventsFired(),
176
+ activeModules: manager.getActive(),
177
+ pendingReset: manager.getPendingReset()
178
+ }, {
179
+ F: __dxlog_file,
180
+ L: 180,
181
+ S: void 0,
182
+ C: (f, a) => f(...a)
183
+ });
184
+ void runAndForwardErrors(Fiber.interrupt(fiber));
185
+ setError(new Error(`Startup timed out after ${timeout}ms`));
186
+ }
187
+ }, timeout);
188
+ return () => {
189
+ log("useApp: effect cleanup", void 0, {
190
+ F: __dxlog_file,
191
+ L: 191,
192
+ S: void 0,
193
+ C: (f, a) => f(...a)
194
+ });
195
+ clearTimeout(timeoutId);
196
+ void runAndForwardErrors(Fiber.interrupt(fiber));
197
+ if (!isExternalManager) {
198
+ void runAndForwardErrors(manager.shutdown());
199
+ }
200
+ };
201
+ }, [
202
+ manager
203
+ ]);
204
+ return useCallback(() => /* @__PURE__ */ React.createElement(ErrorBoundary, {
205
+ name: "app",
206
+ FallbackComponent: fallback
207
+ }, /* @__PURE__ */ React.createElement(PluginManagerProvider, {
208
+ value: manager
209
+ }, /* @__PURE__ */ React.createElement(ContextProtocolProvider, {
210
+ value: manager,
211
+ context: PluginManagerContext
212
+ }, /* @__PURE__ */ React.createElement(RegistryContext.Provider, {
213
+ value: manager.registry
214
+ }, /* @__PURE__ */ React.createElement(App, {
215
+ placeholder,
216
+ ready,
217
+ error,
218
+ debounce
219
+ }))))), [
220
+ fallback,
221
+ manager,
222
+ placeholder,
223
+ ready,
224
+ error
225
+ ]);
226
+ };
227
+ var setupDevtools = (manager) => {
228
+ globalThis.composer ??= {};
229
+ globalThis.composer.manager = manager;
230
+ };
27
231
 
28
- // src/react/useCapabilities.ts
29
- var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/react/useCapabilities.ts";
232
+ // src/ui/hooks/useCapabilities.ts
233
+ import { useAtomValue } from "@effect-atom/atom-react";
234
+ import { useCallback as useCallback2 } from "react";
235
+ import { invariant as invariant2 } from "@dxos/invariant";
236
+ var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/hooks/useCapabilities.ts";
30
237
  var useCapabilities = (interfaceDef) => {
31
238
  const manager = usePluginManager();
32
239
  return useAtomValue(manager.capabilities.atom(interfaceDef));
33
240
  };
34
241
  var useCapability = (interfaceDef) => {
35
242
  const capabilities = useCapabilities(interfaceDef);
36
- invariant(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, {
37
- F: __dxlog_file,
38
- L: 31,
243
+ invariant2(capabilities.length > 0, `No capability found for ${interfaceDef.identifier}`, {
244
+ F: __dxlog_file2,
245
+ L: 30,
39
246
  S: void 0,
40
247
  A: [
41
248
  "capabilities.length > 0",
@@ -49,10 +256,10 @@ var useAtomCapability = (atomCapability) => {
49
256
  return useAtomValue(atom);
50
257
  };
51
258
  var useAtomCapabilityState = (atomCapability) => {
52
- const registry = useCapability(Capability.AtomRegistry);
259
+ const registry = useCapability(capabilities_exports.AtomRegistry);
53
260
  const atom = useCapability(atomCapability);
54
261
  const value = useAtomValue(atom);
55
- const update = useCallback((fn) => {
262
+ const update = useCallback2((fn) => {
56
263
  registry.set(atom, fn(registry.get(atom)));
57
264
  }, [
58
265
  registry,
@@ -63,15 +270,87 @@ var useAtomCapabilityState = (atomCapability) => {
63
270
  update
64
271
  ];
65
272
  };
273
+ var useOperationInvoker = () => useCapability(capabilities_exports.OperationInvoker);
274
+
275
+ // src/ui/hooks/useLoading.tsx
276
+ import { useEffect as useEffect2, useState as useState2 } from "react";
277
+ var LoadingState = /* @__PURE__ */ (function(LoadingState2) {
278
+ LoadingState2[LoadingState2["Loading"] = 0] = "Loading";
279
+ LoadingState2[LoadingState2["FadeIn"] = 1] = "FadeIn";
280
+ LoadingState2[LoadingState2["FadeOut"] = 2] = "FadeOut";
281
+ LoadingState2[LoadingState2["Done"] = 3] = "Done";
282
+ return LoadingState2;
283
+ })({});
284
+ var useLoading = (ready, debounce = 0) => {
285
+ const [stage, setStage] = useState2(0);
286
+ useEffect2(() => {
287
+ if (!debounce) {
288
+ return;
289
+ }
290
+ const i = setInterval(() => {
291
+ setStage((stage2) => {
292
+ switch (stage2) {
293
+ case 0: {
294
+ if (!ready) {
295
+ return 1;
296
+ } else {
297
+ clearInterval(i);
298
+ return 3;
299
+ }
300
+ }
301
+ case 1: {
302
+ if (ready) {
303
+ return 2;
304
+ }
305
+ break;
306
+ }
307
+ case 2: {
308
+ clearInterval(i);
309
+ return 3;
310
+ }
311
+ }
312
+ return stage2;
313
+ });
314
+ }, debounce);
315
+ return () => clearInterval(i);
316
+ }, [
317
+ debounce
318
+ ]);
319
+ if (!debounce) {
320
+ return ready ? 3 : 0;
321
+ }
322
+ return stage;
323
+ };
324
+
325
+ // src/ui/hooks/useOperationResolver.ts
326
+ import { useEffect as useEffect3, useMemo as useMemo2 } from "react";
327
+ var useOperationResolver = (module, resolver) => {
328
+ const manager = usePluginManager();
329
+ const resolverArray = useMemo2(() => [
330
+ resolver
331
+ ], [
332
+ resolver
333
+ ]);
334
+ useEffect3(() => {
335
+ manager.capabilities.contribute({
336
+ module,
337
+ interface: capabilities_exports.OperationResolver,
338
+ implementation: resolverArray
339
+ });
340
+ return () => manager.capabilities.remove(capabilities_exports.OperationResolver, resolverArray);
341
+ }, [
342
+ module,
343
+ resolverArray
344
+ ]);
345
+ };
66
346
 
67
- // src/react/common.ts
68
- var useOperationInvoker = () => useCapability(Capability.OperationInvoker);
69
- var useAppGraph = () => useCapability(Capability.AppGraph);
70
- var useLayout = () => useAtomCapability(Capability.Layout);
347
+ // src/ui/hooks/useSettingsState.ts
348
+ import { RegistryContext as RegistryContext2, useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
349
+ import { useCallback as useCallback3, useContext } from "react";
71
350
  var useSettingsState = (atom) => {
72
- const registry = useContext2(RegistryContext);
351
+ const registry = useContext(RegistryContext2);
73
352
  const settings = useAtomValue2(atom);
74
- const updateSettings = useCallback2((fn) => {
353
+ const updateSettings = useCallback3((fn) => {
75
354
  registry.set(atom, fn(registry.get(atom)));
76
355
  }, [
77
356
  registry,
@@ -83,66 +362,70 @@ var useSettingsState = (atom) => {
83
362
  };
84
363
  };
85
364
 
86
- // src/react/ErrorBoundary.tsx
87
- import React, { Component } from "react";
88
- var ErrorBoundary = class extends Component {
89
- static getDerivedStateFromError(error) {
90
- return {
91
- error
92
- };
93
- }
94
- state = {
95
- error: void 0
96
- };
97
- componentDidUpdate(prevProps) {
98
- if (prevProps.data !== this.props.data) {
99
- this.resetError();
100
- }
365
+ // src/ui/hooks/useSurface.ts
366
+ import { useContext as useContext2 } from "react";
367
+ import { raise } from "@dxos/debug";
368
+ var useSurface = () => {
369
+ return useContext2(Surface.Context) ?? raise(new Error("Missing SurfaceContext"));
370
+ };
371
+
372
+ // src/ui/components/App/App.tsx
373
+ var App = ({ placeholder: Placeholder, ready, error, debounce }) => {
374
+ const reactContexts = useCapabilities(capabilities_exports.ReactContext);
375
+ const reactRoots = useCapabilities(capabilities_exports.ReactRoot);
376
+ const stage = useLoading(ready, debounce);
377
+ if (error) {
378
+ throw error;
101
379
  }
102
- render() {
103
- if (this.state.error) {
104
- const Fallback = this.props.fallback ?? DefaultFallback;
105
- return /* @__PURE__ */ React.createElement(Fallback, {
106
- data: this.props.data,
107
- error: this.state.error
108
- });
380
+ if (stage < LoadingState.Done) {
381
+ if (!Placeholder) {
382
+ return null;
109
383
  }
110
- return this.props.children;
111
- }
112
- resetError() {
113
- this.setState({
114
- error: void 0
384
+ return /* @__PURE__ */ React2.createElement(Placeholder, {
385
+ stage
115
386
  });
116
387
  }
388
+ const ComposedContext = composeContexts(reactContexts);
389
+ return /* @__PURE__ */ React2.createElement(ComposedContext, null, reactRoots.map(({ id, root: Component }) => /* @__PURE__ */ React2.createElement(Component, {
390
+ key: id
391
+ })));
117
392
  };
118
- var DefaultFallback = ({ data, error }) => {
119
- return /* @__PURE__ */ React.createElement("div", {
120
- className: "flex flex-col gap-2 overflow-hidden border border-red-500 rounded-sm"
121
- }, /* @__PURE__ */ React.createElement("h1", {
122
- className: "p-2"
123
- }, "ERROR: ", error.message), /* @__PURE__ */ React.createElement("pre", {
124
- className: "p-2 overflow-y-auto text-sm text-subdued"
125
- }, JSON.stringify(data, null, 2)));
393
+ var composeContexts = (contexts) => {
394
+ if (contexts.length === 0) {
395
+ return ({ children }) => /* @__PURE__ */ React2.createElement(React2.Fragment, null, children);
396
+ }
397
+ return topologicalSort(contexts).map(({ context }) => context).reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React2.createElement(Acc, null, /* @__PURE__ */ React2.createElement(Next, null, children)));
126
398
  };
127
399
 
128
- // src/react/Surface.tsx
129
- import React3, { Fragment, Suspense, createContext as createContext2, forwardRef as forwardRef2, memo, useContext as useContext3, useEffect, useMemo, useRef } from "react";
400
+ // src/ui/components/PluginManager/PluginManagerProvider.ts
401
+ import { createContext, useContext as useContext3 } from "react";
130
402
  import { raise as raise2 } from "@dxos/debug";
131
- import { log } from "@dxos/log";
132
- import { useDefaultValue } from "@dxos/react-hooks";
403
+ var PluginManagerContext2 = createContext(void 0);
404
+ var usePluginManager = () => useContext3(PluginManagerContext2) ?? raise2(new Error("Missing PluginManagerContext"));
405
+ var PluginManagerProvider = PluginManagerContext2.Provider;
406
+
407
+ // src/ui/components/Surface/context.ts
408
+ import { createContext as createContext2 } from "react";
409
+ var SurfaceContext = createContext2(void 0);
410
+
411
+ // src/ui/components/Surface/SurfaceComponent.tsx
412
+ import React4, { Fragment, Suspense, forwardRef as forwardRef2, memo, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef2 } from "react";
413
+ import { log as log2 } from "@dxos/log";
414
+ import { ErrorBoundary as ErrorBoundary2 } from "@dxos/react-error-boundary";
415
+ import { useDefaultValue as useDefaultValue2 } from "@dxos/react-hooks";
133
416
  import { byPosition } from "@dxos/util";
134
417
 
135
- // src/react/SurfaceInfo.tsx
136
- import React2, { cloneElement, forwardRef, useCallback as useCallback3, useLayoutEffect, useState } from "react";
418
+ // src/ui/components/Surface/SurfaceInfo.tsx
419
+ import React3, { cloneElement, forwardRef, useCallback as useCallback4, useLayoutEffect, useState as useState3 } from "react";
137
420
  import { createPortal } from "react-dom";
138
421
  import { addEventListener, combine } from "@dxos/async";
139
422
  import { useMergeRefs } from "@dxos/react-hooks";
140
423
  var SurfaceInfo = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
141
- const [rect, setRect] = useState(null);
142
- const [expand, setExpand] = useState(false);
424
+ const [rect, setRect] = useState3(null);
425
+ const [expand, setExpand] = useState3(false);
143
426
  const info = useSurface();
144
- const [root, setRoot] = useState(null);
145
- const measureRef = useCallback3((node) => setRoot(node), []);
427
+ const [root, setRoot] = useState3(null);
428
+ const measureRef = useCallback4((node) => setRoot(node), []);
146
429
  const mergedRef = useMergeRefs([
147
430
  measureRef,
148
431
  forwardedRef
@@ -168,8 +451,8 @@ var SurfaceInfo = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
168
451
  root
169
452
  ]);
170
453
  const padding = 0;
171
- return /* @__PURE__ */ React2.createElement(React2.Fragment, null, childWithRef, rect && /* @__PURE__ */ createPortal(
172
- /* @__PURE__ */ React2.createElement("div", {
454
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, childWithRef, rect && /* @__PURE__ */ createPortal(
455
+ /* @__PURE__ */ React3.createElement("div", {
173
456
  role: "none",
174
457
  className: "z-[100] fixed flex flex-col-reverse scrollbar-none overflow-auto pointer-events-none",
175
458
  style: {
@@ -178,18 +461,18 @@ var SurfaceInfo = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
178
461
  width: rect.width - padding * 2,
179
462
  height: rect.height - padding * 2
180
463
  }
181
- }, expand ? /* @__PURE__ */ React2.createElement("div", {
182
- className: "absolute inset-0 bg-deckSurface border border-green-500 cursor-pointer pointer-events-auto overflow-auto",
464
+ }, expand ? /* @__PURE__ */ React3.createElement("div", {
465
+ className: "absolute inset-0 bg-deck-surface border border-green-500 cursor-pointer pointer-events-auto overflow-auto",
183
466
  onPointerDown: (ev) => ev.stopPropagation(),
184
467
  onClick: (ev) => {
185
468
  ev.stopPropagation();
186
469
  setExpand(false);
187
470
  }
188
- }, /* @__PURE__ */ React2.createElement("pre", {
471
+ }, /* @__PURE__ */ React3.createElement("pre", {
189
472
  className: "p-2 text-xs text-description font-mono"
190
473
  }, JSON.stringify({
191
474
  info
192
- }, null, 2))) : /* @__PURE__ */ React2.createElement("span", {
475
+ }, null, 2))) : /* @__PURE__ */ React3.createElement("span", {
193
476
  className: "absolute right-1 bottom-0 flex items-center p-1 text-green-500 opacity-80 hover:opacity-100 text-xl cursor-pointer pointer-events-auto",
194
477
  title: info.id,
195
478
  onPointerDown: (ev) => ev.stopPropagation(),
@@ -203,15 +486,14 @@ var SurfaceInfo = /* @__PURE__ */ forwardRef(({ children }, forwardedRef) => {
203
486
  ));
204
487
  });
205
488
 
206
- // src/react/Surface.tsx
207
- var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/react/Surface.tsx";
208
- var DEFAULT_PLACEHOLDER = /* @__PURE__ */ React3.createElement(Fragment, null);
489
+ // src/ui/components/Surface/SurfaceComponent.tsx
490
+ var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/ui/components/Surface/SurfaceComponent.tsx";
491
+ var DEFAULT_PLACEHOLDER = /* @__PURE__ */ React4.createElement(Fragment, null);
209
492
  var DEBUG = import.meta.env.VITE_DEBUG;
210
- var SurfaceContext = /* @__PURE__ */ createContext2(void 0);
211
493
  var WebComponentWrapper = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id, role, data, limit, definition, ...rest }, forwardedRef) => {
212
- const containerRef = useRef(null);
213
- const elementRef = useRef(null);
214
- const propsRef = useRef({
494
+ const containerRef = useRef2(null);
495
+ const elementRef = useRef2(null);
496
+ const propsRef = useRef2({
215
497
  id,
216
498
  role,
217
499
  data,
@@ -225,8 +507,10 @@ var WebComponentWrapper = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id
225
507
  limit,
226
508
  ...rest
227
509
  };
228
- useEffect(() => {
229
- if (!containerRef.current || elementRef.current) return;
510
+ useEffect4(() => {
511
+ if (!containerRef.current || elementRef.current) {
512
+ return;
513
+ }
230
514
  const element = document.createElement(definition.tagName);
231
515
  elementRef.current = element;
232
516
  Object.assign(element, propsRef.current);
@@ -251,18 +535,20 @@ var WebComponentWrapper = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id
251
535
  definition.tagName,
252
536
  forwardedRef
253
537
  ]);
254
- useEffect(() => {
538
+ useEffect4(() => {
255
539
  const element = elementRef.current;
256
- if (!element) return;
540
+ if (!element) {
541
+ return;
542
+ }
257
543
  Object.assign(element, propsRef.current);
258
544
  });
259
- return /* @__PURE__ */ React3.createElement("div", {
545
+ return /* @__PURE__ */ React4.createElement("div", {
260
546
  ref: containerRef
261
547
  });
262
548
  }));
263
549
  WebComponentWrapper.displayName = "WebComponentWrapper";
264
- var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id, role, data, limit, fallback = DefaultFallback2, definition, ...rest }, forwardedRef) => {
265
- const contextValue = useMemo(() => ({
550
+ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id, role, data, limit, fallback = ErrorFallback2, definition, ...rest }, forwardedRef) => {
551
+ const contextValue = useMemo3(() => ({
266
552
  id,
267
553
  role,
268
554
  data
@@ -272,12 +558,15 @@ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({
272
558
  data
273
559
  ]);
274
560
  if (definition.kind === "web-component") {
275
- return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
276
- data,
277
- fallback
278
- }, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
561
+ return /* @__PURE__ */ React4.createElement(ErrorBoundary2, {
562
+ name: "surface",
563
+ resetKeys: [
564
+ data
565
+ ],
566
+ FallbackComponent: fallback
567
+ }, /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
279
568
  value: contextValue
280
- }, /* @__PURE__ */ React3.createElement(WebComponentWrapper, {
569
+ }, /* @__PURE__ */ React4.createElement(WebComponentWrapper, {
281
570
  id,
282
571
  role,
283
572
  data,
@@ -287,22 +576,25 @@ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({
287
576
  ...rest
288
577
  })));
289
578
  }
290
- const Component2 = definition.component;
579
+ const Component = definition.component;
291
580
  const debug = DEBUG || "__DX_DEBUG__" in window;
292
581
  if (debug) {
293
- return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
294
- data,
295
- fallback
296
- }, /* @__PURE__ */ React3.createElement("div", {
582
+ return /* @__PURE__ */ React4.createElement(ErrorBoundary2, {
583
+ name: "surface",
584
+ resetKeys: [
585
+ data
586
+ ],
587
+ FallbackComponent: fallback
588
+ }, /* @__PURE__ */ React4.createElement("div", {
297
589
  role: "none",
298
590
  className: "contents",
299
591
  "data-id": id,
300
592
  "data-role": role
301
- }, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
593
+ }, /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
302
594
  value: contextValue
303
- }, /* @__PURE__ */ React3.createElement(SurfaceInfo, {
595
+ }, /* @__PURE__ */ React4.createElement(SurfaceInfo, {
304
596
  ref: forwardedRef
305
- }, /* @__PURE__ */ React3.createElement(Component2, {
597
+ }, /* @__PURE__ */ React4.createElement(Component, {
306
598
  id,
307
599
  role,
308
600
  data,
@@ -310,17 +602,20 @@ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({
310
602
  ...rest
311
603
  })))));
312
604
  }
313
- return /* @__PURE__ */ React3.createElement(ErrorBoundary, {
314
- data,
315
- fallback
316
- }, /* @__PURE__ */ React3.createElement("div", {
605
+ return /* @__PURE__ */ React4.createElement(ErrorBoundary2, {
606
+ name: "surface",
607
+ resetKeys: [
608
+ data
609
+ ],
610
+ FallbackComponent: fallback
611
+ }, /* @__PURE__ */ React4.createElement("div", {
317
612
  role: "none",
318
613
  className: "contents",
319
614
  "data-id": id,
320
615
  "data-role": role
321
- }, /* @__PURE__ */ React3.createElement(SurfaceContext.Provider, {
616
+ }, /* @__PURE__ */ React4.createElement(SurfaceContext.Provider, {
322
617
  value: contextValue
323
- }, /* @__PURE__ */ React3.createElement(Component2, {
618
+ }, /* @__PURE__ */ React4.createElement(Component, {
324
619
  id,
325
620
  role,
326
621
  data,
@@ -330,12 +625,8 @@ var SurfaceContextProvider = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({
330
625
  }))));
331
626
  }));
332
627
  SurfaceContextProvider.displayName = "SurfaceContextProvider";
333
- var useSurface = () => {
334
- const context = useContext3(SurfaceContext) ?? raise2(new Error("Missing SurfaceContext"));
335
- return context;
336
- };
337
- var Surface = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
338
- const data = useDefaultValue(dataProp, () => ({}));
628
+ var SurfaceComponent = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role, data: dataProp, limit, placeholder = DEFAULT_PLACEHOLDER, ...rest }, forwardedRef) => {
629
+ const data = useDefaultValue2(dataProp, () => ({}));
339
630
  const surfaces = useSurfaces();
340
631
  const definitions = findCandidates(surfaces, {
341
632
  role,
@@ -343,20 +634,20 @@ var Surface = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role,
343
634
  });
344
635
  const candidates = limit ? definitions.slice(0, limit) : definitions;
345
636
  if (DEBUG && candidates.length === 0) {
346
- log.warn("no candidates for surface", {
637
+ log2.warn("no candidates for surface", {
347
638
  role,
348
639
  data
349
640
  }, {
350
- F: __dxlog_file2,
351
- L: 191,
641
+ F: __dxlog_file3,
642
+ L: 185,
352
643
  S: void 0,
353
644
  C: (f, a) => f(...a)
354
645
  });
355
646
  return null;
356
647
  }
357
- return /* @__PURE__ */ React3.createElement(Suspense, {
648
+ return /* @__PURE__ */ React4.createElement(Suspense, {
358
649
  fallback: placeholder
359
- }, candidates.map((definition) => /* @__PURE__ */ React3.createElement(SurfaceContextProvider, {
650
+ }, candidates.map((definition) => /* @__PURE__ */ React4.createElement(SurfaceContextProvider, {
360
651
  key: definition.id,
361
652
  id: definition.id,
362
653
  role,
@@ -367,38 +658,29 @@ var Surface = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef2(({ id: _id, role,
367
658
  ...rest
368
659
  })));
369
660
  }));
370
- Surface.displayName = "Surface";
661
+ SurfaceComponent.displayName = "Surface";
662
+ var ErrorFallback2 = ({ error }) => {
663
+ const { message } = error instanceof Error ? error : {
664
+ message: String(error)
665
+ };
666
+ return /* @__PURE__ */ React4.createElement("div", {
667
+ role: "alert",
668
+ "data-testid": "error-boundary-fallback"
669
+ }, /* @__PURE__ */ React4.createElement("h1", {
670
+ className: "flex gap-2 text-sm mt-2 text-info-text"
671
+ }, message));
672
+ };
371
673
  var findCandidates = (surfaces, { role, data }) => {
372
674
  return Object.values(surfaces).filter((definition) => Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role).filter(({ filter }) => filter ? filter(data ?? {}) : true).toSorted(byPosition);
373
675
  };
374
- var DefaultFallback2 = ({ data, error, dev }) => {
375
- if (dev) {
376
- return /* @__PURE__ */ React3.createElement("div", {
377
- className: "flex flex-col gap-4 p-4 is-full overflow-y-auto"
378
- }, /* @__PURE__ */ React3.createElement("h1", {
379
- className: "flex gap-2 text-sm mbs-2"
380
- }, error.message), /* @__PURE__ */ React3.createElement("pre", {
381
- className: "overflow-auto text-xs text-description"
382
- }, JSON.stringify(data, null, 2)));
383
- }
384
- return /* @__PURE__ */ React3.createElement("div", {
385
- className: "flex flex-col gap-4 p-4 is-full overflow-y-auto border border-roseFill"
386
- }, /* @__PURE__ */ React3.createElement("h1", {
387
- className: "flex gap-2 text-sm mbs-2 text-rose-500"
388
- }, error.message), /* @__PURE__ */ React3.createElement("pre", {
389
- className: "overflow-auto text-xs text-description"
390
- }, error.stack), /* @__PURE__ */ React3.createElement("pre", {
391
- className: "overflow-auto text-xs text-description"
392
- }, JSON.stringify(data, null, 2)));
393
- };
394
676
  var useSurfaces = () => {
395
- const surfaces = useCapabilities(Capability.ReactSurface);
396
- return useMemo(() => surfaces.flat(), [
677
+ const surfaces = useCapabilities(capabilities_exports.ReactSurface);
678
+ return useMemo3(() => surfaces.flat(), [
397
679
  surfaces
398
680
  ]);
399
681
  };
400
682
  var isSurfaceAvailable = (capabilityManager, { role, data }) => {
401
- const surfaces = capabilityManager.getAll(Capability.ReactSurface);
683
+ const surfaces = capabilityManager.getAll(capabilities_exports.ReactSurface);
402
684
  const candidates = findCandidates(surfaces.flat(), {
403
685
  role,
404
686
  data
@@ -406,341 +688,41 @@ var isSurfaceAvailable = (capabilityManager, { role, data }) => {
406
688
  return candidates.length > 0;
407
689
  };
408
690
 
409
- // src/react/useApp.tsx
410
- import { RegistryContext as RegistryContext2 } from "@effect-atom/atom-react";
411
- import * as Effect from "effect/Effect";
412
- import * as Fiber from "effect/Fiber";
413
- import * as PubSub from "effect/PubSub";
414
- import * as Queue from "effect/Queue";
415
- import React6, { useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
416
- import { runAndForwardErrors } from "@dxos/effect";
417
- import { invariant as invariant2 } from "@dxos/invariant";
418
- import { log as log2 } from "@dxos/log";
419
- import { useAsyncEffect, useDefaultValue as useDefaultValue2 } from "@dxos/react-hooks";
420
- import { ContextProtocolProvider } from "@dxos/web-context-react";
421
-
422
- // src/react/App.tsx
423
- import React4 from "react";
424
-
425
- // src/helpers.ts
426
- var topologicalSort = (nodes) => {
427
- const getDependencies = (nodeId, seen = /* @__PURE__ */ new Set(), path = /* @__PURE__ */ new Set()) => {
428
- if (path.has(nodeId)) {
429
- throw new Error(`Circular dependency detected involving ${nodeId}`);
430
- }
431
- if (seen.has(nodeId)) {
432
- return [];
433
- }
434
- const node = nodes.find((n) => n.id === nodeId);
435
- if (!node) {
436
- throw new Error(`Node ${nodeId} not found but is listed as a dependency`);
437
- }
438
- const newPath = /* @__PURE__ */ new Set([
439
- ...path,
440
- nodeId
441
- ]);
442
- const newSeen = /* @__PURE__ */ new Set([
443
- ...seen,
444
- nodeId
445
- ]);
446
- const dependsOn = node.dependsOn ?? [];
447
- return [
448
- ...dependsOn.flatMap((depId) => getDependencies(depId, newSeen, newPath)),
449
- nodeId
450
- ];
451
- };
452
- const allDependencies = nodes.map((node) => node.id).flatMap((id) => getDependencies(id)).filter((id, index, self) => self.indexOf(id) === index);
453
- return allDependencies.map((id) => nodes.find((node) => node.id === id)).filter((node) => node !== void 0);
454
- };
455
-
456
- // src/react/useLoading.tsx
457
- import { useEffect as useEffect2, useState as useState2 } from "react";
458
- var LoadingState = /* @__PURE__ */ (function(LoadingState2) {
459
- LoadingState2[LoadingState2["Loading"] = 0] = "Loading";
460
- LoadingState2[LoadingState2["FadeIn"] = 1] = "FadeIn";
461
- LoadingState2[LoadingState2["FadeOut"] = 2] = "FadeOut";
462
- LoadingState2[LoadingState2["Done"] = 3] = "Done";
463
- return LoadingState2;
464
- })({});
465
- var useLoading = (ready, debounce = 0) => {
466
- const [stage, setStage] = useState2(0);
467
- useEffect2(() => {
468
- if (!debounce) {
469
- return;
470
- }
471
- const i = setInterval(() => {
472
- setStage((stage2) => {
473
- switch (stage2) {
474
- case 0: {
475
- if (!ready) {
476
- return 1;
477
- } else {
478
- clearInterval(i);
479
- return 3;
480
- }
481
- }
482
- case 1: {
483
- if (ready) {
484
- return 2;
485
- }
486
- break;
487
- }
488
- case 2: {
489
- clearInterval(i);
490
- return 3;
491
- }
492
- }
493
- return stage2;
494
- });
495
- }, debounce);
496
- return () => clearInterval(i);
497
- }, [
498
- debounce
499
- ]);
500
- if (!debounce) {
501
- return ready ? 3 : 0;
502
- }
503
- return stage;
504
- };
505
-
506
- // src/react/App.tsx
507
- var App = ({ placeholder: Placeholder, ready, error, debounce }) => {
508
- const reactContexts = useCapabilities(Capability.ReactContext);
509
- const reactRoots = useCapabilities(Capability.ReactRoot);
510
- const stage = useLoading(ready, debounce);
511
- if (error) {
512
- throw error;
513
- }
514
- if (stage < LoadingState.Done) {
515
- if (!Placeholder) {
516
- return null;
517
- }
518
- return /* @__PURE__ */ React4.createElement(Placeholder, {
519
- stage
520
- });
521
- }
522
- const ComposedContext = composeContexts(reactContexts);
523
- return /* @__PURE__ */ React4.createElement(ComposedContext, null, reactRoots.map(({ id, root: Component2 }) => /* @__PURE__ */ React4.createElement(Component2, {
524
- key: id
525
- })));
526
- };
527
- var composeContexts = (contexts) => {
528
- if (contexts.length === 0) {
529
- return ({ children }) => /* @__PURE__ */ React4.createElement(React4.Fragment, null, children);
530
- }
531
- return topologicalSort(contexts).map(({ context }) => context).reduce((Acc, Next) => ({ children }) => /* @__PURE__ */ React4.createElement(Acc, null, /* @__PURE__ */ React4.createElement(Next, null, children)));
532
- };
533
-
534
- // src/react/DefaultFallback.tsx
535
- import React5 from "react";
536
- var DefaultFallback3 = ({ error }) => {
537
- return /* @__PURE__ */ React5.createElement("div", {
538
- style: {
539
- margin: "1rem",
540
- padding: "1rem",
541
- overflow: "hidden",
542
- border: "4px solid teal",
543
- borderRadius: "1rem"
544
- }
545
- }, /* @__PURE__ */ React5.createElement("h1", {
546
- style: {
547
- margin: "0.5rem 0",
548
- fontSize: "1.2rem"
549
- }
550
- }, "ERROR: ", error.message), /* @__PURE__ */ React5.createElement("pre", {
551
- style: {
552
- overflow: "auto",
553
- fontSize: "1rem",
554
- whiteSpace: "pre-wrap",
555
- color: "#888888"
556
- }
557
- }, error.stack));
558
- };
559
-
560
- // src/react/useApp.tsx
561
- var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/react/useApp.tsx";
562
- var ENABLED_KEY = "dxos.org/app-framework/enabled";
563
- var useApp = ({ pluginManager, pluginLoader: pluginLoaderProp, plugins: pluginsProp, core: coreProp, defaults: defaultsProp, placeholder, fallback = DefaultFallback3, cacheEnabled = false, safeMode = false, debounce = 0, timeout = 3e4 }) => {
564
- const plugins = useDefaultValue2(pluginsProp, () => []);
565
- const core = useDefaultValue2(coreProp, () => plugins.map(({ meta }) => meta.id));
566
- const defaults = useDefaultValue2(defaultsProp, () => []);
567
- const pluginLoader = useMemo2(() => pluginLoaderProp ?? ((id) => Effect.sync(() => {
568
- const plugin = plugins.find((plugin2) => plugin2.meta.id === id);
569
- invariant2(plugin, `Plugin not found: ${id}`, {
570
- F: __dxlog_file3,
571
- L: 92,
572
- S: void 0,
573
- A: [
574
- "plugin",
575
- "`Plugin not found: ${id}`"
576
- ]
577
- });
578
- return plugin;
579
- })), [
580
- pluginLoaderProp,
581
- plugins
582
- ]);
583
- const readyRef = useRef2(false);
584
- const [ready, setReady] = useState3(false);
585
- const errorRef = useRef2(null);
586
- const [error, setError] = useState3(null);
587
- const cached = useMemo2(() => JSON.parse(localStorage.getItem(ENABLED_KEY) ?? "[]"), []);
588
- const enabled = useMemo2(() => safeMode ? [] : cacheEnabled && cached.length > 0 ? cached : defaults, [
589
- safeMode,
590
- cacheEnabled,
591
- cached,
592
- defaults
593
- ]);
594
- const manager = useMemo2(() => pluginManager ?? plugin_manager_exports.make({
595
- pluginLoader,
596
- plugins,
597
- core,
598
- enabled
599
- }), [
600
- pluginManager,
601
- pluginLoader,
602
- plugins,
603
- core,
604
- enabled
605
- ]);
606
- useEffect3(() => {
607
- if (!cacheEnabled) {
608
- return;
609
- }
610
- return manager.registry.subscribe(manager.enabled, (value) => {
611
- localStorage.setItem(ENABLED_KEY, JSON.stringify(value));
612
- });
613
- }, [
614
- cacheEnabled,
615
- manager
616
- ]);
617
- useEffect3(() => {
618
- setupDevtools(manager);
619
- }, [
620
- manager
621
- ]);
622
- useAsyncEffect(async () => {
623
- manager.capabilities.contribute({
624
- interface: Capability.PluginManager,
625
- implementation: manager,
626
- module: "dxos.org/app-framework/plugin-manager"
627
- });
628
- manager.capabilities.contribute({
629
- interface: Capability.AtomRegistry,
630
- implementation: manager.registry,
631
- module: "dxos.org/app-framework/atom-registry"
632
- });
633
- const fiber = Effect.gen(function* () {
634
- const queue = yield* PubSub.subscribe(manager.activation);
635
- const listener = yield* Effect.forkDaemon(Queue.take(queue).pipe(Effect.tap(({ event, state, error: error$ }) => Effect.sync(() => {
636
- if (event === ActivationEvent.Startup.id && state === "activated") {
637
- clearTimeout(timeoutId);
638
- setReady(true);
639
- readyRef.current = true;
640
- }
641
- if (error$ && !readyRef.current) {
642
- setError(error$);
643
- errorRef.current = error$;
644
- }
645
- })), Effect.forever));
646
- yield* Effect.all([
647
- manager.activate(ActivationEvent.SetupSettings),
648
- manager.activate(ActivationEvent.SetupReactSurface),
649
- manager.activate(ActivationEvent.Startup)
650
- ]);
651
- return yield* Fiber.join(listener);
652
- }).pipe(Effect.scoped, Effect.runFork);
653
- const timeoutId = setTimeout(() => {
654
- if (!readyRef.current && !errorRef.current) {
655
- log2.warn("startup timeout diagnostic", {
656
- eventsFired: manager.getEventsFired(),
657
- activeModules: manager.getActive(),
658
- pendingReset: manager.getPendingReset()
659
- }, {
660
- F: __dxlog_file3,
661
- L: 172,
662
- S: void 0,
663
- C: (f, a) => f(...a)
664
- });
665
- void runAndForwardErrors(Fiber.interrupt(fiber));
666
- setError(new Error(`Startup timed out after ${timeout}ms`));
667
- }
668
- }, timeout);
669
- return () => {
670
- clearTimeout(timeoutId);
671
- void runAndForwardErrors(Fiber.interrupt(fiber));
672
- manager.capabilities.remove(Capability.PluginManager, manager);
673
- manager.capabilities.remove(Capability.AtomRegistry, manager.registry);
674
- };
675
- }, [
676
- manager
677
- ]);
678
- return useCallback4(() => /* @__PURE__ */ React6.createElement(ErrorBoundary, {
679
- fallback
680
- }, /* @__PURE__ */ React6.createElement(PluginManagerProvider, {
681
- value: manager
682
- }, /* @__PURE__ */ React6.createElement(ContextProtocolProvider, {
683
- value: manager,
684
- context: PluginManagerContext
685
- }, /* @__PURE__ */ React6.createElement(RegistryContext2.Provider, {
686
- value: manager.registry
687
- }, /* @__PURE__ */ React6.createElement(App, {
688
- placeholder,
689
- ready,
690
- error,
691
- debounce
692
- }))))), [
693
- fallback,
694
- manager,
695
- placeholder,
696
- ready,
697
- error
698
- ]);
699
- };
700
- var setupDevtools = (manager) => {
701
- globalThis.composer ??= {};
702
- globalThis.composer.manager = manager;
703
- };
691
+ // src/ui/components/Surface/types.ts
692
+ var create = (definition) => ({
693
+ ...definition,
694
+ kind: "react"
695
+ });
696
+ var createWeb = (definition) => ({
697
+ ...definition,
698
+ kind: "web-component"
699
+ });
704
700
 
705
- // src/react/useOperationResolver.ts
706
- import { useEffect as useEffect4, useMemo as useMemo3 } from "react";
707
- var useOperationResolver = (module, resolver) => {
708
- const manager = usePluginManager();
709
- const resolverArray = useMemo3(() => [
710
- resolver
711
- ], [
712
- resolver
713
- ]);
714
- useEffect4(() => {
715
- manager.capabilities.contribute({
716
- module,
717
- interface: Capability.OperationResolver,
718
- implementation: resolverArray
719
- });
720
- return () => manager.capabilities.remove(Capability.OperationResolver, resolverArray);
721
- }, [
722
- module,
723
- resolverArray
724
- ]);
725
- };
701
+ // src/ui/components/Surface/index.ts
702
+ (function(Surface2) {
703
+ Surface2.create = create;
704
+ Surface2.createWeb = createWeb;
705
+ Surface2.Context = SurfaceContext;
706
+ Surface2.Surface = SurfaceComponent;
707
+ Surface2.isAvailable = isSurfaceAvailable;
708
+ })(Surface || (Surface = {}));
709
+ var Surface;
726
710
 
727
711
  export {
728
- usePluginManager,
729
- PluginManagerProvider,
712
+ useApp,
730
713
  useCapabilities,
731
714
  useCapability,
732
715
  useAtomCapability,
733
716
  useAtomCapabilityState,
734
717
  useOperationInvoker,
735
- useAppGraph,
736
- useLayout,
718
+ LoadingState,
719
+ useLoading,
720
+ useOperationResolver,
737
721
  useSettingsState,
738
- ErrorBoundary,
739
722
  useSurface,
740
- Surface,
741
- useSurfaces,
742
- isSurfaceAvailable,
743
- useApp,
744
- useOperationResolver
723
+ App,
724
+ usePluginManager,
725
+ PluginManagerProvider,
726
+ Surface
745
727
  };
746
- //# sourceMappingURL=chunk-XYNO72GQ.mjs.map
728
+ //# sourceMappingURL=chunk-7AL6SKIV.mjs.map