@gridsheet/preact-core 3.0.0-rc.1 → 3.0.0-rc.3
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/components/ColumnMenuFilterSection.d.ts +5 -0
- package/dist/components/ColumnMenuLabelSection.d.ts +5 -0
- package/dist/components/ColumnMenuSortSection.d.ts +5 -0
- package/dist/components/ContextMenu.d.ts +0 -19
- package/dist/components/FunctionGuide.d.ts +3 -2
- package/dist/components/GridSheet.d.ts +6 -4
- package/dist/components/MenuItem.d.ts +18 -0
- package/dist/components/PluginBase.d.ts +2 -2
- package/dist/components/StoreObserver.d.ts +7 -4
- package/dist/constants.d.ts +4 -0
- package/dist/formula/evaluator.d.ts +36 -40
- package/dist/formula/formula-error.d.ts +10 -0
- package/dist/formula/functions/__async.d.ts +17 -12
- package/dist/formula/functions/__base.d.ts +82 -23
- package/dist/formula/functions/__utils.d.ts +4 -0
- package/dist/formula/functions/abs.d.ts +5 -5
- package/dist/formula/functions/add.d.ts +6 -6
- package/dist/formula/functions/and.d.ts +5 -5
- package/dist/formula/functions/arrayformula.d.ts +12 -0
- package/dist/formula/functions/average.d.ts +5 -5
- package/dist/formula/functions/concat.d.ts +5 -5
- package/dist/formula/functions/count.d.ts +4 -4
- package/dist/formula/functions/counta.d.ts +4 -4
- package/dist/formula/functions/divide.d.ts +5 -4
- package/dist/formula/functions/eq.d.ts +4 -4
- package/dist/formula/functions/gt.d.ts +5 -5
- package/dist/formula/functions/gte.d.ts +5 -5
- package/dist/formula/functions/if.d.ts +5 -5
- package/dist/formula/functions/iferror.d.ts +7 -9
- package/dist/formula/functions/len.d.ts +5 -5
- package/dist/formula/functions/lt.d.ts +5 -5
- package/dist/formula/functions/lte.d.ts +5 -5
- package/dist/formula/functions/max.d.ts +5 -5
- package/dist/formula/functions/min.d.ts +5 -5
- package/dist/formula/functions/minus.d.ts +6 -6
- package/dist/formula/functions/multiply.d.ts +5 -5
- package/dist/formula/functions/ne.d.ts +4 -4
- package/dist/formula/functions/not.d.ts +5 -5
- package/dist/formula/functions/now.d.ts +4 -4
- package/dist/formula/functions/or.d.ts +5 -5
- package/dist/formula/functions/power.d.ts +5 -5
- package/dist/formula/functions/sum.d.ts +5 -5
- package/dist/formula/functions/uminus.d.ts +5 -5
- package/dist/formula/mapping.d.ts +4 -3
- package/dist/formula/solver.d.ts +28 -15
- package/dist/index.d.ts +25 -23
- package/dist/index.js +7883 -7796
- package/dist/index.js.map +1 -1
- package/dist/lib/autofill.d.ts +3 -3
- package/dist/lib/{hub.d.ts → book.d.ts} +30 -45
- package/dist/lib/cell.d.ts +6 -4
- package/dist/lib/clipboard.d.ts +16 -1
- package/dist/lib/coords.d.ts +13 -1
- package/dist/lib/dom.d.ts +7 -0
- package/dist/lib/input.d.ts +11 -2
- package/dist/lib/label.d.ts +4 -0
- package/dist/lib/menu.d.ts +99 -0
- package/dist/lib/operation.d.ts +0 -3
- package/dist/lib/popup.d.ts +24 -0
- package/dist/lib/reference.d.ts +10 -4
- package/dist/lib/sheet.d.ts +507 -2
- package/dist/lib/sheet_utils.d.ts +55 -0
- package/dist/lib/spatial.d.ts +5 -20
- package/dist/lib/time.d.ts +19 -15
- package/dist/lib/virtualization.d.ts +4 -4
- package/dist/policy/checkbox.d.ts +3 -0
- package/dist/policy/core.d.ts +128 -18
- package/dist/policy/thousand_separator.d.ts +4 -0
- package/dist/sentinels.d.ts +21 -4
- package/dist/store/actions.d.ts +3 -3
- package/dist/store/dispatchers.d.ts +38 -34
- package/dist/store/helpers.d.ts +13 -4
- package/dist/styles/minified.d.ts +2 -2
- package/dist/types.d.ts +59 -55
- package/package.json +1 -1
- package/dist/formula/functions/acos.d.ts +0 -9
- package/dist/formula/functions/asin.d.ts +0 -9
- package/dist/formula/functions/atan.d.ts +0 -9
- package/dist/formula/functions/atan2.d.ts +0 -9
- package/dist/formula/functions/col.d.ts +0 -9
- package/dist/formula/functions/concatenate.d.ts +0 -9
- package/dist/formula/functions/cos.d.ts +0 -9
- package/dist/formula/functions/countif.d.ts +0 -10
- package/dist/formula/functions/exp.d.ts +0 -9
- package/dist/formula/functions/hlookup.d.ts +0 -10
- package/dist/formula/functions/index.d.ts +0 -10
- package/dist/formula/functions/lenb.d.ts +0 -9
- package/dist/formula/functions/ln.d.ts +0 -9
- package/dist/formula/functions/log.d.ts +0 -9
- package/dist/formula/functions/log10.d.ts +0 -9
- package/dist/formula/functions/match.d.ts +0 -10
- package/dist/formula/functions/match.test.d.ts +0 -2
- package/dist/formula/functions/mod.d.ts +0 -9
- package/dist/formula/functions/pi.d.ts +0 -9
- package/dist/formula/functions/product.d.ts +0 -9
- package/dist/formula/functions/radians.d.ts +0 -9
- package/dist/formula/functions/rand.d.ts +0 -9
- package/dist/formula/functions/round.d.ts +0 -9
- package/dist/formula/functions/rounddown.d.ts +0 -9
- package/dist/formula/functions/roundup.d.ts +0 -9
- package/dist/formula/functions/row.d.ts +0 -9
- package/dist/formula/functions/sin.d.ts +0 -9
- package/dist/formula/functions/sqrt.d.ts +0 -9
- package/dist/formula/functions/sumif.d.ts +0 -10
- package/dist/formula/functions/tan.d.ts +0 -9
- package/dist/formula/functions/vlookup.d.ts +0 -10
- package/dist/lib/table.d.ts +0 -463
- package/dist/parsers/core.d.ts +0 -38
- package/dist/renderers/checkbox.d.ts +0 -5
- package/dist/renderers/core.d.ts +0 -66
- package/dist/renderers/thousand_separator.d.ts +0 -3
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { ContextMenuProps } from '../types';
|
|
3
1
|
export declare const ContextMenu: () => JSX.Element | null;
|
|
4
|
-
export declare const DividerItem: (props: ContextMenuProps) => JSX.Element;
|
|
5
|
-
export declare const CutItem: (props: ContextMenuProps) => JSX.Element;
|
|
6
|
-
export declare const SearchItem: (props: ContextMenuProps) => JSX.Element;
|
|
7
|
-
export declare const CopyItem: (props: ContextMenuProps) => JSX.Element;
|
|
8
|
-
export declare const PasteItem: (props: ContextMenuProps) => JSX.Element;
|
|
9
|
-
export declare const PasteOnlyValueItem: (props: ContextMenuProps) => JSX.Element;
|
|
10
|
-
export declare const RowsColsOperationDividerItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
11
|
-
export declare const InsertRowsAboveItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
12
|
-
export declare const InsertRowsBelowItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
13
|
-
export declare const InsertColsLeftItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
14
|
-
export declare const InsertColsRightItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
15
|
-
export declare const RemoveRowsItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
16
|
-
export declare const RemoveColsItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
17
|
-
export declare const HistoryDeviderItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
18
|
-
export declare const UndoItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
19
|
-
export declare const RedoItem: (props: ContextMenuProps) => JSX.Element | null;
|
|
20
|
-
export declare const defaultContextMenuItems: FC<ContextMenuProps>[];
|
|
21
2
|
//# sourceMappingURL=ContextMenu.d.ts.map
|
|
@@ -4,8 +4,9 @@ import { AutocompleteOption } from '../policy/core';
|
|
|
4
4
|
type OptionWithGuide = AutocompleteOption & {
|
|
5
5
|
isFunction?: boolean;
|
|
6
6
|
example?: string;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
category?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
defs?: any[];
|
|
9
10
|
};
|
|
10
11
|
export interface FunctionGuideProps {
|
|
11
12
|
option?: OptionWithGuide;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare
|
|
1
|
+
import { SheetHandle, StoreHandle, Props } from '../types';
|
|
2
|
+
export declare const createSheetRef: () => import('react').RefObject<SheetHandle | null>;
|
|
3
|
+
export declare const useSheetRef: () => import('react').MutableRefObject<SheetHandle | null>;
|
|
4
|
+
export declare const createStoreRef: () => import('react').RefObject<StoreHandle | null>;
|
|
5
|
+
export declare const useStoreRef: () => import('react').MutableRefObject<StoreHandle | null>;
|
|
6
|
+
export declare function GridSheet({ initialCells, sheetName, sheetRef: initialSheetRef, storeRef: initialStoreRef, options, className, style, book: initialBook, }: Props): JSX.Element;
|
|
5
7
|
//# sourceMappingURL=GridSheet.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
type MenuItemProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
shortcuts?: string[];
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* undefined → no check column
|
|
8
|
+
* true/false → displayed as a toggle row with a checkmark
|
|
9
|
+
*/
|
|
10
|
+
checked?: boolean;
|
|
11
|
+
testId?: string;
|
|
12
|
+
onClick?: () => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare const MenuItem: FC<MenuItemProps>;
|
|
16
|
+
export declare const MenuDivider: FC;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=MenuItem.d.ts.map
|
|
@@ -4,9 +4,9 @@ import { Dispatcher } from '../store';
|
|
|
4
4
|
export type PluginContextType = {
|
|
5
5
|
provided: boolean;
|
|
6
6
|
store?: StoreType;
|
|
7
|
-
|
|
7
|
+
apply?: Dispatcher;
|
|
8
8
|
setStore: (store: StoreType) => void;
|
|
9
|
-
|
|
9
|
+
setApply: (apply: Dispatcher) => void;
|
|
10
10
|
};
|
|
11
11
|
export declare const PluginContext: import('react').Context<PluginContextType>;
|
|
12
12
|
export declare function useInitialPluginContext(): PluginContextType;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { FC, MutableRefObject } from 'react';
|
|
2
|
-
import { OptionsType,
|
|
2
|
+
import { OptionsType, SheetHandle, StoreHandle } from '../types';
|
|
3
3
|
type StoreObserverProps = OptionsType & {
|
|
4
4
|
sheetName?: string;
|
|
5
|
-
|
|
5
|
+
sheetRef?: MutableRefObject<SheetHandle | null>;
|
|
6
|
+
storeRef?: MutableRefObject<StoreHandle | null>;
|
|
6
7
|
};
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const createSheetRef: () => import('react').RefObject<SheetHandle | null>;
|
|
9
|
+
export declare const useSheetRef: () => MutableRefObject<SheetHandle | null>;
|
|
10
|
+
export declare const createStoreRef: () => import('react').RefObject<StoreHandle | null>;
|
|
11
|
+
export declare const useStoreRef: () => MutableRefObject<StoreHandle | null>;
|
|
9
12
|
export declare const StoreObserver: FC<StoreObserverProps>;
|
|
10
13
|
export {};
|
|
11
14
|
//# sourceMappingURL=StoreObserver.d.ts.map
|
package/dist/constants.d.ts
CHANGED
|
@@ -14,4 +14,8 @@ export declare const DEFAULT_ALPHABET_CACHE_SIZE = 1000;
|
|
|
14
14
|
export declare const SECONDS_IN_DAY = 86400;
|
|
15
15
|
export declare const FULLDATE_FORMAT_UTC = "YYYY-MM-DDTHH:mm:ss.SSSZ";
|
|
16
16
|
export declare const RESET_ZONE: ZoneType;
|
|
17
|
+
export declare const BASE_DATE: Date;
|
|
18
|
+
export declare const DEFAULT_KEY = "default";
|
|
19
|
+
export declare const DEFAULT_COL_KEY = "defaultCol";
|
|
20
|
+
export declare const DEFAULT_ROW_KEY = "defaultRow";
|
|
17
21
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Id
|
|
1
|
+
import { Sheet } from '../lib/sheet';
|
|
2
|
+
import { Id } from '../types';
|
|
3
3
|
type EvaluateProps = {
|
|
4
|
-
|
|
4
|
+
sheet: Sheet;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
table: Table;
|
|
6
|
+
type IdentityBaseProps = {
|
|
8
7
|
slideY?: number;
|
|
9
8
|
slideX?: number;
|
|
10
9
|
operation?: 'move' | 'removeRows' | 'removeCols';
|
|
11
|
-
dependency:
|
|
10
|
+
dependency: Id;
|
|
11
|
+
};
|
|
12
|
+
export type ProcessFormulaProps = IdentityBaseProps & {
|
|
12
13
|
idMap?: {
|
|
13
14
|
[id: string]: string;
|
|
14
15
|
};
|
|
15
16
|
};
|
|
17
|
+
export type IdentifyProps = IdentityBaseProps & {
|
|
18
|
+
sheet: Sheet;
|
|
19
|
+
};
|
|
16
20
|
export type DisplayProps = {
|
|
17
|
-
|
|
21
|
+
sheet: Sheet;
|
|
18
22
|
slideY?: number;
|
|
19
23
|
slideX?: number;
|
|
20
24
|
};
|
|
21
|
-
export declare class FormulaError {
|
|
22
|
-
code: string;
|
|
23
|
-
message: string;
|
|
24
|
-
error?: Error;
|
|
25
|
-
__isFormulaError: boolean;
|
|
26
|
-
constructor(code: string, message: string, error?: Error);
|
|
27
|
-
static is(obj: any): boolean;
|
|
28
|
-
}
|
|
29
25
|
declare class Entity<T = any> {
|
|
30
26
|
value: T;
|
|
27
|
+
ids: string[];
|
|
31
28
|
constructor(value: T);
|
|
32
29
|
}
|
|
33
30
|
export declare class ValueEntity extends Entity {
|
|
@@ -42,33 +39,33 @@ export declare class InvalidRefEntity extends Entity<string> {
|
|
|
42
39
|
export declare class RefEntity extends Entity<string> {
|
|
43
40
|
constructor(value: string);
|
|
44
41
|
stringify(): string;
|
|
45
|
-
evaluate({
|
|
42
|
+
evaluate({ sheet }: EvaluateProps): Sheet;
|
|
46
43
|
identify(props: IdentifyProps): string;
|
|
47
44
|
}
|
|
48
45
|
export declare class RangeEntity extends Entity<string> {
|
|
49
46
|
stringify(): string;
|
|
50
|
-
evaluate({
|
|
47
|
+
evaluate({ sheet }: EvaluateProps): Sheet;
|
|
51
48
|
identify(props: IdentifyProps): string;
|
|
52
49
|
}
|
|
53
50
|
export declare class IdEntity extends Entity<string> {
|
|
54
51
|
private parse;
|
|
55
|
-
evaluate({
|
|
56
|
-
display({
|
|
52
|
+
evaluate({ sheet }: EvaluateProps): Sheet;
|
|
53
|
+
display({ sheet, slideY, slideX }: DisplayProps): string;
|
|
57
54
|
identify(props: IdentifyProps): string;
|
|
58
55
|
}
|
|
59
56
|
export declare class IdRangeEntity extends Entity<string> {
|
|
60
57
|
private parse;
|
|
61
|
-
evaluate({
|
|
62
|
-
display({
|
|
63
|
-
identify(props: IdentifyProps): string
|
|
58
|
+
evaluate({ sheet }: EvaluateProps): Sheet;
|
|
59
|
+
display({ sheet, slideY, slideX }: DisplayProps): string;
|
|
60
|
+
identify(props: IdentifyProps): string;
|
|
64
61
|
}
|
|
65
62
|
export declare class FunctionEntity {
|
|
66
63
|
args: Expression[];
|
|
67
64
|
name: string;
|
|
68
65
|
precedence: number;
|
|
69
|
-
private
|
|
70
|
-
constructor(name: string, precedence?: number, args?: Expression[],
|
|
71
|
-
evaluate({
|
|
66
|
+
private at?;
|
|
67
|
+
constructor(name: string, precedence?: number, args?: Expression[], at?: Id);
|
|
68
|
+
evaluate({ sheet }: EvaluateProps): any;
|
|
72
69
|
}
|
|
73
70
|
export type Expression = ValueEntity | RefEntity | RangeEntity | IdEntity | IdRangeEntity | FunctionEntity | UnreferencedEntity | InvalidRefEntity;
|
|
74
71
|
export type TokenType = 'VALUE' | 'REF' | 'RANGE' | 'ID' | 'ID_RANGE' | 'FUNCTION' | 'PREFIX_OPERATOR' | 'INFIX_OPERATOR' | 'POSTFIX_OPERATOR' | 'OPEN' | 'CLOSE' | 'COMMA' | 'SPACE' | 'UNREFERENCED' | 'INVALID_REF';
|
|
@@ -76,25 +73,24 @@ export declare class Token {
|
|
|
76
73
|
type: TokenType;
|
|
77
74
|
entity: any;
|
|
78
75
|
precedence: number;
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
closed: boolean;
|
|
77
|
+
private at?;
|
|
78
|
+
constructor(type: TokenType, entity: any, precedence?: number, at?: Id, closed?: boolean);
|
|
81
79
|
length(): number;
|
|
82
80
|
stringify(): string;
|
|
83
81
|
convert(): ValueEntity | UnreferencedEntity | InvalidRefEntity | RefEntity | RangeEntity | IdEntity | IdRangeEntity | FunctionEntity | undefined;
|
|
84
82
|
}
|
|
85
83
|
type LexerOption = {
|
|
86
|
-
|
|
87
|
-
idMap?: {
|
|
88
|
-
[id: Id]: Id;
|
|
89
|
-
};
|
|
84
|
+
at?: Id;
|
|
90
85
|
};
|
|
91
86
|
export declare class Lexer {
|
|
92
87
|
private index;
|
|
93
88
|
private formula;
|
|
94
89
|
tokens: Token[];
|
|
95
90
|
foreign: boolean;
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
identifiedFormula: string;
|
|
92
|
+
dependencyIds: string[];
|
|
93
|
+
private at?;
|
|
98
94
|
constructor(formula: string, options?: LexerOption);
|
|
99
95
|
private isWhiteSpace;
|
|
100
96
|
private next;
|
|
@@ -103,12 +99,13 @@ export declare class Lexer {
|
|
|
103
99
|
getTokenIndexByCharPosition(pos: number): [number, boolean];
|
|
104
100
|
getTokenPositionRange(index: number, slide?: number): [number, number];
|
|
105
101
|
stringify(): string;
|
|
106
|
-
identify(props: IdentifyProps):
|
|
107
|
-
display({
|
|
108
|
-
tokenize(
|
|
102
|
+
identify(props: IdentifyProps): void;
|
|
103
|
+
display({ sheet }: DisplayProps): string;
|
|
104
|
+
tokenize(idMap?: {
|
|
105
|
+
[id: Id]: Id;
|
|
106
|
+
}): void;
|
|
109
107
|
private skipSpaces;
|
|
110
108
|
private getString;
|
|
111
|
-
private resolveIdRange;
|
|
112
109
|
}
|
|
113
110
|
export declare class Parser {
|
|
114
111
|
index: number;
|
|
@@ -120,14 +117,13 @@ export declare class Parser {
|
|
|
120
117
|
}
|
|
121
118
|
/** Alias for Parser, exported for external tooling (e.g. Debugger). */
|
|
122
119
|
export declare const FormulaParser: typeof Parser;
|
|
123
|
-
export declare const identifyFormula: (value: any, { idMap, ...props }: IdentifyProps) => any;
|
|
124
120
|
export declare const stripSheetName: (sheetName: string) => string;
|
|
125
121
|
export declare function splitRef(ref: string): {
|
|
126
122
|
sheetName: string | undefined;
|
|
127
123
|
addresses: string[];
|
|
128
124
|
};
|
|
129
|
-
export declare const parseRef: (ref: string, {
|
|
130
|
-
|
|
125
|
+
export declare const parseRef: (ref: string, { sheet, operation, dependency }: IdentifyProps) => {
|
|
126
|
+
sheet: Sheet;
|
|
131
127
|
sheetId?: number;
|
|
132
128
|
formula?: string;
|
|
133
129
|
sheetName?: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class FormulaError {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
error?: Error;
|
|
5
|
+
readonly __gsType: "FormulaError";
|
|
6
|
+
constructor(code: string, message: string, error?: Error);
|
|
7
|
+
static is(obj: any): obj is FormulaError;
|
|
8
|
+
toString(): string;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=formula-error.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Pending, Sentinel } from '../../sentinels';
|
|
2
|
-
import {
|
|
3
|
-
import { PointType } from '../../types';
|
|
2
|
+
import { Registry } from '../../lib/book';
|
|
3
|
+
import { Id, PointType } from '../../types';
|
|
4
4
|
/**
|
|
5
5
|
* Sentinel value to distinguish cache miss from user-returned undefined/null.
|
|
6
6
|
* Since user functions can return undefined or null, we need a special marker
|
|
@@ -9,6 +9,11 @@ import { PointType } from '../../types';
|
|
|
9
9
|
export declare const asyncCacheMiss: Sentinel;
|
|
10
10
|
/** Returns true if any element of `args` is a Pending sentinel. */
|
|
11
11
|
export declare const hasPendingArg: (args: any[]) => boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Recursively check whether any value in the structure is a Pending sentinel.
|
|
14
|
+
* Handles flat values, nested arrays, and Sheet objects (via getFieldMatrix).
|
|
15
|
+
*/
|
|
16
|
+
export declare const hasDeepPending: (values: any[], at: Id) => boolean;
|
|
12
17
|
/**
|
|
13
18
|
* Build a cache key from function name + hashed serialised arguments.
|
|
14
19
|
*
|
|
@@ -16,11 +21,11 @@ export declare const hasPendingArg: (args: any[]) => boolean;
|
|
|
16
21
|
* - length: byte length of the JSON-serialised args
|
|
17
22
|
* - hash: cyrb53 hash of the JSON string, repeated hashPrecision times with different seeds
|
|
18
23
|
*
|
|
19
|
-
* When a
|
|
24
|
+
* When a Sheet appears as an argument its trimmed area is converted to a
|
|
20
25
|
* value matrix (`any[][]`) via `getFieldMatrix()` so the key reflects the
|
|
21
26
|
* actual cell values the function will operate on.
|
|
22
27
|
*/
|
|
23
|
-
export declare const buildAsyncCacheKey: (funcName: string,
|
|
28
|
+
export declare const buildAsyncCacheKey: (funcName: string, args: any[], hashPrecision?: number) => string;
|
|
24
29
|
/**
|
|
25
30
|
* Try to retrieve a cached or pending async result for the given cache key.
|
|
26
31
|
*
|
|
@@ -29,16 +34,16 @@ export declare const buildAsyncCacheKey: (funcName: string, bareArgs: any[], has
|
|
|
29
34
|
* - Pending if there is an in-flight promise for this cell
|
|
30
35
|
* - asyncCacheMiss if no cache/pending exists (distinguishes from user-returned undefined/null)
|
|
31
36
|
*/
|
|
32
|
-
export declare const getAsyncCache: (
|
|
33
|
-
|
|
37
|
+
export declare const getAsyncCache: (sheet: {
|
|
38
|
+
registry: Registry;
|
|
34
39
|
getId: (p: PointType) => string;
|
|
35
|
-
},
|
|
40
|
+
}, id: Id, key: string, useInflight?: boolean) => any;
|
|
36
41
|
/**
|
|
37
42
|
* Handle an async (Promise) result returned by BaseFunction.main().
|
|
38
43
|
*
|
|
39
44
|
* Cache is stored per-cell in cell.asyncCache.
|
|
40
|
-
* In-flight tracking uses
|
|
41
|
-
* If useInflight is true, also tracks by cache key in
|
|
45
|
+
* In-flight tracking uses Binding.asyncPending (keyed by cell ID).
|
|
46
|
+
* If useInflight is true, also tracks by cache key in Binding.asyncInflight.
|
|
42
47
|
*
|
|
43
48
|
* Flow:
|
|
44
49
|
* 1. If cell has asyncCache and the key matches (inputs unchanged) and not expired → return cached value
|
|
@@ -50,10 +55,10 @@ export declare const getAsyncCache: (table: {
|
|
|
50
55
|
* @param ttlMilliseconds - Cache time-to-live in **milliseconds**. undefined = never expires.
|
|
51
56
|
* @param useInflight - If true, reuse the same promise for matching cache keys across different cells.
|
|
52
57
|
*/
|
|
53
|
-
export declare const awaitAndSave: (promise: Promise<any>,
|
|
54
|
-
|
|
58
|
+
export declare const awaitAndSave: (promise: Promise<any>, sheet: {
|
|
59
|
+
registry: Registry;
|
|
55
60
|
getId: (p: PointType) => string;
|
|
56
|
-
},
|
|
61
|
+
}, id: Id, key: string, ttlMilliseconds?: number, useInflight?: boolean) => Pending;
|
|
57
62
|
/**
|
|
58
63
|
* Create a Pending sentinel that resolves immediately.
|
|
59
64
|
* Used when an argument is already pending — the result is propagated.
|
|
@@ -1,23 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Sheet } from '../../lib/sheet';
|
|
2
|
+
import { Id } from '../../types';
|
|
3
3
|
import { Expression } from '../evaluator';
|
|
4
|
+
/** Duck-type check for Sheet instances (avoids runtime import cycle). */
|
|
5
|
+
export declare const isSheet: (v: any) => v is Sheet;
|
|
6
|
+
export type FunctionCategory = 'math' | 'statistics' | 'text' | 'time' | 'lookup' | 'information' | 'finance' | 'engineering' | 'logical' | 'other';
|
|
4
7
|
export type FunctionProps = {
|
|
5
8
|
args: Expression[];
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
sheet: Sheet;
|
|
10
|
+
at?: Id;
|
|
8
11
|
};
|
|
9
|
-
export type
|
|
12
|
+
export type FunctionArgumentType = 'number' | 'string' | 'boolean' | 'date' | 'time' | 'matrix' | 'reference' | 'any';
|
|
13
|
+
export type FunctionArgumentDefinition = {
|
|
10
14
|
name: string;
|
|
11
15
|
description: string;
|
|
12
16
|
optional?: boolean;
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
nullable?: boolean;
|
|
18
|
+
variadic?: boolean;
|
|
19
|
+
errorTolerant?: boolean;
|
|
20
|
+
acceptedTypes?: FunctionArgumentType[];
|
|
21
|
+
/** When true, this argument takes a range/matrix value — broadcasting is suppressed for it. */
|
|
22
|
+
takesMatrix?: boolean;
|
|
15
23
|
};
|
|
16
|
-
export declare const conditionArg:
|
|
24
|
+
export declare const conditionArg: FunctionArgumentDefinition;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a value is a "matrix" (Sheet, Spilling, or 2D array).
|
|
27
|
+
*/
|
|
28
|
+
export declare const isMatrix: (value: any) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Extract the scalar from a 1×1 matrix (Sheet, Spilling, or plain 2D array).
|
|
31
|
+
* Returns the value unchanged if it is not a matrix.
|
|
32
|
+
*/
|
|
33
|
+
export declare const stripMatrix: (value: any, at: Id) => any;
|
|
34
|
+
/**
|
|
35
|
+
* Check if a value is a matrix that is larger than 1×1.
|
|
36
|
+
*/
|
|
37
|
+
export declare const isMultiCell: (value: any) => boolean;
|
|
17
38
|
export declare class BaseFunction {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
39
|
+
defs: FunctionArgumentDefinition[];
|
|
40
|
+
example: string | undefined;
|
|
41
|
+
description: string;
|
|
42
|
+
category: FunctionCategory;
|
|
21
43
|
/** Indicates if this function is async. Override in subclass or use BaseFunctionAsync. */
|
|
22
44
|
protected isAsync: boolean;
|
|
23
45
|
/** Cache TTL in milliseconds. Override in subclass to set expiry. undefined = never expires. */
|
|
@@ -26,19 +48,56 @@ export declare class BaseFunction {
|
|
|
26
48
|
protected hashPrecision: number;
|
|
27
49
|
/** If true, reuse the same in-flight promise for matching cache keys across different cells. */
|
|
28
50
|
protected useInflight: boolean;
|
|
29
|
-
|
|
30
|
-
protected
|
|
31
|
-
protected
|
|
32
|
-
|
|
33
|
-
|
|
51
|
+
/** If true, broadcasting is unconditionally disabled for this function. */
|
|
52
|
+
protected broadcastDisabled: boolean;
|
|
53
|
+
protected args: any[];
|
|
54
|
+
protected autoSpilling: boolean;
|
|
55
|
+
sheet: Sheet;
|
|
56
|
+
at: Id;
|
|
57
|
+
static __name: string;
|
|
58
|
+
constructor({ args, sheet, at }: FunctionProps);
|
|
59
|
+
private _main;
|
|
60
|
+
/**
|
|
61
|
+
* Validate and normalise arguments before `main()` is called.
|
|
62
|
+
*
|
|
63
|
+
* Checks:
|
|
64
|
+
* 1. Argument count satisfies defs (respecting optional / variadic).
|
|
65
|
+
* 2. Each argument's runtime type matches the corresponding def's `type` list.
|
|
66
|
+
*
|
|
67
|
+
* Subclasses may override for additional coercion / spreading.
|
|
68
|
+
*/
|
|
69
|
+
protected validate(args: any[]): any[];
|
|
70
|
+
eachMatrix: (value: any, callback: (v: any) => void) => void;
|
|
71
|
+
/**
|
|
72
|
+
* Extract a 2D array from a matrix value (Spilling, Sheet, or nested array).
|
|
73
|
+
* Default behavior for Sheet is value.solve(). Functions like COL can override
|
|
74
|
+
* this to preserve Sheet metadata per cell.
|
|
75
|
+
*/
|
|
76
|
+
protected toMatrix(value: any): any[][];
|
|
77
|
+
/**
|
|
78
|
+
* Collapse a 1×1 matrix value (Sheet, Spilling, or 2D array) to a scalar.
|
|
79
|
+
* Non-matrix values pass through unchanged.
|
|
80
|
+
*
|
|
81
|
+
* Override in sub-classes that need the original Sheet / reference
|
|
82
|
+
* metadata (e.g. COL, ROW) — for instance, to extract position
|
|
83
|
+
* information before collapsing.
|
|
84
|
+
*/
|
|
85
|
+
protected toScalar(value: any): any;
|
|
34
86
|
call(): any;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
87
|
+
/**
|
|
88
|
+
* If any broadcastable argument is a matrix (multi-cell), expand the call
|
|
89
|
+
* across all element positions and return a Spilling.
|
|
90
|
+
* Returns `undefined` when no broadcast is necessary.
|
|
91
|
+
*
|
|
92
|
+
* Rules:
|
|
93
|
+
* - broadcastDisabled = true → never broadcast
|
|
94
|
+
* - An arg is broadcastable when its corresponding args[].takesMatrix is not true
|
|
95
|
+
* - A Sheet/Spilling/2D-array whose size is (1,1) is treated as a scalar
|
|
96
|
+
* (not broadcast); only multi-cell matrices trigger broadcast
|
|
97
|
+
* - For variadic args, extra args are assigned round-robin
|
|
98
|
+
* across the variadic helpArg positions
|
|
99
|
+
*/
|
|
100
|
+
private broadcast;
|
|
42
101
|
}
|
|
43
102
|
/**
|
|
44
103
|
* Base class for async functions.
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Sheet } from '../../lib/sheet';
|
|
2
|
+
import { Id, PointType } from '../../types';
|
|
1
3
|
export declare const gt: (left: any, right: any) => boolean;
|
|
2
4
|
export declare const gte: (left: any, right: any) => boolean;
|
|
3
5
|
export declare const lt: (left: any, right: any) => boolean;
|
|
@@ -16,4 +18,6 @@ export declare const ensureNumber: (value: any, options?: EnsureNumberOptions) =
|
|
|
16
18
|
export declare const ensureString: (value: any) => string;
|
|
17
19
|
export declare const ensureBoolean: (value: any, options?: EnsureBooleanOptions) => boolean;
|
|
18
20
|
export declare const check: (value: any, condition: string) => boolean;
|
|
21
|
+
export declare const eachMatrix: (value: any, callback: (v: any, relativePoint: PointType) => void, at: Id) => void;
|
|
22
|
+
export declare const createBooleanMask: (sheets: Sheet[], conditions: string[], at: Id) => boolean[][];
|
|
19
23
|
//# sourceMappingURL=__utils.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class AbsFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
protected main(value:
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
|
+
protected main(value: any): number;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=abs.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
2
|
-
import {
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
|
+
import { Time } from '../../lib/time';
|
|
3
3
|
export declare class AddFunction extends BaseFunction {
|
|
4
4
|
example: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
protected main(v1: number | Date |
|
|
5
|
+
description: string;
|
|
6
|
+
defs: FunctionArgumentDefinition[];
|
|
7
|
+
category: FunctionCategory;
|
|
8
|
+
protected main(v1: number | Date | Time, v2: number | Date | Time): number | Date;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=add.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class AndFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
protected main(...values:
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
|
+
protected main(...values: any[]): boolean;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=and.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Spilling } from '../../sentinels';
|
|
2
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
3
|
+
export declare class ArrayformulaFunction extends BaseFunction {
|
|
4
|
+
autoSpilling: boolean;
|
|
5
|
+
example: string;
|
|
6
|
+
description: string;
|
|
7
|
+
defs: FunctionArgumentDefinition[];
|
|
8
|
+
category: FunctionCategory;
|
|
9
|
+
protected broadcastDisabled: boolean;
|
|
10
|
+
protected main(value: any): any[] | Spilling;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=arrayformula.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class AverageFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
protected main(...values:
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
|
+
protected main(...values: any[]): number;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=average.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class ConcatFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
protected main(v1:
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
|
+
protected main(v1: any, v2: any): string;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=concat.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class CountFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
7
|
protected main(...values: any[]): number;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=count.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BaseFunction,
|
|
1
|
+
import { BaseFunction, FunctionCategory, FunctionArgumentDefinition } from './__base';
|
|
2
2
|
export declare class CountaFunction extends BaseFunction {
|
|
3
3
|
example: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
description: string;
|
|
5
|
+
defs: FunctionArgumentDefinition[];
|
|
6
|
+
category: FunctionCategory;
|
|
7
7
|
protected main(...values: any[]): number;
|
|
8
8
|
}
|
|
9
9
|
//# sourceMappingURL=counta.d.ts.map
|