@dxos/app-framework 0.7.4 → 0.7.5-labs.071a3e2

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