@sheetxl/primitives 0.7.28-beta.4 → 0.8.0-beta.2

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.7.28-beta.4
2
+ * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.2
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -32,7 +32,13 @@ var t, r, o, n, s = {
32
32
  }, a = {
33
33
  ...s,
34
34
  Date: "date"
35
- }, i = /[.*+?^${}()|[\]\\]/, c = (e) => i.test(e) ? "\\" + e : e, u = {
35
+ }, i = {
36
+ ...s,
37
+ Reference: "reference",
38
+ Array: "array",
39
+ Lambda: "lambda",
40
+ Omitted: "omitted"
41
+ }, c = /[.*+?^${}()|[\]\\]/, u = (e) => c.test(e) ? "\\" + e : e, l = {
36
42
  isWildCard: (e) => "string" == typeof e && /[*?]/.test(e),
37
43
  toRegex: (e, t, r = !1) => {
38
44
  let o = "";
@@ -41,14 +47,14 @@ var t, r, o, n, s = {
41
47
  const r = e[t];
42
48
  if ("~" === r) {
43
49
  const r = e[t + 1];
44
- "*" === r || "?" === r || "~" === r ? (o += c(r), t++) : o += "~";
50
+ "*" !== r && "?" !== r && "~" !== r || (o += u(r), t++);
45
51
  continue;
46
52
  }
47
- "*" !== r ? o += "?" !== r ? c(r) : "." : o += ".*";
53
+ "*" !== r ? o += "?" !== r ? u(r) : "[\\s\\S]" : o += "[\\s\\S]*";
48
54
  }
49
- return RegExp(r ? `^${o}$` : o, t);
55
+ return "start" === r ? RegExp(`^${o}`, t) : RegExp(r ? `^${o}$` : o, t);
50
56
  }
51
- };
57
+ }, d = (e) => null !== e && "object" == typeof e && !0 === e.isLazy;
52
58
  (r = t || (t = {})).Axis = {
53
59
  Column: "column",
54
60
  Row: "row"
@@ -246,7 +252,7 @@ var t, r, o, n, s = {
246
252
  }
247
253
  }
248
254
  e.Connect = m;
249
- class C extends o {
255
+ class S extends o {
250
256
  constructor(e, o) {
251
257
  super(t.Blocked, r.Blocked, e, o);
252
258
  }
@@ -254,8 +260,8 @@ var t, r, o, n, s = {
254
260
  this.code = n.Code.Blocked;
255
261
  }
256
262
  }
257
- e.Blocked = C;
258
- class S extends o {
263
+ e.Blocked = S;
264
+ class C extends o {
259
265
  constructor(e, o) {
260
266
  super(t.Unknown, r.Unknown, e, o);
261
267
  }
@@ -263,8 +269,8 @@ var t, r, o, n, s = {
263
269
  this.code = n.Code.Unknown;
264
270
  }
265
271
  }
266
- e.Unknown = S;
267
- class N extends o {
272
+ e.Unknown = C;
273
+ class w extends o {
268
274
  constructor(e, o) {
269
275
  super(t.Field, r.Field, e, o);
270
276
  }
@@ -272,8 +278,8 @@ var t, r, o, n, s = {
272
278
  this.code = n.Code.Field;
273
279
  }
274
280
  }
275
- e.Field = N;
276
- class w extends o {
281
+ e.Field = w;
282
+ class f extends o {
277
283
  constructor(e, o) {
278
284
  super(t.Calc, r.Calc, e, o);
279
285
  }
@@ -281,8 +287,8 @@ var t, r, o, n, s = {
281
287
  this.code = n.Code.Calc;
282
288
  }
283
289
  }
284
- e.Calc = w;
285
- class f extends o {
290
+ e.Calc = f;
291
+ class y extends o {
286
292
  constructor(e, o) {
287
293
  super(t.Busy, r.Busy, e, o);
288
294
  }
@@ -290,8 +296,8 @@ var t, r, o, n, s = {
290
296
  this.code = n.Code.Busy;
291
297
  }
292
298
  }
293
- e.Busy = f;
294
- class b extends o {
299
+ e.Busy = y;
300
+ class N extends o {
295
301
  constructor(e, o) {
296
302
  super(t.Python, r.Python, e, o);
297
303
  }
@@ -299,8 +305,8 @@ var t, r, o, n, s = {
299
305
  this.code = n.Code.Python;
300
306
  }
301
307
  }
302
- e.Python = b;
303
- class y extends o {
308
+ e.Python = N;
309
+ class b extends o {
304
310
  constructor(e, o) {
305
311
  super(t.Timeout, r.Timeout, e, o);
306
312
  }
@@ -308,17 +314,17 @@ var t, r, o, n, s = {
308
314
  this.code = n.Code.Timeout;
309
315
  }
310
316
  }
311
- e.Timeout = y;
317
+ e.Timeout = b;
312
318
  }(n || (n = {}));
313
- var l = {};
314
- l[n.Code.Parse] = n.Parse, l[n.Code.Null] = n.Null, l[n.Code.Div0] = n.Div0, l[n.Code.Value] = n.Value, l[n.Code.Ref] = n.Ref, l[n.Code.Name] = n.Name, l[n.Code.Num] = n.Num, l[n.Code.NA] = n.NA, l[n.Code.GettingData] = n.GettingData, l[n.Code.Spill] = n.Spill, l[n.Code.Connect] = n.Connect, l[n.Code.Blocked] = n.Blocked, l[n.Code.Unknown] = n.Unknown, l[n.Code.Field] = n.Field, l[n.Code.Calc] = n.Calc, l[n.Code.Busy] = n.Busy, l[n.Code.Python] = n.Python, l[n.Code.Timeout] = n.Timeout;
315
- var d = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = Object.keys(l);
316
- for (let e = 0; e < m.length; e++) {
317
- const t = l[m[e]], r = new t();
318
- p.set(r.getLabel(), t), h.set(r.getCode(), t), d.set(r.getLabel(), r), g.set(r.getCode(), r);
319
+ var g = {};
320
+ g[n.Code.Parse] = n.Parse, g[n.Code.Null] = n.Null, g[n.Code.Div0] = n.Div0, g[n.Code.Value] = n.Value, g[n.Code.Ref] = n.Ref, g[n.Code.Name] = n.Name, g[n.Code.Num] = n.Num, g[n.Code.NA] = n.NA, g[n.Code.GettingData] = n.GettingData, g[n.Code.Spill] = n.Spill, g[n.Code.Connect] = n.Connect, g[n.Code.Blocked] = n.Blocked, g[n.Code.Unknown] = n.Unknown, g[n.Code.Field] = n.Field, g[n.Code.Calc] = n.Calc, g[n.Code.Busy] = n.Busy, g[n.Code.Python] = n.Python, g[n.Code.Timeout] = n.Timeout;
321
+ var p = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), C = Object.keys(g);
322
+ for (let e = 0; e < C.length; e++) {
323
+ const t = g[C[e]], r = new t();
324
+ m.set(r.getLabel(), t), S.set(r.getCode(), t), p.set(r.getLabel(), r), h.set(r.getCode(), r);
319
325
  }
320
326
  (function(e) {
321
- const t = e.getBuiltInByCode = (e) => g.get(e);
327
+ const t = e.getBuiltInByCode = (e) => h.get(e);
322
328
  e.BuiltIn = {
323
329
  Parse: t(n.Code.Parse),
324
330
  Null: t(n.Code.Null),
@@ -340,12 +346,12 @@ for (let e = 0; e < m.length; e++) {
340
346
  Timeout: t(n.Code.Timeout)
341
347
  }, e.newTypedError = (e, t, r) => {
342
348
  let o;
343
- return o = "string" == typeof e ? p.get(e) : h.get(e), o || (o = n.Unknown), new o(t, r);
344
- }, e.getBuiltInByLabel = (e) => d.get(e), e.isError = function(e, t) {
349
+ return o = "string" == typeof e ? m.get(e) : S.get(e), o || (o = n.Unknown), new o(t, r);
350
+ }, e.getBuiltInByLabel = (e) => p.get(e), e.isError = function(e, t) {
345
351
  return !!e && !0 === e.isFormulaError && (void 0 === t || e.getCode() === t);
346
352
  };
347
353
  })(n || (n = {}));
348
- var C = class {
354
+ var w = class {
349
355
  constructor(e) {
350
356
  this._subscribeFn = e;
351
357
  }
@@ -365,42 +371,48 @@ var C = class {
365
371
  "function" == typeof n && n();
366
372
  }, o;
367
373
  }
368
- }, S = class {
374
+ }, f = class {
369
375
  createRange(e, t, r) {
370
- throw new w();
376
+ throw new b();
377
+ }
378
+ flattenAreas(e) {
379
+ throw new b();
371
380
  }
372
381
  getReference(e, t) {
373
- throw new w();
382
+ throw new b();
374
383
  }
375
384
  getResizedReference(e, t, r) {
376
- throw new w();
385
+ throw new b();
377
386
  }
378
387
  getNumberFormat(e, t) {
379
- throw new w();
388
+ throw new b();
380
389
  }
381
390
  fromSerialDate(e, t) {
382
- throw new w();
391
+ throw new b();
383
392
  }
384
393
  toSerialDate(e, t) {
385
- throw new w();
394
+ throw new b();
386
395
  }
387
396
  getDateParts(e, t) {
388
- throw new w();
397
+ throw new b();
389
398
  }
390
399
  getSerialDate(e, t, r, o, n, s, a) {
391
- throw new w();
400
+ throw new b();
392
401
  }
393
402
  getNow() {
394
- throw new w();
403
+ throw new b();
404
+ }
405
+ getRandom() {
406
+ return Math.random();
395
407
  }
396
408
  getValueAt(e, t, r, o) {
397
409
  return null;
398
410
  }
399
411
  getEntireCoords() {
400
- return f;
412
+ return A;
401
413
  }
402
414
  isValidDate(e, t) {
403
- return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e > y);
415
+ return e instanceof Date || "[object Date]" === Object.prototype.toString.call(e) ? !isNaN(e.getTime()) : !t && "number" == typeof e && !(e < 0 || e > _);
404
416
  }
405
417
  getRow() {
406
418
  return 0;
@@ -408,6 +420,9 @@ var C = class {
408
420
  getColumn() {
409
421
  return 0;
410
422
  }
423
+ isImplicitIntersect() {
424
+ return !1;
425
+ }
411
426
  getFormulaAt(e, t, r) {
412
427
  return null;
413
428
  }
@@ -432,19 +447,19 @@ var C = class {
432
447
  return null;
433
448
  }
434
449
  getAddress(e, t) {
435
- throw new w();
450
+ throw new b();
436
451
  }
437
452
  parseAsSerialDate(e, t) {
438
- throw new w();
453
+ throw new b();
439
454
  }
440
455
  parseAsDate(e, t) {
441
- throw new w();
456
+ throw new b();
442
457
  }
443
458
  parseAsNumber(e, t) {
444
- throw new w();
459
+ throw new b();
445
460
  }
446
- createCriteria(e) {
447
- throw new w();
461
+ createCriteria(e, t) {
462
+ throw new b();
448
463
  }
449
464
  parseAsLiteral(e) {
450
465
  const t = e.toUpperCase();
@@ -455,13 +470,16 @@ var C = class {
455
470
  }
456
471
  compare(e, t, r) {
457
472
  if (e === t) return 0;
458
- const o = N(e), n = N(t);
473
+ const o = y(e), n = y(t);
459
474
  return o !== n ? o < n ? -1 : 1 : e < t ? -1 : e > t ? 1 : 0;
460
475
  }
461
476
  getRuntime() {
462
- return b;
477
+ return D;
478
+ }
479
+ getArgs() {
480
+ throw new b(N);
463
481
  }
464
- }, N = (e) => {
482
+ }, y = (e) => {
465
483
  if (null == e) return 0;
466
484
  switch (typeof e) {
467
485
  case "number": return 1;
@@ -469,41 +487,45 @@ var C = class {
469
487
  case "boolean": return 3;
470
488
  default: return 4;
471
489
  }
472
- }, w = class extends Error {
490
+ }, N = "FormulaContext.getArgs() is only valid while a function body is running", b = class extends Error {
473
491
  constructor(e = "Not implemented in StubbedFormulaContext") {
474
492
  super(e), this.name = "NotImplementedError";
475
493
  }
476
- }, f = Object.freeze({
494
+ }, A = Object.freeze({
477
495
  colStart: 0,
478
496
  rowStart: 0,
479
497
  colEnd: Math.pow(2, 14) - 1,
480
498
  rowEnd: Math.pow(2, 20) - 1
481
- }), b = {
499
+ }), D = {
482
500
  isDate1904: () => !1,
483
- getLocale: () => _.tag,
484
- getLocaleProfile: () => _,
501
+ getLocale: () => F.tag,
502
+ getLocaleProfile: () => F,
485
503
  isR1C1: () => !1,
486
504
  getNow: () => 0,
505
+ getRandom: () => Math.random(),
487
506
  getLocation: () => "unknown",
488
507
  getVersion: () => "1.0.0",
489
508
  getOS: () => "unknown",
490
509
  getUser: () => "unidentified",
491
510
  getDescription: () => "Stubbed Formula Context"
492
- }, y = 2958465, D = new S(), A = class {
511
+ }, _ = 2958465, R = new f(), x = class {
493
512
  constructor() {
494
- this._scope = D;
513
+ this._scope = R, this._argsFn = null;
495
514
  }
496
515
  _setScope(e) {
497
- this._scope = e ?? D;
516
+ this._scope = e ?? R;
498
517
  }
499
518
  _getScope() {
500
519
  return this._scope;
501
520
  }
521
+ _setArgsProvider(e) {
522
+ this._argsFn = e;
523
+ }
502
524
  getNumberFormat(e, t) {
503
525
  return this._getScope().getNumberFormat(e, t);
504
526
  }
505
527
  getEntireCoords() {
506
- return this._getScope().getEntireCoords() ?? f;
528
+ return this._getScope().getEntireCoords() ?? A;
507
529
  }
508
530
  parseAsSerialDate(e, t) {
509
531
  return this._getScope().parseAsSerialDate(e, t);
@@ -514,12 +536,12 @@ var C = class {
514
536
  parseAsNumber(e, t) {
515
537
  return this._getScope().parseAsNumber(e, t);
516
538
  }
517
- createCriteria(e) {
518
- return this._getScope().createCriteria(e);
539
+ createCriteria(e, t) {
540
+ return this._getScope().createCriteria(e, t);
519
541
  }
520
542
  parseAsLiteral(e) {
521
543
  const t = this._getScope();
522
- return t.parseAsLiteral ? t.parseAsLiteral(e) : D.parseAsLiteral(e);
544
+ return t.parseAsLiteral ? t.parseAsLiteral(e) : R.parseAsLiteral(e);
523
545
  }
524
546
  toText(e) {
525
547
  return this._getScope().toText(e);
@@ -542,15 +564,30 @@ var C = class {
542
564
  getNow() {
543
565
  return this._getScope().getNow();
544
566
  }
567
+ getRandom() {
568
+ return this._getScope().getRandom?.() ?? Math.random();
569
+ }
545
570
  createRange(e, t, r) {
546
571
  return this._getScope().createRange(e, t, r);
547
572
  }
573
+ flattenAreas(e) {
574
+ if (!Array.isArray(e)) return e;
575
+ const t = [];
576
+ for (let r = 0; r < e.length; r++) {
577
+ const o = e[r], { rows: n, columns: s } = o.getShape();
578
+ for (let e = 0; e < n; e++) for (let r = 0; r < s; r++) t.push(o.getValueAt(e, r));
579
+ }
580
+ return this.createRange(t.length, 1, (e, r) => t[r.rowIndex]);
581
+ }
548
582
  getRow() {
549
583
  return this._getScope().getRow?.() ?? 0;
550
584
  }
551
585
  getColumn() {
552
586
  return this._getScope().getColumn?.() ?? 0;
553
587
  }
588
+ isImplicitIntersect() {
589
+ return this._getScope().isImplicitIntersect?.() ?? !1;
590
+ }
554
591
  getReference(e, t) {
555
592
  return this._getScope().getReference(e, t);
556
593
  }
@@ -591,18 +628,23 @@ var C = class {
591
628
  return this._getScope().getAddress(e, t);
592
629
  }
593
630
  compare(e, t, r) {
594
- return this._getScope().compare?.(e, t, r) ?? D.compare(e, t, r);
631
+ return this._getScope().compare?.(e, t, r) ?? R.compare(e, t, r);
595
632
  }
596
633
  getRuntime() {
597
634
  return this._getScope().getRuntime();
598
635
  }
636
+ getArgs() {
637
+ const e = this._argsFn, t = e ? e() : null;
638
+ if (!t) throw new b(N);
639
+ return t;
640
+ }
599
641
  get [Symbol.toStringTag]() {
600
642
  return "[FormulaContext]";
601
643
  }
602
644
  toString() {
603
645
  return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
604
646
  }
605
- }, _ = Object.freeze({
647
+ }, F = Object.freeze({
606
648
  tag: "en-US",
607
649
  numberingSystem: "latn",
608
650
  decimal: ".",
@@ -682,5 +724,5 @@ var C = class {
682
724
  sensitivity: "base",
683
725
  numeric: !0
684
726
  })
685
- }), x = new A();
686
- export { _ as DEFAULT_LOCALE_PROFILE, x as FormulaContext, n as FormulaError, t as IRange, o as IRangeStats, a as InteropScalarType, C as Observable, e as Scalar, s as ScalarType, A as ScopedFormulaContext, S as StubbedFormulaContext, u as WildCard };
727
+ }), T = new x();
728
+ export { F as DEFAULT_LOCALE_PROFILE, T as FormulaContext, n as FormulaError, t as IRange, o as IRangeStats, a as InteropScalarType, w as Observable, e as Scalar, s as ScalarType, x as ScopedFormulaContext, f as StubbedFormulaContext, i as ValueKind, l as WildCard, d as isLazyValue };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/primitives",
3
3
  "description": "Primitives - Base types for SheetXL functions.",
4
- "version": "0.7.28-beta.4",
4
+ "version": "0.8.0-beta.2",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -1,78 +1,69 @@
1
1
  /**
2
- * Parameter markers that declare how the engine handles `FormulaError` values *before* a
3
- * function body runs. At the type level they are identity aliases — the body sees plain `T` —
4
- * but the declaration records the policy for the engine.
2
+ * The one parameter marker that speaks about errors — and it is a RULE, not quite a type. At the
3
+ * type level it is an identity alias (what arrives at any slot may already be an error — `Scalar`
4
+ * says so in its own definition); the marker says the ENGINE DOES NOT AUTO-REJECT a bare error at
5
+ * this slot: it is delivered raw, and the body decides.
5
6
  *
6
- * **ONE default, every position: errors reject.** Scalar arguments, lifted members,
7
- * flattened members, and range parameters alike propagate the first error — preserving its
8
- * identity (`#N/A` stays `#N/A`) — and the body never runs. Opt out with {@link AcceptError}.
9
- * The single exception needs no marker: a `FormulaError.Known`-typed parameter receives
10
- * errors because the type declares it.
7
+ * **There are two kinds of error, and the marker is about the first only:**
11
8
  *
12
- * > *Errors propagate unless your function opts in to seeing them.*
9
+ * 1. an error *instead of* a value or a range — `NA()`, an unresolvable name (`#NAME?`), a
10
+ * union `(A1,C1)` where one rectangle is needed;
11
+ * 2. an error *inside* a range — a cell or member holding `#N/A`.
13
12
  *
14
- * | position | default | opt-out |
15
- * | --- | --- | --- |
16
- * | scalar argument | reject — propagate with identity, body never runs | `AcceptError<T>` — body receives raw |
17
- * | lifted member | reject — error becomes an error **member** of the output | `AcceptError<T>` |
18
- * | flattened member (`Scalar[]`, rest) | reject — first error wins, argument order, row-major | `AcceptError<T>` |
19
- * | range parameter | reject — first error (row-major) outranks everything | `AcceptError<IRange>` — members arrive raw |
20
- * | `FormulaError.Known` parameter | receive (the type declares it) | — |
13
+ * The engine never delivers the first unless the slot declares {@link AcceptError} — any `T`,
14
+ * one meaning. Without the marker the error propagates with its identity (`#N/A` stays `#N/A`)
15
+ * and the body never runs: as the call's answer for a scalar argument, as an error MEMBER of the
16
+ * output under a lift, as the first error in argument order for a flattened list. The single
17
+ * exception needs no marker: a `FormulaError.Known`-typed parameter receives errors because the
18
+ * type declares it.
21
19
  *
22
- * One parameter splits the two by ARGUMENT SHAPE rather than picking one:
23
- * {@link AcceptRefError} rejects a direct/computed error and accepts a reference-shaped one.
20
+ * The second is never the engine's business. A valid range is handed over whole, marker or no
21
+ * marker, and a body that cares asks:
24
22
  *
25
- * There is no marker for the default. A `RejectError<T>` alias existed and declared nothing the
26
- * engine did not already do, so it was removed rather than left as a second way to say nothing.
23
+ * ```ts
24
+ * if (range.hasError()) return range.firstError();
25
+ * ```
26
+ *
27
+ * placed before its own validation where Excel's error outranks it (`LARGE(range-with-#N/A, 0)`
28
+ * is `#N/A`, not `#NUM!`). Aggregators and consumers say it; reshapers and lookups, whose members
29
+ * pass through or are never read, need no line at all. Where a function takes several ranges the
30
+ * lines run in ARGUMENT order — the whole of argument N before N+1, row-major within — which is
31
+ * Excel's which-error-wins order, and a function that pairs its ranges (the paired
32
+ * statistics) orders its own scan the way it pairs.
27
33
  *
28
- * Which-error-wins is ARGUMENT ORDER: the whole of argument N is scanned before argument
29
- * N+1, row-major within each. The engine's range scan rides `IRange.errors()` /
30
- * `IRange.hasError()` — raw stored members only, same definition as
31
- * `getStats().getTypedCounts([ScalarType.Error])`.
34
+ * > *A bare error propagates unless your function opts in to seeing it; the members of a range
35
+ * > are yours.*
32
36
  *
33
- * The tolerant set — parameters that declare `AcceptError` — is finite and documented
34
- * (RANGE-ERROR-PROP.md §6.3): operators (broadcast is per-member), reshapers / dynamic
35
- * arrays (error members pass through to the output), lookups (errors in never-consumed
36
- * cells are tolerated), shape-only reference params (ROWS, COLUMNS, INDEX, OFFSET…),
37
- * conditional consumers (SUMIF-family; the database family and SUBTOTAL/AGGREGATE keep
38
- * their in-body, data-dependent policy), counters (COUNT, COUNTA), and the error handlers
39
- * themselves (IS*, IFERROR…).
37
+ * There is no marker for the default. A `RejectError<T>` alias existed and declared nothing the
38
+ * engine did not already do, so it was removed rather than left as a second way to say nothing.
39
+ * `AcceptRefError<T>`, which split the policy by argument shape, retired with the engine's member
40
+ * scan: its range form is this default, and its scalar form (the database `field`) is a range
41
+ * slot whose body reads the one cell.
40
42
  */
41
43
  /**
42
- * Opts a parameter out of the reject default: the body receives `FormulaError` values raw.
43
- * Use this for functions whose job is to inspect, replace, or render errors (the IS*
44
- * family, IFERROR, ERROR.TYPE, VALUETOTEXT…), that remap errors rather than propagate
45
- * them, or that legitimately tolerate error members they may never consume (lookups,
46
- * reshapers, conditional consumers — the §6.3 tolerant set).
44
+ * The engine does not auto-reject a bare error at this parameter: it is delivered RAW — a
45
+ * `FormulaError.Known`, never boxed as a 1×1 range — and the body narrows with
46
+ * `FormulaError.isError` (if it cares). A raw error is therefore never confusable with a
47
+ * one-cell range holding an error MEMBER: the two kinds this file keeps apart stay apart in the
48
+ * value itself, and members are no engine concern at all. For the functions whose job is to
49
+ * inspect, replace, or count errors — the IS* family, IFERROR, ERROR.TYPE, TYPE, COUNT and
50
+ * COUNTA — for the binders (`LET`, `LAMBDA`), whose value slots carry an argument unevaluated,
51
+ * and for a body that owns a reading ORDER or a LIFT the engine cannot see (SERIESSUM's
52
+ * coefficients; CONCATENATE broadcasts the error over its lifted ranges, so the SHAPE of the
53
+ * answer is the marker's work).
47
54
  *
48
- * On a TYPED parameter (`IRange<number>`), `AcceptError` means errors and failed coercions
49
- * arrive as raw MEMBERS instead of propagating — COUNT ignores them, COUNTA counts them.
55
+ * On a TYPED range parameter (`IRange<number>`) the marker also lets error members and failed
56
+ * coercions ride through the typed read as raw members — COUNT ignores them, COUNTA counts them.
57
+ * On an untyped range it changes nothing about members: they arrive raw either way.
50
58
  *
51
59
  * @example
52
60
  * ```ts
53
61
  * export function ISERROR(value: AcceptError<Scalar>): Scalar { ... }
54
62
  * export function IFERROR(value: AcceptError<Scalar>, valueIfError: AcceptError<Scalar>): Scalar { ... }
55
63
  * // Both parameters: an unused error fallback must pass through untouched (IFERROR(5,NA()) → 5).
56
- * export function ROWS(array: AcceptError<IRange>): number { ... }
57
- * // Shape-only: ROWS(A1:A2) is 2 even if A1 is #REF!.
64
+ * export function COUNT(number: AcceptError<IRange<number>>[]): number { ... }
65
+ * // COUNT(NA()) is 0: the error is a value, and not a number.
58
66
  * ```
59
67
  */
60
68
  export type AcceptError<T> = T;
61
- /**
62
- * Splits the policy by the ARGUMENT'S SHAPE: a **direct or computed** error rejects (propagates
63
- * with its identity, exactly the default), while a **reference-shaped** one is accepted and the
64
- * body receives it raw. "Direct" is the same runtime-shape test the coercion uses — a scalar,
65
- * typed or computed; a reference or a computed array is not (`isDirectArg` in `TypedFunction`).
66
- *
67
- * ```
68
- * =DSUM(A1:B3,NA(),G1:G2) #N/A direct — rejects, identity preserved
69
- * =DSUM(A1:B3,NA()+0,G1:G2) #N/A computed — still direct
70
- * =DSUM(A1:B3,E1,G1:G2) #VALUE! E1=#N/A — reference: body remaps
71
- * =DSUM(A1:B3,E2,G1:G2) #VALUE! E2=#DIV/0!
72
- * ```
73
- *
74
- * A body under this marker MUST handle the error it may now receive; a `FormulaError` reaching
75
- * an unguarded body is the item 18 hazard.
76
- */
77
- export type AcceptRefError<T> = T;
78
69
  //# sourceMappingURL=ErrorPolicy.d.ts.map
@@ -18,8 +18,11 @@
18
18
  *
19
19
  * Both are the same mechanism at different granularity — the marshaller picks the unit from the
20
20
  * element type — and a blank drops out of either. The scalar case is the common one; the range case
21
- * exists because a reference UNION is a single argument holding several areas, and a parameter that
22
- * does not declare `Flatten` refuses one outright (`#REF!` — `ROWS((A1:A3,C1:C5))` in Excel).
21
+ * exists because a reference UNION is a single argument holding several areas: a parameter that does
22
+ * not declare `Flatten` refuses one outright (`#VALUE!` — `TRANSPOSE((A1:A3,C1:C3))` in Excel), and a
23
+ * body that declares it answers for the union itself, in one line, the way Excel's own do:
24
+ * `AREAS` counts the areas, `SUM` adds them, `ROWS` answers `#REF!` to more than one, the lookups
25
+ * `#N/A`.
23
26
  *
24
27
  * At the type level it is `T[]`, so the body reads the list directly.
25
28
  *
@@ -27,7 +30,7 @@
27
30
  * ```ts
28
31
  * export function IRR(values: Flatten<number>, guess?: number): number { ... }
29
32
  * export function NETWORKDAYS(start: Date, end: Date, holidays?: Flatten<Scalar>): number { ... }
30
- * export function INDEX(array: Flatten<AcceptError<IRange>>, rowNum?: number, ...): any { ... }
33
+ * export function INDEX(array: Flatten<IRange>, rowNum?: number, ...): any { ... }
31
34
  * ```
32
35
  */
33
36
  export type Flatten<T> = T[];