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

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