@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,29 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type Plugin } from '../plugin-host';
6
-
7
- export type Metadata = Record<string, any>;
8
-
9
- export type MetadataRecordsProvides = {
10
- metadata: {
11
- records: Record<string, Metadata>;
12
- };
13
- };
14
-
15
- export type MetadataResolver = (type: string) => Metadata;
16
-
17
- export type MetadataResolverProvides = {
18
- metadata: {
19
- resolver: MetadataResolver;
20
- };
21
- };
22
-
23
- export const parseMetadataRecordsPlugin = (plugin: Plugin) => {
24
- return (plugin.provides as any).metadata?.records ? (plugin as Plugin<MetadataRecordsProvides>) : undefined;
25
- };
26
-
27
- export const parseMetadataResolverPlugin = (plugin: Plugin) => {
28
- return (plugin.provides as any).metadata?.resolver ? (plugin as Plugin<MetadataResolverProvides>) : undefined;
29
- };
@@ -1,36 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { z } from 'zod';
6
-
7
- import { type Plugin } from '../plugin-host';
8
-
9
- // TODO(burdon): Replace zed with effect.
10
- export const ResourceKey = z.union([z.string(), z.record(z.any())]);
11
- export type ResourceKey = z.infer<typeof ResourceKey>;
12
-
13
- export const ResourceLanguage = z.record(ResourceKey);
14
- export type ResourceLanguage = z.infer<typeof ResourceLanguage>;
15
-
16
- /**
17
- * A resource is a collection of translations for a language.
18
- */
19
- export const Resource = z.record(ResourceLanguage);
20
- export type Resource = z.infer<typeof Resource>;
21
-
22
- /**
23
- * Provides for a plugin that exposes translations.
24
- */
25
- // TODO(wittjosiah): Rename to TranslationResourcesProvides.
26
- export type TranslationsProvides = {
27
- translations: Readonly<Resource[]>;
28
- };
29
-
30
- /**
31
- * Type guard for translation plugins.
32
- */
33
- export const parseTranslationsPlugin = (plugin: Plugin) => {
34
- const { success } = z.array(Resource).safeParse((plugin.provides as any).translations);
35
- return success ? (plugin as Plugin<TranslationsProvides>) : undefined;
36
- };
@@ -1,92 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { Context, type DisposeCallback } from '@dxos/context';
6
- import { raise } from '@dxos/debug';
7
- import { invariant } from '@dxos/invariant';
8
-
9
- import { type Plugin, type PluginDefinition } from './plugin-host';
10
-
11
- /**
12
- * Resolvers allow different instances of plugins to provide a particular capability.
13
- */
14
- export type PluginResolver<T> = (plugin: Plugin) => Plugin<T> | undefined;
15
-
16
- /**
17
- * Find a plugin by ID.
18
- */
19
- export const findPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> | undefined => {
20
- return plugins.find(
21
- (plugin) => plugin.meta.id === id || (typeof plugin.meta.shortId === 'string' && plugin.meta.shortId === id),
22
- ) as Plugin<T>;
23
- };
24
-
25
- /**
26
- * Find a plugin by ID, or raise an error if not found.
27
- */
28
- export const getPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> => {
29
- return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
30
- };
31
-
32
- /**
33
- * Filter a list of plugins to only those that match a predicate.
34
- */
35
- export const filterPlugins = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T>[] =>
36
- plugins.map((plugin) => predicate(plugin)).filter((plugin): plugin is Plugin<T> => !!plugin);
37
-
38
- /**
39
- * Resolves a plugin by predicate.
40
- *
41
- * @example
42
- * import { parseIntentPlugin, resolvePlugin } from '@dxos/app-framework';
43
- * const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
44
- */
45
- export const resolvePlugin = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T> | undefined =>
46
- filterPlugins(plugins, predicate)[0];
47
-
48
- class PluginContext {
49
- // TODO(burdon): Use Resource (@dima)?
50
- public readonly ctx = new Context();
51
-
52
- private _plugins?: Plugin[];
53
-
54
- init(plugins: Plugin[]) {
55
- this._plugins = plugins;
56
- }
57
-
58
- getPlugin<T>(id: string): Plugin<T> {
59
- invariant(this._plugins);
60
- return getPlugin(this._plugins, id);
61
- }
62
-
63
- resolvePlugin<T>(resolver: PluginResolver<T>): Plugin<T>;
64
- resolvePlugin<T>(resolver: PluginResolver<T>, required = false): Plugin<T> | undefined {
65
- invariant(this._plugins, 'context not initialized');
66
- const plugin = resolvePlugin(this._plugins, resolver);
67
- if (required && !plugin) {
68
- // TODO(burdon): Resolver should have a name.
69
- throw new Error('Plugin not found.');
70
- }
71
-
72
- return plugin;
73
- }
74
-
75
- onDispose(cb: DisposeCallback) {
76
- this.ctx.onDispose(cb);
77
- }
78
-
79
- dispose() {
80
- void this.ctx.dispose();
81
- }
82
- }
83
-
84
- /**
85
- * Plugin helper with dependency injection and life-cycle support.
86
- */
87
- export const definePlugin = <Provides>(
88
- cb: (context: PluginContext) => PluginDefinition<Provides>,
89
- ): (() => PluginDefinition<Provides>) => {
90
- const context = new PluginContext();
91
- return () => cb(context);
92
- };
@@ -1,11 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './common';
6
- export * from './helpers';
7
-
8
- export * from './plugin-intent';
9
- export * from './plugin-host';
10
- export * from './plugin-settings';
11
- export * from './plugin-surface';
@@ -1,96 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type ReactNode } from 'react';
6
-
7
- import { LocalStorageStore } from '@dxos/local-storage';
8
-
9
- import { PluginContainer } from './PluginContainer';
10
- import { type PluginContext, PluginProvider } from './PluginContext';
11
- import { type Plugin, type PluginDefinition, type PluginMeta } from './plugin';
12
- import { ErrorBoundary } from '../plugin-surface';
13
-
14
- export type HostPluginParams = {
15
- plugins: Record<string, () => Promise<PluginDefinition>>;
16
- // Ordered list of plugins.
17
- meta: PluginMeta[];
18
- core: string[];
19
- defaults?: string[];
20
- fallback?: ErrorBoundary['props']['fallback'];
21
- placeholder?: ReactNode;
22
- };
23
-
24
- export type HostPluginProvides = {
25
- plugins: PluginContext;
26
- };
27
-
28
- export const parsePluginHost = (plugin: Plugin) =>
29
- (plugin.provides as HostPluginProvides).plugins ? (plugin as Plugin<HostPluginProvides>) : undefined;
30
-
31
- const HOST_PLUGIN = 'dxos.org/plugin/host';
32
-
33
- /**
34
- * Bootstraps an application by initializing plugins and rendering root components.
35
- */
36
- export const HostPlugin = ({
37
- plugins,
38
- meta,
39
- core,
40
- defaults = [],
41
- fallback = DefaultFallback,
42
- placeholder = null,
43
- }: HostPluginParams): PluginDefinition<HostPluginProvides> => {
44
- const state = new LocalStorageStore<PluginContext>(HOST_PLUGIN, {
45
- ready: false,
46
- core,
47
- enabled: [...defaults],
48
- plugins: [],
49
- available: meta.filter(({ id }) => !core.includes(id)),
50
- // TODO(burdon): Functions should not be part of the settings type.
51
- setPlugin: (id: string, enabled: boolean) => {
52
- if (enabled) {
53
- state.values.enabled.push(id);
54
- } else {
55
- const index = state.values.enabled.findIndex((enabled) => enabled === id);
56
- index !== -1 && state.values.enabled.splice(index, 1);
57
- }
58
- },
59
- });
60
-
61
- // Register and load values.
62
- state.prop({ key: 'enabled', type: LocalStorageStore.json<string[]>() });
63
-
64
- return {
65
- meta: {
66
- id: HOST_PLUGIN,
67
- name: 'Plugin host',
68
- },
69
- provides: {
70
- plugins: state.values,
71
- context: ({ children }) => {
72
- return <PluginProvider value={state.values}>{children}</PluginProvider>;
73
- },
74
- root: () => {
75
- return (
76
- <ErrorBoundary fallback={fallback}>
77
- <PluginContainer plugins={plugins} core={core} state={state.values} placeholder={placeholder} />
78
- </ErrorBoundary>
79
- );
80
- },
81
- },
82
- };
83
- };
84
-
85
- /**
86
- * Fallback does not use tailwind or theme.
87
- */
88
- const DefaultFallback = ({ error }: { error: Error }) => {
89
- return (
90
- <div style={{ padding: '1rem' }}>
91
- {/* TODO(wittjosiah): Link to docs for replacing default. */}
92
- <h1 style={{ fontSize: '1.2rem', fontWeight: 700, margin: '0.5rem 0' }}>{error.message}</h1>
93
- <pre>{error.stack}</pre>
94
- </div>
95
- );
96
- };
@@ -1,120 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import React, { type JSX, type FC, type PropsWithChildren, type ReactNode, useEffect, useState } from 'react';
6
-
7
- import { log } from '@dxos/log';
8
-
9
- import { type HostPluginParams } from './HostPlugin';
10
- import { type PluginContext } from './PluginContext';
11
- import { type Plugin, type PluginDefinition, type PluginProvides } from './plugin';
12
-
13
- export type PluginContainerProps = Pick<HostPluginParams, 'core'> & {
14
- plugins: Record<string, () => Promise<PluginDefinition>>;
15
- state: PluginContext;
16
- placeholder: ReactNode;
17
- };
18
-
19
- /**
20
- * Root component initializes plugins.
21
- */
22
- export const PluginContainer = ({ plugins: definitions, core, state, placeholder }: PluginContainerProps) => {
23
- const [error, setError] = useState<unknown>();
24
-
25
- useEffect(() => {
26
- log('initializing plugins', { enabled: state.enabled });
27
- const t = setTimeout(async () => {
28
- try {
29
- const enabledIds = [...core, ...state.enabled];
30
- const enabled = await Promise.all(
31
- enabledIds
32
- .map((id) => definitions[id])
33
- // If local storage indicates a plugin is enabled, but it is not available, ignore it.
34
- .filter((definition): definition is () => Promise<PluginDefinition> => Boolean(definition))
35
- .map((definition) => definition()),
36
- );
37
-
38
- const plugins = await Promise.all(
39
- enabled.map(async (definition) => {
40
- const plugin = await initializePlugin(definition).catch((err) => {
41
- log.error('Failed to initialize plugin:', { id: definition.meta.id, err });
42
- });
43
-
44
- log('initialized', { plugin: definition.meta.id });
45
- return plugin;
46
- }),
47
- );
48
-
49
- const initialized = plugins.filter((plugin): plugin is Plugin => Boolean(plugin));
50
- log('plugins initialized', { plugins: initialized });
51
-
52
- await Promise.all(enabled.map((plugin) => plugin.ready?.(initialized)));
53
- log('plugins ready', { plugins: initialized });
54
-
55
- state.plugins = initialized;
56
- state.ready = true;
57
- } catch (err) {
58
- setError(err);
59
- }
60
- });
61
-
62
- return () => {
63
- clearTimeout(t);
64
- state.ready = false;
65
- // TODO(wittjosiah): Does this ever need to be called prior to having dynamic plugins?
66
- // void Promise.all(enabled.map((definition) => definition.unload?.()));
67
- };
68
- }, []);
69
-
70
- if (error) {
71
- throw error;
72
- }
73
-
74
- if (!state.ready) {
75
- return <>{placeholder}</>;
76
- }
77
-
78
- const ComposedContext = composeContext(state.plugins);
79
-
80
- return <ComposedContext>{rootComponents(state.plugins)}</ComposedContext>;
81
- };
82
-
83
- /**
84
- * Resolve a `PluginDefinition` into a fully initialized `Plugin`.
85
- */
86
- const initializePlugin = async <T, U>(pluginDefinition: PluginDefinition<T, U>): Promise<Plugin<T & U>> => {
87
- const provides = await pluginDefinition.initialize?.();
88
- return {
89
- ...pluginDefinition,
90
- provides: {
91
- ...pluginDefinition.provides,
92
- ...provides,
93
- } as PluginProvides<T & U>,
94
- };
95
- };
96
-
97
- const rootComponents = (plugins: Plugin[]) => {
98
- return plugins
99
- .map((plugin) => {
100
- const Component = plugin.provides.root;
101
- if (Component) {
102
- return <Component key={plugin.meta.id} />;
103
- } else {
104
- return null;
105
- }
106
- })
107
- .filter((node): node is JSX.Element => Boolean(node));
108
- };
109
-
110
- const composeContext = (plugins: Plugin[]) => {
111
- return compose(plugins.map((p) => p.provides.context!).filter(Boolean));
112
- };
113
-
114
- const compose = (contexts: FC<PropsWithChildren>[]) => {
115
- return [...contexts].reduce((Acc, Next) => ({ children }) => (
116
- <Acc>
117
- <Next>{children}</Next>
118
- </Acc>
119
- ));
120
- };
@@ -1,79 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { createContext, useContext, useMemo } from 'react';
6
-
7
- import { raise } from '@dxos/debug';
8
- import { nonNullable } from '@dxos/util';
9
-
10
- import { type Plugin, type PluginMeta } from './plugin';
11
- import { findPlugin, resolvePlugin } from '../helpers';
12
-
13
- export type PluginContext = {
14
- /**
15
- * All plugins are ready.
16
- */
17
- ready: boolean;
18
-
19
- /**
20
- * Core plugins.
21
- */
22
- core: string[];
23
-
24
- /**
25
- * Ids of plugins which are enabled on this device.
26
- */
27
- enabled: string[];
28
-
29
- /**
30
- * Initialized and ready plugins.
31
- */
32
- plugins: Plugin[];
33
-
34
- /**
35
- * All available plugins.
36
- * NOTE: This is metadata rather than just ids because it includes plugins which have not been fully loaded yet.
37
- */
38
- available: PluginMeta[];
39
-
40
- /**
41
- * Mark plugin as enabled.
42
- * Requires reload to take effect.
43
- */
44
- // TODO(burdon): Functions should not be part of the settings type.
45
- setPlugin: (id: string, enabled: boolean) => void;
46
- };
47
-
48
- const PluginContext = createContext<PluginContext | undefined>(undefined);
49
-
50
- /**
51
- * Get all plugins.
52
- */
53
- export const usePlugins = (): PluginContext => useContext(PluginContext) ?? raise(new Error('Missing PluginContext'));
54
-
55
- /**
56
- * Get a plugin by ID.
57
- */
58
- export const usePlugin = <T,>(id: string): Plugin<T> | undefined => {
59
- const { plugins } = usePlugins();
60
- return findPlugin<T>(plugins, id);
61
- };
62
-
63
- /**
64
- * Resolve a plugin by predicate.
65
- */
66
- export const useResolvePlugin = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T> | undefined => {
67
- const { plugins } = usePlugins();
68
- return resolvePlugin(plugins, predicate);
69
- };
70
-
71
- /**
72
- * Resolve a collection of plugins by predicate.
73
- */
74
- export const useResolvePlugins = <T,>(predicate: (plugin: Plugin) => Plugin<T> | undefined): Plugin<T>[] => {
75
- const { plugins } = usePlugins();
76
- return useMemo(() => plugins.map(predicate).filter(nonNullable), [plugins, predicate]);
77
- };
78
-
79
- export const PluginProvider = PluginContext.Provider;
@@ -1,8 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- export * from './plugin';
6
-
7
- export * from './HostPlugin';
8
- export * from './PluginContext';
@@ -1,158 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import { type FC } from 'react';
6
- import { describe, expect, test } from 'vitest';
7
-
8
- import { log } from '@dxos/log';
9
-
10
- import { type Plugin } from './plugin';
11
-
12
- // eslint-disable-next-line unused-imports/no-unused-vars
13
- export interface Interface<T> {
14
- key: string;
15
- }
16
-
17
- type InterfaceDef<T> = {
18
- key: Interface<T>;
19
- impl: T;
20
- };
21
-
22
- export const provide = <T>(key: Interface<T>, impl: T): InterfaceDef<T> => ({ key, impl });
23
-
24
- export type PluginProps = {
25
- provides?: InterfaceDef<any>[];
26
- };
27
-
28
- export class TestPlugin {
29
- readonly _interfaces = new Map<string, any>();
30
- constructor({ provides }: PluginProps) {
31
- provides?.forEach(({ key, impl }) => this._interfaces.set(key.key, impl));
32
- }
33
-
34
- getInterface = <T>(key: Interface<T>): T | undefined => this._interfaces.get(key.key);
35
- }
36
-
37
- const getInterfaces = <T>(plugins: TestPlugin[], key: Interface<T>): T[] =>
38
- plugins.map((plugin) => plugin.getInterface(key)).filter(Boolean) as any;
39
-
40
- //
41
- // Interfaces allow shared typesafe contracts between plugins.
42
- // The system might define common contracts (e.g., Printable); others would be defined by individual plugins.
43
- // This allows parts of the system to find interfaces across all plugins to enable loosely coupled actions
44
- // (separate from broadcast events) or requests for information.
45
- //
46
-
47
- export interface Printable {
48
- print: (data: any | undefined) => void;
49
- }
50
-
51
- export const Printable: Interface<Printable> = { key: 'printable' };
52
-
53
- export interface Selectable {
54
- selection: () => string | undefined;
55
- select: (object?: { id: string | undefined }) => void;
56
- }
57
-
58
- export const Selectable: Interface<Selectable> = { key: 'selectable' };
59
-
60
- // NOTE: Would allow Stack to define a contract for plugins that have embeddable content.
61
- export type Section = FC<{ object: any; onSelect: (object: string | undefined) => void }>;
62
-
63
- export const Section: Interface<Section> = { key: 'list' };
64
-
65
- //
66
- // Plugin defs
67
- //
68
-
69
- // TODO(burdon): Tie to declarative manifest.
70
- // {
71
- // Printable: { print: (data: any) => console.log(data) }
72
- // }
73
- //
74
-
75
- const plugin1 = new TestPlugin({
76
- provides: [
77
- provide(Printable, {
78
- print: (data: any | undefined) => log(data),
79
- }),
80
-
81
- provide(Selectable, {
82
- selection: () => undefined,
83
- select: (data: any) => {}, // TODO(burdon): Update plugin state.
84
- }),
85
-
86
- // provide(Section, ({ object }) => <div>{JSON.stringify(object)}</div>),
87
- ],
88
- });
89
-
90
- const plugin2 = new TestPlugin({
91
- provides: [
92
- provide(Printable, {
93
- print: (data: any) => log(data),
94
- }),
95
- ],
96
- });
97
-
98
- const plugin3 = new TestPlugin({});
99
-
100
- describe('Plugins', () => {
101
- const plugins = [plugin1, plugin2, plugin3];
102
-
103
- test('invocation', () => {
104
- // Invoke against all plugins that provide interface.
105
- expect(getInterfaces(plugins, Printable)).to.have.length(2);
106
- getInterfaces(plugins, Printable).forEach((i) => i.print({}));
107
- });
108
-
109
- test('symbols', () => {
110
- const s1 = Symbol.for('s1');
111
- const s2 = Symbol.for('s1');
112
- expect(s1).to.be.eq(s2);
113
-
114
- const map = new Map();
115
- map.set(s1, true);
116
- map.set(s2, false);
117
- expect(map.get(s1)).to.be.false;
118
- });
119
-
120
- test('filter', () => {
121
- type Provides1 = {
122
- test1: {};
123
- };
124
-
125
- type Provides2 = {
126
- test2: {};
127
- };
128
-
129
- const p1: Plugin<Provides1> = {
130
- meta: { id: 'example.com/plugin/plugin-1' },
131
- provides: {
132
- test1: {},
133
- },
134
- };
135
-
136
- const p2: Plugin<Provides2> = {
137
- meta: { id: 'example.com/plugin/plugin-2' },
138
- provides: {
139
- test2: {},
140
- },
141
- };
142
-
143
- const plugins: Plugin[] = [p1, p2];
144
-
145
- const matching = plugins.filter((plugin) => true);
146
- expect(matching).to.have.length(2);
147
- });
148
- });
149
-
150
- // eslint-disable-next-line unused-imports/no-unused-vars
151
- // const StackContainer: FC<{}> = () => {
152
- // const StackSection = plugin1.getInterface(Section)!;
153
- // const selected = plugin1.getInterface(Selectable)?.selection();
154
-
155
- // return (
156
- // <StackSection object={selected} onSelect={(object) => plugin1.getInterface(Selectable)?.select({ id: object })} />
157
- // );
158
- // };