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