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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (327) hide show
  1. package/dist/lib/browser/chunk-EGGZVV7Q.mjs +1595 -0
  2. package/dist/lib/browser/chunk-EGGZVV7Q.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +136 -527
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +67 -0
  7. package/dist/lib/browser/testing/index.mjs.map +7 -0
  8. package/dist/lib/node/chunk-UBX6GP2N.cjs +1639 -0
  9. package/dist/lib/node/chunk-UBX6GP2N.cjs.map +7 -0
  10. package/dist/lib/node/index.cjs +141 -551
  11. package/dist/lib/node/index.cjs.map +4 -4
  12. package/dist/lib/node/meta.json +1 -1
  13. package/dist/lib/node/testing/index.cjs +91 -0
  14. package/dist/lib/node/testing/index.cjs.map +7 -0
  15. package/dist/lib/node-esm/chunk-HG5P55WF.mjs +1597 -0
  16. package/dist/lib/node-esm/chunk-HG5P55WF.mjs.map +7 -0
  17. package/dist/lib/node-esm/index.mjs +136 -527
  18. package/dist/lib/node-esm/index.mjs.map +4 -4
  19. package/dist/lib/node-esm/meta.json +1 -1
  20. package/dist/lib/node-esm/testing/index.mjs +68 -0
  21. package/dist/lib/node-esm/testing/index.mjs.map +7 -0
  22. package/dist/types/src/App.d.ts +22 -13
  23. package/dist/types/src/App.d.ts.map +1 -1
  24. package/dist/types/src/common/capabilities.d.ts +340 -0
  25. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  26. package/dist/types/src/common/events.d.ts +41 -0
  27. package/dist/types/src/common/events.d.ts.map +1 -0
  28. package/dist/types/src/common/file.d.ts +14 -0
  29. package/dist/types/src/common/file.d.ts.map +1 -0
  30. package/dist/types/src/common/graph.d.ts +21 -0
  31. package/dist/types/src/common/graph.d.ts.map +1 -0
  32. package/dist/types/src/{plugins/common → common}/index.d.ts +3 -1
  33. package/dist/types/src/common/index.d.ts.map +1 -0
  34. package/dist/types/src/common/layout.d.ts +165 -0
  35. package/dist/types/src/common/layout.d.ts.map +1 -0
  36. package/dist/types/src/{plugins/common → common}/navigation.d.ts +77 -32
  37. package/dist/types/src/common/navigation.d.ts.map +1 -0
  38. package/dist/types/src/common/surface.d.ts +68 -0
  39. package/dist/types/src/common/surface.d.ts.map +1 -0
  40. package/dist/types/src/{plugins/common → common}/translations.d.ts +0 -11
  41. package/dist/types/src/common/translations.d.ts.map +1 -0
  42. package/dist/types/src/core/capabilities.d.ts +90 -0
  43. package/dist/types/src/core/capabilities.d.ts.map +1 -0
  44. package/dist/types/src/core/capabilities.test.d.ts +2 -0
  45. package/dist/types/src/core/capabilities.test.d.ts.map +1 -0
  46. package/dist/types/src/core/events.d.ts +58 -0
  47. package/dist/types/src/core/events.d.ts.map +1 -0
  48. package/dist/types/src/core/index.d.ts +5 -0
  49. package/dist/types/src/core/index.d.ts.map +1 -0
  50. package/dist/types/src/core/manager.d.ts +126 -0
  51. package/dist/types/src/core/manager.d.ts.map +1 -0
  52. package/dist/types/src/core/manager.test.d.ts +2 -0
  53. package/dist/types/src/core/manager.test.d.ts.map +1 -0
  54. package/dist/types/src/core/plugin.d.ts +94 -0
  55. package/dist/types/src/core/plugin.d.ts.map +1 -0
  56. package/dist/types/src/helpers.d.ts +10 -0
  57. package/dist/types/src/helpers.d.ts.map +1 -0
  58. package/dist/types/src/helpers.test.d.ts +2 -0
  59. package/dist/types/src/helpers.test.d.ts.map +1 -0
  60. package/dist/types/src/index.d.ts +5 -1
  61. package/dist/types/src/index.d.ts.map +1 -1
  62. package/dist/types/src/playground/debug/Debug.d.ts +6 -0
  63. package/dist/types/src/playground/debug/Debug.d.ts.map +1 -0
  64. package/dist/types/src/playground/debug/index.d.ts +2 -0
  65. package/dist/types/src/playground/debug/index.d.ts.map +1 -0
  66. package/dist/types/src/playground/debug/plugin.d.ts +2 -0
  67. package/dist/types/src/playground/debug/plugin.d.ts.map +1 -0
  68. package/dist/types/src/playground/generator/Main.d.ts +6 -0
  69. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  70. package/dist/types/src/playground/generator/Toolbar.d.ts +6 -0
  71. package/dist/types/src/playground/generator/Toolbar.d.ts.map +1 -0
  72. package/dist/types/src/playground/generator/generator.d.ts +5 -0
  73. package/dist/types/src/playground/generator/generator.d.ts.map +1 -0
  74. package/dist/types/src/playground/generator/index.d.ts +3 -0
  75. package/dist/types/src/playground/generator/index.d.ts.map +1 -0
  76. package/dist/types/src/playground/generator/plugin.d.ts +2 -0
  77. package/dist/types/src/playground/generator/plugin.d.ts.map +1 -0
  78. package/dist/types/src/playground/layout/Layout.d.ts +8 -0
  79. package/dist/types/src/playground/layout/Layout.d.ts.map +1 -0
  80. package/dist/types/src/playground/layout/index.d.ts +2 -0
  81. package/dist/types/src/playground/layout/index.d.ts.map +1 -0
  82. package/dist/types/src/playground/layout/plugin.d.ts +2 -0
  83. package/dist/types/src/playground/layout/plugin.d.ts.map +1 -0
  84. package/dist/types/src/playground/logger/Toolbar.d.ts +6 -0
  85. package/dist/types/src/playground/logger/Toolbar.d.ts.map +1 -0
  86. package/dist/types/src/playground/logger/index.d.ts +2 -0
  87. package/dist/types/src/playground/logger/index.d.ts.map +1 -0
  88. package/dist/types/src/playground/logger/plugin.d.ts +2 -0
  89. package/dist/types/src/playground/logger/plugin.d.ts.map +1 -0
  90. package/dist/types/src/playground/logger/schema.d.ts +13 -0
  91. package/dist/types/src/playground/logger/schema.d.ts.map +1 -0
  92. package/dist/types/src/playground/playground.stories.d.ts +10 -0
  93. package/dist/types/src/playground/playground.stories.d.ts.map +1 -0
  94. package/dist/types/src/plugin-intent/IntentContext.d.ts +8 -0
  95. package/dist/types/src/plugin-intent/IntentContext.d.ts.map +1 -0
  96. package/dist/types/src/plugin-intent/IntentPlugin.d.ts +2 -0
  97. package/dist/types/src/plugin-intent/IntentPlugin.d.ts.map +1 -0
  98. package/dist/types/src/plugin-intent/actions.d.ts +23 -0
  99. package/dist/types/src/plugin-intent/actions.d.ts.map +1 -0
  100. package/dist/types/src/plugin-intent/errors.d.ts +16 -0
  101. package/dist/types/src/plugin-intent/errors.d.ts.map +1 -0
  102. package/dist/types/src/plugin-intent/index.d.ts +6 -0
  103. package/dist/types/src/plugin-intent/index.d.ts.map +1 -0
  104. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts +106 -0
  105. package/dist/types/src/plugin-intent/intent-dispatcher.d.ts.map +1 -0
  106. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts +2 -0
  107. package/dist/types/src/plugin-intent/intent-dispatcher.test.d.ts.map +1 -0
  108. package/dist/types/src/plugin-intent/intent.d.ts +68 -0
  109. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  110. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  111. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  112. package/dist/types/src/plugin-settings/actions.d.ts +17 -0
  113. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  114. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  115. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  116. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  117. package/dist/types/src/react/PluginManagerProvider.d.ts +10 -0
  118. package/dist/types/src/react/PluginManagerProvider.d.ts.map +1 -0
  119. package/dist/types/src/react/Surface.d.ts +12 -0
  120. package/dist/types/src/react/Surface.d.ts.map +1 -0
  121. package/dist/types/src/react/index.d.ts +5 -0
  122. package/dist/types/src/react/index.d.ts.map +1 -0
  123. package/dist/types/src/react/useCapabilities.d.ts +13 -0
  124. package/dist/types/src/react/useCapabilities.d.ts.map +1 -0
  125. package/dist/types/src/testing/index.d.ts +2 -0
  126. package/dist/types/src/testing/index.d.ts.map +1 -0
  127. package/dist/types/src/testing/withPluginManager.d.ts +10 -0
  128. package/dist/types/src/testing/withPluginManager.d.ts.map +1 -0
  129. package/dist/types/src/testing/withPluginManager.stories.d.ts +5 -0
  130. package/dist/types/src/testing/withPluginManager.stories.d.ts.map +1 -0
  131. package/dist/types/tsconfig.tsbuildinfo +1 -0
  132. package/package.json +30 -14
  133. package/project.json +2 -1
  134. package/src/App.tsx +138 -34
  135. package/src/common/capabilities.ts +82 -0
  136. package/src/common/events.ts +63 -0
  137. package/src/common/file.ts +22 -0
  138. package/src/common/graph.ts +30 -0
  139. package/src/{plugins/common → common}/index.ts +3 -1
  140. package/src/common/layout.ts +157 -0
  141. package/src/{plugins/common → common}/navigation.ts +59 -45
  142. package/src/common/surface.ts +81 -0
  143. package/src/common/translations.ts +18 -0
  144. package/src/core/capabilities.test.ts +116 -0
  145. package/src/core/capabilities.ts +213 -0
  146. package/src/core/events.ts +58 -0
  147. package/src/core/index.ts +8 -0
  148. package/src/core/manager.test.ts +567 -0
  149. package/src/core/manager.ts +497 -0
  150. package/src/core/plugin.ts +128 -0
  151. package/src/helpers.test.ts +97 -0
  152. package/src/helpers.ts +45 -0
  153. package/src/index.ts +6 -3
  154. package/src/playground/debug/Debug.tsx +39 -0
  155. package/src/playground/debug/index.ts +5 -0
  156. package/src/playground/debug/plugin.ts +17 -0
  157. package/src/playground/generator/Main.tsx +71 -0
  158. package/src/playground/generator/Toolbar.tsx +46 -0
  159. package/src/playground/generator/generator.ts +23 -0
  160. package/src/playground/generator/index.ts +6 -0
  161. package/src/playground/generator/plugin.ts +18 -0
  162. package/src/playground/layout/Layout.tsx +33 -0
  163. package/src/playground/layout/index.ts +5 -0
  164. package/src/playground/layout/plugin.ts +17 -0
  165. package/src/playground/logger/Toolbar.tsx +28 -0
  166. package/src/playground/logger/index.ts +5 -0
  167. package/src/playground/logger/plugin.ts +33 -0
  168. package/src/playground/logger/schema.ts +12 -0
  169. package/src/playground/playground.stories.tsx +34 -0
  170. package/src/plugin-intent/IntentContext.tsx +34 -0
  171. package/src/plugin-intent/IntentPlugin.tsx +60 -0
  172. package/src/plugin-intent/actions.ts +22 -0
  173. package/src/plugin-intent/errors.ts +39 -0
  174. package/src/plugin-intent/index.ts +9 -0
  175. package/src/plugin-intent/intent-dispatcher.test.ts +280 -0
  176. package/src/plugin-intent/intent-dispatcher.ts +269 -0
  177. package/src/plugin-intent/intent.ts +146 -0
  178. package/src/plugin-settings/SettingsPlugin.ts +29 -0
  179. package/src/plugin-settings/actions.ts +17 -0
  180. package/src/plugin-settings/index.ts +6 -0
  181. package/src/react/PluginManagerProvider.ts +22 -0
  182. package/src/react/Surface.tsx +72 -0
  183. package/src/react/index.ts +8 -0
  184. package/src/react/useCapabilities.ts +40 -0
  185. package/src/testing/index.ts +5 -0
  186. package/src/testing/withPluginManager.stories.tsx +47 -0
  187. package/src/testing/withPluginManager.tsx +67 -0
  188. package/tsconfig.json +51 -2
  189. package/dist/lib/browser/chunk-3E7RY3CE.mjs +0 -72
  190. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +0 -7
  191. package/dist/lib/browser/chunk-653Y45CL.mjs +0 -41
  192. package/dist/lib/browser/chunk-653Y45CL.mjs.map +0 -7
  193. package/dist/lib/browser/chunk-FRXJ25VI.mjs +0 -214
  194. package/dist/lib/browser/chunk-FRXJ25VI.mjs.map +0 -7
  195. package/dist/lib/browser/chunk-YXM35XRE.mjs +0 -213
  196. package/dist/lib/browser/chunk-YXM35XRE.mjs.map +0 -7
  197. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs +0 -22
  198. package/dist/lib/browser/plugin-intent-LU4KL2RO.mjs.map +0 -7
  199. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +0 -11
  200. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +0 -7
  201. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs +0 -24
  202. package/dist/lib/browser/plugin-surface-LECZMKSQ.mjs.map +0 -7
  203. package/dist/lib/node/chunk-JZ2JVKRY.cjs +0 -58
  204. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +0 -7
  205. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  206. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  207. package/dist/lib/node/chunk-QSVP5HOW.cjs +0 -238
  208. package/dist/lib/node/chunk-QSVP5HOW.cjs.map +0 -7
  209. package/dist/lib/node/chunk-SOVLKUWI.cjs +0 -236
  210. package/dist/lib/node/chunk-SOVLKUWI.cjs.map +0 -7
  211. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs +0 -43
  212. package/dist/lib/node/plugin-intent-FVFR2LKB.cjs.map +0 -7
  213. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +0 -32
  214. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +0 -7
  215. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs +0 -45
  216. package/dist/lib/node/plugin-surface-YWDRXQTD.cjs.map +0 -7
  217. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs +0 -215
  218. package/dist/lib/node-esm/chunk-2R4GVK7O.mjs.map +0 -7
  219. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  220. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  221. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs +0 -214
  222. package/dist/lib/node-esm/chunk-YFMFQBB4.mjs.map +0 -7
  223. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +0 -43
  224. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +0 -7
  225. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs +0 -23
  226. package/dist/lib/node-esm/plugin-intent-V7ER24Y6.mjs.map +0 -7
  227. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +0 -12
  228. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +0 -7
  229. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs +0 -25
  230. package/dist/lib/node-esm/plugin-surface-TEU42XQN.mjs.map +0 -7
  231. package/dist/types/src/plugins/common/file.d.ts +0 -22
  232. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  233. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  234. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  235. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  236. package/dist/types/src/plugins/common/layout.d.ts +0 -202
  237. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  238. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  239. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  240. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  241. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  242. package/dist/types/src/plugins/helpers.d.ts +0 -41
  243. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  244. package/dist/types/src/plugins/index.d.ts +0 -7
  245. package/dist/types/src/plugins/index.d.ts.map +0 -1
  246. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -21
  247. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  248. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  249. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  250. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  251. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  252. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -4
  253. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  254. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -98
  255. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  256. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  257. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  258. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts +0 -21
  259. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  260. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  261. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  262. package/dist/types/src/plugins/plugin-intent/helpers.d.ts +0 -6
  263. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +0 -1
  264. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -6
  265. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  266. package/dist/types/src/plugins/plugin-intent/intent.d.ts +0 -81
  267. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  268. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -5
  269. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  270. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -20
  271. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  272. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  273. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  274. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  275. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  276. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  277. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  278. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -13
  279. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  280. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  281. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -62
  282. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  283. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  284. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  285. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts +0 -39
  286. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +0 -1
  287. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  288. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  289. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  290. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  291. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  292. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  293. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -16
  294. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  295. package/src/plugins/common/file.ts +0 -36
  296. package/src/plugins/common/graph.ts +0 -70
  297. package/src/plugins/common/layout.ts +0 -155
  298. package/src/plugins/common/metadata.ts +0 -29
  299. package/src/plugins/common/translations.ts +0 -36
  300. package/src/plugins/helpers.ts +0 -92
  301. package/src/plugins/index.ts +0 -11
  302. package/src/plugins/plugin-host/HostPlugin.tsx +0 -96
  303. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  304. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  305. package/src/plugins/plugin-host/index.ts +0 -8
  306. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  307. package/src/plugins/plugin-host/plugin.ts +0 -126
  308. package/src/plugins/plugin-intent/IntentContext.tsx +0 -49
  309. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -151
  310. package/src/plugins/plugin-intent/helpers.ts +0 -11
  311. package/src/plugins/plugin-intent/index.ts +0 -12
  312. package/src/plugins/plugin-intent/intent.ts +0 -101
  313. package/src/plugins/plugin-intent/meta.ts +0 -9
  314. package/src/plugins/plugin-intent/provides.ts +0 -38
  315. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  316. package/src/plugins/plugin-settings/index.ts +0 -9
  317. package/src/plugins/plugin-settings/meta.ts +0 -9
  318. package/src/plugins/plugin-settings/provides.ts +0 -29
  319. package/src/plugins/plugin-surface/Surface.tsx +0 -195
  320. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -33
  321. package/src/plugins/plugin-surface/SurfaceRootContext.tsx +0 -60
  322. package/src/plugins/plugin-surface/helpers.ts +0 -22
  323. package/src/plugins/plugin-surface/index.ts +0 -14
  324. package/src/plugins/plugin-surface/meta.ts +0 -9
  325. package/src/plugins/plugin-surface/provides.ts +0 -26
  326. /package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +0 -0
  327. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -0,0 +1,146 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { S } from '@dxos/echo-schema';
6
+
7
+ export type IntentParams = {
8
+ readonly input: S.Schema.All;
9
+ readonly output: S.Schema.All;
10
+ };
11
+
12
+ export type IntentData<Fields extends IntentParams> =
13
+ S.Schema.Type<S.Struct<Fields>> extends { readonly input: any } ? S.Schema.Type<S.Struct<Fields>>['input'] : any;
14
+
15
+ export type IntentResultData<Fields extends IntentParams> =
16
+ S.Schema.Type<S.Struct<Fields>> extends { readonly output: any } ? S.Schema.Type<S.Struct<Fields>>['output'] : any;
17
+
18
+ export type IntentSchema<Tag extends string, Fields extends IntentParams> = S.TaggedClass<any, Tag, Fields>;
19
+
20
+ /**
21
+ * An intent is an abstract description of an operation to be performed.
22
+ * Intents allow actions to be performed across plugins.
23
+ */
24
+ export type Intent<Tag extends string, Fields extends IntentParams> = {
25
+ _schema: IntentSchema<Tag, Fields>;
26
+
27
+ /**
28
+ * The action to perform.
29
+ */
30
+ action: Tag;
31
+
32
+ /**
33
+ * Any data needed to perform the desired action.
34
+ */
35
+ data: IntentData<Fields>;
36
+
37
+ /**
38
+ * Module ID.
39
+ * If specified, the intent will be sent explicitly to the plugin module.
40
+ * Otherwise, the intent will be sent to all plugins, in order and the first to resolve a non-null value will be used.
41
+ */
42
+ module?: string;
43
+
44
+ /**
45
+ * Whether or not the intent is being undone.
46
+ */
47
+ undo?: boolean;
48
+ };
49
+
50
+ export type AnyIntent = Intent<any, any>;
51
+
52
+ /**
53
+ * Chain of intents to be executed together.
54
+ * The result of each intent is merged into the next intent's input data.
55
+ */
56
+ export type IntentChain<
57
+ FirstTag extends string,
58
+ LastTag extends string,
59
+ FirstFields extends IntentParams,
60
+ LastFields extends IntentParams,
61
+ > = {
62
+ first: Intent<FirstTag, FirstFields>;
63
+ last: Intent<LastTag, LastFields>;
64
+ all: AnyIntent[];
65
+ };
66
+
67
+ export type AnyIntentChain = IntentChain<any, any, any, any>;
68
+
69
+ /**
70
+ * Creates a typed intent.
71
+ * @param schema Schema of the intent. Must be a tagged class with input and output schemas.
72
+ * @param data Data fulfilling the input schema of the intent.
73
+ * @param params.plugin Optional plugin ID to send the intent to.
74
+ * @param params.undo Optional flag to indicate that the intent is being undone. Generally not set manually.
75
+ */
76
+ export const createIntent = <Tag extends string, Fields extends IntentParams>(
77
+ schema: IntentSchema<Tag, Fields>,
78
+ data: IntentData<Fields> = {},
79
+ params: Pick<AnyIntent, 'module' | 'undo'> = {},
80
+ ): IntentChain<Tag, Tag, Fields, Fields> => {
81
+ // The output of validateSync breaks proxy objects so this is just used for validation.
82
+ // TODO(wittjosiah): Is there a better way to make theses types align?
83
+ const _ = S.validateSync(schema.fields.input as S.Schema<any, any, unknown>)(data);
84
+ const intent = {
85
+ ...params,
86
+ _schema: schema,
87
+ action: schema._tag,
88
+ data,
89
+ } satisfies Intent<Tag, Fields>;
90
+
91
+ return {
92
+ first: intent,
93
+ last: intent,
94
+ all: [intent],
95
+ };
96
+ };
97
+
98
+ // TODO(wittjosiah): Add a function for mapping the output of one intent to the input of another.
99
+
100
+ /**
101
+ * Chain two intents together.
102
+ *
103
+ * NOTE: Chaining of intents depends on the data inputs and outputs being structs.
104
+ */
105
+ export const chain =
106
+ <
107
+ FirstTag extends string,
108
+ NextTag extends string,
109
+ FirstFields extends IntentParams,
110
+ LastFields extends IntentParams,
111
+ NextFields extends IntentParams,
112
+ >(
113
+ schema: IntentSchema<NextTag, NextFields>,
114
+ data: Omit<IntentData<NextFields>, keyof IntentResultData<LastFields>> = {},
115
+ params: Pick<AnyIntent, 'module' | 'undo'> = {},
116
+ ) =>
117
+ (
118
+ intent: IntentChain<FirstTag, any, FirstFields, LastFields>,
119
+ ): IntentChain<FirstTag, NextTag, FirstFields, NextFields> => {
120
+ const intents = 'all' in intent ? intent.all : [intent];
121
+ const first = intents[0];
122
+ const last = {
123
+ ...params,
124
+ _schema: schema,
125
+ action: schema._tag,
126
+ data,
127
+ } satisfies Intent<NextTag, NextFields>;
128
+
129
+ return {
130
+ first,
131
+ last,
132
+ all: [...intents, last],
133
+ };
134
+ };
135
+
136
+ //
137
+ // Intents
138
+ //
139
+
140
+ // NOTE: Should maintain compatibility with `i18next` (and @dxos/react-ui).
141
+ // TODO(wittjosiah): Making this immutable breaks type compatibility.
142
+ export const Label = S.Union(
143
+ S.String,
144
+ S.mutable(S.Tuple(S.String, S.mutable(S.Struct({ ns: S.String, count: S.optional(S.Number) })))),
145
+ );
146
+ export type Label = S.Schema.Type<typeof Label>;
@@ -0,0 +1,29 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { RootSettingsStore } from '@dxos/local-storage';
6
+
7
+ import { SETTINGS_PLUGIN } from './actions';
8
+ import { Capabilities, Events } from '../common';
9
+ import { contributes, defineModule, definePlugin } from '../core';
10
+
11
+ export const SettingsPlugin = () =>
12
+ definePlugin({ id: SETTINGS_PLUGIN }, [
13
+ defineModule({
14
+ id: `${SETTINGS_PLUGIN}/module/store`,
15
+ activatesOn: Events.Startup,
16
+ activatesBefore: [Events.SetupSettings],
17
+ activatesAfter: [Events.SettingsReady],
18
+ activate: (context) => {
19
+ const allSettings = context.requestCapabilities(Capabilities.Settings);
20
+ const settingsStore = new RootSettingsStore();
21
+
22
+ allSettings.forEach((setting) => {
23
+ settingsStore.createStore(setting as any);
24
+ });
25
+
26
+ return contributes(Capabilities.SettingsStore, settingsStore);
27
+ },
28
+ }),
29
+ ]);
@@ -0,0 +1,17 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { S } from '@dxos/echo-schema';
6
+
7
+ export const SETTINGS_PLUGIN = 'dxos.org/plugin/settings';
8
+ export const SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;
9
+
10
+ export namespace SettingsAction {
11
+ export class Open extends S.TaggedClass<Open>()(`${SETTINGS_ACTION}/open`, {
12
+ input: S.Struct({
13
+ plugin: S.optional(S.String),
14
+ }),
15
+ output: S.Void,
16
+ }) {}
17
+ }
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ export * from './actions';
6
+ export * from './SettingsPlugin';
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2024 DXOS.org
3
+ //
4
+
5
+ import { createContext, useContext } from 'react';
6
+
7
+ import { raise } from '@dxos/debug';
8
+
9
+ import { type PluginManager } from '../core';
10
+
11
+ const PluginManagerContext = createContext<PluginManager | undefined>(undefined);
12
+
13
+ /**
14
+ * Get the plugin manager.
15
+ */
16
+ export const usePluginManager = (): PluginManager =>
17
+ useContext(PluginManagerContext) ?? raise(new Error('Missing PluginManagerContext'));
18
+
19
+ /**
20
+ * Context provider for a plugin manager.
21
+ */
22
+ export const PluginManagerProvider = PluginManagerContext.Provider;
@@ -0,0 +1,72 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React, { memo, forwardRef, Suspense, useMemo } from 'react';
6
+
7
+ import { useDefaultValue } from '@dxos/react-hooks';
8
+ import { byDisposition } from '@dxos/util';
9
+
10
+ import { ErrorBoundary } from './ErrorBoundary';
11
+ import { useCapabilities } from './useCapabilities';
12
+ import { Capabilities, type SurfaceDefinition, type SurfaceProps } from '../common';
13
+ import { type PluginsContext } from '../core';
14
+
15
+ const useSurfaces = () => {
16
+ const surfaces = useCapabilities(Capabilities.ReactSurface);
17
+ return useMemo(() => surfaces.flat(), [surfaces]);
18
+ };
19
+
20
+ const findCandidates = (surfaces: SurfaceDefinition[], { role, data }: Pick<SurfaceProps, 'role' | 'data'>) => {
21
+ return Object.values(surfaces)
22
+ .filter((definition) =>
23
+ Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,
24
+ )
25
+ .filter(({ filter }) => (filter ? filter(data ?? {}) : true))
26
+ .toSorted(byDisposition);
27
+ };
28
+
29
+ /**
30
+ * @returns `true` if there is a contributed surface which matches the specified role & data, `false` otherwise.
31
+ */
32
+ export const isSurfaceAvailable = (context: PluginsContext, { role, data }: Pick<SurfaceProps, 'role' | 'data'>) => {
33
+ const surfaces = context.requestCapabilities(Capabilities.ReactSurface);
34
+ const candidates = findCandidates(surfaces.flat(), { role, data });
35
+ return candidates.length > 0;
36
+ };
37
+
38
+ /**
39
+ * A surface is a named region of the screen that can be populated by plugins.
40
+ */
41
+ export const Surface = memo(
42
+ forwardRef<HTMLElement, SurfaceProps>(
43
+ ({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {
44
+ // TODO(wittjosiah): This will make all surfaces depend on a single signal.
45
+ // This isn't ideal because it means that any change to the data will cause all surfaces to re-render.
46
+ // This effectively means that plugin modules which contribute surfaces need to all be activated at startup.
47
+ // This should be fine for now because it's how it worked prior to capabilities api anyways.
48
+ // In the future, it would be nice to be able to bucket the surface contributions by role.
49
+ const surfaces = useSurfaces();
50
+ const data = useDefaultValue(_data, () => ({}));
51
+
52
+ const candidates = useMemo(() => {
53
+ const definitions = findCandidates(surfaces, { role, data });
54
+ return limit ? definitions.slice(0, limit) : definitions;
55
+ }, [surfaces, role, data, limit]);
56
+
57
+ const nodes = candidates.map(({ component: Component, id }) => (
58
+ <Component ref={forwardedRef} key={id} id={id} role={role} data={data} limit={limit} {...rest} />
59
+ ));
60
+
61
+ const suspense = placeholder ? <Suspense fallback={placeholder}>{nodes}</Suspense> : nodes;
62
+
63
+ return fallback ? (
64
+ <ErrorBoundary data={data} fallback={fallback}>
65
+ {suspense}
66
+ </ErrorBoundary>
67
+ ) : (
68
+ suspense
69
+ );
70
+ },
71
+ ),
72
+ );
@@ -0,0 +1,8 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ export * from './ErrorBoundary';
6
+ export * from './PluginManagerProvider';
7
+ export * from './Surface';
8
+ export * from './useCapabilities';
@@ -0,0 +1,40 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { computed } from '@preact/signals-core';
6
+ import { useMemo } from 'react';
7
+
8
+ import { usePluginManager } from './PluginManagerProvider';
9
+ import { type InterfaceDef } from '../core';
10
+
11
+ /**
12
+ * Hook to request capabilities from the plugin context.
13
+ * @returns An array of capabilities.
14
+ */
15
+ export const useCapabilities = <T, U extends T = T>(
16
+ interfaceDef: InterfaceDef<T>,
17
+ filter?: (capability: T, moduleId: string) => capability is U,
18
+ ) => {
19
+ const manager = usePluginManager();
20
+ const signal = useMemo(
21
+ () => computed(() => manager.context.requestCapabilities(interfaceDef, filter)),
22
+ [interfaceDef],
23
+ );
24
+
25
+ return signal.value;
26
+ };
27
+
28
+ /**
29
+ * Hook to request a capability from the plugin context.
30
+ * @returns The capability.
31
+ * @throws If no capability is found.
32
+ */
33
+ export const useCapability = <T, U extends T = T>(
34
+ interfaceDef: InterfaceDef<T>,
35
+ filter?: (capability: T, moduleId: string) => capability is U,
36
+ ) => {
37
+ const manager = usePluginManager();
38
+ const signal = useMemo(() => computed(() => manager.context.requestCapability(interfaceDef, filter)), [interfaceDef]);
39
+ return signal.value;
40
+ };
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './withPluginManager';
@@ -0,0 +1,47 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+
4
+ //
5
+
6
+ import React from 'react';
7
+
8
+ import { withTheme, type Meta } from '@dxos/storybook-utils';
9
+
10
+ import { withPluginManager } from './withPluginManager';
11
+ import { Capabilities, createSurface } from '../common';
12
+ import { contributes } from '../core';
13
+ import { Surface } from '../react';
14
+
15
+ const Render = () => {
16
+ console.log('Render');
17
+ return (
18
+ <div>
19
+ <div>Hello</div>
20
+ <Surface role='main' />
21
+ </div>
22
+ );
23
+ };
24
+
25
+ const meta: Meta = {
26
+ title: 'sdk/app-framework/withPluginManager',
27
+ render: Render,
28
+ decorators: [
29
+ withTheme,
30
+ withPluginManager({
31
+ capabilities: [
32
+ contributes(
33
+ Capabilities.ReactSurface,
34
+ createSurface({
35
+ id: 'test',
36
+ role: 'main',
37
+ component: ({ role }) => <span>{JSON.stringify({ role })}</span>,
38
+ }),
39
+ ),
40
+ ],
41
+ }),
42
+ ],
43
+ };
44
+
45
+ export default meta;
46
+
47
+ export const Default = {};
@@ -0,0 +1,67 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Decorator } from '@storybook/react';
6
+ import React, { useEffect } from 'react';
7
+
8
+ import { raise } from '@dxos/debug';
9
+
10
+ import { createApp, type CreateAppOptions } from '../App';
11
+ import { Capabilities, Events } from '../common';
12
+ import { type AnyCapability, contributes, defineModule, definePlugin, PluginManager } from '../core';
13
+
14
+ /**
15
+ * Wraps a story with a plugin manager.
16
+ */
17
+ export const withPluginManager = ({
18
+ capabilities,
19
+ plugins = [],
20
+ core = plugins.map(({ meta }) => meta.id),
21
+ ...options
22
+ }: CreateAppOptions & { capabilities?: AnyCapability[] } = {}): Decorator => {
23
+ const pluginManager = new PluginManager({
24
+ pluginLoader: () => raise(new Error('Not implemented')),
25
+ plugins: [StoryPlugin(), ...plugins],
26
+ core: [STORY_PLUGIN, ...core],
27
+ ...options,
28
+ });
29
+
30
+ if (capabilities) {
31
+ capabilities.forEach((capability) => {
32
+ pluginManager.context.contributeCapability({
33
+ interface: capability.interface,
34
+ implementation: capability.implementation,
35
+ module: 'story',
36
+ });
37
+ });
38
+ }
39
+
40
+ const App = createApp({ pluginManager });
41
+
42
+ return (Story, context) => {
43
+ useEffect(() => {
44
+ const capability = contributes(Capabilities.ReactRoot, {
45
+ id: context.id,
46
+ root: () => <Story />,
47
+ });
48
+
49
+ pluginManager.context.contributeCapability({
50
+ ...capability,
51
+ module: 'dxos.org/app-framework/withPluginManager',
52
+ });
53
+
54
+ return () => pluginManager.context.removeCapability(capability.interface, capability.implementation);
55
+ }, []);
56
+
57
+ return <App />;
58
+ };
59
+ };
60
+
61
+ // No-op plugin to ensure there exists at least one plugin for the startup event.
62
+ // This is necessary because `createApp` expects the startup event to complete before the app is ready.
63
+ const STORY_PLUGIN = 'dxos.org/app-framework/story';
64
+ const StoryPlugin = () =>
65
+ definePlugin({ id: STORY_PLUGIN }, [
66
+ defineModule({ id: STORY_PLUGIN, activatesOn: Events.Startup, activate: () => [] }),
67
+ ]);
package/tsconfig.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "ESNext"
9
9
  ],
10
10
  "module": "ESNext",
11
- "outDir": "dist"
11
+ "outDir": "./dist/types"
12
12
  },
13
13
  "exclude": [
14
14
  "/node_modules/"
@@ -16,7 +16,56 @@
16
16
  "include": [
17
17
  "src"
18
18
  ],
19
- "references": [],
19
+ "references": [
20
+ {
21
+ "path": "../../common/async"
22
+ },
23
+ {
24
+ "path": "../../common/context"
25
+ },
26
+ {
27
+ "path": "../../common/debug"
28
+ },
29
+ {
30
+ "path": "../../common/invariant"
31
+ },
32
+ {
33
+ "path": "../../common/local-storage"
34
+ },
35
+ {
36
+ "path": "../../common/log"
37
+ },
38
+ {
39
+ "path": "../../common/storybook-utils"
40
+ },
41
+ {
42
+ "path": "../../common/util"
43
+ },
44
+ {
45
+ "path": "../../core/echo/echo-schema"
46
+ },
47
+ {
48
+ "path": "../../core/echo/echo-signals"
49
+ },
50
+ {
51
+ "path": "../../core/echo/live-object"
52
+ },
53
+ {
54
+ "path": "../../ui/primitives/react-hooks"
55
+ },
56
+ {
57
+ "path": "../../ui/react-ui"
58
+ },
59
+ {
60
+ "path": "../../ui/react-ui-syntax-highlighter"
61
+ },
62
+ {
63
+ "path": "../app-graph"
64
+ },
65
+ {
66
+ "path": "../client-protocol"
67
+ }
68
+ ],
20
69
  "ts-node": {
21
70
  "compilerOptions": {
22
71
  "module": "CommonJS"
@@ -1,72 +0,0 @@
1
- // packages/sdk/app-framework/src/plugins/helpers.ts
2
- import { Context } from "@dxos/context";
3
- import { raise } from "@dxos/debug";
4
- import { invariant } from "@dxos/invariant";
5
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/helpers.ts";
6
- var findPlugin = (plugins, id) => {
7
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
8
- };
9
- var getPlugin = (plugins, id) => {
10
- return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
11
- };
12
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
13
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
14
- var PluginContext = class {
15
- constructor() {
16
- // TODO(burdon): Use Resource (@dima)?
17
- this.ctx = new Context(void 0, {
18
- F: __dxlog_file,
19
- L: 50
20
- });
21
- }
22
- init(plugins) {
23
- this._plugins = plugins;
24
- }
25
- getPlugin(id) {
26
- invariant(this._plugins, void 0, {
27
- F: __dxlog_file,
28
- L: 59,
29
- S: this,
30
- A: [
31
- "this._plugins",
32
- ""
33
- ]
34
- });
35
- return getPlugin(this._plugins, id);
36
- }
37
- resolvePlugin(resolver, required = false) {
38
- invariant(this._plugins, "context not initialized", {
39
- F: __dxlog_file,
40
- L: 65,
41
- S: this,
42
- A: [
43
- "this._plugins",
44
- "'context not initialized'"
45
- ]
46
- });
47
- const plugin = resolvePlugin(this._plugins, resolver);
48
- if (required && !plugin) {
49
- throw new Error("Plugin not found.");
50
- }
51
- return plugin;
52
- }
53
- onDispose(cb) {
54
- this.ctx.onDispose(cb);
55
- }
56
- dispose() {
57
- void this.ctx.dispose();
58
- }
59
- };
60
- var definePlugin = (cb) => {
61
- const context = new PluginContext();
62
- return () => cb(context);
63
- };
64
-
65
- export {
66
- findPlugin,
67
- getPlugin,
68
- filterPlugins,
69
- resolvePlugin,
70
- definePlugin
71
- };
72
- //# sourceMappingURL=chunk-3E7RY3CE.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/helpers.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Context, type DisposeCallback } from '@dxos/context';\nimport { raise } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\n\nimport { type Plugin, type PluginDefinition } from './plugin-host';\n\n/**\n * Resolvers allow different instances of plugins to provide a particular capability.\n */\nexport type PluginResolver<T> = (plugin: Plugin) => Plugin<T> | undefined;\n\n/**\n * Find a plugin by ID.\n */\nexport const findPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> | undefined => {\n return plugins.find(\n (plugin) => plugin.meta.id === id || (typeof plugin.meta.shortId === 'string' && plugin.meta.shortId === id),\n ) as Plugin<T>;\n};\n\n/**\n * Find a plugin by ID, or raise an error if not found.\n */\nexport const getPlugin = <T>(plugins: Plugin[], id: string): Plugin<T> => {\n return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));\n};\n\n/**\n * Filter a list of plugins to only those that match a predicate.\n */\nexport const filterPlugins = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T>[] =>\n plugins.map((plugin) => predicate(plugin)).filter((plugin): plugin is Plugin<T> => !!plugin);\n\n/**\n * Resolves a plugin by predicate.\n *\n * @example\n * import { parseIntentPlugin, resolvePlugin } from '@dxos/app-framework';\n * const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);\n */\nexport const resolvePlugin = <T>(plugins: Plugin[], predicate: PluginResolver<T>): Plugin<T> | undefined =>\n filterPlugins(plugins, predicate)[0];\n\nclass PluginContext {\n // TODO(burdon): Use Resource (@dima)?\n public readonly ctx = new Context();\n\n private _plugins?: Plugin[];\n\n init(plugins: Plugin[]) {\n this._plugins = plugins;\n }\n\n getPlugin<T>(id: string): Plugin<T> {\n invariant(this._plugins);\n return getPlugin(this._plugins, id);\n }\n\n resolvePlugin<T>(resolver: PluginResolver<T>): Plugin<T>;\n resolvePlugin<T>(resolver: PluginResolver<T>, required = false): Plugin<T> | undefined {\n invariant(this._plugins, 'context not initialized');\n const plugin = resolvePlugin(this._plugins, resolver);\n if (required && !plugin) {\n // TODO(burdon): Resolver should have a name.\n throw new Error('Plugin not found.');\n }\n\n return plugin;\n }\n\n onDispose(cb: DisposeCallback) {\n this.ctx.onDispose(cb);\n }\n\n dispose() {\n void this.ctx.dispose();\n }\n}\n\n/**\n * Plugin helper with dependency injection and life-cycle support.\n */\nexport const definePlugin = <Provides>(\n cb: (context: PluginContext) => PluginDefinition<Provides>,\n): (() => PluginDefinition<Provides>) => {\n const context = new PluginContext();\n return () => cb(context);\n};\n"],
5
- "mappings": ";AAIA,SAASA,eAAqC;AAC9C,SAASC,aAAa;AACtB,SAASC,iBAAiB;;AAYnB,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACC,WAAWA,OAAOC,KAAKH,OAAOA,MAAO,OAAOE,OAAOC,KAAKC,YAAY,YAAYF,OAAOC,KAAKC,YAAYJ,EAAAA;AAE7G;AAKO,IAAMK,YAAY,CAAIN,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,KAAOJ,MAAM,IAAIU,MAAM,qBAAqBN,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMO,gBAAgB,CAAIR,SAAmBS,cAClDT,QAAQU,IAAI,CAACP,WAAWM,UAAUN,MAAAA,CAAAA,EAASQ,OAAO,CAACR,WAAgC,CAAC,CAACA,MAAAA;AAShF,IAAMS,gBAAgB,CAAIZ,SAAmBS,cAClDD,cAAcR,SAASS,SAAAA,EAAW,CAAA;AAEpC,IAAMI,gBAAN,MAAMA;EAAN;AAEkBC;eAAM,IAAIlB,QAAAA,QAAAA;;;;;EAI1BmB,KAAKf,SAAmB;AACtB,SAAKgB,WAAWhB;EAClB;EAEAM,UAAaL,IAAuB;AAClCH,cAAU,KAAKkB,UAAQ,QAAA;;;;;;;;;AACvB,WAAOV,UAAU,KAAKU,UAAUf,EAAAA;EAClC;EAGAW,cAAiBK,UAA6BC,WAAW,OAA8B;AACrFpB,cAAU,KAAKkB,UAAU,2BAAA;;;;;;;;;AACzB,UAAMb,SAASS,cAAc,KAAKI,UAAUC,QAAAA;AAC5C,QAAIC,YAAY,CAACf,QAAQ;AAEvB,YAAM,IAAII,MAAM,mBAAA;IAClB;AAEA,WAAOJ;EACT;EAEAgB,UAAUC,IAAqB;AAC7B,SAAKN,IAAIK,UAAUC,EAAAA;EACrB;EAEAC,UAAU;AACR,SAAK,KAAKP,IAAIO,QAAO;EACvB;AACF;AAKO,IAAMC,eAAe,CAC1BF,OAAAA;AAEA,QAAMG,UAAU,IAAIV,cAAAA;AACpB,SAAO,MAAMO,GAAGG,OAAAA;AAClB;",
6
- "names": ["Context", "raise", "invariant", "findPlugin", "plugins", "id", "find", "plugin", "meta", "shortId", "getPlugin", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin", "PluginContext", "ctx", "init", "_plugins", "resolver", "required", "onDispose", "cb", "dispose", "definePlugin", "context"]
7
- }
@@ -1,41 +0,0 @@
1
- // packages/sdk/app-framework/src/plugins/plugin-settings/SettingsPlugin.tsx
2
- import { RootSettingsStore } from "@dxos/local-storage";
3
-
4
- // packages/sdk/app-framework/src/plugins/plugin-settings/meta.ts
5
- var SettingsMeta = {
6
- id: "dxos.org/plugin/settings"
7
- };
8
- var meta_default = SettingsMeta;
9
-
10
- // packages/sdk/app-framework/src/plugins/plugin-settings/SettingsPlugin.tsx
11
- var SettingsPlugin = () => {
12
- const settingsStore = new RootSettingsStore();
13
- return {
14
- meta: meta_default,
15
- provides: {
16
- settingsStore
17
- }
18
- };
19
- };
20
-
21
- // packages/sdk/app-framework/src/plugins/plugin-settings/provides.ts
22
- var parseSettingsPlugin = (plugin) => {
23
- return typeof plugin.provides.settingsStore === "object" ? plugin : void 0;
24
- };
25
- var SETTINGS_PLUGIN = "dxos.org/plugin/settings";
26
- var SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;
27
- var SettingsAction;
28
- (function(SettingsAction2) {
29
- SettingsAction2[SettingsAction2["OPEN"] = `${SETTINGS_ACTION}/open`] = "OPEN";
30
- })(SettingsAction || (SettingsAction = {}));
31
-
32
- // packages/sdk/app-framework/src/plugins/plugin-settings/index.ts
33
- var plugin_settings_default = SettingsPlugin;
34
-
35
- export {
36
- meta_default,
37
- parseSettingsPlugin,
38
- SettingsAction,
39
- plugin_settings_default
40
- };
41
- //# sourceMappingURL=chunk-653Y45CL.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-settings/SettingsPlugin.tsx", "../../../src/plugins/plugin-settings/meta.ts", "../../../src/plugins/plugin-settings/provides.ts", "../../../src/plugins/plugin-settings/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { RootSettingsStore } from '@dxos/local-storage';\n\nimport SettingsMeta from './meta';\nimport { type SettingsPluginProvides } from './provides';\nimport { type PluginDefinition } from '../plugin-host';\n\nexport const SettingsPlugin = (): PluginDefinition<SettingsPluginProvides> => {\n // Global settings singleton.\n // TODO(burdon): Make settings storage extensible so that other plugins can decide the persistence of them.\n const settingsStore = new RootSettingsStore();\n\n return {\n meta: SettingsMeta,\n provides: {\n settingsStore,\n },\n };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SettingsMeta = {\n id: 'dxos.org/plugin/settings',\n};\n\nexport default SettingsMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SettingsStoreFactory, type SettingsValue } from '@dxos/local-storage';\n\nimport { type Plugin } from '../plugin-host';\n\nexport type SettingsProvides<T extends SettingsValue> = {\n settings: T;\n};\n\nexport type SettingsPluginProvides = {\n settingsStore: SettingsStoreFactory;\n};\n\nexport const parseSettingsPlugin = (plugin: Plugin) => {\n return typeof (plugin.provides as any).settingsStore === 'object'\n ? (plugin as Plugin<SettingsPluginProvides>)\n : undefined;\n};\n\nconst SETTINGS_PLUGIN = 'dxos.org/plugin/settings';\n\nconst SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;\n\nexport enum SettingsAction {\n OPEN = `${SETTINGS_ACTION}/open`,\n}\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SettingsPlugin } from './SettingsPlugin';\n\nexport * from './provides';\n\nexport default SettingsPlugin;\n"],
5
- "mappings": ";AAIA,SAASA,yBAAyB;;;ACAlC,IAAMC,eAAe;EACnBC,IAAI;AACN;AAEA,IAAA,eAAeD;;;ADER,IAAME,iBAAiB,MAAA;AAG5B,QAAMC,gBAAgB,IAAIC,kBAAAA;AAE1B,SAAO;IACLC,MAAMC;IACNC,UAAU;MACRJ;IACF;EACF;AACF;;;AELO,IAAMK,sBAAsB,CAACC,WAAAA;AAClC,SAAO,OAAQA,OAAOC,SAAiBC,kBAAkB,WACpDF,SACDG;AACN;AAEA,IAAMC,kBAAkB;AAExB,IAAMC,kBAAkB,GAAGD,eAAAA;;UAEfE,iBAAAA;4CACH,GAAGD,eAAAA,OAAsB,IAAA;GADtBC,mBAAAA,iBAAAA,CAAAA,EAAAA;;;AClBZ,IAAA,0BAAeC;",
6
- "names": ["RootSettingsStore", "SettingsMeta", "id", "SettingsPlugin", "settingsStore", "RootSettingsStore", "meta", "SettingsMeta", "provides", "parseSettingsPlugin", "plugin", "provides", "settingsStore", "undefined", "SETTINGS_PLUGIN", "SETTINGS_ACTION", "SettingsAction", "SettingsPlugin"]
7
- }