@dxos/app-framework 0.7.4 → 0.7.5-labs.071a3e2

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 (389) hide show
  1. package/dist/lib/browser/app-graph-builder-MOLT4EHG.mjs +137 -0
  2. package/dist/lib/browser/app-graph-builder-MOLT4EHG.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-G3HBVVT5.mjs +1403 -0
  4. package/dist/lib/browser/chunk-G3HBVVT5.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-LDJ3T4V3.mjs +32 -0
  6. package/dist/lib/browser/chunk-LDJ3T4V3.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-TGOF2WQZ.mjs +285 -0
  8. package/dist/lib/browser/chunk-TGOF2WQZ.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +135 -543
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/intent-dispatcher-LJKNIGAM.mjs +11 -0
  12. package/dist/lib/browser/intent-resolver-Z724VAMC.mjs +38 -0
  13. package/dist/lib/browser/intent-resolver-Z724VAMC.mjs.map +7 -0
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/store-NWCY7LAP.mjs +19 -0
  16. package/dist/lib/browser/store-NWCY7LAP.mjs.map +7 -0
  17. package/dist/lib/browser/testing/index.mjs +74 -0
  18. package/dist/lib/browser/testing/index.mjs.map +7 -0
  19. package/dist/lib/browser/worker.mjs +77 -0
  20. package/dist/lib/node/app-graph-builder-G7SRXDFD.cjs +146 -0
  21. package/dist/lib/node/app-graph-builder-G7SRXDFD.cjs.map +7 -0
  22. package/dist/lib/node/chunk-55KIQ6YK.cjs +1437 -0
  23. package/dist/lib/node/chunk-55KIQ6YK.cjs.map +7 -0
  24. package/dist/lib/node/chunk-5GABBW2Q.cjs +308 -0
  25. package/dist/lib/node/chunk-5GABBW2Q.cjs.map +7 -0
  26. package/dist/lib/node/chunk-QLVQ6PND.cjs +58 -0
  27. package/dist/lib/node/chunk-QLVQ6PND.cjs.map +7 -0
  28. package/dist/lib/node/index.cjs +136 -558
  29. package/dist/lib/node/index.cjs.map +4 -4
  30. package/dist/lib/node/{plugin-settings-OZ6IKAE5.cjs → intent-dispatcher-CGUK3BCJ.cjs} +10 -10
  31. package/dist/lib/node/intent-dispatcher-CGUK3BCJ.cjs.map +7 -0
  32. package/dist/lib/node/intent-resolver-7GNKPRWT.cjs +45 -0
  33. package/dist/lib/node/intent-resolver-7GNKPRWT.cjs.map +7 -0
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/store-WMJSEQPC.cjs +34 -0
  36. package/dist/lib/node/store-WMJSEQPC.cjs.map +7 -0
  37. package/dist/lib/node/testing/index.cjs +98 -0
  38. package/dist/lib/node/testing/index.cjs.map +7 -0
  39. package/dist/lib/node/worker.cjs +99 -0
  40. package/dist/lib/node/worker.cjs.map +7 -0
  41. package/dist/lib/node-esm/app-graph-builder-MKLYH3NE.mjs +138 -0
  42. package/dist/lib/node-esm/app-graph-builder-MKLYH3NE.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-47FG42II.mjs +286 -0
  44. package/dist/lib/node-esm/chunk-47FG42II.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-CNJYZNSL.mjs +34 -0
  46. package/dist/lib/node-esm/chunk-CNJYZNSL.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-ZTB4TA6Q.mjs +1405 -0
  48. package/dist/lib/node-esm/chunk-ZTB4TA6Q.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +135 -543
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/intent-dispatcher-RZAWA4XD.mjs +12 -0
  52. package/dist/lib/node-esm/intent-resolver-UIU37CKJ.mjs +39 -0
  53. package/dist/lib/node-esm/intent-resolver-UIU37CKJ.mjs.map +7 -0
  54. package/dist/lib/node-esm/meta.json +1 -1
  55. package/dist/lib/node-esm/store-YUWINFBN.mjs +20 -0
  56. package/dist/lib/node-esm/store-YUWINFBN.mjs.map +7 -0
  57. package/dist/lib/node-esm/testing/index.mjs +75 -0
  58. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  59. package/dist/lib/node-esm/worker.mjs +78 -0
  60. package/dist/types/src/App.d.ts +22 -13
  61. package/dist/types/src/App.d.ts.map +1 -1
  62. package/dist/types/src/common/capabilities.d.ts +296 -0
  63. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  64. package/dist/types/src/common/events.d.ts +48 -0
  65. package/dist/types/src/common/events.d.ts.map +1 -0
  66. package/dist/types/src/common/file.d.ts +14 -0
  67. package/dist/types/src/common/file.d.ts.map +1 -0
  68. package/dist/types/src/common/graph.d.ts +21 -0
  69. package/dist/types/src/common/graph.d.ts.map +1 -0
  70. package/dist/types/src/common/index.d.ts +8 -0
  71. package/dist/types/src/common/index.d.ts.map +1 -0
  72. package/dist/types/src/common/layout.d.ts +248 -0
  73. package/dist/types/src/common/layout.d.ts.map +1 -0
  74. package/dist/types/src/common/surface.d.ts +68 -0
  75. package/dist/types/src/common/surface.d.ts.map +1 -0
  76. package/dist/types/src/common/translations.d.ts +11 -0
  77. package/dist/types/src/common/translations.d.ts.map +1 -0
  78. package/dist/types/src/core/capabilities.d.ts +94 -0
  79. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  80. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  81. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  82. package/dist/types/src/core/events.d.ts +58 -0
  83. package/dist/types/src/core/events.d.ts.map +1 -0
  84. package/dist/types/src/core/index.d.ts +5 -0
  85. package/dist/types/src/core/index.d.ts.map +1 -0
  86. package/dist/types/src/core/manager.d.ts +119 -0
  87. package/dist/types/src/core/manager.d.ts.map +1 -0
  88. package/dist/types/src/core/manager.test.d.ts +2 -0
  89. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  90. package/dist/types/src/core/plugin.d.ts +97 -0
  91. package/dist/types/src/core/plugin.d.ts.map +1 -0
  92. package/dist/types/src/helpers.d.ts +10 -0
  93. package/dist/types/src/helpers.d.ts.map +1 -0
  94. package/dist/types/src/helpers.test.d.ts +2 -0
  95. package/dist/types/src/helpers.test.d.ts.map +1 -0
  96. package/dist/types/src/index.d.ts +5 -1
  97. package/dist/types/src/index.d.ts.map +1 -1
  98. package/dist/types/src/playground/debug/Debug.d.ts +6 -0
  99. package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
  100. package/dist/types/src/playground/debug/index.d.ts +2 -0
  101. package/dist/types/src/playground/debug/index.d.ts.map +1 -0
  102. package/dist/types/src/playground/debug/plugin.d.ts +2 -0
  103. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
  104. package/dist/types/src/playground/generator/Main.d.ts +6 -0
  105. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  106. package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
  107. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
  108. package/dist/types/src/playground/generator/generator.d.ts +7 -0
  109. package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
  110. package/dist/types/src/playground/generator/index.d.ts +3 -0
  111. package/dist/types/src/playground/generator/index.d.ts.map +1 -0
  112. package/dist/types/src/playground/generator/plugin.d.ts +2 -0
  113. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
  114. package/dist/types/src/playground/layout/Layout.d.ts +8 -0
  115. package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
  116. package/dist/types/src/playground/layout/index.d.ts +2 -0
  117. package/dist/types/src/playground/layout/index.d.ts.map +1 -0
  118. package/dist/types/src/playground/layout/plugin.d.ts +2 -0
  119. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
  120. package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
  121. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
  122. package/dist/types/src/playground/logger/index.d.ts +2 -0
  123. package/dist/types/src/playground/logger/index.d.ts.map +1 -0
  124. package/dist/types/src/playground/logger/plugin.d.ts +2 -0
  125. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
  126. package/dist/types/src/playground/logger/schema.d.ts +13 -0
  127. package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
  128. package/dist/types/src/playground/playground.stories.d.ts +10 -0
  129. package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
  130. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
  131. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
  132. package/dist/types/src/plugin-intent/actions.d.ts +23 -0
  133. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
  134. package/dist/types/src/plugin-intent/errors.d.ts +16 -0
  135. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
  136. package/dist/types/src/plugin-intent/index.d.ts +5 -0
  137. package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
  138. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +113 -0
  139. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
  140. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
  141. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
  142. package/dist/types/src/plugin-intent/intent.d.ts +68 -0
  143. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  144. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  145. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  146. package/dist/types/src/plugin-settings/actions.d.ts +27 -0
  147. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  148. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
  149. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
  150. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  151. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  152. package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
  153. package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
  154. package/dist/types/src/plugin-settings/store.d.ts +5 -0
  155. package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
  156. package/dist/types/src/plugin-settings/translations.d.ts +11 -0
  157. package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
  158. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  159. package/dist/types/src/react/IntentContext.d.ts +8 -0
  160. package/dist/types/src/react/IntentContext.d.ts.map +1 -0
  161. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  162. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  163. package/dist/types/src/react/Surface.d.ts +12 -0
  164. package/dist/types/src/react/Surface.d.ts.map +1 -0
  165. package/dist/types/src/react/Surface.stories.d.ts +16 -0
  166. package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
  167. package/dist/types/src/react/common.d.ts +12 -0
  168. package/dist/types/src/react/common.d.ts.map +1 -0
  169. package/dist/types/src/react/index.d.ts +7 -0
  170. package/dist/types/src/react/index.d.ts.map +1 -0
  171. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  172. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  173. package/dist/types/src/react/useIntentResolver.d.ts +3 -0
  174. package/dist/types/src/react/useIntentResolver.d.ts.map +1 -0
  175. package/dist/types/src/testing/index.d.ts +2 -0
  176. package/dist/types/src/testing/index.d.ts.map +1 -0
  177. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  178. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  179. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  180. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  181. package/dist/types/src/worker.d.ts +4 -0
  182. package/dist/types/src/worker.d.ts.map +1 -0
  183. package/dist/types/tsconfig.tsbuildinfo +1 -0
  184. package/package.json +39 -17
  185. package/project.json +4 -3
  186. package/src/App.tsx +139 -34
  187. package/src/common/capabilities.ts +97 -0
  188. package/src/common/events.ts +72 -0
  189. package/src/common/file.ts +22 -0
  190. package/src/common/graph.ts +30 -0
  191. package/src/{plugins/common → common}/index.ts +3 -2
  192. package/src/common/layout.ts +225 -0
  193. package/src/common/surface.ts +81 -0
  194. package/src/common/translations.ts +17 -0
  195. package/src/core/capabilities.test.ts +116 -0
  196. package/src/core/capabilities.ts +222 -0
  197. package/src/core/events.ts +58 -0
  198. package/src/core/index.ts +8 -0
  199. package/src/core/manager.test.ts +516 -0
  200. package/src/core/manager.ts +511 -0
  201. package/src/core/plugin.ts +131 -0
  202. package/src/helpers.test.ts +97 -0
  203. package/src/helpers.ts +45 -0
  204. package/src/index.ts +6 -3
  205. package/src/playground/debug/Debug.tsx +39 -0
  206. package/src/playground/debug/index.ts +5 -0
  207. package/src/playground/debug/plugin.ts +17 -0
  208. package/src/playground/generator/Main.tsx +71 -0
  209. package/src/playground/generator/Toolbar.tsx +46 -0
  210. package/src/playground/generator/generator.ts +48 -0
  211. package/src/playground/generator/index.ts +6 -0
  212. package/src/playground/generator/plugin.ts +23 -0
  213. package/src/playground/layout/Layout.tsx +33 -0
  214. package/src/playground/layout/index.ts +5 -0
  215. package/src/playground/layout/plugin.ts +17 -0
  216. package/src/playground/logger/Toolbar.tsx +29 -0
  217. package/src/playground/logger/index.ts +5 -0
  218. package/src/playground/logger/plugin.ts +36 -0
  219. package/src/playground/logger/schema.ts +12 -0
  220. package/src/playground/playground.stories.tsx +34 -0
  221. package/src/plugin-intent/IntentPlugin.tsx +20 -0
  222. package/src/plugin-intent/actions.ts +22 -0
  223. package/src/plugin-intent/errors.ts +39 -0
  224. package/src/plugin-intent/index.ts +8 -0
  225. package/src/plugin-intent/intent-dispatcher.test.ts +299 -0
  226. package/src/plugin-intent/intent-dispatcher.ts +304 -0
  227. package/src/plugin-intent/intent.ts +146 -0
  228. package/src/plugin-settings/SettingsPlugin.ts +35 -0
  229. package/src/plugin-settings/actions.ts +27 -0
  230. package/src/plugin-settings/app-graph-builder.ts +122 -0
  231. package/src/plugin-settings/index.ts +6 -0
  232. package/src/plugin-settings/intent-resolver.ts +28 -0
  233. package/src/plugin-settings/store.ts +20 -0
  234. package/src/plugin-settings/translations.ts +17 -0
  235. package/src/react/IntentContext.tsx +34 -0
  236. package/src/react/PluginManagerProvider.ts +22 -0
  237. package/src/react/Surface.stories.tsx +96 -0
  238. package/src/react/Surface.tsx +75 -0
  239. package/src/react/common.ts +12 -0
  240. package/src/react/index.ts +10 -0
  241. package/src/react/useCapabilities.ts +40 -0
  242. package/src/react/useIntentResolver.ts +22 -0
  243. package/src/testing/index.ts +5 -0
  244. package/src/testing/withPluginManager.stories.tsx +47 -0
  245. package/src/testing/withPluginManager.tsx +75 -0
  246. package/src/worker.ts +11 -0
  247. package/tsconfig.json +54 -2
  248. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  249. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  250. package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
  251. package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
  252. package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
  253. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
  254. package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
  255. package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
  256. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
  257. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
  258. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
  259. package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
  260. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
  261. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  262. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  263. package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
  264. package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
  265. package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
  266. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
  267. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
  268. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
  269. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
  270. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
  271. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
  272. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
  273. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
  274. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  275. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  276. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
  277. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
  278. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
  279. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
  280. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
  281. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
  282. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
  283. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
  284. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
  285. package/dist/types/src/plugins/common/file.d.ts +0 -22
  286. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  287. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  288. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  289. package/dist/types/src/plugins/common/index.d.ts +0 -7
  290. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  291. package/dist/types/src/plugins/common/layout.d.ts +0 -202
  292. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  293. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  294. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  295. package/dist/types/src/plugins/common/navigation.d.ts +0 -196
  296. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  297. package/dist/types/src/plugins/common/translations.d.ts +0 -22
  298. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  299. package/dist/types/src/plugins/helpers.d.ts +0 -41
  300. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  301. package/dist/types/src/plugins/index.d.ts +0 -7
  302. package/dist/types/src/plugins/index.d.ts.map +0 -1
  303. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
  304. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  305. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  306. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  307. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  308. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  309. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
  310. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  311. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
  312. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  313. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  314. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  315. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
  316. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  317. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  318. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  319. package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
  320. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
  321. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
  322. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  323. package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
  324. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  325. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
  326. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  327. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
  328. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  329. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  330. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  331. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  332. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  333. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  334. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  335. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
  336. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  337. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  338. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
  339. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  340. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  341. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  342. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
  343. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
  344. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  345. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  346. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  347. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  348. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  349. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  350. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
  351. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  352. package/src/plugins/common/file.ts +0 -36
  353. package/src/plugins/common/graph.ts +0 -70
  354. package/src/plugins/common/layout.ts +0 -155
  355. package/src/plugins/common/metadata.ts +0 -29
  356. package/src/plugins/common/navigation.ts +0 -185
  357. package/src/plugins/common/translations.ts +0 -36
  358. package/src/plugins/helpers.ts +0 -92
  359. package/src/plugins/index.ts +0 -11
  360. package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
  361. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  362. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  363. package/src/plugins/plugin-host/index.ts +0 -8
  364. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  365. package/src/plugins/plugin-host/plugin.ts +0 -126
  366. package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
  367. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
  368. package/src/plugins/plugin-intent/helpers.ts +0 -11
  369. package/src/plugins/plugin-intent/index.ts +0 -12
  370. package/src/plugins/plugin-intent/intent.ts +0 -101
  371. package/src/plugins/plugin-intent/meta.ts +0 -9
  372. package/src/plugins/plugin-intent/provides.ts +0 -38
  373. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  374. package/src/plugins/plugin-settings/index.ts +0 -9
  375. package/src/plugins/plugin-settings/meta.ts +0 -9
  376. package/src/plugins/plugin-settings/provides.ts +0 -29
  377. package/src/plugins/plugin-surface/Surface.tsx +0 -195
  378. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
  379. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
  380. package/src/plugins/plugin-surface/helpers.ts +0 -22
  381. package/src/plugins/plugin-surface/index.ts +0 -14
  382. package/src/plugins/plugin-surface/meta.ts +0 -9
  383. package/src/plugins/plugin-surface/provides.ts +0 -26
  384. /package/dist/lib/browser/{plugin-intent-LU4KL2RO.mjs.map → intent-dispatcher-LJKNIGAM.mjs.map} +0 -0
  385. /package/dist/lib/browser/{plugin-settings-OM3G2QFY.mjs.map → worker.mjs.map} +0 -0
  386. /package/dist/lib/{browser/plugin-surface-LECZMKSQ.mjs.map → node-esm/intent-dispatcher-RZAWA4XD.mjs.map} +0 -0
  387. /package/dist/lib/node-esm/{plugin-intent-V7ER24Y6.mjs.map → worker.mjs.map} +0 -0
  388. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  389. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -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
- // };
@@ -1,126 +0,0 @@
1
- //
2
- // Copyright 2023 DXOS.org
3
- //
4
-
5
- import type { FC, PropsWithChildren } from 'react';
6
-
7
- /**
8
- * Capabilities provided by a plugin.
9
- * The base surface capabilities are always included.
10
- */
11
- export type PluginProvides<TProvides> = TProvides & {
12
- /**
13
- * React Context which is wrapped around the application to enable any hooks the plugin may provide.
14
- */
15
- context?: FC<PropsWithChildren>;
16
-
17
- /*
18
- * React component which is rendered at the root of the application.
19
- */
20
- root?: FC<PropsWithChildren>;
21
- };
22
-
23
- export type PluginMeta = {
24
- /**
25
- * Globally unique ID.
26
- *
27
- * Expected to be in the form of a valid URL.
28
- *
29
- * @example dxos.org/plugin/example
30
- */
31
- id: string;
32
-
33
- /**
34
- * Short ID for use in URLs.
35
- *
36
- * NOTE: This is especially experimental and likely to change.
37
- */
38
- // TODO(wittjosiah): How should these be managed?
39
- shortId?: string;
40
-
41
- /**
42
- * Human-readable name.
43
- */
44
- name?: string;
45
-
46
- /**
47
- * Short description of plugin functionality.
48
- */
49
- description?: string;
50
-
51
- /**
52
- * URL of home page.
53
- */
54
- homePage?: string;
55
-
56
- /**
57
- * URL of source code.
58
- */
59
- source?: string;
60
-
61
- /**
62
- * Tags to help categorize the plugin.
63
- */
64
- tags?: string[];
65
-
66
- /**
67
- * A grep-able symbol string which can be resolved to an icon asset by @ch-ui/icons, via @ch-ui/vite-plugin-icons.
68
- */
69
- icon?: string;
70
- };
71
-
72
- /**
73
- * A unit of containment of modular functionality that can be provided to an application.
74
- * Plugins provide things like components, state, actions, etc. to the application.
75
- */
76
- export type Plugin<TProvides = {}> = {
77
- meta: PluginMeta;
78
-
79
- /**
80
- * Capabilities provided by the plugin.
81
- */
82
- provides: PluginProvides<TProvides>;
83
- };
84
-
85
- /**
86
- * Plugin definitions extend the base `Plugin` interface with additional lifecycle methods.
87
- */
88
- export type PluginDefinition<TProvides = {}, TInitializeProvides = {}> = Omit<Plugin, 'provides'> & {
89
- /**
90
- * Capabilities provided by the plugin.
91
- */
92
- provides?: Plugin<TProvides>['provides'];
93
-
94
- /**
95
- * Initialize any async behavior required by the plugin.
96
- *
97
- * @return Capabilities provided by the plugin which are merged with base capabilities.
98
- */
99
- initialize?: () => Promise<PluginProvides<TInitializeProvides> | void>;
100
-
101
- /**
102
- * Called once all plugins have been initialized.
103
- * This is the place to do any initialization which requires other plugins to be ready.
104
- *
105
- * @param plugins All plugins which successfully initialized.
106
- */
107
- // TODO(wittjosiah): Rename `ready` to a verb?
108
- ready?: (plugins: Plugin[]) => Promise<void>;
109
-
110
- /**
111
- * Called when the plugin is unloaded.
112
- * This is the place to do any cleanup required by the plugin.
113
- */
114
- unload?: () => Promise<void>;
115
- };
116
-
117
- type LazyPlugin<T> = () => Promise<{ default: (props: T) => PluginDefinition }>;
118
-
119
- export namespace Plugin {
120
- export const lazy = <T>(p: LazyPlugin<T>, props?: T) => {
121
- return () =>
122
- p().then(({ default: definition }) => {
123
- return definition(props as T);
124
- });
125
- };
126
- }