@dxos/app-framework 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (383) hide show
  1. package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs +137 -0
  2. package/dist/lib/browser/app-graph-builder-S4MYSHQA.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-BCMEJONP.mjs +1432 -0
  4. package/dist/lib/browser/chunk-BCMEJONP.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-QS4J6O47.mjs +285 -0
  6. package/dist/lib/browser/chunk-QS4J6O47.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-SRZH2PQ2.mjs +32 -0
  8. package/dist/lib/browser/chunk-SRZH2PQ2.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +119 -642
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/intent-dispatcher-GFBH7T2J.mjs +11 -0
  12. package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs +39 -0
  13. package/dist/lib/browser/intent-resolver-KAFM7CQH.mjs.map +7 -0
  14. package/dist/lib/browser/meta.json +1 -1
  15. package/dist/lib/browser/store-L3VRR7II.mjs +29 -0
  16. package/dist/lib/browser/store-L3VRR7II.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-VMHWFCTP.cjs +146 -0
  21. package/dist/lib/node/app-graph-builder-VMHWFCTP.cjs.map +7 -0
  22. package/dist/lib/node/chunk-7Y6KJ3OK.cjs +1466 -0
  23. package/dist/lib/node/chunk-7Y6KJ3OK.cjs.map +7 -0
  24. package/dist/lib/node/chunk-B65NJEIJ.cjs +308 -0
  25. package/dist/lib/node/chunk-B65NJEIJ.cjs.map +7 -0
  26. package/dist/lib/node/{chunk-FCMHRU3M.cjs → chunk-VCIHQZSN.cjs} +23 -35
  27. package/dist/lib/node/chunk-VCIHQZSN.cjs.map +7 -0
  28. package/dist/lib/node/index.cjs +125 -665
  29. package/dist/lib/node/index.cjs.map +4 -4
  30. package/dist/lib/node/{plugin-settings-W6UHMH5M.cjs → intent-dispatcher-PRCC4KZT.cjs} +10 -14
  31. package/dist/lib/node/intent-dispatcher-PRCC4KZT.cjs.map +7 -0
  32. package/dist/lib/node/intent-resolver-OZDKCHPW.cjs +46 -0
  33. package/dist/lib/node/intent-resolver-OZDKCHPW.cjs.map +7 -0
  34. package/dist/lib/node/meta.json +1 -1
  35. package/dist/lib/node/store-BVUKNVKL.cjs +44 -0
  36. package/dist/lib/node/store-BVUKNVKL.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-XHI5IIXQ.mjs +138 -0
  42. package/dist/lib/node-esm/app-graph-builder-XHI5IIXQ.mjs.map +7 -0
  43. package/dist/lib/node-esm/chunk-CBT75GCX.mjs +34 -0
  44. package/dist/lib/node-esm/chunk-CBT75GCX.mjs.map +7 -0
  45. package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs +286 -0
  46. package/dist/lib/node-esm/chunk-JDAHZRYQ.mjs.map +7 -0
  47. package/dist/lib/node-esm/chunk-TVIR2PHY.mjs +1434 -0
  48. package/dist/lib/node-esm/chunk-TVIR2PHY.mjs.map +7 -0
  49. package/dist/lib/node-esm/index.mjs +119 -642
  50. package/dist/lib/node-esm/index.mjs.map +4 -4
  51. package/dist/lib/node-esm/intent-dispatcher-LGACN32C.mjs +12 -0
  52. package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs +40 -0
  53. package/dist/lib/node-esm/intent-resolver-RBNG76ZX.mjs.map +7 -0
  54. package/dist/lib/node-esm/meta.json +1 -1
  55. package/dist/lib/node-esm/store-PHTOEREN.mjs +30 -0
  56. package/dist/lib/node-esm/store-PHTOEREN.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 +304 -0
  63. package/dist/types/src/common/capabilities.d.ts.map +1 -0
  64. package/dist/types/src/common/events.d.ts +52 -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 +262 -0
  73. package/dist/types/src/common/layout.d.ts.map +1 -0
  74. package/dist/types/src/{plugins/plugin-surface/SurfaceContext.d.ts → common/surface.d.ts} +12 -29
  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 +5 -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 +5 -0
  105. package/dist/types/src/playground/generator/Main.d.ts.map +1 -0
  106. package/dist/types/src/playground/generator/Toolbar.d.ts +5 -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 +5 -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 +9 -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.map +1 -0
  141. package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent.d.ts +8 -28
  142. package/dist/types/src/plugin-intent/intent.d.ts.map +1 -0
  143. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts +2 -0
  144. package/dist/types/src/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  145. package/dist/types/src/plugin-settings/actions.d.ts +27 -0
  146. package/dist/types/src/plugin-settings/actions.d.ts.map +1 -0
  147. package/dist/types/src/plugin-settings/app-graph-builder.d.ts +197 -0
  148. package/dist/types/src/plugin-settings/app-graph-builder.d.ts.map +1 -0
  149. package/dist/types/src/plugin-settings/index.d.ts +3 -0
  150. package/dist/types/src/plugin-settings/index.d.ts.map +1 -0
  151. package/dist/types/src/plugin-settings/intent-resolver.d.ts +4 -0
  152. package/dist/types/src/plugin-settings/intent-resolver.d.ts.map +1 -0
  153. package/dist/types/src/plugin-settings/store.d.ts +5 -0
  154. package/dist/types/src/plugin-settings/store.d.ts.map +1 -0
  155. package/dist/types/src/plugin-settings/translations.d.ts +11 -0
  156. package/dist/types/src/plugin-settings/translations.d.ts.map +1 -0
  157. package/dist/types/src/{plugins/plugin-surface → react}/ErrorBoundary.d.ts +1 -1
  158. package/dist/types/src/react/ErrorBoundary.d.ts.map +1 -0
  159. package/dist/types/src/{plugins/plugin-intent → react}/IntentContext.d.ts +2 -2
  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 +15 -0
  166. package/dist/types/src/react/Surface.stories.d.ts.map +1 -0
  167. package/dist/types/src/react/common.d.ts +13 -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 -1
  184. package/package.json +40 -19
  185. package/project.json +5 -3
  186. package/src/App.tsx +140 -34
  187. package/src/common/capabilities.ts +101 -0
  188. package/src/common/events.ts +77 -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 +238 -0
  193. package/src/{plugins/plugin-surface/SurfaceContext.ts → common/surface.ts} +6 -37
  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/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.ts +83 -63
  226. package/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.ts +118 -95
  227. package/src/{plugins/plugin-intent → plugin-intent}/intent.ts +10 -26
  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 +34 -0
  233. package/src/plugin-settings/store.ts +30 -0
  234. package/src/plugin-settings/translations.ts +17 -0
  235. package/src/{plugins/plugin-intent → react}/IntentContext.tsx +13 -5
  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 +19 -13
  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-QG25ZU2N.mjs +0 -320
  251. package/dist/lib/browser/chunk-QG25ZU2N.mjs.map +0 -7
  252. package/dist/lib/browser/chunk-SPDTXTOV.mjs +0 -163
  253. package/dist/lib/browser/chunk-SPDTXTOV.mjs.map +0 -7
  254. package/dist/lib/browser/chunk-WBOXEHBE.mjs +0 -51
  255. package/dist/lib/browser/chunk-WBOXEHBE.mjs.map +0 -7
  256. package/dist/lib/browser/plugin-intent-T7Y3MJ5C.mjs +0 -32
  257. package/dist/lib/browser/plugin-settings-5U2L2NRU.mjs +0 -15
  258. package/dist/lib/browser/plugin-surface-OKPF3EQI.mjs +0 -24
  259. package/dist/lib/node/chunk-BW3RNEVI.cjs +0 -185
  260. package/dist/lib/node/chunk-BW3RNEVI.cjs.map +0 -7
  261. package/dist/lib/node/chunk-FCMHRU3M.cjs.map +0 -7
  262. package/dist/lib/node/chunk-QBM42OQ6.cjs +0 -97
  263. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +0 -7
  264. package/dist/lib/node/chunk-VWHAALIN.cjs +0 -344
  265. package/dist/lib/node/chunk-VWHAALIN.cjs.map +0 -7
  266. package/dist/lib/node/plugin-intent-F3TQZIUR.cjs +0 -53
  267. package/dist/lib/node/plugin-intent-F3TQZIUR.cjs.map +0 -7
  268. package/dist/lib/node/plugin-settings-W6UHMH5M.cjs.map +0 -7
  269. package/dist/lib/node/plugin-surface-CCSIONYW.cjs +0 -45
  270. package/dist/lib/node/plugin-surface-CCSIONYW.cjs.map +0 -7
  271. package/dist/lib/node-esm/chunk-3T5UIJY3.mjs +0 -53
  272. package/dist/lib/node-esm/chunk-3T5UIJY3.mjs.map +0 -7
  273. package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs +0 -164
  274. package/dist/lib/node-esm/chunk-4GX7V5ZE.mjs.map +0 -7
  275. package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs +0 -321
  276. package/dist/lib/node-esm/chunk-CFOUYXQ6.mjs.map +0 -7
  277. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +0 -74
  278. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +0 -7
  279. package/dist/lib/node-esm/plugin-intent-W2HQC6LC.mjs +0 -33
  280. package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs +0 -16
  281. package/dist/lib/node-esm/plugin-settings-H5RHNFVC.mjs.map +0 -7
  282. package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs +0 -25
  283. package/dist/lib/node-esm/plugin-surface-V3YET3UL.mjs.map +0 -7
  284. package/dist/types/src/plugins/common/file.d.ts +0 -22
  285. package/dist/types/src/plugins/common/file.d.ts.map +0 -1
  286. package/dist/types/src/plugins/common/graph.d.ts +0 -51
  287. package/dist/types/src/plugins/common/graph.d.ts.map +0 -1
  288. package/dist/types/src/plugins/common/index.d.ts +0 -7
  289. package/dist/types/src/plugins/common/index.d.ts.map +0 -1
  290. package/dist/types/src/plugins/common/layout.d.ts +0 -176
  291. package/dist/types/src/plugins/common/layout.d.ts.map +0 -1
  292. package/dist/types/src/plugins/common/metadata.d.ts +0 -16
  293. package/dist/types/src/plugins/common/metadata.d.ts.map +0 -1
  294. package/dist/types/src/plugins/common/navigation.d.ts +0 -243
  295. package/dist/types/src/plugins/common/navigation.d.ts.map +0 -1
  296. package/dist/types/src/plugins/common/translations.d.ts +0 -22
  297. package/dist/types/src/plugins/common/translations.d.ts.map +0 -1
  298. package/dist/types/src/plugins/helpers.d.ts +0 -41
  299. package/dist/types/src/plugins/helpers.d.ts.map +0 -1
  300. package/dist/types/src/plugins/index.d.ts +0 -7
  301. package/dist/types/src/plugins/index.d.ts.map +0 -1
  302. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts +0 -16
  303. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +0 -1
  304. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts +0 -14
  305. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +0 -1
  306. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts +0 -47
  307. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +0 -1
  308. package/dist/types/src/plugins/plugin-host/index.d.ts +0 -6
  309. package/dist/types/src/plugins/plugin-host/index.d.ts.map +0 -1
  310. package/dist/types/src/plugins/plugin-host/plugin.d.ts +0 -104
  311. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +0 -1
  312. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts +0 -35
  313. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +0 -1
  314. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +0 -1
  315. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts +0 -8
  316. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +0 -1
  317. package/dist/types/src/plugins/plugin-intent/index.d.ts +0 -7
  318. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +0 -1
  319. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts +0 -107
  320. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.d.ts.map +0 -1
  321. package/dist/types/src/plugins/plugin-intent/intent-dispatcher.test.d.ts.map +0 -1
  322. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +0 -1
  323. package/dist/types/src/plugins/plugin-intent/meta.d.ts +0 -6
  324. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +0 -1
  325. package/dist/types/src/plugins/plugin-intent/provides.d.ts +0 -16
  326. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +0 -1
  327. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +0 -4
  328. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +0 -1
  329. package/dist/types/src/plugins/plugin-settings/index.d.ts +0 -4
  330. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +0 -1
  331. package/dist/types/src/plugins/plugin-settings/meta.d.ts +0 -5
  332. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +0 -1
  333. package/dist/types/src/plugins/plugin-settings/provides.d.ts +0 -26
  334. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +0 -1
  335. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +0 -1
  336. package/dist/types/src/plugins/plugin-surface/Surface.d.ts +0 -7
  337. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +0 -1
  338. package/dist/types/src/plugins/plugin-surface/SurfaceContext.d.ts.map +0 -1
  339. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +0 -7
  340. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +0 -1
  341. package/dist/types/src/plugins/plugin-surface/helpers.d.ts +0 -21
  342. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +0 -1
  343. package/dist/types/src/plugins/plugin-surface/index.d.ts +0 -8
  344. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +0 -1
  345. package/dist/types/src/plugins/plugin-surface/meta.d.ts +0 -5
  346. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +0 -1
  347. package/dist/types/src/plugins/plugin-surface/provides.d.ts +0 -17
  348. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +0 -1
  349. package/src/plugins/common/file.ts +0 -36
  350. package/src/plugins/common/graph.ts +0 -70
  351. package/src/plugins/common/layout.ts +0 -173
  352. package/src/plugins/common/metadata.ts +0 -29
  353. package/src/plugins/common/navigation.ts +0 -214
  354. package/src/plugins/common/translations.ts +0 -36
  355. package/src/plugins/helpers.ts +0 -92
  356. package/src/plugins/index.ts +0 -11
  357. package/src/plugins/plugin-host/HostPlugin.tsx +0 -88
  358. package/src/plugins/plugin-host/PluginContainer.tsx +0 -120
  359. package/src/plugins/plugin-host/PluginContext.tsx +0 -79
  360. package/src/plugins/plugin-host/index.ts +0 -12
  361. package/src/plugins/plugin-host/plugin.test.ts +0 -158
  362. package/src/plugins/plugin-host/plugin.ts +0 -133
  363. package/src/plugins/plugin-intent/IntentPlugin.tsx +0 -75
  364. package/src/plugins/plugin-intent/index.ts +0 -13
  365. package/src/plugins/plugin-intent/meta.ts +0 -11
  366. package/src/plugins/plugin-intent/provides.ts +0 -26
  367. package/src/plugins/plugin-settings/SettingsPlugin.tsx +0 -22
  368. package/src/plugins/plugin-settings/index.ts +0 -9
  369. package/src/plugins/plugin-settings/meta.ts +0 -9
  370. package/src/plugins/plugin-settings/provides.ts +0 -34
  371. package/src/plugins/plugin-surface/Surface.tsx +0 -62
  372. package/src/plugins/plugin-surface/SurfacePlugin.tsx +0 -45
  373. package/src/plugins/plugin-surface/helpers.ts +0 -22
  374. package/src/plugins/plugin-surface/index.ts +0 -14
  375. package/src/plugins/plugin-surface/meta.ts +0 -9
  376. package/src/plugins/plugin-surface/provides.ts +0 -27
  377. /package/{.eslintrc.js → .eslintrc.cjs} +0 -0
  378. /package/dist/lib/browser/{plugin-intent-T7Y3MJ5C.mjs.map → intent-dispatcher-GFBH7T2J.mjs.map} +0 -0
  379. /package/dist/lib/browser/{plugin-settings-5U2L2NRU.mjs.map → worker.mjs.map} +0 -0
  380. /package/dist/lib/{browser/plugin-surface-OKPF3EQI.mjs.map → node-esm/intent-dispatcher-LGACN32C.mjs.map} +0 -0
  381. /package/dist/lib/node-esm/{plugin-intent-W2HQC6LC.mjs.map → worker.mjs.map} +0 -0
  382. /package/dist/types/src/{plugins/plugin-intent → plugin-intent}/intent-dispatcher.test.d.ts +0 -0
  383. /package/src/{plugins/plugin-surface → react}/ErrorBoundary.tsx +0 -0
@@ -1,51 +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
- import { S } from "@dxos/echo-schema";
23
- var parseSettingsPlugin = (plugin) => {
24
- return typeof plugin.provides.settingsStore === "object" ? plugin : void 0;
25
- };
26
- var SETTINGS_PLUGIN = "dxos.org/plugin/settings";
27
- var SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;
28
- var SettingsAction;
29
- (function(SettingsAction2) {
30
- class Open extends S.TaggedClass()(`${SETTINGS_ACTION}/open`, {
31
- input: S.Struct({
32
- plugin: S.optional(S.String)
33
- }),
34
- output: S.Void
35
- }) {
36
- }
37
- SettingsAction2.Open = Open;
38
- })(SettingsAction || (SettingsAction = {}));
39
-
40
- // packages/sdk/app-framework/src/plugins/plugin-settings/index.ts
41
- var plugin_settings_default = SettingsPlugin;
42
-
43
- export {
44
- meta_default,
45
- parseSettingsPlugin,
46
- SETTINGS_PLUGIN,
47
- SETTINGS_ACTION,
48
- SettingsAction,
49
- plugin_settings_default
50
- };
51
- //# sourceMappingURL=chunk-WBOXEHBE.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 { S } from '@dxos/echo-schema';\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\nexport const SETTINGS_PLUGIN = 'dxos.org/plugin/settings';\nexport const SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;\n\nexport namespace SettingsAction {\n export class Open extends S.TaggedClass<Open>()(`${SETTINGS_ACTION}/open`, {\n input: S.Struct({\n plugin: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\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;;;AEjBA,SAASK,SAAS;AAaX,IAAMC,sBAAsB,CAACC,WAAAA;AAClC,SAAO,OAAQA,OAAOC,SAAiBC,kBAAkB,WACpDF,SACDG;AACN;AAEO,IAAMC,kBAAkB;AACxB,IAAMC,kBAAkB,GAAGD,eAAAA;;UAEjBE,iBAAAA;EACR,MAAMC,aAAaC,EAAEC,YAAW,EAAS,GAAGJ,eAAAA,SAAwB;IACzEK,OAAOF,EAAEG,OAAO;MACdX,QAAQQ,EAAEI,SAASJ,EAAEK,MAAM;IAC7B,CAAA;IACAC,QAAQN,EAAEO;EACZ,CAAA,EAAA;EAAI;kBALSR,OAAAA;AAMf,GAPiBD,mBAAAA,iBAAAA,CAAAA,EAAAA;;;AClBjB,IAAA,0BAAeU;",
6
- "names": ["RootSettingsStore", "SettingsMeta", "id", "SettingsPlugin", "settingsStore", "RootSettingsStore", "meta", "SettingsMeta", "provides", "S", "parseSettingsPlugin", "plugin", "provides", "settingsStore", "undefined", "SETTINGS_PLUGIN", "SETTINGS_ACTION", "SettingsAction", "Open", "S", "TaggedClass", "input", "Struct", "optional", "String", "output", "Void", "SettingsPlugin"]
7
- }
@@ -1,32 +0,0 @@
1
- import {
2
- INTENT_ACTION,
3
- IntentAction,
4
- IntentProvider,
5
- Label,
6
- chain,
7
- createDispatcher,
8
- createIntent,
9
- createResolver,
10
- parseIntentPlugin,
11
- parseIntentResolverPlugin,
12
- plugin_intent_default,
13
- useIntentDispatcher,
14
- useIntentResolver
15
- } from "./chunk-QG25ZU2N.mjs";
16
- import "./chunk-3E7RY3CE.mjs";
17
- export {
18
- INTENT_ACTION,
19
- IntentAction,
20
- IntentProvider,
21
- Label,
22
- chain,
23
- createDispatcher,
24
- createIntent,
25
- createResolver,
26
- plugin_intent_default as default,
27
- parseIntentPlugin,
28
- parseIntentResolverPlugin,
29
- useIntentDispatcher,
30
- useIntentResolver
31
- };
32
- //# sourceMappingURL=plugin-intent-T7Y3MJ5C.mjs.map
@@ -1,15 +0,0 @@
1
- import {
2
- SETTINGS_ACTION,
3
- SETTINGS_PLUGIN,
4
- SettingsAction,
5
- parseSettingsPlugin,
6
- plugin_settings_default
7
- } from "./chunk-WBOXEHBE.mjs";
8
- export {
9
- SETTINGS_ACTION,
10
- SETTINGS_PLUGIN,
11
- SettingsAction,
12
- plugin_settings_default as default,
13
- parseSettingsPlugin
14
- };
15
- //# sourceMappingURL=plugin-settings-5U2L2NRU.mjs.map
@@ -1,24 +0,0 @@
1
- import {
2
- ErrorBoundary,
3
- Surface,
4
- SurfaceProvider,
5
- createSurface,
6
- isObject,
7
- parseRootSurfacePlugin,
8
- parseSurfacePlugin,
9
- plugin_surface_default,
10
- useSurfaceRoot
11
- } from "./chunk-SPDTXTOV.mjs";
12
- import "./chunk-3E7RY3CE.mjs";
13
- export {
14
- ErrorBoundary,
15
- Surface,
16
- SurfaceProvider,
17
- createSurface,
18
- plugin_surface_default as default,
19
- isObject,
20
- parseRootSurfacePlugin,
21
- parseSurfacePlugin,
22
- useSurfaceRoot
23
- };
24
- //# sourceMappingURL=plugin-surface-OKPF3EQI.mjs.map
@@ -1,185 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_BW3RNEVI_exports = {};
30
- __export(chunk_BW3RNEVI_exports, {
31
- ErrorBoundary: () => ErrorBoundary,
32
- Surface: () => Surface,
33
- SurfaceProvider: () => SurfaceProvider,
34
- createSurface: () => createSurface,
35
- isObject: () => isObject,
36
- meta_default: () => meta_default,
37
- parseRootSurfacePlugin: () => parseRootSurfacePlugin,
38
- parseSurfacePlugin: () => parseSurfacePlugin,
39
- plugin_surface_default: () => plugin_surface_default,
40
- useSurfaceRoot: () => useSurfaceRoot
41
- });
42
- module.exports = __toCommonJS(chunk_BW3RNEVI_exports);
43
- var import_chunk_QBM42OQ6 = require("./chunk-QBM42OQ6.cjs");
44
- var import_react = __toESM(require("react"));
45
- var import_live_object = require("@dxos/live-object");
46
- var import_react2 = require("react");
47
- var import_debug = require("@dxos/debug");
48
- var import_react3 = __toESM(require("react"));
49
- var import_react4 = __toESM(require("react"));
50
- var import_react_hooks = require("@dxos/react-hooks");
51
- var createSurface = (definition) => definition;
52
- var SurfaceContext = (0, import_react2.createContext)(void 0);
53
- var useSurfaceRoot = () => (0, import_react2.useContext)(SurfaceContext) ?? (0, import_debug.raise)(new Error("Missing SurfaceContext"));
54
- var SurfaceProvider = SurfaceContext.Provider;
55
- var SurfaceMeta = {
56
- id: "dxos.org/plugin/surface"
57
- };
58
- var meta_default = SurfaceMeta;
59
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.surfaces ? plugin : void 0;
60
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.definitions ? plugin : void 0;
61
- var SurfacePlugin = () => {
62
- const state = (0, import_live_object.create)({
63
- surfaces: {},
64
- debugInfo: /* @__PURE__ */ new Map()
65
- });
66
- return {
67
- meta: meta_default,
68
- ready: async (context) => {
69
- state.surfaces = (0, import_chunk_QBM42OQ6.filterPlugins)(context.plugins, parseSurfacePlugin).reduce((acc, plugin) => reduceSurfaces(plugin.provides.surface.definitions(context), acc), {});
70
- },
71
- provides: {
72
- surface: state,
73
- context: ({ children }) => /* @__PURE__ */ import_react.default.createElement(SurfaceProvider, {
74
- value: state
75
- }, children)
76
- }
77
- };
78
- };
79
- var reduceSurfaces = (definitions, surfaces = {}) => {
80
- if (Array.isArray(definitions)) {
81
- return definitions.reduce((acc, definition) => reduceSurfaces(definition, acc), surfaces);
82
- }
83
- return {
84
- ...surfaces,
85
- [definitions.id]: definitions
86
- };
87
- };
88
- var isObject = (data) => !!data && typeof data === "object";
89
- var ErrorBoundary = class extends import_react3.Component {
90
- constructor(props) {
91
- super(props);
92
- this.state = {
93
- error: void 0
94
- };
95
- }
96
- static getDerivedStateFromError(error) {
97
- return {
98
- error
99
- };
100
- }
101
- componentDidUpdate(prevProps) {
102
- if (prevProps.data !== this.props.data) {
103
- this.resetError();
104
- }
105
- }
106
- render() {
107
- if (this.state.error) {
108
- return /* @__PURE__ */ import_react3.default.createElement(this.props.fallback, {
109
- data: this.props.data,
110
- error: this.state.error,
111
- reset: this.resetError
112
- });
113
- }
114
- return this.props.children;
115
- }
116
- resetError() {
117
- this.setState({
118
- error: void 0
119
- });
120
- }
121
- };
122
- var Surface = /* @__PURE__ */ (0, import_react4.memo)(/* @__PURE__ */ (0, import_react4.forwardRef)(({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {
123
- const { surfaces, debugInfo } = useSurfaceRoot();
124
- const data = (0, import_react_hooks.useDefaultValue)(_data, () => ({}));
125
- const reactId = (0, import_react4.useId)();
126
- const id = _id ?? reactId;
127
- (0, import_react4.useEffect)(() => {
128
- debugInfo?.set(id, {
129
- id,
130
- created: Date.now(),
131
- role,
132
- renderCount: 0
133
- });
134
- return () => {
135
- debugInfo?.delete(id);
136
- };
137
- }, [
138
- id
139
- ]);
140
- if (debugInfo?.get(id)) {
141
- debugInfo.get(id).renderCount++;
142
- }
143
- const candidates = (0, import_react4.useMemo)(() => {
144
- const definitions = Object.values(surfaces).filter((definition) => Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role).filter(({ filter }) => filter ? filter(data) : true).toSorted(({ disposition: a = "static" }, { disposition: b = "static" }) => {
145
- return a === b ? 0 : a === "hoist" || b === "fallback" ? -1 : b === "hoist" || a === "fallback" ? 1 : 0;
146
- });
147
- return limit ? definitions.slice(0, limit) : definitions;
148
- }, [
149
- surfaces,
150
- role,
151
- data,
152
- limit
153
- ]);
154
- const nodes = candidates.map(({ component: Component2, id: id2 }) => /* @__PURE__ */ import_react4.default.createElement(Component2, {
155
- ref: forwardedRef,
156
- key: id2,
157
- id: id2,
158
- role,
159
- data,
160
- limit,
161
- ...rest
162
- }));
163
- const suspense = placeholder ? /* @__PURE__ */ import_react4.default.createElement(import_react4.Suspense, {
164
- fallback: placeholder
165
- }, nodes) : nodes;
166
- return fallback ? /* @__PURE__ */ import_react4.default.createElement(ErrorBoundary, {
167
- data,
168
- fallback
169
- }, suspense) : suspense;
170
- }));
171
- var plugin_surface_default = SurfacePlugin;
172
- // Annotate the CommonJS export names for ESM import in node:
173
- 0 && (module.exports = {
174
- ErrorBoundary,
175
- Surface,
176
- SurfaceProvider,
177
- createSurface,
178
- isObject,
179
- meta_default,
180
- parseRootSurfacePlugin,
181
- parseSurfacePlugin,
182
- plugin_surface_default,
183
- useSurfaceRoot
184
- });
185
- //# sourceMappingURL=chunk-BW3RNEVI.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-surface/SurfacePlugin.tsx", "../../../src/plugins/plugin-surface/SurfaceContext.ts", "../../../src/plugins/plugin-surface/meta.ts", "../../../src/plugins/plugin-surface/provides.ts", "../../../src/plugins/plugin-surface/helpers.ts", "../../../src/plugins/plugin-surface/ErrorBoundary.tsx", "../../../src/plugins/plugin-surface/Surface.tsx", "../../../src/plugins/plugin-surface/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/live-object';\n\nimport { SurfaceProvider, type SurfaceContextValue } from './SurfaceContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides, type SurfaceDefinitions } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\n/**\n * Provides a registry of surface components.\n */\nexport const SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceContextValue>({ surfaces: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (context) => {\n state.surfaces = filterPlugins(context.plugins, parseSurfacePlugin).reduce(\n (acc, plugin) => reduceSurfaces(plugin.provides.surface.definitions(context), acc),\n {},\n );\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n\nconst reduceSurfaces = (\n definitions: SurfaceDefinitions,\n surfaces: SurfaceContextValue['surfaces'] = {},\n): SurfaceContextValue['surfaces'] => {\n if (Array.isArray(definitions)) {\n return definitions.reduce((acc, definition) => reduceSurfaces(definition, acc), surfaces);\n }\n\n return { ...surfaces, [definitions.id]: definitions };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef, type PropsWithChildren, type ReactNode } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { type GuardedType, type MakeOptional } from '@dxos/util';\n\nimport { type ErrorBoundary } from './ErrorBoundary';\n\n/**\n * SurfaceProps are the props that are passed to the Surface component.\n */\nexport type SurfaceProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<{\n /**\n * If specified, the Surface will be wrapped in an error boundary.\n * The fallback component will be rendered if an error occurs.\n */\n fallback?: ErrorBoundary['props']['fallback'];\n\n /**\n * If specified, the Surface will be wrapped in a suspense boundary.\n * The placeholder component will be rendered while the surface component is loading.\n */\n placeholder?: ReactNode;\n}> &\n MakeOptional<CoreSurfaceProps<T>, 'id' | 'data'> & {\n /**\n * Additional props to pass to the component.\n * These props are not used by Surface itself but may be used by components which resolve the surface.\n */\n [key: string]: unknown;\n };\n\n// NOTE: If `[key: string]: unknown` is included in shared types, when re-used other fields become unknown as well.\ntype CoreSurfaceProps<T extends Record<string, any> = Record<string, unknown>> = {\n /**\n * ID for debugging.\n */\n id: string;\n\n /**\n * Role defines how the data should be rendered.\n */\n role: string;\n\n /**\n * The data to be rendered by the surface.\n */\n data: T;\n\n /**\n * If more than one component is resolved, the limit determines how many are rendered.\n */\n limit?: number | undefined;\n};\n\ntype SurfaceComponentProps<T extends Record<string, any> = Record<string, unknown>> = PropsWithChildren<\n CoreSurfaceProps<T> & { [key: string]: unknown }\n>;\n\n/**\n * React component used to render a surface once is has matched.\n */\nexport type SurfaceComponent<T extends Record<string, any> = Record<string, unknown>> = (\n props: SurfaceComponentProps<T>,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | null;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n *\n * - `static` - The component is rendered in the order it was resolved.\n * - `hoist` - The component is rendered before `static` components.\n * - `fallback` - The component is rendered after `static` components.\n */\nexport type SurfaceDisposition = 'static' | 'hoist' | 'fallback';\n\n/**\n * Definition of when a SurfaceComponent should be rendered.\n */\nexport type SurfaceDefinition<T extends Record<string, any> = any> = {\n id: string;\n role: string | string[];\n disposition?: SurfaceDisposition;\n filter?: (data: Record<string, unknown>) => data is T;\n component: SurfaceComponent<GuardedType<SurfaceDefinition<T>['filter']>>;\n};\n\nexport const createSurface = <T extends Record<string, any> = any>(definition: SurfaceDefinition<T>) => definition;\n\n/**\n * Surface debug info.\n * NOTE: Short-term measure to track perf issues.\n */\nexport type DebugInfo = {\n id: string;\n created: number;\n renderCount: number;\n} & Pick<SurfaceProps, 'role'>;\n\nexport type SurfaceContextValue = {\n surfaces: Record<string, SurfaceDefinition>;\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceContext = createContext<SurfaceContextValue | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceContext) ?? raise(new Error('Missing SurfaceContext'));\n\nexport const SurfaceProvider = SurfaceContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceDefinition, type SurfaceContextValue } from './SurfaceContext';\nimport { type HostContext, type Plugin } from '../plugin-host';\n\nexport type SurfaceDefinitions = SurfaceDefinition | SurfaceDefinition[] | SurfaceDefinitions[];\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n definitions: (context: HostContext) => SurfaceDefinitions;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceContextValue;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.surfaces ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.definitions ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\n/**\n * Checks if the given data is an object and not null.\n *\n * Useful inside surface component resolvers as a type guard.\n *\n * @example\n * ```ts\n * const old =\n * data.content &&\n * typeof data.content === 'object' &&\n * 'id' in data.content &&\n * typeof data.content.id === 'string';\n *\n * // becomes\n * const new = isObject(data.content) && typeof data.content.id === 'string';\n * ```\n */\nexport const isObject = (data: unknown): data is { [key: string]: unknown } => !!data && typeof data === 'object';\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { Component, type FC, type PropsWithChildren } from 'react';\n\ntype Props = PropsWithChildren<{ data?: any; fallback: FC<{ data?: any; error: Error; reset: () => void }> }>;\ntype State = { error: Error | undefined };\n\n/**\n * Surface error boundary.\n *\n * For basic usage prefer providing a fallback component to `Surface`.\n *\n * For more information on error boundaries, see:\n * https://react.dev/reference/react/Component#catching-rendering-errors-with-an-error-boundary\n */\nexport class ErrorBoundary extends Component<Props, State> {\n constructor(props: Props) {\n super(props);\n this.state = { error: undefined };\n }\n\n static getDerivedStateFromError(error: Error) {\n return { error };\n }\n\n override componentDidUpdate(prevProps: Props): void {\n if (prevProps.data !== this.props.data) {\n this.resetError();\n }\n }\n\n override render() {\n if (this.state.error) {\n return <this.props.fallback data={this.props.data} error={this.state.error} reset={this.resetError} />;\n }\n\n return this.props.children;\n }\n\n private resetError() {\n this.setState({ error: undefined });\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport React, { Suspense, forwardRef, memo, useEffect, useId, useMemo } from 'react';\n\nimport { useDefaultValue } from '@dxos/react-hooks';\n\nimport { ErrorBoundary } from './ErrorBoundary';\nimport { type SurfaceProps, useSurfaceRoot } from './SurfaceContext';\n\n/**\n * A surface is a named region of the screen that can be populated by plugins.\n */\nexport const Surface = memo(\n forwardRef<HTMLElement, SurfaceProps>(\n ({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {\n const { surfaces, debugInfo } = useSurfaceRoot();\n const data = useDefaultValue(_data, () => ({}));\n\n // Track debug info.\n const reactId = useId();\n const id = _id ?? reactId;\n useEffect(() => {\n debugInfo?.set(id, { id, created: Date.now(), role, renderCount: 0 });\n return () => {\n debugInfo?.delete(id);\n };\n }, [id]);\n\n if (debugInfo?.get(id)) {\n debugInfo.get(id)!.renderCount++;\n }\n\n const candidates = useMemo(() => {\n const definitions = Object.values(surfaces)\n .filter((definition) =>\n Array.isArray(definition.role) ? definition.role.includes(role) : definition.role === role,\n )\n .filter(({ filter }) => (filter ? filter(data) : true))\n .toSorted(({ disposition: a = 'static' }, { disposition: b = 'static' }) => {\n return a === b ? 0 : a === 'hoist' || b === 'fallback' ? -1 : b === 'hoist' || a === 'fallback' ? 1 : 0;\n });\n return limit ? definitions.slice(0, limit) : definitions;\n }, [surfaces, role, data, limit]);\n\n const nodes = candidates.map(({ component: Component, id }) => (\n <Component ref={forwardedRef} key={id} id={id} role={role} data={data} limit={limit} {...rest} />\n ));\n\n const suspense = placeholder ? <Suspense fallback={placeholder}>{nodes}</Suspense> : nodes;\n\n return fallback ? (\n <ErrorBoundary data={data} fallback={fallback}>\n {suspense}\n </ErrorBoundary>\n ) : (\n suspense\n );\n },\n ),\n);\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { SurfacePlugin } from './SurfacePlugin';\n\nexport * from './helpers';\nexport * from './provides';\n\nexport * from './ErrorBoundary';\nexport * from './Surface';\nexport * from './SurfaceContext';\n\nexport default SurfacePlugin;\n"],
5
- "mappings": "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",
6
- "names": ["import_react", "createSurface", "definition", "SurfaceContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id", "parseRootSurfacePlugin", "plugin", "provides", "surface", "surfaces", "parseSurfacePlugin", "definitions", "SurfacePlugin", "state", "create", "debugInfo", "Map", "meta", "ready", "context", "filterPlugins", "plugins", "reduce", "acc", "reduceSurfaces", "children", "React", "value", "Array", "isArray", "isObject", "data", "ErrorBoundary", "Component", "constructor", "props", "error", "getDerivedStateFromError", "componentDidUpdate", "prevProps", "resetError", "render", "this", "fallback", "reset", "setState", "Surface", "memo", "forwardRef", "_id", "role", "_data", "limit", "placeholder", "rest", "forwardedRef", "useDefaultValue", "reactId", "useId", "useEffect", "set", "created", "Date", "now", "renderCount", "delete", "get", "candidates", "useMemo", "Object", "values", "filter", "includes", "toSorted", "disposition", "a", "b", "slice", "nodes", "map", "component", "ref", "key", "suspense", "Suspense"]
7
- }
@@ -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 { S } from '@dxos/echo-schema';\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\nexport const SETTINGS_PLUGIN = 'dxos.org/plugin/settings';\nexport const SETTINGS_ACTION = `${SETTINGS_PLUGIN}/action`;\n\nexport namespace SettingsAction {\n export class Open extends S.TaggedClass<Open>()(`${SETTINGS_ACTION}/open`, {\n input: S.Struct({\n plugin: S.optional(S.String),\n }),\n output: S.Void,\n }) {}\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,2BAAkC;AEAlC,yBAAkB;ADAlB,IAAMA,eAAe;EACnBC,IAAI;AACN;AAEA,IAAA,eAAeD;ADER,IAAME,iBAAiB,MAAA;AAG5B,QAAMC,gBAAgB,IAAIC,uCAAAA;AAE1B,SAAO;IACLC,MAAML;IACNM,UAAU;MACRH;IACF;EACF;AACF;AEJO,IAAMI,sBAAsB,CAACC,WAAAA;AAClC,SAAO,OAAQA,OAAOF,SAAiBH,kBAAkB,WACpDK,SACDC;AACN;AAEO,IAAMC,kBAAkB;AACxB,IAAMC,kBAAkB,GAAGD,eAAAA;;UAEjBE,iBAAAA;EACR,MAAMC,aAAaC,qBAAEC,YAAW,EAAS,GAAGJ,eAAAA,SAAwB;IACzEK,OAAOF,qBAAEG,OAAO;MACdT,QAAQM,qBAAEI,SAASJ,qBAAEK,MAAM;IAC7B,CAAA;IACAC,QAAQN,qBAAEO;EACZ,CAAA,EAAA;EAAI;kBALSR,OAAAA;AAMf,GAPiBD,mBAAAA,iBAAAA,CAAAA,EAAAA;AClBjB,IAAA,0BAAeV;",
6
- "names": ["SettingsMeta", "id", "SettingsPlugin", "settingsStore", "RootSettingsStore", "meta", "provides", "parseSettingsPlugin", "plugin", "undefined", "SETTINGS_PLUGIN", "SETTINGS_ACTION", "SettingsAction", "Open", "S", "TaggedClass", "input", "Struct", "optional", "String", "output", "Void"]
7
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_QBM42OQ6_exports = {};
20
- __export(chunk_QBM42OQ6_exports, {
21
- definePlugin: () => definePlugin,
22
- filterPlugins: () => filterPlugins,
23
- findPlugin: () => findPlugin,
24
- getPlugin: () => getPlugin,
25
- resolvePlugin: () => resolvePlugin
26
- });
27
- module.exports = __toCommonJS(chunk_QBM42OQ6_exports);
28
- var import_context = require("@dxos/context");
29
- var import_debug = require("@dxos/debug");
30
- var import_invariant = require("@dxos/invariant");
31
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/app-framework/src/plugins/helpers.ts";
32
- var findPlugin = (plugins, id) => {
33
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
34
- };
35
- var getPlugin = (plugins, id) => {
36
- return findPlugin(plugins, id) ?? (0, import_debug.raise)(new Error(`Plugin not found: ${id}`));
37
- };
38
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
39
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
40
- var PluginContext = class {
41
- constructor() {
42
- this.ctx = new import_context.Context(void 0, {
43
- F: __dxlog_file,
44
- L: 50
45
- });
46
- }
47
- init(plugins) {
48
- this._plugins = plugins;
49
- }
50
- getPlugin(id) {
51
- (0, import_invariant.invariant)(this._plugins, void 0, {
52
- F: __dxlog_file,
53
- L: 59,
54
- S: this,
55
- A: [
56
- "this._plugins",
57
- ""
58
- ]
59
- });
60
- return getPlugin(this._plugins, id);
61
- }
62
- resolvePlugin(resolver, required = false) {
63
- (0, import_invariant.invariant)(this._plugins, "context not initialized", {
64
- F: __dxlog_file,
65
- L: 65,
66
- S: this,
67
- A: [
68
- "this._plugins",
69
- "'context not initialized'"
70
- ]
71
- });
72
- const plugin = resolvePlugin(this._plugins, resolver);
73
- if (required && !plugin) {
74
- throw new Error("Plugin not found.");
75
- }
76
- return plugin;
77
- }
78
- onDispose(cb) {
79
- this.ctx.onDispose(cb);
80
- }
81
- dispose() {
82
- void this.ctx.dispose();
83
- }
84
- };
85
- var definePlugin = (cb) => {
86
- const context = new PluginContext();
87
- return () => cb(context);
88
- };
89
- // Annotate the CommonJS export names for ESM import in node:
90
- 0 && (module.exports = {
91
- definePlugin,
92
- filterPlugins,
93
- findPlugin,
94
- getPlugin,
95
- resolvePlugin
96
- });
97
- //# sourceMappingURL=chunk-QBM42OQ6.cjs.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,qBAA8C;AAC9C,mBAAsB;AACtB,uBAA0B;;AAYnB,IAAMA,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,SAAOM,oBAAM,IAAIC,MAAM,qBAAqBP,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMQ,gBAAgB,CAAIT,SAAmBU,cAClDV,QAAQW,IAAI,CAACR,WAAWO,UAAUP,MAAAA,CAAAA,EAASS,OAAO,CAACT,WAAgC,CAAC,CAACA,MAAAA;AAShF,IAAMU,gBAAgB,CAAIb,SAAmBU,cAClDD,cAAcT,SAASU,SAAAA,EAAW,CAAA;AAEpC,IAAMI,gBAAN,MAAMA;EAAN,cAAA;eAEwB,IAAIC,uBAAAA,QAAAA;;;;;EAI1BC,KAAKhB,SAAmB;AACtB,SAAKiB,WAAWjB;EAClB;EAEAM,UAAaL,IAAuB;AAClCiB,oCAAU,KAAKD,UAAQ,QAAA;;;;;;;;;AACvB,WAAOX,UAAU,KAAKW,UAAUhB,EAAAA;EAClC;EAGAY,cAAiBM,UAA6BC,WAAW,OAA8B;AACrFF,oCAAU,KAAKD,UAAU,2BAAA;;;;;;;;;AACzB,UAAMd,SAASU,cAAc,KAAKI,UAAUE,QAAAA;AAC5C,QAAIC,YAAY,CAACjB,QAAQ;AAEvB,YAAM,IAAIK,MAAM,mBAAA;IAClB;AAEA,WAAOL;EACT;EAEAkB,UAAUC,IAAqB;AAC7B,SAAKC,IAAIF,UAAUC,EAAAA;EACrB;EAEAE,UAAU;AACR,SAAK,KAAKD,IAAIC,QAAO;EACvB;AACF;AAKO,IAAMC,eAAe,CAC1BH,OAAAA;AAEA,QAAMI,UAAU,IAAIZ,cAAAA;AACpB,SAAO,MAAMQ,GAAGI,OAAAA;AAClB;",
6
- "names": ["findPlugin", "plugins", "id", "find", "plugin", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin", "PluginContext", "Context", "init", "_plugins", "invariant", "resolver", "required", "onDispose", "cb", "ctx", "dispose", "definePlugin", "context"]
7
- }