@sourcemeta/blaze 16.0.0 → 16.2.0

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/describe.mjs CHANGED
@@ -471,6 +471,12 @@ export function describe(valid, instruction, evaluatePath,
471
471
  if (keyword === '$ref') {
472
472
  return describeReference(target);
473
473
  }
474
+ // For the wrapper instruction we emit when hoisting `then` subschemas
475
+ // whose `if` condition compiles to nothing
476
+ if (keyword === 'then') {
477
+ return 'The ' + typeName(targetType) +
478
+ ' value was expected to validate against the given conditional';
479
+ }
474
480
  return '<unknown>';
475
481
  }
476
482
 
package/index.mjs CHANGED
@@ -697,6 +697,22 @@ function evaluateInstructionFastCallback(instruction, instance, depth, template,
697
697
  return handler(instruction, instance, depth, template, evaluator);
698
698
  }
699
699
 
700
+ // Evaluate an entire subtree without emitting callbacks, while still
701
+ // maintaining the schema resources stack for dynamic anchor resolution,
702
+ // mirroring `evaluate_instruction_without_callback` from the C++ evaluator
703
+ function evaluateInstructionWithoutCallback(instruction, instance, depth, template, evaluator) {
704
+ const previousDispatch = evaluateInstruction;
705
+ const previousCallbackMode = evaluator.callbackMode;
706
+ evaluateInstruction = (evaluator.trackMode || evaluator.dynamicMode)
707
+ ? evaluateInstructionTracked
708
+ : evaluateInstructionFast;
709
+ evaluator.callbackMode = false;
710
+ const result = evaluateInstruction(instruction, instance, depth, template, evaluator);
711
+ evaluateInstruction = previousDispatch;
712
+ evaluator.callbackMode = previousCallbackMode;
713
+ return result;
714
+ }
715
+
700
716
  function evaluateInstructionTrackedCallback(instruction, instance, depth, template, evaluator) {
701
717
  if (depth > DEPTH_LIMIT) {
702
718
  throw new Error('The evaluation path depth limit was reached likely due to infinite recursion');
@@ -1551,7 +1567,7 @@ function AssertionObjectPropertiesSimple(instruction, instance, depth, template,
1551
1567
  continue;
1552
1568
  }
1553
1569
  if (index < children.length) {
1554
- if (!evaluateInstructionFast(children[index], target[name], depth + 1, template, evaluator)) {
1570
+ if (!evaluateInstructionWithoutCallback(children[index], target[name], depth + 1, template, evaluator)) {
1555
1571
  if (evaluator.callbackMode) evaluator.callbackPop(instruction, false);
1556
1572
  return false;
1557
1573
  }
@@ -3455,7 +3471,10 @@ function AssertionObjectPropertiesSimple_fast(instruction, instance, depth, temp
3455
3471
  continue;
3456
3472
  }
3457
3473
  if (index < children.length) {
3458
- if (!evaluateInstructionFast(children[index], target[name], depth + 1, template, evaluator)) return false;
3474
+ // Note that we don't hardcode the fast dispatcher here, as the fused
3475
+ // children may require schema resource tracking for dynamic anchor
3476
+ // resolution, which the current dispatcher takes care of
3477
+ if (!evaluateInstruction(children[index], target[name], depth + 1, template, evaluator)) return false;
3459
3478
  }
3460
3479
  }
3461
3480
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sourcemeta/blaze",
3
- "version": "16.0.0",
3
+ "version": "16.2.0",
4
4
  "description": "A pure JavaScript port of the evaluator from Blaze, a high-performance C++ JSON Schema validator. Zero dependencies. Supports Draft 4, Draft 6, Draft 7, 2019-09, and 2020-12 with schema-specific code generation for near-native speed",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",