@dxos/app-framework 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8

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