@dxos/app-framework 0.8.4-main.ead640a → 0.8.4-main.ef1bc66f44

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