@dxos/plugin-sheet 0.6.8-main.3be982f → 0.6.8-staging.63bcb81
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-6K3XOBZ7.mjs +1765 -0
- package/dist/lib/browser/SheetContainer-6K3XOBZ7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-6VPEAUG6.mjs → chunk-D3PUKBH6.mjs} +1 -1
- package/dist/lib/browser/{chunk-6VPEAUG6.mjs.map → chunk-D3PUKBH6.mjs.map} +1 -1
- package/dist/lib/browser/chunk-MJOFSXLS.mjs +3251 -0
- package/dist/lib/browser/chunk-MJOFSXLS.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +82 -6
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/types.mjs +1 -1
- package/dist/lib/node/SheetContainer-QWNOHX7P.cjs +1759 -0
- package/dist/lib/node/SheetContainer-QWNOHX7P.cjs.map +7 -0
- package/dist/lib/node/chunk-3AINF7RX.cjs +3275 -0
- package/dist/lib/node/chunk-3AINF7RX.cjs.map +7 -0
- package/dist/lib/node/{chunk-4CE6FK5Z.cjs → chunk-3R3J7IZR.cjs} +4 -4
- package/dist/lib/node/{chunk-4CE6FK5Z.cjs.map → chunk-3R3J7IZR.cjs.map} +1 -1
- package/dist/lib/node/index.cjs +84 -15
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- 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/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +2 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/async-function.d.ts +4 -2
- package/dist/types/src/components/ComputeGraph/async-function.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 +2 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +9 -4
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -1
- package/dist/types/src/components/ComputeGraph/index.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/Sheet/sheet-context.d.ts +3 -2
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/model/functions.d.ts +11 -0
- package/dist/types/src/model/functions.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +1 -0
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/model.d.ts +25 -2
- package/dist/types/src/model/model.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +28 -30
- package/src/SheetPlugin.tsx +26 -3
- package/src/components/CellEditor/CellEditor.stories.tsx +5 -2
- package/src/components/CellEditor/extension.test.ts +3 -1
- package/src/components/CellEditor/extension.ts +6 -13
- package/src/components/ComputeGraph/async-function.ts +10 -1
- package/src/components/ComputeGraph/edge-function.ts +8 -9
- package/src/components/ComputeGraph/graph-context.tsx +6 -2
- package/src/components/ComputeGraph/graph.browser.test.ts +3 -2
- package/src/components/ComputeGraph/graph.ts +22 -12
- package/src/components/ComputeGraph/index.ts +1 -1
- package/src/components/Sheet/Sheet.stories.tsx +3 -7
- package/src/components/Sheet/Sheet.tsx +7 -5
- package/src/components/Sheet/sheet-context.tsx +55 -6
- package/src/model/functions.ts +2427 -0
- package/src/model/index.ts +1 -0
- package/src/model/model.browser.test.ts +1 -1
- package/src/model/model.ts +77 -6
- package/src/types.ts +1 -1
- package/dist/lib/browser/SheetContainer-H22IDJ43.mjs +0 -3740
- package/dist/lib/browser/SheetContainer-H22IDJ43.mjs.map +0 -7
- package/dist/lib/browser/chunk-AT2FJXQX.mjs +0 -861
- package/dist/lib/browser/chunk-AT2FJXQX.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-S32KTNZ6.cjs +0 -3731
- package/dist/lib/node/SheetContainer-S32KTNZ6.cjs.map +0 -7
- package/dist/lib/node/chunk-FCKJ4QRM.cjs +0 -881
- package/dist/lib/node/chunk-FCKJ4QRM.cjs.map +0 -7
- package/dist/types/src/components/CellEditor/functions.d.ts +0 -66
- package/dist/types/src/components/CellEditor/functions.d.ts.map +0 -1
- package/src/components/CellEditor/functions.ts +0 -2017
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import { HyperFormula } from 'hyperformula';
|
|
1
|
+
import { type FunctionPluginDefinition, HyperFormula } from 'hyperformula';
|
|
2
|
+
import { type FunctionTranslationsPackage } from 'hyperformula/typings/interpreter';
|
|
2
3
|
import { Event } from '@dxos/async';
|
|
3
4
|
import { type Space } from '@dxos/client/echo';
|
|
4
|
-
import { FunctionContext } from './async-function';
|
|
5
|
+
import { FunctionContext, type FunctionContextOptions } from './async-function';
|
|
5
6
|
/**
|
|
6
7
|
* Create root graph for space.
|
|
7
8
|
*/
|
|
8
|
-
export declare const createComputeGraph: (
|
|
9
|
+
export declare const createComputeGraph: (functionPlugins?: {
|
|
10
|
+
plugin: FunctionPluginDefinition;
|
|
11
|
+
translations: FunctionTranslationsPackage;
|
|
12
|
+
}[], space?: Space, options?: Partial<FunctionContextOptions>) => ComputeGraph;
|
|
9
13
|
/**
|
|
10
14
|
* Per-space compute and dependency graph.
|
|
11
15
|
*/
|
|
12
16
|
export declare class ComputeGraph {
|
|
13
17
|
readonly hf: HyperFormula;
|
|
14
18
|
private readonly _space?;
|
|
19
|
+
private readonly _options?;
|
|
15
20
|
readonly id: string;
|
|
16
21
|
readonly update: Event<void>;
|
|
17
22
|
readonly context: FunctionContext;
|
|
18
|
-
constructor(hf: HyperFormula, _space?: Space | undefined);
|
|
23
|
+
constructor(hf: HyperFormula, _space?: Space | undefined, _options?: Partial<FunctionContextOptions> | undefined);
|
|
19
24
|
refresh(): void;
|
|
20
25
|
}
|
|
21
26
|
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../../src/components/ComputeGraph/graph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../../../../src/components/ComputeGraph/graph.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,wBAAwB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAEpF,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAI/C,OAAO,EAAE,eAAe,EAAE,KAAK,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,kBAAkB,qBAEZ;IAAE,MAAM,EAAE,wBAAwB,CAAC;IAAC,YAAY,EAAE,2BAA2B,CAAA;CAAE,EAAE,UAC1F,KAAK,YACH,OAAO,CAAC,sBAAsB,CAAC,KACxC,YAOF,CAAC;AAEF;;GAEG;AAEH,qBAAa,YAAY;aAeL,EAAE,EAAE,YAAY;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAhB5B,SAAgB,EAAE,SAA4C;IAC9D,SAAgB,MAAM,cAAe;IAGrC,SAAgB,OAAO,kBAOrB;gBAGgB,EAAE,EAAE,YAAY,EACf,MAAM,CAAC,EAAE,KAAK,YAAA,EACd,QAAQ,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,YAAA;IAK7D,OAAO;CAIR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ComputeGraph/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/ComputeGraph/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EACZ,KAAK,aAAa,EAElB,KAAK,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/Sheet.tsx"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,EACZ,KAAK,aAAa,EAElB,KAAK,iBAAiB,EAOvB,MAAM,OAAO,CAAC;AAOf,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAItD,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,OAAO,EAYb,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,KAAK,QAAQ,EAA6C,MAAM,OAAO,CAAC;AACjF,OAAO,EAAE,KAAK,iBAAiB,EAAyC,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EACL,KAAK,SAAS,EACd,KAAK,WAAW,EAKjB,MAAM,aAAa,CAAC;AAyDrB,KAAK,cAAc,GAAG,iBAAiB,CAAC;AAUxC,KAAK,cAAc,GAAG,eAAe,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;AA4NzD,KAAK,WAAW,GAAG;IACjB,KAAK,CA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AAc,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sheet.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/Sheet.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAA0C,MAAM,OAAO,CAAC;AAW/D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Sheet.stories.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/Sheet.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,YAAY,CAAC;AAEpB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,KAA0C,MAAM,OAAO,CAAC;AAW/D,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;;;;;;;;;;;;;;;gFAmT07D,CAAC;;;;;;;;;;;gFAAD,CAAC;;;;;;;;;;;;;AA1Mj+D,wBAIE;AAEF,eAAO,MAAM,OAAO,gCAenB,CAAC;AAEF,eAAO,MAAM,KAAK,gCAajB,CAAC;AAEF,eAAO,MAAM,IAAI,gCAiBhB,CAAC;AAEF,eAAO,MAAM,OAAO,gCAiBnB,CAAC;AAEF,eAAO,MAAM,IAAI,gCAqBhB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,yBAkBxB,CAAC;AAEF,eAAO,MAAM,UAAU,yBActB,CAAC"}
|
|
@@ -3,6 +3,7 @@ import { type Space } from '@dxos/react-client/echo';
|
|
|
3
3
|
import { FormattingModel } from './formatting';
|
|
4
4
|
import { type CellAddress, type CellRange, SheetModel } from '../../model';
|
|
5
5
|
import { type SheetType } from '../../types';
|
|
6
|
+
import { type FunctionContextOptions } from '../ComputeGraph';
|
|
6
7
|
export type SheetContextType = {
|
|
7
8
|
model: SheetModel;
|
|
8
9
|
formatting: FormattingModel;
|
|
@@ -19,6 +20,6 @@ export type SheetContextProps = {
|
|
|
19
20
|
sheet: SheetType;
|
|
20
21
|
space: Space;
|
|
21
22
|
readonly?: boolean;
|
|
22
|
-
} & Pick<SheetContextType, 'onInfo'>;
|
|
23
|
-
export declare const SheetContextProvider: ({ children, sheet, space, readonly, onInfo, }: PropsWithChildren<SheetContextProps>) => React.JSX.Element | null;
|
|
23
|
+
} & Pick<SheetContextType, 'onInfo'> & Partial<FunctionContextOptions>;
|
|
24
|
+
export declare const SheetContextProvider: ({ children, sheet, space, readonly, onInfo, ...options }: PropsWithChildren<SheetContextProps>) => React.JSX.Element | null;
|
|
24
25
|
//# sourceMappingURL=sheet-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-context.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/sheet-context.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAkD,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sheet-context.d.ts","sourceRoot":"","sources":["../../../../../src/components/Sheet/sheet-context.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,EAAE,KAAK,iBAAiB,EAAkD,MAAM,OAAO,CAAC;AAItG,OAAO,EAAoB,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAEvE,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,SAAS,EAAoB,UAAU,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAO9D,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,eAAe,CAAC;IAI5B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,KAAK,IAAI,CAAC;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IAGjD,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAIvC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAIF,eAAO,MAAM,eAAe,QAAO,gBAIlC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GAAG,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAClC,OAAO,CAAC,sBAAsB,CAAC,CAAC;AA2ClC,eAAO,MAAM,oBAAoB,6DAO9B,iBAAiB,CAAC,iBAAiB,CAAC,6BA8CtC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type FunctionDefinition = {
|
|
2
|
+
name: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
syntax?: string;
|
|
5
|
+
section?: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* nullDate {year: 1899, month: 12, day: 30}
|
|
9
|
+
*/
|
|
10
|
+
export declare const defaultFunctions: FunctionDefinition[];
|
|
11
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../../src/model/functions.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,EA42EhD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/model/index.ts"],"names":[],"mappings":"AAIA,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/model/index.ts"],"names":[],"mappings":"AAIA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type SimpleDate, type SimpleDateTime } from 'hyperformula/typings/DateTimeHelper';
|
|
2
2
|
import { Event } from '@dxos/async';
|
|
3
|
+
import { type Space } from '@dxos/client/echo';
|
|
4
|
+
import { type FunctionType } from '@dxos/plugin-script/types';
|
|
5
|
+
import { type FunctionDefinition } from './functions';
|
|
3
6
|
import { type CellAddress, type CellRange } from './types';
|
|
4
7
|
import { type ComputeGraph } from '../components';
|
|
5
8
|
import { type CellScalarValue, type CellValue, type SheetType, ValueTypeEnum } from '../types';
|
|
@@ -9,6 +12,8 @@ export type SheetModelOptions = {
|
|
|
9
12
|
readonly?: boolean;
|
|
10
13
|
rows: number;
|
|
11
14
|
columns: number;
|
|
15
|
+
mapFormulaBindingToId: (functions: FunctionType[]) => (formula: string) => string;
|
|
16
|
+
mapFormulaBindingFromId: (functions: FunctionType[]) => (formula: string) => string;
|
|
12
17
|
};
|
|
13
18
|
export declare const defaultOptions: SheetModelOptions;
|
|
14
19
|
/**
|
|
@@ -19,6 +24,7 @@ export declare const defaultOptions: SheetModelOptions;
|
|
|
19
24
|
export declare class SheetModel {
|
|
20
25
|
private readonly _graph;
|
|
21
26
|
private readonly _sheet;
|
|
27
|
+
private readonly _space?;
|
|
22
28
|
readonly id: string;
|
|
23
29
|
private _ctx?;
|
|
24
30
|
/**
|
|
@@ -27,8 +33,9 @@ export declare class SheetModel {
|
|
|
27
33
|
*/
|
|
28
34
|
private readonly _sheetId;
|
|
29
35
|
private readonly _options;
|
|
36
|
+
private _functions;
|
|
30
37
|
readonly update: Event<void>;
|
|
31
|
-
constructor(_graph: ComputeGraph, _sheet: SheetType, options?: Partial<SheetModelOptions>);
|
|
38
|
+
constructor(_graph: ComputeGraph, _sheet: SheetType, _space?: Space | undefined, options?: Partial<SheetModelOptions>);
|
|
32
39
|
get graph(): ComputeGraph;
|
|
33
40
|
get sheet(): SheetType;
|
|
34
41
|
get readonly(): boolean | undefined;
|
|
@@ -36,7 +43,7 @@ export declare class SheetModel {
|
|
|
36
43
|
rows: number;
|
|
37
44
|
columns: number;
|
|
38
45
|
};
|
|
39
|
-
get functions():
|
|
46
|
+
get functions(): FunctionDefinition[];
|
|
40
47
|
get initialized(): boolean;
|
|
41
48
|
/**
|
|
42
49
|
* Initialize sheet and engine.
|
|
@@ -121,6 +128,22 @@ export declare class SheetModel {
|
|
|
121
128
|
* E.g., "x1@y1:x2@y2" => "A1:B2".
|
|
122
129
|
*/
|
|
123
130
|
rangeFromIndex(idx: string): CellRange;
|
|
131
|
+
/**
|
|
132
|
+
* E.g., "HELLO()" => "EDGE("HELLO")".
|
|
133
|
+
*/
|
|
134
|
+
mapFormulaBindingToFormula(formula: string): string;
|
|
135
|
+
/**
|
|
136
|
+
* E.g., "EDGE("HELLO")" => "HELLO()".
|
|
137
|
+
*/
|
|
138
|
+
mapFormulaBindingFromFormula(formula: string): string;
|
|
139
|
+
/**
|
|
140
|
+
* Map from binding to fully qualified ECHO ID.
|
|
141
|
+
*/
|
|
142
|
+
mapFormulaBindingToId(formula: string): string;
|
|
143
|
+
/**
|
|
144
|
+
* Map from fully qualified ECHO ID to binding.
|
|
145
|
+
*/
|
|
146
|
+
mapFormulaBindingFromId(formula: string): string;
|
|
124
147
|
/**
|
|
125
148
|
* Map from A1 notation to indices.
|
|
126
149
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/model/model.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/model/model.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAK/C,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,OAAO,EAAoB,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAA8C,KAAK,WAAW,EAAE,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAEvG,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAM/F,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IAClF,uBAAuB,EA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WhD;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK9B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAIvC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAI/B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAGhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GraphBuilderProvides, IntentResolverProvides, MetadataRecordsProvides, SurfaceProvides, TranslationsProvides } from '@dxos/app-framework';
|
|
2
2
|
import { S } from '@dxos/echo-schema';
|
|
3
3
|
import { type SchemaProvides } from '@dxos/plugin-client';
|
|
4
|
-
import type
|
|
4
|
+
import { type StackProvides } from '@dxos/plugin-stack';
|
|
5
5
|
export declare enum SheetAction {
|
|
6
6
|
CREATE = "dxos.org/plugin/sheet/action/create"
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAU,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAU,CAAC,EAAe,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAMxD,oBAAY,WAAW;IACrB,MAAM,wCAA2B;CAClC;AAED,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAC/C,sBAAsB,GACtB,oBAAoB,GACpB,uBAAuB,GACvB,oBAAoB,GACpB,cAAc,GACd,aAAa,CAAC;AAEhB,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAE/D,eAAO,MAAM,SAAS;;EAMpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,SAAS,CAAC,CAAC;AAExD;;GAEG;AAEH,oBAAY,aAAa;IACvB,IAAI,IAAI;IACR,MAAM,IAAI;IACV,OAAO,IAAI;IACX,MAAM,IAAI;IAGV,OAAO,KAAK;IACZ,QAAQ,KAAK;IAGb,QAAQ,KAAK;IACb,IAAI,KAAK;IACT,IAAI,KAAK;IAIT,GAAG,KAAK;IACR,GAAG,KAAK;CACT;AAED,eAAO,MAAM,SAAS,+BAAyB,CAAC;AAEhD,eAAO,MAAM,UAAU;;;;;EAKrB,CAAC;AAEH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,UAAU,CAAC,CAAC;AAG1D,eAAO,MAAM,aAAa;;EAExB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,qBAAa,SAAU,SAAQ,cAoB7B;CAAG;AAGL,eAAO,MAAM,WAAW,WAAY,MAAM,KAAG,SACgE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.6.8-
|
|
3
|
+
"version": "0.6.8-staging.63bcb81",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -63,55 +63,53 @@
|
|
|
63
63
|
"codemirror-lang-spreadsheet": "^1.3.0",
|
|
64
64
|
"hyperformula": "^2.7.1",
|
|
65
65
|
"lodash.defaultsdeep": "^4.6.1",
|
|
66
|
-
"lodash.get": "^4.4.2",
|
|
67
66
|
"re-resizable": "^6.9.17",
|
|
68
67
|
"react-markdown": "^8.0.5",
|
|
69
68
|
"react-resize-detector": "^11.0.1",
|
|
70
|
-
"@dxos/app-framework": "0.6.8-
|
|
71
|
-
"@dxos/
|
|
72
|
-
"@dxos/
|
|
73
|
-
"@dxos/
|
|
74
|
-
"@dxos/crypto": "0.6.8-
|
|
75
|
-
"@dxos/debug": "0.6.8-
|
|
76
|
-
"@dxos/echo-schema": "0.6.8-
|
|
77
|
-
"@dxos/invariant": "0.6.8-
|
|
78
|
-
"@dxos/keys": "0.6.8-
|
|
79
|
-
"@dxos/
|
|
80
|
-
"@dxos/
|
|
81
|
-
"@dxos/plugin-
|
|
82
|
-
"@dxos/plugin-
|
|
83
|
-
"@dxos/plugin-space": "0.6.8-
|
|
84
|
-
"@dxos/plugin-stack": "0.6.8-
|
|
85
|
-
"@dxos/react-client": "0.6.8-
|
|
86
|
-
"@dxos/react-ui-attention": "0.6.8-
|
|
87
|
-
"@dxos/react-ui-editor": "0.6.8-
|
|
88
|
-
"@dxos/util": "0.6.8-
|
|
69
|
+
"@dxos/app-framework": "0.6.8-staging.63bcb81",
|
|
70
|
+
"@dxos/context": "0.6.8-staging.63bcb81",
|
|
71
|
+
"@dxos/async": "0.6.8-staging.63bcb81",
|
|
72
|
+
"@dxos/client": "0.6.8-staging.63bcb81",
|
|
73
|
+
"@dxos/crypto": "0.6.8-staging.63bcb81",
|
|
74
|
+
"@dxos/debug": "0.6.8-staging.63bcb81",
|
|
75
|
+
"@dxos/echo-schema": "0.6.8-staging.63bcb81",
|
|
76
|
+
"@dxos/invariant": "0.6.8-staging.63bcb81",
|
|
77
|
+
"@dxos/keys": "0.6.8-staging.63bcb81",
|
|
78
|
+
"@dxos/plugin-client": "0.6.8-staging.63bcb81",
|
|
79
|
+
"@dxos/log": "0.6.8-staging.63bcb81",
|
|
80
|
+
"@dxos/plugin-graph": "0.6.8-staging.63bcb81",
|
|
81
|
+
"@dxos/plugin-script": "0.6.8-staging.63bcb81",
|
|
82
|
+
"@dxos/plugin-space": "0.6.8-staging.63bcb81",
|
|
83
|
+
"@dxos/plugin-stack": "0.6.8-staging.63bcb81",
|
|
84
|
+
"@dxos/react-client": "0.6.8-staging.63bcb81",
|
|
85
|
+
"@dxos/react-ui-attention": "0.6.8-staging.63bcb81",
|
|
86
|
+
"@dxos/react-ui-editor": "0.6.8-staging.63bcb81",
|
|
87
|
+
"@dxos/util": "0.6.8-staging.63bcb81"
|
|
89
88
|
},
|
|
90
89
|
"devDependencies": {
|
|
91
90
|
"@lezer/generator": "^1.7.1",
|
|
92
91
|
"@phosphor-icons/react": "^2.1.5",
|
|
93
92
|
"@tldraw/indices": "^2.0.0-alpha.14",
|
|
94
93
|
"@types/lodash.defaultsdeep": "^4.6.6",
|
|
95
|
-
"@types/lodash.get": "^4.4.7",
|
|
96
94
|
"@types/react": "~18.2.0",
|
|
97
95
|
"@types/react-dom": "~18.2.0",
|
|
98
96
|
"@types/react-window": "^1.8.8",
|
|
99
97
|
"react": "~18.2.0",
|
|
100
98
|
"react-dom": "~18.2.0",
|
|
101
99
|
"vite": "^5.3.4",
|
|
102
|
-
"@dxos/echo-generator": "0.6.8-
|
|
103
|
-
"@dxos/random": "0.6.8-
|
|
104
|
-
"@dxos/react-ui": "0.6.8-
|
|
105
|
-
"@dxos/react-ui-theme": "0.6.8-
|
|
106
|
-
"@dxos/
|
|
107
|
-
"@dxos/
|
|
100
|
+
"@dxos/echo-generator": "0.6.8-staging.63bcb81",
|
|
101
|
+
"@dxos/random": "0.6.8-staging.63bcb81",
|
|
102
|
+
"@dxos/react-ui": "0.6.8-staging.63bcb81",
|
|
103
|
+
"@dxos/react-ui-theme": "0.6.8-staging.63bcb81",
|
|
104
|
+
"@dxos/storybook-utils": "0.6.8-staging.63bcb81",
|
|
105
|
+
"@dxos/react-ui-types": "0.6.8-staging.63bcb81"
|
|
108
106
|
},
|
|
109
107
|
"optionalDependencies": {
|
|
110
108
|
"@phosphor-icons/react": "^2.1.5",
|
|
111
109
|
"react": "^18.0.0",
|
|
112
110
|
"react-dom": "^18.0.0",
|
|
113
|
-
"@dxos/react-ui": "0.6.8-
|
|
114
|
-
"@dxos/react-ui-theme": "0.6.8-
|
|
111
|
+
"@dxos/react-ui": "0.6.8-staging.63bcb81",
|
|
112
|
+
"@dxos/react-ui-theme": "0.6.8-staging.63bcb81"
|
|
115
113
|
},
|
|
116
114
|
"publishConfig": {
|
|
117
115
|
"access": "public"
|
package/src/SheetPlugin.tsx
CHANGED
|
@@ -15,16 +15,22 @@ import {
|
|
|
15
15
|
import { create } from '@dxos/echo-schema';
|
|
16
16
|
import { parseClientPlugin } from '@dxos/plugin-client';
|
|
17
17
|
import { type ActionGroup, createExtension, isActionGroup } from '@dxos/plugin-graph';
|
|
18
|
+
import { FunctionType } from '@dxos/plugin-script/types';
|
|
18
19
|
import { SpaceAction } from '@dxos/plugin-space';
|
|
19
20
|
import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
20
21
|
|
|
21
|
-
import {
|
|
22
|
+
import { createComputeGraph, SheetContainer, type ComputeGraph } from './components';
|
|
23
|
+
// TODO(wittjosiah): Refactor. These are not exported from ./components due to depending on ECHO.
|
|
24
|
+
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './components/ComputeGraph/edge-function';
|
|
25
|
+
import { ComputeGraphContextProvider } from './components/ComputeGraph/graph-context';
|
|
22
26
|
import meta, { SHEET_PLUGIN } from './meta';
|
|
23
27
|
import { SheetModel } from './model';
|
|
24
28
|
import translations from './translations';
|
|
25
29
|
import { createSheet, SheetAction, type SheetPluginProvides, SheetType } from './types';
|
|
26
30
|
|
|
27
31
|
export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
32
|
+
let remoteFunctionUrl: string | undefined;
|
|
33
|
+
|
|
28
34
|
const graphs = create<Record<string, ComputeGraph>>({});
|
|
29
35
|
const setGraph = (key: string, graph: ComputeGraph) => {
|
|
30
36
|
graphs[key] = graph;
|
|
@@ -32,6 +38,14 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
32
38
|
|
|
33
39
|
return {
|
|
34
40
|
meta,
|
|
41
|
+
ready: async (plugins) => {
|
|
42
|
+
const client = resolvePlugin(plugins, parseClientPlugin)?.provides.client;
|
|
43
|
+
if (!client) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
remoteFunctionUrl = client.config.values.runtime?.app?.env?.DX_FUNCTIONS_SERVICE_HOST;
|
|
48
|
+
},
|
|
35
49
|
provides: {
|
|
36
50
|
context: ({ children }) => {
|
|
37
51
|
return (
|
|
@@ -51,7 +65,9 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
51
65
|
},
|
|
52
66
|
translations,
|
|
53
67
|
echo: {
|
|
54
|
-
|
|
68
|
+
// TODO(wittjosiah): Factor out to common package/plugin.
|
|
69
|
+
// FunctionType is currently registered here in case script plugin isn't enabled.
|
|
70
|
+
schema: [SheetType, FunctionType],
|
|
55
71
|
},
|
|
56
72
|
graph: {
|
|
57
73
|
builder: (plugins) => {
|
|
@@ -126,6 +142,7 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
126
142
|
space={space}
|
|
127
143
|
role={role}
|
|
128
144
|
coordinate={data.coordinate as LayoutCoordinate}
|
|
145
|
+
remoteFunctionUrl={remoteFunctionUrl}
|
|
129
146
|
/>
|
|
130
147
|
) : null;
|
|
131
148
|
},
|
|
@@ -136,7 +153,13 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
136
153
|
case SheetAction.CREATE: {
|
|
137
154
|
const space = intent.data?.space;
|
|
138
155
|
const sheet = createSheet();
|
|
139
|
-
const graph =
|
|
156
|
+
const graph =
|
|
157
|
+
graphs[space.id] ??
|
|
158
|
+
createComputeGraph(
|
|
159
|
+
[{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations }],
|
|
160
|
+
space,
|
|
161
|
+
{ remoteFunctionUrl },
|
|
162
|
+
);
|
|
140
163
|
const model = new SheetModel(graph, sheet);
|
|
141
164
|
await model.initialize();
|
|
142
165
|
await model.destroy();
|
|
@@ -14,6 +14,7 @@ import { withTheme } from '@dxos/storybook-utils';
|
|
|
14
14
|
|
|
15
15
|
import { CellEditor, type CellEditorProps } from './CellEditor';
|
|
16
16
|
import { sheetExtension } from './extension';
|
|
17
|
+
import { defaultFunctions } from '../../model';
|
|
17
18
|
import { createSheet, SheetType } from '../../types';
|
|
18
19
|
|
|
19
20
|
export default {
|
|
@@ -27,7 +28,8 @@ type StoryProps = CellEditorProps;
|
|
|
27
28
|
|
|
28
29
|
const Story = ({ value, ...props }: StoryProps) => {
|
|
29
30
|
const extension = useMemo(() => {
|
|
30
|
-
const
|
|
31
|
+
const functionNames = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' }).getRegisteredFunctionNames();
|
|
32
|
+
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
31
33
|
return [sheetExtension({ functions })];
|
|
32
34
|
}, []);
|
|
33
35
|
|
|
@@ -58,7 +60,8 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
58
60
|
return [];
|
|
59
61
|
}
|
|
60
62
|
|
|
61
|
-
const
|
|
63
|
+
const functionNames = HyperFormula.buildEmpty({ licenseKey: 'gpl-v3' }).getRegisteredFunctionNames();
|
|
64
|
+
const functions = defaultFunctions.filter(({ name }) => functionNames.includes(name));
|
|
62
65
|
const accessor = createDocAccessor(object, ['cells', cell, 'value']);
|
|
63
66
|
return [automerge(accessor), sheetExtension({ functions })];
|
|
64
67
|
}, [object]);
|
|
@@ -11,6 +11,7 @@ import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
|
11
11
|
import { describe, test } from 'vitest';
|
|
12
12
|
|
|
13
13
|
import { sheetExtension } from './extension';
|
|
14
|
+
import { defaultFunctions } from '../../model/functions';
|
|
14
15
|
|
|
15
16
|
describe('formula parser', () => {
|
|
16
17
|
const {
|
|
@@ -29,10 +30,11 @@ describe('formula parser', () => {
|
|
|
29
30
|
|
|
30
31
|
test('autocomplete', async () => {
|
|
31
32
|
const text = '=SUM';
|
|
33
|
+
const functions = defaultFunctions.filter((fn) => ['ABS', 'SUM'].includes(fn.name));
|
|
32
34
|
const state = EditorState.create({
|
|
33
35
|
doc: text,
|
|
34
36
|
selection: { anchor: 0 },
|
|
35
|
-
extensions: sheetExtension({ functions
|
|
37
|
+
extensions: sheetExtension({ functions }),
|
|
36
38
|
});
|
|
37
39
|
|
|
38
40
|
const [f] = state.languageDataAt<CompletionSource>('autocomplete', text.length);
|
|
@@ -20,7 +20,7 @@ import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
|
20
20
|
|
|
21
21
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
22
|
|
|
23
|
-
import {
|
|
23
|
+
import { type FunctionDefinition } from '../../model';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* https://codemirror.net/examples/styling
|
|
@@ -62,7 +62,7 @@ const highlightStyles = HighlightStyle.define([
|
|
|
62
62
|
const languageFacet = Facet.define<Language>();
|
|
63
63
|
|
|
64
64
|
export type SheetExtensionOptions = {
|
|
65
|
-
functions?:
|
|
65
|
+
functions?: FunctionDefinition[];
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
/**
|
|
@@ -72,19 +72,11 @@ export type SheetExtensionOptions = {
|
|
|
72
72
|
* https://github.com/codemirror/lang-example
|
|
73
73
|
* https://hyperformula.handsontable.com/guide/key-concepts.html#grammar
|
|
74
74
|
*/
|
|
75
|
-
export const sheetExtension = ({ functions }: SheetExtensionOptions): Extension => {
|
|
75
|
+
export const sheetExtension = ({ functions = [] }: SheetExtensionOptions): Extension => {
|
|
76
76
|
const { extension, language } = spreadsheet({ idiom: 'en-US', decimalSeparator: '.' });
|
|
77
77
|
|
|
78
|
-
// Parse functions.
|
|
79
|
-
const functionInfo = Object.entries(functionDefs).reduce((map, [section, values]) => {
|
|
80
|
-
values.forEach(({ function: id, ...props }) => {
|
|
81
|
-
map.set(id, { function: id, ...props, section });
|
|
82
|
-
});
|
|
83
|
-
return map;
|
|
84
|
-
}, new Map());
|
|
85
|
-
|
|
86
78
|
const createCompletion = (name: string) => {
|
|
87
|
-
const { section, description, syntax } =
|
|
79
|
+
const { section = 'Custom', description, syntax } = functions.find((value) => value.name === name) ?? {};
|
|
88
80
|
|
|
89
81
|
return {
|
|
90
82
|
section,
|
|
@@ -157,7 +149,8 @@ export const sheetExtension = ({ functions }: SheetExtensionOptions): Extension
|
|
|
157
149
|
|
|
158
150
|
return {
|
|
159
151
|
from: match.from,
|
|
160
|
-
options:
|
|
152
|
+
options:
|
|
153
|
+
functions?.filter(({ name }) => name.startsWith(text)).map(({ name }) => createCompletion(name)) ?? [],
|
|
161
154
|
};
|
|
162
155
|
},
|
|
163
156
|
}),
|
|
@@ -6,6 +6,7 @@ import { CellError, ErrorType, EmptyValue, FunctionPlugin, type HyperFormula } f
|
|
|
6
6
|
import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
|
|
7
7
|
import { type InterpreterValue } from 'hyperformula/typings/interpreter/InterpreterValue';
|
|
8
8
|
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
9
|
+
import defaultsDeep from 'lodash.defaultsdeep';
|
|
9
10
|
|
|
10
11
|
import { debounce } from '@dxos/async';
|
|
11
12
|
import { type Space } from '@dxos/client/echo';
|
|
@@ -27,11 +28,13 @@ export type FunctionOptions = {
|
|
|
27
28
|
export type FunctionContextOptions = {
|
|
28
29
|
defaultTtl: number;
|
|
29
30
|
recalculationDelay: number;
|
|
31
|
+
remoteFunctionUrl: string;
|
|
30
32
|
};
|
|
31
33
|
|
|
32
34
|
export const defaultFunctionContextOptions: FunctionContextOptions = {
|
|
33
35
|
defaultTtl: 5_000,
|
|
34
36
|
recalculationDelay: 200,
|
|
37
|
+
remoteFunctionUrl: 'https://functions-staging.dxos.workers.dev',
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
/**
|
|
@@ -57,14 +60,16 @@ export class FunctionContext {
|
|
|
57
60
|
// Invocation count.
|
|
58
61
|
private _invocations: Record<string, number> = {};
|
|
59
62
|
|
|
63
|
+
private readonly _options: FunctionContextOptions;
|
|
60
64
|
private readonly _onUpdate: () => void;
|
|
61
65
|
|
|
62
66
|
constructor(
|
|
63
67
|
private readonly _hf: HyperFormula,
|
|
64
68
|
private readonly _space: Space | undefined,
|
|
65
69
|
onUpdate: (context: FunctionContext) => void,
|
|
66
|
-
|
|
70
|
+
_options?: Partial<FunctionContextOptions>,
|
|
67
71
|
) {
|
|
72
|
+
this._options = defaultsDeep(_options ?? {}, defaultFunctionContextOptions);
|
|
68
73
|
this._onUpdate = debounce(() => {
|
|
69
74
|
// TODO(burdon): Better way to trigger recalculation?
|
|
70
75
|
// NOTE: rebuildAndRecalculate resets the undo history.
|
|
@@ -77,6 +82,10 @@ export class FunctionContext {
|
|
|
77
82
|
return this._space;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
get remoteFunctionUrl() {
|
|
86
|
+
return this._options.remoteFunctionUrl;
|
|
87
|
+
}
|
|
88
|
+
|
|
80
89
|
get info() {
|
|
81
90
|
return { cache: this._cache.size, invocations: this._invocations };
|
|
82
91
|
}
|
|
@@ -8,7 +8,7 @@ import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
|
8
8
|
|
|
9
9
|
import { Filter, getMeta } from '@dxos/client/echo';
|
|
10
10
|
import { getUserFunctionUrlInMetadata } from '@dxos/plugin-script/edge';
|
|
11
|
-
import {
|
|
11
|
+
import { FunctionType } from '@dxos/plugin-script/types';
|
|
12
12
|
|
|
13
13
|
import { type AsyncFunction, FunctionPluginAsync } from './async-function';
|
|
14
14
|
|
|
@@ -22,19 +22,18 @@ export class EdgeFunctionPlugin extends FunctionPluginAsync {
|
|
|
22
22
|
const handler: AsyncFunction = async (binding: string) => {
|
|
23
23
|
const space = this.context.space;
|
|
24
24
|
if (!space) {
|
|
25
|
-
return new CellError(ErrorType.
|
|
25
|
+
return new CellError(ErrorType.REF, 'Missing space');
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
const {
|
|
29
|
-
objects: [
|
|
30
|
-
} = await space.db.query(Filter.schema(
|
|
31
|
-
if (!
|
|
32
|
-
return new CellError(ErrorType.
|
|
29
|
+
objects: [fn],
|
|
30
|
+
} = await space.db.query(Filter.schema(FunctionType, { binding })).run();
|
|
31
|
+
if (!fn) {
|
|
32
|
+
return new CellError(ErrorType.REF, 'Function not found');
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const path = getUserFunctionUrlInMetadata(getMeta(
|
|
36
|
-
|
|
37
|
-
const result = await fetch(`https://functions-staging.dxos.workers.dev${path}`, { method: 'POST' });
|
|
35
|
+
const path = getUserFunctionUrlInMetadata(getMeta(fn));
|
|
36
|
+
const result = await fetch(`${this.context.remoteFunctionUrl}${path}`, { method: 'POST' });
|
|
38
37
|
return await result.text();
|
|
39
38
|
};
|
|
40
39
|
|
|
@@ -6,6 +6,8 @@ import React, { createContext, type PropsWithChildren, useContext, useEffect } f
|
|
|
6
6
|
|
|
7
7
|
import { type Space } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
|
+
import { type FunctionContextOptions } from './async-function';
|
|
10
|
+
import { EdgeFunctionPlugin, EdgeFunctionPluginTranslations } from './edge-function';
|
|
9
11
|
import { createComputeGraph, type ComputeGraph } from './graph';
|
|
10
12
|
|
|
11
13
|
export type ComputeGraphContextType = {
|
|
@@ -23,9 +25,11 @@ export const ComputeGraphContextProvider = ({
|
|
|
23
25
|
return <ComputeGraphContext.Provider value={{ graphs, setGraph }}>{children}</ComputeGraphContext.Provider>;
|
|
24
26
|
};
|
|
25
27
|
|
|
26
|
-
export const useComputeGraph = (space: Space): ComputeGraph => {
|
|
28
|
+
export const useComputeGraph = (space: Space, options?: Partial<FunctionContextOptions>): ComputeGraph => {
|
|
27
29
|
const { graphs, setGraph } = useContext(ComputeGraphContext);
|
|
28
|
-
const graph =
|
|
30
|
+
const graph =
|
|
31
|
+
graphs[space.id] ??
|
|
32
|
+
createComputeGraph([{ plugin: EdgeFunctionPlugin, translations: EdgeFunctionPluginTranslations }], space, options);
|
|
29
33
|
|
|
30
34
|
useEffect(() => {
|
|
31
35
|
if (!graphs[space.id]) {
|
|
@@ -7,6 +7,7 @@ import { describe, test } from 'vitest';
|
|
|
7
7
|
|
|
8
8
|
import { Trigger } from '@dxos/async';
|
|
9
9
|
|
|
10
|
+
import { CustomPlugin, CustomPluginTranslations } from './custom';
|
|
10
11
|
import { createComputeGraph } from './graph';
|
|
11
12
|
import { addressFromA1Notation, SheetModel } from '../../model';
|
|
12
13
|
import { type CellScalarValue, createSheet } from '../../types';
|
|
@@ -17,9 +18,9 @@ import { type CellScalarValue, createSheet } from '../../types';
|
|
|
17
18
|
*/
|
|
18
19
|
describe('compute graph', () => {
|
|
19
20
|
const createModel = async () => {
|
|
20
|
-
const graph = createComputeGraph();
|
|
21
|
+
const graph = createComputeGraph([{ plugin: CustomPlugin, translations: CustomPluginTranslations }]);
|
|
21
22
|
const sheet = createSheet();
|
|
22
|
-
const model = new SheetModel(graph, sheet, { rows: 5, columns: 5 });
|
|
23
|
+
const model = new SheetModel(graph, sheet, undefined, { rows: 5, columns: 5 });
|
|
23
24
|
graph.update.on(() => model.update.emit());
|
|
24
25
|
return { graph, model };
|
|
25
26
|
};
|