@sheetxl/primitives 0.8.0-beta.1 → 0.8.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/esm/index.mjs +94 -75
- package/node/esm/index.mjs +104 -83
- package/package.json +3 -4
- package/types/src/ErrorPolicy.d.ts +48 -57
- package/types/src/Flatten.d.ts +6 -3
- package/types/src/FormulaContext.d.ts +30 -7
- package/types/src/IFormulaContext.d.ts +205 -11
- package/types/src/IFunction.d.ts +368 -54
- package/types/src/IFunctionArguments.d.ts +86 -15
- package/types/src/IRange.d.ts +170 -38
- package/types/src/IRangeStats.d.ts +34 -3
- package/types/src/IRichData.d.ts +19 -2
- package/types/src/IRuntime.d.ts +24 -1
- package/types/src/Lazy.d.ts +76 -0
- package/types/src/NoFilter.d.ts +34 -0
- package/types/src/NoLift.d.ts +31 -0
- package/types/src/Repeating.d.ts +24 -4
- package/types/src/ReportType.d.ts +42 -0
- package/types/src/Scalar.d.ts +1 -1
- package/types/src/ValueKind.d.ts +43 -0
- package/types/src/Volatile.d.ts +12 -0
- package/types/src/WildCard.d.ts +13 -9
- package/types/src/index.d.ts +6 -1
- package/browser/cjs/index.cjs +0 -1
- package/types/src/Compat.d.ts +0 -77
package/browser/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.
|
|
2
|
+
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.11
|
|
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, n, r, i, a = {
|
|
|
32
32
|
}, o = {
|
|
33
33
|
...a,
|
|
34
34
|
Date: "date"
|
|
35
|
-
}, s =
|
|
35
|
+
}, s = {
|
|
36
|
+
...a,
|
|
37
|
+
Reference: "reference",
|
|
38
|
+
Array: "array",
|
|
39
|
+
Lambda: "lambda",
|
|
40
|
+
Omitted: "omitted"
|
|
41
|
+
}, c = /[.*+?^${}()|[\]\\]/, l = (e) => c.test(e) ? "\\" + e : e, u = {
|
|
36
42
|
isWildCard: (e) => typeof e == "string" && /[*?]/.test(e),
|
|
37
43
|
toRegex: (e, t, n = !1) => {
|
|
38
44
|
let r = "", i = e.length;
|
|
@@ -40,30 +46,12 @@ var t, n, r, i, a = {
|
|
|
40
46
|
let n = e[t];
|
|
41
47
|
if (n === "~") {
|
|
42
48
|
let n = e[t + 1];
|
|
43
|
-
n
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}, u = {
|
|
51
|
-
noReferenceLift: "A multi-cell reference at a non-repeating scalar parameter is #VALUE! rather than a broadcast.",
|
|
52
|
-
noMemberFilter: "Members of a repeating scalar parameter are coerced rather than filtered; one that cannot be is #VALUE!."
|
|
53
|
-
}, d = { atp: ["noReferenceLift", "noMemberFilter"] };
|
|
54
|
-
function f(e) {
|
|
55
|
-
let t = p(e);
|
|
56
|
-
if (t) return [t];
|
|
57
|
-
let n = (e ?? "").trim().toLowerCase();
|
|
58
|
-
for (let e of Object.keys(d)) if (e.toLowerCase() === n) return d[e];
|
|
59
|
-
return null;
|
|
60
|
-
}
|
|
61
|
-
function p(e) {
|
|
62
|
-
if (!e) return null;
|
|
63
|
-
let t = e.trim().toLowerCase();
|
|
64
|
-
for (let e of Object.keys(u)) if (e.toLowerCase() === t) return e;
|
|
65
|
-
return null;
|
|
66
|
-
}
|
|
49
|
+
n !== "*" && n !== "?" && n !== "~" || (r += l(n), t++);
|
|
50
|
+
} else r += n === "*" ? "[\\s\\S]*" : n === "?" ? "[\\s\\S]" : l(n);
|
|
51
|
+
}
|
|
52
|
+
return RegExp(n === "start" ? `^${r}` : n ? `^${r}$` : r, t);
|
|
53
|
+
}
|
|
54
|
+
}, d = (e) => typeof e == "object" && !!e && !0 === e.isLazy;
|
|
67
55
|
(n = t ||= {}).Axis = {
|
|
68
56
|
Column: "column",
|
|
69
57
|
Row: "row"
|
|
@@ -325,15 +313,15 @@ function p(e) {
|
|
|
325
313
|
}
|
|
326
314
|
e.Timeout = S;
|
|
327
315
|
}(i ||= {});
|
|
328
|
-
var
|
|
329
|
-
|
|
330
|
-
var
|
|
331
|
-
for (let e = 0; e <
|
|
332
|
-
let t =
|
|
333
|
-
|
|
316
|
+
var f = {};
|
|
317
|
+
f[i.Code.Parse] = i.Parse, f[i.Code.Null] = i.Null, f[i.Code.Div0] = i.Div0, f[i.Code.Value] = i.Value, f[i.Code.Ref] = i.Ref, f[i.Code.Name] = i.Name, f[i.Code.Num] = i.Num, f[i.Code.NA] = i.NA, f[i.Code.GettingData] = i.GettingData, f[i.Code.Spill] = i.Spill, f[i.Code.Connect] = i.Connect, f[i.Code.Blocked] = i.Blocked, f[i.Code.Unknown] = i.Unknown, f[i.Code.Field] = i.Field, f[i.Code.Calc] = i.Calc, f[i.Code.Busy] = i.Busy, f[i.Code.Python] = i.Python, f[i.Code.Timeout] = i.Timeout;
|
|
318
|
+
var p = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), _ = Object.keys(f);
|
|
319
|
+
for (let e = 0; e < _.length; e++) {
|
|
320
|
+
let t = f[_[e]], n = new t();
|
|
321
|
+
h.set(n.getLabel(), t), g.set(n.getCode(), t), p.set(n.getLabel(), n), m.set(n.getCode(), n);
|
|
334
322
|
}
|
|
335
323
|
(function(e) {
|
|
336
|
-
let t = e.getBuiltInByCode = (e) =>
|
|
324
|
+
let t = e.getBuiltInByCode = (e) => m.get(e);
|
|
337
325
|
e.BuiltIn = {
|
|
338
326
|
Parse: t(i.Code.Parse),
|
|
339
327
|
Null: t(i.Code.Null),
|
|
@@ -355,12 +343,12 @@ for (let e = 0; e < y.length; e++) {
|
|
|
355
343
|
Timeout: t(i.Code.Timeout)
|
|
356
344
|
}, e.newTypedError = (e, t, n) => {
|
|
357
345
|
let r;
|
|
358
|
-
return r = typeof e == "string" ?
|
|
359
|
-
}, e.getBuiltInByLabel = (e) =>
|
|
346
|
+
return r = typeof e == "string" ? h.get(e) : g.get(e), r ||= i.Unknown, new r(t, n);
|
|
347
|
+
}, e.getBuiltInByLabel = (e) => p.get(e), e.isError = function(e, t) {
|
|
360
348
|
return !!e && !0 === e.isFormulaError && (t === void 0 || e.getCode() === t);
|
|
361
349
|
};
|
|
362
350
|
})(i ||= {});
|
|
363
|
-
var
|
|
351
|
+
var v = class {
|
|
364
352
|
constructor(e) {
|
|
365
353
|
this._subscribeFn = e;
|
|
366
354
|
}
|
|
@@ -380,42 +368,48 @@ var b = class {
|
|
|
380
368
|
typeof i == "function" && i();
|
|
381
369
|
}, r;
|
|
382
370
|
}
|
|
383
|
-
},
|
|
371
|
+
}, y = class {
|
|
384
372
|
createRange(e, t, n) {
|
|
385
|
-
throw new
|
|
373
|
+
throw new S();
|
|
374
|
+
}
|
|
375
|
+
flattenAreas(e) {
|
|
376
|
+
throw new S();
|
|
386
377
|
}
|
|
387
378
|
getReference(e, t) {
|
|
388
|
-
throw new
|
|
379
|
+
throw new S();
|
|
389
380
|
}
|
|
390
381
|
getResizedReference(e, t, n) {
|
|
391
|
-
throw new
|
|
382
|
+
throw new S();
|
|
392
383
|
}
|
|
393
384
|
getNumberFormat(e, t) {
|
|
394
|
-
throw new
|
|
385
|
+
throw new S();
|
|
395
386
|
}
|
|
396
387
|
fromSerialDate(e, t) {
|
|
397
|
-
throw new
|
|
388
|
+
throw new S();
|
|
398
389
|
}
|
|
399
390
|
toSerialDate(e, t) {
|
|
400
|
-
throw new
|
|
391
|
+
throw new S();
|
|
401
392
|
}
|
|
402
393
|
getDateParts(e, t) {
|
|
403
|
-
throw new
|
|
394
|
+
throw new S();
|
|
404
395
|
}
|
|
405
396
|
getSerialDate(e, t, n, r, i, a, o) {
|
|
406
|
-
throw new
|
|
397
|
+
throw new S();
|
|
407
398
|
}
|
|
408
399
|
getNow() {
|
|
409
|
-
throw new
|
|
400
|
+
throw new S();
|
|
401
|
+
}
|
|
402
|
+
getRandom() {
|
|
403
|
+
return Math.random();
|
|
410
404
|
}
|
|
411
405
|
getValueAt(e, t, n, r) {
|
|
412
406
|
return null;
|
|
413
407
|
}
|
|
414
408
|
getEntireCoords() {
|
|
415
|
-
return
|
|
409
|
+
return C;
|
|
416
410
|
}
|
|
417
411
|
isValidDate(e, t) {
|
|
418
|
-
return e instanceof Date || Object.prototype.toString.call(e) === "[object Date]" ? !isNaN(e.getTime()) : !t && typeof e == "number" && !(e < 0 || e >
|
|
412
|
+
return e instanceof Date || Object.prototype.toString.call(e) === "[object Date]" ? !isNaN(e.getTime()) : !t && typeof e == "number" && !(e < 0 || e > T);
|
|
419
413
|
}
|
|
420
414
|
getRow() {
|
|
421
415
|
return 0;
|
|
@@ -423,6 +417,9 @@ var b = class {
|
|
|
423
417
|
getColumn() {
|
|
424
418
|
return 0;
|
|
425
419
|
}
|
|
420
|
+
isImplicitIntersect() {
|
|
421
|
+
return !1;
|
|
422
|
+
}
|
|
426
423
|
getFormulaAt(e, t, n) {
|
|
427
424
|
return null;
|
|
428
425
|
}
|
|
@@ -447,19 +444,22 @@ var b = class {
|
|
|
447
444
|
return null;
|
|
448
445
|
}
|
|
449
446
|
getAddress(e, t) {
|
|
450
|
-
throw new
|
|
447
|
+
throw new S();
|
|
451
448
|
}
|
|
452
449
|
parseAsSerialDate(e, t) {
|
|
453
|
-
throw new
|
|
450
|
+
throw new S();
|
|
454
451
|
}
|
|
455
452
|
parseAsDate(e, t) {
|
|
456
|
-
throw new
|
|
453
|
+
throw new S();
|
|
457
454
|
}
|
|
458
455
|
parseAsNumber(e, t) {
|
|
459
|
-
throw new
|
|
456
|
+
throw new S();
|
|
457
|
+
}
|
|
458
|
+
createCriteria(e, t) {
|
|
459
|
+
throw new S();
|
|
460
460
|
}
|
|
461
|
-
|
|
462
|
-
throw new
|
|
461
|
+
createGrouping(e, t) {
|
|
462
|
+
throw new S();
|
|
463
463
|
}
|
|
464
464
|
parseAsLiteral(e) {
|
|
465
465
|
let t = e.toUpperCase();
|
|
@@ -470,16 +470,16 @@ var b = class {
|
|
|
470
470
|
}
|
|
471
471
|
compare(e, t, n) {
|
|
472
472
|
if (e === t) return 0;
|
|
473
|
-
let r =
|
|
473
|
+
let r = b(e), i = b(t);
|
|
474
474
|
return r === i ? e < t ? -1 : +(e > t) : r < i ? -1 : 1;
|
|
475
475
|
}
|
|
476
476
|
getRuntime() {
|
|
477
|
-
return
|
|
477
|
+
return w;
|
|
478
478
|
}
|
|
479
479
|
getArgs() {
|
|
480
|
-
throw new
|
|
480
|
+
throw new S(x);
|
|
481
481
|
}
|
|
482
|
-
},
|
|
482
|
+
}, b = (e) => {
|
|
483
483
|
if (e == null) return 0;
|
|
484
484
|
switch (typeof e) {
|
|
485
485
|
case "number": return 1;
|
|
@@ -487,32 +487,33 @@ var b = class {
|
|
|
487
487
|
case "boolean": return 3;
|
|
488
488
|
default: return 4;
|
|
489
489
|
}
|
|
490
|
-
},
|
|
490
|
+
}, x = "FormulaContext.getArgs() is only valid while a function body is running", S = class extends Error {
|
|
491
491
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
492
492
|
super(e), this.name = "NotImplementedError";
|
|
493
493
|
}
|
|
494
|
-
},
|
|
494
|
+
}, C = Object.freeze({
|
|
495
495
|
colStart: 0,
|
|
496
496
|
rowStart: 0,
|
|
497
497
|
colEnd: 2 ** 14 - 1,
|
|
498
498
|
rowEnd: 2 ** 20 - 1
|
|
499
|
-
}),
|
|
499
|
+
}), w = {
|
|
500
500
|
isDate1904: () => !1,
|
|
501
|
-
getLocale: () =>
|
|
502
|
-
getLocaleProfile: () =>
|
|
501
|
+
getLocale: () => O.tag,
|
|
502
|
+
getLocaleProfile: () => O,
|
|
503
503
|
isR1C1: () => !1,
|
|
504
504
|
getNow: () => 0,
|
|
505
|
+
getRandom: () => Math.random(),
|
|
505
506
|
getLocation: () => "unknown",
|
|
506
507
|
getVersion: () => "1.0.0",
|
|
507
508
|
getOS: () => "unknown",
|
|
508
509
|
getUser: () => "unidentified",
|
|
509
510
|
getDescription: () => "Stubbed Formula Context"
|
|
510
|
-
},
|
|
511
|
+
}, T = 2958465, E = new y(), D = class {
|
|
511
512
|
constructor() {
|
|
512
|
-
this._scope =
|
|
513
|
+
this._scope = E, this._argsFn = null;
|
|
513
514
|
}
|
|
514
515
|
_setScope(e) {
|
|
515
|
-
this._scope = e ??
|
|
516
|
+
this._scope = e ?? E;
|
|
516
517
|
}
|
|
517
518
|
_getScope() {
|
|
518
519
|
return this._scope;
|
|
@@ -524,7 +525,7 @@ var b = class {
|
|
|
524
525
|
return this._getScope().getNumberFormat(e, t);
|
|
525
526
|
}
|
|
526
527
|
getEntireCoords() {
|
|
527
|
-
return this._getScope().getEntireCoords() ??
|
|
528
|
+
return this._getScope().getEntireCoords() ?? C;
|
|
528
529
|
}
|
|
529
530
|
parseAsSerialDate(e, t) {
|
|
530
531
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -535,12 +536,15 @@ var b = class {
|
|
|
535
536
|
parseAsNumber(e, t) {
|
|
536
537
|
return this._getScope().parseAsNumber(e, t);
|
|
537
538
|
}
|
|
538
|
-
createCriteria(e) {
|
|
539
|
-
return this._getScope().createCriteria(e);
|
|
539
|
+
createCriteria(e, t) {
|
|
540
|
+
return this._getScope().createCriteria(e, t);
|
|
541
|
+
}
|
|
542
|
+
createGrouping(e, t) {
|
|
543
|
+
return this._getScope().createGrouping(e, t);
|
|
540
544
|
}
|
|
541
545
|
parseAsLiteral(e) {
|
|
542
546
|
let t = this._getScope();
|
|
543
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
547
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : E.parseAsLiteral(e);
|
|
544
548
|
}
|
|
545
549
|
toText(e) {
|
|
546
550
|
return this._getScope().toText(e);
|
|
@@ -563,15 +567,30 @@ var b = class {
|
|
|
563
567
|
getNow() {
|
|
564
568
|
return this._getScope().getNow();
|
|
565
569
|
}
|
|
570
|
+
getRandom() {
|
|
571
|
+
return this._getScope().getRandom?.() ?? Math.random();
|
|
572
|
+
}
|
|
566
573
|
createRange(e, t, n) {
|
|
567
574
|
return this._getScope().createRange(e, t, n);
|
|
568
575
|
}
|
|
576
|
+
flattenAreas(e) {
|
|
577
|
+
if (!Array.isArray(e)) return e;
|
|
578
|
+
let t = [];
|
|
579
|
+
for (let n = 0; n < e.length; n++) {
|
|
580
|
+
let r = e[n], { rows: i, columns: a } = r.getShape();
|
|
581
|
+
for (let e = 0; e < i; e++) for (let n = 0; n < a; n++) t.push(r.getValueAt(e, n));
|
|
582
|
+
}
|
|
583
|
+
return this.createRange(t.length, 1, (e, n) => t[n.rowIndex]);
|
|
584
|
+
}
|
|
569
585
|
getRow() {
|
|
570
586
|
return this._getScope().getRow?.() ?? 0;
|
|
571
587
|
}
|
|
572
588
|
getColumn() {
|
|
573
589
|
return this._getScope().getColumn?.() ?? 0;
|
|
574
590
|
}
|
|
591
|
+
isImplicitIntersect() {
|
|
592
|
+
return this._getScope().isImplicitIntersect?.() ?? !1;
|
|
593
|
+
}
|
|
575
594
|
getReference(e, t) {
|
|
576
595
|
return this._getScope().getReference(e, t);
|
|
577
596
|
}
|
|
@@ -612,14 +631,14 @@ var b = class {
|
|
|
612
631
|
return this._getScope().getAddress(e, t);
|
|
613
632
|
}
|
|
614
633
|
compare(e, t, n) {
|
|
615
|
-
return this._getScope().compare?.(e, t, n) ??
|
|
634
|
+
return this._getScope().compare?.(e, t, n) ?? E.compare(e, t, n);
|
|
616
635
|
}
|
|
617
636
|
getRuntime() {
|
|
618
637
|
return this._getScope().getRuntime();
|
|
619
638
|
}
|
|
620
639
|
getArgs() {
|
|
621
640
|
let e = this._argsFn, t = e ? e() : null;
|
|
622
|
-
if (!t) throw new
|
|
641
|
+
if (!t) throw new S(x);
|
|
623
642
|
return t;
|
|
624
643
|
}
|
|
625
644
|
get [Symbol.toStringTag]() {
|
|
@@ -628,7 +647,7 @@ var b = class {
|
|
|
628
647
|
toString() {
|
|
629
648
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
630
649
|
}
|
|
631
|
-
},
|
|
650
|
+
}, O = Object.freeze({
|
|
632
651
|
tag: "en-US",
|
|
633
652
|
numberingSystem: "latn",
|
|
634
653
|
decimal: ".",
|
|
@@ -708,5 +727,5 @@ var b = class {
|
|
|
708
727
|
sensitivity: "base",
|
|
709
728
|
numeric: !0
|
|
710
729
|
})
|
|
711
|
-
}),
|
|
712
|
-
export {
|
|
730
|
+
}), k = new D();
|
|
731
|
+
export { O as DEFAULT_LOCALE_PROFILE, k as FormulaContext, i as FormulaError, t as IRange, r as IRangeStats, o as InteropScalarType, v as Observable, e as Scalar, a as ScalarType, D as ScopedFormulaContext, y as StubbedFormulaContext, s as ValueKind, u as WildCard, d as isLazyValue };
|