@dxos/app-framework 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb

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