ata-validator 1.44.0 → 1.46.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/README.md +10 -10
- package/bin/ata.js +16 -0
- package/index.js +73 -12
- package/lib/branch-collapse.js +1 -1
- package/lib/combined-runtime.js +149 -0
- package/lib/formats.js +8 -2
- package/lib/interpreter.js +45 -52
- package/lib/js-compiler.js +1124 -91
- package/lib/migrate.js +253 -0
- package/lib/plan-compiler.js +23 -25
- package/lib/regex-linear.js +35 -26
- package/lib/unique-items.js +139 -0
- package/lib/validator-core.js +26 -4
- package/lib/version.js +1 -1
- package/package.json +9 -9
package/lib/validator-core.js
CHANGED
|
@@ -755,6 +755,17 @@ class Validator {
|
|
|
755
755
|
// richErrors: default true. Only the literal `false` opts back into the
|
|
756
756
|
// v0.14 error shape (no code/expected/received/docUrl, no aliases).
|
|
757
757
|
this._richErrors = options && options.richErrors === false ? false : true;
|
|
758
|
+
// Declared here, set later (the one-pass switch): a property added to an
|
|
759
|
+
// instance after construction moves every instance that gets it to a
|
|
760
|
+
// new hidden class, which cost the suite benchmark nine percent.
|
|
761
|
+
this._onePass = undefined;
|
|
762
|
+
this._tierOnePass = undefined;
|
|
763
|
+
this._skipNativeFast = false;
|
|
764
|
+
this._scanner = undefined;
|
|
765
|
+
this._lastParsed = undefined;
|
|
766
|
+
this._twin = undefined;
|
|
767
|
+
this._coldCalls = undefined;
|
|
768
|
+
this._posCache = undefined;
|
|
758
769
|
|
|
759
770
|
// Optional schema source descriptor. When supplied, the renderer pipeline
|
|
760
771
|
// can attach a `schemaSource` frame to enriched errors.
|
|
@@ -1362,9 +1373,13 @@ class Validator {
|
|
|
1362
1373
|
let _errorsNow = _buildErrors;
|
|
1363
1374
|
let _onePass = null;
|
|
1364
1375
|
let _richLater = (_plain !== null && _oneShotRich !== null && _richBuilder !== null && !_extra) ? 1 : 0;
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1376
|
+
// The switch the third read makes, also reachable from validateJSON
|
|
1377
|
+
// (index.js) for a validator whose rejections only ever arrive as
|
|
1378
|
+
// text: those reads never pass through `_errorsOf`.
|
|
1379
|
+
const _switchOnePass = () => {
|
|
1380
|
+
if (_richLater === 0) return _onePass;
|
|
1381
|
+
_richLater = 0;
|
|
1382
|
+
{
|
|
1368
1383
|
const combRich = _oneShotRich();
|
|
1369
1384
|
if (combRich) {
|
|
1370
1385
|
const clean = !this._richErrors && _isCleanShape !== null && _isCleanShape(combRich);
|
|
@@ -1384,9 +1399,16 @@ class Validator {
|
|
|
1384
1399
|
// the verdict, so one pass measured no faster on rejections and
|
|
1385
1400
|
// slower on acceptances.
|
|
1386
1401
|
const onePass = !this._richErrors && _onePassOf !== null && _isCombined !== null && _isCombined(combRich) ? _onePassOf(EMPTY_ERRORS, _plainValidate) : null;
|
|
1387
|
-
|
|
1402
|
+
// Also where validateJSON can reach it (index.js): a rejected
|
|
1403
|
+
// text is parsed and handed to this function directly.
|
|
1404
|
+
if (onePass) { _onePass = onePass; self.validate = onePass; self._onePass = onePass; }
|
|
1388
1405
|
}
|
|
1389
1406
|
}
|
|
1407
|
+
return _onePass;
|
|
1408
|
+
};
|
|
1409
|
+
if (_richLater !== 0) this._tierOnePass = _switchOnePass;
|
|
1410
|
+
const _errorsOf = (data) => {
|
|
1411
|
+
if (_richLater !== 0 && ++_richLater > 2) _switchOnePass();
|
|
1390
1412
|
return _errorsNow(data);
|
|
1391
1413
|
};
|
|
1392
1414
|
_errorsOf.final = false;
|
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ata-validator",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.46.0",
|
|
4
4
|
"description": "JSON Schema validator that compiles to plain JavaScript, still runs where code generation is blocked, and can be compiled away at build time. Passes the full official test suite.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"release:check": "node tests/test_pack_purity.js && node scripts/check-doc-coverage.js && node tests/test_error_codes_lock.js && node tests/test_safe_regex_embed.js && node tests/test_version_sync.js",
|
|
65
65
|
"build": "cmake-js build --target ata",
|
|
66
66
|
"rebuild": "cmake-js rebuild --target ata",
|
|
67
|
-
"test": "node
|
|
67
|
+
"test": "node tests/run.js",
|
|
68
68
|
"bench:size": "node benchmark/bench_aot_size.mjs",
|
|
69
69
|
"test:suite": "node tests/run_suite.js && node tests/run_suite.js draft7 && node tests/run_suite.js v1",
|
|
70
70
|
"test:compat": "node tests/test_compat.js",
|
|
@@ -143,13 +143,13 @@
|
|
|
143
143
|
"LICENSE"
|
|
144
144
|
],
|
|
145
145
|
"optionalDependencies": {
|
|
146
|
-
"@ata-validator/native-darwin-arm64": "1.
|
|
147
|
-
"@ata-validator/native-darwin-x64": "1.
|
|
148
|
-
"@ata-validator/native-linux-arm64-gnu": "1.
|
|
149
|
-
"@ata-validator/native-linux-arm64-musl": "1.
|
|
150
|
-
"@ata-validator/native-linux-x64-gnu": "1.
|
|
151
|
-
"@ata-validator/native-linux-x64-musl": "1.
|
|
152
|
-
"@ata-validator/native-win32-x64": "1.
|
|
146
|
+
"@ata-validator/native-darwin-arm64": "1.46.0",
|
|
147
|
+
"@ata-validator/native-darwin-x64": "1.46.0",
|
|
148
|
+
"@ata-validator/native-linux-arm64-gnu": "1.46.0",
|
|
149
|
+
"@ata-validator/native-linux-arm64-musl": "1.46.0",
|
|
150
|
+
"@ata-validator/native-linux-x64-gnu": "1.46.0",
|
|
151
|
+
"@ata-validator/native-linux-x64-musl": "1.46.0",
|
|
152
|
+
"@ata-validator/native-win32-x64": "1.46.0"
|
|
153
153
|
},
|
|
154
154
|
"peerDependencies": {
|
|
155
155
|
"yaml": "^2.0.0"
|