@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
package/src/App.tsx CHANGED
@@ -1,63 +1,168 @@
1
1
  //
2
- // Copyright 2023 DXOS.org
2
+ // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import { effect } from '@preact/signals-core';
6
+ import React, { type PropsWithChildren, type ReactNode } from 'react';
6
7
 
7
8
  import { invariant } from '@dxos/invariant';
9
+ import { create } from '@dxos/live-object';
8
10
 
9
- import { type HostPluginParams, Plugin, HostPlugin } from './plugins';
10
- import IntentMeta from './plugins/plugin-intent/meta';
11
- import SettingsMeta from './plugins/plugin-settings/meta';
12
- import SurfaceMeta from './plugins/plugin-surface/meta';
11
+ import { Capabilities, Events } from './common';
12
+ import { PluginManager, type PluginManagerOptions, type Plugin } from './core';
13
+ import { topologicalSort } from './helpers';
14
+ import { ErrorBoundary, PluginManagerProvider, useCapabilities } from './react';
15
+
16
+ const ENABLED_KEY = 'dxos.org/app-framework/enabled';
17
+
18
+ export type CreateAppOptions = {
19
+ pluginManager?: PluginManager;
20
+ pluginLoader?: PluginManagerOptions['pluginLoader'];
21
+ plugins?: Plugin[];
22
+ core?: string[];
23
+ defaults?: string[];
24
+ placeholder?: ReactNode;
25
+ fallback?: ErrorBoundary['props']['fallback'];
26
+ cacheEnabled?: boolean;
27
+ };
13
28
 
14
29
  /**
15
30
  * Expected usage is for this to be the entrypoint of the application.
16
31
  * Initializes plugins and renders the root components.
17
32
  *
18
33
  * @example
19
- * const meta = [LayoutMeta, MyPluginMeta];
20
- * const plugins = {
21
- * [LayoutMeta.id]: Plugin.lazy(() => import('./plugins/LayoutPlugin/plugin')),
22
- * [MyPluginMeta.id]: Plugin.lazy(() => import('./plugins/MyPlugin/plugin')),
23
- * };
24
- * const core = [LayoutMeta.id];
25
- * const default = [MyPluginMeta.id];
34
+ * const plugins = [LayoutPlugin(), MyPlugin()];
35
+ * const core = [LayoutPluginId];
36
+ * const default = [MyPluginId];
26
37
  * const fallback = <div>Initializing Plugins...</div>;
27
- * const App = createApp({ order, plugins, core, default, fallback });
38
+ * const App = createApp({ plugins, core, default, fallback });
28
39
  * createRoot(document.getElementById('root')!).render(
29
40
  * <StrictMode>
30
41
  * <App />
31
42
  * </StrictMode>,
32
43
  * );
33
44
  *
45
+ * @param params.pluginLoader A function which loads new plugins.
34
46
  * @param params.plugins All plugins available to the application.
35
- * @param params.meta All plugin metadata.
36
47
  * @param params.core Core plugins which will always be enabled.
37
48
  * @param params.defaults Default plugins are enabled by default but can be disabled by the user.
38
- * @param params.fallback Fallback component to render while plugins are initializing.
49
+ * @param params.placeholder Placeholder component to render during startup.
50
+ * @param params.fallback Fallback component to render if an error occurs during startup.
51
+ * @param params.cacheEnabled Whether to cache enabled plugins in localStorage.
39
52
  */
40
- export const createApp = ({ meta, plugins, core, ...params }: HostPluginParams) => {
41
- const hostPlugin = HostPlugin({
42
- plugins: {
43
- ...plugins,
44
- [IntentMeta.id]: Plugin.lazy(() => import('./plugins/plugin-intent')),
45
- [SettingsMeta.id]: Plugin.lazy(() => import('./plugins/plugin-settings')),
46
- [SurfaceMeta.id]: Plugin.lazy(() => import('./plugins/plugin-surface')),
47
- },
48
- meta: [IntentMeta, SettingsMeta, SurfaceMeta, ...meta],
49
- core: [IntentMeta.id, SettingsMeta.id, SurfaceMeta.id, ...core],
50
- ...params,
53
+ export const createApp = ({
54
+ pluginManager,
55
+ pluginLoader: _pluginLoader,
56
+ plugins = [],
57
+ core = plugins.map(({ meta }) => meta.id),
58
+ defaults = [],
59
+ placeholder = null,
60
+ fallback = DefaultFallback,
61
+ cacheEnabled = false,
62
+ }: CreateAppOptions) => {
63
+ // TODO(wittjosiah): Provide a custom plugin loader which supports loading via url.
64
+ const pluginLoader =
65
+ _pluginLoader ??
66
+ ((id: string) => {
67
+ const plugin = plugins.find((plugin) => plugin.meta.id === id);
68
+ invariant(plugin, `Plugin not found: ${id}`);
69
+ return plugin;
70
+ });
71
+
72
+ const state = create({ ready: false, error: null });
73
+ const cached: string[] = JSON.parse(localStorage.getItem(ENABLED_KEY) ?? '[]');
74
+ const enabled = cacheEnabled && cached.length > 0 ? cached : defaults;
75
+ const manager = pluginManager ?? new PluginManager({ pluginLoader, plugins, core, enabled });
76
+
77
+ manager.activation.on(({ event, state: _state, error }) => {
78
+ if (event === Events.Startup.id) {
79
+ state.ready = _state === 'activated';
80
+ }
81
+
82
+ if (error && !state.ready && !state.error) {
83
+ state.error = error;
84
+ }
85
+ });
86
+
87
+ effect(() => {
88
+ cacheEnabled && localStorage.setItem(ENABLED_KEY, JSON.stringify(manager.enabled));
89
+ });
90
+
91
+ manager.context.contributeCapability({
92
+ interface: Capabilities.PluginManager,
93
+ implementation: manager,
94
+ module: 'dxos.org/app-framework/plugin-manager',
51
95
  });
52
96
 
53
- invariant(hostPlugin.provides);
54
- const { context: Context, root: Root } = hostPlugin.provides;
55
- invariant(Context);
56
- invariant(Root);
97
+ setupDevtools(manager);
98
+
99
+ // TODO(wittjosiah): Factor out such that this could be called per surface role when attempting to render.
100
+ void manager.activate(Events.SetupSurfaces);
101
+ void manager.activate(Events.Startup);
57
102
 
58
103
  return () => (
59
- <Context>
60
- <Root />
61
- </Context>
104
+ <ErrorBoundary fallback={fallback}>
105
+ <PluginManagerProvider value={manager}>
106
+ <App placeholder={placeholder} state={state} />
107
+ </PluginManagerProvider>
108
+ </ErrorBoundary>
62
109
  );
63
110
  };
111
+
112
+ type AppProps = Required<Pick<CreateAppOptions, 'placeholder'>> & {
113
+ state: { ready: boolean; error: unknown };
114
+ };
115
+
116
+ const App = ({ placeholder, state }: AppProps) => {
117
+ const reactContexts = useCapabilities(Capabilities.ReactContext);
118
+ const reactRoots = useCapabilities(Capabilities.ReactRoot);
119
+
120
+ if (state.error) {
121
+ // This trigger the error boundary to provide UI feedback for the startup error.
122
+ throw state.error;
123
+ }
124
+
125
+ // TODO(wittjosiah): Consider using Suspense instead?
126
+ if (!state.ready) {
127
+ return <>{placeholder}</>;
128
+ }
129
+
130
+ const ComposedContext = composeContexts(reactContexts);
131
+ return (
132
+ <ComposedContext>
133
+ {reactRoots.map(({ id, root: Component }) => (
134
+ <Component key={id} />
135
+ ))}
136
+ </ComposedContext>
137
+ );
138
+ };
139
+
140
+ // Default fallback does not use tailwind or theme.
141
+ const DefaultFallback = ({ error }: { error: Error }) => {
142
+ return (
143
+ <div style={{ padding: '1rem' }}>
144
+ {/* TODO(wittjosiah): Link to docs for replacing default. */}
145
+ <h1 style={{ fontSize: '1.2rem', fontWeight: 700, margin: '0.5rem 0' }}>{error.message}</h1>
146
+ <pre>{error.stack}</pre>
147
+ </div>
148
+ );
149
+ };
150
+
151
+ const composeContexts = (contexts: Capabilities.ReactContext[]) => {
152
+ if (contexts.length === 0) {
153
+ return ({ children }: PropsWithChildren) => <>{children}</>;
154
+ }
155
+
156
+ return topologicalSort(contexts)
157
+ .map(({ context }) => context)
158
+ .reduce((Acc, Next) => ({ children }) => (
159
+ <Acc>
160
+ <Next>{children}</Next>
161
+ </Acc>
162
+ ));
163
+ };
164
+
165
+ const setupDevtools = (manager: PluginManager) => {
166
+ (globalThis as any).composer ??= {};
167
+ (globalThis as any).composer.manager = manager;
168
+ };
@@ -0,0 +1,91 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Schema as S } from '@effect/schema';
6
+ import { type FC, type PropsWithChildren } from 'react';
7
+
8
+ import { type GraphBuilder } from '@dxos/app-graph';
9
+ import { type Space } from '@dxos/client-protocol';
10
+ import { type RootSettingsStore } from '@dxos/local-storage';
11
+
12
+ import { type FileInfo } from './file';
13
+ import { type NodeSerializer } from './graph';
14
+ import { type SurfaceDefinition } from './surface';
15
+ import { type Resource } from './translations';
16
+ import { defineCapability, type PluginManager } from '../core';
17
+ import { type AnyIntentResolver, type IntentContext } from '../plugin-intent';
18
+
19
+ export namespace Capabilities {
20
+ export const PluginManager = defineCapability<PluginManager>('dxos.org/app-framework/capability/plugin-manager');
21
+
22
+ export const Null = defineCapability<null>('dxos.org/app-framework/capability/null');
23
+
24
+ export type ReactContext = Readonly<{ id: string; dependsOn?: string[]; context: FC<PropsWithChildren> }>;
25
+ export const ReactContext = defineCapability<ReactContext>('dxos.org/app-framework/capability/react-context');
26
+
27
+ export type ReactRoot = Readonly<{ id: string; root: FC<PropsWithChildren> }>;
28
+ export const ReactRoot = defineCapability<ReactRoot>('dxos.org/app-framework/capability/react-root');
29
+
30
+ export type ReactSurface = SurfaceDefinition | readonly SurfaceDefinition[];
31
+ export const ReactSurface = defineCapability<ReactSurface>('dxos.org/app-framework/common/react-surface');
32
+
33
+ export type IntentResolver = AnyIntentResolver | readonly AnyIntentResolver[];
34
+ export const IntentResolver = defineCapability<IntentResolver>('dxos.org/app-framework/capability/intent-resolver');
35
+
36
+ export const IntentDispatcher = defineCapability<IntentContext>(
37
+ 'dxos.org/app-framework/capability/intent-dispatcher',
38
+ );
39
+
40
+ export type Layout = Readonly<{
41
+ mode: string;
42
+ dialogOpen: boolean;
43
+ sidebarOpen: boolean;
44
+ complementarySidebarOpen: boolean;
45
+ /**
46
+ * Identifiers of items which are currently active in the application.
47
+ */
48
+ active: string[];
49
+ /**
50
+ * Identifiers of items which were previously active in the application.
51
+ */
52
+ inactive: string[];
53
+ /**
54
+ * Identifier of the item which should be scrolled into view.
55
+ */
56
+ scrollIntoView: string | undefined;
57
+ }>;
58
+ export const Layout = defineCapability<Layout>('dxos.org/app-framework/capability/layout');
59
+
60
+ export const Translations = defineCapability<Readonly<Resource[]>>('dxos.org/app-framework/capability/translations');
61
+
62
+ export const AppGraph = defineCapability<Readonly<Pick<GraphBuilder, 'graph' | 'explore'>>>(
63
+ 'dxos.org/app-framework/capability/app-graph',
64
+ );
65
+
66
+ export const AppGraphBuilder = defineCapability<Parameters<GraphBuilder['addExtension']>[0]>(
67
+ 'dxos.org/app-framework/capability/app-graph-builder',
68
+ );
69
+
70
+ export const AppGraphSerializer = defineCapability<NodeSerializer[]>(
71
+ 'dxos.org/app-framework/capability/app-graph-serializer',
72
+ );
73
+
74
+ export const SettingsStore = defineCapability<RootSettingsStore>('dxos.org/app-framework/capability/settings-store');
75
+
76
+ // TODO(wittjosiah): The generics caused type inference issues for schemas when contributing settings.
77
+ // export type Settings = Parameters<RootSettingsStore['createStore']>[0];
78
+ // export type Settings<T extends SettingsValue = SettingsValue> = SettingsProps<T>;
79
+ export type Settings = {
80
+ schema: S.Schema.All;
81
+ prefix: string;
82
+ value?: Record<string, any>;
83
+ };
84
+ export const Settings = defineCapability<Settings>('dxos.org/app-framework/capability/settings');
85
+
86
+ export type Metadata = Readonly<{ id: string; metadata: Record<string, any> }>;
87
+ export const Metadata = defineCapability<Metadata>('dxos.org/app-framework/capability/metadata');
88
+
89
+ export type FileUploader = (file: File, space: Space) => Promise<FileInfo | undefined>;
90
+ export const FileUploader = defineCapability<FileUploader>('dxos.org/app-framework/capability/file-uploader');
91
+ }
@@ -0,0 +1,72 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities } from './capabilities';
6
+ import { defineEvent } from '../core';
7
+
8
+ export namespace Events {
9
+ /**
10
+ * Fired when the app is started.
11
+ */
12
+ export const Startup = defineEvent('dxos.org/app-framework/event/startup');
13
+
14
+ //
15
+ // Dependent Events
16
+ //
17
+
18
+ /**
19
+ * Fired to load any newly available surfaces.
20
+ */
21
+ export const SetupSurfaces = defineEvent('dxos.org/app-framework/event/setup-surfaces');
22
+
23
+ /**
24
+ * Fired to load any newly available metadata.
25
+ */
26
+ export const SetupMetadata = defineEvent('dxos.org/app-framework/event/setup-metadata');
27
+
28
+ /**
29
+ * Fired before the intent dispatcher is activated.
30
+ */
31
+ export const SetupIntents = defineEvent('dxos.org/app-framework/event/setup-intents');
32
+
33
+ /**
34
+ * Fired before the settings store is activated.
35
+ */
36
+ export const SetupSettings = defineEvent('dxos.org/app-framework/event/setup-settings');
37
+
38
+ /**
39
+ * Fired before the graph is created.
40
+ */
41
+ export const SetupAppGraph = defineEvent('dxos.org/app-framework/event/setup-graph');
42
+
43
+ /**
44
+ * Fired before the translations provider is created.
45
+ */
46
+ export const SetupTranslations = defineEvent('dxos.org/app-framework/event/setup-translations');
47
+
48
+ //
49
+ // Triggered Events
50
+ //
51
+
52
+ /**
53
+ * Fired after the intent dispatcher is ready.
54
+ */
55
+ export const DispatcherReady = defineEvent('dxos.org/app-framework/event/dispatcher-ready');
56
+
57
+ /**
58
+ * Fired after the settings store is ready.
59
+ */
60
+ export const SettingsReady = defineEvent('dxos.org/app-framework/event/settings-ready');
61
+
62
+ /**
63
+ * Fired when the graph is ready.
64
+ */
65
+ export const AppGraphReady = defineEvent('dxos.org/app-framework/event/graph-ready');
66
+
67
+ /**
68
+ * Fired when plugin state is ready.
69
+ */
70
+ export const createStateEvent = (specifier: string) => defineEvent('dxos.org/app-framework/event/state', specifier);
71
+ export const LayoutReady = createStateEvent(Capabilities.Layout.identifier);
72
+ }
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { Schema as S } from '@effect/schema';
6
+
7
+ // TODO(burdon): See Accept attribute (uses MIME types).
8
+ // E.g., 'image/*': ['.jpg', '.jpeg', '.png', '.gif'],
9
+ export const defaultFileTypes = {
10
+ images: ['png', 'jpg', 'jpeg', 'gif'],
11
+ media: ['mp3', 'mp4', 'mov', 'avi'],
12
+ text: ['pdf', 'txt', 'md'],
13
+ };
14
+
15
+ export const FileInfoSchema = S.Struct({
16
+ name: S.String,
17
+ type: S.String,
18
+ url: S.optional(S.String),
19
+ cid: S.optional(S.String), // TODO(burdon): Meta key? Or other common properties with other file management system? (e.g., WNFS).
20
+ });
21
+
22
+ export type FileInfo = S.Schema.Type<typeof FileInfoSchema>;
@@ -0,0 +1,30 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import type { Node } from '@dxos/app-graph';
6
+ import { type MaybePromise, type Position } from '@dxos/util';
7
+
8
+ // TODO(wittjosiah): Factor out.
9
+ export type SerializedNode = {
10
+ name: string;
11
+ data: string;
12
+ type?: string;
13
+ };
14
+
15
+ // TODO(wittjosiah): Factor out.
16
+ export type NodeSerializer<T = any> = {
17
+ inputType: string;
18
+ outputType: string;
19
+ position?: Position;
20
+
21
+ /**
22
+ * Takes a node and serializes it into a format that can be stored.
23
+ */
24
+ serialize: (node: Node<T>) => MaybePromise<SerializedNode>;
25
+
26
+ /**
27
+ * Takes a serialized node and deserializes it into the application.
28
+ */
29
+ deserialize: (data: SerializedNode, ancestors: unknown[]) => MaybePromise<T>;
30
+ };
@@ -2,9 +2,10 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
+ export * from './capabilities';
6
+ export * from './events';
5
7
  export * from './file';
6
8
  export * from './graph';
7
9
  export * from './layout';
8
- export * from './metadata';
9
- export * from './navigation';
10
+ export * from './surface';
10
11
  export * from './translations';
@@ -0,0 +1,225 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { Schema as S } from '@effect/schema';
6
+
7
+ import { Label } from '../plugin-intent';
8
+
9
+ export const LAYOUT_PLUGIN = 'dxos.org/plugin/layout';
10
+ export const LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
11
+
12
+ /**
13
+ * Expected payload for layout actions.
14
+ */
15
+ export namespace LayoutAction {
16
+ export const UPDATE_LAYOUT = `${LAYOUT_ACTION}/update-layout`;
17
+
18
+ /**
19
+ * Generic layout action.
20
+ */
21
+ export class UpdateLayout extends S.TaggedClass<UpdateLayout>()(UPDATE_LAYOUT, {
22
+ input: S.Struct({
23
+ part: S.String.annotations({ description: 'The part of the layout to mutate.' }),
24
+ subject: S.optional(S.Any.annotations({ description: 'The subject of the layout update.' })),
25
+ options: S.optional(
26
+ S.Record({ key: S.String, value: S.Any }).annotations({
27
+ description: 'Additional options for the layout action.',
28
+ }),
29
+ ),
30
+ }),
31
+ output: S.Void,
32
+ }) {}
33
+
34
+ //
35
+ // Common layout actions.
36
+ //
37
+
38
+ // NOTE: These are layout actions which are currently in common use.
39
+ // They constrain the generic layout action types to provide additional type safety.
40
+ // However, they all follow the same generic structure and intent id.
41
+ // This allows for plugins to update the layout without depending on a specific layout plugin.
42
+ // The expectation is that other norms other than these will emerge over time.
43
+
44
+ export class SetLayoutMode extends S.TaggedClass<SetLayoutMode>()(UPDATE_LAYOUT, {
45
+ input: S.Struct({
46
+ part: S.Literal('mode').annotations({ description: 'Setting the layout mode.' }),
47
+ subject: S.optional(S.String.annotations({ description: 'Item which is the subject of the new layout mode.' })),
48
+ options: S.Union(
49
+ S.Struct({ mode: S.String.annotations({ description: 'The new layout mode.' }) }),
50
+ S.Struct({ revert: S.Boolean.annotations({ description: 'Revert to the previous layout mode.' }) }),
51
+ ),
52
+ }),
53
+ output: S.Void,
54
+ }) {}
55
+
56
+ export class UpdateSidebar extends S.TaggedClass<UpdateSidebar>()(UPDATE_LAYOUT, {
57
+ input: S.Struct({
58
+ part: S.Literal('sidebar').annotations({ description: 'Updating the sidebar.' }),
59
+ subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the sidebar.' })),
60
+ options: S.optional(
61
+ S.Struct({
62
+ state: S.Literal('closed', 'collapsed', 'expanded').annotations({
63
+ description: 'Whether the sidebar is closed, collapsed, or expanded.',
64
+ }),
65
+ }),
66
+ ),
67
+ }),
68
+ output: S.Void,
69
+ }) {}
70
+
71
+ export class UpdateComplementary extends S.TaggedClass<UpdateComplementary>()(UPDATE_LAYOUT, {
72
+ input: S.Struct({
73
+ part: S.Literal('complementary').annotations({ description: 'Updating the complementary sidebar.' }),
74
+ subject: S.optional(
75
+ S.String.annotations({ description: 'URI of the component to display in the complementary area.' }),
76
+ ),
77
+ options: S.optional(
78
+ S.Struct({
79
+ state: S.Literal('closed', 'collapsed', 'expanded').annotations({
80
+ description: 'Whether the complementary sidebar is closed, collapsed, or expanded.',
81
+ }),
82
+ }),
83
+ ),
84
+ }),
85
+ output: S.Void,
86
+ }) {}
87
+
88
+ export class UpdateDialog extends S.TaggedClass<UpdateDialog>()(UPDATE_LAYOUT, {
89
+ input: S.Struct({
90
+ part: S.Literal('dialog').annotations({ description: 'Updating the dialog.' }),
91
+ subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the dialog.' })),
92
+ options: S.Struct({
93
+ state: S.optional(S.Boolean.annotations({ description: 'Whether the dialog is open or closed.' })),
94
+ blockAlign: S.optional(
95
+ S.Literal('start', 'center').annotations({ description: 'The alignment of the dialog.' }),
96
+ ),
97
+ type: S.optional(S.Literal('default', 'alert').annotations({ description: 'The type of dialog.' })),
98
+ props: S.optional(
99
+ S.Record({ key: S.String, value: S.Any }).annotations({
100
+ description: 'Additional props for the dialog.',
101
+ }),
102
+ ),
103
+ }),
104
+ }),
105
+ output: S.Void,
106
+ }) {}
107
+
108
+ export class UpdatePopover extends S.TaggedClass<UpdatePopover>()(UPDATE_LAYOUT, {
109
+ input: S.Struct({
110
+ part: S.Literal('popover').annotations({ description: 'Updating the popover.' }),
111
+ subject: S.optional(S.String.annotations({ description: 'URI of the component to display in the popover.' })),
112
+ options: S.Struct({
113
+ anchorId: S.String.annotations({ description: 'The id of the element to anchor the popover to.' }),
114
+ state: S.optional(S.Boolean.annotations({ description: 'Whether the popover is open or closed.' })),
115
+ props: S.optional(
116
+ S.Record({ key: S.String, value: S.Any }).annotations({
117
+ description: 'Additional props for the popover.',
118
+ }),
119
+ ),
120
+ }),
121
+ }),
122
+ output: S.Void,
123
+ }) {}
124
+
125
+ export const Toast = S.Struct({
126
+ id: S.String.annotations({ description: 'The id of the toast.' }),
127
+ title: S.optional(Label.annotations({ description: 'The title of the toast.' })),
128
+ description: S.optional(Label.annotations({ description: 'The description of the toast.' })),
129
+ icon: S.optional(S.String.annotations({ description: 'The icon of the toast.' })),
130
+ duration: S.optional(S.Number.annotations({ description: 'The duration of the toast.' })),
131
+ closeLabel: S.optional(Label.annotations({ description: 'The label of the close button.' })),
132
+ actionLabel: S.optional(Label.annotations({ description: 'The label of the action button.' })),
133
+ actionAlt: S.optional(Label.annotations({ description: 'The alt text of the action button.' })),
134
+ onAction: S.optional(
135
+ S.Any.annotations({ description: 'The action to perform when the action button is clicked.' }),
136
+ ),
137
+ });
138
+
139
+ export interface Toast extends Omit<S.Schema.Type<typeof Toast>, 'onAction'> {
140
+ onAction?: () => void;
141
+ }
142
+
143
+ export class AddToast extends S.TaggedClass<AddToast>()(UPDATE_LAYOUT, {
144
+ input: S.Struct({
145
+ part: S.Literal('toast').annotations({ description: 'Adding a toast.' }),
146
+ subject: Toast.annotations({ description: 'The toast to add.' }),
147
+ }),
148
+ output: S.Void,
149
+ }) {}
150
+
151
+ export class SwitchWorkspace extends S.TaggedClass<SwitchWorkspace>()(UPDATE_LAYOUT, {
152
+ input: S.Struct({
153
+ part: S.Literal('workspace').annotations({ description: 'Switching the workspace.' }),
154
+ subject: S.String.annotations({ description: 'The id of the workspace to switch to.' }),
155
+ }),
156
+ output: S.Void,
157
+ }) {}
158
+
159
+ export class Open extends S.TaggedClass<Open>()(UPDATE_LAYOUT, {
160
+ input: S.Struct({
161
+ part: S.Literal('main').annotations({ description: 'Opening an item in the main content area.' }),
162
+ subject: S.Array(S.String.annotations({ description: 'Ids of the items to open.' })),
163
+ options: S.optional(
164
+ S.Struct({
165
+ state: S.optional(S.Literal(true).annotations({ description: 'The items are being added.' })),
166
+ key: S.optional(
167
+ S.String.annotations({ description: 'If provided, will replace item with a matching key (id prefix).' }),
168
+ ),
169
+ scrollIntoView: S.optional(S.Boolean.annotations({ description: 'Scroll the items into view.' })),
170
+ pivotId: S.optional(S.String.annotations({ description: 'The id of the item to place new items next to.' })),
171
+ positioning: S.optional(
172
+ S.Union(
173
+ S.Literal('start').annotations({ description: 'The items are being added before the pivot item.' }),
174
+ S.Literal('end').annotations({ description: 'The items are being added after the pivot item.' }),
175
+ ),
176
+ ),
177
+ }),
178
+ ),
179
+ }),
180
+ output: S.Void,
181
+ }) {}
182
+
183
+ export class Set extends S.TaggedClass<Set>()(UPDATE_LAYOUT, {
184
+ input: S.Struct({
185
+ part: S.Literal('main').annotations({ description: 'Setting items in the main content area.' }),
186
+ subject: S.Array(S.String.annotations({ description: 'Ids of the items to set.' })),
187
+ options: S.Struct({
188
+ override: S.Literal(true).annotations({ description: 'Override the current items in the main content area.' }),
189
+ }),
190
+ }),
191
+ output: S.Void,
192
+ }) {}
193
+
194
+ export class Close extends S.TaggedClass<Close>()(UPDATE_LAYOUT, {
195
+ input: S.Struct({
196
+ part: S.Literal('main').annotations({ description: 'Closing items in the main content area.' }),
197
+ subject: S.Array(S.String.annotations({ description: 'Ids of the items to close.' })),
198
+ options: S.Struct({
199
+ state: S.Literal(false).annotations({ description: 'The items are being removed.' }),
200
+ }),
201
+ }),
202
+ output: S.Void,
203
+ }) {}
204
+
205
+ export class ScrollIntoView extends S.TaggedClass<ScrollIntoView>()(UPDATE_LAYOUT, {
206
+ input: S.Struct({
207
+ part: S.Literal('current').annotations({ description: 'Setting the current item' }),
208
+ subject: S.optional(S.String.annotations({ description: 'The id of the item to set as current.' })),
209
+ options: S.optional(
210
+ S.Record({ key: S.String, value: S.Any }).annotations({
211
+ description: 'Additional options for the scroll into view.',
212
+ }),
213
+ ),
214
+ }),
215
+ output: S.Void,
216
+ }) {}
217
+
218
+ export class Expose extends S.TaggedClass<Expose>()(UPDATE_LAYOUT, {
219
+ input: S.Struct({
220
+ part: S.Literal('navigation').annotations({ description: 'Exposing an item in the navigation area.' }),
221
+ subject: S.String.annotations({ description: 'The id of the item to expose.' }),
222
+ }),
223
+ output: S.Void,
224
+ }) {}
225
+ }