@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
@@ -639,6 +639,65 @@ declare global {
639
639
  }
640
640
  }
641
641
 
642
+ /**
643
+ * Family aliases: one name an author writes that expands to several {@link CompatFeatures}.
644
+ *
645
+ * @remarks
646
+ * Excel's Analysis-ToolPak heritage is ONE measured rule with two halves that act on disjoint
647
+ * parameter kinds — `noReferenceLift` at a non-repeating scalar slot, `noMemberFilter` at a
648
+ * repeating one — so every function in the family carries the same two bits and `@compat atp`
649
+ * says so in one word. The alias is expanded by the linter; only the atomic features are ever
650
+ * stored, so `@compat atp` and `@compat noReferenceLift noMemberFilter` emit the same declaration.
651
+ * The atomic names stay available for the day a function measures as disagreeing on one half.
652
+ */
653
+ export const CompatAliases: Readonly<Record<string, readonly CompatFeature[]>>;
654
+
655
+ /**
656
+ * One of the {@link CompatFeatures} names.
657
+ */
658
+ export type CompatFeature = keyof typeof CompatFeatures;
659
+
660
+ /**
661
+ * The behaviors `@compat` can turn on, and what each one does.
662
+ *
663
+ * @remarks
664
+ * A feature earns a place here only if the BODY cannot do it — the decision happens before the
665
+ * body runs, or instead of running it. Everything a body can decide for itself belongs in the
666
+ * body, where `FormulaContext.getArgs()` and `Omittable` already reach.
667
+ *
668
+ * Function-level until a measurement forces otherwise: `noReferenceLift` is per-function in
669
+ * Excel, and no function is known whose parameters disagree.
670
+ *
671
+ * @see {@link https://www.sheetxl.com/docs/guides/concepts/udf | UDF authoring guide}
672
+ */
673
+ export const CompatFeatures: {
674
+ /**
675
+ * A multi-cell REFERENCE at a non-repeating scalar parameter is `#VALUE!` rather than a
676
+ * broadcast.
677
+ *
678
+ * Excel's Analysis-ToolPak family answers `CUMIPMT(G1:G2,120,100000,13,24,0)` with `#VALUE!`
679
+ * where the native `ROUND(B1:B3,3)` spills three results. A multi-cell reference has no way to
680
+ * become a scalar there, because these functions never intersect. An ARRAY at the same slot
681
+ * still lifts (`MROUND({3,4,5},5)` spills), so the refusal is about references specifically,
682
+ * and a REPEATING slot absorbs a container as members either way (`GCD(C1:C3)` is 4) — so this
683
+ * never applies to one.
684
+ */
685
+ readonly noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.";
686
+ /**
687
+ * Members of a REPEATING scalar parameter are coerced rather than filtered: numeric text
688
+ * parses, a blank inside a multi-cell range reads 0, and a boolean or non-numeric text member
689
+ * is `#VALUE!` for the whole call.
690
+ *
691
+ * The native family FILTERS — `SUM({1,"8",TRUE})` is 1, the text and the boolean skipped, and a
692
+ * blank cell contributes nothing. Excel's Analysis-ToolPak family coerces instead:
693
+ * `GCD({6,"8",12})` is 2, `GCD({6,TRUE,12})` is `#VALUE!`, `LCM(6,A1:A2)` over two blank cells
694
+ * is 0. A direct argument follows the same rule (`GCD(6,TRUE,12)` is `#VALUE!` where
695
+ * `SUM(6,TRUE,12)` is 19), and a one-cell blank reference or an omitted argument is still
696
+ * skipped — it never became a member.
697
+ */
698
+ readonly noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!.";
699
+ };
700
+
642
701
  /**
643
702
  * A compiled collection of functions — the serialized form of one module.
644
703
  *
@@ -1707,6 +1766,32 @@ declare global {
1707
1766
  readonly TwoCell: "twoCell";
1708
1767
  };
1709
1768
  type Type = typeof Type[keyof typeof Type];
1769
+ /**
1770
+ * Options shared by the collections that add anchored items — conditional formats, data
1771
+ * validations, protected ranges.
1772
+ */
1773
+ interface AddOptions extends ITransaction.OperationOptions {
1774
+ /**
1775
+ * Position in the collection. `0` is first — for a conditional format, the highest priority.
1776
+ *
1777
+ * @defaultValue 0 — a new item goes first, as in Excel.
1778
+ */
1779
+ index?: number;
1780
+ /**
1781
+ * Redefine the item already at `index` instead of inserting, when it is anchored to exactly
1782
+ * the same ranges (discontiguous ranges compare area by area, in authored order).
1783
+ *
1784
+ * @defaultValue false
1785
+ *
1786
+ * @remarks
1787
+ * Only the item at `index` is considered, as in Excel. What counts as the same item is per
1788
+ * collection: a data validation or protected range matches on ranges alone; a conditional
1789
+ * format only redefines a scale rule (data bar, color scale, icon set) of the same kind —
1790
+ * a style rule always inserts, since several may apply to one cell, whereas a second scale
1791
+ * of one kind on the same ranges could never render.
1792
+ */
1793
+ replaceExisting?: boolean;
1794
+ }
1710
1795
  }
1711
1796
 
1712
1797
  /**
@@ -2192,6 +2277,63 @@ declare global {
2192
2277
  * This is similar convenience method for `getCalculation().createFormula(expression).evaluate(options)`.
2193
2278
  */
2194
2279
  evaluate(expression: string, options?: number | ICalculation.EvaluateOptions & Partial<IRange.CellCoords>): Promise<Scalar | IRange>;
2280
+ /**
2281
+ * When the engine recalculates on its own — Excel's Calculation Options.
2282
+ *
2283
+ * @remarks
2284
+ * In {@link ICalculation.CalculationMode.Automatic} every commit that dirties a formula
2285
+ * schedules a pass. In {@link ICalculation.CalculationMode.Manual} an edit only marks its
2286
+ * dependents out of date ({@link isCalculationRequired}) and nothing is recalculated — volatile
2287
+ * functions (`NOW`, `RAND`) stop re-rolling too — until {@link calculate}: Excel's F9 (every
2288
+ * sheet), Shift+F9 (`scope`) and Ctrl+Alt+F9 (`full`). {@link ready} resolves at once in manual
2289
+ * mode; a caller that wants current values calls {@link calculate}.
2290
+ *
2291
+ * @defaultValue {@link ICalculation.CalculationMode.Automatic}
2292
+ */
2293
+ getCalculationMode(): ICalculation.CalculationMode;
2294
+ /**
2295
+ * Sets the calculation mode.
2296
+ *
2297
+ * @remarks
2298
+ * Leaving manual mode recalculates whatever is out of date, as Excel does.
2299
+ * {@link ICalculation.CalculationMode.AutomaticExceptTables} is accepted for parity with the
2300
+ * file format and Office Scripts; this engine has no what-if data tables, so it recalculates
2301
+ * exactly as `Automatic` does.
2302
+ */
2303
+ setCalculationMode(mode: ICalculation.CalculationMode): this;
2304
+ /**
2305
+ * Whether any formula is out of date — Excel's `Calculate` indicator in the status bar.
2306
+ *
2307
+ * @remarks
2308
+ * Meaningful in manual mode, where edits accumulate until {@link calculate}. In automatic
2309
+ * mode it is `true` only between an edit and the pass it schedules.
2310
+ */
2311
+ isCalculationRequired(): boolean;
2312
+ /**
2313
+ * How a reference cycle is resolved — Excel's "Enable iterative calculation" and its limits.
2314
+ *
2315
+ * @see {@link ICalculation.IterativeCalculation}
2316
+ */
2317
+ getIterativeCalculation(): ICalculation.IterativeCalculation;
2318
+ /**
2319
+ * Enables, disables or configures iterative calculation.
2320
+ *
2321
+ * @param options `true`/`false` toggles `enabled` alone; an object updates the fields given and
2322
+ * keeps the rest.
2323
+ *
2324
+ * @remarks
2325
+ * Every cell in a cycle is recalculated when this changes: turning iteration on resolves the
2326
+ * cycles the workbook shows as unresolved, turning it off writes `0` to them again.
2327
+ */
2328
+ setIterativeCalculation(options: boolean | Partial<ICalculation.IterativeCalculation>): this;
2329
+ /**
2330
+ * The calculation settings as JSON — what an xlsx carries in `calcPr`.
2331
+ *
2332
+ * @remarks
2333
+ * Sparse: a setting at its default is omitted. Settings a file carried that this engine does
2334
+ * not act on (`calcOnSave`, `fullCalcOnLoad`, `fullPrecision`, …) are kept and written back.
2335
+ */
2336
+ toJSON(): ICalculation.JSON;
2195
2337
  /**
2196
2338
  * Add Listeners.
2197
2339
  *
@@ -2221,6 +2363,87 @@ declare global {
2221
2363
  * tokenizer, the AST, a formula input — is ever handed an expression of unbounded size.
2222
2364
  */
2223
2365
  const MAX_EXPRESSION_LENGTH = 8192;
2366
+ /**
2367
+ * A reference cycle — the answer to "why is this cell `0`".
2368
+ *
2369
+ * @remarks
2370
+ * A cell is in a cycle when calculating it opens its own value, directly or through other cells
2371
+ * — `=A1+1` in A1, `=OFFSET(A1,0,0)` in A1, `=SUMIF(B1,C1,A1)` in A1 while B1 matches C1. With
2372
+ * iterative calculation off (the default, and Excel's) every cell in a cycle, and every cell
2373
+ * downstream of one, evaluates to `0`; nothing on the value says why. This does.
2374
+ *
2375
+ * Reached from a cell — {@link ICell.getCircularReference} answers it for members and for
2376
+ * downstream cells alike — and carried by the `ICellRange.Feature.Circular` regions, so a
2377
+ * range, a sheet or the workbook is asked the way any other error is asked:
2378
+ * `getCounts(Feature.Circular)` for how many, `getRegions(Feature.Circular)` for which, with
2379
+ * this object as each region's payload. There is no list of cycles on the calculation: nobody
2380
+ * starts from the cycle; they start from a cell or a range and want to know more.
2381
+ *
2382
+ * Live, not a snapshot: it reads the engine's cycle table on every call and drops members whose
2383
+ * formula has since been edited away, so a stale handle answers `getMemberCount() === 0`.
2384
+ * Persists until the last member is edited away.
2385
+ */
2386
+ interface ICircularReference {
2387
+ /**
2388
+ * The cell named for the cycle, the way Excel's status bar names one
2389
+ * (`Worksheet.CircularReference` likewise answers a single cell): the first member in
2390
+ * row-major order. `scope` is the sheet name, or `null` when the member lives in a named
2391
+ * formula's body rather than on a sheet.
2392
+ */
2393
+ getRepresentative(): IRange.CellCoords | null;
2394
+ /**
2395
+ * Every cell IN the cycle, in row-major order, `scope` set to the sheet name. Small — a cycle
2396
+ * is the cells that read each other, not everything that reads them (that is
2397
+ * {@link getDownstreamCount}).
2398
+ */
2399
+ getMembers(): readonly IRange.CellCoords[];
2400
+ /** How many cells are IN the cycle, the representative included. */
2401
+ getMemberCount(): number;
2402
+ /** How many cells read the cycle (transitively) and evaluate to `0` because of it. */
2403
+ getDownstreamCount(): number;
2404
+ /**
2405
+ * Whether `coords` is IN the cycle, as opposed to downstream of it. A cell that reads a
2406
+ * member's `0` answers `false` here but still resolves this cycle from
2407
+ * {@link ICell.getCircularReference} — the tooltip for it says "reads a circular reference
2408
+ * at A1", not "is one".
2409
+ */
2410
+ isMember(coords: IRange.CellCoords): boolean;
2411
+ /**
2412
+ * The cycle as a walk of reads from `from` back to itself — each cell reads the next, and
2413
+ * the last reads the first. A cycle has no start, so it is told from the cell that asks:
2414
+ * with `A1 = B1+1` and `B1 = A1+1`, asked from A1 it is `[A1, B1]` (A1 → B1 → A1), asked
2415
+ * from B1 it is `[B1, A1]`. A cycle of one is `[A1]`.
2416
+ *
2417
+ * @remarks
2418
+ * Exact, not inferred from formula text: it is the order the engine found the cycle in,
2419
+ * which is the order the reads happened — a dynamic read (`INDIRECT`, `OFFSET`) is a step
2420
+ * like any other. Interlocking cycles share members; the walk follows the read that closed
2421
+ * the cycle `from` was found in, so it is ONE loop through that cell, not every member
2422
+ * ({@link getMembers} is every member).
2423
+ *
2424
+ * Empty when `from` is not a live member — a downstream cell asks from
2425
+ * {@link getRepresentative}.
2426
+ */
2427
+ getPath(from: IRange.CellCoords): readonly IRange.CellCoords[];
2428
+ /**
2429
+ * Whether iterative calculation was on when the cycle was last evaluated. When `false` the
2430
+ * cycle is unresolved and every member and downstream cell is `0`; the iteration answers
2431
+ * below are then meaningless (`0` sweeps, no change).
2432
+ */
2433
+ isIterative(): boolean;
2434
+ /**
2435
+ * Whether iterative calculation settled it: every member moved by less than the workbook's
2436
+ * `maxIterateChange` in the last sweep. Always `false` with iteration off.
2437
+ */
2438
+ isConverged(): boolean;
2439
+ /** How many sweeps the last evaluation ran — up to the workbook's `maxIterations`. */
2440
+ getIterationCount(): number;
2441
+ /**
2442
+ * The largest change any member made in the last sweep — what stopped the iteration when
2443
+ * {@link isConverged}, what it never got under when not. `0` with iteration off.
2444
+ */
2445
+ getLastChange(): number;
2446
+ }
2224
2447
  /**
2225
2448
  * Represents a formula that can be evaluated.
2226
2449
  */
@@ -2899,8 +3122,16 @@ declare global {
2899
3122
  /**
2900
3123
  * Called when the calculation has been updated and
2901
3124
  * a calculation has not been started.
3125
+ *
3126
+ * @remarks
3127
+ * In manual mode this is every edit that leaves a formula out of date — see
3128
+ * {@link ICalculation.isCalculationRequired}.
2902
3129
  */
2903
3130
  onStale?(source: ICalculation): void;
3131
+ /**
3132
+ * Called when the calculation mode or the iterative-calculation settings change.
3133
+ */
3134
+ onOptionsChange?(source: ICalculation): void;
2904
3135
  /**
2905
3136
  * Called when a calculation is starting.
2906
3137
  */
@@ -2984,6 +3215,38 @@ declare global {
2984
3215
  readonly AutomaticExceptTables: "automaticExceptTables";
2985
3216
  };
2986
3217
  type CalculationMode = typeof CalculationMode[keyof typeof CalculationMode];
3218
+ /**
3219
+ * Iterative calculation — Excel's "Enable iterative calculation" with its two limits.
3220
+ *
3221
+ * @remarks
3222
+ * With it off a reference cycle evaluates to `0` and is reported as unresolved. With it on the
3223
+ * cells of the cycle are re-evaluated in turn, each read seeing the latest value, until no cell
3224
+ * moved by {@link maxChange} or {@link maxIterations} sweeps ran — and the results persist into
3225
+ * the next recalculation, which re-runs every cycle the way it re-runs `NOW()`: `=A1+1` in A1 is
3226
+ * a counter that advances by `maxIterations` per recalc. A cycle that stops on the sweep cap is
3227
+ * still reported ({@link ICircularReference.isConverged}); a converged one is not.
3228
+ *
3229
+ * Office Scripts calls the count `maxIteration`; the file format `iterateCount` / `iterateDelta`.
3230
+ */
3231
+ interface IterativeCalculation {
3232
+ /**
3233
+ * @defaultValue `false`
3234
+ */
3235
+ enabled: boolean;
3236
+ /**
3237
+ * The most sweeps one recalculation runs over a cycle.
3238
+ *
3239
+ * @defaultValue `100`
3240
+ */
3241
+ maxIterations: number;
3242
+ /**
3243
+ * Sweeps stop early once every cell in the cycle moved by less than this. A non-numeric
3244
+ * change (text, error) never counts as settled.
3245
+ *
3246
+ * @defaultValue `0.001`
3247
+ */
3248
+ maxChange: number;
3249
+ }
2987
3250
  /**
2988
3251
  * Represents the status of a calculation result
2989
3252
  */
@@ -3246,12 +3509,28 @@ declare global {
3246
3509
  *
3247
3510
  * @remarks
3248
3511
  * Warnings differ from errors in that they may alter the display of the cell's value or type.
3512
+ * A cell in a reference cycle, or downstream of one, carries one here — the text form of
3513
+ * {@link getCircularReference}: the walk from this cell around the cycle and back
3514
+ * ("Circular reference: A1 → B1 → A1"), or "Reads a circular reference at A1".
3249
3515
  */
3250
3516
  getWarnings(): readonly string[];
3251
3517
  /**
3252
3518
  * Retrieves any errors attached to the cell.
3253
3519
  */
3254
3520
  getErrors(): readonly string[];
3521
+ /**
3522
+ * The reference cycle this cell is in, or downstream of — or `null` when it is neither.
3523
+ *
3524
+ * @remarks
3525
+ * Evaluated state, beside the value: a cell in a cycle, and every cell that reads one, is `0`
3526
+ * (Excel, iterative calculation off), and this is the only thing that says why. Ask the cycle
3527
+ * whether this cell is a member or a reader ({@link ICalculation.ICircularReference.isMember})
3528
+ * and, under iterative calculation, whether it converged.
3529
+ *
3530
+ * The range-level view is `ICellRange.Feature.Circular` — `getCounts` for how many cells,
3531
+ * `getRegions` for which, each region carrying this same object as its payload.
3532
+ */
3533
+ getCircularReference(): ICalculation.ICircularReference | null;
3255
3534
  /**
3256
3535
  * Returns the style information applied to the cell.
3257
3536
  *
@@ -5550,6 +5829,22 @@ declare global {
5550
5829
  * Returns the absolute bounds for the range.
5551
5830
  */
5552
5831
  getBounds(): Bounds;
5832
+ /**
5833
+ * The size this range's content needs — what {@link getBounds} would report if the range had
5834
+ * been {@link autoFit}. A pure query: nothing is measured onto the model and nothing is committed.
5835
+ *
5836
+ * @param options Measurement options. Default `{ axes: IRange.AxisSelection.Both }`.
5837
+ *
5838
+ * @remarks
5839
+ * - The width is the sum of the per-column best fits and the height the sum of the per-row best
5840
+ * fits, so a single-column range answers "how wide must this list be" directly.
5841
+ * - An axis left out of {@link BestFitOptions.axes} reports its current size.
5842
+ * - Only the range's own content is measured, so the answer never depends on cells outside it.
5843
+ * (`autoFit` also scans outside the range, to prove a shrink is safe.)
5844
+ * - Sheet protection is not consulted: reading a size cannot violate it, and a protected sheet
5845
+ * answers the same as an unprotected one.
5846
+ */
5847
+ getBestFit(options?: ICellRange.BestFitOptions): Size;
5553
5848
  /**
5554
5849
  * Indicates if the range is readonly only.
5555
5850
  *
@@ -6036,9 +6331,9 @@ declare global {
6036
6331
  includeMergeOverflow?: boolean;
6037
6332
  }
6038
6333
  /**
6039
- * Options for {@link ICellRange.autoFit}.
6334
+ * Options for {@link ICellRange.getBestFit} — measurement only.
6040
6335
  */
6041
- interface AutoFitOptions extends ITransaction.OperationOptions {
6336
+ interface BestFitOptions {
6042
6337
  /**
6043
6338
  * Best fit using the minimum amount of space required.
6044
6339
  *
@@ -6049,21 +6344,6 @@ declare global {
6049
6344
  * For example allowing numbers to round or use scientific notation.
6050
6345
  */
6051
6346
  minContent?: boolean;
6052
- /**
6053
- * Restricts autoFit to only grow, never shrink.
6054
- *
6055
- * @defaultValue false - adjust in both directions.
6056
- *
6057
- * @remarks
6058
- * This is useful when adjusting fonts and wan the columns to resize but not the rows.
6059
- */
6060
- expandOnly?: boolean | IRange.Axis;
6061
- /**
6062
- * If this is set to `true` then any headers that have custom sizes will be ignored.
6063
- *
6064
- * @defaultValue false
6065
- */
6066
- skipCustomSize?: boolean;
6067
6347
  /**
6068
6348
  * The axes to autoFit.
6069
6349
  *
@@ -6085,6 +6365,26 @@ declare global {
6085
6365
  */
6086
6366
  formulaView?: boolean;
6087
6367
  }
6368
+ /**
6369
+ * Options for {@link ICellRange.autoFit}.
6370
+ */
6371
+ interface AutoFitOptions extends BestFitOptions, ITransaction.OperationOptions {
6372
+ /**
6373
+ * Restricts autoFit to only grow, never shrink.
6374
+ *
6375
+ * @defaultValue false - adjust in both directions.
6376
+ *
6377
+ * @remarks
6378
+ * This is useful when adjusting fonts and wan the columns to resize but not the rows.
6379
+ */
6380
+ expandOnly?: boolean | IRange.Axis;
6381
+ /**
6382
+ * If this is set to `true` then any headers that have custom sizes will be ignored.
6383
+ *
6384
+ * @defaultValue false
6385
+ */
6386
+ skipCustomSize?: boolean;
6387
+ }
6088
6388
  /**
6089
6389
  * Options for {@link ICellRanges.getFlattened}.
6090
6390
  */
@@ -6614,11 +6914,20 @@ declare global {
6614
6914
  /** Cells inside a dynamic-array spill zone. Writing into one is a real failure mode. */
6615
6915
  readonly Spills: "spills";
6616
6916
  /**
6617
- * Evaluated state: cells whose calculation itself failed — mostly circular references.
6618
- * Distinct from {@link Feature.Error}: `#DIV/0!` is a successfully calculated error VALUE
6619
- * (the `Error` kind); `CalcError` is the engine failing to evaluate at all.
6917
+ * Evaluated state: cells whose calculation itself failed. Distinct from
6918
+ * {@link Feature.Error}: `#DIV/0!` is a successfully calculated error VALUE (the `Error`
6919
+ * kind); `CalcError` is the engine failing to evaluate at all. A reference cycle is not a
6920
+ * failure — its cells evaluate, to `0` — and is {@link Feature.Circular}.
6620
6921
  */
6621
6922
  readonly CalcError: "calcError";
6923
+ /**
6924
+ * Evaluated state: cells in a reference cycle, or downstream of one. Both evaluate to `0`
6925
+ * (Excel, iterative calculation off) with nothing else to show for it — this is the marker.
6926
+ * Regions group by cycle and by kind (`member` | `downstream`), so a block that reads one bad
6927
+ * cell is ONE region, and each region's payload is the cycle itself
6928
+ * (`ICalculation.ICircularReference` — members, counts, whether iteration settled it).
6929
+ */
6930
+ readonly Circular: "circular";
6622
6931
  /** Direct fill. */
6623
6932
  readonly Fill: "fill";
6624
6933
  /** Direct borders. */
@@ -9908,8 +10217,11 @@ declare global {
9908
10217
  * Only the keys named are touched. An explicit `null` **clears** a key — required when switching
9909
10218
  * a rule between its two shapes, since `condition`+`style` and `scale` are mutually exclusive
9910
10219
  * (setting one side also clears the other unless the caller named both).
10220
+ *
10221
+ * Passing another rule takes its whole definition — every key, cleared where the other rule
10222
+ * has none — so the shape switches with it. The anchor is not part of it.
9911
10223
  */
9912
- update(properties: IConditionalFormat.Modifiers, options?: ITransaction.OperationOptions): this;
10224
+ update(properties: IConditionalFormat.Modifiers | IConditionalFormat, options?: ITransaction.OperationOptions): this;
9913
10225
  /**
9914
10226
  * Returns a snapshot of the conditional that can be used for copying and archiving.
9915
10227
  */
@@ -10339,8 +10651,12 @@ declare global {
10339
10651
  export namespace IConditionalFormatCollection {
10340
10652
  /**
10341
10653
  * Options for adding a {@link IConditionalFormat}.
10654
+ *
10655
+ * @remarks
10656
+ * `replaceExisting` redefines the rule at `index` only when it is a scale rule of the same
10657
+ * kind on exactly the same ranges — see {@link IAnchored.AddOptions.replaceExisting}.
10342
10658
  */
10343
- interface AddOptions extends IConditionalFormat.Properties, ITransaction.OperationOptions {
10659
+ interface AddOptions extends IConditionalFormat.Properties, IAnchored.AddOptions {
10344
10660
  }
10345
10661
  /**
10346
10662
  * Options for searching for {@link IConditionalFormat}s.
@@ -10724,8 +11040,12 @@ declare global {
10724
11040
  export namespace IDataValidationCollection {
10725
11041
  /**
10726
11042
  * Options for adding a data validation to the collection.
11043
+ *
11044
+ * @remarks
11045
+ * `replaceExisting` redefines the validation at `index` when it covers exactly the same ranges —
11046
+ * see {@link IAnchored.AddOptions.replaceExisting}.
10727
11047
  */
10728
- interface AddOptions extends IDataValidation.Properties, ITransaction.OperationOptions {
11048
+ interface AddOptions extends IDataValidation.Properties, IAnchored.AddOptions {
10729
11049
  }
10730
11050
  interface GetItemsOptions {
10731
11051
  /**
@@ -12260,6 +12580,7 @@ declare global {
12260
12580
  * | Category | Key methods |
12261
12581
  * |---|---|
12262
12582
  * | Evaluation lifecycle | `markVolatile`, `getRow`, `getColumn`, `getEntireCoords` |
12583
+ * | Argument reflection | `getArgs` |
12263
12584
  * | Output hints | `formatResults` |
12264
12585
  * | Range construction | `createRange`, `filterHidden` |
12265
12586
  * | Dynamic references | `getReference`, `getValueAt`, `getFormulaAt`, `getSpillAt` |
@@ -12714,6 +13035,22 @@ declare global {
12714
13035
  * Mostly for diagnostics; the built-in `INFO` function is built on it.
12715
13036
  */
12716
13037
  getRuntime(): IRuntime;
13038
+ /**
13039
+ * The current call's arguments — how many the caller supplied, in which positions, of what kind,
13040
+ * and what each value was BEFORE coercion.
13041
+ *
13042
+ * @remarks
13043
+ * Argument REFLECTION, for the one thing a declaration cannot say: what happened at *this* call.
13044
+ * It exists to serve Excel's declared `any`, which means "no contract, the body decides" — every
13045
+ * other Excel type maps onto a type we already have and the marshaller handles it.
13046
+ *
13047
+ * The returned view is valid ONLY while the body that asked for it is running. Views are pooled
13048
+ * by dispatch depth, so retaining one across an `await`, a callback, or a nested evaluation hands
13049
+ * you another call's arguments.
13050
+ *
13051
+ * @throws If called outside a function dispatch — there are no arguments to reflect on.
13052
+ */
13053
+ getArgs(): IFunctionArguments;
12717
13054
  }
12718
13055
 
12719
13056
  /**
@@ -13375,9 +13712,164 @@ declare global {
13375
13712
  * @defaultValue false
13376
13713
  */
13377
13714
  cancelable?: boolean;
13715
+ /**
13716
+ * Named engine behaviors this function opts into, from the `@compat` doc tag.
13717
+ *
13718
+ * @remarks
13719
+ * Canonical spellings, deduplicated and in declaration order; a family alias the author wrote
13720
+ * (`@compat atp`) has already been expanded to its atomic features. An unknown name never
13721
+ * reaches here — the linter fails the build on one, deliberately: a compatibility rule that
13722
+ * silently no-ops is the worst failure available, because the fixtures keep passing and the
13723
+ * behavior is simply absent.
13724
+ *
13725
+ * @see {@link CompatFeatures}
13726
+ * @see {@link CompatAliases}
13727
+ */
13728
+ compat?: CompatFeature[];
13378
13729
  }
13379
13730
  }
13380
13731
 
13732
+ /**
13733
+ * The current call's arguments, as the body sees them — argument **reflection**.
13734
+ *
13735
+ * @remarks
13736
+ * A declaration answers "what does this parameter mean?", and the marshaller coerces every
13737
+ * argument to it. That is right for the overwhelming majority of parameters. What it cannot answer
13738
+ * is anything about *this particular call*:
13739
+ *
13740
+ * - What did the caller write there — a value, a cell, an array, nothing at all?
13741
+ * - What was the value BEFORE the parameter's type coerced it?
13742
+ * - Was that empty slot an omission, or a blank cell the caller pointed at?
13743
+ *
13744
+ * Excel has measured behaviors that turn on exactly those questions, and they cluster at the
13745
+ * parameters Excel declares `any` — where there is nothing to express as a type, because Excel
13746
+ * declined to express one. `CUMIPMT` refuses a boolean at every slot while `FV` coerces one at
13747
+ * every slot; the difference is not the values, it is that `CUMIPMT`'s slots are `any` and its
13748
+ * body decides.
13749
+ *
13750
+ * It is REFLECTION and nothing else — two questions, and no third:
13751
+ *
13752
+ * | question | answers |
13753
+ * | --- | --- |
13754
+ * | *what was supplied* | {@link getLength}, {@link isOmittedAt} |
13755
+ * | *what it is* | {@link getRawAt} |
13756
+ *
13757
+ * Coercion is deliberately absent. A body that wants a number calls
13758
+ * {@link IFormulaContext.parseAsNumber} on the value this hands it — that already takes a value,
13759
+ * already propagates an incoming error with its identity, and already answers `#VALUE!` for a
13760
+ * boolean, which IS the rule an `any` slot needs. There is no coercion an index can do that a
13761
+ * value cannot.
13762
+ *
13763
+ * Obtained from `FormulaContext.getArgs()`, and valid ONLY while the body that asked for it is
13764
+ * running. A body must not retain it across an `await`, a callback, or a nested evaluation — the
13765
+ * views are pooled by dispatch depth, so the one at your depth is handed to the next call at that
13766
+ * depth.
13767
+ *
13768
+ * ```typescript
13769
+ * export function CUMIPMT(rate: Scalar, nper: Scalar): number {
13770
+ * const args = FormulaContext.getArgs();
13771
+ * if (args.isOmittedAt(0)) return FormulaError.BuiltIn.NA; // `CUMIPMT(,120,…)` is #N/A
13772
+ * const asNumber = FormulaContext.parseAsNumber(args.getRawAt(0) as Scalar); // TRUE is #VALUE!
13773
+ * // …
13774
+ * }
13775
+ * ```
13776
+ *
13777
+ * @see {@link IFormulaContext.getArgs}
13778
+ */
13779
+ export interface IFunctionArguments {
13780
+ /**
13781
+ * How many PARAMETERS the caller supplied.
13782
+ *
13783
+ * @remarks
13784
+ * Indexing throughout matches the BODY's own signature, never the raw call positions
13785
+ * (see {@link getRawAt}). `index >= getLength()` is an ABSENT argument — one the caller never
13786
+ * wrote, whose own JS initializer supplied the value. That is a different thing from an OMITTED
13787
+ * one; see {@link isOmittedAt}.
13788
+ */
13789
+ getLength(): number;
13790
+ /**
13791
+ * This invocation's value at `index`, uncoerced.
13792
+ *
13793
+ * @param index The PARAMETER index — the position in the body's own signature.
13794
+ *
13795
+ * @remarks
13796
+ * A `Scalar` means the argument IS a value; an {@link IRange} means a container whose members
13797
+ * the body reads itself (a reference materializes on demand); a {@link Lambda} means a callable.
13798
+ *
13799
+ * At a REPEATING parameter (`Repeating<T>`, or a rest parameter) this is the ARRAY of that
13800
+ * group's values — one entry per argument the caller wrote — and {@link getRepeatingArgsAt} is the
13801
+ * per-argument view of the same thing. Indexing by parameter rather than by call position is
13802
+ * what lets a body ask its questions in the vocabulary it declared:
13803
+ *
13804
+ * ```typescript
13805
+ * // IFS(condition: Repeating<[logicalTest: boolean, logicalTrue: AcceptError<any>]>)
13806
+ * args.getRawAt(0); // [test1, value1, test2, value2, …]
13807
+ * args.getRepeatingArgsAt(0).getRawAt(0); // test1
13808
+ * ```
13809
+ *
13810
+ * **Under a lift** the call broadcasts and the body runs once per output cell; this reports the
13811
+ * value for THIS invocation — the member at the current broadcast position for a lifted argument,
13812
+ * the whole argument for one that is not lifting. That is what every identified caller wants: a
13813
+ * body checking for a boolean must see the member, not the array around it.
13814
+ *
13815
+ * One boundary is worth knowing: under a lift at a parameter that declares a CONCRETE scalar
13816
+ * type, the member has already been converted by that declaration, so the raw and coerced answers
13817
+ * coincide there. At the `Scalar` slots this interface exists for, nothing coerces and the value
13818
+ * is the member exactly as the caller's range holds it.
13819
+ */
13820
+ getRawAt(index: number): IFunctionArguments.RawArg | IFunctionArguments.RawArg[];
13821
+ /**
13822
+ * A nested view over one REPEATING parameter's arguments, so a body can ask the same questions
13823
+ * one level down — `getRepeatingArgsAt(0).isOmittedAt(1)`.
13824
+ *
13825
+ * @param index The PARAMETER index of the repeating group (or rest parameter).
13826
+ *
13827
+ * @remarks
13828
+ * The nested view is FLAT over the group's arguments: a period-2 group repeated three times reads
13829
+ * as six, in call order. That is where "which one was omitted" has an answer at all — the group
13830
+ * as a whole cannot be omitted, only one of its arguments can.
13831
+ *
13832
+ * At a non-repeating parameter this returns an EMPTY view (`getLength()` of 0) rather than
13833
+ * throwing, so a body that folds over its groups needs no special case.
13834
+ */
13835
+ getRepeatingArgsAt(index: number): IFunctionArguments;
13836
+ /**
13837
+ * True for an OMITTED argument — one the caller supplied EMPTY, as the trailing comma of
13838
+ * `CUMIPMT(,120,100000,13,24,0)`.
13839
+ *
13840
+ * @remarks
13841
+ * There are THREE positions, not two, and Excel answers each differently:
13842
+ *
13843
+ * | form | position | Excel |
13844
+ * | --- | --- | --- |
13845
+ * | `CUMIPMT(0.01,120,100000,13,24)` | ABSENT | refused at entry |
13846
+ * | `CUMIPMT(,120,100000,13,24,0)` | **OMITTED** | `#N/A` |
13847
+ * | `CUMIPMT(0.01,120,100000,13,24,E1)`, E1 blank | a blank CELL | the ordinary answer |
13848
+ *
13849
+ * This separates the middle row from the other two. ABSENT is `index >= getLength()`; a blank
13850
+ * cell is an ordinary value the caller pointed at and is not omitted.
13851
+ */
13852
+ isOmittedAt(index: number): boolean;
13853
+ }
13854
+
13855
+ /**
13856
+ * {@inheritDoc IFunctionArguments}
13857
+ *
13858
+ * @see
13859
+ * ### **Interface**
13860
+ *
13861
+ * {@link IFunctionArguments}
13862
+ */
13863
+ export namespace IFunctionArguments {
13864
+ /**
13865
+ * One argument as the caller wrote it — a value, a container, a callable, or nothing.
13866
+ *
13867
+ * @remarks
13868
+ * `undefined` is an OMITTED or ABSENT argument; `null` is a blank, which is a value.
13869
+ */
13870
+ type RawArg = Scalar | IRange | Lambda | undefined;
13871
+ }
13872
+
13381
13873
  /**
13382
13874
  * Collections of {@link IFunction}.
13383
13875
  */
@@ -14021,7 +14513,9 @@ declare global {
14021
14513
  * @remarks
14022
14514
  * This has no counterpart in Excel; it is ours and applies to links opened in a browser.
14023
14515
  *
14024
- * @defaultValue `_self` for a location within this workbook, otherwise `_blank`.
14516
+ * @defaultValue `_self` for a location within this workbook or a `mailto:`/`tel:`/`sms:`
14517
+ * address (handled by another application, so there is nothing to show in a new tab),
14518
+ * otherwise `_blank`.
14025
14519
  */
14026
14520
  getTarget(): string;
14027
14521
  /**
@@ -16363,8 +16857,13 @@ declare global {
16363
16857
  export namespace IProtectedRangeCollection {
16364
16858
  /**
16365
16859
  * Options for adding an {@link IProtectedRange}.
16860
+ *
16861
+ * @remarks
16862
+ * `replaceExisting` redefines the entry at `index` when it covers exactly the same ranges; the
16863
+ * entry keeps its name unless a free one is supplied — see
16864
+ * {@link IAnchored.AddOptions.replaceExisting}.
16366
16865
  */
16367
- interface AddOptions extends IProtectedRange.Properties, ITransaction.OperationOptions {
16866
+ interface AddOptions extends IProtectedRange.Properties, IAnchored.AddOptions {
16368
16867
  }
16369
16868
  /**
16370
16869
  * Options for searching for {@link IProtectedRange}s.
@@ -16805,11 +17304,28 @@ declare global {
16805
17304
  */
16806
17305
  filter<TS extends Scalar = T>(callbackFn: (value: TS, coords: IRange.CellCoords, range: IRange<T>) => MaybeError<boolean>, options?: IRange.TraversalAxis | IRange.IteratorOptions): this;
16807
17306
  /**
16808
- * Returns the values as an array of values.
17307
+ * Linearizes the range into a single column by flattened ordinal — the member at ordinal `i`
17308
+ * lands at row `i`, column 0.
16809
17309
  *
16810
17310
  * @param options {@link IRange.IteratorOptions}
17311
+ *
17312
+ * @remarks
17313
+ * `options.axis` is the TRAVERSAL order feeding the ordinal, not the orientation of the result:
17314
+ * the result is always Nx1, and a row is `flatten().transpose()`. The default is row-major,
17315
+ * which is the order Excel pairs two range operands in.
17316
+ *
17317
+ * `options.type` carries a read type onto the result, so a member the type filters out becomes
17318
+ * a HOLE at its ordinal rather than compacting the column. That is what lets two operands be
17319
+ * paired position by position — see {@link alignValues}.
17320
+ *
17321
+ * `options.includeEmpty` has no meaning here and is ignored: a range is inherently sparse, so
17322
+ * an empty position is simply absent. Sparsity is preserved and nothing is materialized.
17323
+ *
17324
+ * Equivalent to `reshape(rows * columns, 1)`, which is where the ordinal rule is stated.
17325
+ *
17326
+ * @see {@link getValuesFlat} for the same linearization as a JS array.
16811
17327
  */
16812
- flatten<TS extends Scalar = T>(options?: IRange.IteratorOptions): TS[];
17328
+ flatten(options?: IRange.IteratorOptions): this;
16813
17329
  /**
16814
17330
  * Iterates over the cells within the range, applying the provided callback function to each cell.
16815
17331
  *
@@ -16887,6 +17403,16 @@ declare global {
16887
17403
  * @param options {@link IRange.ValueOptions}
16888
17404
  */
16889
17405
  getValueAt<TS extends Scalar = T>(rowIndex: number, colIndex: number, options?: IRange.ValueOptions): TS;
17406
+ /**
17407
+ * Returns the members as a flat JS array.
17408
+ *
17409
+ * @param options {@link IRange.IteratorOptions}
17410
+ *
17411
+ * @remarks
17412
+ * The array form of {@link flatten}. Skips empty members unless `includeEmpty` is set, where
17413
+ * `flatten` keeps them as holes in a range.
17414
+ */
17415
+ getValuesFlat<TS extends Scalar = T>(options?: IRange.IteratorOptions): TS[];
16890
17416
  /**
16891
17417
  * Returns the number of columns of the range.
16892
17418
  */
@@ -22094,6 +22620,11 @@ declare global {
22094
22620
  readonly Quarters5: "5Quarters";
22095
22621
  readonly Rating5: "5Rating";
22096
22622
  readonly Boxes5: "5Boxes";
22623
+ /**
22624
+ * Not a set to apply — the x14 name Excel writes for a band whose custom icon is
22625
+ * "No Cell Icon" (`iconSet="NoIcons" iconId="0"`). It holds zero icons.
22626
+ */
22627
+ readonly NoIcons: "NoIcons";
22097
22628
  };
22098
22629
  type IconSet = typeof IconSet[keyof typeof IconSet];
22099
22630
  }
@@ -27899,6 +28430,11 @@ declare global {
27899
28430
  getCpuCount(): number;
27900
28431
  getMemory(): number;
27901
28432
  isEval(): boolean;
28433
+ /**
28434
+ * `true` when the licensed product may run `feature` without the license watermark: a valid
28435
+ * license with no exceptions, or an evaluation on localhost / in a dev build. An evaluation on
28436
+ * any other host answers `false` so the watermark shows.
28437
+ */
27902
28438
  isValidFor: (feature: string) => boolean;
27903
28439
  getDeveloperCount(): number;
27904
28440
  getType(): string;
@@ -28306,6 +28842,7 @@ declare global {
28306
28842
  c?: boolean;
28307
28843
  p?: MinifiedParameter[];
28308
28844
  r?: MinifiedValue;
28845
+ x?: CompatFeature[];
28309
28846
  }
28310
28847
 
28311
28848
  export type MinifiedDeclarations = {
@@ -29216,6 +29753,28 @@ declare global {
29216
29753
  */
29217
29754
  export type Repeating<T> = T[];
29218
29755
 
29756
+ /**
29757
+ * Resolves a `@compat` feature name, CASE-INSENSITIVELY, to its canonical spelling.
29758
+ *
29759
+ * @param name The name as the author wrote it.
29760
+ * @returns The canonical name, or `null` when no feature goes by it.
29761
+ *
29762
+ * @remarks
29763
+ * Authors write `@compat noReferenceLift`; `@Compat NOREFERENCELIFT` means the same thing. Only
29764
+ * the canonical spelling is ever stored, so the declaration a build emits does not depend on how
29765
+ * the tag was typed.
29766
+ */
29767
+ export function resolveCompatFeature(name: string): CompatFeature | null;
29768
+
29769
+ /**
29770
+ * Resolves a `@compat` name — a feature or a family alias — CASE-INSENSITIVELY, to the canonical
29771
+ * features it turns on.
29772
+ *
29773
+ * @param name The name as the author wrote it.
29774
+ * @returns The canonical features, or `null` when no feature or alias goes by that name.
29775
+ */
29776
+ export function resolveCompatFeatures(name: string): readonly CompatFeature[] | null;
29777
+
29219
29778
  /**
29220
29779
  * Flatten a locale's declared `inherit` into a concrete lookup order, most-specific first.
29221
29780
  *