ata-validator 0.17.0 → 0.17.1

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 (3) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/index.js +13 -2
  3. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to ata-validator are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/), and this project adheres to semantic versioning.
4
4
 
5
+ ## 0.17.1 - 2026-05-24
6
+
7
+ ### Fixed
8
+
9
+ - Standalone output for schemas with `anyOf` or `oneOf` no longer references undefined branch helpers. `toStandaloneModule` and `bundleCompact` now emit the hoisted branch functions, so the generated module runs instead of throwing on the first validation. `bundleStandalone` already emitted them.
10
+
5
11
  ## 0.17.0 - 2026-05-23
6
12
 
7
13
  ### Added
package/index.js CHANGED
@@ -1223,6 +1223,11 @@ module.exports = { boolFn, hybridFactory, errFn };
1223
1223
  if (lines.length) closureDecls = lines.join('\n') + '\n';
1224
1224
  }
1225
1225
 
1226
+ // Hoisted oneOf/anyOf branch checks live in the boolean fn's preamble (the
1227
+ // runtime emits them before the function). The standalone module must declare
1228
+ // them at module scope too, or _fn references undefined names (e.g. _af1_b0).
1229
+ const preambleDecls = jsFn._preambleSource ? jsFn._preambleSource + '\n' : '';
1230
+
1226
1231
  const validBody = errCore
1227
1232
  ? 'return _fn(data) ? VALID : { valid: false, errors: errFn(data, true).errors }'
1228
1233
  : 'return _fn(data) ? VALID : ABORT';
@@ -1245,7 +1250,7 @@ const ABORT = Object.freeze({
1245
1250
  path: '',
1246
1251
  })]),
1247
1252
  });
1248
- ${closureDecls}const _fn = function(d) {
1253
+ ${closureDecls}${preambleDecls}const _fn = function(d) {
1249
1254
  ${src}
1250
1255
  };
1251
1256
  ${errCore}function isValid(data) { return _fn(data); }
@@ -1520,8 +1525,14 @@ Validator.bundleCompact = function (schemas, opts) {
1520
1525
  typeof schema === "string" ? JSON.parse(schema) : schema,
1521
1526
  v._schemaMap,
1522
1527
  );
1528
+ // Hoisted anyOf/oneOf branch helpers (e.g. `_af1_b0`) must travel with the
1529
+ // hybrid body or it references undefined names. Prepending keeps dedup honest:
1530
+ // schemas with different branch sets no longer collide on body alone.
1531
+ const hybrid = jsFn._preambleSource
1532
+ ? `${jsFn._preambleSource}\n${jsFn._hybridSource}`
1533
+ : jsFn._hybridSource;
1523
1534
  return {
1524
- hybrid: jsFn._hybridSource,
1535
+ hybrid,
1525
1536
  err: jsErrFn && jsErrFn._errSource ? jsErrFn._errSource : null,
1526
1537
  };
1527
1538
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ata-validator",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "JSON Schema validation with first-class TypeScript and zero runtime cost. AOT compile to per-schema ESM modules with zero validator dependency. Generic Validator<T> for TypeBox/Zod/Valibot composition. Optional runtime API. Standard Schema V1 compatible.",
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",
@@ -42,7 +42,7 @@
42
42
  "rebuild": "cmake-js rebuild --target ata",
43
43
  "prebuild": "pkg-prebuilds-copy --baseDir build/Release --source ata.node --name=ata --strip --napi_version=10",
44
44
  "prebuild-all": "npm run prebuild -- --arch x64 && npm run prebuild -- --arch arm64",
45
- "test": "node test.js && node tests/test_no_native.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_enrich_error.js && node tests/test_rich_errors_optout.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_data_positions.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node benchmark/bench_aot_size.mjs",
45
+ "test": "node test.js && node tests/test_no_native.js && node tests/test_aot_build.js && node tests/test_aot_differential.js && node tests/test_aot_cli_build.js && node tests/test_aot_cli_smoke.js && node tests/test_bundle_standalone.js && node tests/test_standalone_anyof.js && node tests/test_typed_validator_runner.js && node tests/test_define_schema.js && node tests/test_error_codes_lock.js && node tests/test_nullable.js && node tests/test_validate_and_parse.js && node tests/test_enrich_error.js && node tests/test_rich_errors_optout.js && node tests/test_source_positions.js && node tests/fuzz_positions.js && node tests/test_data_positions.js && node tests/test_render_shared.js && node tests/test_renderers.js && node tests/test_runtime_error_dx.js && node tests/test_aot_error_dx.js && node tests/test_abort_early.js && node tests/test_branch_collapse.js && node tests/test_suggestions.js && node tests/test_cli_validate.js && node benchmark/bench_aot_size.mjs",
46
46
  "bench:size": "node benchmark/bench_aot_size.mjs",
47
47
  "test:suite": "node tests/run_suite.js",
48
48
  "test:compat": "node tests/test_compat.js",