@dxos/app-framework 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae

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