@dxos/app-framework 0.8.4-main.1da679c → 0.8.4-main.21d9917

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