ata-validator 1.46.1 → 1.47.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 +14 -14
- package/bin/ata.js +9 -2
- package/build.d.ts +15 -2
- package/index.js +3 -2
- package/lib/aot-build.js +3 -1
- package/lib/aot-impl.js +178 -8
- package/lib/combined-runtime.js +1 -1
- package/lib/compile-fn.js +16 -0
- package/lib/env.js +13 -0
- package/lib/interpreter.js +3 -1
- package/lib/js-compiler-errors.js +3483 -0
- package/lib/js-compiler.js +362 -3704
- package/lib/native-load.js +10 -1
- package/lib/scan-compiler.js +2 -1
- package/lib/validator-core.js +5 -3
- package/lib/version.js +1 -1
- package/package.json +8 -8
package/lib/native-load.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const { env } = require('./env');
|
|
2
3
|
|
|
3
4
|
// Locate the optional native engine. Resolution order:
|
|
4
5
|
// 1. ATA_NO_NATIVE set -> null (explicit pure-JS mode)
|
|
@@ -36,6 +37,12 @@ function detectMusl() {
|
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
39
|
|
|
40
|
+
// The require of the platform package is of a computed name on purpose. A
|
|
41
|
+
// literal require of each of the seven packages was tried: at most one of
|
|
42
|
+
// them is installed on any machine, and a bundler that bundles the Node
|
|
43
|
+
// entry (esbuild, bun, webpack) fails to resolve the other six and stops.
|
|
44
|
+
// A supply-chain scanner reports a computed require as dynamic loading;
|
|
45
|
+
// this is what it loads, and nothing else is ever required by name here.
|
|
39
46
|
let warned = false;
|
|
40
47
|
function checkVersion(binding, source) {
|
|
41
48
|
if (!binding) return null;
|
|
@@ -58,7 +65,7 @@ function checkVersion(binding, source) {
|
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
module.exports = function loadNative() {
|
|
61
|
-
if (
|
|
68
|
+
if (env('ATA_NO_NATIVE')) return null;
|
|
62
69
|
|
|
63
70
|
const isMusl = process.platform === 'linux' ? detectMusl() : false;
|
|
64
71
|
const candidates = [];
|
|
@@ -80,6 +87,8 @@ module.exports = function loadNative() {
|
|
|
80
87
|
|
|
81
88
|
// Contributors running from a source checkout.
|
|
82
89
|
try {
|
|
90
|
+
// Not a literal path for the same reason: the file is absent from the
|
|
91
|
+
// published package and a bundler must not try to resolve it.
|
|
83
92
|
const path = require('path');
|
|
84
93
|
const binding = checkVersion(
|
|
85
94
|
require(path.join(__dirname, '..', 'build', 'Release', 'ata.node')),
|
package/lib/scan-compiler.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
const { compileFunction } = require('./compile-fn');
|
|
2
3
|
|
|
3
4
|
// A schema-directed scanner: it answers the verdict from the JSON text without
|
|
4
5
|
// building the document. `JSON.parse` is three quarters of the cost of a real
|
|
@@ -436,7 +437,7 @@ function finish(built, opts) {
|
|
|
436
437
|
let fn;
|
|
437
438
|
try {
|
|
438
439
|
// eslint-disable-next-line no-new-func
|
|
439
|
-
fn =
|
|
440
|
+
fn = compileFunction('_h', '_r', ctx.subSource.join('\n') + '\nreturn function scan(s){\n' + body + '\n}')(ctx.helpers, require('./scan-runtime'));
|
|
440
441
|
} catch {
|
|
441
442
|
return null; // a runtime without code generation has no scanner, by design
|
|
442
443
|
}
|
package/lib/validator-core.js
CHANGED
|
@@ -10,6 +10,8 @@ function getNative() {
|
|
|
10
10
|
if (_nativeMod === undefined) _nativeMod = require("./native-load")();
|
|
11
11
|
return _nativeMod;
|
|
12
12
|
}
|
|
13
|
+
const { env } = require('./env');
|
|
14
|
+
const { compileFunction } = require('./compile-fn');
|
|
13
15
|
const { normalizeKeywords, schemaUsesKeywords } = require('./keywords');
|
|
14
16
|
// The code generator (lib/js-compiler and what builds on it: the scanner, the
|
|
15
17
|
// parse() copy, the ahead-of-time emitters) is registered by the entry that
|
|
@@ -207,7 +209,7 @@ function codegenAvailable() {
|
|
|
207
209
|
if (_codegen === null) return false;
|
|
208
210
|
if (_codegenAvailable === null) {
|
|
209
211
|
try {
|
|
210
|
-
_codegenAvailable =
|
|
212
|
+
_codegenAvailable = compileFunction('return 1')() === 1;
|
|
211
213
|
} catch {
|
|
212
214
|
_codegenAvailable = false;
|
|
213
215
|
}
|
|
@@ -880,7 +882,7 @@ class Validator {
|
|
|
880
882
|
// Check cache first -- reuse compiled functions for same schema
|
|
881
883
|
const sm = this._schemaMap.size > 0 ? this._schemaMap : null;
|
|
882
884
|
const mapKey = compileCacheKey(this._schemaStr, this._schemaMap);
|
|
883
|
-
var _forceNapi = this._interpretOnly || (
|
|
885
|
+
var _forceNapi = this._interpretOnly || env('ATA_FORCE_NAPI');
|
|
884
886
|
// Custom formats are JS functions: bypass the compile cache since they can
|
|
885
887
|
// differ between validators that share the same schema string. An
|
|
886
888
|
// interpreter-only validator never touches it either way: a function a
|
|
@@ -1584,7 +1586,7 @@ class Validator {
|
|
|
1584
1586
|
return;
|
|
1585
1587
|
}
|
|
1586
1588
|
this._ensureVocabularies();
|
|
1587
|
-
if (this._interpretOnly || _codegen === null || (
|
|
1589
|
+
if (this._interpretOnly || _codegen === null || env('ATA_FORCE_NAPI')) return;
|
|
1588
1590
|
_codegen.compileVerdict.call(this);
|
|
1589
1591
|
}
|
|
1590
1592
|
|
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.47.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",
|
|
@@ -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.47.0",
|
|
147
|
+
"@ata-validator/native-darwin-x64": "1.47.0",
|
|
148
|
+
"@ata-validator/native-linux-arm64-gnu": "1.47.0",
|
|
149
|
+
"@ata-validator/native-linux-arm64-musl": "1.47.0",
|
|
150
|
+
"@ata-validator/native-linux-x64-gnu": "1.47.0",
|
|
151
|
+
"@ata-validator/native-linux-x64-musl": "1.47.0",
|
|
152
|
+
"@ata-validator/native-win32-x64": "1.47.0"
|
|
153
153
|
},
|
|
154
154
|
"peerDependencies": {
|
|
155
155
|
"yaml": "^2.0.0"
|