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