@orkestrel/contract 0.0.13 → 0.0.14

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.
@@ -6503,28 +6503,38 @@ var ContractCompiler = class ContractCompiler {
6503
6503
  static #weakMap = WeakMap;
6504
6504
  static #visits = 0;
6505
6505
  static #scope = 0;
6506
+ static #emptyStack = [];
6507
+ static #emptyNodes = [];
6508
+ static #emptyOrder = [];
6509
+ static #emptySchemas = [];
6510
+ static #emptyGuards = [];
6511
+ static #emptyParsers = [];
6512
+ static #emptyAudits = [];
6513
+ static #emptyReports = [];
6514
+ static #emptySeeds = [];
6515
+ static {
6516
+ INTRINSICS.freeze(ContractCompiler.#emptyStack);
6517
+ INTRINSICS.freeze(ContractCompiler.#emptyNodes);
6518
+ INTRINSICS.freeze(ContractCompiler.#emptyOrder);
6519
+ INTRINSICS.freeze(ContractCompiler.#emptySchemas);
6520
+ INTRINSICS.freeze(ContractCompiler.#emptyGuards);
6521
+ INTRINSICS.freeze(ContractCompiler.#emptyParsers);
6522
+ INTRINSICS.freeze(ContractCompiler.#emptyAudits);
6523
+ INTRINSICS.freeze(ContractCompiler.#emptyReports);
6524
+ INTRINSICS.freeze(ContractCompiler.#emptySeeds);
6525
+ }
6506
6526
  #source;
6507
6527
  #state;
6508
6528
  #stack;
6509
- #emptyStack;
6510
6529
  #nodes;
6511
- #emptyNodes;
6512
6530
  #index;
6513
- #emptyIndex;
6514
6531
  #order;
6515
- #emptyOrder;
6516
6532
  #schemas;
6517
- #emptySchemas;
6518
6533
  #guards;
6519
- #emptyGuards;
6520
6534
  #parsers;
6521
- #emptyParsers;
6522
6535
  #audits;
6523
- #emptyAudits;
6524
6536
  #reports;
6525
- #emptyReports;
6526
6537
  #seeds;
6527
- #emptySeeds;
6528
6538
  #schema;
6529
6539
  #guard;
6530
6540
  #parser;
@@ -6541,25 +6551,15 @@ var ContractCompiler = class ContractCompiler {
6541
6551
  this.#source = shape;
6542
6552
  this.#state = { phase: "ready" };
6543
6553
  this.#stack = [];
6544
- this.#emptyStack = [];
6545
6554
  this.#nodes = [];
6546
- this.#emptyNodes = [];
6547
6555
  this.#index = new ContractCompiler.#weakMap();
6548
- this.#emptyIndex = new ContractCompiler.#weakMap();
6549
6556
  this.#order = [];
6550
- this.#emptyOrder = [];
6551
6557
  this.#schemas = [];
6552
- this.#emptySchemas = [];
6553
6558
  this.#guards = [];
6554
- this.#emptyGuards = [];
6555
6559
  this.#parsers = [];
6556
- this.#emptyParsers = [];
6557
6560
  this.#audits = [];
6558
- this.#emptyAudits = [];
6559
6561
  this.#reports = [];
6560
- this.#emptyReports = [];
6561
6562
  this.#seeds = [];
6562
- this.#emptySeeds = [];
6563
6563
  this.#schema = void 0;
6564
6564
  this.#guard = void 0;
6565
6565
  this.#parser = void 0;
@@ -6681,16 +6681,16 @@ var ContractCompiler = class ContractCompiler {
6681
6681
  }
6682
6682
  #release() {
6683
6683
  this.#source = void 0;
6684
- this.#stack = this.#emptyStack;
6685
- this.#nodes = this.#emptyNodes;
6686
- this.#index = this.#emptyIndex;
6687
- this.#order = this.#emptyOrder;
6688
- this.#schemas = this.#emptySchemas;
6689
- this.#guards = this.#emptyGuards;
6690
- this.#parsers = this.#emptyParsers;
6691
- this.#audits = this.#emptyAudits;
6692
- this.#reports = this.#emptyReports;
6693
- this.#seeds = this.#emptySeeds;
6684
+ this.#stack = ContractCompiler.#emptyStack;
6685
+ this.#nodes = ContractCompiler.#emptyNodes;
6686
+ this.#index = void 0;
6687
+ this.#order = ContractCompiler.#emptyOrder;
6688
+ this.#schemas = ContractCompiler.#emptySchemas;
6689
+ this.#guards = ContractCompiler.#emptyGuards;
6690
+ this.#parsers = ContractCompiler.#emptyParsers;
6691
+ this.#audits = ContractCompiler.#emptyAudits;
6692
+ this.#reports = ContractCompiler.#emptyReports;
6693
+ this.#seeds = ContractCompiler.#emptySeeds;
6694
6694
  }
6695
6695
  #prepare() {
6696
6696
  if (this.#nodes.length > 0) return;
@@ -6710,6 +6710,14 @@ var ContractCompiler = class ContractCompiler {
6710
6710
  this.#source = void 0;
6711
6711
  }
6712
6712
  #discover(root) {
6713
+ const known = this.#index;
6714
+ if (known === void 0) throw new ContractError("ContractCompiler: the prepared index is unavailable", {
6715
+ code: "structure",
6716
+ context: {
6717
+ path: [],
6718
+ shape: "contract"
6719
+ }
6720
+ });
6713
6721
  this.#stack[this.#stack.length] = {
6714
6722
  operation: "enter",
6715
6723
  shape: root
@@ -6724,10 +6732,10 @@ var ContractCompiler = class ContractCompiler {
6724
6732
  continue;
6725
6733
  }
6726
6734
  const shape = frame.shape;
6727
- if (INTRINSICS.apply(INTRINSICS.recall, this.#index, [shape]) !== void 0) continue;
6735
+ if (INTRINSICS.apply(INTRINSICS.recall, known, [shape]) !== void 0) continue;
6728
6736
  const index = this.#nodes.length;
6729
6737
  this.#nodes[index] = shape;
6730
- INTRINSICS.apply(INTRINSICS.retain, this.#index, [shape, index]);
6738
+ INTRINSICS.apply(INTRINSICS.retain, known, [shape, index]);
6731
6739
  this.#stack[this.#stack.length] = {
6732
6740
  operation: "exit",
6733
6741
  index
@@ -6783,7 +6791,15 @@ var ContractCompiler = class ContractCompiler {
6783
6791
  }
6784
6792
  }
6785
6793
  #locate(shape) {
6786
- const index = INTRINSICS.apply(INTRINSICS.recall, this.#index, [shape]);
6794
+ const known = this.#index;
6795
+ if (known === void 0) throw new ContractError("ContractCompiler: the prepared index is unavailable", {
6796
+ code: "structure",
6797
+ context: {
6798
+ path: [],
6799
+ shape: "contract"
6800
+ }
6801
+ });
6802
+ const index = INTRINSICS.apply(INTRINSICS.recall, known, [shape]);
6787
6803
  if (index === void 0) throw new ContractError("ContractCompiler: a structural child is not in the prepared index", {
6788
6804
  code: "structure",
6789
6805
  context: {
@@ -6815,7 +6831,7 @@ var ContractCompiler = class ContractCompiler {
6815
6831
  }
6816
6832
  #trackGuard(plan) {
6817
6833
  let filled = 0;
6818
- let memo = new ContractCompiler.#weakMap();
6834
+ let memo;
6819
6835
  return (value) => {
6820
6836
  if (!isObject(value)) return plan(value);
6821
6837
  const opened = ContractCompiler.#scope === 0;
@@ -6825,7 +6841,7 @@ var ContractCompiler = class ContractCompiler {
6825
6841
  }
6826
6842
  try {
6827
6843
  const scope = ContractCompiler.#scope;
6828
- if (filled !== scope) {
6844
+ if (memo === void 0 || filled !== scope) {
6829
6845
  memo = new ContractCompiler.#weakMap();
6830
6846
  filled = scope;
6831
6847
  }
@@ -6841,7 +6857,7 @@ var ContractCompiler = class ContractCompiler {
6841
6857
  }
6842
6858
  #trackFaults(plan) {
6843
6859
  let filled = 0;
6844
- let memo = new ContractCompiler.#weakMap();
6860
+ let memo;
6845
6861
  return (value, path) => {
6846
6862
  if (!isObject(value)) return plan(value, path);
6847
6863
  const opened = ContractCompiler.#scope === 0;
@@ -6851,7 +6867,7 @@ var ContractCompiler = class ContractCompiler {
6851
6867
  }
6852
6868
  try {
6853
6869
  const scope = ContractCompiler.#scope;
6854
- if (filled !== scope) {
6870
+ if (memo === void 0 || filled !== scope) {
6855
6871
  memo = new ContractCompiler.#weakMap();
6856
6872
  filled = scope;
6857
6873
  }