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