@dxos/app-framework 0.7.5-main.499c70c → 0.7.5-main.5ae2ba8

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 +77 -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 +101 -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 +78 -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 +12 -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 +91 -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,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,320 +0,0 @@
1
- import {
2
- filterPlugins
3
- } from "./chunk-3E7RY3CE.mjs";
4
-
5
- // packages/sdk/app-framework/src/plugins/plugin-intent/IntentPlugin.tsx
6
- import { Effect as Effect2 } from "effect";
7
- import React from "react";
8
- import { create } from "@dxos/live-object";
9
-
10
- // packages/sdk/app-framework/src/plugins/plugin-intent/IntentContext.tsx
11
- import { createContext, useContext, useEffect } from "react";
12
- import { raise } from "@dxos/debug";
13
- import { pick } from "@dxos/util";
14
- var IntentContext = /* @__PURE__ */ createContext(void 0);
15
- var useIntentDispatcher = () => {
16
- const context = useContext(IntentContext) ?? raise(new Error("IntentContext not found"));
17
- return pick(context, [
18
- "dispatch",
19
- "dispatchPromise"
20
- ]);
21
- };
22
- var useIntentResolver = (pluginId, resolver) => {
23
- const { registerResolver } = useContext(IntentContext) ?? raise(new Error("IntentContext not found"));
24
- useEffect(() => {
25
- return registerResolver(pluginId, resolver);
26
- }, [
27
- pluginId,
28
- resolver
29
- ]);
30
- };
31
- var IntentProvider = IntentContext.Provider;
32
-
33
- // packages/sdk/app-framework/src/plugins/plugin-intent/intent-dispatcher.ts
34
- import { Effect, Ref } from "effect";
35
- import { pick as pick2 } from "@dxos/util";
36
-
37
- // packages/sdk/app-framework/src/plugins/plugin-intent/intent.ts
38
- import { S } from "@dxos/echo-schema";
39
-
40
- // packages/sdk/app-framework/src/plugins/plugin-intent/meta.ts
41
- var INTENT_PLUGIN = "dxos.org/plugin/intent";
42
- var IntentMeta = {
43
- id: INTENT_PLUGIN
44
- };
45
- var meta_default = IntentMeta;
46
-
47
- // packages/sdk/app-framework/src/plugins/plugin-intent/intent.ts
48
- var createIntent = (schema, data = {}, params = {}) => {
49
- const _ = S.validateSync(schema.fields.input)(data);
50
- const intent = {
51
- ...params,
52
- _schema: schema,
53
- action: schema._tag,
54
- data
55
- };
56
- return {
57
- first: intent,
58
- last: intent,
59
- all: [
60
- intent
61
- ]
62
- };
63
- };
64
- var chain = (schema, data = {}, params = {}) => (intent) => {
65
- const intents = "all" in intent ? intent.all : [
66
- intent
67
- ];
68
- const first = intents[0];
69
- const last = {
70
- ...params,
71
- _schema: schema,
72
- action: schema._tag,
73
- data
74
- };
75
- return {
76
- first,
77
- last,
78
- all: [
79
- ...intents,
80
- last
81
- ]
82
- };
83
- };
84
- var Label = S.Union(S.String, S.mutable(S.Tuple(S.String, S.mutable(S.Struct({
85
- ns: S.String,
86
- count: S.optional(S.Number)
87
- })))));
88
- var INTENT_ACTION = `${INTENT_PLUGIN}/action`;
89
- var IntentAction;
90
- (function(IntentAction2) {
91
- class ShowUndo extends S.TaggedClass()(`${INTENT_ACTION}/show-undo`, {
92
- input: S.Struct({
93
- message: Label
94
- }),
95
- output: S.Void
96
- }) {
97
- }
98
- IntentAction2.ShowUndo = ShowUndo;
99
- })(IntentAction || (IntentAction = {}));
100
-
101
- // packages/sdk/app-framework/src/plugins/plugin-intent/intent-dispatcher.ts
102
- var EXECUTION_LIMIT = 100;
103
- var HISTORY_LIMIT = 100;
104
- var createResolver = (schema, effect, params = {}) => ({
105
- action: schema._tag,
106
- effect,
107
- ...params
108
- });
109
- var isUndoable = (historyEntry) => historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);
110
- var createDispatcher = (resolvers, { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {}) => {
111
- const historyRef = Effect.runSync(Ref.make([]));
112
- const handleIntent = (intent) => {
113
- return Effect.gen(function* () {
114
- const candidates = Object.entries(resolvers).filter(([id, _]) => intent.plugin ? id === intent.plugin : true).flatMap(([_, resolvers2]) => resolvers2).filter((r) => r.action === intent.action).filter((r) => !r.filter || r.filter(intent.data)).toSorted(({ disposition: a = "static" }, { disposition: b = "static" }) => {
115
- return a === b ? 0 : a === "hoist" || b === "fallback" ? -1 : b === "hoist" || a === "fallback" ? 1 : 0;
116
- });
117
- if (candidates.length === 0) {
118
- return {
119
- _intent: intent,
120
- error: new Error(`No resolver found for action: ${intent.action}`)
121
- };
122
- }
123
- const effect = candidates[0].effect(intent.data, intent.undo ?? false);
124
- const result = Effect.isEffect(effect) ? yield* effect : yield* Effect.promise(async () => effect);
125
- return {
126
- _intent: intent,
127
- ...result
128
- };
129
- });
130
- };
131
- const dispatch = (intentChain, depth = 0) => {
132
- return Effect.gen(function* () {
133
- if (depth > executionLimit) {
134
- yield* Effect.fail(new Error("Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers."));
135
- }
136
- const resultsRef = yield* Ref.make([]);
137
- for (const intent of intentChain.all) {
138
- const { data: prev } = (yield* resultsRef.get)[0] ?? {};
139
- const result2 = yield* handleIntent({
140
- ...intent,
141
- data: {
142
- ...intent.data,
143
- ...prev
144
- }
145
- });
146
- yield* Ref.update(resultsRef, (results2) => [
147
- result2,
148
- ...results2
149
- ]);
150
- if (result2.error) {
151
- break;
152
- }
153
- if (result2.intents) {
154
- for (const intent2 of result2.intents) {
155
- yield* dispatch(intent2, depth + 1);
156
- }
157
- }
158
- }
159
- const results = yield* resultsRef.get;
160
- const result = results[0];
161
- if (result) {
162
- yield* Ref.update(historyRef, (history) => {
163
- const next = [
164
- ...history,
165
- results
166
- ];
167
- if (next.length > historyLimit) {
168
- next.splice(0, next.length - historyLimit);
169
- }
170
- return next;
171
- });
172
- if (result.undoable && isUndoable(results)) {
173
- yield* dispatch(createIntent(IntentAction.ShowUndo, {
174
- message: result.undoable.message
175
- }));
176
- }
177
- return pick2(result, [
178
- "data",
179
- "error"
180
- ]);
181
- } else {
182
- return {
183
- data: {},
184
- error: new Error("No results")
185
- };
186
- }
187
- });
188
- };
189
- const dispatchPromise = (intentChain) => {
190
- const program = dispatch(intentChain);
191
- return Effect.runPromise(program);
192
- };
193
- const undo = () => {
194
- return Effect.gen(function* () {
195
- const history = yield* historyRef.get;
196
- const last = history.findLastIndex(isUndoable);
197
- const result = last !== -1 ? history[last] : void 0;
198
- if (result) {
199
- const all = result.map(({ _intent, undoable }) => {
200
- const data = _intent.data;
201
- const undoData = undoable?.data ?? {};
202
- return {
203
- ..._intent,
204
- data: {
205
- ...data,
206
- ...undoData
207
- },
208
- undo: true
209
- };
210
- });
211
- const intent = {
212
- first: all[0],
213
- last: all.at(-1),
214
- all
215
- };
216
- yield* Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));
217
- return yield* dispatch(intent);
218
- }
219
- });
220
- };
221
- const undoPromise = () => {
222
- const program = undo();
223
- return Effect.runPromise(program);
224
- };
225
- const registerResolver = (id, resolver) => {
226
- resolvers[id] = [
227
- ...resolvers[id] ?? [],
228
- resolver
229
- ];
230
- return () => {
231
- resolvers[id] = resolvers[id].filter((r) => r !== resolver);
232
- };
233
- };
234
- return {
235
- dispatch,
236
- dispatchPromise,
237
- undo,
238
- undoPromise,
239
- registerResolver
240
- };
241
- };
242
-
243
- // packages/sdk/app-framework/src/plugins/plugin-intent/provides.ts
244
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
245
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolvers ? plugin : void 0;
246
-
247
- // packages/sdk/app-framework/src/plugins/plugin-intent/IntentPlugin.tsx
248
- var defaultEffect = () => Effect2.fail(new Error("Intent runtime not ready"));
249
- var defaultPromise = () => Effect2.runPromise(defaultEffect());
250
- var IntentPlugin = () => {
251
- const state = create({
252
- dispatch: defaultEffect,
253
- dispatchPromise: defaultPromise,
254
- undo: defaultEffect,
255
- undoPromise: defaultPromise,
256
- registerResolver: () => () => {
257
- }
258
- });
259
- return {
260
- meta: meta_default,
261
- ready: async ({ plugins }) => {
262
- const resolvers = Object.fromEntries(filterPlugins(plugins, parseIntentResolverPlugin).map((plugin) => {
263
- const resolvers2 = reduceResolvers(plugin.provides.intent.resolvers({
264
- plugins,
265
- dispatch: (intent) => state.dispatch(intent),
266
- dispatchPromise: (intent) => state.dispatchPromise(intent),
267
- undo: () => state.undo(),
268
- undoPromise: () => state.undoPromise(),
269
- registerResolver: (id, resolver) => state.registerResolver(id, resolver)
270
- }));
271
- return [
272
- plugin.meta.id,
273
- resolvers2
274
- ];
275
- }));
276
- const { dispatch, dispatchPromise, undo, undoPromise, registerResolver } = createDispatcher(resolvers);
277
- state.dispatch = dispatch;
278
- state.dispatchPromise = dispatchPromise;
279
- state.undo = undo;
280
- state.undoPromise = undoPromise;
281
- state.registerResolver = registerResolver;
282
- },
283
- provides: {
284
- intent: state,
285
- context: ({ children }) => /* @__PURE__ */ React.createElement(IntentProvider, {
286
- value: state
287
- }, children)
288
- }
289
- };
290
- };
291
- var reduceResolvers = (definitions, resolvers = []) => {
292
- if (Array.isArray(definitions)) {
293
- return definitions.reduce((acc, definition) => reduceResolvers(definition, acc), resolvers);
294
- }
295
- return [
296
- ...resolvers,
297
- definitions
298
- ];
299
- };
300
-
301
- // packages/sdk/app-framework/src/plugins/plugin-intent/index.ts
302
- var plugin_intent_default = IntentPlugin;
303
-
304
- export {
305
- useIntentDispatcher,
306
- useIntentResolver,
307
- IntentProvider,
308
- meta_default,
309
- createIntent,
310
- chain,
311
- Label,
312
- INTENT_ACTION,
313
- IntentAction,
314
- createResolver,
315
- createDispatcher,
316
- parseIntentPlugin,
317
- parseIntentResolverPlugin,
318
- plugin_intent_default
319
- };
320
- //# sourceMappingURL=chunk-QG25ZU2N.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/plugin-intent/IntentPlugin.tsx", "../../../src/plugins/plugin-intent/IntentContext.tsx", "../../../src/plugins/plugin-intent/intent-dispatcher.ts", "../../../src/plugins/plugin-intent/intent.ts", "../../../src/plugins/plugin-intent/meta.ts", "../../../src/plugins/plugin-intent/provides.ts", "../../../src/plugins/plugin-intent/index.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Effect } from 'effect';\nimport React from 'react';\n\nimport { create } from '@dxos/live-object';\n\nimport { IntentProvider } from './IntentContext';\nimport { createDispatcher, type AnyIntentResolver, type IntentContext } from './intent-dispatcher';\nimport IntentMeta from './meta';\nimport { type IntentPluginProvides, type ResolverDefinitions, parseIntentResolverPlugin } from './provides';\nimport { filterPlugins } from '../helpers';\nimport { type PluginDefinition } from '../plugin-host';\n\nconst defaultEffect = () => Effect.fail(new Error('Intent runtime not ready'));\nconst defaultPromise = () => Effect.runPromise(defaultEffect());\n\n/**\n * Allows plugins to register intent handlers and routes sent intents to the appropriate plugin.\n * Inspired by https://developer.android.com/reference/android/content/Intent.\n */\nexport const IntentPlugin = (): PluginDefinition<IntentPluginProvides> => {\n const state = create<IntentContext>({\n dispatch: defaultEffect,\n dispatchPromise: defaultPromise,\n undo: defaultEffect,\n undoPromise: defaultPromise,\n registerResolver: () => () => {},\n });\n\n return {\n meta: IntentMeta,\n ready: async ({ plugins }) => {\n const resolvers = Object.fromEntries(\n filterPlugins(plugins, parseIntentResolverPlugin).map((plugin): [string, AnyIntentResolver[]] => {\n const resolvers = reduceResolvers(\n plugin.provides.intent.resolvers({\n plugins,\n dispatch: (intent) => state.dispatch(intent),\n dispatchPromise: (intent) => state.dispatchPromise(intent),\n undo: () => state.undo(),\n undoPromise: () => state.undoPromise(),\n registerResolver: (id, resolver) => state.registerResolver(id, resolver),\n }),\n );\n return [plugin.meta.id, resolvers];\n }),\n );\n const { dispatch, dispatchPromise, undo, undoPromise, registerResolver } = createDispatcher(resolvers);\n\n state.dispatch = dispatch;\n state.dispatchPromise = dispatchPromise;\n state.undo = undo;\n state.undoPromise = undoPromise;\n state.registerResolver = registerResolver;\n },\n provides: {\n intent: state,\n context: ({ children }) => <IntentProvider value={state}>{children}</IntentProvider>,\n },\n };\n};\n\nconst reduceResolvers = (\n definitions: ResolverDefinitions,\n resolvers: AnyIntentResolver[] = [],\n): AnyIntentResolver[] => {\n if (Array.isArray(definitions)) {\n return definitions.reduce((acc: AnyIntentResolver[], definition) => reduceResolvers(definition, acc), resolvers);\n }\n\n return [...resolvers, definitions];\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider, useEffect } from 'react';\n\nimport { raise } from '@dxos/debug';\nimport { pick } from '@dxos/util';\n\nimport { type AnyIntentResolver, type IntentContext } from './intent-dispatcher';\n\nconst IntentContext: Context<IntentContext | undefined> = createContext<IntentContext | undefined>(undefined);\n\nexport const useIntentDispatcher = (): Pick<IntentContext, 'dispatch' | 'dispatchPromise'> => {\n const context = useContext(IntentContext) ?? raise(new Error('IntentContext not found'));\n return pick(context, ['dispatch', 'dispatchPromise']);\n};\n\nexport const useIntentResolver = (pluginId: string, resolver: AnyIntentResolver) => {\n const { registerResolver } = useContext(IntentContext) ?? raise(new Error('IntentContext not found'));\n useEffect(() => {\n return registerResolver(pluginId, resolver);\n }, [pluginId, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext | undefined> = IntentContext.Provider;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { Effect, Ref } from 'effect';\n\nimport { type MaybePromise, pick } from '@dxos/util';\n\nimport {\n createIntent,\n IntentAction,\n type AnyIntent,\n type AnyIntentChain,\n type Intent,\n type IntentChain,\n type IntentData,\n type IntentParams,\n type IntentResultData,\n type IntentSchema,\n type Label,\n} from './intent';\n\nconst EXECUTION_LIMIT = 100;\nconst HISTORY_LIMIT = 100;\n\n/**\n * The return value of an intent effect.\n */\nexport type IntentEffectResult<Fields extends IntentParams> = {\n /**\n * The output of the action that was performed.\n *\n * If the intent is apart of a chain of intents, the data will be passed to the next intent.\n */\n data?: IntentResultData<Fields>;\n\n /**\n * If provided, the action will be undoable.\n */\n undoable?: {\n /**\n * Message to display to the user when indicating that the action can be undone.\n */\n message: Label;\n\n /**\n * Will be merged with the original intent data when firing the undo intent.\n */\n data?: Partial<IntentData<Fields>>;\n };\n\n /**\n * An error that occurred while performing the action.\n *\n * If the intent is apart of a chain of intents and an error occurs, the chain will be aborted.\n */\n error?: Error;\n\n /**\n * Other intent chains to be triggered.\n */\n intents?: AnyIntentChain[];\n};\n\nexport type AnyIntentEffectResult = IntentEffectResult<any>;\n\n/**\n * The result of an intent dispatcher.\n */\nexport type IntentDispatcherResult<Fields extends IntentParams> = Pick<IntentEffectResult<Fields>, 'data' | 'error'>;\n\n/**\n * Determines the priority of the effect when multiple intent resolvers are matched.\n *\n * - `static` - The effect is selected in the order it was resolved.\n * - `hoist` - The effect is selected before `static` effects.\n * - `fallback` - The effect is selected after `static` effects.\n */\nexport type IntentDisposition = 'static' | 'hoist' | 'fallback';\n\n/**\n * The implementation of an intent effect.\n */\nexport type IntentEffectDefinition<Fields extends IntentParams> = (\n data: IntentData<Fields>,\n undo: boolean,\n) => MaybePromise<IntentEffectResult<Fields> | void> | Effect.Effect<IntentEffectResult<Fields> | void>;\n\n/**\n * Intent resolver to match intents to their effects.\n */\nexport type IntentResolver<Tag extends string, Fields extends IntentParams> = {\n action: Tag;\n disposition?: IntentDisposition;\n // TODO(wittjosiah): Would be nice to make this a guard for intents with optional data.\n filter?: (data: IntentData<Fields>) => boolean;\n effect: IntentEffectDefinition<Fields>;\n};\n\nexport type AnyIntentResolver = IntentResolver<any, any>;\n\n/**\n * Creates an intent resolver to match intents to their effects.\n * @param schema Schema of the intent. Must be a tagged class with input and output schemas.\n * @param effect Effect to be performed when the intent is resolved.\n * @param params.disposition Determines the priority of the resolver when multiple are resolved.\n * @param params.filter Optional filter to determine if the resolver should be used.\n */\nexport const createResolver = <Tag extends string, Fields extends IntentParams>(\n schema: IntentSchema<Tag, Fields>,\n effect: IntentEffectDefinition<Fields>,\n params: Pick<IntentResolver<Tag, Fields>, 'disposition' | 'filter'> = {},\n): IntentResolver<Tag, Fields> => ({\n action: schema._tag,\n effect,\n ...params,\n});\n\n/**\n * Invokes intents and returns the result.\n */\nexport type PromiseIntentDispatcher = <Fields extends IntentParams>(\n intent: IntentChain<any, any, any, Fields>,\n) => Promise<IntentDispatcherResult<Fields>>;\n\n/**\n * Creates an effect for intents.\n */\nexport type IntentDispatcher = <Fields extends IntentParams>(\n intent: IntentChain<any, any, any, Fields>,\n depth?: number,\n) => Effect.Effect<IntentDispatcherResult<Fields>, Error>;\n\ntype IntentResult<Tag extends string, Fields extends IntentParams> = IntentEffectResult<Fields> & {\n _intent: Intent<Tag, Fields>;\n};\n\ntype AnyIntentResult = IntentResult<any, any>;\n\n/**\n * Invokes the most recent undoable intent with undo flags.\n */\nexport type PromiseIntentUndo = () => Promise<IntentDispatcherResult<any> | undefined>;\n\n/**\n * Creates an effect which undoes the last intent.\n */\nexport type IntentUndo = () => Effect.Effect<IntentDispatcherResult<any> | undefined, Error>;\n\n/**\n * Check if a chain of results is undoable.\n */\nconst isUndoable = (historyEntry: AnyIntentResult[]): boolean =>\n historyEntry.length > 0 && historyEntry.every(({ undoable }) => !!undoable);\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n dispatchPromise: PromiseIntentDispatcher;\n undo: IntentUndo;\n undoPromise: PromiseIntentUndo;\n registerResolver: (id: string, resolver: AnyIntentResolver) => () => void;\n};\n\n/**\n * Sets of an intent dispatcher.\n *\n * @param resolvers An array of available intent resolvers.\n * @param params.historyLimit The maximum number of intent results to keep in history.\n * @param params.executionLimit The maximum recursion depth of intent chains.\n */\nexport const createDispatcher = (\n resolvers: Record<string, AnyIntentResolver[]>,\n { executionLimit = EXECUTION_LIMIT, historyLimit = HISTORY_LIMIT } = {},\n): IntentContext => {\n const historyRef = Effect.runSync(Ref.make<AnyIntentResult[][]>([]));\n\n const handleIntent = (intent: AnyIntent) => {\n return Effect.gen(function* () {\n const candidates = Object.entries(resolvers)\n .filter(([id, _]) => (intent.plugin ? id === intent.plugin : true))\n .flatMap(([_, resolvers]) => resolvers)\n .filter((r) => r.action === intent.action)\n .filter((r) => !r.filter || r.filter(intent.data))\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 if (candidates.length === 0) {\n return {\n _intent: intent,\n error: new Error(`No resolver found for action: ${intent.action}`),\n } satisfies AnyIntentResult;\n }\n\n const effect = candidates[0].effect(intent.data, intent.undo ?? false);\n const result = Effect.isEffect(effect) ? yield* effect : yield* Effect.promise(async () => effect);\n return { _intent: intent, ...result } satisfies AnyIntentResult;\n });\n };\n\n const dispatch: IntentDispatcher = (intentChain, depth = 0) => {\n return Effect.gen(function* () {\n if (depth > executionLimit) {\n yield* Effect.fail(\n new Error('Intent execution limit exceeded. This is likely due to an infinite loop within intent resolvers.'),\n );\n }\n\n const resultsRef = yield* Ref.make<AnyIntentResult[]>([]);\n for (const intent of intentChain.all) {\n const { data: prev } = (yield* resultsRef.get)[0] ?? {};\n const result = yield* handleIntent({ ...intent, data: { ...intent.data, ...prev } });\n yield* Ref.update(resultsRef, (results) => [result, ...results]);\n if (result.error) {\n break;\n }\n if (result.intents) {\n for (const intent of result.intents) {\n // Returned intents are dispatched but not yielded into results,\n // as such they cannot be undone.\n // TODO(wittjosiah): Use higher execution concurrency?\n yield* dispatch(intent, depth + 1);\n }\n }\n }\n\n const results = yield* resultsRef.get;\n const result = results[0];\n if (result) {\n yield* Ref.update(historyRef, (history) => {\n const next = [...history, results];\n if (next.length > historyLimit) {\n next.splice(0, next.length - historyLimit);\n }\n return next;\n });\n\n if (result.undoable && isUndoable(results)) {\n // TODO(wittjosiah): Is there a better way to handle showing undo for chains?\n yield* dispatch(createIntent(IntentAction.ShowUndo, { message: result.undoable.message }));\n }\n\n return pick(result, ['data', 'error']);\n } else {\n return { data: {}, error: new Error('No results') };\n }\n });\n };\n\n const dispatchPromise: PromiseIntentDispatcher = (intentChain) => {\n const program = dispatch(intentChain);\n return Effect.runPromise(program);\n };\n\n const undo: IntentUndo = () => {\n return Effect.gen(function* () {\n const history = yield* historyRef.get;\n const last = history.findLastIndex(isUndoable);\n const result = last !== -1 ? history[last] : undefined;\n if (result) {\n const all = result.map(({ _intent, undoable }): AnyIntent => {\n const data = _intent.data;\n const undoData = undoable?.data ?? {};\n return { ..._intent, data: { ...data, ...undoData }, undo: true } satisfies AnyIntent;\n });\n const intent = { first: all[0], last: all.at(-1)!, all } satisfies AnyIntentChain;\n yield* Ref.update(historyRef, (h) => h.filter((_, index) => index !== last));\n return yield* dispatch(intent);\n }\n });\n };\n\n const undoPromise: PromiseIntentUndo = () => {\n const program = undo();\n return Effect.runPromise(program);\n };\n\n const registerResolver = (id: string, resolver: AnyIntentResolver) => {\n resolvers[id] = [...(resolvers[id] ?? []), resolver];\n return () => {\n resolvers[id] = resolvers[id].filter((r) => r !== resolver);\n };\n };\n\n return { dispatch, dispatchPromise, undo, undoPromise, registerResolver };\n};\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { S } from '@dxos/echo-schema';\n\nimport { INTENT_PLUGIN } from './meta';\n\nexport type IntentParams = {\n readonly input: S.Schema.All;\n readonly output: S.Schema.All;\n};\n\nexport type IntentData<Fields extends IntentParams> =\n S.Schema.Type<S.Struct<Fields>> extends { readonly input: any } ? S.Schema.Type<S.Struct<Fields>>['input'] : any;\n\nexport type IntentResultData<Fields extends IntentParams> =\n S.Schema.Type<S.Struct<Fields>> extends { readonly output: any } ? S.Schema.Type<S.Struct<Fields>>['output'] : any;\n\nexport type IntentSchema<Tag extends string, Fields extends IntentParams> = S.TaggedClass<any, Tag, Fields>;\n\n/**\n * An intent is an abstract description of an operation to be performed.\n * Intents allow actions to be performed across plugins.\n */\nexport type Intent<Tag extends string, Fields extends IntentParams> = {\n _schema: IntentSchema<Tag, Fields>;\n\n /**\n * The action to perform.\n */\n action: Tag;\n\n /**\n * Any data needed to perform the desired action.\n */\n data: IntentData<Fields>;\n\n /**\n * Plugin ID.\n * If specified, the intent will be sent explicitly to the plugin.\n * Otherwise, the intent will be sent to all plugins, in order and the first to resolve a non-null value will be used.\n */\n plugin?: string;\n\n /**\n * Whether or not the intent is being undone.\n */\n undo?: boolean;\n};\n\nexport type AnyIntent = Intent<any, any>;\n\n/**\n * Chain of intents to be executed together.\n * The result of each intent is merged into the next intent's input data.\n */\nexport type IntentChain<\n FirstTag extends string,\n LastTag extends string,\n FirstFields extends IntentParams,\n LastFields extends IntentParams,\n> = {\n first: Intent<FirstTag, FirstFields>;\n last: Intent<LastTag, LastFields>;\n all: AnyIntent[];\n};\n\nexport type AnyIntentChain = IntentChain<any, any, any, any>;\n\n/**\n * Creates a typed intent.\n * @param schema Schema of the intent. Must be a tagged class with input and output schemas.\n * @param data Data fulfilling the input schema of the intent.\n * @param params.plugin Optional plugin ID to send the intent to.\n * @param params.undo Optional flag to indicate that the intent is being undone. Generally not set manually.\n */\nexport const createIntent = <Tag extends string, Fields extends IntentParams>(\n schema: IntentSchema<Tag, Fields>,\n data: IntentData<Fields> = {},\n params: Pick<AnyIntent, 'plugin' | 'undo'> = {},\n): IntentChain<Tag, Tag, Fields, Fields> => {\n // The output of validateSync breaks proxy objects so this is just used for validation.\n // TODO(wittjosiah): Is there a better way to make theses types align?\n const _ = S.validateSync(schema.fields.input as S.Schema<any, any, unknown>)(data);\n const intent = {\n ...params,\n _schema: schema,\n action: schema._tag,\n data,\n } satisfies Intent<Tag, Fields>;\n\n return {\n first: intent,\n last: intent,\n all: [intent],\n };\n};\n\n// TODO(wittjosiah): Add a function for mapping the output of one intent to the input of another.\n\n/**\n * Chain two intents together.\n *\n * NOTE: Chaining of intents depends on the data inputs and outputs being structs.\n */\nexport const chain =\n <\n FirstTag extends string,\n NextTag extends string,\n FirstFields extends IntentParams,\n LastFields extends IntentParams,\n NextFields extends IntentParams,\n >(\n schema: IntentSchema<NextTag, NextFields>,\n data: Omit<IntentData<NextFields>, keyof IntentResultData<LastFields>> = {},\n params: Pick<AnyIntent, 'plugin' | 'undo'> = {},\n ) =>\n (\n intent: IntentChain<FirstTag, any, FirstFields, LastFields>,\n ): IntentChain<FirstTag, NextTag, FirstFields, NextFields> => {\n const intents = 'all' in intent ? intent.all : [intent];\n const first = intents[0];\n const last = {\n ...params,\n _schema: schema,\n action: schema._tag,\n data,\n } satisfies Intent<NextTag, NextFields>;\n\n return {\n first,\n last,\n all: [...intents, last],\n };\n };\n\n//\n// Intents\n//\n\n// NOTE: Should maintain compatibility with `i18next` (and @dxos/react-ui).\n// TODO(wittjosiah): Making this immutable breaks type compatibility.\nexport const Label = S.Union(\n S.String,\n S.mutable(S.Tuple(S.String, S.mutable(S.Struct({ ns: S.String, count: S.optional(S.Number) })))),\n);\nexport type Label = S.Schema.Type<typeof Label>;\n\nexport const INTENT_ACTION = `${INTENT_PLUGIN}/action`;\n\nexport namespace IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n export class ShowUndo extends S.TaggedClass<ShowUndo>()(`${INTENT_ACTION}/show-undo`, {\n input: S.Struct({\n message: Label,\n }),\n output: S.Void,\n }) {}\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nexport const INTENT_PLUGIN = 'dxos.org/plugin/intent';\n\nconst IntentMeta = {\n id: INTENT_PLUGIN,\n};\n\nexport default IntentMeta;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext, type AnyIntentResolver } from './intent-dispatcher';\nimport { type HostContext, type Plugin } from '../plugin-host';\n\ntype Context = HostContext & IntentContext;\n\nexport type ResolverDefinitions = AnyIntentResolver | AnyIntentResolver[] | ResolverDefinitions[];\n\nexport type IntentResolverProvides = {\n intent: {\n resolvers: (context: Context) => ResolverDefinitions;\n };\n};\n\nexport type IntentPluginProvides = {\n intent: IntentContext;\n};\n\nexport const parseIntentPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.dispatch ? (plugin as Plugin<IntentPluginProvides>) : undefined;\n\nexport const parseIntentResolverPlugin = (plugin: Plugin) =>\n (plugin.provides as any).intent?.resolvers ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { IntentPlugin } from './IntentPlugin';\n\nexport * from './intent';\nexport * from './intent-dispatcher';\nexport * from './provides';\n\nexport * from './IntentContext';\n\nexport default IntentPlugin;\n"],
5
- "mappings": ";;;;;AAIA,SAASA,UAAAA,eAAc;AACvB,OAAOC,WAAW;AAElB,SAASC,cAAc;;;ACHvB,SAAuBC,eAAeC,YAA2BC,i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ACjC,CAAA;AAEA,SAAO;IACLC,MAAMC;IACNC,OAAO,OAAO,EAAEC,QAAO,MAAE;AACvB,YAAMC,YAAYC,OAAOC,YACvBC,cAAcJ,SAASK,yBAAAA,EAA2BC,IAAI,CAACC,WAAAA;AACrD,cAAMN,aAAYO,gBAChBD,OAAOE,SAASC,OAAOT,UAAU;UAC/BD;UACAR,UAAU,CAACkB,WAAWpB,MAAME,SAASkB,MAAAA;UACrCjB,iBAAiB,CAACiB,WAAWpB,MAAMG,gBAAgBiB,MAAAA;UACnDhB,MAAM,MAAMJ,MAAMI,KAAI;UACtBC,aAAa,MAAML,MAAMK,YAAW;UACpCC,kBAAkB,CAACe,IAAIC,aAAatB,MAAMM,iBAAiBe,IAAIC,QAAAA;QACjE,CAAA,CAAA;AAEF,eAAO;UAACL,OAAOV,KAAKc;UAAIV;;MAC1B,CAAA,CAAA;AAEF,YAAM,EAAET,UAAUC,iBAAiBC,MAAMC,aAAaC,iBAAgB,IAAKiB,iBAAiBZ,SAAAA;AAE5FX,YAAME,WAAWA;AACjBF,YAAMG,kBAAkBA;AACxBH,YAAMI,OAAOA;AACbJ,YAAMK,cAAcA;AACpBL,YAAMM,mBAAmBA;IAC3B;IACAa,UAAU;MACRC,QAAQpB;MACRwB,SAAS,CAAC,EAAEC,SAAQ,MAAO,sBAAA,cAACC,gBAAAA;QAAeC,OAAO3B;SAAQyB,QAAAA;IAC5D;EACF;AACF;AAEA,IAAMP,kBAAkB,CACtBU,aACAjB,YAAiC,CAAA,MAAE;AAEnC,MAAIkB,MAAMC,QAAQF,WAAAA,GAAc;AAC9B,WAAOA,YAAYG,OAAO,CAACC,KAA0BC,eAAef,gBAAgBe,YAAYD,GAAAA,GAAMrB,SAAAA;EACxG;AAEA,SAAO;OAAIA;IAAWiB;;AACxB;;;AM9DA,IAAA,wBAAeM;",
6
- "names": ["Effect", "React", "create", "createContext", "useContext", "useEffect", "raise", "pick", "IntentContext", "createContext", "undefined", "useIntentDispatcher", "context", "useContext", "raise", "Error", "pick", "useIntentResolver", "pluginId", "resolver", "registerResolver", "useEffect", "IntentProvider", "Provider", "Effect", "Ref", "pick", "S", "INTENT_PLUGIN", "IntentMeta", "id", "createIntent", "schema", "data", "params", "_", "S", "validateSync", "fields", "input", "intent", "_schema", "action", "_tag", "first", "last", "all", "chain", "intents", "Label", "Union", "String", "mutable", "Tuple", "Struct", "ns", "count", "optional", "Number", "INTENT_ACTION", "INTENT_PLUGIN", "IntentAction", "ShowUndo", "TaggedClass", "message", "output", "Void", "EXECUTION_LIMIT", "HISTORY_LIMIT", "createResolver", "schema", "effect", "params", "action", "_tag", "isUndoable", "historyEntry", "length", "every", "undoable", "createDispatcher", "resolvers", "executionLimit", "historyLimit", "historyRef", "Effect", "runSync", "Ref", "make", "handleIntent", "intent", "gen", "candidates", "Object", "entries", "filter", "id", "_", "plugin", "flatMap", "r", "data", "toSorted", "disposition", "a", "b", "_intent", "error", "Error", "undo", "result", "isEffect", "promise", "dispatch", "intentChain", "depth", "fail", "resultsRef", "all", "prev", "get", "update", "results", "intents", "history", "next", "splice", "createIntent", "IntentAction", "ShowUndo", "message", "pick", "dispatchPromise", "program", "runPromise", "last", "findLastIndex", "undefined", "map", "undoData", "first", "at", "h", "index", "undoPromise", "registerResolver", "resolver", "parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolvers", "defaultEffect", "Effect", "fail", "Error", "defaultPromise", "runPromise", "IntentPlugin", "state", "create", "dispatch", "dispatchPromise", "undo", "undoPromise", "registerResolver", "meta", "IntentMeta", "ready", "plugins", "resolvers", "Object", "fromEntries", "filterPlugins", "parseIntentResolverPlugin", "map", "plugin", "reduceResolvers", "provides", "intent", "id", "resolver", "createDispatcher", "context", "children", "IntentProvider", "value", "definitions", "Array", "isArray", "reduce", "acc", "definition", "IntentPlugin"]
7
- }
@@ -1,163 +0,0 @@
1
- import {
2
- filterPlugins
3
- } from "./chunk-3E7RY3CE.mjs";
4
-
5
- // packages/sdk/app-framework/src/plugins/plugin-surface/SurfacePlugin.tsx
6
- import React from "react";
7
- import { create } from "@dxos/live-object";
8
-
9
- // packages/sdk/app-framework/src/plugins/plugin-surface/SurfaceContext.ts
10
- import { createContext, useContext } from "react";
11
- import { raise } from "@dxos/debug";
12
- var createSurface = (definition) => definition;
13
- var SurfaceContext = createContext(void 0);
14
- var useSurfaceRoot = () => useContext(SurfaceContext) ?? raise(new Error("Missing SurfaceContext"));
15
- var SurfaceProvider = SurfaceContext.Provider;
16
-
17
- // packages/sdk/app-framework/src/plugins/plugin-surface/meta.ts
18
- var SurfaceMeta = {
19
- id: "dxos.org/plugin/surface"
20
- };
21
- var meta_default = SurfaceMeta;
22
-
23
- // packages/sdk/app-framework/src/plugins/plugin-surface/provides.ts
24
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.surfaces ? plugin : void 0;
25
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.definitions ? plugin : void 0;
26
-
27
- // packages/sdk/app-framework/src/plugins/plugin-surface/SurfacePlugin.tsx
28
- var SurfacePlugin = () => {
29
- const state = create({
30
- surfaces: {},
31
- debugInfo: /* @__PURE__ */ new Map()
32
- });
33
- return {
34
- meta: meta_default,
35
- ready: async (context) => {
36
- state.surfaces = filterPlugins(context.plugins, parseSurfacePlugin).reduce((acc, plugin) => reduceSurfaces(plugin.provides.surface.definitions(context), acc), {});
37
- },
38
- provides: {
39
- surface: state,
40
- context: ({ children }) => /* @__PURE__ */ React.createElement(SurfaceProvider, {
41
- value: state
42
- }, children)
43
- }
44
- };
45
- };
46
- var reduceSurfaces = (definitions, surfaces = {}) => {
47
- if (Array.isArray(definitions)) {
48
- return definitions.reduce((acc, definition) => reduceSurfaces(definition, acc), surfaces);
49
- }
50
- return {
51
- ...surfaces,
52
- [definitions.id]: definitions
53
- };
54
- };
55
-
56
- // packages/sdk/app-framework/src/plugins/plugin-surface/helpers.ts
57
- var isObject = (data) => !!data && typeof data === "object";
58
-
59
- // packages/sdk/app-framework/src/plugins/plugin-surface/ErrorBoundary.tsx
60
- import React2, { Component } from "react";
61
- var ErrorBoundary = class extends Component {
62
- constructor(props) {
63
- super(props);
64
- this.state = {
65
- error: void 0
66
- };
67
- }
68
- static getDerivedStateFromError(error) {
69
- return {
70
- error
71
- };
72
- }
73
- componentDidUpdate(prevProps) {
74
- if (prevProps.data !== this.props.data) {
75
- this.resetError();
76
- }
77
- }
78
- render() {
79
- if (this.state.error) {
80
- return /* @__PURE__ */ React2.createElement(this.props.fallback, {
81
- data: this.props.data,
82
- error: this.state.error,
83
- reset: this.resetError
84
- });
85
- }
86
- return this.props.children;
87
- }
88
- resetError() {
89
- this.setState({
90
- error: void 0
91
- });
92
- }
93
- };
94
-
95
- // packages/sdk/app-framework/src/plugins/plugin-surface/Surface.tsx
96
- import React3, { Suspense, forwardRef, memo, useEffect, useId, useMemo } from "react";
97
- import { useDefaultValue } from "@dxos/react-hooks";
98
- var Surface = /* @__PURE__ */ memo(/* @__PURE__ */ forwardRef(({ id: _id, role, data: _data, limit, fallback, placeholder, ...rest }, forwardedRef) => {
99
- const { surfaces, debugInfo } = useSurfaceRoot();
100
- const data = useDefaultValue(_data, () => ({}));
101
- const reactId = useId();
102
- const id = _id ?? reactId;
103
- useEffect(() => {
104
- debugInfo?.set(id, {
105
- id,
106
- created: Date.now(),
107
- role,
108
- renderCount: 0
109
- });
110
- return () => {
111
- debugInfo?.delete(id);
112
- };
113
- }, [
114
- id
115
- ]);
116
- if (debugInfo?.get(id)) {
117
- debugInfo.get(id).renderCount++;
118
- }
119
- const candidates = useMemo(() => {
120
- 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" }) => {
121
- return a === b ? 0 : a === "hoist" || b === "fallback" ? -1 : b === "hoist" || a === "fallback" ? 1 : 0;
122
- });
123
- return limit ? definitions.slice(0, limit) : definitions;
124
- }, [
125
- surfaces,
126
- role,
127
- data,
128
- limit
129
- ]);
130
- const nodes = candidates.map(({ component: Component2, id: id2 }) => /* @__PURE__ */ React3.createElement(Component2, {
131
- ref: forwardedRef,
132
- key: id2,
133
- id: id2,
134
- role,
135
- data,
136
- limit,
137
- ...rest
138
- }));
139
- const suspense = placeholder ? /* @__PURE__ */ React3.createElement(Suspense, {
140
- fallback: placeholder
141
- }, nodes) : nodes;
142
- return fallback ? /* @__PURE__ */ React3.createElement(ErrorBoundary, {
143
- data,
144
- fallback
145
- }, suspense) : suspense;
146
- }));
147
-
148
- // packages/sdk/app-framework/src/plugins/plugin-surface/index.ts
149
- var plugin_surface_default = SurfacePlugin;
150
-
151
- export {
152
- createSurface,
153
- useSurfaceRoot,
154
- SurfaceProvider,
155
- meta_default,
156
- parseRootSurfacePlugin,
157
- parseSurfacePlugin,
158
- isObject,
159
- ErrorBoundary,
160
- Surface,
161
- plugin_surface_default
162
- };
163
- //# sourceMappingURL=chunk-SPDTXTOV.mjs.map