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