@dxos/plugin-sheet 0.6.12-main.f9d0246 → 0.6.12-staging.0b4bb48

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 (263) hide show
  1. package/dist/lib/browser/{chunk-ZLJ2GRE2.mjs → SheetContainer-U4H5D34A.mjs} +240 -1151
  2. package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
  4. package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-Z2XOOC2R.mjs → chunk-D5AGLXJP.mjs} +678 -385
  6. package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
  7. package/dist/lib/browser/{chunk-WZMOZKQZ.mjs → chunk-FUAGSXA4.mjs} +16 -9
  8. package/dist/lib/browser/chunk-FUAGSXA4.mjs.map +7 -0
  9. package/dist/lib/{node-esm/chunk-IU2L277A.mjs → browser/chunk-JRL5LGCE.mjs} +5 -4
  10. package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
  12. package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
  13. package/dist/lib/browser/index.mjs +60 -74
  14. package/dist/lib/browser/index.mjs.map +3 -3
  15. package/dist/lib/browser/meta.json +1 -1
  16. package/dist/lib/browser/meta.mjs +1 -1
  17. package/dist/lib/browser/testing.mjs +92 -0
  18. package/dist/lib/browser/testing.mjs.map +7 -0
  19. package/dist/lib/browser/types.mjs +6 -4
  20. package/dist/lib/node/{chunk-6DQABRGJ.cjs → SheetContainer-AXQV3ZT5.cjs} +279 -1182
  21. package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
  22. package/dist/lib/node/{chunk-P5QYYEHQ.cjs → chunk-5KKJ4NPP.cjs} +676 -388
  23. package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
  24. package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-BJ6ZD7MN.cjs} +18 -5
  25. package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +7 -0
  26. package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
  27. package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
  28. package/dist/lib/node/{chunk-AOP42UAA.cjs → chunk-DSYKOI4E.cjs} +21 -13
  29. package/dist/lib/node/chunk-DSYKOI4E.cjs.map +7 -0
  30. package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
  31. package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
  32. package/dist/lib/node/index.cjs +66 -86
  33. package/dist/lib/node/index.cjs.map +3 -3
  34. package/dist/lib/node/meta.cjs +3 -3
  35. package/dist/lib/node/meta.cjs.map +1 -1
  36. package/dist/lib/node/meta.json +1 -1
  37. package/dist/lib/node/testing.cjs +111 -0
  38. package/dist/lib/node/testing.cjs.map +7 -0
  39. package/dist/lib/node/types.cjs +12 -10
  40. package/dist/lib/node/types.cjs.map +2 -2
  41. package/dist/types/src/SheetPlugin.d.ts.map +1 -1
  42. package/dist/types/src/components/CellEditor/CellEditor.d.ts +3 -23
  43. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
  44. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
  45. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
  46. package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
  47. package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
  48. package/dist/types/src/{graph → components/ComputeGraph}/async-function.d.ts +2 -8
  49. package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +1 -0
  50. package/dist/types/src/{graph/testing/custom-function.d.ts → components/ComputeGraph/custom.d.ts} +2 -4
  51. package/dist/types/src/components/ComputeGraph/custom.d.ts.map +1 -0
  52. package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -0
  53. package/dist/types/src/components/ComputeGraph/graph-context.d.ts +12 -0
  54. package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -0
  55. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +2 -0
  56. package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +1 -0
  57. package/dist/types/src/components/ComputeGraph/graph.d.ts +26 -0
  58. package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -0
  59. package/dist/types/src/components/ComputeGraph/index.d.ts +3 -1
  60. package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
  61. package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
  62. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
  63. package/dist/types/src/components/Sheet/Sheet.stories.d.ts +6 -5
  64. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
  65. package/dist/types/src/components/Sheet/formatting.d.ts +14 -0
  66. package/dist/types/src/components/Sheet/formatting.d.ts.map +1 -0
  67. package/dist/types/src/components/Sheet/grid.d.ts +2 -2
  68. package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
  69. package/dist/types/src/components/Sheet/nav.d.ts +3 -3
  70. package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
  71. package/dist/types/src/components/Sheet/sheet-context.d.ts +7 -8
  72. package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
  73. package/dist/types/src/components/SheetContainer.d.ts +3 -2
  74. package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
  75. package/dist/types/src/components/Toolbar/Toolbar.d.ts +3 -19
  76. package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
  77. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +13 -18
  78. package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
  79. package/dist/types/src/components/index.d.ts +2 -2
  80. package/dist/types/src/components/index.d.ts.map +1 -1
  81. package/dist/types/src/meta.d.ts +4 -1
  82. package/dist/types/src/meta.d.ts.map +1 -1
  83. package/dist/types/src/{graph/function-defs.d.ts → model/functions.d.ts} +1 -1
  84. package/dist/types/src/model/functions.d.ts.map +1 -0
  85. package/dist/types/src/model/index.d.ts +3 -2
  86. package/dist/types/src/model/index.d.ts.map +1 -1
  87. package/dist/types/src/model/model.browser.test.d.ts +2 -0
  88. package/dist/types/src/model/model.browser.test.d.ts.map +1 -0
  89. package/dist/types/src/model/{sheet-model.d.ts → model.d.ts} +65 -10
  90. package/dist/types/src/model/model.d.ts.map +1 -0
  91. package/dist/types/src/{defs → model}/types.d.ts +3 -8
  92. package/dist/types/src/model/types.d.ts.map +1 -0
  93. package/dist/types/src/model/types.test.d.ts.map +1 -0
  94. package/dist/types/src/model/util.d.ts +15 -0
  95. package/dist/types/src/model/util.d.ts.map +1 -0
  96. package/dist/types/src/testing.d.ts +9 -0
  97. package/dist/types/src/testing.d.ts.map +1 -0
  98. package/dist/types/src/translations.d.ts +12 -17
  99. package/dist/types/src/translations.d.ts.map +1 -1
  100. package/dist/types/src/types.d.ts +5 -86
  101. package/dist/types/src/types.d.ts.map +1 -1
  102. package/package.json +41 -48
  103. package/src/SheetPlugin.tsx +73 -48
  104. package/src/components/CellEditor/CellEditor.stories.tsx +4 -5
  105. package/src/components/CellEditor/CellEditor.tsx +9 -59
  106. package/src/components/CellEditor/extension.test.ts +5 -4
  107. package/src/components/CellEditor/extension.ts +3 -1
  108. package/src/{graph → components/ComputeGraph}/async-function.ts +6 -15
  109. package/src/{graph/testing/custom-function.ts → components/ComputeGraph/custom.ts} +7 -11
  110. package/src/{graph → components/ComputeGraph}/edge-function.ts +3 -3
  111. package/src/components/ComputeGraph/graph-context.tsx +50 -0
  112. package/src/components/ComputeGraph/graph.browser.test.ts +50 -0
  113. package/src/components/ComputeGraph/graph.ts +62 -0
  114. package/src/components/ComputeGraph/index.ts +3 -1
  115. package/src/components/Sheet/Sheet.stories.tsx +88 -52
  116. package/src/components/Sheet/Sheet.tsx +18 -57
  117. package/src/{model/formatting-model.ts → components/Sheet/formatting.ts} +13 -20
  118. package/src/components/Sheet/grid.ts +3 -3
  119. package/src/components/Sheet/nav.ts +19 -19
  120. package/src/components/Sheet/sheet-context.tsx +80 -18
  121. package/src/components/SheetContainer.tsx +19 -73
  122. package/src/components/Toolbar/Toolbar.tsx +12 -53
  123. package/src/components/index.ts +0 -1
  124. package/src/meta.tsx +5 -1
  125. package/src/model/index.ts +3 -2
  126. package/src/model/model.browser.test.ts +100 -0
  127. package/src/model/model.ts +550 -0
  128. package/src/{defs → model}/types.test.ts +9 -8
  129. package/src/{defs → model}/types.ts +14 -24
  130. package/src/model/util.ts +36 -0
  131. package/src/testing.ts +50 -0
  132. package/src/translations.ts +1 -6
  133. package/src/types.ts +6 -31
  134. package/dist/lib/browser/SheetContainer-VISF3VUB.mjs +0 -261
  135. package/dist/lib/browser/SheetContainer-VISF3VUB.mjs.map +0 -7
  136. package/dist/lib/browser/chunk-QILRZNE5.mjs +0 -15
  137. package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
  138. package/dist/lib/browser/chunk-WZMOZKQZ.mjs.map +0 -7
  139. package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +0 -7
  140. package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +0 -7
  141. package/dist/lib/browser/graph-4XFKIHRL.mjs +0 -21
  142. package/dist/lib/browser/graph-4XFKIHRL.mjs.map +0 -7
  143. package/dist/lib/node/SheetContainer-2MEALQWW.cjs +0 -279
  144. package/dist/lib/node/SheetContainer-2MEALQWW.cjs.map +0 -7
  145. package/dist/lib/node/chunk-6DQABRGJ.cjs.map +0 -7
  146. package/dist/lib/node/chunk-AOP42UAA.cjs.map +0 -7
  147. package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
  148. package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +0 -7
  149. package/dist/lib/node/graph-2LRDUXBZ.cjs +0 -43
  150. package/dist/lib/node/graph-2LRDUXBZ.cjs.map +0 -7
  151. package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs +0 -262
  152. package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs.map +0 -7
  153. package/dist/lib/node-esm/chunk-4MM7THJW.mjs +0 -2944
  154. package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +0 -7
  155. package/dist/lib/node-esm/chunk-5RLTCIE2.mjs +0 -2684
  156. package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +0 -7
  157. package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
  158. package/dist/lib/node-esm/chunk-RR2AO4SM.mjs +0 -76
  159. package/dist/lib/node-esm/chunk-RR2AO4SM.mjs.map +0 -7
  160. package/dist/lib/node-esm/graph-WG5EKOMO.mjs +0 -22
  161. package/dist/lib/node-esm/graph-WG5EKOMO.mjs.map +0 -7
  162. package/dist/lib/node-esm/index.mjs +0 -263
  163. package/dist/lib/node-esm/index.mjs.map +0 -7
  164. package/dist/lib/node-esm/meta.json +0 -1
  165. package/dist/lib/node-esm/meta.mjs +0 -10
  166. package/dist/lib/node-esm/meta.mjs.map +0 -7
  167. package/dist/lib/node-esm/types.mjs +0 -21
  168. package/dist/lib/node-esm/types.mjs.map +0 -7
  169. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +0 -11
  170. package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +0 -1
  171. package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -10
  172. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
  173. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +0 -9
  174. package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
  175. package/dist/types/src/components/GridSheet/util.d.ts +0 -7
  176. package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
  177. package/dist/types/src/components/Sheet/decorations.d.ts +0 -24
  178. package/dist/types/src/components/Sheet/decorations.d.ts.map +0 -1
  179. package/dist/types/src/components/Sheet/threads.d.ts +0 -2
  180. package/dist/types/src/components/Sheet/threads.d.ts.map +0 -1
  181. package/dist/types/src/defs/index.d.ts +0 -3
  182. package/dist/types/src/defs/index.d.ts.map +0 -1
  183. package/dist/types/src/defs/types.d.ts.map +0 -1
  184. package/dist/types/src/defs/types.test.d.ts.map +0 -1
  185. package/dist/types/src/defs/util.d.ts +0 -43
  186. package/dist/types/src/defs/util.d.ts.map +0 -1
  187. package/dist/types/src/extensions/compute.d.ts +0 -9
  188. package/dist/types/src/extensions/compute.d.ts.map +0 -1
  189. package/dist/types/src/extensions/compute.stories.d.ts +0 -26
  190. package/dist/types/src/extensions/compute.stories.d.ts.map +0 -1
  191. package/dist/types/src/extensions/index.d.ts +0 -2
  192. package/dist/types/src/extensions/index.d.ts.map +0 -1
  193. package/dist/types/src/graph/async-function.d.ts.map +0 -1
  194. package/dist/types/src/graph/compute-graph.d.ts +0 -84
  195. package/dist/types/src/graph/compute-graph.d.ts.map +0 -1
  196. package/dist/types/src/graph/compute-graph.stories.d.ts +0 -10
  197. package/dist/types/src/graph/compute-graph.stories.d.ts.map +0 -1
  198. package/dist/types/src/graph/compute-graph.test.d.ts +0 -2
  199. package/dist/types/src/graph/compute-graph.test.d.ts.map +0 -1
  200. package/dist/types/src/graph/compute-node.d.ts +0 -26
  201. package/dist/types/src/graph/compute-node.d.ts.map +0 -1
  202. package/dist/types/src/graph/edge-function.d.ts.map +0 -1
  203. package/dist/types/src/graph/function-defs.d.ts.map +0 -1
  204. package/dist/types/src/graph/hyperformula.test.d.ts +0 -2
  205. package/dist/types/src/graph/hyperformula.test.d.ts.map +0 -1
  206. package/dist/types/src/graph/index.d.ts +0 -4
  207. package/dist/types/src/graph/index.d.ts.map +0 -1
  208. package/dist/types/src/graph/testing/custom-function.d.ts.map +0 -1
  209. package/dist/types/src/graph/testing/index.d.ts +0 -2
  210. package/dist/types/src/graph/testing/index.d.ts.map +0 -1
  211. package/dist/types/src/graph/util.d.ts +0 -2
  212. package/dist/types/src/graph/util.d.ts.map +0 -1
  213. package/dist/types/src/hooks/hooks.stories.d.ts +0 -11
  214. package/dist/types/src/hooks/hooks.stories.d.ts.map +0 -1
  215. package/dist/types/src/hooks/index.d.ts +0 -4
  216. package/dist/types/src/hooks/index.d.ts.map +0 -1
  217. package/dist/types/src/hooks/useComputeGraph.d.ts +0 -7
  218. package/dist/types/src/hooks/useComputeGraph.d.ts.map +0 -1
  219. package/dist/types/src/hooks/useFormattingModel.d.ts +0 -3
  220. package/dist/types/src/hooks/useFormattingModel.d.ts.map +0 -1
  221. package/dist/types/src/hooks/useSheetModel.d.ts +0 -8
  222. package/dist/types/src/hooks/useSheetModel.d.ts.map +0 -1
  223. package/dist/types/src/model/formatting-model.d.ts +0 -16
  224. package/dist/types/src/model/formatting-model.d.ts.map +0 -1
  225. package/dist/types/src/model/sheet-model.d.ts.map +0 -1
  226. package/dist/types/src/sanity.test.d.ts +0 -2
  227. package/dist/types/src/sanity.test.d.ts.map +0 -1
  228. package/dist/types/src/testing/index.d.ts +0 -2
  229. package/dist/types/src/testing/index.d.ts.map +0 -1
  230. package/dist/types/src/testing/testing.d.ts +0 -8
  231. package/dist/types/src/testing/testing.d.ts.map +0 -1
  232. package/dist/vendor/hyperformula.mjs +0 -37145
  233. package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +0 -20
  234. package/src/components/GridSheet/GridSheet.stories.tsx +0 -36
  235. package/src/components/GridSheet/GridSheet.tsx +0 -153
  236. package/src/components/GridSheet/util.ts +0 -108
  237. package/src/components/Sheet/decorations.ts +0 -62
  238. package/src/components/Sheet/threads.tsx +0 -205
  239. package/src/defs/index.ts +0 -6
  240. package/src/defs/util.ts +0 -151
  241. package/src/extensions/compute.stories.tsx +0 -153
  242. package/src/extensions/compute.ts +0 -131
  243. package/src/extensions/index.ts +0 -5
  244. package/src/graph/compute-graph.stories.tsx +0 -93
  245. package/src/graph/compute-graph.test.ts +0 -127
  246. package/src/graph/compute-graph.ts +0 -313
  247. package/src/graph/compute-node.ts +0 -62
  248. package/src/graph/hyperformula.test.ts +0 -15
  249. package/src/graph/index.ts +0 -7
  250. package/src/graph/testing/index.ts +0 -5
  251. package/src/graph/util.ts +0 -8
  252. package/src/hooks/hooks.stories.tsx +0 -50
  253. package/src/hooks/index.ts +0 -7
  254. package/src/hooks/useComputeGraph.ts +0 -21
  255. package/src/hooks/useFormattingModel.ts +0 -11
  256. package/src/hooks/useSheetModel.ts +0 -40
  257. package/src/model/sheet-model.ts +0 -414
  258. package/src/sanity.test.ts +0 -40
  259. package/src/testing/index.ts +0 -5
  260. package/src/testing/testing.tsx +0 -68
  261. /package/dist/types/src/{graph → components/ComputeGraph}/edge-function.d.ts +0 -0
  262. /package/dist/types/src/{defs → model}/types.test.d.ts +0 -0
  263. /package/src/{graph/function-defs.ts → model/functions.ts} +0 -0
@@ -0,0 +1,202 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_CN3RPESU_exports = {};
30
+ __export(chunk_CN3RPESU_exports, {
31
+ ComputeGraphContextProvider: () => ComputeGraphContextProvider,
32
+ EdgeFunctionPlugin: () => EdgeFunctionPlugin,
33
+ EdgeFunctionPluginTranslations: () => EdgeFunctionPluginTranslations,
34
+ useComputeGraph: () => useComputeGraph
35
+ });
36
+ module.exports = __toCommonJS(chunk_CN3RPESU_exports);
37
+ var import_chunk_5KKJ4NPP = require("./chunk-5KKJ4NPP.cjs");
38
+ var import_signals_core = require("@preact/signals-core");
39
+ var import_hyperformula = require("hyperformula");
40
+ var import_echo = require("@dxos/client/echo");
41
+ var import_log = require("@dxos/log");
42
+ var import_edge = require("@dxos/plugin-script/edge");
43
+ var import_types = require("@dxos/plugin-script/types");
44
+ var import_util = require("@dxos/util");
45
+ var import_react = __toESM(require("react"));
46
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/ComputeGraph/edge-function.ts";
47
+ var EDGE_FUNCTION_TTL = 1e4;
48
+ var EdgeFunctionPlugin = class extends import_chunk_5KKJ4NPP.FunctionPluginAsync {
49
+ edge(ast, state) {
50
+ const handler = (subscribe = false) => async (binding, ...args) => {
51
+ const space = this.context.space;
52
+ if (!space) {
53
+ return new import_hyperformula.CellError(import_hyperformula.ErrorType.REF, "Missing space");
54
+ }
55
+ const { objects: [fn] } = await space.db.query(import_echo.Filter.schema(import_types.FunctionType, {
56
+ binding
57
+ })).run();
58
+ if (!fn) {
59
+ import_log.log.info("Function not found", {
60
+ binding
61
+ }, {
62
+ F: __dxlog_file,
63
+ L: 39,
64
+ S: this,
65
+ C: (f, a) => f(...a)
66
+ });
67
+ return new import_hyperformula.CellError(import_hyperformula.ErrorType.REF, "Function not found");
68
+ }
69
+ if (subscribe) {
70
+ const unsubscribe = (0, import_signals_core.effect)(() => {
71
+ import_log.log.info("function changed", {
72
+ fn
73
+ }, {
74
+ F: __dxlog_file,
75
+ L: 45,
76
+ S: this,
77
+ C: (f, a) => f(...a)
78
+ });
79
+ const _ = fn?.version;
80
+ this.runAsyncFunction(ast, state, handler(false), {
81
+ ttl: EDGE_FUNCTION_TTL
82
+ });
83
+ });
84
+ this.context.createSubscription(ast.procedureName, unsubscribe);
85
+ }
86
+ const path = (0, import_edge.getUserFunctionUrlInMetadata)((0, import_echo.getMeta)(fn));
87
+ const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
88
+ method: "POST",
89
+ headers: {
90
+ "Content-Type": "application/json"
91
+ },
92
+ body: JSON.stringify({
93
+ args: args.filter(import_util.nonNullable)
94
+ })
95
+ });
96
+ return await result.text();
97
+ };
98
+ return this.runAsyncFunction(ast, state, handler(true), {
99
+ ttl: EDGE_FUNCTION_TTL
100
+ });
101
+ }
102
+ };
103
+ EdgeFunctionPlugin.implementedFunctions = {
104
+ EDGE: {
105
+ method: "edge",
106
+ parameters: [
107
+ // Binding
108
+ {
109
+ argumentType: import_hyperformula.FunctionArgumentType.STRING
110
+ },
111
+ // Remote function arguments (currently supporting up to 9).
112
+ {
113
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
114
+ optionalArg: true
115
+ },
116
+ {
117
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
118
+ optionalArg: true
119
+ },
120
+ {
121
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
122
+ optionalArg: true
123
+ },
124
+ {
125
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
126
+ optionalArg: true
127
+ },
128
+ {
129
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
130
+ optionalArg: true
131
+ },
132
+ {
133
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
134
+ optionalArg: true
135
+ },
136
+ {
137
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
138
+ optionalArg: true
139
+ },
140
+ {
141
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
142
+ optionalArg: true
143
+ },
144
+ {
145
+ argumentType: import_hyperformula.FunctionArgumentType.ANY,
146
+ optionalArg: true
147
+ }
148
+ ],
149
+ isVolatile: true
150
+ }
151
+ };
152
+ var EdgeFunctionPluginTranslations = {
153
+ enGB: {
154
+ EDGE: "EDGE"
155
+ },
156
+ enUS: {
157
+ EDGE: "EDGE"
158
+ }
159
+ };
160
+ var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)({
161
+ graphs: {},
162
+ setGraph: () => {
163
+ }
164
+ });
165
+ var ComputeGraphContextProvider = ({ children, graphs, setGraph }) => {
166
+ return /* @__PURE__ */ import_react.default.createElement(ComputeGraphContext.Provider, {
167
+ value: {
168
+ graphs,
169
+ setGraph
170
+ }
171
+ }, children);
172
+ };
173
+ var useComputeGraph = (space, options) => {
174
+ const { graphs, setGraph } = (0, import_react.useContext)(ComputeGraphContext);
175
+ const graph = graphs[space.id] ?? (0, import_chunk_5KKJ4NPP.createComputeGraph)([
176
+ {
177
+ plugin: EdgeFunctionPlugin,
178
+ translations: EdgeFunctionPluginTranslations
179
+ },
180
+ // TODO(wittjosiah): Remove. Needed for current test sheet generated data.
181
+ {
182
+ plugin: import_chunk_5KKJ4NPP.CustomPlugin,
183
+ translations: import_chunk_5KKJ4NPP.CustomPluginTranslations
184
+ }
185
+ ], space, options);
186
+ (0, import_react.useEffect)(() => {
187
+ if (!graphs[space.id]) {
188
+ setGraph(space.id, graph);
189
+ }
190
+ }, [
191
+ space
192
+ ]);
193
+ return graph;
194
+ };
195
+ // Annotate the CommonJS export names for ESM import in node:
196
+ 0 && (module.exports = {
197
+ ComputeGraphContextProvider,
198
+ EdgeFunctionPlugin,
199
+ EdgeFunctionPluginTranslations,
200
+ useComputeGraph
201
+ });
202
+ //# sourceMappingURL=chunk-CN3RPESU.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/ComputeGraph/edge-function.ts", "../../../src/components/ComputeGraph/graph-context.tsx"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\nimport { effect } from '@preact/signals-core';\nimport { CellError, ErrorType, FunctionArgumentType } from 'hyperformula';\nimport { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';\nimport { type ProcedureAst } from 'hyperformula/typings/parser';\n\nimport { Filter, getMeta } from '@dxos/client/echo';\nimport { log } from '@dxos/log';\nimport { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';\nimport { FunctionType } from '@dxos/plugin-script/types';\nimport { nonNullable } from '@dxos/util';\n\nimport { type AsyncFunction, FunctionPluginAsync } from './async-function';\n\nconst EDGE_FUNCTION_TTL = 10_000;\n\n/**\n * A hyperformula function plugin for calling EDGE functions.\n *\n * https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function\n */\nexport class EdgeFunctionPlugin extends FunctionPluginAsync {\n edge(ast: ProcedureAst, state: InterpreterState) {\n const handler =\n (subscribe = false): AsyncFunction =>\n async (binding: string, ...args: any) => {\n const space = this.context.space;\n if (!space) {\n return new CellError(ErrorType.REF, 'Missing space');\n }\n\n const {\n objects: [fn],\n } = await space.db.query(Filter.schema(FunctionType, { binding })).run();\n if (!fn) {\n log.info('Function not found', { binding });\n return new CellError(ErrorType.REF, 'Function not found');\n }\n\n if (subscribe) {\n const unsubscribe = effect(() => {\n log.info('function changed', { fn });\n const _ = fn?.version;\n\n // TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.\n // This needs a ttl to prevent a binding change from causing the function not to be found.\n this.runAsyncFunction(ast, state, handler(false), { ttl: EDGE_FUNCTION_TTL });\n });\n\n this.context.createSubscription(ast.procedureName, unsubscribe);\n }\n\n const path = getUserFunctionUrlInMetadata(getMeta(fn));\n const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ args: args.filter(nonNullable) }),\n });\n return await result.text();\n };\n\n return this.runAsyncFunction(ast, state, handler(true), { ttl: EDGE_FUNCTION_TTL });\n }\n}\n\nEdgeFunctionPlugin.implementedFunctions = {\n EDGE: {\n method: 'edge',\n parameters: [\n // Binding\n { argumentType: FunctionArgumentType.STRING },\n\n // Remote function arguments (currently supporting up to 9).\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n { argumentType: FunctionArgumentType.ANY, optionalArg: true },\n ],\n isVolatile: true,\n },\n};\n\nexport const EdgeFunctionPluginTranslations = {\n enGB: {\n EDGE: 'EDGE',\n },\n enUS: {\n EDGE: 'EDGE',\n },\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React, { createContext, type PropsWithChildren, useContext, useEffect } from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\n\nimport { type FunctionContextOptions } from './async-function';\nimport { CustomPlugin, CustomPluginTranslations } from './custom';\nimport { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './edge-function';\nimport { createComputeGraph, type ComputeGraph } from './graph';\n\nexport type ComputeGraphContextType = {\n graphs: Record<string, ComputeGraph>;\n setGraph: (key: string, graph: ComputeGraph) => void;\n};\n\nexport const ComputeGraphContext = createContext<ComputeGraphContextType>({ graphs: {}, setGraph: () => {} });\n\nexport const ComputeGraphContextProvider = ({\n children,\n graphs,\n setGraph,\n}: PropsWithChildren<ComputeGraphContextType>) => {\n return <ComputeGraphContext.Provider value={{ graphs, setGraph }}>{children}</ComputeGraphContext.Provider>;\n};\n\nexport const useComputeGraph = (space: Space, options?: Partial<FunctionContextOptions>): ComputeGraph => {\n const { graphs, setGraph } = useContext(ComputeGraphContext);\n const graph =\n graphs[space.id] ??\n createComputeGraph(\n [\n { plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations },\n // TODO(wittjosiah): Remove. Needed for current test sheet generated data.\n { plugin: CustomPlugin, translations: CustomPluginTranslations },\n ],\n space,\n options,\n );\n\n useEffect(() => {\n if (!graphs[space.id]) {\n setGraph(space.id, graph);\n }\n }, [space]);\n\n return graph;\n};\n"],
5
+ "mappings": "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",
6
+ "names": ["EDGE_FUNCTION_TTL", "EdgeFunctionPlugin", "FunctionPluginAsync", "edge", "ast", "state", "handler", "subscribe", "binding", "args", "space", "context", "CellError", "ErrorType", "REF", "objects", "fn", "db", "query", "Filter", "schema", "FunctionType", "run", "log", "info", "unsubscribe", "effect", "_", "version", "runAsyncFunction", "ttl", "createSubscription", "procedureName", "path", "getUserFunctionUrlInMetadata", "getMeta", "result", "fetch", "remoteFunctionUrl", "method", "headers", "body", "JSON", "stringify", "filter", "nonNullable", "text", "implementedFunctions", "EDGE", "parameters", "argumentType", "FunctionArgumentType", "STRING", "ANY", "optionalArg", "isVolatile", "EdgeFunctionPluginTranslations", "enGB", "enUS", "ComputeGraphContext", "createContext", "graphs", "setGraph", "ComputeGraphContextProvider", "children", "React", "Provider", "value", "useComputeGraph", "options", "useContext", "graph", "id", "createComputeGraph", "plugin", "translations", "CustomPlugin", "CustomPluginTranslations", "useEffect"]
7
+ }
@@ -16,21 +16,21 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_AOP42UAA_exports = {};
20
- __export(chunk_AOP42UAA_exports, {
19
+ var chunk_DSYKOI4E_exports = {};
20
+ __export(chunk_DSYKOI4E_exports, {
21
21
  CellValue: () => CellValue,
22
22
  Formatting: () => Formatting,
23
23
  RowColumnMeta: () => RowColumnMeta,
24
24
  SheetAction: () => SheetAction,
25
25
  SheetType: () => SheetType,
26
26
  ValueType: () => ValueType,
27
- ValueTypeEnum: () => ValueTypeEnum
27
+ ValueTypeEnum: () => ValueTypeEnum,
28
+ createSheet: () => createSheet
28
29
  });
29
- module.exports = __toCommonJS(chunk_AOP42UAA_exports);
30
- var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
30
+ module.exports = __toCommonJS(chunk_DSYKOI4E_exports);
31
+ var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
31
32
  var import_echo_schema = require("@dxos/echo-schema");
32
- var import_types = require("@dxos/plugin-space/types");
33
- var SHEET_ACTION = `${import_chunk_BNARJ5GM.SHEET_PLUGIN}/action`;
33
+ var SHEET_ACTION = `${import_chunk_BJ6ZD7MN.SHEET_PLUGIN}/action`;
34
34
  var SheetAction;
35
35
  (function(SheetAction2) {
36
36
  SheetAction2[SheetAction2["CREATE"] = `${SHEET_ACTION}/create`] = "CREATE";
@@ -70,7 +70,7 @@ var SheetType = class extends (0, import_echo_schema.TypedObject)({
70
70
  typename: "dxos.org/type/SheetType",
71
71
  version: "0.1.0"
72
72
  })({
73
- name: import_echo_schema.S.optional(import_echo_schema.S.String),
73
+ title: import_echo_schema.S.optional(import_echo_schema.S.String),
74
74
  // Sparse map of cells referenced by index.
75
75
  cells: import_echo_schema.S.mutable(import_echo_schema.S.Record(import_echo_schema.S.String, import_echo_schema.S.mutable(CellValue))),
76
76
  // Ordered row indices.
@@ -82,11 +82,18 @@ var SheetType = class extends (0, import_echo_schema.TypedObject)({
82
82
  // Column metadata referenced by index.
83
83
  columnMeta: import_echo_schema.S.mutable(import_echo_schema.S.Record(import_echo_schema.S.String, import_echo_schema.S.mutable(RowColumnMeta))),
84
84
  // Cell formatting referenced by indexed range.
85
- formatting: import_echo_schema.S.mutable(import_echo_schema.S.Record(import_echo_schema.S.String, import_echo_schema.S.mutable(Formatting))),
86
- // Threads associated with the sheet
87
- threads: import_echo_schema.S.optional(import_echo_schema.S.mutable(import_echo_schema.S.Array((0, import_echo_schema.ref)(import_types.ThreadType))))
85
+ formatting: import_echo_schema.S.mutable(import_echo_schema.S.Record(import_echo_schema.S.String, import_echo_schema.S.mutable(Formatting)))
88
86
  }) {
89
87
  };
88
+ var createSheet = (title) => (0, import_echo_schema.create)(SheetType, {
89
+ title,
90
+ cells: {},
91
+ rows: [],
92
+ columns: [],
93
+ rowMeta: {},
94
+ columnMeta: {},
95
+ formatting: {}
96
+ });
90
97
  // Annotate the CommonJS export names for ESM import in node:
91
98
  0 && (module.exports = {
92
99
  CellValue,
@@ -95,6 +102,7 @@ var SheetType = class extends (0, import_echo_schema.TypedObject)({
95
102
  SheetAction,
96
103
  SheetType,
97
104
  ValueType,
98
- ValueTypeEnum
105
+ ValueTypeEnum,
106
+ createSheet
99
107
  });
100
- //# sourceMappingURL=chunk-AOP42UAA.cjs.map
108
+ //# sourceMappingURL=chunk-DSYKOI4E.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n GraphBuilderProvides,\n IntentResolverProvides,\n MetadataRecordsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { create, S, TypedObject } from '@dxos/echo-schema';\nimport { type SchemaProvides } from '@dxos/plugin-client';\nimport { type StackProvides } from '@dxos/plugin-stack';\n\nimport { SHEET_PLUGIN } from './meta';\n\nconst SHEET_ACTION = `${SHEET_PLUGIN}/action`;\n\nexport enum SheetAction {\n CREATE = `${SHEET_ACTION}/create`,\n}\n\nexport type SheetPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n MetadataRecordsProvides &\n TranslationsProvides &\n SchemaProvides &\n StackProvides;\n\nexport type CellScalarValue = number | string | boolean | null;\n\nexport const CellValue = S.Struct({\n // TODO(burdon): How to store dates (datetime, date, time), percentages, etc.\n // Consider import/export; natural access for other plugins. Special handling for currency (precision).\n // TODO(burdon): Automerge (long string) or short string or number.\n // TODO(burdon): Arrays?\n value: S.Any,\n});\n\nexport type CellValue = S.Schema.Type<typeof CellValue>;\n\n/**\n * https://www.tutorialsteacher.com/typescript/typescript-number\n */\n// TODO(burdon): Format vs. value.\nexport enum ValueTypeEnum {\n Null = 0,\n Number = 1,\n Boolean = 2,\n String = 3,\n\n // Special numbers.\n Percent = 10,\n Currency = 11,\n\n // Dates.\n DateTime = 20,\n Date = 21,\n Time = 22,\n\n // Validated string types.\n // TODO(burdon): Define effect types.\n URL = 30,\n DID = 31,\n}\n\nexport const ValueType = S.Enums(ValueTypeEnum);\n\nexport const Formatting = S.Struct({\n type: S.optional(ValueType),\n format: S.optional(S.String),\n precision: S.optional(S.Number),\n classNames: S.optional(S.Array(S.String)),\n});\n\nexport type Formatting = S.Schema.Type<typeof Formatting>;\n\n// TODO(burdon): Visibility, locked, frozen, etc.\nexport const RowColumnMeta = S.Struct({\n size: S.optional(S.Number),\n});\n\n// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.\n// TODO(wittjosiah): Migrate typename to remove `Type` suffix.\n// TODO(wittjosiah): Rename title to name to align with other schemas.\nexport class SheetType extends TypedObject({ typename: 'dxos.org/type/SheetType', version: '0.1.0' })({\n title: S.optional(S.String),\n\n // Sparse map of cells referenced by index.\n cells: S.mutable(S.Record(S.String, S.mutable(CellValue))),\n\n // Ordered row indices.\n rows: S.mutable(S.Array(S.String)),\n\n // Ordered column indices.\n columns: S.mutable(S.Array(S.String)),\n\n // Row metadata referenced by index.\n rowMeta: S.mutable(S.Record(S.String, S.mutable(RowColumnMeta))),\n\n // Column metadata referenced by index.\n columnMeta: S.mutable(S.Record(S.String, S.mutable(RowColumnMeta))),\n\n // Cell formatting referenced by indexed range.\n formatting: S.mutable(S.Record(S.String, S.mutable(Formatting))),\n}) {}\n\n// TODO(burdon): Fix defaults.\nexport const createSheet = (title?: string): SheetType =>\n create(SheetType, { title, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, formatting: {} });\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,yBAAuC;AAMvC,IAAMA,eAAe,GAAGC,kCAAAA;;UAEZC,cAAAA;wCACD,GAAGF,YAAAA,SAAqB,IAAA;GADvBE,gBAAAA,cAAAA,CAAAA,EAAAA;AAcL,IAAMC,YAAYC,qBAAEC,OAAO;;;;;EAKhCC,OAAOF,qBAAEG;AACX,CAAA;;UAQYC,gBAAAA;;;;;;;;;;;;GAAAA,kBAAAA,gBAAAA,CAAAA,EAAAA;AAqBL,IAAMC,YAAYL,qBAAEM,MAAMF,aAAAA;AAE1B,IAAMG,aAAaP,qBAAEC,OAAO;EACjCO,MAAMR,qBAAES,SAASJ,SAAAA;EACjBK,QAAQV,qBAAES,SAAST,qBAAEW,MAAM;EAC3BC,WAAWZ,qBAAES,SAAST,qBAAEa,MAAM;EAC9BC,YAAYd,qBAAES,SAAST,qBAAEe,MAAMf,qBAAEW,MAAM,CAAA;AACzC,CAAA;AAKO,IAAMK,gBAAgBhB,qBAAEC,OAAO;EACpCgB,MAAMjB,qBAAES,SAAST,qBAAEa,MAAM;AAC3B,CAAA;AAKO,IAAMK,YAAN,kBAAwBC,gCAAY;EAAEC,UAAU;EAA2BC,SAAS;AAAQ,CAAA,EAAG;EACpGC,OAAOtB,qBAAES,SAAST,qBAAEW,MAAM;;EAG1BY,OAAOvB,qBAAEwB,QAAQxB,qBAAEyB,OAAOzB,qBAAEW,QAAQX,qBAAEwB,QAAQzB,SAAAA,CAAAA,CAAAA;;EAG9C2B,MAAM1B,qBAAEwB,QAAQxB,qBAAEe,MAAMf,qBAAEW,MAAM,CAAA;;EAGhCgB,SAAS3B,qBAAEwB,QAAQxB,qBAAEe,MAAMf,qBAAEW,MAAM,CAAA;;EAGnCiB,SAAS5B,qBAAEwB,QAAQxB,qBAAEyB,OAAOzB,qBAAEW,QAAQX,qBAAEwB,QAAQR,aAAAA,CAAAA,CAAAA;;EAGhDa,YAAY7B,qBAAEwB,QAAQxB,qBAAEyB,OAAOzB,qBAAEW,QAAQX,qBAAEwB,QAAQR,aAAAA,CAAAA,CAAAA;;EAGnDc,YAAY9B,qBAAEwB,QAAQxB,qBAAEyB,OAAOzB,qBAAEW,QAAQX,qBAAEwB,QAAQjB,UAAAA,CAAAA,CAAAA;AACrD,CAAA,EAAA;AAAI;AAGG,IAAMwB,cAAc,CAACT,cAC1BU,2BAAOd,WAAW;EAAEI;EAAOC,OAAO,CAAC;EAAGG,MAAM,CAAA;EAAIC,SAAS,CAAA;EAAIC,SAAS,CAAC;EAAGC,YAAY,CAAC;EAAGC,YAAY,CAAC;AAAE,CAAA;",
6
+ "names": ["SHEET_ACTION", "SHEET_PLUGIN", "SheetAction", "CellValue", "S", "Struct", "value", "Any", "ValueTypeEnum", "ValueType", "Enums", "Formatting", "type", "optional", "format", "String", "precision", "Number", "classNames", "Array", "RowColumnMeta", "size", "SheetType", "TypedObject", "typename", "version", "title", "cells", "mutable", "Record", "rows", "columns", "rowMeta", "columnMeta", "formatting", "createSheet", "create"]
7
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var chunk_PYXHNAAK_exports = {};
30
+ __export(chunk_PYXHNAAK_exports, {
31
+ SheetContainer: () => SheetContainer
32
+ });
33
+ module.exports = __toCommonJS(chunk_PYXHNAAK_exports);
34
+ var import_react = __toESM(require("react"));
35
+ var SheetContainer = import_react.default.lazy(() => import("./SheetContainer-AXQV3ZT5.cjs"));
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ SheetContainer
39
+ });
40
+ //# sourceMappingURL=chunk-PYXHNAAK.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/index.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nexport * from './ComputeGraph';\n\n// Lazily load components for content surfaces.\nexport const SheetContainer = React.lazy(() => import('./SheetContainer'));\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,mBAAkB;AAKX,IAAMA,iBAAiBC,aAAAA,QAAMC,KAAK,MAAM,OAAO,+BAAA,CAAA;",
6
+ "names": ["SheetContainer", "React", "lazy"]
7
+ }
@@ -32,14 +32,15 @@ __export(node_exports, {
32
32
  default: () => src_default
33
33
  });
34
34
  module.exports = __toCommonJS(node_exports);
35
- var import_chunk_6DQABRGJ = require("./chunk-6DQABRGJ.cjs");
36
- var import_chunk_AOP42UAA = require("./chunk-AOP42UAA.cjs");
37
- var import_chunk_BNARJ5GM = require("./chunk-BNARJ5GM.cjs");
38
- var import_chunk_P5QYYEHQ = require("./chunk-P5QYYEHQ.cjs");
35
+ var import_chunk_PYXHNAAK = require("./chunk-PYXHNAAK.cjs");
36
+ var import_chunk_CN3RPESU = require("./chunk-CN3RPESU.cjs");
37
+ var import_chunk_5KKJ4NPP = require("./chunk-5KKJ4NPP.cjs");
38
+ var import_chunk_DSYKOI4E = require("./chunk-DSYKOI4E.cjs");
39
+ var import_chunk_BJ6ZD7MN = require("./chunk-BJ6ZD7MN.cjs");
39
40
  var import_react = require("@phosphor-icons/react");
40
41
  var import_react2 = __toESM(require("react"));
41
42
  var import_app_framework = require("@dxos/app-framework");
42
- var import_invariant = require("@dxos/invariant");
43
+ var import_echo_schema = require("@dxos/echo-schema");
43
44
  var import_plugin_client = require("@dxos/plugin-client");
44
45
  var import_plugin_graph = require("@dxos/plugin-graph");
45
46
  var import_types = require("@dxos/plugin-script/types");
@@ -48,7 +49,7 @@ var import_echo = require("@dxos/react-client/echo");
48
49
  var translations_default = [
49
50
  {
50
51
  "en-US": {
51
- [import_chunk_BNARJ5GM.SHEET_PLUGIN]: {
52
+ [import_chunk_BJ6ZD7MN.SHEET_PLUGIN]: {
52
53
  "plugin name": "Sheets",
53
54
  "sheet title placeholder": "New sheet",
54
55
  "create sheet label": "Create sheet",
@@ -56,92 +57,61 @@ var translations_default = [
56
57
  "cell placeholder": "Cell value...",
57
58
  "toolbar left label": "Align left",
58
59
  "toolbar left center": "Align center",
59
- "toolbar left right": "Align right",
60
- "selection overlaps existing comment label": "Selected cell already has a comment",
61
- "comment label": "Add comment",
62
- "comment ranges not supported label": "Commenting on ranges is not yet supported",
63
- "no cursor label": "Select a cell to comment",
64
- "open comment for sheet cell": "View comments for cell"
60
+ "toolbar left right": "Align right"
65
61
  }
66
62
  }
67
63
  }
68
64
  ];
69
- var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/SheetPlugin.tsx";
70
65
  var SheetPlugin = () => {
71
- let graphRegistry;
66
+ let remoteFunctionUrl;
67
+ const graphs = (0, import_echo_schema.create)({});
68
+ const setGraph = (key, graph) => {
69
+ graphs[key] = graph;
70
+ };
72
71
  return {
73
- meta: import_chunk_BNARJ5GM.meta_default,
72
+ meta: import_chunk_BJ6ZD7MN.meta_default,
74
73
  ready: async (plugins) => {
75
74
  const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
76
- (0, import_invariant.invariant)(client, void 0, {
77
- F: __dxlog_file,
78
- L: 31,
79
- S: void 0,
80
- A: [
81
- "client",
82
- ""
83
- ]
84
- });
85
- let remoteFunctionUrl;
75
+ if (!client) {
76
+ return;
77
+ }
86
78
  if (client.config.values.runtime?.services?.edge?.url) {
87
79
  const url = new URL("/functions", client.config.values.runtime?.services?.edge?.url);
88
80
  url.protocol = "https";
89
81
  remoteFunctionUrl = url.toString();
90
82
  }
91
- const { ComputeGraphRegistry } = await import("./graph-2LRDUXBZ.cjs");
92
- graphRegistry = new ComputeGraphRegistry({
93
- remoteFunctionUrl
94
- });
95
83
  },
96
84
  provides: {
97
85
  context: ({ children }) => {
98
- (0, import_invariant.invariant)(graphRegistry, void 0, {
99
- F: __dxlog_file,
100
- L: 45,
101
- S: void 0,
102
- A: [
103
- "graphRegistry",
104
- ""
105
- ]
106
- });
107
- return /* @__PURE__ */ import_react2.default.createElement(import_chunk_6DQABRGJ.ComputeGraphContextProvider, {
108
- registry: graphRegistry
86
+ return /* @__PURE__ */ import_react2.default.createElement(import_chunk_CN3RPESU.ComputeGraphContextProvider, {
87
+ graphs,
88
+ setGraph
109
89
  }, children);
110
90
  },
111
91
  metadata: {
112
92
  records: {
113
- [import_chunk_AOP42UAA.SheetType.typename]: {
114
- label: (object) => object instanceof import_chunk_AOP42UAA.SheetType ? object.name : void 0,
93
+ [import_chunk_DSYKOI4E.SheetType.typename]: {
94
+ label: (object) => object instanceof import_chunk_DSYKOI4E.SheetType ? object.title : void 0,
115
95
  placeholder: [
116
96
  "sheet title placeholder",
117
97
  {
118
- ns: import_chunk_BNARJ5GM.SHEET_PLUGIN
98
+ ns: import_chunk_BJ6ZD7MN.SHEET_PLUGIN
119
99
  }
120
100
  ],
121
- icon: "ph--grid-nine--regular"
101
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.GridNine, props),
102
+ iconSymbol: "ph--grid-nine--regular"
122
103
  }
123
104
  }
124
105
  },
125
106
  translations: translations_default,
126
107
  echo: {
127
108
  // TODO(wittjosiah): Factor out to common package/plugin.
128
- // FunctionType is currently registered here in case script plugin isn't enabled.
109
+ // FunctionType is currently registered here in case script plugin isn't enabled.
129
110
  schema: [
130
- import_chunk_AOP42UAA.SheetType,
111
+ import_chunk_DSYKOI4E.SheetType,
131
112
  import_types.FunctionType
132
113
  ]
133
114
  },
134
- space: {
135
- onSpaceCreate: {
136
- label: [
137
- "create sheet label",
138
- {
139
- ns: import_chunk_BNARJ5GM.SHEET_PLUGIN
140
- }
141
- ],
142
- action: import_chunk_AOP42UAA.SheetAction.CREATE
143
- }
144
- },
145
115
  graph: {
146
116
  builder: (plugins) => {
147
117
  const client = (0, import_app_framework.resolvePlugin)(plugins, import_plugin_client.parseClientPlugin)?.provides.client;
@@ -150,7 +120,7 @@ var SheetPlugin = () => {
150
120
  return [];
151
121
  }
152
122
  return (0, import_plugin_graph.createExtension)({
153
- id: import_chunk_AOP42UAA.SheetAction.CREATE,
123
+ id: import_chunk_DSYKOI4E.SheetAction.CREATE,
154
124
  filter: (node) => (0, import_plugin_graph.isActionGroup)(node) && node.id.startsWith(import_plugin_space.SpaceAction.ADD_OBJECT),
155
125
  actions: ({ node }) => {
156
126
  const id = node.id.split("/").at(-1);
@@ -163,12 +133,12 @@ var SheetPlugin = () => {
163
133
  }
164
134
  return [
165
135
  {
166
- id: `${import_chunk_BNARJ5GM.SHEET_PLUGIN}/create/${node.id}`,
136
+ id: `${import_chunk_BJ6ZD7MN.SHEET_PLUGIN}/create/${node.id}`,
167
137
  data: async () => {
168
138
  await dispatch([
169
139
  {
170
- plugin: import_chunk_BNARJ5GM.SHEET_PLUGIN,
171
- action: import_chunk_AOP42UAA.SheetAction.CREATE,
140
+ plugin: import_chunk_BJ6ZD7MN.SHEET_PLUGIN,
141
+ action: import_chunk_DSYKOI4E.SheetAction.CREATE,
172
142
  data: {
173
143
  space
174
144
  }
@@ -188,10 +158,11 @@ var SheetPlugin = () => {
188
158
  label: [
189
159
  "create sheet label",
190
160
  {
191
- ns: import_chunk_BNARJ5GM.SHEET_PLUGIN
161
+ ns: import_chunk_BJ6ZD7MN.SHEET_PLUGIN
192
162
  }
193
163
  ],
194
- icon: "ph--grid-nine--regular",
164
+ icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.GridNine, props),
165
+ iconSymbol: "ph--grid-nine--regular",
195
166
  testId: "sheetPlugin.createObject"
196
167
  }
197
168
  }
@@ -200,12 +171,6 @@ var SheetPlugin = () => {
200
171
  });
201
172
  }
202
173
  },
203
- markdown: {
204
- // TODO(burdon): Facet to get current space/compute graph.
205
- extensions: ({ document }) => {
206
- return void 0;
207
- }
208
- },
209
174
  stack: {
210
175
  creators: [
211
176
  {
@@ -214,39 +179,36 @@ var SheetPlugin = () => {
214
179
  type: [
215
180
  "plugin name",
216
181
  {
217
- ns: import_chunk_BNARJ5GM.SHEET_PLUGIN
182
+ ns: import_chunk_BJ6ZD7MN.SHEET_PLUGIN
218
183
  }
219
184
  ],
220
185
  label: [
221
186
  "create sheet section label",
222
187
  {
223
- ns: import_chunk_BNARJ5GM.SHEET_PLUGIN
188
+ ns: import_chunk_BJ6ZD7MN.SHEET_PLUGIN
224
189
  }
225
190
  ],
226
191
  icon: (props) => /* @__PURE__ */ import_react2.default.createElement(import_react.GridNine, props),
227
192
  intent: {
228
- plugin: import_chunk_BNARJ5GM.SHEET_PLUGIN,
229
- action: import_chunk_AOP42UAA.SheetAction.CREATE
193
+ plugin: import_chunk_BJ6ZD7MN.SHEET_PLUGIN,
194
+ action: import_chunk_DSYKOI4E.SheetAction.CREATE
230
195
  }
231
196
  }
232
197
  ]
233
198
  },
234
- thread: {
235
- predicate: (data) => data instanceof import_chunk_AOP42UAA.SheetType,
236
- createSort: (sheet) => (indexA, indexB) => !indexA || !indexB ? 0 : (0, import_chunk_6DQABRGJ.compareIndexPositions)(sheet, indexA, indexB)
237
- },
238
199
  surface: {
239
- component: ({ data, role }) => {
240
- const space = (0, import_echo.isEchoObject)(data.object) ? (0, import_echo.getSpace)(data.object) : void 0;
241
- const graph = (0, import_chunk_6DQABRGJ.useComputeGraph)(space);
242
- if (graph && data.object instanceof import_chunk_AOP42UAA.SheetType) {
200
+ component: ({ data, role = "never" }) => {
201
+ const space = (0, import_echo.isEchoObject)(data.object) && (0, import_echo.getSpace)(data.object);
202
+ if (space && data.object instanceof import_chunk_DSYKOI4E.SheetType) {
243
203
  switch (role) {
244
204
  case "article":
245
205
  case "section": {
246
- return /* @__PURE__ */ import_react2.default.createElement(import_chunk_6DQABRGJ.SheetContainer, {
247
- graph,
206
+ return /* @__PURE__ */ import_react2.default.createElement(import_chunk_PYXHNAAK.SheetContainer, {
248
207
  sheet: data.object,
249
- role
208
+ space,
209
+ role,
210
+ coordinate: data.coordinate,
211
+ remoteFunctionUrl
250
212
  });
251
213
  }
252
214
  }
@@ -257,9 +219,27 @@ var SheetPlugin = () => {
257
219
  intent: {
258
220
  resolver: async (intent) => {
259
221
  switch (intent.action) {
260
- case import_chunk_AOP42UAA.SheetAction.CREATE: {
222
+ case import_chunk_DSYKOI4E.SheetAction.CREATE: {
223
+ const space = intent.data?.space;
224
+ const sheet = (0, import_chunk_DSYKOI4E.createSheet)();
225
+ const graph = graphs[space.id] ?? (0, import_chunk_5KKJ4NPP.createComputeGraph)([
226
+ {
227
+ plugin: import_chunk_CN3RPESU.EdgeFunctionPlugin,
228
+ translations: import_chunk_CN3RPESU.EdgeFunctionPluginTranslations
229
+ },
230
+ // TODO(wittjosiah): Remove. Needed for current test sheet generated data.
231
+ {
232
+ plugin: import_chunk_5KKJ4NPP.CustomPlugin,
233
+ translations: import_chunk_5KKJ4NPP.CustomPluginTranslations
234
+ }
235
+ ], space, {
236
+ remoteFunctionUrl
237
+ });
238
+ const model = new import_chunk_5KKJ4NPP.SheetModel(graph, sheet);
239
+ await model.initialize();
240
+ await model.destroy();
261
241
  return {
262
- data: (0, import_chunk_6DQABRGJ.createSheet)()
242
+ data: sheet
263
243
  };
264
244
  }
265
245
  }