1
0
mirror of https://github.com/S2-/minifyfromhtml.git synced 2025-08-02 12:00:03 +02:00

update modules

This commit is contained in:
s2
2020-07-20 16:16:07 +02:00
parent 783511ce12
commit 2b23424b86
785 changed files with 91905 additions and 56057 deletions

View File

@@ -1 +1 @@
#mywidget{border:2px solid red} #mywidget{border:2px solid red}#mywidget{color:#00f}

File diff suppressed because one or more lines are too long

1
example/dist/dist.js.map vendored Normal file

File diff suppressed because one or more lines are too long

16
node_modules/.bin/acorn generated vendored
View File

@@ -1 +1,15 @@
../acorn/bin/acorn #!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../acorn/bin/acorn" "$@"
ret=$?
else
node "$basedir/../acorn/bin/acorn" "$@"
ret=$?
fi
exit $ret

12
node_modules/abab/package.json generated vendored
View File

@@ -1,5 +1,5 @@
{ {
"_from": "abab@^2.0.0", "_from": "abab@^2.0.3",
"_id": "abab@2.0.3", "_id": "abab@2.0.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==", "_integrity": "sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==",
@@ -8,12 +8,12 @@
"_requested": { "_requested": {
"type": "range", "type": "range",
"registry": true, "registry": true,
"raw": "abab@^2.0.0", "raw": "abab@^2.0.3",
"name": "abab", "name": "abab",
"escapedName": "abab", "escapedName": "abab",
"rawSpec": "^2.0.0", "rawSpec": "^2.0.3",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^2.0.0" "fetchSpec": "^2.0.3"
}, },
"_requiredBy": [ "_requiredBy": [
"/data-urls", "/data-urls",
@@ -21,8 +21,8 @@
], ],
"_resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz", "_resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz",
"_shasum": "623e2075e02eb2d3f2475e49f99c91846467907a", "_shasum": "623e2075e02eb2d3f2475e49f99c91846467907a",
"_spec": "abab@^2.0.0", "_spec": "abab@^2.0.3",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\jsdom", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\jsdom",
"author": { "author": {
"name": "Jeff Carpenter", "name": "Jeff Carpenter",
"email": "gcarpenterv@gmail.com" "email": "gcarpenterv@gmail.com"

View File

@@ -1,27 +1,27 @@
{ {
"_from": "acorn-globals@^4.3.0", "_from": "acorn-globals@^6.0.0",
"_id": "acorn-globals@4.3.4", "_id": "acorn-globals@6.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A==", "_integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==",
"_location": "/acorn-globals", "_location": "/acorn-globals",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "range",
"registry": true, "registry": true,
"raw": "acorn-globals@^4.3.0", "raw": "acorn-globals@^6.0.0",
"name": "acorn-globals", "name": "acorn-globals",
"escapedName": "acorn-globals", "escapedName": "acorn-globals",
"rawSpec": "^4.3.0", "rawSpec": "^6.0.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^4.3.0" "fetchSpec": "^6.0.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/jsdom" "/jsdom"
], ],
"_resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.4.tgz", "_resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz",
"_shasum": "9fa1926addc11c97308c4e66d7add0d40c3272e7", "_shasum": "46cdd39f0f8ff08a876619b55f5ac8a6dc770b45",
"_spec": "acorn-globals@^4.3.0", "_spec": "acorn-globals@^6.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\jsdom", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\jsdom",
"author": { "author": {
"name": "ForbesLindesay" "name": "ForbesLindesay"
}, },
@@ -30,13 +30,13 @@
}, },
"bundleDependencies": false, "bundleDependencies": false,
"dependencies": { "dependencies": {
"acorn": "^6.0.1", "acorn": "^7.1.1",
"acorn-walk": "^6.0.1" "acorn-walk": "^7.1.1"
}, },
"deprecated": false, "deprecated": false,
"description": "Detect global variables in JavaScript using acorn", "description": "Detect global variables in JavaScript using acorn",
"devDependencies": { "devDependencies": {
"testit": "^3.0.0" "testit": "^3.1.0"
}, },
"files": [ "files": [
"index.js", "index.js",
@@ -62,5 +62,5 @@
"scripts": { "scripts": {
"test": "node test" "test": "node test"
}, },
"version": "4.3.4" "version": "6.0.0"
} }

28
node_modules/acorn-walk/CHANGELOG.md generated vendored
View File

@@ -1,3 +1,31 @@
## 7.2.0 (2020-06-17)
### New features
Support optional chaining and nullish coalescing.
Support `import.meta`.
Add support for `export * as ns from "source"`.
## 7.1.1 (2020-02-13)
### Bug fixes
Clean up the type definitions to actually work well with the main parser.
## 7.1.0 (2020-02-11)
### New features
Add a TypeScript definition file for the library.
## 7.0.0 (2017-08-12)
### New features
Support walking `ImportExpression` nodes.
## 6.2.0 (2017-07-04) ## 6.2.0 (2017-07-04)
### New features ### New features

112
node_modules/acorn-walk/dist/walk.d.ts generated vendored Normal file
View File

@@ -0,0 +1,112 @@
import {Node} from 'acorn';
declare module "acorn-walk" {
type FullWalkerCallback<TState> = (
node: Node,
state: TState,
type: string
) => void;
type FullAncestorWalkerCallback<TState> = (
node: Node,
state: TState | Node[],
ancestors: Node[],
type: string
) => void;
type WalkerCallback<TState> = (node: Node, state: TState) => void;
type SimpleWalkerFn<TState> = (
node: Node,
state: TState
) => void;
type AncestorWalkerFn<TState> = (
node: Node,
state: TState| Node[],
ancestors: Node[]
) => void;
type RecursiveWalkerFn<TState> = (
node: Node,
state: TState,
callback: WalkerCallback<TState>
) => void;
type SimpleVisitors<TState> = {
[type: string]: SimpleWalkerFn<TState>
};
type AncestorVisitors<TState> = {
[type: string]: AncestorWalkerFn<TState>
};
type RecursiveVisitors<TState> = {
[type: string]: RecursiveWalkerFn<TState>
};
type FindPredicate = (type: string, node: Node) => boolean;
interface Found<TState> {
node: Node,
state: TState
}
export function simple<TState>(
node: Node,
visitors: SimpleVisitors<TState>,
base?: RecursiveVisitors<TState>,
state?: TState
): void;
export function ancestor<TState>(
node: Node,
visitors: AncestorVisitors<TState>,
base?: RecursiveVisitors<TState>,
state?: TState
): void;
export function recursive<TState>(
node: Node,
state: TState,
functions: RecursiveVisitors<TState>,
base?: RecursiveVisitors<TState>
): void;
export function full<TState>(
node: Node,
callback: FullWalkerCallback<TState>,
base?: RecursiveVisitors<TState>,
state?: TState
): void;
export function fullAncestor<TState>(
node: Node,
callback: FullAncestorWalkerCallback<TState>,
base?: RecursiveVisitors<TState>,
state?: TState
): void;
export function make<TState>(
functions: RecursiveVisitors<TState>,
base?: RecursiveVisitors<TState>
): RecursiveVisitors<TState>;
export function findNodeAt<TState>(
node: Node,
start: number | undefined,
end?: number | undefined,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
): Found<TState> | undefined;
export function findNodeAround<TState>(
node: Node,
start: number | undefined,
type?: FindPredicate | string,
base?: RecursiveVisitors<TState>,
state?: TState
): Found<TState> | undefined;
export const findNodeAfter: typeof findNodeAround;
}

17
node_modules/acorn-walk/dist/walk.js generated vendored
View File

@@ -2,7 +2,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) : typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {}))); (global = global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {})));
}(this, function (exports) { 'use strict'; }(this, (function (exports) { 'use strict';
// AST walker module for Mozilla Parser API compatible trees // AST walker module for Mozilla Parser API compatible trees
@@ -34,7 +34,7 @@
// An ancestor walk keeps an array of ancestor nodes (including the // An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter // current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present). // (and also as state parameter when no other state is present).
function ancestor(node, visitors, baseVisitor, state) { function ancestor(node, visitors, baseVisitor, state, override) {
var ancestors = []; var ancestors = [];
if (!baseVisitor) { baseVisitor = base if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) { ; }(function c(node, st, override) {
@@ -44,7 +44,7 @@
baseVisitor[type](node, st, c); baseVisitor[type](node, st, c);
if (found) { found(node, st || ancestors, ancestors); } if (found) { found(node, st || ancestors, ancestors); }
if (isNew) { ancestors.pop(); } if (isNew) { ancestors.pop(); }
})(node, state); })(node, state, override);
} }
// A recursive walk is one where your functions override the default // A recursive walk is one where your functions override the default
@@ -200,7 +200,7 @@
}; };
base.Statement = skipThrough; base.Statement = skipThrough;
base.EmptyStatement = ignore; base.EmptyStatement = ignore;
base.ExpressionStatement = base.ParenthesizedExpression = base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); }; function (node, st, c) { return c(node.expression, st, "Expression"); };
base.IfStatement = function (node, st, c) { base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression"); c(node.test, st, "Expression");
@@ -405,6 +405,8 @@
if (node.source) { c(node.source, st, "Expression"); } if (node.source) { c(node.source, st, "Expression"); }
}; };
base.ExportAllDeclaration = function (node, st, c) { base.ExportAllDeclaration = function (node, st, c) {
if (node.exported)
{ c(node.exported, st); }
c(node.source, st, "Expression"); c(node.source, st, "Expression");
}; };
base.ImportDeclaration = function (node, st, c) { base.ImportDeclaration = function (node, st, c) {
@@ -416,7 +418,10 @@
} }
c(node.source, st, "Expression"); c(node.source, st, "Expression");
}; };
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = base.Import = ignore; base.ImportExpression = function (node, st, c) {
c(node.source, st, "Expression");
};
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore;
base.TaggedTemplateExpression = function (node, st, c) { base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression"); c(node.tag, st, "Expression");
@@ -455,4 +460,4 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
})); })));

View File

@@ -28,7 +28,7 @@ function simple(node, visitors, baseVisitor, state, override) {
// An ancestor walk keeps an array of ancestor nodes (including the // An ancestor walk keeps an array of ancestor nodes (including the
// current node) and passes them to the callback as third parameter // current node) and passes them to the callback as third parameter
// (and also as state parameter when no other state is present). // (and also as state parameter when no other state is present).
function ancestor(node, visitors, baseVisitor, state) { function ancestor(node, visitors, baseVisitor, state, override) {
var ancestors = []; var ancestors = [];
if (!baseVisitor) { baseVisitor = base if (!baseVisitor) { baseVisitor = base
; }(function c(node, st, override) { ; }(function c(node, st, override) {
@@ -38,7 +38,7 @@ function ancestor(node, visitors, baseVisitor, state) {
baseVisitor[type](node, st, c); baseVisitor[type](node, st, c);
if (found) { found(node, st || ancestors, ancestors); } if (found) { found(node, st || ancestors, ancestors); }
if (isNew) { ancestors.pop(); } if (isNew) { ancestors.pop(); }
})(node, state); })(node, state, override);
} }
// A recursive walk is one where your functions override the default // A recursive walk is one where your functions override the default
@@ -194,7 +194,7 @@ base.Program = base.BlockStatement = function (node, st, c) {
}; };
base.Statement = skipThrough; base.Statement = skipThrough;
base.EmptyStatement = ignore; base.EmptyStatement = ignore;
base.ExpressionStatement = base.ParenthesizedExpression = base.ExpressionStatement = base.ParenthesizedExpression = base.ChainExpression =
function (node, st, c) { return c(node.expression, st, "Expression"); }; function (node, st, c) { return c(node.expression, st, "Expression"); };
base.IfStatement = function (node, st, c) { base.IfStatement = function (node, st, c) {
c(node.test, st, "Expression"); c(node.test, st, "Expression");
@@ -399,6 +399,8 @@ base.ExportNamedDeclaration = base.ExportDefaultDeclaration = function (node, st
if (node.source) { c(node.source, st, "Expression"); } if (node.source) { c(node.source, st, "Expression"); }
}; };
base.ExportAllDeclaration = function (node, st, c) { base.ExportAllDeclaration = function (node, st, c) {
if (node.exported)
{ c(node.exported, st); }
c(node.source, st, "Expression"); c(node.source, st, "Expression");
}; };
base.ImportDeclaration = function (node, st, c) { base.ImportDeclaration = function (node, st, c) {
@@ -410,7 +412,10 @@ base.ImportDeclaration = function (node, st, c) {
} }
c(node.source, st, "Expression"); c(node.source, st, "Expression");
}; };
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = base.Import = ignore; base.ImportExpression = function (node, st, c) {
c(node.source, st, "Expression");
};
base.ImportSpecifier = base.ImportDefaultSpecifier = base.ImportNamespaceSpecifier = base.Identifier = base.Literal = ignore;
base.TaggedTemplateExpression = function (node, st, c) { base.TaggedTemplateExpression = function (node, st, c) {
c(node.tag, st, "Expression"); c(node.tag, st, "Expression");

23
node_modules/acorn-walk/package.json generated vendored
View File

@@ -1,27 +1,27 @@
{ {
"_from": "acorn-walk@^6.0.1", "_from": "acorn-walk@^7.1.1",
"_id": "acorn-walk@6.2.0", "_id": "acorn-walk@7.2.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==", "_integrity": "sha512-OPdCF6GsMIP+Az+aWfAAOEt2/+iVDKE7oy6lJ098aoe59oAmK76qV6Gw60SbZ8jHuG2wH058GF4pLFbYamYrVA==",
"_location": "/acorn-walk", "_location": "/acorn-walk",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "range",
"registry": true, "registry": true,
"raw": "acorn-walk@^6.0.1", "raw": "acorn-walk@^7.1.1",
"name": "acorn-walk", "name": "acorn-walk",
"escapedName": "acorn-walk", "escapedName": "acorn-walk",
"rawSpec": "^6.0.1", "rawSpec": "^7.1.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^6.0.1" "fetchSpec": "^7.1.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/acorn-globals" "/acorn-globals"
], ],
"_resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", "_resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.2.0.tgz",
"_shasum": "123cb8f3b84c2171f1f7fb252615b1c78a6b1a8c", "_shasum": "0de889a601203909b0fbe07b8938dc21d2e967bc",
"_spec": "acorn-walk@^6.0.1", "_spec": "acorn-walk@^7.1.1",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\acorn-globals", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\acorn-globals",
"bugs": { "bugs": {
"url": "https://github.com/acornjs/acorn/issues" "url": "https://github.com/acornjs/acorn/issues"
}, },
@@ -59,5 +59,6 @@
"scripts": { "scripts": {
"prepare": "cd ..; npm run build:walk" "prepare": "cd ..; npm run build:walk"
}, },
"version": "6.2.0" "types": "dist/walk.d.ts",
"version": "7.2.0"
} }

68
node_modules/acorn/CHANGELOG.md generated vendored
View File

@@ -1,9 +1,71 @@
## 6.4.0 (2019-11-26) ## 7.3.1 (2020-06-11)
### Bug fixes
Make the string in the `version` export match the actual library version.
## 7.3.0 (2020-06-11)
### Bug fixes
Fix a bug that caused parsing of object patterns with a property named `set` that had a default value to fail.
### New features
Add support for optional chaining (`?.`).
## 7.2.0 (2020-05-09)
### Bug fixes
Fix precedence issue in parsing of async arrow functions.
### New features
Add support for nullish coalescing.
Add support for `import.meta`.
Support `export * as ...` syntax.
Upgrade to Unicode 13.
## 6.4.1 (2020-03-09)
### Bug fixes
More carefully check for valid UTF16 surrogate pairs in regexp validator.
## 7.1.1 (2020-03-01)
### Bug fixes
Treat `\8` and `\9` as invalid escapes in template strings.
Allow unicode escapes in property names that are keywords.
Don't error on an exponential operator expression as argument to `await`.
More carefully check for valid UTF16 surrogate pairs in regexp validator.
## 7.1.0 (2019-09-24)
### Bug fixes
Disallow trailing object literal commas when ecmaVersion is less than 5.
### New features ### New features
Add a static `acorn` property to the `Parser` class that contains the entire module interface, to allow plugins to access the instance of the library that they are acting on. Add a static `acorn` property to the `Parser` class that contains the entire module interface, to allow plugins to access the instance of the library that they are acting on.
## 7.0.0 (2019-08-13)
### Breaking changes
Changes the node format for dynamic imports to use the `ImportExpression` node type, as defined in [ESTree](https://github.com/estree/estree/blob/master/es2020.md#importexpression).
Makes 10 (ES2019) the default value for the `ecmaVersion` option.
## 6.3.0 (2019-08-12) ## 6.3.0 (2019-08-12)
### New features ### New features
@@ -28,9 +90,9 @@ Disallow binding `let` in patterns.
### New features ### New features
Support bigint syntax with `ecmaVersion` >= 10. Support bigint syntax with `ecmaVersion` >= 11.
Support dynamic `import` syntax with `ecmaVersion` >= 10. Support dynamic `import` syntax with `ecmaVersion` >= 11.
Upgrade to Unicode version 12. Upgrade to Unicode version 12.

7
node_modules/acorn/README.md generated vendored
View File

@@ -52,9 +52,10 @@ Options can be provided by passing a second argument, which should be
an object containing any of these fields: an object containing any of these fields:
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be - **ecmaVersion**: Indicates the ECMAScript version to parse. Must be
either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), 10 (2019) or 11
support). This influences support for strict mode, the set of (2020, partial support). This influences support for strict mode,
reserved words, and support for new syntax features. Default is 9. the set of reserved words, and support for new syntax features.
Default is 10.
**NOTE**: Only 'stage 4' (finalized) ECMAScript features are being **NOTE**: Only 'stage 4' (finalized) ECMAScript features are being
implemented by Acorn. Other proposed new features can be implemented implemented by Acorn. Other proposed new features can be implemented

2
node_modules/acorn/dist/acorn.d.ts generated vendored
View File

@@ -12,7 +12,7 @@ declare namespace acorn {
} }
interface Options { interface Options {
ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 10 | 2015 | 2016 | 2017 | 2018 | 2019 ecmaVersion?: 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
sourceType?: 'script' | 'module' sourceType?: 'script' | 'module'
onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void onInsertedSemicolon?: (lastTokEnd: number, lastTokEndLoc?: Position) => void
onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void onTrailingComma?: (lastTokEnd: number, lastTokEndLoc?: Position) => void

360
node_modules/acorn/dist/acorn.js generated vendored
View File

@@ -2,7 +2,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) : typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = global || self, factory(global.acorn = {})); (global = global || self, factory(global.acorn = {}));
}(this, function (exports) { 'use strict'; }(this, (function (exports) { 'use strict';
// Reserved word lists for various dialects of the language // Reserved word lists for various dialects of the language
@@ -33,8 +33,8 @@
// are only applied when a character is found to actually have a // are only applied when a character is found to actually have a
// code point above 128. // code point above 128.
// Generated by `bin/generate-identifier-regex.js`. // Generated by `bin/generate-identifier-regex.js`.
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
@@ -48,10 +48,10 @@
// generated by bin/generate-identifier-regex.js // generated by bin/generate-identifier-regex.js
// eslint-disable-next-line comma-spacing // eslint-disable-next-line comma-spacing
var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,155,22,13,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];
// eslint-disable-next-line comma-spacing // eslint-disable-next-line comma-spacing
var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,232,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]; var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];
// This has a complexity linear to the value of the code. The // This has a complexity linear to the value of the code. The
// assumption is that looking up astral identifier characters is // assumption is that looking up astral identifier characters is
@@ -166,6 +166,7 @@
colon: new TokenType(":", beforeExpr), colon: new TokenType(":", beforeExpr),
dot: new TokenType("."), dot: new TokenType("."),
question: new TokenType("?", beforeExpr), question: new TokenType("?", beforeExpr),
questionDot: new TokenType("?."),
arrow: new TokenType("=>", beforeExpr), arrow: new TokenType("=>", beforeExpr),
template: new TokenType("template"), template: new TokenType("template"),
invalidTemplate: new TokenType("invalidTemplate"), invalidTemplate: new TokenType("invalidTemplate"),
@@ -204,6 +205,7 @@
star: binop("*", 10), star: binop("*", 10),
slash: binop("/", 10), slash: binop("/", 10),
starstar: new TokenType("**", {beforeExpr: true}), starstar: new TokenType("**", {beforeExpr: true}),
coalesce: binop("??", 1),
// Keyword token types. // Keyword token types.
_break: kw("break"), _break: kw("break"),
@@ -320,8 +322,8 @@
// either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10 // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
// (2019). This influences support for strict mode, the set of // (2019). This influences support for strict mode, the set of
// reserved words, and support for new syntax features. The default // reserved words, and support for new syntax features. The default
// is 9. // is 10.
ecmaVersion: 9, ecmaVersion: 10,
// `sourceType` indicates the mode the code should be parsed in. // `sourceType` indicates the mode the code should be parsed in.
// Can be either `"script"` or `"module"`. This influences global // Can be either `"script"` or `"module"`. This influences global
// strict mode and parsing of `import` and `export` declarations. // strict mode and parsing of `import` and `export` declarations.
@@ -600,7 +602,14 @@
start += skipWhiteSpace.exec(this.input)[0].length; start += skipWhiteSpace.exec(this.input)[0].length;
var match = literal.exec(this.input.slice(start)); var match = literal.exec(this.input.slice(start));
if (!match) { return false } if (!match) { return false }
if ((match[1] || match[2]) === "use strict") { return true } if ((match[1] || match[2]) === "use strict") {
skipWhiteSpace.lastIndex = start + match[0].length;
var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
var next = this.input.charAt(end);
return next === ";" || next === "}" ||
(lineBreak.test(spaceAfter[0]) &&
!(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
}
start += match[0].length; start += match[0].length;
// Skip semicolon, if any. // Skip semicolon, if any.
@@ -850,7 +859,7 @@
skipWhiteSpace.lastIndex = this.pos; skipWhiteSpace.lastIndex = this.pos;
var skip = skipWhiteSpace.exec(this.input); var skip = skipWhiteSpace.exec(this.input);
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
if (nextCh === 40) // '(' if (nextCh === 40 || nextCh === 46) // '(' or '.'
{ return this.parseExpressionStatement(node, this.parseExpression()) } { return this.parseExpressionStatement(node, this.parseExpression()) }
} }
@@ -1150,17 +1159,19 @@
// strict"` declarations when `allowStrict` is true (used for // strict"` declarations when `allowStrict` is true (used for
// function bodies). // function bodies).
pp$1.parseBlock = function(createNewLexicalScope, node) { pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
if ( node === void 0 ) node = this.startNode(); if ( node === void 0 ) node = this.startNode();
node.body = []; node.body = [];
this.expect(types.braceL); this.expect(types.braceL);
if (createNewLexicalScope) { this.enterScope(0); } if (createNewLexicalScope) { this.enterScope(0); }
while (!this.eat(types.braceR)) { while (this.type !== types.braceR) {
var stmt = this.parseStatement(null); var stmt = this.parseStatement(null);
node.body.push(stmt); node.body.push(stmt);
} }
if (exitStrict) { this.strict = false; }
this.next();
if (createNewLexicalScope) { this.exitScope(); } if (createNewLexicalScope) { this.exitScope(); }
return this.finishNode(node, "BlockStatement") return this.finishNode(node, "BlockStatement")
}; };
@@ -1311,7 +1322,7 @@
var hadConstructor = false; var hadConstructor = false;
classBody.body = []; classBody.body = [];
this.expect(types.braceL); this.expect(types.braceL);
while (!this.eat(types.braceR)) { while (this.type !== types.braceR) {
var element = this.parseClassElement(node.superClass !== null); var element = this.parseClassElement(node.superClass !== null);
if (element) { if (element) {
classBody.body.push(element); classBody.body.push(element);
@@ -1321,8 +1332,9 @@
} }
} }
} }
node.body = this.finishNode(classBody, "ClassBody");
this.strict = oldStrict; this.strict = oldStrict;
this.next();
node.body = this.finishNode(classBody, "ClassBody");
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
}; };
@@ -1410,6 +1422,14 @@
this.next(); this.next();
// export * from '...' // export * from '...'
if (this.eat(types.star)) { if (this.eat(types.star)) {
if (this.options.ecmaVersion >= 11) {
if (this.eatContextual("as")) {
node.exported = this.parseIdent(true);
this.checkExport(exports, node.exported.name, this.lastTokStart);
} else {
node.exported = null;
}
}
this.expectContextual("from"); this.expectContextual("from");
if (this.type !== types.string) { this.unexpected(); } if (this.type !== types.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
@@ -1686,6 +1706,10 @@
this.toAssignable(node.expression, isBinding, refDestructuringErrors); this.toAssignable(node.expression, isBinding, refDestructuringErrors);
break break
case "ChainExpression":
this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
break
case "MemberExpression": case "MemberExpression":
if (!isBinding) { break } if (!isBinding) { break }
@@ -1816,6 +1840,10 @@
if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
break break
case "ChainExpression":
this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
break
case "MemberExpression": case "MemberExpression":
if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); } if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); }
break break
@@ -1884,9 +1912,11 @@
if (this.options.ecmaVersion >= 6) { if (this.options.ecmaVersion >= 6) {
if (name === "__proto__" && kind === "init") { if (name === "__proto__" && kind === "init") {
if (propHash.proto) { if (propHash.proto) {
if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) { refDestructuringErrors.doubleProto = key.start; } if (refDestructuringErrors) {
if (refDestructuringErrors.doubleProto < 0)
{ refDestructuringErrors.doubleProto = key.start; }
// Backwards-compat kludge. Can be removed in version 6.0 // Backwards-compat kludge. Can be removed in version 6.0
else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
} }
propHash.proto = true; propHash.proto = true;
} }
@@ -1951,12 +1981,11 @@
else { this.exprAllowed = false; } else { this.exprAllowed = false; }
} }
var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1; var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
if (refDestructuringErrors) { if (refDestructuringErrors) {
oldParenAssign = refDestructuringErrors.parenthesizedAssign; oldParenAssign = refDestructuringErrors.parenthesizedAssign;
oldTrailingComma = refDestructuringErrors.trailingComma; oldTrailingComma = refDestructuringErrors.trailingComma;
oldShorthandAssign = refDestructuringErrors.shorthandAssign; refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1;
} else { } else {
refDestructuringErrors = new DestructuringErrors; refDestructuringErrors = new DestructuringErrors;
ownDestructuringErrors = true; ownDestructuringErrors = true;
@@ -1971,8 +2000,11 @@
var node = this.startNodeAt(startPos, startLoc); var node = this.startNodeAt(startPos, startLoc);
node.operator = this.value; node.operator = this.value;
node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left; node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
if (!ownDestructuringErrors) { DestructuringErrors.call(refDestructuringErrors); } if (!ownDestructuringErrors) {
refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
}
if (refDestructuringErrors.shorthandAssign >= node.left.start)
{ refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
this.checkLVal(left); this.checkLVal(left);
this.next(); this.next();
node.right = this.parseMaybeAssign(noIn); node.right = this.parseMaybeAssign(noIn);
@@ -1982,7 +2014,6 @@
} }
if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
if (oldShorthandAssign > -1) { refDestructuringErrors.shorthandAssign = oldShorthandAssign; }
return left return left
}; };
@@ -2023,11 +2054,20 @@
if (prec != null && (!noIn || this.type !== types._in)) { if (prec != null && (!noIn || this.type !== types._in)) {
if (prec > minPrec) { if (prec > minPrec) {
var logical = this.type === types.logicalOR || this.type === types.logicalAND; var logical = this.type === types.logicalOR || this.type === types.logicalAND;
var coalesce = this.type === types.coalesce;
if (coalesce) {
// Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
// In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
prec = types.logicalAND.binop;
}
var op = this.value; var op = this.value;
this.next(); this.next();
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc;
var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn); var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical); var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
}
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
} }
} }
@@ -2087,8 +2127,8 @@
pp$3.parseExprSubscripts = function(refDestructuringErrors) { pp$3.parseExprSubscripts = function(refDestructuringErrors) {
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc;
var expr = this.parseExprAtom(refDestructuringErrors); var expr = this.parseExprAtom(refDestructuringErrors);
var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"; if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) { return expr } { return expr }
var result = this.parseSubscripts(expr, startPos, startLoc); var result = this.parseSubscripts(expr, startPos, startLoc);
if (refDestructuringErrors && result.type === "MemberExpression") { if (refDestructuringErrors && result.type === "MemberExpression") {
if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
@@ -2099,30 +2139,50 @@
pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
this.potentialArrowAt === base.start;
var optionalChained = false;
while (true) { while (true) {
var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow); var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained);
if (element === base || element.type === "ArrowFunctionExpression") { return element }
if (element.optional) { optionalChained = true; }
if (element === base || element.type === "ArrowFunctionExpression") {
if (optionalChained) {
var chainNode = this.startNodeAt(startPos, startLoc);
chainNode.expression = element;
element = this.finishNode(chainNode, "ChainExpression");
}
return element
}
base = element; base = element;
} }
}; };
pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow) { pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained) {
var optionalSupported = this.options.ecmaVersion >= 11;
var optional = optionalSupported && this.eat(types.questionDot);
if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
var computed = this.eat(types.bracketL); var computed = this.eat(types.bracketL);
if (computed || this.eat(types.dot)) { if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
var node = this.startNodeAt(startPos, startLoc); var node = this.startNodeAt(startPos, startLoc);
node.object = base; node.object = base;
node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never"); node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
node.computed = !!computed; node.computed = !!computed;
if (computed) { this.expect(types.bracketR); } if (computed) { this.expect(types.bracketR); }
if (optionalSupported) {
node.optional = optional;
}
base = this.finishNode(node, "MemberExpression"); base = this.finishNode(node, "MemberExpression");
} else if (!noCalls && this.eat(types.parenL)) { } else if (!noCalls && this.eat(types.parenL)) {
var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
this.yieldPos = 0; this.yieldPos = 0;
this.awaitPos = 0; this.awaitPos = 0;
this.awaitIdentPos = 0; this.awaitIdentPos = 0;
var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && base.type !== "Import", false, refDestructuringErrors); var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) { if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
this.checkPatternErrors(refDestructuringErrors, false); this.checkPatternErrors(refDestructuringErrors, false);
this.checkYieldAwaitInDefaultParams(); this.checkYieldAwaitInDefaultParams();
if (this.awaitIdentPos > 0) if (this.awaitIdentPos > 0)
@@ -2139,18 +2199,14 @@
var node$1 = this.startNodeAt(startPos, startLoc); var node$1 = this.startNodeAt(startPos, startLoc);
node$1.callee = base; node$1.callee = base;
node$1.arguments = exprList; node$1.arguments = exprList;
if (node$1.callee.type === "Import") { if (optionalSupported) {
if (node$1.arguments.length !== 1) { node$1.optional = optional;
this.raise(node$1.start, "import() requires exactly one argument");
}
var importArg = node$1.arguments[0];
if (importArg && importArg.type === "SpreadElement") {
this.raise(importArg.start, "... is not allowed in import()");
}
} }
base = this.finishNode(node$1, "CallExpression"); base = this.finishNode(node$1, "CallExpression");
} else if (this.type === types.backQuote) { } else if (this.type === types.backQuote) {
if (optional || optionalChained) {
this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
}
var node$2 = this.startNodeAt(startPos, startLoc); var node$2 = this.startNodeAt(startPos, startLoc);
node$2.tag = base; node$2.tag = base;
node$2.quasi = this.parseTemplate({isTagged: true}); node$2.quasi = this.parseTemplate({isTagged: true});
@@ -2183,7 +2239,7 @@
// super [ Expression ] // super [ Expression ]
// super . IdentifierName // super . IdentifierName
// SuperCall: // SuperCall:
// super Arguments // super ( Arguments )
if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
{ this.unexpected(); } { this.unexpected(); }
return this.finishNode(node, "Super") return this.finishNode(node, "Super")
@@ -2260,8 +2316,8 @@
return this.parseTemplate() return this.parseTemplate()
case types._import: case types._import:
if (this.options.ecmaVersion > 10) { if (this.options.ecmaVersion >= 11) {
return this.parseDynamicImport() return this.parseExprImport()
} else { } else {
return this.unexpected() return this.unexpected()
} }
@@ -2271,13 +2327,58 @@
} }
}; };
pp$3.parseDynamicImport = function() { pp$3.parseExprImport = function() {
var node = this.startNode(); var node = this.startNode();
this.next();
if (this.type !== types.parenL) { // Consume `import` as an identifier for `import.meta`.
// Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
var meta = this.parseIdent(true);
switch (this.type) {
case types.parenL:
return this.parseDynamicImport(node)
case types.dot:
node.meta = meta;
return this.parseImportMeta(node)
default:
this.unexpected(); this.unexpected();
} }
return this.finishNode(node, "Import") };
pp$3.parseDynamicImport = function(node) {
this.next(); // skip `(`
// Parse node.source.
node.source = this.parseMaybeAssign();
// Verify ending.
if (!this.eat(types.parenR)) {
var errorPos = this.start;
if (this.eat(types.comma) && this.eat(types.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
} else {
this.unexpected(errorPos);
}
}
return this.finishNode(node, "ImportExpression")
};
pp$3.parseImportMeta = function(node) {
this.next(); // skip `.`
var containsEsc = this.containsEsc;
node.property = this.parseIdent(true);
if (node.property.name !== "meta")
{ this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
if (containsEsc)
{ this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
if (this.options.sourceType !== "module")
{ this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
return this.finishNode(node, "MetaProperty")
}; };
pp$3.parseLiteral = function(value) { pp$3.parseLiteral = function(value) {
@@ -2375,24 +2476,27 @@
var empty$1 = []; var empty$1 = [];
pp$3.parseNew = function() { pp$3.parseNew = function() {
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
var node = this.startNode(); var node = this.startNode();
var meta = this.parseIdent(true); var meta = this.parseIdent(true);
if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) { if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
node.meta = meta; node.meta = meta;
var containsEsc = this.containsEsc; var containsEsc = this.containsEsc;
node.property = this.parseIdent(true); node.property = this.parseIdent(true);
if (node.property.name !== "target" || containsEsc) if (node.property.name !== "target")
{ this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
if (containsEsc)
{ this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
if (!this.inNonArrowFunction()) if (!this.inNonArrowFunction())
{ this.raiseRecoverable(node.start, "new.target can only be used in functions"); } { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); }
return this.finishNode(node, "MetaProperty") return this.finishNode(node, "MetaProperty")
} }
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
if (this.options.ecmaVersion > 10 && node.callee.type === "Import") { if (isImport && node.callee.type === "ImportExpression") {
this.raise(node.callee.start, "Cannot use new with import(...)"); this.raise(startPos, "Cannot use new with import()");
} }
if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && node.callee.type !== "Import", false); } if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
else { node.arguments = empty$1; } else { node.arguments = empty$1; }
return this.finishNode(node, "NewExpression") return this.finishNode(node, "NewExpression")
}; };
@@ -2457,7 +2561,7 @@
while (!this.eat(types.braceR)) { while (!this.eat(types.braceR)) {
if (!first) { if (!first) {
this.expect(types.comma); this.expect(types.comma);
if (this.afterTrailingComma(types.braceR)) { break } if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
} else { first = false; } } else { first = false; }
var prop = this.parseProperty(isPattern, refDestructuringErrors); var prop = this.parseProperty(isPattern, refDestructuringErrors);
@@ -2533,7 +2637,7 @@
} else if (!isPattern && !containsEsc && } else if (!isPattern && !containsEsc &&
this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") && (prop.key.name === "get" || prop.key.name === "set") &&
(this.type !== types.comma && this.type !== types.braceR)) { (this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
if (isGenerator || isAsync) { this.unexpected(); } if (isGenerator || isAsync) { this.unexpected(); }
prop.kind = prop.key.name; prop.kind = prop.key.name;
this.parsePropertyName(prop); this.parsePropertyName(prop);
@@ -2668,16 +2772,14 @@
// Add the params to varDeclaredNames to ensure that an error is thrown // Add the params to varDeclaredNames to ensure that an error is thrown
// if a let/const declaration in the function clashes with one of the params. // if a let/const declaration in the function clashes with one of the params.
this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
node.body = this.parseBlock(false); // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); }
node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
node.expression = false; node.expression = false;
this.adaptDirectivePrologue(node.body.body); this.adaptDirectivePrologue(node.body.body);
this.labels = oldLabels; this.labels = oldLabels;
} }
this.exitScope(); this.exitScope();
// Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); }
this.strict = oldStrict;
}; };
pp$3.isSimpleParamList = function(params) { pp$3.isSimpleParamList = function(params) {
@@ -2775,7 +2877,7 @@
} else { } else {
this.unexpected(); this.unexpected();
} }
this.next(); this.next(!!liberal);
this.finishNode(node, "Identifier"); this.finishNode(node, "Identifier");
if (!liberal) { if (!liberal) {
this.checkUnreserved(node); this.checkUnreserved(node);
@@ -2807,7 +2909,7 @@
var node = this.startNode(); var node = this.startNode();
this.next(); this.next();
node.argument = this.parseMaybeUnary(null, true); node.argument = this.parseMaybeUnary(null, false);
return this.finishNode(node, "AwaitExpression") return this.finishNode(node, "AwaitExpression")
}; };
@@ -3196,49 +3298,61 @@
// If u flag is given, this returns the code point at the index (it combines a surrogate pair). // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
// Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
RegExpValidationState.prototype.at = function at (i) { RegExpValidationState.prototype.at = function at (i, forceU) {
if ( forceU === void 0 ) forceU = false;
var s = this.source; var s = this.source;
var l = s.length; var l = s.length;
if (i >= l) { if (i >= l) {
return -1 return -1
} }
var c = s.charCodeAt(i); var c = s.charCodeAt(i);
if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
return c return c
} }
var next = s.charCodeAt(i + 1); var next = s.charCodeAt(i + 1);
return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
}; };
RegExpValidationState.prototype.nextIndex = function nextIndex (i) { RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
if ( forceU === void 0 ) forceU = false;
var s = this.source; var s = this.source;
var l = s.length; var l = s.length;
if (i >= l) { if (i >= l) {
return l return l
} }
var c = s.charCodeAt(i), next; var c = s.charCodeAt(i), next;
if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
(next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
return i + 1 return i + 1
} }
return i + 2 return i + 2
}; };
RegExpValidationState.prototype.current = function current () { RegExpValidationState.prototype.current = function current (forceU) {
return this.at(this.pos) if ( forceU === void 0 ) forceU = false;
return this.at(this.pos, forceU)
}; };
RegExpValidationState.prototype.lookahead = function lookahead () { RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
return this.at(this.nextIndex(this.pos)) if ( forceU === void 0 ) forceU = false;
return this.at(this.nextIndex(this.pos, forceU), forceU)
}; };
RegExpValidationState.prototype.advance = function advance () { RegExpValidationState.prototype.advance = function advance (forceU) {
this.pos = this.nextIndex(this.pos); if ( forceU === void 0 ) forceU = false;
this.pos = this.nextIndex(this.pos, forceU);
}; };
RegExpValidationState.prototype.eat = function eat (ch) { RegExpValidationState.prototype.eat = function eat (ch, forceU) {
if (this.current() === ch) { if ( forceU === void 0 ) forceU = false;
this.advance();
if (this.current(forceU) === ch) {
this.advance(forceU);
return true return true
} }
return false return false
@@ -3309,7 +3423,7 @@
if (state.eat(0x29 /* ) */)) { if (state.eat(0x29 /* ) */)) {
state.raise("Unmatched ')'"); state.raise("Unmatched ')'");
} }
if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) { if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
state.raise("Lone quantifier brackets"); state.raise("Lone quantifier brackets");
} }
} }
@@ -3577,9 +3691,9 @@
return false return false
}; };
// GroupSpecifier[U] :: // GroupSpecifier ::
// [empty] // [empty]
// `?` GroupName[?U] // `?` GroupName
pp$8.regexp_groupSpecifier = function(state) { pp$8.regexp_groupSpecifier = function(state) {
if (state.eat(0x3F /* ? */)) { if (state.eat(0x3F /* ? */)) {
if (this.regexp_eatGroupName(state)) { if (this.regexp_eatGroupName(state)) {
@@ -3593,8 +3707,8 @@
} }
}; };
// GroupName[U] :: // GroupName ::
// `<` RegExpIdentifierName[?U] `>` // `<` RegExpIdentifierName `>`
// Note: this updates `state.lastStringValue` property with the eaten name. // Note: this updates `state.lastStringValue` property with the eaten name.
pp$8.regexp_eatGroupName = function(state) { pp$8.regexp_eatGroupName = function(state) {
state.lastStringValue = ""; state.lastStringValue = "";
@@ -3607,9 +3721,9 @@
return false return false
}; };
// RegExpIdentifierName[U] :: // RegExpIdentifierName ::
// RegExpIdentifierStart[?U] // RegExpIdentifierStart
// RegExpIdentifierName[?U] RegExpIdentifierPart[?U] // RegExpIdentifierName RegExpIdentifierPart
// Note: this updates `state.lastStringValue` property with the eaten name. // Note: this updates `state.lastStringValue` property with the eaten name.
pp$8.regexp_eatRegExpIdentifierName = function(state) { pp$8.regexp_eatRegExpIdentifierName = function(state) {
state.lastStringValue = ""; state.lastStringValue = "";
@@ -3623,17 +3737,18 @@
return false return false
}; };
// RegExpIdentifierStart[U] :: // RegExpIdentifierStart ::
// UnicodeIDStart // UnicodeIDStart
// `$` // `$`
// `_` // `_`
// `\` RegExpUnicodeEscapeSequence[?U] // `\` RegExpUnicodeEscapeSequence[+U]
pp$8.regexp_eatRegExpIdentifierStart = function(state) { pp$8.regexp_eatRegExpIdentifierStart = function(state) {
var start = state.pos; var start = state.pos;
var ch = state.current(); var forceU = this.options.ecmaVersion >= 11;
state.advance(); var ch = state.current(forceU);
state.advance(forceU);
if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
ch = state.lastIntValue; ch = state.lastIntValue;
} }
if (isRegExpIdentifierStart(ch)) { if (isRegExpIdentifierStart(ch)) {
@@ -3648,19 +3763,20 @@
return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
} }
// RegExpIdentifierPart[U] :: // RegExpIdentifierPart ::
// UnicodeIDContinue // UnicodeIDContinue
// `$` // `$`
// `_` // `_`
// `\` RegExpUnicodeEscapeSequence[?U] // `\` RegExpUnicodeEscapeSequence[+U]
// <ZWNJ> // <ZWNJ>
// <ZWJ> // <ZWJ>
pp$8.regexp_eatRegExpIdentifierPart = function(state) { pp$8.regexp_eatRegExpIdentifierPart = function(state) {
var start = state.pos; var start = state.pos;
var ch = state.current(); var forceU = this.options.ecmaVersion >= 11;
state.advance(); var ch = state.current(forceU);
state.advance(forceU);
if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
ch = state.lastIntValue; ch = state.lastIntValue;
} }
if (isRegExpIdentifierPart(ch)) { if (isRegExpIdentifierPart(ch)) {
@@ -3730,7 +3846,7 @@
this.regexp_eatCControlLetter(state) || this.regexp_eatCControlLetter(state) ||
this.regexp_eatZero(state) || this.regexp_eatZero(state) ||
this.regexp_eatHexEscapeSequence(state) || this.regexp_eatHexEscapeSequence(state) ||
this.regexp_eatRegExpUnicodeEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
(!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
this.regexp_eatIdentityEscape(state) this.regexp_eatIdentityEscape(state)
) )
@@ -3803,13 +3919,16 @@
} }
// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
if ( forceU === void 0 ) forceU = false;
var start = state.pos; var start = state.pos;
var switchU = forceU || state.switchU;
if (state.eat(0x75 /* u */)) { if (state.eat(0x75 /* u */)) {
if (this.regexp_eatFixedHexDigits(state, 4)) { if (this.regexp_eatFixedHexDigits(state, 4)) {
var lead = state.lastIntValue; var lead = state.lastIntValue;
if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) { if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
var leadSurrogateEnd = state.pos; var leadSurrogateEnd = state.pos;
if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
var trail = state.lastIntValue; var trail = state.lastIntValue;
@@ -3824,7 +3943,7 @@
return true return true
} }
if ( if (
state.switchU && switchU &&
state.eat(0x7B /* { */) && state.eat(0x7B /* { */) &&
this.regexp_eatHexDigits(state) && this.regexp_eatHexDigits(state) &&
state.eat(0x7D /* } */) && state.eat(0x7D /* } */) &&
@@ -3832,7 +3951,7 @@
) { ) {
return true return true
} }
if (state.switchU) { if (switchU) {
state.raise("Invalid unicode escape"); state.raise("Invalid unicode escape");
} }
state.pos = start; state.pos = start;
@@ -3998,7 +4117,7 @@
if (state.eat(0x5B /* [ */)) { if (state.eat(0x5B /* [ */)) {
state.eat(0x5E /* ^ */); state.eat(0x5E /* ^ */);
this.regexp_classRanges(state); this.regexp_classRanges(state);
if (state.eat(0x5D /* [ */)) { if (state.eat(0x5D /* ] */)) {
return true return true
} }
// Unreachable since it threw "unterminated regular expression" error before. // Unreachable since it threw "unterminated regular expression" error before.
@@ -4046,7 +4165,7 @@
} }
var ch = state.current(); var ch = state.current();
if (ch !== 0x5D /* [ */) { if (ch !== 0x5D /* ] */) {
state.lastIntValue = ch; state.lastIntValue = ch;
state.advance(); state.advance();
return true return true
@@ -4225,7 +4344,9 @@
// Move to the next token // Move to the next token
pp$9.next = function() { pp$9.next = function(ignoreEscapeSequenceInKeyword) {
if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
{ this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
if (this.options.onToken) if (this.options.onToken)
{ this.options.onToken(new Token(this)); } { this.options.onToken(new Token(this)); }
@@ -4486,6 +4607,18 @@
return this.finishOp(code === 61 ? types.eq : types.prefix, 1) return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
}; };
pp$9.readToken_question = function() { // '?'
if (this.options.ecmaVersion >= 11) {
var next = this.input.charCodeAt(this.pos + 1);
if (next === 46) {
var next2 = this.input.charCodeAt(this.pos + 2);
if (next2 < 48 || next2 > 57) { return this.finishOp(types.questionDot, 2) }
}
if (next === 63) { return this.finishOp(types.coalesce, 2) }
}
return this.finishOp(types.question, 1)
};
pp$9.getTokenFromCode = function(code) { pp$9.getTokenFromCode = function(code) {
switch (code) { switch (code) {
// The interpretation of a dot depends on whether it is followed // The interpretation of a dot depends on whether it is followed
@@ -4503,7 +4636,6 @@
case 123: ++this.pos; return this.finishToken(types.braceL) case 123: ++this.pos; return this.finishToken(types.braceL)
case 125: ++this.pos; return this.finishToken(types.braceR) case 125: ++this.pos; return this.finishToken(types.braceR)
case 58: ++this.pos; return this.finishToken(types.colon) case 58: ++this.pos; return this.finishToken(types.colon)
case 63: ++this.pos; return this.finishToken(types.question)
case 96: // '`' case 96: // '`'
if (this.options.ecmaVersion < 6) { break } if (this.options.ecmaVersion < 6) { break }
@@ -4553,6 +4685,9 @@
case 61: case 33: // '=!' case 61: case 33: // '=!'
return this.readToken_eq_excl(code) return this.readToken_eq_excl(code)
case 63: // '?'
return this.readToken_question()
case 126: // '~' case 126: // '~'
return this.finishOp(types.prefix, 1) return this.finishOp(types.prefix, 1)
} }
@@ -4644,7 +4779,6 @@
if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); } if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); }
var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48; var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
if (octal && this.strict) { this.raise(start, "Invalid number"); } if (octal && this.strict) { this.raise(start, "Invalid number"); }
if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
var next = this.input.charCodeAt(this.pos); var next = this.input.charCodeAt(this.pos);
if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) { if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
var str$1 = this.input.slice(start, this.pos); var str$1 = this.input.slice(start, this.pos);
@@ -4653,6 +4787,7 @@
if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); } if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
return this.finishToken(types.num, val$1) return this.finishToken(types.num, val$1)
} }
if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
if (next === 46 && !octal) { // '.' if (next === 46 && !octal) { // '.'
++this.pos; ++this.pos;
this.readInt(10); this.readInt(10);
@@ -4827,6 +4962,18 @@
case 10: // ' \n' case 10: // ' \n'
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; } if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
return "" return ""
case 56:
case 57:
if (inTemplate) {
var codePos = this.pos - 1;
this.invalidStringToken(
codePos,
"Invalid escape sequence in template string"
);
return null
}
default: default:
if (ch >= 48 && ch <= 55) { if (ch >= 48 && ch <= 55) {
var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0]; var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
@@ -4906,7 +5053,6 @@
var word = this.readWord1(); var word = this.readWord1();
var type = types.name; var type = types.name;
if (this.keywords.test(word)) { if (this.keywords.test(word)) {
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword " + word); }
type = keywords$1[word]; type = keywords$1[word];
} }
return this.finishToken(type, word) return this.finishToken(type, word)
@@ -4914,7 +5060,7 @@
// Acorn is a tiny, fast JavaScript parser written in JavaScript. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
var version = "6.4.0"; var version = "7.3.1";
Parser.acorn = { Parser.acorn = {
Parser: Parser, Parser: Parser,
@@ -4989,4 +5135,4 @@
Object.defineProperty(exports, '__esModule', { value: true }); Object.defineProperty(exports, '__esModule', { value: true });
})); })));

356
node_modules/acorn/dist/acorn.mjs generated vendored
View File

@@ -27,8 +27,8 @@ var keywordRelationalOperator = /^in(stanceof)?$/;
// are only applied when a character is found to actually have a // are only applied when a character is found to actually have a
// code point above 128. // code point above 128.
// Generated by `bin/generate-identifier-regex.js`. // Generated by `bin/generate-identifier-regex.js`.
var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fef\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7c6\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab67\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc"; var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0560-\u0588\u05d0-\u05ea\u05ef-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u0860-\u086a\u08a0-\u08b4\u08b6-\u08c7\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u09fc\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d04-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e86-\u0e8a\u0e8c-\u0ea3\u0ea5\u0ea7-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1878\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1c90-\u1cba\u1cbd-\u1cbf\u1ce9-\u1cec\u1cee-\u1cf3\u1cf5\u1cf6\u1cfa\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312f\u3131-\u318e\u31a0-\u31bf\u31f0-\u31ff\u3400-\u4dbf\u4e00-\u9ffc\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7bf\ua7c2-\ua7ca\ua7f5-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua8fe\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab69\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc";
var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f"; var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u07fd\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d3-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u09fe\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0afa-\u0aff\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b55-\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c04\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d00-\u0d03\u0d3b\u0d3c\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d81-\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1abf\u1ac0\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf4\u1cf7-\u1cf9\u1dc0-\u1df9\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua82c\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua8ff-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f";
var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]"); var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]"); var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
@@ -42,10 +42,10 @@ nonASCIIidentifierStartChars = nonASCIIidentifierChars = null;
// generated by bin/generate-identifier-regex.js // generated by bin/generate-identifier-regex.js
// eslint-disable-next-line comma-spacing // eslint-disable-next-line comma-spacing
var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,477,28,11,0,9,21,155,22,13,52,76,44,33,24,27,35,30,0,12,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,0,33,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,0,161,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,270,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,754,9486,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,15,7472,3104,541]; var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,14,29,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,28,43,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,14,35,349,41,7,1,79,28,11,0,9,21,107,20,28,22,13,52,76,44,33,24,27,35,30,0,3,0,9,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,21,2,31,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,14,0,72,26,230,43,117,63,32,7,3,0,3,7,2,1,2,23,16,0,2,0,95,7,3,38,17,0,2,0,29,0,11,39,8,0,22,0,12,45,20,0,35,56,264,8,2,36,18,0,50,29,113,6,2,1,2,37,22,0,26,5,2,1,2,31,15,0,328,18,190,0,80,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,689,63,129,74,6,0,67,12,65,1,2,0,29,6135,9,1237,43,8,8952,286,50,2,18,3,9,395,2309,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,2357,44,11,6,17,0,370,43,1301,196,60,67,8,0,1205,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42717,35,4148,12,221,3,5761,15,7472,3104,541,1507,4938];
// eslint-disable-next-line comma-spacing // eslint-disable-next-line comma-spacing
var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,525,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,4,9,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,232,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,792487,239]; var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,574,3,9,9,370,1,154,10,176,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,6,1,45,0,13,2,49,13,9,3,2,11,83,11,7,0,161,11,6,9,7,3,56,1,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,5,0,82,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,243,14,166,9,71,5,2,1,3,3,2,0,2,1,13,9,120,6,3,6,4,0,29,9,41,6,2,3,9,0,10,10,47,15,406,7,2,7,17,9,57,21,2,13,123,5,4,0,2,1,2,6,2,0,9,9,49,4,2,1,2,4,9,9,330,3,19306,9,135,4,60,6,26,9,1014,0,2,54,8,3,82,0,12,1,19628,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,262,6,10,9,419,13,1495,6,110,6,6,9,4759,9,787719,239];
// This has a complexity linear to the value of the code. The // This has a complexity linear to the value of the code. The
// assumption is that looking up astral identifier characters is // assumption is that looking up astral identifier characters is
@@ -160,6 +160,7 @@ var types = {
colon: new TokenType(":", beforeExpr), colon: new TokenType(":", beforeExpr),
dot: new TokenType("."), dot: new TokenType("."),
question: new TokenType("?", beforeExpr), question: new TokenType("?", beforeExpr),
questionDot: new TokenType("?."),
arrow: new TokenType("=>", beforeExpr), arrow: new TokenType("=>", beforeExpr),
template: new TokenType("template"), template: new TokenType("template"),
invalidTemplate: new TokenType("invalidTemplate"), invalidTemplate: new TokenType("invalidTemplate"),
@@ -198,6 +199,7 @@ var types = {
star: binop("*", 10), star: binop("*", 10),
slash: binop("/", 10), slash: binop("/", 10),
starstar: new TokenType("**", {beforeExpr: true}), starstar: new TokenType("**", {beforeExpr: true}),
coalesce: binop("??", 1),
// Keyword token types. // Keyword token types.
_break: kw("break"), _break: kw("break"),
@@ -314,8 +316,8 @@ var defaultOptions = {
// either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10 // either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018), or 10
// (2019). This influences support for strict mode, the set of // (2019). This influences support for strict mode, the set of
// reserved words, and support for new syntax features. The default // reserved words, and support for new syntax features. The default
// is 9. // is 10.
ecmaVersion: 9, ecmaVersion: 10,
// `sourceType` indicates the mode the code should be parsed in. // `sourceType` indicates the mode the code should be parsed in.
// Can be either `"script"` or `"module"`. This influences global // Can be either `"script"` or `"module"`. This influences global
// strict mode and parsing of `import` and `export` declarations. // strict mode and parsing of `import` and `export` declarations.
@@ -594,7 +596,14 @@ pp.strictDirective = function(start) {
start += skipWhiteSpace.exec(this.input)[0].length; start += skipWhiteSpace.exec(this.input)[0].length;
var match = literal.exec(this.input.slice(start)); var match = literal.exec(this.input.slice(start));
if (!match) { return false } if (!match) { return false }
if ((match[1] || match[2]) === "use strict") { return true } if ((match[1] || match[2]) === "use strict") {
skipWhiteSpace.lastIndex = start + match[0].length;
var spaceAfter = skipWhiteSpace.exec(this.input), end = spaceAfter.index + spaceAfter[0].length;
var next = this.input.charAt(end);
return next === ";" || next === "}" ||
(lineBreak.test(spaceAfter[0]) &&
!(/[(`.[+\-/*%<>=,?^&]/.test(next) || next === "!" && this.input.charAt(end + 1) === "="))
}
start += match[0].length; start += match[0].length;
// Skip semicolon, if any. // Skip semicolon, if any.
@@ -844,7 +853,7 @@ pp$1.parseStatement = function(context, topLevel, exports) {
skipWhiteSpace.lastIndex = this.pos; skipWhiteSpace.lastIndex = this.pos;
var skip = skipWhiteSpace.exec(this.input); var skip = skipWhiteSpace.exec(this.input);
var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next); var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next);
if (nextCh === 40) // '(' if (nextCh === 40 || nextCh === 46) // '(' or '.'
{ return this.parseExpressionStatement(node, this.parseExpression()) } { return this.parseExpressionStatement(node, this.parseExpression()) }
} }
@@ -1144,17 +1153,19 @@ pp$1.parseExpressionStatement = function(node, expr) {
// strict"` declarations when `allowStrict` is true (used for // strict"` declarations when `allowStrict` is true (used for
// function bodies). // function bodies).
pp$1.parseBlock = function(createNewLexicalScope, node) { pp$1.parseBlock = function(createNewLexicalScope, node, exitStrict) {
if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true; if ( createNewLexicalScope === void 0 ) createNewLexicalScope = true;
if ( node === void 0 ) node = this.startNode(); if ( node === void 0 ) node = this.startNode();
node.body = []; node.body = [];
this.expect(types.braceL); this.expect(types.braceL);
if (createNewLexicalScope) { this.enterScope(0); } if (createNewLexicalScope) { this.enterScope(0); }
while (!this.eat(types.braceR)) { while (this.type !== types.braceR) {
var stmt = this.parseStatement(null); var stmt = this.parseStatement(null);
node.body.push(stmt); node.body.push(stmt);
} }
if (exitStrict) { this.strict = false; }
this.next();
if (createNewLexicalScope) { this.exitScope(); } if (createNewLexicalScope) { this.exitScope(); }
return this.finishNode(node, "BlockStatement") return this.finishNode(node, "BlockStatement")
}; };
@@ -1305,7 +1316,7 @@ pp$1.parseClass = function(node, isStatement) {
var hadConstructor = false; var hadConstructor = false;
classBody.body = []; classBody.body = [];
this.expect(types.braceL); this.expect(types.braceL);
while (!this.eat(types.braceR)) { while (this.type !== types.braceR) {
var element = this.parseClassElement(node.superClass !== null); var element = this.parseClassElement(node.superClass !== null);
if (element) { if (element) {
classBody.body.push(element); classBody.body.push(element);
@@ -1315,8 +1326,9 @@ pp$1.parseClass = function(node, isStatement) {
} }
} }
} }
node.body = this.finishNode(classBody, "ClassBody");
this.strict = oldStrict; this.strict = oldStrict;
this.next();
node.body = this.finishNode(classBody, "ClassBody");
return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression")
}; };
@@ -1404,6 +1416,14 @@ pp$1.parseExport = function(node, exports) {
this.next(); this.next();
// export * from '...' // export * from '...'
if (this.eat(types.star)) { if (this.eat(types.star)) {
if (this.options.ecmaVersion >= 11) {
if (this.eatContextual("as")) {
node.exported = this.parseIdent(true);
this.checkExport(exports, node.exported.name, this.lastTokStart);
} else {
node.exported = null;
}
}
this.expectContextual("from"); this.expectContextual("from");
if (this.type !== types.string) { this.unexpected(); } if (this.type !== types.string) { this.unexpected(); }
node.source = this.parseExprAtom(); node.source = this.parseExprAtom();
@@ -1680,6 +1700,10 @@ pp$2.toAssignable = function(node, isBinding, refDestructuringErrors) {
this.toAssignable(node.expression, isBinding, refDestructuringErrors); this.toAssignable(node.expression, isBinding, refDestructuringErrors);
break break
case "ChainExpression":
this.raiseRecoverable(node.start, "Optional chaining cannot appear in left-hand side");
break
case "MemberExpression": case "MemberExpression":
if (!isBinding) { break } if (!isBinding) { break }
@@ -1810,6 +1834,10 @@ pp$2.checkLVal = function(expr, bindingType, checkClashes) {
if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); } if (bindingType !== BIND_NONE && bindingType !== BIND_OUTSIDE) { this.declareName(expr.name, bindingType, expr.start); }
break break
case "ChainExpression":
this.raiseRecoverable(expr.start, "Optional chaining cannot appear in left-hand side");
break
case "MemberExpression": case "MemberExpression":
if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); } if (bindingType) { this.raiseRecoverable(expr.start, "Binding member expression"); }
break break
@@ -1878,9 +1906,11 @@ pp$3.checkPropClash = function(prop, propHash, refDestructuringErrors) {
if (this.options.ecmaVersion >= 6) { if (this.options.ecmaVersion >= 6) {
if (name === "__proto__" && kind === "init") { if (name === "__proto__" && kind === "init") {
if (propHash.proto) { if (propHash.proto) {
if (refDestructuringErrors && refDestructuringErrors.doubleProto < 0) { refDestructuringErrors.doubleProto = key.start; } if (refDestructuringErrors) {
if (refDestructuringErrors.doubleProto < 0)
{ refDestructuringErrors.doubleProto = key.start; }
// Backwards-compat kludge. Can be removed in version 6.0 // Backwards-compat kludge. Can be removed in version 6.0
else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); } } else { this.raiseRecoverable(key.start, "Redefinition of __proto__ property"); }
} }
propHash.proto = true; propHash.proto = true;
} }
@@ -1945,12 +1975,11 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
else { this.exprAllowed = false; } else { this.exprAllowed = false; }
} }
var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1, oldShorthandAssign = -1; var ownDestructuringErrors = false, oldParenAssign = -1, oldTrailingComma = -1;
if (refDestructuringErrors) { if (refDestructuringErrors) {
oldParenAssign = refDestructuringErrors.parenthesizedAssign; oldParenAssign = refDestructuringErrors.parenthesizedAssign;
oldTrailingComma = refDestructuringErrors.trailingComma; oldTrailingComma = refDestructuringErrors.trailingComma;
oldShorthandAssign = refDestructuringErrors.shorthandAssign; refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = -1;
refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.shorthandAssign = -1;
} else { } else {
refDestructuringErrors = new DestructuringErrors; refDestructuringErrors = new DestructuringErrors;
ownDestructuringErrors = true; ownDestructuringErrors = true;
@@ -1965,8 +1994,11 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
var node = this.startNodeAt(startPos, startLoc); var node = this.startNodeAt(startPos, startLoc);
node.operator = this.value; node.operator = this.value;
node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left; node.left = this.type === types.eq ? this.toAssignable(left, false, refDestructuringErrors) : left;
if (!ownDestructuringErrors) { DestructuringErrors.call(refDestructuringErrors); } if (!ownDestructuringErrors) {
refDestructuringErrors.shorthandAssign = -1; // reset because shorthand default was used correctly refDestructuringErrors.parenthesizedAssign = refDestructuringErrors.trailingComma = refDestructuringErrors.doubleProto = -1;
}
if (refDestructuringErrors.shorthandAssign >= node.left.start)
{ refDestructuringErrors.shorthandAssign = -1; } // reset because shorthand default was used correctly
this.checkLVal(left); this.checkLVal(left);
this.next(); this.next();
node.right = this.parseMaybeAssign(noIn); node.right = this.parseMaybeAssign(noIn);
@@ -1976,7 +2008,6 @@ pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) {
} }
if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; } if (oldParenAssign > -1) { refDestructuringErrors.parenthesizedAssign = oldParenAssign; }
if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; } if (oldTrailingComma > -1) { refDestructuringErrors.trailingComma = oldTrailingComma; }
if (oldShorthandAssign > -1) { refDestructuringErrors.shorthandAssign = oldShorthandAssign; }
return left return left
}; };
@@ -2017,11 +2048,20 @@ pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) {
if (prec != null && (!noIn || this.type !== types._in)) { if (prec != null && (!noIn || this.type !== types._in)) {
if (prec > minPrec) { if (prec > minPrec) {
var logical = this.type === types.logicalOR || this.type === types.logicalAND; var logical = this.type === types.logicalOR || this.type === types.logicalAND;
var coalesce = this.type === types.coalesce;
if (coalesce) {
// Handle the precedence of `tt.coalesce` as equal to the range of logical expressions.
// In other words, `node.right` shouldn't contain logical expressions in order to check the mixed error.
prec = types.logicalAND.binop;
}
var op = this.value; var op = this.value;
this.next(); this.next();
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc;
var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn); var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn);
var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical); var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical || coalesce);
if ((logical && this.type === types.coalesce) || (coalesce && (this.type === types.logicalOR || this.type === types.logicalAND))) {
this.raiseRecoverable(this.start, "Logical expressions and coalesce expressions cannot be mixed. Wrap either by parentheses");
}
return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn)
} }
} }
@@ -2081,8 +2121,8 @@ pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) {
pp$3.parseExprSubscripts = function(refDestructuringErrors) { pp$3.parseExprSubscripts = function(refDestructuringErrors) {
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc;
var expr = this.parseExprAtom(refDestructuringErrors); var expr = this.parseExprAtom(refDestructuringErrors);
var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")"; if (expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")")
if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) { return expr } { return expr }
var result = this.parseSubscripts(expr, startPos, startLoc); var result = this.parseSubscripts(expr, startPos, startLoc);
if (refDestructuringErrors && result.type === "MemberExpression") { if (refDestructuringErrors && result.type === "MemberExpression") {
if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; } if (refDestructuringErrors.parenthesizedAssign >= result.start) { refDestructuringErrors.parenthesizedAssign = -1; }
@@ -2093,30 +2133,50 @@ pp$3.parseExprSubscripts = function(refDestructuringErrors) {
pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) {
var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && var maybeAsyncArrow = this.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" &&
this.lastTokEnd === base.end && !this.canInsertSemicolon() && this.input.slice(base.start, base.end) === "async"; this.lastTokEnd === base.end && !this.canInsertSemicolon() && base.end - base.start === 5 &&
this.potentialArrowAt === base.start;
var optionalChained = false;
while (true) { while (true) {
var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow); var element = this.parseSubscript(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained);
if (element === base || element.type === "ArrowFunctionExpression") { return element }
if (element.optional) { optionalChained = true; }
if (element === base || element.type === "ArrowFunctionExpression") {
if (optionalChained) {
var chainNode = this.startNodeAt(startPos, startLoc);
chainNode.expression = element;
element = this.finishNode(chainNode, "ChainExpression");
}
return element
}
base = element; base = element;
} }
}; };
pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow) { pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArrow, optionalChained) {
var optionalSupported = this.options.ecmaVersion >= 11;
var optional = optionalSupported && this.eat(types.questionDot);
if (noCalls && optional) { this.raise(this.lastTokStart, "Optional chaining cannot appear in the callee of new expressions"); }
var computed = this.eat(types.bracketL); var computed = this.eat(types.bracketL);
if (computed || this.eat(types.dot)) { if (computed || (optional && this.type !== types.parenL && this.type !== types.backQuote) || this.eat(types.dot)) {
var node = this.startNodeAt(startPos, startLoc); var node = this.startNodeAt(startPos, startLoc);
node.object = base; node.object = base;
node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never"); node.property = computed ? this.parseExpression() : this.parseIdent(this.options.allowReserved !== "never");
node.computed = !!computed; node.computed = !!computed;
if (computed) { this.expect(types.bracketR); } if (computed) { this.expect(types.bracketR); }
if (optionalSupported) {
node.optional = optional;
}
base = this.finishNode(node, "MemberExpression"); base = this.finishNode(node, "MemberExpression");
} else if (!noCalls && this.eat(types.parenL)) { } else if (!noCalls && this.eat(types.parenL)) {
var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos; var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, oldAwaitIdentPos = this.awaitIdentPos;
this.yieldPos = 0; this.yieldPos = 0;
this.awaitPos = 0; this.awaitPos = 0;
this.awaitIdentPos = 0; this.awaitIdentPos = 0;
var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && base.type !== "Import", false, refDestructuringErrors); var exprList = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false, refDestructuringErrors);
if (maybeAsyncArrow && !this.canInsertSemicolon() && this.eat(types.arrow)) { if (maybeAsyncArrow && !optional && !this.canInsertSemicolon() && this.eat(types.arrow)) {
this.checkPatternErrors(refDestructuringErrors, false); this.checkPatternErrors(refDestructuringErrors, false);
this.checkYieldAwaitInDefaultParams(); this.checkYieldAwaitInDefaultParams();
if (this.awaitIdentPos > 0) if (this.awaitIdentPos > 0)
@@ -2133,18 +2193,14 @@ pp$3.parseSubscript = function(base, startPos, startLoc, noCalls, maybeAsyncArro
var node$1 = this.startNodeAt(startPos, startLoc); var node$1 = this.startNodeAt(startPos, startLoc);
node$1.callee = base; node$1.callee = base;
node$1.arguments = exprList; node$1.arguments = exprList;
if (node$1.callee.type === "Import") { if (optionalSupported) {
if (node$1.arguments.length !== 1) { node$1.optional = optional;
this.raise(node$1.start, "import() requires exactly one argument");
}
var importArg = node$1.arguments[0];
if (importArg && importArg.type === "SpreadElement") {
this.raise(importArg.start, "... is not allowed in import()");
}
} }
base = this.finishNode(node$1, "CallExpression"); base = this.finishNode(node$1, "CallExpression");
} else if (this.type === types.backQuote) { } else if (this.type === types.backQuote) {
if (optional || optionalChained) {
this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
}
var node$2 = this.startNodeAt(startPos, startLoc); var node$2 = this.startNodeAt(startPos, startLoc);
node$2.tag = base; node$2.tag = base;
node$2.quasi = this.parseTemplate({isTagged: true}); node$2.quasi = this.parseTemplate({isTagged: true});
@@ -2177,7 +2233,7 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
// super [ Expression ] // super [ Expression ]
// super . IdentifierName // super . IdentifierName
// SuperCall: // SuperCall:
// super Arguments // super ( Arguments )
if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL) if (this.type !== types.dot && this.type !== types.bracketL && this.type !== types.parenL)
{ this.unexpected(); } { this.unexpected(); }
return this.finishNode(node, "Super") return this.finishNode(node, "Super")
@@ -2254,8 +2310,8 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
return this.parseTemplate() return this.parseTemplate()
case types._import: case types._import:
if (this.options.ecmaVersion > 10) { if (this.options.ecmaVersion >= 11) {
return this.parseDynamicImport() return this.parseExprImport()
} else { } else {
return this.unexpected() return this.unexpected()
} }
@@ -2265,13 +2321,58 @@ pp$3.parseExprAtom = function(refDestructuringErrors) {
} }
}; };
pp$3.parseDynamicImport = function() { pp$3.parseExprImport = function() {
var node = this.startNode(); var node = this.startNode();
this.next();
if (this.type !== types.parenL) { // Consume `import` as an identifier for `import.meta`.
// Because `this.parseIdent(true)` doesn't check escape sequences, it needs the check of `this.containsEsc`.
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword import"); }
var meta = this.parseIdent(true);
switch (this.type) {
case types.parenL:
return this.parseDynamicImport(node)
case types.dot:
node.meta = meta;
return this.parseImportMeta(node)
default:
this.unexpected(); this.unexpected();
} }
return this.finishNode(node, "Import") };
pp$3.parseDynamicImport = function(node) {
this.next(); // skip `(`
// Parse node.source.
node.source = this.parseMaybeAssign();
// Verify ending.
if (!this.eat(types.parenR)) {
var errorPos = this.start;
if (this.eat(types.comma) && this.eat(types.parenR)) {
this.raiseRecoverable(errorPos, "Trailing comma is not allowed in import()");
} else {
this.unexpected(errorPos);
}
}
return this.finishNode(node, "ImportExpression")
};
pp$3.parseImportMeta = function(node) {
this.next(); // skip `.`
var containsEsc = this.containsEsc;
node.property = this.parseIdent(true);
if (node.property.name !== "meta")
{ this.raiseRecoverable(node.property.start, "The only valid meta property for import is 'import.meta'"); }
if (containsEsc)
{ this.raiseRecoverable(node.start, "'import.meta' must not contain escaped characters"); }
if (this.options.sourceType !== "module")
{ this.raiseRecoverable(node.start, "Cannot use 'import.meta' outside a module"); }
return this.finishNode(node, "MetaProperty")
}; };
pp$3.parseLiteral = function(value) { pp$3.parseLiteral = function(value) {
@@ -2369,24 +2470,27 @@ pp$3.parseParenArrowList = function(startPos, startLoc, exprList) {
var empty$1 = []; var empty$1 = [];
pp$3.parseNew = function() { pp$3.parseNew = function() {
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword new"); }
var node = this.startNode(); var node = this.startNode();
var meta = this.parseIdent(true); var meta = this.parseIdent(true);
if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) { if (this.options.ecmaVersion >= 6 && this.eat(types.dot)) {
node.meta = meta; node.meta = meta;
var containsEsc = this.containsEsc; var containsEsc = this.containsEsc;
node.property = this.parseIdent(true); node.property = this.parseIdent(true);
if (node.property.name !== "target" || containsEsc) if (node.property.name !== "target")
{ this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target"); } { this.raiseRecoverable(node.property.start, "The only valid meta property for new is 'new.target'"); }
if (containsEsc)
{ this.raiseRecoverable(node.start, "'new.target' must not contain escaped characters"); }
if (!this.inNonArrowFunction()) if (!this.inNonArrowFunction())
{ this.raiseRecoverable(node.start, "new.target can only be used in functions"); } { this.raiseRecoverable(node.start, "'new.target' can only be used in functions"); }
return this.finishNode(node, "MetaProperty") return this.finishNode(node, "MetaProperty")
} }
var startPos = this.start, startLoc = this.startLoc; var startPos = this.start, startLoc = this.startLoc, isImport = this.type === types._import;
node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true); node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true);
if (this.options.ecmaVersion > 10 && node.callee.type === "Import") { if (isImport && node.callee.type === "ImportExpression") {
this.raise(node.callee.start, "Cannot use new with import(...)"); this.raise(startPos, "Cannot use new with import()");
} }
if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8 && node.callee.type !== "Import", false); } if (this.eat(types.parenL)) { node.arguments = this.parseExprList(types.parenR, this.options.ecmaVersion >= 8, false); }
else { node.arguments = empty$1; } else { node.arguments = empty$1; }
return this.finishNode(node, "NewExpression") return this.finishNode(node, "NewExpression")
}; };
@@ -2451,7 +2555,7 @@ pp$3.parseObj = function(isPattern, refDestructuringErrors) {
while (!this.eat(types.braceR)) { while (!this.eat(types.braceR)) {
if (!first) { if (!first) {
this.expect(types.comma); this.expect(types.comma);
if (this.afterTrailingComma(types.braceR)) { break } if (this.options.ecmaVersion >= 5 && this.afterTrailingComma(types.braceR)) { break }
} else { first = false; } } else { first = false; }
var prop = this.parseProperty(isPattern, refDestructuringErrors); var prop = this.parseProperty(isPattern, refDestructuringErrors);
@@ -2527,7 +2631,7 @@ pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startP
} else if (!isPattern && !containsEsc && } else if (!isPattern && !containsEsc &&
this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" &&
(prop.key.name === "get" || prop.key.name === "set") && (prop.key.name === "get" || prop.key.name === "set") &&
(this.type !== types.comma && this.type !== types.braceR)) { (this.type !== types.comma && this.type !== types.braceR && this.type !== types.eq)) {
if (isGenerator || isAsync) { this.unexpected(); } if (isGenerator || isAsync) { this.unexpected(); }
prop.kind = prop.key.name; prop.kind = prop.key.name;
this.parsePropertyName(prop); this.parsePropertyName(prop);
@@ -2662,16 +2766,14 @@ pp$3.parseFunctionBody = function(node, isArrowFunction, isMethod) {
// Add the params to varDeclaredNames to ensure that an error is thrown // Add the params to varDeclaredNames to ensure that an error is thrown
// if a let/const declaration in the function clashes with one of the params. // if a let/const declaration in the function clashes with one of the params.
this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params)); this.checkParams(node, !oldStrict && !useStrict && !isArrowFunction && !isMethod && this.isSimpleParamList(node.params));
node.body = this.parseBlock(false); // Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); }
node.body = this.parseBlock(false, undefined, useStrict && !oldStrict);
node.expression = false; node.expression = false;
this.adaptDirectivePrologue(node.body.body); this.adaptDirectivePrologue(node.body.body);
this.labels = oldLabels; this.labels = oldLabels;
} }
this.exitScope(); this.exitScope();
// Ensure the function name isn't a forbidden identifier in strict mode, e.g. 'eval'
if (this.strict && node.id) { this.checkLVal(node.id, BIND_OUTSIDE); }
this.strict = oldStrict;
}; };
pp$3.isSimpleParamList = function(params) { pp$3.isSimpleParamList = function(params) {
@@ -2769,7 +2871,7 @@ pp$3.parseIdent = function(liberal, isBinding) {
} else { } else {
this.unexpected(); this.unexpected();
} }
this.next(); this.next(!!liberal);
this.finishNode(node, "Identifier"); this.finishNode(node, "Identifier");
if (!liberal) { if (!liberal) {
this.checkUnreserved(node); this.checkUnreserved(node);
@@ -2801,7 +2903,7 @@ pp$3.parseAwait = function() {
var node = this.startNode(); var node = this.startNode();
this.next(); this.next();
node.argument = this.parseMaybeUnary(null, true); node.argument = this.parseMaybeUnary(null, false);
return this.finishNode(node, "AwaitExpression") return this.finishNode(node, "AwaitExpression")
}; };
@@ -3190,49 +3292,61 @@ RegExpValidationState.prototype.raise = function raise (message) {
// If u flag is given, this returns the code point at the index (it combines a surrogate pair). // If u flag is given, this returns the code point at the index (it combines a surrogate pair).
// Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair).
RegExpValidationState.prototype.at = function at (i) { RegExpValidationState.prototype.at = function at (i, forceU) {
if ( forceU === void 0 ) forceU = false;
var s = this.source; var s = this.source;
var l = s.length; var l = s.length;
if (i >= l) { if (i >= l) {
return -1 return -1
} }
var c = s.charCodeAt(i); var c = s.charCodeAt(i);
if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) {
return c return c
} }
var next = s.charCodeAt(i + 1); var next = s.charCodeAt(i + 1);
return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c
}; };
RegExpValidationState.prototype.nextIndex = function nextIndex (i) { RegExpValidationState.prototype.nextIndex = function nextIndex (i, forceU) {
if ( forceU === void 0 ) forceU = false;
var s = this.source; var s = this.source;
var l = s.length; var l = s.length;
if (i >= l) { if (i >= l) {
return l return l
} }
var c = s.charCodeAt(i), next; var c = s.charCodeAt(i), next;
if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || if (!(forceU || this.switchU) || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l ||
(next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) {
return i + 1 return i + 1
} }
return i + 2 return i + 2
}; };
RegExpValidationState.prototype.current = function current () { RegExpValidationState.prototype.current = function current (forceU) {
return this.at(this.pos) if ( forceU === void 0 ) forceU = false;
return this.at(this.pos, forceU)
}; };
RegExpValidationState.prototype.lookahead = function lookahead () { RegExpValidationState.prototype.lookahead = function lookahead (forceU) {
return this.at(this.nextIndex(this.pos)) if ( forceU === void 0 ) forceU = false;
return this.at(this.nextIndex(this.pos, forceU), forceU)
}; };
RegExpValidationState.prototype.advance = function advance () { RegExpValidationState.prototype.advance = function advance (forceU) {
this.pos = this.nextIndex(this.pos); if ( forceU === void 0 ) forceU = false;
this.pos = this.nextIndex(this.pos, forceU);
}; };
RegExpValidationState.prototype.eat = function eat (ch) { RegExpValidationState.prototype.eat = function eat (ch, forceU) {
if (this.current() === ch) { if ( forceU === void 0 ) forceU = false;
this.advance();
if (this.current(forceU) === ch) {
this.advance(forceU);
return true return true
} }
return false return false
@@ -3303,7 +3417,7 @@ pp$8.regexp_pattern = function(state) {
if (state.eat(0x29 /* ) */)) { if (state.eat(0x29 /* ) */)) {
state.raise("Unmatched ')'"); state.raise("Unmatched ')'");
} }
if (state.eat(0x5D /* [ */) || state.eat(0x7D /* } */)) { if (state.eat(0x5D /* ] */) || state.eat(0x7D /* } */)) {
state.raise("Lone quantifier brackets"); state.raise("Lone quantifier brackets");
} }
} }
@@ -3571,9 +3685,9 @@ pp$8.regexp_eatExtendedPatternCharacter = function(state) {
return false return false
}; };
// GroupSpecifier[U] :: // GroupSpecifier ::
// [empty] // [empty]
// `?` GroupName[?U] // `?` GroupName
pp$8.regexp_groupSpecifier = function(state) { pp$8.regexp_groupSpecifier = function(state) {
if (state.eat(0x3F /* ? */)) { if (state.eat(0x3F /* ? */)) {
if (this.regexp_eatGroupName(state)) { if (this.regexp_eatGroupName(state)) {
@@ -3587,8 +3701,8 @@ pp$8.regexp_groupSpecifier = function(state) {
} }
}; };
// GroupName[U] :: // GroupName ::
// `<` RegExpIdentifierName[?U] `>` // `<` RegExpIdentifierName `>`
// Note: this updates `state.lastStringValue` property with the eaten name. // Note: this updates `state.lastStringValue` property with the eaten name.
pp$8.regexp_eatGroupName = function(state) { pp$8.regexp_eatGroupName = function(state) {
state.lastStringValue = ""; state.lastStringValue = "";
@@ -3601,9 +3715,9 @@ pp$8.regexp_eatGroupName = function(state) {
return false return false
}; };
// RegExpIdentifierName[U] :: // RegExpIdentifierName ::
// RegExpIdentifierStart[?U] // RegExpIdentifierStart
// RegExpIdentifierName[?U] RegExpIdentifierPart[?U] // RegExpIdentifierName RegExpIdentifierPart
// Note: this updates `state.lastStringValue` property with the eaten name. // Note: this updates `state.lastStringValue` property with the eaten name.
pp$8.regexp_eatRegExpIdentifierName = function(state) { pp$8.regexp_eatRegExpIdentifierName = function(state) {
state.lastStringValue = ""; state.lastStringValue = "";
@@ -3617,17 +3731,18 @@ pp$8.regexp_eatRegExpIdentifierName = function(state) {
return false return false
}; };
// RegExpIdentifierStart[U] :: // RegExpIdentifierStart ::
// UnicodeIDStart // UnicodeIDStart
// `$` // `$`
// `_` // `_`
// `\` RegExpUnicodeEscapeSequence[?U] // `\` RegExpUnicodeEscapeSequence[+U]
pp$8.regexp_eatRegExpIdentifierStart = function(state) { pp$8.regexp_eatRegExpIdentifierStart = function(state) {
var start = state.pos; var start = state.pos;
var ch = state.current(); var forceU = this.options.ecmaVersion >= 11;
state.advance(); var ch = state.current(forceU);
state.advance(forceU);
if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
ch = state.lastIntValue; ch = state.lastIntValue;
} }
if (isRegExpIdentifierStart(ch)) { if (isRegExpIdentifierStart(ch)) {
@@ -3642,19 +3757,20 @@ function isRegExpIdentifierStart(ch) {
return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */ return isIdentifierStart(ch, true) || ch === 0x24 /* $ */ || ch === 0x5F /* _ */
} }
// RegExpIdentifierPart[U] :: // RegExpIdentifierPart ::
// UnicodeIDContinue // UnicodeIDContinue
// `$` // `$`
// `_` // `_`
// `\` RegExpUnicodeEscapeSequence[?U] // `\` RegExpUnicodeEscapeSequence[+U]
// <ZWNJ> // <ZWNJ>
// <ZWJ> // <ZWJ>
pp$8.regexp_eatRegExpIdentifierPart = function(state) { pp$8.regexp_eatRegExpIdentifierPart = function(state) {
var start = state.pos; var start = state.pos;
var ch = state.current(); var forceU = this.options.ecmaVersion >= 11;
state.advance(); var ch = state.current(forceU);
state.advance(forceU);
if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state)) { if (ch === 0x5C /* \ */ && this.regexp_eatRegExpUnicodeEscapeSequence(state, forceU)) {
ch = state.lastIntValue; ch = state.lastIntValue;
} }
if (isRegExpIdentifierPart(ch)) { if (isRegExpIdentifierPart(ch)) {
@@ -3724,7 +3840,7 @@ pp$8.regexp_eatCharacterEscape = function(state) {
this.regexp_eatCControlLetter(state) || this.regexp_eatCControlLetter(state) ||
this.regexp_eatZero(state) || this.regexp_eatZero(state) ||
this.regexp_eatHexEscapeSequence(state) || this.regexp_eatHexEscapeSequence(state) ||
this.regexp_eatRegExpUnicodeEscapeSequence(state) || this.regexp_eatRegExpUnicodeEscapeSequence(state, false) ||
(!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) || (!state.switchU && this.regexp_eatLegacyOctalEscapeSequence(state)) ||
this.regexp_eatIdentityEscape(state) this.regexp_eatIdentityEscape(state)
) )
@@ -3797,13 +3913,16 @@ function isControlLetter(ch) {
} }
// https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence // https://www.ecma-international.org/ecma-262/8.0/#prod-RegExpUnicodeEscapeSequence
pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) { pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state, forceU) {
if ( forceU === void 0 ) forceU = false;
var start = state.pos; var start = state.pos;
var switchU = forceU || state.switchU;
if (state.eat(0x75 /* u */)) { if (state.eat(0x75 /* u */)) {
if (this.regexp_eatFixedHexDigits(state, 4)) { if (this.regexp_eatFixedHexDigits(state, 4)) {
var lead = state.lastIntValue; var lead = state.lastIntValue;
if (state.switchU && lead >= 0xD800 && lead <= 0xDBFF) { if (switchU && lead >= 0xD800 && lead <= 0xDBFF) {
var leadSurrogateEnd = state.pos; var leadSurrogateEnd = state.pos;
if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) { if (state.eat(0x5C /* \ */) && state.eat(0x75 /* u */) && this.regexp_eatFixedHexDigits(state, 4)) {
var trail = state.lastIntValue; var trail = state.lastIntValue;
@@ -3818,7 +3937,7 @@ pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) {
return true return true
} }
if ( if (
state.switchU && switchU &&
state.eat(0x7B /* { */) && state.eat(0x7B /* { */) &&
this.regexp_eatHexDigits(state) && this.regexp_eatHexDigits(state) &&
state.eat(0x7D /* } */) && state.eat(0x7D /* } */) &&
@@ -3826,7 +3945,7 @@ pp$8.regexp_eatRegExpUnicodeEscapeSequence = function(state) {
) { ) {
return true return true
} }
if (state.switchU) { if (switchU) {
state.raise("Invalid unicode escape"); state.raise("Invalid unicode escape");
} }
state.pos = start; state.pos = start;
@@ -3992,7 +4111,7 @@ pp$8.regexp_eatCharacterClass = function(state) {
if (state.eat(0x5B /* [ */)) { if (state.eat(0x5B /* [ */)) {
state.eat(0x5E /* ^ */); state.eat(0x5E /* ^ */);
this.regexp_classRanges(state); this.regexp_classRanges(state);
if (state.eat(0x5D /* [ */)) { if (state.eat(0x5D /* ] */)) {
return true return true
} }
// Unreachable since it threw "unterminated regular expression" error before. // Unreachable since it threw "unterminated regular expression" error before.
@@ -4040,7 +4159,7 @@ pp$8.regexp_eatClassAtom = function(state) {
} }
var ch = state.current(); var ch = state.current();
if (ch !== 0x5D /* [ */) { if (ch !== 0x5D /* ] */) {
state.lastIntValue = ch; state.lastIntValue = ch;
state.advance(); state.advance();
return true return true
@@ -4219,7 +4338,9 @@ var pp$9 = Parser.prototype;
// Move to the next token // Move to the next token
pp$9.next = function() { pp$9.next = function(ignoreEscapeSequenceInKeyword) {
if (!ignoreEscapeSequenceInKeyword && this.type.keyword && this.containsEsc)
{ this.raiseRecoverable(this.start, "Escape sequence in keyword " + this.type.keyword); }
if (this.options.onToken) if (this.options.onToken)
{ this.options.onToken(new Token(this)); } { this.options.onToken(new Token(this)); }
@@ -4480,6 +4601,18 @@ pp$9.readToken_eq_excl = function(code) { // '=!'
return this.finishOp(code === 61 ? types.eq : types.prefix, 1) return this.finishOp(code === 61 ? types.eq : types.prefix, 1)
}; };
pp$9.readToken_question = function() { // '?'
if (this.options.ecmaVersion >= 11) {
var next = this.input.charCodeAt(this.pos + 1);
if (next === 46) {
var next2 = this.input.charCodeAt(this.pos + 2);
if (next2 < 48 || next2 > 57) { return this.finishOp(types.questionDot, 2) }
}
if (next === 63) { return this.finishOp(types.coalesce, 2) }
}
return this.finishOp(types.question, 1)
};
pp$9.getTokenFromCode = function(code) { pp$9.getTokenFromCode = function(code) {
switch (code) { switch (code) {
// The interpretation of a dot depends on whether it is followed // The interpretation of a dot depends on whether it is followed
@@ -4497,7 +4630,6 @@ pp$9.getTokenFromCode = function(code) {
case 123: ++this.pos; return this.finishToken(types.braceL) case 123: ++this.pos; return this.finishToken(types.braceL)
case 125: ++this.pos; return this.finishToken(types.braceR) case 125: ++this.pos; return this.finishToken(types.braceR)
case 58: ++this.pos; return this.finishToken(types.colon) case 58: ++this.pos; return this.finishToken(types.colon)
case 63: ++this.pos; return this.finishToken(types.question)
case 96: // '`' case 96: // '`'
if (this.options.ecmaVersion < 6) { break } if (this.options.ecmaVersion < 6) { break }
@@ -4547,6 +4679,9 @@ pp$9.getTokenFromCode = function(code) {
case 61: case 33: // '=!' case 61: case 33: // '=!'
return this.readToken_eq_excl(code) return this.readToken_eq_excl(code)
case 63: // '?'
return this.readToken_question()
case 126: // '~' case 126: // '~'
return this.finishOp(types.prefix, 1) return this.finishOp(types.prefix, 1)
} }
@@ -4638,7 +4773,6 @@ pp$9.readNumber = function(startsWithDot) {
if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); } if (!startsWithDot && this.readInt(10) === null) { this.raise(start, "Invalid number"); }
var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48; var octal = this.pos - start >= 2 && this.input.charCodeAt(start) === 48;
if (octal && this.strict) { this.raise(start, "Invalid number"); } if (octal && this.strict) { this.raise(start, "Invalid number"); }
if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
var next = this.input.charCodeAt(this.pos); var next = this.input.charCodeAt(this.pos);
if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) { if (!octal && !startsWithDot && this.options.ecmaVersion >= 11 && next === 110) {
var str$1 = this.input.slice(start, this.pos); var str$1 = this.input.slice(start, this.pos);
@@ -4647,6 +4781,7 @@ pp$9.readNumber = function(startsWithDot) {
if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); } if (isIdentifierStart(this.fullCharCodeAtPos())) { this.raise(this.pos, "Identifier directly after number"); }
return this.finishToken(types.num, val$1) return this.finishToken(types.num, val$1)
} }
if (octal && /[89]/.test(this.input.slice(start, this.pos))) { octal = false; }
if (next === 46 && !octal) { // '.' if (next === 46 && !octal) { // '.'
++this.pos; ++this.pos;
this.readInt(10); this.readInt(10);
@@ -4821,6 +4956,18 @@ pp$9.readEscapedChar = function(inTemplate) {
case 10: // ' \n' case 10: // ' \n'
if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; } if (this.options.locations) { this.lineStart = this.pos; ++this.curLine; }
return "" return ""
case 56:
case 57:
if (inTemplate) {
var codePos = this.pos - 1;
this.invalidStringToken(
codePos,
"Invalid escape sequence in template string"
);
return null
}
default: default:
if (ch >= 48 && ch <= 55) { if (ch >= 48 && ch <= 55) {
var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0]; var octalStr = this.input.substr(this.pos - 1, 3).match(/^[0-7]+/)[0];
@@ -4900,7 +5047,6 @@ pp$9.readWord = function() {
var word = this.readWord1(); var word = this.readWord1();
var type = types.name; var type = types.name;
if (this.keywords.test(word)) { if (this.keywords.test(word)) {
if (this.containsEsc) { this.raiseRecoverable(this.start, "Escape sequence in keyword " + word); }
type = keywords$1[word]; type = keywords$1[word];
} }
return this.finishToken(type, word) return this.finishToken(type, word)
@@ -4908,7 +5054,7 @@ pp$9.readWord = function() {
// Acorn is a tiny, fast JavaScript parser written in JavaScript. // Acorn is a tiny, fast JavaScript parser written in JavaScript.
var version = "6.4.0"; var version = "7.3.1";
Parser.acorn = { Parser.acorn = {
Parser: Parser, Parser: Parser,

2
node_modules/acorn/dist/acorn.mjs.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import * as acorn from "./acorn";
export = acorn;

25
node_modules/acorn/package.json generated vendored
View File

@@ -1,28 +1,28 @@
{ {
"_from": "acorn@6.4.1", "_from": "acorn@^7.1.1",
"_id": "acorn@6.4.1", "_id": "acorn@7.3.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==", "_integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==",
"_location": "/acorn", "_location": "/acorn",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "version", "type": "range",
"registry": true, "registry": true,
"raw": "acorn@6.4.1", "raw": "acorn@^7.1.1",
"name": "acorn", "name": "acorn",
"escapedName": "acorn", "escapedName": "acorn",
"rawSpec": "6.4.1", "rawSpec": "^7.1.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "6.4.1" "fetchSpec": "^7.1.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/acorn-globals", "/acorn-globals",
"/jsdom" "/jsdom"
], ],
"_resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz", "_resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz",
"_shasum": "531e58ba3f51b9dacb9a6646ca4debf5b14ca474", "_shasum": "85010754db53c3fbaf3b9ea3e083aa5c5d147ffd",
"_spec": "acorn@6.4.1", "_spec": "acorn@^7.1.1",
"_where": "/home/s2/Code/minifyfromhtml/node_modules/jsdom", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\jsdom",
"bin": { "bin": {
"acorn": "bin/acorn" "acorn": "bin/acorn"
}, },
@@ -63,5 +63,6 @@
"scripts": { "scripts": {
"prepare": "cd ..; npm run build:main && npm run build:bin" "prepare": "cd ..; npm run build:main && npm run build:bin"
}, },
"version": "6.4.1" "types": "dist/acorn.d.ts",
"version": "7.3.1"
} }

240
node_modules/ajv/README.md generated vendored
View File

@@ -1,22 +1,63 @@
<img align="right" alt="Ajv logo" width="160" src="http://epoberezkin.github.io/ajv/images/ajv_logo.png"> <img align="right" alt="Ajv logo" width="160" src="https://ajv.js.org/images/ajv_logo.png">
# Ajv: Another JSON Schema Validator # Ajv: Another JSON Schema Validator
The fastest JSON Schema validator for Node.js and browser. Supports draft-04/06/07. The fastest JSON Schema validator for Node.js and browser. Supports draft-04/06/07.
[![Build Status](https://travis-ci.org/epoberezkin/ajv.svg?branch=master)](https://travis-ci.org/epoberezkin/ajv) [![Build Status](https://travis-ci.org/ajv-validator/ajv.svg?branch=master)](https://travis-ci.org/ajv-validator/ajv)
[![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv) [![npm](https://img.shields.io/npm/v/ajv.svg)](https://www.npmjs.com/package/ajv)
[![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv) [![npm downloads](https://img.shields.io/npm/dm/ajv.svg)](https://www.npmjs.com/package/ajv)
[![Coverage Status](https://coveralls.io/repos/epoberezkin/ajv/badge.svg?branch=master&service=github)](https://coveralls.io/github/epoberezkin/ajv?branch=master) [![Coverage Status](https://coveralls.io/repos/github/ajv-validator/ajv/badge.svg?branch=master)](https://coveralls.io/github/ajv-validator/ajv?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/epoberezkin/ajv.svg)](https://greenkeeper.io/)
[![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv) [![Gitter](https://img.shields.io/gitter/room/ajv-validator/ajv.svg)](https://gitter.im/ajv-validator/ajv)
[![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)](https://github.com/sponsors/epoberezkin)
## Please [sponsor Ajv development](https://github.com/sponsors/epoberezkin)
I will get straight to the point - I need your support to ensure that the development of Ajv continues.
I have developed Ajv for 5 years in my free time, but it is not sustainable. I'd appreciate if you consider supporting its further development with donations:
- [GitHub sponsors page](https://github.com/sponsors/epoberezkin) (GitHub will match it)
- [Ajv Open Collective](https://opencollective.com/ajv)
There are many small and large improvements that are long due, including the support of the next versions of JSON Schema specification, improving website and documentation, and making Ajv more modular and maintainable to address its limitations - what Ajv needs to evolve is much more than what I can contribute in my free time.
I would also really appreciate any advice you could give on how to raise funds for Ajv development - whether some suitable open-source fund I could apply to or some sponsor I should approach.
Since 2015 Ajv has become widely used, thanks to your help and contributions:
- **90** contributors 🏗
- **5,000** dependent npm packages ⚙️
- **7,000** github stars, from GitHub users [all over the world](https://www.google.com/maps/d/u/0/viewer?mid=1MGRV8ciFUGIbO1l0EKFWNJGYE7iSkDxP&ll=-3.81666561775622e-14%2C4.821737100000007&z=2) ⭐️
- **5,000,000** dependent repositories on GitHub 🚀
- **120,000,000** npm downloads per month! 💯
I believe it would benefit all Ajv users to help put together the fund that will be used for its further development - it would allow to bring some additional maintainers to the project.
Thank you
#### Open Collective sponsors
<a href="https://opencollective.com/ajv"><img src="https://opencollective.com/ajv/individuals.svg?width=890"></a>
<a href="https://opencollective.com/ajv/organization/0/website"><img src="https://opencollective.com/ajv/organization/0/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/1/website"><img src="https://opencollective.com/ajv/organization/1/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/2/website"><img src="https://opencollective.com/ajv/organization/2/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/3/website"><img src="https://opencollective.com/ajv/organization/3/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/4/website"><img src="https://opencollective.com/ajv/organization/4/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/5/website"><img src="https://opencollective.com/ajv/organization/5/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/6/website"><img src="https://opencollective.com/ajv/organization/6/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/7/website"><img src="https://opencollective.com/ajv/organization/7/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/8/website"><img src="https://opencollective.com/ajv/organization/8/avatar.svg"></a>
<a href="https://opencollective.com/ajv/organization/9/website"><img src="https://opencollective.com/ajv/organization/9/avatar.svg"></a>
## Using version 6 ## Using version 6
[JSON Schema draft-07](http://json-schema.org/latest/json-schema-validation.html) is published. [JSON Schema draft-07](http://json-schema.org/latest/json-schema-validation.html) is published.
[Ajv version 6.0.0](https://github.com/epoberezkin/ajv/releases/tag/v6.0.0) that supports draft-07 is released. It may require either migrating your schemas or updating your code (to continue using draft-04 and v5 schemas, draft-06 schemas will be supported without changes). [Ajv version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0) that supports draft-07 is released. It may require either migrating your schemas or updating your code (to continue using draft-04 and v5 schemas, draft-06 schemas will be supported without changes).
__Please note__: To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance: __Please note__: To use Ajv with draft-06 schemas you need to explicitly add the meta-schema to the validator instance:
@@ -39,8 +80,9 @@ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
- [Performance](#performance) - [Performance](#performance)
- [Features](#features) - [Features](#features)
- [Getting started](#getting-started) - [Getting started](#getting-started)
- [Frequently Asked Questions](https://github.com/epoberezkin/ajv/blob/master/FAQ.md) - [Frequently Asked Questions](https://github.com/ajv-validator/ajv/blob/master/FAQ.md)
- [Using in browser](#using-in-browser) - [Using in browser](#using-in-browser)
- [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp)
- [Command line interface](#command-line-interface) - [Command line interface](#command-line-interface)
- Validation - Validation
- [Keywords](#validation-keywords) - [Keywords](#validation-keywords)
@@ -69,7 +111,8 @@ ajv.addMetaSchema(require('ajv/lib/refs/json-schema-draft-04.json'));
- [Plugins](#plugins) - [Plugins](#plugins)
- [Related packages](#related-packages) - [Related packages](#related-packages)
- [Some packages using Ajv](#some-packages-using-ajv) - [Some packages using Ajv](#some-packages-using-ajv)
- [Tests, Contributing, History, Support, License](#tests) - [Tests, Contributing, Changes history](#tests)
- [Support, Code of conduct, License](#open-source-software-support)
## Performance ## Performance
@@ -92,24 +135,24 @@ Performance of different validators by [json-schema-benchmark](https://github.co
## Features ## Features
- Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) and draft-04 standards: - Ajv implements full JSON Schema [draft-06/07](http://json-schema.org/) and draft-04 standards:
- all validation keywords (see [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md)) - all validation keywords (see [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md))
- full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available) - full support of remote refs (remote schemas have to be added with `addSchema` or compiled to be available)
- support of circular references between schemas - support of circular references between schemas
- correct string lengths for strings with unicode pairs (can be turned off) - correct string lengths for strings with unicode pairs (can be turned off)
- [formats](#formats) defined by JSON Schema draft-07 standard and custom formats (can be turned off) - [formats](#formats) defined by JSON Schema draft-07 standard and custom formats (can be turned off)
- [validates schemas against meta-schema](#api-validateschema) - [validates schemas against meta-schema](#api-validateschema)
- supports [browsers](#using-in-browser) and Node.js 0.10-8.x - supports [browsers](#using-in-browser) and Node.js 0.10-14.x
- [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation - [asynchronous loading](#asynchronous-schema-compilation) of referenced schemas during compilation
- "All errors" validation mode with [option allErrors](#options) - "All errors" validation mode with [option allErrors](#options)
- [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages - [error messages with parameters](#validation-errors) describing error reasons to allow creating custom error messages
- i18n error messages support with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) package - i18n error messages support with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package
- [filtering data](#filtering-data) from additional properties - [filtering data](#filtering-data) from additional properties
- [assigning defaults](#assigning-defaults) to missing properties and items - [assigning defaults](#assigning-defaults) to missing properties and items
- [coercing data](#coercing-data-types) to the types specified in `type` keywords - [coercing data](#coercing-data-types) to the types specified in `type` keywords
- [custom keywords](#defining-custom-keywords) - [custom keywords](#defining-custom-keywords)
- draft-06/07 keywords `const`, `contains`, `propertyNames` and `if/then/else` - draft-06/07 keywords `const`, `contains`, `propertyNames` and `if/then/else`
- draft-06 boolean schemas (`true`/`false` as a schema to always pass/fail). - draft-06 boolean schemas (`true`/`false` as a schema to always pass/fail).
- keywords `switch`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) with [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package - keywords `switch`, `patternRequired`, `formatMaximum` / `formatMinimum` and `formatExclusiveMaximum` / `formatExclusiveMinimum` from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) with [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package
- [$data reference](#data-reference) to use values from the validated data as values for the schema keywords - [$data reference](#data-reference) to use values from the validated data as values for the schema keywords
- [asynchronous validation](#asynchronous-validation) of custom formats and keywords - [asynchronous validation](#asynchronous-validation) of custom formats and keywords
@@ -131,7 +174,11 @@ Try it in the Node.js REPL: https://tonicdev.com/npm/ajv
The fastest validation call: The fastest validation call:
```javascript ```javascript
// Node.js require:
var Ajv = require('ajv'); var Ajv = require('ajv');
// or ESM/TypeScript import
import Ajv from 'ajv';
var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true} var ajv = new Ajv(); // options can be passed, e.g. {allErrors: true}
var validate = ajv.compile(schema); var validate = ajv.compile(schema);
var valid = validate(data); var valid = validate(data);
@@ -165,6 +212,10 @@ The best performance is achieved when using compiled functions returned by `comp
__Please note__: every time a validation function or `ajv.validate` are called `errors` property is overwritten. You need to copy `errors` array reference to another variable if you want to use it later (e.g., in the callback). See [Validation errors](#validation-errors) __Please note__: every time a validation function or `ajv.validate` are called `errors` property is overwritten. You need to copy `errors` array reference to another variable if you want to use it later (e.g., in the callback). See [Validation errors](#validation-errors)
__Note for TypeScript users__: `ajv` provides its own TypeScript declarations
out of the box, so you don't need to install the deprecated `@types/ajv`
module.
## Using in browser ## Using in browser
@@ -185,21 +236,31 @@ Ajv is tested with these browsers:
[![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin) [![Sauce Test Status](https://saucelabs.com/browser-matrix/epoberezkin.svg)](https://saucelabs.com/u/epoberezkin)
__Please note__: some frameworks, e.g. Dojo, may redefine global require in such way that is not compatible with CommonJS module format. In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue [#234](https://github.com/epoberezkin/ajv/issues/234)). __Please note__: some frameworks, e.g. Dojo, may redefine global require in such way that is not compatible with CommonJS module format. In such case Ajv bundle has to be loaded before the framework and then you can use global Ajv (see issue [#234](https://github.com/ajv-validator/ajv/issues/234)).
### Ajv and Content Security Policies (CSP)
If you're using Ajv to compile a schema (the typical use) in a browser document that is loaded with a Content Security Policy (CSP), that policy will require a `script-src` directive that includes the value `'unsafe-eval'`.
:warning: NOTE, however, that `unsafe-eval` is NOT recommended in a secure CSP[[1]](https://developer.chrome.com/extensions/contentSecurityPolicy#relaxing-eval), as it has the potential to open the document to cross-site scripting (XSS) attacks.
In order to make use of Ajv without easing your CSP, you can [pre-compile a schema using the CLI](https://github.com/ajv-validator/ajv-cli#compile-schemas). This will transpile the schema JSON into a JavaScript file that exports a `validate` function that works simlarly to a schema compiled at runtime.
Note that pre-compilation of schemas is performed using [ajv-pack](https://github.com/ajv-validator/ajv-pack) and there are [some limitations to the schema features it can compile](https://github.com/ajv-validator/ajv-pack#limitations). A successfully pre-compiled schema is equivalent to the same schema compiled at runtime.
## Command line interface ## Command line interface
CLI is available as a separate npm package [ajv-cli](https://github.com/jessedc/ajv-cli). It supports: CLI is available as a separate npm package [ajv-cli](https://github.com/ajv-validator/ajv-cli). It supports:
- compiling JSON Schemas to test their validity - compiling JSON Schemas to test their validity
- BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/epoberezkin/ajv-pack)) - BETA: generating standalone module exporting a validation function to be used without Ajv (using [ajv-pack](https://github.com/ajv-validator/ajv-pack))
- migrate schemas to draft-07 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate)) - migrate schemas to draft-07 (using [json-schema-migrate](https://github.com/epoberezkin/json-schema-migrate))
- validating data file(s) against JSON Schema - validating data file(s) against JSON Schema
- testing expected validity of data against JSON Schema - testing expected validity of data against JSON Schema
- referenced schemas - referenced schemas
- custom meta-schemas - custom meta-schemas
- files in JSON and JavaScript format - files in JSON, JSON5, YAML, and JavaScript format
- all Ajv options - all Ajv options
- reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format - reporting changes in data after validation in [JSON-patch](https://tools.ietf.org/html/rfc6902) format
@@ -208,20 +269,20 @@ CLI is available as a separate npm package [ajv-cli](https://github.com/jessedc/
Ajv supports all validation keywords from draft-07 of JSON Schema standard: Ajv supports all validation keywords from draft-07 of JSON Schema standard:
- [type](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#type) - [type](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#type)
- [for numbers](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-numbers) - maximum, minimum, exclusiveMaximum, exclusiveMinimum, multipleOf - [for numbers](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-numbers) - maximum, minimum, exclusiveMaximum, exclusiveMinimum, multipleOf
- [for strings](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-strings) - maxLength, minLength, pattern, format - [for strings](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-strings) - maxLength, minLength, pattern, format
- [for arrays](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems, [contains](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#contains) - [for arrays](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-arrays) - maxItems, minItems, uniqueItems, items, additionalItems, [contains](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#contains)
- [for objects](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minProperties, required, properties, patternProperties, additionalProperties, dependencies, [propertyNames](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#propertynames) - [for objects](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-objects) - maxProperties, minProperties, required, properties, patternProperties, additionalProperties, dependencies, [propertyNames](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#propertynames)
- [for all types](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, [const](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#const) - [for all types](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#keywords-for-all-types) - enum, [const](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#const)
- [compound keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#compound-keywords) - not, oneOf, anyOf, allOf, [if/then/else](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#ifthenelse) - [compound keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#compound-keywords) - not, oneOf, anyOf, allOf, [if/then/else](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#ifthenelse)
With [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package Ajv also supports validation keywords from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON Schema standard: With [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package Ajv also supports validation keywords from [JSON Schema extension proposals](https://github.com/json-schema/json-schema/wiki/v5-Proposals) for JSON Schema standard:
- [patternRequired](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#patternrequired-proposed) - like `required` but with patterns that some property should match. - [patternRequired](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#patternrequired-proposed) - like `required` but with patterns that some property should match.
- [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-proposed) - setting limits for date, time, etc. - [formatMaximum, formatMinimum, formatExclusiveMaximum, formatExclusiveMinimum](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md#formatmaximum--formatminimum-and-exclusiveformatmaximum--exclusiveformatminimum-proposed) - setting limits for date, time, etc.
See [JSON Schema validation keywords](https://github.com/epoberezkin/ajv/blob/master/KEYWORDS.md) for more details. See [JSON Schema validation keywords](https://github.com/ajv-validator/ajv/blob/master/KEYWORDS.md) for more details.
## Annotation keywords ## Annotation keywords
@@ -265,13 +326,13 @@ The following formats are implemented for string validation with "format" keywor
__Please note__: JSON Schema draft-07 also defines formats `iri`, `iri-reference`, `idn-hostname` and `idn-email` for URLs, hostnames and emails with international characters. Ajv does not implement these formats. If you create Ajv plugin that implements them please make a PR to mention this plugin here. __Please note__: JSON Schema draft-07 also defines formats `iri`, `iri-reference`, `idn-hostname` and `idn-email` for URLs, hostnames and emails with international characters. Ajv does not implement these formats. If you create Ajv plugin that implements them please make a PR to mention this plugin here.
There are two modes of format validation: `fast` and `full`. This mode affects formats `date`, `time`, `date-time`, `uri`, `uri-reference`, `email`, and `hostname`. See [Options](#options) for details. There are two modes of format validation: `fast` and `full`. This mode affects formats `date`, `time`, `date-time`, `uri`, `uri-reference`, and `email`. See [Options](#options) for details.
You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method. You can add additional formats and replace any of the formats above using [addFormat](#api-addformat) method.
The option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can whitelist specific format(s) to be ignored. See [Options](#options) for details. The option `unknownFormats` allows changing the default behaviour when an unknown format is encountered. In this case Ajv can either fail schema compilation (default) or ignore it (default in versions before 5.0.0). You also can whitelist specific format(s) to be ignored. See [Options](#options) for details.
You can find regular expressions used for format validation and the sources that were used in [formats.js](https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js). You can find regular expressions used for format validation and the sources that were used in [formats.js](https://github.com/ajv-validator/ajv/blob/master/lib/compile/formats.js).
## <a name="ref"></a>Combining schemas with $ref ## <a name="ref"></a>Combining schemas with $ref
@@ -328,7 +389,7 @@ __Please note__:
## $data reference ## $data reference
With `$data` option you can use values from the validated data as the values for the schema keywords. See [proposal](https://github.com/json-schema/json-schema/wiki/$data-(v5-proposal)) for more information about how it works. With `$data` option you can use values from the validated data as the values for the schema keywords. See [proposal](https://github.com/json-schema-org/json-schema-spec/issues/51) for more information about how it works.
`$data` reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems. `$data` reference is supported in the keywords: const, enum, format, maximum/minimum, exclusiveMaximum / exclusiveMinimum, maxLength / minLength, maxItems / minItems, maxProperties / minProperties, formatMaximum / formatMinimum, formatExclusiveMaximum / formatExclusiveMinimum, multipleOf, pattern, required, uniqueItems.
@@ -380,7 +441,7 @@ var validData = {
## $merge and $patch keywords ## $merge and $patch keywords
With the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON Schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902). With the package [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) you can use the keywords `$merge` and `$patch` that allow extending JSON Schemas with patches using formats [JSON Merge Patch (RFC 7396)](https://tools.ietf.org/html/rfc7396) and [JSON Patch (RFC 6902)](https://tools.ietf.org/html/rfc6902).
To add keywords `$merge` and `$patch` to Ajv instance use this code: To add keywords `$merge` and `$patch` to Ajv instance use this code:
@@ -439,7 +500,7 @@ The schemas above are equivalent to this schema:
The properties `source` and `with` in the keywords `$merge` and `$patch` can use absolute or relative `$ref` to point to other schemas previously added to the Ajv instance or to the fragments of the current schema. The properties `source` and `with` in the keywords `$merge` and `$patch` can use absolute or relative `$ref` to point to other schemas previously added to the Ajv instance or to the fragments of the current schema.
See the package [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) for more information. See the package [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) for more information.
## Defining custom keywords ## Defining custom keywords
@@ -487,9 +548,9 @@ console.log(validate(2)); // false
console.log(validate(4)); // false console.log(validate(4)); // false
``` ```
Several custom keywords (typeof, instanceof, range and propertyNames) are defined in [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package - they can be used for your schemas and as a starting point for your own custom keywords. Several custom keywords (typeof, instanceof, range and propertyNames) are defined in [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package - they can be used for your schemas and as a starting point for your own custom keywords.
See [Defining custom keywords](https://github.com/epoberezkin/ajv/blob/master/CUSTOM.md) for more details. See [Defining custom keywords](https://github.com/ajv-validator/ajv/blob/master/CUSTOM.md) for more details.
## Asynchronous schema compilation ## Asynchronous schema compilation
@@ -588,7 +649,7 @@ validate({ userId: 1, postId: 19 })
### Using transpilers with asynchronous validation functions. ### Using transpilers with asynchronous validation functions.
[ajv-async](https://github.com/epoberezkin/ajv-async) uses [nodent](https://github.com/MatAtBread/nodent) to transpile async functions. To use another transpiler you should separately install it (or load its bundle in the browser). [ajv-async](https://github.com/ajv-validator/ajv-async) uses [nodent](https://github.com/MatAtBread/nodent) to transpile async functions. To use another transpiler you should separately install it (or load its bundle in the browser).
#### Using nodent #### Using nodent
@@ -632,7 +693,7 @@ Ajv treats JSON schemas as trusted as your application code. This security model
If your schemas are received from untrusted sources (or generated from untrusted data) there are several scenarios you need to prevent: If your schemas are received from untrusted sources (or generated from untrusted data) there are several scenarios you need to prevent:
- compiling schemas can cause stack overflow (if they are too deep) - compiling schemas can cause stack overflow (if they are too deep)
- compiling schemas can be slow (e.g. [#557](https://github.com/epoberezkin/ajv/issues/557)) - compiling schemas can be slow (e.g. [#557](https://github.com/ajv-validator/ajv/issues/557))
- validating certain data can be slow - validating certain data can be slow
It is difficult to predict all the scenarios, but at the very least it may help to limit the size of untrusted schemas (e.g. limit JSON string length) and also the maximum schema object depth (that can be high for relatively small JSON strings). You also may want to mitigate slow regular expressions in `pattern` and `patternProperties` keywords. It is difficult to predict all the scenarios, but at the very least it may help to limit the size of untrusted schemas (e.g. limit JSON string length) and also the maximum schema object depth (that can be high for relatively small JSON strings). You also may want to mitigate slow regular expressions in `pattern` and `patternProperties` keywords.
@@ -642,7 +703,7 @@ Regardless the measures you take, using untrusted schemas increases security ris
##### Circular references in JavaScript objects ##### Circular references in JavaScript objects
Ajv does not support schemas and validated data that have circular references in objects. See [issue #802](https://github.com/epoberezkin/ajv/issues/802). Ajv does not support schemas and validated data that have circular references in objects. See [issue #802](https://github.com/ajv-validator/ajv/issues/802).
An attempt to compile such schemas or validate such data would cause stack overflow (or will not complete in case of asynchronous validation). Depending on the parser you use, untrusted data can lead to circular references. An attempt to compile such schemas or validate such data would cause stack overflow (or will not complete in case of asynchronous validation). Depending on the parser you use, untrusted data can lead to circular references.
@@ -657,7 +718,7 @@ Some keywords in JSON Schemas can lead to very slow validation for certain data.
__Please note__: The suggestions above to prevent slow validation would only work if you do NOT use `allErrors: true` in production code (using it would continue validation after validation errors). __Please note__: The suggestions above to prevent slow validation would only work if you do NOT use `allErrors: true` in production code (using it would continue validation after validation errors).
You can validate your JSON schemas against [this meta-schema](https://github.com/epoberezkin/ajv/blob/master/lib/refs/json-schema-secure.json) to check that these recommendations are followed: You can validate your JSON schemas against [this meta-schema](https://github.com/ajv-validator/ajv/blob/master/lib/refs/json-schema-secure.json) to check that these recommendations are followed:
```javascript ```javascript
const isSchemaSecure = ajv.compile(require('ajv/lib/refs/json-schema-secure.json')); const isSchemaSecure = ajv.compile(require('ajv/lib/refs/json-schema-secure.json'));
@@ -672,13 +733,17 @@ isSchemaSecure(schema2); // true
__Please note__: following all these recommendation is not a guarantee that validation of untrusted data is safe - it can still lead to some undesirable results. __Please note__: following all these recommendation is not a guarantee that validation of untrusted data is safe - it can still lead to some undesirable results.
##### Content Security Policies (CSP)
See [Ajv and Content Security Policies (CSP)](#ajv-and-content-security-policies-csp)
## ReDoS attack ## ReDoS attack
Certain regular expressions can lead to the exponential evaluation time even with relatively short strings. Certain regular expressions can lead to the exponential evaluation time even with relatively short strings.
Please assess the regular expressions you use in the schemas on their vulnerability to this attack - see [safe-regex](https://github.com/substack/safe-regex), for example. Please assess the regular expressions you use in the schemas on their vulnerability to this attack - see [safe-regex](https://github.com/substack/safe-regex), for example.
__Please note__: some formats that Ajv implements use [regular expressions](https://github.com/epoberezkin/ajv/blob/master/lib/compile/formats.js) that can be vulnerable to ReDoS attack, so if you use Ajv to validate data from untrusted sources __it is strongly recommended__ to consider the following: __Please note__: some formats that Ajv implements use [regular expressions](https://github.com/ajv-validator/ajv/blob/master/lib/compile/formats.js) that can be vulnerable to ReDoS attack, so if you use Ajv to validate data from untrusted sources __it is strongly recommended__ to consider the following:
- making assessment of "format" implementations in Ajv. - making assessment of "format" implementations in Ajv.
- using `format: 'fast'` option that simplifies some of the regular expressions (although it does not guarantee that they are safe). - using `format: 'fast'` option that simplifies some of the regular expressions (although it does not guarantee that they are safe).
@@ -758,7 +823,7 @@ The intention of the schema above is to allow objects with either the string pro
With the option `removeAdditional: true` the validation will pass for the object `{ "foo": "abc"}` but will fail for the object `{"bar": 1}`. It happens because while the first subschema in `oneOf` is validated, the property `bar` is removed because it is an additional property according to the standard (because it is not included in `properties` keyword in the same schema). With the option `removeAdditional: true` the validation will pass for the object `{ "foo": "abc"}` but will fail for the object `{"bar": 1}`. It happens because while the first subschema in `oneOf` is validated, the property `bar` is removed because it is an additional property according to the standard (because it is not included in `properties` keyword in the same schema).
While this behaviour is unexpected (issues [#129](https://github.com/epoberezkin/ajv/issues/129), [#134](https://github.com/epoberezkin/ajv/issues/134)), it is correct. To have the expected behaviour (both objects are allowed and additional properties are removed) the schema has to be refactored in this way: While this behaviour is unexpected (issues [#129](https://github.com/ajv-validator/ajv/issues/129), [#134](https://github.com/ajv-validator/ajv/issues/134)), it is correct. To have the expected behaviour (both objects are allowed and additional properties are removed) the schema has to be refactored in this way:
```json ```json
{ {
@@ -832,7 +897,7 @@ console.log(data); // [ 1, "foo" ]
`default` keywords in other cases are ignored: `default` keywords in other cases are ignored:
- not in `properties` or `items` subschemas - not in `properties` or `items` subschemas
- in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/epoberezkin/ajv/issues/42)) - in schemas inside `anyOf`, `oneOf` and `not` (see [#42](https://github.com/ajv-validator/ajv/issues/42))
- in `if` subschema of `switch` keyword - in `if` subschema of `switch` keyword
- in schemas generated by custom macro keywords - in schemas generated by custom macro keywords
@@ -890,7 +955,7 @@ console.log(data); // { "foo": [1], "bar": false }
The coercion rules, as you can see from the example, are different from JavaScript both to validate user input as expected and to have the coercion reversible (to correctly validate cases where different types are defined in subschemas of "anyOf" and other compound keywords). The coercion rules, as you can see from the example, are different from JavaScript both to validate user input as expected and to have the coercion reversible (to correctly validate cases where different types are defined in subschemas of "anyOf" and other compound keywords).
See [Coercion rules](https://github.com/epoberezkin/ajv/blob/master/COERCION.md) for details. See [Coercion rules](https://github.com/ajv-validator/ajv/blob/master/COERCION.md) for details.
## API ## API
@@ -1008,9 +1073,9 @@ Function should return validation result as `true` or `false`.
If object is passed it should have properties `validate`, `compare` and `async`: If object is passed it should have properties `validate`, `compare` and `async`:
- _validate_: a string, RegExp or a function as described above. - _validate_: a string, RegExp or a function as described above.
- _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) package). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal. - _compare_: an optional comparison function that accepts two strings and compares them according to the format meaning. This function is used with keywords `formatMaximum`/`formatMinimum` (defined in [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) package). It should return `1` if the first value is bigger than the second value, `-1` if it is smaller and `0` if it is equal.
- _async_: an optional `true` value if `validate` is an asynchronous function; in this case it should return a promise that resolves with a value `true` or `false`. - _async_: an optional `true` value if `validate` is an asynchronous function; in this case it should return a promise that resolves with a value `true` or `false`.
- _type_: an optional type of data that the format applies to. It can be `"string"` (default) or `"number"` (see https://github.com/epoberezkin/ajv/issues/291#issuecomment-259923858). If the type of data is different, the validation will pass. - _type_: an optional type of data that the format applies to. It can be `"string"` (default) or `"number"` (see https://github.com/ajv-validator/ajv/issues/291#issuecomment-259923858). If the type of data is different, the validation will pass.
Custom formats can be also added via `formats` option. Custom formats can be also added via `formats` option.
@@ -1106,6 +1171,7 @@ Defaults:
// strict mode options // strict mode options
strictDefaults: false, strictDefaults: false,
strictKeywords: false, strictKeywords: false,
strictNumbers: false,
// asynchronous validation options: // asynchronous validation options:
transpile: undefined, // requires ajv-async package transpile: undefined, // requires ajv-async package
// advanced options: // advanced options:
@@ -1120,7 +1186,7 @@ Defaults:
errorDataPath: 'object', // deprecated errorDataPath: 'object', // deprecated
messages: true, messages: true,
sourceCode: false, sourceCode: false,
processCode: undefined, // function (str: string): string {} processCode: undefined, // function (str: string, schema: object): string {}
cache: new Cache, cache: new Cache,
serialize: undefined serialize: undefined
} }
@@ -1144,12 +1210,13 @@ Defaults:
- `"full"` - more restrictive and slow validation. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode. - `"full"` - more restrictive and slow validation. E.g., 25:00:00 and 2015/14/33 will be invalid time and date in 'full' mode but it will be valid in 'fast' mode.
- `false` - ignore all format keywords. - `false` - ignore all format keywords.
- _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method. - _formats_: an object with custom formats. Keys and values will be passed to `addFormat` method.
- _keywords_: an object with custom keywords. Keys and values will be passed to `addKeyword` method.
- _unknownFormats_: handling of unknown formats. Option values: - _unknownFormats_: handling of unknown formats. Option values:
- `true` (default) - if an unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [$data reference](#data-reference) and it is unknown the validation will fail. - `true` (default) - if an unknown format is encountered the exception is thrown during schema compilation. If `format` keyword value is [$data reference](#data-reference) and it is unknown the validation will fail.
- `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if another unknown format is used. If `format` keyword value is [$data reference](#data-reference) and it is not in this array the validation will fail. - `[String]` - an array of unknown format names that will be ignored. This option can be used to allow usage of third party schemas with format(s) for which you don't have definitions, but still fail if another unknown format is used. If `format` keyword value is [$data reference](#data-reference) and it is not in this array the validation will fail.
- `"ignore"` - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. This behaviour is required by JSON Schema specification. - `"ignore"` - to log warning during schema compilation and always pass validation (the default behaviour in versions before 5.0.0). This option is not recommended, as it allows to mistype format name and it won't be validated without any error message. This behaviour is required by JSON Schema specification.
- _schemas_: an array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method `addSchema(value, key)` will be called for each schema in this object. - _schemas_: an array or object of schemas that will be added to the instance. In case you pass the array the schemas must have IDs in them. When the object is passed the method `addSchema(value, key)` will be called for each schema in this object.
- _logger_: sets the logging method. Default is the global `console` object that should have methods `log`, `warn` and `error`. Option values: - _logger_: sets the logging method. Default is the global `console` object that should have methods `log`, `warn` and `error`. See [Error logging](#error-logging). Option values:
- custom logger - it should have methods `log`, `warn` and `error`. If any of these methods is missing an exception will be thrown. - custom logger - it should have methods `log`, `warn` and `error`. If any of these methods is missing an exception will be thrown.
- `false` - logging is disabled. - `false` - logging is disabled.
@@ -1183,7 +1250,7 @@ Defaults:
- `true` - insert defaults by value (object literal is used). - `true` - insert defaults by value (object literal is used).
- `"empty"` - in addition to missing or undefined, use defaults for properties and items that are equal to `null` or `""` (an empty string). - `"empty"` - in addition to missing or undefined, use defaults for properties and items that are equal to `null` or `""` (an empty string).
- `"shared"` (deprecated) - insert defaults by reference. If the default is an object, it will be shared by all instances of validated data. If you modify the inserted default in the validated data, it will be modified in the schema as well. - `"shared"` (deprecated) - insert defaults by reference. If the default is an object, it will be shared by all instances of validated data. If you modify the inserted default in the validated data, it will be modified in the schema as well.
- _coerceTypes_: change data type of data to match `type` keyword. See the example in [Coercing data types](#coercing-data-types) and [coercion rules](https://github.com/epoberezkin/ajv/blob/master/COERCION.md). Option values: - _coerceTypes_: change data type of data to match `type` keyword. See the example in [Coercing data types](#coercing-data-types) and [coercion rules](https://github.com/ajv-validator/ajv/blob/master/COERCION.md). Option values:
- `false` (default) - no type coercion. - `false` (default) - no type coercion.
- `true` - coerce scalar data types. - `true` - coerce scalar data types.
- `"array"` - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema). - `"array"` - in addition to coercions between scalar types, coerce scalar data to an array with one element and vice versa (as required by the schema).
@@ -1199,11 +1266,13 @@ Defaults:
- `false` (default) - unknown keywords are not reported - `false` (default) - unknown keywords are not reported
- `true` - if an unknown keyword is present, throw an error - `true` - if an unknown keyword is present, throw an error
- `"log"` - if an unknown keyword is present, log warning - `"log"` - if an unknown keyword is present, log warning
- _strictNumbers_: validate numbers strictly, failing validation for NaN and Infinity. Option values:
- `false` (default) - NaN or Infinity will pass validation for numeric types
- `true` - NaN or Infinity will not pass validation for numeric types
##### Asynchronous validation options ##### Asynchronous validation options
- _transpile_: Requires [ajv-async](https://github.com/epoberezkin/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values: - _transpile_: Requires [ajv-async](https://github.com/ajv-validator/ajv-async) package. It determines whether Ajv transpiles compiled asynchronous validation function. Option values:
- `undefined` (default) - transpile with [nodent](https://github.com/MatAtBread/nodent) if async functions are not supported. - `undefined` (default) - transpile with [nodent](https://github.com/MatAtBread/nodent) if async functions are not supported.
- `true` - always transpile with nodent. - `true` - always transpile with nodent.
- `false` - do not transpile; if async functions are not supported an exception will be thrown. - `false` - do not transpile; if async functions are not supported an exception will be thrown.
@@ -1224,13 +1293,13 @@ Defaults:
- _passContext_: pass validation context to custom keyword functions. If this option is `true` and you pass some context to the compiled validation function with `validate.call(context, data)`, the `context` will be available as `this` in your custom keywords. By default `this` is Ajv instance. - _passContext_: pass validation context to custom keyword functions. If this option is `true` and you pass some context to the compiled validation function with `validate.call(context, data)`, the `context` will be available as `this` in your custom keywords. By default `this` is Ajv instance.
- _loopRequired_: by default `required` keyword is compiled into a single expression (or a sequence of statements in `allErrors` mode). In case of a very large number of properties in this keyword it may result in a very big validation function. Pass integer to set the number of properties above which `required` keyword will be validated in a loop - smaller validation function size but also worse performance. - _loopRequired_: by default `required` keyword is compiled into a single expression (or a sequence of statements in `allErrors` mode). In case of a very large number of properties in this keyword it may result in a very big validation function. Pass integer to set the number of properties above which `required` keyword will be validated in a loop - smaller validation function size but also worse performance.
- _ownProperties_: by default Ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst. - _ownProperties_: by default Ajv iterates over all enumerable object properties; when this option is `true` only own enumerable object properties (i.e. found directly on the object rather than on its prototype) are iterated. Contributed by @mbroadst.
- _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/epoberezkin/ajv/issues/84)). If you need to use fractional dividers set this option to some positive integer N to have `multipleOf` validated using this formula: `Math.abs(Math.round(division) - division) < 1e-N` (it is slower but allows for float arithmetics deviations). - _multipleOfPrecision_: by default `multipleOf` keyword is validated by comparing the result of division with parseInt() of that result. It works for dividers that are bigger than 1. For small dividers such as 0.01 the result of the division is usually not integer (even when it should be integer, see issue [#84](https://github.com/ajv-validator/ajv/issues/84)). If you need to use fractional dividers set this option to some positive integer N to have `multipleOf` validated using this formula: `Math.abs(Math.round(division) - division) < 1e-N` (it is slower but allows for float arithmetics deviations).
- _errorDataPath_ (deprecated): set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`. - _errorDataPath_ (deprecated): set `dataPath` to point to 'object' (default) or to 'property' when validating keywords `required`, `additionalProperties` and `dependencies`.
- _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/epoberezkin/ajv-i18n)). - _messages_: Include human-readable messages in errors. `true` by default. `false` can be passed when custom messages are used (e.g. with [ajv-i18n](https://github.com/ajv-validator/ajv-i18n)).
- _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call). - _sourceCode_: add `sourceCode` property to validating function (for debugging; this code can be different from the result of toString call).
- _processCode_: an optional function to process generated code before it is passed to Function constructor. It can be used to either beautify (the validating function is generated without line-breaks) or to transpile code. Starting from version 5.0.0 this option replaced options: - _processCode_: an optional function to process generated code before it is passed to Function constructor. It can be used to either beautify (the validating function is generated without line-breaks) or to transpile code. Starting from version 5.0.0 this option replaced options:
- `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass `require('js-beautify').js_beautify`. - `beautify` that formatted the generated function using [js-beautify](https://github.com/beautify-web/js-beautify). If you want to beautify the generated code pass a function calling `require('js-beautify').js_beautify` as `processCode: code => js_beautify(code)`.
- `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/epoberezkin/ajv-async) package. See [Asynchronous validation](#asynchronous-validation) for more information. - `transpile` that transpiled asynchronous validation function. You can still use `transpile` option with [ajv-async](https://github.com/ajv-validator/ajv-async) package. See [Asynchronous validation](#asynchronous-validation) for more information.
- _cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`, `del(key)` and `clear()`. - _cache_: an optional instance of cache to store compiled schemas using stable-stringified schema as a key. For example, set-associative cache [sacjs](https://github.com/epoberezkin/sacjs) can be used. If not passed then a simple hash is used which is good enough for the common use case (a limited number of statically defined schemas). Cache should have methods `put(key, value)`, `get(key)`, `del(key)` and `clear()`.
- _serialize_: an optional function to serialize schema to cache key. Pass `false` to use schema itself as a key (e.g., if WeakMap used as a cache). By default [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used. - _serialize_: an optional function to serialize schema to cache key. Pass `false` to use schema itself as a key (e.g., if WeakMap used as a cache). By default [fast-json-stable-stringify](https://github.com/epoberezkin/fast-json-stable-stringify) is used.
@@ -1247,7 +1316,7 @@ Each error is an object with the following properties:
- _keyword_: validation keyword. - _keyword_: validation keyword.
- _dataPath_: the path to the part of the data that was validated. By default `dataPath` uses JavaScript property access notation (e.g., `".prop[1].subProp"`). When the option `jsonPointers` is true (see [Options](#options)) `dataPath` will be set using JSON pointer standard (e.g., `"/prop/1/subProp"`). - _dataPath_: the path to the part of the data that was validated. By default `dataPath` uses JavaScript property access notation (e.g., `".prop[1].subProp"`). When the option `jsonPointers` is true (see [Options](#options)) `dataPath` will be set using JSON pointer standard (e.g., `"/prop/1/subProp"`).
- _schemaPath_: the path (JSON-pointer as a URI fragment) to the schema of the keyword that failed validation. - _schemaPath_: the path (JSON-pointer as a URI fragment) to the schema of the keyword that failed validation.
- _params_: the object with the additional information about error that can be used to create custom error messages (e.g., using [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) package). See below for parameters set by all keywords. - _params_: the object with the additional information about error that can be used to create custom error messages (e.g., using [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) package). See below for parameters set by all keywords.
- _message_: the standard error message (can be excluded with option `messages` set to false). - _message_: the standard error message (can be excluded with option `messages` set to false).
- _schema_: the schema of the keyword (added with `verbose` option). - _schema_: the schema of the keyword (added with `verbose` option).
- _parentSchema_: the schema containing the keyword (added with `verbose` option) - _parentSchema_: the schema containing the keyword (added with `verbose` option)
@@ -1287,6 +1356,28 @@ Properties of `params` object in errors depend on the keyword that failed valida
- custom keywords (in case keyword definition doesn't create errors) - property `keyword` (the keyword name). - custom keywords (in case keyword definition doesn't create errors) - property `keyword` (the keyword name).
### Error logging
Using the `logger` option when initiallizing Ajv will allow you to define custom logging. Here you can build upon the exisiting logging. The use of other logging packages is supported as long as the package or its associated wrapper exposes the required methods. If any of the required methods are missing an exception will be thrown.
- **Required Methods**: `log`, `warn`, `error`
```javascript
var otherLogger = new OtherLogger();
var ajv = new Ajv({
logger: {
log: console.log.bind(console),
warn: function warn() {
otherLogger.logWarn.apply(otherLogger, arguments);
},
error: function error() {
otherLogger.logError.apply(otherLogger, arguments);
console.error.apply(console, arguments);
}
}
});
```
## Plugins ## Plugins
Ajv can be extended with plugins that add custom keywords, formats or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions: Ajv can be extended with plugins that add custom keywords, formats or functions to process generated code. When such plugin is published as npm package it is recommended that it follows these conventions:
@@ -1300,16 +1391,16 @@ If you have published a useful plugin please submit a PR to add it to the next s
## Related packages ## Related packages
- [ajv-async](https://github.com/epoberezkin/ajv-async) - plugin to configure async validation mode - [ajv-async](https://github.com/ajv-validator/ajv-async) - plugin to configure async validation mode
- [ajv-bsontype](https://github.com/BoLaMN/ajv-bsontype) - plugin to validate mongodb's bsonType formats - [ajv-bsontype](https://github.com/BoLaMN/ajv-bsontype) - plugin to validate mongodb's bsonType formats
- [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface - [ajv-cli](https://github.com/jessedc/ajv-cli) - command line interface
- [ajv-errors](https://github.com/epoberezkin/ajv-errors) - plugin for custom error messages - [ajv-errors](https://github.com/ajv-validator/ajv-errors) - plugin for custom error messages
- [ajv-i18n](https://github.com/epoberezkin/ajv-i18n) - internationalised error messages - [ajv-i18n](https://github.com/ajv-validator/ajv-i18n) - internationalised error messages
- [ajv-istanbul](https://github.com/epoberezkin/ajv-istanbul) - plugin to instrument generated validation code to measure test coverage of your schemas - [ajv-istanbul](https://github.com/ajv-validator/ajv-istanbul) - plugin to instrument generated validation code to measure test coverage of your schemas
- [ajv-keywords](https://github.com/epoberezkin/ajv-keywords) - plugin with custom validation keywords (select, typeof, etc.) - [ajv-keywords](https://github.com/ajv-validator/ajv-keywords) - plugin with custom validation keywords (select, typeof, etc.)
- [ajv-merge-patch](https://github.com/epoberezkin/ajv-merge-patch) - plugin with keywords $merge and $patch - [ajv-merge-patch](https://github.com/ajv-validator/ajv-merge-patch) - plugin with keywords $merge and $patch
- [ajv-pack](https://github.com/epoberezkin/ajv-pack) - produces a compact module exporting validation functions - [ajv-pack](https://github.com/ajv-validator/ajv-pack) - produces a compact module exporting validation functions
- [ajv-formats-draft2019](https://github.com/luzlab/ajv-formats-draft2019) - format validators for draft2019 that aren't already included in ajv (ie. `idn-hostname`, `idn-email`, `iri`, `iri-reference` and `duration`).
## Some packages using Ajv ## Some packages using Ajv
@@ -1346,28 +1437,35 @@ npm test
## Contributing ## Contributing
All validation functions are generated using doT templates in [dot](https://github.com/epoberezkin/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency. All validation functions are generated using doT templates in [dot](https://github.com/ajv-validator/ajv/tree/master/lib/dot) folder. Templates are precompiled so doT is not a run-time dependency.
`npm run build` - compiles templates to [dotjs](https://github.com/epoberezkin/ajv/tree/master/lib/dotjs) folder. `npm run build` - compiles templates to [dotjs](https://github.com/ajv-validator/ajv/tree/master/lib/dotjs) folder.
`npm run watch` - automatically compiles templates when files in dot folder change `npm run watch` - automatically compiles templates when files in dot folder change
Please see [Contributing guidelines](https://github.com/epoberezkin/ajv/blob/master/CONTRIBUTING.md) Please see [Contributing guidelines](https://github.com/ajv-validator/ajv/blob/master/CONTRIBUTING.md)
## Changes history ## Changes history
See https://github.com/epoberezkin/ajv/releases See https://github.com/ajv-validator/ajv/releases
__Please note__: [Changes in version 6.0.0](https://github.com/epoberezkin/ajv/releases/tag/v6.0.0). __Please note__: [Changes in version 6.0.0](https://github.com/ajv-validator/ajv/releases/tag/v6.0.0).
[Version 5.0.0](https://github.com/epoberezkin/ajv/releases/tag/5.0.0). [Version 5.0.0](https://github.com/ajv-validator/ajv/releases/tag/5.0.0).
[Version 4.0.0](https://github.com/epoberezkin/ajv/releases/tag/4.0.0). [Version 4.0.0](https://github.com/ajv-validator/ajv/releases/tag/4.0.0).
[Version 3.0.0](https://github.com/epoberezkin/ajv/releases/tag/3.0.0). [Version 3.0.0](https://github.com/ajv-validator/ajv/releases/tag/3.0.0).
[Version 2.0.0](https://github.com/epoberezkin/ajv/releases/tag/2.0.0). [Version 2.0.0](https://github.com/ajv-validator/ajv/releases/tag/2.0.0).
## Code of conduct
Please review and follow the [Code of conduct](https://github.com/ajv-validator/ajv/blob/master/CODE_OF_CONDUCT.md).
Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
## Open-source software support ## Open-source software support
@@ -1377,4 +1475,4 @@ Ajv is a part of [Tidelift subscription](https://tidelift.com/subscription/pkg/n
## License ## License
[MIT](https://github.com/epoberezkin/ajv/blob/master/LICENSE) [MIT](https://github.com/ajv-validator/ajv/blob/master/LICENSE)

132
node_modules/ajv/dist/ajv.bundle.js generated vendored
View File

@@ -162,7 +162,7 @@ var util = require('./util');
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31]; var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i; var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i; var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
// uri-template: https://tools.ietf.org/html/rfc6570 // uri-template: https://tools.ietf.org/html/rfc6570
@@ -227,7 +227,7 @@ formats.full = {
'uri-template': URITEMPLATE, 'uri-template': URITEMPLATE,
url: URL, url: URL,
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
hostname: hostname, hostname: HOSTNAME,
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
regex: regex, regex: regex,
@@ -280,13 +280,6 @@ function date_time(str) {
} }
function hostname(str) {
// https://tools.ietf.org/html/rfc1034#section-3.5
// https://tools.ietf.org/html/rfc1123#section-2
return str.length <= 255 && HOSTNAME.test(str);
}
var NOT_URI_FRAGMENT = /\/|:/; var NOT_URI_FRAGMENT = /\/|:/;
function uri(str) { function uri(str) {
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "." // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."
@@ -421,7 +414,7 @@ function compile(schema, root, localRefs, baseId) {
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ sourceCode; + sourceCode;
if (opts.processCode) sourceCode = opts.processCode(sourceCode); if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode)); // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
var validate; var validate;
try { try {
@@ -1083,8 +1076,6 @@ module.exports = {
ucs2length: require('./ucs2length'), ucs2length: require('./ucs2length'),
varOccurences: varOccurences, varOccurences: varOccurences,
varReplace: varReplace, varReplace: varReplace,
cleanUpCode: cleanUpCode,
finalCleanUpCode: finalCleanUpCode,
schemaHasRules: schemaHasRules, schemaHasRules: schemaHasRules,
schemaHasRulesExcept: schemaHasRulesExcept, schemaHasRulesExcept: schemaHasRulesExcept,
schemaUnknownRules: schemaUnknownRules, schemaUnknownRules: schemaUnknownRules,
@@ -1106,7 +1097,7 @@ function copy(o, to) {
} }
function checkDataType(dataType, data, negate) { function checkDataType(dataType, data, strictNumbers, negate) {
var EQUAL = negate ? ' !== ' : ' === ' var EQUAL = negate ? ' !== ' : ' === '
, AND = negate ? ' || ' : ' && ' , AND = negate ? ' || ' : ' && '
, OK = negate ? '!' : '' , OK = negate ? '!' : ''
@@ -1119,15 +1110,18 @@ function checkDataType(dataType, data, negate) {
NOT + 'Array.isArray(' + data + '))'; NOT + 'Array.isArray(' + data + '))';
case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND + case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
NOT + '(' + data + ' % 1)' + NOT + '(' + data + ' % 1)' +
AND + data + EQUAL + data + ')'; AND + data + EQUAL + data +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"'; default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
} }
} }
function checkDataTypes(dataTypes, data) { function checkDataTypes(dataTypes, data, strictNumbers) {
switch (dataTypes.length) { switch (dataTypes.length) {
case 1: return checkDataType(dataTypes[0], data, true); case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
default: default:
var code = ''; var code = '';
var types = toHash(dataTypes); var types = toHash(dataTypes);
@@ -1140,7 +1134,7 @@ function checkDataTypes(dataTypes, data) {
} }
if (types.number) delete types.integer; if (types.number) delete types.integer;
for (var t in types) for (var t in types)
code += (code ? ' && ' : '' ) + checkDataType(t, data, true); code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
return code; return code;
} }
@@ -1206,42 +1200,6 @@ function varReplace(str, dataVar, expr) {
} }
var EMPTY_ELSE = /else\s*{\s*}/g
, EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
, EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
function cleanUpCode(out) {
return out.replace(EMPTY_ELSE, '')
.replace(EMPTY_IF_NO_ELSE, '')
.replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
}
var ERRORS_REGEXP = /[^v.]errors/g
, REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
, REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
, RETURN_VALID = 'return errors === 0;'
, RETURN_TRUE = 'validate.errors = null; return true;'
, RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
, RETURN_DATA_ASYNC = 'return data;'
, ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
, REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
function finalCleanUpCode(out, async) {
var matches = out.match(ERRORS_REGEXP);
if (matches && matches.length == 2) {
out = async
? out.replace(REMOVE_ERRORS_ASYNC, '')
.replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
: out.replace(REMOVE_ERRORS, '')
.replace(RETURN_VALID, RETURN_TRUE);
}
matches = out.match(ROOTDATA_REGEXP);
if (!matches || matches.length !== 3) return out;
return out.replace(REMOVE_ROOTDATA, '');
}
function schemaHasRules(schema, rules) { function schemaHasRules(schema, rules) {
if (typeof schema == 'boolean') return !schema; if (typeof schema == 'boolean') return !schema;
for (var key in schema) if (rules[key]) return true; for (var key in schema) if (rules[key]) return true;
@@ -1320,7 +1278,7 @@ function getData($data, lvl, paths) {
function joinPaths (a, b) { function joinPaths (a, b) {
if (a == '""') return b; if (a == '""') return b;
return (a + ' + ' + b).replace(/' \+ '/g, ''); return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
} }
@@ -1384,7 +1342,7 @@ module.exports = function (metaSchema, keywordsJsonPointers) {
keywords[key] = { keywords[key] = {
anyOf: [ anyOf: [
schema, schema,
{ $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' } { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
] ]
}; };
} }
@@ -1400,7 +1358,7 @@ module.exports = function (metaSchema, keywordsJsonPointers) {
var metaSchema = require('./refs/json-schema-draft-07.json'); var metaSchema = require('./refs/json-schema-draft-07.json');
module.exports = { module.exports = {
$id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js', $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
definitions: { definitions: {
simpleTypes: metaSchema.definitions.simpleTypes simpleTypes: metaSchema.definitions.simpleTypes
}, },
@@ -1460,6 +1418,12 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
$op = $isMax ? '<' : '>', $op = $isMax ? '<' : '>',
$notOp = $isMax ? '>' : '<', $notOp = $isMax ? '>' : '<',
$errorKeyword = undefined; $errorKeyword = undefined;
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
throw new Error($keyword + ' must be number');
}
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
throw new Error($exclusiveKeyword + ' must be number or boolean');
}
if ($isDataExcl) { if ($isDataExcl) {
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr), var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
$exclusive = 'exclusive' + $lvl, $exclusive = 'exclusive' + $lvl,
@@ -1612,6 +1576,9 @@ module.exports = function generate__limitItems(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxItems' ? '>' : '<'; var $op = $keyword == 'maxItems' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {
@@ -1691,6 +1658,9 @@ module.exports = function generate__limitLength(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxLength' ? '>' : '<'; var $op = $keyword == 'maxLength' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {
@@ -1775,6 +1745,9 @@ module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxProperties' ? '>' : '<'; var $op = $keyword == 'maxProperties' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {
@@ -1875,7 +1848,6 @@ module.exports = function generate_allOf(it, $keyword, $ruleType) {
out += ' ' + ($closingBraces.slice(0, -1)) + ' '; out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
} }
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -1946,7 +1918,6 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) {
if (it.opts.allErrors) { if (it.opts.allErrors) {
out += ' } '; out += ' } ';
} }
out = it.util.cleanUpCode(out);
} else { } else {
if ($breakOnError) { if ($breakOnError) {
out += ' if (true) { '; out += ' if (true) { ';
@@ -2109,7 +2080,6 @@ module.exports = function generate_contains(it, $keyword, $ruleType) {
if (it.opts.allErrors) { if (it.opts.allErrors) {
out += ' } '; out += ' } ';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -2363,6 +2333,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
$propertyDeps = {}, $propertyDeps = {},
$ownProperties = it.opts.ownProperties; $ownProperties = it.opts.ownProperties;
for ($property in $schema) { for ($property in $schema) {
if ($property == '__proto__') continue;
var $sch = $schema[$property]; var $sch = $schema[$property];
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
$deps[$property] = $sch; $deps[$property] = $sch;
@@ -2509,7 +2480,6 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -2830,7 +2800,6 @@ module.exports = function generate_if(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' else { '; out += ' else { ';
} }
out = it.util.cleanUpCode(out);
} else { } else {
if ($breakOnError) { if ($breakOnError) {
out += ' if (true) { '; out += ' if (true) { ';
@@ -3013,7 +2982,6 @@ module.exports = function generate_items(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -3036,6 +3004,9 @@ module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
out += 'var division' + ($lvl) + ';if ('; out += 'var division' + ($lvl) + ';if (';
if ($isData) { if ($isData) {
out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || '; out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';
@@ -3355,9 +3326,9 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$dataNxt = $it.dataLevel = it.dataLevel + 1, $dataNxt = $it.dataLevel = it.dataLevel + 1,
$nextData = 'data' + $dataNxt, $nextData = 'data' + $dataNxt,
$dataProperties = 'dataProperties' + $lvl; $dataProperties = 'dataProperties' + $lvl;
var $schemaKeys = Object.keys($schema || {}), var $schemaKeys = Object.keys($schema || {}).filter(notProto),
$pProperties = it.schema.patternProperties || {}, $pProperties = it.schema.patternProperties || {},
$pPropertyKeys = Object.keys($pProperties), $pPropertyKeys = Object.keys($pProperties).filter(notProto),
$aProperties = it.schema.additionalProperties, $aProperties = it.schema.additionalProperties,
$someProperties = $schemaKeys.length || $pPropertyKeys.length, $someProperties = $schemaKeys.length || $pPropertyKeys.length,
$noAdditional = $aProperties === false, $noAdditional = $aProperties === false,
@@ -3367,7 +3338,13 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$ownProperties = it.opts.ownProperties, $ownProperties = it.opts.ownProperties,
$currentBaseId = it.baseId; $currentBaseId = it.baseId;
var $required = it.schema.required; var $required = it.schema.required;
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required); if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
var $requiredHash = it.util.toHash($required);
}
function notProto(p) {
return p !== '__proto__';
}
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;'; out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
if ($ownProperties) { if ($ownProperties) {
out += ' var ' + ($dataProperties) + ' = undefined;'; out += ' var ' + ($dataProperties) + ' = undefined;';
@@ -3662,7 +3639,6 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -3746,7 +3722,6 @@ module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }
@@ -4180,7 +4155,7 @@ module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
} else { } else {
out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; '; out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; '; out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
if ($typeIsArray) { if ($typeIsArray) {
out += ' if (typeof item == \'string\') item = \'"\' + item; '; out += ' if (typeof item == \'string\') item = \'"\' + item; ';
} }
@@ -4388,7 +4363,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
var $schemaPath = it.schemaPath + '.type', var $schemaPath = it.schemaPath + '.type',
$errSchemaPath = it.errSchemaPath + '/type', $errSchemaPath = it.errSchemaPath + '/type',
$method = $typeIsArray ? 'checkDataTypes' : 'checkDataType'; $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { '; out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
if ($coerceToTypes) { if ($coerceToTypes) {
var $dataType = 'dataType' + $lvl, var $dataType = 'dataType' + $lvl,
$coerced = 'coerced' + $lvl; $coerced = 'coerced' + $lvl;
@@ -4541,7 +4516,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
$rulesGroup = arr2[i2 += 1]; $rulesGroup = arr2[i2 += 1];
if ($shouldUseGroup($rulesGroup)) { if ($shouldUseGroup($rulesGroup)) {
if ($rulesGroup.type) { if ($rulesGroup.type) {
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { '; out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
} }
if (it.opts.useDefaults) { if (it.opts.useDefaults) {
if ($rulesGroup.type == 'object' && it.schema.properties) { if ($rulesGroup.type == 'object' && it.schema.properties) {
@@ -4709,10 +4684,6 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
} else { } else {
out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';'; out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
} }
out = it.util.cleanUpCode(out);
if ($top) {
out = it.util.finalCleanUpCode(out, $async);
}
function $shouldUseGroup($rulesGroup) { function $shouldUseGroup($rulesGroup) {
var rules = $rulesGroup.rules; var rules = $rulesGroup.rules;
@@ -4781,7 +4752,7 @@ function addKeyword(keyword, definition) {
metaSchema = { metaSchema = {
anyOf: [ anyOf: [
metaSchema, metaSchema,
{ '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' } { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
] ]
}; };
} }
@@ -4883,7 +4854,7 @@ function validateKeyword(definition, throwError) {
},{"./definition_schema":12,"./dotjs/custom":22}],40:[function(require,module,exports){ },{"./definition_schema":12,"./dotjs/custom":22}],40:[function(require,module,exports){
module.exports={ module.exports={
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#", "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
"description": "Meta-schema for $data reference (JSON Schema extension proposal)", "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
"type": "object", "type": "object",
"required": [ "$data" ], "required": [ "$data" ],
@@ -6732,6 +6703,7 @@ function Ajv(opts) {
this._metaOpts = getMetaSchemaOptions(this); this._metaOpts = getMetaSchemaOptions(this);
if (opts.formats) addInitialFormats(this); if (opts.formats) addInitialFormats(this);
if (opts.keywords) addInitialKeywords(this);
addDefaultMetaSchema(this); addDefaultMetaSchema(this);
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta); if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}}); if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
@@ -7130,6 +7102,14 @@ function addInitialFormats(self) {
} }
function addInitialKeywords(self) {
for (var name in self._opts.keywords) {
var keyword = self._opts.keywords[name];
self.addKeyword(name, keyword);
}
}
function checkUnique(self, id) { function checkUnique(self, id) {
if (self._schemas[id] || self._refs[id]) if (self._schemas[id] || self._refs[id])
throw new Error('schema with key or id "' + id + '" already exists'); throw new Error('schema with key or id "' + id + '" already exists');

4
node_modules/ajv/dist/ajv.min.js generated vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13
node_modules/ajv/lib/ajv.d.ts generated vendored
View File

@@ -80,9 +80,9 @@ declare namespace ajv {
/** /**
* Get compiled schema from the instance by `key` or `ref`. * Get compiled schema from the instance by `key` or `ref`.
* @param {string} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id). * @param {string} keyRef `key` that was passed to `addSchema` or full schema reference (`schema.id` or resolved id).
* @return {Function} schema validating function (with property `schema`). * @return {Function} schema validating function (with property `schema`). Returns undefined if keyRef can't be resolved to an existing schema.
*/ */
getSchema(keyRef: string): ValidateFunction; getSchema(keyRef: string): ValidateFunction | undefined;
/** /**
* Remove cached schema(s). * Remove cached schema(s).
* If no parameter is passed all schemas but meta-schemas are removed. * If no parameter is passed all schemas but meta-schemas are removed.
@@ -169,8 +169,9 @@ declare namespace ajv {
jsonPointers?: boolean; jsonPointers?: boolean;
uniqueItems?: boolean; uniqueItems?: boolean;
unicode?: boolean; unicode?: boolean;
format?: string; format?: false | string;
formats?: object; formats?: object;
keywords?: object;
unknownFormats?: true | string[] | 'ignore'; unknownFormats?: true | string[] | 'ignore';
schemas?: Array<object> | object; schemas?: Array<object> | object;
schemaId?: '$id' | 'id' | 'auto'; schemaId?: '$id' | 'id' | 'auto';
@@ -182,6 +183,7 @@ declare namespace ajv {
coerceTypes?: boolean | 'array'; coerceTypes?: boolean | 'array';
strictDefaults?: boolean | 'log'; strictDefaults?: boolean | 'log';
strictKeywords?: boolean | 'log'; strictKeywords?: boolean | 'log';
strictNumbers?: boolean;
async?: boolean | string; async?: boolean | string;
transpile?: string | ((code: string) => string); transpile?: string | ((code: string) => string);
meta?: boolean | object; meta?: boolean | object;
@@ -195,7 +197,7 @@ declare namespace ajv {
errorDataPath?: string, errorDataPath?: string,
messages?: boolean; messages?: boolean;
sourceCode?: boolean; sourceCode?: boolean;
processCode?: (code: string) => string; processCode?: (code: string, schema: object) => string;
cache?: object; cache?: object;
logger?: CustomLogger | false; logger?: CustomLogger | false;
nullable?: boolean; nullable?: boolean;
@@ -252,6 +254,9 @@ declare namespace ajv {
formats: { formats: {
[index: string]: FormatDefinition | undefined; [index: string]: FormatDefinition | undefined;
}; };
keywords: {
[index: string]: KeywordDefinition | undefined;
};
compositeRule: boolean; compositeRule: boolean;
validate: (schema: object) => boolean; validate: (schema: object) => boolean;
util: { util: {

9
node_modules/ajv/lib/ajv.js generated vendored
View File

@@ -69,6 +69,7 @@ function Ajv(opts) {
this._metaOpts = getMetaSchemaOptions(this); this._metaOpts = getMetaSchemaOptions(this);
if (opts.formats) addInitialFormats(this); if (opts.formats) addInitialFormats(this);
if (opts.keywords) addInitialKeywords(this);
addDefaultMetaSchema(this); addDefaultMetaSchema(this);
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta); if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}}); if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: 'boolean'}});
@@ -467,6 +468,14 @@ function addInitialFormats(self) {
} }
function addInitialKeywords(self) {
for (var name in self._opts.keywords) {
var keyword = self._opts.keywords[name];
self.addKeyword(name, keyword);
}
}
function checkUnique(self, id) { function checkUnique(self, id) {
if (self._schemas[id] || self._refs[id]) if (self._schemas[id] || self._refs[id])
throw new Error('schema with key or id "' + id + '" already exists'); throw new Error('schema with key or id "' + id + '" already exists');

View File

@@ -1,5 +1,5 @@
'use strict'; 'use strict';
// do NOT remove this file - it would break pre-compiled schemas // do NOT remove this file - it would break pre-compiled schemas
// https://github.com/epoberezkin/ajv/issues/889 // https://github.com/ajv-validator/ajv/issues/889
module.exports = require('fast-deep-equal'); module.exports = require('fast-deep-equal');

View File

@@ -5,7 +5,7 @@ var util = require('./util');
var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/; var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31]; var DAYS = [0,31,28,31,30,31,30,31,31,30,31,30,31];
var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i; var TIME = /^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i;
var HOSTNAME = /^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*$/i; var HOSTNAME = /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i;
var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i; var URIREF = /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
// uri-template: https://tools.ietf.org/html/rfc6570 // uri-template: https://tools.ietf.org/html/rfc6570
@@ -70,7 +70,7 @@ formats.full = {
'uri-template': URITEMPLATE, 'uri-template': URITEMPLATE,
url: URL, url: URL,
email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i, email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
hostname: hostname, hostname: HOSTNAME,
ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/, ipv4: /^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,
ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i, ipv6: /^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,
regex: regex, regex: regex,
@@ -123,13 +123,6 @@ function date_time(str) {
} }
function hostname(str) {
// https://tools.ietf.org/html/rfc1034#section-3.5
// https://tools.ietf.org/html/rfc1123#section-2
return str.length <= 255 && HOSTNAME.test(str);
}
var NOT_URI_FRAGMENT = /\/|:/; var NOT_URI_FRAGMENT = /\/|:/;
function uri(str) { function uri(str) {
// http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "." // http://jmrware.com/articles/2009/uri_regexp/URI_regex.html + optional protocol + required "."

View File

@@ -113,7 +113,7 @@ function compile(schema, root, localRefs, baseId) {
+ vars(defaults, defaultCode) + vars(customRules, customRuleCode) + vars(defaults, defaultCode) + vars(customRules, customRuleCode)
+ sourceCode; + sourceCode;
if (opts.processCode) sourceCode = opts.processCode(sourceCode); if (opts.processCode) sourceCode = opts.processCode(sourceCode, _schema);
// console.log('\n\n\n *** \n', JSON.stringify(sourceCode)); // console.log('\n\n\n *** \n', JSON.stringify(sourceCode));
var validate; var validate;
try { try {

53
node_modules/ajv/lib/compile/util.js generated vendored
View File

@@ -13,8 +13,6 @@ module.exports = {
ucs2length: require('./ucs2length'), ucs2length: require('./ucs2length'),
varOccurences: varOccurences, varOccurences: varOccurences,
varReplace: varReplace, varReplace: varReplace,
cleanUpCode: cleanUpCode,
finalCleanUpCode: finalCleanUpCode,
schemaHasRules: schemaHasRules, schemaHasRules: schemaHasRules,
schemaHasRulesExcept: schemaHasRulesExcept, schemaHasRulesExcept: schemaHasRulesExcept,
schemaUnknownRules: schemaUnknownRules, schemaUnknownRules: schemaUnknownRules,
@@ -36,7 +34,7 @@ function copy(o, to) {
} }
function checkDataType(dataType, data, negate) { function checkDataType(dataType, data, strictNumbers, negate) {
var EQUAL = negate ? ' !== ' : ' === ' var EQUAL = negate ? ' !== ' : ' === '
, AND = negate ? ' || ' : ' && ' , AND = negate ? ' || ' : ' && '
, OK = negate ? '!' : '' , OK = negate ? '!' : ''
@@ -49,15 +47,18 @@ function checkDataType(dataType, data, negate) {
NOT + 'Array.isArray(' + data + '))'; NOT + 'Array.isArray(' + data + '))';
case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND + case 'integer': return '(typeof ' + data + EQUAL + '"number"' + AND +
NOT + '(' + data + ' % 1)' + NOT + '(' + data + ' % 1)' +
AND + data + EQUAL + data + ')'; AND + data + EQUAL + data +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
case 'number': return '(typeof ' + data + EQUAL + '"' + dataType + '"' +
(strictNumbers ? (AND + OK + 'isFinite(' + data + ')') : '') + ')';
default: return 'typeof ' + data + EQUAL + '"' + dataType + '"'; default: return 'typeof ' + data + EQUAL + '"' + dataType + '"';
} }
} }
function checkDataTypes(dataTypes, data) { function checkDataTypes(dataTypes, data, strictNumbers) {
switch (dataTypes.length) { switch (dataTypes.length) {
case 1: return checkDataType(dataTypes[0], data, true); case 1: return checkDataType(dataTypes[0], data, strictNumbers, true);
default: default:
var code = ''; var code = '';
var types = toHash(dataTypes); var types = toHash(dataTypes);
@@ -70,7 +71,7 @@ function checkDataTypes(dataTypes, data) {
} }
if (types.number) delete types.integer; if (types.number) delete types.integer;
for (var t in types) for (var t in types)
code += (code ? ' && ' : '' ) + checkDataType(t, data, true); code += (code ? ' && ' : '' ) + checkDataType(t, data, strictNumbers, true);
return code; return code;
} }
@@ -136,42 +137,6 @@ function varReplace(str, dataVar, expr) {
} }
var EMPTY_ELSE = /else\s*{\s*}/g
, EMPTY_IF_NO_ELSE = /if\s*\([^)]+\)\s*\{\s*\}(?!\s*else)/g
, EMPTY_IF_WITH_ELSE = /if\s*\(([^)]+)\)\s*\{\s*\}\s*else(?!\s*if)/g;
function cleanUpCode(out) {
return out.replace(EMPTY_ELSE, '')
.replace(EMPTY_IF_NO_ELSE, '')
.replace(EMPTY_IF_WITH_ELSE, 'if (!($1))');
}
var ERRORS_REGEXP = /[^v.]errors/g
, REMOVE_ERRORS = /var errors = 0;|var vErrors = null;|validate.errors = vErrors;/g
, REMOVE_ERRORS_ASYNC = /var errors = 0;|var vErrors = null;/g
, RETURN_VALID = 'return errors === 0;'
, RETURN_TRUE = 'validate.errors = null; return true;'
, RETURN_ASYNC = /if \(errors === 0\) return data;\s*else throw new ValidationError\(vErrors\);/
, RETURN_DATA_ASYNC = 'return data;'
, ROOTDATA_REGEXP = /[^A-Za-z_$]rootData[^A-Za-z0-9_$]/g
, REMOVE_ROOTDATA = /if \(rootData === undefined\) rootData = data;/;
function finalCleanUpCode(out, async) {
var matches = out.match(ERRORS_REGEXP);
if (matches && matches.length == 2) {
out = async
? out.replace(REMOVE_ERRORS_ASYNC, '')
.replace(RETURN_ASYNC, RETURN_DATA_ASYNC)
: out.replace(REMOVE_ERRORS, '')
.replace(RETURN_VALID, RETURN_TRUE);
}
matches = out.match(ROOTDATA_REGEXP);
if (!matches || matches.length !== 3) return out;
return out.replace(REMOVE_ROOTDATA, '');
}
function schemaHasRules(schema, rules) { function schemaHasRules(schema, rules) {
if (typeof schema == 'boolean') return !schema; if (typeof schema == 'boolean') return !schema;
for (var key in schema) if (rules[key]) return true; for (var key in schema) if (rules[key]) return true;
@@ -250,7 +215,7 @@ function getData($data, lvl, paths) {
function joinPaths (a, b) { function joinPaths (a, b) {
if (a == '""') return b; if (a == '""') return b;
return (a + ' + ' + b).replace(/' \+ '/g, ''); return (a + ' + ' + b).replace(/([^\\])' \+ '/g, '$1');
} }

2
node_modules/ajv/lib/data.js generated vendored
View File

@@ -38,7 +38,7 @@ module.exports = function (metaSchema, keywordsJsonPointers) {
keywords[key] = { keywords[key] = {
anyOf: [ anyOf: [
schema, schema,
{ $ref: 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' } { $ref: 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
] ]
}; };
} }

View File

@@ -3,7 +3,7 @@
var metaSchema = require('./refs/json-schema-draft-07.json'); var metaSchema = require('./refs/json-schema-draft-07.json');
module.exports = { module.exports = {
$id: 'https://github.com/epoberezkin/ajv/blob/master/lib/definition_schema.js', $id: 'https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js',
definitions: { definitions: {
simpleTypes: metaSchema.definitions.simpleTypes simpleTypes: metaSchema.definitions.simpleTypes
}, },

View File

@@ -17,6 +17,15 @@
, $op = $isMax ? '<' : '>' , $op = $isMax ? '<' : '>'
, $notOp = $isMax ? '>' : '<' , $notOp = $isMax ? '>' : '<'
, $errorKeyword = undefined; , $errorKeyword = undefined;
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
throw new Error($keyword + ' must be number');
}
if (!($isDataExcl || $schemaExcl === undefined
|| typeof $schemaExcl == 'number'
|| typeof $schemaExcl == 'boolean')) {
throw new Error($exclusiveKeyword + ' must be number or boolean');
}
}} }}
{{? $isDataExcl }} {{? $isDataExcl }}

View File

@@ -3,6 +3,8 @@
{{# def.setupKeyword }} {{# def.setupKeyword }}
{{# def.$data }} {{# def.$data }}
{{# def.numberKeyword }}
{{ var $op = $keyword == 'maxItems' ? '>' : '<'; }} {{ var $op = $keyword == 'maxItems' ? '>' : '<'; }}
if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) { if ({{# def.$dataNotType:'number' }} {{=$data}}.length {{=$op}} {{=$schemaValue}}) {
{{ var $errorKeyword = $keyword; }} {{ var $errorKeyword = $keyword; }}

View File

@@ -3,6 +3,8 @@
{{# def.setupKeyword }} {{# def.setupKeyword }}
{{# def.$data }} {{# def.$data }}
{{# def.numberKeyword }}
{{ var $op = $keyword == 'maxLength' ? '>' : '<'; }} {{ var $op = $keyword == 'maxLength' ? '>' : '<'; }}
if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) { if ({{# def.$dataNotType:'number' }} {{# def.strLength }} {{=$op}} {{=$schemaValue}}) {
{{ var $errorKeyword = $keyword; }} {{ var $errorKeyword = $keyword; }}

View File

@@ -3,6 +3,8 @@
{{# def.setupKeyword }} {{# def.setupKeyword }}
{{# def.$data }} {{# def.$data }}
{{# def.numberKeyword }}
{{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }} {{ var $op = $keyword == 'maxProperties' ? '>' : '<'; }}
if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) { if ({{# def.$dataNotType:'number' }} Object.keys({{=$data}}).length {{=$op}} {{=$schemaValue}}) {
{{ var $errorKeyword = $keyword; }} {{ var $errorKeyword = $keyword; }}

2
node_modules/ajv/lib/dot/allOf.jst generated vendored
View File

@@ -30,5 +30,3 @@
{{= $closingBraces.slice(0,-1) }} {{= $closingBraces.slice(0,-1) }}
{{?}} {{?}}
{{?}} {{?}}
{{# def.cleanUp }}

2
node_modules/ajv/lib/dot/anyOf.jst generated vendored
View File

@@ -39,8 +39,6 @@
} else { } else {
{{# def.resetErrors }} {{# def.resetErrors }}
{{? it.opts.allErrors }} } {{?}} {{? it.opts.allErrors }} } {{?}}
{{# def.cleanUp }}
{{??}} {{??}}
{{? $breakOnError }} {{? $breakOnError }}
if (true) { if (true) {

View File

@@ -53,5 +53,3 @@ var {{=$valid}};
{{# def.resetErrors }} {{# def.resetErrors }}
{{?}} {{?}}
{{? it.opts.allErrors }} } {{?}} {{? it.opts.allErrors }} } {{?}}
{{# def.cleanUp }}

View File

@@ -112,12 +112,6 @@
#}} #}}
{{## def.cleanUp: {{ out = it.util.cleanUpCode(out); }} #}}
{{## def.finalCleanUp: {{ out = it.util.finalCleanUpCode(out, $async); }} #}}
{{## def.$data: {{## def.$data:
{{ {{
var $isData = it.opts.$data && $schema && $schema.$data var $isData = it.opts.$data && $schema && $schema.$data
@@ -144,6 +138,13 @@
#}} #}}
{{## def.numberKeyword:
{{? !($isData || typeof $schema == 'number') }}
{{ throw new Error($keyword + ' must be number'); }}
{{?}}
#}}
{{## def.beginDefOut: {{## def.beginDefOut:
{{ {{
var $$outStack = $$outStack || []; var $$outStack = $$outStack || [];

View File

@@ -19,6 +19,7 @@
, $ownProperties = it.opts.ownProperties; , $ownProperties = it.opts.ownProperties;
for ($property in $schema) { for ($property in $schema) {
if ($property == '__proto__') continue;
var $sch = $schema[$property]; var $sch = $schema[$property];
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
$deps[$property] = $sch; $deps[$property] = $sch;
@@ -76,5 +77,3 @@ var missing{{=$lvl}};
{{= $closingBraces }} {{= $closingBraces }}
if ({{=$errs}} == errors) { if ({{=$errs}} == errors) {
{{?}} {{?}}
{{# def.cleanUp }}

2
node_modules/ajv/lib/dot/if.jst generated vendored
View File

@@ -65,8 +65,6 @@
{{# def.extraError:'if' }} {{# def.extraError:'if' }}
} }
{{? $breakOnError }} else { {{?}} {{? $breakOnError }} else { {{?}}
{{# def.cleanUp }}
{{??}} {{??}}
{{? $breakOnError }} {{? $breakOnError }}
if (true) { if (true) {

2
node_modules/ajv/lib/dot/items.jst generated vendored
View File

@@ -96,5 +96,3 @@ var {{=$valid}};
{{= $closingBraces }} {{= $closingBraces }}
if ({{=$errs}} == errors) { if ({{=$errs}} == errors) {
{{?}} {{?}}
{{# def.cleanUp }}

View File

@@ -3,6 +3,8 @@
{{# def.setupKeyword }} {{# def.setupKeyword }}
{{# def.$data }} {{# def.$data }}
{{# def.numberKeyword }}
var division{{=$lvl}}; var division{{=$lvl}};
if ({{?$isData}} if ({{?$isData}}
{{=$schemaValue}} !== undefined && ( {{=$schemaValue}} !== undefined && (

View File

@@ -28,9 +28,9 @@
, $nextData = 'data' + $dataNxt , $nextData = 'data' + $dataNxt
, $dataProperties = 'dataProperties' + $lvl; , $dataProperties = 'dataProperties' + $lvl;
var $schemaKeys = Object.keys($schema || {}) var $schemaKeys = Object.keys($schema || {}).filter(notProto)
, $pProperties = it.schema.patternProperties || {} , $pProperties = it.schema.patternProperties || {}
, $pPropertyKeys = Object.keys($pProperties) , $pPropertyKeys = Object.keys($pProperties).filter(notProto)
, $aProperties = it.schema.additionalProperties , $aProperties = it.schema.additionalProperties
, $someProperties = $schemaKeys.length || $pPropertyKeys.length , $someProperties = $schemaKeys.length || $pPropertyKeys.length
, $noAdditional = $aProperties === false , $noAdditional = $aProperties === false
@@ -42,8 +42,11 @@
, $currentBaseId = it.baseId; , $currentBaseId = it.baseId;
var $required = it.schema.required; var $required = it.schema.required;
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
var $requiredHash = it.util.toHash($required); var $requiredHash = it.util.toHash($required);
}
function notProto(p) { return p !== '__proto__'; }
}} }}
@@ -240,5 +243,3 @@ var {{=$nextValid}} = true;
{{= $closingBraces }} {{= $closingBraces }}
if ({{=$errs}} == errors) { if ({{=$errs}} == errors) {
{{?}} {{?}}
{{# def.cleanUp }}

View File

@@ -50,5 +50,3 @@ var {{=$errs}} = errors;
{{= $closingBraces }} {{= $closingBraces }}
if ({{=$errs}} == errors) { if ({{=$errs}} == errors) {
{{?}} {{?}}
{{# def.cleanUp }}

View File

@@ -38,7 +38,7 @@
for (;i--;) { for (;i--;) {
var item = {{=$data}}[i]; var item = {{=$data}}[i];
{{ var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); }} {{ var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); }}
if ({{= it.util[$method]($itemType, 'item', true) }}) continue; if ({{= it.util[$method]($itemType, 'item', it.opts.strictNumbers, true) }}) continue;
{{? $typeIsArray}} {{? $typeIsArray}}
if (typeof item == 'string') item = '"' + item; if (typeof item == 'string') item = '"' + item;
{{?}} {{?}}

View File

@@ -140,7 +140,7 @@
, $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType'; , $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
}} }}
if ({{= it.util[$method]($typeSchema, $data, true) }}) { if ({{= it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true) }}) {
#}} #}}
{{? it.schema.$ref && $refKeywords }} {{? it.schema.$ref && $refKeywords }}
@@ -192,7 +192,7 @@
{{~ it.RULES:$rulesGroup }} {{~ it.RULES:$rulesGroup }}
{{? $shouldUseGroup($rulesGroup) }} {{? $shouldUseGroup($rulesGroup) }}
{{? $rulesGroup.type }} {{? $rulesGroup.type }}
if ({{= it.util.checkDataType($rulesGroup.type, $data) }}) { if ({{= it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers) }}) {
{{?}} {{?}}
{{? it.opts.useDefaults }} {{? it.opts.useDefaults }}
{{? $rulesGroup.type == 'object' && it.schema.properties }} {{? $rulesGroup.type == 'object' && it.schema.properties }}
@@ -254,12 +254,6 @@
var {{=$valid}} = errors === errs_{{=$lvl}}; var {{=$valid}} = errors === errs_{{=$lvl}};
{{?}} {{?}}
{{# def.cleanUp }}
{{? $top }}
{{# def.finalCleanUp }}
{{?}}
{{ {{
function $shouldUseGroup($rulesGroup) { function $shouldUseGroup($rulesGroup) {
var rules = $rulesGroup.rules; var rules = $rulesGroup.rules;

View File

@@ -24,6 +24,12 @@ module.exports = function generate__limit(it, $keyword, $ruleType) {
$op = $isMax ? '<' : '>', $op = $isMax ? '<' : '>',
$notOp = $isMax ? '>' : '<', $notOp = $isMax ? '>' : '<',
$errorKeyword = undefined; $errorKeyword = undefined;
if (!($isData || typeof $schema == 'number' || $schema === undefined)) {
throw new Error($keyword + ' must be number');
}
if (!($isDataExcl || $schemaExcl === undefined || typeof $schemaExcl == 'number' || typeof $schemaExcl == 'boolean')) {
throw new Error($exclusiveKeyword + ' must be number or boolean');
}
if ($isDataExcl) { if ($isDataExcl) {
var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr), var $schemaValueExcl = it.util.getData($schemaExcl.$data, $dataLvl, it.dataPathArr),
$exclusive = 'exclusive' + $lvl, $exclusive = 'exclusive' + $lvl,

View File

@@ -17,6 +17,9 @@ module.exports = function generate__limitItems(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxItems' ? '>' : '<'; var $op = $keyword == 'maxItems' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {

View File

@@ -17,6 +17,9 @@ module.exports = function generate__limitLength(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxLength' ? '>' : '<'; var $op = $keyword == 'maxLength' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {

View File

@@ -17,6 +17,9 @@ module.exports = function generate__limitProperties(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
var $op = $keyword == 'maxProperties' ? '>' : '<'; var $op = $keyword == 'maxProperties' ? '>' : '<';
out += 'if ( '; out += 'if ( ';
if ($isData) { if ($isData) {

View File

@@ -38,6 +38,5 @@ module.exports = function generate_allOf(it, $keyword, $ruleType) {
out += ' ' + ($closingBraces.slice(0, -1)) + ' '; out += ' ' + ($closingBraces.slice(0, -1)) + ' ';
} }
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

View File

@@ -64,7 +64,6 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) {
if (it.opts.allErrors) { if (it.opts.allErrors) {
out += ' } '; out += ' } ';
} }
out = it.util.cleanUpCode(out);
} else { } else {
if ($breakOnError) { if ($breakOnError) {
out += ' if (true) { '; out += ' if (true) { ';

View File

@@ -77,6 +77,5 @@ module.exports = function generate_contains(it, $keyword, $ruleType) {
if (it.opts.allErrors) { if (it.opts.allErrors) {
out += ' } '; out += ' } ';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

View File

@@ -17,6 +17,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
$propertyDeps = {}, $propertyDeps = {},
$ownProperties = it.opts.ownProperties; $ownProperties = it.opts.ownProperties;
for ($property in $schema) { for ($property in $schema) {
if ($property == '__proto__') continue;
var $sch = $schema[$property]; var $sch = $schema[$property];
var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps; var $deps = Array.isArray($sch) ? $propertyDeps : $schemaDeps;
$deps[$property] = $sch; $deps[$property] = $sch;
@@ -163,6 +164,5 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

1
node_modules/ajv/lib/dotjs/if.js generated vendored
View File

@@ -94,7 +94,6 @@ module.exports = function generate_if(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' else { '; out += ' else { ';
} }
out = it.util.cleanUpCode(out);
} else { } else {
if ($breakOnError) { if ($breakOnError) {
out += ' if (true) { '; out += ' if (true) { ';

View File

@@ -136,6 +136,5 @@ module.exports = function generate_items(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

View File

@@ -16,6 +16,9 @@ module.exports = function generate_multipleOf(it, $keyword, $ruleType) {
} else { } else {
$schemaValue = $schema; $schemaValue = $schema;
} }
if (!($isData || typeof $schema == 'number')) {
throw new Error($keyword + ' must be number');
}
out += 'var division' + ($lvl) + ';if ('; out += 'var division' + ($lvl) + ';if (';
if ($isData) { if ($isData) {
out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || '; out += ' ' + ($schemaValue) + ' !== undefined && ( typeof ' + ($schemaValue) + ' != \'number\' || ';

View File

@@ -18,9 +18,9 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$dataNxt = $it.dataLevel = it.dataLevel + 1, $dataNxt = $it.dataLevel = it.dataLevel + 1,
$nextData = 'data' + $dataNxt, $nextData = 'data' + $dataNxt,
$dataProperties = 'dataProperties' + $lvl; $dataProperties = 'dataProperties' + $lvl;
var $schemaKeys = Object.keys($schema || {}), var $schemaKeys = Object.keys($schema || {}).filter(notProto),
$pProperties = it.schema.patternProperties || {}, $pProperties = it.schema.patternProperties || {},
$pPropertyKeys = Object.keys($pProperties), $pPropertyKeys = Object.keys($pProperties).filter(notProto),
$aProperties = it.schema.additionalProperties, $aProperties = it.schema.additionalProperties,
$someProperties = $schemaKeys.length || $pPropertyKeys.length, $someProperties = $schemaKeys.length || $pPropertyKeys.length,
$noAdditional = $aProperties === false, $noAdditional = $aProperties === false,
@@ -30,7 +30,13 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
$ownProperties = it.opts.ownProperties, $ownProperties = it.opts.ownProperties,
$currentBaseId = it.baseId; $currentBaseId = it.baseId;
var $required = it.schema.required; var $required = it.schema.required;
if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) var $requiredHash = it.util.toHash($required); if ($required && !(it.opts.$data && $required.$data) && $required.length < it.opts.loopRequired) {
var $requiredHash = it.util.toHash($required);
}
function notProto(p) {
return p !== '__proto__';
}
out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;'; out += 'var ' + ($errs) + ' = errors;var ' + ($nextValid) + ' = true;';
if ($ownProperties) { if ($ownProperties) {
out += ' var ' + ($dataProperties) + ' = undefined;'; out += ' var ' + ($dataProperties) + ' = undefined;';
@@ -325,6 +331,5 @@ module.exports = function generate_properties(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

View File

@@ -77,6 +77,5 @@ module.exports = function generate_propertyNames(it, $keyword, $ruleType) {
if ($breakOnError) { if ($breakOnError) {
out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {'; out += ' ' + ($closingBraces) + ' if (' + ($errs) + ' == errors) {';
} }
out = it.util.cleanUpCode(out);
return out; return out;
} }

View File

@@ -29,7 +29,7 @@ module.exports = function generate_uniqueItems(it, $keyword, $ruleType) {
} else { } else {
out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; '; out += ' var itemIndices = {}, item; for (;i--;) { var item = ' + ($data) + '[i]; ';
var $method = 'checkDataType' + ($typeIsArray ? 's' : ''); var $method = 'checkDataType' + ($typeIsArray ? 's' : '');
out += ' if (' + (it.util[$method]($itemType, 'item', true)) + ') continue; '; out += ' if (' + (it.util[$method]($itemType, 'item', it.opts.strictNumbers, true)) + ') continue; ';
if ($typeIsArray) { if ($typeIsArray) {
out += ' if (typeof item == \'string\') item = \'"\' + item; '; out += ' if (typeof item == \'string\') item = \'"\' + item; ';
} }

View File

@@ -149,7 +149,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
var $schemaPath = it.schemaPath + '.type', var $schemaPath = it.schemaPath + '.type',
$errSchemaPath = it.errSchemaPath + '/type', $errSchemaPath = it.errSchemaPath + '/type',
$method = $typeIsArray ? 'checkDataTypes' : 'checkDataType'; $method = $typeIsArray ? 'checkDataTypes' : 'checkDataType';
out += ' if (' + (it.util[$method]($typeSchema, $data, true)) + ') { '; out += ' if (' + (it.util[$method]($typeSchema, $data, it.opts.strictNumbers, true)) + ') { ';
if ($coerceToTypes) { if ($coerceToTypes) {
var $dataType = 'dataType' + $lvl, var $dataType = 'dataType' + $lvl,
$coerced = 'coerced' + $lvl; $coerced = 'coerced' + $lvl;
@@ -302,7 +302,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
$rulesGroup = arr2[i2 += 1]; $rulesGroup = arr2[i2 += 1];
if ($shouldUseGroup($rulesGroup)) { if ($shouldUseGroup($rulesGroup)) {
if ($rulesGroup.type) { if ($rulesGroup.type) {
out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data)) + ') { '; out += ' if (' + (it.util.checkDataType($rulesGroup.type, $data, it.opts.strictNumbers)) + ') { ';
} }
if (it.opts.useDefaults) { if (it.opts.useDefaults) {
if ($rulesGroup.type == 'object' && it.schema.properties) { if ($rulesGroup.type == 'object' && it.schema.properties) {
@@ -470,10 +470,6 @@ module.exports = function generate_validate(it, $keyword, $ruleType) {
} else { } else {
out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';'; out += ' var ' + ($valid) + ' = errors === errs_' + ($lvl) + ';';
} }
out = it.util.cleanUpCode(out);
if ($top) {
out = it.util.finalCleanUpCode(out, $async);
}
function $shouldUseGroup($rulesGroup) { function $shouldUseGroup($rulesGroup) {
var rules = $rulesGroup.rules; var rules = $rulesGroup.rules;

2
node_modules/ajv/lib/keyword.js generated vendored
View File

@@ -46,7 +46,7 @@ function addKeyword(keyword, definition) {
metaSchema = { metaSchema = {
anyOf: [ anyOf: [
metaSchema, metaSchema,
{ '$ref': 'https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#' } { '$ref': 'https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#' }
] ]
}; };
} }

View File

@@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/data.json#", "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",
"description": "Meta-schema for $data reference (JSON Schema extension proposal)", "description": "Meta-schema for $data reference (JSON Schema extension proposal)",
"type": "object", "type": "object",
"required": [ "$data" ], "required": [ "$data" ],

View File

@@ -1,6 +1,6 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://raw.githubusercontent.com/epoberezkin/ajv/master/lib/refs/json-schema-secure.json#", "$id": "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/json-schema-secure.json#",
"title": "Meta-schema for the security assessment of JSON Schemas", "title": "Meta-schema for the security assessment of JSON Schemas",
"description": "If a JSON Schema fails validation against this meta-schema, it may be unsafe to validate untrusted data", "description": "If a JSON Schema fails validation against this meta-schema, it may be unsafe to validate untrusted data",
"definitions": { "definitions": {

38
node_modules/ajv/package.json generated vendored
View File

@@ -1,8 +1,8 @@
{ {
"_from": "ajv@^6.5.5", "_from": "ajv@^6.5.5",
"_id": "ajv@6.11.0", "_id": "ajv@6.12.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-nCprB/0syFYy9fVYU1ox1l2KN8S9I+tziH8D4zdZuLT3N6RMlGSGt5FSTpAiHB/Whv8Qs1cWHma1aMKZyaHRKA==", "_integrity": "sha512-4K0cK3L1hsqk9xIb2z9vs/XU+PGJZ9PNpJRDS9YLzmNdX6jmVPfamLvTJr0aDAusnHyCHO6MjzlkAsgtqp9teA==",
"_location": "/ajv", "_location": "/ajv",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
@@ -18,17 +18,21 @@
"_requiredBy": [ "_requiredBy": [
"/har-validator" "/har-validator"
], ],
"_resolved": "https://registry.npmjs.org/ajv/-/ajv-6.11.0.tgz", "_resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.3.tgz",
"_shasum": "c3607cbc8ae392d8a5a536f25b21f8e5f3f87fe9", "_shasum": "18c5af38a111ddeb4f2697bd78d68abc1cabd706",
"_spec": "ajv@^6.5.5", "_spec": "ajv@^6.5.5",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\har-validator", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\har-validator",
"author": { "author": {
"name": "Evgeny Poberezkin" "name": "Evgeny Poberezkin"
}, },
"bugs": { "bugs": {
"url": "https://github.com/epoberezkin/ajv/issues" "url": "https://github.com/ajv-validator/ajv/issues"
}, },
"bundleDependencies": false, "bundleDependencies": false,
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/ajv"
},
"dependencies": { "dependencies": {
"fast-deep-equal": "^3.1.1", "fast-deep-equal": "^3.1.1",
"fast-json-stable-stringify": "^2.0.0", "fast-json-stable-stringify": "^2.0.0",
@@ -46,22 +50,22 @@
"coveralls": "^3.0.1", "coveralls": "^3.0.1",
"del-cli": "^3.0.0", "del-cli": "^3.0.0",
"dot": "^1.0.3", "dot": "^1.0.3",
"eslint": "^6.0.0", "eslint": "^7.3.1",
"gh-pages-generator": "^0.2.3", "gh-pages-generator": "^0.2.3",
"glob": "^7.0.0", "glob": "^7.0.0",
"if-node-version": "^1.0.0", "if-node-version": "^1.0.0",
"js-beautify": "^1.7.3", "js-beautify": "^1.7.3",
"jshint": "^2.10.2", "jshint": "^2.10.2",
"json-schema-test": "^2.0.0", "json-schema-test": "^2.0.0",
"karma": "^4.0.1", "karma": "^5.0.0",
"karma-chrome-launcher": "^3.0.0", "karma-chrome-launcher": "^3.0.0",
"karma-mocha": "^1.1.1", "karma-mocha": "^2.0.0",
"karma-sauce-launcher": "^2.0.0", "karma-sauce-launcher": "^4.1.3",
"mocha": "^6.0.0", "mocha": "^8.0.1",
"nyc": "^15.0.0", "nyc": "^15.0.0",
"pre-commit": "^1.1.1", "pre-commit": "^1.1.1",
"require-globify": "^1.3.0", "require-globify": "^1.3.0",
"typescript": "^2.8.3", "typescript": "^3.9.5",
"uglify-js": "^3.6.9", "uglify-js": "^3.6.9",
"watch": "^1.0.0" "watch": "^1.0.0"
}, },
@@ -72,7 +76,11 @@
"LICENSE", "LICENSE",
".tonic_example.js" ".tonic_example.js"
], ],
"homepage": "https://github.com/epoberezkin/ajv", "funding": {
"type": "github",
"url": "https://github.com/sponsors/epoberezkin"
},
"homepage": "https://github.com/ajv-validator/ajv",
"keywords": [ "keywords": [
"JSON", "JSON",
"schema", "schema",
@@ -98,7 +106,7 @@
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/epoberezkin/ajv.git" "url": "git+https://github.com/ajv-validator/ajv.git"
}, },
"scripts": { "scripts": {
"build": "del-cli lib/dotjs/*.js \"!lib/dotjs/index.js\" && node scripts/compile-dots.js", "build": "del-cli lib/dotjs/*.js \"!lib/dotjs/index.js\" && node scripts/compile-dots.js",
@@ -121,5 +129,5 @@
}, },
"tonicExampleFilename": ".tonic_example.js", "tonicExampleFilename": ".tonic_example.js",
"typings": "lib/ajv.d.ts", "typings": "lib/ajv.d.ts",
"version": "6.11.0" "version": "6.12.3"
} }

View File

@@ -8,7 +8,7 @@ if [[ -n $TRAVIS_TAG && $TRAVIS_JOB_NUMBER =~ ".3" ]]; then
git config user.email "$GIT_USER_EMAIL" git config user.email "$GIT_USER_EMAIL"
git config user.name "$GIT_USER_NAME" git config user.name "$GIT_USER_NAME"
git clone https://${GITHUB_TOKEN}@github.com/epoberezkin/ajv-dist.git ../ajv-dist git clone https://${GITHUB_TOKEN}@github.com/ajv-validator/ajv-dist.git ../ajv-dist
rm -rf ../ajv-dist/dist rm -rf ../ajv-dist/dist
mkdir ../ajv-dist/dist mkdir ../ajv-dist/dist

View File

@@ -5,7 +5,7 @@ set -e
if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && $TRAVIS_JOB_NUMBER =~ ".3" ]]; then if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && $TRAVIS_JOB_NUMBER =~ ".3" ]]; then
git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qE '\.md$|^LICENSE$|travis-gh-pages$' && { git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qE '\.md$|^LICENSE$|travis-gh-pages$' && {
rm -rf ../gh-pages rm -rf ../gh-pages
git clone -b gh-pages --single-branch https://${GITHUB_TOKEN}@github.com/epoberezkin/ajv.git ../gh-pages git clone -b gh-pages --single-branch https://${GITHUB_TOKEN}@github.com/ajv-validator/ajv.git ../gh-pages
mkdir -p ../gh-pages/_source mkdir -p ../gh-pages/_source
cp *.md ../gh-pages/_source cp *.md ../gh-pages/_source
cp LICENSE ../gh-pages/_source cp LICENSE ../gh-pages/_source

View File

@@ -1 +0,0 @@
.DS_Store*

11
node_modules/array-equal/README.md generated vendored
View File

@@ -1,11 +0,0 @@
# Array Equal
Check if two arrays are equal:
```js
var equals = require('array-equal')
assert(equals([1, 2, 3], [1, 2, 3])) // => true
assert(equals([1, 2, 3], [1, 2, 3, 4])) // => false
```

View File

@@ -1,10 +0,0 @@
{
"name": "array-equal",
"description": "check if two arrays are equal",
"version": "1.0.0",
"license": "MIT",
"repository": "component/array-equal",
"scripts": [
"index.js"
]
}

9
node_modules/array-equal/index.js generated vendored
View File

@@ -1,9 +0,0 @@
module.exports = function equal(arr1, arr2) {
var length = arr1.length
if (length !== arr2.length) return false
for (var i = 0; i < length; i++)
if (arr1[i] !== arr2[i])
return false
return true
}

View File

@@ -1,44 +0,0 @@
{
"_from": "array-equal@^1.0.0",
"_id": "array-equal@1.0.0",
"_inBundle": false,
"_integrity": "sha1-jCpe8kcv2ep0KwTHenUJO6J1fJM=",
"_location": "/array-equal",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "array-equal@^1.0.0",
"name": "array-equal",
"escapedName": "array-equal",
"rawSpec": "^1.0.0",
"saveSpec": null,
"fetchSpec": "^1.0.0"
},
"_requiredBy": [
"/jsdom"
],
"_resolved": "https://registry.npmjs.org/array-equal/-/array-equal-1.0.0.tgz",
"_shasum": "8c2a5ef2472fd9ea742b04c77a75093ba2757c93",
"_spec": "array-equal@^1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\jsdom",
"author": {
"name": "Jonathan Ong",
"email": "me@jongleberry.com",
"url": "http://jongleberry.com"
},
"bugs": {
"url": "https://github.com/component/array-equal/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "check if two arrays are equal",
"homepage": "https://github.com/component/array-equal#readme",
"license": "MIT",
"name": "array-equal",
"repository": {
"type": "git",
"url": "git+https://github.com/component/array-equal.git"
},
"version": "1.0.0"
}

2
node_modules/asn1/package.json generated vendored
View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz", "_resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.4.tgz",
"_shasum": "8d2475dfab553bb33e77b54e59e880bb8ce23136", "_shasum": "8d2475dfab553bb33e77b54e59e880bb8ce23136",
"_spec": "asn1@~0.2.3", "_spec": "asn1@~0.2.3",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\sshpk", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\sshpk",
"author": { "author": {
"name": "Joyent", "name": "Joyent",
"url": "joyent.com" "url": "joyent.com"

View File

@@ -26,7 +26,7 @@
"_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", "_resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz",
"_shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525", "_shasum": "f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525",
"_spec": "assert-plus@^1.0.0", "_spec": "assert-plus@^1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\http-signature", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\http-signature",
"author": { "author": {
"name": "Mark Cavage", "name": "Mark Cavage",
"email": "mcavage@gmail.com" "email": "mcavage@gmail.com"

View File

@@ -1,2 +0,0 @@
coverage
.nyc_output

10
node_modules/async-limiter/.nycrc generated vendored
View File

@@ -1,10 +0,0 @@
{
"check-coverage": false,
"lines": 99,
"statements": 99,
"functions": 99,
"branches": 99,
"include": [
"index.js"
]
}

View File

@@ -1,9 +0,0 @@
language: node_js
node_js:
- "6"
- "8"
- "10"
- "node"
script: npm run travis
cache:
yarn: true

8
node_modules/async-limiter/LICENSE generated vendored
View File

@@ -1,8 +0,0 @@
The MIT License (MIT)
Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

67
node_modules/async-limiter/index.js generated vendored
View File

@@ -1,67 +0,0 @@
'use strict';
function Queue(options) {
if (!(this instanceof Queue)) {
return new Queue(options);
}
options = options || {};
this.concurrency = options.concurrency || Infinity;
this.pending = 0;
this.jobs = [];
this.cbs = [];
this._done = done.bind(this);
}
var arrayAddMethods = [
'push',
'unshift',
'splice'
];
arrayAddMethods.forEach(function(method) {
Queue.prototype[method] = function() {
var methodResult = Array.prototype[method].apply(this.jobs, arguments);
this._run();
return methodResult;
};
});
Object.defineProperty(Queue.prototype, 'length', {
get: function() {
return this.pending + this.jobs.length;
}
});
Queue.prototype._run = function() {
if (this.pending === this.concurrency) {
return;
}
if (this.jobs.length) {
var job = this.jobs.shift();
this.pending++;
job(this._done);
this._run();
}
if (this.pending === 0) {
while (this.cbs.length !== 0) {
var cb = this.cbs.pop();
process.nextTick(cb);
}
}
};
Queue.prototype.onDone = function(cb) {
if (typeof cb === 'function') {
this.cbs.push(cb);
this._run();
}
};
function done() {
this.pending--;
this._run();
}
module.exports = Queue;

View File

@@ -1,69 +0,0 @@
{
"_from": "async-limiter@~1.0.0",
"_id": "async-limiter@1.0.1",
"_inBundle": false,
"_integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==",
"_location": "/async-limiter",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "async-limiter@~1.0.0",
"name": "async-limiter",
"escapedName": "async-limiter",
"rawSpec": "~1.0.0",
"saveSpec": null,
"fetchSpec": "~1.0.0"
},
"_requiredBy": [
"/ws"
],
"_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
"_shasum": "dd379e94f0db8310b08291f9d64c3209766617fd",
"_spec": "async-limiter@~1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\ws",
"author": {
"name": "Samuel Reed"
},
"bugs": {
"url": "https://github.com/strml/async-limiter/issues"
},
"bundleDependencies": false,
"dependencies": {},
"deprecated": false,
"description": "asynchronous function queue with adjustable concurrency",
"devDependencies": {
"coveralls": "^3.0.3",
"eslint": "^5.16.0",
"eslint-plugin-mocha": "^5.3.0",
"intelli-espower-loader": "^1.0.1",
"mocha": "^6.1.4",
"nyc": "^14.1.1",
"power-assert": "^1.6.1"
},
"homepage": "https://github.com/strml/async-limiter#readme",
"keywords": [
"throttle",
"async",
"limiter",
"asynchronous",
"job",
"task",
"concurrency",
"concurrent"
],
"license": "MIT",
"name": "async-limiter",
"repository": {
"type": "git",
"url": "git+https://github.com/strml/async-limiter.git"
},
"scripts": {
"coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"example": "node example",
"lint": "eslint .",
"test": "mocha --require intelli-espower-loader test/",
"travis": "npm run lint && npm run test"
},
"version": "1.0.1"
}

132
node_modules/async-limiter/readme.md generated vendored
View File

@@ -1,132 +0,0 @@
# Async-Limiter
A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
[![npm](http://img.shields.io/npm/v/async-limiter.svg?style=flat-square)](http://www.npmjs.org/async-limiter)
[![tests](https://img.shields.io/travis/STRML/async-limiter.svg?style=flat-square&branch=master)](https://travis-ci.org/STRML/async-limiter)
[![coverage](https://img.shields.io/coveralls/STRML/async-limiter.svg?style=flat-square&branch=master)](https://coveralls.io/r/STRML/async-limiter)
This module exports a class `Limiter` that implements some of the `Array` API.
Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
## Motivation
Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
run at infinite concurrency.
In this case, it is actually faster, and takes far less memory, to limit concurrency.
This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
make this module faster or lighter, but new functionality is not desired.
Style should confirm to nodejs/node style.
## Example
``` javascript
var Limiter = require('async-limiter')
var t = new Limiter({concurrency: 2});
var results = []
// add jobs using the familiar Array API
t.push(function (cb) {
results.push('two')
cb()
})
t.push(
function (cb) {
results.push('four')
cb()
},
function (cb) {
results.push('five')
cb()
}
)
t.unshift(function (cb) {
results.push('one')
cb()
})
t.splice(2, 0, function (cb) {
results.push('three')
cb()
})
// Jobs run automatically. If you want a callback when all are done,
// call 'onDone()'.
t.onDone(function () {
console.log('all done:', results)
})
```
## Zlib Example
```js
const zlib = require('zlib');
const Limiter = require('async-limiter');
const message = {some: "data"};
const payload = new Buffer(JSON.stringify(message));
// Try with different concurrency values to see how this actually
// slows significantly with higher concurrency!
//
// 5: 1398.607ms
// 10: 1375.668ms
// Infinity: 4423.300ms
//
const t = new Limiter({concurrency: 5});
function deflate(payload, cb) {
t.push(function(done) {
zlib.deflate(payload, function(err, buffer) {
done();
cb(err, buffer);
});
});
}
console.time('deflate');
for(let i = 0; i < 30000; ++i) {
deflate(payload, function (err, buffer) {});
}
t.onDone(function() {
console.timeEnd('deflate');
});
```
## Install
`npm install async-limiter`
## Test
`npm test`
## API
### `var t = new Limiter([opts])`
Constructor. `opts` may contain inital values for:
* `t.concurrency`
## Instance methods
### `t.onDone(fn)`
`fn` will be called once and only once, when the queue is empty.
## Instance methods mixed in from `Array`
Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
### `t.push(element1, ..., elementN)`
### `t.unshift(element1, ..., elementN)`
### `t.splice(index , howMany[, element1[, ...[, elementN]]])`
## Properties
### `t.concurrency`
Max number of jobs the queue should process concurrently, defaults to `Infinity`.
### `t.length`
Jobs pending + jobs to process (readonly).

2
node_modules/asynckit/package.json generated vendored
View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "_resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79", "_shasum": "c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79",
"_spec": "asynckit@^0.4.0", "_spec": "asynckit@^0.4.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\form-data", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\form-data",
"author": { "author": {
"name": "Alex Indigo", "name": "Alex Indigo",
"email": "iam@alexindigo.com" "email": "iam@alexindigo.com"

View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", "_resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz",
"_shasum": "b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8", "_shasum": "b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8",
"_spec": "aws-sign2@~0.7.0", "_spec": "aws-sign2@~0.7.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\request", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\request",
"author": { "author": {
"name": "Mikeal Rogers", "name": "Mikeal Rogers",
"email": "mikeal.rogers@gmail.com", "email": "mikeal.rogers@gmail.com",

429
node_modules/aws4/README.md generated vendored
View File

@@ -1,60 +1,16 @@
aws4 aws4
---- ----
[![Build Status](https://secure.travis-ci.org/mhart/aws4.png?branch=master)](http://travis-ci.org/mhart/aws4) [![Build Status](https://api.travis-ci.org/mhart/aws4.png?branch=master)](https://travis-ci.org/github/mhart/aws4)
A small utility to sign vanilla Node.js http(s) request options using Amazon's A small utility to sign vanilla Node.js http(s) request options using Amazon's
[AWS Signature Version 4](http://docs.amazonwebservices.com/general/latest/gr/signature-version-4.html). [AWS Signature Version 4](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html).
If you want to sign and send AWS requests in a modern browser, or an environment like [Cloudflare Workers](https://developers.cloudflare.com/workers/), then check out [aws4fetch](https://github.com/mhart/aws4fetch) otherwise you can also bundle this library for use [in the browser](./browser). If you want to sign and send AWS requests in a modern browser, or an environment like [Cloudflare Workers](https://developers.cloudflare.com/workers/), then check out [aws4fetch](https://github.com/mhart/aws4fetch) otherwise you can also bundle this library for use [in older browsers](./browser).
This signature is supported by nearly all Amazon services, including The only AWS service that *doesn't* support v4 as of 2020-05-22 is
[S3](http://docs.aws.amazon.com/AmazonS3/latest/API/), [SimpleDB](https://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API.html)
[EC2](http://docs.aws.amazon.com/AWSEC2/latest/APIReference/), (it only supports [AWS Signature Version 2](https://github.com/mhart/aws2)).
[DynamoDB](http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/API.html),
[Kinesis](http://docs.aws.amazon.com/kinesis/latest/APIReference/),
[Lambda](http://docs.aws.amazon.com/lambda/latest/dg/API_Reference.html),
[SQS](http://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/),
[SNS](http://docs.aws.amazon.com/sns/latest/api/),
[IAM](http://docs.aws.amazon.com/IAM/latest/APIReference/),
[STS](http://docs.aws.amazon.com/STS/latest/APIReference/),
[RDS](http://docs.aws.amazon.com/AmazonRDS/latest/APIReference/),
[CloudWatch](http://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/),
[CloudWatch Logs](http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/),
[CodeDeploy](http://docs.aws.amazon.com/codedeploy/latest/APIReference/),
[CloudFront](http://docs.aws.amazon.com/AmazonCloudFront/latest/APIReference/),
[CloudTrail](http://docs.aws.amazon.com/awscloudtrail/latest/APIReference/),
[ElastiCache](http://docs.aws.amazon.com/AmazonElastiCache/latest/APIReference/),
[EMR](http://docs.aws.amazon.com/ElasticMapReduce/latest/API/),
[Glacier](http://docs.aws.amazon.com/amazonglacier/latest/dev/amazon-glacier-api.html),
[CloudSearch](http://docs.aws.amazon.com/cloudsearch/latest/developerguide/APIReq.html),
[Elastic Load Balancing](http://docs.aws.amazon.com/ElasticLoadBalancing/latest/APIReference/),
[Elastic Transcoder](http://docs.aws.amazon.com/elastictranscoder/latest/developerguide/api-reference.html),
[CloudFormation](http://docs.aws.amazon.com/AWSCloudFormation/latest/APIReference/),
[Elastic Beanstalk](http://docs.aws.amazon.com/elasticbeanstalk/latest/api/),
[Storage Gateway](http://docs.aws.amazon.com/storagegateway/latest/userguide/AWSStorageGatewayAPI.html),
[Data Pipeline](http://docs.aws.amazon.com/datapipeline/latest/APIReference/),
[Direct Connect](http://docs.aws.amazon.com/directconnect/latest/APIReference/),
[Redshift](http://docs.aws.amazon.com/redshift/latest/APIReference/),
[OpsWorks](http://docs.aws.amazon.com/opsworks/latest/APIReference/),
[SES](http://docs.aws.amazon.com/ses/latest/APIReference/),
[SWF](http://docs.aws.amazon.com/amazonswf/latest/apireference/),
[AutoScaling](http://docs.aws.amazon.com/AutoScaling/latest/APIReference/),
[Mobile Analytics](http://docs.aws.amazon.com/mobileanalytics/latest/ug/server-reference.html),
[Cognito Identity](http://docs.aws.amazon.com/cognitoidentity/latest/APIReference/),
[Cognito Sync](http://docs.aws.amazon.com/cognitosync/latest/APIReference/),
[Container Service](http://docs.aws.amazon.com/AmazonECS/latest/APIReference/),
[AppStream](http://docs.aws.amazon.com/appstream/latest/developerguide/appstream-api-rest.html),
[Key Management Service](http://docs.aws.amazon.com/kms/latest/APIReference/),
[Config](http://docs.aws.amazon.com/config/latest/APIReference/),
[CloudHSM](http://docs.aws.amazon.com/cloudhsm/latest/dg/api-ref.html),
[Route53](http://docs.aws.amazon.com/Route53/latest/APIReference/requests-rest.html) and
[Route53 Domains](http://docs.aws.amazon.com/Route53/latest/APIReference/requests-rpc.html).
Indeed, the only AWS services that *don't* support v4 as of 2014-12-30 are
[Import/Export](http://docs.aws.amazon.com/AWSImportExport/latest/DG/api-reference.html) and
[SimpleDB](http://docs.aws.amazon.com/AmazonSimpleDB/latest/DeveloperGuide/SDB_API.html)
(they only support [AWS Signature Version 2](https://github.com/mhart/aws2)).
It also provides defaults for a number of core AWS headers and It also provides defaults for a number of core AWS headers and
request parameters, making it very easy to query AWS services, or request parameters, making it very easy to query AWS services, or
@@ -64,21 +20,34 @@ Example
------- -------
```javascript ```javascript
var http = require('http'), var http = require('https')
https = require('https'), var aws4 = require('aws4')
aws4 = require('aws4')
// given an options object you could pass to http.request // to illustrate usage, we'll create a utility function to request and pipe to stdout
var opts = {host: 'sqs.us-east-1.amazonaws.com', path: '/?Action=ListQueues'} function request(opts) { http.request(opts, function(res) { res.pipe(process.stdout) }).end(opts.body || '') }
// alternatively (as aws4 can infer the host): // aws4 will sign an options object as you'd pass to http.request, with an AWS service and region
var opts = { host: 'my-bucket.s3.us-west-1.amazonaws.com', path: '/my-object', service: 's3', region: 'us-west-1' }
// aws4.sign() will sign and modify these options, ready to pass to http.request
aws4.sign(opts, { accessKeyId: '', secretAccessKey: '' })
// or it can get credentials from process.env.AWS_ACCESS_KEY_ID, etc
aws4.sign(opts)
// for most AWS services, aws4 can figure out the service and region if you pass a host
opts = { host: 'my-bucket.s3.us-west-1.amazonaws.com', path: '/my-object' }
// usually it will add/modify request headers, but you can also sign the query:
opts = { host: 'my-bucket.s3.amazonaws.com', path: '/?X-Amz-Expires=12345', signQuery: true }
// and for services with simple hosts, aws4 can infer the host from service and region:
opts = { service: 'sqs', region: 'us-east-1', path: '/?Action=ListQueues' } opts = { service: 'sqs', region: 'us-east-1', path: '/?Action=ListQueues' }
// alternatively (as us-east-1 is default): // and if you're using us-east-1, it's the default:
opts = { service: 'sqs', path: '/?Action=ListQueues' } opts = { service: 'sqs', path: '/?Action=ListQueues' }
aws4.sign(opts) // assumes AWS credentials are available in process.env aws4.sign(opts)
console.log(opts) console.log(opts)
/* /*
{ {
@@ -92,27 +61,13 @@ console.log(opts)
} }
*/ */
// we can now use this to query AWS using the standard node.js http API // we can now use this to query AWS
http.request(opts, function(res) { res.pipe(process.stdout) }).end() request(opts)
/* /*
<?xml version="1.0"?> <?xml version="1.0"?>
<ListQueuesResponse xmlns="http://queue.amazonaws.com/doc/2012-11-05/"> <ListQueuesResponse xmlns="https://queue.amazonaws.com/doc/2012-11-05/">
... ...
*/ */
```
More options
------------
```javascript
// you can also pass AWS credentials in explicitly (otherwise taken from process.env)
aws4.sign(opts, {accessKeyId: '', secretAccessKey: ''})
// can also add the signature to query strings
aws4.sign({service: 's3', path: '/my-bucket?X-Amz-Expires=12345', signQuery: true})
// create a utility function to pipe to stdout (with https this time)
function request(o) { https.request(o, function(res) { res.pipe(process.stdout) }).end(o.body || '') }
// aws4 can infer the HTTP method if a body is passed in // aws4 can infer the HTTP method if a body is passed in
// method will be POST and Content-Type: 'application/x-www-form-urlencoded; charset=utf-8' // method will be POST and Content-Type: 'application/x-www-form-urlencoded; charset=utf-8'
@@ -122,7 +77,7 @@ request(aws4.sign({service: 'iam', body: 'Action=ListGroups&Version=2010-05-08'}
... ...
*/ */
// can specify any custom option or header as per usual // you can specify any custom option or header as per usual
request(aws4.sign({ request(aws4.sign({
service: 'dynamodb', service: 'dynamodb',
region: 'ap-southeast-2', region: 'ap-southeast-2',
@@ -139,310 +94,7 @@ request(aws4.sign({
... ...
*/ */
// works with all other services that support Signature Version 4 // see example.js for examples with other services
request(aws4.sign({service: 's3', path: '/', signQuery: true}))
/*
<ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
...
*/
request(aws4.sign({service: 'ec2', path: '/?Action=DescribeRegions&Version=2014-06-15'}))
/*
<DescribeRegionsResponse xmlns="http://ec2.amazonaws.com/doc/2014-06-15/">
...
*/
request(aws4.sign({service: 'sns', path: '/?Action=ListTopics&Version=2010-03-31'}))
/*
<ListTopicsResponse xmlns="http://sns.amazonaws.com/doc/2010-03-31/">
...
*/
request(aws4.sign({service: 'sts', path: '/?Action=GetSessionToken&Version=2011-06-15'}))
/*
<GetSessionTokenResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
...
*/
request(aws4.sign({service: 'cloudsearch', path: '/?Action=ListDomainNames&Version=2013-01-01'}))
/*
<ListDomainNamesResponse xmlns="http://cloudsearch.amazonaws.com/doc/2013-01-01/">
...
*/
request(aws4.sign({service: 'ses', path: '/?Action=ListIdentities&Version=2010-12-01'}))
/*
<ListIdentitiesResponse xmlns="http://ses.amazonaws.com/doc/2010-12-01/">
...
*/
request(aws4.sign({service: 'autoscaling', path: '/?Action=DescribeAutoScalingInstances&Version=2011-01-01'}))
/*
<DescribeAutoScalingInstancesResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
...
*/
request(aws4.sign({service: 'elasticloadbalancing', path: '/?Action=DescribeLoadBalancers&Version=2012-06-01'}))
/*
<DescribeLoadBalancersResponse xmlns="http://elasticloadbalancing.amazonaws.com/doc/2012-06-01/">
...
*/
request(aws4.sign({service: 'cloudformation', path: '/?Action=ListStacks&Version=2010-05-15'}))
/*
<ListStacksResponse xmlns="http://cloudformation.amazonaws.com/doc/2010-05-15/">
...
*/
request(aws4.sign({service: 'elasticbeanstalk', path: '/?Action=ListAvailableSolutionStacks&Version=2010-12-01'}))
/*
<ListAvailableSolutionStacksResponse xmlns="http://elasticbeanstalk.amazonaws.com/docs/2010-12-01/">
...
*/
request(aws4.sign({service: 'rds', path: '/?Action=DescribeDBInstances&Version=2012-09-17'}))
/*
<DescribeDBInstancesResponse xmlns="http://rds.amazonaws.com/doc/2012-09-17/">
...
*/
request(aws4.sign({service: 'monitoring', path: '/?Action=ListMetrics&Version=2010-08-01'}))
/*
<ListMetricsResponse xmlns="http://monitoring.amazonaws.com/doc/2010-08-01/">
...
*/
request(aws4.sign({service: 'redshift', path: '/?Action=DescribeClusters&Version=2012-12-01'}))
/*
<DescribeClustersResponse xmlns="http://redshift.amazonaws.com/doc/2012-12-01/">
...
*/
request(aws4.sign({service: 'cloudfront', path: '/2014-05-31/distribution'}))
/*
<DistributionList xmlns="http://cloudfront.amazonaws.com/doc/2014-05-31/">
...
*/
request(aws4.sign({service: 'elasticache', path: '/?Action=DescribeCacheClusters&Version=2014-07-15'}))
/*
<DescribeCacheClustersResponse xmlns="http://elasticache.amazonaws.com/doc/2014-07-15/">
...
*/
request(aws4.sign({service: 'elasticmapreduce', path: '/?Action=DescribeJobFlows&Version=2009-03-31'}))
/*
<DescribeJobFlowsResponse xmlns="http://elasticmapreduce.amazonaws.com/doc/2009-03-31">
...
*/
request(aws4.sign({service: 'route53', path: '/2013-04-01/hostedzone'}))
/*
<ListHostedZonesResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
...
*/
request(aws4.sign({service: 'appstream', path: '/applications'}))
/*
{"_links":{"curie":[{"href":"http://docs.aws.amazon.com/appstream/latest/...
...
*/
request(aws4.sign({service: 'cognito-sync', path: '/identitypools'}))
/*
{"Count":0,"IdentityPoolUsages":[],"MaxResults":16,"NextToken":null}
...
*/
request(aws4.sign({service: 'elastictranscoder', path: '/2012-09-25/pipelines'}))
/*
{"NextPageToken":null,"Pipelines":[]}
...
*/
request(aws4.sign({service: 'lambda', path: '/2014-11-13/functions/'}))
/*
{"Functions":[],"NextMarker":null}
...
*/
request(aws4.sign({service: 'ecs', path: '/?Action=ListClusters&Version=2014-11-13'}))
/*
<ListClustersResponse xmlns="http://ecs.amazonaws.com/doc/2014-11-13/">
...
*/
request(aws4.sign({service: 'glacier', path: '/-/vaults', headers: {'X-Amz-Glacier-Version': '2012-06-01'}}))
/*
{"Marker":null,"VaultList":[]}
...
*/
request(aws4.sign({service: 'storagegateway', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'StorageGateway_20120630.ListGateways'
}}))
/*
{"Gateways":[]}
...
*/
request(aws4.sign({service: 'datapipeline', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'DataPipeline.ListPipelines'
}}))
/*
{"hasMoreResults":false,"pipelineIdList":[]}
...
*/
request(aws4.sign({service: 'opsworks', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'OpsWorks_20130218.DescribeStacks'
}}))
/*
{"Stacks":[]}
...
*/
request(aws4.sign({service: 'route53domains', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Route53Domains_v20140515.ListDomains'
}}))
/*
{"Domains":[]}
...
*/
request(aws4.sign({service: 'kinesis', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Kinesis_20131202.ListStreams'
}}))
/*
{"HasMoreStreams":false,"StreamNames":[]}
...
*/
request(aws4.sign({service: 'cloudtrail', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'CloudTrail_20131101.DescribeTrails'
}}))
/*
{"trailList":[]}
...
*/
request(aws4.sign({service: 'logs', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Logs_20140328.DescribeLogGroups'
}}))
/*
{"logGroups":[]}
...
*/
request(aws4.sign({service: 'codedeploy', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'CodeDeploy_20141006.ListApplications'
}}))
/*
{"applications":[]}
...
*/
request(aws4.sign({service: 'directconnect', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'OvertureService.DescribeConnections'
}}))
/*
{"connections":[]}
...
*/
request(aws4.sign({service: 'kms', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'TrentService.ListKeys'
}}))
/*
{"Keys":[],"Truncated":false}
...
*/
request(aws4.sign({service: 'config', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'StarlingDoveService.DescribeDeliveryChannels'
}}))
/*
{"DeliveryChannels":[]}
...
*/
request(aws4.sign({service: 'cloudhsm', body: '{}', headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'CloudHsmFrontendService.ListAvailableZones'
}}))
/*
{"AZList":["us-east-1a","us-east-1b","us-east-1c"]}
...
*/
request(aws4.sign({
service: 'swf',
body: '{"registrationStatus":"REGISTERED"}',
headers: {
'Content-Type': 'application/x-amz-json-1.0',
'X-Amz-Target': 'SimpleWorkflowService.ListDomains'
}
}))
/*
{"domainInfos":[]}
...
*/
request(aws4.sign({
service: 'cognito-identity',
body: '{"MaxResults": 1}',
headers: {
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityService.ListIdentityPools'
}
}))
/*
{"IdentityPools":[]}
...
*/
request(aws4.sign({
service: 'mobileanalytics',
path: '/2014-06-05/events',
body: JSON.stringify({events:[{
eventType: 'a',
timestamp: new Date().toISOString(),
session: {},
}]}),
headers: {
'Content-Type': 'application/json',
'X-Amz-Client-Context': JSON.stringify({
client: {client_id: 'a', app_title: 'a'},
custom: {},
env: {platform: 'a'},
services: {},
}),
}
}))
/*
(HTTP 202, empty response)
*/
// Generate CodeCommit Git access password
var signer = new aws4.RequestSigner({
service: 'codecommit',
host: 'git-codecommit.us-east-1.amazonaws.com',
method: 'GIT',
path: '/v1/repos/MyAwesomeRepo',
})
var password = signer.getDateTime() + 'Z' + signer.signature()
``` ```
API API
@@ -455,18 +107,18 @@ This calculates and populates the `Authorization` header of
options. Returns `requestOptions` as a convenience for chaining. options. Returns `requestOptions` as a convenience for chaining.
`requestOptions` is an object holding the same options that the node.js `requestOptions` is an object holding the same options that the node.js
[http.request](http://nodejs.org/docs/latest/api/http.html#http_http_request_options_callback) [http.request](https://nodejs.org/docs/latest/api/http.html#http_http_request_options_callback)
function takes. function takes.
The following properties of `requestOptions` are used in the signing or The following properties of `requestOptions` are used in the signing or
populated if they don't already exist: populated if they don't already exist:
- `hostname` or `host` (will be determined from `service` and `region` if not given) - `hostname` or `host` (will try to be determined from `service` and `region` if not given)
- `method` (will use `'GET'` if not given or `'POST'` if there is a `body`) - `method` (will use `'GET'` if not given or `'POST'` if there is a `body`)
- `path` (will use `'/'` if not given) - `path` (will use `'/'` if not given)
- `body` (will use `''` if not given) - `body` (will use `''` if not given)
- `service` (will be calculated from `hostname` or `host` if not given) - `service` (will try to be calculated from `hostname` or `host` if not given)
- `region` (will be calculated from `hostname` or `host` or use `'us-east-1'` if not given) - `region` (will try to be calculated from `hostname` or `host` or use `'us-east-1'` if not given)
- `headers['Host']` (will use `hostname` or `host` or be calculated if not given) - `headers['Host']` (will use `hostname` or `host` or be calculated if not given)
- `headers['Content-Type']` (will use `'application/x-www-form-urlencoded; charset=utf-8'` - `headers['Content-Type']` (will use `'application/x-www-form-urlencoded; charset=utf-8'`
if not given and there is a `body`) if not given and there is a `body`)
@@ -489,20 +141,20 @@ aws4.sign(requestOptions, {
- From `process.env`, such as this: - From `process.env`, such as this:
``` ```
export AWS_SECRET_ACCESS_KEY="<your-secret-access-key>"
export AWS_ACCESS_KEY_ID="<your-access-key-id>" export AWS_ACCESS_KEY_ID="<your-access-key-id>"
export AWS_SECRET_ACCESS_KEY="<your-secret-access-key>"
export AWS_SESSION_TOKEN="<your-session-token>" export AWS_SESSION_TOKEN="<your-session-token>"
``` ```
(will also use `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` if available) (will also use `AWS_ACCESS_KEY` and `AWS_SECRET_KEY` if available)
The `sessionToken` property and `AWS_SESSION_TOKEN` environment variable are optional for signing The `sessionToken` property and `AWS_SESSION_TOKEN` environment variable are optional for signing
with [IAM STS temporary credentials](http://docs.aws.amazon.com/STS/latest/UsingSTS/using-temp-creds.html). with [IAM STS temporary credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_use-resources.html).
Installation Installation
------------ ------------
With [npm](http://npmjs.org/) do: With [npm](https://www.npmjs.com/) do:
``` ```
npm install aws4 npm install aws4
@@ -520,4 +172,3 @@ committed and subsequently extracted this code.
Also thanks to the Also thanks to the
[official node.js AWS SDK](https://github.com/aws/aws-sdk-js) for giving [official node.js AWS SDK](https://github.com/aws/aws-sdk-js) for giving
me a start on implementing the v4 signature. me a start on implementing the v4 signature.

22
node_modules/aws4/aws4.js generated vendored
View File

@@ -33,7 +33,7 @@ function RequestSigner(request, credentials) {
if (typeof request === 'string') request = url.parse(request) if (typeof request === 'string') request = url.parse(request)
var headers = request.headers = (request.headers || {}), var headers = request.headers = (request.headers || {}),
hostParts = this.matchHost(request.hostname || request.host || headers.Host || headers.host) hostParts = (!this.service || !this.region) && this.matchHost(request.hostname || request.host || headers.Host || headers.host)
this.request = request this.request = request
this.credentials = credentials || this.defaultCredentials() this.credentials = credentials || this.defaultCredentials()
@@ -70,6 +70,19 @@ RequestSigner.prototype.matchHost = function(host) {
if (hostParts[1] === 'es') if (hostParts[1] === 'es')
hostParts = hostParts.reverse() hostParts = hostParts.reverse()
if (hostParts[1] == 's3') {
hostParts[0] = 's3'
hostParts[1] = 'us-east-1'
} else {
for (var i = 0; i < 2; i++) {
if (/^s3-/.test(hostParts[i])) {
hostParts[1] = hostParts[i].slice(3)
hostParts[0] = 's3'
break
}
}
}
return hostParts return hostParts
} }
@@ -83,10 +96,9 @@ RequestSigner.prototype.isSingleRegion = function() {
} }
RequestSigner.prototype.createHost = function() { RequestSigner.prototype.createHost = function() {
var region = this.isSingleRegion() ? '' : var region = this.isSingleRegion() ? '' : '.' + this.region,
(this.service === 's3' && this.region !== 'us-east-1' ? '-' : '.') + this.region, subdomain = this.service === 'ses' ? 'email' : this.service
service = this.service === 'ses' ? 'email' : this.service return subdomain + region + '.amazonaws.com'
return service + region + '.amazonaws.com'
} }
RequestSigner.prototype.prepareRequest = function() { RequestSigner.prototype.prepareRequest = function() {

72
node_modules/aws4/package.json generated vendored
View File

@@ -1,8 +1,8 @@
{ {
"_from": "aws4@^1.8.0", "_from": "aws4@^1.8.0",
"_id": "aws4@1.9.1", "_id": "aws4@1.10.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", "_integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA==",
"_location": "/aws4", "_location": "/aws4",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
@@ -18,14 +18,14 @@
"_requiredBy": [ "_requiredBy": [
"/request" "/request"
], ],
"_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", "_resolved": "https://registry.npmjs.org/aws4/-/aws4-1.10.0.tgz",
"_shasum": "7e33d8f7d449b3f673cd72deb9abdc552dbe528e", "_shasum": "a17b3a8ea811060e74d47d306122400ad4497ae2",
"_spec": "aws4@^1.8.0", "_spec": "aws4@^1.8.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\request", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\request",
"author": { "author": {
"name": "Michael Hart", "name": "Michael Hart",
"email": "michael.hart.au@gmail.com", "email": "michael.hart.au@gmail.com",
"url": "http://github.com/mhart" "url": "https://github.com/mhart"
}, },
"bugs": { "bugs": {
"url": "https://github.com/mhart/aws4/issues" "url": "https://github.com/mhart/aws4/issues"
@@ -34,62 +34,10 @@
"deprecated": false, "deprecated": false,
"description": "Signs and prepares requests using AWS Signature Version 4", "description": "Signs and prepares requests using AWS Signature Version 4",
"devDependencies": { "devDependencies": {
"mocha": "^2.4.5", "mocha": "^7.1.2",
"should": "^8.2.2" "should": "^13.2.3"
}, },
"homepage": "https://github.com/mhart/aws4#readme", "homepage": "https://github.com/mhart/aws4#readme",
"keywords": [
"amazon",
"aws",
"signature",
"s3",
"ec2",
"autoscaling",
"cloudformation",
"elasticloadbalancing",
"elb",
"elasticbeanstalk",
"cloudsearch",
"dynamodb",
"kinesis",
"lambda",
"glacier",
"sqs",
"sns",
"iam",
"sts",
"ses",
"swf",
"storagegateway",
"datapipeline",
"directconnect",
"redshift",
"opsworks",
"rds",
"monitoring",
"cloudtrail",
"cloudfront",
"codedeploy",
"elasticache",
"elasticmapreduce",
"elastictranscoder",
"emr",
"cloudwatch",
"mobileanalytics",
"cognitoidentity",
"cognitosync",
"cognito",
"containerservice",
"ecs",
"appstream",
"keymanagementservice",
"kms",
"config",
"cloudhsm",
"route53",
"route53domains",
"logs"
],
"license": "MIT", "license": "MIT",
"main": "aws4.js", "main": "aws4.js",
"name": "aws4", "name": "aws4",
@@ -99,7 +47,7 @@
}, },
"scripts": { "scripts": {
"integration": "node ./test/slow.js", "integration": "node ./test/slow.js",
"test": "mocha ./test/fast.js -b -t 100s -R list" "test": "mocha ./test/fast.js -R list"
}, },
"version": "1.9.1" "version": "1.10.0"
} }

View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz", "_resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
"_shasum": "a4301d389b6a43f9b67ff3ca11a3f6637e360e9e", "_shasum": "a4301d389b6a43f9b67ff3ca11a3f6637e360e9e",
"_spec": "bcrypt-pbkdf@^1.0.0", "_spec": "bcrypt-pbkdf@^1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\sshpk", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\sshpk",
"bugs": { "bugs": {
"url": "https://github.com/joyent/node-bcrypt-pbkdf/issues" "url": "https://github.com/joyent/node-bcrypt-pbkdf/issues"
}, },

View File

@@ -1,23 +1,25 @@
# browser-process-hrtime # browser-process-hrtime
Browser shim for Node.js process.hrtime(). Browser shim for Node.js `process.hrtime()`.
See [documentation at nodejs.org](http://nodejs.org/api/process.html#process_process_hrtime) See [documentation at nodejs.org](http://nodejs.org/api/process.html#process_process_hrtime)
This module does not provide the same level of time precision as node.js, but provides a matching API and response format.
### usage ### usage
Use hrtime independant of environment (node or browser). Use hrtime independent of environment (node or browser).
It will use process.hrtime first and fallback if not present. It will use `process.hrtime` first and fallback if not present.
```js ```js
var hrtime = require('browser-process-hrtime') const hrtime = require('browser-process-hrtime')
var start = hrtime() const start = hrtime()
// ... // ...
var delta = hrtime(start) const delta = hrtime(start)
``` ```
### monkey-patching ### monkey-patching
You can monkey-patch process.hrtime for your dependency graph like this: You can monkey-patch `process.hrtime` for your dependency graph like this:
```js ```js
process.hrtime = require('browser-process-hrtime') process.hrtime = require('browser-process-hrtime')
var coolTool = require('module-that-uses-hrtime-somewhere-in-its-depths') const coolTool = require('module-that-uses-hrtime-somewhere-in-its-depths')
``` ```
### note ### note

4
node_modules/browser-process-hrtime/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
declare module "browser-process-hrtime" {
function hrtime(time?: [number, number]): [number, number];
export = hrtime;
}

View File

@@ -1,27 +1,27 @@
{ {
"_from": "browser-process-hrtime@^0.1.2", "_from": "browser-process-hrtime@^1.0.0",
"_id": "browser-process-hrtime@0.1.3", "_id": "browser-process-hrtime@1.0.0",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==", "_integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==",
"_location": "/browser-process-hrtime", "_location": "/browser-process-hrtime",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "range",
"registry": true, "registry": true,
"raw": "browser-process-hrtime@^0.1.2", "raw": "browser-process-hrtime@^1.0.0",
"name": "browser-process-hrtime", "name": "browser-process-hrtime",
"escapedName": "browser-process-hrtime", "escapedName": "browser-process-hrtime",
"rawSpec": "^0.1.2", "rawSpec": "^1.0.0",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^0.1.2" "fetchSpec": "^1.0.0"
}, },
"_requiredBy": [ "_requiredBy": [
"/w3c-hr-time" "/w3c-hr-time"
], ],
"_resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", "_resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz",
"_shasum": "616f00faef1df7ec1b5bf9cfe2bdc3170f26c7b4", "_shasum": "3c9b4b7d782c8121e56f10106d84c0d0ffc94626",
"_spec": "browser-process-hrtime@^0.1.2", "_spec": "browser-process-hrtime@^1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\w3c-hr-time", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\w3c-hr-time",
"author": { "author": {
"name": "kumavis" "name": "kumavis"
}, },
@@ -42,5 +42,5 @@
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"version": "0.1.3" "version": "1.0.0"
} }

View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz", "_resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"_shasum": "32713bc028f75c02fdb710d7c7bcec1f2c6070ef", "_shasum": "32713bc028f75c02fdb710d7c7bcec1f2c6070ef",
"_spec": "buffer-from@^1.0.0", "_spec": "buffer-from@^1.0.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\source-map-support", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\source-map-support",
"bugs": { "bugs": {
"url": "https://github.com/LinusU/buffer-from/issues" "url": "https://github.com/LinusU/buffer-from/issues"
}, },

2
node_modules/caseless/package.json generated vendored
View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", "_resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz",
"_shasum": "1b681c21ff84033c826543090689420d187151dc", "_shasum": "1b681c21ff84033c826543090689420d187151dc",
"_spec": "caseless@~0.12.0", "_spec": "caseless@~0.12.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\request", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\request",
"author": { "author": {
"name": "Mikeal Rogers", "name": "Mikeal Rogers",
"email": "mikeal.rogers@gmail.com" "email": "mikeal.rogers@gmail.com"

23
node_modules/clean-css/package.json generated vendored
View File

@@ -1,27 +1,32 @@
{ {
"_from": "clean-css@^4.2.3", "_args": [
[
"clean-css@4.2.3",
"D:\\Projects\\minifyfromhtml"
]
],
"_from": "clean-css@4.2.3",
"_id": "clean-css@4.2.3", "_id": "clean-css@4.2.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", "_integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==",
"_location": "/clean-css", "_location": "/clean-css",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "version",
"registry": true, "registry": true,
"raw": "clean-css@^4.2.3", "raw": "clean-css@4.2.3",
"name": "clean-css", "name": "clean-css",
"escapedName": "clean-css", "escapedName": "clean-css",
"rawSpec": "^4.2.3", "rawSpec": "4.2.3",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^4.2.3" "fetchSpec": "4.2.3"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", "_resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz",
"_shasum": "507b5de7d97b48ee53d84adb0160ff6216380f78", "_spec": "4.2.3",
"_spec": "clean-css@^4.2.3", "_where": "D:\\Projects\\minifyfromhtml",
"_where": "F:\\projects\\p\\minifyfromhtml",
"author": { "author": {
"name": "Jakub Pawlowicz", "name": "Jakub Pawlowicz",
"email": "contact@jakubpawlowicz.com", "email": "contact@jakubpawlowicz.com",
@@ -30,11 +35,9 @@
"bugs": { "bugs": {
"url": "https://github.com/jakubpawlowicz/clean-css/issues" "url": "https://github.com/jakubpawlowicz/clean-css/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"source-map": "~0.6.0" "source-map": "~0.6.0"
}, },
"deprecated": false,
"description": "A well-tested CSS minifier", "description": "A well-tested CSS minifier",
"devDependencies": { "devDependencies": {
"browserify": "^14.0.0", "browserify": "^14.0.0",

View File

@@ -22,7 +22,7 @@
"_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "_resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"_shasum": "c3d45a8b34fd730631a110a8a2520682b31d5a7f", "_shasum": "c3d45a8b34fd730631a110a8a2520682b31d5a7f",
"_spec": "combined-stream@~1.0.6", "_spec": "combined-stream@~1.0.6",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\request", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\request",
"author": { "author": {
"name": "Felix Geisendörfer", "name": "Felix Geisendörfer",
"email": "felix@debuggable.com", "email": "felix@debuggable.com",

View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "_resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"_shasum": "fd485e84c03eb4881c20722ba48035e8531aeb33", "_shasum": "fd485e84c03eb4881c20722ba48035e8531aeb33",
"_spec": "commander@^2.20.0", "_spec": "commander@^2.20.0",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\terser", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\terser",
"author": { "author": {
"name": "TJ Holowaychuk", "name": "TJ Holowaychuk",
"email": "tj@vision-media.ca" "email": "tj@vision-media.ca"

View File

@@ -21,7 +21,7 @@
"_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", "_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7",
"_spec": "core-util-is@1.0.2", "_spec": "core-util-is@1.0.2",
"_where": "F:\\projects\\p\\minifyfromhtml\\node_modules\\verror", "_where": "D:\\Projects\\minifyfromhtml\\node_modules\\verror",
"author": { "author": {
"name": "Isaac Z. Schlueter", "name": "Isaac Z. Schlueter",
"email": "i@izs.me", "email": "i@izs.me",

View File

@@ -19,7 +19,7 @@ CSSOM.CSSKeyframeRule = function CSSKeyframeRule() {
CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule(); CSSOM.CSSKeyframeRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule; CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;
CSSOM.CSSKeyframeRule.prototype.type = 9; CSSOM.CSSKeyframeRule.prototype.type = 8;
//FIXME //FIXME
//CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule; //CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule; //CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;

View File

@@ -17,7 +17,7 @@ CSSOM.CSSKeyframesRule = function CSSKeyframesRule() {
CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule(); CSSOM.CSSKeyframesRule.prototype = new CSSOM.CSSRule();
CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule; CSSOM.CSSKeyframesRule.prototype.constructor = CSSOM.CSSKeyframesRule;
CSSOM.CSSKeyframesRule.prototype.type = 8; CSSOM.CSSKeyframesRule.prototype.type = 7;
//FIXME //FIXME
//CSSOM.CSSKeyframesRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule; //CSSOM.CSSKeyframesRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
//CSSOM.CSSKeyframesRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule; //CSSOM.CSSKeyframesRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;

13
node_modules/cssom/lib/clone.js generated vendored
View File

@@ -26,20 +26,9 @@ CSSOM.clone = function clone(stylesheet) {
return cloned; return cloned;
} }
var RULE_TYPES = {
1: CSSOM.CSSStyleRule,
4: CSSOM.CSSMediaRule,
//3: CSSOM.CSSImportRule,
//5: CSSOM.CSSFontFaceRule,
//6: CSSOM.CSSPageRule,
8: CSSOM.CSSKeyframesRule,
9: CSSOM.CSSKeyframeRule,
12: CSSOM.CSSSupportsRule
};
for (var i = 0, rulesLength = rules.length; i < rulesLength; i++) { for (var i = 0, rulesLength = rules.length; i < rulesLength; i++) {
var rule = rules[i]; var rule = rules[i];
var ruleClone = cloned.cssRules[i] = new RULE_TYPES[rule.type](); var ruleClone = cloned.cssRules[i] = new rule.constructor();
var style = rule.style; var style = rule.style;
if (style) { if (style) {

1
node_modules/cssom/lib/parse.js generated vendored
View File

@@ -240,7 +240,6 @@ CSSOM.parse = function parse(token) {
state = "before-selector"; state = "before-selector";
} else if (state === "fontFaceRule-begin") { } else if (state === "fontFaceRule-begin") {
if (parentRule) { if (parentRule) {
ancestorRules.push(parentRule);
fontFaceRule.parentRule = parentRule; fontFaceRule.parentRule = parentRule;
} }
fontFaceRule.parentStyleSheet = styleSheet; fontFaceRule.parentStyleSheet = styleSheet;

Some files were not shown because too many files have changed in this diff Show More