@dxos/app-framework 0.7.4 → 0.7.5-feature-compute.4d9d99a

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 (327) hide show
  1. package/dist/lib/browser/chunk-EGGZVV7Q.mjs +1595 -0
  2. package/dist/lib/browser/chunk-EGGZVV7Q.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +136 -527
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +67 -0
  7. package/dist/lib/browser/testing/index.mjs.map +7 -0
  8. package/dist/lib/node/chunk-UBX6GP2N.cjs +1639 -0
  9. package/dist/lib/node/chunk-UBX6GP2N.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +141 -551
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +91 -0
  14. package/dist/lib/node/testing/index.cjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-HG5P55WF.mjs +1597 -0
  16. package/dist/lib/node-esm/chunk-HG5P55WF.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +136 -527
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +68 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/App.d.ts +22 -13
  23. package/dist/types/src/App.d.ts.map +1 -1
  24. package/dist/types/src/common/capabilities.d.ts +340 -0
  25. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  26. package/dist/types/src/common/events.d.ts +41 -0
  27. package/dist/types/src/common/events.d.ts.map +1 -0
  28. package/dist/types/src/common/file.d.ts +14 -0
  29. package/dist/types/src/common/file.d.ts.map +1 -0
  30. package/dist/types/src/common/graph.d.ts +21 -0
  31. package/dist/types/src/common/graph.d.ts.map +1 -0
  32. package/dist/types/src/{plugins/common → common}/index.d.ts +3 -1
  33. package/dist/types/src/common/index.d.ts.map +1 -0
  34. package/dist/types/src/common/layout.d.ts +165 -0
  35. package/dist/types/src/common/layout.d.ts.map +1 -0
  36. package/dist/types/src/{plugins/common → common}/navigation.d.ts +77 -32
  37. package/dist/types/src/common/navigation.d.ts.map +1 -0
  38. package/dist/types/src/common/surface.d.ts +68 -0
  39. package/dist/types/src/common/surface.d.ts.map +1 -0
  40. package/dist/types/src/{plugins/common → common}/translations.d.ts +0 -11
  41. package/dist/types/src/common/translations.d.ts.map +1 -0
  42. package/dist/types/src/core/capabilities.d.ts +90 -0
  43. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  44. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  45. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  46. package/dist/types/src/core/events.d.ts +58 -0
  47. package/dist/types/src/core/events.d.ts.map +1 -0
  48. package/dist/types/src/core/index.d.ts +5 -0
  49. package/dist/types/src/core/index.d.ts.map +1 -0
  50. package/dist/types/src/core/manager.d.ts +126 -0
  51. package/dist/types/src/core/manager.d.ts.map +1 -0
  52. package/dist/types/src/core/manager.test.d.ts +2 -0
  53. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  54. package/dist/types/src/core/plugin.d.ts +94 -0
  55. package/dist/types/src/core/plugin.d.ts.map +1 -0
  56. package/dist/types/src/helpers.d.ts +10 -0
  57. package/dist/types/src/helpers.d.ts.map +1 -0
  58. package/dist/types/src/helpers.test.d.ts +2 -0
  59. package/dist/types/src/helpers.test.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +5 -1
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/playground/debug/Debug.d.ts +6 -0
  63. package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
  64. package/dist/types/src/playground/debug/index.d.ts +2 -0
  65. package/dist/types/src/playground/debug/index.d.ts.map +1 -0
  66. package/dist/types/src/playground/debug/plugin.d.ts +2 -0
  67. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
  68. package/dist/types/src/playground/generator/Main.d.ts +6 -0
  69. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  70. package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
  71. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
  72. package/dist/types/src/playground/generator/generator.d.ts +5 -0
  73. package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
  74. package/dist/types/src/playground/generator/index.d.ts +3 -0
  75. package/dist/types/src/playground/generator/index.d.ts.map +1 -0
  76. package/dist/types/src/playground/generator/plugin.d.ts +2 -0
  77. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
  78. package/dist/types/src/playground/layout/Layout.d.ts +8 -0
  79. package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
  80. package/dist/types/src/playground/layout/index.d.ts +2 -0
  81. package/dist/types/src/playground/layout/index.d.ts.map +1 -0
  82. package/dist/types/src/playground/layout/plugin.d.ts +2 -0
  83. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
  84. package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
  85. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
  86. package/dist/types/src/playground/logger/index.d.ts +2 -0
  87. package/dist/types/src/playground/logger/index.d.ts.map +1 -0
  88. package/dist/types/src/playground/logger/plugin.d.ts +2 -0
  89. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
  90. package/dist/types/src/playground/logger/schema.d.ts +13 -0
  91. package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
  92. package/dist/types/src/playground/playground.stories.d.ts +10 -0
  93. package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
  94. package/dist/types/src/plugin-intent/IntentContext.d.ts +8 -0
  95. package/dist/types/src/plugin-intent/IntentContext.d.ts.map +1 -0
  96. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
  97. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
  98. package/dist/types/src/plugin-intent/actions.d.ts +23 -0
  99. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
  100. package/dist/types/src/plugin-intent/errors.d.ts +16 -0
  101. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
  102. package/dist/types/src/plugin-intent/index.d.ts +6 -0
  103. package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
  104. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +106 -0
  105. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
  106. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
  107. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
  108. package/dist/types/src/plugin-intent/intent.d.ts +68 -0
  109. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  110. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  111. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  112. package/dist/types/src/plugin-settings/actions.d.ts +17 -0
  113. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  114. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  115. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  116. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  117. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  118. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  119. package/dist/types/src/react/Surface.d.ts +12 -0
  120. package/dist/types/src/react/Surface.d.ts.map +1 -0
  121. package/dist/types/src/react/index.d.ts +5 -0
  122. package/dist/types/src/react/index.d.ts.map +1 -0
  123. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  124. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  125. package/dist/types/src/testing/index.d.ts +2 -0
  126. package/dist/types/src/testing/index.d.ts.map +1 -0
  127. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  128. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  129. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  130. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  131. package/dist/types/tsconfig.tsbuildinfo +1 -0
  132. package/package.json +30 -14
  133. package/project.json +2 -1
  134. package/src/App.tsx +138 -34
  135. package/src/common/capabilities.ts +82 -0
  136. package/src/common/events.ts +63 -0
  137. package/src/common/file.ts +22 -0
  138. package/src/common/graph.ts +30 -0
  139. package/src/{plugins/common → common}/index.ts +3 -1
  140. package/src/common/layout.ts +157 -0
  141. package/src/{plugins/common → common}/navigation.ts +59 -45
  142. package/src/common/surface.ts +81 -0
  143. package/src/common/translations.ts +18 -0
  144. package/src/core/capabilities.test.ts +116 -0
  145. package/src/core/capabilities.ts +213 -0
  146. package/src/core/events.ts +58 -0
  147. package/src/core/index.ts +8 -0
  148. package/src/core/manager.test.ts +567 -0
  149. package/src/core/manager.ts +497 -0
  150. package/src/core/plugin.ts +128 -0
  151. package/src/helpers.test.ts +97 -0
  152. package/src/helpers.ts +45 -0
  153. package/src/index.ts +6 -3
  154. package/src/playground/debug/Debug.tsx +39 -0
  155. package/src/playground/debug/index.ts +5 -0
  156. package/src/playground/debug/plugin.ts +17 -0
  157. package/src/playground/generator/Main.tsx +71 -0
  158. package/src/playground/generator/Toolbar.tsx +46 -0
  159. package/src/playground/generator/generator.ts +23 -0
  160. package/src/playground/generator/index.ts +6 -0
  161. package/src/playground/generator/plugin.ts +18 -0
  162. package/src/playground/layout/Layout.tsx +33 -0
  163. package/src/playground/layout/index.ts +5 -0
  164. package/src/playground/layout/plugin.ts +17 -0
  165. package/src/playground/logger/Toolbar.tsx +28 -0
  166. package/src/playground/logger/index.ts +5 -0
  167. package/src/playground/logger/plugin.ts +33 -0
  168. package/src/playground/logger/schema.ts +12 -0
  169. package/src/playground/playground.stories.tsx +34 -0
  170. package/src/plugin-intent/IntentContext.tsx +34 -0
  171. package/src/plugin-intent/IntentPlugin.tsx +60 -0
  172. package/src/plugin-intent/actions.ts +22 -0
  173. package/src/plugin-intent/errors.ts +39 -0
  174. package/src/plugin-intent/index.ts +9 -0
  175. package/src/plugin-intent/intent-dispatcher.test.ts +280 -0
  176. package/src/plugin-intent/intent-dispatcher.ts +269 -0
  177. package/src/plugin-intent/intent.ts +146 -0
  178. package/src/plugin-settings/SettingsPlugin.ts +29 -0
  179. package/src/plugin-settings/actions.ts +17 -0
  180. package/src/plugin-settings/index.ts +6 -0
  181. package/src/react/PluginManagerProvider.ts +22 -0
  182. package/src/react/Surface.tsx +72 -0
  183. package/src/react/index.ts +8 -0
  184. package/src/react/useCapabilities.ts +40 -0
  185. package/src/testing/index.ts +5 -0
  186. package/src/testing/withPluginManager.stories.tsx +47 -0
  187. package/src/testing/withPluginManager.tsx +67 -0
  188. package/tsconfig.json +51 -2
  189. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  190. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
  192. package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
  193. package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
  194. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
  195. package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
  196. package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
  197. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
  198. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs.map +0 -7
  199. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
  200. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +0 -7
  201. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
  202. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs.map +0 -7
  203. package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
  204. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
  205. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  206. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  207. package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
  208. package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
  209. package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
  210. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
  211. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
  212. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
  213. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +0 -32
  214. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
  215. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
  216. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
  217. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
  218. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
  219. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  220. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  221. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
  222. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
  224. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
  225. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
  226. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs.map +0 -7
  227. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
  228. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
  229. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
  230. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
  231. package/dist/types/src/plugins/common/file.d.ts +0 -22
  232. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  233. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  234. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  235. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  236. package/dist/types/src/plugins/common/layout.d.ts +0 -202
  237. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  238. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  239. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  240. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  241. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  242. package/dist/types/src/plugins/helpers.d.ts +0 -41
  243. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  244. package/dist/types/src/plugins/index.d.ts +0 -7
  245. package/dist/types/src/plugins/index.d.ts.map +0 -1
  246. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
  247. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  248. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  249. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  250. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  251. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  252. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
  253. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  254. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
  255. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  256. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  257. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  258. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
  259. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  260. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  261. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  262. package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
  263. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
  264. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
  265. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  266. package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
  267. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  268. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
  269. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  270. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
  271. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  272. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  273. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  274. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  275. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  276. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  277. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  278. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
  279. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  280. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  281. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
  282. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  283. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  284. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  285. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
  286. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
  287. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  288. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  289. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  290. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  291. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  292. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  293. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
  294. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  295. package/src/plugins/common/file.ts +0 -36
  296. package/src/plugins/common/graph.ts +0 -70
  297. package/src/plugins/common/layout.ts +0 -155
  298. package/src/plugins/common/metadata.ts +0 -29
  299. package/src/plugins/common/translations.ts +0 -36
  300. package/src/plugins/helpers.ts +0 -92
  301. package/src/plugins/index.ts +0 -11
  302. package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
  303. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  304. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  305. package/src/plugins/plugin-host/index.ts +0 -8
  306. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  307. package/src/plugins/plugin-host/plugin.ts +0 -126
  308. package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
  309. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
  310. package/src/plugins/plugin-intent/helpers.ts +0 -11
  311. package/src/plugins/plugin-intent/index.ts +0 -12
  312. package/src/plugins/plugin-intent/intent.ts +0 -101
  313. package/src/plugins/plugin-intent/meta.ts +0 -9
  314. package/src/plugins/plugin-intent/provides.ts +0 -38
  315. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  316. package/src/plugins/plugin-settings/index.ts +0 -9
  317. package/src/plugins/plugin-settings/meta.ts +0 -9
  318. package/src/plugins/plugin-settings/provides.ts +0 -29
  319. package/src/plugins/plugin-surface/Surface.tsx +0 -195
  320. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
  321. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
  322. package/src/plugins/plugin-surface/helpers.ts +0 -22
  323. package/src/plugins/plugin-surface/index.ts +0 -14
  324. package/src/plugins/plugin-surface/meta.ts +0 -9
  325. package/src/plugins/plugin-surface/provides.ts +0 -26
  326. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  327. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -0,0 +1,157 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { S } from '@dxos/echo-schema';
6
+
7
+ import { Label } from '../plugin-intent';
8
+
9
+ //
10
+ // Provides
11
+ //
12
+
13
+ export const Toast = S.Struct({
14
+ id: S.String,
15
+ title: S.optional(Label),
16
+ description: S.optional(Label),
17
+ icon: S.optional(S.String),
18
+ duration: S.optional(S.Number),
19
+ closeLabel: S.optional(Label),
20
+ actionLabel: S.optional(Label),
21
+ actionAlt: S.optional(Label),
22
+ // TODO(wittjosiah): Make class with customizable method?
23
+ onAction: S.optional(S.Any),
24
+ });
25
+
26
+ export type Toast = S.Schema.Type<typeof Toast>;
27
+
28
+ /**
29
+ * Basic state provided by a layout plugin.
30
+ *
31
+ * Layout provides the state of global UI landmarks, such as the sidebar, dialog, and popover.
32
+ * Generally only one dialog or popover should be open at a time, a layout plugin should manage this.
33
+ * For other landmarks, such as toasts, rendering them in the layout prevents them from unmounting when navigating.
34
+ */
35
+
36
+ const LayoutMode = S.Union(S.Literal('deck'), S.Literal('solo'), S.Literal('fullscreen'));
37
+ export const isLayoutMode = (value: any): value is LayoutMode => S.is(LayoutMode)(value);
38
+ export type LayoutMode = S.Schema.Type<typeof LayoutMode>;
39
+
40
+ export const Layout = S.mutable(
41
+ S.Struct({
42
+ layoutMode: LayoutMode,
43
+
44
+ sidebarOpen: S.Boolean,
45
+ complementarySidebarOpen: S.Boolean,
46
+ /**
47
+ * @deprecated Data to be passed to the complementary sidebar Surface.
48
+ */
49
+ complementarySidebarContent: S.optional(S.Any),
50
+
51
+ dialogOpen: S.Boolean,
52
+ /**
53
+ * Data to be passed to the dialog Surface.
54
+ */
55
+ dialogContent: S.optional(S.Any),
56
+ // TODO(wittjosiah): Custom properties?
57
+ dialogBlockAlign: S.optional(S.Literal('start', 'center')),
58
+ dialogType: S.optional(S.Literal('default', 'alert')),
59
+
60
+ popoverOpen: S.Boolean,
61
+ /**
62
+ * Data to be passed to the popover Surface.
63
+ */
64
+ popoverContent: S.optional(S.Any),
65
+ popoverAnchorId: S.optional(S.String),
66
+
67
+ toasts: S.mutable(S.Array(Toast)),
68
+
69
+ /**
70
+ * The identifier of a component to scroll into view when it is mounted.
71
+ */
72
+ scrollIntoView: S.optional(S.String),
73
+ }),
74
+ );
75
+
76
+ export type Layout = S.Schema.Type<typeof Layout>;
77
+
78
+ //
79
+ // Intents
80
+ //
81
+
82
+ export const LAYOUT_PLUGIN = 'dxos.org/plugin/layout';
83
+ export const LAYOUT_ACTION = `${LAYOUT_PLUGIN}/action`;
84
+
85
+ /**
86
+ * Expected payload for layout actions.
87
+ */
88
+ export namespace LayoutAction {
89
+ export class SetLayout extends S.TaggedClass<SetLayout>()(`${LAYOUT_ACTION}/set-layout`, {
90
+ input: S.Struct({
91
+ /**
92
+ * Element to set the state of.
93
+ */
94
+ element: S.Literal('fullscreen', 'sidebar', 'complementary', 'dialog', 'popover', 'toast'),
95
+
96
+ /**
97
+ * Whether the element is on or off.
98
+ *
99
+ * If omitted, the element's state will be toggled or set based on other provided data.
100
+ * For example, if `component` is provided, the state will be set to `true`.
101
+ */
102
+ state: S.optional(S.Boolean),
103
+
104
+ /**
105
+ * Component to render in the dialog or popover.
106
+ */
107
+ component: S.optional(S.String),
108
+
109
+ /**
110
+ * Data to be passed to the dialog or popover Surface.
111
+ */
112
+ subject: S.optional(S.Any),
113
+
114
+ /**
115
+ * Anchor ID for the popover.
116
+ */
117
+ anchorId: S.optional(S.String),
118
+
119
+ // TODO(wittjosiah): Custom properties?
120
+
121
+ /**
122
+ * Block alignment for the dialog.
123
+ */
124
+ dialogBlockAlign: S.optional(S.Literal('start', 'center')),
125
+
126
+ /**
127
+ * Type of dialog.
128
+ */
129
+ dialogType: S.optional(S.Literal('default', 'alert')),
130
+ }),
131
+ output: S.Void,
132
+ }) {}
133
+
134
+ // TODO(wittjosiah): Do all these need to be separate actions?
135
+
136
+ export class SetLayoutMode extends S.TaggedClass<SetLayoutMode>()(`${LAYOUT_ACTION}/set-layout-mode`, {
137
+ input: S.Union(
138
+ S.Struct({
139
+ layoutMode: LayoutMode,
140
+ }),
141
+ S.Struct({
142
+ revert: S.Literal(true),
143
+ }),
144
+ ),
145
+ output: S.Void,
146
+ }) {}
147
+
148
+ export class ScrollIntoView extends S.TaggedClass<ScrollIntoView>()(`${LAYOUT_ACTION}/scroll-into-view`, {
149
+ input: S.Struct({
150
+ id: S.optional(S.String),
151
+ // TODO(wittjosiah): Factor out to thread scroll into view action?
152
+ cursor: S.optional(S.String),
153
+ ref: S.optional(S.String),
154
+ }),
155
+ output: S.Void,
156
+ }) {}
157
+ }
@@ -3,13 +3,9 @@
3
3
  //
4
4
 
5
5
  import { Schema as S } from '@effect/schema';
6
- import { z } from 'zod';
7
6
 
8
7
  import { pick } from '@dxos/util';
9
8
 
10
- import { type Plugin } from '../plugin-host';
11
- import { type IntentData } from '../plugin-intent';
12
-
13
9
  // NOTE(thure): These are chosen from RFC 1738’s `safe` characters: http://www.faqs.org/rfcs/rfc1738.html
14
10
  export const SLUG_LIST_SEPARATOR = '+';
15
11
  export const SLUG_ENTRY_SEPARATOR = '_';
@@ -39,7 +35,14 @@ export type LayoutParts = S.Schema.Type<typeof LayoutPartsSchema>;
39
35
  const LayoutCoordinateSchema = S.mutable(S.Struct({ part: LayoutPartSchema, entryId: S.String }));
40
36
  export type LayoutCoordinate = S.Schema.Type<typeof LayoutCoordinateSchema>;
41
37
 
42
- const PartAdjustmentSchema = S.Union(S.Literal('increment-start'), S.Literal('increment-end'), S.Literal('solo'));
38
+ const PartAdjustmentSchema = S.Union(
39
+ S.Literal('increment-start'),
40
+ S.Literal('increment-end'),
41
+ S.Literal('pin-start'),
42
+ S.Literal('pin-end'),
43
+ S.Literal('close'),
44
+ S.Literal('solo'),
45
+ );
43
46
  export type PartAdjustment = S.Schema.Type<typeof PartAdjustmentSchema>;
44
47
 
45
48
  const LayoutAdjustmentSchema = S.mutable(
@@ -48,8 +51,8 @@ const LayoutAdjustmentSchema = S.mutable(
48
51
  export type LayoutAdjustment = S.Schema.Type<typeof LayoutAdjustmentSchema>;
49
52
 
50
53
  /** @deprecated */
51
- export const ActiveParts = z.record(z.string(), z.union([z.string(), z.array(z.string())]));
52
- export type ActiveParts = z.infer<typeof ActiveParts>;
54
+ export const ActiveParts = S.Record({ key: S.String, value: S.Union(S.String, S.mutable(S.Array(S.String))) });
55
+ export type ActiveParts = S.Schema.Type<typeof ActiveParts>;
53
56
 
54
57
  // TODO(burdon): Where should this go?
55
58
  export type LayoutContainerProps<T> = T & { role?: string; coordinate?: LayoutCoordinate };
@@ -79,19 +82,6 @@ export const isLayoutAdjustment = (value: unknown): value is LayoutAdjustment =>
79
82
  return S.is(LayoutAdjustmentSchema)(value);
80
83
  };
81
84
 
82
- export const parseNavigationPlugin = (plugin: Plugin): Plugin<LocationProvides> | undefined => {
83
- const location = (plugin.provides as any)?.location;
84
- if (!location) {
85
- return undefined;
86
- }
87
-
88
- if (S.is(LocationProvidesSchema)({ location })) {
89
- return plugin as Plugin<LocationProvides>;
90
- }
91
-
92
- return undefined;
93
- };
94
-
95
85
  /**
96
86
  * Utilities.
97
87
  */
@@ -135,51 +125,75 @@ export const partLength = (layout: LayoutParts | undefined, part: LayoutPart | u
135
125
  // Intents
136
126
  //
137
127
 
138
- const NAVIGATION_PLUGIN = 'dxos.org/plugin/navigation';
139
-
140
- const NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
141
-
142
- export enum NavigationAction {
143
- OPEN = `${NAVIGATION_ACTION}/open`,
144
- ADD_TO_ACTIVE = `${NAVIGATION_ACTION}/add-to-active`,
145
- SET = `${NAVIGATION_ACTION}/set`,
146
- ADJUST = `${NAVIGATION_ACTION}/adjust`,
147
- CLOSE = `${NAVIGATION_ACTION}/close`,
148
- EXPOSE = `${NAVIGATION_ACTION}/expose`,
149
- }
128
+ export const NAVIGATION_PLUGIN = 'dxos.org/plugin/navigation';
129
+ export const NAVIGATION_ACTION = `${NAVIGATION_PLUGIN}/action`;
150
130
 
151
131
  /**
152
132
  * Expected payload for navigation actions.
153
133
  */
134
+ // TODO(wittjosiah): These seem to be too deck-specific.
154
135
  export namespace NavigationAction {
155
136
  /**
156
137
  * An additive overlay to apply to `location.active` (i.e. the result is a union of previous active and the argument)
157
138
  */
158
- export type Open = IntentData<{ activeParts: ActiveParts }>;
139
+ export class Open extends S.TaggedClass<Open>()(`${NAVIGATION_ACTION}/open`, {
140
+ input: S.Struct({
141
+ activeParts: ActiveParts,
142
+ noToggle: S.optional(S.Boolean),
143
+ }),
144
+ output: S.Struct({
145
+ open: S.Array(S.String),
146
+ }),
147
+ }) {}
159
148
 
160
149
  /**
161
150
  * Payload for adding an item to the active items.
162
151
  */
163
- export type AddToActive = IntentData<{
164
- part: LayoutPart;
165
- id: string;
166
- scrollIntoView?: boolean;
167
- pivotId?: string;
168
- positioning?: 'start' | 'end';
169
- }>;
152
+ export class AddToActive extends S.TaggedClass<AddToActive>()(`${NAVIGATION_ACTION}/add-to-active`, {
153
+ input: S.Struct({
154
+ id: S.String,
155
+ part: LayoutPartSchema,
156
+ scrollIntoView: S.optional(S.Boolean),
157
+ pivotId: S.optional(S.String),
158
+ positioning: S.optional(S.Literal('start', 'end')),
159
+ }),
160
+ output: S.Void,
161
+ }) {}
170
162
 
171
163
  /**
172
- * A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
164
+ * The active parts to directly set, to be used when working with URLs or restoring a specific state.
173
165
  */
174
- export type Close = IntentData<{ activeParts: ActiveParts; noToggle?: boolean }>;
166
+ export class Set extends S.TaggedClass<Set>()(`${NAVIGATION_ACTION}/set`, {
167
+ input: S.Struct({
168
+ activeParts: ActiveParts,
169
+ }),
170
+ output: S.Void,
171
+ }) {}
175
172
 
176
173
  /**
177
- * The active parts to directly set, to be used when working with URLs or restoring a specific state.
174
+ * A subtractive overlay to apply to `location.active` (i.e. the result is a subtraction from the previous active of the argument)
178
175
  */
179
- export type Set = IntentData<{ activeParts: ActiveParts }>;
176
+ export class Close extends S.TaggedClass<Close>()(`${NAVIGATION_ACTION}/close`, {
177
+ input: S.Struct({
178
+ activeParts: ActiveParts,
179
+ noToggle: S.optional(S.Boolean),
180
+ }),
181
+ output: S.Void,
182
+ }) {}
180
183
 
181
184
  /**
182
185
  * An atomic transaction to apply to `location.active`, describing which element to (attempt to) move to which location.
183
186
  */
184
- export type Adjust = IntentData<LayoutAdjustment>;
187
+ export class Adjust extends S.TaggedClass<Adjust>()(`${NAVIGATION_ACTION}/adjust`, {
188
+ input: LayoutAdjustmentSchema,
189
+ output: S.Void,
190
+ }) {}
191
+
192
+ // TODO(wittjosiah): This action seems unrelated to the others.
193
+ export class Expose extends S.TaggedClass<Expose>()(`${NAVIGATION_ACTION}/expose`, {
194
+ input: S.Struct({
195
+ id: S.String,
196
+ }),
197
+ output: S.Void,
198
+ }) {}
185
199
  }
@@ -0,0 +1,81 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { type JSX, type ForwardedRef, type PropsWithChildren, type ReactNode } from 'react';
6
+
7
+ import { type GuardedType, type MakeOptional, type Disposition } from '@dxos/util';
8
+
9
+ import { type ErrorBoundary } from '../react';
10
+
11
+ /**
12
+ * SurfaceProps are the props that are passed to the Surface component.
13
+ */
14
+ export type SurfaceProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{
15
+ /**
16
+ * If specified, the Surface will be wrapped in an error boundary.
17
+ * The fallback component will be rendered if an error occurs.
18
+ */
19
+ fallback?: ErrorBoundary['props']['fallback'];
20
+
21
+ /**
22
+ * If specified, the Surface will be wrapped in a suspense boundary.
23
+ * The placeholder component will be rendered while the surface component is loading.
24
+ */
25
+ placeholder?: ReactNode;
26
+ }> &
27
+ MakeOptional<CoreSurfaceProps<T>, 'id' | 'data'> & {
28
+ /**
29
+ * Additional props to pass to the component.
30
+ * These props are not used by Surface itself but may be used by components which resolve the surface.
31
+ */
32
+ [key: string]: unknown;
33
+ };
34
+
35
+ // NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.
36
+ type CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> = {
37
+ /**
38
+ * ID for debugging.
39
+ */
40
+ id: string;
41
+
42
+ /**
43
+ * Role defines how the data should be rendered.
44
+ */
45
+ role: string;
46
+
47
+ /**
48
+ * The data to be rendered by the surface.
49
+ */
50
+ data: T;
51
+
52
+ /**
53
+ * If more than one component is resolved, the limit determines how many are rendered.
54
+ */
55
+ limit?: number | undefined;
56
+ };
57
+
58
+ type SurfaceComponentProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<
59
+ CoreSurfaceProps<T> & { [key: string]: unknown }
60
+ >;
61
+
62
+ /**
63
+ * React component used to render a surface once is has matched.
64
+ */
65
+ export type SurfaceComponent<T extends Record<string, any> = Record<string, unknown>> = (
66
+ props: SurfaceComponentProps<T>,
67
+ forwardedRef: ForwardedRef<HTMLElement>,
68
+ ) => JSX.Element | null;
69
+
70
+ /**
71
+ * Definition of when a SurfaceComponent should be rendered.
72
+ */
73
+ export type SurfaceDefinition<T extends Record<string, any> = any> = Readonly<{
74
+ id: string;
75
+ role: string | string[];
76
+ disposition?: Disposition;
77
+ filter?: (data: Record<string, unknown>) => data is T;
78
+ component: SurfaceComponent<GuardedType<SurfaceDefinition<T>['filter']>>;
79
+ }>;
80
+
81
+ export const createSurface = <T extends Record<string, any> = any>(definition: SurfaceDefinition<T>) => definition;
@@ -0,0 +1,18 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { z } from 'zod';
6
+
7
+ // TODO(burdon): Replace zod with effect.
8
+ export const ResourceKey = z.union([z.string(), z.record(z.any())]);
9
+ export type ResourceKey = z.infer<typeof ResourceKey>;
10
+
11
+ export const ResourceLanguage = z.record(ResourceKey);
12
+ export type ResourceLanguage = z.infer<typeof ResourceLanguage>;
13
+
14
+ /**
15
+ * A resource is a collection of translations for a language.
16
+ */
17
+ export const Resource = z.record(ResourceLanguage);
18
+ export type Resource = z.infer<typeof Resource>;
@@ -0,0 +1,116 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { describe, expect, it } from 'vitest';
6
+
7
+ import { updateCounter } from '@dxos/echo-schema/testing';
8
+ import { registerSignalsRuntime } from '@dxos/echo-signals';
9
+
10
+ import { defineCapability, PluginsContext } from './capabilities';
11
+
12
+ registerSignalsRuntime();
13
+
14
+ const defaultOptions = {
15
+ activate: () => Promise.resolve(false),
16
+ reset: () => Promise.resolve(false),
17
+ };
18
+
19
+ describe('PluginsContext', () => {
20
+ it('should return empty array if no capabilities are contributed', () => {
21
+ const context = new PluginsContext(defaultOptions);
22
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
23
+ expect(context.requestCapabilities(interfaceDef)).toEqual([]);
24
+ });
25
+
26
+ it('should be able to contribute and request capabilities', () => {
27
+ const context = new PluginsContext(defaultOptions);
28
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
29
+ const implementation = { example: 'identifier' };
30
+ context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
31
+ expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
32
+ });
33
+
34
+ it('should be able to remove capabilities', () => {
35
+ const context = new PluginsContext(defaultOptions);
36
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
37
+ const implementation = { example: 'identifier' };
38
+ context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
39
+ expect(context.requestCapabilities(interfaceDef)).toEqual([implementation]);
40
+ context.removeCapability(interfaceDef, implementation);
41
+ expect(context.requestCapabilities(interfaceDef)).toEqual([]);
42
+ });
43
+
44
+ it('should be able to contribute and request multiple implementations', () => {
45
+ const context = new PluginsContext(defaultOptions);
46
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
47
+ const implementation1 = { example: 'first' };
48
+ const implementation2 = { example: 'second' };
49
+ context.contributeCapability({ interface: interfaceDef, implementation: implementation1, module: 'test' });
50
+ context.contributeCapability({ interface: interfaceDef, implementation: implementation2, module: 'test' });
51
+ expect(context.requestCapabilities(interfaceDef)).toEqual([implementation1, implementation2]);
52
+ });
53
+
54
+ it('should be able to request multiple capabilities', () => {
55
+ const context = new PluginsContext(defaultOptions);
56
+ const interfaceDef1 = defineCapability<{ one: number }>('@dxos/app-framework/test/one');
57
+ const interfaceDef2 = defineCapability<{ two: number }>('@dxos/app-framework/test/two');
58
+ const implementation1 = { one: 1 };
59
+ const implementation2 = { two: 2 };
60
+ context.contributeCapability({ interface: interfaceDef1, implementation: implementation1, module: 'test' });
61
+ context.contributeCapability({ interface: interfaceDef2, implementation: implementation2, module: 'test' });
62
+ expect(context.requestCapabilities(interfaceDef1)).toEqual([implementation1]);
63
+ expect(context.requestCapabilities(interfaceDef2)).toEqual([implementation2]);
64
+ });
65
+
66
+ it('should be reactive', () => {
67
+ const context = new PluginsContext(defaultOptions);
68
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
69
+
70
+ using updates = updateCounter(() => {
71
+ context.requestCapabilities(interfaceDef);
72
+ });
73
+
74
+ expect(updates.count).toEqual(0);
75
+
76
+ const implementation = { example: 'identifier' };
77
+ context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
78
+ expect(updates.count).toEqual(1);
79
+
80
+ context.removeCapability(interfaceDef, implementation);
81
+ expect(updates.count).toEqual(2);
82
+ });
83
+
84
+ it('should not be reactive to changes within the implementation', () => {
85
+ const context = new PluginsContext(defaultOptions);
86
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
87
+
88
+ using updates = updateCounter(() => {
89
+ context.requestCapabilities(interfaceDef);
90
+ });
91
+
92
+ expect(updates.count).toEqual(0);
93
+
94
+ const implementation = { example: 'identifier' };
95
+ context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
96
+ expect(updates.count).toEqual(1);
97
+
98
+ implementation.example = 'updated';
99
+ expect(updates.count).toEqual(1);
100
+
101
+ const capabilities = context.requestCapabilities(interfaceDef);
102
+ expect(capabilities).toEqual([implementation]);
103
+ expect(capabilities[0].example).toEqual('updated');
104
+ expect(updates.count).toEqual(1);
105
+ });
106
+
107
+ it('should be able to wait for a capability', async () => {
108
+ const context = new PluginsContext(defaultOptions);
109
+ const interfaceDef = defineCapability<{ example: string }>('@dxos/app-framework/test/example');
110
+ const implementation = { example: 'identifier' };
111
+ const promise = context.waitForCapability(interfaceDef);
112
+ context.contributeCapability({ interface: interfaceDef, implementation, module: 'test' });
113
+ const capability = await promise;
114
+ expect(capability).toEqual(implementation);
115
+ });
116
+ });