@sheetxl/primitives 0.7.28-beta.4 → 0.8.0-beta.10
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 +101 -55
- package/node/esm/index.mjs +115 -67
- 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 +47 -7
- package/types/src/IFormulaContext.d.ts +223 -11
- package/types/src/IFunction.d.ts +368 -39
- package/types/src/IFunctionArguments.d.ts +214 -0
- package/types/src/IRange.d.ts +199 -40
- package/types/src/IRangeStats.d.ts +34 -3
- 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 +7 -0
- package/browser/cjs/index.cjs +0 -1
package/browser/esm/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.
|
|
2
|
+
* @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.10
|
|
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,14 +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
|
-
n === "*" ? r += ".*" : r += n === "?" ? "." : c(n);
|
|
49
|
+
n !== "*" && n !== "?" && n !== "~" || (r += l(n), t++);
|
|
50
|
+
} else r += n === "*" ? "[\\s\\S]*" : n === "?" ? "[\\s\\S]" : l(n);
|
|
47
51
|
}
|
|
48
|
-
return RegExp(n ? `^${r}$` : r, t);
|
|
52
|
+
return RegExp(n === "start" ? `^${r}` : n ? `^${r}$` : r, t);
|
|
49
53
|
}
|
|
50
|
-
};
|
|
54
|
+
}, d = (e) => typeof e == "object" && !!e && !0 === e.isLazy;
|
|
51
55
|
(n = t ||= {}).Axis = {
|
|
52
56
|
Column: "column",
|
|
53
57
|
Row: "row"
|
|
@@ -309,15 +313,15 @@ var t, n, r, i, a = {
|
|
|
309
313
|
}
|
|
310
314
|
e.Timeout = S;
|
|
311
315
|
}(i ||= {});
|
|
312
|
-
var
|
|
313
|
-
|
|
314
|
-
var
|
|
315
|
-
for (let e = 0; e <
|
|
316
|
-
let t =
|
|
317
|
-
|
|
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);
|
|
318
322
|
}
|
|
319
323
|
(function(e) {
|
|
320
|
-
let t = e.getBuiltInByCode = (e) =>
|
|
324
|
+
let t = e.getBuiltInByCode = (e) => m.get(e);
|
|
321
325
|
e.BuiltIn = {
|
|
322
326
|
Parse: t(i.Code.Parse),
|
|
323
327
|
Null: t(i.Code.Null),
|
|
@@ -339,12 +343,12 @@ for (let e = 0; e < h.length; e++) {
|
|
|
339
343
|
Timeout: t(i.Code.Timeout)
|
|
340
344
|
}, e.newTypedError = (e, t, n) => {
|
|
341
345
|
let r;
|
|
342
|
-
return r = typeof e == "string" ?
|
|
343
|
-
}, 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) {
|
|
344
348
|
return !!e && !0 === e.isFormulaError && (t === void 0 || e.getCode() === t);
|
|
345
349
|
};
|
|
346
350
|
})(i ||= {});
|
|
347
|
-
var
|
|
351
|
+
var v = class {
|
|
348
352
|
constructor(e) {
|
|
349
353
|
this._subscribeFn = e;
|
|
350
354
|
}
|
|
@@ -364,42 +368,48 @@ var g = class {
|
|
|
364
368
|
typeof i == "function" && i();
|
|
365
369
|
}, r;
|
|
366
370
|
}
|
|
367
|
-
},
|
|
371
|
+
}, y = class {
|
|
368
372
|
createRange(e, t, n) {
|
|
369
|
-
throw new
|
|
373
|
+
throw new S();
|
|
374
|
+
}
|
|
375
|
+
flattenAreas(e) {
|
|
376
|
+
throw new S();
|
|
370
377
|
}
|
|
371
378
|
getReference(e, t) {
|
|
372
|
-
throw new
|
|
379
|
+
throw new S();
|
|
373
380
|
}
|
|
374
381
|
getResizedReference(e, t, n) {
|
|
375
|
-
throw new
|
|
382
|
+
throw new S();
|
|
376
383
|
}
|
|
377
384
|
getNumberFormat(e, t) {
|
|
378
|
-
throw new
|
|
385
|
+
throw new S();
|
|
379
386
|
}
|
|
380
387
|
fromSerialDate(e, t) {
|
|
381
|
-
throw new
|
|
388
|
+
throw new S();
|
|
382
389
|
}
|
|
383
390
|
toSerialDate(e, t) {
|
|
384
|
-
throw new
|
|
391
|
+
throw new S();
|
|
385
392
|
}
|
|
386
393
|
getDateParts(e, t) {
|
|
387
|
-
throw new
|
|
394
|
+
throw new S();
|
|
388
395
|
}
|
|
389
396
|
getSerialDate(e, t, n, r, i, a, o) {
|
|
390
|
-
throw new
|
|
397
|
+
throw new S();
|
|
391
398
|
}
|
|
392
399
|
getNow() {
|
|
393
|
-
throw new
|
|
400
|
+
throw new S();
|
|
401
|
+
}
|
|
402
|
+
getRandom() {
|
|
403
|
+
return Math.random();
|
|
394
404
|
}
|
|
395
405
|
getValueAt(e, t, n, r) {
|
|
396
406
|
return null;
|
|
397
407
|
}
|
|
398
408
|
getEntireCoords() {
|
|
399
|
-
return
|
|
409
|
+
return C;
|
|
400
410
|
}
|
|
401
411
|
isValidDate(e, t) {
|
|
402
|
-
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);
|
|
403
413
|
}
|
|
404
414
|
getRow() {
|
|
405
415
|
return 0;
|
|
@@ -407,6 +417,9 @@ var g = class {
|
|
|
407
417
|
getColumn() {
|
|
408
418
|
return 0;
|
|
409
419
|
}
|
|
420
|
+
isImplicitIntersect() {
|
|
421
|
+
return !1;
|
|
422
|
+
}
|
|
410
423
|
getFormulaAt(e, t, n) {
|
|
411
424
|
return null;
|
|
412
425
|
}
|
|
@@ -431,19 +444,22 @@ var g = class {
|
|
|
431
444
|
return null;
|
|
432
445
|
}
|
|
433
446
|
getAddress(e, t) {
|
|
434
|
-
throw new
|
|
447
|
+
throw new S();
|
|
435
448
|
}
|
|
436
449
|
parseAsSerialDate(e, t) {
|
|
437
|
-
throw new
|
|
450
|
+
throw new S();
|
|
438
451
|
}
|
|
439
452
|
parseAsDate(e, t) {
|
|
440
|
-
throw new
|
|
453
|
+
throw new S();
|
|
441
454
|
}
|
|
442
455
|
parseAsNumber(e, t) {
|
|
443
|
-
throw new
|
|
456
|
+
throw new S();
|
|
444
457
|
}
|
|
445
|
-
createCriteria(e) {
|
|
446
|
-
throw new
|
|
458
|
+
createCriteria(e, t) {
|
|
459
|
+
throw new S();
|
|
460
|
+
}
|
|
461
|
+
createGrouping(e, t) {
|
|
462
|
+
throw new S();
|
|
447
463
|
}
|
|
448
464
|
parseAsLiteral(e) {
|
|
449
465
|
let t = e.toUpperCase();
|
|
@@ -454,13 +470,16 @@ var g = class {
|
|
|
454
470
|
}
|
|
455
471
|
compare(e, t, n) {
|
|
456
472
|
if (e === t) return 0;
|
|
457
|
-
let r =
|
|
473
|
+
let r = b(e), i = b(t);
|
|
458
474
|
return r === i ? e < t ? -1 : +(e > t) : r < i ? -1 : 1;
|
|
459
475
|
}
|
|
460
476
|
getRuntime() {
|
|
461
|
-
return
|
|
477
|
+
return w;
|
|
478
|
+
}
|
|
479
|
+
getArgs() {
|
|
480
|
+
throw new S(x);
|
|
462
481
|
}
|
|
463
|
-
},
|
|
482
|
+
}, b = (e) => {
|
|
464
483
|
if (e == null) return 0;
|
|
465
484
|
switch (typeof e) {
|
|
466
485
|
case "number": return 1;
|
|
@@ -468,41 +487,45 @@ var g = class {
|
|
|
468
487
|
case "boolean": return 3;
|
|
469
488
|
default: return 4;
|
|
470
489
|
}
|
|
471
|
-
},
|
|
490
|
+
}, x = "FormulaContext.getArgs() is only valid while a function body is running", S = class extends Error {
|
|
472
491
|
constructor(e = "Not implemented in StubbedFormulaContext") {
|
|
473
492
|
super(e), this.name = "NotImplementedError";
|
|
474
493
|
}
|
|
475
|
-
},
|
|
494
|
+
}, C = Object.freeze({
|
|
476
495
|
colStart: 0,
|
|
477
496
|
rowStart: 0,
|
|
478
497
|
colEnd: 2 ** 14 - 1,
|
|
479
498
|
rowEnd: 2 ** 20 - 1
|
|
480
|
-
}),
|
|
499
|
+
}), w = {
|
|
481
500
|
isDate1904: () => !1,
|
|
482
|
-
getLocale: () =>
|
|
483
|
-
getLocaleProfile: () =>
|
|
501
|
+
getLocale: () => O.tag,
|
|
502
|
+
getLocaleProfile: () => O,
|
|
484
503
|
isR1C1: () => !1,
|
|
485
504
|
getNow: () => 0,
|
|
505
|
+
getRandom: () => Math.random(),
|
|
486
506
|
getLocation: () => "unknown",
|
|
487
507
|
getVersion: () => "1.0.0",
|
|
488
508
|
getOS: () => "unknown",
|
|
489
509
|
getUser: () => "unidentified",
|
|
490
510
|
getDescription: () => "Stubbed Formula Context"
|
|
491
|
-
},
|
|
511
|
+
}, T = 2958465, E = new y(), D = class {
|
|
492
512
|
constructor() {
|
|
493
|
-
this._scope =
|
|
513
|
+
this._scope = E, this._argsFn = null;
|
|
494
514
|
}
|
|
495
515
|
_setScope(e) {
|
|
496
|
-
this._scope = e ??
|
|
516
|
+
this._scope = e ?? E;
|
|
497
517
|
}
|
|
498
518
|
_getScope() {
|
|
499
519
|
return this._scope;
|
|
500
520
|
}
|
|
521
|
+
_setArgsProvider(e) {
|
|
522
|
+
this._argsFn = e;
|
|
523
|
+
}
|
|
501
524
|
getNumberFormat(e, t) {
|
|
502
525
|
return this._getScope().getNumberFormat(e, t);
|
|
503
526
|
}
|
|
504
527
|
getEntireCoords() {
|
|
505
|
-
return this._getScope().getEntireCoords() ??
|
|
528
|
+
return this._getScope().getEntireCoords() ?? C;
|
|
506
529
|
}
|
|
507
530
|
parseAsSerialDate(e, t) {
|
|
508
531
|
return this._getScope().parseAsSerialDate(e, t);
|
|
@@ -513,12 +536,15 @@ var g = class {
|
|
|
513
536
|
parseAsNumber(e, t) {
|
|
514
537
|
return this._getScope().parseAsNumber(e, t);
|
|
515
538
|
}
|
|
516
|
-
createCriteria(e) {
|
|
517
|
-
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);
|
|
518
544
|
}
|
|
519
545
|
parseAsLiteral(e) {
|
|
520
546
|
let t = this._getScope();
|
|
521
|
-
return t.parseAsLiteral ? t.parseAsLiteral(e) :
|
|
547
|
+
return t.parseAsLiteral ? t.parseAsLiteral(e) : E.parseAsLiteral(e);
|
|
522
548
|
}
|
|
523
549
|
toText(e) {
|
|
524
550
|
return this._getScope().toText(e);
|
|
@@ -541,15 +567,30 @@ var g = class {
|
|
|
541
567
|
getNow() {
|
|
542
568
|
return this._getScope().getNow();
|
|
543
569
|
}
|
|
570
|
+
getRandom() {
|
|
571
|
+
return this._getScope().getRandom?.() ?? Math.random();
|
|
572
|
+
}
|
|
544
573
|
createRange(e, t, n) {
|
|
545
574
|
return this._getScope().createRange(e, t, n);
|
|
546
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
|
+
}
|
|
547
585
|
getRow() {
|
|
548
586
|
return this._getScope().getRow?.() ?? 0;
|
|
549
587
|
}
|
|
550
588
|
getColumn() {
|
|
551
589
|
return this._getScope().getColumn?.() ?? 0;
|
|
552
590
|
}
|
|
591
|
+
isImplicitIntersect() {
|
|
592
|
+
return this._getScope().isImplicitIntersect?.() ?? !1;
|
|
593
|
+
}
|
|
553
594
|
getReference(e, t) {
|
|
554
595
|
return this._getScope().getReference(e, t);
|
|
555
596
|
}
|
|
@@ -590,18 +631,23 @@ var g = class {
|
|
|
590
631
|
return this._getScope().getAddress(e, t);
|
|
591
632
|
}
|
|
592
633
|
compare(e, t, n) {
|
|
593
|
-
return this._getScope().compare?.(e, t, n) ??
|
|
634
|
+
return this._getScope().compare?.(e, t, n) ?? E.compare(e, t, n);
|
|
594
635
|
}
|
|
595
636
|
getRuntime() {
|
|
596
637
|
return this._getScope().getRuntime();
|
|
597
638
|
}
|
|
639
|
+
getArgs() {
|
|
640
|
+
let e = this._argsFn, t = e ? e() : null;
|
|
641
|
+
if (!t) throw new S(x);
|
|
642
|
+
return t;
|
|
643
|
+
}
|
|
598
644
|
get [Symbol.toStringTag]() {
|
|
599
645
|
return "[FormulaContext]";
|
|
600
646
|
}
|
|
601
647
|
toString() {
|
|
602
648
|
return this._getScope()?.toString?.() ?? "{STUB SCOPE}";
|
|
603
649
|
}
|
|
604
|
-
},
|
|
650
|
+
}, O = Object.freeze({
|
|
605
651
|
tag: "en-US",
|
|
606
652
|
numberingSystem: "latn",
|
|
607
653
|
decimal: ".",
|
|
@@ -681,5 +727,5 @@ var g = class {
|
|
|
681
727
|
sensitivity: "base",
|
|
682
728
|
numeric: !0
|
|
683
729
|
})
|
|
684
|
-
}),
|
|
685
|
-
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 };
|