@sheetxl/sdk 0.7.28-beta.3 → 0.8.0-beta.1

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.
Files changed (66) hide show
  1. package/browser/cjs/{BX6A6xGDOr_td9mw.cjs → BatsV2UUraVDCRXm.cjs} +1 -1
  2. package/browser/cjs/CUz53T65cRGQRgvv.cjs +33 -0
  3. package/browser/cjs/{CWCKcp58KidyndaL.cjs → DU0kYUtdFa3jK-im.cjs} +1 -1
  4. package/browser/cjs/{B4PKKgaDTG9aSO-f.cjs → Dv4yIPLV98M5zLHa.cjs} +1 -1
  5. package/browser/cjs/a0Z-SXs_N71CtqYb.cjs +1 -0
  6. package/browser/cjs/index.cjs +2 -2
  7. package/browser/esm/{Dv8FyXyeygJPXoHo.mjs → 6JKSOvc5czaQB2Bj.mjs} +3 -3
  8. package/browser/esm/{DZfds6s3ayTZrozO.mjs → B0HS42a7lga1k1U_.mjs} +1 -1
  9. package/browser/esm/{C78IaCXqwCcraBPe.mjs → BtuJ9AGzeURtAsGo.mjs} +6946 -5790
  10. package/browser/esm/{CX1NO_a1QPjXDvTU.mjs → DGU6sM25u0EWCKl1.mjs} +3 -3
  11. package/browser/esm/{B1gpnr-7kLU7jTy-.mjs → DlPMeIyxT9tG_WDk.mjs} +2 -2
  12. package/browser/esm/{CPgz9_iM7xyAcytg.mjs → f2G3QRgEbvFJcoa2.mjs} +2 -2
  13. package/browser/esm/index.mjs +17 -14
  14. package/browser/esm/{Rj8e7SashcMlcdZJ.mjs → uyWBMSIxMlt8n5Z3.mjs} +2 -2
  15. package/node/esm/{8VtzCFSmLPKxJjOa.mjs → -pxdn3M3tc6PLHs7.mjs} +20 -20
  16. package/node/esm/{BkY99r-c3BhlT_Kv.mjs → 0n5bslM9jhO1JnI2.mjs} +1 -1
  17. package/node/esm/{DE3eIaqkk5xzmV1c.mjs → Cku7XiUvw1xrRasi.mjs} +1 -1
  18. package/node/esm/index.mjs +9650 -8487
  19. package/package.json +6 -6
  20. package/types/scripting-enums.json +6 -0
  21. package/types/scripting.d.ts +586 -27
  22. package/types/src/anchored/IAnchored.d.ts +27 -0
  23. package/types/src/calculation/Calculation.d.ts +26 -12
  24. package/types/src/calculation/ICalculation.d.ts +178 -0
  25. package/types/src/calculation/executor/CalcExecutor.d.ts +314 -14
  26. package/types/src/calculation/executor/CalcExecutorUtils.d.ts +31 -0
  27. package/types/src/calculation/executor/CircularReference.d.ts +81 -0
  28. package/types/src/calculation/grid/CalcGrid.d.ts +3 -1
  29. package/types/src/calculation/grid/CalcGridUtils.d.ts +3 -2
  30. package/types/src/calculation/grid/ICalcGrid.d.ts +12 -1
  31. package/types/src/calculation/spatial/CircularEntry.d.ts +18 -0
  32. package/types/src/calculation/spatial/index.d.ts +1 -0
  33. package/types/src/calculation/state/CalcNode.d.ts +44 -17
  34. package/types/src/calculation/state/CalcState.d.ts +78 -15
  35. package/types/src/calculation/state/CalculationContext.d.ts +42 -1
  36. package/types/src/calculation/state/IContextContainer.d.ts +31 -0
  37. package/types/src/calculation/state/_ReadObservedGrid.d.ts +90 -0
  38. package/types/src/cell/ICell.d.ts +16 -0
  39. package/types/src/cellRange/ICellRange.d.ts +51 -21
  40. package/types/src/condition/AnchoredConditional.d.ts +26 -6
  41. package/types/src/conditionalFormat/ConditionalFormat.d.ts +8 -1
  42. package/types/src/conditionalFormat/IConditionalFormat.d.ts +4 -1
  43. package/types/src/conditionalFormat/IConditionalFormatCollection.d.ts +6 -2
  44. package/types/src/dataValidation/IDataValidationCollection.d.ts +6 -2
  45. package/types/src/hyperlink/IHyperlink.d.ts +3 -1
  46. package/types/src/hyperlink/_Hyperlink.d.ts +6 -0
  47. package/types/src/lib/utils/_Utils.d.ts +7 -0
  48. package/types/src/lib/utils/utils.browser.d.ts +5 -0
  49. package/types/src/license/LicenseDetails.d.ts +5 -0
  50. package/types/src/primitives/CalcSignal.d.ts +20 -0
  51. package/types/src/primitives/PrimitiveUtils.d.ts +4 -2
  52. package/types/src/primitives/Range.d.ts +3 -1
  53. package/types/src/protectedRange/IProtectedRangeCollection.d.ts +7 -2
  54. package/types/src/scripting/FunctionArguments.d.ts +22 -0
  55. package/types/src/scripting/TypedFunction.d.ts +60 -0
  56. package/types/src/scripting/_ScriptUtils.d.ts +13 -0
  57. package/types/src/sheet/Sheet.d.ts +41 -2
  58. package/types/src/sheet/SheetCell.d.ts +2 -0
  59. package/types/src/sheet/SheetRange.d.ts +3 -0
  60. package/types/src/sheet/_SheetAutoFitUtils.d.ts +28 -0
  61. package/types/src/sheet/_SheetStateTypes.d.ts +14 -1
  62. package/types/src/style/IStyle.d.ts +5 -0
  63. package/types/src/table/AnchoredTable.d.ts +17 -1
  64. package/types/src/text/TextUtils.d.ts +18 -0
  65. package/browser/cjs/1mH2uhx_Dmceu88H.cjs +0 -33
  66. package/browser/cjs/D6cjnwWR_iUSe1f6.cjs +0 -1
@@ -1,6 +1,6 @@
1
- import { ITransaction } from '../transaction';
2
1
  import { ICollection } from '../type';
3
2
  import { ICellRange, ICellRanges } from '../cellRange';
3
+ import { IAnchored } from '../anchored';
4
4
  import { IDataValidation } from './IDataValidation';
5
5
  /**
6
6
  * Holds a collection of {@link IDataValidation}s.
@@ -38,8 +38,12 @@ export interface IDataValidationCollection extends ICollection<IDataValidation>
38
38
  export declare namespace IDataValidationCollection {
39
39
  /**
40
40
  * Options for adding a data validation to the collection.
41
+ *
42
+ * @remarks
43
+ * `replaceExisting` redefines the validation at `index` when it covers exactly the same ranges —
44
+ * see {@link IAnchored.AddOptions.replaceExisting}.
41
45
  */
42
- interface AddOptions extends IDataValidation.Properties, ITransaction.OperationOptions {
46
+ interface AddOptions extends IDataValidation.Properties, IAnchored.AddOptions {
43
47
  }
44
48
  interface GetItemsOptions {
45
49
  /**
@@ -49,7 +49,9 @@ export interface IHyperlink {
49
49
  * @remarks
50
50
  * This has no counterpart in Excel; it is ours and applies to links opened in a browser.
51
51
  *
52
- * @defaultValue `_self` for a location within this workbook, otherwise `_blank`.
52
+ * @defaultValue `_self` for a location within this workbook or a `mailto:`/`tel:`/`sms:`
53
+ * address (handled by another application, so there is nothing to show in a new tab),
54
+ * otherwise `_blank`.
53
55
  */
54
56
  getTarget(): string;
55
57
  /**
@@ -1,5 +1,11 @@
1
1
  import { ITypes } from '../type';
2
2
  import { IHyperlink } from './IHyperlink';
3
+ /**
4
+ * `true` for an address the browser hands to another application (`mailto:`, `tel:`, `sms:`)
5
+ * rather than rendering.
6
+ * @internal
7
+ */
8
+ export declare const isHandlerScheme: (address: string) => boolean;
3
9
  export declare class Hyperlink implements IHyperlink {
4
10
  protected _t: () => string;
5
11
  protected _p: IHyperlink.Properties;
@@ -15,6 +15,13 @@ export interface HostDetails {
15
15
  domain?: string | null;
16
16
  fingerprint?: NodeFingerprint;
17
17
  }
18
+ /**
19
+ * A placeholder license key: the "evaluation" spellings a caller may pass to
20
+ * `LicenseManager.setLicenseKey` to run unlicensed on purpose (`eval`, `trial`, or the
21
+ * `visit …`/`email …` pointer text a starter template ships with). These select an evaluation
22
+ * license; they are never keys, so the persistent key store ignores them.
23
+ */
24
+ export declare function isPlaceholderLicenseKey(key: string | null | undefined): boolean;
18
25
  export declare function getBuildVersion(): string;
19
26
  export declare function getBuildDate(): string;
20
27
  //# sourceMappingURL=_Utils.d.ts.map
@@ -1,6 +1,11 @@
1
1
  import { HostDetails } from './_Utils';
2
2
  import { LicenseDetails } from '../../license';
3
3
  export declare function getHostDetails(): Promise<HostDetails>;
4
+ /**
5
+ * Only the loopback host is a dev environment. A dev *build* served on any other host (a LAN IP,
6
+ * a tunnel) is checked exactly like production: license domains apply and an evaluation shows
7
+ * the watermark.
8
+ */
4
9
  export declare function isDevEnv(): Promise<boolean>;
5
10
  /**
6
11
  * The runtime location - the current page url in the browser.
@@ -8,6 +8,11 @@ export interface LicenseDetails {
8
8
  getCpuCount(): number;
9
9
  getMemory(): number;
10
10
  isEval(): boolean;
11
+ /**
12
+ * `true` when the licensed product may run `feature` without the license watermark: a valid
13
+ * license with no exceptions, or an evaluation on localhost / in a dev build. An evaluation on
14
+ * any other host answers `false` so the watermark shows.
15
+ */
11
16
  isValidFor: (feature: string) => boolean;
12
17
  getDeveloperCount(): number;
13
18
  getType(): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Base of the control-flow signals the calculation engine throws THROUGH a formula's evaluation.
3
+ *
4
+ * @remarks
5
+ * A demand evaluation (a cell the topological sort could not order) reads its precedents lazily;
6
+ * a read that lands on a cell not yet calculated suspends the formula so that cell can go first,
7
+ * and a read that lands on a cell already suspended is a reference cycle. Both are raised from
8
+ * inside the read and unwind the whole evaluation to the executor, which is the only catcher
9
+ * that knows what to do with them.
10
+ *
11
+ * Every catch site on the evaluation path that turns an arbitrary throw into a `#VALUE!` — a
12
+ * function call, a lambda body, a lift over range members, the commit-site dereference — must
13
+ * let a signal pass: {@link isCalcSignal}. A signal is not an error and never becomes a value.
14
+ */
15
+ export declare class CalcSignal {
16
+ readonly isCalcSignal: true;
17
+ }
18
+ /** `true` for a {@link CalcSignal} — a throw that must be rethrown, never turned into a value. */
19
+ export declare const isCalcSignal: (e: unknown) => e is CalcSignal;
20
+ //# sourceMappingURL=CalcSignal.d.ts.map
@@ -127,7 +127,8 @@ export declare function isMultiAreaValue(value: any): boolean;
127
127
  export declare function countArgDepth(value: any): number;
128
128
  export declare function flattenToScalarArray(context: IFormulaContext, coercedArr: FixedPackedArray | Scalar[], currentArg: any, isDirect: boolean | undefined, rangeType: string | null, // the range preference for dims higher than 2 (if not specified then will materialize to array values
129
129
  scalarType: ScalarType | null, // the scalar preference. If not specified no coercion will occur.
130
- errors?: 'reject' | 'accept' | null): void | FormulaError.Known;
130
+ errors?: 'reject' | 'accept' | null, // effective error policy (TypedFunction resolves the default)
131
+ noMemberFilter?: boolean): void | FormulaError.Known;
131
132
  /**
132
133
  * Returns a 2d shape. Either a reference.
133
134
  */
@@ -168,7 +169,8 @@ isDirect: boolean, errors?: 'reject' | 'accept' | null): IRange | any[][] | Form
168
169
  */
169
170
  export declare function addCoercedValue(context: IFormulaContext, coercedArr: FixedPackedArray | Scalar[], currentArg: any, isDirect: boolean, rangeType: 'p' | 'r' | 'm' | null, scalarType: ScalarType | null, // the scalar preference. If not specified then no coercion will occur.
170
171
  allowError: boolean, flatten: boolean, // indicates we should flatten
171
- errors?: 'reject' | 'accept' | null): FormulaError.Known | void;
172
+ errors?: 'reject' | 'accept' | null, // effective error policy (TypedFunction resolves the default)
173
+ noMemberFilter?: boolean): FormulaError.Known | void;
172
174
  /**
173
175
  * Minimal validation used from the return value of functions.
174
176
  */
@@ -58,7 +58,9 @@ export declare class Range<T extends Scalar = Scalar> implements IRange<T> {
58
58
  /** @inheritdoc IRange.filter */
59
59
  filter<TS extends Scalar = T>(callbackFn: (value: TS, coords: IRange.CellCoords, range: IRange<T>) => boolean, options?: IRange.IteratorOptions): this;
60
60
  /** @inheritdoc IRange.flatten */
61
- flatten<TS extends Scalar = T>(options?: IRange.IteratorOptions): TS[];
61
+ flatten(options?: IRange.IteratorOptions): this;
62
+ /** @inheritdoc IRange.getValuesFlat */
63
+ getValuesFlat<TS extends Scalar = T>(options?: IRange.IteratorOptions): TS[];
62
64
  /** @inheritdoc IRange.forEach */
63
65
  forEach<TS extends Scalar = T, B = any>(callbackFn: (value: TS, coords: IRange.CellCoords, range: IRange<T>) => {
64
66
  break: B;
@@ -1,6 +1,6 @@
1
1
  import { ICellRange, ICellRanges } from '../cellRange';
2
2
  import { ICollection } from '../type';
3
- import { ITransaction } from '../transaction';
3
+ import { IAnchored } from '../anchored';
4
4
  import { IProtectedRange } from './IProtectedRange';
5
5
  /**
6
6
  * Holds a collection of {@link IProtectedRange}s.
@@ -41,8 +41,13 @@ export interface IProtectedRangeCollection extends ICollection<IProtectedRange>
41
41
  export declare namespace IProtectedRangeCollection {
42
42
  /**
43
43
  * Options for adding an {@link IProtectedRange}.
44
+ *
45
+ * @remarks
46
+ * `replaceExisting` redefines the entry at `index` when it covers exactly the same ranges; the
47
+ * entry keeps its name unless a free one is supplied — see
48
+ * {@link IAnchored.AddOptions.replaceExisting}.
44
49
  */
45
- interface AddOptions extends IProtectedRange.Properties, ITransaction.OperationOptions {
50
+ interface AddOptions extends IProtectedRange.Properties, IAnchored.AddOptions {
46
51
  }
47
52
  /**
48
53
  * Options for searching for {@link IProtectedRange}s.
@@ -0,0 +1,22 @@
1
+ import { IFunction, IFunctionArguments } from '@sheetxl/primitives';
2
+ /**
3
+ * A bound view, as the marshaller holds it.
4
+ *
5
+ * @internal The public half is {@link IFunctionArguments}; this adds the two things only `_exec`
6
+ * may do — point the view at the argument array its broadcast loop rewrites per output cell, and
7
+ * take it off the engine's shared dispatch buffer when the body is about to re-enter dispatch.
8
+ */
9
+ export interface IArgumentsFrame extends IFunctionArguments {
10
+ /** @see FunctionArguments._setLiftValues */
11
+ _setLiftValues(values: any[] | null): void;
12
+ /** @see FunctionArguments._setPrivateArgs */
13
+ _setPrivateArgs(args: any[]): void;
14
+ }
15
+ /**
16
+ * Binds the view for a call about to dispatch, and returns it so the lift can point it at its
17
+ * per-cell arguments. Pairs with {@link popArguments} in a `finally`.
18
+ */
19
+ export declare const pushArguments: (params: IFunction.ParameterTypeJSON[] | null | undefined, variadic: number, suffix: number, args: any[], argsLength: number) => IArgumentsFrame;
20
+ /** Ends the call {@link pushArguments} began. */
21
+ export declare const popArguments: () => void;
22
+ //# sourceMappingURL=FunctionArguments.d.ts.map
@@ -33,6 +33,14 @@ interface RepeatPlan {
33
33
  short: boolean;
34
34
  /** Period 1 hands the body `T[]`; period 2+ hands it tuples. */
35
35
  tuples: boolean;
36
+ /**
37
+ * Declared parameters SUPPLIED after the group, solved for alongside `n` rather than fixed — a
38
+ * trailing suffix may be optional (SWITCH's `default`).
39
+ *
40
+ * Only `getArgs()` reads it: the suffix parameters are pinned to the TAIL of the argument list,
41
+ * so this is what lets a body ask for its `default` without counting how many pairs preceded it.
42
+ */
43
+ suffix: number;
36
44
  }
37
45
  export declare class TypedFunction implements IFunction {
38
46
  protected _n: string;
@@ -52,6 +60,24 @@ export declare class TypedFunction implements IFunction {
52
60
  };
53
61
  protected _lc: boolean;
54
62
  protected _rlc: boolean;
63
+ /**
64
+ * `@compat noReferenceLift` — a multi-cell REFERENCE at a non-repeating scalar parameter is
65
+ * `#VALUE!` rather than a broadcast (DESIGN-FUNCTION-ARGUMENTS §2.3, §6).
66
+ *
67
+ * A declaration bit and not a body concern, because the body never runs: without it the lift
68
+ * runs instead and answers one result per cell, so there is nothing for a body-facing API to
69
+ * express.
70
+ */
71
+ protected _nrl: boolean;
72
+ /**
73
+ * `@compat noMemberFilter` — members of a REPEATING scalar parameter are coerced rather than
74
+ * filtered: numeric text parses, a blank inside a multi-cell range reads 0, and a boolean or
75
+ * non-numeric text member is `#VALUE!` for the whole call (DESIGN-FUNCTION-ARGUMENTS §2.8, §6).
76
+ *
77
+ * The other half of the ATP heritage `_nrl` carries; `@compat atp` turns on both. It is applied
78
+ * where the native filter lives — the rest branch of the coercion loop — and nowhere else.
79
+ */
80
+ protected _nmf: boolean;
55
81
  /**
56
82
  * The declared return scalar type, normalized (`'*'`/null → null).
57
83
  *
@@ -64,6 +90,16 @@ export declare class TypedFunction implements IFunction {
64
90
  protected _pj: IFunction.ParameterTypeJSON[] | null | undefined;
65
91
  /** Index of the repeating-group parameter, or `-1`. */
66
92
  protected _gi: number;
93
+ /**
94
+ * Index of the one parameter that consumes a VARIABLE number of arguments — a repeating group or
95
+ * a trailing rest — or `-1`.
96
+ *
97
+ * `getArgs()` indexes by PARAMETER (DESIGN-FUNCTION-ARGUMENTS §3.3) and this is the single place
98
+ * parameter numbering and argument numbering part company, so it is resolved once here rather
99
+ * than re-derived per call. `_gi` cannot serve: it covers `Repeating<T>` only, and a plain rest
100
+ * parameter is the same thing to a body asking which parameter its argument landed in.
101
+ */
102
+ protected _va: number;
67
103
  /** Resolved {@link RepeatPlan} per argument count (`null` = an arity the declaration refuses). */
68
104
  protected _gc: Map<number, RepeatPlan | null> | null;
69
105
  constructor(json: IFunction.DeclarationJSON, fn: (...args: any) => any, getContext: () => IFormulaContext | null | undefined, desc?: IFunction.DescriptorJSON | ((locale?: string) => Promise<IFunction.DescriptorJSON>) | null, builtIn?: boolean);
@@ -106,6 +142,30 @@ export declare class TypedFunction implements IFunction {
106
142
  * writes anything into it.
107
143
  */
108
144
  protected _exec<R = any>(argsEval: any[], argsLength: number): R;
145
+ /**
146
+ * `@compat noReferenceLift`: is a multi-cell REFERENCE sitting at a non-repeating scalar
147
+ * parameter? (DESIGN-FUNCTION-ARGUMENTS §2.3, §2.7 rule 3.)
148
+ *
149
+ * Three qualifications, each measured rather than assumed
150
+ * (`fn-battery/adhoc-container-at-slot{,2}`, Excel 16.0 build 20326):
151
+ *
152
+ * - **A REFERENCE, not an array.** `MROUND({3,4,5},5)` spills where `MROUND(A1:A3,5)` is
153
+ * `#VALUE!`, so an array at the same slot still lifts. That is the whole reason this reads the
154
+ * argument's shape rather than trusting the parameter: the engine hands a reference over as
155
+ * COORDS and an array as an `IRange`.
156
+ * - **MULTI-CELL.** A 1×1 reference collapses to its member and is an ordinary argument
157
+ * (`EFFECT(J1,4)` over a text cell is `0.0824…`).
158
+ * - **NON-REPEATING.** A repeating scalar slot ABSORBS a container as members whatever the
159
+ * function's heritage — `GCD(C1:C3)` is 4, `MULTINOMIAL(A1:A3)` is 27720 — and those were the
160
+ * rows that could have broken the rule and did not. Period-1 groups marshal through the rest
161
+ * branch and are already excluded by `rest`; period 2+ expand to per-argument entries, so the
162
+ * group's span is skipped explicitly.
163
+ *
164
+ * A multi-AREA union `(A1:A3,C1:C5)` arrives as an ARRAY of areas and is not treated as a
165
+ * reference here — unmeasured at these slots, and inventing a verdict for it would be the kind
166
+ * of unification §2.0 warns about.
167
+ */
168
+ protected _refusesReferenceLift(params: IFunction.ParameterTypeJSON[] | null | undefined, paramLength: number, argsEval: any[], argsLength: number, plan: RepeatPlan | null): boolean;
109
169
  /**
110
170
  * The consumer half of the lift (CALC-ISSUES item 22 change 2). Each `refLifts` entry is a
111
171
  * reference-only (r:'p') argument holding a producer lift's preserved per-element results.
@@ -13,6 +13,19 @@ export declare const _ReuseGlobalContext: {
13
13
  FormulaError: typeof FormulaError;
14
14
  Observable: typeof Observable;
15
15
  };
16
+ /**
17
+ * Publishes the shared context on `globalThis` for bundled scripts.
18
+ *
19
+ * @remarks
20
+ * A compiled script binds `globalThis.__SHEETXL.FormulaContext` (and `IRange`, `FormulaError`, …)
21
+ * ONCE, at module load — the `Bundler`'s virtual `@sheetxl/primitives` module reads them into
22
+ * top-level `export const`s. Every later call goes through that captured singleton, whose
23
+ * per-evaluation state is {@link setGlobalScope}. So the global only has to exist while a module
24
+ * loads. Idempotent, and never removed: nothing observes its absence, and installing it per
25
+ * function invocation (with a stash and a `delete` on the way out) cost ~290,000 property writes
26
+ * and deletes for one load of a 28K-formula workbook.
27
+ */
28
+ export declare function installGlobalContext(): void;
16
29
  export declare function setGlobalScope(scope: Partial<IFormulaContext> | null | undefined): void;
17
30
  export declare function clearGlobalScope(): void;
18
31
  //# sourceMappingURL=_ScriptUtils.d.ts.map
@@ -11,6 +11,7 @@ import { IComment } from '../comment';
11
11
  import { IColor } from '../color';
12
12
  import { IHyperlink } from '../hyperlink';
13
13
  import { ISort } from '../sort';
14
+ import { IAnchored } from '../anchored';
14
15
  import { Anchored } from '../anchored/Anchored';
15
16
  import { IAnchoredMap } from '../anchored/IAnchoredMap';
16
17
  import { ITable, ITableCollection } from '../table';
@@ -223,6 +224,7 @@ export declare class Sheet implements ISheet {
223
224
  calculate: (ranges: ICellRanges.Coords, options?: ICalculation.CalculateOptions) => void;
224
225
  autoSelect: (options?: boolean | ICellRange.SelectOptions, selectionOverride?: Partial<IRangeSelection.Coords> | null, axis?: IRange.Axis) => Promise<IRange.Coords[]>;
225
226
  autoFit: (ranges: readonly IRange.Coords[], options?: ICellRange.AutoFitOptions) => void;
227
+ getBestFit: (range: IRange.Coords, options?: ICellRange.BestFitOptions) => Size;
226
228
  addRangesListeners: (ranges: readonly IRange.Coords[], listener: ICellRange.Listener, options?: ICellRange.ListenerOptions) => IListener.Remove;
227
229
  addRangesListeners2: (ranges: readonly IRange.Coords[], listener: ICellRange.Listener, options: ICellRange.ListenerOptions | undefined, isRanges: boolean) => IListener.Remove;
228
230
  surroundingRegion: (range: IRange.Coords, options?: ICellRange.GetSurroundingOptions) => IRange.Coords;
@@ -385,6 +387,7 @@ export declare class Sheet implements ISheet {
385
387
  calculate: (ranges: ICellRanges.Coords, options?: ICalculation.CalculateOptions) => void;
386
388
  autoSelect: (options?: boolean | ICellRange.SelectOptions, selectionOverride?: Partial<IRangeSelection.Coords> | null, axis?: IRange.Axis) => Promise<IRange.Coords[]>;
387
389
  autoFit: (ranges: readonly IRange.Coords[], options?: ICellRange.AutoFitOptions) => void;
390
+ getBestFit: (range: IRange.Coords, options?: ICellRange.BestFitOptions) => Size;
388
391
  addRangesListeners: (ranges: readonly IRange.Coords[], listener: ICellRange.Listener, options?: ICellRange.ListenerOptions) => IListener.Remove;
389
392
  addRangesListeners2: (ranges: readonly IRange.Coords[], listener: ICellRange.Listener, options: ICellRange.ListenerOptions | undefined, isRanges: boolean) => IListener.Remove;
390
393
  surroundingRegion: (range: IRange.Coords, options?: ICellRange.GetSurroundingOptions) => IRange.Coords;
@@ -607,6 +610,12 @@ export declare class Sheet implements ISheet {
607
610
  * Implementation lives in `_SheetAutoFitUtils` (same pattern as `_SheetSortUtils.doSort`).
608
611
  */
609
612
  protected _autoFit(ranges: readonly IRange.Coords[], options?: ICellRange.AutoFitOptions): void;
613
+ /**
614
+ * The size a range's content needs, without writing it. See {@link ICellRange.getBestFit}.
615
+ *
616
+ * @internal
617
+ */
618
+ protected _getBestFit(range: IRange.Coords, options?: ICellRange.BestFitOptions): Size;
610
619
  /** @internal */
611
620
  protected _createRangeEvent(coords: (readonly IRange.FixableCoords[]) | IRange.FixableCoords, options: NotifierOptions, coordsFrom?: (readonly IRange.FixableCoords[]) | IRange.FixableCoords): ICellRange.Event;
612
621
  /**
@@ -841,13 +850,43 @@ export declare class Sheet implements ISheet {
841
850
  * @internal
842
851
  */
843
852
  protected _addTable(address: ICellRange.Address, options: ITableCollection.AddOptions | boolean): ITable;
853
+ /**
854
+ * The add shared by the anchored collections — conditional formats, data validations, protected
855
+ * ranges. Resolves an item-or-address input, keeps the option keys out of the persisted JSON, and
856
+ * either redefines the item at `index` (when `replaceExisting` and the collection agrees it is the
857
+ * same item) or inserts there — first by default, as in Excel.
858
+ * @internal
859
+ */
860
+ protected _addAnchored<T extends IAnchored & {
861
+ getRanges(): ICellRanges;
862
+ toJSON(): J | null;
863
+ }, J extends object>(add: ICellRanges.Address | T | null | undefined, options: (IAnchored.AddOptions & J) | undefined, spec: {
864
+ /** The sheet-state slot the collection lives in. */
865
+ key: 'conditionalFormats' | 'dataValidations' | 'protectedRanges';
866
+ isItem: (add: unknown) => add is T;
867
+ description: string;
868
+ /** Loads one ref into the map, handing the created model to `capture`. */
869
+ load: (map: IAnchoredMap<T, J>, ref: IRange.JSONReference<J>, capture: (model: T) => void) => IAnchoredMap<T, J>;
870
+ /**
871
+ * Whether the item at `index` — already known to cover exactly the same ranges — is the one
872
+ * `json` redefines: the per-collection half of `replaceExisting`. Omit to match on ranges alone.
873
+ */
874
+ isSameItem?: (existing: T, json: J) => boolean;
875
+ /** Redefines `existing` from `json`, inside the add's commit. */
876
+ replace: (existing: T, json: J, options: ITransaction.OperationOptions) => void;
877
+ /** A last look at the JSON before it is inserted (a protected range mints its name here). */
878
+ prepareInsert?: (json: J) => J;
879
+ notify: () => void;
880
+ /** Widen the item's columns after an insert — a validation or format may show a dropdown. */
881
+ autoFit?: boolean;
882
+ }): T;
844
883
  /**
845
884
  * @internal
846
885
  */
847
886
  protected _addDataValidation(add: ICellRanges.Address | IDataValidation, options?: IDataValidationCollection.AddOptions): IDataValidation;
848
887
  /**
849
- * @internal
850
- */
888
+ * @internal
889
+ */
851
890
  protected _addConditionalFormat(add: ICellRanges.Address | IConditionalFormat, options?: IConditionalFormatCollection.AddOptions): IConditionalFormat;
852
891
  /**
853
892
  * The first unused `Range<n>` name, matching Excel's default for a new Allow-Edit-Range.
@@ -292,6 +292,8 @@ export declare class SheetCell implements ICell {
292
292
  getHyperlink(): IHyperlink | null;
293
293
  /** {@inheritDoc ICell.getErrors} */
294
294
  getErrors(): readonly string[];
295
+ /** {@inheritDoc ICell.getCircularReference} */
296
+ getCircularReference(): ICalculation.ICircularReference | null;
295
297
  /** {@inheritDoc ICell.getWarnings} */
296
298
  getWarnings(): readonly string[];
297
299
  /** {@inheritDoc ICell.getSpans} */
@@ -1,4 +1,5 @@
1
1
  import { IRange, Scalar, IRangeStats, InteropScalar } from '@sheetxl/primitives';
2
+ import { Size } from '@sheetxl/utils';
2
3
  import { ITransaction } from '../transaction';
3
4
  import { IListener } from '../listener';
4
5
  import { ICell } from '../cell';
@@ -246,6 +247,8 @@ export declare class SheetRange implements ICellRange {
246
247
  get size(): number;
247
248
  /** {@inheritDoc ICellRange.getBounds} */
248
249
  getBounds(): import('@sheetxl/utils').Bounds;
250
+ /** {@inheritDoc ICellRange.getBestFit} */
251
+ getBestFit(options?: ICellRange.BestFitOptions): Size;
249
252
  /** {@inheritDoc ICellRange.isInvalid} */
250
253
  isInvalid(): boolean;
251
254
  /** {@inheritDoc ICellRange.getDefaultShiftAxis} */
@@ -1,4 +1,5 @@
1
1
  import { IRange } from '@sheetxl/primitives';
2
+ import { Size } from '@sheetxl/utils';
2
3
  import { ICellRange } from '../cellRange';
3
4
  import { Sheet } from './Sheet';
4
5
  /**
@@ -15,4 +16,31 @@ import { Sheet } from './Sheet';
15
16
  * @internal
16
17
  */
17
18
  export declare function doAutoFit(sheet: Sheet, ranges: readonly IRange.Coords[], options?: ICellRange.AutoFitOptions): void;
19
+ /**
20
+ * The size `range`'s content needs — what {@link doAutoFit} would commit, reduced to a `Size`
21
+ * instead of written.
22
+ *
23
+ * @remarks
24
+ * The same phases as `doAutoFit` ({@link measureRange}, then {@link reduceColumnWidths} /
25
+ * {@link reduceRowHeights}) minus the commit. Everything that differs follows from not writing:
26
+ *
27
+ * - The clamps are IDENTITY. `expandOnly` reconciles a measurement with the size a header already
28
+ * has; a query has no such size to reconcile against.
29
+ * - `axes: Both` still lays the rows out against the widths the column pass produced — a wrapped
30
+ * cell's height is a function of its column width — but those widths reach
31
+ * {@link refreshSegmentWidths} as a lookup rather than being read back from headers that were
32
+ * never written.
33
+ * - The scan is not widened to the used range. Widening proves a shrink is safe, and a query does
34
+ * not shrink; so only the range's own content is measured.
35
+ * - No protection check and no protected-axis skip: nothing is written, so nothing can be violated.
36
+ *
37
+ * An axis not being fitted reports its current size, so the result is comparable with
38
+ * `getBounds()` whichever axes were asked for.
39
+ *
40
+ * @param sheet The sheet to measure.
41
+ * @param range The range to measure.
42
+ * @param options Measurement options (axes, minContent, formulaView).
43
+ * @internal
44
+ */
45
+ export declare function doBestFit(sheet: Sheet, range: IRange.Coords, options?: ICellRange.BestFitOptions): Size;
18
46
  //# sourceMappingURL=_SheetAutoFitUtils.d.ts.map
@@ -7,7 +7,7 @@ import { IStyle } from '../style';
7
7
  import { ICellRange } from '../cellRange';
8
8
  import { OverlappingRange, ISparseGrid, ISpatialMap } from '../collections';
9
9
  import { MergeEntry } from './spatial';
10
- import { SpillEntry, ContentfulSpatialValue } from '../calculation/spatial';
10
+ import { SpillEntry, ContentfulSpatialValue, CircularEntry } from '../calculation/spatial';
11
11
  import { IConditionalFormat } from '../conditionalFormat';
12
12
  import { IDataValidation } from '../dataValidation';
13
13
  import { IProtectedRange } from '../protectedRange';
@@ -220,6 +220,10 @@ export declare namespace RangeState {
220
220
  * Errors during calculation.
221
221
  */
222
222
  calcError?: string;
223
+ /**
224
+ * In a reference cycle, or downstream of one.
225
+ */
226
+ circular?: CircularEntry;
223
227
  /**
224
228
  * An error VALUE lives here (the `Error` scalar kind — from the reconciled error spatial).
225
229
  */
@@ -263,6 +267,10 @@ export declare namespace RangeState {
263
267
  readonly Spills: "spills";
264
268
  readonly Pending: "pending";
265
269
  readonly CalcError: "calcError";
270
+ /**
271
+ * In a reference cycle, or downstream of one — evaluates to `0` (DESIGN-CIRCULAR-CALC.md §7).
272
+ */
273
+ readonly Circular: "circular";
266
274
  /**
267
275
  * Error VALUES (the `Error` scalar kind). Backed by the RECONCILED view
268
276
  * (`SheetReadContext.getErrorSpatial`), not `state.errorSpatial` directly — resolving it may
@@ -383,6 +391,11 @@ export interface State {
383
391
  spillSpatial: ISpatialMap<SpillEntry>;
384
392
  pendingSpatial: ISpatialMap<boolean>;
385
393
  calcErrorsSpatial: ISpatialMap<string>;
394
+ /**
395
+ * Cells in a reference cycle or downstream of one, by cycle (DESIGN-CIRCULAR-CALC.md §7.2).
396
+ * Maintained by calc realize from the executor's deltas, like {@link pendingSpatial}.
397
+ */
398
+ circularSpatial: ISpatialMap<CircularEntry>;
386
399
  /**
387
400
  * Error VALUES (`#DIV/0!`, `#N/A`, …) — the `Error` scalar kind, NOT engine failures
388
401
  * (those are {@link calcErrorsSpatial} / `CalcError`). Deliberately not per-type: `true`
@@ -479,6 +479,11 @@ export declare namespace IStyle {
479
479
  readonly Quarters5: "5Quarters";
480
480
  readonly Rating5: "5Rating";
481
481
  readonly Boxes5: "5Boxes";
482
+ /**
483
+ * Not a set to apply — the x14 name Excel writes for a band whose custom icon is
484
+ * "No Cell Icon" (`iconSet="NoIcons" iconId="0"`). It holds zero icons.
485
+ */
486
+ readonly NoIcons: "NoIcons";
482
487
  };
483
488
  type IconSet = typeof IconSet[keyof typeof IconSet];
484
489
  }
@@ -217,11 +217,27 @@ export declare class AnchoredTable extends AbstractAnchored<State, CommitView, I
217
217
  * 2. create or reused new Ids
218
218
  *
219
219
  * @remarks
220
- * Mutates columnPropsNews to ensure index is correct.
220
+ * Each entry is cloned before its `index`/`id` are settled. Callers routinely build
221
+ * `columnPropsNews` out of the committed `orderedColumnsProps` (a slice, a spread, a splice),
222
+ * which shares the prop objects with the state undo restores - writing through them would
223
+ * rewrite history in place.
221
224
  *
222
225
  * @internal
223
226
  */
224
227
  protected _updateColumnsState(columnPropsNews: Partial<ColumnPropertiesState>[], options?: string | ITransaction.OperationOptions): ITable.IColumn[];
228
+ /**
229
+ * Re-derives the active filter and sort levels from the column props.
230
+ *
231
+ * @remarks
232
+ * A level is bound to a column id, but the column props are where a filter or sort actually
233
+ * lives. Rebuilding the columns (a delete, a sheet sync) can therefore take a column out from
234
+ * under its level, and a level that outlives its column reads back as unfiltered while its rows
235
+ * stay hidden. Deriving the levels from the props instead of carrying them alongside keeps the
236
+ * two from drifting, and closes the gap in `level` left by whatever was dropped.
237
+ *
238
+ * @internal
239
+ */
240
+ private _rebuildActiveLevels;
225
241
  /** {@inheritDoc ITable.getVisibleRefRangeCoords} */
226
242
  getVisibleRefRangeCoords(): IRange.Coords;
227
243
  /** {@inheritDoc ITable.getVisibleCellCoords} */
@@ -157,6 +157,24 @@ export declare function isValidHttpUrl(value: string): boolean;
157
157
  * @returns `true` if the string is a valid email, `false` otherwise.
158
158
  */
159
159
  export declare function isValidEmail(text: string): boolean;
160
+ /**
161
+ * The hyperlink address for text that Excel's AutoCorrect would turn into a link, or `null`
162
+ * when the text is not link-shaped.
163
+ *
164
+ * @param text The text to check.
165
+ * @returns The address, with the scheme Excel supplies when the text omits one, or `null`.
166
+ *
167
+ * @remarks
168
+ * Mirrors Excel's "Internet and network paths with hyperlinks" rule, which links:
169
+ *
170
+ * * `http(s)://…` - as is.
171
+ * * `www.…` - as `http://www.…`.
172
+ * * `mailto:…` - as is.
173
+ * * an email address - as `mailto:…`.
174
+ *
175
+ * A bare domain (`sheetxl.com`) is left alone, as Excel leaves it.
176
+ */
177
+ export declare function toHyperlinkAddress(text: string): string | null;
160
178
  /**
161
179
  * Converts a number to alphabet.
162
180
  * @param i The number to stringify