@sheetxl/primitives 0.8.0-beta.11 → 0.8.0-beta.13
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/browser/esm/index.mjs +80 -36
- package/node/esm/index.mjs +102 -56
- package/package.json +1 -1
- package/types/src/ErrorPolicy.d.ts +2 -2
- package/types/src/Flatten.d.ts +2 -2
- package/types/src/FormulaContext.d.ts +15 -6
- package/types/src/FormulaError.d.ts +1 -1
- package/types/src/IFormulaContext.d.ts +218 -13
- package/types/src/IFunction.d.ts +13 -44
- package/types/src/IFunctionArguments.d.ts +3 -4
- package/types/src/IRange.d.ts +4 -4
- package/types/src/IRangeStats.d.ts +6 -6
- package/types/src/IRichData.d.ts +33 -10
- package/types/src/IRichType.d.ts +139 -0
- package/types/src/Repeating.d.ts +3 -3
- package/types/src/ReportType.d.ts +2 -2
- package/types/src/Scalar.d.ts +53 -2
- package/types/src/ValueKind.d.ts +2 -2
- package/types/src/WildCard.d.ts +1 -1
- package/types/src/index.d.ts +1 -0
package/types/src/IRichData.d.ts
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
import { Scalar } from './Scalar';
|
|
2
|
+
import { IRichMeta, IRichType } from './IRichType';
|
|
2
3
|
/**
|
|
3
4
|
* A complex object type. This allows for more complex data types to be stored in a cell.
|
|
4
5
|
*/
|
|
5
6
|
export interface IRichData {
|
|
6
7
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
8
|
+
* The value's kind: the properties it has and how they show. Every value of a kind returns the
|
|
9
|
+
* same instance.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
getKind(): IRichType;
|
|
11
12
|
/**
|
|
12
13
|
* @param name The name of the property to retrieve.
|
|
13
14
|
*/
|
|
14
15
|
getProperty(name: string): Scalar;
|
|
16
|
+
/**
|
|
17
|
+
* How the property `name` shows on this value: the value's own presentation where it differs
|
|
18
|
+
* from its kind's (a price in another currency), else the kind's ({@link IRichType.Property.meta}).
|
|
19
|
+
* `null`, or the method absent, for none.
|
|
20
|
+
*/
|
|
21
|
+
getPropertyMeta?(name: string): IRichMeta | null;
|
|
15
22
|
/**
|
|
16
23
|
* The text shown for this value where nothing renders it: a client with no renderer for the
|
|
17
24
|
* kind, a log, a placeholder. A rich text shows its text; an image a short description.
|
|
@@ -23,32 +30,48 @@ export interface IRichData {
|
|
|
23
30
|
toString(): string;
|
|
24
31
|
/**
|
|
25
32
|
* The primitive this value reads as wherever one is consumed: `LEN`, `&`, `+`, comparison,
|
|
26
|
-
* `ISTEXT`, `TYPE()`, sort, filter, find. A rich text reads as its text; an
|
|
27
|
-
*
|
|
33
|
+
* `ISTEXT`, `TYPE()`, sort, filter, find. A rich text reads as its text; an error that carries
|
|
34
|
+
* more than its code reads as that error; an image reads as nothing (`null`, or the method
|
|
35
|
+
* absent), and is `#VALUE!` wherever a primitive is needed.
|
|
28
36
|
*
|
|
29
37
|
* @remarks
|
|
30
|
-
* The ordinary rules then apply to the primitive (text-to-number coercion, collation
|
|
31
|
-
* value adds no coercions of its own.
|
|
38
|
+
* The ordinary rules then apply to the primitive (text-to-number coercion, collation, error
|
|
39
|
+
* propagation), so a value adds no coercions of its own.
|
|
32
40
|
*/
|
|
33
|
-
toPrimitive?():
|
|
41
|
+
toPrimitive?(): Exclude<Scalar, IRichData>;
|
|
34
42
|
/**
|
|
35
43
|
* The items this value unpacks to where a range or array is accepted (a list); `null`, or the
|
|
36
44
|
* method absent, for a value that is one value.
|
|
37
45
|
*/
|
|
38
46
|
toArray?(): Scalar[][] | null;
|
|
39
47
|
/**
|
|
40
|
-
*
|
|
48
|
+
* The value as JSON, which its kind makes it again from. A value that holds a resource (a
|
|
49
|
+
* picture's bytes) names it by the id `toResourceId` answers, and the file saves the resource;
|
|
50
|
+
* without `toResourceId` it names none.
|
|
41
51
|
*/
|
|
42
|
-
toJSON?(): IRichData.JSON | Promise<IRichData.JSON>;
|
|
52
|
+
toJSON?(toResourceId?: IRichData.ToResourceId): IRichData.JSON | Promise<IRichData.JSON>;
|
|
43
53
|
/**
|
|
44
54
|
* For runtime type checking.
|
|
45
55
|
*/
|
|
46
56
|
get isIRichData(): true;
|
|
47
57
|
}
|
|
48
58
|
export declare namespace IRichData {
|
|
59
|
+
/**
|
|
60
|
+
* The id a file being saved gives a resource a value holds (an `IResource`); `null` when the
|
|
61
|
+
* file does not save it.
|
|
62
|
+
*/
|
|
63
|
+
type ToResourceId = (resource: any) => number | null;
|
|
49
64
|
interface JSON {
|
|
65
|
+
/** The name of the value's kind ({@link IRichType.getName}). */
|
|
50
66
|
type: string;
|
|
67
|
+
/** The value's own data, as its kind reads it. */
|
|
51
68
|
data?: any;
|
|
69
|
+
/**
|
|
70
|
+
* Presentation for the properties where this value differs from its kind, by property name.
|
|
71
|
+
*/
|
|
72
|
+
meta?: {
|
|
73
|
+
readonly [property: string]: IRichMeta;
|
|
74
|
+
};
|
|
52
75
|
}
|
|
53
76
|
}
|
|
54
77
|
//# sourceMappingURL=IRichData.d.ts.map
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Scalar } from './Scalar';
|
|
2
|
+
/**
|
|
3
|
+
* The kind of a rich value: its class. A kind is a static set of typed property definitions, and
|
|
4
|
+
* every value of a kind shares the one `IRichType` its {@link IRichData.getKind} returns.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* For introspection: a renderer, a card, a formula editor offering `A1.` completions, or a
|
|
8
|
+
* function reading a field asks the value's kind which properties it has. What a value reads as
|
|
9
|
+
* where a primitive is consumed is the value's own answer ({@link IRichData.toPrimitive}).
|
|
10
|
+
*/
|
|
11
|
+
export interface IRichType {
|
|
12
|
+
/**
|
|
13
|
+
* The kind's name: what a value's JSON names as its `type`.
|
|
14
|
+
*/
|
|
15
|
+
getName(): string;
|
|
16
|
+
/**
|
|
17
|
+
* The name a UI shows for the kind, such as in a list of what can be inserted. The name when the
|
|
18
|
+
* kind has no label of its own.
|
|
19
|
+
*/
|
|
20
|
+
getLabel(): string;
|
|
21
|
+
/**
|
|
22
|
+
* The kind's properties, in the order the kind declares them.
|
|
23
|
+
*/
|
|
24
|
+
getProperties(): readonly IRichType.Property[];
|
|
25
|
+
/**
|
|
26
|
+
* The property `name`, or `null` when the kind has none by that name.
|
|
27
|
+
*/
|
|
28
|
+
getProperty(name: string): IRichType.Property | null;
|
|
29
|
+
/**
|
|
30
|
+
* The property whose value is the text a cell shows for a value of this kind, or `null` when
|
|
31
|
+
* the kind shows none (an image).
|
|
32
|
+
*/
|
|
33
|
+
getDisplayProperty(): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* The kind's own presentation (a card, an icon, a provider), or `null` for none.
|
|
36
|
+
*/
|
|
37
|
+
getMeta(): IRichMeta | null;
|
|
38
|
+
}
|
|
39
|
+
export declare namespace IRichType {
|
|
40
|
+
/**
|
|
41
|
+
* What a property holds.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* `rich` is another rich value (a capital city, an image); `array` is an array value; `resource`
|
|
45
|
+
* is a workbook resource such as a picture's bytes.
|
|
46
|
+
*/
|
|
47
|
+
type ValueType = 'number' | 'integer' | 'string' | 'boolean' | 'error' | 'rich' | 'array' | 'resource';
|
|
48
|
+
/**
|
|
49
|
+
* One property a kind declares.
|
|
50
|
+
*/
|
|
51
|
+
interface Property {
|
|
52
|
+
/** The property's name. */
|
|
53
|
+
readonly name: string;
|
|
54
|
+
/** What it holds. */
|
|
55
|
+
readonly valueType: ValueType;
|
|
56
|
+
/** What it reads as on a value that holds none. Omitted, `null`. */
|
|
57
|
+
readonly defaultValue?: Scalar;
|
|
58
|
+
/** How the property shows, unless a value says otherwise. */
|
|
59
|
+
readonly meta?: IRichMeta;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* A kind saved with the workbook whose values name it: one that is not registered in code, such
|
|
63
|
+
* as a kind read from a file.
|
|
64
|
+
*/
|
|
65
|
+
interface JSON {
|
|
66
|
+
/** {@inheritDoc IRichType.getName} */
|
|
67
|
+
name: string;
|
|
68
|
+
/** {@inheritDoc IRichType.getLabel} */
|
|
69
|
+
label?: string;
|
|
70
|
+
/** {@inheritDoc IRichType.getProperties} */
|
|
71
|
+
properties?: readonly Property[];
|
|
72
|
+
/** {@inheritDoc IRichType.getDisplayProperty} */
|
|
73
|
+
displayProperty?: string | null;
|
|
74
|
+
/** {@inheritDoc IRichType.getMeta} */
|
|
75
|
+
meta?: IRichMeta;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* How a rich value, or one of its properties, is presented: the number format and caption of a
|
|
80
|
+
* property, where it is offered, its sources; a kind's card, icon and provider.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* Presentation only, never a value. A kind gives each of its properties a default; a value gives
|
|
84
|
+
* one only for a property where it differs (a price in another currency).
|
|
85
|
+
*/
|
|
86
|
+
export interface IRichMeta {
|
|
87
|
+
/** The number format a number property shows in. */
|
|
88
|
+
readonly numberFormat?: string;
|
|
89
|
+
/** A short caption shown beside the property, such as its unit or the year of its data. */
|
|
90
|
+
readonly sublabel?: string;
|
|
91
|
+
/** Where the property is not offered. Each omitted entry is `false`. */
|
|
92
|
+
readonly excludeFrom?: IRichMeta.ExcludeFrom;
|
|
93
|
+
/** Where the property's data comes from and under what license. */
|
|
94
|
+
readonly attribution?: readonly IRichMeta.Attribution[];
|
|
95
|
+
/** A kind's card. */
|
|
96
|
+
readonly card?: IRichMeta.Card;
|
|
97
|
+
/** A kind's icon, by name. */
|
|
98
|
+
readonly icon?: string;
|
|
99
|
+
/** Who provides a kind's data. */
|
|
100
|
+
readonly provider?: IRichMeta.Provider;
|
|
101
|
+
}
|
|
102
|
+
export declare namespace IRichMeta {
|
|
103
|
+
/** Where a property is not offered. */
|
|
104
|
+
interface ExcludeFrom {
|
|
105
|
+
/** Not shown on the card. */
|
|
106
|
+
readonly cardView?: boolean;
|
|
107
|
+
/** Not offered after `A1.` in a formula. */
|
|
108
|
+
readonly dotNotation?: boolean;
|
|
109
|
+
/** Not offered by formula autocomplete. */
|
|
110
|
+
readonly autoComplete?: boolean;
|
|
111
|
+
/** A change to the property is not a change to the value. */
|
|
112
|
+
readonly calcCompare?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** One source of a property's data. */
|
|
115
|
+
interface Attribution {
|
|
116
|
+
readonly sourceText?: string;
|
|
117
|
+
readonly sourceAddress?: string;
|
|
118
|
+
readonly licenseText?: string;
|
|
119
|
+
readonly licenseAddress?: string;
|
|
120
|
+
}
|
|
121
|
+
/** A kind's card: which properties it shows, and how. */
|
|
122
|
+
interface Card {
|
|
123
|
+
/** The properties shown, in order. Omitted, the kind's order. */
|
|
124
|
+
readonly order?: readonly string[];
|
|
125
|
+
/** The property shown as the title. */
|
|
126
|
+
readonly title?: string;
|
|
127
|
+
/** The property shown under the title. */
|
|
128
|
+
readonly subTitle?: string;
|
|
129
|
+
/** The image property shown at the top. */
|
|
130
|
+
readonly mainImage?: string;
|
|
131
|
+
}
|
|
132
|
+
/** Who provides a kind's data. */
|
|
133
|
+
interface Provider {
|
|
134
|
+
readonly description?: string;
|
|
135
|
+
readonly logoSourceAddress?: string;
|
|
136
|
+
readonly logoTargetAddress?: string;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=IRichType.d.ts.map
|
package/types/src/Repeating.d.ts
CHANGED
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
* omitted when there is a single repetition. `SORTBY`'s legal arities are 2 and 1+2n and nothing
|
|
47
47
|
* else — `SORTBY(array, by1)` is legal, `SORTBY(array, by1, o1, by2)` is not. It is not a general
|
|
48
48
|
* "the final element of the final group may be omitted" rule; that rule would accept a formula
|
|
49
|
-
*
|
|
49
|
+
* that must be refused. An optional slot anywhere else in the group is a compiler error.
|
|
50
50
|
*
|
|
51
51
|
* ### The maximum, `Max`
|
|
52
52
|
*
|
|
53
|
-
* The second type argument is the largest number of arguments the WHOLE CALL accepts
|
|
54
|
-
*
|
|
53
|
+
* The second type argument is the largest number of arguments the WHOLE CALL accepts: one
|
|
54
|
+
* number per NAME, compared against the call's total argument count and
|
|
55
55
|
* refused at entry (`Excess_function_arguments`), never a count of this parameter's own share.
|
|
56
56
|
* `SWITCH`'s 254 therefore covers its `expression` and its trailing `default` as well as the
|
|
57
57
|
* pairs, and `CHOOSEROWS`' covers its `array`.
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
* what can arrive and {@link IFunctionArguments.getAreaCountAt} answers the union question the
|
|
28
28
|
* kind cannot — a plain reference is one area, a union is more.
|
|
29
29
|
*
|
|
30
|
-
* Its use is meant to stay countable: a slot earns it with a
|
|
31
|
-
*
|
|
30
|
+
* Its use is meant to stay countable: a slot earns it with a concrete behavior that needs it,
|
|
31
|
+
* never speculatively.
|
|
32
32
|
*
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
package/types/src/Scalar.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare namespace Scalar {
|
|
|
31
31
|
*/
|
|
32
32
|
const MAX_SIGNIFICANT_DIGITS = 15;
|
|
33
33
|
/**
|
|
34
|
-
* Applies
|
|
35
|
-
* 15th becomes `0`, so the text parses to the double
|
|
34
|
+
* Applies the 15-digit entry rule to numeric text: every significand digit past the
|
|
35
|
+
* 15th becomes `0`, so the text parses to the double a cell stores.
|
|
36
36
|
*
|
|
37
37
|
* @param text Numeric text in any accepted form — signed, grouped, percent,
|
|
38
38
|
* currency-affixed, or scientific. The scan is locale-blind: only digit
|
|
@@ -46,6 +46,57 @@ export declare namespace Scalar {
|
|
|
46
46
|
* truncation, not rounding: `1234567890.123456789` stores `…345`, never `…346`.
|
|
47
47
|
*/
|
|
48
48
|
function truncateNumberText(text: string): string;
|
|
49
|
+
/**
|
|
50
|
+
* The smallest magnitude a stored number can have: the smallest normal double. A smaller one is
|
|
51
|
+
* stored as `0`.
|
|
52
|
+
*/
|
|
53
|
+
const MIN_NUMBER = 2.2250738585072014e-308;
|
|
54
|
+
/**
|
|
55
|
+
* Applies the stored-number floor to a number entering a workbook — typed, parsed from text, written
|
|
56
|
+
* through the API or loaded from a file: a magnitude below {@link MIN_NUMBER} becomes `0`.
|
|
57
|
+
*/
|
|
58
|
+
function flushSubnormal(value: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Whether numeric text is inside the range accepted as a number, judged from the text as
|
|
61
|
+
* written rather than the double it parses to.
|
|
62
|
+
*
|
|
63
|
+
* @param text Numeric text in any accepted form, as {@link truncateNumberText} takes it. Only
|
|
64
|
+
* digits, `decimal` and an exponent marker are read.
|
|
65
|
+
* @param decimal The decimal separator `text` is written with.
|
|
66
|
+
* @returns `false` when the leading significant digit sits outside `1E-309` … `1E+307`
|
|
67
|
+
* (`1E-310`, `0.00001E-305`, `1E+308`); for a zero mantissa, when its scale — exponent less
|
|
68
|
+
* fraction digits — is outside ±308 (`0E-309`, `0.0E-308` and `0E+309`, but not `0E-308`,
|
|
69
|
+
* `000E-308` or `0.0E+309`). Text out of range is not a number: a formula literal will not
|
|
70
|
+
* commit, `VALUE` is `#VALUE!` and typed entry stays text.
|
|
71
|
+
*/
|
|
72
|
+
function isNumberTextInRange(text: string, decimal?: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Encodings of `ScalarType` for persistence.
|
|
75
|
+
*/
|
|
76
|
+
type JSONType = 'n' | 's' | 'b' | 'e' | 'r' | 'z';
|
|
77
|
+
/**
|
|
78
|
+
* A value encoded as a number with an associated type.
|
|
79
|
+
*/
|
|
80
|
+
interface JSONTypedValue {
|
|
81
|
+
t: JSONType;
|
|
82
|
+
/**
|
|
83
|
+
* The number, string id, error code or boolean flag; for `'r'`, the rich data's own JSON
|
|
84
|
+
* (`IRichData.JSON`), which its registered kind reads back.
|
|
85
|
+
*/
|
|
86
|
+
v: number | IRichData.JSON;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* JSON values whose type is implied by their JavaScript type.
|
|
90
|
+
*
|
|
91
|
+
* @remarks
|
|
92
|
+
* What a string means is up to the container: a worksheet stores the id of the string in its
|
|
93
|
+
* strings collection, while an external link cache stores the string itself.
|
|
94
|
+
*/
|
|
95
|
+
type JSONUnTypedValue = number | boolean | string;
|
|
96
|
+
/**
|
|
97
|
+
* For persisting a single scalar value and its type.
|
|
98
|
+
*/
|
|
99
|
+
type JSON = JSONUnTypedValue | JSONTypedValue;
|
|
49
100
|
}
|
|
50
101
|
/**
|
|
51
102
|
* Represents a cell value in JavaScript, including `Date` for convenience.
|
package/types/src/ValueKind.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @remarks
|
|
6
6
|
* A value's kind and its extent are different axes: `{10}`, `A1` and a bare `10` all reach a
|
|
7
|
-
* range-typed parameter as a 1x1 container, yet
|
|
7
|
+
* range-typed parameter as a 1x1 container, yet they are distinct:
|
|
8
8
|
* `VLOOKUP(10,10,1,TRUE)` is `#N/A` while `VLOOKUP(10,{10},1,TRUE)` is 10, and `TYPE` answers
|
|
9
9
|
* 1 vs 64. The kind is what the CALLER supplied; the extent is merely its size.
|
|
10
10
|
*
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* argument can be: a reference, a non-reference array, a callable, and no argument at all. As an
|
|
14
14
|
* argument kind, {@link ScalarType.Null} means a BLANK value.
|
|
15
15
|
*
|
|
16
|
-
* The names and values are ours. The numeric codes
|
|
16
|
+
* The names and values are ours. The numeric codes the `TYPE` function answers are a
|
|
17
17
|
* PROJECTION of this kind (see `TYPE`'s implementation), not the kind itself.
|
|
18
18
|
*
|
|
19
19
|
* @see {@link IFunctionArguments.getKindAt}
|
package/types/src/WildCard.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export declare const WildCard: {
|
|
|
11
11
|
* Compiles Excel wildcard text into a regex.
|
|
12
12
|
*
|
|
13
13
|
* @param anchor Where the pattern has to line up: `true` for the WHOLE string, `'start'` for a
|
|
14
|
-
* PREFIX, `false` for anywhere in it.
|
|
14
|
+
* PREFIX, `false` for anywhere in it. A criterion matches a whole cell, so every lookup and criteria
|
|
15
15
|
* caller anchors; `SEARCH`, which looks for a substring, does not; and a `D` function's criteria
|
|
16
16
|
* table is the prefix form — `DSUM` with the criterion `appl` takes the row whose value is
|
|
17
17
|
* `Apple`, where `COUNTIF` with the same criterion takes none.
|
package/types/src/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export * from './Volatile';
|
|
|
15
15
|
export * from './IRange';
|
|
16
16
|
export * from './IReferenceRange';
|
|
17
17
|
export * from './IRichData';
|
|
18
|
+
export * from './IRichType';
|
|
18
19
|
export * from './IFunction';
|
|
19
20
|
export * from './IFormulaContext';
|
|
20
21
|
export * from './IFunctionArguments';
|