@dxos/plugin-sheet 0.6.10 → 0.6.11-staging.32b42e4
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.
- package/dist/lib/browser/{SheetContainer-ISY6DUVE.mjs → SheetContainer-U4H5D34A.mjs} +64 -52
- package/dist/lib/browser/SheetContainer-U4H5D34A.mjs.map +7 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs +175 -0
- package/dist/lib/browser/chunk-APHOLYUB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-CBRBNG3R.mjs → chunk-D5AGLXJP.mjs} +123 -202
- package/dist/lib/browser/chunk-D5AGLXJP.mjs.map +7 -0
- package/dist/lib/browser/{chunk-D3PUKBH6.mjs → chunk-FUAGSXA4.mjs} +1 -1
- package/dist/lib/browser/{chunk-D3PUKBH6.mjs.map → chunk-FUAGSXA4.mjs.map} +2 -2
- package/dist/lib/browser/chunk-NU4PBN33.mjs +8 -0
- package/dist/lib/browser/chunk-NU4PBN33.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +37 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing.mjs +92 -0
- package/dist/lib/browser/testing.mjs.map +7 -0
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/{SheetContainer-ESRTE7A5.cjs → SheetContainer-AXQV3ZT5.cjs} +83 -72
- package/dist/lib/node/SheetContainer-AXQV3ZT5.cjs.map +7 -0
- package/dist/lib/node/{chunk-4EGEA3KL.cjs → chunk-5KKJ4NPP.cjs} +135 -214
- package/dist/lib/node/chunk-5KKJ4NPP.cjs.map +7 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs +202 -0
- package/dist/lib/node/chunk-CN3RPESU.cjs.map +7 -0
- package/dist/lib/node/{chunk-3R3J7IZR.cjs → chunk-DSYKOI4E.cjs} +4 -4
- package/dist/lib/node/{chunk-3R3J7IZR.cjs.map → chunk-DSYKOI4E.cjs.map} +2 -2
- package/dist/lib/node/chunk-PYXHNAAK.cjs +40 -0
- package/dist/lib/node/chunk-PYXHNAAK.cjs.map +7 -0
- package/dist/lib/node/index.cjs +38 -79
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing.cjs +111 -0
- package/dist/lib/node/testing.cjs.map +7 -0
- package/dist/lib/node/types.cjs +9 -9
- package/dist/lib/node/types.cjs.map +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/model/model.d.ts.map +1 -1
- package/dist/types/src/testing.d.ts +9 -0
- package/dist/types/src/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +38 -28
- package/src/SheetPlugin.tsx +36 -16
- package/src/components/CellEditor/extension.ts +16 -10
- package/src/components/ComputeGraph/edge-function.ts +6 -2
- package/src/components/ComputeGraph/graph-context.tsx +10 -1
- package/src/components/Sheet/Sheet.stories.tsx +9 -47
- package/src/components/Sheet/Sheet.tsx +24 -33
- package/src/components/Sheet/formatting.ts +1 -1
- package/src/components/SheetContainer.tsx +3 -4
- package/src/components/Toolbar/Toolbar.stories.tsx +5 -10
- package/src/model/model.ts +2 -3
- package/src/testing.ts +50 -0
- package/src/types.ts +2 -0
- package/dist/lib/browser/SheetContainer-ISY6DUVE.mjs.map +0 -7
- package/dist/lib/browser/chunk-CBRBNG3R.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-ESRTE7A5.cjs.map +0 -7
- package/dist/lib/node/chunk-4EGEA3KL.cjs.map +0 -7
|
@@ -26,11 +26,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
EdgeFunctionPluginTranslations: () => EdgeFunctionPluginTranslations,
|
|
29
|
+
var chunk_5KKJ4NPP_exports = {};
|
|
30
|
+
__export(chunk_5KKJ4NPP_exports, {
|
|
31
|
+
CustomPlugin: () => CustomPlugin,
|
|
32
|
+
CustomPluginTranslations: () => CustomPluginTranslations,
|
|
34
33
|
FunctionPluginAsync: () => FunctionPluginAsync,
|
|
35
34
|
SheetModel: () => SheetModel,
|
|
36
35
|
addressFromA1Notation: () => addressFromA1Notation,
|
|
@@ -40,11 +39,10 @@ __export(chunk_4EGEA3KL_exports, {
|
|
|
40
39
|
defaultFunctions: () => defaultFunctions,
|
|
41
40
|
inRange: () => inRange,
|
|
42
41
|
posEquals: () => posEquals,
|
|
43
|
-
rangeToA1Notation: () => rangeToA1Notation
|
|
44
|
-
useComputeGraph: () => useComputeGraph
|
|
42
|
+
rangeToA1Notation: () => rangeToA1Notation
|
|
45
43
|
});
|
|
46
|
-
module.exports = __toCommonJS(
|
|
47
|
-
var
|
|
44
|
+
module.exports = __toCommonJS(chunk_5KKJ4NPP_exports);
|
|
45
|
+
var import_chunk_DSYKOI4E = require("./chunk-DSYKOI4E.cjs");
|
|
48
46
|
var import_hyperformula = require("hyperformula");
|
|
49
47
|
var import_async = require("@dxos/async");
|
|
50
48
|
var import_keys = require("@dxos/keys");
|
|
@@ -53,21 +51,16 @@ var import_hyperformula2 = require("hyperformula");
|
|
|
53
51
|
var import_lodash = __toESM(require("lodash.defaultsdeep"));
|
|
54
52
|
var import_async2 = require("@dxos/async");
|
|
55
53
|
var import_log2 = require("@dxos/log");
|
|
56
|
-
var import_invariant = require("@dxos/invariant");
|
|
57
54
|
var import_hyperformula3 = require("hyperformula");
|
|
58
55
|
var import_async3 = require("@dxos/async");
|
|
59
56
|
var import_context = require("@dxos/context");
|
|
60
|
-
var
|
|
57
|
+
var import_invariant = require("@dxos/invariant");
|
|
61
58
|
var import_keys2 = require("@dxos/keys");
|
|
62
59
|
var import_log3 = require("@dxos/log");
|
|
60
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
63
61
|
var import_crypto = require("@dxos/crypto");
|
|
64
|
-
var import_signals_core = require("@preact/signals-core");
|
|
65
62
|
var import_hyperformula4 = require("hyperformula");
|
|
66
|
-
var import_echo = require("@dxos/client/echo");
|
|
67
|
-
var import_edge = require("@dxos/plugin-script/edge");
|
|
68
|
-
var import_types = require("@dxos/plugin-script/types");
|
|
69
63
|
var import_util = require("@dxos/util");
|
|
70
|
-
var import_react = __toESM(require("react"));
|
|
71
64
|
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/components/ComputeGraph/async-function.ts";
|
|
72
65
|
var defaultFunctionContextOptions = {
|
|
73
66
|
defaultTtl: 5e3,
|
|
@@ -229,68 +222,6 @@ var ComputeGraph = class {
|
|
|
229
222
|
this.update.emit();
|
|
230
223
|
}
|
|
231
224
|
};
|
|
232
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/types.ts";
|
|
233
|
-
var MAX_COLUMNS = 26 * 26;
|
|
234
|
-
var posEquals = (a, b) => {
|
|
235
|
-
return a?.column === b?.column && a?.row === b?.row;
|
|
236
|
-
};
|
|
237
|
-
var columnLetter = (column) => {
|
|
238
|
-
(0, import_invariant.invariant)(column < MAX_COLUMNS, `Invalid column: ${column}`, {
|
|
239
|
-
F: __dxlog_file3,
|
|
240
|
-
L: 17,
|
|
241
|
-
S: void 0,
|
|
242
|
-
A: [
|
|
243
|
-
"column < MAX_COLUMNS",
|
|
244
|
-
"`Invalid column: ${column}`"
|
|
245
|
-
]
|
|
246
|
-
});
|
|
247
|
-
return (column >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(column / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + column % 26);
|
|
248
|
-
};
|
|
249
|
-
var addressToA1Notation = ({ column, row }) => {
|
|
250
|
-
return `${columnLetter(column)}${row + 1}`;
|
|
251
|
-
};
|
|
252
|
-
var addressFromA1Notation = (ref) => {
|
|
253
|
-
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
254
|
-
(0, import_invariant.invariant)(match, `Invalid notation: ${ref}`, {
|
|
255
|
-
F: __dxlog_file3,
|
|
256
|
-
L: 30,
|
|
257
|
-
S: void 0,
|
|
258
|
-
A: [
|
|
259
|
-
"match",
|
|
260
|
-
"`Invalid notation: ${ref}`"
|
|
261
|
-
]
|
|
262
|
-
});
|
|
263
|
-
return {
|
|
264
|
-
row: parseInt(match[2], 10) - 1,
|
|
265
|
-
column: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
266
|
-
};
|
|
267
|
-
};
|
|
268
|
-
var rangeToA1Notation = (range) => {
|
|
269
|
-
return [
|
|
270
|
-
range?.from && addressToA1Notation(range?.from),
|
|
271
|
-
range?.to && addressToA1Notation(range?.to)
|
|
272
|
-
].filter(Boolean).join(":");
|
|
273
|
-
};
|
|
274
|
-
var inRange = (range, cell) => {
|
|
275
|
-
if (!range) {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
const { from, to } = range;
|
|
279
|
-
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
280
|
-
return true;
|
|
281
|
-
}
|
|
282
|
-
if (!from || !to) {
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
const { column: c1, row: r1 } = from;
|
|
286
|
-
const { column: c2, row: r2 } = to;
|
|
287
|
-
const cMin = Math.min(c1, c2);
|
|
288
|
-
const cMax = Math.max(c1, c2);
|
|
289
|
-
const rMin = Math.min(r1, r2);
|
|
290
|
-
const rMax = Math.max(r1, r2);
|
|
291
|
-
const { column, row } = cell;
|
|
292
|
-
return column >= cMin && column <= cMax && row >= rMin && row <= rMax;
|
|
293
|
-
};
|
|
294
225
|
var defaultFunctions = [
|
|
295
226
|
// Array
|
|
296
227
|
{
|
|
@@ -2663,6 +2594,68 @@ var defaultFunctions = [
|
|
|
2663
2594
|
section: "Text"
|
|
2664
2595
|
}
|
|
2665
2596
|
];
|
|
2597
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/types.ts";
|
|
2598
|
+
var MAX_COLUMNS = 26 * 26;
|
|
2599
|
+
var posEquals = (a, b) => {
|
|
2600
|
+
return a?.column === b?.column && a?.row === b?.row;
|
|
2601
|
+
};
|
|
2602
|
+
var columnLetter = (column) => {
|
|
2603
|
+
(0, import_invariant2.invariant)(column < MAX_COLUMNS, `Invalid column: ${column}`, {
|
|
2604
|
+
F: __dxlog_file3,
|
|
2605
|
+
L: 17,
|
|
2606
|
+
S: void 0,
|
|
2607
|
+
A: [
|
|
2608
|
+
"column < MAX_COLUMNS",
|
|
2609
|
+
"`Invalid column: ${column}`"
|
|
2610
|
+
]
|
|
2611
|
+
});
|
|
2612
|
+
return (column >= 26 ? String.fromCharCode("A".charCodeAt(0) + Math.floor(column / 26) - 1) : "") + String.fromCharCode("A".charCodeAt(0) + column % 26);
|
|
2613
|
+
};
|
|
2614
|
+
var addressToA1Notation = ({ column, row }) => {
|
|
2615
|
+
return `${columnLetter(column)}${row + 1}`;
|
|
2616
|
+
};
|
|
2617
|
+
var addressFromA1Notation = (ref) => {
|
|
2618
|
+
const match = ref.match(/([A-Z]+)(\d+)/);
|
|
2619
|
+
(0, import_invariant2.invariant)(match, `Invalid notation: ${ref}`, {
|
|
2620
|
+
F: __dxlog_file3,
|
|
2621
|
+
L: 30,
|
|
2622
|
+
S: void 0,
|
|
2623
|
+
A: [
|
|
2624
|
+
"match",
|
|
2625
|
+
"`Invalid notation: ${ref}`"
|
|
2626
|
+
]
|
|
2627
|
+
});
|
|
2628
|
+
return {
|
|
2629
|
+
row: parseInt(match[2], 10) - 1,
|
|
2630
|
+
column: match[1].split("").reduce((acc, c) => acc * 26 + c.charCodeAt(0) - "A".charCodeAt(0) + 1, 0) - 1
|
|
2631
|
+
};
|
|
2632
|
+
};
|
|
2633
|
+
var rangeToA1Notation = (range) => {
|
|
2634
|
+
return [
|
|
2635
|
+
range?.from && addressToA1Notation(range?.from),
|
|
2636
|
+
range?.to && addressToA1Notation(range?.to)
|
|
2637
|
+
].filter(Boolean).join(":");
|
|
2638
|
+
};
|
|
2639
|
+
var inRange = (range, cell) => {
|
|
2640
|
+
if (!range) {
|
|
2641
|
+
return false;
|
|
2642
|
+
}
|
|
2643
|
+
const { from, to } = range;
|
|
2644
|
+
if (from && posEquals(from, cell) || to && posEquals(to, cell)) {
|
|
2645
|
+
return true;
|
|
2646
|
+
}
|
|
2647
|
+
if (!from || !to) {
|
|
2648
|
+
return false;
|
|
2649
|
+
}
|
|
2650
|
+
const { column: c1, row: r1 } = from;
|
|
2651
|
+
const { column: c2, row: r2 } = to;
|
|
2652
|
+
const cMin = Math.min(c1, c2);
|
|
2653
|
+
const cMax = Math.max(c1, c2);
|
|
2654
|
+
const rMin = Math.min(r1, r2);
|
|
2655
|
+
const rMax = Math.max(r1, r2);
|
|
2656
|
+
const { column, row } = cell;
|
|
2657
|
+
return column >= cMin && column <= cMax && row >= rMin && row <= rMax;
|
|
2658
|
+
};
|
|
2666
2659
|
var ApiError = class extends Error {
|
|
2667
2660
|
};
|
|
2668
2661
|
var ReadonlyException = class extends ApiError {
|
|
@@ -2682,16 +2675,16 @@ var createIndices = (length) => Array.from({
|
|
|
2682
2675
|
length
|
|
2683
2676
|
}).map(() => createIndex());
|
|
2684
2677
|
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/plugins/plugin-sheet/src/model/model.ts";
|
|
2685
|
-
var DEFAULT_ROWS =
|
|
2686
|
-
var DEFAULT_COLUMNS = 26
|
|
2678
|
+
var DEFAULT_ROWS = 100;
|
|
2679
|
+
var DEFAULT_COLUMNS = 26;
|
|
2687
2680
|
var typeMap = {
|
|
2688
|
-
BOOLEAN:
|
|
2689
|
-
NUMBER_RAW:
|
|
2690
|
-
NUMBER_PERCENT:
|
|
2691
|
-
NUMBER_CURRENCY:
|
|
2692
|
-
NUMBER_DATETIME:
|
|
2693
|
-
NUMBER_DATE:
|
|
2694
|
-
NUMBER_TIME:
|
|
2681
|
+
BOOLEAN: import_chunk_DSYKOI4E.ValueTypeEnum.Boolean,
|
|
2682
|
+
NUMBER_RAW: import_chunk_DSYKOI4E.ValueTypeEnum.Number,
|
|
2683
|
+
NUMBER_PERCENT: import_chunk_DSYKOI4E.ValueTypeEnum.Percent,
|
|
2684
|
+
NUMBER_CURRENCY: import_chunk_DSYKOI4E.ValueTypeEnum.Currency,
|
|
2685
|
+
NUMBER_DATETIME: import_chunk_DSYKOI4E.ValueTypeEnum.DateTime,
|
|
2686
|
+
NUMBER_DATE: import_chunk_DSYKOI4E.ValueTypeEnum.Date,
|
|
2687
|
+
NUMBER_TIME: import_chunk_DSYKOI4E.ValueTypeEnum.Time
|
|
2695
2688
|
};
|
|
2696
2689
|
var defaultOptions = {
|
|
2697
2690
|
rows: 50,
|
|
@@ -2773,13 +2766,13 @@ var SheetModel = class {
|
|
|
2773
2766
|
id: this.id
|
|
2774
2767
|
}, {
|
|
2775
2768
|
F: __dxlog_file4,
|
|
2776
|
-
L:
|
|
2769
|
+
L: 142,
|
|
2777
2770
|
S: this,
|
|
2778
2771
|
C: (f, a) => f(...a)
|
|
2779
2772
|
});
|
|
2780
|
-
(0,
|
|
2773
|
+
(0, import_invariant.invariant)(!this.initialized, "Already initialized.", {
|
|
2781
2774
|
F: __dxlog_file4,
|
|
2782
|
-
L:
|
|
2775
|
+
L: 143,
|
|
2783
2776
|
S: this,
|
|
2784
2777
|
A: [
|
|
2785
2778
|
"!this.initialized",
|
|
@@ -2788,7 +2781,7 @@ var SheetModel = class {
|
|
|
2788
2781
|
});
|
|
2789
2782
|
this._ctx = new import_context.Context(void 0, {
|
|
2790
2783
|
F: __dxlog_file4,
|
|
2791
|
-
L:
|
|
2784
|
+
L: 144
|
|
2792
2785
|
});
|
|
2793
2786
|
if (!this._sheet.rows.length) {
|
|
2794
2787
|
this._insertIndices(this._sheet.rows, 0, this._options.rows, DEFAULT_ROWS);
|
|
@@ -2800,9 +2793,9 @@ var SheetModel = class {
|
|
|
2800
2793
|
const unsubscribe = this._graph.update.on(() => this.update.emit());
|
|
2801
2794
|
this._ctx.onDispose(unsubscribe);
|
|
2802
2795
|
if (this._space) {
|
|
2803
|
-
const { Filter
|
|
2804
|
-
const { FunctionType
|
|
2805
|
-
const query = this._space?.db.query(
|
|
2796
|
+
const { Filter } = await import("@dxos/client/echo");
|
|
2797
|
+
const { FunctionType } = await import("@dxos/plugin-script/types");
|
|
2798
|
+
const query = this._space?.db.query(Filter.schema(FunctionType));
|
|
2806
2799
|
const unsubscribe2 = query.subscribe(({ objects }) => {
|
|
2807
2800
|
this._functions = objects.filter((fn) => fn.binding);
|
|
2808
2801
|
this.update.emit();
|
|
@@ -2816,7 +2809,7 @@ var SheetModel = class {
|
|
|
2816
2809
|
id: this.id
|
|
2817
2810
|
}, {
|
|
2818
2811
|
F: __dxlog_file4,
|
|
2819
|
-
L:
|
|
2812
|
+
L: 174,
|
|
2820
2813
|
S: this,
|
|
2821
2814
|
C: (f, a) => f(...a)
|
|
2822
2815
|
});
|
|
@@ -3139,9 +3132,9 @@ var SheetModel = class {
|
|
|
3139
3132
|
* Map from A1 notation to indices.
|
|
3140
3133
|
*/
|
|
3141
3134
|
mapFormulaRefsToIndices(formula) {
|
|
3142
|
-
(0,
|
|
3135
|
+
(0, import_invariant.invariant)(formula.charAt(0) === "=", void 0, {
|
|
3143
3136
|
F: __dxlog_file4,
|
|
3144
|
-
L:
|
|
3137
|
+
L: 509,
|
|
3145
3138
|
S: this,
|
|
3146
3139
|
A: [
|
|
3147
3140
|
"formula.charAt(0) === '='",
|
|
@@ -3156,9 +3149,9 @@ var SheetModel = class {
|
|
|
3156
3149
|
* Map from indices to A1 notation.
|
|
3157
3150
|
*/
|
|
3158
3151
|
mapFormulaIndicesToRefs(formula) {
|
|
3159
|
-
(0,
|
|
3152
|
+
(0, import_invariant.invariant)(formula.charAt(0) === "=", void 0, {
|
|
3160
3153
|
F: __dxlog_file4,
|
|
3161
|
-
L:
|
|
3154
|
+
L: 519,
|
|
3162
3155
|
S: this,
|
|
3163
3156
|
A: [
|
|
3164
3157
|
"formula.charAt(0) === '='",
|
|
@@ -3191,138 +3184,67 @@ var SheetModel = class {
|
|
|
3191
3184
|
return this._graph.hf.numberToTime(num);
|
|
3192
3185
|
}
|
|
3193
3186
|
};
|
|
3194
|
-
var
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
}
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3187
|
+
var parseNumberString = (str) => {
|
|
3188
|
+
return parseFloat(str.replace(/[^\d.]/g, ""));
|
|
3189
|
+
};
|
|
3190
|
+
var CustomPlugin = class extends FunctionPluginAsync {
|
|
3191
|
+
test(ast, state) {
|
|
3192
|
+
const handler = async () => {
|
|
3193
|
+
return Math.random();
|
|
3194
|
+
};
|
|
3195
|
+
return this.runAsyncFunction(ast, state, handler);
|
|
3196
|
+
}
|
|
3197
|
+
crypto(ast, state) {
|
|
3198
|
+
const handler = async (_currency) => {
|
|
3199
|
+
const currency = (_currency || "USD").toUpperCase();
|
|
3200
|
+
const result = await fetch(`https://api.coindesk.com/v1/bpi/currentprice/${currency}.json`);
|
|
3201
|
+
const data = await result.json();
|
|
3202
|
+
const rate = (0, import_util.getDeep)(data, [
|
|
3203
|
+
"bpi",
|
|
3204
|
+
currency,
|
|
3205
|
+
"rate"
|
|
3206
|
+
]);
|
|
3207
|
+
if (!rate) {
|
|
3208
|
+
return NaN;
|
|
3216
3209
|
}
|
|
3217
|
-
|
|
3218
|
-
const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
|
|
3219
|
-
method: "POST",
|
|
3220
|
-
headers: {
|
|
3221
|
-
"Content-Type": "application/json"
|
|
3222
|
-
},
|
|
3223
|
-
body: JSON.stringify({
|
|
3224
|
-
args: args.filter(import_util.nonNullable)
|
|
3225
|
-
})
|
|
3226
|
-
});
|
|
3227
|
-
return await result.text();
|
|
3210
|
+
return parseNumberString(rate);
|
|
3228
3211
|
};
|
|
3229
|
-
return this.runAsyncFunction(ast, state, handler
|
|
3230
|
-
ttl:
|
|
3212
|
+
return this.runAsyncFunction(ast, state, handler, {
|
|
3213
|
+
ttl: 1e4
|
|
3231
3214
|
});
|
|
3232
3215
|
}
|
|
3233
3216
|
};
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
method: "
|
|
3217
|
+
CustomPlugin.implementedFunctions = {
|
|
3218
|
+
TEST: {
|
|
3219
|
+
method: "test",
|
|
3220
|
+
parameters: [],
|
|
3221
|
+
isVolatile: true
|
|
3222
|
+
},
|
|
3223
|
+
CRYPTO: {
|
|
3224
|
+
method: "crypto",
|
|
3237
3225
|
parameters: [
|
|
3238
|
-
// Binding
|
|
3239
|
-
{
|
|
3240
|
-
argumentType: import_hyperformula4.FunctionArgumentType.STRING
|
|
3241
|
-
},
|
|
3242
|
-
// Remote function arguments (currently supporting up to 9).
|
|
3243
|
-
{
|
|
3244
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3245
|
-
optionalArg: true
|
|
3246
|
-
},
|
|
3247
|
-
{
|
|
3248
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3249
|
-
optionalArg: true
|
|
3250
|
-
},
|
|
3251
|
-
{
|
|
3252
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3253
|
-
optionalArg: true
|
|
3254
|
-
},
|
|
3255
|
-
{
|
|
3256
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3257
|
-
optionalArg: true
|
|
3258
|
-
},
|
|
3259
|
-
{
|
|
3260
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3261
|
-
optionalArg: true
|
|
3262
|
-
},
|
|
3263
|
-
{
|
|
3264
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3265
|
-
optionalArg: true
|
|
3266
|
-
},
|
|
3267
|
-
{
|
|
3268
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3269
|
-
optionalArg: true
|
|
3270
|
-
},
|
|
3271
|
-
{
|
|
3272
|
-
argumentType: import_hyperformula4.FunctionArgumentType.ANY,
|
|
3273
|
-
optionalArg: true
|
|
3274
|
-
},
|
|
3275
3226
|
{
|
|
3276
|
-
argumentType: import_hyperformula4.FunctionArgumentType.
|
|
3227
|
+
argumentType: import_hyperformula4.FunctionArgumentType.STRING,
|
|
3277
3228
|
optionalArg: true
|
|
3278
3229
|
}
|
|
3279
3230
|
],
|
|
3280
3231
|
isVolatile: true
|
|
3281
3232
|
}
|
|
3282
3233
|
};
|
|
3283
|
-
var
|
|
3234
|
+
var CustomPluginTranslations = {
|
|
3284
3235
|
enGB: {
|
|
3285
|
-
|
|
3236
|
+
TEST: "TEST",
|
|
3237
|
+
CRYPTO: "CRYPTO"
|
|
3286
3238
|
},
|
|
3287
3239
|
enUS: {
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
};
|
|
3291
|
-
var ComputeGraphContext = /* @__PURE__ */ (0, import_react.createContext)({
|
|
3292
|
-
graphs: {},
|
|
3293
|
-
setGraph: () => {
|
|
3240
|
+
TEST: "TEST",
|
|
3241
|
+
CRYPTO: "CRYPTO"
|
|
3294
3242
|
}
|
|
3295
|
-
});
|
|
3296
|
-
var ComputeGraphContextProvider = ({ children, graphs, setGraph }) => {
|
|
3297
|
-
return /* @__PURE__ */ import_react.default.createElement(ComputeGraphContext.Provider, {
|
|
3298
|
-
value: {
|
|
3299
|
-
graphs,
|
|
3300
|
-
setGraph
|
|
3301
|
-
}
|
|
3302
|
-
}, children);
|
|
3303
|
-
};
|
|
3304
|
-
var useComputeGraph = (space, options) => {
|
|
3305
|
-
const { graphs, setGraph } = (0, import_react.useContext)(ComputeGraphContext);
|
|
3306
|
-
const graph = graphs[space.id] ?? createComputeGraph([
|
|
3307
|
-
{
|
|
3308
|
-
plugin: EdgeFunctionPlugin,
|
|
3309
|
-
translations: EdgeFunctionPluginTranslations
|
|
3310
|
-
}
|
|
3311
|
-
], space, options);
|
|
3312
|
-
(0, import_react.useEffect)(() => {
|
|
3313
|
-
if (!graphs[space.id]) {
|
|
3314
|
-
setGraph(space.id, graph);
|
|
3315
|
-
}
|
|
3316
|
-
}, [
|
|
3317
|
-
space
|
|
3318
|
-
]);
|
|
3319
|
-
return graph;
|
|
3320
3243
|
};
|
|
3321
3244
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3322
3245
|
0 && (module.exports = {
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
EdgeFunctionPluginTranslations,
|
|
3246
|
+
CustomPlugin,
|
|
3247
|
+
CustomPluginTranslations,
|
|
3326
3248
|
FunctionPluginAsync,
|
|
3327
3249
|
SheetModel,
|
|
3328
3250
|
addressFromA1Notation,
|
|
@@ -3332,7 +3254,6 @@ var useComputeGraph = (space, options) => {
|
|
|
3332
3254
|
defaultFunctions,
|
|
3333
3255
|
inRange,
|
|
3334
3256
|
posEquals,
|
|
3335
|
-
rangeToA1Notation
|
|
3336
|
-
useComputeGraph
|
|
3257
|
+
rangeToA1Notation
|
|
3337
3258
|
});
|
|
3338
|
-
//# sourceMappingURL=chunk-
|
|
3259
|
+
//# sourceMappingURL=chunk-5KKJ4NPP.cjs.map
|