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

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 (382) hide show
  1. package/dist/lib/browser/app-graph-builder-F7VZ6LRN.mjs +137 -0
  2. package/dist/lib/browser/app-graph-builder-F7VZ6LRN.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-ATRNTMSS.mjs +1399 -0
  4. package/dist/lib/browser/chunk-ATRNTMSS.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-WS6SU6HI.mjs +285 -0
  8. package/dist/lib/browser/chunk-WS6SU6HI.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +119 -642
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/intent-dispatcher-E6J7E5Y5.mjs +11 -0
  12. package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs +38 -0
  13. package/dist/lib/browser/intent-resolver-XLE4L3LS.mjs.map +7 -0
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/store-QU2IKFAI.mjs +19 -0
  16. package/dist/lib/browser/store-QU2IKFAI.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-JGBADFF7.cjs +146 -0
  21. package/dist/lib/node/app-graph-builder-JGBADFF7.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-QLVQ6PND.cjs} +23 -35
  23. package/dist/lib/node/chunk-QLVQ6PND.cjs.map +7 -0
  24. package/dist/lib/node/chunk-WKC6YMEQ.cjs +1433 -0
  25. package/dist/lib/node/chunk-WKC6YMEQ.cjs.map +7 -0
  26. package/dist/lib/node/chunk-WRWRZKZU.cjs +308 -0
  27. package/dist/lib/node/chunk-WRWRZKZU.cjs.map +7 -0
  28. package/dist/lib/node/index.cjs +125 -665
  29. package/dist/lib/node/index.cjs.map +4 -4
  30. package/dist/lib/node/{plugin-settings-W6UHMH5M.cjs → intent-dispatcher-CFBKDZQR.cjs} +10 -14
  31. package/dist/lib/node/intent-dispatcher-CFBKDZQR.cjs.map +7 -0
  32. package/dist/lib/node/intent-resolver-3TKCXP4S.cjs +45 -0
  33. package/dist/lib/node/intent-resolver-3TKCXP4S.cjs.map +7 -0
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/store-4QMUUU2A.cjs +34 -0
  36. package/dist/lib/node/store-4QMUUU2A.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-2QEX57NX.mjs +138 -0
  42. package/dist/lib/node-esm/app-graph-builder-2QEX57NX.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-44J2VZBB.mjs +1401 -0
  44. package/dist/lib/node-esm/chunk-44J2VZBB.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-HTLXL32I.mjs +286 -0
  48. package/dist/lib/node-esm/chunk-HTLXL32I.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +119 -642
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/intent-dispatcher-LDQGDZ62.mjs +12 -0
  52. package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs +39 -0
  53. package/dist/lib/node-esm/intent-resolver-7VJWN67U.mjs.map +7 -0
  54. package/dist/lib/node-esm/meta.json +1 -1
  55. package/dist/lib/node-esm/store-VWDAYUQY.mjs +20 -0
  56. package/dist/lib/node-esm/store-VWDAYUQY.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 +293 -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/{plugins/plugin-surface/SurfaceContext.d.ts → common/surface.d.ts} +12 -29
  75. package/dist/types/src/common/surface.d.ts.map +1 -0
  76. package/dist/types/src/common/translations.d.ts +11 -0
  77. package/dist/types/src/common/translations.d.ts.map +1 -0
  78. package/dist/types/src/core/capabilities.d.ts +94 -0
  79. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  80. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  81. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  82. package/dist/types/src/core/events.d.ts +58 -0
  83. package/dist/types/src/core/events.d.ts.map +1 -0
  84. package/dist/types/src/core/index.d.ts +5 -0
  85. package/dist/types/src/core/index.d.ts.map +1 -0
  86. package/dist/types/src/core/manager.d.ts +119 -0
  87. package/dist/types/src/core/manager.d.ts.map +1 -0
  88. package/dist/types/src/core/manager.test.d.ts +2 -0
  89. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  90. package/dist/types/src/core/plugin.d.ts +97 -0
  91. package/dist/types/src/core/plugin.d.ts.map +1 -0
  92. package/dist/types/src/helpers.d.ts +10 -0
  93. package/dist/types/src/helpers.d.ts.map +1 -0
  94. package/dist/types/src/helpers.test.d.ts +2 -0
  95. package/dist/types/src/helpers.test.d.ts.map +1 -0
  96. package/dist/types/src/index.d.ts +5 -1
  97. package/dist/types/src/index.d.ts.map +1 -1
  98. package/dist/types/src/playground/debug/Debug.d.ts +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.map +1 -0
  141. package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent.d.ts +8 -28
  142. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  143. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  144. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  145. package/dist/types/src/plugin-settings/actions.d.ts +27 -0
  146. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  147. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
  148. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
  149. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  150. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  151. package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
  152. package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
  153. package/dist/types/src/plugin-settings/store.d.ts +5 -0
  154. package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
  155. package/dist/types/src/plugin-settings/translations.d.ts +11 -0
  156. package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
  157. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  158. package/dist/types/src/{plugins/plugin-intent → react}/IntentContext.d.ts +2 -2
  159. package/dist/types/src/react/IntentContext.d.ts.map +1 -0
  160. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  161. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  162. package/dist/types/src/react/Surface.d.ts +12 -0
  163. package/dist/types/src/react/Surface.d.ts.map +1 -0
  164. package/dist/types/src/react/Surface.stories.d.ts +16 -0
  165. package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
  166. package/dist/types/src/react/common.d.ts +12 -0
  167. package/dist/types/src/react/common.d.ts.map +1 -0
  168. package/dist/types/src/react/index.d.ts +7 -0
  169. package/dist/types/src/react/index.d.ts.map +1 -0
  170. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  171. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  172. package/dist/types/src/react/useIntentResolver.d.ts +3 -0
  173. package/dist/types/src/react/useIntentResolver.d.ts.map +1 -0
  174. package/dist/types/src/testing/index.d.ts +2 -0
  175. package/dist/types/src/testing/index.d.ts.map +1 -0
  176. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  177. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  178. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  179. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  180. package/dist/types/src/worker.d.ts +4 -0
  181. package/dist/types/src/worker.d.ts.map +1 -0
  182. package/dist/types/tsconfig.tsbuildinfo +1 -1
  183. package/package.json +37 -18
  184. package/project.json +4 -3
  185. package/src/App.tsx +139 -34
  186. package/src/common/capabilities.ts +91 -0
  187. package/src/common/events.ts +72 -0
  188. package/src/common/file.ts +22 -0
  189. package/src/common/graph.ts +30 -0
  190. package/src/{plugins/common → common}/index.ts +3 -2
  191. package/src/common/layout.ts +225 -0
  192. package/src/{plugins/plugin-surface/SurfaceContext.ts → common/surface.ts} +6 -37
  193. package/src/common/translations.ts +17 -0
  194. package/src/core/capabilities.test.ts +116 -0
  195. package/src/core/capabilities.ts +222 -0
  196. package/src/core/events.ts +58 -0
  197. package/src/core/index.ts +8 -0
  198. package/src/core/manager.test.ts +516 -0
  199. package/src/core/manager.ts +511 -0
  200. package/src/core/plugin.ts +131 -0
  201. package/src/helpers.test.ts +97 -0
  202. package/src/helpers.ts +45 -0
  203. package/src/index.ts +6 -3
  204. package/src/playground/debug/Debug.tsx +39 -0
  205. package/src/playground/debug/index.ts +5 -0
  206. package/src/playground/debug/plugin.ts +17 -0
  207. package/src/playground/generator/Main.tsx +71 -0
  208. package/src/playground/generator/Toolbar.tsx +46 -0
  209. package/src/playground/generator/generator.ts +48 -0
  210. package/src/playground/generator/index.ts +6 -0
  211. package/src/playground/generator/plugin.ts +23 -0
  212. package/src/playground/layout/Layout.tsx +33 -0
  213. package/src/playground/layout/index.ts +5 -0
  214. package/src/playground/layout/plugin.ts +17 -0
  215. package/src/playground/logger/Toolbar.tsx +29 -0
  216. package/src/playground/logger/index.ts +5 -0
  217. package/src/playground/logger/plugin.ts +36 -0
  218. package/src/playground/logger/schema.ts +12 -0
  219. package/src/playground/playground.stories.tsx +34 -0
  220. package/src/plugin-intent/IntentPlugin.tsx +20 -0
  221. package/src/plugin-intent/actions.ts +22 -0
  222. package/src/plugin-intent/errors.ts +39 -0
  223. package/src/plugin-intent/index.ts +8 -0
  224. package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.ts +83 -63
  225. package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.ts +114 -95
  226. package/src/{plugins/plugin-intent → plugin-intent}/intent.ts +10 -26
  227. package/src/plugin-settings/SettingsPlugin.ts +35 -0
  228. package/src/plugin-settings/actions.ts +27 -0
  229. package/src/plugin-settings/app-graph-builder.ts +122 -0
  230. package/src/plugin-settings/index.ts +6 -0
  231. package/src/plugin-settings/intent-resolver.ts +28 -0
  232. package/src/plugin-settings/store.ts +20 -0
  233. package/src/plugin-settings/translations.ts +17 -0
  234. package/src/{plugins/plugin-intent → react}/IntentContext.tsx +13 -5
  235. package/src/react/PluginManagerProvider.ts +22 -0
  236. package/src/react/Surface.stories.tsx +96 -0
  237. package/src/react/Surface.tsx +75 -0
  238. package/src/react/common.ts +12 -0
  239. package/src/react/index.ts +10 -0
  240. package/src/react/useCapabilities.ts +39 -0
  241. package/src/react/useIntentResolver.ts +22 -0
  242. package/src/testing/index.ts +5 -0
  243. package/src/testing/withPluginManager.stories.tsx +47 -0
  244. package/src/testing/withPluginManager.tsx +75 -0
  245. package/src/worker.ts +11 -0
  246. package/tsconfig.json +16 -4
  247. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  248. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  249. package/dist/lib/browser/chunk-QG25ZU2N.mjs +0 -320
  250. package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +0 -7
  251. package/dist/lib/browser/chunk-SPDTXTOV.mjs +0 -163
  252. package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +0 -7
  253. package/dist/lib/browser/chunk-WBOXEHBE.mjs +0 -51
  254. package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +0 -7
  255. package/dist/lib/browser/plugin-intent-T7Y3MJ5C.mjs +0 -32
  256. package/dist/lib/browser/plugin-settings-5U2L2NRU.mjs +0 -15
  257. package/dist/lib/browser/plugin-surface-OKPF3EQI.mjs +0 -24
  258. package/dist/lib/node/chunk-BW3RNEVI.cjs +0 -185
  259. package/dist/lib/node/chunk-BW3RNEVI.cjs.map +0 -7
  260. package/dist/lib/node/chunk-FCMHRU3M.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-VWHAALIN.cjs +0 -344
  264. package/dist/lib/node/chunk-VWHAALIN.cjs.map +0 -7
  265. package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +0 -53
  266. package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +0 -7
  267. package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +0 -7
  268. package/dist/lib/node/plugin-surface-CCSIONYW.cjs +0 -45
  269. package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +0 -7
  270. package/dist/lib/node-esm/chunk-3T5UIJY3.mjs +0 -53
  271. package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +0 -7
  272. package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +0 -164
  273. package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +0 -7
  274. package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +0 -321
  275. package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs.map +0 -7
  276. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  277. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  278. package/dist/lib/node-esm/plugin-intent-W2HQC6LC.mjs +0 -33
  279. package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs +0 -16
  280. package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs.map +0 -7
  281. package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs +0 -25
  282. package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs.map +0 -7
  283. package/dist/types/src/plugins/common/file.d.ts +0 -22
  284. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  285. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  286. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  287. package/dist/types/src/plugins/common/index.d.ts +0 -7
  288. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  289. package/dist/types/src/plugins/common/layout.d.ts +0 -176
  290. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  291. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  292. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  293. package/dist/types/src/plugins/common/navigation.d.ts +0 -243
  294. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  295. package/dist/types/src/plugins/common/translations.d.ts +0 -22
  296. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  297. package/dist/types/src/plugins/helpers.d.ts +0 -41
  298. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  299. package/dist/types/src/plugins/index.d.ts +0 -7
  300. package/dist/types/src/plugins/index.d.ts.map +0 -1
  301. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -16
  302. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  303. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  304. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  305. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  306. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  307. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -6
  308. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  309. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -104
  310. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  311. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  312. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  313. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  314. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  315. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  316. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -7
  317. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  318. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +0 -107
  319. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +0 -1
  320. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
  321. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  322. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -6
  323. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  324. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -16
  325. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  326. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  327. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  328. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  329. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  330. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  331. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  332. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -26
  333. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  334. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  335. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -7
  336. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  337. package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts.map +0 -1
  338. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  339. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  340. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  341. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  342. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  343. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  344. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  345. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  346. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -17
  347. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  348. package/src/plugins/common/file.ts +0 -36
  349. package/src/plugins/common/graph.ts +0 -70
  350. package/src/plugins/common/layout.ts +0 -173
  351. package/src/plugins/common/metadata.ts +0 -29
  352. package/src/plugins/common/navigation.ts +0 -214
  353. package/src/plugins/common/translations.ts +0 -36
  354. package/src/plugins/helpers.ts +0 -92
  355. package/src/plugins/index.ts +0 -11
  356. package/src/plugins/plugin-host/HostPlugin.tsx +0 -88
  357. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  358. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  359. package/src/plugins/plugin-host/index.ts +0 -12
  360. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  361. package/src/plugins/plugin-host/plugin.ts +0 -133
  362. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -75
  363. package/src/plugins/plugin-intent/index.ts +0 -13
  364. package/src/plugins/plugin-intent/meta.ts +0 -11
  365. package/src/plugins/plugin-intent/provides.ts +0 -26
  366. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  367. package/src/plugins/plugin-settings/index.ts +0 -9
  368. package/src/plugins/plugin-settings/meta.ts +0 -9
  369. package/src/plugins/plugin-settings/provides.ts +0 -34
  370. package/src/plugins/plugin-surface/Surface.tsx +0 -62
  371. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -45
  372. package/src/plugins/plugin-surface/helpers.ts +0 -22
  373. package/src/plugins/plugin-surface/index.ts +0 -14
  374. package/src/plugins/plugin-surface/meta.ts +0 -9
  375. package/src/plugins/plugin-surface/provides.ts +0 -27
  376. /package/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-E6J7E5Y5.mjs.map} +0 -0
  377. /package/dist/lib/browser/{plugin-settings-5U2L2NRU.mjs.map → worker.mjs.map} +0 -0
  378. /package/dist/lib/{browser/plugin-surface-OKPF3EQI.mjs.map → node-esm/intent-dispatcher-LDQGDZ62.mjs.map} +0 -0
  379. /package/dist/lib/node-esm/{plugin-intent-W2HQC6LC.mjs.map → worker.mjs.map} +0 -0
  380. /package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.d.ts +0 -0
  381. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  382. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -0,0 +1,1401 @@
1
+ import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
+
3
+ // packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
4
+ import { Effect as Effect2, Option, pipe as pipe2, Ref } from "effect";
5
+ import { create as create3 } from "@dxos/live-object";
6
+ import { byPosition } from "@dxos/util";
7
+
8
+ // packages/sdk/app-framework/src/plugin-intent/actions.ts
9
+ import { Schema as S2 } from "@effect/schema";
10
+
11
+ // packages/sdk/app-framework/src/plugin-intent/intent.ts
12
+ import { Schema as S } from "@effect/schema";
13
+ var createIntent = (schema, data = {}, params = {}) => {
14
+ const _ = S.validateSync(schema.fields.input)(data);
15
+ const intent = {
16
+ ...params,
17
+ _schema: schema,
18
+ id: schema._tag,
19
+ data
20
+ };
21
+ return {
22
+ first: intent,
23
+ last: intent,
24
+ all: [
25
+ intent
26
+ ]
27
+ };
28
+ };
29
+ var chain = (schema, data = {}, params = {}) => (intent) => {
30
+ const intents = "all" in intent ? intent.all : [
31
+ intent
32
+ ];
33
+ const first = intents[0];
34
+ const last = {
35
+ ...params,
36
+ _schema: schema,
37
+ id: schema._tag,
38
+ data
39
+ };
40
+ return {
41
+ first,
42
+ last,
43
+ all: [
44
+ ...intents,
45
+ last
46
+ ]
47
+ };
48
+ };
49
+ var Label = S.Union(S.String, S.mutable(S.Tuple(S.String, S.mutable(S.Struct({
50
+ ns: S.String,
51
+ count: S.optional(S.Number)
52
+ })))));
53
+
54
+ // packages/sdk/app-framework/src/plugin-intent/actions.ts
55
+ var INTENT_PLUGIN = "dxos.org/plugin/intent";
56
+ var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
57
+ var IntentAction;
58
+ (function(IntentAction2) {
59
+ class ShowUndo extends S2.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
60
+ input: S2.Struct({
61
+ message: Label
62
+ }),
63
+ output: S2.Void
64
+ }) {
65
+ }
66
+ IntentAction2.ShowUndo = ShowUndo;
67
+ })(IntentAction || (IntentAction = {}));
68
+
69
+ // packages/sdk/app-framework/src/plugin-intent/errors.ts
70
+ var BaseError = class extends Error {
71
+ constructor(code, message, context) {
72
+ super(message ?? code);
73
+ 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.FileUploader = defineCapability("dxos.org/app-framework/capability/file-uploader");
836
+ })(Capabilities || (Capabilities = {}));
837
+
838
+ // packages/sdk/app-framework/src/common/events.ts
839
+ var Events;
840
+ (function(Events2) {
841
+ Events2.Startup = defineEvent("dxos.org/app-framework/event/startup");
842
+ Events2.SetupSurfaces = defineEvent("dxos.org/app-framework/event/setup-surfaces");
843
+ Events2.SetupMetadata = defineEvent("dxos.org/app-framework/event/setup-metadata");
844
+ Events2.SetupIntents = defineEvent("dxos.org/app-framework/event/setup-intents");
845
+ Events2.SetupSettings = defineEvent("dxos.org/app-framework/event/setup-settings");
846
+ Events2.SetupAppGraph = defineEvent("dxos.org/app-framework/event/setup-graph");
847
+ Events2.SetupTranslations = defineEvent("dxos.org/app-framework/event/setup-translations");
848
+ Events2.DispatcherReady = defineEvent("dxos.org/app-framework/event/dispatcher-ready");
849
+ Events2.SettingsReady = defineEvent("dxos.org/app-framework/event/settings-ready");
850
+ Events2.AppGraphReady = defineEvent("dxos.org/app-framework/event/graph-ready");
851
+ Events2.createStateEvent = (specifier) => defineEvent("dxos.org/app-framework/event/state", specifier);
852
+ Events2.LayoutReady = Events2.createStateEvent(Capabilities.Layout.identifier);
853
+ })(Events || (Events = {}));
854
+
855
+ // packages/sdk/app-framework/src/common/file.ts
856
+ import { Schema as S3 } from "@effect/schema";
857
+ var defaultFileTypes = {
858
+ images: [
859
+ "png",
860
+ "jpg",
861
+ "jpeg",
862
+ "gif"
863
+ ],
864
+ media: [
865
+ "mp3",
866
+ "mp4",
867
+ "mov",
868
+ "avi"
869
+ ],
870
+ text: [
871
+ "pdf",
872
+ "txt",
873
+ "md"
874
+ ]
875
+ };
876
+ var FileInfoSchema = S3.Struct({
877
+ name: S3.String,
878
+ type: S3.String,
879
+ url: S3.optional(S3.String),
880
+ cid: S3.optional(S3.String)
881
+ });
882
+
883
+ // packages/sdk/app-framework/src/common/layout.ts
884
+ import { Schema as S4 } from "@effect/schema";
885
+
886
+ // packages/sdk/app-framework/src/plugin-intent/IntentPlugin.tsx
887
+ var IntentPlugin = () => definePlugin({
888
+ id: INTENT_PLUGIN
889
+ }, [
890
+ defineModule({
891
+ id: `${INTENT_PLUGIN}/module/dispatcher`,
892
+ // TODO(wittjosiah): This will mean that startup needs to be reset when intents are added or removed.
893
+ // This is fine for now because it's how it worked prior to capabilities api anyways.
894
+ // In the future, the intent dispatcher should be able to be reset without resetting the entire app.
895
+ activatesOn: Events.Startup,
896
+ activatesAfter: [
897
+ Events.DispatcherReady
898
+ ],
899
+ activate: lazy(() => import("./intent-dispatcher-LDQGDZ62.mjs"))
900
+ })
901
+ ]);
902
+
903
+ // packages/sdk/app-framework/src/common/layout.ts
904
+ var LAYOUT_PLUGIN = "dxos.org/plugin/layout";
905
+ var LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
906
+ var LayoutAction;
907
+ (function(LayoutAction2) {
908
+ LayoutAction2.UPDATE_LAYOUT = `${LAYOUT_ACTION}/update-layout`;
909
+ class UpdateLayout extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
910
+ input: S4.Struct({
911
+ part: S4.String.annotations({
912
+ description: "The part of the layout to mutate."
913
+ }),
914
+ subject: S4.optional(S4.Any.annotations({
915
+ description: "The subject of the layout update."
916
+ })),
917
+ options: S4.optional(S4.Record({
918
+ key: S4.String,
919
+ value: S4.Any
920
+ }).annotations({
921
+ description: "Additional options for the layout action."
922
+ }))
923
+ }),
924
+ output: S4.Void
925
+ }) {
926
+ }
927
+ LayoutAction2.UpdateLayout = UpdateLayout;
928
+ class SetLayoutMode extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
929
+ input: S4.Struct({
930
+ part: S4.Literal("mode").annotations({
931
+ description: "Setting the layout mode."
932
+ }),
933
+ subject: S4.optional(S4.String.annotations({
934
+ description: "Item which is the subject of the new layout mode."
935
+ })),
936
+ options: S4.Union(S4.Struct({
937
+ mode: S4.String.annotations({
938
+ description: "The new layout mode."
939
+ })
940
+ }), S4.Struct({
941
+ revert: S4.Boolean.annotations({
942
+ description: "Revert to the previous layout mode."
943
+ })
944
+ }))
945
+ }),
946
+ output: S4.Void
947
+ }) {
948
+ }
949
+ LayoutAction2.SetLayoutMode = SetLayoutMode;
950
+ class UpdateSidebar extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
951
+ input: S4.Struct({
952
+ part: S4.Literal("sidebar").annotations({
953
+ description: "Updating the sidebar."
954
+ }),
955
+ subject: S4.optional(S4.String.annotations({
956
+ description: "URI of the component to display in the sidebar."
957
+ })),
958
+ options: S4.optional(S4.Struct({
959
+ state: S4.Literal("closed", "collapsed", "expanded").annotations({
960
+ description: "Whether the sidebar is closed, collapsed, or expanded."
961
+ })
962
+ }))
963
+ }),
964
+ output: S4.Void
965
+ }) {
966
+ }
967
+ LayoutAction2.UpdateSidebar = UpdateSidebar;
968
+ class UpdateComplementary extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
969
+ input: S4.Struct({
970
+ part: S4.Literal("complementary").annotations({
971
+ description: "Updating the complementary sidebar."
972
+ }),
973
+ subject: S4.optional(S4.String.annotations({
974
+ description: "URI of the component to display in the complementary area."
975
+ })),
976
+ options: S4.optional(S4.Struct({
977
+ state: S4.Literal("closed", "collapsed", "expanded").annotations({
978
+ description: "Whether the complementary sidebar is closed, collapsed, or expanded."
979
+ })
980
+ }))
981
+ }),
982
+ output: S4.Void
983
+ }) {
984
+ }
985
+ LayoutAction2.UpdateComplementary = UpdateComplementary;
986
+ class UpdateDialog extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
987
+ input: S4.Struct({
988
+ part: S4.Literal("dialog").annotations({
989
+ description: "Updating the dialog."
990
+ }),
991
+ subject: S4.optional(S4.String.annotations({
992
+ description: "URI of the component to display in the dialog."
993
+ })),
994
+ options: S4.Struct({
995
+ state: S4.optional(S4.Boolean.annotations({
996
+ description: "Whether the dialog is open or closed."
997
+ })),
998
+ blockAlign: S4.optional(S4.Literal("start", "center").annotations({
999
+ description: "The alignment of the dialog."
1000
+ })),
1001
+ type: S4.optional(S4.Literal("default", "alert").annotations({
1002
+ description: "The type of dialog."
1003
+ })),
1004
+ props: S4.optional(S4.Record({
1005
+ key: S4.String,
1006
+ value: S4.Any
1007
+ }).annotations({
1008
+ description: "Additional props for the dialog."
1009
+ }))
1010
+ })
1011
+ }),
1012
+ output: S4.Void
1013
+ }) {
1014
+ }
1015
+ LayoutAction2.UpdateDialog = UpdateDialog;
1016
+ class UpdatePopover extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1017
+ input: S4.Struct({
1018
+ part: S4.Literal("popover").annotations({
1019
+ description: "Updating the popover."
1020
+ }),
1021
+ subject: S4.optional(S4.String.annotations({
1022
+ description: "URI of the component to display in the popover."
1023
+ })),
1024
+ options: S4.Struct({
1025
+ anchorId: S4.String.annotations({
1026
+ description: "The id of the element to anchor the popover to."
1027
+ }),
1028
+ state: S4.optional(S4.Boolean.annotations({
1029
+ description: "Whether the popover is open or closed."
1030
+ })),
1031
+ props: S4.optional(S4.Record({
1032
+ key: S4.String,
1033
+ value: S4.Any
1034
+ }).annotations({
1035
+ description: "Additional props for the popover."
1036
+ }))
1037
+ })
1038
+ }),
1039
+ output: S4.Void
1040
+ }) {
1041
+ }
1042
+ LayoutAction2.UpdatePopover = UpdatePopover;
1043
+ LayoutAction2.Toast = S4.Struct({
1044
+ id: S4.String.annotations({
1045
+ description: "The id of the toast."
1046
+ }),
1047
+ title: S4.optional(Label.annotations({
1048
+ description: "The title of the toast."
1049
+ })),
1050
+ description: S4.optional(Label.annotations({
1051
+ description: "The description of the toast."
1052
+ })),
1053
+ icon: S4.optional(S4.String.annotations({
1054
+ description: "The icon of the toast."
1055
+ })),
1056
+ duration: S4.optional(S4.Number.annotations({
1057
+ description: "The duration of the toast."
1058
+ })),
1059
+ closeLabel: S4.optional(Label.annotations({
1060
+ description: "The label of the close button."
1061
+ })),
1062
+ actionLabel: S4.optional(Label.annotations({
1063
+ description: "The label of the action button."
1064
+ })),
1065
+ actionAlt: S4.optional(Label.annotations({
1066
+ description: "The alt text of the action button."
1067
+ })),
1068
+ onAction: S4.optional(S4.Any.annotations({
1069
+ description: "The action to perform when the action button is clicked."
1070
+ }))
1071
+ });
1072
+ class AddToast extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1073
+ input: S4.Struct({
1074
+ part: S4.Literal("toast").annotations({
1075
+ description: "Adding a toast."
1076
+ }),
1077
+ subject: LayoutAction2.Toast.annotations({
1078
+ description: "The toast to add."
1079
+ })
1080
+ }),
1081
+ output: S4.Void
1082
+ }) {
1083
+ }
1084
+ LayoutAction2.AddToast = AddToast;
1085
+ class SwitchWorkspace extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1086
+ input: S4.Struct({
1087
+ part: S4.Literal("workspace").annotations({
1088
+ description: "Switching the workspace."
1089
+ }),
1090
+ subject: S4.String.annotations({
1091
+ description: "The id of the workspace to switch to."
1092
+ })
1093
+ }),
1094
+ output: S4.Void
1095
+ }) {
1096
+ }
1097
+ LayoutAction2.SwitchWorkspace = SwitchWorkspace;
1098
+ class Open extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1099
+ input: S4.Struct({
1100
+ part: S4.Literal("main").annotations({
1101
+ description: "Opening an item in the main content area."
1102
+ }),
1103
+ subject: S4.Array(S4.String.annotations({
1104
+ description: "Ids of the items to open."
1105
+ })),
1106
+ options: S4.optional(S4.Struct({
1107
+ state: S4.optional(S4.Literal(true).annotations({
1108
+ description: "The items are being added."
1109
+ })),
1110
+ key: S4.optional(S4.String.annotations({
1111
+ description: "If provided, will replace item with a matching key (id prefix)."
1112
+ })),
1113
+ scrollIntoView: S4.optional(S4.Boolean.annotations({
1114
+ description: "Scroll the items into view."
1115
+ })),
1116
+ pivotId: S4.optional(S4.String.annotations({
1117
+ description: "The id of the item to place new items next to."
1118
+ })),
1119
+ positioning: S4.optional(S4.Union(S4.Literal("start").annotations({
1120
+ description: "The items are being added before the pivot item."
1121
+ }), S4.Literal("end").annotations({
1122
+ description: "The items are being added after the pivot item."
1123
+ })))
1124
+ }))
1125
+ }),
1126
+ output: S4.Void
1127
+ }) {
1128
+ }
1129
+ LayoutAction2.Open = Open;
1130
+ class Set2 extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1131
+ input: S4.Struct({
1132
+ part: S4.Literal("main").annotations({
1133
+ description: "Setting items in the main content area."
1134
+ }),
1135
+ subject: S4.Array(S4.String.annotations({
1136
+ description: "Ids of the items to set."
1137
+ })),
1138
+ options: S4.Struct({
1139
+ override: S4.Literal(true).annotations({
1140
+ description: "Override the current items in the main content area."
1141
+ })
1142
+ })
1143
+ }),
1144
+ output: S4.Void
1145
+ }) {
1146
+ }
1147
+ LayoutAction2.Set = Set2;
1148
+ class Close extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1149
+ input: S4.Struct({
1150
+ part: S4.Literal("main").annotations({
1151
+ description: "Closing items in the main content area."
1152
+ }),
1153
+ subject: S4.Array(S4.String.annotations({
1154
+ description: "Ids of the items to close."
1155
+ })),
1156
+ options: S4.Struct({
1157
+ state: S4.Literal(false).annotations({
1158
+ description: "The items are being removed."
1159
+ })
1160
+ })
1161
+ }),
1162
+ output: S4.Void
1163
+ }) {
1164
+ }
1165
+ LayoutAction2.Close = Close;
1166
+ class ScrollIntoView extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1167
+ input: S4.Struct({
1168
+ part: S4.Literal("current").annotations({
1169
+ description: "Setting the current item"
1170
+ }),
1171
+ subject: S4.optional(S4.String.annotations({
1172
+ description: "The id of the item to set as current."
1173
+ })),
1174
+ options: S4.optional(S4.Record({
1175
+ key: S4.String,
1176
+ value: S4.Any
1177
+ }).annotations({
1178
+ description: "Additional options for the scroll into view."
1179
+ }))
1180
+ }),
1181
+ output: S4.Void
1182
+ }) {
1183
+ }
1184
+ LayoutAction2.ScrollIntoView = ScrollIntoView;
1185
+ class Expose extends S4.TaggedClass()(LayoutAction2.UPDATE_LAYOUT, {
1186
+ input: S4.Struct({
1187
+ part: S4.Literal("navigation").annotations({
1188
+ description: "Exposing an item in the navigation area."
1189
+ }),
1190
+ subject: S4.String.annotations({
1191
+ description: "The id of the item to expose."
1192
+ })
1193
+ }),
1194
+ output: S4.Void
1195
+ }) {
1196
+ }
1197
+ LayoutAction2.Expose = Expose;
1198
+ })(LayoutAction || (LayoutAction = {}));
1199
+
1200
+ // packages/sdk/app-framework/src/common/surface.ts
1201
+ var createSurface = (definition) => definition;
1202
+
1203
+ // packages/sdk/app-framework/src/common/translations.ts
1204
+ import { Schema as S5 } from "@effect/schema";
1205
+ var ResourceKey = S5.Union(S5.String, S5.Record({
1206
+ key: S5.String,
1207
+ value: S5.Any
1208
+ }));
1209
+ var ResourceLanguage = S5.Record({
1210
+ key: S5.String,
1211
+ value: ResourceKey
1212
+ });
1213
+ var Resource = S5.Record({
1214
+ key: S5.String,
1215
+ value: ResourceLanguage
1216
+ });
1217
+
1218
+ // packages/sdk/app-framework/src/plugin-intent/intent-dispatcher.ts
1219
+ var EXECUTION_LIMIT = 100;
1220
+ var HISTORY_LIMIT = 100;
1221
+ var createResolver = (resolver) => resolver;
1222
+ var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
1223
+ var createDispatcher = (getResolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
1224
+ const historyRef = Effect2.runSync(Ref.make([]));
1225
+ const handleIntent = (intent) => Effect2.gen(function* () {
1226
+ const candidates = getResolvers(intent.module).filter((r) => r.intent._tag === intent.id).filter((r) => !r.filter || r.filter(intent.data)).toSorted(byPosition);
1227
+ if (candidates.length === 0) {
1228
+ yield* Effect2.fail(new NoResolversError(intent.id));
1229
+ }
1230
+ const effect2 = candidates[0].resolve(intent.data, intent.undo ?? false);
1231
+ const result = Effect2.isEffect(effect2) ? yield* effect2 : yield* Effect2.promise(async () => effect2);
1232
+ return {
1233
+ _intent: intent,
1234
+ ...result
1235
+ };
1236
+ });
1237
+ const dispatch = (intentChain, depth = 0) => {
1238
+ return Effect2.gen(function* () {
1239
+ if (depth > executionLimit) {
1240
+ yield* Effect2.fail(new CycleDetectedError());
1241
+ }
1242
+ const resultsRef = yield* Ref.make([]);
1243
+ for (const intent of intentChain.all) {
1244
+ const { data: prev } = (yield* resultsRef.get)[0] ?? {};
1245
+ const result2 = yield* handleIntent({
1246
+ ...intent,
1247
+ data: {
1248
+ ...intent.data,
1249
+ ...prev
1250
+ }
1251
+ });
1252
+ yield* Ref.update(resultsRef, (results2) => [
1253
+ result2,
1254
+ ...results2
1255
+ ]);
1256
+ if (result2.intents) {
1257
+ for (const intent2 of result2.intents) {
1258
+ yield* dispatch(intent2, depth + 1);
1259
+ }
1260
+ }
1261
+ if (result2.error) {
1262
+ yield* Effect2.fail(result2.error);
1263
+ }
1264
+ }
1265
+ const results = yield* resultsRef.get;
1266
+ const result = results[0];
1267
+ yield* Ref.update(historyRef, (history) => {
1268
+ const next = [
1269
+ ...history,
1270
+ results
1271
+ ];
1272
+ if (next.length > historyLimit) {
1273
+ next.splice(0, next.length - historyLimit);
1274
+ }
1275
+ return next;
1276
+ });
1277
+ if (result.undoable && isUndoable(results)) {
1278
+ yield* pipe2(dispatch(createIntent(IntentAction.ShowUndo, {
1279
+ message: result.undoable.message
1280
+ })), Effect2.catchSome((err) => err instanceof NoResolversError ? Option.some(Effect2.succeed(void 0)) : Option.none()));
1281
+ }
1282
+ return result.data;
1283
+ });
1284
+ };
1285
+ const dispatchPromise = (intentChain) => {
1286
+ return Effect2.runPromise(dispatch(intentChain)).then((data) => ({
1287
+ data
1288
+ })).catch((error) => ({
1289
+ error
1290
+ }));
1291
+ };
1292
+ const undo = () => {
1293
+ return Effect2.gen(function* () {
1294
+ const history = yield* historyRef.get;
1295
+ const last = history.findLastIndex(isUndoable);
1296
+ const result = last !== -1 ? history[last] : void 0;
1297
+ if (result) {
1298
+ const all = result.map(({ _intent, undoable }) => {
1299
+ const data = _intent.data;
1300
+ const undoData = undoable?.data ?? {};
1301
+ return {
1302
+ ..._intent,
1303
+ data: {
1304
+ ...data,
1305
+ ...undoData
1306
+ },
1307
+ undo: true
1308
+ };
1309
+ });
1310
+ const intent = {
1311
+ first: all[0],
1312
+ last: all.at(-1),
1313
+ all
1314
+ };
1315
+ yield* Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));
1316
+ return yield* dispatch(intent);
1317
+ }
1318
+ });
1319
+ };
1320
+ const undoPromise = () => {
1321
+ return Effect2.runPromise(undo()).then((data) => ({
1322
+ data
1323
+ })).catch((error) => ({
1324
+ error
1325
+ }));
1326
+ };
1327
+ return {
1328
+ dispatch,
1329
+ dispatchPromise,
1330
+ undo,
1331
+ undoPromise
1332
+ };
1333
+ };
1334
+ var defaultEffect = () => Effect2.fail(new Error("Intent runtime not ready"));
1335
+ var defaultPromise = () => Effect2.runPromise(defaultEffect());
1336
+ var intent_dispatcher_default = (context) => {
1337
+ const state = create3({
1338
+ dispatch: defaultEffect,
1339
+ dispatchPromise: defaultPromise,
1340
+ undo: defaultEffect,
1341
+ undoPromise: defaultPromise
1342
+ });
1343
+ const { dispatch, dispatchPromise, undo, undoPromise } = createDispatcher((module) => context.requestCapabilities(Capabilities.IntentResolver, (c, moduleId) => {
1344
+ return module ? moduleId === module : true;
1345
+ }).flat());
1346
+ const manager = context.requestCapability(Capabilities.PluginManager);
1347
+ state.dispatch = (intentChain, depth) => {
1348
+ return Effect2.gen(function* () {
1349
+ yield* manager._activate(Events.SetupIntents);
1350
+ return yield* dispatch(intentChain, depth);
1351
+ });
1352
+ };
1353
+ state.dispatchPromise = async (intentChain) => {
1354
+ await manager.activate(Events.SetupIntents);
1355
+ return await dispatchPromise(intentChain);
1356
+ };
1357
+ state.undo = undo;
1358
+ state.undoPromise = undoPromise;
1359
+ return contributes(Capabilities.IntentDispatcher, state);
1360
+ };
1361
+
1362
+ export {
1363
+ defineCapability,
1364
+ contributes,
1365
+ lazy,
1366
+ PluginsContext,
1367
+ defineEvent,
1368
+ eventKey,
1369
+ oneOf,
1370
+ allOf,
1371
+ isOneOf,
1372
+ isAllOf,
1373
+ getEvents,
1374
+ PluginManager,
1375
+ PluginModule,
1376
+ defineModule,
1377
+ Plugin,
1378
+ definePlugin,
1379
+ Capabilities,
1380
+ Events,
1381
+ defaultFileTypes,
1382
+ FileInfoSchema,
1383
+ createIntent,
1384
+ chain,
1385
+ Label,
1386
+ INTENT_PLUGIN,
1387
+ INTENT_ACTION,
1388
+ IntentAction,
1389
+ createResolver,
1390
+ createDispatcher,
1391
+ intent_dispatcher_default,
1392
+ IntentPlugin,
1393
+ LAYOUT_PLUGIN,
1394
+ LAYOUT_ACTION,
1395
+ LayoutAction,
1396
+ createSurface,
1397
+ ResourceKey,
1398
+ ResourceLanguage,
1399
+ Resource
1400
+ };
1401
+ //# sourceMappingURL=chunk-44J2VZBB.mjs.map