@dxos/app-framework 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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