nudojs 1.0.1 → 1.0.3

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 (2) hide show
  1. package/dist/index.js +459 -190
  2. package/package.json +5 -5
package/dist/index.js CHANGED
@@ -47,7 +47,12 @@ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__
47
47
  function termEquals(a, b) {
48
48
  if (a === b) return true;
49
49
  if (a.op !== b.op) return false;
50
- if (a.op === "lit" && b.op === "lit") return a.value === b.value;
50
+ if (a.op === "lit" && b.op === "lit") {
51
+ if (typeof a.value === "number" && typeof b.value === "number" && Number.isNaN(a.value) && Number.isNaN(b.value)) {
52
+ return true;
53
+ }
54
+ return a.value === b.value;
55
+ }
51
56
  if (a.op === "var" && b.op === "var") return a.id === b.id;
52
57
  if (a.op === "app" && b.op === "app") {
53
58
  return a.fn === b.fn && a.args.length === b.args.length && a.args.every((x, i) => termEquals(x, b.args[i]));
@@ -86,18 +91,10 @@ function simplifyTerm(t) {
86
91
  const folded = foldLiterals(fn2, xs);
87
92
  if (folded !== void 0) return lit(folded);
88
93
  }
89
- if (fn2 === "+" && args.length === 2) {
90
- const [a, b] = args;
91
- if (a.op === "lit" && a.value === 0) return b;
92
- if (b.op === "lit" && b.value === 0) return a;
93
- }
94
94
  if (fn2 === "*" && args.length === 2) {
95
95
  const [a, b] = args;
96
96
  if (a.op === "lit" && a.value === 1) return b;
97
97
  if (b.op === "lit" && b.value === 1) return a;
98
- if (a.op === "lit" && a.value === 0 || b.op === "lit" && b.value === 0) {
99
- return lit(0);
100
- }
101
98
  }
102
99
  if (fn2 === "-" && args.length === 2) {
103
100
  const [a, b] = args;
@@ -17294,7 +17291,7 @@ function coercibleLit(v2) {
17294
17291
  return v2 !== void 0 && (typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null);
17295
17292
  }
17296
17293
  function toNumberResult(a, b, op) {
17297
- const term = a.term && b.term ? simplifyTerm(app(op, [a.term, b.term])) : void 0;
17294
+ const term = a.term && b.term ? app(op, [a.term, b.term]) : void 0;
17298
17295
  return abs(
17299
17296
  { k: "prim", type: "number" },
17300
17297
  term,
@@ -17461,9 +17458,6 @@ function mul(a, b, phi2 = pTrue) {
17461
17458
  }
17462
17459
  if (isNumericLike(a) && isNumericLike(b) && a.term && b.term) {
17463
17460
  const term = simplifyTerm(app("*", [a.term, b.term]));
17464
- if (b.term.op === "lit" && b.term.value === 0 || a.term.op === "lit" && a.term.value === 0) {
17465
- return numLit(0);
17466
- }
17467
17461
  let k;
17468
17462
  let base;
17469
17463
  if (b.term.op === "lit" && typeof b.term.value === "number") {
@@ -17575,9 +17569,6 @@ function mod(a, b, phi2 = pTrue) {
17575
17569
  return abs({ k: "prim", type: "bigint" }, void 0, void 0, confJoin(a.conf, b.conf));
17576
17570
  }
17577
17571
  if (typeof va === "number" && typeof vb === "number") {
17578
- if (vb === 0) {
17579
- return abs(num().shape, void 0, void 0, "path");
17580
- }
17581
17572
  return numLit(va % vb);
17582
17573
  }
17583
17574
  if (coercibleLit(va) && coercibleLit(vb)) {
@@ -17585,14 +17576,24 @@ function mod(a, b, phi2 = pTrue) {
17585
17576
  }
17586
17577
  if (isNumericLike(a) && isNumericLike(b) && a.term && b.term) {
17587
17578
  const term = simplifyTerm(app("%", [a.term, b.term]));
17588
- if (b.term.op === "lit" && typeof b.term.value === "number" && b.term.value !== 0) {
17579
+ if (b.term.op === "lit") {
17580
+ const bv = b.term.value;
17581
+ if (typeof bv === "number" && (bv === 0 || Number.isNaN(bv))) {
17582
+ return numLit(NaN);
17583
+ }
17584
+ }
17585
+ if (b.term.op === "lit" && typeof b.term.value === "number" && Number.isFinite(b.term.value) && b.term.value !== 0) {
17589
17586
  const k = Math.abs(b.term.value);
17590
- return abs(
17591
- num().shape,
17592
- term,
17593
- and(gt(term, lit(-k)), lt(term, lit(k))),
17594
- confJoin(confJoin(a.conf, b.conf), "path")
17595
- );
17587
+ const ab = numericBounds(a, phi2);
17588
+ const finiteDividend = ab?.lo !== void 0 && ab?.hi !== void 0 && Number.isFinite(ab.lo.value) && Number.isFinite(ab.hi.value);
17589
+ if (finiteDividend) {
17590
+ return abs(
17591
+ num().shape,
17592
+ term,
17593
+ and(gt(term, lit(-k)), lt(term, lit(k))),
17594
+ confJoin(confJoin(a.conf, b.conf), "path")
17595
+ );
17596
+ }
17596
17597
  }
17597
17598
  return abs(num().shape, term, void 0, confJoin(confJoin(a.conf, b.conf), "path"));
17598
17599
  }
@@ -17605,11 +17606,18 @@ function mod(a, b, phi2 = pTrue) {
17605
17606
  return abs({ k: "unknown" }, void 0, void 0, "partial");
17606
17607
  }
17607
17608
  function cmp(op, a, b, phi2 = pTrue) {
17608
- const va = litValue(a);
17609
- const vb = litValue(b);
17610
- if (va !== void 0 && vb !== void 0) {
17611
- const result = compareLits(op, va, vb);
17609
+ const ta = a.term;
17610
+ const tb = b.term;
17611
+ if (ta?.op === "lit" && tb?.op === "lit") {
17612
+ const result = compareLits(op, ta.value, tb.value);
17612
17613
  if (result !== void 0) return boolLit(result);
17614
+ } else {
17615
+ const va = litValue(a);
17616
+ const vb = litValue(b);
17617
+ if (va !== void 0 && vb !== void 0) {
17618
+ const result = compareLits(op, va, vb);
17619
+ if (result !== void 0) return boolLit(result);
17620
+ }
17613
17621
  }
17614
17622
  if (a.term && b.term) {
17615
17623
  const pred = op === "lt" ? lt(a.term, b.term) : op === "le" ? le(a.term, b.term) : op === "gt" ? gt(a.term, b.term) : op === "ge" ? ge(a.term, b.term) : op === "eq" ? { op: "eq", a: a.term, b: b.term } : { op: "ne", a: a.term, b: b.term };
@@ -17838,54 +17846,36 @@ var init_shared = __esm({
17838
17846
  });
17839
17847
 
17840
17848
  // ../core/src/algebra/builtins/math.ts
17849
+ function coerceMathArg(a) {
17850
+ if (!a || a.term?.op !== "lit") return void 0;
17851
+ const v2 = a.term.value;
17852
+ if (typeof v2 === "number") return v2;
17853
+ if (typeof v2 === "string") return Number(v2);
17854
+ if (typeof v2 === "boolean") return v2 ? 1 : 0;
17855
+ if (v2 === null) return 0;
17856
+ if (v2 === void 0) return void 0;
17857
+ return "throw";
17858
+ }
17859
+ function mathMethod(name) {
17860
+ if (!Object.hasOwn(Math, name)) return void 0;
17861
+ const impl = Math[name];
17862
+ return typeof impl === "function" ? impl : void 0;
17863
+ }
17841
17864
  function evalMathMethod(name, args) {
17842
- const a0 = args[0] ? litValue(args[0]) : void 0;
17843
- const a1 = args[1] ? litValue(args[1]) : void 0;
17844
- switch (name) {
17845
- case "abs":
17846
- if (typeof a0 === "number") return numLit(Math.abs(a0));
17847
- return numPrim();
17848
- case "floor":
17849
- if (typeof a0 === "number") return numLit(Math.floor(a0));
17850
- return numPrim();
17851
- case "ceil":
17852
- if (typeof a0 === "number") return numLit(Math.ceil(a0));
17853
- return numPrim();
17854
- case "round":
17855
- if (typeof a0 === "number") return numLit(Math.round(a0));
17856
- return numPrim();
17857
- case "random":
17858
- return numPrim("path");
17859
- case "sqrt":
17860
- if (typeof a0 === "number") return numLit(Math.sqrt(a0));
17861
- return numPrim();
17862
- case "min": {
17863
- const lits = args.map(litValue);
17864
- if (lits.length > 0 && lits.every((x) => typeof x === "number")) {
17865
- return numLit(Math.min(...lits));
17866
- }
17867
- return numPrim();
17868
- }
17869
- case "max": {
17870
- const lits = args.map(litValue);
17871
- if (lits.length > 0 && lits.every((x) => typeof x === "number")) {
17872
- return numLit(Math.max(...lits));
17873
- }
17874
- return numPrim();
17875
- }
17876
- case "pow":
17877
- if (typeof a0 === "number" && typeof a1 === "number") return numLit(Math.pow(a0, a1));
17878
- return numPrim();
17879
- case "sign":
17880
- if (typeof a0 === "number") return numLit(Math.sign(a0));
17881
- return numPrim();
17882
- case "atan2":
17883
- if (typeof a0 === "number" && typeof a1 === "number") {
17884
- return numLit(Math.atan2(a0, a1));
17885
- }
17886
- return numPrim();
17887
- default:
17888
- return void 0;
17865
+ if (name === "random") return numPrim("path");
17866
+ const impl = mathMethod(name);
17867
+ if (!impl) return void 0;
17868
+ const nums = [];
17869
+ for (const a of args) {
17870
+ const n = coerceMathArg(a);
17871
+ if (n === void 0) return numPrim();
17872
+ if (n === "throw") throw new NudoThrow(errorTypeAbs("TypeError"));
17873
+ nums.push(n);
17874
+ }
17875
+ try {
17876
+ return numLit(impl(...nums));
17877
+ } catch {
17878
+ return numPrim();
17889
17879
  }
17890
17880
  }
17891
17881
  var init_math = __esm({
@@ -17893,6 +17883,8 @@ var init_math = __esm({
17893
17883
  "use strict";
17894
17884
  init_abs();
17895
17885
  init_shared();
17886
+ init_nudo_throw();
17887
+ init_may_throw();
17896
17888
  }
17897
17889
  });
17898
17890
 
@@ -18530,6 +18522,11 @@ function jsonValueToAbs(v2) {
18530
18522
  }
18531
18523
  return abs({ k: "obj", slots }, void 0, void 0, "exact");
18532
18524
  }
18525
+ function isNonJsonTopLevel(a) {
18526
+ if (a.shape.k === "fn") return true;
18527
+ if (a.shape.k === "prim" && a.shape.type === "symbol") return true;
18528
+ return false;
18529
+ }
18533
18530
  function evalJsonMethod(name, args) {
18534
18531
  if (name === "parse") {
18535
18532
  const a0Abs = args[0];
@@ -18552,7 +18549,10 @@ function evalJsonMethod(name, args) {
18552
18549
  const a0Abs = args[0];
18553
18550
  if (!a0Abs) return undefAbs();
18554
18551
  const v2 = absToJsonNative(a0Abs, /* @__PURE__ */ new Set());
18555
- if (v2 === NOT_LITERAL) return str2("partial");
18552
+ if (v2 === NOT_LITERAL) {
18553
+ if (isNonJsonTopLevel(a0Abs)) return undefAbs();
18554
+ return str2("partial");
18555
+ }
18556
18556
  const replacerArg = args[1];
18557
18557
  let replacer;
18558
18558
  if (replacerArg) {
@@ -18608,34 +18608,60 @@ var init_json = __esm({
18608
18608
  function foldParseInt(s, radix) {
18609
18609
  const str6 = String(s);
18610
18610
  if (radix === void 0) return numLit(parseInt(str6));
18611
- const r = radix | 0;
18611
+ const r = Number(radix) | 0;
18612
18612
  if (r === 0) return numLit(parseInt(str6));
18613
18613
  if (r < 2 || r > 36) return numLit(NaN);
18614
18614
  return numLit(parseInt(str6, r));
18615
18615
  }
18616
+ function foldParseFloat(s) {
18617
+ return numLit(parseFloat(String(s)));
18618
+ }
18619
+ function toStringLitArg(a) {
18620
+ if (!a) return { lit: true, v: void 0 };
18621
+ if (a.term?.op !== "lit") return { lit: false };
18622
+ const v2 = a.term.value;
18623
+ if (typeof v2 === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
18624
+ return { lit: true, v: v2 };
18625
+ }
18626
+ function radixLitArg(a) {
18627
+ if (!a) return { ok: true, v: void 0 };
18628
+ if (a.term?.op !== "lit") return { ok: false };
18629
+ const v2 = a.term.value;
18630
+ if (typeof v2 === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
18631
+ if (v2 === void 0) return { ok: true, v: void 0 };
18632
+ if (typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null) {
18633
+ return { ok: true, v: v2 };
18634
+ }
18635
+ return { ok: false };
18636
+ }
18616
18637
  function evalNumberStatic(name, args) {
18617
- const a0 = args[0] ? litValue(args[0]) : void 0;
18638
+ const a0Arg = args[0];
18639
+ const a0 = a0Arg ? litValue(a0Arg) : void 0;
18640
+ const foldStrictNumberPred = (pred) => {
18641
+ if (!a0Arg) return boolLit(false);
18642
+ if (a0Arg.term?.op !== "lit") return void 0;
18643
+ const v2 = a0Arg.term.value;
18644
+ return boolLit(typeof v2 === "number" && pred(v2));
18645
+ };
18618
18646
  switch (name) {
18619
18647
  case "isInteger":
18620
- if (typeof a0 === "number") return boolLit(Number.isInteger(a0));
18621
- return boolPrim();
18648
+ return foldStrictNumberPred(Number.isInteger) ?? boolPrim();
18622
18649
  case "isNaN":
18623
- if (typeof a0 === "number") return boolLit(Number.isNaN(a0));
18624
- return boolPrim();
18650
+ return foldStrictNumberPred(Number.isNaN) ?? boolPrim();
18625
18651
  case "isFinite":
18626
- if (typeof a0 === "number") return boolLit(Number.isFinite(a0));
18627
- return boolPrim();
18628
- case "parseInt":
18629
- if (typeof a0 === "string" || typeof a0 === "number") {
18630
- const radix = args[1] ? litValue(args[1]) : void 0;
18631
- if (radix === void 0) return foldParseInt(a0, void 0);
18632
- if (typeof radix === "number") return foldParseInt(a0, radix);
18633
- return numPrim();
18634
- }
18635
- return numPrim();
18636
- case "parseFloat":
18637
- if (typeof a0 === "string" || typeof a0 === "number") return numLit(parseFloat(String(a0)));
18638
- return numPrim();
18652
+ return foldStrictNumberPred(Number.isFinite) ?? boolPrim();
18653
+ case "parseInt": {
18654
+ const s = toStringLitArg(a0Arg);
18655
+ if (!s.lit) return numPrim();
18656
+ const radix = radixLitArg(args[1]);
18657
+ if (!radix.ok) return numPrim();
18658
+ return foldParseInt(s.v, radix.v);
18659
+ }
18660
+ case "parseFloat": {
18661
+ const s = toStringLitArg(a0Arg);
18662
+ if (!s.lit) return numPrim();
18663
+ return foldParseFloat(s.v);
18664
+ }
18639
18665
  case "MAX_SAFE_INTEGER":
18640
18666
  return numLit(Number.MAX_SAFE_INTEGER);
18641
18667
  default:
@@ -18647,6 +18673,8 @@ var init_number = __esm({
18647
18673
  "use strict";
18648
18674
  init_abs();
18649
18675
  init_shared();
18676
+ init_nudo_throw();
18677
+ init_may_throw();
18650
18678
  }
18651
18679
  });
18652
18680
 
@@ -19539,29 +19567,59 @@ var init_array = __esm({
19539
19567
  });
19540
19568
 
19541
19569
  // ../core/src/algebra/builtins/global.ts
19570
+ function litTermOf(a) {
19571
+ return a?.term?.op === "lit" ? a.term : void 0;
19572
+ }
19542
19573
  function evalGlobalFn(name, args) {
19543
19574
  const a0 = args[0] ? litValue(args[0]) : void 0;
19575
+ const a0Lit = litTermOf(args[0]);
19544
19576
  switch (name) {
19545
19577
  case "eval":
19546
19578
  return unknown;
19547
19579
  case "Array":
19548
19580
  return makeArrayCtorAbs(args);
19549
- case "parseInt":
19550
- if (typeof a0 === "string" || typeof a0 === "number") {
19551
- const radix = args[1] ? litValue(args[1]) : void 0;
19552
- if (radix === void 0) return foldParseInt(a0, void 0);
19553
- if (typeof radix === "number") return foldParseInt(a0, radix);
19581
+ case "parseInt": {
19582
+ const sVal = a0Lit ? a0Lit.value : void 0;
19583
+ if (a0Lit && typeof sVal === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
19584
+ if (!a0Lit && args[0] && args[0].term?.op !== "lit") return numPrim();
19585
+ const rAbs = args[1];
19586
+ let radix;
19587
+ if (!rAbs) {
19588
+ radix = void 0;
19589
+ } else if (rAbs.term?.op !== "lit") {
19554
19590
  return numPrim();
19591
+ } else if (typeof rAbs.term.value === "symbol") {
19592
+ throw new NudoThrow(errorTypeAbs("TypeError"));
19593
+ } else {
19594
+ const rv = rAbs.term.value;
19595
+ radix = rv === void 0 ? void 0 : rv;
19596
+ if (rv !== void 0 && typeof rv !== "number" && typeof rv !== "string" && typeof rv !== "boolean" && rv !== null) {
19597
+ return numPrim();
19598
+ }
19599
+ }
19600
+ return foldParseInt(sVal, radix);
19601
+ }
19602
+ case "parseFloat": {
19603
+ if (!a0Lit && args[0] && args[0].term?.op !== "lit") return numPrim();
19604
+ if (a0Lit && typeof a0Lit.value === "symbol") throw new NudoThrow(errorTypeAbs("TypeError"));
19605
+ return foldParseFloat(a0Lit ? a0Lit.value : void 0);
19606
+ }
19607
+ case "isNaN": {
19608
+ if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
19609
+ if (!args[0] || args[0].term?.op === "lit" && args[0].term.value === void 0) {
19610
+ return boolLit(true);
19555
19611
  }
19556
- return numPrim();
19557
- case "parseFloat":
19558
- if (typeof a0 === "string" || typeof a0 === "number") return numLit(parseFloat(String(a0)));
19559
- return numPrim();
19560
- case "isNaN":
19561
19612
  if (typeof a0 === "number") return boolLit(Number.isNaN(a0));
19613
+ if (typeof a0 === "boolean" || a0 === null) return boolLit(false);
19614
+ if (typeof a0 === "string") return boolLit(Number.isNaN(Number(a0)));
19615
+ if (typeof a0 === "bigint") throw new NudoThrow(errorTypeAbs("TypeError"));
19562
19616
  return boolPrim();
19617
+ }
19563
19618
  case "isFinite": {
19564
- if (a0 === void 0 && args.length === 0) return boolLit(false);
19619
+ if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
19620
+ if (!args[0] || args[0].term?.op === "lit" && args[0].term.value === void 0) {
19621
+ return boolLit(false);
19622
+ }
19565
19623
  if (typeof a0 === "number") return boolLit(Number.isFinite(a0));
19566
19624
  if (typeof a0 === "boolean") return boolLit(true);
19567
19625
  if (typeof a0 === "string") return boolLit(Number.isFinite(Number(a0)));
@@ -19570,18 +19628,24 @@ function evalGlobalFn(name, args) {
19570
19628
  }
19571
19629
  case "Number":
19572
19630
  if (args[0] && isSymbolAbs2(args[0])) throw new NudoThrow(errorTypeAbs("TypeError"));
19631
+ if (!args[0]) return numLit(0);
19632
+ if (a0Lit && a0Lit.value === void 0) return numLit(NaN);
19573
19633
  if (typeof a0 === "number") return numLit(a0);
19574
19634
  if (typeof a0 === "string") return numLit(Number(a0));
19575
19635
  if (typeof a0 === "boolean") return numLit(a0 ? 1 : 0);
19636
+ if (a0 === null) return numLit(0);
19637
+ if (typeof a0 === "bigint") return numLit(Number(a0));
19576
19638
  return numPrim();
19577
19639
  case "String":
19578
19640
  if (args[0] && isSymbolAbs2(args[0])) return stringOfSymbol(args[0]);
19579
- if (a0 !== void 0) return strLit(String(a0));
19641
+ if (!args[0]) return strLit("");
19642
+ if (a0Lit) return strLit(String(a0Lit.value));
19580
19643
  return str2();
19581
19644
  case "Symbol":
19582
19645
  return makeSymbolAbs(args[0]);
19583
19646
  case "Boolean":
19584
- if (a0 !== void 0) return boolLit(Boolean(a0));
19647
+ if (!args[0]) return boolLit(false);
19648
+ if (a0Lit) return boolLit(Boolean(a0Lit.value));
19585
19649
  return boolPrim();
19586
19650
  case "Object": {
19587
19651
  const arg = args[0];
@@ -20577,6 +20641,12 @@ function negAbs(a, _phi = pTrue) {
20577
20641
  const v2 = litValue(a);
20578
20642
  if (typeof v2 === "number") return numLitAbs(-v2);
20579
20643
  if (typeof v2 === "bigint") return bigintLit(-v2);
20644
+ if (a.term?.op === "lit") {
20645
+ const tv = a.term.value;
20646
+ if (typeof tv === "string" || typeof tv === "boolean" || tv === null) {
20647
+ return numLitAbs(-Number(tv));
20648
+ }
20649
+ }
20580
20650
  if (a.shape.k === "prim" && a.shape.type === "number") {
20581
20651
  if (!a.term) {
20582
20652
  return abs(num().shape, void 0, void 0, confJoin(a.conf, "widened"));
@@ -20643,7 +20713,7 @@ function isDefinitelyTruthyShape(s) {
20643
20713
  case "eff":
20644
20714
  return true;
20645
20715
  case "prim":
20646
- return s.type === "symbol" || s.type === "bigint";
20716
+ return s.type === "symbol";
20647
20717
  default:
20648
20718
  return false;
20649
20719
  }
@@ -20710,7 +20780,12 @@ function strictEqAbs(a, b) {
20710
20780
  if (bNullish && definitelyNotNullishShape(a.shape)) return false;
20711
20781
  if (aNullish && definitelyNotNullishShape(b.shape)) return false;
20712
20782
  if (a.term && b.term && a.term.op === "var" && b.term.op === "var" && a.term.id === b.term.id) {
20713
- return true;
20783
+ const k = a.shape.k;
20784
+ if (k === "obj" || k === "arr" || k === "tuple" || k === "fn" || k === "brand" || k === "eff") {
20785
+ return true;
20786
+ }
20787
+ if (k === "prim" && a.shape.type !== "number") return true;
20788
+ return void 0;
20714
20789
  }
20715
20790
  return void 0;
20716
20791
  }
@@ -20785,9 +20860,26 @@ function callbackEnv() {
20785
20860
  function isStrRecv(recv) {
20786
20861
  return isTemplateLike(recv) || recv.shape.k === "prim" && recv.shape.type === "string" || recv.term?.op === "lit" && typeof recv.term.value === "string";
20787
20862
  }
20863
+ function isFoldableIndexArg(x) {
20864
+ if (x === void 0) return true;
20865
+ if (x.term?.op !== "lit") return false;
20866
+ const v2 = x.term.value;
20867
+ return v2 === void 0 || typeof v2 === "number" || typeof v2 === "string" || typeof v2 === "boolean" || v2 === null;
20868
+ }
20869
+ function toStringArg(x) {
20870
+ if (x === void 0) return "undefined";
20871
+ if (x.term?.op !== "lit") return void 0;
20872
+ const v2 = x.term.value;
20873
+ if (typeof v2 === "symbol") return void 0;
20874
+ return String(v2);
20875
+ }
20876
+ function isUndefinedArg(x) {
20877
+ return x === void 0 || x.term?.op === "lit" && x.term.value === void 0;
20878
+ }
20788
20879
  function callAbsMethod(recv, name, args) {
20789
20880
  if (!isStrRecv(recv)) return void 0;
20790
20881
  const a0 = args[0] ? litValue(args[0]) : void 0;
20882
+ const a0Str = toStringArg(args[0]);
20791
20883
  const lit3 = recv.term?.op === "lit" && typeof recv.term.value === "string" ? recv.term.value : void 0;
20792
20884
  if (isTemplateLike(recv)) {
20793
20885
  const views = absTemplateViews(templatePartsOf(recv));
@@ -20796,20 +20888,20 @@ function callAbsMethod(recv, name, args) {
20796
20888
  switch (name) {
20797
20889
  case "startsWith": {
20798
20890
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
20799
- if (typeof a0 !== "string") return boolPrim5();
20800
- const d = decideStartsWith(prefix2, a0);
20891
+ if (a0Str === void 0) return boolPrim5();
20892
+ const d = decideStartsWith(prefix2, a0Str);
20801
20893
  return d === "unknown" ? boolPrim5() : boolLit(d);
20802
20894
  }
20803
20895
  case "endsWith": {
20804
20896
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
20805
- if (typeof a0 !== "string") return boolPrim5();
20806
- const d = decideEndsWith(suffix, a0);
20897
+ if (a0Str === void 0) return boolPrim5();
20898
+ const d = decideEndsWith(suffix, a0Str);
20807
20899
  return d === "unknown" ? boolPrim5() : boolLit(d);
20808
20900
  }
20809
20901
  case "includes": {
20810
20902
  if (args[1] && litValue(args[1]) !== void 0) return boolPrim5();
20811
- if (typeof a0 !== "string") return boolPrim5();
20812
- const d = decideIncludes(allFixedTextOfViews(views), a0);
20903
+ if (a0Str === void 0) return boolPrim5();
20904
+ const d = decideIncludes(allFixedTextOfViews(views), a0Str);
20813
20905
  return d === "unknown" ? boolPrim5() : boolLit(d);
20814
20906
  }
20815
20907
  case "toUpperCase":
@@ -20835,10 +20927,10 @@ function callAbsMethod(recv, name, args) {
20835
20927
  const a1 = a1Abs ? litValue(a1Abs) : void 0;
20836
20928
  const a1Unknown = a1Abs !== void 0 && a1Abs.term?.op !== "lit";
20837
20929
  if (a1Unknown) return boolPrim5();
20838
- if (lit3 !== void 0 && typeof a0 === "string") {
20839
- if (name === "startsWith") return boolLit(lit3.startsWith(a0, a1));
20840
- if (name === "endsWith") return boolLit(lit3.endsWith(a0, a1));
20841
- return boolLit(lit3.includes(a0, a1));
20930
+ if (lit3 !== void 0 && a0Str !== void 0) {
20931
+ if (name === "startsWith") return boolLit(lit3.startsWith(a0Str, a1));
20932
+ if (name === "endsWith") return boolLit(lit3.endsWith(a0Str, a1));
20933
+ return boolLit(lit3.includes(a0Str, a1));
20842
20934
  }
20843
20935
  return boolPrim5();
20844
20936
  }
@@ -20851,8 +20943,7 @@ function callAbsMethod(recv, name, args) {
20851
20943
  case "slice":
20852
20944
  case "substring":
20853
20945
  if (lit3 !== void 0) {
20854
- const numOrMissing = (x) => x === void 0 || x.term?.op === "lit" && (x.term.value === void 0 || typeof x.term.value === "number");
20855
- if (!numOrMissing(args[0]) || !numOrMissing(args[1])) return strPrim("path");
20946
+ if (!isFoldableIndexArg(args[0]) || !isFoldableIndexArg(args[1])) return strPrim("path");
20856
20947
  const a1 = args[1] ? litValue(args[1]) : void 0;
20857
20948
  if (name === "slice") {
20858
20949
  return strLit(lit3.slice(a0, a1));
@@ -20860,8 +20951,11 @@ function callAbsMethod(recv, name, args) {
20860
20951
  return strLit(lit3.substring(Number(a0 ?? 0), Number(a1 ?? lit3.length)));
20861
20952
  }
20862
20953
  return strPrim("path");
20863
- case "charAt":
20864
- return lit3 !== void 0 && typeof a0 === "number" ? strLit(lit3.charAt(a0)) : strPrim("path");
20954
+ case "charAt": {
20955
+ if (lit3 === void 0) return strPrim("path");
20956
+ if (!isFoldableIndexArg(args[0])) return strPrim("path");
20957
+ return strLit(lit3.charAt(Number(a0 ?? 0)));
20958
+ }
20865
20959
  case "toString":
20866
20960
  case "valueOf":
20867
20961
  return lit3 !== void 0 ? strLit(lit3) : strPrim("path");
@@ -20877,17 +20971,36 @@ function callAbsMethod(recv, name, args) {
20877
20971
  return strPrim("path");
20878
20972
  }
20879
20973
  case "indexOf":
20880
- case "lastIndexOf":
20881
- case "charCodeAt":
20882
- return numPrim5("path");
20974
+ case "lastIndexOf": {
20975
+ if (lit3 === void 0) return numPrim5("path");
20976
+ const search = toStringArg(args[0]);
20977
+ if (search === void 0) return numPrim5("path");
20978
+ if (!isFoldableIndexArg(args[1])) return numPrim5("path");
20979
+ const from = args[1] ? litValue(args[1]) : void 0;
20980
+ return numLit(
20981
+ name === "indexOf" ? lit3.indexOf(search, from) : lit3.lastIndexOf(search, from)
20982
+ );
20983
+ }
20984
+ case "charCodeAt": {
20985
+ if (lit3 === void 0) return numPrim5("path");
20986
+ if (!isFoldableIndexArg(args[0])) return numPrim5("path");
20987
+ return numLit(lit3.charCodeAt(Number(a0 ?? 0)));
20988
+ }
20883
20989
  case "split": {
20884
20990
  if (lit3 !== void 0) {
20885
- const sep5 = typeof a0 === "string" ? a0 : void 0;
20886
- const a1Abs = args[1];
20887
- const a1 = a1Abs ? litValue(a1Abs) : void 0;
20888
- if (a1Abs !== void 0 && a1Abs.term?.op !== "lit") return strArr("path");
20991
+ const limAbs = args[1];
20992
+ const lim = limAbs ? litValue(limAbs) : void 0;
20993
+ if (limAbs !== void 0 && limAbs.term?.op !== "lit") return strArr("path");
20994
+ if (isUndefinedArg(args[0])) {
20995
+ const one = abs({ k: "tuple", elements: [strLit(lit3)] }, void 0, void 0, "exact");
20996
+ if (lim === void 0) return one;
20997
+ const n = Number(lim);
20998
+ if (!(n > 0)) return abs({ k: "tuple", elements: [] }, void 0, void 0, "exact");
20999
+ return one;
21000
+ }
21001
+ const sep5 = toStringArg(args[0]);
20889
21002
  if (sep5 !== void 0) {
20890
- const parts = lit3.split(sep5, a1).map((s) => strLit(s));
21003
+ const parts = lit3.split(sep5, lim).map((s) => strLit(s));
20891
21004
  return abs({ k: "tuple", elements: parts }, void 0, void 0, "exact");
20892
21005
  }
20893
21006
  return strArr("path");
@@ -20899,12 +21012,16 @@ function callAbsMethod(recv, name, args) {
20899
21012
  if (lit3 !== void 0) {
20900
21013
  const patAbs = args[0];
20901
21014
  const repAbs = args[1];
20902
- if (patAbs && repAbs) {
21015
+ {
20903
21016
  let patSrc;
20904
21017
  let patRe;
20905
- const pv = patAbs.term?.op === "lit" ? patAbs.term.value : void 0;
20906
- if (typeof pv === "string") {
21018
+ const pv = patAbs?.term?.op === "lit" ? patAbs.term.value : void 0;
21019
+ if (patAbs === void 0) {
21020
+ patSrc = "undefined";
21021
+ } else if (typeof pv === "string") {
20907
21022
  patSrc = pv;
21023
+ } else if (patAbs.term?.op === "lit" && typeof pv !== "symbol") {
21024
+ patSrc = String(pv);
20908
21025
  } else if (patAbs.shape.k === "brand" && patAbs.shape.name === "RegExp") {
20909
21026
  const inner = patAbs.shape.shape;
20910
21027
  const slots = inner.shape.k === "obj" ? inner.shape.slots : void 0;
@@ -20923,11 +21040,12 @@ function callAbsMethod(recv, name, args) {
20923
21040
  throw new NudoThrow(errorTypeAbs("TypeError"));
20924
21041
  }
20925
21042
  const pat = patSrc ?? patRe;
20926
- const rv = repAbs.term?.op === "lit" ? repAbs.term.value : void 0;
20927
- if (typeof rv === "string") {
21043
+ const rvLit = repAbs?.term?.op === "lit" ? repAbs.term.value : void 0;
21044
+ const rv = repAbs === void 0 ? "undefined" : typeof rvLit === "string" ? rvLit : repAbs.term?.op === "lit" && typeof rvLit !== "symbol" ? String(rvLit) : void 0;
21045
+ if (rv !== void 0) {
20928
21046
  return strLit(name === "replaceAll" ? lit3.replaceAll(pat, rv) : lit3.replace(pat, rv));
20929
21047
  }
20930
- if (repAbs.shape.k === "fn") {
21048
+ if (repAbs && repAbs.shape.k === "fn") {
20931
21049
  let anyUnknown = false;
20932
21050
  const replWrapper = (...caps) => {
20933
21051
  const last2 = caps[caps.length - 1];
@@ -21338,8 +21456,9 @@ function leqWithPred(src, tgt, phi2, env2, depth) {
21338
21456
  if (src.shape.k === "any") return ok();
21339
21457
  const sv = litValue(src);
21340
21458
  const tv = litValue(tgt);
21459
+ const sameLit = sv === tv || typeof sv === "number" && typeof tv === "number" && Number.isNaN(sv) && Number.isNaN(tv);
21341
21460
  if (sv !== void 0 && tv !== void 0) {
21342
- if (sv === tv) return ok();
21461
+ if (sameLit) return ok();
21343
21462
  if (tgt.shape.k === "prim") {
21344
21463
  return fail(`lit ${String(sv)} \u22AD lit ${String(tv)}`);
21345
21464
  }
@@ -24396,7 +24515,7 @@ function litTruth(a) {
24396
24515
  case "eff":
24397
24516
  return true;
24398
24517
  case "prim":
24399
- return a.shape.type === "symbol" || a.shape.type === "bigint" ? true : void 0;
24518
+ return a.shape.type === "symbol" ? true : void 0;
24400
24519
  case "never":
24401
24520
  return false;
24402
24521
  default:
@@ -25567,7 +25686,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
25567
25686
  if (node.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.computed !== true && node.callee.property?.type === "Identifier" && ARR_MUTATOR_NAMES.has(node.callee.property.name)) {
25568
25687
  const methodName = node.callee.property.name;
25569
25688
  const argSrcs = (node.arguments ?? []).map(
25570
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : isExpression(a) ? emitTranspileExpression(a, opts) : "$lit(undefined)"
25689
+ (a) => a.type === "SpreadElement" ? "$unknown()" : isExpression(a) ? emitTranspileExpression(a, opts) : "$unknown()"
25571
25690
  ).join(", ");
25572
25691
  const objNode = node.callee.object;
25573
25692
  if (objNode.type === "Identifier") {
@@ -25589,7 +25708,7 @@ function emitArrMutatorRebinds(expr, opts, pad) {
25589
25708
  }
25590
25709
  if (node.type === "CallExpression" && node.callee?.type === "MemberExpression" && node.callee.computed !== true && node.callee.object?.type === "Identifier" && node.callee.object.name === "Object" && node.callee.property?.type === "Identifier" && node.callee.property.name === "defineProperty" && node.arguments?.[0] && node.arguments[0].type === "Identifier") {
25591
25710
  const argSrcs = node.arguments.map(
25592
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : emitTranspileExpression(a, opts)
25711
+ (a) => a.type === "SpreadElement" ? "$unknown()" : emitTranspileExpression(a, opts)
25593
25712
  ).join(", ");
25594
25713
  const targetName = node.arguments[0].name;
25595
25714
  lines.push(
@@ -26241,7 +26360,7 @@ ${pad}export default ${name};`;
26241
26360
  const methodName = expr.callee.property.name;
26242
26361
  if (["push", "unshift", "splice", "pop", "shift", "reverse", "sort"].includes(methodName)) {
26243
26362
  const argSrcs = expr.arguments.map(
26244
- (a) => a.type === "SpreadElement" ? "$lit(undefined)" : emitTranspileExpression(a, opts)
26363
+ (a) => a.type === "SpreadElement" ? "$unknown()" : emitTranspileExpression(a, opts)
26245
26364
  ).join(", ");
26246
26365
  const objNode = expr.callee.object;
26247
26366
  if (objNode.type === "Identifier") {
@@ -27141,7 +27260,7 @@ function transpileExpression(expr, opts = {}) {
27141
27260
  case "NewExpression": {
27142
27261
  const callee = expr.callee;
27143
27262
  const cname = callee.type === "Identifier" ? callee.name : isExpression(callee) ? transpileExpression(callee, opts) : "$lit(undefined)";
27144
- const args = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
27263
+ const args = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
27145
27264
  return `$new(${cname}, [${args}])`;
27146
27265
  }
27147
27266
  case "LogicalExpression": {
@@ -27577,11 +27696,11 @@ ${mBodyInner}
27577
27696
  const optionalCall = exprAny.type === "OptionalCallExpression" || exprAny.optional === true;
27578
27697
  const callee = expr.callee;
27579
27698
  if (callee.type === "Super" && opts.thisParam && opts.className) {
27580
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
27699
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
27581
27700
  return `${opts.thisParam} = $super(${opts.thisParam}, ${JSON.stringify(opts.className)}, [${args2}])`;
27582
27701
  }
27583
27702
  if (callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Super" && callee.property.type === "Identifier" && opts.thisParam && opts.className) {
27584
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
27703
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
27585
27704
  return `$invokeSuper(${opts.thisParam}, ${JSON.stringify(opts.className)}, ${JSON.stringify(callee.property.name)}, [${args2}])`;
27586
27705
  }
27587
27706
  if (callee.type === "MemberExpression" && !callee.computed && callee.object.type === "Identifier" && callee.object.name === "require" && callee.property.type === "Identifier" && callee.property.name === "resolve") {
@@ -27596,7 +27715,7 @@ ${mBodyInner}
27596
27715
  }
27597
27716
  if ((callee.type === "MemberExpression" || callee.type === "OptionalMemberExpression") && !callee.computed && callee.property.type === "Identifier") {
27598
27717
  const recv = transpileExpression(callee.object, opts);
27599
- const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$lit(undefined)" : transpileExpression(a, opts)).join(", ");
27718
+ const args2 = expr.arguments.map((a) => a.type === "SpreadElement" ? "$unknown()" : transpileExpression(a, opts)).join(", ");
27600
27719
  const name = JSON.stringify(callee.property.name);
27601
27720
  const opt = optionalCall || callee.optional === true;
27602
27721
  const loc = expr.loc;
@@ -27612,7 +27731,7 @@ ${mBodyInner}
27612
27731
  const argLocSrcs = [];
27613
27732
  for (const a of expr.arguments) {
27614
27733
  if (a.type === "SpreadElement") {
27615
- argSrcs.push("$lit(undefined)");
27734
+ argSrcs.push("$unknown()");
27616
27735
  argLocSrcs.push("null");
27617
27736
  } else {
27618
27737
  argSrcs.push(transpileExpression(a, opts));
@@ -28844,16 +28963,21 @@ function $arrMutContainer(arr, method, args) {
28844
28963
  function $idx(a, i) {
28845
28964
  if (a?.shape?.k === "any") return anyMemberResult();
28846
28965
  const iv = litValue(i);
28966
+ const idx = iv !== void 0 ? canonicalArrayIndex(iv) : void 0;
28847
28967
  if (a.shape.k === "tuple") {
28848
28968
  const els = a.shape.elements;
28849
- if (typeof iv === "number" && Number.isInteger(iv)) {
28850
- if (iv >= 0 && iv < els.length) return els[iv];
28969
+ if (iv !== void 0 && idx === void 0) return undef();
28970
+ if (idx !== void 0) {
28971
+ if (idx < els.length) return els[idx];
28851
28972
  return undef();
28852
28973
  }
28853
28974
  if (els.length === 0) return undef();
28854
28975
  return els.reduce((x, y) => joinAbs(x, y));
28855
28976
  }
28856
- if (a.shape.k === "arr") return a.shape.element;
28977
+ if (a.shape.k === "arr") {
28978
+ if (iv !== void 0 && idx === void 0) return undef();
28979
+ return a.shape.element;
28980
+ }
28857
28981
  if (a.shape.k === "sum") {
28858
28982
  return a.shape.members.map((m) => $idx(m, i)).reduce((x, y) => joinAbs(x, y));
28859
28983
  }
@@ -29242,6 +29366,9 @@ function namespaceNameOf(v2) {
29242
29366
  function $regex(pattern, flags = "") {
29243
29367
  return regexBrandAbsFrom(pattern, flags);
29244
29368
  }
29369
+ function isPossiblyProtoMemberKey(key) {
29370
+ return OBJECT_PROTO_METHOD_NAMES.has(key) || ARRAY_PROTO_METHOD_NAMES.has(key) || key === "constructor" || key.startsWith("@@");
29371
+ }
29245
29372
  function $get(o, key, opts) {
29246
29373
  if (!o || typeof o !== "object" || !("shape" in o)) {
29247
29374
  if (o === Object.prototype) {
@@ -29333,10 +29460,19 @@ function $get(o, key, opts) {
29333
29460
  if ((o.shape.k === "tuple" || o.shape.k === "arr") && key === "length") {
29334
29461
  return $len(o);
29335
29462
  }
29336
- if ((o.shape.k === "tuple" || o.shape.k === "arr" || o.shape.k === "prim") && OBJECT_PROTO_METHOD_NAMES.has(key) && !(o.shape.k === "prim" && o.shape.type === "string" && key === "toString")) {
29463
+ if (o.shape.k === "tuple") {
29464
+ const idx = canonicalArrayIndex(key);
29465
+ const els = o.shape.elements;
29466
+ if (idx !== void 0) return idx < els.length ? els[idx] : undef();
29467
+ if (!isPossiblyProtoMemberKey(key)) return undef();
29468
+ }
29469
+ if ((o.shape.k === "tuple" || o.shape.k === "arr" || o.shape.k === "prim") && (OBJECT_PROTO_METHOD_NAMES.has(key) || o.shape.k !== "prim" && ARRAY_PROTO_METHOD_NAMES.has(key)) && !(o.shape.k === "prim" && o.shape.type === "string" && key === "toString")) {
29337
29470
  if ((o.shape.k === "tuple" || o.shape.k === "arr") && (key === "toString" || key === "toLocaleString" || key === "join")) {
29338
29471
  return arrayMethodAbs(key === "join" ? "join" : key);
29339
29472
  }
29473
+ if (o.shape.k !== "prim" && (ARRAY_PROTO_METHOD_NAMES.has(key) || key === "@@iterator")) {
29474
+ return absFunction([], { body: noBody2 });
29475
+ }
29340
29476
  return objectProtoMethodAbs(key);
29341
29477
  }
29342
29478
  if (noteNullishMemberThrows(o, key, "property")) {
@@ -29535,7 +29671,7 @@ function $set(o, key, value) {
29535
29671
  clearStaleTermPred(o);
29536
29672
  return o;
29537
29673
  }
29538
- var ARR_MUTATORS;
29674
+ var ARR_MUTATORS, ARRAY_PROTO_METHOD_NAMES;
29539
29675
  var init_containers2 = __esm({
29540
29676
  "../core/src/algebra/exec/runtime/containers.ts"() {
29541
29677
  "use strict";
@@ -29568,6 +29704,43 @@ var init_containers2 = __esm({
29568
29704
  "copyWithin",
29569
29705
  "fill"
29570
29706
  ]);
29707
+ ARRAY_PROTO_METHOD_NAMES = /* @__PURE__ */ new Set([
29708
+ "at",
29709
+ "concat",
29710
+ "copyWithin",
29711
+ "entries",
29712
+ "every",
29713
+ "fill",
29714
+ "filter",
29715
+ "find",
29716
+ "findIndex",
29717
+ "findLast",
29718
+ "findLastIndex",
29719
+ "flat",
29720
+ "flatMap",
29721
+ "forEach",
29722
+ "includes",
29723
+ "indexOf",
29724
+ "join",
29725
+ "keys",
29726
+ "lastIndexOf",
29727
+ "map",
29728
+ "pop",
29729
+ "push",
29730
+ "reduce",
29731
+ "reduceRight",
29732
+ "reverse",
29733
+ "shift",
29734
+ "slice",
29735
+ "some",
29736
+ "sort",
29737
+ "splice",
29738
+ "toLocaleString",
29739
+ "toString",
29740
+ "unshift",
29741
+ "values",
29742
+ "@@iterator"
29743
+ ]);
29571
29744
  }
29572
29745
  });
29573
29746
 
@@ -30219,7 +30392,9 @@ __export(calls_exports, {
30219
30392
  $recordBinding: () => $recordBinding,
30220
30393
  MAX_B_CALL_DEPTH: () => MAX_B_CALL_DEPTH,
30221
30394
  MAX_B_TOTAL_CALLS: () => MAX_B_TOTAL_CALLS,
30395
+ blockHostSideEffect: () => blockHostSideEffect,
30222
30396
  getBCallCollector: () => getBCallCollector,
30397
+ neverExecHostName: () => neverExecHostName,
30223
30398
  noteBCallRecord: () => noteBCallRecord,
30224
30399
  resetBCallBudget: () => resetBCallBudget,
30225
30400
  setBAssignCollector: () => setBAssignCollector,
@@ -30259,6 +30434,12 @@ function neverExecHostName(fn2) {
30259
30434
  }
30260
30435
  return null;
30261
30436
  }
30437
+ function blockHostSideEffect(fn2) {
30438
+ const hostName = neverExecHostName(fn2);
30439
+ if (hostName === null) return null;
30440
+ noteHostEffectBlocked(hostName);
30441
+ return abs({ k: "unknown" }, void 0, void 0, "opaque");
30442
+ }
30262
30443
  function noteBCallRecord(r) {
30263
30444
  if (!bCallCollector) return;
30264
30445
  try {
@@ -30333,12 +30514,11 @@ function $callNamed(name, fn2, args, loc, argLocs) {
30333
30514
  try {
30334
30515
  if (typeof fn2 === "function") {
30335
30516
  const g = GLOBAL_FNS.has(name) && fn2 === globalThis[name] ? evalGlobalFn(name, args) : void 0;
30336
- const blockedHost = g === void 0 ? neverExecHostName(fn2) : null;
30517
+ const blockedHost = g === void 0 ? blockHostSideEffect(fn2) : null;
30337
30518
  if (g !== void 0) {
30338
30519
  result = g;
30339
30520
  } else if (blockedHost !== null) {
30340
- noteHostEffectBlocked(blockedHost);
30341
- result = bTruncatedAbs();
30521
+ result = blockedHost;
30342
30522
  } else {
30343
30523
  const entered = bEnterCall(name, fn2, args);
30344
30524
  if (!entered.ok) {
@@ -30691,6 +30871,8 @@ function $new(cls, args) {
30691
30871
  }
30692
30872
  }
30693
30873
  if (typeof cls === "function") {
30874
+ const blockedHost = blockHostSideEffect(cls);
30875
+ if (blockedHost) return blockedHost;
30694
30876
  if (cls === Array) {
30695
30877
  return makeArrayCtorAbs(args);
30696
30878
  }
@@ -30985,13 +31167,11 @@ function $invoke(thisVal, method, args, loc) {
30985
31167
  }
30986
31168
  const brandName = thisVal.shape.k === "brand" ? thisVal.shape.name : void 0;
30987
31169
  if (brandName) {
30988
- if (brandName === "Map" || brandName === "Set") {
30989
- const viaCol = evalBuiltinInstanceMethod(brandName, method, thisVal, args);
30990
- if (viaCol !== void 0) return viaCol;
30991
- if (method === "forEach") {
30992
- const r = $collectionForEach(thisVal, args[0]);
30993
- if (r !== void 0) return r;
30994
- }
31170
+ const viaBuiltin = evalBuiltinInstanceMethod(brandName, method, thisVal, args);
31171
+ if (viaBuiltin !== void 0) return viaBuiltin;
31172
+ if ((brandName === "Map" || brandName === "Set") && method === "forEach") {
31173
+ const r = $collectionForEach(thisVal, args[0]);
31174
+ if (r !== void 0) return r;
30995
31175
  }
30996
31176
  const m = findMethod(brandName, method);
30997
31177
  if (m) {
@@ -37829,37 +38009,105 @@ function parseObjectLiteral(content) {
37829
38009
  }
37830
38010
  return absExact({ k: "obj", slots });
37831
38011
  }
38012
+ function scanWithStrings(s, onChar, onStructural) {
38013
+ let depth = 0;
38014
+ let inString = null;
38015
+ for (let i = 0; i < s.length; i++) {
38016
+ const ch = s[i];
38017
+ if (inString) {
38018
+ onChar(ch, i);
38019
+ if (ch === "\\") {
38020
+ i++;
38021
+ if (i < s.length) onChar(s[i], i);
38022
+ continue;
38023
+ }
38024
+ if (ch === inString) inString = null;
38025
+ continue;
38026
+ }
38027
+ if (ch === '"' || ch === "'") {
38028
+ inString = ch;
38029
+ onChar(ch, i);
38030
+ continue;
38031
+ }
38032
+ if (ch === "(" || ch === "[" || ch === "{") {
38033
+ depth++;
38034
+ onChar(ch, i);
38035
+ onStructural(ch, i, depth);
38036
+ continue;
38037
+ }
38038
+ if (ch === ")" || ch === "]" || ch === "}") {
38039
+ depth--;
38040
+ onChar(ch, i);
38041
+ onStructural(ch, i, depth);
38042
+ continue;
38043
+ }
38044
+ onChar(ch, i);
38045
+ onStructural(ch, i, depth);
38046
+ }
38047
+ }
37832
38048
  function splitTopLevelArgs(s) {
37833
38049
  const result = [];
37834
- let depth = 0;
37835
38050
  let current = "";
37836
- for (const ch of s) {
38051
+ let depth = 0;
38052
+ let inString = null;
38053
+ for (let i = 0; i < s.length; i++) {
38054
+ const ch = s[i];
38055
+ if (inString) {
38056
+ current += ch;
38057
+ if (ch === "\\") {
38058
+ i++;
38059
+ if (i < s.length) current += s[i];
38060
+ continue;
38061
+ }
38062
+ if (ch === inString) inString = null;
38063
+ continue;
38064
+ }
38065
+ if (ch === '"' || ch === "'") {
38066
+ inString = ch;
38067
+ current += ch;
38068
+ continue;
38069
+ }
37837
38070
  if (ch === "(" || ch === "[" || ch === "{") depth++;
37838
38071
  if (ch === ")" || ch === "]" || ch === "}") depth--;
37839
38072
  if (ch === "," && depth === 0) {
37840
38073
  result.push(current.trim());
37841
38074
  current = "";
37842
- } else {
37843
- current += ch;
38075
+ continue;
37844
38076
  }
38077
+ current += ch;
37845
38078
  }
37846
38079
  if (current.trim()) result.push(current.trim());
37847
38080
  return result;
37848
38081
  }
37849
38082
  function findTopLevelColon(s) {
37850
- let depth = 0;
37851
- for (let i = 0; i < s.length; i++) {
37852
- const ch = s[i];
37853
- if (ch === "(" || ch === "[" || ch === "{") depth++;
37854
- if (ch === ")" || ch === "]" || ch === "}") depth--;
37855
- if (ch === ":" && depth === 0) return i;
37856
- }
37857
- return -1;
38083
+ let found = -1;
38084
+ scanWithStrings(
38085
+ s,
38086
+ () => {
38087
+ },
38088
+ (ch, i, depth) => {
38089
+ if (found === -1 && ch === ":" && depth === 0) found = i;
38090
+ }
38091
+ );
38092
+ return found;
37858
38093
  }
37859
38094
  function findTopLevelArrow(s) {
37860
38095
  let depth = 0;
38096
+ let inString = null;
37861
38097
  for (let i = 0; i < s.length - 1; i++) {
37862
38098
  const ch = s[i];
38099
+ if (inString) {
38100
+ if (ch === "\\") {
38101
+ i++;
38102
+ continue;
38103
+ }
38104
+ if (ch === inString) inString = null;
38105
+ continue;
38106
+ }
38107
+ if (ch === '"' || ch === "'") {
38108
+ inString = ch;
38109
+ continue;
38110
+ }
37863
38111
  if (ch === "(" || ch === "[" || ch === "{") depth++;
37864
38112
  else if (ch === ")" || ch === "]" || ch === "}") depth--;
37865
38113
  else if (depth === 0 && ch === "=" && s[i + 1] === ">") return i;
@@ -37869,9 +38117,23 @@ function findTopLevelArrow(s) {
37869
38117
  function extractBalancedParens(text, startIdx) {
37870
38118
  if (text[startIdx] !== "(") return null;
37871
38119
  let depth = 0;
38120
+ let inString = null;
37872
38121
  for (let i = startIdx; i < text.length; i++) {
37873
- if (text[i] === "(") depth++;
37874
- if (text[i] === ")") depth--;
38122
+ const ch = text[i];
38123
+ if (inString) {
38124
+ if (ch === "\\") {
38125
+ i++;
38126
+ continue;
38127
+ }
38128
+ if (ch === inString) inString = null;
38129
+ continue;
38130
+ }
38131
+ if (ch === '"' || ch === "'") {
38132
+ inString = ch;
38133
+ continue;
38134
+ }
38135
+ if (ch === "(") depth++;
38136
+ if (ch === ")") depth--;
37875
38137
  if (depth === 0) return text.slice(startIdx + 1, i);
37876
38138
  }
37877
38139
  return null;
@@ -48788,14 +49050,21 @@ import { resolve as resolve5, dirname as dirname5, relative, sep } from "path";
48788
49050
  function checkConfig(config) {
48789
49051
  const raw = config?.check;
48790
49052
  const rawEntry = raw?.entryThrows;
49053
+ const rawProfile = raw?.profile;
48791
49054
  let entryThrows = "error";
48792
- if (rawEntry === "off" || rawEntry === "warning" || rawEntry === "error") {
49055
+ const entryValid = rawEntry === "off" || rawEntry === "warning" || rawEntry === "error";
49056
+ if (entryValid) {
48793
49057
  entryThrows = rawEntry;
48794
- } else if (rawEntry !== void 0) {
48795
- process.stderr?.write?.(
48796
- `nudo.check.entryThrows: invalid value ${JSON.stringify(rawEntry)} (expected error|warning|off); using error
49058
+ } else {
49059
+ if (rawEntry !== void 0) {
49060
+ process.stderr?.write?.(
49061
+ `nudo.check.entryThrows: invalid value ${JSON.stringify(rawEntry)} (expected error|warning|off); using error
48797
49062
  `
48798
- );
49063
+ );
49064
+ }
49065
+ if (rawProfile === "adoption" || rawProfile === "strict") {
49066
+ entryThrows = rawProfile === "adoption" ? "warning" : "error";
49067
+ }
48799
49068
  }
48800
49069
  const ignore = Array.isArray(raw?.ignoreThrows) ? raw.ignoreThrows.filter((s) => typeof s === "string" && s.length > 0) : [];
48801
49070
  return { entryThrows, ignoreThrows: ignore };
@@ -269041,7 +269310,7 @@ var init_chunk_J2PUE4NV = __esm({
269041
269310
  }
269042
269311
  });
269043
269312
 
269044
- // ../service/dist/chunk-ZXVAX7DE.js
269313
+ // ../service/dist/chunk-COMUCF3K.js
269045
269314
  import { readFileSync as readFileSync17, existsSync as existsSync18, statSync as statSync12, mkdirSync as mkdirSync5, writeFileSync as writeFileSync5 } from "fs";
269046
269315
  import { resolve as resolvePath2, join as joinPath2 } from "path";
269047
269316
  import { pathToFileURL as pathToFileURL2 } from "url";
@@ -269441,8 +269710,8 @@ function resolveNpmJsEntry2(source, fromDir) {
269441
269710
  return tryFile(resolve22(pkgDir, subpath));
269442
269711
  }
269443
269712
  var BUILTIN_ERROR_CLASSES2, BUILTIN_PROTOTYPE_CLASSES2, numA2, strA2, boolA2, unkA2, undefA2, nullA2, OBJECT_PROTOTYPE_METHODS2, BUILTIN_PROTOTYPE_METHOD_APPROXIMATIONS2, BoundedLruMap3, envFactories2, impliedDeps2, PATH_ENV_CACHE_MAX2, PATH_ENV_BY_PATH_MAX2, PATH_ENV_BASE_DIRS_MAX2, pathEnvCache2, pathEnvByPath2, pathEnvBaseDirs2, DEFAULT_SESSION_CACHE_LIMITS2, HARD_CAP2, explicit2, fromProject2, envCache2, DEFAULT_ANALYSIS_EXCLUDE2, DEFAULT_ANALYSIS_MODE2;
269444
- var init_chunk_ZXVAX7DE = __esm({
269445
- "../service/dist/chunk-ZXVAX7DE.js"() {
269713
+ var init_chunk_COMUCF3K = __esm({
269714
+ "../service/dist/chunk-COMUCF3K.js"() {
269446
269715
  "use strict";
269447
269716
  init_src();
269448
269717
  init_es();
@@ -269718,7 +269987,7 @@ var init_chunk_ZXVAX7DE = __esm({
269718
269987
  }
269719
269988
  });
269720
269989
 
269721
- // ../service/dist/chunk-NQXAF4LJ.js
269990
+ // ../service/dist/chunk-H2LVQGKH.js
269722
269991
  import { existsSync as existsSync23, statSync as statSync23, readFileSync as readFileSync23 } from "fs";
269723
269992
  import { dirname as dirname23, resolve as resolve23, join as join14 } from "path";
269724
269993
  import { readFileSync as readFileSync33, statSync as statSync32 } from "fs";
@@ -272863,10 +273132,10 @@ function analyzeFile2(filePath, source, activeCases, externalCallRecords, loadMo
272863
273132
  return cloneAnalysisResult2(result);
272864
273133
  }
272865
273134
  var externalRecordIds2, nextExternalRecordId2, ABS_MODULE_CACHE_MAX2, absModuleCache2, ENV_DEPENDENTS_MAX2, ENV_DEPENDENTS_PER_KEY_MAX2, envDependents2, analysisByFile2, fnAnalysisCache2, envHarvestConflictCollector2, bRunByFile2, neverAbs2, undefAbs4, MAX_RECORD_TYPE_NODES2, KNOWN_GLOBALS2, DEFAULT_CALLSITE_BUDGET3, COLLAPSE_LITERAL_THRESHOLD2;
272866
- var init_chunk_NQXAF4LJ = __esm({
272867
- "../service/dist/chunk-NQXAF4LJ.js"() {
273135
+ var init_chunk_H2LVQGKH = __esm({
273136
+ "../service/dist/chunk-H2LVQGKH.js"() {
272868
273137
  "use strict";
272869
- init_chunk_ZXVAX7DE();
273138
+ init_chunk_COMUCF3K();
272870
273139
  init_src2();
272871
273140
  init_lib5();
272872
273141
  init_src();
@@ -276421,8 +276690,8 @@ var init_emit2 = __esm({
276421
276690
  "../service/dist/emit/index.js"() {
276422
276691
  "use strict";
276423
276692
  init_chunk_J2PUE4NV();
276424
- init_chunk_NQXAF4LJ();
276425
- init_chunk_ZXVAX7DE();
276693
+ init_chunk_H2LVQGKH();
276694
+ init_chunk_COMUCF3K();
276426
276695
  init_src();
276427
276696
  init_src();
276428
276697
  init_src2();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nudojs",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "engines": {
5
5
  "node": ">=20"
6
6
  },
@@ -46,10 +46,10 @@
46
46
  "dependencies": {
47
47
  "@babel/generator": "^8.0.6",
48
48
  "@babel/types": "^8.0.6",
49
- "@nudojs/core": "1.1.1",
50
- "@nudojs/parser": "1.1.1",
51
- "@nudojs/service": "1.1.1",
52
- "@nudojs/harvester": "0.2.9",
49
+ "@nudojs/core": "1.1.3",
50
+ "@nudojs/parser": "1.1.3",
51
+ "@nudojs/service": "1.1.3",
52
+ "@nudojs/harvester": "0.2.11",
53
53
  "commander": "^15.0.0"
54
54
  },
55
55
  "devDependencies": {