@dxos/app-framework 0.7.4 → 0.7.5-labs.5f04cf6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/dist/lib/browser/chunk-22MGDQXD.mjs +1621 -0
  2. package/dist/lib/browser/chunk-22MGDQXD.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +136 -527
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +67 -0
  7. package/dist/lib/browser/testing/index.mjs.map +7 -0
  8. package/dist/lib/node/chunk-7PNEFY2G.cjs +1665 -0
  9. package/dist/lib/node/chunk-7PNEFY2G.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +141 -551
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +91 -0
  14. package/dist/lib/node/testing/index.cjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-ZFOOPWBG.mjs +1623 -0
  16. package/dist/lib/node-esm/chunk-ZFOOPWBG.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +136 -527
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +68 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/App.d.ts +22 -13
  23. package/dist/types/src/App.d.ts.map +1 -1
  24. package/dist/types/src/common/capabilities.d.ts +343 -0
  25. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  26. package/dist/types/src/common/events.d.ts +41 -0
  27. package/dist/types/src/common/events.d.ts.map +1 -0
  28. package/dist/types/src/common/file.d.ts +14 -0
  29. package/dist/types/src/common/file.d.ts.map +1 -0
  30. package/dist/types/src/common/graph.d.ts +21 -0
  31. package/dist/types/src/common/graph.d.ts.map +1 -0
  32. package/dist/types/src/{plugins/common → common}/index.d.ts +3 -1
  33. package/dist/types/src/common/index.d.ts.map +1 -0
  34. package/dist/types/src/common/layout.d.ts +165 -0
  35. package/dist/types/src/common/layout.d.ts.map +1 -0
  36. package/dist/types/src/{plugins/common → common}/navigation.d.ts +77 -32
  37. package/dist/types/src/common/navigation.d.ts.map +1 -0
  38. package/dist/types/src/common/surface.d.ts +68 -0
  39. package/dist/types/src/common/surface.d.ts.map +1 -0
  40. package/dist/types/src/{plugins/common → common}/translations.d.ts +0 -11
  41. package/dist/types/src/common/translations.d.ts.map +1 -0
  42. package/dist/types/src/core/capabilities.d.ts +90 -0
  43. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  44. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  45. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  46. package/dist/types/src/core/events.d.ts +58 -0
  47. package/dist/types/src/core/events.d.ts.map +1 -0
  48. package/dist/types/src/core/index.d.ts +5 -0
  49. package/dist/types/src/core/index.d.ts.map +1 -0
  50. package/dist/types/src/core/manager.d.ts +126 -0
  51. package/dist/types/src/core/manager.d.ts.map +1 -0
  52. package/dist/types/src/core/manager.test.d.ts +2 -0
  53. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  54. package/dist/types/src/core/plugin.d.ts +94 -0
  55. package/dist/types/src/core/plugin.d.ts.map +1 -0
  56. package/dist/types/src/helpers.d.ts +10 -0
  57. package/dist/types/src/helpers.d.ts.map +1 -0
  58. package/dist/types/src/helpers.test.d.ts +2 -0
  59. package/dist/types/src/helpers.test.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +5 -1
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/playground/debug/Debug.d.ts +6 -0
  63. package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
  64. package/dist/types/src/playground/debug/index.d.ts +2 -0
  65. package/dist/types/src/playground/debug/index.d.ts.map +1 -0
  66. package/dist/types/src/playground/debug/plugin.d.ts +2 -0
  67. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
  68. package/dist/types/src/playground/generator/Main.d.ts +6 -0
  69. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  70. package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
  71. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
  72. package/dist/types/src/playground/generator/generator.d.ts +5 -0
  73. package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
  74. package/dist/types/src/playground/generator/index.d.ts +3 -0
  75. package/dist/types/src/playground/generator/index.d.ts.map +1 -0
  76. package/dist/types/src/playground/generator/plugin.d.ts +2 -0
  77. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
  78. package/dist/types/src/playground/layout/Layout.d.ts +8 -0
  79. package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
  80. package/dist/types/src/playground/layout/index.d.ts +2 -0
  81. package/dist/types/src/playground/layout/index.d.ts.map +1 -0
  82. package/dist/types/src/playground/layout/plugin.d.ts +2 -0
  83. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
  84. package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
  85. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
  86. package/dist/types/src/playground/logger/index.d.ts +2 -0
  87. package/dist/types/src/playground/logger/index.d.ts.map +1 -0
  88. package/dist/types/src/playground/logger/plugin.d.ts +2 -0
  89. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
  90. package/dist/types/src/playground/logger/schema.d.ts +13 -0
  91. package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
  92. package/dist/types/src/playground/playground.stories.d.ts +10 -0
  93. package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
  94. package/dist/types/src/plugin-intent/IntentContext.d.ts +8 -0
  95. package/dist/types/src/plugin-intent/IntentContext.d.ts.map +1 -0
  96. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
  97. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
  98. package/dist/types/src/plugin-intent/actions.d.ts +23 -0
  99. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
  100. package/dist/types/src/plugin-intent/errors.d.ts +16 -0
  101. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
  102. package/dist/types/src/plugin-intent/index.d.ts +6 -0
  103. package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
  104. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +106 -0
  105. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
  106. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
  107. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
  108. package/dist/types/src/plugin-intent/intent.d.ts +68 -0
  109. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  110. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  111. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  112. package/dist/types/src/plugin-settings/actions.d.ts +17 -0
  113. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  114. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  115. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  116. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  117. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  118. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  119. package/dist/types/src/react/Surface.d.ts +12 -0
  120. package/dist/types/src/react/Surface.d.ts.map +1 -0
  121. package/dist/types/src/react/index.d.ts +5 -0
  122. package/dist/types/src/react/index.d.ts.map +1 -0
  123. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  124. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  125. package/dist/types/src/testing/index.d.ts +2 -0
  126. package/dist/types/src/testing/index.d.ts.map +1 -0
  127. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  128. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  129. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  130. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  131. package/dist/types/tsconfig.tsbuildinfo +1 -0
  132. package/package.json +31 -14
  133. package/project.json +2 -1
  134. package/src/App.tsx +138 -34
  135. package/src/common/capabilities.ts +88 -0
  136. package/src/common/events.ts +63 -0
  137. package/src/common/file.ts +22 -0
  138. package/src/common/graph.ts +30 -0
  139. package/src/{plugins/common → common}/index.ts +3 -1
  140. package/src/common/layout.ts +157 -0
  141. package/src/{plugins/common → common}/navigation.ts +69 -50
  142. package/src/common/surface.ts +81 -0
  143. package/src/common/translations.ts +18 -0
  144. package/src/core/capabilities.test.ts +116 -0
  145. package/src/core/capabilities.ts +213 -0
  146. package/src/core/events.ts +58 -0
  147. package/src/core/index.ts +8 -0
  148. package/src/core/manager.test.ts +567 -0
  149. package/src/core/manager.ts +497 -0
  150. package/src/core/plugin.ts +128 -0
  151. package/src/helpers.test.ts +97 -0
  152. package/src/helpers.ts +45 -0
  153. package/src/index.ts +6 -3
  154. package/src/playground/debug/Debug.tsx +39 -0
  155. package/src/playground/debug/index.ts +5 -0
  156. package/src/playground/debug/plugin.ts +17 -0
  157. package/src/playground/generator/Main.tsx +71 -0
  158. package/src/playground/generator/Toolbar.tsx +46 -0
  159. package/src/playground/generator/generator.ts +23 -0
  160. package/src/playground/generator/index.ts +6 -0
  161. package/src/playground/generator/plugin.ts +18 -0
  162. package/src/playground/layout/Layout.tsx +33 -0
  163. package/src/playground/layout/index.ts +5 -0
  164. package/src/playground/layout/plugin.ts +17 -0
  165. package/src/playground/logger/Toolbar.tsx +28 -0
  166. package/src/playground/logger/index.ts +5 -0
  167. package/src/playground/logger/plugin.ts +33 -0
  168. package/src/playground/logger/schema.ts +12 -0
  169. package/src/playground/playground.stories.tsx +34 -0
  170. package/src/plugin-intent/IntentContext.tsx +34 -0
  171. package/src/plugin-intent/IntentPlugin.tsx +60 -0
  172. package/src/plugin-intent/actions.ts +22 -0
  173. package/src/plugin-intent/errors.ts +39 -0
  174. package/src/plugin-intent/index.ts +9 -0
  175. package/src/plugin-intent/intent-dispatcher.test.ts +280 -0
  176. package/src/plugin-intent/intent-dispatcher.ts +269 -0
  177. package/src/plugin-intent/intent.ts +146 -0
  178. package/src/plugin-settings/SettingsPlugin.ts +29 -0
  179. package/src/plugin-settings/actions.ts +17 -0
  180. package/src/plugin-settings/index.ts +6 -0
  181. package/src/react/PluginManagerProvider.ts +22 -0
  182. package/src/react/Surface.tsx +72 -0
  183. package/src/react/index.ts +8 -0
  184. package/src/react/useCapabilities.ts +40 -0
  185. package/src/testing/index.ts +5 -0
  186. package/src/testing/withPluginManager.stories.tsx +47 -0
  187. package/src/testing/withPluginManager.tsx +67 -0
  188. package/tsconfig.json +54 -2
  189. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  190. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
  192. package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
  193. package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
  194. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
  195. package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
  196. package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
  197. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
  198. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs.map +0 -7
  199. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
  200. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +0 -7
  201. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
  202. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs.map +0 -7
  203. package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
  204. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
  205. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  206. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  207. package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
  208. package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
  209. package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
  210. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
  211. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
  212. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
  213. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +0 -32
  214. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
  215. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
  216. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
  217. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
  218. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
  219. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  220. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  221. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
  222. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
  224. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
  225. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
  226. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs.map +0 -7
  227. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
  228. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
  229. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
  230. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
  231. package/dist/types/src/plugins/common/file.d.ts +0 -22
  232. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  233. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  234. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  235. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  236. package/dist/types/src/plugins/common/layout.d.ts +0 -202
  237. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  238. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  239. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  240. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  241. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  242. package/dist/types/src/plugins/helpers.d.ts +0 -41
  243. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  244. package/dist/types/src/plugins/index.d.ts +0 -7
  245. package/dist/types/src/plugins/index.d.ts.map +0 -1
  246. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
  247. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  248. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  249. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  250. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  251. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  252. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
  253. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  254. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
  255. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  256. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  257. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  258. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
  259. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  260. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  261. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  262. package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
  263. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
  264. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
  265. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  266. package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
  267. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  268. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
  269. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  270. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
  271. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  272. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  273. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  274. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  275. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  276. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  277. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  278. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
  279. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  280. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  281. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
  282. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  283. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  284. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  285. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
  286. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
  287. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  288. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  289. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  290. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  291. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  292. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  293. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
  294. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  295. package/src/plugins/common/file.ts +0 -36
  296. package/src/plugins/common/graph.ts +0 -70
  297. package/src/plugins/common/layout.ts +0 -155
  298. package/src/plugins/common/metadata.ts +0 -29
  299. package/src/plugins/common/translations.ts +0 -36
  300. package/src/plugins/helpers.ts +0 -92
  301. package/src/plugins/index.ts +0 -11
  302. package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
  303. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  304. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  305. package/src/plugins/plugin-host/index.ts +0 -8
  306. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  307. package/src/plugins/plugin-host/plugin.ts +0 -126
  308. package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
  309. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
  310. package/src/plugins/plugin-intent/helpers.ts +0 -11
  311. package/src/plugins/plugin-intent/index.ts +0 -12
  312. package/src/plugins/plugin-intent/intent.ts +0 -101
  313. package/src/plugins/plugin-intent/meta.ts +0 -9
  314. package/src/plugins/plugin-intent/provides.ts +0 -38
  315. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  316. package/src/plugins/plugin-settings/index.ts +0 -9
  317. package/src/plugins/plugin-settings/meta.ts +0 -9
  318. package/src/plugins/plugin-settings/provides.ts +0 -29
  319. package/src/plugins/plugin-surface/Surface.tsx +0 -195
  320. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
  321. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
  322. package/src/plugins/plugin-surface/helpers.ts +0 -22
  323. package/src/plugins/plugin-surface/index.ts +0 -14
  324. package/src/plugins/plugin-surface/meta.ts +0 -9
  325. package/src/plugins/plugin-surface/provides.ts +0 -26
  326. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  327. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { S } from '@dxos/echo-schema';
6
+
7
+ import { Label } from './intent';
8
+
9
+ export const INTENT_PLUGIN = 'dxos.org/plugin/intent';
10
+ export const INTENT_ACTION = `${INTENT_PLUGIN}/action`;
11
+
12
+ export namespace IntentAction {
13
+ /**
14
+ * Fired after an intent is dispatched if the intent is undoable.
15
+ */
16
+ export class ShowUndo extends S.TaggedClass<ShowUndo>()(`${INTENT_ACTION}/show-undo`, {
17
+ input: S.Struct({
18
+ message: Label,
19
+ }),
20
+ output: S.Void,
21
+ }) {}
22
+ }
@@ -0,0 +1,39 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ // TODO(wittjosiah): Reconcile with @dxos/protocols. Factor out errors.
6
+
7
+ /**
8
+ * NOTE: Messages should be sentences (Start with a capital letter and end with a period).
9
+ * Errors can optionally include a JSON context object.
10
+ */
11
+ export class BaseError extends Error {
12
+ constructor(
13
+ readonly code: string,
14
+ message?: string,
15
+ readonly context?: Record<string, any>,
16
+ ) {
17
+ // TODO(dmaretskyi): Error.cause.
18
+ super(message ?? code);
19
+ this.name = code;
20
+ // NOTE: Restores prototype chain (https://stackoverflow.com/a/48342359).
21
+ Object.setPrototypeOf(this, new.target.prototype);
22
+ }
23
+ }
24
+
25
+ export class NoResolversError extends BaseError {
26
+ constructor(action: string) {
27
+ super('NO_RESOLVERS', 'No resolvers were found for the action', { action });
28
+ }
29
+ }
30
+
31
+ export class CycleDetectedError extends BaseError {
32
+ constructor(context?: Record<string, any>) {
33
+ super(
34
+ 'CYCLE_DETECTED',
35
+ 'Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.',
36
+ context,
37
+ );
38
+ }
39
+ }
@@ -0,0 +1,9 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './actions';
6
+ export * from './intent';
7
+ export * from './intent-dispatcher';
8
+ export * from './IntentContext';
9
+ export * from './IntentPlugin';
@@ -0,0 +1,280 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Effect, Fiber, pipe } from 'effect';
6
+ import { describe, expect, test } from 'vitest';
7
+
8
+ import { S } from '@dxos/echo-schema';
9
+
10
+ import { chain, createIntent } from './intent';
11
+ import { type AnyIntentResolver, createDispatcher, createResolver } from './intent-dispatcher';
12
+
13
+ describe('Intent dispatcher', () => {
14
+ test('throws error if no resolver found', async () => {
15
+ const { dispatchPromise } = createDispatcher(() => []);
16
+ const { data, error } = await dispatchPromise(createIntent(ToString, { value: 1 }));
17
+
18
+ expect(data).toBe(undefined);
19
+ expect(error).toBeInstanceOf(Error);
20
+ });
21
+
22
+ test('matches intent to resolver and executes', async () => {
23
+ const { dispatchPromise } = createDispatcher(() => [toStringResolver]);
24
+ const { data, error } = await dispatchPromise(createIntent(ToString, { value: 1 }));
25
+
26
+ expect(error).toBe(undefined);
27
+ expect(data?.string).toBe('1');
28
+ });
29
+
30
+ test('update resolvers', async () => {
31
+ const resolvers: AnyIntentResolver[] = [];
32
+ const { dispatchPromise } = createDispatcher(() => resolvers);
33
+ const { error } = await dispatchPromise(createIntent(ToString, { value: 1 }));
34
+
35
+ expect(error).toBeInstanceOf(Error);
36
+
37
+ resolvers.push(toStringResolver);
38
+
39
+ const { data } = await dispatchPromise(createIntent(ToString, { value: 1 }));
40
+
41
+ expect(data?.string).toBe('1');
42
+
43
+ resolvers.splice(resolvers.indexOf(toStringResolver), 1);
44
+
45
+ {
46
+ const { data, error } = await dispatchPromise(createIntent(ToString, { value: 1 }));
47
+
48
+ expect(data).toBe(undefined);
49
+ expect(error).toBeInstanceOf(Error);
50
+ }
51
+ });
52
+
53
+ test('compose intent effects', async () => {
54
+ const { dispatch } = createDispatcher(() => [computeResolver]);
55
+ const program = Effect.gen(function* () {
56
+ const a = yield* dispatch(createIntent(Compute, { value: 1 }));
57
+ const b = yield* dispatch(createIntent(Compute, { value: 2 }));
58
+ return b.value - a.value;
59
+ });
60
+
61
+ expect(await Effect.runPromise(program)).toBe(2);
62
+ });
63
+
64
+ test('concurrent intent effects', async () => {
65
+ const { dispatch } = createDispatcher(() => [computeResolver]);
66
+ const program = Effect.gen(function* () {
67
+ const fiberA = yield* Effect.fork(dispatch(createIntent(Compute, { value: 5 })));
68
+ const fiberB = yield* Effect.fork(dispatch(createIntent(Compute, { value: 2 })));
69
+ const [a, b] = yield* Fiber.join(Fiber.zip(fiberA, fiberB));
70
+ return b.value - a.value;
71
+ });
72
+
73
+ expect(await Effect.runPromise(program)).toBe(-6);
74
+ });
75
+
76
+ test('mix & match intent effects with promises', async () => {
77
+ const { dispatch, dispatchPromise } = createDispatcher(() => [toStringResolver, computeResolver]);
78
+ const program = Effect.gen(function* () {
79
+ const a = yield* dispatch(createIntent(Compute, { value: 2 }));
80
+ const b = yield* dispatch(createIntent(ToString, { value: a.value }));
81
+ return b.string;
82
+ });
83
+
84
+ expect(await Effect.runPromise(program)).toBe('4');
85
+
86
+ const a = await dispatchPromise(createIntent(Compute, { value: 2 }));
87
+ const b = await dispatchPromise(createIntent(ToString, { value: a.data!.value }));
88
+
89
+ expect(b.data?.string).toBe('4');
90
+ });
91
+
92
+ test('undo intent', async () => {
93
+ const { dispatch, undo } = createDispatcher(() => [computeResolver]);
94
+ const program = Effect.gen(function* () {
95
+ const a = yield* dispatch(createIntent(Compute, { value: 2 }));
96
+
97
+ expect(a.value).toBe(4);
98
+
99
+ const b = yield* undo();
100
+
101
+ expect(b.value).toBe(2);
102
+ });
103
+
104
+ await Effect.runPromise(program);
105
+ });
106
+
107
+ test('chain intents', async () => {
108
+ const { dispatch } = createDispatcher(() => [computeResolver, toStringResolver, concatResolver]);
109
+ const intent = pipe(createIntent(Compute, { value: 1 }), chain(ToString, {}), chain(Concat, { plus: '!' }));
110
+
111
+ expect(intent.first.action).toBe(Compute._tag);
112
+ expect(intent.last.action).toBe(Concat._tag);
113
+ expect(intent.all.length).toBe(3);
114
+
115
+ const program = Effect.gen(function* () {
116
+ const data = yield* dispatch(intent);
117
+ return data.string;
118
+ });
119
+
120
+ expect(await Effect.runPromise(program)).toBe('2!');
121
+ });
122
+
123
+ test('undo chained intent', async () => {
124
+ const { dispatch, undo } = createDispatcher(() => [computeResolver, toStringResolver, concatResolver]);
125
+ const intent = pipe(createIntent(Compute, { value: 1 }), chain(Compute, {}), chain(Compute, {}));
126
+ const program = Effect.gen(function* () {
127
+ const a = yield* dispatch(intent);
128
+
129
+ expect(a.value).toBe(8);
130
+
131
+ const b = yield* undo();
132
+
133
+ expect(b.value).toBe(1);
134
+ });
135
+
136
+ await Effect.runPromise(program);
137
+ });
138
+
139
+ test('filter resolvers by plugin', async () => {
140
+ const otherComputeResolver = createResolver(Compute, async (data) => ({ data: { value: data?.value * 3 } }));
141
+ const { dispatch } = createDispatcher((module) => (module === 'test' ? [computeResolver] : [otherComputeResolver]));
142
+ const program = Effect.gen(function* () {
143
+ const a = yield* dispatch(createIntent(Compute, { value: 1 }));
144
+
145
+ expect(a.value).toBe(3);
146
+
147
+ const b = yield* dispatch(createIntent(Compute, { value: 1 }, { module: 'test' }));
148
+
149
+ expect(b.value).toBe(2);
150
+ });
151
+
152
+ await Effect.runPromise(program);
153
+ });
154
+
155
+ test('filter resolvers by predicate', async () => {
156
+ const conditionalComputeResolver = createResolver(Compute, async (data) => ({ data: { value: data?.value * 3 } }), {
157
+ filter: (data): data is { value: number } => data?.value > 1,
158
+ });
159
+ const { dispatch } = createDispatcher(() => [conditionalComputeResolver, computeResolver]);
160
+ const program = Effect.gen(function* () {
161
+ const a = yield* dispatch(createIntent(Compute, { value: 1 }));
162
+
163
+ expect(a.value).toBe(2);
164
+
165
+ const b = yield* dispatch(createIntent(Compute, { value: 2 }));
166
+
167
+ expect(b.value).toBe(6);
168
+ });
169
+
170
+ await Effect.runPromise(program);
171
+ });
172
+
173
+ test('hoist resolvers', async () => {
174
+ const hoistedComputeResolver = createResolver(Compute, async (data) => ({ data: { value: data?.value * 3 } }), {
175
+ disposition: 'hoist',
176
+ });
177
+ const { dispatchPromise } = createDispatcher(() => [computeResolver, hoistedComputeResolver]);
178
+ const { data } = await dispatchPromise(createIntent(Compute, { value: 1 }));
179
+ expect(data?.value).toBe(3);
180
+ });
181
+
182
+ test('fallback resolvers', async () => {
183
+ const conditionalComputeResolver = createResolver(Compute, async (data) => ({ data: { value: data?.value * 2 } }), {
184
+ filter: (data): data is { value: number } => data?.value === 1,
185
+ });
186
+ const fallbackComputeResolver = createResolver(Compute, async (data) => ({ data: { value: data?.value * 3 } }), {
187
+ disposition: 'fallback',
188
+ });
189
+ const { dispatch } = createDispatcher(() => [fallbackComputeResolver, conditionalComputeResolver]);
190
+ const program = Effect.gen(function* () {
191
+ const a = yield* dispatch(createIntent(Compute, { value: 1 }));
192
+
193
+ expect(a.value).toBe(2);
194
+
195
+ const b = yield* dispatch(createIntent(Compute, { value: 2 }));
196
+
197
+ expect(b.value).toBe(6);
198
+ });
199
+
200
+ await Effect.runPromise(program);
201
+ });
202
+
203
+ test('non-struct inputs & outputs', async () => {
204
+ const { dispatchPromise } = createDispatcher(() => [addResolver]);
205
+ const { data } = await dispatchPromise(createIntent(Add, [1, 1]));
206
+ expect(data).toBe(2);
207
+ });
208
+
209
+ test('empty inputs & outputs', async () => {
210
+ const { dispatchPromise } = createDispatcher(() => [sideEffectResolver]);
211
+ const { data } = await dispatchPromise(createIntent(SideEffect));
212
+ expect(data).toBe(undefined);
213
+ });
214
+
215
+ test.todo('follow up intents');
216
+ });
217
+
218
+ class ToString extends S.TaggedClass<ToString>()('ToString', {
219
+ input: S.Struct({
220
+ value: S.Number,
221
+ }),
222
+ output: S.Struct({
223
+ string: S.String,
224
+ }),
225
+ }) {}
226
+
227
+ const toStringResolver = createResolver(ToString, async (data) => {
228
+ return { data: { string: data.value.toString() } };
229
+ });
230
+
231
+ class Compute extends S.TaggedClass<Compute>()('Compute', {
232
+ input: S.Struct({
233
+ value: S.Number,
234
+ }),
235
+ output: S.Struct({
236
+ value: S.Number,
237
+ }),
238
+ }) {}
239
+
240
+ const computeResolver = createResolver(Compute, (data, undo) => {
241
+ return Effect.gen(function* () {
242
+ if (undo) {
243
+ return { data: { value: data.value / 2 } };
244
+ }
245
+
246
+ yield* Effect.sleep(data.value * 10);
247
+ const value = data.value * 2;
248
+ return { data: { value }, undoable: { message: 'test', data: { value } } };
249
+ });
250
+ });
251
+
252
+ class Concat extends S.TaggedClass<Concat>()('Concat', {
253
+ input: S.Struct({
254
+ string: S.String,
255
+ plus: S.String,
256
+ }),
257
+ output: S.Struct({
258
+ string: S.String,
259
+ }),
260
+ }) {}
261
+
262
+ const concatResolver = createResolver(Concat, async (data) => {
263
+ return { data: { string: data.string + data.plus } };
264
+ });
265
+
266
+ class Add extends S.TaggedClass<Add>()('Add', {
267
+ input: S.Tuple(S.Number, S.Number),
268
+ output: S.Number,
269
+ }) {}
270
+
271
+ const addResolver = createResolver(Add, async (data) => {
272
+ return { data: data[0] + data[1] };
273
+ });
274
+
275
+ class SideEffect extends S.TaggedClass<SideEffect>()('SideEffect', {
276
+ input: S.Void,
277
+ output: S.Void,
278
+ }) {}
279
+
280
+ const sideEffectResolver = createResolver(SideEffect, async () => {});
@@ -0,0 +1,269 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Effect, Option, pipe, Ref } from 'effect';
6
+ import { type Simplify } from 'effect/Types';
7
+
8
+ import { type MaybePromise, byDisposition, type Disposition } from '@dxos/util';
9
+
10
+ import { IntentAction } from './actions';
11
+ import { CycleDetectedError, NoResolversError } from './errors';
12
+ import {
13
+ createIntent,
14
+ type AnyIntent,
15
+ type AnyIntentChain,
16
+ type Intent,
17
+ type IntentChain,
18
+ type IntentData,
19
+ type IntentParams,
20
+ type IntentResultData,
21
+ type IntentSchema,
22
+ type Label,
23
+ } from './intent';
24
+
25
+ const EXECUTION_LIMIT = 100;
26
+ const HISTORY_LIMIT = 100;
27
+
28
+ /**
29
+ * The return value of an intent effect.
30
+ */
31
+ export type IntentEffectResult<Fields extends IntentParams> = {
32
+ /**
33
+ * The output of the action that was performed.
34
+ *
35
+ * If the intent is apart of a chain of intents, the data will be passed to the next intent.
36
+ */
37
+ data?: IntentResultData<Fields>;
38
+
39
+ /**
40
+ * If provided, the action will be undoable.
41
+ */
42
+ undoable?: {
43
+ /**
44
+ * Message to display to the user when indicating that the action can be undone.
45
+ */
46
+ message: Label;
47
+
48
+ /**
49
+ * Will be merged with the original intent data when firing the undo intent.
50
+ */
51
+ data?: Partial<IntentData<Fields>>;
52
+ };
53
+
54
+ /**
55
+ * An error that occurred while performing the action.
56
+ *
57
+ * If the intent is apart of a chain of intents and an error occurs, the chain will be aborted.
58
+ *
59
+ * Return caught error instead of throwing to trigger other intent to be triggered prior to returning the error.
60
+ */
61
+ error?: Error;
62
+
63
+ /**
64
+ * Other intent chains to be triggered.
65
+ */
66
+ intents?: AnyIntentChain[];
67
+ };
68
+
69
+ export type AnyIntentEffectResult = IntentEffectResult<any>;
70
+
71
+ /**
72
+ * The result of an intent dispatcher.
73
+ */
74
+ export type IntentDispatcherResult<Fields extends IntentParams> = Pick<IntentEffectResult<Fields>, 'data' | 'error'>;
75
+
76
+ /**
77
+ * The implementation of an intent effect.
78
+ */
79
+ export type IntentEffectDefinition<Fields extends IntentParams> = (
80
+ data: IntentData<Fields>,
81
+ undo: boolean,
82
+ ) => MaybePromise<IntentEffectResult<Fields> | void> | Effect.Effect<IntentEffectResult<Fields> | void>;
83
+
84
+ /**
85
+ * Intent resolver to match intents to their effects.
86
+ */
87
+ export type IntentResolver<Tag extends string, Fields extends IntentParams> = Readonly<{
88
+ action: Tag;
89
+ disposition?: Disposition;
90
+ // TODO(wittjosiah): Would be nice to make this a guard for intents with optional data.
91
+ filter?: (data: IntentData<Fields>) => boolean;
92
+ effect: IntentEffectDefinition<Fields>;
93
+ }>;
94
+
95
+ export type AnyIntentResolver = IntentResolver<any, any>;
96
+
97
+ /**
98
+ * Creates an intent resolver to match intents to their effects.
99
+ * @param schema Schema of the intent. Must be a tagged class with input and output schemas.
100
+ * @param effect Effect to be performed when the intent is resolved.
101
+ * @param params.disposition Determines the priority of the resolver when multiple are resolved.
102
+ * @param params.filter Optional filter to determine if the resolver should be used.
103
+ */
104
+ export const createResolver = <Tag extends string, Fields extends IntentParams>(
105
+ schema: IntentSchema<Tag, Fields>,
106
+ effect: IntentEffectDefinition<Fields>,
107
+ params: Pick<IntentResolver<Tag, Fields>, 'disposition' | 'filter'> = {},
108
+ ): IntentResolver<Tag, Fields> => ({
109
+ action: schema._tag,
110
+ effect,
111
+ ...params,
112
+ });
113
+
114
+ /**
115
+ * Invokes intents and returns the result.
116
+ */
117
+ export type PromiseIntentDispatcher = <Fields extends IntentParams>(
118
+ intent: IntentChain<any, any, any, Fields>,
119
+ ) => Promise<Simplify<IntentDispatcherResult<Fields>>>;
120
+
121
+ /**
122
+ * Creates an effect for intents.
123
+ */
124
+ export type IntentDispatcher = <Fields extends IntentParams>(
125
+ intent: IntentChain<any, any, any, Fields>,
126
+ depth?: number,
127
+ ) => Effect.Effect<Simplify<Required<IntentDispatcherResult<Fields>>['data']>, Error>;
128
+
129
+ type IntentResult<Tag extends string, Fields extends IntentParams> = IntentEffectResult<Fields> & {
130
+ _intent: Intent<Tag, Fields>;
131
+ };
132
+
133
+ export type AnyIntentResult = IntentResult<any, any>;
134
+
135
+ /**
136
+ * Invokes the most recent undoable intent with undo flags.
137
+ */
138
+ export type PromiseIntentUndo = () => Promise<IntentDispatcherResult<any>>;
139
+
140
+ /**
141
+ * Creates an effect which undoes the last intent.
142
+ */
143
+ export type IntentUndo = () => Effect.Effect<any, Error>;
144
+
145
+ /**
146
+ * Check if a chain of results is undoable.
147
+ */
148
+ const isUndoable = (historyEntry: AnyIntentResult[]): boolean =>
149
+ historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
150
+
151
+ export type IntentContext = {
152
+ dispatch: IntentDispatcher;
153
+ dispatchPromise: PromiseIntentDispatcher;
154
+ undo: IntentUndo;
155
+ undoPromise: PromiseIntentUndo;
156
+ };
157
+
158
+ /**
159
+ * Sets of an intent dispatcher.
160
+ *
161
+ * @param resolvers An array of available intent resolvers.
162
+ * @param params.historyLimit The maximum number of intent results to keep in history.
163
+ * @param params.executionLimit The maximum recursion depth of intent chains.
164
+ */
165
+ export const createDispatcher = (
166
+ getResolvers: (module?: string) => AnyIntentResolver[],
167
+ { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {},
168
+ ): IntentContext => {
169
+ const historyRef = Effect.runSync(Ref.make<AnyIntentResult[][]>([]));
170
+
171
+ const handleIntent = (intent: AnyIntent) => {
172
+ return Effect.gen(function* () {
173
+ const candidates = getResolvers(intent.module)
174
+ .filter((r) => r.action === intent.action)
175
+ .filter((r) => !r.filter || r.filter(intent.data))
176
+ .toSorted(byDisposition);
177
+ if (candidates.length === 0) {
178
+ return {
179
+ _intent: intent,
180
+ error: new NoResolversError(intent.action),
181
+ } as AnyIntentResult;
182
+ }
183
+
184
+ const effect = candidates[0].effect(intent.data, intent.undo ?? false);
185
+ const result = Effect.isEffect(effect) ? yield* effect : yield* Effect.promise(async () => effect);
186
+ return { _intent: intent, ...result } as AnyIntentResult;
187
+ });
188
+ };
189
+
190
+ const dispatch: IntentDispatcher = (intentChain, depth = 0) => {
191
+ return Effect.gen(function* () {
192
+ if (depth > executionLimit) {
193
+ yield* Effect.fail(new CycleDetectedError());
194
+ }
195
+
196
+ const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);
197
+ for (const intent of intentChain.all) {
198
+ const { data: prev } = (yield* resultsRef.get)[0] ?? {};
199
+ const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });
200
+ yield* Ref.update(resultsRef, (results) => [result, ...results]);
201
+ if (result.intents) {
202
+ for (const intent of result.intents) {
203
+ // Returned intents are dispatched but not yielded into results,
204
+ // as such they cannot be undone.
205
+ // TODO(wittjosiah): Use higher execution concurrency?
206
+ yield* dispatch(intent, depth + 1);
207
+ }
208
+ }
209
+ if (result.error) {
210
+ yield* Effect.fail(result.error);
211
+ }
212
+ }
213
+
214
+ const results = yield* resultsRef.get;
215
+ const result = results[0];
216
+ yield* Ref.update(historyRef, (history) => {
217
+ const next = [...history, results];
218
+ if (next.length > historyLimit) {
219
+ next.splice(0, next.length - historyLimit);
220
+ }
221
+ return next;
222
+ });
223
+
224
+ if (result.undoable && isUndoable(results)) {
225
+ // TODO(wittjosiah): Is there a better way to handle showing undo for chains?
226
+ yield* pipe(
227
+ dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message })),
228
+ Effect.catchSome((err) =>
229
+ err instanceof NoResolversError ? Option.some(Effect.succeed(undefined)) : Option.none(),
230
+ ),
231
+ );
232
+ }
233
+
234
+ return result.data;
235
+ });
236
+ };
237
+
238
+ const dispatchPromise: PromiseIntentDispatcher = (intentChain) => {
239
+ return Effect.runPromise(dispatch(intentChain))
240
+ .then((data) => ({ data }))
241
+ .catch((error) => ({ error }));
242
+ };
243
+
244
+ const undo: IntentUndo = () => {
245
+ return Effect.gen(function* () {
246
+ const history = yield* historyRef.get;
247
+ const last = history.findLastIndex(isUndoable);
248
+ const result = last !== -1 ? history[last] : undefined;
249
+ if (result) {
250
+ const all = result.map(({ _intent, undoable }): AnyIntent => {
251
+ const data = _intent.data;
252
+ const undoData = undoable?.data ?? {};
253
+ return { ..._intent, data: { ...data, ...undoData }, undo: true } satisfies AnyIntent;
254
+ });
255
+ const intent = { first: all[0], last: all.at(-1)!, all } satisfies AnyIntentChain;
256
+ yield* Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));
257
+ return yield* dispatch(intent);
258
+ }
259
+ });
260
+ };
261
+
262
+ const undoPromise: PromiseIntentUndo = () => {
263
+ return Effect.runPromise(undo())
264
+ .then((data) => ({ data }))
265
+ .catch((error) => ({ error }));
266
+ };
267
+
268
+ return { dispatch, dispatchPromise, undo, undoPromise };
269
+ };