@sheetxl/primitives 0.8.0-beta.1 → 0.8.0-beta.11

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.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Declares a parameter the engine may hand over UNEVALUATED — the argument's subtree is not run
3
+ * before the call, and it runs only if this call's answer needs it.
4
+ *
5
+ * @remarks
6
+ * An argument that is a bare reference has always been cheap to ignore: it resolves into a
7
+ * register and a body that never reads it never dereferences it. An argument that is an
8
+ * EXPRESSION is not — `IF(FALSE,B1+1,1)` evaluates `B1+1` before `IF` runs, so the untaken branch
9
+ * opens `B1` anyway. That is a correctness difference and not a cost one: a read is what decides
10
+ * a circular reference and what registers a volatile, so an arm nobody takes can report a cycle
11
+ * the sheet does not have.
12
+ *
13
+ * The marker is what closes it, and it is a CONTRACT rather than an inference. Nothing in
14
+ * JavaScript intercepts a plain parameter read, so a body holding a deferred value is only safe
15
+ * while it never touches it — which the declaration has to say out loud:
16
+ *
17
+ * ```ts
18
+ * export function IF(
19
+ * logicalTest: boolean,
20
+ * valueIfTrue: Lazy<AcceptError<any>>,
21
+ * valueIfFalse: Lazy<AcceptError<any>, false>
22
+ * ): any {
23
+ * return logicalTest ? valueIfTrue : valueIfFalse;
24
+ * }
25
+ * ```
26
+ *
27
+ * The parameter is ALWAYS an {@link ILazy} handle and never a union with the bare value, so the
28
+ * body has two things it may do with it and the type says which is which:
29
+ *
30
+ * - **return it unread**, which is what every branch-selecting function does. The engine
31
+ * recognizes its own handle coming back as the call's result and evaluates that subtree then.
32
+ * - **read it** with {@link ILazy.getValue}, which forces the subtree in place. Synchronous only:
33
+ * the engine is mid-formula there and has no way to wait, so an ASYNC subtree at a forced
34
+ * handle is an error rather than a wrong answer.
35
+ *
36
+ * Only the RESULT positions are marked. A condition, an index and a case value are eager, which
37
+ * is what keeps `AND(FALSE,A1)` a circular reference: laziness is a property of what the function
38
+ * READS, not of the syntax around it.
39
+ *
40
+ * The engine may DECLINE to defer at any time and hand the body a handle that is already full —
41
+ * an absent argument, an async subtree, a lift that needs every arm anyway. `getValue()` then
42
+ * returns the value it was built with. The author cannot tell the two apart and must not try.
43
+ *
44
+ * @typeParam T - what the argument evaluates to; the marker is otherwise transparent.
45
+ * @typeParam V - what an ABSENT argument means, as a literal. It replaces the `= false`
46
+ * initializer an ordinary parameter would carry, which cannot typecheck against a handle;
47
+ * declaring it makes the parameter optional and the engine supplies the value, so the body
48
+ * still sees nothing but a handle.
49
+ *
50
+ * @see {@link IFunction.ParameterTypeJSON.lazy}
51
+ */
52
+ export type Lazy<T, V = never> = ILazy<T | V>;
53
+ /**
54
+ * The handle a {@link Lazy} parameter receives: an argument's subtree, anchored at the calling
55
+ * cell, that has either not been evaluated yet or has been evaluated already.
56
+ *
57
+ * @remarks
58
+ * The brand exists for the same reason {@link Lambda}'s does — the value-layer sites (coercion,
59
+ * the operators, a range's typed read, a cell's final value) RECOGNIZE a handle and refuse it, so
60
+ * that one can never reach a grid, a spill or a named-formula result. A handle is only ever a
61
+ * live call's argument.
62
+ */
63
+ export interface ILazy<T = any> {
64
+ /** The brand itself — the property every recognizing site reads. */
65
+ readonly isLazy: true;
66
+ /**
67
+ * Evaluates the argument and answers its value, forcing the subtree where the engine deferred
68
+ * it and answering the value it already has where it declined to.
69
+ *
70
+ * Forced at most once: a second call answers the same value.
71
+ */
72
+ getValue(): T;
73
+ }
74
+ /** `true` for a deferred-argument handle — see {@link ILazy}. */
75
+ export declare const isLazyValue: (value: unknown) => value is ILazy;
76
+ //# sourceMappingURL=Lazy.d.ts.map
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Declares that the members reaching a REPEATING scalar parameter are COERCED rather than
3
+ * filtered — one that cannot be coerced is `#VALUE!` for the whole call.
4
+ *
5
+ * The native functions FILTER: `SUM({1,"8",TRUE})` is 1, the text and the boolean skipped, and a
6
+ * blank cell contributes nothing. Excel's Analysis-ToolPak heritage coerces at the slot instead,
7
+ * and the difference is visible in both directions:
8
+ *
9
+ * | argument | native (`SUM`) | this marker (`GCD`) |
10
+ * | --- | --- | --- |
11
+ * | numeric text, `{6,"8",12}` | skipped | parses — `GCD({6,"8",12})` is 2 |
12
+ * | a boolean, `{6,TRUE,12}` | skipped | `#VALUE!` for the whole call |
13
+ * | a blank inside a multi-cell range | skipped | reads 0 — `LCM(6,A1:A2)` is 0 |
14
+ *
15
+ * A DIRECT argument follows the same rule (`GCD(6,TRUE,12)` is `#VALUE!` where `SUM(6,TRUE,12)`
16
+ * is 19). A one-cell blank reference and an omitted argument are still skipped either way: they
17
+ * never became members.
18
+ *
19
+ * Only a repeating slot has members to filter, so the marker means nothing on a plain scalar,
20
+ * range or lambda parameter and the linter refuses it there. It is the repeating counterpart of
21
+ * {@link NoLift}, which is the same heritage's reading of a NON-repeating scalar slot.
22
+ *
23
+ * It may be written over the group or on the slot — `NoFilter<number[]>` and `NoFilter<number>[]`
24
+ * mean the same thing, as they do for `AcceptError`.
25
+ *
26
+ * At the type level it is `T`.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * export function GCD(number: NoFilter<number>[]): number { ... }
31
+ * ```
32
+ */
33
+ export type NoFilter<T> = T;
34
+ //# sourceMappingURL=NoFilter.d.ts.map
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Declares that a SCALAR parameter refuses a multi-cell REFERENCE with `#VALUE!` instead of
3
+ * broadcasting over it.
4
+ *
5
+ * The native functions lift: `ROUND(B1:B3,3)` spills three results. Excel's Analysis-ToolPak
6
+ * heritage refuses at the slot instead — `EDATE(A1:A3,1)` is `#VALUE!` — and the refusal is per
7
+ * PARAMETER: `NETWORKDAYS.INTL` refuses a reference at its two date slots and lifts one at its
8
+ * `weekend` slot. Three qualifications:
9
+ *
10
+ * | argument at the slot | answer |
11
+ * | --- | --- |
12
+ * | a multi-cell REFERENCE, `A1:A3` | `#VALUE!` — the call never runs |
13
+ * | an ARRAY, `{3,4,5}` | lifts as usual (`MROUND({3,4,5},5)` spills) |
14
+ * | a one-cell reference or a value | an ordinary argument |
15
+ *
16
+ * Only a scalar slot can lift, so the marker means nothing on a range, list or lambda parameter
17
+ * and the linter refuses it there. A REPEATING scalar slot is also never this marker's business —
18
+ * it absorbs a container as members whatever the function's heritage (`GCD(C1:C3)` is 4); its
19
+ * ATP reading is `NoFilter<T>`.
20
+ *
21
+ * At the type level it is `T`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * export function NETWORKDAYS_INTL(
26
+ * startDate: NoLift<Scalar>, endDate: NoLift<Scalar>, weekend?: Scalar, holidays?: Flatten<Scalar>
27
+ * ): number { ... }
28
+ * ```
29
+ */
30
+ export type NoLift<T> = T;
31
+ //# sourceMappingURL=NoLift.d.ts.map
@@ -48,19 +48,39 @@
48
48
  * "the final element of the final group may be omitted" rule; that rule would accept a formula
49
49
  * Excel refuses. An optional slot anywhere else in the group is a compiler error.
50
50
  *
51
+ * ### The maximum, `Max`
52
+ *
53
+ * The second type argument is the largest number of arguments the WHOLE CALL accepts, which is
54
+ * how Excel states it: one number per NAME, compared against the call's total argument count and
55
+ * refused at entry (`Excess_function_arguments`), never a count of this parameter's own share.
56
+ * `SWITCH`'s 254 therefore covers its `expression` and its trailing `default` as well as the
57
+ * pairs, and `CHOOSEROWS`' covers its `array`.
58
+ *
59
+ * It defaults to **255**, which is the ceiling for most names and the highest any name carries.
60
+ * Declare it only where a name draws the line lower — `XOR`, `IFS`, `SWITCH`, `LAMBDA`, `LET`,
61
+ * `AGGREGATE`, `SORTBY`, `MAXIFS`, `MINIFS`, `CONCAT`, `TEXTJOIN`, `HSTACK`, `VSTACK`,
62
+ * `CHOOSEROWS`, `CHOOSECOLS` and every DOTTED
63
+ * descriptive spelling (`STDEV.S`, `VAR.P`, `MODE.MULT`, …) all stop at 254 where their legacy
64
+ * twins take 255. It cannot be derived from the shape, so it belongs to the declaration.
65
+ *
66
+ * A REST parameter is the one place `Repeating` may be written alongside `...`, and only with an
67
+ * explicit `Max`: `...rest: Repeating<T, 254>` keeps the rest parameter's own 0-or-more meaning
68
+ * and adds nothing but the ceiling. A bare `Repeating<T>` on a rest parameter stays an error —
69
+ * that is the spelling collision the marker exists to avoid.
70
+ *
51
71
  * @example
52
72
  * ```ts
53
73
  * export function SUMIFS(
54
- * sumRange: AcceptError<IRange>,
55
- * criteria: Repeating<[criteriaRange: AcceptError<IReferenceRange>, criteria: AcceptError<IRange>]>
74
+ * sumRange: IRange,
75
+ * criteria: Repeating<[criteriaRange: IReferenceRange, criteria: AcceptError<Scalar>]>
56
76
  * ): IRange {
57
77
  * for (const [range, test] of criteria) { ... }
58
78
  * }
59
79
  *
60
- * export function HSTACK(array: Repeating<AcceptError<IRange>>): IRange {
80
+ * export function HSTACK(array: Repeating<IRange, 254>): IRange {
61
81
  * return array.reduce((acc, next) => acc.concat(next, IRange.Axis.Column));
62
82
  * }
63
83
  * ```
64
84
  */
65
- export type Repeating<T> = T[];
85
+ export type Repeating<T, Max extends number = 255> = T[];
66
86
  //# sourceMappingURL=Repeating.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Declares the parameter's type as ADVISORY: the engine delivers it when it can, and hands the
3
+ * body whatever actually arrived when it cannot, instead of answering `#VALUE!` on the body's
4
+ * behalf.
5
+ *
6
+ * @remarks
7
+ * Excel has no marshalling contract. A function there is called with the operands as they are and
8
+ * calls library helpers for whatever it needs — `LARGE` asks for a range's values and gets every
9
+ * area of a union, `ROWS` never dereferences at all and answers `#REF!` when it sees two areas,
10
+ * `SUMPRODUCT` demands one rectangle and fails on the same argument. Three answers, no rule: the
11
+ * body's own access pattern is the whole of it.
12
+ *
13
+ * A declared surface cannot express that, and modelling it would mean a marker per behavior. This
14
+ * is the boundary instead — ONE marker saying "the type is what the caller is told, not a
15
+ * guarantee to the body". The declared `T` still reaches the function help, the wizard and the
16
+ * linter, because that IS what the slot means to a user; it just stops being a gate.
17
+ *
18
+ * | argument | plain `IRange` | `ReportType<IRange>` |
19
+ * | --- | --- | --- |
20
+ * | `A1:A5` | the range | the range |
21
+ * | `(A1:A5,B1:B2)` — a union | `#VALUE!`, the call never runs | the areas, as `IRange[]` |
22
+ * | a value, an error | `#VALUE!` / propagates | the value, the error |
23
+ *
24
+ * At the type level it is `T` — like {@link AcceptError}, and for the same reason: the marker is a
25
+ * RULE, not a type. A body that declares it and then assumes `T` will crash on the argument the
26
+ * marker exists to deliver, so narrow first. {@link IFunctionArguments.getKindAt} is total over
27
+ * what can arrive and {@link IFunctionArguments.getAreaCountAt} answers the union question the
28
+ * kind cannot — a plain reference is one area, a union is more.
29
+ *
30
+ * Its use is meant to stay countable: a slot earns it with a rule Excel actually shows, never
31
+ * with a guess.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * export function ROWS(array: ReportType<IRange>): Scalar {
36
+ * if (FormulaContext.getArgs().getAreaCountAt(0) > 1) return FormulaError.BuiltIn.Ref!;
37
+ * return array.getRowCount();
38
+ * }
39
+ * ```
40
+ */
41
+ export type ReportType<T> = T;
42
+ //# sourceMappingURL=ReportType.d.ts.map
@@ -42,7 +42,7 @@ export declare namespace Scalar {
42
42
  * text's shape (decimal places, grouping) survives for format inference.
43
43
  *
44
44
  * @remarks
45
- * Callers apply this to every text→number path and to nothing else — measured
45
+ * Callers apply this to every text→number path and to nothing else. It is
46
46
  * truncation, not rounding: `1234567890.123456789` stores `…345`, never `…346`.
47
47
  */
48
48
  function truncateNumberText(text: string): string;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The KIND of one value — the total discriminator over {@link IFunctionArguments.RawArg}, and the
3
+ * vocabulary a RETURN declaration speaks ({@link IFunction.IReturnType.getKind}).
4
+ *
5
+ * @remarks
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 Excel separates them:
8
+ * `VLOOKUP(10,10,1,TRUE)` is `#N/A` while `VLOOKUP(10,{10},1,TRUE)` is 10, and `TYPE` answers
9
+ * 1 vs 64. The kind is what the CALLER supplied; the extent is merely its size.
10
+ *
11
+ * The scalar kinds ARE {@link ScalarType} values — one vocabulary, so
12
+ * `getKindAt(i) === ScalarType.Boolean` reads naturally — extended with the four kinds only an
13
+ * argument can be: a reference, a non-reference array, a callable, and no argument at all. As an
14
+ * argument kind, {@link ScalarType.Null} means a BLANK value.
15
+ *
16
+ * The names and values are ours. The numeric codes Excel's `TYPE` function answers are a
17
+ * PROJECTION of this kind (see `TYPE`'s implementation), not the kind itself.
18
+ *
19
+ * @see {@link IFunctionArguments.getKindAt}
20
+ */
21
+ export declare const ValueKind: {
22
+ /** A reference — `A1`, `A1:B3`, or a reference-returning call (`INDEX`, `OFFSET`, `TAKE`). */
23
+ readonly Reference: "reference";
24
+ /** An ARRAY that is not a reference — `{1,2}`, or a computed one (`SEQUENCE`, `TRANSPOSE(…)`). */
25
+ readonly Array: "array";
26
+ /** A callable — `LAMBDA(…)`, an eta-reduced function name, or a lambda-valued binding. */
27
+ readonly Lambda: "lambda";
28
+ /**
29
+ * OMITTED — nothing at this position: the empty comma of `CUMIPMT(,120,…)`, or a position
30
+ * past what the caller wrote. A blank CELL is a `Reference` (blankness is the cell's value).
31
+ * ABSENT-vs-omitted — whether the position exists in the call at all — is not a kind; it is
32
+ * `index >= getLength()`.
33
+ */
34
+ readonly Omitted: "omitted";
35
+ readonly Number: "number";
36
+ readonly String: "string";
37
+ readonly Boolean: "boolean";
38
+ readonly Error: "error";
39
+ readonly RichData: "richData";
40
+ readonly Null: "null";
41
+ };
42
+ export type ValueKind = typeof ValueKind[keyof typeof ValueKind];
43
+ //# sourceMappingURL=ValueKind.d.ts.map
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Declares that a function's RESULT can change with nothing dirty, so a cell naming it
3
+ * recalculates on every pass.
4
+ *
5
+ * ```ts
6
+ * export function NOW(): Volatile<number> { ... }
7
+ * ```
8
+ *
9
+ * @see {@link IFunction.ReturnTypeJSON.volatile}
10
+ */
11
+ export type Volatile<T> = T;
12
+ //# sourceMappingURL=Volatile.d.ts.map
@@ -10,17 +10,21 @@ export declare const WildCard: {
10
10
  /**
11
11
  * Compiles Excel wildcard text into a regex.
12
12
  *
13
- * @param anchor Whether the pattern must match the WHOLE string. Excel matches a whole cell, so
14
- * every lookup and criteria caller anchors; `SEARCH`, which looks for a substring, does not.
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. Excel matches a whole cell, so every lookup and criteria
15
+ * caller anchors; `SEARCH`, which looks for a substring, does not; and a `D` function's criteria
16
+ * table is the prefix form — `DSUM` with the criterion `appl` takes the row whose value is
17
+ * `Apple`, where `COUNTIF` with the same criterion takes none.
15
18
  *
16
19
  * @remarks
17
- * `~` escapes the next `*`, `?` or `~`; standing alone it is a literal tilde (`COUNTIF(range,
18
- * "a~b")` finds the text `a~b`). One left-to-right pass, because chained replaces cannot express
19
- * this: the previous implementation guarded its `*`/`?` rewrites with `([^~]??)`, a lazy OPTIONAL
20
- * group that matches empty and so guards nothing, and then unescaped `~([?*])` — which could
21
- * never fire, the `*` and `?` having already become `.*` and `.`. Every escape was silently
22
- * ignored, so `"~*"` compiled to `~.*`: a literal tilde followed by anything.
20
+ * `~` escapes the next `*`, `?` or `~`; before anything else it is dropped, not kept —
21
+ * `SEARCH("~b","abc")` is 2 and `MATCH("a~b",…)` finds the text `ab`. A caller that reaches this
22
+ * compiler only when the pattern holds a `*` or `?` — which is what COUNTIF and its family do —
23
+ * therefore still compares `"a~b"` literally, because that criteria never becomes a pattern.
24
+ *
25
+ * One left-to-right pass; chained replaces cannot express the escape, since by the time a pass
26
+ * could unescape `~*` the `*` has already become `.*`.
23
27
  */
24
- toRegex: (lookupText: string, flags?: any, anchor?: boolean) => RegExp;
28
+ toRegex: (lookupText: string, flags?: any, anchor?: boolean | "start") => RegExp;
25
29
  };
26
30
  //# sourceMappingURL=WildCard.d.ts.map
@@ -1,12 +1,17 @@
1
1
  export * from './Scalar';
2
2
  export * from './ScalarType';
3
+ export * from './ValueKind';
3
4
  export * from './WildCard';
4
5
  export * from './Lambda';
5
6
  export * from './ErrorPolicy';
6
7
  export * from './Repeating';
7
8
  export * from './Flatten';
9
+ export * from './NoLift';
10
+ export * from './NoFilter';
11
+ export * from './ReportType';
8
12
  export * from './Omittable';
9
- export * from './Compat';
13
+ export * from './Lazy';
14
+ export * from './Volatile';
10
15
  export * from './IRange';
11
16
  export * from './IReferenceRange';
12
17
  export * from './IRichData';
@@ -1 +0,0 @@
1
- var e;Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),function(e){e.MAX_TEXT_LENGTH=32767;let t=e.MAX_SIGNIFICANT_DIGITS=15;e.truncateNumberText=function(e){let n=e.length;if(n<=t)return e;let r=0,i=null;for(let a=0;a<n;a++){let n=e.charCodeAt(a);if(n>=48&&n<=57){if(r===0&&n===48)continue;r++,r>t&&((i??=e.split(``))[a]=`0`)}else if((n===69||n===101)&&r>0)break}return i===null?e:i.join(``)}}(e||={});var t,n,r,i,a={Number:`number`,String:`string`,Boolean:`boolean`,Error:`error`,RichData:`richData`,Null:`null`},o={...a,Date:`date`},s=/[.*+?^${}()|[\]\\]/,c=e=>s.test(e)?`\\`+e:e,l={isWildCard:e=>typeof e==`string`&&/[*?]/.test(e),toRegex:(e,t,n=!1)=>{let r=``,i=e.length;for(let t=0;t<i;t++){let n=e[t];if(n===`~`){let n=e[t+1];n===`*`||n===`?`||n===`~`?(r+=c(n),t++):r+=`~`;continue}n===`*`?r+=`.*`:r+=n===`?`?`.`:c(n)}return RegExp(n?`^${r}$`:r,t)}},u={noReferenceLift:`A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.`,noMemberFilter:`Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!.`},d={atp:[`noReferenceLift`,`noMemberFilter`]};function f(e){if(!e)return null;let t=e.trim().toLowerCase();for(let e of Object.keys(u))if(e.toLowerCase()===t)return e;return null}(n=t||={}).Axis={Column:`column`,Row:`row`},n.AxisSelection={...t.Axis,Both:`both`},n.Direction={Up:`up`,Down:`down`,Left:`left`,Right:`right`},(r||={}).Aggregate={Count:`count`,NumericalCount:`numericalCount`,Sum:`sum`,Average:`average`,StdDev:`stdDev`,PopulationStdDev:`stdDevP`,Variance:`var`,PopulationVariance:`varP`,Min:`min`,Max:`max`},function(e){let t=e.Code={Parse:0,Null:1,Div0:2,Value:3,Ref:4,Name:5,Num:6,NA:7,GettingData:8,Spill:9,Connect:10,Blocked:11,Unknown:12,Field:13,Calc:14,Busy:16,Python:19,Timeout:20},n=e.Label={Parse:`#PARSE!`,Null:`#NULL!`,Div0:`#DIV/0!`,Value:`#VALUE!`,Ref:`#REF!`,Name:`#NAME?`,Num:`#NUM!`,NA:`#N/A`,GettingData:`#GETTING_DATA`,Spill:`#SPILL!`,Connect:`#CONNECT!`,Blocked:`#BLOCKED!`,Unknown:`#UNKNOWN!`,Field:`#FIELD!`,Calc:`#CALC!`,Busy:`#BUSY!`,Python:`#PYTHON!`,Timeout:`#TIMEOUT!`};class r extends Error{constructor(e,t,n,r){super(n,r),this._label=t,this._code=e,this.details=r}static{this.code=i.Code.Unknown}get isFormulaError(){return!0}getLabel(){return this._label}getCode(){return this._code}equals(e){return!!e&&(this._code===e._code||this._code===e.code)}get[Symbol.toStringTag](){return`[FormulaError]`}toString(){return this._label}}e.Known=r;class a extends r{constructor(e,r){super(t.Parse,n.Parse,e,r)}static{this.code=i.Code.Parse}getDetails(){let e=this.details;return{line:e?.line??1,column:e?.column??1,offset:e?.offset??0,length:e?.length??0}}}e.Parse=a;class o extends r{constructor(e,r){super(t.Null,n.Null,e,r)}static{this.code=i.Code.Null}}e.Null=o;class s extends r{constructor(e,r){super(t.Div0,n.Div0,e,r)}static{this.code=i.Code.Div0}}e.Div0=s;class c extends r{constructor(e,r){super(t.Value,n.Value,e,r)}static{this.code=i.Code.Value}}e.Value=c;class l extends r{constructor(e,r){super(t.Ref,n.Ref,e,r)}static{this.code=i.Code.Ref}}e.Ref=l;class u extends r{constructor(e,r){super(t.Name,n.Name,e,r)}static{this.code=i.Code.Name}}e.Name=u;class d extends r{constructor(e,r){super(t.Num,n.Num,e,r)}static{this.code=i.Code.Num}}e.Num=d;class f extends r{constructor(e,r){super(t.NA,n.NA,e,r)}static{this.code=i.Code.NA}}e.NA=f;class p extends r{constructor(e,r){super(t.GettingData,n.GettingData,e,r)}static{this.code=i.Code.GettingData}}e.GettingData=p;class m extends r{constructor(e,r){super(t.Spill,n.Spill,e,r)}static{this.code=i.Code.Spill}}e.Spill=m;class h extends r{constructor(e,r){super(t.Connect,n.Connect,e,r)}static{this.code=i.Code.Connect}}e.Connect=h;class g extends r{constructor(e,r){super(t.Blocked,n.Blocked,e,r)}static{this.code=i.Code.Blocked}}e.Blocked=g;class _ extends r{constructor(e,r){super(t.Unknown,n.Unknown,e,r)}static{this.code=i.Code.Unknown}}e.Unknown=_;class v extends r{constructor(e,r){super(t.Field,n.Field,e,r)}static{this.code=i.Code.Field}}e.Field=v;class y extends r{constructor(e,r){super(t.Calc,n.Calc,e,r)}static{this.code=i.Code.Calc}}e.Calc=y;class b extends r{constructor(e,r){super(t.Busy,n.Busy,e,r)}static{this.code=i.Code.Busy}}e.Busy=b;class x extends r{constructor(e,r){super(t.Python,n.Python,e,r)}static{this.code=i.Code.Python}}e.Python=x;class S extends r{constructor(e,r){super(t.Timeout,n.Timeout,e,r)}static{this.code=i.Code.Timeout}}e.Timeout=S}(i||={});var p={};p[i.Code.Parse]=i.Parse,p[i.Code.Null]=i.Null,p[i.Code.Div0]=i.Div0,p[i.Code.Value]=i.Value,p[i.Code.Ref]=i.Ref,p[i.Code.Name]=i.Name,p[i.Code.Num]=i.Num,p[i.Code.NA]=i.NA,p[i.Code.GettingData]=i.GettingData,p[i.Code.Spill]=i.Spill,p[i.Code.Connect]=i.Connect,p[i.Code.Blocked]=i.Blocked,p[i.Code.Unknown]=i.Unknown,p[i.Code.Field]=i.Field,p[i.Code.Calc]=i.Calc,p[i.Code.Busy]=i.Busy,p[i.Code.Python]=i.Python,p[i.Code.Timeout]=i.Timeout;var m=new Map,h=new Map,g=new Map,_=new Map,v=Object.keys(p);for(let e=0;e<v.length;e++){let t=p[v[e]],n=new t;g.set(n.getLabel(),t),_.set(n.getCode(),t),m.set(n.getLabel(),n),h.set(n.getCode(),n)}(function(e){let t=e.getBuiltInByCode=e=>h.get(e);e.BuiltIn={Parse:t(i.Code.Parse),Null:t(i.Code.Null),Div0:t(i.Code.Div0),Value:t(i.Code.Value),Ref:t(i.Code.Ref),Name:t(i.Code.Name),Num:t(i.Code.Num),NA:t(i.Code.NA),GettingData:t(i.Code.GettingData),Spill:t(i.Code.Spill),Connect:t(i.Code.Connect),Blocked:t(i.Code.Blocked),Unknown:t(i.Code.Unknown),Field:t(i.Code.Field),Calc:t(i.Code.Calc),Busy:t(i.Code.Busy),Python:t(i.Code.Python),Timeout:t(i.Code.Timeout)},e.newTypedError=(e,t,n)=>{let r;return r=typeof e==`string`?g.get(e):_.get(e),r||=i.Unknown,new r(t,n)},e.getBuiltInByLabel=e=>m.get(e),e.isError=function(e,t){return!!e&&!0===e.isFormulaError&&(t===void 0||e.getCode()===t)}})(i||={});var y=class{createRange(e,t,n){throw new S}getReference(e,t){throw new S}getResizedReference(e,t,n){throw new S}getNumberFormat(e,t){throw new S}fromSerialDate(e,t){throw new S}toSerialDate(e,t){throw new S}getDateParts(e,t){throw new S}getSerialDate(e,t,n,r,i,a,o){throw new S}getNow(){throw new S}getValueAt(e,t,n,r){return null}getEntireCoords(){return C}isValidDate(e,t){return e instanceof Date||Object.prototype.toString.call(e)===`[object Date]`?!isNaN(e.getTime()):!t&&typeof e==`number`&&!(e<0||e>T)}getRow(){return 0}getColumn(){return 0}getFormulaAt(e,t,n){return null}getSpillAt(e,t,n){return null}getSheetIndex(e){return-1}getSheetCount(){return 1}markVolatile(){}formatResults(e){}filterHidden(e,t){return e}filterTotals(e){return e}getFunction(e){return null}getAddress(e,t){throw new S}parseAsSerialDate(e,t){throw new S}parseAsDate(e,t){throw new S}parseAsNumber(e,t){throw new S}createCriteria(e){throw new S}parseAsLiteral(e){let t=e.toUpperCase();return t===`TRUE`||t!==`FALSE`&&i.getBuiltInByLabel(t)}toText(e){return typeof e==`string`?e:e==null?``:typeof e==`boolean`?e?`TRUE`:`FALSE`:e?.isFormulaError?e.getLabel():String(e)}compare(e,t,n){if(e===t)return 0;let r=b(e),i=b(t);return r===i?e<t?-1:+(e>t):r<i?-1:1}getRuntime(){return w}getArgs(){throw new S(x)}},b=e=>{if(e==null)return 0;switch(typeof e){case`number`:return 1;case`string`:return 2;case`boolean`:return 3;default:return 4}},x=`FormulaContext.getArgs() is only valid while a function body is running`,S=class extends Error{constructor(e=`Not implemented in StubbedFormulaContext`){super(e),this.name=`NotImplementedError`}},C=Object.freeze({colStart:0,rowStart:0,colEnd:2**14-1,rowEnd:2**20-1}),w={isDate1904:()=>!1,getLocale:()=>O.tag,getLocaleProfile:()=>O,isR1C1:()=>!1,getNow:()=>0,getLocation:()=>`unknown`,getVersion:()=>`1.0.0`,getOS:()=>`unknown`,getUser:()=>`unidentified`,getDescription:()=>`Stubbed Formula Context`},T=2958465,E=new y,D=class{constructor(){this._scope=E,this._argsFn=null}_setScope(e){this._scope=e??E}_getScope(){return this._scope}_setArgsProvider(e){this._argsFn=e}getNumberFormat(e,t){return this._getScope().getNumberFormat(e,t)}getEntireCoords(){return this._getScope().getEntireCoords()??C}parseAsSerialDate(e,t){return this._getScope().parseAsSerialDate(e,t)}parseAsDate(e,t){return this._getScope().parseAsDate(e,t)}parseAsNumber(e,t){return this._getScope().parseAsNumber(e,t)}createCriteria(e){return this._getScope().createCriteria(e)}parseAsLiteral(e){let t=this._getScope();return t.parseAsLiteral?t.parseAsLiteral(e):E.parseAsLiteral(e)}toText(e){return this._getScope().toText(e)}isValidDate(e,t=!1){return this._getScope().isValidDate(e,t)}fromSerialDate(e,t=!1){return this._getScope().fromSerialDate(e,t)}toSerialDate(e,t=!1){return this._getScope().toSerialDate(e,t)}getDateParts(e,t){return this._getScope().getDateParts(e,t)}getSerialDate(e,t,n,r=0,i=0,a=0,o=0){return this._getScope().getSerialDate(e,t,n,r,i,a,o)}getNow(){return this._getScope().getNow()}createRange(e,t,n){return this._getScope().createRange(e,t,n)}getRow(){return this._getScope().getRow?.()??0}getColumn(){return this._getScope().getColumn?.()??0}getReference(e,t){return this._getScope().getReference(e,t)}getResizedReference(e,t,n){return this._getScope().getResizedReference(e,t,n)}getValueAt(e,t,n){return this._getScope().getValueAt(e,t,n)}getFormulaAt(e,t,n){return this._getScope().getFormulaAt?.(e,t,n)??null}getSpillAt(e,t,n){return this._getScope().getSpillAt?.(e,t,n)??null}getSheetIndex(e){return this._getScope().getSheetIndex?.(e)??-1}getSheetCount(){return this._getScope().getSheetCount?.()??1}markVolatile(){this._getScope().markVolatile?.()}formatResults(e){this._getScope().formatResults?.(e)}filterHidden(e,t){return this._getScope().filterHidden?.(e,t)??e}filterTotals(e){return this._getScope().filterTotals?.(e)??e}getFunction(e){return this._getScope().getFunction?.(e)??null}getAddress(e,t){return this._getScope().getAddress(e,t)}compare(e,t,n){return this._getScope().compare?.(e,t,n)??E.compare(e,t,n)}getRuntime(){return this._getScope().getRuntime()}getArgs(){let e=this._argsFn,t=e?e():null;if(!t)throw new S(x);return t}get[Symbol.toStringTag](){return`[FormulaContext]`}toString(){return this._getScope()?.toString?.()??`{STUB SCOPE}`}},O=Object.freeze({tag:`en-US`,numberingSystem:`latn`,decimal:`.`,group:`,`,grouping:[3],minusSign:`-`,percentSign:`%`,permilleSign:`‰`,currencyCode:`USD`,currencySymbol:`$`,currencyDisplay:`symbol`,currencyPosition:`before`,currencySpacing:`tight`,date:Object.freeze({calendar:`gregory`,short:`M/d/yy`,medium:`MMM d, y`,long:`MMMM d, y`,timeShort:`h:mm a`,timeLong:`h:mm:ss a`,am:`AM`,pm:`PM`,firstDay:0,weekend:[6,0],monthsWide:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],monthsAbbr:[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],weekdaysWide:[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],weekdaysAbbr:[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],hour12:!0}),listSeparator:`,`,csvDelimiter:`,`,rtl:!1,collator:Object.freeze({sensitivity:`base`,numeric:!0})}),k=new D;exports.CompatAliases=d,exports.CompatFeatures=u,exports.DEFAULT_LOCALE_PROFILE=O,exports.FormulaContext=k,Object.defineProperty(exports,"FormulaError",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"IRange",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"IRangeStats",{enumerable:!0,get:function(){return r}}),exports.InteropScalarType=o,exports.Observable=class{constructor(e){this._subscribeFn=e}subscribe(e,t,n){let r=typeof e==`object`?{next:e.next||(()=>{}),error:e.error||(()=>{}),complete:e.complete||(()=>{}),unsubscribe:()=>{}}:{next:e||(()=>{}),error:t||(()=>{}),complete:n||(()=>{}),unsubscribe:()=>{}},i=this._subscribeFn(r);return r.unsubscribe=()=>{typeof i==`function`&&i()},r}},Object.defineProperty(exports,"Scalar",{enumerable:!0,get:function(){return e}}),exports.ScalarType=a,exports.ScopedFormulaContext=D,exports.StubbedFormulaContext=y,exports.WildCard=l,exports.resolveCompatFeature=f,exports.resolveCompatFeatures=function(e){let t=f(e);if(t)return[t];let n=(e??``).trim().toLowerCase();for(let e of Object.keys(d))if(e.toLowerCase()===n)return d[e];return null};
@@ -1,77 +0,0 @@
1
- /**
2
- * The behaviors `@compat` can turn on, and what each one does.
3
- *
4
- * @remarks
5
- * A feature earns a place here only if the BODY cannot do it — the decision happens before the
6
- * body runs, or instead of running it. Everything a body can decide for itself belongs in the
7
- * body, where `FormulaContext.getArgs()` and `Omittable` already reach.
8
- *
9
- * Function-level until a measurement forces otherwise: `noReferenceLift` is per-function in
10
- * Excel, and no function is known whose parameters disagree.
11
- *
12
- * @see {@link https://www.sheetxl.com/docs/guides/concepts/udf | UDF authoring guide}
13
- */
14
- export declare const CompatFeatures: {
15
- /**
16
- * A multi-cell REFERENCE at a non-repeating scalar parameter is `#VALUE!` rather than a
17
- * broadcast.
18
- *
19
- * Excel's Analysis-ToolPak family answers `CUMIPMT(G1:G2,120,100000,13,24,0)` with `#VALUE!`
20
- * where the native `ROUND(B1:B3,3)` spills three results. A multi-cell reference has no way to
21
- * become a scalar there, because these functions never intersect. An ARRAY at the same slot
22
- * still lifts (`MROUND({3,4,5},5)` spills), so the refusal is about references specifically,
23
- * and a REPEATING slot absorbs a container as members either way (`GCD(C1:C3)` is 4) — so this
24
- * never applies to one.
25
- */
26
- readonly noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.";
27
- /**
28
- * Members of a REPEATING scalar parameter are coerced rather than filtered: numeric text
29
- * parses, a blank inside a multi-cell range reads 0, and a boolean or non-numeric text member
30
- * is `#VALUE!` for the whole call.
31
- *
32
- * The native family FILTERS — `SUM({1,"8",TRUE})` is 1, the text and the boolean skipped, and a
33
- * blank cell contributes nothing. Excel's Analysis-ToolPak family coerces instead:
34
- * `GCD({6,"8",12})` is 2, `GCD({6,TRUE,12})` is `#VALUE!`, `LCM(6,A1:A2)` over two blank cells
35
- * is 0. A direct argument follows the same rule (`GCD(6,TRUE,12)` is `#VALUE!` where
36
- * `SUM(6,TRUE,12)` is 19), and a one-cell blank reference or an omitted argument is still
37
- * skipped — it never became a member.
38
- */
39
- readonly noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!.";
40
- };
41
- /**
42
- * One of the {@link CompatFeatures} names.
43
- */
44
- export type CompatFeature = keyof typeof CompatFeatures;
45
- /**
46
- * Family aliases: one name an author writes that expands to several {@link CompatFeatures}.
47
- *
48
- * @remarks
49
- * Excel's Analysis-ToolPak heritage is ONE measured rule with two halves that act on disjoint
50
- * parameter kinds — `noReferenceLift` at a non-repeating scalar slot, `noMemberFilter` at a
51
- * repeating one — so every function in the family carries the same two bits and `@compat atp`
52
- * says so in one word. The alias is expanded by the linter; only the atomic features are ever
53
- * stored, so `@compat atp` and `@compat noReferenceLift noMemberFilter` emit the same declaration.
54
- * The atomic names stay available for the day a function measures as disagreeing on one half.
55
- */
56
- export declare const CompatAliases: Readonly<Record<string, readonly CompatFeature[]>>;
57
- /**
58
- * Resolves a `@compat` name — a feature or a family alias — CASE-INSENSITIVELY, to the canonical
59
- * features it turns on.
60
- *
61
- * @param name The name as the author wrote it.
62
- * @returns The canonical features, or `null` when no feature or alias goes by that name.
63
- */
64
- export declare function resolveCompatFeatures(name: string): readonly CompatFeature[] | null;
65
- /**
66
- * Resolves a `@compat` feature name, CASE-INSENSITIVELY, to its canonical spelling.
67
- *
68
- * @param name The name as the author wrote it.
69
- * @returns The canonical name, or `null` when no feature goes by it.
70
- *
71
- * @remarks
72
- * Authors write `@compat noReferenceLift`; `@Compat NOREFERENCELIFT` means the same thing. Only
73
- * the canonical spelling is ever stored, so the declaration a build emits does not depend on how
74
- * the tag was typed.
75
- */
76
- export declare function resolveCompatFeature(name: string): CompatFeature | null;
77
- //# sourceMappingURL=Compat.d.ts.map