@dxos/app-framework 0.6.14-main.2b6a0f3 → 0.6.14-main.f49f251

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 (210) hide show
  1. package/dist/lib/browser/chunk-3E7RY3CE.mjs +72 -0
  2. package/dist/lib/browser/chunk-3E7RY3CE.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-653Y45CL.mjs +41 -0
  4. package/dist/lib/browser/chunk-653Y45CL.mjs.map +7 -0
  5. package/dist/lib/browser/{plugin-MM66VRCO.mjs → chunk-CDLQO5K2.mjs} +66 -20
  6. package/dist/lib/browser/chunk-CDLQO5K2.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-EQTQGGE6.mjs +214 -0
  8. package/dist/lib/browser/chunk-EQTQGGE6.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +78 -212
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/meta.json +1 -1
  12. package/dist/lib/browser/plugin-intent-Q5KFPKFA.mjs +22 -0
  13. package/dist/lib/browser/plugin-intent-Q5KFPKFA.mjs.map +7 -0
  14. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs +11 -0
  15. package/dist/lib/browser/plugin-settings-OM3G2QFY.mjs.map +7 -0
  16. package/dist/lib/browser/plugin-surface-ZQXFAL46.mjs +24 -0
  17. package/dist/lib/browser/plugin-surface-ZQXFAL46.mjs.map +7 -0
  18. package/dist/lib/node/chunk-EF67TRWJ.cjs +236 -0
  19. package/dist/lib/node/chunk-EF67TRWJ.cjs.map +7 -0
  20. package/dist/lib/node/chunk-JZ2JVKRY.cjs +58 -0
  21. package/dist/lib/node/chunk-JZ2JVKRY.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-62W6CMGM.cjs → chunk-QBM42OQ6.cjs} +56 -5
  23. package/dist/lib/node/chunk-QBM42OQ6.cjs.map +7 -0
  24. package/dist/lib/node/{plugin-QV7ESETI.cjs → chunk-VOKMWTKO.cjs} +74 -20
  25. package/dist/lib/node/chunk-VOKMWTKO.cjs.map +7 -0
  26. package/dist/lib/node/index.cjs +89 -223
  27. package/dist/lib/node/index.cjs.map +4 -4
  28. package/dist/lib/node/meta.json +1 -1
  29. package/dist/lib/node/plugin-intent-FMC4SDI3.cjs +43 -0
  30. package/dist/lib/node/plugin-intent-FMC4SDI3.cjs.map +7 -0
  31. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs +32 -0
  32. package/dist/lib/node/plugin-settings-OZ6IKAE5.cjs.map +7 -0
  33. package/dist/lib/node/plugin-surface-B5NHOBSW.cjs +45 -0
  34. package/dist/lib/node/plugin-surface-B5NHOBSW.cjs.map +7 -0
  35. package/dist/lib/node-esm/chunk-3FCLBEOX.mjs +215 -0
  36. package/dist/lib/node-esm/chunk-3FCLBEOX.mjs.map +7 -0
  37. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs +74 -0
  38. package/dist/lib/node-esm/chunk-EYCTSFEJ.mjs.map +7 -0
  39. package/dist/lib/node-esm/{plugin-5AAUGDB3.mjs → chunk-MYNXI5VG.mjs} +66 -20
  40. package/dist/lib/node-esm/chunk-MYNXI5VG.mjs.map +7 -0
  41. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs +43 -0
  42. package/dist/lib/node-esm/chunk-YNU7FTGJ.mjs.map +7 -0
  43. package/dist/lib/node-esm/index.mjs +78 -212
  44. package/dist/lib/node-esm/index.mjs.map +4 -4
  45. package/dist/lib/node-esm/meta.json +1 -1
  46. package/dist/lib/node-esm/plugin-intent-KETLP7UL.mjs +23 -0
  47. package/dist/lib/node-esm/plugin-intent-KETLP7UL.mjs.map +7 -0
  48. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs +12 -0
  49. package/dist/lib/node-esm/plugin-settings-37UVWF2V.mjs.map +7 -0
  50. package/dist/lib/node-esm/plugin-surface-QXQRR534.mjs +25 -0
  51. package/dist/lib/node-esm/plugin-surface-QXQRR534.mjs.map +7 -0
  52. package/dist/types/src/App.d.ts +2 -2
  53. package/dist/types/src/App.d.ts.map +1 -1
  54. package/dist/types/src/plugins/common/file.d.ts +1 -1
  55. package/dist/types/src/plugins/common/file.d.ts.map +1 -1
  56. package/dist/types/src/plugins/common/graph.d.ts +1 -1
  57. package/dist/types/src/plugins/common/graph.d.ts.map +1 -1
  58. package/dist/types/src/plugins/common/index.d.ts +0 -1
  59. package/dist/types/src/plugins/common/index.d.ts.map +1 -1
  60. package/dist/types/src/plugins/common/layout.d.ts +6 -6
  61. package/dist/types/src/plugins/common/layout.d.ts.map +1 -1
  62. package/dist/types/src/plugins/common/metadata.d.ts +1 -1
  63. package/dist/types/src/plugins/common/metadata.d.ts.map +1 -1
  64. package/dist/types/src/plugins/common/navigation.d.ts +8 -8
  65. package/dist/types/src/plugins/common/navigation.d.ts.map +1 -1
  66. package/dist/types/src/plugins/common/translations.d.ts +1 -1
  67. package/dist/types/src/plugins/common/translations.d.ts.map +1 -1
  68. package/dist/types/src/plugins/helpers.d.ts +20 -5
  69. package/dist/types/src/plugins/helpers.d.ts.map +1 -1
  70. package/dist/types/src/plugins/index.d.ts +4 -3
  71. package/dist/types/src/plugins/index.d.ts.map +1 -1
  72. package/dist/types/src/plugins/{PluginHost/PluginHost.d.ts → plugin-host/HostPlugin.d.ts} +6 -6
  73. package/dist/types/src/plugins/plugin-host/HostPlugin.d.ts.map +1 -0
  74. package/dist/types/src/plugins/{PluginHost → plugin-host}/PluginContainer.d.ts +2 -2
  75. package/dist/types/src/plugins/plugin-host/PluginContainer.d.ts.map +1 -0
  76. package/dist/types/src/plugins/plugin-host/PluginContext.d.ts.map +1 -0
  77. package/dist/types/src/plugins/plugin-host/index.d.ts +4 -0
  78. package/dist/types/src/plugins/plugin-host/index.d.ts.map +1 -0
  79. package/dist/types/src/plugins/plugin-host/plugin.d.ts.map +1 -0
  80. package/dist/types/src/plugins/plugin-host/plugin.test.d.ts.map +1 -0
  81. package/dist/types/src/plugins/plugin-intent/IntentContext.d.ts.map +1 -0
  82. package/dist/types/src/plugins/{IntentPlugin/plugin.d.ts → plugin-intent/IntentPlugin.d.ts} +3 -4
  83. package/dist/types/src/plugins/plugin-intent/IntentPlugin.d.ts.map +1 -0
  84. package/dist/types/src/plugins/plugin-intent/helpers.d.ts.map +1 -0
  85. package/dist/types/src/plugins/plugin-intent/index.d.ts +6 -0
  86. package/dist/types/src/plugins/plugin-intent/index.d.ts.map +1 -0
  87. package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/intent.d.ts +1 -1
  88. package/dist/types/src/plugins/plugin-intent/intent.d.ts.map +1 -0
  89. package/dist/types/src/plugins/plugin-intent/meta.d.ts.map +1 -0
  90. package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/provides.d.ts +2 -2
  91. package/dist/types/src/plugins/plugin-intent/provides.d.ts.map +1 -0
  92. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts +4 -0
  93. package/dist/types/src/plugins/plugin-settings/SettingsPlugin.d.ts.map +1 -0
  94. package/dist/types/src/plugins/plugin-settings/index.d.ts +4 -0
  95. package/dist/types/src/plugins/plugin-settings/index.d.ts.map +1 -0
  96. package/dist/types/src/plugins/plugin-settings/meta.d.ts +5 -0
  97. package/dist/types/src/plugins/plugin-settings/meta.d.ts.map +1 -0
  98. package/dist/types/src/plugins/plugin-settings/provides.d.ts +13 -0
  99. package/dist/types/src/plugins/plugin-settings/provides.d.ts.map +1 -0
  100. package/dist/types/src/plugins/plugin-surface/ErrorBoundary.d.ts.map +1 -0
  101. package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/Surface.d.ts +4 -0
  102. package/dist/types/src/plugins/plugin-surface/Surface.d.ts.map +1 -0
  103. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts +7 -0
  104. package/dist/types/src/plugins/plugin-surface/SurfacePlugin.d.ts.map +1 -0
  105. package/dist/types/src/plugins/plugin-surface/SurfaceRootContext.d.ts.map +1 -0
  106. package/dist/types/src/plugins/plugin-surface/helpers.d.ts.map +1 -0
  107. package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/index.d.ts +2 -0
  108. package/dist/types/src/plugins/plugin-surface/index.d.ts.map +1 -0
  109. package/dist/types/src/plugins/plugin-surface/meta.d.ts.map +1 -0
  110. package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/provides.d.ts +1 -1
  111. package/dist/types/src/plugins/plugin-surface/provides.d.ts.map +1 -0
  112. package/package.json +14 -16
  113. package/src/App.tsx +13 -12
  114. package/src/plugins/common/file.ts +1 -1
  115. package/src/plugins/common/graph.ts +1 -1
  116. package/src/plugins/common/index.ts +0 -1
  117. package/src/plugins/common/layout.ts +6 -3
  118. package/src/plugins/common/metadata.ts +1 -1
  119. package/src/plugins/common/navigation.ts +6 -3
  120. package/src/plugins/common/translations.ts +2 -8
  121. package/src/plugins/helpers.ts +55 -11
  122. package/src/plugins/index.ts +4 -3
  123. package/src/plugins/{PluginHost/PluginHost.tsx → plugin-host/HostPlugin.tsx} +10 -9
  124. package/src/plugins/{PluginHost → plugin-host}/PluginContainer.tsx +2 -2
  125. package/src/plugins/{PluginHost → plugin-host}/PluginContext.tsx +1 -0
  126. package/src/plugins/{PluginHost → plugin-host}/index.ts +2 -1
  127. package/src/plugins/{IntentPlugin/plugin.tsx → plugin-intent/IntentPlugin.tsx} +3 -6
  128. package/src/plugins/{IntentPlugin → plugin-intent}/index.ts +4 -0
  129. package/src/plugins/{IntentPlugin → plugin-intent}/intent.ts +1 -1
  130. package/src/plugins/{IntentPlugin → plugin-intent}/provides.ts +5 -2
  131. package/src/plugins/plugin-settings/SettingsPlugin.tsx +22 -0
  132. package/src/plugins/plugin-settings/index.ts +9 -0
  133. package/src/plugins/plugin-settings/meta.ts +9 -0
  134. package/src/plugins/plugin-settings/provides.ts +29 -0
  135. package/src/plugins/{SurfacePlugin → plugin-surface}/Surface.tsx +60 -46
  136. package/src/plugins/{SurfacePlugin/plugin.tsx → plugin-surface/SurfacePlugin.tsx} +2 -4
  137. package/src/plugins/{SurfacePlugin → plugin-surface}/index.ts +4 -0
  138. package/src/plugins/{SurfacePlugin → plugin-surface}/provides.ts +2 -1
  139. package/dist/lib/browser/chunk-J45KR4DI.mjs +0 -52
  140. package/dist/lib/browser/chunk-J45KR4DI.mjs.map +0 -7
  141. package/dist/lib/browser/chunk-S5CI6EUQ.mjs +0 -20
  142. package/dist/lib/browser/chunk-S5CI6EUQ.mjs.map +0 -7
  143. package/dist/lib/browser/chunk-SB4XRTGZ.mjs +0 -25
  144. package/dist/lib/browser/chunk-SB4XRTGZ.mjs.map +0 -7
  145. package/dist/lib/browser/plugin-MM66VRCO.mjs.map +0 -7
  146. package/dist/lib/browser/plugin-Y4KRQJE4.mjs +0 -40
  147. package/dist/lib/browser/plugin-Y4KRQJE4.mjs.map +0 -7
  148. package/dist/lib/node/chunk-62W6CMGM.cjs.map +0 -7
  149. package/dist/lib/node/chunk-DFST5IG5.cjs +0 -77
  150. package/dist/lib/node/chunk-DFST5IG5.cjs.map +0 -7
  151. package/dist/lib/node/chunk-PJGE52CN.cjs +0 -47
  152. package/dist/lib/node/chunk-PJGE52CN.cjs.map +0 -7
  153. package/dist/lib/node/plugin-6TEDSCXW.cjs +0 -62
  154. package/dist/lib/node/plugin-6TEDSCXW.cjs.map +0 -7
  155. package/dist/lib/node/plugin-QV7ESETI.cjs.map +0 -7
  156. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs +0 -22
  157. package/dist/lib/node-esm/chunk-IY7HCP4K.mjs.map +0 -7
  158. package/dist/lib/node-esm/chunk-MBHRXQTR.mjs +0 -27
  159. package/dist/lib/node-esm/chunk-MBHRXQTR.mjs.map +0 -7
  160. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs +0 -54
  161. package/dist/lib/node-esm/chunk-P2TQLXZR.mjs.map +0 -7
  162. package/dist/lib/node-esm/plugin-5AAUGDB3.mjs.map +0 -7
  163. package/dist/lib/node-esm/plugin-J5IRJLM6.mjs +0 -41
  164. package/dist/lib/node-esm/plugin-J5IRJLM6.mjs.map +0 -7
  165. package/dist/types/src/plugins/IntentPlugin/IntentContext.d.ts.map +0 -1
  166. package/dist/types/src/plugins/IntentPlugin/helpers.d.ts.map +0 -1
  167. package/dist/types/src/plugins/IntentPlugin/index.d.ts +0 -4
  168. package/dist/types/src/plugins/IntentPlugin/index.d.ts.map +0 -1
  169. package/dist/types/src/plugins/IntentPlugin/intent.d.ts.map +0 -1
  170. package/dist/types/src/plugins/IntentPlugin/meta.d.ts.map +0 -1
  171. package/dist/types/src/plugins/IntentPlugin/plugin.d.ts.map +0 -1
  172. package/dist/types/src/plugins/IntentPlugin/provides.d.ts.map +0 -1
  173. package/dist/types/src/plugins/PluginHost/PluginContainer.d.ts.map +0 -1
  174. package/dist/types/src/plugins/PluginHost/PluginContext.d.ts.map +0 -1
  175. package/dist/types/src/plugins/PluginHost/PluginHost.d.ts.map +0 -1
  176. package/dist/types/src/plugins/PluginHost/index.d.ts +0 -4
  177. package/dist/types/src/plugins/PluginHost/index.d.ts.map +0 -1
  178. package/dist/types/src/plugins/PluginHost/plugin.d.ts.map +0 -1
  179. package/dist/types/src/plugins/PluginHost/plugin.test.d.ts.map +0 -1
  180. package/dist/types/src/plugins/SurfacePlugin/ErrorBoundary.d.ts.map +0 -1
  181. package/dist/types/src/plugins/SurfacePlugin/Surface.d.ts.map +0 -1
  182. package/dist/types/src/plugins/SurfacePlugin/SurfaceRootContext.d.ts.map +0 -1
  183. package/dist/types/src/plugins/SurfacePlugin/helpers.d.ts.map +0 -1
  184. package/dist/types/src/plugins/SurfacePlugin/index.d.ts.map +0 -1
  185. package/dist/types/src/plugins/SurfacePlugin/meta.d.ts.map +0 -1
  186. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts +0 -8
  187. package/dist/types/src/plugins/SurfacePlugin/plugin.d.ts.map +0 -1
  188. package/dist/types/src/plugins/SurfacePlugin/provides.d.ts.map +0 -1
  189. package/dist/types/src/plugins/common/settings.d.ts +0 -9
  190. package/dist/types/src/plugins/common/settings.d.ts.map +0 -1
  191. package/src/plugins/common/settings.ts +0 -22
  192. /package/dist/types/src/plugins/{PluginHost → plugin-host}/PluginContext.d.ts +0 -0
  193. /package/dist/types/src/plugins/{PluginHost → plugin-host}/plugin.d.ts +0 -0
  194. /package/dist/types/src/plugins/{PluginHost → plugin-host}/plugin.test.d.ts +0 -0
  195. /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/IntentContext.d.ts +0 -0
  196. /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/helpers.d.ts +0 -0
  197. /package/dist/types/src/plugins/{IntentPlugin → plugin-intent}/meta.d.ts +0 -0
  198. /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/ErrorBoundary.d.ts +0 -0
  199. /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/SurfaceRootContext.d.ts +0 -0
  200. /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/helpers.d.ts +0 -0
  201. /package/dist/types/src/plugins/{SurfacePlugin → plugin-surface}/meta.d.ts +0 -0
  202. /package/src/plugins/{PluginHost → plugin-host}/plugin.test.ts +0 -0
  203. /package/src/plugins/{PluginHost → plugin-host}/plugin.ts +0 -0
  204. /package/src/plugins/{IntentPlugin → plugin-intent}/IntentContext.tsx +0 -0
  205. /package/src/plugins/{IntentPlugin → plugin-intent}/helpers.ts +0 -0
  206. /package/src/plugins/{IntentPlugin → plugin-intent}/meta.ts +0 -0
  207. /package/src/plugins/{SurfacePlugin → plugin-surface}/ErrorBoundary.tsx +0 -0
  208. /package/src/plugins/{SurfacePlugin → plugin-surface}/SurfaceRootContext.tsx +0 -0
  209. /package/src/plugins/{SurfacePlugin → plugin-surface}/helpers.ts +0 -0
  210. /package/src/plugins/{SurfacePlugin → plugin-surface}/meta.ts +0 -0
@@ -1,52 +0,0 @@
1
- // packages/sdk/app-framework/src/plugins/IntentPlugin/provides.ts
2
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
3
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
4
- var INTENT_ACTION = "dxos.org/plugin/intent";
5
- var IntentAction;
6
- (function(IntentAction2) {
7
- IntentAction2[IntentAction2["SHOW_UNDO"] = `${INTENT_ACTION}/show-undo`] = "SHOW_UNDO";
8
- })(IntentAction || (IntentAction = {}));
9
-
10
- // packages/sdk/app-framework/src/plugins/IntentPlugin/IntentContext.tsx
11
- import { createContext, useContext } from "react";
12
- import { useEffect } from "react";
13
- var IntentContext = /* @__PURE__ */ createContext({
14
- dispatch: async () => ({}),
15
- undo: async () => ({}),
16
- history: [],
17
- registerResolver: () => () => {
18
- }
19
- });
20
- var useIntent = () => useContext(IntentContext);
21
- var useIntentDispatcher = () => {
22
- const { dispatch } = useIntent();
23
- return dispatch;
24
- };
25
- var useIntentResolver = (plugin, resolver) => {
26
- const { registerResolver } = useIntent();
27
- useEffect(() => {
28
- return registerResolver(plugin, resolver);
29
- }, [
30
- plugin,
31
- resolver
32
- ]);
33
- };
34
- var IntentProvider = IntentContext.Provider;
35
-
36
- // packages/sdk/app-framework/src/plugins/IntentPlugin/meta.ts
37
- var IntentMeta = {
38
- id: "dxos.org/plugin/intent"
39
- };
40
- var meta_default = IntentMeta;
41
-
42
- export {
43
- parseIntentPlugin,
44
- parseIntentResolverPlugin,
45
- IntentAction,
46
- useIntent,
47
- useIntentDispatcher,
48
- useIntentResolver,
49
- IntentProvider,
50
- meta_default
51
- };
52
- //# sourceMappingURL=chunk-J45KR4DI.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/IntentPlugin/provides.ts", "../../../src/plugins/IntentPlugin/IntentContext.tsx", "../../../src/plugins/IntentPlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext } from './IntentContext';\nimport { type IntentResolver } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: IntentResolver;\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?.resolver ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n\n//\n// Intents\n//\n\nconst INTENT_ACTION = 'dxos.org/plugin/intent';\nexport enum IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n SHOW_UNDO = `${INTENT_ACTION}/show-undo`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\nimport { useEffect } from 'react';\n\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Intent, IntentDispatcher, IntentResolver, IntentResult } from './intent';\n\nexport type IntentExecution = {\n intent: Intent;\n result: IntentResult;\n};\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n undo: () => Promise<IntentResult | void>;\n history: IntentExecution[][];\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated Prefer granular hooks.\n */\n// TODO(burdon): Remove. Use useIntentDispatcher.\nexport const useIntent = () => useContext(IntentContext);\n\nexport const useIntentDispatcher = (): IntentDispatcher => {\n const { dispatch } = useIntent();\n return dispatch;\n};\n\nexport const useIntentResolver = (plugin: string, resolver: IntentResolver) => {\n const { registerResolver } = useIntent();\n useEffect(() => {\n return registerResolver(plugin, resolver);\n }, [plugin, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext> = IntentContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst IntentMeta = {\n id: 'dxos.org/plugin/intent',\n};\n\nexport default IntentMeta;\n"],
5
- "mappings": ";AAkBO,IAAMA,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;AAM3F,IAAMG,gBAAgB;;UACVC,eAAAA;AAGT,EAAAA,cAAAA,cAAA,WAAA,IACW,GAAGD,aAAAA,YAAyB,IAAA;GAJ9BC,iBAAAA,eAAAA,CAAAA,EAAAA;;;ACzBZ,SAAuBC,eAAeC,kBAAiC;AACvE,SAASC,iBAAiB;AAkB1B,IAAMC,gBAAwCC,8BAA6B;EACzEC,UAAU,aAAa,CAAC;EACxBC,MAAM,aAAa,CAAC;EACpBC,SAAS,CAAA;EACTC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,MAAMC,WAAWP,aAAAA;AAEnC,IAAMQ,sBAAsB,MAAA;AACjC,QAAM,EAAEN,SAAQ,IAAKI,UAAAA;AACrB,SAAOJ;AACT;AAEO,IAAMO,oBAAoB,CAACC,QAAgBC,aAAAA;AAChD,QAAM,EAAEN,iBAAgB,IAAKC,UAAAA;AAC7BM,YAAU,MAAA;AACR,WAAOP,iBAAiBK,QAAQC,QAAAA;EAClC,GAAG;IAACD;IAAQC;GAAS;AACvB;AAEO,IAAME,iBAA0Cb,cAAcc;;;AC5CrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "INTENT_ACTION", "IntentAction", "createContext", "useContext", "useEffect", "IntentContext", "createContext", "dispatch", "undo", "history", "registerResolver", "useIntent", "useContext", "useIntentDispatcher", "useIntentResolver", "plugin", "resolver", "useEffect", "IntentProvider", "Provider", "IntentMeta", "id"]
7
- }
@@ -1,20 +0,0 @@
1
- // packages/sdk/app-framework/src/plugins/helpers.ts
2
- import { raise } from "@dxos/debug";
3
- var definePlugin = (plugin) => plugin;
4
- var findPlugin = (plugins, id) => {
5
- return plugins.find((plugin) => plugin.meta.id === id || typeof plugin.meta.shortId === "string" && plugin.meta.shortId === id);
6
- };
7
- var getPlugin = (plugins, id) => {
8
- return findPlugin(plugins, id) ?? raise(new Error(`Plugin not found: ${id}`));
9
- };
10
- var filterPlugins = (plugins, predicate) => plugins.map((plugin) => predicate(plugin)).filter((plugin) => !!plugin);
11
- var resolvePlugin = (plugins, predicate) => filterPlugins(plugins, predicate)[0];
12
-
13
- export {
14
- definePlugin,
15
- findPlugin,
16
- getPlugin,
17
- filterPlugins,
18
- resolvePlugin
19
- };
20
- //# sourceMappingURL=chunk-S5CI6EUQ.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 { raise } from '@dxos/debug';\n\nimport { type Plugin } from './PluginHost';\n\n/**\n * Define a plugin\n */\nexport const definePlugin = <TProvides>(plugin: Plugin<TProvides>): Plugin<TProvides> => plugin;\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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T>[] => 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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T> | undefined => filterPlugins(plugins, predicate)[0];\n"],
5
- "mappings": ";AAIA,SAASA,aAAa;AAOf,IAAMC,eAAe,CAAYC,WAAiDA;AAKlF,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACJ,WAAWA,OAAOK,KAAKF,OAAOA,MAAO,OAAOH,OAAOK,KAAKC,YAAY,YAAYN,OAAOK,KAAKC,YAAYH,EAAAA;AAE7G;AAKO,IAAMI,YAAY,CAAIL,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,KAAOK,MAAM,IAAIC,MAAM,qBAAqBN,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMO,gBAAgB,CAC3BR,SACAS,cACgBT,QAAQU,IAAI,CAACZ,WAAWW,UAAUX,MAAAA,CAAAA,EAASa,OAAO,CAACb,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMc,gBAAgB,CAC3BZ,SACAS,cAC0BD,cAAcR,SAASS,SAAAA,EAAW,CAAA;",
6
- "names": ["raise", "definePlugin", "plugin", "findPlugin", "plugins", "id", "find", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
- }
@@ -1,25 +0,0 @@
1
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
2
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
3
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
4
-
5
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
6
- import { createContext, useContext } from "react";
7
- import { raise } from "@dxos/debug";
8
- var SurfaceRootContext = /* @__PURE__ */ createContext(void 0);
9
- var useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error("Missing SurfaceRootContext"));
10
- var SurfaceProvider = SurfaceRootContext.Provider;
11
-
12
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
13
- var SurfaceMeta = {
14
- id: "dxos.org/plugin/surface"
15
- };
16
- var meta_default = SurfaceMeta;
17
-
18
- export {
19
- parseRootSurfacePlugin,
20
- parseSurfacePlugin,
21
- useSurfaceRoot,
22
- SurfaceProvider,
23
- meta_default
24
- };
25
- //# sourceMappingURL=chunk-SB4XRTGZ.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\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' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
5
- "mappings": ";AAoBO,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;;;ACpBxF,SAASG,eAAeC,kBAA+C;AAEvE,SAASC,aAAa;AAkDtB,IAAMC,qBAAqBC,8BAA8CC,MAAAA;AAElE,IAAMC,iBAAiB,MAAMC,WAAWJ,kBAAAA,KAAuBK,MAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBP,mBAAmBQ;;;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "createContext", "useContext", "raise", "SurfaceRootContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/IntentPlugin/plugin.tsx", "../../../src/plugins/IntentPlugin/helpers.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { type IntentContext, IntentProvider, type IntentExecution } from './IntentContext';\nimport { isUndoable } from './helpers';\nimport type { Intent, IntentResolver } from './intent';\nimport IntentMeta from './meta';\nimport {\n type IntentPluginProvides,\n type IntentResolverProvides,\n parseIntentResolverPlugin,\n IntentAction,\n} from './provides';\nimport type { PluginDefinition } from '../PluginHost';\nimport { filterPlugins, findPlugin } from '../helpers';\n\nconst EXECUTION_LIMIT = 1000;\nconst HISTORY_LIMIT = 100;\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 */\nconst IntentPlugin = (): PluginDefinition<IntentPluginProvides> => {\n const state = create<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n });\n\n const dynamicResolvers = new Set<{ plugin: string; resolver: IntentResolver }>();\n\n return {\n meta: IntentMeta,\n ready: async (plugins) => {\n // Dispatch intent to associated plugin.\n const dispatch = async (intent: Intent) => {\n log('dispatch', { action: intent.action, intent });\n if (intent.plugin) {\n for (const entry of dynamicResolvers) {\n if (entry.plugin === intent.plugin) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n }\n\n const plugin = findPlugin<IntentResolverProvides>(plugins, intent.plugin);\n const result = plugin?.provides.intent.resolver(intent, plugins);\n return result;\n }\n\n for (const entry of dynamicResolvers) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // Return resolved value from first plugin that handles the intent.\n for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {\n const result = await plugin.provides.intent.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // https://vitejs.dev/guide/env-and-mode#env-variables\n // TODO(wittjosiah): How to handle this more generically?\n if (import.meta?.env?.DEV) {\n log.warn('No plugin found to handle intent', intent);\n }\n };\n\n // Sequentially dispatch array of invents.\n const dispatchChain = async (intentOrArray: Intent | Intent[], depth = 0) => {\n if (depth > EXECUTION_LIMIT) {\n return {\n error: new Error(\n `Intent execution limit exceeded (${EXECUTION_LIMIT} iterations). This is likely due to an infinite loop within intent resolvers.`,\n ),\n };\n }\n\n const executionResults: IntentExecution[] = [];\n const chain = Array.isArray(intentOrArray) ? intentOrArray : [intentOrArray];\n for (const intent of chain) {\n const { result: prevResult } = executionResults.at(-1) ?? {};\n const data = intent.data ? { result: prevResult?.data, ...intent.data } : prevResult?.data;\n const result = await dispatch({ ...intent, data });\n\n if (!result || result?.error) {\n break;\n }\n\n executionResults.push({ intent, result });\n\n // TODO(wittjosiah): How does undo work with returned intents?\n result?.intents?.forEach((intents) => {\n void dispatchChain(intents, depth + 1);\n });\n }\n\n state.history.push(executionResults);\n if (state.history.length > HISTORY_LIMIT) {\n state.history.splice(0, state.history.length - HISTORY_LIMIT);\n }\n\n if (isUndoable(executionResults)) {\n void dispatch({ action: IntentAction.SHOW_UNDO, data: { results: executionResults } });\n }\n\n return executionResults.at(-1)?.result;\n };\n\n const undo = async () => {\n const last = state.history.findLastIndex(isUndoable);\n const chain =\n last !== -1 &&\n state.history[last]?.map(({ intent, result }): Intent => {\n const data = result.undoable?.data ? { ...intent.data, ...result.undoable.data } : intent.data;\n return { ...intent, data, undo: true };\n });\n if (chain) {\n const result = await dispatchChain(chain);\n state.history = state.history.filter((_, index) => index !== last);\n return result;\n }\n };\n\n state.dispatch = dispatchChain;\n state.undo = undo;\n state.registerResolver = (plugin, resolver) => {\n const entry = { plugin, resolver };\n dynamicResolvers.add(entry);\n return () => dynamicResolvers.delete(entry);\n };\n },\n provides: {\n intent: state,\n context: ({ children }) => <IntentProvider value={state}>{children}</IntentProvider>,\n },\n };\n};\n\nexport default IntentPlugin;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type IntentExecution } from './IntentContext';\n\n/**\n * Check if the chain of intents is undoable.\n */\nexport const isUndoable = (chain: IntentExecution[]): boolean =>\n chain.length > 0 && chain.every(({ result }) => result.undoable);\n"],
5
- "mappings": "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",
6
- "names": ["React", "create", "log", "isUndoable", "chain", "length", "every", "result", "undoable", "EXECUTION_LIMIT", "HISTORY_LIMIT", "IntentPlugin", "state", "create", "dispatch", "undo", "history", "registerResolver", "dynamicResolvers", "Set", "meta", "IntentMeta", "ready", "plugins", "intent", "log", "action", "plugin", "entry", "result", "resolver", "findPlugin", "provides", "filterPlugins", "parseIntentResolverPlugin", "env", "DEV", "warn", "dispatchChain", "intentOrArray", "depth", "error", "Error", "executionResults", "chain", "Array", "isArray", "prevResult", "at", "data", "push", "intents", "forEach", "length", "splice", "isUndoable", "IntentAction", "SHOW_UNDO", "results", "last", "findLastIndex", "map", "undoable", "filter", "_", "index", "add", "delete", "context", "children", "IntentProvider", "value"]
7
- }
@@ -1,40 +0,0 @@
1
- import {
2
- SurfaceProvider,
3
- meta_default,
4
- parseSurfacePlugin
5
- } from "./chunk-SB4XRTGZ.mjs";
6
- import {
7
- filterPlugins
8
- } from "./chunk-S5CI6EUQ.mjs";
9
-
10
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/plugin.tsx
11
- import React from "react";
12
- import { create } from "@dxos/echo-schema";
13
- var SurfacePlugin = () => {
14
- const state = create({
15
- components: {},
16
- debugInfo: /* @__PURE__ */ new Map()
17
- });
18
- return {
19
- meta: meta_default,
20
- ready: async (plugins) => {
21
- state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {
22
- return {
23
- ...acc,
24
- [plugin.meta.id]: plugin.provides.surface.component
25
- };
26
- }, {});
27
- },
28
- provides: {
29
- surface: state,
30
- context: ({ children }) => /* @__PURE__ */ React.createElement(SurfaceProvider, {
31
- value: state
32
- }, children)
33
- }
34
- };
35
- };
36
- var plugin_default = SurfacePlugin;
37
- export {
38
- plugin_default as default
39
- };
40
- //# sourceMappingURL=plugin-Y4KRQJE4.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/plugin.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport { type PluginDefinition } from '../PluginHost';\nimport { filterPlugins } from '../helpers';\n\n/**\n * Provides a registry of surface components.\n */\nconst SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n\nexport default SurfacePlugin;\n"],
5
- "mappings": ";;;;;;;;;;AAIA,OAAOA,WAAW;AAElB,SAASC,cAAc;AAWvB,IAAMC,gBAAgB,MAAA;AACpB,QAAMC,QAAQC,OAA2B;IAAEC,YAAY,CAAC;IAAGC,WAAW,oBAAIC,IAAAA;EAAM,CAAA;AAEhF,SAAO;IACLC,MAAMC;IACNC,OAAO,OAAOC,YAAAA;AACZR,YAAME,aAAaO,cAAcD,SAASE,kBAAAA,EAAoBC,OAAO,CAACC,KAAKC,WAAAA;AACzE,eAAO;UAAE,GAAGD;UAAK,CAACC,OAAOR,KAAKS,EAAE,GAAGD,OAAOE,SAASC,QAAQC;QAAU;MACvE,GAAG,CAAC,CAAA;IACN;IACAF,UAAU;MACRC,SAAShB;MACTkB,SAAS,CAAC,EAAEC,SAAQ,MAAO,sBAAA,cAACC,iBAAAA;QAAgBC,OAAOrB;SAAQmB,QAAAA;IAC7D;EACF;AACF;AAEA,IAAA,iBAAepB;",
6
- "names": ["React", "create", "SurfacePlugin", "state", "create", "components", "debugInfo", "Map", "meta", "SurfaceMeta", "ready", "plugins", "filterPlugins", "parseSurfacePlugin", "reduce", "acc", "plugin", "id", "provides", "surface", "component", "context", "children", "SurfaceProvider", "value"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/helpers.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { raise } from '@dxos/debug';\n\nimport { type Plugin } from './PluginHost';\n\n/**\n * Define a plugin\n */\nexport const definePlugin = <TProvides>(plugin: Plugin<TProvides>): Plugin<TProvides> => plugin;\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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T>[] => 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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T> | undefined => filterPlugins(plugins, predicate)[0];\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAsB;AAOf,IAAMA,eAAe,CAAYC,WAAiDA;AAKlF,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACJ,WAAWA,OAAOK,KAAKF,OAAOA,MAAO,OAAOH,OAAOK,KAAKC,YAAY,YAAYN,OAAOK,KAAKC,YAAYH,EAAAA;AAE7G;AAKO,IAAMI,YAAY,CAAIL,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,SAAOK,oBAAM,IAAIC,MAAM,qBAAqBN,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMO,gBAAgB,CAC3BR,SACAS,cACgBT,QAAQU,IAAI,CAACZ,WAAWW,UAAUX,MAAAA,CAAAA,EAASa,OAAO,CAACb,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMc,gBAAgB,CAC3BZ,SACAS,cAC0BD,cAAcR,SAASS,SAAAA,EAAW,CAAA;",
6
- "names": ["definePlugin", "plugin", "findPlugin", "plugins", "id", "find", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
- }
@@ -1,77 +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_DFST5IG5_exports = {};
20
- __export(chunk_DFST5IG5_exports, {
21
- IntentAction: () => IntentAction,
22
- IntentProvider: () => IntentProvider,
23
- meta_default: () => meta_default,
24
- parseIntentPlugin: () => parseIntentPlugin,
25
- parseIntentResolverPlugin: () => parseIntentResolverPlugin,
26
- useIntent: () => useIntent,
27
- useIntentDispatcher: () => useIntentDispatcher,
28
- useIntentResolver: () => useIntentResolver
29
- });
30
- module.exports = __toCommonJS(chunk_DFST5IG5_exports);
31
- var import_react = require("react");
32
- var import_react2 = require("react");
33
- var parseIntentPlugin = (plugin) => plugin.provides.intent?.dispatch ? plugin : void 0;
34
- var parseIntentResolverPlugin = (plugin) => plugin.provides.intent?.resolver ? plugin : void 0;
35
- var INTENT_ACTION = "dxos.org/plugin/intent";
36
- var IntentAction;
37
- (function(IntentAction2) {
38
- IntentAction2[IntentAction2["SHOW_UNDO"] = `${INTENT_ACTION}/show-undo`] = "SHOW_UNDO";
39
- })(IntentAction || (IntentAction = {}));
40
- var IntentContext = /* @__PURE__ */ (0, import_react.createContext)({
41
- dispatch: async () => ({}),
42
- undo: async () => ({}),
43
- history: [],
44
- registerResolver: () => () => {
45
- }
46
- });
47
- var useIntent = () => (0, import_react.useContext)(IntentContext);
48
- var useIntentDispatcher = () => {
49
- const { dispatch } = useIntent();
50
- return dispatch;
51
- };
52
- var useIntentResolver = (plugin, resolver) => {
53
- const { registerResolver } = useIntent();
54
- (0, import_react2.useEffect)(() => {
55
- return registerResolver(plugin, resolver);
56
- }, [
57
- plugin,
58
- resolver
59
- ]);
60
- };
61
- var IntentProvider = IntentContext.Provider;
62
- var IntentMeta = {
63
- id: "dxos.org/plugin/intent"
64
- };
65
- var meta_default = IntentMeta;
66
- // Annotate the CommonJS export names for ESM import in node:
67
- 0 && (module.exports = {
68
- IntentAction,
69
- IntentProvider,
70
- meta_default,
71
- parseIntentPlugin,
72
- parseIntentResolverPlugin,
73
- useIntent,
74
- useIntentDispatcher,
75
- useIntentResolver
76
- });
77
- //# sourceMappingURL=chunk-DFST5IG5.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/IntentPlugin/provides.ts", "../../../src/plugins/IntentPlugin/IntentContext.tsx", "../../../src/plugins/IntentPlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type IntentContext } from './IntentContext';\nimport { type IntentResolver } from './intent';\nimport { type Plugin } from '../PluginHost';\n\nexport type IntentResolverProvides = {\n intent: {\n resolver: IntentResolver;\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?.resolver ? (plugin as Plugin<IntentResolverProvides>) : undefined;\n\n//\n// Intents\n//\n\nconst INTENT_ACTION = 'dxos.org/plugin/intent';\nexport enum IntentAction {\n /**\n * Fired after an intent is dispatched if the intent is undoable.\n */\n SHOW_UNDO = `${INTENT_ACTION}/show-undo`,\n}\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { type Context, createContext, useContext, type Provider } from 'react';\nimport { useEffect } from 'react';\n\nimport type { UnsubscribeCallback } from '@dxos/async';\n\nimport type { Intent, IntentDispatcher, IntentResolver, IntentResult } from './intent';\n\nexport type IntentExecution = {\n intent: Intent;\n result: IntentResult;\n};\n\nexport type IntentContext = {\n dispatch: IntentDispatcher;\n undo: () => Promise<IntentResult | void>;\n history: IntentExecution[][];\n registerResolver: (pluginId: string, resolver: IntentResolver) => UnsubscribeCallback;\n};\n\nconst IntentContext: Context<IntentContext> = createContext<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n});\n\n/**\n * @deprecated Prefer granular hooks.\n */\n// TODO(burdon): Remove. Use useIntentDispatcher.\nexport const useIntent = () => useContext(IntentContext);\n\nexport const useIntentDispatcher = (): IntentDispatcher => {\n const { dispatch } = useIntent();\n return dispatch;\n};\n\nexport const useIntentResolver = (plugin: string, resolver: IntentResolver) => {\n const { registerResolver } = useIntent();\n useEffect(() => {\n return registerResolver(plugin, resolver);\n }, [plugin, resolver]);\n};\n\nexport const IntentProvider: Provider<IntentContext> = IntentContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst IntentMeta = {\n id: 'dxos.org/plugin/intent',\n};\n\nexport default IntentMeta;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAuE;AACvE,IAAAA,gBAA0B;ADanB,IAAMC,oBAAoB,CAACC,WAC/BA,OAAOC,SAAiBC,QAAQC,WAAYH,SAA0CI;AAElF,IAAMC,4BAA4B,CAACL,WACvCA,OAAOC,SAAiBC,QAAQI,WAAYN,SAA4CI;AAM3F,IAAMG,gBAAgB;;UACVC,eAAAA;AAGTA,gBAAAA,cAAA,WAAA,IACW,GAAGD,aAAAA,YAAyB,IAAA;GAJ9BC,iBAAAA,eAAAA,CAAAA,EAAAA;ACNZ,IAAMC,gBAAwCC,gDAA6B;EACzEP,UAAU,aAAa,CAAC;EACxBQ,MAAM,aAAa,CAAC;EACpBC,SAAS,CAAA;EACTC,kBAAkB,MAAM,MAAA;EAAO;AACjC,CAAA;AAMO,IAAMC,YAAY,UAAMC,yBAAWN,aAAAA;AAEnC,IAAMO,sBAAsB,MAAA;AACjC,QAAM,EAAEb,SAAQ,IAAKW,UAAAA;AACrB,SAAOX;AACT;AAEO,IAAMc,oBAAoB,CAACjB,QAAgBM,aAAAA;AAChD,QAAM,EAAEO,iBAAgB,IAAKC,UAAAA;AAC7BI,+BAAU,MAAA;AACR,WAAOL,iBAAiBb,QAAQM,QAAAA;EAClC,GAAG;IAACN;IAAQM;GAAS;AACvB;AAEO,IAAMa,iBAA0CV,cAAcW;AC5CrE,IAAMC,aAAa;EACjBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["import_react", "parseIntentPlugin", "plugin", "provides", "intent", "dispatch", "undefined", "parseIntentResolverPlugin", "resolver", "INTENT_ACTION", "IntentAction", "IntentContext", "createContext", "undo", "history", "registerResolver", "useIntent", "useContext", "useIntentDispatcher", "useIntentResolver", "useEffect", "IntentProvider", "Provider", "IntentMeta", "id"]
7
- }
@@ -1,47 +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_PJGE52CN_exports = {};
20
- __export(chunk_PJGE52CN_exports, {
21
- SurfaceProvider: () => SurfaceProvider,
22
- meta_default: () => meta_default,
23
- parseRootSurfacePlugin: () => parseRootSurfacePlugin,
24
- parseSurfacePlugin: () => parseSurfacePlugin,
25
- useSurfaceRoot: () => useSurfaceRoot
26
- });
27
- module.exports = __toCommonJS(chunk_PJGE52CN_exports);
28
- var import_react = require("react");
29
- var import_debug = require("@dxos/debug");
30
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
31
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
32
- var SurfaceRootContext = /* @__PURE__ */ (0, import_react.createContext)(void 0);
33
- var useSurfaceRoot = () => (0, import_react.useContext)(SurfaceRootContext) ?? (0, import_debug.raise)(new Error("Missing SurfaceRootContext"));
34
- var SurfaceProvider = SurfaceRootContext.Provider;
35
- var SurfaceMeta = {
36
- id: "dxos.org/plugin/surface"
37
- };
38
- var meta_default = SurfaceMeta;
39
- // Annotate the CommonJS export names for ESM import in node:
40
- 0 && (module.exports = {
41
- SurfaceProvider,
42
- meta_default,
43
- parseRootSurfacePlugin,
44
- parseSurfacePlugin,
45
- useSurfaceRoot
46
- });
47
- //# sourceMappingURL=chunk-PJGE52CN.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\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' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,mBAAuE;AAEvE,mBAAsB;ADcf,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;ACgCxF,IAAMG,qBAAqBC,gDAA8CJ,MAAAA;AAElE,IAAMK,iBAAiB,UAAMC,yBAAWH,kBAAAA,SAAuBI,oBAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBN,mBAAmBO;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "SurfaceRootContext", "createContext", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
- }
@@ -1,62 +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 plugin_6TEDSCXW_exports = {};
30
- __export(plugin_6TEDSCXW_exports, {
31
- default: () => plugin_default
32
- });
33
- module.exports = __toCommonJS(plugin_6TEDSCXW_exports);
34
- var import_chunk_PJGE52CN = require("./chunk-PJGE52CN.cjs");
35
- var import_chunk_62W6CMGM = require("./chunk-62W6CMGM.cjs");
36
- var import_react = __toESM(require("react"));
37
- var import_echo_schema = require("@dxos/echo-schema");
38
- var SurfacePlugin = () => {
39
- const state = (0, import_echo_schema.create)({
40
- components: {},
41
- debugInfo: /* @__PURE__ */ new Map()
42
- });
43
- return {
44
- meta: import_chunk_PJGE52CN.meta_default,
45
- ready: async (plugins) => {
46
- state.components = (0, import_chunk_62W6CMGM.filterPlugins)(plugins, import_chunk_PJGE52CN.parseSurfacePlugin).reduce((acc, plugin) => {
47
- return {
48
- ...acc,
49
- [plugin.meta.id]: plugin.provides.surface.component
50
- };
51
- }, {});
52
- },
53
- provides: {
54
- surface: state,
55
- context: ({ children }) => /* @__PURE__ */ import_react.default.createElement(import_chunk_PJGE52CN.SurfaceProvider, {
56
- value: state
57
- }, children)
58
- }
59
- };
60
- };
61
- var plugin_default = SurfacePlugin;
62
- //# sourceMappingURL=plugin-6TEDSCXW.cjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/plugin.tsx"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\n\nimport { SurfaceProvider, type SurfaceRootContext } from './SurfaceRootContext';\nimport SurfaceMeta from './meta';\nimport { parseSurfacePlugin, type SurfacePluginProvides } from './provides';\nimport { type PluginDefinition } from '../PluginHost';\nimport { filterPlugins } from '../helpers';\n\n/**\n * Provides a registry of surface components.\n */\nconst SurfacePlugin = (): PluginDefinition<SurfacePluginProvides> => {\n const state = create<SurfaceRootContext>({ components: {}, debugInfo: new Map() });\n\n return {\n meta: SurfaceMeta,\n ready: async (plugins) => {\n state.components = filterPlugins(plugins, parseSurfacePlugin).reduce((acc, plugin) => {\n return { ...acc, [plugin.meta.id]: plugin.provides.surface.component };\n }, {});\n },\n provides: {\n surface: state,\n context: ({ children }) => <SurfaceProvider value={state}>{children}</SurfaceProvider>,\n },\n };\n};\n\nexport default SurfacePlugin;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAElB,yBAAuB;AAWvB,IAAMA,gBAAgB,MAAA;AACpB,QAAMC,YAAQC,2BAA2B;IAAEC,YAAY,CAAC;IAAGC,WAAW,oBAAIC,IAAAA;EAAM,CAAA;AAEhF,SAAO;IACLC,MAAMC;IACNC,OAAO,OAAOC,YAAAA;AACZR,YAAME,iBAAaO,qCAAcD,SAASE,wCAAAA,EAAoBC,OAAO,CAACC,KAAKC,WAAAA;AACzE,eAAO;UAAE,GAAGD;UAAK,CAACC,OAAOR,KAAKS,EAAE,GAAGD,OAAOE,SAASC,QAAQC;QAAU;MACvE,GAAG,CAAC,CAAA;IACN;IACAF,UAAU;MACRC,SAAShB;MACTkB,SAAS,CAAC,EAAEC,SAAQ,MAAO,6BAAAC,QAAA,cAACC,uCAAAA;QAAgBC,OAAOtB;SAAQmB,QAAAA;IAC7D;EACF;AACF;AAEA,IAAA,iBAAepB;",
6
- "names": ["SurfacePlugin", "state", "create", "components", "debugInfo", "Map", "meta", "SurfaceMeta", "ready", "plugins", "filterPlugins", "parseSurfacePlugin", "reduce", "acc", "plugin", "id", "provides", "surface", "component", "context", "children", "React", "SurfaceProvider", "value"]
7
- }
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/IntentPlugin/plugin.tsx", "../../../src/plugins/IntentPlugin/helpers.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { create } from '@dxos/echo-schema';\nimport { log } from '@dxos/log';\n\nimport { type IntentContext, IntentProvider, type IntentExecution } from './IntentContext';\nimport { isUndoable } from './helpers';\nimport type { Intent, IntentResolver } from './intent';\nimport IntentMeta from './meta';\nimport {\n type IntentPluginProvides,\n type IntentResolverProvides,\n parseIntentResolverPlugin,\n IntentAction,\n} from './provides';\nimport type { PluginDefinition } from '../PluginHost';\nimport { filterPlugins, findPlugin } from '../helpers';\n\nconst EXECUTION_LIMIT = 1000;\nconst HISTORY_LIMIT = 100;\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 */\nconst IntentPlugin = (): PluginDefinition<IntentPluginProvides> => {\n const state = create<IntentContext>({\n dispatch: async () => ({}),\n undo: async () => ({}),\n history: [],\n registerResolver: () => () => {},\n });\n\n const dynamicResolvers = new Set<{ plugin: string; resolver: IntentResolver }>();\n\n return {\n meta: IntentMeta,\n ready: async (plugins) => {\n // Dispatch intent to associated plugin.\n const dispatch = async (intent: Intent) => {\n log('dispatch', { action: intent.action, intent });\n if (intent.plugin) {\n for (const entry of dynamicResolvers) {\n if (entry.plugin === intent.plugin) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n }\n\n const plugin = findPlugin<IntentResolverProvides>(plugins, intent.plugin);\n const result = plugin?.provides.intent.resolver(intent, plugins);\n return result;\n }\n\n for (const entry of dynamicResolvers) {\n const result = await entry.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // Return resolved value from first plugin that handles the intent.\n for (const plugin of filterPlugins(plugins, parseIntentResolverPlugin)) {\n const result = await plugin.provides.intent.resolver(intent, plugins);\n if (result) {\n return result;\n }\n }\n\n // https://vitejs.dev/guide/env-and-mode#env-variables\n // TODO(wittjosiah): How to handle this more generically?\n if (import.meta?.env?.DEV) {\n log.warn('No plugin found to handle intent', intent);\n }\n };\n\n // Sequentially dispatch array of invents.\n const dispatchChain = async (intentOrArray: Intent | Intent[], depth = 0) => {\n if (depth > EXECUTION_LIMIT) {\n return {\n error: new Error(\n `Intent execution limit exceeded (${EXECUTION_LIMIT} iterations). This is likely due to an infinite loop within intent resolvers.`,\n ),\n };\n }\n\n const executionResults: IntentExecution[] = [];\n const chain = Array.isArray(intentOrArray) ? intentOrArray : [intentOrArray];\n for (const intent of chain) {\n const { result: prevResult } = executionResults.at(-1) ?? {};\n const data = intent.data ? { result: prevResult?.data, ...intent.data } : prevResult?.data;\n const result = await dispatch({ ...intent, data });\n\n if (!result || result?.error) {\n break;\n }\n\n executionResults.push({ intent, result });\n\n // TODO(wittjosiah): How does undo work with returned intents?\n result?.intents?.forEach((intents) => {\n void dispatchChain(intents, depth + 1);\n });\n }\n\n state.history.push(executionResults);\n if (state.history.length > HISTORY_LIMIT) {\n state.history.splice(0, state.history.length - HISTORY_LIMIT);\n }\n\n if (isUndoable(executionResults)) {\n void dispatch({ action: IntentAction.SHOW_UNDO, data: { results: executionResults } });\n }\n\n return executionResults.at(-1)?.result;\n };\n\n const undo = async () => {\n const last = state.history.findLastIndex(isUndoable);\n const chain =\n last !== -1 &&\n state.history[last]?.map(({ intent, result }): Intent => {\n const data = result.undoable?.data ? { ...intent.data, ...result.undoable.data } : intent.data;\n return { ...intent, data, undo: true };\n });\n if (chain) {\n const result = await dispatchChain(chain);\n state.history = state.history.filter((_, index) => index !== last);\n return result;\n }\n };\n\n state.dispatch = dispatchChain;\n state.undo = undo;\n state.registerResolver = (plugin, resolver) => {\n const entry = { plugin, resolver };\n dynamicResolvers.add(entry);\n return () => dynamicResolvers.delete(entry);\n };\n },\n provides: {\n intent: state,\n context: ({ children }) => <IntentProvider value={state}>{children}</IntentProvider>,\n },\n };\n};\n\nexport default IntentPlugin;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type IntentExecution } from './IntentContext';\n\n/**\n * Check if the chain of intents is undoable.\n */\nexport const isUndoable = (chain: IntentExecution[]): boolean =>\n chain.length > 0 && chain.every(({ result }) => result.undoable);\n"],
5
- "mappings": "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",
6
- "names": ["isUndoable", "chain", "length", "every", "result", "undoable", "EXECUTION_LIMIT", "HISTORY_LIMIT", "IntentPlugin", "state", "create", "dispatch", "undo", "history", "registerResolver", "dynamicResolvers", "Set", "meta", "IntentMeta", "ready", "plugins", "intent", "log", "action", "plugin", "entry", "resolver", "findPlugin", "provides", "filterPlugins", "parseIntentResolverPlugin", "env", "DEV", "warn", "dispatchChain", "intentOrArray", "depth", "error", "Error", "executionResults", "Array", "isArray", "prevResult", "at", "data", "push", "intents", "forEach", "splice", "IntentAction", "SHOW_UNDO", "results", "last", "findLastIndex", "map", "filter", "_", "index", "add", "delete", "context", "children", "React", "IntentProvider", "value"]
7
- }
@@ -1,22 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/sdk/app-framework/src/plugins/helpers.ts
4
- import { raise } from "@dxos/debug";
5
- var definePlugin = (plugin) => plugin;
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
-
15
- export {
16
- definePlugin,
17
- findPlugin,
18
- getPlugin,
19
- filterPlugins,
20
- resolvePlugin
21
- };
22
- //# sourceMappingURL=chunk-IY7HCP4K.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 { raise } from '@dxos/debug';\n\nimport { type Plugin } from './PluginHost';\n\n/**\n * Define a plugin\n */\nexport const definePlugin = <TProvides>(plugin: Plugin<TProvides>): Plugin<TProvides> => plugin;\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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T>[] => 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>(\n plugins: Plugin[],\n predicate: (plugin: Plugin) => Plugin<T> | undefined,\n): Plugin<T> | undefined => filterPlugins(plugins, predicate)[0];\n"],
5
- "mappings": ";;;AAIA,SAASA,aAAa;AAOf,IAAMC,eAAe,CAAYC,WAAiDA;AAKlF,IAAMC,aAAa,CAAIC,SAAmBC,OAAAA;AAC/C,SAAOD,QAAQE,KACb,CAACJ,WAAWA,OAAOK,KAAKF,OAAOA,MAAO,OAAOH,OAAOK,KAAKC,YAAY,YAAYN,OAAOK,KAAKC,YAAYH,EAAAA;AAE7G;AAKO,IAAMI,YAAY,CAAIL,SAAmBC,OAAAA;AAC9C,SAAOF,WAAWC,SAASC,EAAAA,KAAOK,MAAM,IAAIC,MAAM,qBAAqBN,EAAAA,EAAI,CAAA;AAC7E;AAKO,IAAMO,gBAAgB,CAC3BR,SACAS,cACgBT,QAAQU,IAAI,CAACZ,WAAWW,UAAUX,MAAAA,CAAAA,EAASa,OAAO,CAACb,WAAgC,CAAC,CAACA,MAAAA;AAShG,IAAMc,gBAAgB,CAC3BZ,SACAS,cAC0BD,cAAcR,SAASS,SAAAA,EAAW,CAAA;",
6
- "names": ["raise", "definePlugin", "plugin", "findPlugin", "plugins", "id", "find", "meta", "shortId", "getPlugin", "raise", "Error", "filterPlugins", "predicate", "map", "filter", "resolvePlugin"]
7
- }
@@ -1,27 +0,0 @@
1
- import { createRequire } from 'node:module';const require = createRequire(import.meta.url);
2
-
3
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/provides.ts
4
- var parseRootSurfacePlugin = (plugin) => plugin?.provides?.surface?.components ? plugin : void 0;
5
- var parseSurfacePlugin = (plugin) => plugin?.provides?.surface?.component ? plugin : void 0;
6
-
7
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/SurfaceRootContext.tsx
8
- import { createContext, useContext } from "react";
9
- import { raise } from "@dxos/debug";
10
- var SurfaceRootContext = /* @__PURE__ */ createContext(void 0);
11
- var useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error("Missing SurfaceRootContext"));
12
- var SurfaceProvider = SurfaceRootContext.Provider;
13
-
14
- // packages/sdk/app-framework/src/plugins/SurfacePlugin/meta.ts
15
- var SurfaceMeta = {
16
- id: "dxos.org/plugin/surface"
17
- };
18
- var meta_default = SurfaceMeta;
19
-
20
- export {
21
- parseRootSurfacePlugin,
22
- parseSurfacePlugin,
23
- useSurfaceRoot,
24
- SurfaceProvider,
25
- meta_default
26
- };
27
- //# sourceMappingURL=chunk-MBHRXQTR.mjs.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/plugins/SurfacePlugin/provides.ts", "../../../src/plugins/SurfacePlugin/SurfaceRootContext.tsx", "../../../src/plugins/SurfacePlugin/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type SurfaceComponent, type SurfaceRootContext } from './SurfaceRootContext';\nimport { type Plugin } from '../PluginHost';\n\nexport type SurfaceProvides = {\n surface: {\n /**\n * Used by the `Surface` resolver to find a component to render.\n */\n component: SurfaceComponent;\n };\n};\n\nexport type SurfacePluginProvides = {\n surface: SurfaceRootContext;\n};\n\nexport const parseRootSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.components ? (plugin as Plugin<SurfacePluginProvides>) : undefined;\n\nexport const parseSurfacePlugin = (plugin?: Plugin) =>\n (plugin?.provides as any)?.surface?.component ? (plugin as Plugin<SurfaceProvides>) : undefined;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nimport { createContext, useContext, type JSX, type ForwardedRef } from 'react';\n\nimport { raise } from '@dxos/debug';\n\nimport { type SurfaceProps } from './Surface';\n\n// TODO(wittjosiah): Factor out.\ntype WithRequiredProperty<Type, Key extends keyof Type> = Type & {\n [Property in Key]-?: Type[Property];\n};\n\ntype SurfaceComponentProps = WithRequiredProperty<SurfaceProps, 'data'>;\n\n/**\n * Determines the priority of the surface when multiple components are resolved.\n */\nexport type SurfaceDisposition = 'hoist' | 'fallback';\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' | 'name'>;\n\nexport type SurfaceResult = {\n node: JSX.Element;\n disposition?: SurfaceDisposition;\n};\n\n/**\n * Function which resolves a Surface.\n *\n * If a null value is returned, the rendering is deferred to other plugins.\n */\nexport type SurfaceComponent = (\n props: SurfaceComponentProps,\n forwardedRef: ForwardedRef<HTMLElement>,\n) => JSX.Element | SurfaceResult | null;\n\nexport type SurfaceRootContext = {\n components: Record<string, SurfaceComponent>;\n\n /**\n * Debug info.\n */\n debugInfo?: Map<string, DebugInfo>;\n};\n\nconst SurfaceRootContext = createContext<SurfaceRootContext | undefined>(undefined);\n\nexport const useSurfaceRoot = () => useContext(SurfaceRootContext) ?? raise(new Error('Missing SurfaceRootContext'));\n\nexport const SurfaceProvider = SurfaceRootContext.Provider;\n", "//\n// Copyright 2023 DXOS.org\n//\n\nconst SurfaceMeta = {\n id: 'dxos.org/plugin/surface',\n};\n\nexport default SurfaceMeta;\n"],
5
- "mappings": ";;;AAoBO,IAAMA,yBAAyB,CAACC,WACpCA,QAAQC,UAAkBC,SAASC,aAAcH,SAA2CI;AAExF,IAAMC,qBAAqB,CAACL,WAChCA,QAAQC,UAAkBC,SAASI,YAAaN,SAAqCI;;;ACpBxF,SAASG,eAAeC,kBAA+C;AAEvE,SAASC,aAAa;AAkDtB,IAAMC,qBAAqBC,8BAA8CC,MAAAA;AAElE,IAAMC,iBAAiB,MAAMC,WAAWJ,kBAAAA,KAAuBK,MAAM,IAAIC,MAAM,4BAAA,CAAA;AAE/E,IAAMC,kBAAkBP,mBAAmBQ;;;ACxDlD,IAAMC,cAAc;EAClBC,IAAI;AACN;AAEA,IAAA,eAAeD;",
6
- "names": ["parseRootSurfacePlugin", "plugin", "provides", "surface", "components", "undefined", "parseSurfacePlugin", "component", "createContext", "useContext", "raise", "SurfaceRootContext", "createContext", "undefined", "useSurfaceRoot", "useContext", "raise", "Error", "SurfaceProvider", "Provider", "SurfaceMeta", "id"]
7
- }