@dxos/plugin-sheet 0.7.4 → 0.7.5-main.937ce75
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-KCLT6PEO.mjs → SheetContainer-S4NCLUYL.mjs} +16 -22
- package/dist/lib/browser/SheetContainer-S4NCLUYL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-E5WQ7U7G.mjs → chunk-A374JPWV.mjs} +72 -705
- package/dist/lib/browser/chunk-A374JPWV.mjs.map +7 -0
- package/dist/lib/browser/chunk-Q4XS4YWF.mjs +900 -0
- package/dist/lib/browser/chunk-Q4XS4YWF.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +74 -180
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types/index.mjs +62 -0
- package/dist/lib/node/{SheetContainer-VVVRYTQG.cjs → SheetContainer-TP4GYXZB.cjs} +41 -43
- package/dist/lib/node/SheetContainer-TP4GYXZB.cjs.map +7 -0
- package/dist/lib/node/{chunk-45YW2DX2.cjs → chunk-FDEQ2PGJ.cjs} +115 -726
- package/dist/lib/node/chunk-FDEQ2PGJ.cjs.map +7 -0
- package/dist/lib/node/chunk-TQOJ7DG2.cjs +935 -0
- package/dist/lib/node/chunk-TQOJ7DG2.cjs.map +7 -0
- package/dist/lib/node/index.cjs +104 -207
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types/index.cjs +84 -0
- package/dist/lib/node/types/index.cjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-LSBE6Q4X.mjs → SheetContainer-YB3JBVPZ.mjs} +16 -22
- package/dist/lib/node-esm/SheetContainer-YB3JBVPZ.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-NYDNXI7L.mjs → chunk-L5PQHVTX.mjs} +72 -705
- package/dist/lib/node-esm/chunk-L5PQHVTX.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NYYIDVR7.mjs +901 -0
- package/dist/lib/node-esm/chunk-NYYIDVR7.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +74 -180
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/types/index.mjs +63 -0
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts +1 -2
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts +1 -1
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts +1 -1
- package/dist/types/src/extensions/editor/extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -8
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +1 -1
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +1 -1
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +2 -2
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/{defs → types}/index.d.ts +1 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/types/schema.d.ts +105 -0
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -0
- package/dist/types/src/types/types.d.ts +82 -0
- package/dist/types/src/types/types.d.ts.map +1 -0
- package/dist/types/src/{defs → types}/util.d.ts +5 -1
- package/dist/types/src/types/util.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +46 -53
- package/src/SheetPlugin.tsx +44 -115
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +1 -2
- package/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.tsx +6 -7
- package/src/components/FunctionEditor/FunctionEditor.tsx +2 -1
- package/src/components/GridSheet/GridSheet.tsx +15 -18
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +6 -7
- package/src/components/GridSheet/util.ts +3 -2
- package/src/components/RangeList/RangeList.tsx +2 -1
- package/src/components/SheetContainer/SheetContainer.stories.tsx +11 -12
- package/src/components/SheetContext/SheetContext.tsx +1 -2
- package/src/components/Toolbar/Toolbar.tsx +18 -20
- package/src/extensions/compute.ts +7 -4
- package/src/extensions/editor/extension.test.ts +2 -1
- package/src/extensions/editor/extension.ts +2 -3
- package/src/index.ts +1 -3
- package/src/integrations/thread-ranges.ts +28 -24
- package/src/model/sheet-model.test.ts +4 -10
- package/src/model/sheet-model.ts +30 -22
- package/src/model/testing.ts +3 -2
- package/src/model/useSheetModel.ts +2 -1
- package/src/sanity.test.ts +1 -1
- package/src/testing/testing.tsx +2 -3
- package/src/{defs → types}/index.ts +1 -0
- package/src/types/schema.ts +56 -0
- package/src/types/types.ts +93 -0
- package/src/{defs → types}/util.ts +13 -13
- package/dist/lib/browser/SheetContainer-KCLT6PEO.mjs.map +0 -7
- package/dist/lib/browser/chunk-E5WQ7U7G.mjs.map +0 -7
- package/dist/lib/browser/chunk-F3HE6D3J.mjs +0 -3269
- package/dist/lib/browser/chunk-F3HE6D3J.mjs.map +0 -7
- package/dist/lib/browser/chunk-JXFPOYNA.mjs +0 -67
- package/dist/lib/browser/chunk-JXFPOYNA.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-SNUS7HOH.mjs +0 -35
- package/dist/lib/browser/types.mjs +0 -16
- package/dist/lib/node/SheetContainer-VVVRYTQG.cjs.map +0 -7
- package/dist/lib/node/chunk-45YW2DX2.cjs.map +0 -7
- package/dist/lib/node/chunk-KSEEI5VC.cjs +0 -3323
- package/dist/lib/node/chunk-KSEEI5VC.cjs.map +0 -7
- package/dist/lib/node/chunk-OWH2EUHZ.cjs +0 -90
- package/dist/lib/node/chunk-OWH2EUHZ.cjs.map +0 -7
- package/dist/lib/node/compute-graph-WILPHO4A.cjs +0 -57
- package/dist/lib/node/compute-graph-WILPHO4A.cjs.map +0 -7
- package/dist/lib/node/types.cjs +0 -38
- package/dist/lib/node/types.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-LSBE6Q4X.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs +0 -3270
- package/dist/lib/node-esm/chunk-6JF2AHKO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs +0 -68
- package/dist/lib/node-esm/chunk-BVS2IQRO.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-NYDNXI7L.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs +0 -36
- package/dist/lib/node-esm/compute-graph-S6CVN7RS.mjs.map +0 -7
- package/dist/lib/node-esm/types.mjs +0 -17
- package/dist/lib/node-esm/types.mjs.map +0 -7
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts +0 -34
- package/dist/types/src/compute-graph/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.d.ts +0 -64
- package/dist/types/src/compute-graph/compute-graph.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.stories.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-graph.test.d.ts +0 -2
- package/dist/types/src/compute-graph/compute-graph.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/compute-node.d.ts +0 -26
- package/dist/types/src/compute-graph/compute-node.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/async-function.d.ts +0 -66
- package/dist/types/src/compute-graph/functions/async-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/edge-function.d.ts +0 -21
- package/dist/types/src/compute-graph/functions/edge-function.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/function-defs.d.ts +0 -11
- package/dist/types/src/compute-graph/functions/function-defs.d.ts.map +0 -1
- package/dist/types/src/compute-graph/functions/index.d.ts +0 -4
- package/dist/types/src/compute-graph/functions/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/hyperformula.test.d.ts +0 -2
- package/dist/types/src/compute-graph/hyperformula.test.d.ts.map +0 -1
- package/dist/types/src/compute-graph/index.d.ts +0 -5
- package/dist/types/src/compute-graph/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/index.d.ts +0 -3
- package/dist/types/src/compute-graph/testing/index.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-builder.d.ts +0 -15
- package/dist/types/src/compute-graph/testing/test-builder.d.ts.map +0 -1
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts +0 -36
- package/dist/types/src/compute-graph/testing/test-plugin.d.ts.map +0 -1
- package/dist/types/src/compute-graph/util.d.ts +0 -2
- package/dist/types/src/compute-graph/util.d.ts.map +0 -1
- package/dist/types/src/defs/index.d.ts.map +0 -1
- package/dist/types/src/defs/sheet-range-types.d.ts.map +0 -1
- package/dist/types/src/defs/types.d.ts +0 -26
- package/dist/types/src/defs/types.d.ts.map +0 -1
- package/dist/types/src/defs/types.test.d.ts +0 -2
- package/dist/types/src/defs/types.test.d.ts.map +0 -1
- package/dist/types/src/defs/util.d.ts.map +0 -1
- package/dist/types/src/types.d.ts +0 -182
- package/dist/types/src/types.d.ts.map +0 -1
- package/dist/vendor/hyperformula.mjs +0 -37145
- package/src/compute-graph/compute-graph-registry.ts +0 -90
- package/src/compute-graph/compute-graph.test.ts +0 -87
- package/src/compute-graph/compute-graph.ts +0 -260
- package/src/compute-graph/compute-node.ts +0 -62
- package/src/compute-graph/functions/async-function.ts +0 -179
- package/src/compute-graph/functions/edge-function.ts +0 -102
- package/src/compute-graph/functions/function-defs.ts +0 -2427
- package/src/compute-graph/functions/index.ts +0 -7
- package/src/compute-graph/hyperformula.test.ts +0 -14
- package/src/compute-graph/index.ts +0 -8
- package/src/compute-graph/testing/index.ts +0 -6
- package/src/compute-graph/testing/test-builder.ts +0 -54
- package/src/compute-graph/testing/test-plugin.ts +0 -100
- package/src/compute-graph/util.ts +0 -8
- package/src/defs/types.test.ts +0 -91
- package/src/defs/types.ts +0 -88
- package/src/types.ts +0 -125
- /package/dist/lib/browser/{compute-graph-SNUS7HOH.mjs.map → types/index.mjs.map} +0 -0
- /package/dist/lib/{browser/types.mjs.map → node-esm/types/index.mjs.map} +0 -0
- /package/dist/types/src/{compute-graph → components/ComputeGraph}/compute-graph.stories.d.ts +0 -0
- /package/dist/types/src/{defs → types}/sheet-range-types.d.ts +0 -0
- /package/src/{defs → types}/sheet-range-types.ts +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { effect } from '@preact/signals-core';
|
|
6
|
-
import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
|
|
7
|
-
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
8
|
-
|
|
9
|
-
import { Filter, getMeta } from '@dxos/client/echo';
|
|
10
|
-
import { log } from '@dxos/log';
|
|
11
|
-
import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
|
|
12
|
-
import { FunctionType } from '@dxos/plugin-script/types';
|
|
13
|
-
import { nonNullable } from '@dxos/util';
|
|
14
|
-
|
|
15
|
-
import { CellError, ErrorType, FunctionArgumentType } from '#hyperformula';
|
|
16
|
-
import { type AsyncFunction, AsyncFunctionPlugin } from './async-function';
|
|
17
|
-
|
|
18
|
-
export const EDGE_FUNCTION_NAME = 'DX';
|
|
19
|
-
|
|
20
|
-
const FUNCTION_TTL = 10_000;
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* A hyperformula function plugin for calling remote (EDGE) functions.
|
|
24
|
-
*
|
|
25
|
-
* https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
|
|
26
|
-
*/
|
|
27
|
-
export class EdgeFunctionPlugin extends AsyncFunctionPlugin {
|
|
28
|
-
dx(ast: ProcedureAst, state: InterpreterState) {
|
|
29
|
-
const handler =
|
|
30
|
-
(subscribe = false): AsyncFunction =>
|
|
31
|
-
async (binding: string, ...args: any) => {
|
|
32
|
-
const space = this.context.space;
|
|
33
|
-
if (!space) {
|
|
34
|
-
return new CellError(ErrorType.REF, 'Missing space');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
objects: [fn],
|
|
39
|
-
} = await space.db.query(Filter.schema(FunctionType, { binding })).run();
|
|
40
|
-
if (!fn) {
|
|
41
|
-
log.info('Function not found', { binding });
|
|
42
|
-
return new CellError(ErrorType.REF, 'Function not found');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (subscribe) {
|
|
46
|
-
const unsubscribe = effect(() => {
|
|
47
|
-
log('function changed', { fn });
|
|
48
|
-
const _ = fn?.version;
|
|
49
|
-
|
|
50
|
-
// TODO(wittjosiah): `ttl` should be 0 to force a recalculation when a new version is deployed.
|
|
51
|
-
// This needs a ttl to prevent a binding change from causing the function not to be found.
|
|
52
|
-
this.runAsyncFunction(ast, state, handler(false), { ttl: FUNCTION_TTL });
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
this.context.createSubscription(ast.procedureName, unsubscribe);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const path = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
59
|
-
const response = await fetch(`${this.context.remoteFunctionUrl}${path}`, {
|
|
60
|
-
method: 'POST',
|
|
61
|
-
headers: { 'Content-Type': 'application/json' },
|
|
62
|
-
body: JSON.stringify({ args: args.filter(nonNullable) }),
|
|
63
|
-
});
|
|
64
|
-
const result = await response.text();
|
|
65
|
-
log('function executed', { result });
|
|
66
|
-
|
|
67
|
-
return result;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
return this.runAsyncFunction(ast, state, handler(true), { ttl: FUNCTION_TTL });
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
EdgeFunctionPlugin.implementedFunctions = {
|
|
75
|
-
[EDGE_FUNCTION_NAME]: {
|
|
76
|
-
method: 'dx',
|
|
77
|
-
parameters: [
|
|
78
|
-
// Binding
|
|
79
|
-
{ argumentType: FunctionArgumentType.STRING },
|
|
80
|
-
|
|
81
|
-
// Remote function arguments (currently supporting up to 8).
|
|
82
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
83
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
84
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
85
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
86
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
87
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
88
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
89
|
-
{ argumentType: FunctionArgumentType.ANY, optionalArg: true },
|
|
90
|
-
],
|
|
91
|
-
isVolatile: true,
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export const EdgeFunctionPluginTranslations = {
|
|
96
|
-
enGB: {
|
|
97
|
-
[EDGE_FUNCTION_NAME]: 'Remote function',
|
|
98
|
-
},
|
|
99
|
-
enUS: {
|
|
100
|
-
[EDGE_FUNCTION_NAME]: 'Remote function',
|
|
101
|
-
},
|
|
102
|
-
};
|