@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
@@ -1,195 +0,0 @@
1
- //
2
- // Copyright 2022 DXOS.org
3
- //
4
-
5
- import React, {
6
- Fragment,
7
- type ForwardedRef,
8
- type PropsWithChildren,
9
- type ReactNode,
10
- Suspense,
11
- createContext,
12
- forwardRef,
13
- isValidElement,
14
- memo,
15
- useContext,
16
- useEffect,
17
- useState,
18
- } from 'react';
19
-
20
- import { raise } from '@dxos/debug';
21
- import { log } from '@dxos/log';
22
-
23
- import { ErrorBoundary } from './ErrorBoundary';
24
- import { type SurfaceComponent, type SurfaceResult, useSurfaceRoot } from './SurfaceRootContext';
25
-
26
- /**
27
- * Direction determines how multiple components are laid out.
28
- */
29
- export type Direction = 'inline' | 'inline-reverse' | 'block' | 'block-reverse';
30
-
31
- /**
32
- * SurfaceProps are the props that are passed to the Surface component.
33
- */
34
- export type SurfaceProps = PropsWithChildren<{
35
- /**
36
- * Optional ID for debugging.
37
- */
38
- id?: string;
39
-
40
- /**
41
- * Role defines how the data should be rendered.
42
- */
43
- role?: string;
44
-
45
- /**
46
- * Names allow nested surfaces to be specified in the parent context, similar to a slot.
47
- * Defaults to the value of `role` if not specified.
48
- */
49
- name?: string;
50
-
51
- /**
52
- * The data to be rendered by the surface.
53
- */
54
- data?: Record<string, unknown>;
55
-
56
- /**
57
- * Configure nested surfaces (indexed by the surface's `name`).
58
- */
59
- surfaces?: Record<string, Pick<SurfaceProps, 'data' | 'surfaces'>>;
60
-
61
- /**
62
- * If specified, the Surface will be wrapped in an error boundary.
63
- * The fallback component will be rendered if an error occurs.
64
- */
65
- fallback?: ErrorBoundary['props']['fallback'];
66
-
67
- /**
68
- * If specified, the Surface will be wrapped in a suspense boundary.
69
- * The placeholder component will be rendered while the surface component is loading.
70
- */
71
- placeholder?: ReactNode;
72
-
73
- /**
74
- * If more than one component is resolved, the limit determines how many are rendered.
75
- */
76
- limit?: number | undefined;
77
-
78
- /**
79
- * If more than one component is resolved, the direction determines how they are laid out.
80
- * NOTE: This is not yet implemented.
81
- */
82
- direction?: Direction;
83
-
84
- /**
85
- * Additional props to pass to the component.
86
- * These props are not used by Surface itself but may be used by components which resolve the surface.
87
- */
88
- [key: string]: unknown;
89
- }>;
90
-
91
- let count = 0;
92
-
93
- /**
94
- * A surface is a named region of the screen that can be populated by plugins.
95
- */
96
- export const Surface = memo(
97
- forwardRef<HTMLElement, SurfaceProps>(
98
- ({ id: _id, role, name = role, fallback, placeholder, ...rest }, forwardedRef) => {
99
- const props = { role, name, fallback, ...rest };
100
- const { debugInfo } = useSurfaceRoot();
101
-
102
- // Track debug info.
103
- const [id] = useState<string>(() => _id ?? `surface-${++count}`);
104
- useEffect(() => {
105
- debugInfo?.set(id, { id, created: Date.now(), name, role, renderCount: 0 });
106
- return () => {
107
- debugInfo?.delete(id);
108
- };
109
- }, [id]);
110
-
111
- if (debugInfo?.get(id)) {
112
- debugInfo.get(id)!.renderCount++;
113
- }
114
-
115
- const context = useContext(SurfaceContext);
116
- const data = props.data ?? ((name && context?.surfaces?.[name]?.data) || {});
117
-
118
- const resolver = <SurfaceResolver {...props} id={id} ref={forwardedRef} />;
119
- const suspense = placeholder ? <Suspense fallback={placeholder}>{resolver}</Suspense> : resolver;
120
-
121
- return fallback ? (
122
- <ErrorBoundary data={data} fallback={fallback}>
123
- {suspense}
124
- </ErrorBoundary>
125
- ) : (
126
- suspense
127
- );
128
- },
129
- ),
130
- );
131
-
132
- const SurfaceContext = createContext<SurfaceProps | undefined>(undefined);
133
-
134
- export const useSurface = (): SurfaceProps =>
135
- useContext(SurfaceContext) ?? raise(new Error('Surface context not found'));
136
-
137
- /**
138
- * Root surface component.
139
- */
140
- const SurfaceResolver = forwardRef<HTMLElement, SurfaceProps>((props, forwardedRef) => {
141
- const { components } = useSurfaceRoot();
142
- const parent = useContext(SurfaceContext);
143
- const nodes = resolveNodes(components, props, parent, forwardedRef);
144
- const currentContext: SurfaceProps = {
145
- ...props,
146
- surfaces: {
147
- ...((props.name && parent?.surfaces?.[props.name]?.surfaces) || {}),
148
- ...props.surfaces,
149
- },
150
- };
151
-
152
- return <SurfaceContext.Provider value={currentContext}>{nodes}</SurfaceContext.Provider>;
153
- });
154
-
155
- /**
156
- * Resolve surface nodes from across all component.
157
- */
158
- const resolveNodes = (
159
- components: Record<string, SurfaceComponent>,
160
- props: SurfaceProps,
161
- context: SurfaceProps | undefined,
162
- forwardedRef: ForwardedRef<HTMLElement>,
163
- ): ReactNode[] => {
164
- const data = {
165
- ...((props.name && context?.surfaces?.[props.name]?.data) || {}),
166
- ...props.data,
167
- };
168
-
169
- const candidates = Object.entries(components)
170
- .map(([key, component]): [string, SurfaceResult] | undefined => {
171
- // TODO(burdon): Avoid variable return types in plugin contract.
172
- const result = component({ ...props, data }, forwardedRef);
173
- if (!result || typeof result !== 'object') {
174
- return undefined;
175
- }
176
-
177
- // Normalize tuple.
178
- if ('node' in result) {
179
- return [key, result];
180
- } else if (isValidElement(result)) {
181
- return [key, { node: result }];
182
- } else {
183
- log.warn('invalid result', { result });
184
- return undefined;
185
- }
186
- })
187
- .filter((result): result is [string, SurfaceResult] => Boolean(result))
188
- .sort(([, { disposition: a = 'default' }], [, { disposition: b = 'default' }]) => {
189
- return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;
190
- });
191
-
192
- // TODO(burdon): Does this prematurely process the node?
193
- const nodes = candidates.map(([key, result]) => <Fragment key={key}>{result.node}</Fragment>);
194
- return props.limit ? nodes.slice(0, props.limit) : nodes;
195
- };
@@ -1,33 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React from 'react';
6
-
7
- import { create } from '@dxos/live-object';
8
-
9
- import { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';
10
- import SurfaceMeta from './meta';
11
- import { parseSurfacePlugin, type SurfacePluginProvides } from './provides';
12
- import { filterPlugins } from '../helpers';
13
- import { type PluginDefinition } from '../plugin-host';
14
-
15
- /**
16
- * Provides a registry of surface components.
17
- */
18
- export const SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {
19
- const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });
20
-
21
- return {
22
- meta: SurfaceMeta,
23
- ready: async (plugins) => {
24
- state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
25
- return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };
26
- }, {});
27
- },
28
- provides: {
29
- surface: state,
30
- context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,
31
- },
32
- };
33
- };
@@ -1,60 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { createContext, useContext, type JSX, type ForwardedRef } from 'react';
6
-
7
- import { raise } from '@dxos/debug';
8
-
9
- import { type SurfaceProps } from './Surface';
10
-
11
- // TODO(wittjosiah): Factor out.
12
- type WithRequiredProperty<Type, Key extends keyof Type> = Type & {
13
- [Property in Key]-?: Type[Property];
14
- };
15
-
16
- type SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;
17
-
18
- /**
19
- * Determines the priority of the surface when multiple components are resolved.
20
- */
21
- export type SurfaceDisposition = 'hoist' | 'fallback';
22
-
23
- /**
24
- * Surface debug info.
25
- * NOTE: Short-term measure to track perf issues.
26
- */
27
- export type DebugInfo = {
28
- id: string;
29
- created: number;
30
- renderCount: number;
31
- } & Pick<SurfaceProps, 'role' | 'name'>;
32
-
33
- export type SurfaceResult = {
34
- node: JSX.Element;
35
- disposition?: SurfaceDisposition;
36
- };
37
-
38
- /**
39
- * Function that resolves a Surface.
40
- * If a null value is returned, the rendering is deferred to other plugins.
41
- */
42
- export type SurfaceComponent = (
43
- props: SurfaceComponentProps,
44
- forwardedRef: ForwardedRef<HTMLElement>,
45
- ) => JSX.Element | SurfaceResult | null;
46
-
47
- export type SurfaceRootContext = {
48
- components: Record<string, SurfaceComponent>;
49
-
50
- /**
51
- * Debug info.
52
- */
53
- debugInfo?: Map<string, DebugInfo>;
54
- };
55
-
56
- const SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);
57
-
58
- export const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));
59
-
60
- export const SurfaceProvider = SurfaceRootContext.Provider;
@@ -1,22 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- /**
6
- * Checks if the given data is an object and not null.
7
- *
8
- * Useful inside surface component resolvers as a type guard.
9
- *
10
- * @example
11
- * ```ts
12
- * const old =
13
- * data.content &&
14
- * typeof data.content === 'object' &&
15
- * 'id' in data.content &&
16
- * typeof data.content.id === 'string';
17
- *
18
- * // becomes
19
- * const new = isObject(data.content) && typeof data.content.id === 'string';
20
- * ```
21
- */
22
- export const isObject = (data: unknown): data is { [key: string]: unknown } => !!data && typeof data === 'object';
@@ -1,14 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { SurfacePlugin } from './SurfacePlugin';
6
-
7
- export * from './helpers';
8
- export * from './provides';
9
-
10
- export * from './ErrorBoundary';
11
- export * from './Surface';
12
- export * from './SurfaceRootContext';
13
-
14
- export default SurfacePlugin;
@@ -1,9 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- const SurfaceMeta = {
6
- id: 'dxos.org/plugin/surface',
7
- };
8
-
9
- export default SurfaceMeta;
@@ -1,26 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';
6
- import { type Plugin } from '../plugin-host';
7
-
8
- // TODO(burdon): Predicate based providers?
9
- export type SurfaceProvides = {
10
- surface: {
11
- /**
12
- * Used by the `Surface` resolver to find a component to render.
13
- */
14
- component: SurfaceComponent;
15
- };
16
- };
17
-
18
- export type SurfacePluginProvides = {
19
- surface: SurfaceRootContext;
20
- };
21
-
22
- export const parseRootSurfacePlugin = (plugin?: Plugin) =>
23
- (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;
24
-
25
- export const parseSurfacePlugin = (plugin?: Plugin) =>
26
- (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;