@dxos/app-framework 0.8.4-main.dedc0f3 → 0.8.4-main.dfabb4ec29

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 (577) hide show
  1. package/.storybook/main.mts +9 -0
  2. package/.storybook/preview.mts +8 -0
  3. package/dist/lib/browser/capability-5RRH3WIB.mjs +35 -0
  4. package/dist/lib/browser/capability-5RRH3WIB.mjs.map +7 -0
  5. package/dist/lib/browser/capability-LUKGKUQH.mjs +38 -0
  6. package/dist/lib/browser/capability-LUKGKUQH.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-23D4SJUE.mjs +42 -0
  8. package/dist/lib/browser/chunk-23D4SJUE.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-3JWJXGLK.mjs +79 -0
  10. package/dist/lib/browser/chunk-3JWJXGLK.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-45CHLTBV.mjs +34 -0
  12. package/dist/lib/browser/chunk-45CHLTBV.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-66IXTIVK.mjs +48 -0
  14. package/dist/lib/browser/chunk-66IXTIVK.mjs.map +7 -0
  15. package/dist/lib/browser/chunk-7VZJR2OA.mjs +581 -0
  16. package/dist/lib/browser/chunk-7VZJR2OA.mjs.map +7 -0
  17. package/dist/lib/browser/chunk-CZ4BIAHH.mjs +422 -0
  18. package/dist/lib/browser/chunk-CZ4BIAHH.mjs.map +7 -0
  19. package/dist/lib/browser/chunk-FJ4765WW.mjs +8 -0
  20. package/dist/lib/browser/chunk-FJ4765WW.mjs.map +7 -0
  21. package/dist/lib/browser/chunk-FO3IYSLV.mjs +68 -0
  22. package/dist/lib/browser/chunk-FO3IYSLV.mjs.map +7 -0
  23. package/dist/lib/browser/chunk-J5LGTIGS.mjs +10 -0
  24. package/dist/lib/browser/chunk-JD3Z5NEF.mjs +469 -0
  25. package/dist/lib/browser/chunk-JD3Z5NEF.mjs.map +7 -0
  26. package/dist/lib/browser/chunk-NBXPP7JR.mjs +1174 -0
  27. package/dist/lib/browser/chunk-NBXPP7JR.mjs.map +7 -0
  28. package/dist/lib/browser/chunk-WBHCSOBW.mjs +80 -0
  29. package/dist/lib/browser/chunk-WBHCSOBW.mjs.map +7 -0
  30. package/dist/lib/browser/chunk-Z55LVAGN.mjs +213 -0
  31. package/dist/lib/browser/chunk-Z55LVAGN.mjs.map +7 -0
  32. package/dist/lib/browser/chunk-ZGJAZSNE.mjs +142 -0
  33. package/dist/lib/browser/chunk-ZGJAZSNE.mjs.map +7 -0
  34. package/dist/lib/browser/cli/index.mjs +76 -0
  35. package/dist/lib/browser/cli/index.mjs.map +7 -0
  36. package/dist/lib/browser/common/activation-events.mjs +24 -0
  37. package/dist/lib/browser/common/capabilities.mjs +46 -0
  38. package/dist/lib/browser/core/activation-event.mjs +20 -0
  39. package/dist/lib/browser/core/capability.mjs +30 -0
  40. package/dist/lib/browser/core/capability.mjs.map +7 -0
  41. package/dist/lib/browser/core/plugin-manager.mjs +19 -0
  42. package/dist/lib/browser/core/plugin-manager.mjs.map +7 -0
  43. package/dist/lib/browser/core/plugin.mjs +37 -0
  44. package/dist/lib/browser/core/plugin.mjs.map +7 -0
  45. package/dist/lib/browser/core/url-loader.mjs +24 -0
  46. package/dist/lib/browser/core/url-loader.mjs.map +7 -0
  47. package/dist/lib/browser/index.mjs +108 -162
  48. package/dist/lib/browser/index.mjs.map +4 -4
  49. package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs +44 -0
  50. package/dist/lib/browser/invoker-capability-K4GHUFXF.mjs.map +7 -0
  51. package/dist/lib/browser/meta.json +1 -1
  52. package/dist/lib/browser/testing/index.mjs +235 -48
  53. package/dist/lib/browser/testing/index.mjs.map +4 -4
  54. package/dist/lib/browser/testing/react.mjs +78 -0
  55. package/dist/lib/browser/testing/react.mjs.map +7 -0
  56. package/dist/lib/browser/ui/index.mjs +48 -0
  57. package/dist/lib/browser/ui/index.mjs.map +7 -0
  58. package/dist/lib/node-esm/capability-FCGZVIEG.mjs +39 -0
  59. package/dist/lib/node-esm/capability-FCGZVIEG.mjs.map +7 -0
  60. package/dist/lib/node-esm/capability-JOIQ2MQE.mjs +36 -0
  61. package/dist/lib/node-esm/capability-JOIQ2MQE.mjs.map +7 -0
  62. package/dist/lib/node-esm/chunk-37Z53PXZ.mjs +10 -0
  63. package/dist/lib/node-esm/chunk-37Z53PXZ.mjs.map +7 -0
  64. package/dist/lib/node-esm/chunk-6XW6LET6.mjs +35 -0
  65. package/dist/lib/node-esm/chunk-6XW6LET6.mjs.map +7 -0
  66. package/dist/lib/node-esm/chunk-D347W3KO.mjs +143 -0
  67. package/dist/lib/node-esm/chunk-D347W3KO.mjs.map +7 -0
  68. package/dist/lib/node-esm/chunk-DRZKO5UZ.mjs +470 -0
  69. package/dist/lib/node-esm/chunk-DRZKO5UZ.mjs.map +7 -0
  70. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs +11 -0
  71. package/dist/lib/node-esm/chunk-HSLMI22Q.mjs.map +7 -0
  72. package/dist/lib/node-esm/chunk-HTBJU5FX.mjs +214 -0
  73. package/dist/lib/node-esm/chunk-HTBJU5FX.mjs.map +7 -0
  74. package/dist/lib/node-esm/chunk-M3HKPRPO.mjs +423 -0
  75. package/dist/lib/node-esm/chunk-M3HKPRPO.mjs.map +7 -0
  76. package/dist/lib/node-esm/chunk-MUVUQC3G.mjs +1175 -0
  77. package/dist/lib/node-esm/chunk-MUVUQC3G.mjs.map +7 -0
  78. package/dist/lib/node-esm/chunk-SBS2YMPT.mjs +43 -0
  79. package/dist/lib/node-esm/chunk-SBS2YMPT.mjs.map +7 -0
  80. package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs +80 -0
  81. package/dist/lib/node-esm/chunk-SDJ4B2LU.mjs.map +7 -0
  82. package/dist/lib/node-esm/chunk-V24UWT36.mjs +582 -0
  83. package/dist/lib/node-esm/chunk-V24UWT36.mjs.map +7 -0
  84. package/dist/lib/node-esm/chunk-WFSRZKBP.mjs +81 -0
  85. package/dist/lib/node-esm/chunk-WFSRZKBP.mjs.map +7 -0
  86. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs +70 -0
  87. package/dist/lib/node-esm/chunk-WK7OIQKI.mjs.map +7 -0
  88. package/dist/lib/node-esm/chunk-XOCUANHO.mjs +49 -0
  89. package/dist/lib/node-esm/chunk-XOCUANHO.mjs.map +7 -0
  90. package/dist/lib/node-esm/cli/index.mjs +77 -0
  91. package/dist/lib/node-esm/cli/index.mjs.map +7 -0
  92. package/dist/lib/node-esm/common/activation-events.mjs +25 -0
  93. package/dist/lib/node-esm/common/activation-events.mjs.map +7 -0
  94. package/dist/lib/node-esm/common/capabilities.mjs +47 -0
  95. package/dist/lib/node-esm/common/capabilities.mjs.map +7 -0
  96. package/dist/lib/node-esm/core/activation-event.mjs +21 -0
  97. package/dist/lib/node-esm/core/activation-event.mjs.map +7 -0
  98. package/dist/lib/node-esm/core/capability.mjs +31 -0
  99. package/dist/lib/node-esm/core/capability.mjs.map +7 -0
  100. package/dist/lib/node-esm/core/plugin-manager.mjs +20 -0
  101. package/dist/lib/node-esm/core/plugin-manager.mjs.map +7 -0
  102. package/dist/lib/node-esm/core/plugin.mjs +38 -0
  103. package/dist/lib/node-esm/core/plugin.mjs.map +7 -0
  104. package/dist/lib/node-esm/core/url-loader.mjs +25 -0
  105. package/dist/lib/node-esm/core/url-loader.mjs.map +7 -0
  106. package/dist/lib/node-esm/index.mjs +108 -162
  107. package/dist/lib/node-esm/index.mjs.map +4 -4
  108. package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs +45 -0
  109. package/dist/lib/node-esm/invoker-capability-XEPW5LMJ.mjs.map +7 -0
  110. package/dist/lib/node-esm/meta.json +1 -1
  111. package/dist/lib/node-esm/testing/index.mjs +235 -48
  112. package/dist/lib/node-esm/testing/index.mjs.map +4 -4
  113. package/dist/lib/node-esm/testing/react.mjs +79 -0
  114. package/dist/lib/node-esm/testing/react.mjs.map +7 -0
  115. package/dist/lib/node-esm/ui/index.mjs +49 -0
  116. package/dist/lib/node-esm/ui/index.mjs.map +7 -0
  117. package/dist/plugin/node-esm/index.mjs +893 -0
  118. package/dist/plugin/node-esm/index.mjs.map +7 -0
  119. package/dist/plugin/node-esm/meta.json +1 -0
  120. package/dist/types/src/cli/cli.d.ts +39 -0
  121. package/dist/types/src/cli/cli.d.ts.map +1 -0
  122. package/dist/types/src/cli/index.d.ts +2 -0
  123. package/dist/types/src/cli/index.d.ts.map +1 -0
  124. package/dist/types/src/common/activation-events.d.ts +27 -0
  125. package/dist/types/src/common/activation-events.d.ts.map +1 -0
  126. package/dist/types/src/common/annotations.d.ts +1 -0
  127. package/dist/types/src/common/annotations.d.ts.map +1 -0
  128. package/dist/types/src/common/capabilities.d.ts +110 -190
  129. package/dist/types/src/common/capabilities.d.ts.map +1 -1
  130. package/dist/types/src/common/index.d.ts +4 -8
  131. package/dist/types/src/common/index.d.ts.map +1 -1
  132. package/dist/types/src/common/operations.d.ts +19 -0
  133. package/dist/types/src/common/operations.d.ts.map +1 -0
  134. package/dist/types/src/common/translations.d.ts +8 -8
  135. package/dist/types/src/common/translations.d.ts.map +1 -1
  136. package/dist/types/src/context.d.ts +5 -0
  137. package/dist/types/src/context.d.ts.map +1 -0
  138. package/dist/types/src/core/{events.d.ts → activation-event.d.ts} +11 -11
  139. package/dist/types/src/core/activation-event.d.ts.map +1 -0
  140. package/dist/types/src/core/capability-manager.d.ts +48 -0
  141. package/dist/types/src/core/capability-manager.d.ts.map +1 -0
  142. package/dist/types/src/core/capability-manager.test.d.ts +2 -0
  143. package/dist/types/src/core/capability-manager.test.d.ts.map +1 -0
  144. package/dist/types/src/core/capability.d.ts +156 -0
  145. package/dist/types/src/core/capability.d.ts.map +1 -0
  146. package/dist/types/src/core/edge-registry-plugin-provider.d.ts +30 -0
  147. package/dist/types/src/core/edge-registry-plugin-provider.d.ts.map +1 -0
  148. package/dist/types/src/core/index.d.ts +11 -4
  149. package/dist/types/src/core/index.d.ts.map +1 -1
  150. package/dist/types/src/core/plugin-asset-cache.d.ts +71 -0
  151. package/dist/types/src/core/plugin-asset-cache.d.ts.map +1 -0
  152. package/dist/types/src/core/plugin-manager.d.ts +239 -0
  153. package/dist/types/src/core/plugin-manager.d.ts.map +1 -0
  154. package/dist/types/src/core/plugin-manager.test.d.ts +2 -0
  155. package/dist/types/src/core/plugin-manager.test.d.ts.map +1 -0
  156. package/dist/types/src/core/plugin-manifest.d.ts +101 -0
  157. package/dist/types/src/core/plugin-manifest.d.ts.map +1 -0
  158. package/dist/types/src/core/plugin-manifest.test.d.ts +2 -0
  159. package/dist/types/src/core/plugin-manifest.test.d.ts.map +1 -0
  160. package/dist/types/src/core/plugin.d.ts +208 -37
  161. package/dist/types/src/core/plugin.d.ts.map +1 -1
  162. package/dist/types/src/core/registry.d.ts +101 -0
  163. package/dist/types/src/core/registry.d.ts.map +1 -0
  164. package/dist/types/src/core/url-loader.d.ts +127 -0
  165. package/dist/types/src/core/url-loader.d.ts.map +1 -0
  166. package/dist/types/src/core/url-loader.test.d.ts +2 -0
  167. package/dist/types/src/core/url-loader.test.d.ts.map +1 -0
  168. package/dist/types/src/helpers.d.ts.map +1 -1
  169. package/dist/types/src/index.d.ts +3 -4
  170. package/dist/types/src/index.d.ts.map +1 -1
  171. package/dist/types/src/plugin-operation/OperationPlugin.d.ts +3 -0
  172. package/dist/types/src/plugin-operation/OperationPlugin.d.ts.map +1 -0
  173. package/dist/types/src/plugin-operation/history/capability.d.ts +7 -0
  174. package/dist/types/src/plugin-operation/history/capability.d.ts.map +1 -0
  175. package/dist/types/src/plugin-operation/history/errors.d.ts +32 -0
  176. package/dist/types/src/plugin-operation/history/errors.d.ts.map +1 -0
  177. package/dist/types/src/plugin-operation/history/history-tracker.d.ts +18 -0
  178. package/dist/types/src/plugin-operation/history/history-tracker.d.ts.map +1 -0
  179. package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts +2 -0
  180. package/dist/types/src/plugin-operation/history/history-tracker.test.d.ts.map +1 -0
  181. package/dist/types/src/plugin-operation/history/index.d.ts +6 -0
  182. package/dist/types/src/plugin-operation/history/index.d.ts.map +1 -0
  183. package/dist/types/src/plugin-operation/history/types.d.ts +13 -0
  184. package/dist/types/src/plugin-operation/history/types.d.ts.map +1 -0
  185. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts +101 -0
  186. package/dist/types/src/plugin-operation/history/undo-mapping.d.ts.map +1 -0
  187. package/dist/types/src/plugin-operation/history/undo-registry.d.ts +23 -0
  188. package/dist/types/src/plugin-operation/history/undo-registry.d.ts.map +1 -0
  189. package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts +2 -0
  190. package/dist/types/src/plugin-operation/history/undo-registry.test.d.ts.map +1 -0
  191. package/dist/types/src/plugin-operation/index.d.ts +3 -0
  192. package/dist/types/src/plugin-operation/index.d.ts.map +1 -0
  193. package/dist/types/src/plugin-operation/invoker-capability.d.ts +6 -0
  194. package/dist/types/src/plugin-operation/invoker-capability.d.ts.map +1 -0
  195. package/dist/types/src/plugin-operation/meta.d.ts +3 -0
  196. package/dist/types/src/plugin-operation/meta.d.ts.map +1 -0
  197. package/dist/types/src/plugin-operation/testing.d.ts +59 -0
  198. package/dist/types/src/plugin-operation/testing.d.ts.map +1 -0
  199. package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts +3 -0
  200. package/dist/types/src/plugin-runtime/RuntimePlugin.d.ts.map +1 -0
  201. package/dist/types/src/plugin-runtime/capability.d.ts +6 -0
  202. package/dist/types/src/plugin-runtime/capability.d.ts.map +1 -0
  203. package/dist/types/src/plugin-runtime/index.d.ts +2 -0
  204. package/dist/types/src/plugin-runtime/index.d.ts.map +1 -0
  205. package/dist/types/src/plugin-runtime/meta.d.ts +3 -0
  206. package/dist/types/src/plugin-runtime/meta.d.ts.map +1 -0
  207. package/dist/types/src/testing/harness.d.ts +67 -0
  208. package/dist/types/src/testing/harness.d.ts.map +1 -0
  209. package/dist/types/src/testing/index.d.ts +2 -0
  210. package/dist/types/src/testing/index.d.ts.map +1 -1
  211. package/dist/types/src/testing/react.d.ts +27 -0
  212. package/dist/types/src/testing/react.d.ts.map +1 -0
  213. package/dist/types/src/testing/react.test.d.ts +2 -0
  214. package/dist/types/src/testing/react.test.d.ts.map +1 -0
  215. package/dist/types/src/testing/service.d.ts +8 -0
  216. package/dist/types/src/testing/service.d.ts.map +1 -0
  217. package/dist/types/src/testing/withPluginManager.d.ts +8 -9
  218. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -1
  219. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -1
  220. package/dist/types/src/ui/components/App/App.d.ts +9 -0
  221. package/dist/types/src/ui/components/App/App.d.ts.map +1 -0
  222. package/dist/types/src/ui/components/App/App.stories.d.ts +19 -0
  223. package/dist/types/src/ui/components/App/App.stories.d.ts.map +1 -0
  224. package/dist/types/src/ui/components/App/index.d.ts +2 -0
  225. package/dist/types/src/ui/components/App/index.d.ts.map +1 -0
  226. package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts +64 -0
  227. package/dist/types/src/ui/components/Placeholder/Placeholder.d.ts.map +1 -0
  228. package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts +19 -0
  229. package/dist/types/src/ui/components/Placeholder/Placeholder.stories.d.ts.map +1 -0
  230. package/dist/types/src/ui/components/Placeholder/index.d.ts +2 -0
  231. package/dist/types/src/ui/components/Placeholder/index.d.ts.map +1 -0
  232. package/dist/types/src/{playground/playground.stories.d.ts → ui/components/PluginManager/PluginManagerContext.stories.d.ts} +5 -4
  233. package/dist/types/src/ui/components/PluginManager/PluginManagerContext.stories.d.ts.map +1 -0
  234. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts +10 -0
  235. package/dist/types/src/ui/components/PluginManager/PluginManagerProvider.d.ts.map +1 -0
  236. package/dist/types/src/ui/components/PluginManager/index.d.ts +2 -0
  237. package/dist/types/src/ui/components/PluginManager/index.d.ts.map +1 -0
  238. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts +24 -0
  239. package/dist/types/src/ui/components/Surface/SurfaceComponent.d.ts.map +1 -0
  240. package/dist/types/src/{components/App.stories.d.ts → ui/components/Surface/SurfaceComponent.stories.d.ts} +1 -2
  241. package/dist/types/src/ui/components/Surface/SurfaceComponent.stories.d.ts.map +1 -0
  242. package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts +11 -0
  243. package/dist/types/src/ui/components/Surface/SurfaceInfo.d.ts.map +1 -0
  244. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts +48 -0
  245. package/dist/types/src/ui/components/Surface/SurfaceProfilerContext.d.ts.map +1 -0
  246. package/dist/types/src/ui/components/Surface/context.d.ts +5 -0
  247. package/dist/types/src/ui/components/Surface/context.d.ts.map +1 -0
  248. package/dist/types/src/ui/components/Surface/index.d.ts +36 -0
  249. package/dist/types/src/ui/components/Surface/index.d.ts.map +1 -0
  250. package/dist/types/src/ui/components/Surface/types.d.ts +197 -0
  251. package/dist/types/src/ui/components/Surface/types.d.ts.map +1 -0
  252. package/dist/types/src/ui/components/Surface/types.test.d.ts +2 -0
  253. package/dist/types/src/ui/components/Surface/types.test.d.ts.map +1 -0
  254. package/dist/types/src/ui/components/index.d.ts +5 -0
  255. package/dist/types/src/ui/components/index.d.ts.map +1 -0
  256. package/dist/types/src/ui/hooks/index.d.ts +6 -0
  257. package/dist/types/src/ui/hooks/index.d.ts.map +1 -0
  258. package/dist/types/src/ui/hooks/useApp.d.ts +89 -0
  259. package/dist/types/src/ui/hooks/useApp.d.ts.map +1 -0
  260. package/dist/types/src/ui/hooks/useApp.test.d.ts +2 -0
  261. package/dist/types/src/ui/hooks/useApp.test.d.ts.map +1 -0
  262. package/dist/types/src/ui/hooks/useCapabilities.d.ts +31 -0
  263. package/dist/types/src/ui/hooks/useCapabilities.d.ts.map +1 -0
  264. package/dist/types/src/{components → ui/hooks}/useLoading.d.ts +1 -2
  265. package/dist/types/src/ui/hooks/useLoading.d.ts.map +1 -0
  266. package/dist/types/src/ui/hooks/useSettingsState.d.ts +10 -0
  267. package/dist/types/src/ui/hooks/useSettingsState.d.ts.map +1 -0
  268. package/dist/types/src/ui/hooks/useSurface.d.ts +3 -0
  269. package/dist/types/src/ui/hooks/useSurface.d.ts.map +1 -0
  270. package/dist/types/src/ui/index.d.ts +3 -0
  271. package/dist/types/src/ui/index.d.ts.map +1 -0
  272. package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts +34 -0
  273. package/dist/types/src/vite-plugin/boot-loader/BootLoader.stories.d.ts.map +1 -0
  274. package/dist/types/src/vite-plugin/boot-loader/index.d.ts +2 -0
  275. package/dist/types/src/vite-plugin/boot-loader/index.d.ts.map +1 -0
  276. package/dist/types/src/vite-plugin/boot-loader/loader.d.ts +51 -0
  277. package/dist/types/src/vite-plugin/boot-loader/loader.d.ts.map +1 -0
  278. package/dist/types/src/vite-plugin/composer/index.d.ts +34 -0
  279. package/dist/types/src/vite-plugin/composer/index.d.ts.map +1 -0
  280. package/dist/types/src/vite-plugin/import-map/index.d.ts +28 -0
  281. package/dist/types/src/vite-plugin/import-map/index.d.ts.map +1 -0
  282. package/dist/types/src/vite-plugin/index.d.ts +5 -0
  283. package/dist/types/src/vite-plugin/index.d.ts.map +1 -0
  284. package/dist/types/src/vite-plugin/manifest.d.ts +41 -0
  285. package/dist/types/src/vite-plugin/manifest.d.ts.map +1 -0
  286. package/dist/types/src/vite-plugin/manifest.test.d.ts +2 -0
  287. package/dist/types/src/vite-plugin/manifest.test.d.ts.map +1 -0
  288. package/dist/types/src/vite-plugin/packages.d.ts +13 -0
  289. package/dist/types/src/vite-plugin/packages.d.ts.map +1 -0
  290. package/dist/types/tsconfig.tsbuildinfo +1 -1
  291. package/moon.yml +26 -3
  292. package/package.json +114 -54
  293. package/src/cli/cli.ts +107 -0
  294. package/src/{playground/logger → cli}/index.ts +1 -1
  295. package/src/common/activation-events.ts +44 -0
  296. package/src/{components/index.ts → common/annotations.ts} +0 -2
  297. package/src/common/capabilities.ts +169 -195
  298. package/src/common/index.ts +4 -8
  299. package/src/common/operations.ts +35 -0
  300. package/src/common/translations.ts +18 -10
  301. package/src/context.ts +9 -0
  302. package/src/core/{events.ts → activation-event.ts} +10 -7
  303. package/src/core/capability-manager.test.ts +151 -0
  304. package/src/core/capability-manager.ts +192 -0
  305. package/src/core/capability.ts +247 -0
  306. package/src/core/edge-registry-plugin-provider.ts +92 -0
  307. package/src/core/index.ts +11 -4
  308. package/src/core/plugin-asset-cache.ts +60 -0
  309. package/src/core/plugin-manager.test.ts +1671 -0
  310. package/src/core/plugin-manager.ts +1335 -0
  311. package/src/core/plugin-manifest.test.ts +75 -0
  312. package/src/core/plugin-manifest.ts +134 -0
  313. package/src/core/plugin.ts +369 -43
  314. package/src/core/registry.ts +157 -0
  315. package/src/core/url-loader.test.ts +221 -0
  316. package/src/core/url-loader.ts +388 -0
  317. package/src/index.ts +3 -4
  318. package/src/plugin-operation/OperationPlugin.ts +24 -0
  319. package/src/plugin-operation/history/capability.ts +36 -0
  320. package/src/plugin-operation/history/errors.ts +7 -0
  321. package/src/plugin-operation/history/history-tracker.test.ts +374 -0
  322. package/src/plugin-operation/history/history-tracker.ts +128 -0
  323. package/src/plugin-operation/history/index.ts +9 -0
  324. package/src/plugin-operation/history/types.ts +17 -0
  325. package/src/plugin-operation/history/undo-mapping.ts +135 -0
  326. package/src/plugin-operation/history/undo-registry.test.ts +72 -0
  327. package/src/plugin-operation/history/undo-registry.ts +54 -0
  328. package/src/plugin-operation/index.ts +6 -0
  329. package/src/plugin-operation/invoker-capability.ts +55 -0
  330. package/src/plugin-operation/meta.ts +12 -0
  331. package/src/plugin-operation/testing.ts +155 -0
  332. package/src/plugin-runtime/RuntimePlugin.ts +19 -0
  333. package/src/plugin-runtime/capability.ts +53 -0
  334. package/src/plugin-runtime/index.ts +5 -0
  335. package/src/plugin-runtime/meta.ts +12 -0
  336. package/src/testing/harness.ts +229 -0
  337. package/src/testing/index.ts +2 -0
  338. package/src/testing/react.test.tsx +48 -0
  339. package/src/testing/react.tsx +113 -0
  340. package/src/testing/service.ts +52 -0
  341. package/src/testing/withPluginManager.stories.tsx +9 -10
  342. package/src/testing/withPluginManager.tsx +74 -50
  343. package/src/ui/components/App/App.stories.tsx +88 -0
  344. package/src/ui/components/App/App.tsx +81 -0
  345. package/src/{playground/layout → ui/components/App}/index.ts +1 -1
  346. package/src/ui/components/Placeholder/Placeholder.stories.tsx +77 -0
  347. package/src/ui/components/Placeholder/Placeholder.tsx +155 -0
  348. package/src/{playground/debug → ui/components/Placeholder}/index.ts +1 -1
  349. package/src/ui/components/PluginManager/PluginManagerContext.stories.tsx +185 -0
  350. package/src/{react → ui/components/PluginManager}/PluginManagerProvider.ts +3 -3
  351. package/src/ui/components/PluginManager/index.ts +5 -0
  352. package/src/ui/components/Surface/SurfaceComponent.stories.tsx +144 -0
  353. package/src/ui/components/Surface/SurfaceComponent.tsx +303 -0
  354. package/src/ui/components/Surface/SurfaceInfo.tsx +106 -0
  355. package/src/ui/components/Surface/SurfaceProfilerContext.tsx +207 -0
  356. package/src/ui/components/Surface/context.ts +12 -0
  357. package/src/ui/components/Surface/index.ts +54 -0
  358. package/src/ui/components/Surface/types.test.ts +126 -0
  359. package/src/ui/components/Surface/types.ts +269 -0
  360. package/src/ui/components/index.ts +8 -0
  361. package/src/ui/hooks/index.ts +9 -0
  362. package/src/ui/hooks/useApp.test.tsx +159 -0
  363. package/src/ui/hooks/useApp.tsx +424 -0
  364. package/src/ui/hooks/useCapabilities.ts +67 -0
  365. package/src/{components → ui/hooks}/useLoading.tsx +16 -10
  366. package/src/ui/hooks/useSettingsState.ts +26 -0
  367. package/src/ui/hooks/useSurface.ts +13 -0
  368. package/src/ui/index.ts +6 -0
  369. package/src/vite-plugin/boot-loader/BootLoader.stories.tsx +270 -0
  370. package/src/vite-plugin/boot-loader/boot-loader.css +320 -0
  371. package/src/vite-plugin/boot-loader/boot-loader.js +325 -0
  372. package/src/vite-plugin/boot-loader/index.ts +5 -0
  373. package/src/vite-plugin/boot-loader/loader.ts +123 -0
  374. package/src/vite-plugin/composer/index.ts +306 -0
  375. package/src/vite-plugin/import-map/index.ts +527 -0
  376. package/src/vite-plugin/index.ts +10 -0
  377. package/src/vite-plugin/manifest.test.ts +46 -0
  378. package/src/vite-plugin/manifest.ts +57 -0
  379. package/src/vite-plugin/packages.ts +187 -0
  380. package/tsconfig.json +24 -15
  381. package/tsconfig.node.json +2 -4
  382. package/typedoc.json +2 -4
  383. package/vitest.config.ts +8 -6
  384. package/.swc/plugins/linux_x86_64_19.0.0/727453fb3a62f7f1d952a41e051ca8a6f88cadc45cee43c6a4d1aa45f9b75665.wasmer-v7 +0 -0
  385. package/.swc/plugins/linux_x86_64_19.0.0/fce1bdb8e20a094e4af08bad09cc81497ed0e2e7c51223b07d371063cca18429.wasmer-v7 +0 -0
  386. package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs +0 -137
  387. package/dist/lib/browser/app-graph-builder-AFFC6VB2.mjs.map +0 -7
  388. package/dist/lib/browser/chunk-ORWHM7CO.mjs +0 -32
  389. package/dist/lib/browser/chunk-ORWHM7CO.mjs.map +0 -7
  390. package/dist/lib/browser/chunk-OZY7HV2A.mjs +0 -1643
  391. package/dist/lib/browser/chunk-OZY7HV2A.mjs.map +0 -7
  392. package/dist/lib/browser/chunk-T6M7JB7M.mjs +0 -471
  393. package/dist/lib/browser/chunk-T6M7JB7M.mjs.map +0 -7
  394. package/dist/lib/browser/intent-dispatcher-QG7UPGQX.mjs +0 -11
  395. package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs +0 -39
  396. package/dist/lib/browser/intent-resolver-4S4PSTM5.mjs.map +0 -7
  397. package/dist/lib/browser/store-6E33KLGK.mjs +0 -30
  398. package/dist/lib/browser/store-6E33KLGK.mjs.map +0 -7
  399. package/dist/lib/browser/worker.mjs +0 -85
  400. package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs +0 -138
  401. package/dist/lib/node-esm/app-graph-builder-S4OAULX5.mjs.map +0 -7
  402. package/dist/lib/node-esm/chunk-F63ZRXMK.mjs +0 -1645
  403. package/dist/lib/node-esm/chunk-F63ZRXMK.mjs.map +0 -7
  404. package/dist/lib/node-esm/chunk-HJFU7QOR.mjs +0 -472
  405. package/dist/lib/node-esm/chunk-HJFU7QOR.mjs.map +0 -7
  406. package/dist/lib/node-esm/chunk-UMZQERLE.mjs +0 -34
  407. package/dist/lib/node-esm/chunk-UMZQERLE.mjs.map +0 -7
  408. package/dist/lib/node-esm/intent-dispatcher-NXBGPJOX.mjs +0 -12
  409. package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs +0 -40
  410. package/dist/lib/node-esm/intent-resolver-2ZKXI5ET.mjs.map +0 -7
  411. package/dist/lib/node-esm/store-QQUTQHHT.mjs +0 -31
  412. package/dist/lib/node-esm/store-QQUTQHHT.mjs.map +0 -7
  413. package/dist/lib/node-esm/worker.mjs +0 -86
  414. package/dist/types/src/common/collaboration.d.ts +0 -20
  415. package/dist/types/src/common/collaboration.d.ts.map +0 -1
  416. package/dist/types/src/common/events.d.ts +0 -52
  417. package/dist/types/src/common/events.d.ts.map +0 -1
  418. package/dist/types/src/common/file.d.ts +0 -14
  419. package/dist/types/src/common/file.d.ts.map +0 -1
  420. package/dist/types/src/common/graph.d.ts +0 -21
  421. package/dist/types/src/common/graph.d.ts.map +0 -1
  422. package/dist/types/src/common/layout.d.ts +0 -281
  423. package/dist/types/src/common/layout.d.ts.map +0 -1
  424. package/dist/types/src/common/surface.d.ts +0 -65
  425. package/dist/types/src/common/surface.d.ts.map +0 -1
  426. package/dist/types/src/components/App.d.ts +0 -10
  427. package/dist/types/src/components/App.d.ts.map +0 -1
  428. package/dist/types/src/components/App.stories.d.ts.map +0 -1
  429. package/dist/types/src/components/DefaultFallback.d.ts +0 -8
  430. package/dist/types/src/components/DefaultFallback.d.ts.map +0 -1
  431. package/dist/types/src/components/index.d.ts +0 -2
  432. package/dist/types/src/components/index.d.ts.map +0 -1
  433. package/dist/types/src/components/useApp.d.ts +0 -44
  434. package/dist/types/src/components/useApp.d.ts.map +0 -1
  435. package/dist/types/src/components/useLoading.d.ts.map +0 -1
  436. package/dist/types/src/core/capabilities.d.ts +0 -117
  437. package/dist/types/src/core/capabilities.d.ts.map +0 -1
  438. package/dist/types/src/core/capabilities.test.d.ts +0 -2
  439. package/dist/types/src/core/capabilities.test.d.ts.map +0 -1
  440. package/dist/types/src/core/events.d.ts.map +0 -1
  441. package/dist/types/src/core/manager.d.ts +0 -126
  442. package/dist/types/src/core/manager.d.ts.map +0 -1
  443. package/dist/types/src/core/manager.test.d.ts +0 -2
  444. package/dist/types/src/core/manager.test.d.ts.map +0 -1
  445. package/dist/types/src/playground/debug/Debug.d.ts +0 -6
  446. package/dist/types/src/playground/debug/Debug.d.ts.map +0 -1
  447. package/dist/types/src/playground/debug/index.d.ts +0 -2
  448. package/dist/types/src/playground/debug/index.d.ts.map +0 -1
  449. package/dist/types/src/playground/debug/plugin.d.ts +0 -2
  450. package/dist/types/src/playground/debug/plugin.d.ts.map +0 -1
  451. package/dist/types/src/playground/generator/Main.d.ts +0 -6
  452. package/dist/types/src/playground/generator/Main.d.ts.map +0 -1
  453. package/dist/types/src/playground/generator/Toolbar.d.ts +0 -6
  454. package/dist/types/src/playground/generator/Toolbar.d.ts.map +0 -1
  455. package/dist/types/src/playground/generator/generator.d.ts +0 -7
  456. package/dist/types/src/playground/generator/generator.d.ts.map +0 -1
  457. package/dist/types/src/playground/generator/index.d.ts +0 -3
  458. package/dist/types/src/playground/generator/index.d.ts.map +0 -1
  459. package/dist/types/src/playground/generator/plugin.d.ts +0 -2
  460. package/dist/types/src/playground/generator/plugin.d.ts.map +0 -1
  461. package/dist/types/src/playground/layout/Layout.d.ts +0 -8
  462. package/dist/types/src/playground/layout/Layout.d.ts.map +0 -1
  463. package/dist/types/src/playground/layout/index.d.ts +0 -2
  464. package/dist/types/src/playground/layout/index.d.ts.map +0 -1
  465. package/dist/types/src/playground/layout/plugin.d.ts +0 -2
  466. package/dist/types/src/playground/layout/plugin.d.ts.map +0 -1
  467. package/dist/types/src/playground/logger/Toolbar.d.ts +0 -6
  468. package/dist/types/src/playground/logger/Toolbar.d.ts.map +0 -1
  469. package/dist/types/src/playground/logger/index.d.ts +0 -2
  470. package/dist/types/src/playground/logger/index.d.ts.map +0 -1
  471. package/dist/types/src/playground/logger/plugin.d.ts +0 -2
  472. package/dist/types/src/playground/logger/plugin.d.ts.map +0 -1
  473. package/dist/types/src/playground/logger/schema.d.ts +0 -13
  474. package/dist/types/src/playground/logger/schema.d.ts.map +0 -1
  475. package/dist/types/src/playground/playground.stories.d.ts.map +0 -1
  476. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +0 -2
  477. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +0 -1
  478. package/dist/types/src/plugin-intent/actions.d.ts +0 -38
  479. package/dist/types/src/plugin-intent/actions.d.ts.map +0 -1
  480. package/dist/types/src/plugin-intent/errors.d.ts +0 -16
  481. package/dist/types/src/plugin-intent/errors.d.ts.map +0 -1
  482. package/dist/types/src/plugin-intent/index.d.ts +0 -6
  483. package/dist/types/src/plugin-intent/index.d.ts.map +0 -1
  484. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +0 -139
  485. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +0 -1
  486. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +0 -2
  487. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
  488. package/dist/types/src/plugin-intent/intent.d.ts +0 -63
  489. package/dist/types/src/plugin-intent/intent.d.ts.map +0 -1
  490. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +0 -2
  491. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  492. package/dist/types/src/plugin-settings/actions.d.ts +0 -27
  493. package/dist/types/src/plugin-settings/actions.d.ts.map +0 -1
  494. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +0 -4
  495. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +0 -1
  496. package/dist/types/src/plugin-settings/index.d.ts +0 -3
  497. package/dist/types/src/plugin-settings/index.d.ts.map +0 -1
  498. package/dist/types/src/plugin-settings/intent-resolver.d.ts +0 -4
  499. package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +0 -1
  500. package/dist/types/src/plugin-settings/store.d.ts +0 -5
  501. package/dist/types/src/plugin-settings/store.d.ts.map +0 -1
  502. package/dist/types/src/plugin-settings/translations.d.ts +0 -10
  503. package/dist/types/src/plugin-settings/translations.d.ts.map +0 -1
  504. package/dist/types/src/react/ErrorBoundary.d.ts +0 -30
  505. package/dist/types/src/react/ErrorBoundary.d.ts.map +0 -1
  506. package/dist/types/src/react/IntentContext.d.ts +0 -8
  507. package/dist/types/src/react/IntentContext.d.ts.map +0 -1
  508. package/dist/types/src/react/PluginManagerProvider.d.ts +0 -10
  509. package/dist/types/src/react/PluginManagerProvider.d.ts.map +0 -1
  510. package/dist/types/src/react/Surface.d.ts +0 -12
  511. package/dist/types/src/react/Surface.d.ts.map +0 -1
  512. package/dist/types/src/react/Surface.stories.d.ts +0 -18
  513. package/dist/types/src/react/Surface.stories.d.ts.map +0 -1
  514. package/dist/types/src/react/common.d.ts +0 -13
  515. package/dist/types/src/react/common.d.ts.map +0 -1
  516. package/dist/types/src/react/index.d.ts +0 -7
  517. package/dist/types/src/react/index.d.ts.map +0 -1
  518. package/dist/types/src/react/useCapabilities.d.ts +0 -13
  519. package/dist/types/src/react/useCapabilities.d.ts.map +0 -1
  520. package/dist/types/src/react/useIntentResolver.d.ts +0 -3
  521. package/dist/types/src/react/useIntentResolver.d.ts.map +0 -1
  522. package/dist/types/src/worker.d.ts +0 -4
  523. package/dist/types/src/worker.d.ts.map +0 -1
  524. package/src/common/collaboration.ts +0 -18
  525. package/src/common/events.ts +0 -79
  526. package/src/common/file.ts +0 -22
  527. package/src/common/graph.ts +0 -30
  528. package/src/common/layout.ts +0 -278
  529. package/src/common/surface.ts +0 -86
  530. package/src/components/App.stories.tsx +0 -35
  531. package/src/components/App.tsx +0 -59
  532. package/src/components/DefaultFallback.tsx +0 -26
  533. package/src/components/useApp.tsx +0 -166
  534. package/src/core/capabilities.test.ts +0 -136
  535. package/src/core/capabilities.ts +0 -259
  536. package/src/core/manager.test.ts +0 -516
  537. package/src/core/manager.ts +0 -597
  538. package/src/playground/debug/Debug.tsx +0 -39
  539. package/src/playground/debug/plugin.ts +0 -17
  540. package/src/playground/generator/Main.tsx +0 -71
  541. package/src/playground/generator/Toolbar.tsx +0 -47
  542. package/src/playground/generator/generator.ts +0 -48
  543. package/src/playground/generator/index.ts +0 -6
  544. package/src/playground/generator/plugin.ts +0 -23
  545. package/src/playground/layout/Layout.tsx +0 -33
  546. package/src/playground/layout/plugin.ts +0 -17
  547. package/src/playground/logger/Toolbar.tsx +0 -30
  548. package/src/playground/logger/plugin.ts +0 -37
  549. package/src/playground/logger/schema.ts +0 -12
  550. package/src/playground/playground.stories.tsx +0 -47
  551. package/src/plugin-intent/IntentPlugin.ts +0 -21
  552. package/src/plugin-intent/actions.ts +0 -33
  553. package/src/plugin-intent/errors.ts +0 -39
  554. package/src/plugin-intent/index.ts +0 -9
  555. package/src/plugin-intent/intent-dispatcher.test.ts +0 -279
  556. package/src/plugin-intent/intent-dispatcher.ts +0 -335
  557. package/src/plugin-intent/intent.ts +0 -154
  558. package/src/plugin-settings/SettingsPlugin.ts +0 -36
  559. package/src/plugin-settings/actions.ts +0 -29
  560. package/src/plugin-settings/app-graph-builder.ts +0 -158
  561. package/src/plugin-settings/index.ts +0 -6
  562. package/src/plugin-settings/intent-resolver.ts +0 -35
  563. package/src/plugin-settings/store.ts +0 -33
  564. package/src/plugin-settings/translations.ts +0 -19
  565. package/src/react/ErrorBoundary.tsx +0 -54
  566. package/src/react/IntentContext.tsx +0 -35
  567. package/src/react/Surface.stories.tsx +0 -104
  568. package/src/react/Surface.tsx +0 -78
  569. package/src/react/common.ts +0 -13
  570. package/src/react/index.ts +0 -10
  571. package/src/react/useCapabilities.ts +0 -31
  572. package/src/react/useIntentResolver.ts +0 -22
  573. package/src/worker.ts +0 -11
  574. /package/dist/lib/{node-esm/worker.mjs.map → browser/chunk-J5LGTIGS.mjs.map} +0 -0
  575. /package/dist/lib/{node-esm/intent-dispatcher-NXBGPJOX.mjs.map → browser/common/activation-events.mjs.map} +0 -0
  576. /package/dist/lib/browser/{worker.mjs.map → common/capabilities.mjs.map} +0 -0
  577. /package/dist/lib/browser/{intent-dispatcher-QG7UPGQX.mjs.map → core/activation-event.mjs.map} +0 -0
@@ -1,1643 +0,0 @@
1
- // src/plugin-intent/intent-dispatcher.ts
2
- import { Effect as Effect3, Option, Ref as Ref2, pipe as pipe2 } from "effect";
3
- import { live as live2 } from "@dxos/live-object";
4
- import { log as log3 } from "@dxos/log";
5
- import { byPosition } from "@dxos/util";
6
-
7
- // src/core/capabilities.ts
8
- import { Rx } from "@effect-rx/rx-react";
9
- import { Effect } from "effect";
10
- import { Trigger } from "@dxos/async";
11
- import { invariant } from "@dxos/invariant";
12
- import { log } from "@dxos/log";
13
- function _define_property(obj, key, value) {
14
- if (key in obj) {
15
- Object.defineProperty(obj, key, {
16
- value,
17
- enumerable: true,
18
- configurable: true,
19
- writable: true
20
- });
21
- } else {
22
- obj[key] = value;
23
- }
24
- return obj;
25
- }
26
- var __dxlog_file = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/capabilities.ts";
27
- var InterfaceDefTypeId = Symbol.for("InterfaceDefTypeId");
28
- var defineCapability = (identifier) => {
29
- return {
30
- identifier
31
- };
32
- };
33
- var CapabilityImpl = class {
34
- constructor(moduleId, implementation) {
35
- _define_property(this, "moduleId", void 0);
36
- _define_property(this, "implementation", void 0);
37
- this.moduleId = moduleId;
38
- this.implementation = implementation;
39
- }
40
- };
41
- var contributes = (interfaceDef, implementation, deactivate) => {
42
- return {
43
- interface: interfaceDef,
44
- implementation,
45
- deactivate
46
- };
47
- };
48
- var lazy = (c) => async (props) => {
49
- const { default: getCapability } = await c();
50
- return async () => getCapability(props);
51
- };
52
- var PluginContext = class {
53
- /**
54
- * @internal
55
- */
56
- contributeCapability({ module: moduleId, interface: interfaceDef, implementation }) {
57
- const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
58
- const capability = new CapabilityImpl(moduleId, implementation);
59
- if (current.includes(capability)) {
60
- return;
61
- }
62
- this._registry.set(this._capabilityImpls(interfaceDef.identifier), [
63
- ...current,
64
- capability
65
- ]);
66
- log("capability contributed", {
67
- id: interfaceDef.identifier,
68
- moduleId,
69
- count: current.length
70
- }, {
71
- F: __dxlog_file,
72
- L: 166,
73
- S: this,
74
- C: (f, a) => f(...a)
75
- });
76
- }
77
- /**
78
- * @internal
79
- */
80
- removeCapability(interfaceDef, implementation) {
81
- const current = this._registry.get(this._capabilityImpls(interfaceDef.identifier));
82
- if (current.length === 0) {
83
- return;
84
- }
85
- const next = current.filter((c) => c.implementation !== implementation);
86
- if (next.length !== current.length) {
87
- this._registry.set(this._capabilityImpls(interfaceDef.identifier), next);
88
- log("capability removed", {
89
- id: interfaceDef.identifier,
90
- count: current.length
91
- }, {
92
- F: __dxlog_file,
93
- L: 185,
94
- S: this,
95
- C: (f, a) => f(...a)
96
- });
97
- } else {
98
- log.warn("capability not removed", {
99
- id: interfaceDef.identifier
100
- }, {
101
- F: __dxlog_file,
102
- L: 187,
103
- S: this,
104
- C: (f, a) => f(...a)
105
- });
106
- }
107
- }
108
- /**
109
- * Get the Rx reference to the available capabilities for a given interface.
110
- * Primarily useful for deriving other Rx values based on the capabilities or
111
- * for subscribing to changes in the capabilities.
112
- * @returns An Rx reference to the available capabilities.
113
- */
114
- capabilities(interfaceDef) {
115
- return this._capabilities(interfaceDef.identifier);
116
- }
117
- /**
118
- * Get the Rx reference to the available capabilities for a given interface.
119
- * Primarily useful for deriving other Rx values based on the capability or
120
- * for subscribing to changes in the capability.
121
- * @returns An Rx reference to the available capability.
122
- * @throws If no capability is found.
123
- */
124
- capability(interfaceDef) {
125
- return this._capability(interfaceDef.identifier);
126
- }
127
- /**
128
- * Get capabilities from the plugin context.
129
- * @returns An array of capabilities.
130
- */
131
- getCapabilities(interfaceDef) {
132
- return this._registry.get(this.capabilities(interfaceDef));
133
- }
134
- /**
135
- * Requests a single capability from the plugin context.
136
- * @returns The capability.
137
- * @throws If no capability is found.
138
- */
139
- getCapability(interfaceDef) {
140
- return this._registry.get(this.capability(interfaceDef));
141
- }
142
- /**
143
- * Waits for a capability to be available.
144
- * @returns The capability.
145
- */
146
- async waitForCapability(interfaceDef) {
147
- const [capability] = this.getCapabilities(interfaceDef);
148
- if (capability) {
149
- return capability;
150
- }
151
- const trigger = new Trigger();
152
- const cancel = this._registry.subscribe(this.capabilities(interfaceDef), (capabilities) => {
153
- if (capabilities.length > 0) {
154
- trigger.wake(capabilities[0]);
155
- }
156
- });
157
- const result = await trigger.wait();
158
- cancel();
159
- return result;
160
- }
161
- async activatePromise(event) {
162
- return this.activate(event).pipe(Effect.runPromise);
163
- }
164
- async resetPromise(event) {
165
- return this.reset(event).pipe(Effect.runPromise);
166
- }
167
- constructor({ registry, activate, reset }) {
168
- _define_property(this, "_registry", void 0);
169
- _define_property(this, "_capabilityImpls", Rx.family(() => {
170
- return Rx.make([]).pipe(Rx.keepAlive);
171
- }));
172
- _define_property(this, "_capabilities", Rx.family((id) => {
173
- return Rx.make((get) => {
174
- const current = get(this._capabilityImpls(id));
175
- return current.map((c) => c.implementation);
176
- });
177
- }));
178
- _define_property(this, "_capability", Rx.family((id) => {
179
- return Rx.make((get) => {
180
- const current = get(this._capabilities(id));
181
- invariant(current.length > 0, `No capability found for ${id}`, {
182
- F: __dxlog_file,
183
- L: 122,
184
- S: this,
185
- A: [
186
- "current.length > 0",
187
- "`No capability found for ${id}`"
188
- ]
189
- });
190
- return current[0];
191
- });
192
- }));
193
- _define_property(this, "activate", void 0);
194
- _define_property(this, "reset", void 0);
195
- this._registry = registry;
196
- this.activate = activate;
197
- this.reset = reset;
198
- }
199
- };
200
-
201
- // src/core/events.ts
202
- var defineEvent = (id, specifier) => {
203
- return {
204
- id,
205
- specifier
206
- };
207
- };
208
- var eventKey = (event) => event.specifier ? `${event.id}:${event.specifier}` : event.id;
209
- var oneOf = (...events) => ({
210
- type: "one-of",
211
- events
212
- });
213
- var allOf = (...events) => ({
214
- type: "all-of",
215
- events
216
- });
217
- var isOneOf = (events) => "type" in events && events.type === "one-of";
218
- var isAllOf = (events) => "type" in events && events.type === "all-of";
219
- var getEvents = (events) => "type" in events ? events.events : [
220
- events
221
- ];
222
-
223
- // src/core/manager.ts
224
- import { Registry } from "@effect-rx/rx-react";
225
- import { untracked } from "@preact/signals-core";
226
- import { Array, Duration, Effect as Effect2, Fiber, HashSet, Match, Ref, pipe } from "effect";
227
- import { Event } from "@dxos/async";
228
- import { live } from "@dxos/live-object";
229
- import { log as log2 } from "@dxos/log";
230
- function _define_property2(obj, key, value) {
231
- if (key in obj) {
232
- Object.defineProperty(obj, key, {
233
- value,
234
- enumerable: true,
235
- configurable: true,
236
- writable: true
237
- });
238
- } else {
239
- obj[key] = value;
240
- }
241
- return obj;
242
- }
243
- var __dxlog_file2 = "/__w/dxos/dxos/packages/sdk/app-framework/src/core/manager.ts";
244
- var isPromise = (value) => {
245
- return value !== null && typeof value === "object" && "then" in value;
246
- };
247
- var PluginManager = class {
248
- /**
249
- * Plugins that are currently registered.
250
- *
251
- * @reactive
252
- */
253
- get plugins() {
254
- return this._state.plugins;
255
- }
256
- /**
257
- * Ids of plugins that are core and cannot be removed.
258
- *
259
- * @reactive
260
- */
261
- get core() {
262
- return this._state.core;
263
- }
264
- /**
265
- * Ids of plugins that are currently enabled.
266
- *
267
- * @reactive
268
- */
269
- get enabled() {
270
- return this._state.enabled;
271
- }
272
- /**
273
- * Modules of plugins which are currently enabled.
274
- *
275
- * @reactive
276
- */
277
- get modules() {
278
- return this._state.modules;
279
- }
280
- /**
281
- * Ids of modules which are currently active.
282
- *
283
- * @reactive
284
- */
285
- get active() {
286
- return this._state.active;
287
- }
288
- /**
289
- * Ids of events which have been fired.
290
- *
291
- * @reactive
292
- */
293
- get eventsFired() {
294
- return this._state.eventsFired;
295
- }
296
- /**
297
- * Ids of modules which are pending reset.
298
- *
299
- * @reactive
300
- */
301
- get pendingReset() {
302
- return this._state.pendingReset;
303
- }
304
- /**
305
- * Adds a plugin to the manager via the plugin loader.
306
- * @param id The id of the plugin.
307
- */
308
- async add(id) {
309
- return untracked(async () => {
310
- log2("add plugin", {
311
- id
312
- }, {
313
- F: __dxlog_file2,
314
- L: 157,
315
- S: this,
316
- C: (f, a) => f(...a)
317
- });
318
- const plugin = await this._pluginLoader(id);
319
- this._addPlugin(plugin);
320
- return this.enable(id);
321
- });
322
- }
323
- /**
324
- * Enables a plugin.
325
- * @param id The id of the plugin.
326
- */
327
- enable(id) {
328
- return untracked(async () => {
329
- log2("enable plugin", {
330
- id
331
- }, {
332
- F: __dxlog_file2,
333
- L: 170,
334
- S: this,
335
- C: (f, a) => f(...a)
336
- });
337
- const plugin = this._getPlugin(id);
338
- if (!plugin) {
339
- return false;
340
- }
341
- if (!this._state.enabled.includes(id)) {
342
- this._state.enabled.push(id);
343
- }
344
- plugin.modules.forEach((module) => {
345
- this._addModule(module);
346
- this._setPendingResetByModule(module);
347
- });
348
- log2("pending reset", {
349
- events: [
350
- ...this.pendingReset
351
- ]
352
- }, {
353
- F: __dxlog_file2,
354
- L: 185,
355
- S: this,
356
- C: (f, a) => f(...a)
357
- });
358
- await Effect2.runPromise(Effect2.all(this.pendingReset.map((event) => this._activate(event)), {
359
- concurrency: "unbounded"
360
- }));
361
- return true;
362
- });
363
- }
364
- /**
365
- * Removes a plugin from the manager.
366
- * @param id The id of the plugin.
367
- */
368
- remove(id) {
369
- return untracked(() => {
370
- log2("remove plugin", {
371
- id
372
- }, {
373
- F: __dxlog_file2,
374
- L: 203,
375
- S: this,
376
- C: (f, a) => f(...a)
377
- });
378
- const result = this.disable(id);
379
- if (!result) {
380
- return false;
381
- }
382
- this._removePlugin(id);
383
- return true;
384
- });
385
- }
386
- /**
387
- * Disables a plugin.
388
- * @param id The id of the plugin.
389
- */
390
- disable(id) {
391
- return untracked(async () => {
392
- log2("disable plugin", {
393
- id
394
- }, {
395
- F: __dxlog_file2,
396
- L: 220,
397
- S: this,
398
- C: (f, a) => f(...a)
399
- });
400
- if (this._state.core.includes(id)) {
401
- return false;
402
- }
403
- const plugin = this._getPlugin(id);
404
- if (!plugin) {
405
- return false;
406
- }
407
- const enabledIndex = this._state.enabled.findIndex((enabled) => enabled === id);
408
- if (enabledIndex !== -1) {
409
- this._state.enabled.splice(enabledIndex, 1);
410
- await Effect2.runPromise(this._deactivate(id));
411
- plugin.modules.forEach((module) => {
412
- this._removeModule(module.id);
413
- });
414
- }
415
- return true;
416
- });
417
- }
418
- /**
419
- * Activates plugins based on the activation event.
420
- * @param event The activation event.
421
- * @returns Whether the activation was successful.
422
- */
423
- activate(event) {
424
- return untracked(() => Effect2.runPromise(this._activate(event)));
425
- }
426
- /**
427
- * Deactivates all of the modules for a plugin.
428
- * @param id The id of the plugin.
429
- * @returns Whether the deactivation was successful.
430
- */
431
- deactivate(id) {
432
- return untracked(() => Effect2.runPromise(this._deactivate(id)));
433
- }
434
- /**
435
- * Re-activates the modules that were activated by the event.
436
- * @param event The activation event.
437
- * @returns Whether the reset was successful.
438
- */
439
- reset(event) {
440
- return untracked(() => Effect2.runPromise(this._reset(event)));
441
- }
442
- _addPlugin(plugin) {
443
- untracked(() => {
444
- log2("add plugin", {
445
- id: plugin.meta.id
446
- }, {
447
- F: __dxlog_file2,
448
- L: 273,
449
- S: this,
450
- C: (f, a) => f(...a)
451
- });
452
- if (!this._state.plugins.includes(plugin)) {
453
- this._state.plugins.push(plugin);
454
- }
455
- });
456
- }
457
- _removePlugin(id) {
458
- untracked(() => {
459
- log2("remove plugin", {
460
- id
461
- }, {
462
- F: __dxlog_file2,
463
- L: 283,
464
- S: this,
465
- C: (f, a) => f(...a)
466
- });
467
- const pluginIndex = this._state.plugins.findIndex((plugin) => plugin.meta.id === id);
468
- if (pluginIndex !== -1) {
469
- this._state.plugins.splice(pluginIndex, 1);
470
- }
471
- });
472
- }
473
- _addModule(module) {
474
- untracked(() => {
475
- log2("add module", {
476
- id: module.id
477
- }, {
478
- F: __dxlog_file2,
479
- L: 293,
480
- S: this,
481
- C: (f, a) => f(...a)
482
- });
483
- if (!this._state.modules.includes(module)) {
484
- this._state.modules.push(module);
485
- }
486
- });
487
- }
488
- _removeModule(id) {
489
- untracked(() => {
490
- log2("remove module", {
491
- id
492
- }, {
493
- F: __dxlog_file2,
494
- L: 303,
495
- S: this,
496
- C: (f, a) => f(...a)
497
- });
498
- const moduleIndex = this._state.modules.findIndex((module) => module.id === id);
499
- if (moduleIndex !== -1) {
500
- this._state.modules.splice(moduleIndex, 1);
501
- }
502
- });
503
- }
504
- _getPlugin(id) {
505
- return this._state.plugins.find((plugin) => plugin.meta.id === id);
506
- }
507
- _getActiveModules() {
508
- return this._state.modules.filter((module) => this._state.active.includes(module.id));
509
- }
510
- _getInactiveModules() {
511
- return this._state.modules.filter((module) => !this._state.active.includes(module.id));
512
- }
513
- _getActiveModulesByEvent(key) {
514
- return this._getActiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
515
- }
516
- _getInactiveModulesByEvent(key) {
517
- return this._getInactiveModules().filter((module) => getEvents(module.activatesOn).map(eventKey).includes(key));
518
- }
519
- _setPendingResetByModule(module) {
520
- return untracked(() => {
521
- const activationEvents = getEvents(module.activatesOn).map(eventKey).filter((key) => this._state.eventsFired.includes(key));
522
- const pendingReset = Array.fromIterable(new Set(activationEvents)).filter((event) => !this._state.pendingReset.includes(event));
523
- if (pendingReset.length > 0) {
524
- log2("pending reset", {
525
- events: pendingReset
526
- }, {
527
- F: __dxlog_file2,
528
- L: 341,
529
- S: this,
530
- C: (f, a) => f(...a)
531
- });
532
- this._state.pendingReset.push(...pendingReset);
533
- }
534
- });
535
- }
536
- /**
537
- * @internal
538
- */
539
- // TODO(wittjosiah): Improve error typing.
540
- _activate(event, params) {
541
- return Effect2.gen(this, function* () {
542
- const key = typeof event === "string" ? event : eventKey(event);
543
- log2("activating", {
544
- key,
545
- ...params
546
- }, {
547
- F: __dxlog_file2,
548
- L: 357,
549
- S: this,
550
- C: (f, a) => f(...a)
551
- });
552
- yield* Ref.update(this._activatingEvents, (activating) => Array.append(activating, key));
553
- const pendingIndex = this._state.pendingReset.findIndex((event2) => event2 === key);
554
- if (pendingIndex !== -1) {
555
- this._state.pendingReset.splice(pendingIndex, 1);
556
- }
557
- const activatingEvents = yield* this._activatingEvents;
558
- const activatingModules = yield* this._activatingModules;
559
- const modules = this._getInactiveModulesByEvent(key).filter((module) => {
560
- const allOf2 = isAllOf(module.activatesOn);
561
- if (!allOf2) {
562
- return true;
563
- }
564
- const events = module.activatesOn.events.filter((event2) => eventKey(event2) !== key);
565
- return events.every((event2) => this._state.eventsFired.includes(eventKey(event2)) || activatingEvents.includes(eventKey(event2))) && !activatingModules.includes(module.id);
566
- });
567
- yield* Ref.update(this._activatingModules, (activating) => Array.appendAll(activating, modules.map((module) => module.id)));
568
- if (modules.length === 0) {
569
- log2("no modules to activate", {
570
- key
571
- }, {
572
- F: __dxlog_file2,
573
- L: 388,
574
- S: this,
575
- C: (f, a) => f(...a)
576
- });
577
- if (!this._state.eventsFired.includes(key)) {
578
- this._state.eventsFired.push(key);
579
- }
580
- return false;
581
- }
582
- log2("activating modules", {
583
- key,
584
- modules: modules.map((module) => module.id)
585
- }, {
586
- F: __dxlog_file2,
587
- L: 395,
588
- S: this,
589
- C: (f, a) => f(...a)
590
- });
591
- this.activation.emit({
592
- event: key,
593
- state: "activating"
594
- });
595
- yield* pipe(modules, Array.flatMap((module) => module.activatesBefore ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
596
- before: key
597
- })), Effect2.allWith({
598
- concurrency: "unbounded"
599
- }));
600
- const getCapabilities = yield* pipe(modules, Array.map((mod) => this._loadModule(mod)), Effect2.allWith({
601
- concurrency: "unbounded"
602
- }), Effect2.catchAll((error) => {
603
- this.activation.emit({
604
- event: key,
605
- state: "error",
606
- error
607
- });
608
- return Effect2.fail(error);
609
- }));
610
- yield* pipe(
611
- modules,
612
- Array.zip(getCapabilities),
613
- Array.map(([module, capabilities]) => this._contributeCapabilities(module, capabilities)),
614
- // TODO(wittjosiah): This currently can't be run in parallel.
615
- // Running this with concurrency causes races with `allOf` activation events.
616
- Effect2.all
617
- );
618
- yield* pipe(modules, Array.flatMap((module) => module.activatesAfter ?? []), HashSet.fromIterable, HashSet.toValues, Array.filter((event2) => !activatingEvents.includes(eventKey(event2))), Array.map((event2) => this._activate(event2, {
619
- after: key
620
- })), Effect2.allWith({
621
- concurrency: "unbounded"
622
- }));
623
- yield* Ref.update(this._activatingEvents, (activating) => Array.filter(activating, (event2) => event2 !== key));
624
- yield* Ref.update(this._activatingModules, (activating) => Array.filter(activating, (module) => !modules.map((module2) => module2.id).includes(module)));
625
- if (!this._state.eventsFired.includes(key)) {
626
- this._state.eventsFired.push(key);
627
- }
628
- this.activation.emit({
629
- event: key,
630
- state: "activated"
631
- });
632
- log2("activated", {
633
- key
634
- }, {
635
- F: __dxlog_file2,
636
- L: 451,
637
- S: this,
638
- C: (f, a) => f(...a)
639
- });
640
- return true;
641
- });
642
- }
643
- _contributeCapabilities(module, capabilities) {
644
- return Effect2.gen(this, function* () {
645
- capabilities.forEach((capability) => {
646
- this.context.contributeCapability({
647
- module: module.id,
648
- ...capability
649
- });
650
- });
651
- this._state.active.push(module.id);
652
- this._capabilities.set(module.id, capabilities);
653
- });
654
- }
655
- _deactivate(id) {
656
- return Effect2.gen(this, function* () {
657
- const plugin = this._getPlugin(id);
658
- if (!plugin) {
659
- return false;
660
- }
661
- const modules = plugin.modules;
662
- const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
663
- concurrency: "unbounded"
664
- });
665
- return results.every((result) => result);
666
- });
667
- }
668
- _deactivateModule(module) {
669
- return Effect2.gen(this, function* () {
670
- const id = module.id;
671
- log2("deactivating", {
672
- id
673
- }, {
674
- F: __dxlog_file2,
675
- L: 533,
676
- S: this,
677
- C: (f, a) => f(...a)
678
- });
679
- this._moduleMemoMap.delete(id);
680
- const capabilities = this._capabilities.get(id);
681
- if (capabilities) {
682
- for (const capability of capabilities) {
683
- this.context.removeCapability(capability.interface, capability.implementation);
684
- const program = capability.deactivate?.();
685
- yield* Match.value(program).pipe(Match.when(Effect2.isEffect, (effect) => effect), Match.when(isPromise, (promise) => Effect2.tryPromise({
686
- try: () => promise,
687
- catch: (error) => error
688
- })), Match.orElse((program2) => Effect2.succeed(program2)));
689
- }
690
- this._capabilities.delete(id);
691
- }
692
- const activeIndex = this._state.active.findIndex((event) => event === id);
693
- if (activeIndex !== -1) {
694
- this._state.active.splice(activeIndex, 1);
695
- }
696
- log2("deactivated", {
697
- id
698
- }, {
699
- F: __dxlog_file2,
700
- L: 560,
701
- S: this,
702
- C: (f, a) => f(...a)
703
- });
704
- return true;
705
- });
706
- }
707
- _reset(event) {
708
- return Effect2.gen(this, function* () {
709
- const key = typeof event === "string" ? event : eventKey(event);
710
- log2("reset", {
711
- key
712
- }, {
713
- F: __dxlog_file2,
714
- L: 568,
715
- S: this,
716
- C: (f, a) => f(...a)
717
- });
718
- const modules = this._getActiveModulesByEvent(key);
719
- const results = yield* Effect2.all(modules.map((module) => this._deactivateModule(module)), {
720
- concurrency: "unbounded"
721
- });
722
- if (results.every((result) => result)) {
723
- return yield* this._activate(key);
724
- } else {
725
- return false;
726
- }
727
- });
728
- }
729
- constructor({ pluginLoader, plugins = [], core = plugins.map(({ meta }) => meta.id), enabled = [], registry }) {
730
- _define_property2(this, "activation", new Event());
731
- _define_property2(this, "context", void 0);
732
- _define_property2(this, "registry", void 0);
733
- _define_property2(this, "_state", void 0);
734
- _define_property2(this, "_pluginLoader", void 0);
735
- _define_property2(this, "_capabilities", /* @__PURE__ */ new Map());
736
- _define_property2(this, "_moduleMemoMap", /* @__PURE__ */ new Map());
737
- _define_property2(this, "_activatingEvents", Effect2.runSync(Ref.make([])));
738
- _define_property2(this, "_activatingModules", Effect2.runSync(Ref.make([])));
739
- _define_property2(this, "_loadModule", (mod) => Effect2.tryPromise({
740
- try: async () => {
741
- const entry = this._moduleMemoMap.get(mod.id);
742
- if (entry) {
743
- return entry;
744
- }
745
- const promise = (async () => {
746
- const start = performance.now();
747
- let failed = false;
748
- try {
749
- log2("loading module", {
750
- module: mod.id
751
- }, {
752
- F: __dxlog_file2,
753
- L: 470,
754
- S: this,
755
- C: (f, a) => f(...a)
756
- });
757
- let activationResult = await mod.activate(this.context);
758
- if (typeof activationResult === "function") {
759
- activationResult = await activationResult();
760
- }
761
- return Array.isArray(activationResult) ? activationResult : [
762
- activationResult
763
- ];
764
- } catch (error) {
765
- failed = true;
766
- throw error;
767
- } finally {
768
- performance.measure("activate-module", {
769
- start,
770
- end: performance.now(),
771
- detail: {
772
- module: mod.id
773
- }
774
- });
775
- log2("loaded module", {
776
- module: mod.id,
777
- elapsed: performance.now() - start,
778
- failed
779
- }, {
780
- F: __dxlog_file2,
781
- L: 488,
782
- S: this,
783
- C: (f, a) => f(...a)
784
- });
785
- }
786
- })();
787
- this._moduleMemoMap.set(mod.id, promise);
788
- return promise;
789
- },
790
- catch: (error) => error
791
- }).pipe(Effect2.withSpan("PluginManager._loadModule"), together(Effect2.sleep(Duration.seconds(10)).pipe(Effect2.andThen(Effect2.sync(() => log2.warn(`module is taking a long time to activate`, {
792
- module: mod.id
793
- }, {
794
- F: __dxlog_file2,
795
- L: 499,
796
- S: this,
797
- C: (f, a) => f(...a)
798
- })))))));
799
- this.registry = registry ?? Registry.make();
800
- this.context = new PluginContext({
801
- registry: this.registry,
802
- activate: (event) => this._activate(event),
803
- reset: (id) => this._reset(id)
804
- });
805
- this._pluginLoader = pluginLoader;
806
- this._state = live({
807
- plugins,
808
- core,
809
- enabled,
810
- modules: [],
811
- active: [],
812
- eventsFired: [],
813
- pendingReset: []
814
- });
815
- plugins.forEach((plugin) => this._addPlugin(plugin));
816
- core.forEach((id) => this.enable(id));
817
- enabled.forEach((id) => this.enable(id));
818
- }
819
- };
820
- var together = (togetherEffect) => (effect) => Effect2.gen(function* () {
821
- const togetherFiber = yield* Effect2.fork(togetherEffect);
822
- const result = yield* effect;
823
- yield* Fiber.interrupt(togetherFiber);
824
- return result;
825
- });
826
-
827
- // src/core/plugin.ts
828
- function _define_property3(obj, key, value) {
829
- if (key in obj) {
830
- Object.defineProperty(obj, key, {
831
- value,
832
- enumerable: true,
833
- configurable: true,
834
- writable: true
835
- });
836
- } else {
837
- obj[key] = value;
838
- }
839
- return obj;
840
- }
841
- var PluginModule = class {
842
- constructor(options) {
843
- _define_property3(this, "id", void 0);
844
- _define_property3(this, "activatesOn", void 0);
845
- _define_property3(this, "activatesBefore", void 0);
846
- _define_property3(this, "activatesAfter", void 0);
847
- _define_property3(this, "activate", void 0);
848
- this.id = options.id;
849
- this.activatesOn = options.activatesOn;
850
- this.activatesBefore = options.activatesBefore;
851
- this.activatesAfter = options.activatesAfter;
852
- this.activate = options.activate;
853
- }
854
- };
855
- var defineModule = (options) => new PluginModule(options);
856
- var Plugin = class {
857
- constructor(meta, modules) {
858
- _define_property3(this, "meta", void 0);
859
- _define_property3(this, "modules", void 0);
860
- this.meta = meta;
861
- this.modules = modules;
862
- }
863
- };
864
- var definePlugin = (meta, modules) => {
865
- return new Plugin(meta, modules);
866
- };
867
-
868
- // src/common/capabilities.ts
869
- (function(Capabilities2) {
870
- Capabilities2.Null = defineCapability("dxos.org/app-framework/capability/null");
871
- Capabilities2.PluginManager = defineCapability("dxos.org/app-framework/capability/plugin-manager");
872
- Capabilities2.RxRegistry = defineCapability("dxos.org/app-framework/capability/rx-registry");
873
- Capabilities2.ReactContext = defineCapability("dxos.org/app-framework/capability/react-context");
874
- Capabilities2.ReactRoot = defineCapability("dxos.org/app-framework/capability/react-root");
875
- Capabilities2.ReactSurface = defineCapability("dxos.org/app-framework/common/react-surface");
876
- Capabilities2.IntentResolver = defineCapability("dxos.org/app-framework/capability/intent-resolver");
877
- Capabilities2.IntentDispatcher = defineCapability("dxos.org/app-framework/capability/intent-dispatcher");
878
- Capabilities2.Layout = defineCapability("dxos.org/app-framework/capability/layout");
879
- Capabilities2.Translations = defineCapability("dxos.org/app-framework/capability/translations");
880
- Capabilities2.AppGraph = defineCapability("dxos.org/app-framework/capability/app-graph");
881
- Capabilities2.AppGraphBuilder = defineCapability("dxos.org/app-framework/capability/app-graph-builder");
882
- Capabilities2.AppGraphSerializer = defineCapability("dxos.org/app-framework/capability/app-graph-serializer");
883
- Capabilities2.SettingsStore = defineCapability("dxos.org/app-framework/capability/settings-store");
884
- Capabilities2.Settings = defineCapability("dxos.org/app-framework/capability/settings");
885
- Capabilities2.Metadata = defineCapability("dxos.org/app-framework/capability/metadata");
886
- Capabilities2.Toolkit = defineCapability("dxos.org/app-framework/capability/ai-toolkit");
887
- Capabilities2.ToolkitHandler = defineCapability("dxos.org/app-framework/capability/ai-toolkit-handler");
888
- Capabilities2.BlueprintDefinition = defineCapability("dxos.org/app-framework/capability/blueprint-definition");
889
- Capabilities2.Functions = defineCapability("dxos.org/app-framework/capability/functions");
890
- Capabilities2.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
891
- Capabilities2.AnchorSort = defineCapability("dxos.org/app-framework/capability/anchor-sort");
892
- })(Capabilities || (Capabilities = {}));
893
- var Capabilities;
894
-
895
- // src/common/collaboration.ts
896
- import { Schema } from "effect";
897
- import { DataType } from "@dxos/schema";
898
- (function(CollaborationActions2) {
899
- class AcceptProposal extends Schema.TaggedClass()("collaboration/accept-proposal", {
900
- input: Schema.Struct({
901
- subject: Schema.Any,
902
- anchor: Schema.String,
903
- proposal: DataType.MessageBlock.Proposal
904
- }),
905
- output: Schema.Void
906
- }) {
907
- }
908
- CollaborationActions2.AcceptProposal = AcceptProposal;
909
- })(CollaborationActions || (CollaborationActions = {}));
910
- var CollaborationActions;
911
-
912
- // src/common/events.ts
913
- (function(Events2) {
914
- Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
915
- Events2.SetupReactSurface = defineEvent("dxos.org/app-framework/event/setup-react-surface");
916
- Events2.SetupMetadata = defineEvent("dxos.org/app-framework/event/setup-metadata");
917
- Events2.SetupIntentResolver = defineEvent("dxos.org/app-framework/event/setup-intent-resolver");
918
- Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
919
- Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
920
- Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
921
- Events2.SetupArtifactDefinition = defineEvent("dxos.org/app-framework/event/setup-artifact-definition");
922
- Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
923
- Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
924
- Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
925
- Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
926
- Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
927
- })(Events || (Events = {}));
928
- var Events;
929
-
930
- // src/common/file.ts
931
- import { Schema as Schema2 } from "effect";
932
- var defaultFileTypes = {
933
- images: [
934
- "png",
935
- "jpg",
936
- "jpeg",
937
- "gif"
938
- ],
939
- media: [
940
- "mp3",
941
- "mp4",
942
- "mov",
943
- "avi"
944
- ],
945
- text: [
946
- "pdf",
947
- "txt",
948
- "md"
949
- ]
950
- };
951
- var FileInfoSchema = Schema2.Struct({
952
- name: Schema2.String,
953
- type: Schema2.String,
954
- url: Schema2.optional(Schema2.String),
955
- cid: Schema2.optional(Schema2.String)
956
- });
957
-
958
- // src/common/layout.ts
959
- import { Schema as Schema5 } from "effect";
960
-
961
- // src/plugin-intent/actions.ts
962
- import { Schema as Schema4 } from "effect";
963
-
964
- // src/plugin-intent/intent.ts
965
- import { Schema as Schema3 } from "effect";
966
- var createIntent = (schema, data = {}, params = {}) => {
967
- const _ = Schema3.validateSync(schema.fields.input)(data);
968
- const intent = {
969
- ...params,
970
- _schema: schema,
971
- id: schema._tag,
972
- data
973
- };
974
- return {
975
- first: intent,
976
- last: intent,
977
- all: [
978
- intent
979
- ]
980
- };
981
- };
982
- var chain = (schema, data = {}, params = {}) => (intent) => {
983
- const intents = "all" in intent ? intent.all : [
984
- intent
985
- ];
986
- const first = intents[0];
987
- const last = {
988
- ...params,
989
- _schema: schema,
990
- id: schema._tag,
991
- data
992
- };
993
- return {
994
- first,
995
- last,
996
- all: [
997
- ...intents,
998
- last
999
- ]
1000
- };
1001
- };
1002
- var Label = Schema3.Union(Schema3.String, Schema3.mutable(Schema3.Tuple(Schema3.String, Schema3.mutable(Schema3.Struct({
1003
- ns: Schema3.String,
1004
- count: Schema3.optional(Schema3.Number),
1005
- defaultValue: Schema3.optional(Schema3.String)
1006
- })))));
1007
-
1008
- // src/plugin-intent/actions.ts
1009
- var INTENT_PLUGIN = "dxos.org/plugin/intent";
1010
- var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
1011
- (function(IntentAction2) {
1012
- class Track extends Schema4.TaggedClass()(`${INTENT_ACTION}/track`, {
1013
- input: Schema4.Struct({
1014
- intents: Schema4.Array(Schema4.String),
1015
- error: Schema4.optional(Schema4.String)
1016
- }),
1017
- output: Schema4.Void
1018
- }) {
1019
- }
1020
- IntentAction2.Track = Track;
1021
- class ShowUndo extends Schema4.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
1022
- input: Schema4.Struct({
1023
- message: Label
1024
- }),
1025
- output: Schema4.Void
1026
- }) {
1027
- }
1028
- IntentAction2.ShowUndo = ShowUndo;
1029
- })(IntentAction || (IntentAction = {}));
1030
- var IntentAction;
1031
-
1032
- // src/plugin-intent/errors.ts
1033
- function _define_property4(obj, key, value) {
1034
- if (key in obj) {
1035
- Object.defineProperty(obj, key, {
1036
- value,
1037
- enumerable: true,
1038
- configurable: true,
1039
- writable: true
1040
- });
1041
- } else {
1042
- obj[key] = value;
1043
- }
1044
- return obj;
1045
- }
1046
- var BaseError = class extends Error {
1047
- constructor(code, message, context) {
1048
- super(message ?? code, {
1049
- cause: context
1050
- }), _define_property4(this, "code", void 0), _define_property4(this, "context", void 0), this.code = code, this.context = context;
1051
- this.name = code;
1052
- Object.setPrototypeOf(this, new.target.prototype);
1053
- }
1054
- };
1055
- var NoResolversError = class extends BaseError {
1056
- constructor(action) {
1057
- super("NO_RESOLVERS", "No resolvers were found for the action", {
1058
- action
1059
- });
1060
- }
1061
- };
1062
- var CycleDetectedError = class extends BaseError {
1063
- constructor(context) {
1064
- super("CYCLE_DETECTED", "Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.", context);
1065
- }
1066
- };
1067
-
1068
- // src/plugin-intent/IntentPlugin.ts
1069
- var IntentPlugin = () => definePlugin({
1070
- id: INTENT_PLUGIN,
1071
- name: "Intent"
1072
- }, [
1073
- defineModule({
1074
- id: `${INTENT_PLUGIN}/module/dispatcher`,
1075
- // TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
1076
- // This is fine for now because it's how it worked prior to capabilities api anyways.
1077
- // In the future, the intent dispatcher should be able to be reset without resetting the entire app.
1078
- activatesOn: Events.Startup,
1079
- activatesAfter: [
1080
- Events.DispatcherReady
1081
- ],
1082
- activate: lazy(() => import("./intent-dispatcher-QG7UPGQX.mjs"))
1083
- })
1084
- ]);
1085
-
1086
- // src/common/layout.ts
1087
- var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
1088
- var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
1089
- (function(LayoutAction2) {
1090
- LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_ACTION}/update-layout`;
1091
- class UpdateLayout extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1092
- input: Schema5.Struct({
1093
- part: Schema5.String.annotations({
1094
- description: "The part of the layout to mutate."
1095
- }),
1096
- subject: Schema5.optional(Schema5.Any.annotations({
1097
- description: "The subject of the layout update."
1098
- })),
1099
- options: Schema5.optional(Schema5.Record({
1100
- key: Schema5.String,
1101
- value: Schema5.Any
1102
- }).annotations({
1103
- description: "Additional options for the layout action."
1104
- }))
1105
- }),
1106
- output: Schema5.Void
1107
- }) {
1108
- }
1109
- LayoutAction2.UpdateLayout = UpdateLayout;
1110
- class SetLayoutMode extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1111
- input: Schema5.Struct({
1112
- part: Schema5.Literal("mode").annotations({
1113
- description: "Setting the layout mode."
1114
- }),
1115
- subject: Schema5.optional(Schema5.String.annotations({
1116
- description: "Item which is the subject of the new layout mode."
1117
- })),
1118
- options: Schema5.Union(Schema5.Struct({
1119
- mode: Schema5.String.annotations({
1120
- description: "The new layout mode."
1121
- })
1122
- }), Schema5.Struct({
1123
- revert: Schema5.Boolean.annotations({
1124
- description: "Revert to the previous layout mode."
1125
- })
1126
- }))
1127
- }),
1128
- output: Schema5.Void
1129
- }) {
1130
- }
1131
- LayoutAction2.SetLayoutMode = SetLayoutMode;
1132
- class UpdateSidebar extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1133
- input: Schema5.Struct({
1134
- part: Schema5.Literal("sidebar").annotations({
1135
- description: "Updating the sidebar."
1136
- }),
1137
- subject: Schema5.optional(Schema5.String.annotations({
1138
- description: "URI of the component to display in the sidebar."
1139
- })),
1140
- options: Schema5.optional(Schema5.Struct({
1141
- state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
1142
- description: "Whether the sidebar is closed, collapsed, or expanded."
1143
- })
1144
- }))
1145
- }),
1146
- output: Schema5.Void
1147
- }) {
1148
- }
1149
- LayoutAction2.UpdateSidebar = UpdateSidebar;
1150
- class UpdateComplementary extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1151
- input: Schema5.Struct({
1152
- part: Schema5.Literal("complementary").annotations({
1153
- description: "Updating the complementary sidebar."
1154
- }),
1155
- subject: Schema5.optional(Schema5.String.annotations({
1156
- description: "URI of the component to display in the complementary area."
1157
- })),
1158
- options: Schema5.optional(Schema5.Struct({
1159
- state: Schema5.Literal("closed", "collapsed", "expanded").annotations({
1160
- description: "Whether the complementary sidebar is closed, collapsed, or expanded."
1161
- })
1162
- }))
1163
- }),
1164
- output: Schema5.Void
1165
- }) {
1166
- }
1167
- LayoutAction2.UpdateComplementary = UpdateComplementary;
1168
- class UpdateDialog extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1169
- input: Schema5.Struct({
1170
- part: Schema5.Literal("dialog").annotations({
1171
- description: "Updating the dialog."
1172
- }),
1173
- subject: Schema5.optional(Schema5.String.annotations({
1174
- description: "URI of the component to display in the dialog."
1175
- })),
1176
- options: Schema5.Struct({
1177
- state: Schema5.optional(Schema5.Boolean.annotations({
1178
- description: "Whether the dialog is open or closed."
1179
- })),
1180
- type: Schema5.optional(Schema5.Literal("default", "alert").annotations({
1181
- description: "The type of dialog."
1182
- })),
1183
- blockAlign: Schema5.optional(Schema5.Literal("start", "center", "end").annotations({
1184
- description: "The alignment of the dialog."
1185
- })),
1186
- overlayClasses: Schema5.optional(Schema5.String.annotations({
1187
- description: "Additional classes for the dialog overlay."
1188
- })),
1189
- overlayStyle: Schema5.optional(Schema5.Record({
1190
- key: Schema5.String,
1191
- value: Schema5.Any
1192
- }).annotations({
1193
- description: "Additional styles for the dialog overlay."
1194
- })),
1195
- props: Schema5.optional(Schema5.Record({
1196
- key: Schema5.String,
1197
- value: Schema5.Any
1198
- }).annotations({
1199
- description: "Additional props for the dialog."
1200
- }))
1201
- })
1202
- }),
1203
- output: Schema5.Void
1204
- }) {
1205
- }
1206
- LayoutAction2.UpdateDialog = UpdateDialog;
1207
- class UpdatePopover extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1208
- input: Schema5.Struct({
1209
- part: Schema5.Literal("popover").annotations({
1210
- description: "Updating the popover."
1211
- }),
1212
- subject: Schema5.optional(Schema5.Any.annotations({
1213
- description: "URI of the component to display in the popover or data to pass to the popover."
1214
- })),
1215
- options: Schema5.Struct({
1216
- side: Schema5.optional(Schema5.Literal("top", "right", "bottom", "left").annotations({
1217
- description: "The side of the anchor."
1218
- })),
1219
- state: Schema5.optional(Schema5.Boolean.annotations({
1220
- description: "Whether the popover is open or closed."
1221
- })),
1222
- props: Schema5.optional(Schema5.Record({
1223
- key: Schema5.String,
1224
- value: Schema5.Any
1225
- }).annotations({
1226
- description: "Additional props for the popover."
1227
- }))
1228
- }).pipe(Schema5.extend(Schema5.Union(Schema5.Struct({
1229
- variant: Schema5.Literal("virtual"),
1230
- anchor: Schema5.Any.annotations({
1231
- description: "The DOM element to anchor the popover to."
1232
- })
1233
- }), Schema5.Struct({
1234
- variant: Schema5.optional(Schema5.Literal("react")),
1235
- anchorId: Schema5.String.annotations({
1236
- description: "An id that can be used to determine whether to render the anchor subcomponent."
1237
- })
1238
- }))))
1239
- }),
1240
- output: Schema5.Void
1241
- }) {
1242
- }
1243
- LayoutAction2.UpdatePopover = UpdatePopover;
1244
- LayoutAction2.Toast = Schema5.Struct({
1245
- id: Schema5.String.annotations({
1246
- description: "The id of the toast."
1247
- }),
1248
- title: Schema5.optional(Label.annotations({
1249
- description: "The title of the toast."
1250
- })),
1251
- description: Schema5.optional(Label.annotations({
1252
- description: "The description of the toast."
1253
- })),
1254
- icon: Schema5.optional(Schema5.String.annotations({
1255
- description: "The icon of the toast."
1256
- })),
1257
- duration: Schema5.optional(Schema5.Number.annotations({
1258
- description: "The duration of the toast."
1259
- })),
1260
- closeLabel: Schema5.optional(Label.annotations({
1261
- description: "The label of the close button."
1262
- })),
1263
- actionLabel: Schema5.optional(Label.annotations({
1264
- description: "The label of the action button."
1265
- })),
1266
- actionAlt: Schema5.optional(Label.annotations({
1267
- description: "The alt text of the action button."
1268
- })),
1269
- onAction: Schema5.optional(Schema5.Any.annotations({
1270
- description: "The action to perform when the action button is clicked."
1271
- }))
1272
- });
1273
- class AddToast extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1274
- input: Schema5.Struct({
1275
- part: Schema5.Literal("toast").annotations({
1276
- description: "Adding a toast."
1277
- }),
1278
- subject: LayoutAction2.Toast.annotations({
1279
- description: "The toast to add."
1280
- })
1281
- }),
1282
- output: Schema5.Void
1283
- }) {
1284
- }
1285
- LayoutAction2.AddToast = AddToast;
1286
- class SwitchWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1287
- input: Schema5.Struct({
1288
- part: Schema5.Literal("workspace").annotations({
1289
- description: "Switching the workspace."
1290
- }),
1291
- subject: Schema5.String.annotations({
1292
- description: "The id of the workspace to switch to."
1293
- })
1294
- }),
1295
- output: Schema5.Void
1296
- }) {
1297
- }
1298
- LayoutAction2.SwitchWorkspace = SwitchWorkspace;
1299
- class RevertWorkspace extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1300
- input: Schema5.Struct({
1301
- part: Schema5.Literal("workspace").annotations({
1302
- description: "Switching the workspace."
1303
- }),
1304
- options: Schema5.Struct({
1305
- revert: Schema5.Literal(true).annotations({
1306
- description: "Revert to the previous workspace."
1307
- })
1308
- })
1309
- }),
1310
- output: Schema5.Void
1311
- }) {
1312
- }
1313
- LayoutAction2.RevertWorkspace = RevertWorkspace;
1314
- class Open extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1315
- input: Schema5.Struct({
1316
- part: Schema5.Literal("main").annotations({
1317
- description: "Opening an item in the main content area."
1318
- }),
1319
- subject: Schema5.Array(Schema5.String.annotations({
1320
- description: "Ids of the items to open."
1321
- })),
1322
- options: Schema5.optional(Schema5.Struct({
1323
- state: Schema5.optional(Schema5.Literal(true).annotations({
1324
- description: "The items are being added."
1325
- })),
1326
- variant: Schema5.optional(Schema5.String.annotations({
1327
- description: "The variant of the item to open."
1328
- })),
1329
- key: Schema5.optional(Schema5.String.annotations({
1330
- description: "If provided, will replace item with a matching key (id prefix)."
1331
- })),
1332
- workspace: Schema5.optional(Schema5.String.annotations({
1333
- description: "The workspace to open the items in."
1334
- })),
1335
- scrollIntoView: Schema5.optional(Schema5.Boolean.annotations({
1336
- description: "Scroll the items into view."
1337
- })),
1338
- pivotId: Schema5.optional(Schema5.String.annotations({
1339
- description: "The id of the item to place new items next to."
1340
- })),
1341
- positioning: Schema5.optional(Schema5.Union(Schema5.Literal("start").annotations({
1342
- description: "The items are being added before the pivot item."
1343
- }), Schema5.Literal("end").annotations({
1344
- description: "The items are being added after the pivot item."
1345
- })))
1346
- }))
1347
- }),
1348
- output: Schema5.Void
1349
- }) {
1350
- }
1351
- LayoutAction2.Open = Open;
1352
- class Set2 extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1353
- input: Schema5.Struct({
1354
- part: Schema5.Literal("main").annotations({
1355
- description: "Setting items in the main content area."
1356
- }),
1357
- subject: Schema5.Array(Schema5.String.annotations({
1358
- description: "Ids of the items to set."
1359
- })),
1360
- options: Schema5.Struct({
1361
- override: Schema5.Literal(true).annotations({
1362
- description: "Override the current items in the main content area."
1363
- })
1364
- })
1365
- }),
1366
- output: Schema5.Void
1367
- }) {
1368
- }
1369
- LayoutAction2.Set = Set2;
1370
- class Close extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1371
- input: Schema5.Struct({
1372
- part: Schema5.Literal("main").annotations({
1373
- description: "Closing items in the main content area."
1374
- }),
1375
- subject: Schema5.Array(Schema5.String.annotations({
1376
- description: "Ids of the items to close."
1377
- })),
1378
- options: Schema5.Struct({
1379
- state: Schema5.Literal(false).annotations({
1380
- description: "The items are being removed."
1381
- })
1382
- })
1383
- }),
1384
- output: Schema5.Void
1385
- }) {
1386
- }
1387
- LayoutAction2.Close = Close;
1388
- class ScrollIntoView extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1389
- input: Schema5.Struct({
1390
- part: Schema5.Literal("current").annotations({
1391
- description: "Setting the current item"
1392
- }),
1393
- subject: Schema5.optional(Schema5.String.annotations({
1394
- description: "The id of the item to set as current."
1395
- })),
1396
- options: Schema5.optional(Schema5.Record({
1397
- key: Schema5.String,
1398
- value: Schema5.Any
1399
- }).annotations({
1400
- description: "Additional options for the scroll into view."
1401
- }))
1402
- }),
1403
- output: Schema5.Void
1404
- }) {
1405
- }
1406
- LayoutAction2.ScrollIntoView = ScrollIntoView;
1407
- class Expose extends Schema5.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1408
- input: Schema5.Struct({
1409
- part: Schema5.Literal("navigation").annotations({
1410
- description: "Exposing an item in the navigation area."
1411
- }),
1412
- subject: Schema5.String.annotations({
1413
- description: "The id of the item to expose."
1414
- })
1415
- }),
1416
- output: Schema5.Void
1417
- }) {
1418
- }
1419
- LayoutAction2.Expose = Expose;
1420
- })(LayoutAction || (LayoutAction = {}));
1421
- var LayoutAction;
1422
-
1423
- // src/common/surface.ts
1424
- var createSurface = (definition) => definition;
1425
-
1426
- // src/common/translations.ts
1427
- import { Schema as Schema6 } from "effect";
1428
- var ResourceKey = Schema6.Union(Schema6.String, Schema6.Record({
1429
- key: Schema6.String,
1430
- value: Schema6.Any
1431
- }));
1432
- var ResourceLanguage = Schema6.Record({
1433
- key: Schema6.String,
1434
- value: ResourceKey
1435
- });
1436
- var Resource = Schema6.Record({
1437
- key: Schema6.String,
1438
- value: ResourceLanguage
1439
- });
1440
-
1441
- // src/plugin-intent/intent-dispatcher.ts
1442
- var __dxlog_file3 = "/__w/dxos/dxos/packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts";
1443
- var EXECUTION_LIMIT = 100;
1444
- var HISTORY_LIMIT = 100;
1445
- var createResolver = (resolver) => resolver;
1446
- var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
1447
- var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
1448
- const historyRef = Effect3.runSync(Ref2.make([]));
1449
- const handleIntent = (intent) => Effect3.gen(function* () {
1450
- const candidates = getResolvers().filter((resolver) => resolver.intent._tag === intent.id).filter((resolver) => !resolver.filter || resolver.filter(intent.data)).toSorted(byPosition);
1451
- if (candidates.length === 0) {
1452
- log3.info("no resolvers found", {
1453
- intent: intent.id
1454
- }, {
1455
- F: __dxlog_file3,
1456
- L: 200,
1457
- S: this,
1458
- C: (f, a) => f(...a)
1459
- });
1460
- return yield* Effect3.fail(new NoResolversError(intent.id));
1461
- }
1462
- const effect = candidates[0].resolve(intent.data, intent.undo ?? false);
1463
- const result = Effect3.isEffect(effect) ? yield* effect : yield* Effect3.promise(async () => effect);
1464
- return {
1465
- _intent: intent,
1466
- ...result
1467
- };
1468
- });
1469
- const dispatch = (intentChain, depth = 0) => {
1470
- return Effect3.gen(function* () {
1471
- if (depth > executionLimit) {
1472
- return yield* Effect3.fail(new CycleDetectedError());
1473
- }
1474
- const resultsRef = yield* Ref2.make([]);
1475
- for (const intent of intentChain.all) {
1476
- const { data: prev } = (yield* resultsRef.get)[0] ?? {};
1477
- const result2 = yield* handleIntent({
1478
- ...intent,
1479
- data: {
1480
- ...intent.data,
1481
- ...prev
1482
- }
1483
- });
1484
- yield* Ref2.update(resultsRef, (results2) => [
1485
- result2,
1486
- ...results2
1487
- ]);
1488
- if (result2.intents) {
1489
- for (const intent2 of result2.intents) {
1490
- yield* dispatch(intent2, depth + 1);
1491
- }
1492
- }
1493
- if (result2.error) {
1494
- return yield* Effect3.fail(result2.error);
1495
- }
1496
- }
1497
- const results = yield* resultsRef.get;
1498
- const result = results[0];
1499
- yield* Ref2.update(historyRef, (history) => {
1500
- const next = [
1501
- ...history,
1502
- results
1503
- ];
1504
- if (next.length > historyLimit) {
1505
- next.splice(0, next.length - historyLimit);
1506
- }
1507
- return next;
1508
- });
1509
- if (result.undoable && isUndoable(results)) {
1510
- yield* pipe2(dispatch(createIntent(IntentAction.ShowUndo, {
1511
- message: result.undoable.message
1512
- })), Effect3.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect3.succeed(void 0)) : Option.none()));
1513
- }
1514
- return result.data;
1515
- });
1516
- };
1517
- const dispatchPromise = (intentChain) => {
1518
- return Effect3.runPromise(dispatch(intentChain)).then((data) => ({
1519
- data
1520
- })).catch((error) => {
1521
- log3.catch(error, void 0, {
1522
- F: __dxlog_file3,
1523
- L: 272,
1524
- S: void 0,
1525
- C: (f, a) => f(...a)
1526
- });
1527
- return {
1528
- error
1529
- };
1530
- });
1531
- };
1532
- const undo = () => {
1533
- return Effect3.gen(function* () {
1534
- const history = yield* historyRef.get;
1535
- const last = history.findLastIndex(isUndoable);
1536
- const result = last !== -1 ? history[last] : void 0;
1537
- if (result) {
1538
- const all = result.map(({ _intent, undoable }) => {
1539
- const data = _intent.data;
1540
- const undoData = undoable?.data ?? {};
1541
- return {
1542
- ..._intent,
1543
- data: {
1544
- ...data,
1545
- ...undoData
1546
- },
1547
- undo: true
1548
- };
1549
- });
1550
- const intent = {
1551
- first: all[0],
1552
- last: all.at(-1),
1553
- all
1554
- };
1555
- yield* Ref2.update(historyRef, (h) => h.filter((_, index) => index !== last));
1556
- return yield* dispatch(intent);
1557
- }
1558
- });
1559
- };
1560
- const undoPromise = () => {
1561
- return Effect3.runPromise(undo()).then((data) => ({
1562
- data
1563
- })).catch((error) => ({
1564
- error
1565
- }));
1566
- };
1567
- return {
1568
- dispatch,
1569
- dispatchPromise,
1570
- undo,
1571
- undoPromise
1572
- };
1573
- };
1574
- var defaultEffect = () => Effect3.fail(new Error("Intent runtime not ready"));
1575
- var defaultPromise = () => Effect3.runPromise(defaultEffect());
1576
- var intent_dispatcher_default = (context) => {
1577
- const state = live2({
1578
- dispatch: defaultEffect,
1579
- dispatchPromise: defaultPromise,
1580
- undo: defaultEffect,
1581
- undoPromise: defaultPromise
1582
- });
1583
- const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher(() => context.getCapabilities(Capabilities.IntentResolver).flat());
1584
- const manager = context.getCapability(Capabilities.PluginManager);
1585
- state.dispatch = (intentChain, depth) => {
1586
- return Effect3.gen(function* () {
1587
- yield* manager._activate(Events.SetupIntentResolver);
1588
- return yield* dispatch(intentChain, depth);
1589
- });
1590
- };
1591
- state.dispatchPromise = async (intentChain) => {
1592
- await manager.activate(Events.SetupIntentResolver);
1593
- return await dispatchPromise(intentChain);
1594
- };
1595
- state.undo = undo;
1596
- state.undoPromise = undoPromise;
1597
- return contributes(Capabilities.IntentDispatcher, state);
1598
- };
1599
-
1600
- export {
1601
- defineCapability,
1602
- contributes,
1603
- lazy,
1604
- PluginContext,
1605
- defineEvent,
1606
- eventKey,
1607
- oneOf,
1608
- allOf,
1609
- isOneOf,
1610
- isAllOf,
1611
- getEvents,
1612
- PluginManager,
1613
- PluginModule,
1614
- defineModule,
1615
- Plugin,
1616
- definePlugin,
1617
- Capabilities,
1618
- CollaborationActions,
1619
- Events,
1620
- defaultFileTypes,
1621
- FileInfoSchema,
1622
- createIntent,
1623
- chain,
1624
- Label,
1625
- INTENT_PLUGIN,
1626
- INTENT_ACTION,
1627
- IntentAction,
1628
- BaseError,
1629
- NoResolversError,
1630
- CycleDetectedError,
1631
- createResolver,
1632
- createDispatcher,
1633
- intent_dispatcher_default,
1634
- IntentPlugin,
1635
- LAYOUT_PLUGIN,
1636
- LAYOUT_ACTION,
1637
- LayoutAction,
1638
- createSurface,
1639
- ResourceKey,
1640
- ResourceLanguage,
1641
- Resource
1642
- };
1643
- //# sourceMappingURL=chunk-OZY7HV2A.mjs.map