From c09f3dc2f32e91b18c0c9698b93652b43d3f38db Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Fri, 18 Sep 2020 12:55:59 -0400 Subject: [PATCH 01/42] doc: put release script specifics in details MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Listing all the steps can be confusing an make it seem like the releaser is meant to run each of these steps manually. In fact I personally did that my first release. Let's put those steps in a details block to make it more obvious that it is informational and not steps to follow PR-URL: https://github.com/nodejs/node/pull/35260 Reviewed-By: Richard Lau Reviewed-By: Ruy Adorno Reviewed-By: Daijiro Wachi Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso --- doc/guides/releases.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/guides/releases.md b/doc/guides/releases.md index c828a4b2826821..e66204e8d007a0 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -598,6 +598,8 @@ $ ./tools/release.sh -i ~/.ssh/node_id_rsa `tools/release.sh` will perform the following actions when run: +
+ **a.** Select a GPG key from your private keys. It will use a command similar to: `gpg --list-secret-keys` to list your keys. If you don't have any keys, it will bail. If you have only one key, it will use that. If you have more than @@ -631,6 +633,7 @@ SHASUMS256.txt.sig. **g.** Upload the `SHASUMS256.txt` files back to the server into the release directory. +
If you didn't wait for ARM builds in the previous step before promoting the release, you should re-run `tools/release.sh` after the ARM builds have From 2a4ae0926d77d43d0fb6d3e56b2961c94865a014 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Fri, 18 Sep 2020 01:52:51 +0200 Subject: [PATCH 02/42] doc: update crypto.createSecretKey accepted types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/35246 Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 329f32bdeb1d80..10c4fded8b6df4 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -2060,7 +2060,7 @@ and it will be impossible to extract the private key from the returned object. added: v11.6.0 --> -* `key` {Buffer} +* `key` {Buffer | TypedArray | DataView} * Returns: {KeyObject} Creates and returns a new key object containing a secret key for symmetric From 68ea7f55600970d666e0ebd66fcf5b7d1ea66084 Mon Sep 17 00:00:00 2001 From: Christoph Tavan Date: Fri, 18 Sep 2020 16:35:34 +0200 Subject: [PATCH 03/42] module: fix crash on multiline named cjs imports The node process crashes when trying to parse a multiline import statement for named exports of a CommonJS module: TypeError: Cannot read property '0' of null at ModuleJob._instantiate (internal/modules/esm/module_job.js:112:77) at async ModuleJob.run (internal/modules/esm/module_job.js:137:5) at async Loader.import (internal/modules/esm/loader.js:165:24) at async rejects.name (file:///***/node/test/es-module/test-esm-cjs-named-error.mjs:56:3) at async waitForActual (assert.js:721:5) at async rejects (assert.js:830:25), The reason is that the regexp that is currently used to decorate the original error fails for multi line import statements. Unfortunately the undecorated error stack only contains the single line which causes the import to fail: file:///***/node/test/fixtures/es-modules/package-cjs-named-error/multi-line.mjs:2 comeOn, ^^^^^^ SyntaxError: The requested module './fail.cjs' does not provide an export named 'comeOn' at ModuleJob._instantiate (internal/modules/esm/module_job.js:98:21) at async ModuleJob.run (internal/modules/esm/module_job.js:141:5) at async Loader.import (internal/modules/esm/loader.js:165:24) at async rejects.name (file:///***/node/test/es-module/test-esm-cjs-named-error.mjs:56:3) at async waitForActual (assert.js:721:5) at async rejects (assert.js:830:25) Hence, for multiline import statements we cannot create an equivalent piece of code that uses default import followed by an object destructuring assignment. In any case the node process should definitely not crash. So until we have a more sophisticated way of extracting the entire problematic multiline import statement, show the code example only for single-line imports where the current regexp approach works well. Refs: https://github.com/nodejs/node/issues/35259 PR-URL: https://github.com/nodejs/node/pull/35275 Reviewed-By: Matteo Collina Reviewed-By: Anna Henningsen Reviewed-By: Myles Borins Reviewed-By: Rich Trott --- lib/internal/modules/esm/module_job.js | 21 ++++++++++++------- test/es-module/test-esm-cjs-named-error.mjs | 11 ++++++++++ .../package-cjs-named-error/fail.cjs | 3 ++- .../package-cjs-named-error/multi-line.mjs | 4 ++++ 4 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 test/fixtures/es-modules/package-cjs-named-error/multi-line.mjs diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index 4ffa8db9dab903..dedfc54e7f3845 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -108,16 +108,23 @@ class ModuleJob { await this.loader.resolve(childSpecifier, parentFileUrl); const format = await this.loader.getFormat(childFileURL); if (format === 'commonjs') { - const importStatement = splitStack[1]; - const namedImports = StringPrototypeMatch(importStatement, /{.*}/)[0]; - const destructuringAssignment = StringPrototypeReplace(namedImports, /\s+as\s+/g, ': '); e.message = `The requested module '${childSpecifier}' is expected ` + 'to be of type CommonJS, which does not support named exports. ' + 'CommonJS modules can be imported by importing the default ' + - 'export.\n' + - 'For example:\n' + - `import pkg from '${childSpecifier}';\n` + - `const ${destructuringAssignment} = pkg;`; + 'export.'; + // TODO(@ctavan): The original error stack only provides the single + // line which causes the error. For multi-line import statements we + // cannot generate an equivalent object descructuring assignment by + // just parsing the error stack. + const importStatement = splitStack[1]; + const oneLineNamedImports = StringPrototypeMatch(importStatement, /{.*}/); + if (oneLineNamedImports) { + const destructuringAssignment = + StringPrototypeReplace(oneLineNamedImports[0], /\s+as\s+/g, ': '); + e.message += '\nFor example:\n' + + `import pkg from '${childSpecifier}';\n` + + `const ${destructuringAssignment} = pkg;`; + } const newStack = StringPrototypeSplit(e.stack, '\n'); newStack[3] = `SyntaxError: ${e.message}`; e.stack = ArrayPrototypeJoin(newStack, '\n'); diff --git a/test/es-module/test-esm-cjs-named-error.mjs b/test/es-module/test-esm-cjs-named-error.mjs index d71dc959e21fb7..e9ddc67c0fbcea 100644 --- a/test/es-module/test-esm-cjs-named-error.mjs +++ b/test/es-module/test-esm-cjs-named-error.mjs @@ -10,6 +10,10 @@ const expectedRelative = 'The requested module \'./fail.cjs\' is expected to ' + 'import pkg from \'./fail.cjs\';\n' + 'const { comeOn } = pkg;'; +const expectedWithoutExample = 'The requested module \'./fail.cjs\' is ' + + 'expected to be of type CommonJS, which does not support named exports. ' + + 'CommonJS modules can be imported by importing the default export.'; + const expectedRenamed = 'The requested module \'./fail.cjs\' is expected to ' + 'be of type CommonJS, which does not support named exports. CommonJS ' + 'modules can be imported by importing the default export.\n' + @@ -52,6 +56,13 @@ rejects(async () => { message: expectedRenamed }, 'should correctly format named imports with renames'); +rejects(async () => { + await import(`${fixtureBase}/multi-line.mjs`); +}, { + name: 'SyntaxError', + message: expectedWithoutExample, +}, 'should correctly format named imports across multiple lines'); + rejects(async () => { await import(`${fixtureBase}/json-hack.mjs`); }, { diff --git a/test/fixtures/es-modules/package-cjs-named-error/fail.cjs b/test/fixtures/es-modules/package-cjs-named-error/fail.cjs index 40c512ab0e5ad2..cab82d3eb60d60 100644 --- a/test/fixtures/es-modules/package-cjs-named-error/fail.cjs +++ b/test/fixtures/es-modules/package-cjs-named-error/fail.cjs @@ -1,3 +1,4 @@ module.exports = { - comeOn: 'fhqwhgads' + comeOn: 'fhqwhgads', + everybody: 'to the limit', }; diff --git a/test/fixtures/es-modules/package-cjs-named-error/multi-line.mjs b/test/fixtures/es-modules/package-cjs-named-error/multi-line.mjs new file mode 100644 index 00000000000000..a4f80eba042576 --- /dev/null +++ b/test/fixtures/es-modules/package-cjs-named-error/multi-line.mjs @@ -0,0 +1,4 @@ +import { + comeOn, + everybody, +} from './fail.cjs'; From 9d91842a9d4346d1b4e08489c94b7d78f083b53f Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 17 Sep 2020 18:12:06 +0200 Subject: [PATCH 04/42] tools,doc: upgrade dependencies PR-URL: https://github.com/nodejs/node/pull/35244 Reviewed-By: Rich Trott Reviewed-By: Shelley Vohr --- tools/doc/generate.js | 2 +- tools/doc/html.js | 6 +- tools/doc/json.js | 4 +- tools/doc/package-lock.json | 918 ++++++++++++++++++++---------------- tools/doc/package.json | 26 +- 5 files changed, 541 insertions(+), 415 deletions(-) diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 93c3b263009bb6..007a0d48eed347 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -87,7 +87,7 @@ async function main() { .use(html.firstHeader) .use(html.preprocessElements, { filename }) .use(html.buildToc, { filename, apilinks }) - .use(remark2rehype, { allowDangerousHTML: true }) + .use(remark2rehype, { allowDangerousHtml: true }) .use(raw) .use(htmlStringify) .process(input); diff --git a/tools/doc/html.js b/tools/doc/html.js index cbed8ba6b2d8ef..2e60d0786448b5 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -54,7 +54,7 @@ const gtocPath = path.join(docPath, 'api', 'index.md'); const gtocMD = fs.readFileSync(gtocPath, 'utf8').replace(/^/gms, ''); const gtocHTML = unified() .use(markdown) - .use(remark2rehype, { allowDangerousHTML: true }) + .use(remark2rehype, { allowDangerousHtml: true }) .use(raw) .use(navClasses) .use(htmlStringify) @@ -281,7 +281,7 @@ function parseYAML(text) { meta.changes.forEach((change) => { const description = unified() .use(markdown) - .use(remark2rehype, { allowDangerousHTML: true }) + .use(remark2rehype, { allowDangerousHtml: true }) .use(raw) .use(htmlStringify) .processSync(change.description).toString(); @@ -379,7 +379,7 @@ function buildToc({ filename, apilinks }) { file.toc = unified() .use(markdown) - .use(remark2rehype, { allowDangerousHTML: true }) + .use(remark2rehype, { allowDangerousHtml: true }) .use(raw) .use(htmlStringify) .processSync(toc).toString(); diff --git a/tools/doc/json.js b/tools/doc/json.js index 739a4f9f4fd3de..6dd25d41026f84 100644 --- a/tools/doc/json.js +++ b/tools/doc/json.js @@ -24,7 +24,7 @@ const unified = require('unified'); const common = require('./common.js'); const html = require('remark-html'); -const select = require('unist-util-select'); +const { selectAll } = require('unist-util-select'); module.exports = { jsonAPI }; @@ -38,7 +38,7 @@ function jsonAPI({ filename }) { const stabilityExpr = /^Stability: ([0-5])(?:\s*-\s*)?(.*)$/s; // Extract definitions. - const definitions = select(tree, 'definition'); + const definitions = selectAll('definition', tree); // Determine the start, stop, and depth of each section. const sections = []; diff --git a/tools/doc/package-lock.json b/tools/doc/package-lock.json index b448baa7e3730b..36514e5989c7b7 100644 --- a/tools/doc/package-lock.json +++ b/tools/doc/package-lock.json @@ -4,34 +4,20 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/node": { - "version": "10.5.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.6.tgz", - "integrity": "sha512-c5Z1j1ysgo4878ptz6gxLcgMfJ6Wf908R3l5KAGabr0XJ72ZFmOCgsaodPpNYTfp4iOrSwgTDvR/BxbFfB4zPQ==" + "@types/mdast": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-3.0.3.tgz", + "integrity": "sha512-SXPBMnFVQg1s00dlMCc/jCdvPqdE4mXaMMCeRlxLDmTAEoegHT53xKtkDnzDTOcmMHUfcjyf36/YYZ6SxRdnsw==", + "dev": true, + "requires": { + "@types/unist": "*" + } }, "@types/unist": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz", - "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==" - }, - "@types/vfile": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@types/vfile/-/vfile-3.0.2.tgz", - "integrity": "sha512-b3nLFGaGkJ9rzOcuXRfHkZMdjsawuDD0ENL9fzTophtBg8FJHSGbH7daXkEpcwy3v7Xol3pAvsmlYyFhR4pqJw==", - "requires": { - "@types/node": "*", - "@types/unist": "*", - "@types/vfile-message": "*" - } - }, - "@types/vfile-message": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@types/vfile-message/-/vfile-message-1.0.1.tgz", - "integrity": "sha512-mlGER3Aqmq7bqR1tTTIVHq8KSAFFRyGbrxuM8C/H82g6k7r2fS+IMEkIu3D7JHzG10NvPdR8DNx0jr0pwpp4dA==", - "requires": { - "@types/node": "*", - "@types/unist": "*" - } + "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==", + "dev": true }, "argparse": { "version": "1.0.10", @@ -43,87 +29,64 @@ } }, "bail": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.3.tgz", - "integrity": "sha512-1X8CnjFVQ+a+KW36uBNMTU5s8+v5FzeqrP7hTG5aTb4aPreSbZJlhwPon9VKMuEVgV++JM+SQrALY3kr7eswdg==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", + "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==", + "dev": true }, "boolbase": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/boolbase/-/boolbase-1.0.0.tgz", - "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=" - }, - "camelcase": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz", - "integrity": "sha1-MvxLn82vhF/N9+c7uXysImHwqwo=" + "integrity": "sha1-aN/1++YMUes3cl6p4+0xDcwed24=", + "dev": true }, "ccount": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.3.tgz", - "integrity": "sha512-Jt9tIBkRc9POUof7QA/VwWd+58fKkEEfI+/t1/eOlxKM7ZhrczNzMFefge7Ai+39y1pR/pP6cI19guHy3FSLmw==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/ccount/-/ccount-1.0.5.tgz", + "integrity": "sha512-MOli1W+nfbPLlKEhInaxhRdp7KVLFxLN5ykwzHgLsLI3H3gs5jjFAK4Eoj3OzzcxCtumDaI8onoVDeQyWaNTkw==", + "dev": true }, "character-entities": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.2.tgz", - "integrity": "sha512-sMoHX6/nBiy3KKfC78dnEalnpn0Az0oSNvqUWYTtYrhRI5iUIYsROU48G+E+kMFQzqXaJ8kHJZ85n7y6/PHgwQ==" + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/character-entities/-/character-entities-1.2.4.tgz", + "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", + "dev": true }, "character-entities-html4": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.2.tgz", - "integrity": "sha512-sIrXwyna2+5b0eB9W149izTPJk/KkJTg6mEzDGibwBUkyH1SbDa+nf515Ppdi3MaH35lW0JFJDWeq9Luzes1Iw==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-entities-html4/-/character-entities-html4-1.1.4.tgz", + "integrity": "sha512-HRcDxZuZqMx3/a+qrzxdBKBPUpxWEq9xw2OPZ3a/174ihfrQKVsFhqtthBInFy1zZ9GgZyFXOatNujm8M+El3g==", + "dev": true }, "character-entities-legacy": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.2.tgz", - "integrity": "sha512-9NB2VbXtXYWdXzqrvAHykE/f0QJxzaKIpZ5QzNZrrgQ7Iyxr2vnfS8fCBNVW9nUEZE0lo57nxKRqnzY/dKrwlA==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", + "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", + "dev": true }, "character-reference-invalid": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.2.tgz", - "integrity": "sha512-7I/xceXfKyUJmSAn/jw8ve/9DyOP7XxufNYLI9Px7CmsKgEUaZLUTax6nZxGQtaoiZCjpu6cHPj20xC/vqRReQ==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", + "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", + "dev": true }, "collapse-white-space": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.4.tgz", - "integrity": "sha512-YfQ1tAUZm561vpYD+5eyWN8+UsceQbSrqqlc/6zDY2gtAE+uZLSdkkovhnGpmCThsvKBFakq4EdY/FF93E8XIw==" + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/collapse-white-space/-/collapse-white-space-1.0.6.tgz", + "integrity": "sha512-jEovNnrhMuqyCcjfEJA56v0Xq8SkIoPKDyaHahwo3POf4qcSXqMYuwNcOTzp74vTsR9Tn08z4MxWqAhcekogkQ==", + "dev": true }, "comma-separated-tokens": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.5.tgz", - "integrity": "sha512-Cg90/fcK93n0ecgYTAz1jaA3zvnQ0ExlmKY1rdbyHqAx6BHxwoJc+J7HDu0iuQ7ixEs1qaa+WyQ6oeuBpYP1iA==", - "requires": { - "trim": "0.0.1" - } + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", + "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", + "dev": true }, "css-selector-parser": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/css-selector-parser/-/css-selector-parser-1.3.0.tgz", - "integrity": "sha1-XxrUPi2O77/cME/NOaUhZklD4+s=" - }, - "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", - "requires": { - "ms": "2.0.0" - } - }, - "define-properties": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz", - "integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=", - "requires": { - "foreach": "^2.0.5", - "object-keys": "^1.0.8" - } - }, - "detab": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/detab/-/detab-2.0.1.tgz", - "integrity": "sha512-/hhdqdQc5thGrqzjyO/pz76lDZ5GSuAs6goxOaKTsvPk7HNnzAyFN5lyHgqpX4/s1i66K8qMGj+VhA9504x7DQ==", - "requires": { - "repeat-string": "^1.5.4" - } + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/css-selector-parser/-/css-selector-parser-1.4.1.tgz", + "integrity": "sha512-HYPSb7y/Z7BNDCOrakL4raGO2zltZkbeXyAd6Tg9obzix6QhzxCotdBl6VT0Dv4vZfJGVz3WL/xaEI9Ly3ul0g==", + "dev": true }, "esprima": { "version": "4.0.1", @@ -134,306 +97,315 @@ "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", - "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" - }, - "foreach": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz", - "integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=" + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==", + "dev": true }, "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true }, "has": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, "requires": { "function-bind": "^1.1.1" } }, "hast-to-hyperscript": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hast-to-hyperscript/-/hast-to-hyperscript-3.1.0.tgz", - "integrity": "sha512-/At2y6sQLTAcL6y+3hRQFcaBoRlKrmHSpvvdOZqRz6uI2YyjrU8rJ7e1LbmLtWUmzaIqKEdNSku+AJC0pt4+aw==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/hast-to-hyperscript/-/hast-to-hyperscript-7.0.4.tgz", + "integrity": "sha512-vmwriQ2H0RPS9ho4Kkbf3n3lY436QKLq6VaGA1pzBh36hBi3tm1DO9bR+kaJIbpT10UqaANDkMjxvjVfr+cnOA==", + "dev": true, "requires": { "comma-separated-tokens": "^1.0.0", - "is-nan": "^1.2.1", - "kebab-case": "^1.0.0", - "property-information": "^3.0.0", + "property-information": "^5.3.0", "space-separated-tokens": "^1.0.0", - "trim": "0.0.1", - "unist-util-is": "^2.0.0" + "style-to-object": "^0.2.1", + "unist-util-is": "^3.0.0", + "web-namespaces": "^1.1.2" } }, "hast-util-from-parse5": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-2.1.0.tgz", - "integrity": "sha1-9hI9g9NoljCwl+E+Qw0W2dG9iIQ=", + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-5.0.3.tgz", + "integrity": "sha512-gOc8UB99F6eWVWFtM9jUikjN7QkWxB3nY0df5Z0Zq1/Nkwl5V4hAAsl0tmwlgWl/1shlTF8DnNYLO8X6wRV9pA==", + "dev": true, "requires": { - "camelcase": "^3.0.0", - "hastscript": "^3.0.0", - "property-information": "^3.1.0", - "vfile-location": "^2.0.0" + "ccount": "^1.0.3", + "hastscript": "^5.0.0", + "property-information": "^5.0.0", + "web-namespaces": "^1.1.2", + "xtend": "^4.0.1" } }, "hast-util-is-element": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.0.1.tgz", - "integrity": "sha512-s/ggaNehYVqmLgTXEv12Lbb72bsOD2r5DhAqPgtDdaI/YFNXVzz0zHFVJnhjIjn7Nak8GbL4nzT2q0RA5div+A==" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-1.1.0.tgz", + "integrity": "sha512-oUmNua0bFbdrD/ELDSSEadRVtWZOf3iF6Lbv81naqsIV99RnSCieTbWuWCY8BAeEfKJTKl0gRdokv+dELutHGQ==", + "dev": true }, "hast-util-parse-selector": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.0.tgz", - "integrity": "sha512-trw0pqZN7+sH9k7hPWCJNZUbWW2KroSIM/XpIy3G5ZMtx9LSabCyoSp4skJZ4q/eZ5UOBPtvWh4W9c+RE3HRoQ==" + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-2.2.4.tgz", + "integrity": "sha512-gW3sxfynIvZApL4L07wryYF4+C9VvH3AUi7LAnVXV4MneGEgwOByXvFo18BgmTWnm7oHAe874jKbIB1YhHSIzA==", + "dev": true }, "hast-util-raw": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-2.0.2.tgz", - "integrity": "sha512-ujytXSAZC85bvh38f8ALzfE2IZDdCwB9XeHUs9l20C1p4/1YeAoZqq9z9U17vWQ9hMmqbVaROuSK8feL3wTCJg==", - "requires": { - "hast-util-from-parse5": "^2.0.0", - "hast-util-to-parse5": "^2.0.0", - "html-void-elements": "^1.0.1", - "parse5": "^3.0.3", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/hast-util-raw/-/hast-util-raw-5.0.2.tgz", + "integrity": "sha512-3ReYQcIHmzSgMq8UrDZHFL0oGlbuVGdLKs8s/Fe8BfHFAyZDrdv1fy/AGn+Fim8ZuvAHcJ61NQhVMtyfHviT/g==", + "dev": true, + "requires": { + "hast-util-from-parse5": "^5.0.0", + "hast-util-to-parse5": "^5.0.0", + "html-void-elements": "^1.0.0", + "parse5": "^5.0.0", "unist-util-position": "^3.0.0", "web-namespaces": "^1.0.0", + "xtend": "^4.0.0", "zwitch": "^1.0.0" } }, "hast-util-sanitize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-1.2.0.tgz", - "integrity": "sha512-VwCTqjt6fbMGacxGB1FKV5sBJaVVkyCGVMDwb4nnqvCW2lkqscA2GEpOyBx4ZWRXty1eAZF58MHBrllEoQEoBg==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-sanitize/-/hast-util-sanitize-3.0.0.tgz", + "integrity": "sha512-gxsM24ARtuulsrWEj8QtVM6FNeAEHklF/t7TEIWvX1wuQcoAQtJtEUcT8t0os4uxCUqh1epX/gTi8fp8gNKvCA==", + "dev": true, "requires": { - "xtend": "^4.0.1" + "xtend": "^4.0.0" } }, "hast-util-to-html": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-3.1.0.tgz", - "integrity": "sha1-iCyZhJ5AEw6ZHAQuRW1FPZXDbP8=", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/hast-util-to-html/-/hast-util-to-html-7.1.1.tgz", + "integrity": "sha512-Ujqj0hGuo3dIQKilkbauAv5teOqPvhaSLEgs1lgApFT0812e114KiffV8XfE4ttR8dRPqxNOIJOMu6SKOVOGlg==", + "dev": true, "requires": { "ccount": "^1.0.0", - "comma-separated-tokens": "^1.0.1", + "comma-separated-tokens": "^1.0.0", "hast-util-is-element": "^1.0.0", "hast-util-whitespace": "^1.0.0", "html-void-elements": "^1.0.0", - "kebab-case": "^1.0.0", - "property-information": "^3.1.0", + "property-information": "^5.0.0", "space-separated-tokens": "^1.0.0", - "stringify-entities": "^1.0.1", - "unist-util-is": "^2.0.0", - "xtend": "^4.0.1" + "stringify-entities": "^3.0.1", + "unist-util-is": "^4.0.0", + "xtend": "^4.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", + "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==", + "dev": true + } } }, "hast-util-to-parse5": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-2.2.0.tgz", - "integrity": "sha512-Eg1mrf0VTT/PipFN5z1+mVi+4GNhinKk/i/HKeX1h17IYiMdm3G8vgA0FU04XCuD1cWV58f5zziFKcBkr+WuKw==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/hast-util-to-parse5/-/hast-util-to-parse5-5.1.2.tgz", + "integrity": "sha512-ZgYLJu9lYknMfsBY0rBV4TJn2xiwF1fXFFjbP6EE7S0s5mS8LIKBVWzhA1MeIs1SWW6GnnE4In6c3kPb+CWhog==", + "dev": true, "requires": { - "hast-to-hyperscript": "^3.0.0", - "mapz": "^1.0.0", + "hast-to-hyperscript": "^7.0.0", + "property-information": "^5.0.0", "web-namespaces": "^1.0.0", - "xtend": "^4.0.1", + "xtend": "^4.0.0", "zwitch": "^1.0.0" } }, "hast-util-whitespace": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.1.tgz", - "integrity": "sha512-Mfx2ZnmVMTAopZ8as42nKrNt650tCZYhy/MPeO1Imdg/cmCWK6GUSnFrrE3ezGjVifn7x5zMfu8jrjwIGyImSw==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-1.0.4.tgz", + "integrity": "sha512-I5GTdSfhYfAPNztx2xJRQpG8cuDSNt599/7YUn7Gx/WxNMsG+a835k97TDkFgk123cwjfwINaZknkKkphx/f2A==", + "dev": true }, "hastscript": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-3.1.0.tgz", - "integrity": "sha512-8V34dMSDT1Ik+ZSgTzCLdyp89MrWxcxctXPxhmb72GQj1Xkw1aHPM9UaHCWewvH2Q+PVkYUm4ZJVw4T0dgEGNA==", + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-5.1.2.tgz", + "integrity": "sha512-WlztFuK+Lrvi3EggsqOkQ52rKbxkXL3RwB6t5lwoa8QLMemoWfBuL43eDrwOamJyR7uKQKdmKYaBH1NZBiIRrQ==", + "dev": true, "requires": { - "camelcase": "^3.0.0", "comma-separated-tokens": "^1.0.0", "hast-util-parse-selector": "^2.0.0", - "property-information": "^3.0.0", + "property-information": "^5.0.0", "space-separated-tokens": "^1.0.0" } }, "highlight.js": { - "version": "9.18.1", - "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.18.1.tgz", - "integrity": "sha512-OrVKYz70LHsnCgmbXctv/bfuvntIKDz177h0Co37DQ5jamGZLVmoCVMtjMtNZY3X9DrCcKfklHPNeA0uPZhSJg==" + "version": "10.1.0", + "resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-10.1.0.tgz", + "integrity": "sha512-e8aO/LUHDoxW4ntyKQf0/T3OtIZPhsfTr8XRuOq+FW5VdWEg/UDAeArzKF/22BaNZp6hPi/Zu/XQlTLOGLix3Q==", + "dev": true }, "html-void-elements": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.3.tgz", - "integrity": "sha512-SaGhCDPXJVNrQyKMtKy24q6IMdXg5FCPN3z+xizxw9l+oXQw5fOoaj/ERU5KqWhSYhXtW5bWthlDbTDLBhJQrA==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/html-void-elements/-/html-void-elements-1.0.5.tgz", + "integrity": "sha512-uE/TxKuyNIcx44cIWnjr/rfIATDH7ZaOMmstu0CwhFG1Dunhlp4OC6/NMbhiwoq5BpW0ubi303qnEk/PZj614w==", + "dev": true }, "inherits": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", - "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "dev": true + }, + "inline-style-parser": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/inline-style-parser/-/inline-style-parser-0.1.1.tgz", + "integrity": "sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==", + "dev": true }, "is-alphabetical": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.2.tgz", - "integrity": "sha512-V0xN4BYezDHcBSKb1QHUFMlR4as/XEuCZBzMJUU4n7+Cbt33SmUnSol+pnXFvLxSHNq2CemUXNdaXV6Flg7+xg==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-alphabetical/-/is-alphabetical-1.0.4.tgz", + "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", + "dev": true }, "is-alphanumerical": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.2.tgz", - "integrity": "sha512-pyfU/0kHdISIgslFfZN9nfY1Gk3MquQgUm1mJTjdkEPpkAKNWuBTSqFwewOpR7N351VkErCiyV71zX7mlQQqsg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", + "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", + "dev": true, "requires": { "is-alphabetical": "^1.0.0", "is-decimal": "^1.0.0" } }, "is-buffer": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz", - "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==" + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.4.tgz", + "integrity": "sha512-Kq1rokWXOPXWuaMAqZiJW4XxsmD9zGx9q4aePabbn3qCRGedtH7Cm+zV8WETitMfu1wdh+Rvd6w5egwSngUX2A==", + "dev": true }, "is-decimal": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.2.tgz", - "integrity": "sha512-TRzl7mOCchnhchN+f3ICUCzYvL9ul7R+TYOsZ8xia++knyZAJfv/uA1FvQXsAnYIl1T3B2X5E/J7Wb1QXiIBXg==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-decimal/-/is-decimal-1.0.4.tgz", + "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", + "dev": true }, "is-hexadecimal": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.2.tgz", - "integrity": "sha512-but/G3sapV3MNyqiDBLrOi4x8uCIw0RY3o/Vb5GT0sMFHrVV7731wFSVy41T5FO1og7G0gXLJh0MkgPRouko/A==" - }, - "is-nan": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.2.1.tgz", - "integrity": "sha1-n69ltvttskt/XAYoR16nH5iEAeI=", - "requires": { - "define-properties": "^1.1.1" - } + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", + "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", + "dev": true }, "is-plain-obj": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", - "integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", + "dev": true }, "is-whitespace-character": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.2.tgz", - "integrity": "sha512-SzM+T5GKUCtLhlHFKt2SDAX2RFzfS6joT91F2/WSi9LxgFdsnhfPK/UIA+JhRR2xuyLdrCys2PiFDrtn1fU5hQ==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-whitespace-character/-/is-whitespace-character-1.0.4.tgz", + "integrity": "sha512-SDweEzfIZM0SJV0EUga669UTKlmL0Pq8Lno0QDQsPnvECB3IM2aP0gdx5TrU0A01MAPfViaZiI2V1QMZLaKK5w==", + "dev": true }, "is-word-character": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.2.tgz", - "integrity": "sha512-T3FlsX8rCHAH8e7RE7PfOPZVFQlcV3XRF9eOOBQ1uf70OxO7CjjSOjeImMPCADBdYWcStAbVbYvJ1m2D3tb+EA==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-word-character/-/is-word-character-1.0.4.tgz", + "integrity": "sha512-5SMO8RVennx3nZrqtKwCGyyetPE9VDba5ugvKLaD4KopPG5kR4mQ7tNt/r7feL5yt5h3lpuBbIUmCOG2eSzXHA==", + "dev": true }, "js-yaml": { - "version": "3.13.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz", - "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==", + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.0.tgz", + "integrity": "sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A==", "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" } }, - "kebab-case": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/kebab-case/-/kebab-case-1.0.0.tgz", - "integrity": "sha1-P55JkK3K0MaGwOcB92RYaPdfkes=" - }, "lodash.iteratee": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.iteratee/-/lodash.iteratee-4.7.0.tgz", - "integrity": "sha1-vkF32yiajMw8CZDx2ya1si/BVUw=" + "integrity": "sha1-vkF32yiajMw8CZDx2ya1si/BVUw=", + "dev": true }, "longest-streak": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-1.0.0.tgz", - "integrity": "sha1-0GWXxNTDG1LMsfXY+P5xSOr9aWU=" - }, - "mapz": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/mapz/-/mapz-1.0.2.tgz", - "integrity": "sha512-NuY43BoHy5K4jVg3/oD+g8ysNwdXY3HB5UankVWoikxT9YMqgCYC77pNRENTm/DfslLxPFEOyJUw9h9isRty6w==", - "requires": { - "x-is-array": "^0.1.0" - } + "integrity": "sha1-0GWXxNTDG1LMsfXY+P5xSOr9aWU=", + "dev": true }, "markdown-escapes": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.2.tgz", - "integrity": "sha512-lbRZ2mE3Q9RtLjxZBZ9+IMl68DKIXaVAhwvwn9pmjnPLS0h/6kyBMgNhqi1xFJ/2yv6cSyv0jbiZavZv93JkkA==" + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/markdown-escapes/-/markdown-escapes-1.0.4.tgz", + "integrity": "sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==", + "dev": true }, "markdown-table": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/markdown-table/-/markdown-table-0.4.0.tgz", - "integrity": "sha1-iQwsGzv+g/sA5BKbjkz+ZFJw+dE=" + "integrity": "sha1-iQwsGzv+g/sA5BKbjkz+ZFJw+dE=", + "dev": true }, "mdast-util-definitions": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-1.2.2.tgz", - "integrity": "sha512-9NloPSwaB9f1PKcGqaScfqRf6zKOEjTIXVIbPOmgWI/JKxznlgVXC5C+8qgl3AjYg2vJBRgLYfLICaNiac89iA==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mdast-util-definitions/-/mdast-util-definitions-3.0.1.tgz", + "integrity": "sha512-BAv2iUm/e6IK/b2/t+Fx69EL/AGcq/IG2S+HxHjDJGfLJtd6i9SZUS76aC9cig+IEucsqxKTR0ot3m933R3iuA==", + "dev": true, "requires": { - "unist-util-visit": "^1.0.0" + "unist-util-visit": "^2.0.0" } }, "mdast-util-to-hast": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-3.0.2.tgz", - "integrity": "sha512-YI8Ea3TFWEZrS31+6Q/d8ZYTOSDKM06IPc3l2+OMFX1o3JTG2mrztlmzDsUMwIXLWofEdTVl/WXBgRG6ddlU/A==", + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/mdast-util-to-hast/-/mdast-util-to-hast-9.1.1.tgz", + "integrity": "sha512-vpMWKFKM2mnle+YbNgDXxx95vv0CoLU0v/l3F5oFAG5DV7qwkZVWA206LsAdOnEVyf5vQcLnb3cWJywu7mUxsQ==", + "dev": true, "requires": { - "collapse-white-space": "^1.0.0", - "detab": "^2.0.0", - "mdast-util-definitions": "^1.2.0", - "mdurl": "^1.0.1", - "trim": "0.0.1", - "trim-lines": "^1.0.0", - "unist-builder": "^1.0.1", - "unist-util-generated": "^1.1.0", + "@types/mdast": "^3.0.0", + "@types/unist": "^2.0.3", + "mdast-util-definitions": "^3.0.0", + "mdurl": "^1.0.0", + "unist-builder": "^2.0.0", + "unist-util-generated": "^1.0.0", "unist-util-position": "^3.0.0", - "unist-util-visit": "^1.1.0", - "xtend": "^4.0.1" + "unist-util-visit": "^2.0.0" } }, "mdurl": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", - "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=" + "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", + "dev": true }, - "ms": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", - "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + "not": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/not/-/not-0.1.0.tgz", + "integrity": "sha1-yWkcF0bFXc++VMvYvU/wQbwrUZ0=", + "dev": true }, "nth-check": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.1.tgz", - "integrity": "sha1-mSms32KPwsQQmN6rgqxYDPFJquQ=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz", + "integrity": "sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg==", + "dev": true, "requires": { "boolbase": "~1.0.0" } }, - "object-assign": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", - "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" - }, - "object-keys": { - "version": "1.0.12", - "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz", - "integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==" - }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, "requires": { "wrappy": "1" } }, "parse-entities": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.1.2.tgz", - "integrity": "sha512-5N9lmQ7tmxfXf+hO3X6KRG6w7uYO/HL9fHalSySTdyn63C3WNvTM/1R8tn1u1larNcEbo3Slcy2bsVDQqvEpUg==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-2.0.0.tgz", + "integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==", + "dev": true, "requires": { "character-entities": "^1.0.0", "character-entities-legacy": "^1.0.0", @@ -444,49 +416,68 @@ } }, "parse5": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-3.0.3.tgz", - "integrity": "sha512-rgO9Zg5LLLkfJF9E6CCmXlSE4UVceloys8JrFqCcHloC3usd/kJCyPDwH2SOlzix2j3xaP9sUX3e8+kvkuleAA==", - "requires": { - "@types/node": "*" - } + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", + "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==", + "dev": true }, "property-information": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/property-information/-/property-information-3.2.0.tgz", - "integrity": "sha1-/RSDyPusYYCPX+NZ52k6H0ilgzE=" + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/property-information/-/property-information-5.5.0.tgz", + "integrity": "sha512-RgEbCx2HLa1chNgvChcx+rrCWD0ctBmGSE0M7lVm1yyv4UbvbrWoXp/BkVLZefzjrRBGW8/Js6uh/BnlHXFyjA==", + "dev": true, + "requires": { + "xtend": "^4.0.0" + } }, "rehype-raw": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-2.0.0.tgz", - "integrity": "sha1-Vjep/O7zSAD9fFfKMv2dWSf9Kqo=", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-4.0.2.tgz", + "integrity": "sha512-xQt94oXfDaO7sK9mJBtsZXkjW/jm6kArCoYN+HqKZ51O19AFHlp3Xa5UfZZ2tJkbpAZzKtgVUYvnconk9IsFuA==", + "dev": true, "requires": { - "hast-util-raw": "^2.0.0" + "hast-util-raw": "^5.0.0" } }, "rehype-stringify": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-3.0.0.tgz", - "integrity": "sha1-n+8IaCE8Lc4veAt289BIjIXoGes=", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/rehype-stringify/-/rehype-stringify-8.0.0.tgz", + "integrity": "sha512-VkIs18G0pj2xklyllrPSvdShAV36Ff3yE5PUO9u36f6+2qJFnn22Z5gKwBOwgXviux4UC7K+/j13AnZfPICi/g==", + "dev": true, "requires": { - "hast-util-to-html": "^3.0.0", - "xtend": "^4.0.1" + "hast-util-to-html": "^7.1.1" } }, "remark": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/remark/-/remark-5.1.0.tgz", "integrity": "sha1-y0Y709vLS5l5STXu4c9x16jjBow=", + "dev": true, "requires": { "remark-parse": "^1.1.0", "remark-stringify": "^1.1.0", "unified": "^4.1.1" }, "dependencies": { + "parse-entities": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz", + "integrity": "sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg==", + "dev": true, + "requires": { + "character-entities": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "character-reference-invalid": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + }, "remark-parse": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-1.1.0.tgz", "integrity": "sha1-w8oQ+ajaBGFcKPCapOMEUQUm7CE=", + "dev": true, "requires": { "collapse-white-space": "^1.0.0", "extend": "^3.0.0", @@ -503,6 +494,7 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/unified/-/unified-4.2.1.tgz", "integrity": "sha1-dv9Dqo2kMPbn5KVchOusKtLPzS4=", + "dev": true, "requires": { "bail": "^1.0.0", "extend": "^3.0.0", @@ -512,58 +504,97 @@ "vfile": "^1.0.0" } }, + "unist-util-remove-position": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.4.tgz", + "integrity": "sha512-tLqd653ArxJIPnKII6LMZwH+mb5q+n/GtXQZo6S6csPRs5zB0u79Yw8ouR3wTw8wxvdJFhpP6Y7jorWdCgLO0A==", + "dev": true, + "requires": { + "unist-util-visit": "^1.1.0" + } + }, + "unist-util-visit": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "dev": true, + "requires": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "unist-util-visit-parents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "dev": true, + "requires": { + "unist-util-is": "^3.0.0" + } + }, "vfile": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/vfile/-/vfile-1.4.0.tgz", - "integrity": "sha1-wP1vpIT43r23cfaMMe112I2pf+c=" + "integrity": "sha1-wP1vpIT43r23cfaMMe112I2pf+c=", + "dev": true + }, + "vfile-location": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.6.tgz", + "integrity": "sha512-sSFdyCP3G6Ka0CEmN83A2YCMKIieHx0EDaj5IDP4g1pa5ZJ4FJDvpO0WODLxo4LUX4oe52gmSCK7Jw4SBghqxA==", + "dev": true } } }, "remark-html": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-7.0.0.tgz", - "integrity": "sha512-jqRzkZXCkM12gIY2ibMLTW41m7rfanliMTVQCFTezHJFsbH00YaTox/BX4gU+f/zCdzfhFJONtebFByvpMv37w==", + "version": "12.0.0", + "resolved": "https://registry.npmjs.org/remark-html/-/remark-html-12.0.0.tgz", + "integrity": "sha512-M104NMHs48+uswChJkCDXCdabzxAinpHikpt6kS3gmGMyIvPZ5kn53tB9shFsL2O4HUJ9DIEsah1SX1Ve5FXHA==", + "dev": true, "requires": { - "hast-util-sanitize": "^1.0.0", - "hast-util-to-html": "^3.0.0", - "mdast-util-to-hast": "^3.0.0", + "hast-util-sanitize": "^3.0.0", + "hast-util-to-html": "^7.0.0", + "mdast-util-to-hast": "^9.0.0", "xtend": "^4.0.1" } }, "remark-parse": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-5.0.0.tgz", - "integrity": "sha512-b3iXszZLH1TLoyUzrATcTQUZrwNl1rE70rVdSruJFlDaJ9z5aMkhrG43Pp68OgfHndL/ADz6V69Zow8cTQu+JA==", + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/remark-parse/-/remark-parse-8.0.3.tgz", + "integrity": "sha512-E1K9+QLGgggHxCQtLt++uXltxEprmWzNfg+MxpfHsZlrddKzZ/hZyWHDbK3/Ap8HJQqYJRXP+jHczdL6q6i85Q==", + "dev": true, "requires": { + "ccount": "^1.0.0", "collapse-white-space": "^1.0.2", "is-alphabetical": "^1.0.0", "is-decimal": "^1.0.0", "is-whitespace-character": "^1.0.0", "is-word-character": "^1.0.0", "markdown-escapes": "^1.0.0", - "parse-entities": "^1.1.0", + "parse-entities": "^2.0.0", "repeat-string": "^1.5.4", "state-toggle": "^1.0.0", "trim": "0.0.1", "trim-trailing-lines": "^1.0.0", "unherit": "^1.0.4", - "unist-util-remove-position": "^1.0.0", - "vfile-location": "^2.0.0", + "unist-util-remove-position": "^2.0.0", + "vfile-location": "^3.0.0", "xtend": "^4.0.1" } }, "remark-rehype": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-3.0.2.tgz", - "integrity": "sha512-KDRCnMzRyyCDr0I14Kfk5094W7jjhQwAIJ1C6NniGNjp2OIhcrtqRaiTZCoyEtoYILXTmZKmuOnL5yYGaEFFJA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/remark-rehype/-/remark-rehype-7.0.0.tgz", + "integrity": "sha512-uqQ/VbaTdxyu/da6npHAso6hA00cMqhA3a59RziQdOLN2KEIkPykAVy52IcmZEVTuauXO0VtpxkyCey4phtHzQ==", + "dev": true, "requires": { - "mdast-util-to-hast": "^3.0.0" + "mdast-util-to-hast": "^9.1.0" } }, "remark-stringify": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remark-stringify/-/remark-stringify-1.1.0.tgz", "integrity": "sha1-pxBeJbnuK/mkm3XSxCPxGwauIJI=", + "dev": true, "requires": { "ccount": "^1.0.0", "extend": "^3.0.0", @@ -573,25 +604,53 @@ "repeat-string": "^1.5.4", "stringify-entities": "^1.0.1", "unherit": "^1.0.4" + }, + "dependencies": { + "parse-entities": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/parse-entities/-/parse-entities-1.2.2.tgz", + "integrity": "sha512-NzfpbxW/NPrzZ/yYSoQxyqUZMZXIdCfE0OIN4ESsnptHJECoUk3FZktxNuzQf4tjt5UEopnxpYJbvYuxIFDdsg==", + "dev": true, + "requires": { + "character-entities": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "character-reference-invalid": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-decimal": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + }, + "stringify-entities": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.2.tgz", + "integrity": "sha512-nrBAQClJAPN2p+uGCVJRPIPakKeKWZ9GtBCmormE7pWOSlHat7+x5A8gx85M7HM5Dt0BP3pP5RhVW77WdbJJ3A==", + "dev": true, + "requires": { + "character-entities-html4": "^1.0.0", + "character-entities-legacy": "^1.0.0", + "is-alphanumerical": "^1.0.0", + "is-hexadecimal": "^1.0.0" + } + } } }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", - "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=" + "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", + "dev": true }, "replace-ext": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", - "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=" + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=", + "dev": true }, "space-separated-tokens": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.2.tgz", - "integrity": "sha512-G3jprCEw+xFEs0ORweLmblJ3XLymGGr6hxZYTYZjIlvDti9vOBUjRQa1Rzjt012aRrocKstHwdNi+F7HguPsEA==", - "requires": { - "trim": "0.0.1" - } + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", + "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", + "dev": true }, "sprintf-js": { "version": "1.0.3", @@ -600,199 +659,268 @@ "dev": true }, "state-toggle": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.1.tgz", - "integrity": "sha512-Qe8QntFrrpWTnHwvwj2FZTgv+PKIsp0B9VxLzLLbSpPXWOgRgc5LVj/aTiSfK1RqIeF9jeC1UeOH8Q8y60A7og==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/state-toggle/-/state-toggle-1.0.3.tgz", + "integrity": "sha512-d/5Z4/2iiCnHw6Xzghyhb+GcmF89bxwgXG60wjIiZaxnymbyOmI8Hk4VqHXiVVp6u2ysaskFfXg3ekCj4WNftQ==", + "dev": true }, "stringify-entities": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-1.3.2.tgz", - "integrity": "sha512-nrBAQClJAPN2p+uGCVJRPIPakKeKWZ9GtBCmormE7pWOSlHat7+x5A8gx85M7HM5Dt0BP3pP5RhVW77WdbJJ3A==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/stringify-entities/-/stringify-entities-3.0.1.tgz", + "integrity": "sha512-Lsk3ISA2++eJYqBMPKcr/8eby1I6L0gP0NlxF8Zja6c05yr/yCYyb2c9PwXjd08Ib3If1vn1rbs1H5ZtVuOfvQ==", + "dev": true, "requires": { "character-entities-html4": "^1.0.0", "character-entities-legacy": "^1.0.0", "is-alphanumerical": "^1.0.0", + "is-decimal": "^1.0.2", "is-hexadecimal": "^1.0.0" } }, + "style-to-object": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/style-to-object/-/style-to-object-0.2.3.tgz", + "integrity": "sha512-1d/k4EY2N7jVLOqf2j04dTc37TPOv/hHxZmvpg8Pdh8UYydxeu/C1W1U4vD8alzf5V2Gt7rLsmkr4dxAlDm9ng==", + "dev": true, + "requires": { + "inline-style-parser": "0.1.1" + } + }, "to-vfile": { - "version": "5.0.2", - "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-5.0.2.tgz", - "integrity": "sha512-Gp2q0HCUR+4At6c6mvFKug75NP/8Cu5r7ONvEcJJPBGiDT4HeLBrRnPKJbOe84nHJqYhIah2y367Tr2+IUkwMA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/to-vfile/-/to-vfile-6.1.0.tgz", + "integrity": "sha512-BxX8EkCxOAZe+D/ToHdDsJcVI4HqQfmw0tCkp31zf3dNP/XWIAjU4CmeuSwsSoOzOTqHPOL0KUzyZqJplkD0Qw==", + "dev": true, "requires": { "is-buffer": "^2.0.0", - "vfile": "^3.0.0" + "vfile": "^4.0.0" } }, "trim": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", - "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=" - }, - "trim-lines": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/trim-lines/-/trim-lines-1.1.1.tgz", - "integrity": "sha512-X+eloHbgJGxczUk1WSjIvn7aC9oN3jVE3rQfRVKcgpavi3jxtCn0VVKtjOBj64Yop96UYn/ujJRpTbCdAF1vyg==" + "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=", + "dev": true }, "trim-trailing-lines": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.1.tgz", - "integrity": "sha512-bWLv9BbWbbd7mlqqs2oQYnLD/U/ZqeJeJwbO0FG2zA1aTq+HTvxfHNKFa/HGCVyJpDiioUYaBhfiT6rgk+l4mg==" + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/trim-trailing-lines/-/trim-trailing-lines-1.1.3.tgz", + "integrity": "sha512-4ku0mmjXifQcTVfYDfR5lpgV7zVqPg6zV9rdZmwOPqq0+Zq19xDqEgagqVbc4pOOShbncuAOIs59R3+3gcF3ZA==", + "dev": true }, "trough": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.3.tgz", - "integrity": "sha512-fwkLWH+DimvA4YCy+/nvJd61nWQQ2liO/nF/RjkTpiOGi+zxZzVkhb1mvbHIIW4b/8nDsYI8uTmAlc0nNkRMOw==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", + "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==", + "dev": true }, "unherit": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.1.tgz", - "integrity": "sha512-+XZuV691Cn4zHsK0vkKYwBEwB74T3IZIcxrgn2E4rKwTfFyI1zCh7X7grwh9Re08fdPlarIdyWgI8aVB3F5A5g==", + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.3.tgz", + "integrity": "sha512-Ft16BJcnapDKp0+J/rqFC3Rrk6Y/Ng4nzsC028k2jdDII/rdZ7Wd3pPT/6+vIIxRagwRc9K0IUX0Ra4fKvw+WQ==", + "dev": true, "requires": { - "inherits": "^2.0.1", - "xtend": "^4.0.1" + "inherits": "^2.0.0", + "xtend": "^4.0.0" } }, "unified": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/unified/-/unified-7.1.0.tgz", - "integrity": "sha512-lbk82UOIGuCEsZhPj8rNAkXSDXd6p0QLzIuSsCdxrqnqU56St4eyOB+AlXsVgVeRmetPTYydIuvFfpDIed8mqw==", + "version": "9.2.0", + "resolved": "https://registry.npmjs.org/unified/-/unified-9.2.0.tgz", + "integrity": "sha512-vx2Z0vY+a3YoTj8+pttM3tiJHCwY5UFbYdiWrwBEbHmK8pvsPj2rtAX2BFfgXen8T39CJWblWRDT4L5WGXtDdg==", + "dev": true, "requires": { - "@types/unist": "^2.0.0", - "@types/vfile": "^3.0.0", "bail": "^1.0.0", "extend": "^3.0.0", - "is-plain-obj": "^1.1.0", + "is-buffer": "^2.0.0", + "is-plain-obj": "^2.0.0", "trough": "^1.0.0", - "vfile": "^3.0.0", - "x-is-string": "^0.1.0" + "vfile": "^4.0.0" } }, "unist-builder": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-1.0.2.tgz", - "integrity": "sha1-jDuZA+9kvPsRfdfPal2Y/Bs7J7Y=", - "requires": { - "object-assign": "^4.1.0" - } + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-builder/-/unist-builder-2.0.3.tgz", + "integrity": "sha512-f98yt5pnlMWlzP539tPc4grGMsFaQQlP/vM396b00jngsiINumNmsY8rkXjfoi1c6QaM8nQ3vaGDuoKWbe/1Uw==", + "dev": true }, "unist-util-find": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/unist-util-find/-/unist-util-find-1.0.1.tgz", "integrity": "sha1-EGK7tpKMepfGrcibU3RdTEbCIqI=", + "dev": true, "requires": { "lodash.iteratee": "^4.5.0", "remark": "^5.0.1", "unist-util-visit": "^1.1.0" + }, + "dependencies": { + "unist-util-visit": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.1.tgz", + "integrity": "sha512-AvGNk7Bb//EmJZyhtRUnNMEpId/AZ5Ph/KUpTI09WHQuDZHKovQ1oEv3mfmKpWKtoMzyMC4GLBm1Zy5k12fjIw==", + "dev": true, + "requires": { + "unist-util-visit-parents": "^2.0.0" + } + }, + "unist-util-visit-parents": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.1.2.tgz", + "integrity": "sha512-DyN5vD4NE3aSeB+PXYNKxzGsfocxp6asDc2XXE3b0ekO2BaRUpBicbbUygfSvYfUz1IkmjFR1YF7dPklraMZ2g==", + "dev": true, + "requires": { + "unist-util-is": "^3.0.0" + } + } } }, "unist-util-generated": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.2.tgz", - "integrity": "sha512-1HcwiEO62dr0XWGT+abVK4f0aAm8Ik8N08c5nAYVmuSxfvpA9rCcNyX/le8xXj1pJK5nBrGlZefeWB6bN8Pstw==" + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/unist-util-generated/-/unist-util-generated-1.1.5.tgz", + "integrity": "sha512-1TC+NxQa4N9pNdayCYA1EGUOCAO0Le3fVp7Jzns6lnua/mYgwHo0tz5WUAfrdpNch1RZLHc61VZ1SDgrtNXLSw==", + "dev": true }, "unist-util-is": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-2.1.2.tgz", - "integrity": "sha512-YkXBK/H9raAmG7KXck+UUpnKiNmUdB+aBGrknfQ4EreE1banuzrKABx3jP6Z5Z3fMSPMQQmeXBlKpCbMwBkxVw==" + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-3.0.0.tgz", + "integrity": "sha512-sVZZX3+kspVNmLWBPAB6r+7D9ZgAFPNWm66f7YNb420RlQSbn+n8rG8dGZSkrER7ZIXGQYNm5pqC3v3HopH24A==", + "dev": true }, "unist-util-position": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.0.1.tgz", - "integrity": "sha512-05QfJDPI7PE1BIUtAxeSV+cDx21xP7+tUZgSval5CA7tr0pHBwybF7OnEa1dOFqg6BfYH/qiMUnWwWj+Frhlww==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-position/-/unist-util-position-3.1.0.tgz", + "integrity": "sha512-w+PkwCbYSFw8vpgWD0v7zRCl1FpY3fjDSQ3/N/wNd9Ffa4gPi8+4keqt99N3XW6F99t/mUzp2xAhNmfKWp95QA==", + "dev": true }, "unist-util-remove-position": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-1.1.2.tgz", - "integrity": "sha512-XxoNOBvq1WXRKXxgnSYbtCF76TJrRoe5++pD4cCBsssSiWSnPEktyFrFLE8LTk3JW5mt9hB0Sk5zn4x/JeWY7Q==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/unist-util-remove-position/-/unist-util-remove-position-2.0.1.tgz", + "integrity": "sha512-fDZsLYIe2uT+oGFnuZmy73K6ZxOPG/Qcm+w7jbEjaFcJgbQ6cqjs/eSPzXhsmGpAsWPkqZM9pYjww5QTn3LHMA==", + "dev": true, "requires": { - "unist-util-visit": "^1.1.0" + "unist-util-visit": "^2.0.0" } }, "unist-util-select": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-1.5.0.tgz", - "integrity": "sha1-qTwr6MD2U4J4A7gTMa3sKqJM2TM=", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/unist-util-select/-/unist-util-select-3.0.1.tgz", + "integrity": "sha512-VQpTuqZVJlRbosQdnLdTPIIqwZeU70YZ5aMBOqtFNGeeCdYn6ORZt/9RiaVlbl06ocuf58SVMoFa7a13CSGPMA==", + "dev": true, "requires": { - "css-selector-parser": "^1.1.0", - "debug": "^2.2.0", - "nth-check": "^1.0.1" + "css-selector-parser": "^1.0.0", + "not": "^0.1.0", + "nth-check": "^1.0.0", + "unist-util-is": "^4.0.0", + "zwitch": "^1.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", + "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==", + "dev": true + } } }, "unist-util-stringify-position": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-1.1.2.tgz", - "integrity": "sha512-pNCVrk64LZv1kElr0N1wPiHEUoXNVFERp+mlTg/s9R5Lwg87f9bM/3sQB99w+N9D/qnM9ar3+AKDBwo/gm/iQQ==" + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", + "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", + "dev": true, + "requires": { + "@types/unist": "^2.0.2" + } }, "unist-util-visit": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.4.0.tgz", - "integrity": "sha512-FiGu34ziNsZA3ZUteZxSFaczIjGmksfSgdKqBfOejrrfzyUy5b7YrlzT1Bcvi+djkYDituJDy2XB7tGTeBieKw==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "dev": true, "requires": { - "unist-util-visit-parents": "^2.0.0" + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", + "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==", + "dev": true + } } }, "unist-util-visit-parents": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-2.0.1.tgz", - "integrity": "sha512-6B0UTiMfdWql4cQ03gDTCSns+64Zkfo2OCbK31Ov0uMizEz+CJeAp0cgZVb5Fhmcd7Bct2iRNywejT0orpbqUA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.0.tgz", + "integrity": "sha512-0g4wbluTF93npyPrp/ymd3tCDTMnP0yo2akFD2FIBAYXq/Sga3lwaU1D8OYKbtpioaI6CkDcQ6fsMnmtzt7htw==", + "dev": true, "requires": { - "unist-util-is": "^2.1.2" + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0" + }, + "dependencies": { + "unist-util-is": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.2.tgz", + "integrity": "sha512-Ofx8uf6haexJwI1gxWMGg6I/dLnF2yE+KibhD3/diOqY2TinLcqHXCV6OI5gFVn3xQqDH+u0M625pfKwIwgBKQ==", + "dev": true + } } }, "vfile": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/vfile/-/vfile-3.0.1.tgz", - "integrity": "sha512-y7Y3gH9BsUSdD4KzHsuMaCzRjglXN0W2EcMf0gpvu6+SbsGhMje7xDc8AEoeXy6mIwCKMI6BkjMsRjzQbhMEjQ==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.0.tgz", + "integrity": "sha512-a/alcwCvtuc8OX92rqqo7PflxiCgXRFjdyoGVuYV+qbgCb0GgZJRvIgCD4+U/Kl1yhaRsaTwksF88xbPyGsgpw==", + "dev": true, "requires": { + "@types/unist": "^2.0.0", "is-buffer": "^2.0.0", "replace-ext": "1.0.0", - "unist-util-stringify-position": "^1.0.0", - "vfile-message": "^1.0.0" + "unist-util-stringify-position": "^2.0.0", + "vfile-message": "^2.0.0" } }, "vfile-location": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-2.0.3.tgz", - "integrity": "sha512-zM5/l4lfw1CBoPx3Jimxoc5RNDAHHpk6AM6LM0pTIkm5SUSsx8ZekZ0PVdf0WEZ7kjlhSt7ZlqbRL6Cd6dBs6A==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/vfile-location/-/vfile-location-3.1.0.tgz", + "integrity": "sha512-FCZ4AN9xMcjFIG1oGmZKo61PjwJHRVA+0/tPUP2ul4uIwjGGndIxavEMRpWn5p4xwm/ZsdXp9YNygf1ZyE4x8g==", + "dev": true }, "vfile-message": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-1.1.1.tgz", - "integrity": "sha512-1WmsopSGhWt5laNir+633LszXvZ+Z/lxveBf6yhGsqnQIhlhzooZae7zV6YVM1Sdkw68dtAW3ow0pOdPANugvA==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", + "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", + "dev": true, "requires": { - "unist-util-stringify-position": "^1.1.1" + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^2.0.0" } }, "web-namespaces": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.2.tgz", - "integrity": "sha512-II+n2ms4mPxK+RnIxRPOw3zwF2jRscdJIUE9BfkKHm4FYEg9+biIoTMnaZF5MpemE3T+VhMLrhbyD4ilkPCSbg==" + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.4.tgz", + "integrity": "sha512-wYxSGajtmoP4WxfejAPIr4l0fVh+jeMXZb08wNc0tMg6xsfZXj3cECqIK0G7ZAqUq0PP8WlMDtaOGVBTAWztNw==", + "dev": true }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" - }, - "x-is-array": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/x-is-array/-/x-is-array-0.1.0.tgz", - "integrity": "sha1-3lIBcdR7P0FvVYfWKbidJrEtwp0=" - }, - "x-is-string": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz", - "integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI=" + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true }, "xtend": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.1.tgz", - "integrity": "sha1-pcbVMr5lbiPbgg77lDofBJmNY68=" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", + "dev": true }, "zwitch": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.3.tgz", - "integrity": "sha512-aynRpmJDw7JIq6X4NDWJoiK1yVSiG57ArWSg4HLC1SFupX5/bo0Cf4jpX0ifwuzBfxpYBuNSyvMlWNNRuy3cVA==" + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/zwitch/-/zwitch-1.0.5.tgz", + "integrity": "sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==", + "dev": true } } } diff --git a/tools/doc/package.json b/tools/doc/package.json index 23178fcbc10635..e3e60831a85e57 100644 --- a/tools/doc/package.json +++ b/tools/doc/package.json @@ -6,21 +6,19 @@ "engines": { "node": ">=12.10.0" }, - "dependencies": { - "highlight.js": "^9.18.1", - "rehype-raw": "^2.0.0", - "rehype-stringify": "^3.0.0", - "remark-html": "^7.0.0", - "remark-parse": "^5.0.0", - "remark-rehype": "^3.0.0", - "to-vfile": "^5.0.1", - "unified": "^7.0.0", - "unist-util-find": "^1.0.1", - "unist-util-select": "^1.5.0", - "unist-util-visit": "^1.4.0" - }, "devDependencies": { - "js-yaml": "^3.13.1" + "highlight.js": "10.1.0", + "js-yaml": "3.14.0", + "rehype-raw": "4.0.2", + "rehype-stringify": "8.0.0", + "remark-html": "12.0.0", + "remark-parse": "8.0.3", + "remark-rehype": "7.0.0", + "to-vfile": "6.1.0", + "unified": "9.2.0", + "unist-util-find": "1.0.1", + "unist-util-select": "3.0.1", + "unist-util-visit": "2.0.3" }, "optionalDependencies": {}, "bin": "./generate.js" From c5d27e1e29d65491983cab3bb6012c0619d76103 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Thu, 17 Sep 2020 18:53:37 +0200 Subject: [PATCH 05/42] tools,doc: enforce alphabetical order for md refs PR-URL: https://github.com/nodejs/node/pull/35244 Reviewed-By: Rich Trott Reviewed-By: Shelley Vohr --- doc/api/inspector.md | 4 ++-- doc/api/punycode.md | 2 +- doc/api/wasi.md | 2 +- doc/guides/backporting-to-release-lines.md | 2 +- doc/guides/collaborator-guide.md | 2 +- doc/guides/contributing/pull-requests.md | 8 ++++---- doc/guides/cpp-style-guide.md | 8 ++++---- doc/guides/maintaining-V8.md | 4 ++-- doc/guides/maintaining-icu.md | 4 ++-- doc/guides/releases.md | 4 ++-- doc/guides/writing-and-running-benchmarks.md | 6 +++--- doc/guides/writing-tests.md | 4 ++-- onboarding.md | 4 ++-- src/README.md | 8 ++++---- test/wpt/README.md | 2 +- tools/doc/checkLinks.js | 21 +++++++++++++++++--- tools/icu/README.md | 2 +- 17 files changed, 51 insertions(+), 36 deletions(-) diff --git a/doc/api/inspector.md b/doc/api/inspector.md index f541b9eb99fb68..7dc359a0185404 100644 --- a/doc/api/inspector.md +++ b/doc/api/inspector.md @@ -239,8 +239,8 @@ session.post('HeapProfiler.takeHeapSnapshot', null, (err, r) => { }); ``` -[`'Debugger.paused'`]: https://chromedevtools.github.io/devtools-protocol/v8/Debugger#event-paused -[`session.connect()`]: #inspector_session_connect [CPU Profiler]: https://chromedevtools.github.io/devtools-protocol/v8/Profiler [Chrome DevTools Protocol Viewer]: https://chromedevtools.github.io/devtools-protocol/v8/ [Heap Profiler]: https://chromedevtools.github.io/devtools-protocol/v8/HeapProfiler +[`'Debugger.paused'`]: https://chromedevtools.github.io/devtools-protocol/v8/Debugger#event-paused +[`session.connect()`]: #inspector_session_connect diff --git a/doc/api/punycode.md b/doc/api/punycode.md index d19d79f8195a78..620585afa484c1 100644 --- a/doc/api/punycode.md +++ b/doc/api/punycode.md @@ -148,5 +148,5 @@ added: v0.6.1 Returns a string identifying the current [Punycode.js][] version number. -[Punycode.js]: https://github.com/bestiejs/punycode.js [Punycode]: https://tools.ietf.org/html/rfc3492 +[Punycode.js]: https://github.com/bestiejs/punycode.js diff --git a/doc/api/wasi.md b/doc/api/wasi.md index 85a75bd104f857..66971aa0631540 100644 --- a/doc/api/wasi.md +++ b/doc/api/wasi.md @@ -162,6 +162,6 @@ added: should be passed as the `wasi_snapshot_preview1` import during the instantiation of a [`WebAssembly.Instance`][]. +[WebAssembly System Interface]: https://wasi.dev/ [`WebAssembly.Instance`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Instance [`WebAssembly.Memory`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WebAssembly/Memory -[WebAssembly System Interface]: https://wasi.dev/ diff --git a/doc/guides/backporting-to-release-lines.md b/doc/guides/backporting-to-release-lines.md index 5a96b160351700..90b4a3dcaf328c 100644 --- a/doc/guides/backporting-to-release-lines.md +++ b/doc/guides/backporting-to-release-lines.md @@ -89,6 +89,6 @@ replace that with the staging branch for the targeted release line. After the pull request lands, replace the `backport-requested-v10.x` label on the original pull request with `backported-to-v10.x`. -[Release Schedule]: https://github.com/nodejs/Release#release-schedule1 [Release Plan]: https://github.com/nodejs/Release#release-plan +[Release Schedule]: https://github.com/nodejs/Release#release-schedule1 [`node-test-pull-request`]: https://ci.nodejs.org/job/node-test-pull-request/build diff --git a/doc/guides/collaborator-guide.md b/doc/guides/collaborator-guide.md index 2867a83df177ce..6f408783449ae0 100644 --- a/doc/guides/collaborator-guide.md +++ b/doc/guides/collaborator-guide.md @@ -771,10 +771,10 @@ If you cannot find who to cc for a file, `git shortlog -n -s ` can help. [backporting guide]: backporting-to-release-lines.md [commit message guidelines]: contributing/pull-requests.md#commit-message-guidelines [commit-example]: https://github.com/nodejs/node/commit/b636ba8186 +[git-email]: https://help.github.com/articles/setting-your-commit-email-address-in-git/ [git-node]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md [git-node-metadata]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-metadata [git-username]: https://help.github.com/articles/setting-your-username-in-git/ -[git-email]: https://help.github.com/articles/setting-your-commit-email-address-in-git/ [node-core-utils-credentials]: https://github.com/nodejs/node-core-utils#setting-up-credentials [node-core-utils-issues]: https://github.com/nodejs/node-core-utils/issues [unreliable tests]: https://github.com/nodejs/node/issues?q=is%3Aopen+is%3Aissue+label%3A%22CI+%2F+flaky+test%22 diff --git a/doc/guides/contributing/pull-requests.md b/doc/guides/contributing/pull-requests.md index 18c84068380fa4..5cdf6e82f19ec4 100644 --- a/doc/guides/contributing/pull-requests.md +++ b/doc/guides/contributing/pull-requests.md @@ -593,15 +593,15 @@ widely used, so don't be discouraged! If you want to know more about the code review and the landing process, see the [Collaborator Guide][]. -[approved]: #getting-approvals-for-your-pull-request -[benchmark results]: ../writing-and-running-benchmarks.md [Building guide]: ../../../BUILDING.md [CI (Continuous Integration) test run]: #ci-testing [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md [Collaborator Guide]: ../collaborator-guide.md +[IRC in the #node-dev channel]: https://webchat.freenode.net?channels=node-dev&uio=d4 +[Onboarding guide]: ../../../onboarding.md +[approved]: #getting-approvals-for-your-pull-request +[benchmark results]: ../writing-and-running-benchmarks.md [guide for writing tests in Node.js]: ../writing-tests.md [hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment [https://ci.nodejs.org/]: https://ci.nodejs.org/ -[IRC in the #node-dev channel]: https://webchat.freenode.net?channels=node-dev&uio=d4 -[Onboarding guide]: ../../../onboarding.md [running tests]: ../../../BUILDING.md#running-tests diff --git a/doc/guides/cpp-style-guide.md b/doc/guides/cpp-style-guide.md index adf8f0481697f8..56f3f5b4c84094 100644 --- a/doc/guides/cpp-style-guide.md +++ b/doc/guides/cpp-style-guide.md @@ -392,15 +392,15 @@ Node.js is built [without C++ exception handling][], so code using `throw` or even `try` and `catch` **will** break. [C++ Core Guidelines]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines -[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html -[Google’s `cpplint`]: https://github.com/google/styleguide -[errors]: https://github.com/nodejs/node/blob/master/doc/guides/using-internal-errors.md [ES.47]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-nullptr [ES.48]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-casts [ES.49]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Res-casts-named +[Google C++ Style Guide]: https://google.github.io/styleguide/cppguide.html +[Google’s `cpplint`]: https://github.com/google/styleguide [R.20]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-owner [R.21]: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-unique [Run Time Type Information]: https://en.wikipedia.org/wiki/Run-time_type_information +[aliased_buffer.h]: https://github.com/nodejs/node/blob/master/src/aliased_buffer.h#L12 [cppref_auto_ptr]: https://en.cppreference.com/w/cpp/memory/auto_ptr +[errors]: https://github.com/nodejs/node/blob/master/doc/guides/using-internal-errors.md [without C++ exception handling]: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_exceptions.html#intro.using.exception.no -[aliased_buffer.h]: https://github.com/nodejs/node/blob/master/src/aliased_buffer.h#L12 diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index f57b6f38840707..291c7eb0d9aadd 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -415,8 +415,8 @@ This would require some tooling to: as their support has ended. [ChromiumReleaseCalendar]: https://www.chromium.org/developers/calendar -[Node.js `canary` branch]: https://github.com/nodejs/node-v8/tree/canary [Node.js CI]: https://ci.nodejs.org/job/node-test-pull-request/ +[Node.js `canary` branch]: https://github.com/nodejs/node-v8/tree/canary [NodeJS-Backport-Approved-Chromium]: https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Approved [NodeJS-Backport-Approved-V8]: https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Approved [NodeJS-Backport-Done-Chromium]: https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Done @@ -425,10 +425,10 @@ as their support has ended. [NodeJS-Backport-Rejected-V8]: https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Rejected [NodeJS-Backport-Review-Chromium]: https://bugs.chromium.org/p/chromium/issues/list?can=1&q=label%3ANodeJS-Backport-Review [NodeJS-Backport-Review-V8]: https://bugs.chromium.org/p/v8/issues/list?can=1&q=label%3ANodeJS-Backport-Review -[`git-node`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-v8 [V8 CI]: https://ci.nodejs.org/job/node-test-commit-v8-linux/ [V8ActiveBranches]: https://build.chromium.org/p/client.v8.branches/console [V8Contributing]: https://github.com/v8/v8/wiki/Contributing [V8MergingPatching]: https://github.com/v8/v8/wiki/Merging%20&%20Patching [V8TemplateMergeRequest]: https://bugs.chromium.org/p/v8/issues/entry?template=Node.js%20merge%20request [V8TemplateUpstreamBug]: https://bugs.chromium.org/p/v8/issues/entry?template=Node.js%20upstream%20bug +[`git-node`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-v8 diff --git a/doc/guides/maintaining-icu.md b/doc/guides/maintaining-icu.md index bf5727d4e865c3..f83a435b847c90 100644 --- a/doc/guides/maintaining-icu.md +++ b/doc/guides/maintaining-icu.md @@ -261,8 +261,8 @@ Node.js (see the top level README.md). Only modifying `icu-small` would cause the patch not to be landed in case the user specifies the ICU source code another way. +[CLDR]: https://unicode.org/cldr +[Ecma402]: https://github.com/tc39/ecma402 [ICU]: http://icu-project.org [Unicode]: https://unicode.org [tz]: https://www.iana.org/time-zones -[CLDR]: https://unicode.org/cldr -[Ecma402]: https://github.com/tc39/ecma402 diff --git a/doc/guides/releases.md b/doc/guides/releases.md index e66204e8d007a0..93e5fb85ffa3c1 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -869,9 +869,9 @@ test, or doc-related are to be listed as notable changes. Some SEMVER-MINOR commits may be listed as notable changes on a case-by-case basis. Use your judgment there. -[CI lockdown procedure]: https://github.com/nodejs/build/blob/master/doc/jenkins-guide.md#restricting-access-for-security-releases [Build issue tracker]: https://github.com/nodejs/build/issues/new +[CI lockdown procedure]: https://github.com/nodejs/build/blob/master/doc/jenkins-guide.md#restricting-access-for-security-releases +[Partner Communities]: https://github.com/nodejs/community-committee/blob/master/governance/PARTNER_COMMUNITIES.md [nodejs.org release-post.js script]: https://github.com/nodejs/nodejs.org/blob/master/scripts/release-post.js [nodejs.org repository]: https://github.com/nodejs/nodejs.org -[Partner Communities]: https://github.com/nodejs/community-committee/blob/master/governance/PARTNER_COMMUNITIES.md [webchat.freenode.net]: https://webchat.freenode.net/ diff --git a/doc/guides/writing-and-running-benchmarks.md b/doc/guides/writing-and-running-benchmarks.md index 5f630ccc1f805d..b6b22d75c17e2c 100644 --- a/doc/guides/writing-and-running-benchmarks.md +++ b/doc/guides/writing-and-running-benchmarks.md @@ -551,8 +551,8 @@ Supported options keys are: benchmarker [autocannon]: https://github.com/mcollina/autocannon -[wrk]: https://github.com/wg/wrk -[t-test]: https://en.wikipedia.org/wiki/Student%27s_t-test#Equal_or_unequal_sample_sizes.2C_unequal_variances +[benchmark-ci]: https://github.com/nodejs/benchmarking/blob/master/docs/core_benchmarks.md [git-for-windows]: https://git-scm.com/download/win [nghttp2.org]: https://nghttp2.org -[benchmark-ci]: https://github.com/nodejs/benchmarking/blob/master/docs/core_benchmarks.md +[t-test]: https://en.wikipedia.org/wiki/Student%27s_t-test#Equal_or_unequal_sample_sizes.2C_unequal_variances +[wrk]: https://github.com/wg/wrk diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index 0aa4cb8221f278..b7d92709444678 100644 --- a/doc/guides/writing-tests.md +++ b/doc/guides/writing-tests.md @@ -434,9 +434,9 @@ Nightly coverage reports for the Node.js master branch are available at [ASCII]: https://man7.org/linux/man-pages/man7/ascii.7.html [Google Test]: https://github.com/google/googletest +[Test Coverage section of the Building guide]: https://github.com/nodejs/node/blob/master/BUILDING.md#running-coverage [`common` module]: https://github.com/nodejs/node/blob/master/test/common/README.md [all maintained branches]: https://github.com/nodejs/lts +[directory structure overview]: https://github.com/nodejs/node/blob/master/test/README.md#test-directories [node.green]: https://node.green/ [test fixture]: https://github.com/google/googletest/blob/master/googletest/docs/Primer.md#test-fixtures-using-the-same-data-configuration-for-multiple-tests -[Test Coverage section of the Building guide]: https://github.com/nodejs/node/blob/master/BUILDING.md#running-coverage -[directory structure overview]: https://github.com/nodejs/node/blob/master/test/README.md#test-directories diff --git a/onboarding.md b/onboarding.md index ce176be9a6ab67..8036e459f5122a 100644 --- a/onboarding.md +++ b/onboarding.md @@ -245,12 +245,12 @@ needs to be pointed out separately during the onboarding. the [summit](https://github.com/nodejs/summit) repository for details. [Code of Conduct]: https://github.com/nodejs/admin/blob/master/CODE_OF_CONDUCT.md +[Landing Pull Requests]: doc/guides/collaborator-guide.md#landing-pull-requests +[Publicizing or hiding organization membership]: https://help.github.com/articles/publicizing-or-hiding-organization-membership/ [`author-ready`]: doc/guides/collaborator-guide.md#author-ready-pull-requests [`core-validate-commit`]: https://github.com/nodejs/core-validate-commit [`git-node`]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md [`node-core-utils`]: https://github.com/nodejs/node-core-utils -[Landing Pull Requests]: doc/guides/collaborator-guide.md#landing-pull-requests -[Publicizing or hiding organization membership]: https://help.github.com/articles/publicizing-or-hiding-organization-membership/ [set up the credentials]: https://github.com/nodejs/node-core-utils#setting-up-credentials [two-factor authentication]: https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/ [using a TOTP mobile app]: https://help.github.com/articles/configuring-two-factor-authentication-via-a-totp-mobile-app/ diff --git a/src/README.md b/src/README.md index 3cabf72e11e6af..e81f1e1c70b781 100644 --- a/src/README.md +++ b/src/README.md @@ -929,6 +929,10 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { } ``` +[C++ coding style]: ../doc/guides/cpp-style-guide.md +[Callback scopes]: #callback-scopes +[JavaScript value handles]: #js-handles +[N-API]: https://nodejs.org/api/n-api.html [`BaseObject`]: #baseobject [`Context`]: #context [`Environment`]: #environment @@ -951,10 +955,6 @@ static void GetUserInfo(const FunctionCallbackInfo& args) { [`v8.h` in Node.js master]: https://github.com/nodejs/node/blob/master/deps/v8/include/v8.h [`v8.h` in V8 master]: https://github.com/v8/v8/blob/master/include/v8.h [`vm` module]: https://nodejs.org/api/vm.html -[C++ coding style]: ../doc/guides/cpp-style-guide.md -[Callback scopes]: #callback-scopes -[JavaScript value handles]: #js-handles -[N-API]: https://nodejs.org/api/n-api.html [binding function]: #binding-functions [cleanup hooks]: #cleanup-hooks [event loop]: #event-loop diff --git a/test/wpt/README.md b/test/wpt/README.md index d2a47737b0367b..ec30c2176849a7 100644 --- a/test/wpt/README.md +++ b/test/wpt/README.md @@ -164,5 +164,5 @@ Web API, or certain harness has not been ported in our test runner yet. In that case it needs to be marked with `skip` instead of `fail`. [Web Platform Tests]: https://github.com/web-platform-tests/wpt -[git node wpt]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt [`test/fixtures/wpt/README.md`]: ../fixtures/wpt/README.md +[git node wpt]: https://github.com/nodejs/node-core-utils/blob/master/docs/git-node.md#git-node-wpt diff --git a/tools/doc/checkLinks.js b/tools/doc/checkLinks.js index eea9af4cc9cfc9..97210ca03076e4 100644 --- a/tools/doc/checkLinks.js +++ b/tools/doc/checkLinks.js @@ -27,11 +27,12 @@ function findMarkdownFilesRecursively(dirPath) { if ( entry.isDirectory() && entry.name !== 'api' && - entry.name !== 'tmp' && - entry.name !== 'fixtures' && entry.name !== 'changelogs' && entry.name !== 'deps' && - entry.name !== 'node_modules' + entry.name !== 'fixtures' && + entry.name !== 'node_modules' && + entry.name !== 'out' && + entry.name !== 'tmp' ) { findMarkdownFilesRecursively(path); } else if (entry.isFile() && extname(entry.name) === '.md') { @@ -46,6 +47,7 @@ function checkFile(path) { .parse(fs.readFileSync(path)); const base = pathToFileURL(path); + let previousDefinitionLabel; for (const node of getLinksRecursively(tree)) { const targetURL = new URL(node.url, base); if (targetURL.protocol === 'file:' && !fs.existsSync(targetURL)) { @@ -55,5 +57,18 @@ function checkFile(path) { `Broken link at ${path}:${line}:${column} (${node.url})`); process.exitCode = 1; } + if (node.type === 'definition') { + if (previousDefinitionLabel && + previousDefinitionLabel > node.label) { + const { line, column } = node.position.start; + console.error((process.env.GITHUB_ACTIONS ? + `::error file=${path},line=${line},col=${column}::` : '') + + `Unordered reference at ${path}:${line}:${column} (` + + `"${node.label}" should be before "${previousDefinitionLabel})"` + ); + process.exitCode = 1; + } + previousDefinitionLabel = node.label; + } } } diff --git a/tools/icu/README.md b/tools/icu/README.md index e59f28b71801b7..ab90b760b8c844 100644 --- a/tools/icu/README.md +++ b/tools/icu/README.md @@ -33,5 +33,5 @@ information on maintaining ICU in Node.js internationalization-related APIs in Node.js * [The ICU Homepage][ICU] -[ICU data slicer]: https://github.com/unicode-org/icu/blob/master/docs/userguide/icu_data/buildtool.md [ICU]: http://icu-project.org +[ICU data slicer]: https://github.com/unicode-org/icu/blob/master/docs/userguide/icu_data/buildtool.md From ec6b78ae730362422c03c827013346cff5c78fca Mon Sep 17 00:00:00 2001 From: Clark Kozak Date: Fri, 18 Sep 2020 15:16:59 -0600 Subject: [PATCH 06/42] doc: add `socket.readyState` + description of `socket.readyState` Note: YAML tag found in commit e697cfb6fc020c08afa2c794ee5802e5a4d2b97b Co-authored-by: Michael Auderer PR-URL: https://github.com/nodejs/node/pull/35262 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott --- doc/api/net.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/api/net.md b/doc/api/net.md index 7d70e905be1563..28de44d8897246 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -964,6 +964,20 @@ written out, which may not be immediately. See `Writable` stream [`write()`][stream_writable_write] method for more information. +### `socket.readyState` + + +* {string} + +This property represents the state of the connection as a string. + +* If the stream is connecting `socket.readyState` is `opening`. +* If the stream is readable and writable, it is `open`. +* If the stream is readable and not writable, it is `readOnly`. +* If the stream is not readable and writable, it is `writeOnly`. + ## `net.connect()` Aliases to From 0c4540b050824390c406191cec632a1983be0b79 Mon Sep 17 00:00:00 2001 From: Thomas Hunter II Date: Tue, 22 Sep 2020 20:29:28 -0700 Subject: [PATCH 07/42] doc: fix heading space bug in assert.md Fixing a heading rendering bug PR-URL: https://github.com/nodejs/node/pull/35310 Reviewed-By: Richard Lau Reviewed-By: Rich Trott --- doc/api/assert.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index 01da101908ce6d..e074107cf566c1 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -160,7 +160,7 @@ added: v14.2.0 This feature is currently experimental and behavior might still change. -### `new assert.CallTracker()` +### `new assert.CallTracker()` From 7f355735df53d663dd8081fc21d5912bd62efafd Mon Sep 17 00:00:00 2001 From: Ash Cripps Date: Wed, 23 Sep 2020 11:35:40 +0100 Subject: [PATCH 08/42] tools: ignore build folder when checking links We checkout build as a subdirectory as part of CI and if you run `make test` instead of `make test-ci` you get loads of errors about markdown link breaks. Ignore this directory as we don't need to examine another repo PR-URL: https://github.com/nodejs/node/pull/35315 Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca --- tools/doc/checkLinks.js | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/doc/checkLinks.js b/tools/doc/checkLinks.js index 97210ca03076e4..f3415f521cc6d5 100644 --- a/tools/doc/checkLinks.js +++ b/tools/doc/checkLinks.js @@ -27,6 +27,7 @@ function findMarkdownFilesRecursively(dirPath) { if ( entry.isDirectory() && entry.name !== 'api' && + entry.name !== 'build' && entry.name !== 'changelogs' && entry.name !== 'deps' && entry.name !== 'fixtures' && From 18934497246b25d74980ce1e8941c3e3d8e9ad70 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 20 Sep 2020 08:29:52 -0700 Subject: [PATCH 09/42] doc: revise dependency redirection text in policy.md PR-URL: https://github.com/nodejs/node/pull/35276 Reviewed-By: Ruben Bridgewater Reviewed-By: Luigi Pinca --- doc/api/policy.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/doc/api/policy.md b/doc/api/policy.md index 8a17bd25f74c09..6cca07f8ba59b2 100644 --- a/doc/api/policy.md +++ b/doc/api/policy.md @@ -137,7 +137,7 @@ replaced. ``` The dependencies are keyed by the requested specifier string and have values -of either `true`, `null`, a string pointing to a module that will be resolved, +of either `true`, `null`, a string pointing to a module to be resolved, or a conditions object. The specifier string does not perform any searching and must match exactly @@ -145,20 +145,20 @@ what is provided to the `require()` or `import`. Therefore, multiple specifiers may be needed in the policy if it uses multiple different strings to point to the same module (such as excluding the extension). -If the value of the redirection is `true` the default searching algorithms will -be used to find the module. +If the value of the redirection is `true` the default searching algorithms are +used to find the module. -If the value of the redirection is a string, it will be resolved relative to -the manifest and then immediately be used without searching. +If the value of the redirection is a string, it is resolved relative to +the manifest and then immediately used without searching. -Any specifier string that is attempted to resolve and not listed in the -dependencies will result in an error according to the policy. +Any specifier string for which resolution is attempted and that is not listed in +the dependencies results in an error according to the policy. -Redirection will not prevent access to APIs through means such as direct access -to `require.cache` and/or through `module.constructor` which allow access to +Redirection does not prevent access to APIs through means such as direct access +to `require.cache` or through `module.constructor` which allow access to loading modules. Policy redirection only affects specifiers to `require()` and -`import`. Other means such as to prevent undesired access to APIs through -variables are necessary to lock down that path of loading modules. +`import`. Other means, such as to prevent undesired access to APIs through +variables, are necessary to lock down that path of loading modules. A boolean value of `true` for the dependencies map can be specified to allow a module to load any specifier without redirection. This can be useful for local @@ -167,14 +167,14 @@ only with care after auditing a module to ensure its behavior is valid. Similar to `"exports"` in `package.json`, dependencies can also be specified to be objects containing conditions which branch how dependencies are loaded. In -the preceding example, `"http"` will be allowed when the `"import"` condition is +the preceding example, `"http"` is allowed when the `"import"` condition is part of loading it. -A value of `null` for the resolved value will cause the resolution to fail. This +A value of `null` for the resolved value causes the resolution to fail. This can be used to ensure some kinds of dynamic access are explicitly prevented. -Unknown values for the resolved module location will cause failure but are -not guaranteed to be forwards compatible. +Unknown values for the resolved module location cause failures but are +not guaranteed to be forward compatible. #### Example: Patched dependency From b4514d464d0cc22d587af77dbb64906a878cdc56 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 21 Sep 2020 09:22:54 -0700 Subject: [PATCH 10/42] doc: replace "this guide" link text with guide title PR-URL: https://github.com/nodejs/node/pull/35283 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- doc/api/synopsis.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/synopsis.md b/doc/api/synopsis.md index 1a8fd3ab4bbc88..d4b0ffa36cd1ab 100644 --- a/doc/api/synopsis.md +++ b/doc/api/synopsis.md @@ -20,8 +20,8 @@ there to show the start of each command. Lines that don’t start with `$` or `>` character show the output of the previous command. -First, make sure to have downloaded and installed Node.js. See [this guide][] -for further install information. +First, make sure to have downloaded and installed Node.js. See +[Installing Node.js via package manager][] for further install information. Now, create an empty project folder called `projects`, then navigate into it. @@ -87,5 +87,5 @@ If the browser displays the string `Hello, World!`, that indicates the server is working. [Command-line options]: cli.html#cli_command_line_options -[this guide]: https://nodejs.org/en/download/package-manager/ +[Installing Node.js via package manager]: https://nodejs.org/en/download/package-manager/ [web server]: http.html From b9d767c4d5cd78a6ff6e775739116b3a4f31976b Mon Sep 17 00:00:00 2001 From: Linn Dahlgren Date: Wed, 16 Sep 2020 08:43:00 +0200 Subject: [PATCH 11/42] doc: change type of child_process.signalCode to string During testing, and interfacing with child_processes, I found that the child_process.signalCode property to be the string representation of the signal, not number. PR-URL: https://github.com/nodejs/node/pull/35223 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- doc/api/child_process.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 7ef5c82387346b..3a5f64d622885a 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -1389,9 +1389,9 @@ connection to the child. ### `subprocess.signalCode` -* {integer} +* {string|null} -The `subprocess.signalCode` property indicates the signal number received by +The `subprocess.signalCode` property indicates the signal received by the child process if any, else `null`. ### `subprocess.spawnargs` From ef0d2ef5a254a43cf8f7dec59acb81c30c5104da Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Fri, 7 Aug 2020 13:04:13 +0200 Subject: [PATCH 12/42] doc: move package config docs to separate page This part of the docs aims to contain documentation regarding package configuration that covers both ESM and CJS realms. * Move Enabling section * Update Enabling section * Remove -u flag * Package scopes do not carry through `node_modules` folders Refs: https://github.com/nodejs/modules/issues/539 Co-authored-by: Geoffrey Booth > Co-authored-by: Guy Bedford PR-URL: https://github.com/nodejs/node/pull/34748 Reviewed-By: Derek Lewis Reviewed-By: Geoffrey Booth Reviewed-By: Guy Bedford Reviewed-By: Trivikram Kamat Reviewed-By: Ruy Adorno --- .eslintrc.js | 1 + doc/api/errors.md | 8 +- doc/api/esm.md | 846 ++------------------------------------------ doc/api/index.md | 1 + doc/api/packages.md | 828 +++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 865 insertions(+), 819 deletions(-) create mode 100644 doc/api/packages.md diff --git a/.eslintrc.js b/.eslintrc.js index d9185356d15b06..2ad6cc199cedf7 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -45,6 +45,7 @@ module.exports = { 'doc/api/esm.md', 'doc/api/module.md', 'doc/api/modules.md', + 'doc/api/packages.md', 'test/es-module/test-esm-type-flag.js', 'test/es-module/test-esm-type-flag-alias.js', '*.mjs', diff --git a/doc/api/errors.md b/doc/api/errors.md index 1041d10b5c4129..20394fc5b53483 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -2560,7 +2560,7 @@ closed. [crypto digest algorithm]: crypto.html#crypto_crypto_gethashes [domains]: domain.html [event emitter-based]: events.html#events_class_eventemitter -[exports]: esm.html#esm_package_entry_points +[exports]: packages.html#packages_package_entry_points [file descriptors]: https://en.wikipedia.org/wiki/File_descriptor [policy]: policy.html [stream-based]: stream.html @@ -2568,6 +2568,6 @@ closed. [Subresource Integrity specification]: https://www.w3.org/TR/SRI/#the-integrity-attribute [try-catch]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch [vm]: vm.html -[self-reference a package using its name]: esm.html#esm_self_referencing_a_package_using_its_name -[define a custom subpath]: esm.html#esm_subpath_exports -["imports" field]: esm.html#esm_internal_package_imports +[self-reference a package using its name]: packages.html#packages_self_referencing_a_package_using_its_name +[define a custom subpath]: packages.html#packages_subpath_exports +["imports" field]: packages.html#packages_internal_package_imports diff --git a/doc/api/esm.md b/doc/api/esm.md index 5b1fb5e0417ced..160a6633d7d362 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -44,822 +44,41 @@ Node.js contains support for ES Modules based upon the Expect major changes in the implementation including interoperability support, specifier resolution, and default behavior. + + + + + ## Enabling -Experimental support for ECMAScript modules is enabled by default. -Node.js will treat the following as ES modules when passed to `node` as the -initial input, or when referenced by `import` statements within ES module code: - -* Files ending in `.mjs`. - -* Files ending in `.js` when the nearest parent `package.json` file contains a - top-level field `"type"` with a value of `"module"`. - -* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`, - with the flag `--input-type=module`. - -Node.js will treat as CommonJS all other forms of input, such as `.js` files -where the nearest parent `package.json` file contains no top-level `"type"` -field, or string input without the flag `--input-type`. This behavior is to -preserve backward compatibility. However, now that Node.js supports both -CommonJS and ES modules, it is best to be explicit whenever possible. Node.js -will treat the following as CommonJS when passed to `node` as the initial input, -or when referenced by `import` statements within ES module code: - -* Files ending in `.cjs`. - -* Files ending in `.js` when the nearest parent `package.json` file contains a - top-level field `"type"` with a value of `"commonjs"`. - -* Strings passed in as an argument to `--eval` or `--print`, or piped to `node` - via `STDIN`, with the flag `--input-type=commonjs`. - -### `package.json` `"type"` field - -Files ending with `.js` will be loaded as ES modules when the nearest parent -`package.json` file contains a top-level field `"type"` with a value of -`"module"`. - -The nearest parent `package.json` is defined as the first `package.json` found -when searching in the current folder, that folder’s parent, and so on up -until the root of the volume is reached. - - -```js -// package.json -{ - "type": "module" -} -``` - -```bash -# In same folder as preceding package.json -node my-app.js # Runs as ES module -``` - -If the nearest parent `package.json` lacks a `"type"` field, or contains -`"type": "commonjs"`, `.js` files are treated as CommonJS. If the volume root is -reached and no `package.json` is found, Node.js defers to the default, a -`package.json` with no `"type"` field. - -`import` statements of `.js` files are treated as ES modules if the nearest -parent `package.json` contains `"type": "module"`. - -```js -// my-app.js, part of the same example as above -import './startup.js'; // Loaded as ES module because of package.json -``` - -Package authors should include the `"type"` field, even in packages where all -sources are CommonJS. Being explicit about the `type` of the package will -future-proof the package in case the default type of Node.js ever changes, and -it will also make things easier for build tools and loaders to determine how the -files in the package should be interpreted. - -Regardless of the value of the `"type"` field, `.mjs` files are always treated -as ES modules and `.cjs` files are always treated as CommonJS. - -### Package scope and file extensions - -A folder containing a `package.json` file, and all subfolders below that folder -until the next folder containing another `package.json`, are a -_package scope_. The `"type"` field defines how to treat `.js` files -within the package scope. Every package in a -project’s `node_modules` folder contains its own `package.json` file, so each -project’s dependencies have their own package scopes. If a `package.json` file -does not have a `"type"` field, the default `"type"` is `"commonjs"`. - -The package scope applies not only to initial entry points (`node my-app.js`) -but also to files referenced by `import` statements and `import()` expressions. - -```js -// my-app.js, in an ES module package scope because there is a package.json -// file in the same folder with "type": "module". - -import './startup/init.js'; -// Loaded as ES module since ./startup contains no package.json file, -// and therefore inherits the ES module package scope from one level up. - -import 'commonjs-package'; -// Loaded as CommonJS since ./node_modules/commonjs-package/package.json -// lacks a "type" field or contains "type": "commonjs". - -import './node_modules/commonjs-package/index.js'; -// Loaded as CommonJS since ./node_modules/commonjs-package/package.json -// lacks a "type" field or contains "type": "commonjs". -``` - -Files ending with `.mjs` are always loaded as ES modules regardless of package -scope. - -Files ending with `.cjs` are always loaded as CommonJS regardless of package -scope. - -```js -import './legacy-file.cjs'; -// Loaded as CommonJS since .cjs is always loaded as CommonJS. - -import 'commonjs-package/src/index.mjs'; -// Loaded as ES module since .mjs is always loaded as ES module. -``` - -The `.mjs` and `.cjs` extensions may be used to mix types within the same -package scope: - -* Within a `"type": "module"` package scope, Node.js can be instructed to - interpret a particular file as CommonJS by naming it with a `.cjs` extension - (since both `.js` and `.mjs` files are treated as ES modules within a - `"module"` package scope). - -* Within a `"type": "commonjs"` package scope, Node.js can be instructed to - interpret a particular file as an ES module by naming it with an `.mjs` - extension (since both `.js` and `.cjs` files are treated as CommonJS within a - `"commonjs"` package scope). - -### `--input-type` flag - -Strings passed in as an argument to `--eval` (or `-e`), or piped to `node` via -`STDIN`, will be treated as ES modules when the `--input-type=module` flag is -set. - -```bash -node --input-type=module --eval "import { sep } from 'path'; console.log(sep);" - -echo "import { sep } from 'path'; console.log(sep);" | node --input-type=module -``` - -For completeness there is also `--input-type=commonjs`, for explicitly running -string input as CommonJS. This is the default behavior if `--input-type` is -unspecified. +Node.js treats JavaScript code as CommonJS modules by default. +Authors can tell Node.js to treat JavaScript code as ECMAScript modules +via the `.mjs` file extension, the `package.json` `"type"` field, or the +`--input-type` flag. See +[Modules: Packages](packages.html#packages_determining_module_system) for more +details. + + + + + + + + + + + + + + + + ## Packages -### Package entry points - -In a package’s `package.json` file, two fields can define entry points for a -package: `"main"` and `"exports"`. The `"main"` field is supported in all -versions of Node.js, but its capabilities are limited: it only defines the main -entry point of the package. - -The `"exports"` field provides an alternative to `"main"` where the package -main entry point can be defined while also encapsulating the package, -**preventing any other entry points besides those defined in `"exports"`**. -This encapsulation allows module authors to define a public interface for -their package. - -If both `"exports"` and `"main"` are defined, the `"exports"` field takes -precedence over `"main"`. `"exports"` are not specific to ES modules or -CommonJS; `"main"` will be overridden by `"exports"` if it exists. As such -`"main"` cannot be used as a fallback for CommonJS but it can be used as a -fallback for legacy versions of Node.js that do not support the `"exports"` -field. - -[Conditional exports][] can be used within `"exports"` to define different -package entry points per environment, including whether the package is -referenced via `require` or via `import`. For more information about supporting -both CommonJS and ES Modules in a single package please consult -[the dual CommonJS/ES module packages section][]. - -**Warning**: Introducing the `"exports"` field prevents consumers of a package -from using any entry points that are not defined, including the `package.json` -(e.g. `require('your-package/package.json')`. **This will likely be a breaking -change.** - -To make the introduction of `"exports"` non-breaking, ensure that every -previously supported entry point is exported. It is best to explicitly specify -entry points so that the package’s public API is well-defined. For example, -a project that previous exported `main`, `lib`, -`feature`, and the `package.json` could use the following `package.exports`: - -```json -{ - "name": "my-mod", - "exports": { - ".": "./lib/index.js", - "./lib": "./lib/index.js", - "./lib/index": "./lib/index.js", - "./lib/index.js": "./lib/index.js", - "./feature": "./feature/index.js", - "./feature/index.js": "./feature/index.js", - "./package.json": "./package.json" - } -} -``` - -Alternatively a project could choose to export entire folders: - -```json -{ - "name": "my-mod", - "exports": { - ".": "./lib/index.js", - "./lib": "./lib/index.js", - "./lib/": "./lib/", - "./feature": "./feature/index.js", - "./feature/": "./feature/", - "./package.json": "./package.json" - } -} -``` - -As a last resort, package encapsulation can be disabled entirely by creating an -export for the root of the package `"./": "./"`. This will expose every file in -the package at the cost of disabling the encapsulation and potential tooling -benefits this provides. As the ES Module loader in Node.js enforces the use of -[the full specifier path][], exporting the root rather than being explicit -about entry is less expressive than either of the prior examples. Not only -will encapsulation be lost but module consumers will be unable to -`import feature from 'my-mod/feature'` as they will need to provide the full -path `import feature from 'my-mod/feature/index.js`. - -#### Main entry point export - -To set the main entry point for a package, it is advisable to define both -`"exports"` and `"main"` in the package’s `package.json` file: - - -```js -{ - "main": "./main.js", - "exports": "./main.js" -} -``` - -The benefit of doing this is that when using the `"exports"` field all -subpaths of the package will no longer be available to importers under -`require('pkg/subpath.js')`, and instead they will get a new error, -`ERR_PACKAGE_PATH_NOT_EXPORTED`. - -This encapsulation of exports provides more reliable guarantees -about package interfaces for tools and when handling semver upgrades for a -package. It is not a strong encapsulation since a direct require of any -absolute subpath of the package such as -`require('/path/to/node_modules/pkg/subpath.js')` will still load `subpath.js`. - -#### Subpath exports - -When using the `"exports"` field, custom subpaths can be defined along -with the main entry point by treating the main entry point as the -`"."` subpath: - - -```js -{ - "main": "./main.js", - "exports": { - ".": "./main.js", - "./submodule": "./src/submodule.js" - } -} -``` - -Now only the defined subpath in `"exports"` can be imported by a -consumer: - -```js -import submodule from 'es-module-package/submodule'; -// Loads ./node_modules/es-module-package/src/submodule.js -``` - -While other subpaths will error: - -```js -import submodule from 'es-module-package/private-module.js'; -// Throws ERR_PACKAGE_PATH_NOT_EXPORTED -``` - -Entire folders can also be mapped with package exports: - - -```js -// ./node_modules/es-module-package/package.json -{ - "exports": { - "./features/": "./src/features/" - } -} -``` - -With the above, all modules within the `./src/features/` folder -are exposed deeply to `import` and `require`: - -```js -import feature from 'es-module-package/features/x.js'; -// Loads ./node_modules/es-module-package/src/features/x.js -``` - -When using folder mappings, ensure that you do want to expose every -module inside the subfolder. Any modules which are not public -should be moved to another folder to retain the encapsulation -benefits of exports. - -#### Package exports fallbacks - -For possible new specifier support in future, array fallbacks are -supported for all invalid specifiers: - - -```js -{ - "exports": { - "./submodule": ["not:valid", "./submodule.js"] - } -} -``` - -Since `"not:valid"` is not a valid specifier, `"./submodule.js"` is used -instead as the fallback, as if it were the only target. - -#### Exports sugar - -If the `"."` export is the only export, the `"exports"` field provides sugar -for this case being the direct `"exports"` field value. - -If the `"."` export has a fallback array or string value, then the `"exports"` -field can be set to this value directly. - - -```js -{ - "exports": { - ".": "./main.js" - } -} -``` - -can be written: - - -```js -{ - "exports": "./main.js" -} -``` - -#### Conditional exports - -Conditional exports provide a way to map to different paths depending on -certain conditions. They are supported for both CommonJS and ES module imports. - -For example, a package that wants to provide different ES module exports for -`require()` and `import` can be written: - - -```js -// package.json -{ - "main": "./main-require.cjs", - "exports": { - "import": "./main-module.js", - "require": "./main-require.cjs" - }, - "type": "module" -} -``` - -Node.js supports the following conditions out of the box: - -* `"import"` - matched when the package is loaded via `import` or - `import()`. Can reference either an ES module or CommonJS file, as both - `import` and `import()` can load either ES module or CommonJS sources. - _Always matched when the `"require"` condition is not matched._ -* `"require"` - matched when the package is loaded via `require()`. - As `require()` only supports CommonJS, the referenced file must be CommonJS. - _Always matched when the `"import"` condition is not matched._ -* `"node"` - matched for any Node.js environment. Can be a CommonJS or ES - module file. _This condition should always come after `"import"` or - `"require"`._ -* `"default"` - the generic fallback that will always match. Can be a CommonJS - or ES module file. _This condition should always come last._ - -Within the `"exports"` object, key order is significant. During condition -matching, earlier entries have higher priority and take precedence over later -entries. _The general rule is that conditions should be from most specific to -least specific in object order_. - -Other conditions such as `"browser"`, `"electron"`, `"deno"`, `"react-native"`, -etc. are unknown to, and thus ignored by Node.js. Runtimes or tools other than -Node.js may use them at their discretion. Further restrictions, definitions, or -guidance on condition names may occur in the future. - -Using the `"import"` and `"require"` conditions can lead to some hazards, -which are further explained in [the dual CommonJS/ES module packages section][]. - -Conditional exports can also be extended to exports subpaths, for example: - - -```js -{ - "main": "./main.js", - "exports": { - ".": "./main.js", - "./feature": { - "node": "./feature-node.js", - "default": "./feature.js" - } - } -} -``` - -Defines a package where `require('pkg/feature')` and `import 'pkg/feature'` -could provide different implementations between Node.js and other JS -environments. - -When using environment branches, always include a `"default"` condition where -possible. Providing a `"default"` condition ensures that any unknown JS -environments are able to use this universal implementation, which helps avoid -these JS environments from having to pretend to be existing environments in -order to support packages with conditional exports. For this reason, using -`"node"` and `"default"` condition branches is usually preferable to using -`"node"` and `"browser"` condition branches. - -#### Nested conditions - -In addition to direct mappings, Node.js also supports nested condition objects. - -For example, to define a package that only has dual mode entry points for -use in Node.js but not the browser: - - -```js -{ - "main": "./main.js", - "exports": { - "node": { - "import": "./feature-node.mjs", - "require": "./feature-node.cjs" - }, - "default": "./feature.mjs", - } -} -``` - -Conditions continue to be matched in order as with flat conditions. If -a nested conditional does not have any mapping it will continue checking -the remaining conditions of the parent condition. In this way nested -conditions behave analogously to nested JavaScript `if` statements. - -#### Resolving user conditions - -When running Node.js, custom user conditions can be added with the -`--conditions` or `-u` flag: - -```bash -node --conditions=development main.js -``` - -which would then resolve the `"development"` condition in package imports and -exports, while resolving the existing `"node"`, `"default"`, `"import"`, and -`"require"` conditions as appropriate. - -Any number of custom conditions can be set with repeat flags. - -#### Self-referencing a package using its name - -Within a package, the values defined in the package’s -`package.json` `"exports"` field can be referenced via the package’s name. -For example, assuming the `package.json` is: - -```json -// package.json -{ - "name": "a-package", - "exports": { - ".": "./main.mjs", - "./foo": "./foo.js" - } -} -``` - -Then any module _in that package_ can reference an export in the package itself: - -```js -// ./a-module.mjs -import { something } from 'a-package'; // Imports "something" from ./main.mjs. -``` - -Self-referencing is available only if `package.json` has `exports`, and will -allow importing only what that `exports` (in the `package.json`) allows. -So the code below, given the previous package, will generate a runtime error: - -```js -// ./another-module.mjs - -// Imports "another" from ./m.mjs. Fails because -// the "package.json" "exports" field -// does not provide an export named "./m.mjs". -import { another } from 'a-package/m.mjs'; -``` - -Self-referencing is also available when using `require`, both in an ES module, -and in a CommonJS one. For example, this code will also work: - -```js -// ./a-module.js -const { something } = require('a-package/foo'); // Loads from ./foo.js. -``` - -### Internal package imports - -In addition to the `"exports"` field it is possible to define internal package -import maps that only apply to import specifiers from within the package itself. - -Entries in the imports field must always start with `#` to ensure they are -clearly disambiguated from package specifiers. - -For example, the imports field can be used to gain the benefits of conditional -exports for internal modules: - -```json -// package.json -{ - "imports": { - "#dep": { - "node": "dep-node-native", - "default": "./dep-polyfill.js" - } - }, - "dependencies": { - "dep-node-native": "^1.0.0" - } -} -``` - -where `import '#dep'` would now get the resolution of the external package -`dep-node-native` (including its exports in turn), and instead get the local -file `./dep-polyfill.js` relative to the package in other environments. - -Unlike the exports field, import maps permit mapping to external packages -because this provides an important use case for conditional loading and also can -be done without the risk of cycles, unlike for exports. - -Apart from the above, the resolution rules for the imports field are otherwise -analogous to the exports field. - -### Dual CommonJS/ES module packages - -Prior to the introduction of support for ES modules in Node.js, it was a common -pattern for package authors to include both CommonJS and ES module JavaScript -sources in their package, with `package.json` `"main"` specifying the CommonJS -entry point and `package.json` `"module"` specifying the ES module entry point. -This enabled Node.js to run the CommonJS entry point while build tools such as -bundlers used the ES module entry point, since Node.js ignored (and still -ignores) the top-level `"module"` field. - -Node.js can now run ES module entry points, and a package can contain both -CommonJS and ES module entry points (either via separate specifiers such as -`'pkg'` and `'pkg/es-module'`, or both at the same specifier via [Conditional -exports][]). Unlike in the scenario where `"module"` is only used by bundlers, -or ES module files are transpiled into CommonJS on the fly before evaluation by -Node.js, the files referenced by the ES module entry point are evaluated as ES -modules. - -#### Dual package hazard - -When an application is using a package that provides both CommonJS and ES module -sources, there is a risk of certain bugs if both versions of the package get -loaded. This potential comes from the fact that the `pkgInstance` created by -`const pkgInstance = require('pkg')` is not the same as the `pkgInstance` -created by `import pkgInstance from 'pkg'` (or an alternative main path like -`'pkg/module'`). This is the “dual package hazard,” where two versions of the -same package can be loaded within the same runtime environment. While it is -unlikely that an application or package would intentionally load both versions -directly, it is common for an application to load one version while a dependency -of the application loads the other version. This hazard can happen because -Node.js supports intermixing CommonJS and ES modules, and can lead to unexpected -behavior. - -If the package main export is a constructor, an `instanceof` comparison of -instances created by the two versions returns `false`, and if the export is an -object, properties added to one (like `pkgInstance.foo = 3`) are not present on -the other. This differs from how `import` and `require` statements work in -all-CommonJS or all-ES module environments, respectively, and therefore is -surprising to users. It also differs from the behavior users are familiar with -when using transpilation via tools like [Babel][] or [`esm`][]. - -#### Writing dual packages while avoiding or minimizing hazards - -First, the hazard described in the previous section occurs when a package -contains both CommonJS and ES module sources and both sources are provided for -use in Node.js, either via separate main entry points or exported paths. A -package could instead be written where any version of Node.js receives only -CommonJS sources, and any separate ES module sources the package may contain -could be intended only for other environments such as browsers. Such a package -would be usable by any version of Node.js, since `import` can refer to CommonJS -files; but it would not provide any of the advantages of using ES module syntax. - -A package could also switch from CommonJS to ES module syntax in a breaking -change version bump. This has the disadvantage that the newest version -of the package would only be usable in ES module-supporting versions of Node.js. - -Every pattern has tradeoffs, but there are two broad approaches that satisfy the -following conditions: - -1. The package is usable via both `require` and `import`. -1. The package is usable in both current Node.js and older versions of Node.js - that lack support for ES modules. -1. The package main entry point, e.g. `'pkg'` can be used by both `require` to - resolve to a CommonJS file and by `import` to resolve to an ES module file. - (And likewise for exported paths, e.g. `'pkg/feature'`.) -1. The package provides named exports, e.g. `import { name } from 'pkg'` rather - than `import pkg from 'pkg'; pkg.name`. -1. The package is potentially usable in other ES module environments such as - browsers. -1. The hazards described in the previous section are avoided or minimized. - -##### Approach #1: Use an ES module wrapper - -Write the package in CommonJS or transpile ES module sources into CommonJS, and -create an ES module wrapper file that defines the named exports. Using -[Conditional exports][], the ES module wrapper is used for `import` and the -CommonJS entry point for `require`. - - -```js -// ./node_modules/pkg/package.json -{ - "type": "module", - "main": "./index.cjs", - "exports": { - "import": "./wrapper.mjs", - "require": "./index.cjs" - } -} -``` - -The preceding example uses explicit extensions `.mjs` and `.cjs`. -If your files use the `.js` extension, `"type": "module"` will cause such files -to be treated as ES modules, just as `"type": "commonjs"` would cause them -to be treated as CommonJS. -See [Enabling](#esm_enabling). - -```js -// ./node_modules/pkg/index.cjs -exports.name = 'value'; -``` - -```js -// ./node_modules/pkg/wrapper.mjs -import cjsModule from './index.cjs'; -export const name = cjsModule.name; -``` - -In this example, the `name` from `import { name } from 'pkg'` is the same -singleton as the `name` from `const { name } = require('pkg')`. Therefore `===` -returns `true` when comparing the two `name`s and the divergent specifier hazard -is avoided. - -If the module is not simply a list of named exports, but rather contains a -unique function or object export like `module.exports = function () { ... }`, -or if support in the wrapper for the `import pkg from 'pkg'` pattern is desired, -then the wrapper would instead be written to export the default optionally -along with any named exports as well: - -```js -import cjsModule from './index.cjs'; -export const name = cjsModule.name; -export default cjsModule; -``` - -This approach is appropriate for any of the following use cases: -* The package is currently written in CommonJS and the author would prefer not - to refactor it into ES module syntax, but wishes to provide named exports for - ES module consumers. -* The package has other packages that depend on it, and the end user might - install both this package and those other packages. For example a `utilities` - package is used directly in an application, and a `utilities-plus` package - adds a few more functions to `utilities`. Because the wrapper exports - underlying CommonJS files, it doesn’t matter if `utilities-plus` is written in - CommonJS or ES module syntax; it will work either way. -* The package stores internal state, and the package author would prefer not to - refactor the package to isolate its state management. See the next section. - -A variant of this approach not requiring conditional exports for consumers could -be to add an export, e.g. `"./module"`, to point to an all-ES module-syntax -version of the package. This could be used via `import 'pkg/module'` by users -who are certain that the CommonJS version will not be loaded anywhere in the -application, such as by dependencies; or if the CommonJS version can be loaded -but doesn’t affect the ES module version (for example, because the package is -stateless): - - -```js -// ./node_modules/pkg/package.json -{ - "type": "module", - "main": "./index.cjs", - "exports": { - ".": "./index.cjs", - "./module": "./wrapper.mjs" - } -} -``` - -##### Approach #2: Isolate state - -A `package.json` file can define the separate CommonJS and ES module entry -points directly: - - -```js -// ./node_modules/pkg/package.json -{ - "type": "module", - "main": "./index.cjs", - "exports": { - "import": "./index.mjs", - "require": "./index.cjs" - } -} -``` - -This can be done if both the CommonJS and ES module versions of the package are -equivalent, for example because one is the transpiled output of the other; and -the package’s management of state is carefully isolated (or the package is -stateless). - -The reason that state is an issue is because both the CommonJS and ES module -versions of the package may get used within an application; for example, the -user’s application code could `import` the ES module version while a dependency -`require`s the CommonJS version. If that were to occur, two copies of the -package would be loaded in memory and therefore two separate states would be -present. This would likely cause hard-to-troubleshoot bugs. - -Aside from writing a stateless package (if JavaScript’s `Math` were a package, -for example, it would be stateless as all of its methods are static), there are -some ways to isolate state so that it’s shared between the potentially loaded -CommonJS and ES module instances of the package: - -1. If possible, contain all state within an instantiated object. JavaScript’s - `Date`, for example, needs to be instantiated to contain state; if it were a - package, it would be used like this: - - ```js - import Date from 'date'; - const someDate = new Date(); - // someDate contains state; Date does not - ``` - - The `new` keyword isn’t required; a package’s function can return a new - object, or modify a passed-in object, to keep the state external to the - package. - -1. Isolate the state in one or more CommonJS files that are shared between the - CommonJS and ES module versions of the package. For example, if the CommonJS - and ES module entry points are `index.cjs` and `index.mjs`, respectively: - - ```js - // ./node_modules/pkg/index.cjs - const state = require('./state.cjs'); - module.exports.state = state; - ``` - - ```js - // ./node_modules/pkg/index.mjs - import state from './state.cjs'; - export { - state - }; - ``` - - Even if `pkg` is used via both `require` and `import` in an application (for - example, via `import` in application code and via `require` by a dependency) - each reference of `pkg` will contain the same state; and modifying that - state from either module system will apply to both. - -Any plugins that attach to the package’s singleton would need to separately -attach to both the CommonJS and ES module singletons. - -This approach is appropriate for any of the following use cases: -* The package is currently written in ES module syntax and the package author - wants that version to be used wherever such syntax is supported. -* The package is stateless or its state can be isolated without too much - difficulty. -* The package is unlikely to have other public packages that depend on it, or if - it does, the package is stateless or has state that need not be shared between - dependencies or with the overall application. - -Even with isolated state, there is still the cost of possible extra code -execution between the CommonJS and ES module versions of a package. - -As with the previous approach, a variant of this approach not requiring -conditional exports for consumers could be to add an export, e.g. -`"./module"`, to point to an all-ES module-syntax version of the package: - - -```js -// ./node_modules/pkg/package.json -{ - "type": "module", - "main": "./index.cjs", - "exports": { - ".": "./index.cjs", - "./module": "./index.mjs" - } -} -``` +This section was moved to [Modules: Packages](packages.html). ## `import` Specifiers @@ -1079,7 +298,7 @@ cjs === 'cjs'; // true ## Builtin modules -Builtin modules will provide named exports of their public API. A +[Core modules][] will provide named exports of their public API. A default export is also provided which is the value of the CommonJS exports. The default export can be used for, among other things, modifying the named exports. Named exports of builtin modules are updated only by calling @@ -1910,9 +1129,8 @@ $ node --experimental-specifier-resolution=node index success! ``` -[Babel]: https://babeljs.io/ [CommonJS]: modules.html -[Conditional exports]: #esm_conditional_exports +[Conditional exports]: packages.html#packages_conditional_exports [Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports [ECMAScript-modules implementation]: https://github.com/nodejs/modules/blob/master/doc/plan-for-new-modules-implementation.md [ECMAScript Top-Level `await` proposal]: https://github.com/tc39/proposal-top-level-await/ @@ -1921,7 +1139,6 @@ success! [Terminology]: #esm_terminology [WHATWG JSON modules specification]: https://html.spec.whatwg.org/#creating-a-json-module-script [`data:` URLs]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs -[`esm`]: https://github.com/standard-things/esm#readme [`export`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export [`import()`]: #esm_import_expressions [`import.meta.url`]: #esm_import_meta @@ -1937,9 +1154,8 @@ success! [`util.TextDecoder`]: util.html#util_class_util_textdecoder [import an ES or CommonJS module for its side effects only]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only [special scheme]: https://url.spec.whatwg.org/#special-scheme -[the full specifier path]: #esm_mandatory_file_extensions [the official standard format]: https://tc39.github.io/ecma262/#sec-modules -[the dual CommonJS/ES module packages section]: #esm_dual_commonjs_es_module_packages [transpiler loader example]: #esm_transpiler_loader [6.1.7 Array Index]: https://tc39.es/ecma262/#integer-index [Top-Level Await]: https://github.com/tc39/proposal-top-level-await +[Core modules]: modules.html#modules_core_modules diff --git a/doc/api/index.md b/doc/api/index.md index 756b79ec0812dc..69746392df61a2 100644 --- a/doc/api/index.md +++ b/doc/api/index.md @@ -37,6 +37,7 @@ * [Modules: CommonJS modules](modules.html) * [Modules: ECMAScript modules](esm.html) * [Modules: `module` API](module.html) +* [Modules: Packages](packages.html) * [Net](net.html) * [OS](os.html) * [Path](path.html) diff --git a/doc/api/packages.md b/doc/api/packages.md new file mode 100644 index 00000000000000..c8fbf6c213bb83 --- /dev/null +++ b/doc/api/packages.md @@ -0,0 +1,828 @@ +# Modules: Packages + + + +## Introduction + +A package is a folder described by a `package.json` file. + +A folder containing a `package.json` file, and all subfolders below that folder +until the next folder containing another `package.json` file, are a _package +scope_. + +## Determining module system + +Node.js will treat the following as [ES modules][] when passed to `node` as the +initial input, or when referenced by `import` statements within ES module code: + +* Files ending in `.mjs`. + +* Files ending in `.js` when the nearest parent `package.json` file contains a + top-level field `"type"` with a value of `"module"`. + +* Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`, + with the flag `--input-type=module`. + +Node.js will treat as [CommonJS][] all other forms of input, such as `.js` files +where the nearest parent `package.json` file contains no top-level `"type"` +field, or string input without the flag `--input-type`. This behavior is to +preserve backward compatibility. However, now that Node.js supports both +CommonJS and ES modules, it is best to be explicit whenever possible. Node.js +will treat the following as CommonJS when passed to `node` as the initial input, +or when referenced by `import` statements within ES module code: + +* Files ending in `.cjs`. + +* Files ending in `.js` when the nearest parent `package.json` file contains a + top-level field `"type"` with a value of `"commonjs"`. + +* Strings passed in as an argument to `--eval` or `--print`, or piped to `node` + via `STDIN`, with the flag `--input-type=commonjs`. + +### `package.json` `"type"` field + +Files ending with `.js` will be loaded as [ES modules][] when the nearest parent +`package.json` file contains a top-level field `"type"` with a value of +`"module"`. + +The nearest parent `package.json` is defined as the first `package.json` found +when searching in the current folder, that folder’s parent, and so on up +until the root of the volume is reached. + + +```js +// package.json +{ + "type": "module" +} +``` + +```bash +# In same folder as preceding package.json +node my-app.js # Runs as ES module +``` + +If the nearest parent `package.json` lacks a `"type"` field, or contains +`"type": "commonjs"`, `.js` files are treated as [CommonJS][]. If the volume +root is reached and no `package.json` is found, Node.js defers to the default, a +`package.json` with no `"type"` field. + +`import` statements of `.js` files are treated as ES modules if the nearest +parent `package.json` contains `"type": "module"`. + +```js +// my-app.js, part of the same example as above +import './startup.js'; // Loaded as ES module because of package.json +``` + +Package authors should include the `"type"` field, even in packages where all +sources are [CommonJS][]. Being explicit about the `type` of the package will +future-proof the package in case the default type of Node.js ever changes, and +it will also make things easier for build tools and loaders to determine how the +files in the package should be interpreted. + +Regardless of the value of the `"type"` field, `.mjs` files are always treated +as ES modules and `.cjs` files are always treated as [CommonJS][]. + +### Package scope and file extensions + +A folder containing a `package.json` file, and all subfolders below that folder +until the next folder containing another `package.json`, are a +_package scope_. Package scopes do not carry through `node_modules` folders. The +`"type"` field defines how to treat `.js` files within the package scope. If a +`package.json` file does not have a `"type"` field, the default is `"commonjs"`. + +The package scope applies not only to initial entry points (`node my-app.js`) +but also to files referenced by `import` statements and `import()` expressions. + +```js +// my-app.js, in an ES module package scope because there is a package.json +// file in the same folder with "type": "module". + +import './startup/init.js'; +// Loaded as ES module since ./startup contains no package.json file, +// and therefore inherits the ES module package scope from one level up. + +import 'commonjs-package'; +// Loaded as CommonJS since ./node_modules/commonjs-package/package.json +// lacks a "type" field or contains "type": "commonjs". + +import './node_modules/commonjs-package/index.js'; +// Loaded as CommonJS since ./node_modules/commonjs-package/package.json +// lacks a "type" field or contains "type": "commonjs". +``` + +Files ending with `.mjs` are always loaded as [ES modules][] regardless of +package scope. + +Files ending with `.cjs` are always loaded as [CommonJS][] regardless of package +scope. + +```js +import './legacy-file.cjs'; +// Loaded as CommonJS since .cjs is always loaded as CommonJS. + +import 'commonjs-package/src/index.mjs'; +// Loaded as ES module since .mjs is always loaded as ES module. +``` + +The `.mjs` and `.cjs` extensions may be used to mix types within the same +package scope: + +* Within a `"type": "module"` package scope, Node.js can be instructed to + interpret a particular file as [CommonJS][] by naming it with a `.cjs` + extension (since both `.js` and `.mjs` files are treated as ES modules within + a `"module"` package scope). + +* Within a `"type": "commonjs"` package scope, Node.js can be instructed to + interpret a particular file as an ES module by naming it with an `.mjs` + extension (since both `.js` and `.cjs` files are treated as CommonJS within a + `"commonjs"` package scope). + +### `--input-type` flag + +Strings passed in as an argument to `--eval` (or `-e`), or piped to `node` via +`STDIN`, will be treated as [ES modules][] when the `--input-type=module` flag +is set. + +```bash +node --input-type=module --eval "import { sep } from 'path'; console.log(sep);" + +echo "import { sep } from 'path'; console.log(sep);" | node --input-type=module +``` + +For completeness there is also `--input-type=commonjs`, for explicitly running +string input as CommonJS. This is the default behavior if `--input-type` is +unspecified. + +## Package entry points + +In a package’s `package.json` file, two fields can define entry points for a +package: `"main"` and `"exports"`. The `"main"` field is supported in all +versions of Node.js, but its capabilities are limited: it only defines the main +entry point of the package. + +The `"exports"` field provides an alternative to `"main"` where the package +main entry point can be defined while also encapsulating the package, +**preventing any other entry points besides those defined in `"exports"`**. +This encapsulation allows module authors to define a public interface for +their package. + +If both `"exports"` and `"main"` are defined, the `"exports"` field takes +precedence over `"main"`. `"exports"` are not specific to ES modules or +CommonJS; `"main"` will be overridden by `"exports"` if it exists. As such +`"main"` cannot be used as a fallback for CommonJS but it can be used as a +fallback for legacy versions of Node.js that do not support the `"exports"` +field. + +[Conditional exports][] can be used within `"exports"` to define different +package entry points per environment, including whether the package is +referenced via `require` or via `import`. For more information about supporting +both CommonJS and ES Modules in a single package please consult +[the dual CommonJS/ES module packages section][]. + +**Warning**: Introducing the `"exports"` field prevents consumers of a package +from using any entry points that are not defined, including the `package.json` +(e.g. `require('your-package/package.json')`. **This will likely be a breaking +change.** + +To make the introduction of `"exports"` non-breaking, ensure that every +previously supported entry point is exported. It is best to explicitly specify +entry points so that the package’s public API is well-defined. For example, +a project that previous exported `main`, `lib`, +`feature`, and the `package.json` could use the following `package.exports`: + +```json +{ + "name": "my-mod", + "exports": { + ".": "./lib/index.js", + "./lib": "./lib/index.js", + "./lib/index": "./lib/index.js", + "./lib/index.js": "./lib/index.js", + "./feature": "./feature/index.js", + "./feature/index.js": "./feature/index.js", + "./package.json": "./package.json" + } +} +``` + +Alternatively a project could choose to export entire folders: + +```json +{ + "name": "my-mod", + "exports": { + ".": "./lib/index.js", + "./lib": "./lib/index.js", + "./lib/": "./lib/", + "./feature": "./feature/index.js", + "./feature/": "./feature/", + "./package.json": "./package.json" + } +} +``` + +As a last resort, package encapsulation can be disabled entirely by creating an +export for the root of the package `"./": "./"`. This will expose every file in +the package at the cost of disabling the encapsulation and potential tooling +benefits this provides. As the ES Module loader in Node.js enforces the use of +[the full specifier path][], exporting the root rather than being explicit +about entry is less expressive than either of the prior examples. Not only +will encapsulation be lost but module consumers will be unable to +`import feature from 'my-mod/feature'` as they will need to provide the full +path `import feature from 'my-mod/feature/index.js`. + +### Main entry point export + +To set the main entry point for a package, it is advisable to define both +`"exports"` and `"main"` in the package’s `package.json` file: + +```json +{ + "main": "./main.js", + "exports": "./main.js" +} +``` + +The benefit of doing this is that when using the `"exports"` field all +subpaths of the package will no longer be available to importers under +`require('pkg/subpath.js')`, and instead they will get a new error, +`ERR_PACKAGE_PATH_NOT_EXPORTED`. + +This encapsulation of exports provides more reliable guarantees +about package interfaces for tools and when handling semver upgrades for a +package. It is not a strong encapsulation since a direct require of any +absolute subpath of the package such as +`require('/path/to/node_modules/pkg/subpath.js')` will still load `subpath.js`. + +### Subpath exports + +> Stability: 1 - Experimental + +When using the `"exports"` field, custom subpaths can be defined along +with the main entry point by treating the main entry point as the +`"."` subpath: + +```json +{ + "main": "./main.js", + "exports": { + ".": "./main.js", + "./submodule": "./src/submodule.js" + } +} +``` + +Now only the defined subpath in `"exports"` can be imported by a +consumer: + +```js +import submodule from 'es-module-package/submodule'; +// Loads ./node_modules/es-module-package/src/submodule.js +``` + +While other subpaths will error: + +```js +import submodule from 'es-module-package/private-module.js'; +// Throws ERR_PACKAGE_PATH_NOT_EXPORTED +``` + +Entire folders can also be mapped with package exports: + +```json +// ./node_modules/es-module-package/package.json +{ + "exports": { + "./features/": "./src/features/" + } +} +``` + +With the preceding, all modules within the `./src/features/` folder +are exposed deeply to `import` and `require`: + +```js +import feature from 'es-module-package/features/x.js'; +// Loads ./node_modules/es-module-package/src/features/x.js +``` + +When using folder mappings, ensure that you do want to expose every +module inside the subfolder. Any modules which are not public +should be moved to another folder to retain the encapsulation +benefits of exports. + +### Package exports fallbacks + +> Stability: 1 - Experimental + +For possible new specifier support in future, array fallbacks are +supported for all invalid specifiers: + +```json +{ + "exports": { + "./submodule": ["not:valid", "./submodule.js"] + } +} +``` + +Since `"not:valid"` is not a valid specifier, `"./submodule.js"` is used +instead as the fallback, as if it were the only target. + +### Exports sugar + +> Stability: 1 - Experimental + +If the `"."` export is the only export, the `"exports"` field provides sugar +for this case being the direct `"exports"` field value. + +If the `"."` export has a fallback array or string value, then the `"exports"` +field can be set to this value directly. + +```json +{ + "exports": { + ".": "./main.js" + } +} +``` + +can be written: + +```json +{ + "exports": "./main.js" +} +``` + +### Conditional exports + +> Stability: 1 - Experimental + +Conditional exports provide a way to map to different paths depending on +certain conditions. They are supported for both CommonJS and ES module imports. + +For example, a package that wants to provide different ES module exports for +`require()` and `import` can be written: + +```json +// package.json +{ + "main": "./main-require.cjs", + "exports": { + "import": "./main-module.js", + "require": "./main-require.cjs" + }, + "type": "module" +} +``` + +Node.js supports the following conditions out of the box: + +* `"import"` - matched when the package is loaded via `import` or + `import()`. Can reference either an ES module or CommonJS file, as both + `import` and `import()` can load either ES module or CommonJS sources. + _Always matched when the `"require"` condition is not matched._ +* `"require"` - matched when the package is loaded via `require()`. + As `require()` only supports CommonJS, the referenced file must be CommonJS. + _Always matched when the `"import"` condition is not matched._ +* `"node"` - matched for any Node.js environment. Can be a CommonJS or ES + module file. _This condition should always come after `"import"` or + `"require"`._ +* `"default"` - the generic fallback that will always match. Can be a CommonJS + or ES module file. _This condition should always come last._ + +Within the `"exports"` object, key order is significant. During condition +matching, earlier entries have higher priority and take precedence over later +entries. _The general rule is that conditions should be from most specific to +least specific in object order_. + +Other conditions such as `"browser"`, `"electron"`, `"deno"`, `"react-native"`, +etc. are unknown to, and thus ignored by Node.js. Runtimes or tools other than +Node.js may use them at their discretion. Further restrictions, definitions, or +guidance on condition names may occur in the future. + +Using the `"import"` and `"require"` conditions can lead to some hazards, +which are further explained in [the dual CommonJS/ES module packages section][]. + +Conditional exports can also be extended to exports subpaths, for example: + +```json +{ + "main": "./main.js", + "exports": { + ".": "./main.js", + "./feature": { + "node": "./feature-node.js", + "default": "./feature.js" + } + } +} +``` + +Defines a package where `require('pkg/feature')` and `import 'pkg/feature'` +could provide different implementations between Node.js and other JS +environments. + +When using environment branches, always include a `"default"` condition where +possible. Providing a `"default"` condition ensures that any unknown JS +environments are able to use this universal implementation, which helps avoid +these JS environments from having to pretend to be existing environments in +order to support packages with conditional exports. For this reason, using +`"node"` and `"default"` condition branches is usually preferable to using +`"node"` and `"browser"` condition branches. + +### Nested conditions + +> Stability: 1 - Experimental + +In addition to direct mappings, Node.js also supports nested condition objects. + +For example, to define a package that only has dual mode entry points for +use in Node.js but not the browser: + +```json +{ + "main": "./main.js", + "exports": { + "node": { + "import": "./feature-node.mjs", + "require": "./feature-node.cjs" + }, + "default": "./feature.mjs", + } +} +``` + +Conditions continue to be matched in order as with flat conditions. If +a nested conditional does not have any mapping it will continue checking +the remaining conditions of the parent condition. In this way nested +conditions behave analogously to nested JavaScript `if` statements. + +### Resolving user conditions + +When running Node.js, custom user conditions can be added with the +`--conditions` flag: + +```bash +node --conditions=development main.js +``` + +which would then resolve the `"development"` condition in package imports and +exports, while resolving the existing `"node"`, `"default"`, `"import"`, and +`"require"` conditions as appropriate. + +Any number of custom conditions can be set with repeat flags. + +### Self-referencing a package using its name + +Within a package, the values defined in the package’s +`package.json` `"exports"` field can be referenced via the package’s name. +For example, assuming the `package.json` is: + +```json +// package.json +{ + "name": "a-package", + "exports": { + ".": "./main.mjs", + "./foo": "./foo.js" + } +} +``` + +Then any module _in that package_ can reference an export in the package itself: + +```js +// ./a-module.mjs +import { something } from 'a-package'; // Imports "something" from ./main.mjs. +``` + +Self-referencing is available only if `package.json` has `exports`, and will +allow importing only what that `exports` (in the `package.json`) allows. +So the code below, given the previous package, will generate a runtime error: + +```js +// ./another-module.mjs + +// Imports "another" from ./m.mjs. Fails because +// the "package.json" "exports" field +// does not provide an export named "./m.mjs". +import { another } from 'a-package/m.mjs'; +``` + +Self-referencing is also available when using `require`, both in an ES module, +and in a CommonJS one. For example, this code will also work: + +```js +// ./a-module.js +const { something } = require('a-package/foo'); // Loads from ./foo.js. +``` + +## Internal package imports + +> Stability: 1 - Experimental + +In addition to the `"exports"` field it is possible to define internal package +import maps that only apply to import specifiers from within the package itself. + +Entries in the imports field must always start with `#` to ensure they are +clearly disambiguated from package specifiers. + +For example, the imports field can be used to gain the benefits of conditional +exports for internal modules: + +```json +// package.json +{ + "imports": { + "#dep": { + "node": "dep-node-native", + "default": "./dep-polyfill.js" + } + }, + "dependencies": { + "dep-node-native": "^1.0.0" + } +} +``` + +where `import '#dep'` would now get the resolution of the external package +`dep-node-native` (including its exports in turn), and instead get the local +file `./dep-polyfill.js` relative to the package in other environments. + +Unlike the exports field, import maps permit mapping to external packages +because this provides an important use case for conditional loading and also can +be done without the risk of cycles, unlike for exports. + +Apart from the above, the resolution rules for the imports field are otherwise +analogous to the exports field. + +## Dual CommonJS/ES module packages + +Prior to the introduction of support for ES modules in Node.js, it was a common +pattern for package authors to include both CommonJS and ES module JavaScript +sources in their package, with `package.json` `"main"` specifying the CommonJS +entry point and `package.json` `"module"` specifying the ES module entry point. +This enabled Node.js to run the CommonJS entry point while build tools such as +bundlers used the ES module entry point, since Node.js ignored (and still +ignores) the top-level `"module"` field. + +Node.js can now run ES module entry points, and a package can contain both +CommonJS and ES module entry points (either via separate specifiers such as +`'pkg'` and `'pkg/es-module'`, or both at the same specifier via [Conditional +exports][]). Unlike in the scenario where `"module"` is only used by bundlers, +or ES module files are transpiled into CommonJS on the fly before evaluation by +Node.js, the files referenced by the ES module entry point are evaluated as ES +modules. + +### Dual package hazard + +When an application is using a package that provides both CommonJS and ES module +sources, there is a risk of certain bugs if both versions of the package get +loaded. This potential comes from the fact that the `pkgInstance` created by +`const pkgInstance = require('pkg')` is not the same as the `pkgInstance` +created by `import pkgInstance from 'pkg'` (or an alternative main path like +`'pkg/module'`). This is the “dual package hazard,” where two versions of the +same package can be loaded within the same runtime environment. While it is +unlikely that an application or package would intentionally load both versions +directly, it is common for an application to load one version while a dependency +of the application loads the other version. This hazard can happen because +Node.js supports intermixing CommonJS and ES modules, and can lead to unexpected +behavior. + +If the package main export is a constructor, an `instanceof` comparison of +instances created by the two versions returns `false`, and if the export is an +object, properties added to one (like `pkgInstance.foo = 3`) are not present on +the other. This differs from how `import` and `require` statements work in +all-CommonJS or all-ES module environments, respectively, and therefore is +surprising to users. It also differs from the behavior users are familiar with +when using transpilation via tools like [Babel][] or [`esm`][]. + +### Writing dual packages while avoiding or minimizing hazards + +First, the hazard described in the previous section occurs when a package +contains both CommonJS and ES module sources and both sources are provided for +use in Node.js, either via separate main entry points or exported paths. A +package could instead be written where any version of Node.js receives only +CommonJS sources, and any separate ES module sources the package may contain +could be intended only for other environments such as browsers. Such a package +would be usable by any version of Node.js, since `import` can refer to CommonJS +files; but it would not provide any of the advantages of using ES module syntax. + +A package could also switch from CommonJS to ES module syntax in a breaking +change version bump. This has the disadvantage that the newest version +of the package would only be usable in ES module-supporting versions of Node.js. + +Every pattern has tradeoffs, but there are two broad approaches that satisfy the +following conditions: + +1. The package is usable via both `require` and `import`. +1. The package is usable in both current Node.js and older versions of Node.js + that lack support for ES modules. +1. The package main entry point, e.g. `'pkg'` can be used by both `require` to + resolve to a CommonJS file and by `import` to resolve to an ES module file. + (And likewise for exported paths, e.g. `'pkg/feature'`.) +1. The package provides named exports, e.g. `import { name } from 'pkg'` rather + than `import pkg from 'pkg'; pkg.name`. +1. The package is potentially usable in other ES module environments such as + browsers. +1. The hazards described in the previous section are avoided or minimized. + +#### Approach #1: Use an ES module wrapper + +Write the package in CommonJS or transpile ES module sources into CommonJS, and +create an ES module wrapper file that defines the named exports. Using +[Conditional exports][], the ES module wrapper is used for `import` and the +CommonJS entry point for `require`. + +```json +// ./node_modules/pkg/package.json +{ + "type": "module", + "main": "./index.cjs", + "exports": { + "import": "./wrapper.mjs", + "require": "./index.cjs" + } +} +``` + +The preceding example uses explicit extensions `.mjs` and `.cjs`. +If your files use the `.js` extension, `"type": "module"` will cause such files +to be treated as ES modules, just as `"type": "commonjs"` would cause them +to be treated as CommonJS. +See [Enabling](#esm_enabling). + +```js +// ./node_modules/pkg/index.cjs +exports.name = 'value'; +``` + +```js +// ./node_modules/pkg/wrapper.mjs +import cjsModule from './index.cjs'; +export const name = cjsModule.name; +``` + +In this example, the `name` from `import { name } from 'pkg'` is the same +singleton as the `name` from `const { name } = require('pkg')`. Therefore `===` +returns `true` when comparing the two `name`s and the divergent specifier hazard +is avoided. + +If the module is not simply a list of named exports, but rather contains a +unique function or object export like `module.exports = function () { ... }`, +or if support in the wrapper for the `import pkg from 'pkg'` pattern is desired, +then the wrapper would instead be written to export the default optionally +along with any named exports as well: + +```js +import cjsModule from './index.cjs'; +export const name = cjsModule.name; +export default cjsModule; +``` + +This approach is appropriate for any of the following use cases: +* The package is currently written in CommonJS and the author would prefer not + to refactor it into ES module syntax, but wishes to provide named exports for + ES module consumers. +* The package has other packages that depend on it, and the end user might + install both this package and those other packages. For example a `utilities` + package is used directly in an application, and a `utilities-plus` package + adds a few more functions to `utilities`. Because the wrapper exports + underlying CommonJS files, it doesn’t matter if `utilities-plus` is written in + CommonJS or ES module syntax; it will work either way. +* The package stores internal state, and the package author would prefer not to + refactor the package to isolate its state management. See the next section. + +A variant of this approach not requiring conditional exports for consumers could +be to add an export, e.g. `"./module"`, to point to an all-ES module-syntax +version of the package. This could be used via `import 'pkg/module'` by users +who are certain that the CommonJS version will not be loaded anywhere in the +application, such as by dependencies; or if the CommonJS version can be loaded +but doesn’t affect the ES module version (for example, because the package is +stateless): + +```json +// ./node_modules/pkg/package.json +{ + "type": "module", + "main": "./index.cjs", + "exports": { + ".": "./index.cjs", + "./module": "./wrapper.mjs" + } +} +``` + +#### Approach #2: Isolate state + +A `package.json` file can define the separate CommonJS and ES module entry +points directly: + +```json +// ./node_modules/pkg/package.json +{ + "type": "module", + "main": "./index.cjs", + "exports": { + "import": "./index.mjs", + "require": "./index.cjs" + } +} +``` + +This can be done if both the CommonJS and ES module versions of the package are +equivalent, for example because one is the transpiled output of the other; and +the package’s management of state is carefully isolated (or the package is +stateless). + +The reason that state is an issue is because both the CommonJS and ES module +versions of the package may get used within an application; for example, the +user’s application code could `import` the ES module version while a dependency +`require`s the CommonJS version. If that were to occur, two copies of the +package would be loaded in memory and therefore two separate states would be +present. This would likely cause hard-to-troubleshoot bugs. + +Aside from writing a stateless package (if JavaScript’s `Math` were a package, +for example, it would be stateless as all of its methods are static), there are +some ways to isolate state so that it’s shared between the potentially loaded +CommonJS and ES module instances of the package: + +1. If possible, contain all state within an instantiated object. JavaScript’s + `Date`, for example, needs to be instantiated to contain state; if it were a + package, it would be used like this: + + ```js + import Date from 'date'; + const someDate = new Date(); + // someDate contains state; Date does not + ``` + + The `new` keyword isn’t required; a package’s function can return a new + object, or modify a passed-in object, to keep the state external to the + package. + +1. Isolate the state in one or more CommonJS files that are shared between the + CommonJS and ES module versions of the package. For example, if the CommonJS + and ES module entry points are `index.cjs` and `index.mjs`, respectively: + + ```js + // ./node_modules/pkg/index.cjs + const state = require('./state.cjs'); + module.exports.state = state; + ``` + + ```js + // ./node_modules/pkg/index.mjs + import state from './state.cjs'; + export { + state + }; + ``` + + Even if `pkg` is used via both `require` and `import` in an application (for + example, via `import` in application code and via `require` by a dependency) + each reference of `pkg` will contain the same state; and modifying that + state from either module system will apply to both. + +Any plugins that attach to the package’s singleton would need to separately +attach to both the CommonJS and ES module singletons. + +This approach is appropriate for any of the following use cases: +* The package is currently written in ES module syntax and the package author + wants that version to be used wherever such syntax is supported. +* The package is stateless or its state can be isolated without too much + difficulty. +* The package is unlikely to have other public packages that depend on it, or if + it does, the package is stateless or has state that need not be shared between + dependencies or with the overall application. + +Even with isolated state, there is still the cost of possible extra code +execution between the CommonJS and ES module versions of a package. + +As with the previous approach, a variant of this approach not requiring +conditional exports for consumers could be to add an export, e.g. +`"./module"`, to point to an all-ES module-syntax version of the package: + +```json +// ./node_modules/pkg/package.json +{ + "type": "module", + "main": "./index.cjs", + "exports": { + ".": "./index.cjs", + "./module": "./index.mjs" + } +} +``` + +[Conditional exports]: #packages_conditional_exports +[Babel]: https://babeljs.io/ +[`esm`]: https://github.com/standard-things/esm#readme +[the full specifier path]: modules_esm.html#modules_esm_mandatory_file_extensions +[the dual CommonJS/ES module packages section]: #packages_dual_commonjs_es_module_packages +[ES modules]: esm.html +[CommonJS]: modules.html From ab7d0e92b1ea2180789d83e31b7ce23edf188af1 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Wed, 26 Aug 2020 13:37:20 +0200 Subject: [PATCH 13/42] meta: update module pages in CODEOWNERS PR-URL: https://github.com/nodejs/node/pull/34932 Reviewed-By: Mary Marchini Reviewed-By: Richard Lau Reviewed-By: Derek Lewis Reviewed-By: Myles Borins --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 8be627067e3a87..f492eb65e683e6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -77,6 +77,8 @@ /doc/api/modules.md @nodejs/modules /doc/api/esm.md @nodejs/modules +/doc/api/module.md @nodejs/modules +/doc/api/packages.md @nodejs/modules /lib/module.js @nodejs/modules /lib/internal/modules/* @nodejs/modules /lib/internal/bootstrap/loaders.js @nodejs/modules From 1d1ce1fc2cff5935644b0c019cdefdfbea34f046 Mon Sep 17 00:00:00 2001 From: Antoine du HAMEL Date: Fri, 7 Aug 2020 13:12:25 +0200 Subject: [PATCH 14/42] doc: document support for package.json fields Fixes: https://github.com/nodejs/node/issues/33143 PR-URL: https://github.com/nodejs/node/pull/34970 Reviewed-By: Guy Bedford Reviewed-By: Geoffrey Booth Reviewed-By: Trivikram Kamat --- doc/api/errors.md | 17 +- doc/api/esm.md | 11 +- doc/api/modules.md | 12 +- doc/api/packages.md | 384 ++++++++++++++++++++++++++++++-------------- 4 files changed, 282 insertions(+), 142 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 20394fc5b53483..d58893fd7c6205 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -1391,13 +1391,13 @@ An invalid or unknown file encoding was passed. ### `ERR_INVALID_PACKAGE_CONFIG` -An invalid `package.json` file failed parsing. +An invalid [`package.json`][] file was found which failed parsing. ### `ERR_INVALID_PACKAGE_TARGET` -The `package.json` [exports][] field contains an invalid target mapping value -for the attempted module resolution. +The `package.json` [`"exports"`][] field contains an invalid target mapping +value for the attempted module resolution. ### `ERR_INVALID_PERFORMANCE_MARK` @@ -1712,13 +1712,13 @@ A given value is out of the accepted range. ### `ERR_PACKAGE_IMPORT_NOT_DEFINED` -The `package.json` ["imports" field][] does not define the given internal +The `package.json` [`"imports"`][] field does not define the given internal package specifier mapping. ### `ERR_PACKAGE_PATH_NOT_EXPORTED` -The `package.json` [exports][] field does not export the requested subpath. +The `package.json` [`"exports"`][] field does not export the requested subpath. Because exports are encapsulated, private internal modules that are not exported cannot be imported through the package resolution, unless using an absolute URL. @@ -2074,7 +2074,7 @@ signal (such as [`subprocess.kill()`][]). `import` a directory URL is unsupported. Instead, [self-reference a package using its name][] and [define a custom subpath][] in -the `"exports"` field of the `package.json` file. +the [`"exports"`][] field of the [`package.json`][] file. ```js @@ -2560,7 +2560,8 @@ closed. [crypto digest algorithm]: crypto.html#crypto_crypto_gethashes [domains]: domain.html [event emitter-based]: events.html#events_class_eventemitter -[exports]: packages.html#packages_package_entry_points +[`package.json`]: packages.html#packages_node_js_package_json_field_definitions +[`"exports"`]: packages.html#packages_exports [file descriptors]: https://en.wikipedia.org/wiki/File_descriptor [policy]: policy.html [stream-based]: stream.html @@ -2570,4 +2571,4 @@ closed. [vm]: vm.html [self-reference a package using its name]: packages.html#packages_self_referencing_a_package_using_its_name [define a custom subpath]: packages.html#packages_subpath_exports -["imports" field]: packages.html#packages_internal_package_imports +[`"imports"`]: packages.html#packages_imports diff --git a/doc/api/esm.md b/doc/api/esm.md index 160a6633d7d362..9a4d65d25f71b4 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -55,7 +55,7 @@ specifier resolution, and default behavior. Node.js treats JavaScript code as CommonJS modules by default. Authors can tell Node.js to treat JavaScript code as ECMAScript modules -via the `.mjs` file extension, the `package.json` `"type"` field, or the +via the `.mjs` file extension, the `package.json` [`"type"`][] field, or the `--input-type` flag. See [Modules: Packages](packages.html#packages_determining_module_system) for more details. @@ -253,9 +253,9 @@ can either be an URL-style relative path like `'./file.mjs'` or a package name like `'fs'`. Like in CommonJS, files within packages can be accessed by appending a path to -the package name; unless the package’s `package.json` contains an `"exports"` -field, in which case files within packages need to be accessed via the path -defined in `"exports"`. +the package name; unless the package’s [`package.json`][] contains an +[`"exports"`][] field, in which case files within packages need to be accessed +via the path defined in [`"exports"`][]. ```js import { sin, cos } from 'geometry/trigonometry-functions.mjs'; @@ -1159,3 +1159,6 @@ success! [6.1.7 Array Index]: https://tc39.es/ecma262/#integer-index [Top-Level Await]: https://github.com/tc39/proposal-top-level-await [Core modules]: modules.html#modules_core_modules +[`package.json`]: packages.html#packages_node_js_package_json_field_definitions +[`"exports"`]: packages.html#packages_exports +[`"type"`]: packages.html#packages_type diff --git a/doc/api/modules.md b/doc/api/modules.md index e287a5846826d2..4e7b3da3408827 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -390,8 +390,8 @@ directories, and then provide a single entry point to those directories. There are three ways in which a folder may be passed to `require()` as an argument. -The first is to create a `package.json` file in the root of the folder, -which specifies a `main` module. An example `package.json` file might +The first is to create a [`package.json`][] file in the root of the folder, +which specifies a `main` module. An example [`package.json`][] file might look like this: ```json @@ -405,10 +405,10 @@ If this was in a folder at `./some-library`, then This is the extent of the awareness of `package.json` files within Node.js. -If there is no `package.json` file present in the directory, or if the -`'main'` entry is missing or cannot be resolved, then Node.js +If there is no [`package.json`][] file present in the directory, or if the +[`"main"`][] entry is missing or cannot be resolved, then Node.js will attempt to load an `index.js` or `index.node` file out of that -directory. For example, if there was no `package.json` file in the above +directory. For example, if there was no [`package.json`][] file in the previous example, then `require('./some-library')` would attempt to load: * `./some-library/index.js` @@ -986,3 +986,5 @@ This section was moved to [module resolution]: #modules_all_together [native addons]: addons.html [`require.main`]: #modules_require_main +[`package.json`]: packages.html#packages_node_js_package_json_field_definitions +[`"main"`]: packages.html#packages_main diff --git a/doc/api/packages.md b/doc/api/packages.md index c8fbf6c213bb83..7adcb36711791e 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -18,7 +18,7 @@ initial input, or when referenced by `import` statements within ES module code: * Files ending in `.mjs`. * Files ending in `.js` when the nearest parent `package.json` file contains a - top-level field `"type"` with a value of `"module"`. + top-level field [`"type"`][] with a value of `"module"`. * Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`, with the flag `--input-type=module`. @@ -34,63 +34,29 @@ or when referenced by `import` statements within ES module code: * Files ending in `.cjs`. * Files ending in `.js` when the nearest parent `package.json` file contains a - top-level field `"type"` with a value of `"commonjs"`. + top-level field [`"type"`][] with a value of `"commonjs"`. * Strings passed in as an argument to `--eval` or `--print`, or piped to `node` via `STDIN`, with the flag `--input-type=commonjs`. -### `package.json` `"type"` field - -Files ending with `.js` will be loaded as [ES modules][] when the nearest parent -`package.json` file contains a top-level field `"type"` with a value of -`"module"`. - -The nearest parent `package.json` is defined as the first `package.json` found -when searching in the current folder, that folder’s parent, and so on up -until the root of the volume is reached. - - -```js -// package.json -{ - "type": "module" -} -``` - -```bash -# In same folder as preceding package.json -node my-app.js # Runs as ES module -``` - -If the nearest parent `package.json` lacks a `"type"` field, or contains -`"type": "commonjs"`, `.js` files are treated as [CommonJS][]. If the volume -root is reached and no `package.json` is found, Node.js defers to the default, a -`package.json` with no `"type"` field. - -`import` statements of `.js` files are treated as ES modules if the nearest -parent `package.json` contains `"type": "module"`. - -```js -// my-app.js, part of the same example as above -import './startup.js'; // Loaded as ES module because of package.json -``` - -Package authors should include the `"type"` field, even in packages where all -sources are [CommonJS][]. Being explicit about the `type` of the package will +Package authors should include the [`"type"`][] field, even in packages where +all sources are CommonJS. Being explicit about the `type` of the package will future-proof the package in case the default type of Node.js ever changes, and it will also make things easier for build tools and loaders to determine how the files in the package should be interpreted. -Regardless of the value of the `"type"` field, `.mjs` files are always treated -as ES modules and `.cjs` files are always treated as [CommonJS][]. - ### Package scope and file extensions A folder containing a `package.json` file, and all subfolders below that folder -until the next folder containing another `package.json`, are a -_package scope_. Package scopes do not carry through `node_modules` folders. The -`"type"` field defines how to treat `.js` files within the package scope. If a -`package.json` file does not have a `"type"` field, the default is `"commonjs"`. +until the next folder containing another [`package.json`][], are a +_package scope_. Package scopes do not carry through `node_modules` folders. + +Within a package scope, the [`package.json`][] [`"type"`][] field defines how +Node.js should interpret `.js` files. If a `package.json` file does not have a +`"type"` field, `.js` files are treated as [CommonJS][]. + +A `package.json` `"type"` value of `"module"` tells Node.js to interpret `.js` +files within that package scope as using [ES module][] syntax. The package scope applies not only to initial entry points (`node my-app.js`) but also to files referenced by `import` statements and `import()` expressions. @@ -135,7 +101,7 @@ package scope: a `"module"` package scope). * Within a `"type": "commonjs"` package scope, Node.js can be instructed to - interpret a particular file as an ES module by naming it with an `.mjs` + interpret a particular file as an [ES module][] by naming it with an `.mjs` extension (since both `.js` and `.cjs` files are treated as CommonJS within a `"commonjs"` package scope). @@ -158,35 +124,35 @@ unspecified. ## Package entry points In a package’s `package.json` file, two fields can define entry points for a -package: `"main"` and `"exports"`. The `"main"` field is supported in all -versions of Node.js, but its capabilities are limited: it only defines the main -entry point of the package. +package: [`"main"`][] and [`"exports"`][]. The [`"main"`][] field is supported +in all versions of Node.js, but its capabilities are limited: it only defines +the main entry point of the package. -The `"exports"` field provides an alternative to `"main"` where the package -main entry point can be defined while also encapsulating the package, -**preventing any other entry points besides those defined in `"exports"`**. +The [`"exports"`][] field provides an alternative to [`"main"`][] where the +package main entry point can be defined while also encapsulating the package, +**preventing any other entry points besides those defined in [`"exports"`][]**. This encapsulation allows module authors to define a public interface for their package. -If both `"exports"` and `"main"` are defined, the `"exports"` field takes -precedence over `"main"`. `"exports"` are not specific to ES modules or -CommonJS; `"main"` will be overridden by `"exports"` if it exists. As such -`"main"` cannot be used as a fallback for CommonJS but it can be used as a -fallback for legacy versions of Node.js that do not support the `"exports"` -field. +If both [`"exports"`][] and [`"main"`][] are defined, the [`"exports"`][] field +takes precedence over [`"main"`][]. [`"exports"`][] are not specific to ES +modules or CommonJS; [`"main"`][] will be overridden by [`"exports"`][] if it +exists. As such [`"main"`][] cannot be used as a fallback for CommonJS but it +can be used as a fallback for legacy versions of Node.js that do not support the +[`"exports"`][] field. -[Conditional exports][] can be used within `"exports"` to define different +[Conditional exports][] can be used within [`"exports"`][] to define different package entry points per environment, including whether the package is referenced via `require` or via `import`. For more information about supporting both CommonJS and ES Modules in a single package please consult [the dual CommonJS/ES module packages section][]. -**Warning**: Introducing the `"exports"` field prevents consumers of a package -from using any entry points that are not defined, including the `package.json` -(e.g. `require('your-package/package.json')`. **This will likely be a breaking -change.** +**Warning**: Introducing the [`"exports"`][] field prevents consumers of a +package from using any entry points that are not defined, including the +[`package.json`][] (e.g. `require('your-package/package.json')`. **This will +likely be a breaking change.** -To make the introduction of `"exports"` non-breaking, ensure that every +To make the introduction of [`"exports"`][] non-breaking, ensure that every previously supported entry point is exported. It is best to explicitly specify entry points so that the package’s public API is well-defined. For example, a project that previous exported `main`, `lib`, @@ -236,7 +202,7 @@ path `import feature from 'my-mod/feature/index.js`. ### Main entry point export To set the main entry point for a package, it is advisable to define both -`"exports"` and `"main"` in the package’s `package.json` file: +[`"exports"`][] and [`"main"`][] in the package’s [`package.json`][] file: ```json { @@ -245,7 +211,7 @@ To set the main entry point for a package, it is advisable to define both } ``` -The benefit of doing this is that when using the `"exports"` field all +The benefit of doing this is that when using the [`"exports"`][] field all subpaths of the package will no longer be available to importers under `require('pkg/subpath.js')`, and instead they will get a new error, `ERR_PACKAGE_PATH_NOT_EXPORTED`. @@ -260,7 +226,7 @@ absolute subpath of the package such as > Stability: 1 - Experimental -When using the `"exports"` field, custom subpaths can be defined along +When using the [`"exports"`][] field, custom subpaths can be defined along with the main entry point by treating the main entry point as the `"."` subpath: @@ -274,8 +240,7 @@ with the main entry point by treating the main entry point as the } ``` -Now only the defined subpath in `"exports"` can be imported by a -consumer: +Now only the defined subpath in [`"exports"`][] can be imported by a consumer: ```js import submodule from 'es-module-package/submodule'; @@ -335,11 +300,11 @@ instead as the fallback, as if it were the only target. > Stability: 1 - Experimental -If the `"."` export is the only export, the `"exports"` field provides sugar -for this case being the direct `"exports"` field value. +If the `"."` export is the only export, the [`"exports"`][] field provides sugar +for this case being the direct [`"exports"`][] field value. -If the `"."` export has a fallback array or string value, then the `"exports"` -field can be set to this value directly. +If the `"."` export has a fallback array or string value, then the +[`"exports"`][] field can be set to this value directly. ```json { @@ -394,7 +359,7 @@ Node.js supports the following conditions out of the box: * `"default"` - the generic fallback that will always match. Can be a CommonJS or ES module file. _This condition should always come last._ -Within the `"exports"` object, key order is significant. During condition +Within the [`"exports"`][] object, key order is significant. During condition matching, earlier entries have higher priority and take precedence over later entries. _The general rule is that conditions should be from most specific to least specific in object order_. @@ -479,7 +444,7 @@ Any number of custom conditions can be set with repeat flags. ### Self-referencing a package using its name Within a package, the values defined in the package’s -`package.json` `"exports"` field can be referenced via the package’s name. +`package.json` [`"exports"`][] field can be referenced via the package’s name. For example, assuming the `package.json` is: ```json @@ -500,9 +465,10 @@ Then any module _in that package_ can reference an export in the package itself: import { something } from 'a-package'; // Imports "something" from ./main.mjs. ``` -Self-referencing is available only if `package.json` has `exports`, and will -allow importing only what that `exports` (in the `package.json`) allows. -So the code below, given the previous package, will generate a runtime error: +Self-referencing is available only if `package.json` has [`"exports"`][], and +will allow importing only what that [`"exports"`][] (in the `package.json`) +allows. So the code below, given the previous package, will generate a runtime +error: ```js // ./another-module.mjs @@ -521,51 +487,13 @@ and in a CommonJS one. For example, this code will also work: const { something } = require('a-package/foo'); // Loads from ./foo.js. ``` -## Internal package imports - -> Stability: 1 - Experimental - -In addition to the `"exports"` field it is possible to define internal package -import maps that only apply to import specifiers from within the package itself. - -Entries in the imports field must always start with `#` to ensure they are -clearly disambiguated from package specifiers. - -For example, the imports field can be used to gain the benefits of conditional -exports for internal modules: - -```json -// package.json -{ - "imports": { - "#dep": { - "node": "dep-node-native", - "default": "./dep-polyfill.js" - } - }, - "dependencies": { - "dep-node-native": "^1.0.0" - } -} -``` - -where `import '#dep'` would now get the resolution of the external package -`dep-node-native` (including its exports in turn), and instead get the local -file `./dep-polyfill.js` relative to the package in other environments. - -Unlike the exports field, import maps permit mapping to external packages -because this provides an important use case for conditional loading and also can -be done without the risk of cycles, unlike for exports. - -Apart from the above, the resolution rules for the imports field are otherwise -analogous to the exports field. - ## Dual CommonJS/ES module packages Prior to the introduction of support for ES modules in Node.js, it was a common pattern for package authors to include both CommonJS and ES module JavaScript -sources in their package, with `package.json` `"main"` specifying the CommonJS -entry point and `package.json` `"module"` specifying the ES module entry point. +sources in their package, with `package.json` [`"main"`][] specifying the +CommonJS entry point and `package.json` `"module"` specifying the ES module +entry point. This enabled Node.js to run the CommonJS entry point while build tools such as bundlers used the ES module entry point, since Node.js ignored (and still ignores) the top-level `"module"` field. @@ -719,7 +647,7 @@ stateless): #### Approach #2: Isolate state -A `package.json` file can define the separate CommonJS and ES module entry +A [`package.json`][] file can define the separate CommonJS and ES module entry points directly: ```json @@ -819,10 +747,216 @@ conditional exports for consumers could be to add an export, e.g. } ``` -[Conditional exports]: #packages_conditional_exports +## Node.js `package.json` field definitions + +This section describes the fields used by the Node.js runtime. Other tools (such +as [npm](https://docs.npmjs.com/creating-a-package-json-file)) may use +additional fields which are ignored by Node.js and not documented here. + +### `"name"` + + +* Type: {string} + +```json +{ + "name": "package-name" +} +``` + +The `"name"` field defines your package’s name. Publishing to the +_npm_ registry may require a name that satisfies +[certain requirements](https://docs.npmjs.com/files/package.json#name). + +The `"name"` field can be used in addition to the [`"exports"`][] field to +[self-reference][] a package using its name. + +### `"type"` + + +* Type: {string} + +The `"type"` field defines the module format that Node.js will use for all +`.js` files within a particular `package.json` file’s [package scope][]. + +Files ending with `.js` will be loaded as ES modules when the nearest parent +`package.json` file contains a top-level field `"type"` with a value of +`"module"`. + +The nearest parent `package.json` is defined as the first `package.json` found +when searching in the current folder, that folder’s parent, and so on up +until a node_modules folder or the volume root is reached. + +```json +// package.json +{ + "type": "module" +} +``` + +```bash +# In same folder as preceding package.json +node my-app.js # Runs as ES module +``` + +If the nearest parent `package.json` lacks a `"type"` field, or contains +`"type": "commonjs"`, `.js` files are treated as [CommonJS][]. If the volume +root is reached and no `package.json` is found, Node.js defers to the default +treatment as [CommonJS][]. + +`import` statements of `.js` files are treated as ES modules if the nearest +parent `package.json` contains `"type": "module"`. + +```js +// my-app.js, part of the same example as above +import './startup.js'; // Loaded as ES module because of package.json +``` + +Regardless of the value of the `"type"` field, `.mjs` files are always treated +as ES modules and `.cjs` files are always treated as CommonJS. + +### `"exports"` + + +* Type: {Object} | {string} | {string[]} + +```json +{ + "exports": "./index.js" +} +``` + +The `"exports"` field allows defining the [entry points][] of a package when +imported by name loaded either via a `node_modules` lookup or a +[self-reference][] to its own name. It is supported in Node.js 12+ as an +alternative to the [`"main"`][] that can support defining [subpath exports][] +and [conditional exports][] while encapsulating internal unexported modules. + +[Conditional Exports][] can also be used within `"exports"` to define different +package entry points per environment, including whether the package is +referenced via `require` or via `import`. + +All paths defined in the `"exports"` must be relative file URLs starting with +`./`. + +### `"main"` + + +* Type: {string} + +```json +{ + "main": "./main.js" +} +``` + +The `"main"` field defines the script that is used when the [package directory +is loaded via `require()`](modules.html#modules_folders_as_modules). Its value +is interpreted as a path. + +```js +require('./path/to/directory'); // This resolves to ./path/to/directory/main.js. +``` + +When a package has an [`"exports"`][] field, this will take precedence over the +`"main"` field when importing the package by name. + +### `"imports"` + + +> Stability: 1 - Experimental + +* Type: {Object} + +In addition to the [`"exports"`][] field it is possible to define internal +package import maps that only apply to import specifiers from within the package +itself. + +Entries in the imports field must always start with `#` to ensure they are +clearly disambiguated from package specifiers. + +For example, the imports field can be used to gain the benefits of conditional +exports for internal modules: + +```json +// package.json +{ + "imports": { + "#dep": { + "node": "dep-node-native", + "default": "./dep-polyfill.js" + } + }, + "dependencies": { + "dep-node-native": "^1.0.0" + } +} +``` + +where `import '#dep'` would now get the resolution of the external package +`dep-node-native` (including its exports in turn), and instead get the local +file `./dep-polyfill.js` relative to the package in other environments. + +Unlike the exports field, import maps permit mapping to external packages +because this provides an important use case for conditional loading and also can +be done without the risk of cycles, unlike for exports. + +Apart from the above, the resolution rules for the imports field are otherwise +analogous to the exports field. + [Babel]: https://babeljs.io/ +[Conditional exports]: #packages_conditional_exports +[CommonJS]: modules.html +[entry points]: #packages_package_entry_points [`esm`]: https://github.com/standard-things/esm#readme +[ES modules]: esm.html +[ES module]: esm.html +[`"exports"`]: #packages_exports +[`"main"`]: #packages_main +[`package.json`]: #packages_node_js_package_json_field_definitions +[package scope]: #packages_package_scope_and_file_extensions +[self-reference]: #packages_self_referencing_a_package_using_its_name +[subpath exports]: #packages_subpath_exports [the full specifier path]: modules_esm.html#modules_esm_mandatory_file_extensions [the dual CommonJS/ES module packages section]: #packages_dual_commonjs_es_module_packages -[ES modules]: esm.html -[CommonJS]: modules.html +[`"type"`]: #packages_type From 505731871ea07d9df8aadc910a519ae1629c6482 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 11 Aug 2020 18:40:05 -0700 Subject: [PATCH 15/42] module: exports pattern support PR-URL: https://github.com/nodejs/node/pull/34718 Reviewed-By: Jan Krems Reviewed-By: Matteo Collina --- doc/api/esm.md | 49 ++++++++++---- doc/api/packages.md | 43 +++++++++---- lib/internal/modules/esm/resolve.js | 64 +++++++++++++------ test/es-module/test-esm-exports.mjs | 3 + .../es-modules/pkgimports/package.json | 4 +- .../node_modules/pkgexports/package.json | 4 +- 6 files changed, 118 insertions(+), 49 deletions(-) diff --git a/doc/api/esm.md b/doc/api/esm.md index 9a4d65d25f71b4..3f163225f1d316 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -976,7 +976,8 @@ The resolver can throw the following errors: > 1. Set _mainExport_ to _exports_\[_"."_\]. > 1. If _mainExport_ is not **undefined**, then > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( -> _packageURL_, _mainExport_, _""_, **false**, _conditions_). +> _packageURL_, _mainExport_, _""_, **false**, **false**, +> _conditions_). > 1. If _resolved_ is not **null** or **undefined**, then > 1. Return _resolved_. > 1. Otherwise, if _exports_ is an Object and all keys of _exports_ start with @@ -1010,29 +1011,43 @@ _isImports_, _conditions_) > 1. If _matchKey_ is a key of _matchObj_, and does not end in _"*"_, then > 1. Let _target_ be the value of _matchObj_\[_matchKey_\]. > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( -> _packageURL_, _target_, _""_, _isImports_, _conditions_). +> _packageURL_, _target_, _""_, **false**, _isImports_, _conditions_). > 1. Return the object _{ resolved, exact: **true** }_. -> 1. Let _expansionKeys_ be the list of keys of _matchObj_ ending in _"/"_, -> sorted by length descending. +> 1. Let _expansionKeys_ be the list of keys of _matchObj_ ending in _"/"_ +> or _"*"_, sorted by length descending. > 1. For each key _expansionKey_ in _expansionKeys_, do +> 1. If _expansionKey_ ends in _"*"_ and _matchKey_ starts with but is +> not equal to the substring of _expansionKey_ excluding the last _"*"_ +> character, then +> 1. Let _target_ be the value of _matchObj_\[_expansionKey_\]. +> 1. Let _subpath_ be the substring of _matchKey_ starting at the +> index of the length of _expansionKey_ minus one. +> 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( +> _packageURL_, _target_, _subpath_, **true**, _isImports_, +> _conditions_). +> 1. Return the object _{ resolved, exact: **true** }_. > 1. If _matchKey_ starts with _expansionKey_, then > 1. Let _target_ be the value of _matchObj_\[_expansionKey_\]. > 1. Let _subpath_ be the substring of _matchKey_ starting at the > index of the length of _expansionKey_. > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( -> _packageURL_, _target_, _subpath_, _isImports_, _conditions_). +> _packageURL_, _target_, _subpath_, **false**, _isImports_, +> _conditions_). > 1. Return the object _{ resolved, exact: **false** }_. > 1. Return the object _{ resolved: **null**, exact: **true** }_. -**PACKAGE_TARGET_RESOLVE**(_packageURL_, _target_, _subpath_, _internal_, -_conditions_) +**PACKAGE_TARGET_RESOLVE**(_packageURL_, _target_, _subpath_, _pattern_, +_internal_, _conditions_) > 1. If _target_ is a String, then -> 1. If _subpath_ has non-zero length and _target_ does not end with _"/"_, -> throw an _Invalid Module Specifier_ error. +> 1. If _pattern_ is **false**, _subpath_ has non-zero length and _target_ +> does not end with _"/"_, throw an _Invalid Module Specifier_ error. > 1. If _target_ does not start with _"./"_, then > 1. If _internal_ is **true** and _target_ does not start with _"../"_ or > _"/"_ and is not a valid URL, then +> 1. If _pattern_ is **true**, then +> 1. Return **PACKAGE_RESOLVE**(_target_ with every instance of +> _"*"_ replaced by _subpath_, _packageURL_ + _"/"_)_. > 1. Return **PACKAGE_RESOLVE**(_target_ + _subpath_, > _packageURL_ + _"/"_)_. > 1. Otherwise, throw an _Invalid Package Target_ error. @@ -1044,8 +1059,12 @@ _conditions_) > 1. Assert: _resolvedTarget_ is contained in _packageURL_. > 1. If _subpath_ split on _"/"_ or _"\\"_ contains any _"."_, _".."_ or > _"node_modules"_ segments, throw an _Invalid Module Specifier_ error. -> 1. Return the URL resolution of the concatenation of _subpath_ and -> _resolvedTarget_. +> 1. If _pattern_ is **true**, then +> 1. Return the URL resolution of _resolvedTarget_ with every instance of +> _"*"_ replaced with _subpath_. +> 1. Otherwise, +> 1. Return the URL resolution of the concatenation of _subpath_ and +> _resolvedTarget_. > 1. Otherwise, if _target_ is a non-null Object, then > 1. If _exports_ contains any index property keys, as defined in ECMA-262 > [6.1.7 Array Index][], throw an _Invalid Package Configuration_ error. @@ -1054,7 +1073,8 @@ _conditions_) > then > 1. Let _targetValue_ be the value of the _p_ property in _target_. > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( -> _packageURL_, _targetValue_, _subpath_, _internal_, _conditions_). +> _packageURL_, _targetValue_, _subpath_, _pattern_, _internal_, +> _conditions_). > 1. If _resolved_ is equal to **undefined**, continue the loop. > 1. Return _resolved_. > 1. Return **undefined**. @@ -1062,8 +1082,9 @@ _conditions_) > 1. If _target.length is zero, return **null**. > 1. For each item _targetValue_ in _target_, do > 1. Let _resolved_ be the result of **PACKAGE_TARGET_RESOLVE**( -> _packageURL_, _targetValue_, _subpath_, _internal_, _conditions_), -> continuing the loop on any _Invalid Package Target_ error. +> _packageURL_, _targetValue_, _subpath_, _pattern_, _internal_, +> _conditions_), continuing the loop on any _Invalid Package Target_ +> error. > 1. If _resolved_ is **undefined**, continue the loop. > 1. Return _resolved_. > 1. Return or throw the last fallback resolution **null** return or error. diff --git a/doc/api/packages.md b/doc/api/packages.md index 7adcb36711791e..8cf2397279c7eb 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -181,17 +181,17 @@ Alternatively a project could choose to export entire folders: "exports": { ".": "./lib/index.js", "./lib": "./lib/index.js", - "./lib/": "./lib/", + "./lib/*": "./lib/*.js", "./feature": "./feature/index.js", - "./feature/": "./feature/", + "./feature/*": "./feature/*.js", "./package.json": "./package.json" } } ``` As a last resort, package encapsulation can be disabled entirely by creating an -export for the root of the package `"./": "./"`. This will expose every file in -the package at the cost of disabling the encapsulation and potential tooling +export for the root of the package `"./*": "./*"`. This will expose every file +in the package at the cost of disabling the encapsulation and potential tooling benefits this provides. As the ES Module loader in Node.js enforces the use of [the full specifier path][], exporting the root rather than being explicit about entry is less expressive than either of the prior examples. Not only @@ -254,29 +254,46 @@ import submodule from 'es-module-package/private-module.js'; // Throws ERR_PACKAGE_PATH_NOT_EXPORTED ``` -Entire folders can also be mapped with package exports: +### Subpath export patterns + +> Stability: 1 - Experimental + +Explicitly listing each exports subpath entry is recommended for packages with +a small number of exports. But for packages that have very large numbers of +subpaths this can start to cause package.json bloat and maintenance issues. + +For these use cases, subpath export patterns can be used instead: ```json // ./node_modules/es-module-package/package.json { "exports": { - "./features/": "./src/features/" + "./features/*": "./src/features/*.js" } } ``` -With the preceding, all modules within the `./src/features/` folder -are exposed deeply to `import` and `require`: +The left hand matching pattern must always end in `*`. All instances of `*` on +the right hand side will then be replaced with this value, including if it +contains any `/` separators. ```js -import feature from 'es-module-package/features/x.js'; +import featureX from 'es-module-package/features/x'; // Loads ./node_modules/es-module-package/src/features/x.js + +import featureY from 'es-module-package/features/y/y'; +// Loads ./node_modules/es-module-package/src/features/y/y.js ``` -When using folder mappings, ensure that you do want to expose every -module inside the subfolder. Any modules which are not public -should be moved to another folder to retain the encapsulation -benefits of exports. +This is a direct static replacement without any special handling for file +extensions. In the previous example, `pkg/features/x.json` would be resolved to +`./src/features/x.json.js` in the mapping. + +The property of exports being statically enumerable is maintained with exports +patterns since the individual exports for a package can be determined by +treating the right hand side target pattern as a `**` glob against the list of +files within the package. Because `node_modules` paths are forbidden in exports +targets, this expansion is dependent on only the files of the package itself. ### Package exports fallbacks diff --git a/lib/internal/modules/esm/resolve.js b/lib/internal/modules/esm/resolve.js index 7091a55a5c41bf..12a9b14a577ce9 100644 --- a/lib/internal/modules/esm/resolve.js +++ b/lib/internal/modules/esm/resolve.js @@ -312,10 +312,11 @@ function throwInvalidPackageTarget( } const invalidSegmentRegEx = /(^|\\|\/)(\.\.?|node_modules)(\\|\/|$)/; +const patternRegEx = /\*/g; function resolvePackageTargetString( - target, subpath, match, packageJSONUrl, base, internal, conditions) { - if (subpath !== '' && target[target.length - 1] !== '/') + target, subpath, match, packageJSONUrl, base, pattern, internal, conditions) { + if (subpath !== '' && !pattern && target[target.length - 1] !== '/') throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); if (!StringPrototypeStartsWith(target, './')) { @@ -326,8 +327,12 @@ function resolvePackageTargetString( new URL(target); isURL = true; } catch {} - if (!isURL) - return packageResolve(target + subpath, packageJSONUrl, conditions); + if (!isURL) { + const exportTarget = pattern ? + StringPrototypeReplace(target, patternRegEx, subpath) : + target + subpath; + return packageResolve(exportTarget, packageJSONUrl, conditions); + } } throwInvalidPackageTarget(match, target, packageJSONUrl, internal, base); } @@ -347,6 +352,9 @@ function resolvePackageTargetString( if (RegExpPrototypeTest(invalidSegmentRegEx, subpath)) throwInvalidSubpath(match + subpath, packageJSONUrl, internal, base); + if (pattern) + return new URL(StringPrototypeReplace(resolved.href, patternRegEx, + subpath)); return new URL(subpath, resolved); } @@ -361,10 +369,10 @@ function isArrayIndex(key) { } function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, - base, internal, conditions) { + base, pattern, internal, conditions) { if (typeof target === 'string') { return resolvePackageTargetString( - target, subpath, packageSubpath, packageJSONUrl, base, internal, + target, subpath, packageSubpath, packageJSONUrl, base, pattern, internal, conditions); } else if (ArrayIsArray(target)) { if (target.length === 0) @@ -376,8 +384,8 @@ function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, let resolved; try { resolved = resolvePackageTarget( - packageJSONUrl, targetItem, subpath, packageSubpath, base, internal, - conditions); + packageJSONUrl, targetItem, subpath, packageSubpath, base, pattern, + internal, conditions); } catch (e) { lastException = e; if (e.code === 'ERR_INVALID_PACKAGE_TARGET') @@ -411,7 +419,7 @@ function resolvePackageTarget(packageJSONUrl, target, subpath, packageSubpath, const conditionalTarget = target[key]; const resolved = resolvePackageTarget( packageJSONUrl, conditionalTarget, subpath, packageSubpath, base, - internal, conditions); + pattern, internal, conditions); if (resolved === undefined) continue; return resolved; @@ -465,7 +473,7 @@ function packageExportsResolve( if (ObjectPrototypeHasOwnProperty(exports, packageSubpath)) { const target = exports[packageSubpath]; const resolved = resolvePackageTarget( - packageJSONUrl, target, '', packageSubpath, base, false, conditions + packageJSONUrl, target, '', packageSubpath, base, false, false, conditions ); if (resolved === null || resolved === undefined) throwExportsNotFound(packageSubpath, packageJSONUrl, base); @@ -476,7 +484,13 @@ function packageExportsResolve( const keys = ObjectGetOwnPropertyNames(exports); for (let i = 0; i < keys.length; i++) { const key = keys[i]; - if (key[key.length - 1] === '/' && + if (key[key.length - 1] === '*' && + StringPrototypeStartsWith(packageSubpath, + StringPrototypeSlice(key, 0, -1)) && + packageSubpath.length >= key.length && + key.length > bestMatch.length) { + bestMatch = key; + } else if (key[key.length - 1] === '/' && StringPrototypeStartsWith(packageSubpath, key) && key.length > bestMatch.length) { bestMatch = key; @@ -485,12 +499,15 @@ function packageExportsResolve( if (bestMatch) { const target = exports[bestMatch]; - const subpath = StringPrototypeSubstr(packageSubpath, bestMatch.length); + const pattern = bestMatch[bestMatch.length - 1] === '*'; + const subpath = StringPrototypeSubstr(packageSubpath, bestMatch.length - + (pattern ? 1 : 0)); const resolved = resolvePackageTarget(packageJSONUrl, target, subpath, - bestMatch, base, false, conditions); + bestMatch, base, pattern, false, + conditions); if (resolved === null || resolved === undefined) throwExportsNotFound(packageSubpath, packageJSONUrl, base); - return { resolved, exact: false }; + return { resolved, exact: pattern }; } throwExportsNotFound(packageSubpath, packageJSONUrl, base); @@ -509,7 +526,7 @@ function packageImportsResolve(name, base, conditions) { if (imports) { if (ObjectPrototypeHasOwnProperty(imports, name)) { const resolved = resolvePackageTarget( - packageJSONUrl, imports[name], '', name, base, true, conditions + packageJSONUrl, imports[name], '', name, base, false, true, conditions ); if (resolved !== null) return { resolved, exact: true }; @@ -518,7 +535,13 @@ function packageImportsResolve(name, base, conditions) { const keys = ObjectGetOwnPropertyNames(imports); for (let i = 0; i < keys.length; i++) { const key = keys[i]; - if (key[key.length - 1] === '/' && + if (key[key.length - 1] === '*' && + StringPrototypeStartsWith(name, + StringPrototypeSlice(key, 0, -1)) && + name.length >= key.length && + key.length > bestMatch.length) { + bestMatch = key; + } else if (key[key.length - 1] === '/' && StringPrototypeStartsWith(name, key) && key.length > bestMatch.length) { bestMatch = key; @@ -527,11 +550,14 @@ function packageImportsResolve(name, base, conditions) { if (bestMatch) { const target = imports[bestMatch]; - const subpath = StringPrototypeSubstr(name, bestMatch.length); + const pattern = bestMatch[bestMatch.length - 1] === '*'; + const subpath = StringPrototypeSubstr(name, bestMatch.length - + (pattern ? 1 : 0)); const resolved = resolvePackageTarget( - packageJSONUrl, target, subpath, bestMatch, base, true, conditions); + packageJSONUrl, target, subpath, bestMatch, base, pattern, true, + conditions); if (resolved !== null) - return { resolved, exact: false }; + return { resolved, exact: pattern }; } } } diff --git a/test/es-module/test-esm-exports.mjs b/test/es-module/test-esm-exports.mjs index a4cced41f897b0..d234099732e3aa 100644 --- a/test/es-module/test-esm-exports.mjs +++ b/test/es-module/test-esm-exports.mjs @@ -33,6 +33,9 @@ import fromInside from '../fixtures/node_modules/pkgexports/lib/hole.js'; { default: 'self-cjs' } : { default: 'self-mjs' }], // Resolve self sugar ['pkgexports-sugar', { default: 'main' }], + // Path patterns + ['pkgexports/subpath/sub-dir1', { default: 'main' }], + ['pkgexports/features/dir1', { default: 'main' }] ]); if (isRequire) { diff --git a/test/fixtures/es-modules/pkgimports/package.json b/test/fixtures/es-modules/pkgimports/package.json index 7cd179631fa618..a2224b39ddd2ac 100644 --- a/test/fixtures/es-modules/pkgimports/package.json +++ b/test/fixtures/es-modules/pkgimports/package.json @@ -5,9 +5,9 @@ "import": "./importbranch.js", "require": "./requirebranch.js" }, - "#subpath/": "./sub/", + "#subpath/*": "./sub/*", "#external": "pkgexports/valid-cjs", - "#external/subpath/": "pkgexports/sub/", + "#external/subpath/*": "pkgexports/sub/*", "#external/invalidsubpath/": "pkgexports/sub", "#belowbase": "../belowbase", "#url": "some:url", diff --git a/test/fixtures/node_modules/pkgexports/package.json b/test/fixtures/node_modules/pkgexports/package.json index 71406a407c453d..240122d4aaec95 100644 --- a/test/fixtures/node_modules/pkgexports/package.json +++ b/test/fixtures/node_modules/pkgexports/package.json @@ -47,6 +47,8 @@ "require": "./resolve-self-invalid.js", "import": "./resolve-self-invalid.mjs" }, - "./subpath/": "./subpath/" + "./subpath/": "./subpath/", + "./subpath/sub-*": "./subpath/dir1/*.js", + "./features/*": "./subpath/*/*.js" } } From d7282c0ae34f42dd2e6be4b230fba6433a7a0756 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 18 Sep 2020 02:48:37 -0700 Subject: [PATCH 16/42] doc: edit subpath export patterns introduction * Use parallel construction in the two sentences * Backticks around _package.json_ to match rest of file * Add comma for readability * Own the recommendation ("we recommend") PR-URL: https://github.com/nodejs/node/pull/35254 Reviewed-By: Jan Krems Reviewed-By: Michael Dawson Reviewed-By: Guy Bedford --- doc/api/packages.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/packages.md b/doc/api/packages.md index 8cf2397279c7eb..997ffae76a529b 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -258,9 +258,9 @@ import submodule from 'es-module-package/private-module.js'; > Stability: 1 - Experimental -Explicitly listing each exports subpath entry is recommended for packages with -a small number of exports. But for packages that have very large numbers of -subpaths this can start to cause package.json bloat and maintenance issues. +For packages with a small number of exports, we recommend explicitly listing +each exports subpath entry. But for packages that have large numbers of +subpaths, this might cause `package.json` bloat and maintenance issues. For these use cases, subpath export patterns can be used instead: From dd530364d029f14e908abe1667001ce71f20c65d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Thu, 24 Sep 2020 15:10:30 +0200 Subject: [PATCH 17/42] doc: fixup lutimes metadata MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs: https://github.com/nodejs/node/pull/35320#discussion_r493912423 PR-URL: https://github.com/nodejs/node/pull/35328 Reviewed-By: Richard Lau Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index bafdcc4ef561d9..ece4e5a783b6bd 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2430,7 +2430,7 @@ Synchronous lchown(2). Returns `undefined`. ## `fs.lutimes(path, atime, mtime, callback)` * `path` {string|Buffer|URL} From a8d3a7f742560127831a2fce68940d877cb1372f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 25 Sep 2020 07:51:23 -0700 Subject: [PATCH 18/42] doc: put landing specifics in details tag MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Showing all the steps isn't usually useful and makes it seem like the collaborator is meant to follow the manual steps. I've seen this happen during at least one onboarding. The section is also a bit long to comfortably scroll over quickly to find the next section. Let's put those steps in a details block to make it more obvious that it is there for unusual situations only. Co-authored-by: Shelley Vohr PR-URL: https://github.com/nodejs/node/pull/35296 Reviewed-By: Michaël Zasso Reviewed-By: Richard Lau Reviewed-By: Michael Dawson --- doc/guides/collaborator-guide.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/guides/collaborator-guide.md b/doc/guides/collaborator-guide.md index 6f408783449ae0..b6080292713fdd 100644 --- a/doc/guides/collaborator-guide.md +++ b/doc/guides/collaborator-guide.md @@ -469,6 +469,12 @@ code. If you wish to create the token yourself in advance, see ### Technical HOWTO +Infrequently, it is necessary to manually perform the steps required to land a +pull request rather than rely on `git-node`. + +
+Manual Landing Steps + Clear any `am`/`rebase` that might already be underway: ```text @@ -626,6 +632,8 @@ your pull request shows the purple merged status, add the "Landed in \..\" comment if you added more than one commit. +
+ ### Troubleshooting Sometimes, when running `git push upstream master`, you might get an error From 0a847ca729e598628fb8eb4f949e4b4008c8e598 Mon Sep 17 00:00:00 2001 From: Gerhard Stoebich <18708370+Flarna@users.noreply.github.com> Date: Wed, 23 Sep 2020 23:28:31 +0200 Subject: [PATCH 19/42] doc: update napi_make_callback documentation Calling napi_make_callback() with no async_context is not resulting in using the current async context instead an empty context (id 0) is used. Using NULL is like using node::Makecallback without async_context which is deprecated since Node.js 10 (DEP0099). PR-URL: https://github.com/nodejs/node/pull/35321 Fixes: https://github.com/nodejs/node/issues/35188 Reviewed-By: Anna Henningsen Reviewed-By: Gabriel Schulhof Reviewed-By: Chengzhong Wu Reviewed-By: Michael Dawson --- doc/api/n-api.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 3b62d1ecd870c2..793405318c1c79 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -5176,9 +5176,11 @@ NAPI_EXTERN napi_status napi_make_callback(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[in] async_context`: Context for the async operation that is invoking the callback. This should normally be a value previously - obtained from [`napi_async_init`][]. However `NULL` is also allowed, - which indicates the current async context (if any) is to be used - for the callback. + obtained from [`napi_async_init`][]. + In order to retain ABI compatibility with previous versions, passing `NULL` + for `async_context` will not result in an error. However, this will result + in incorrect operation of async hooks. Potential issues include loss of + async context when using the `AsyncLocalStorage` API. * `[in] recv`: The `this` object passed to the called function. * `[in] func`: `napi_value` representing the JavaScript function to be invoked. * `[in] argc`: The count of elements in the `argv` array. From 6dc6dadfc69407051b756a638bf0c23624804aaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Tue, 22 Sep 2020 20:22:26 +0200 Subject: [PATCH 20/42] doc: avoid referring to C array size The size of arrays is measured in bytes in C, not in the number of elements. The napi_get_cb_info function takes the length of the array, that is, the number of elements it can contain, and not its size. PR-URL: https://github.com/nodejs/node/pull/35300 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig Reviewed-By: Jiawen Geng Reviewed-By: Chengzhong Wu Reviewed-By: Gabriel Schulhof --- doc/api/n-api.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 793405318c1c79..18f8a596029f56 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -4388,8 +4388,8 @@ napi_status napi_get_cb_info(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[in] cbinfo`: The callback info passed into the callback function. -* `[in-out] argc`: Specifies the size of the provided `argv` array and receives - the actual count of arguments. +* `[in-out] argc`: Specifies the length of the provided `argv` array and + receives the actual count of arguments. * `[out] argv`: Buffer to which the `napi_value` representing the arguments are copied. If there are more arguments than the provided count, only the requested number of arguments are copied. If there are fewer arguments From 482ce6ce1d5237117709b5ec0a569ee7b379bd06 Mon Sep 17 00:00:00 2001 From: Gabriel Schulhof Date: Wed, 23 Sep 2020 12:44:47 -0700 Subject: [PATCH 21/42] doc: improve N-API string-to-native doc Mention null termination handling in the string size accounting and string truncation. PR-URL: https://github.com/nodejs/node/pull/35322 Reviewed-By: Anna Henningsen Reviewed-By: Michael Dawson --- doc/api/n-api.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 18f8a596029f56..2415bc55a9cd0e 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3077,9 +3077,10 @@ napi_status napi_get_value_string_latin1(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[in] value`: `napi_value` representing JavaScript string. * `[in] buf`: Buffer to write the ISO-8859-1-encoded string into. If `NULL` is - passed in, the length of the string (in bytes) is returned. + passed in, the length of the string in bytes and excluding the null terminator + is returned in `result`. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated. + insufficient, the returned string will be truncated and null-terminated. * `[out] result`: Number of bytes copied into the buffer, excluding the null terminator. @@ -3106,9 +3107,10 @@ napi_status napi_get_value_string_utf8(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[in] value`: `napi_value` representing JavaScript string. * `[in] buf`: Buffer to write the UTF8-encoded string into. If `NULL` is passed - in, the length of the string (in bytes) is returned. + in, the length of the string in bytes and excluding the null terminator is + returned in `result`. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated. + insufficient, the returned string will be truncated and null-terminated. * `[out] result`: Number of bytes copied into the buffer, excluding the null terminator. @@ -3134,9 +3136,10 @@ napi_status napi_get_value_string_utf16(napi_env env, * `[in] env`: The environment that the API is invoked under. * `[in] value`: `napi_value` representing JavaScript string. * `[in] buf`: Buffer to write the UTF16-LE-encoded string into. If `NULL` is - passed in, the length of the string (in 2-byte code units) is returned. + passed in, the length of the string in 2-byte code units and excluding the + null terminator is returned. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated. + insufficient, the returned string will be truncated and null-terminated. * `[out] result`: Number of 2-byte code units copied into the buffer, excluding the null terminator. From 5da5d41b1c172fb2c16138f7fb3ced55005273fc Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Tue, 22 Sep 2020 20:35:47 -0700 Subject: [PATCH 22/42] doc: refine require/import conditions constraints PR-URL: https://github.com/nodejs/node/pull/35311 Reviewed-By: Jan Krems --- doc/api/packages.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/api/packages.md b/doc/api/packages.md index 997ffae76a529b..737e777550c148 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -364,12 +364,15 @@ For example, a package that wants to provide different ES module exports for Node.js supports the following conditions out of the box: * `"import"` - matched when the package is loaded via `import` or - `import()`. Can reference either an ES module or CommonJS file, as both - `import` and `import()` can load either ES module or CommonJS sources. - _Always matched when the `"require"` condition is not matched._ -* `"require"` - matched when the package is loaded via `require()`. - As `require()` only supports CommonJS, the referenced file must be CommonJS. - _Always matched when the `"import"` condition is not matched._ + `import()`, or via any top-level import or resolve operation by the + ECMAScript module loader. Applies regardless of the module format of the + target file. _Always mutually exclusive with `"require"`._ +* `"require"` - matched when the package is loaded via `require()`. The + referenced file should be loadable with `require()` although the condition + will be matched regardless of the module format of the target file. Expected + formats include CommonJS, JSON, and native addons but not ES modules as + `require()` doesn't support them. _Always mutually exclusive with + `"import"`._ * `"node"` - matched for any Node.js environment. Can be a CommonJS or ES module file. _This condition should always come after `"import"` or `"require"`._ From 353a5672358aadd08f3a89f406fecc8b80756e82 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 23 Sep 2020 21:27:13 -0700 Subject: [PATCH 23/42] deps: upgrade to c-ares v1.16.1 PR-URL: https://github.com/nodejs/node/pull/35324 Refs: https://github.com/c-ares/c-ares/releases/tag/cares-1_16_1 Reviewed-By: Jiawen Geng Reviewed-By: Anna Henningsen Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott --- deps/cares/include/ares_version.h | 4 +- deps/cares/src/RELEASE-NOTES | 99 ++++++-------------------- deps/cares/src/ares_getaddrinfo.c | 13 ++-- deps/cares/src/ares_getnameinfo.c | 4 +- deps/cares/src/ares_parse_a_reply.c | 4 +- deps/cares/src/ares_parse_aaaa_reply.c | 4 +- deps/cares/src/ares_parse_txt_reply.c | 2 +- deps/cares/src/ares_private.h | 5 ++ deps/cares/src/ares_process.c | 4 +- 9 files changed, 45 insertions(+), 94 deletions(-) diff --git a/deps/cares/include/ares_version.h b/deps/cares/include/ares_version.h index 7758a48148a804..c041d574dee09e 100644 --- a/deps/cares/include/ares_version.h +++ b/deps/cares/include/ares_version.h @@ -7,11 +7,11 @@ #define ARES_VERSION_MAJOR 1 #define ARES_VERSION_MINOR 16 -#define ARES_VERSION_PATCH 0 +#define ARES_VERSION_PATCH 1 #define ARES_VERSION ((ARES_VERSION_MAJOR<<16)|\ (ARES_VERSION_MINOR<<8)|\ (ARES_VERSION_PATCH)) -#define ARES_VERSION_STR "1.16.0" +#define ARES_VERSION_STR "1.16.1" #if (ARES_VERSION >= 0x010700) # define CARES_HAVE_ARES_LIBRARY_INIT 1 diff --git a/deps/cares/src/RELEASE-NOTES b/deps/cares/src/RELEASE-NOTES index 0d8573ae8dd933..7a9d75fe788e84 100644 --- a/deps/cares/src/RELEASE-NOTES +++ b/deps/cares/src/RELEASE-NOTES @@ -1,85 +1,30 @@ -c-ares version 1.16.0 +c-ares version 1.16.1 + +Security: + o Prevent possible use-after-free and double-free in ares_getaddrinfo() if + ares_destroy() is called prior to ares_getaddrinfo() completing. Reported + by Jann Horn at Google Project Zero. Changes: - o Introduction of ares_getaddrinfo() API which provides similar output - (including proper sorting as per RFC 6724) to the system native API, but - utilizes different data structures in order to provide additional information - such as TTLs and all aliases. Please reference the respective man pages for - usage details. [3] [4] [5] [7] [8] [13] [14] [15] [16] [17] [22] - o Parse SOA records from ns_t_any response [29] [30] - o CMake: Provide c-ares version in package export file [24] - o CMake: Add CPACK functionality for DEB and RPM [28] - o CMake: Generate PDB files during build [33] [34] - o CMake: Support manpage installation [37] [38] + o Allow TXT records on CHAOS qclass. Used for retriving things like + version.bind, version.server, authoris.bind, hostname.bind, and id.server. + [3] Bug fixes: - o Fix bad expectation in IPv6 localhost test. [1] [2] - o AutoTools: use XC_CHECK_BUILD_FLAGS instead of XC_CHECK_USER_FLAGS to prevent - complaints about CPPFLAGS in CFLAGS. [6] - o Fix .onion handling - o Command line usage was out of date for adig and ahost. [18] - o Typos in manpages [19] [20] - o If ares_getenv is defined, it must return a value on all platforms [21] - o If /etc/resolv.conf has invalid lookup values, use the defaults. [23] - o Tests: Separate live tests from SetServers* tests as only live tests should - require internet access. [25] - o ares_gethostbyname() should return ENODATA if no valid A or AAAA record is - found, but a CNAME was found. [26] [27] - o CMake: Rework library function checking to prevent unintended linking with - system libraries that aren't needed. [31] [32] - o Due to use of inet_addr() it was not possible to return 255.255.255.255 from - ares_gethostbyname(). [35] [36] - o CMake: Fix building of tests on Windows + o Fix Windows Unicode incompatibilities with ares_getaddrinfo() [1] + o Silence false cast-align compiler warnings due to valid casts of + struct sockaddr to struct sockaddr_in and struct sockaddr_in6. + o MacOS should use libresolv for retrieving DNS servers, like iOS + o CMake build system should populate the INCLUDE_DIRECTORIES property of + installed targets [2] + o Correct macros in use for the ares_getaddrinfo.3 man page Thanks go to these friendly people for their efforts and contributions: - Abhishek Arya (@inferno-chromium), Adam Majer (@AdamMajer), - Andrew Selivanov (@ki11roy), Ben Noordhuis (@bnoordhuis), - Brad House (@bradh352), Christian Ammer (@ChristianAmmer), Dan Noé (@dnoe), - Daniel Stenberg (@bagder), Darrin Cullop (@dwcullop), - Dron Rathore (@DronRathore), Fabrice Fontaine (@ffontaine), - Gregor Jasny (@gjasny), @kedixa, Khaidi Chu (@XadillaX), - Kyle Edwards (@KyleFromKitware), @lifenjoiner, Michal Rostecki (@mrostecki), - Peter Eisentraut (@petere), Piotr Pietraszkiewicz (@ppietrasa), - Stephen Bryant (@bf-bryants), @tjwalton, Vy Nguyen (@oontvoo) - (22 contributors) + Brad House (@bradh352), Daniel Stenberg (@bagder), Dmitry Igrishin (@dmitigr), + Jann Horn, Shelly Vohr, Teemu R (@rytilahti) + (6 contributors) References to bug reports and discussions on issues: - [1] = https://github.com/c-ares/c-ares/pull/227 - [2] = https://github.com/c-ares/c-ares/issues/85 - [3] = https://github.com/c-ares/c-ares/pull/112 - [4] = https://github.com/c-ares/c-ares/pull/233 - [5] = https://github.com/c-ares/c-ares/pull/234 - [6] = https://github.com/c-ares/c-ares/pull/236 - [7] = https://github.com/c-ares/c-ares/pull/235 - [8] = https://github.com/c-ares/c-ares/pull/239 - [9] = https://github.com/c-ares/c-ares/pull/241 - [10] = https://github.com/c-ares/c-ares/pull/187 - [11] = https://github.com/c-ares/c-ares/pull/252 - [12] = https://github.com/c-ares/c-ares/issues/251 - [13] = https://github.com/c-ares/c-ares/pull/258 - [14] = https://github.com/c-ares/c-ares/pull/257 - [15] = https://github.com/c-ares/c-ares/pull/262 - [16] = https://github.com/c-ares/c-ares/pull/264 - [17] = https://github.com/c-ares/c-ares/pull/265 - [18] = https://github.com/c-ares/c-ares/pull/256 - [19] = https://github.com/c-ares/c-ares/pull/269 - [20] = https://github.com/c-ares/c-ares/pull/275 - [21] = https://github.com/c-ares/c-ares/pull/279 - [22] = https://github.com/c-ares/c-ares/pull/290 - [23] = https://github.com/c-ares/c-ares/pull/274 - [24] = https://github.com/c-ares/c-ares/pull/296 - [25] = https://github.com/c-ares/c-ares/pull/299 - [26] = https://github.com/c-ares/c-ares/pull/304 - [27] = https://github.com/c-ares/c-ares/issues/303 - [28] = https://github.com/c-ares/c-ares/pull/283 - [29] = https://github.com/c-ares/c-ares/pull/103 - [30] = https://github.com/c-ares/c-ares/issues/102 - [31] = https://github.com/c-ares/c-ares/pull/310 - [32] = https://github.com/c-ares/c-ares/issues/307 - [33] = https://github.com/c-ares/c-ares/pull/311 - [34] = https://github.com/c-ares/c-ares/issues/245 - [35] = https://github.com/c-ares/c-ares/issues/309 - [36] = https://github.com/c-ares/c-ares/pull/312 - [37] = https://github.com/c-ares/c-ares/issues/297 - [38] = https://github.com/c-ares/c-ares/pull/314 - + [1] = https://github.com/c-ares/c-ares/pull/328 + [2] = https://github.com/c-ares/c-ares/pull/323 + [3] = https://github.com/c-ares/c-ares/pull/321 diff --git a/deps/cares/src/ares_getaddrinfo.c b/deps/cares/src/ares_getaddrinfo.c index 8265e4afc20f60..be168068b1d424 100644 --- a/deps/cares/src/ares_getaddrinfo.c +++ b/deps/cares/src/ares_getaddrinfo.c @@ -408,11 +408,11 @@ static void end_hquery(struct host_query *hquery, int status) { if (next->ai_family == AF_INET) { - ((struct sockaddr_in *)next->ai_addr)->sin_port = htons(hquery->port); + (CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr))->sin_port = htons(hquery->port); } else { - ((struct sockaddr_in6 *)next->ai_addr)->sin6_port = htons(hquery->port); + (CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr))->sin6_port = htons(hquery->port); } next = next->ai_next; } @@ -456,18 +456,18 @@ static int file_lookup(struct host_query *hquery) char tmp[MAX_PATH]; HKEY hkeyHosts; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, + if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts) == ERROR_SUCCESS) { DWORD dwLength = MAX_PATH; - RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, + RegQueryValueExA(hkeyHosts, DATABASEPATH, NULL, NULL, (LPBYTE)tmp, &dwLength); - ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH); + ExpandEnvironmentStringsA(tmp, PATH_HOSTS, MAX_PATH); RegCloseKey(hkeyHosts); } } else if (platform == WIN_9X) - GetWindowsDirectory(PATH_HOSTS, MAX_PATH); + GetWindowsDirectoryA(PATH_HOSTS, MAX_PATH); else return ARES_ENOTFOUND; @@ -548,6 +548,7 @@ static void host_callback(void *arg, int status, int timeouts, else if (status == ARES_EDESTRUCTION) { end_hquery(hquery, status); + return; } if (!hquery->remaining) diff --git a/deps/cares/src/ares_getnameinfo.c b/deps/cares/src/ares_getnameinfo.c index aa089417060fec..53f91ca8459fc1 100644 --- a/deps/cares/src/ares_getnameinfo.c +++ b/deps/cares/src/ares_getnameinfo.c @@ -92,13 +92,13 @@ void ares_getnameinfo(ares_channel channel, const struct sockaddr *sa, if ((sa->sa_family == AF_INET) && (salen == sizeof(struct sockaddr_in))) { - addr = (struct sockaddr_in *)sa; + addr = CARES_INADDR_CAST(struct sockaddr_in *, sa); port = addr->sin_port; } else if ((sa->sa_family == AF_INET6) && (salen == sizeof(struct sockaddr_in6))) { - addr6 = (struct sockaddr_in6 *)sa; + addr6 = CARES_INADDR_CAST(struct sockaddr_in6 *, sa); port = addr6->sin6_port; } else diff --git a/deps/cares/src/ares_parse_a_reply.c b/deps/cares/src/ares_parse_a_reply.c index 920ba24af42129..d8a9e9b578363b 100644 --- a/deps/cares/src/ares_parse_a_reply.c +++ b/deps/cares/src/ares_parse_a_reply.c @@ -163,7 +163,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen, { hostent->h_addr_list[i] = (char *)&addrs[i]; memcpy(hostent->h_addr_list[i], - &(((struct sockaddr_in *)next->ai_addr)->sin_addr), + &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr), sizeof(struct in_addr)); if (naddrttls && i < *naddrttls) { @@ -173,7 +173,7 @@ int ares_parse_a_reply(const unsigned char *abuf, int alen, addrttls[i].ttl = next->ai_ttl; memcpy(&addrttls[i].ipaddr, - &(((struct sockaddr_in *)next->ai_addr)->sin_addr), + &(CARES_INADDR_CAST(struct sockaddr_in *, next->ai_addr)->sin_addr), sizeof(struct in_addr)); } ++i; diff --git a/deps/cares/src/ares_parse_aaaa_reply.c b/deps/cares/src/ares_parse_aaaa_reply.c index d39e138d4c3304..0d39bfa8268bc0 100644 --- a/deps/cares/src/ares_parse_aaaa_reply.c +++ b/deps/cares/src/ares_parse_aaaa_reply.c @@ -165,7 +165,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, { hostent->h_addr_list[i] = (char*)&addrs[i]; memcpy(hostent->h_addr_list[i], - &(((struct sockaddr_in6 *)next->ai_addr)->sin6_addr), + &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr), sizeof(struct ares_in6_addr)); if (naddrttls && i < *naddrttls) { @@ -175,7 +175,7 @@ int ares_parse_aaaa_reply(const unsigned char *abuf, int alen, addrttls[i].ttl = next->ai_ttl; memcpy(&addrttls[i].ip6addr, - &(((struct sockaddr_in6 *)next->ai_addr)->sin6_addr), + &(CARES_INADDR_CAST(struct sockaddr_in6 *, next->ai_addr)->sin6_addr), sizeof(struct ares_in6_addr)); } ++i; diff --git a/deps/cares/src/ares_parse_txt_reply.c b/deps/cares/src/ares_parse_txt_reply.c index 4856b4cea31f9f..3f47e23f08637f 100644 --- a/deps/cares/src/ares_parse_txt_reply.c +++ b/deps/cares/src/ares_parse_txt_reply.c @@ -113,7 +113,7 @@ ares__parse_txt_reply (const unsigned char *abuf, int alen, } /* Check if we are really looking at a TXT record */ - if (rr_class == C_IN && rr_type == T_TXT) + if ((rr_class == C_IN || rr_class == C_CHAOS) && rr_type == T_TXT) { /* * There may be multiple substrings in a single TXT record. Each diff --git a/deps/cares/src/ares_private.h b/deps/cares/src/ares_private.h index 2ee54e5ecd8e21..1884c1659681c1 100644 --- a/deps/cares/src/ares_private.h +++ b/deps/cares/src/ares_private.h @@ -50,6 +50,11 @@ #define STATIC_TESTABLE static #endif +/* By using a double cast, we can get rid of the bogus warning of + * warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *' increases required alignment from 1 to 4 [-Wcast-align] + */ +#define CARES_INADDR_CAST(type, var) ((type)((void *)var)) + #if defined(WIN32) && !defined(WATT32) #define WIN_NS_9X "System\\CurrentControlSet\\Services\\VxD\\MSTCP" diff --git a/deps/cares/src/ares_process.c b/deps/cares/src/ares_process.c index c86d3f2026b20b..ff71f66a1ecce0 100644 --- a/deps/cares/src/ares_process.c +++ b/deps/cares/src/ares_process.c @@ -1337,13 +1337,13 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa) { case AF_INET: addr1 = &aa->addrV4; - addr2 = &((struct sockaddr_in *)sa)->sin_addr; + addr2 = &(CARES_INADDR_CAST(struct sockaddr_in *, sa))->sin_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV4)) == 0) return 1; /* match */ break; case AF_INET6: addr1 = &aa->addrV6; - addr2 = &((struct sockaddr_in6 *)sa)->sin6_addr; + addr2 = &(CARES_INADDR_CAST(struct sockaddr_in6 *, sa))->sin6_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV6)) == 0) return 1; /* match */ break; From 0d8eaa3942f289874ed8c5d2a9468ba9c9ec45c8 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 22 Sep 2020 20:35:48 +0200 Subject: [PATCH 24/42] src: allow N-API addon in `AddLinkedBinding()` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `AddLinkedBinding()` can be used to load old-style Node.js addons, but currently not N-API addons. There’s no good reason not to support N-API addons as well, so add that. PR-URL: https://github.com/nodejs/node/pull/35301 Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Zeyu Yang --- src/api/environment.cc | 4 ++ src/node.h | 4 ++ src/node_api.cc | 17 +++-- src/node_api.h | 2 +- src/node_internals.h | 2 + test/cctest/test_linked_binding.cc | 109 ++++++++++++++++++++++++++++- 6 files changed, 131 insertions(+), 7 deletions(-) diff --git a/src/api/environment.cc b/src/api/environment.cc index bc1ab0bfcf8793..9a2661ce8b6146 100644 --- a/src/api/environment.cc +++ b/src/api/environment.cc @@ -677,6 +677,10 @@ void AddLinkedBinding(Environment* env, const node_module& mod) { prev_head->nm_link = &env->extra_linked_bindings()->back(); } +void AddLinkedBinding(Environment* env, const napi_module& mod) { + AddLinkedBinding(env, napi_module_to_node_module(&mod)); +} + void AddLinkedBinding(Environment* env, const char* name, addon_context_register_func fn, diff --git a/src/node.h b/src/node.h index 1914e72ee8fa43..33e11327e487bc 100644 --- a/src/node.h +++ b/src/node.h @@ -117,6 +117,8 @@ // Forward-declare libuv loop struct uv_loop_s; +struct napi_module; + // Forward-declare these functions now to stop MSVS from becoming // terminally confused when it's done in node_internals.h namespace node { @@ -824,6 +826,8 @@ extern "C" NODE_EXTERN void node_module_register(void* mod); // In each variant, the registration function needs to be usable at least for // the time during which the Environment exists. NODE_EXTERN void AddLinkedBinding(Environment* env, const node_module& mod); +NODE_EXTERN void AddLinkedBinding(Environment* env, + const struct napi_module& mod); NODE_EXTERN void AddLinkedBinding(Environment* env, const char* name, addon_context_register_func fn, diff --git a/src/node_api.cc b/src/node_api.cc index 93488146d56690..12f369a809734f 100644 --- a/src/node_api.cc +++ b/src/node_api.cc @@ -447,7 +447,7 @@ static void napi_module_register_cb(v8::Local exports, v8::Local context, void* priv) { napi_module_register_by_symbol(exports, module, context, - static_cast(priv)->nm_register_func); + static_cast(priv)->nm_register_func); } void napi_module_register_by_symbol(v8::Local exports, @@ -480,9 +480,9 @@ void napi_module_register_by_symbol(v8::Local exports, } } -// Registers a NAPI module. -void napi_module_register(napi_module* mod) { - node::node_module* nm = new node::node_module { +namespace node { +node_module napi_module_to_node_module(const napi_module* mod) { + return { -1, mod->nm_flags | NM_F_DELETEME, nullptr, @@ -490,9 +490,16 @@ void napi_module_register(napi_module* mod) { nullptr, napi_module_register_cb, mod->nm_modname, - mod, // priv + const_cast(mod), // priv nullptr, }; +} +} // namespace node + +// Registers a NAPI module. +void napi_module_register(napi_module* mod) { + node::node_module* nm = new node::node_module( + node::napi_module_to_node_module(mod)); node::node_module_register(nm); } diff --git a/src/node_api.h b/src/node_api.h index 577a1dcd949872..786988e296b8b2 100644 --- a/src/node_api.h +++ b/src/node_api.h @@ -31,7 +31,7 @@ struct uv_loop_s; // Forward declaration. typedef napi_value (*napi_addon_register_func)(napi_env env, napi_value exports); -typedef struct { +typedef struct napi_module { int nm_version; unsigned int nm_flags; const char* nm_filename; diff --git a/src/node_internals.h b/src/node_internals.h index dffaa084db409b..c8952e59a2b071 100644 --- a/src/node_internals.h +++ b/src/node_internals.h @@ -398,6 +398,8 @@ namespace fs { std::string Basename(const std::string& str, const std::string& extension); } // namespace fs +node_module napi_module_to_node_module(const napi_module* mod); + } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/test/cctest/test_linked_binding.cc b/test/cctest/test_linked_binding.cc index 523acc86c63e2a..17c020429f0993 100644 --- a/test/cctest/test_linked_binding.cc +++ b/test/cctest/test_linked_binding.cc @@ -1,5 +1,5 @@ #include "node_test_fixture.h" -#include "node_internals.h" // RunBootstrapping() +#include "node_api.h" void InitializeBinding(v8::Local exports, v8::Local module, @@ -83,3 +83,110 @@ TEST_F(LinkedBindingTest, LocallyDefinedLinkedBindingTest) { CHECK_EQ(strcmp(*utf8val, "value"), 0); CHECK_EQ(calls, 1); } + +napi_value InitializeLocalNapiBinding(napi_env env, napi_value exports) { + napi_value key, value; + CHECK_EQ( + napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &key), napi_ok); + CHECK_EQ( + napi_create_string_utf8(env, "world", NAPI_AUTO_LENGTH, &value), napi_ok); + CHECK_EQ(napi_set_property(env, exports, key, value), napi_ok); + return nullptr; +} + +static napi_module local_linked_napi = { + NAPI_MODULE_VERSION, + node::ModuleFlags::kLinked, + nullptr, + InitializeLocalNapiBinding, + "local_linked_napi", + nullptr, + {0}, +}; + +TEST_F(LinkedBindingTest, LocallyDefinedLinkedBindingNapiTest) { + const v8::HandleScope handle_scope(isolate_); + const Argv argv; + Env test_env {handle_scope, argv}; + + AddLinkedBinding(*test_env, local_linked_napi); + + v8::Local context = isolate_->GetCurrentContext(); + + const char* run_script = + "process._linkedBinding('local_linked_napi').hello"; + v8::Local script = v8::Script::Compile( + context, + v8::String::NewFromOneByte(isolate_, + reinterpret_cast(run_script)) + .ToLocalChecked()) + .ToLocalChecked(); + v8::Local completion_value = script->Run(context).ToLocalChecked(); + v8::String::Utf8Value utf8val(isolate_, completion_value); + CHECK_NOT_NULL(*utf8val); + CHECK_EQ(strcmp(*utf8val, "world"), 0); +} + +napi_value NapiLinkedWithInstanceData(napi_env env, napi_value exports) { + int* instance_data = new int(0); + CHECK_EQ( + napi_set_instance_data( + env, + instance_data, + [](napi_env env, void* data, void* hint) { + ++*static_cast(data); + }, nullptr), + napi_ok); + + napi_value key, value; + CHECK_EQ( + napi_create_string_utf8(env, "hello", NAPI_AUTO_LENGTH, &key), napi_ok); + CHECK_EQ( + napi_create_external(env, instance_data, nullptr, nullptr, &value), + napi_ok); + CHECK_EQ(napi_set_property(env, exports, key, value), napi_ok); + return nullptr; +} + +static napi_module local_linked_napi_id = { + NAPI_MODULE_VERSION, + node::ModuleFlags::kLinked, + nullptr, + NapiLinkedWithInstanceData, + "local_linked_napi_id", + nullptr, + {0}, +}; + +TEST_F(LinkedBindingTest, LocallyDefinedLinkedBindingNapiInstanceDataTest) { + const v8::HandleScope handle_scope(isolate_); + int* instance_data = nullptr; + + { + const Argv argv; + Env test_env {handle_scope, argv}; + + AddLinkedBinding(*test_env, local_linked_napi_id); + + v8::Local context = isolate_->GetCurrentContext(); + + const char* run_script = + "process._linkedBinding('local_linked_napi_id').hello"; + v8::Local script = v8::Script::Compile( + context, + v8::String::NewFromOneByte(isolate_, + reinterpret_cast(run_script)) + .ToLocalChecked()) + .ToLocalChecked(); + v8::Local completion_value = + script->Run(context).ToLocalChecked(); + CHECK(completion_value->IsExternal()); + instance_data = static_cast( + completion_value.As()->Value()); + CHECK_NE(instance_data, nullptr); + CHECK_EQ(*instance_data, 0); + } + + CHECK_EQ(*instance_data, 1); + delete instance_data; +} From 1e1cb94e69c65f2d2b4307315286f4181c974f1a Mon Sep 17 00:00:00 2001 From: Anatoly Korniltsev Date: Mon, 21 Sep 2020 17:29:19 +0300 Subject: [PATCH 25/42] src: fix incorrect SIGSEGV handling in NODE_USE_V8_WASM_TRAP_HANDLER Pass SA_SIGINFO to sa_flags so the TrapWebAssemblyOrContinue is treated as sa_sigaction, not sa_handler, otherwise siginfo_t* info contains some garbage PR-URL: https://github.com/nodejs/node/pull/35282 Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Minwoo Jung --- src/node.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/node.cc b/src/node.cc index c5a406062c48dd..905afd8c235b7b 100644 --- a/src/node.cc +++ b/src/node.cc @@ -644,6 +644,7 @@ inline void PlatformInit() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = TrapWebAssemblyOrContinue; + sa.sa_flags = SA_SIGINFO; CHECK_EQ(sigaction(SIGSEGV, &sa, nullptr), 0); } V8::EnableWebAssemblyTrapHandler(false); From d7c28c9243a36c2a42b3bf5ae982b21470d3118c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 24 Sep 2020 05:46:36 -0700 Subject: [PATCH 26/42] test,child_process: add tests for signalCode value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prior to this change, none of the child_process tests checked the signalCode property for a value other than null. Add a check to an existing test. PR-URL: https://github.com/nodejs/node/pull/35327 Reviewed-By: Anna Henningsen Reviewed-By: Gerhard Stöbich --- test/parallel/test-child-process-kill.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/parallel/test-child-process-kill.js b/test/parallel/test-child-process-kill.js index 00aab44dd1318d..1025c69ba1ac28 100644 --- a/test/parallel/test-child-process-kill.js +++ b/test/parallel/test-child-process-kill.js @@ -32,8 +32,10 @@ cat.stderr.on('end', common.mustCall()); cat.on('exit', common.mustCall((code, signal) => { assert.strictEqual(code, null); assert.strictEqual(signal, 'SIGTERM'); + assert.strictEqual(cat.signalCode, 'SIGTERM'); })); +assert.strictEqual(cat.signalCode, null); assert.strictEqual(cat.killed, false); cat.kill(); assert.strictEqual(cat.killed, true); From 1758ac8237bafb9330e78923fc28a6b3d7dfa07c Mon Sep 17 00:00:00 2001 From: NickNaso Date: Wed, 23 Sep 2020 22:33:14 +0200 Subject: [PATCH 27/42] doc: added version 7 to N-API version matrix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Node.js version 14.12.0 released the N-API version 7, but it's not present on the N-API version matrix. This change should fix the problem in the documentation. PR-URL: https://github.com/nodejs/node/pull/35319 Reviewed-By: Gerhard Stöbich Reviewed-By: Chengzhong Wu Reviewed-By: Jiawen Geng Reviewed-By: Michael Dawson Reviewed-By: Rich Trott --- doc/api/n-api.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 2415bc55a9cd0e..4306cf8a55d6d0 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -256,6 +256,7 @@ listed as supporting a later version. 4 5 6 + 7 v6.x @@ -265,6 +266,7 @@ listed as supporting a later version. + v8.x @@ -274,6 +276,7 @@ listed as supporting a later version. v8.16.0 + v9.x @@ -283,6 +286,7 @@ listed as supporting a later version. + v10.x @@ -292,6 +296,7 @@ listed as supporting a later version. v10.16.0 v10.17.0 v10.20.0 + v11.x @@ -301,6 +306,7 @@ listed as supporting a later version. v11.8.0 + v12.x @@ -310,6 +316,7 @@ listed as supporting a later version. v12.0.0 v12.11.0 v12.17.0 + v13.x @@ -319,6 +326,7 @@ listed as supporting a later version. v13.0.0 v13.0.0 + v14.x @@ -328,6 +336,7 @@ listed as supporting a later version. v14.0.0 v14.0.0 v14.0.0 + v14.12.0 From 87dfed012c434a8b3fc4ae6d56f16a27a59ca833 Mon Sep 17 00:00:00 2001 From: Danielle Adams Date: Tue, 22 Sep 2020 12:39:26 -0400 Subject: [PATCH 28/42] doc: add gpg key export directions to releases doc Adds an extra step with instructions for exporting a gpg key to be uploaded to the key server. PR-URL: https://github.com/nodejs/node/pull/35298 Reviewed-By: Richard Lau Reviewed-By: Beth Griggs Reviewed-By: Rich Trott --- doc/guides/releases.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 93e5fb85ffa3c1..fbbb43b4e3e7a4 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -92,8 +92,14 @@ signed by someone who has been authorized to create a release. The GPG keys should be fetchable from a known third-party keyserver. The SKS Keyservers at are recommended. Use the -[submission](https://pgp.mit.edu/) form to submit a new GPG key. Keys should be -fetchable via: +[submission](https://pgp.mit.edu/) form to submit a new GPG key. You'll need to +do an ASCII-armored export of your key first: + +```console +$ gpg --armor --export email@server.com > ~/nodekey.asc +``` + +Keys should be fetchable via: ```console $ gpg --keyserver pool.sks-keyservers.net --recv-keys From 19b95a7fa9c704820c515b2020e443dc8d0ee6fd Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 24 Sep 2020 20:47:14 -0400 Subject: [PATCH 29/42] deps: upgrade to libuv 1.40.0 Notable changes: - The UV_UDP_MMSG_FREE flag has been added. - UV__EPROTO has been remapped from 4046 to -4046 for consistency with other error codes. - On Windows, UTF-16 surrogate pairs are no longer replaced with the Unicode replacement character. - uv_timer_get_due_in() has been added. PR-URL: https://github.com/nodejs/node/pull/35333 Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat Reviewed-By: Jiawen Geng --- deps/uv/AUTHORS | 5 + deps/uv/CMakeLists.txt | 29 ++++- deps/uv/ChangeLog | 35 ++++++ deps/uv/configure.ac | 2 +- deps/uv/docs/src/loop.rst | 2 + deps/uv/docs/src/metrics.rst | 2 + deps/uv/docs/src/timer.rst | 7 ++ deps/uv/docs/src/udp.rst | 14 ++- deps/uv/include/uv.h | 7 ++ deps/uv/include/uv/errno.h | 2 +- deps/uv/include/uv/unix.h | 2 + deps/uv/include/uv/version.h | 2 +- deps/uv/libuv-static.pc.in | 12 +++ deps/uv/src/random.c | 2 +- deps/uv/src/timer.c | 8 ++ deps/uv/src/unix/bsd-ifaddrs.c | 4 +- deps/uv/src/unix/freebsd.c | 41 +------ deps/uv/src/unix/fs.c | 19 +++- deps/uv/src/unix/internal.h | 11 +- deps/uv/src/unix/linux-core.c | 1 + deps/uv/src/unix/linux-syscalls.c | 56 +++++++--- deps/uv/src/unix/qnx.c | 137 ++++++++++++++++++++++++ deps/uv/src/unix/udp.c | 36 ++++--- deps/uv/src/win/tty.c | 13 ++- deps/uv/src/win/udp.c | 4 +- deps/uv/test/test-dlerror.c | 4 +- deps/uv/test/test-fs-copyfile.c | 2 +- deps/uv/test/test-tcp-connect-timeout.c | 4 +- deps/uv/test/test-timer.c | 4 + deps/uv/test/test-udp-connect.c | 11 ++ deps/uv/test/test-udp-mmsg.c | 26 +++-- 31 files changed, 390 insertions(+), 114 deletions(-) create mode 100644 deps/uv/libuv-static.pc.in create mode 100644 deps/uv/src/unix/qnx.c diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 9078925bb07669..e7c789cfd1b81f 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -443,3 +443,8 @@ escherstair Evan Lucas tjarlama <59913901+tjarlama@users.noreply.github.com> 司徒玟琅 +YuMeiJie +Aleksej Lebedev +Nikolay Mitev +Ulrik Strid +Elad Lahav diff --git a/deps/uv/CMakeLists.txt b/deps/uv/CMakeLists.txt index e9bf77f7c36de0..e648b00be6432f 100644 --- a/deps/uv/CMakeLists.txt +++ b/deps/uv/CMakeLists.txt @@ -146,7 +146,7 @@ if(WIN32) list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c) else() list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE) - if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390") + if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390|QNX") # TODO: This should be replaced with find_package(Threads) if possible # Android has pthread as part of its c library, not as a separate # libpthread.so. @@ -298,6 +298,30 @@ if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") list(APPEND uv_sources src/unix/no-proctitle.c src/unix/sunos.c) endif() +if(CMAKE_SYSTEM_NAME STREQUAL "Haiku") + list(APPEND uv_defines _BSD_SOURCE) + list(APPEND uv_libraries bsd network) + list(APPEND uv_sources + src/unix/haiku.c + src/unix/bsd-ifaddrs.c + src/unix/no-fsevents.c + src/unix/no-proctitle.c + src/unix/posix-hrtime.c + src/unix/posix-poll.c) +endif() + +if(CMAKE_SYSTEM_NAME STREQUAL "QNX") + list(APPEND uv_sources + src/unix/posix-hrtime.c + src/unix/posix-poll.c + src/unix/qnx.c + src/unix/bsd-ifaddrs.c + src/unix/no-proctitle.c + src/unix/no-fsevents.c) + list(APPEND uv_cflags -fno-strict-aliasing) + list(APPEND uv_libraries socket) +endif() + if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD") list(APPEND uv_test_libraries util) endif() @@ -568,10 +592,11 @@ if(UNIX OR MINGW) set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) set(prefix ${CMAKE_INSTALL_PREFIX}) configure_file(libuv.pc.in libuv.pc @ONLY) + configure_file(libuv-static.pc.in libuv-static.pc @ONLY) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR}) - install(FILES ${PROJECT_BINARY_DIR}/libuv.pc + install(FILES ${PROJECT_BINARY_DIR}/libuv.pc ${PROJECT_BINARY_DIR}/libuv-static.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index 06509e7d15857d..055dcaf9f18b4e 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,38 @@ +2020.09.26, Version 1.40.0 (Stable), 4e69e333252693bd82d6338d6124f0416538dbfc + +Changes since version 1.39.0: + +* udp: add UV_UDP_MMSG_FREE recv_cb flag (Ryan Liptak) + +* include: re-map UV__EPROTO from 4046 to -4046 (YuMeiJie) + +* doc: correct UV_UDP_MMSG_FREE version added (cjihrig) + +* doc: add uv_metrics_idle_time() version metadata (Ryan Liptak) + +* win,tty: pass through utf-16 surrogate pairs (Mustafa M) + +* unix: fix DragonFly BSD build (Aleksej Lebedev) + +* win,udp: fix error code returned by connect() (Santiago Gimeno) + +* src: suppress user_timeout maybe-uninitialized (Daniel Bevenius) + +* test: fix compiler warning (Vladimír Čunát) + +* build: fix the Haiku cmake build (David Carlier) + +* linux: fix i386 sendmmsg/recvmmsg support (Ben Noordhuis) + +* build: add libuv-static pkg-config file (Nikolay Mitev) + +* unix,win: add uv_timer_get_due_in() (Ulrik Strid) + +* build,unix: add QNX support (Elad Lahav) + +* include: remove incorrect UV__ERR() for EPROTO (cjihrig) + + 2020.08.26, Version 1.39.0 (Stable), 25f4b8b8a3c0f934158cd37a37b0525d75ca488e Changes since version 1.38.1: diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index 8f5c89b1a99ffb..1a66b74d28357a 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.39.0], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.40.0], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/docs/src/loop.rst b/deps/uv/docs/src/loop.rst index f9ebb9d4a4f0c2..0f5ddfb3ca21b7 100644 --- a/deps/uv/docs/src/loop.rst +++ b/deps/uv/docs/src/loop.rst @@ -73,6 +73,8 @@ API This option is necessary to use :c:func:`uv_metrics_idle_time`. + .. versionchanged:: 1.39.0 added the UV_METRICS_IDLE_TIME option. + .. c:function:: int uv_loop_close(uv_loop_t* loop) Releases all internal loop resources. Call this function only when the loop diff --git a/deps/uv/docs/src/metrics.rst b/deps/uv/docs/src/metrics.rst index 223f7feb8fdfee..696c620d192f36 100644 --- a/deps/uv/docs/src/metrics.rst +++ b/deps/uv/docs/src/metrics.rst @@ -23,3 +23,5 @@ API The event loop will not begin accumulating the event provider's idle time until calling :c:type:`uv_loop_configure` with :c:type:`UV_METRICS_IDLE_TIME`. + + .. versionadded:: 1.39.0 diff --git a/deps/uv/docs/src/timer.rst b/deps/uv/docs/src/timer.rst index e163e288fdb275..070fa79da9d6df 100644 --- a/deps/uv/docs/src/timer.rst +++ b/deps/uv/docs/src/timer.rst @@ -78,4 +78,11 @@ API Get the timer repeat value. +.. c:function:: uint64_t uv_timer_get_due_in(const uv_timer_t* handle) + + Get the timer due value or 0 if it has expired. The time is relative to + :c:func:`uv_now()`. + + .. versionadded:: 1.40.0 + .. seealso:: The :c:type:`uv_handle_t` API functions also apply. diff --git a/deps/uv/docs/src/udp.rst b/deps/uv/docs/src/udp.rst index aed7ce22716557..30aa4593f01936 100644 --- a/deps/uv/docs/src/udp.rst +++ b/deps/uv/docs/src/udp.rst @@ -47,6 +47,12 @@ Data types * must not be freed by the recv_cb callback. */ UV_UDP_MMSG_CHUNK = 8, + /* + * Indicates that the buffer provided has been fully utilized by recvmmsg and + * that it should now be freed by the recv_cb callback. When this flag is set + * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. + */ + UV_UDP_MMSG_FREE = 16, /* * Indicates that recvmmsg should be used, if available. */ @@ -80,8 +86,10 @@ Data types When using :man:`recvmmsg(2)`, chunks will have the `UV_UDP_MMSG_CHUNK` flag set, those must not be freed. There will be a final callback with `nread` set to 0, `addr` set to NULL and the buffer pointing at the initially allocated data with - the `UV_UDP_MMSG_CHUNK` flag cleared. This is a good chance for the callee to - free the provided buffer. + the `UV_UDP_MMSG_CHUNK` flag cleared and the `UV_UDP_MMSG_FREE` flag set. + The callee can now safely free the provided buffer. + + .. versionchanged:: 1.40.0 added the `UV_UDP_MMSG_FREE` flag. .. note:: The receive callback will be called with `nread` == 0 and `addr` == NULL when there is @@ -392,7 +400,7 @@ API it must be explicitly requested by passing the `UV_UDP_RECVMMSG` flag to :c:func:`uv_udp_init_ex`. .. versionchanged:: 1.39.0 :c:func:`uv_udp_using_recvmmsg` can be used in `alloc_cb` to - determine if a buffer sized for use with :man:`recvmmsg(2)` should be + determine if a buffer sized for use with :man:`recvmmsg(2)` should be allocated for the current handle/platform. .. c:function:: int uv_udp_using_recvmmsg(uv_udp_t* handle) diff --git a/deps/uv/include/uv.h b/deps/uv/include/uv.h index 06b6d001040e04..2557961eedba7f 100644 --- a/deps/uv/include/uv.h +++ b/deps/uv/include/uv.h @@ -614,6 +614,12 @@ enum uv_udp_flags { * must not be freed by the recv_cb callback. */ UV_UDP_MMSG_CHUNK = 8, + /* + * Indicates that the buffer provided has been fully utilized by recvmmsg and + * that it should now be freed by the recv_cb callback. When this flag is set + * in uv_udp_recv_cb, nread will always be 0 and addr will always be NULL. + */ + UV_UDP_MMSG_FREE = 16, /* * Indicates that recvmmsg should be used, if available. @@ -865,6 +871,7 @@ UV_EXTERN int uv_timer_stop(uv_timer_t* handle); UV_EXTERN int uv_timer_again(uv_timer_t* handle); UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); +UV_EXTERN uint64_t uv_timer_get_due_in(const uv_timer_t* handle); /* diff --git a/deps/uv/include/uv/errno.h b/deps/uv/include/uv/errno.h index 165fd11c376a1c..aadce9c14c9a6c 100644 --- a/deps/uv/include/uv/errno.h +++ b/deps/uv/include/uv/errno.h @@ -317,7 +317,7 @@ #if defined(EPROTO) && !defined(_WIN32) # define UV__EPROTO UV__ERR(EPROTO) #else -# define UV__EPROTO UV__ERR(4046) +# define UV__EPROTO (-4046) #endif #if defined(EPROTONOSUPPORT) && !defined(_WIN32) diff --git a/deps/uv/include/uv/unix.h b/deps/uv/include/uv/unix.h index 3a131638f77606..e3cf7bdd4efd82 100644 --- a/deps/uv/include/uv/unix.h +++ b/deps/uv/include/uv/unix.h @@ -69,6 +69,8 @@ # include "uv/posix.h" #elif defined(__HAIKU__) # include "uv/posix.h" +#elif defined(__QNX__) +# include "uv/posix.h" #endif #ifndef NI_MAXHOST diff --git a/deps/uv/include/uv/version.h b/deps/uv/include/uv/version.h index 3219e9637f4510..5272008a3434b5 100644 --- a/deps/uv/include/uv/version.h +++ b/deps/uv/include/uv/version.h @@ -31,7 +31,7 @@ */ #define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 39 +#define UV_VERSION_MINOR 40 #define UV_VERSION_PATCH 0 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/libuv-static.pc.in b/deps/uv/libuv-static.pc.in new file mode 100644 index 00000000000000..ea625482d5ebd4 --- /dev/null +++ b/deps/uv/libuv-static.pc.in @@ -0,0 +1,12 @@ +prefix=@prefix@ +exec_prefix=${prefix} +libdir=@libdir@ +includedir=@includedir@ + +Name: libuv-static +Version: @PACKAGE_VERSION@ +Description: multi-platform support library with a focus on asynchronous I/O. +URL: http://libuv.org/ + +Libs: -L${libdir} -luv_a @LIBS@ +Cflags: -I${includedir} diff --git a/deps/uv/src/random.c b/deps/uv/src/random.c index 491bf703309955..e75f77deb2bdaf 100644 --- a/deps/uv/src/random.c +++ b/deps/uv/src/random.c @@ -33,7 +33,7 @@ static int uv__random(void* buf, size_t buflen) { #if defined(__PASE__) rc = uv__random_readpath("/dev/urandom", buf, buflen); -#elif defined(_AIX) +#elif defined(_AIX) || defined(__QNX__) rc = uv__random_readpath("/dev/random", buf, buflen); #elif defined(__APPLE__) || defined(__OpenBSD__) || \ (defined(__ANDROID_API__) && __ANDROID_API__ >= 28) diff --git a/deps/uv/src/timer.c b/deps/uv/src/timer.c index 4cf4ed42648650..1bea2a8bd29cdf 100644 --- a/deps/uv/src/timer.c +++ b/deps/uv/src/timer.c @@ -130,6 +130,14 @@ uint64_t uv_timer_get_repeat(const uv_timer_t* handle) { } +uint64_t uv_timer_get_due_in(const uv_timer_t* handle) { + if (handle->loop->time >= handle->timeout) + return 0; + + return handle->timeout - handle->loop->time; +} + + int uv__next_timeout(const uv_loop_t* loop) { const struct heap_node* heap_node; const uv_timer_t* handle; diff --git a/deps/uv/src/unix/bsd-ifaddrs.c b/deps/uv/src/unix/bsd-ifaddrs.c index a3385af17c889f..5223ab4879677e 100644 --- a/deps/uv/src/unix/bsd-ifaddrs.c +++ b/deps/uv/src/unix/bsd-ifaddrs.c @@ -113,7 +113,9 @@ int uv_interface_addresses(uv_interface_address_t** addresses, int* count) { address->address.address4 = *((struct sockaddr_in*) ent->ifa_addr); } - if (ent->ifa_netmask->sa_family == AF_INET6) { + if (ent->ifa_netmask == NULL) { + memset(&address->netmask, 0, sizeof(address->netmask)); + } else if (ent->ifa_netmask->sa_family == AF_INET6) { address->netmask.netmask6 = *((struct sockaddr_in6*) ent->ifa_netmask); } else { address->netmask.netmask4 = *((struct sockaddr_in*) ent->ifa_netmask); diff --git a/deps/uv/src/unix/freebsd.c b/deps/uv/src/unix/freebsd.c index ef77e127c26c39..fe795a0e75ea1a 100644 --- a/deps/uv/src/unix/freebsd.c +++ b/deps/uv/src/unix/freebsd.c @@ -56,31 +56,6 @@ int uv__platform_loop_init(uv_loop_t* loop) { void uv__platform_loop_delete(uv_loop_t* loop) { } - -#ifdef __DragonFly__ -int uv_exepath(char* buffer, size_t* size) { - char abspath[PATH_MAX * 2 + 1]; - ssize_t abspath_size; - - if (buffer == NULL || size == NULL || *size == 0) - return UV_EINVAL; - - abspath_size = readlink("/proc/curproc/file", abspath, sizeof(abspath)); - if (abspath_size < 0) - return UV__ERR(errno); - - assert(abspath_size > 0); - *size -= 1; - - if (*size > abspath_size) - *size = abspath_size; - - memcpy(buffer, abspath, *size); - buffer[*size] = '\0'; - - return 0; -} -#else int uv_exepath(char* buffer, size_t* size) { char abspath[PATH_MAX * 2 + 1]; int mib[4]; @@ -110,7 +85,6 @@ int uv_exepath(char* buffer, size_t* size) { return 0; } -#endif uint64_t uv_get_free_memory(void) { int freecount; @@ -290,25 +264,18 @@ int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { } -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags) { +int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) { #if __FreeBSD__ >= 11 - return sendmmsg(fd, mmsg, vlen, flags); + return sendmmsg(fd, mmsg, vlen, /* flags */ 0); #else return errno = ENOSYS, -1; #endif } -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout) { +int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) { #if __FreeBSD__ >= 11 - return recvmmsg(fd, mmsg, vlen, flags, timeout); + return recvmmsg(fd, mmsg, vlen, 0 /* flags */, NULL /* timeout */); #else return errno = ENOSYS, -1; #endif diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 87cb8b816aea39..556fd103c3a954 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -79,7 +79,11 @@ defined(__NetBSD__) # include # include -#elif defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__) +#elif defined(__sun) || \ + defined(__MVS__) || \ + defined(__NetBSD__) || \ + defined(__HAIKU__) || \ + defined(__QNX__) # include #else # include @@ -629,7 +633,11 @@ static int uv__fs_closedir(uv_fs_t* req) { static int uv__fs_statfs(uv_fs_t* req) { uv_statfs_t* stat_fs; -#if defined(__sun) || defined(__MVS__) || defined(__NetBSD__) || defined(__HAIKU__) +#if defined(__sun) || \ + defined(__MVS__) || \ + defined(__NetBSD__) || \ + defined(__HAIKU__) || \ + defined(__QNX__) struct statvfs buf; if (0 != statvfs(req->path, &buf)) @@ -646,7 +654,12 @@ static int uv__fs_statfs(uv_fs_t* req) { return -1; } -#if defined(__sun) || defined(__MVS__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) +#if defined(__sun) || \ + defined(__MVS__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) || \ + defined(__HAIKU__) || \ + defined(__QNX__) stat_fs->f_type = 0; /* f_type is not supported. */ #else stat_fs->f_type = buf.f_type; diff --git a/deps/uv/src/unix/internal.h b/deps/uv/src/unix/internal.h index 9d3c2297f8d764..570274ed60bebc 100644 --- a/deps/uv/src/unix/internal.h +++ b/deps/uv/src/unix/internal.h @@ -334,15 +334,8 @@ struct uv__mmsghdr { unsigned int msg_len; }; -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout); -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags); +int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen); +int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen); #else #define HAVE_MMSG 0 #endif diff --git a/deps/uv/src/unix/linux-core.c b/deps/uv/src/unix/linux-core.c index 14d5f0c04a93bc..4db2f05053a1cc 100644 --- a/deps/uv/src/unix/linux-core.c +++ b/deps/uv/src/unix/linux-core.c @@ -281,6 +281,7 @@ void uv__io_poll(uv_loop_t* loop, int timeout) { timeout = 0; } else { reset_timeout = 0; + user_timeout = 0; } /* You could argue there is a dependency between these two but diff --git a/deps/uv/src/unix/linux-syscalls.c b/deps/uv/src/unix/linux-syscalls.c index 160056b46ec383..44daaf12d49810 100644 --- a/deps/uv/src/unix/linux-syscalls.c +++ b/deps/uv/src/unix/linux-syscalls.c @@ -37,8 +37,6 @@ #ifndef __NR_recvmmsg # if defined(__x86_64__) # define __NR_recvmmsg 299 -# elif defined(__i386__) -# define __NR_recvmmsg 337 # elif defined(__arm__) # define __NR_recvmmsg (UV_SYSCALL_BASE + 365) # endif @@ -47,8 +45,6 @@ #ifndef __NR_sendmmsg # if defined(__x86_64__) # define __NR_sendmmsg 307 -# elif defined(__i386__) -# define __NR_sendmmsg 345 # elif defined(__arm__) # define __NR_sendmmsg (UV_SYSCALL_BASE + 374) # endif @@ -146,25 +142,51 @@ struct uv__mmsghdr; -int uv__sendmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags) { -#if defined(__NR_sendmmsg) - return syscall(__NR_sendmmsg, fd, mmsg, vlen, flags); +int uv__sendmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) { +#if defined(__i386__) + unsigned long args[4]; + int rc; + + args[0] = (unsigned long) fd; + args[1] = (unsigned long) mmsg; + args[2] = (unsigned long) vlen; + args[3] = /* flags */ 0; + + /* socketcall() raises EINVAL when SYS_SENDMMSG is not supported. */ + rc = syscall(/* __NR_socketcall */ 102, 20 /* SYS_SENDMMSG */, args); + if (rc == -1) + if (errno == EINVAL) + errno = ENOSYS; + + return rc; +#elif defined(__NR_sendmmsg) + return syscall(__NR_sendmmsg, fd, mmsg, vlen, /* flags */ 0); #else return errno = ENOSYS, -1; #endif } -int uv__recvmmsg(int fd, - struct uv__mmsghdr* mmsg, - unsigned int vlen, - unsigned int flags, - struct timespec* timeout) { -#if defined(__NR_recvmmsg) - return syscall(__NR_recvmmsg, fd, mmsg, vlen, flags, timeout); +int uv__recvmmsg(int fd, struct uv__mmsghdr* mmsg, unsigned int vlen) { +#if defined(__i386__) + unsigned long args[5]; + int rc; + + args[0] = (unsigned long) fd; + args[1] = (unsigned long) mmsg; + args[2] = (unsigned long) vlen; + args[3] = /* flags */ 0; + args[4] = /* timeout */ 0; + + /* socketcall() raises EINVAL when SYS_RECVMMSG is not supported. */ + rc = syscall(/* __NR_socketcall */ 102, 19 /* SYS_RECVMMSG */, args); + if (rc == -1) + if (errno == EINVAL) + errno = ENOSYS; + + return rc; +#elif defined(__NR_recvmmsg) + return syscall(__NR_recvmmsg, fd, mmsg, vlen, /* flags */ 0, /* timeout */ 0); #else return errno = ENOSYS, -1; #endif diff --git a/deps/uv/src/unix/qnx.c b/deps/uv/src/unix/qnx.c new file mode 100644 index 00000000000000..ca148d349f87c8 --- /dev/null +++ b/deps/uv/src/unix/qnx.c @@ -0,0 +1,137 @@ +/* Copyright libuv contributors. All rights reserved. + * + * 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. + */ + +#include "uv.h" +#include "internal.h" + +#include +#include +#include +#include +#include +#include + +static void +get_mem_info(uint64_t* totalmem, uint64_t* freemem) { + mem_info_t msg; + + memset(&msg, 0, sizeof(msg)); + msg.i.type = _MEM_INFO; + msg.i.fd = -1; + + if (MsgSend(MEMMGR_COID, &msg.i, sizeof(msg.i), &msg.o, sizeof(msg.o)) + != -1) { + *totalmem = msg.o.info.__posix_tmi_total; + *freemem = msg.o.info.posix_tmi_length; + } else { + *totalmem = 0; + *freemem = 0; + } +} + + +void uv_loadavg(double avg[3]) { + avg[0] = 0.0; + avg[1] = 0.0; + avg[2] = 0.0; +} + + +int uv_exepath(char* buffer, size_t* size) { + char path[PATH_MAX]; + if (buffer == NULL || size == NULL || *size == 0) + return UV_EINVAL; + + realpath(_cmdname(NULL), path); + strlcpy(buffer, path, *size); + *size = strlen(buffer); + return 0; +} + + +uint64_t uv_get_free_memory(void) { + uint64_t totalmem; + uint64_t freemem; + get_mem_info(&totalmem, &freemem); + return freemem; +} + + +uint64_t uv_get_total_memory(void) { + uint64_t totalmem; + uint64_t freemem; + get_mem_info(&totalmem, &freemem); + return totalmem; +} + + +uint64_t uv_get_constrained_memory(void) { + return 0; +} + + +int uv_resident_set_memory(size_t* rss) { + int fd; + procfs_asinfo asinfo; + + fd = uv__open_cloexec("/proc/self/ctl", O_RDONLY); + if (fd == -1) + return UV__ERR(errno); + + if (devctl(fd, DCMD_PROC_ASINFO, &asinfo, sizeof(asinfo), 0) == -1) { + uv__close(fd); + return UV__ERR(errno); + } + + uv__close(fd); + *rss = asinfo.rss; + return 0; +} + + +int uv_uptime(double* uptime) { + struct qtime_entry* qtime = _SYSPAGE_ENTRY(_syspage_ptr, qtime); + *uptime = (qtime->nsec / 1000000000.0); + return 0; +} + + +int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count) { + struct cpuinfo_entry* cpuinfo = + (struct cpuinfo_entry*)_SYSPAGE_ENTRY(_syspage_ptr, new_cpuinfo); + size_t cpuinfo_size = _SYSPAGE_ELEMENT_SIZE(_syspage_ptr, cpuinfo); + struct strings_entry* strings = _SYSPAGE_ENTRY(_syspage_ptr, strings); + int num_cpus = _syspage_ptr->num_cpu; + int i; + + *count = num_cpus; + *cpu_infos = uv__malloc(num_cpus * sizeof(**cpu_infos)); + if (*cpu_infos == NULL) + return UV_ENOMEM; + + for (i = 0; i < num_cpus; i++) { + (*cpu_infos)[i].model = strdup(&strings->data[cpuinfo->name]); + (*cpu_infos)[i].speed = cpuinfo->speed; + SYSPAGE_ARRAY_ADJ_OFFSET(cpuinfo, cpuinfo, cpuinfo_size); + } + + return 0; +} diff --git a/deps/uv/src/unix/udp.c b/deps/uv/src/unix/udp.c index 16c7f38ae82473..7d699a16753c6b 100644 --- a/deps/uv/src/unix/udp.c +++ b/deps/uv/src/unix/udp.c @@ -73,12 +73,12 @@ static void uv__udp_mmsg_init(void) { s = uv__socket(AF_INET, SOCK_DGRAM, 0); if (s < 0) return; - ret = uv__sendmmsg(s, NULL, 0, 0); + ret = uv__sendmmsg(s, NULL, 0); if (ret == 0 || errno != ENOSYS) { uv__sendmmsg_avail = 1; uv__recvmmsg_avail = 1; } else { - ret = uv__recvmmsg(s, NULL, 0, 0, NULL); + ret = uv__recvmmsg(s, NULL, 0); if (ret == 0 || errno != ENOSYS) uv__recvmmsg_avail = 1; } @@ -213,7 +213,7 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { } do - nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks, 0, NULL); + nread = uv__recvmmsg(handle->io_watcher.fd, msgs, chunks); while (nread == -1 && errno == EINTR); if (nread < 1) { @@ -238,7 +238,7 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) { /* one last callback so the original buffer is freed */ if (handle->recv_cb != NULL) - handle->recv_cb(handle, 0, buf, NULL, 0); + handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE); } return nread; } @@ -356,7 +356,7 @@ static void uv__udp_sendmmsg(uv_udp_t* handle) { } do - npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts, 0); + npkts = uv__sendmmsg(handle->io_watcher.fd, h, pkts); while (npkts == -1 && errno == EINTR); if (npkts < 1) { @@ -851,7 +851,11 @@ static int uv__udp_set_membership6(uv_udp_t* handle, } -#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__) +#if !defined(__OpenBSD__) && \ + !defined(__NetBSD__) && \ + !defined(__ANDROID__) && \ + !defined(__DragonFly__) & \ + !defined(__QNX__) static int uv__udp_set_source_membership4(uv_udp_t* handle, const struct sockaddr_in* multicast_addr, const char* interface_addr, @@ -1039,7 +1043,11 @@ int uv_udp_set_source_membership(uv_udp_t* handle, const char* interface_addr, const char* source_addr, uv_membership membership) { -#if !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__ANDROID__) +#if !defined(__OpenBSD__) && \ + !defined(__NetBSD__) && \ + !defined(__ANDROID__) && \ + !defined(__DragonFly__) && \ + !defined(__QNX__) int err; union uv__sockaddr mcast_addr; union uv__sockaddr src_addr; @@ -1146,7 +1154,7 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { * and use the general uv__setsockopt_maybe_char call on other platforms. */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) + defined(__MVS__) || defined(__QNX__) return uv__setsockopt(handle, IP_TTL, @@ -1155,7 +1163,7 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { sizeof(ttl)); #else /* !(defined(__sun) || defined(_AIX) || defined (__OpenBSD__) || - defined(__MVS__)) */ + defined(__MVS__) || defined(__QNX__)) */ return uv__setsockopt_maybe_char(handle, IP_TTL, @@ -1163,7 +1171,7 @@ int uv_udp_set_ttl(uv_udp_t* handle, int ttl) { ttl); #endif /* defined(__sun) || defined(_AIX) || defined (__OpenBSD__) || - defined(__MVS__) */ + defined(__MVS__) || defined(__QNX__) */ } @@ -1175,7 +1183,7 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { * and use the general uv__setsockopt_maybe_char call otherwise. */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) + defined(__MVS__) || defined(__QNX__) if (handle->flags & UV_HANDLE_IPV6) return uv__setsockopt(handle, IP_MULTICAST_TTL, @@ -1183,7 +1191,7 @@ int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl) { &ttl, sizeof(ttl)); #endif /* defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) */ + defined(__MVS__) || defined(__QNX__) */ return uv__setsockopt_maybe_char(handle, IP_MULTICAST_TTL, @@ -1200,7 +1208,7 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { * and use the general uv__setsockopt_maybe_char call otherwise. */ #if defined(__sun) || defined(_AIX) || defined(__OpenBSD__) || \ - defined(__MVS__) + defined(__MVS__) || defined(__QNX__) if (handle->flags & UV_HANDLE_IPV6) return uv__setsockopt(handle, IP_MULTICAST_LOOP, @@ -1208,7 +1216,7 @@ int uv_udp_set_multicast_loop(uv_udp_t* handle, int on) { &on, sizeof(on)); #endif /* defined(__sun) || defined(_AIX) ||defined(__OpenBSD__) || - defined(__MVS__) */ + defined(__MVS__) || defined(__QNX__) */ return uv__setsockopt_maybe_char(handle, IP_MULTICAST_LOOP, diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index 4604fb0c874694..1b9d4f8532635c 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -2122,13 +2122,6 @@ static int uv_tty_write_bufs(uv_tty_t* handle, abort(); } - /* We wouldn't mind emitting utf-16 surrogate pairs. Too bad, the windows - * console doesn't really support UTF-16, so just emit the replacement - * character. */ - if (utf8_codepoint > 0xffff) { - utf8_codepoint = UNICODE_REPLACEMENT_CHARACTER; - } - if (utf8_codepoint == 0x0a || utf8_codepoint == 0x0d) { /* EOL conversion - emit \r\n when we see \n. */ @@ -2155,6 +2148,12 @@ static int uv_tty_write_bufs(uv_tty_t* handle, ENSURE_BUFFER_SPACE(1); utf16_buf[utf16_buf_used++] = (WCHAR) utf8_codepoint; previous_eol = 0; + } else { + ENSURE_BUFFER_SPACE(2); + utf8_codepoint -= 0x10000; + utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint / 0x400 + 0xD800); + utf16_buf[utf16_buf_used++] = (WCHAR) (utf8_codepoint % 0x400 + 0xDC00); + previous_eol = 0; } } } diff --git a/deps/uv/src/win/udp.c b/deps/uv/src/win/udp.c index 7032b685dedfd6..68ca728aa5c9cc 100644 --- a/deps/uv/src/win/udp.c +++ b/deps/uv/src/win/udp.c @@ -1073,7 +1073,7 @@ int uv__udp_connect(uv_udp_t* handle, err = connect(handle->socket, addr, addrlen); if (err) - return uv_translate_sys_error(err); + return uv_translate_sys_error(WSAGetLastError()); handle->flags |= UV_HANDLE_UDP_CONNECTED; @@ -1089,7 +1089,7 @@ int uv__udp_disconnect(uv_udp_t* handle) { err = connect(handle->socket, &addr, sizeof(addr)); if (err) - return uv_translate_sys_error(err); + return uv_translate_sys_error(WSAGetLastError()); handle->flags &= ~UV_HANDLE_UDP_CONNECTED; return 0; diff --git a/deps/uv/test/test-dlerror.c b/deps/uv/test/test-dlerror.c index 70cc9bfa884290..42ad68828626b1 100644 --- a/deps/uv/test/test-dlerror.c +++ b/deps/uv/test/test-dlerror.c @@ -42,7 +42,7 @@ TEST_IMPL(dlerror) { msg = uv_dlerror(&lib); ASSERT(msg != NULL); -#ifndef __OpenBSD__ +#if !defined(__OpenBSD__) && !defined(__QNX__) ASSERT(strstr(msg, path) != NULL); #endif ASSERT(strstr(msg, dlerror_no_error) == NULL); @@ -50,7 +50,7 @@ TEST_IMPL(dlerror) { /* Should return the same error twice in a row. */ msg = uv_dlerror(&lib); ASSERT(msg != NULL); -#ifndef __OpenBSD__ +#if !defined(__OpenBSD__) && !defined(__QNX__) ASSERT(strstr(msg, path) != NULL); #endif ASSERT(strstr(msg, dlerror_no_error) == NULL); diff --git a/deps/uv/test/test-fs-copyfile.c b/deps/uv/test/test-fs-copyfile.c index e6f06e6eac5a2b..c785a4b51fbb10 100644 --- a/deps/uv/test/test-fs-copyfile.c +++ b/deps/uv/test/test-fs-copyfile.c @@ -25,7 +25,7 @@ #if defined(__unix__) || defined(__POSIX__) || \ defined(__APPLE__) || defined(__sun) || \ defined(_AIX) || defined(__MVS__) || \ - defined(__HAIKU__) + defined(__HAIKU__) || defined(__QNX__) #include /* unlink, etc. */ #else # include diff --git a/deps/uv/test/test-tcp-connect-timeout.c b/deps/uv/test/test-tcp-connect-timeout.c index 6b455276c516b1..a67d325284da11 100644 --- a/deps/uv/test/test-tcp-connect-timeout.c +++ b/deps/uv/test/test-tcp-connect-timeout.c @@ -100,13 +100,13 @@ static void connect_local_cb(uv_connect_t* req, int status) { connect_cb_called++; } -static int is_supported_system() { +static int is_supported_system(void) { int semver[3]; int min_semver[3] = {10, 0, 16299}; int cnt; uv_utsname_t uname; ASSERT_EQ(uv_os_uname(&uname), 0); - if (strcmp(uname.sysname, "Windows_NT") == 0) { + if (strcmp(uname.sysname, "Windows_NT") == 0) { cnt = sscanf(uname.release, "%d.%d.%d", &semver[0], &semver[1], &semver[2]); if (cnt != 3) { return 0; diff --git a/deps/uv/test/test-timer.c b/deps/uv/test/test-timer.c index c667da00ec3af8..ee8331c2045ff3 100644 --- a/deps/uv/test/test-timer.c +++ b/deps/uv/test/test-timer.c @@ -161,6 +161,7 @@ TEST_IMPL(timer_init) { ASSERT(0 == uv_timer_init(uv_default_loop(), &handle)); ASSERT(0 == uv_timer_get_repeat(&handle)); + ASSERT_UINT64_LE(0, uv_timer_get_due_in(&handle)); ASSERT(0 == uv_is_active((uv_handle_t*) &handle)); MAKE_VALGRIND_HAPPY(); @@ -232,6 +233,9 @@ TEST_IMPL(timer_huge_timeout) { ASSERT(0 == uv_timer_start(&tiny_timer, tiny_timer_cb, 1, 0)); ASSERT(0 == uv_timer_start(&huge_timer1, tiny_timer_cb, 0xffffffffffffLL, 0)); ASSERT(0 == uv_timer_start(&huge_timer2, tiny_timer_cb, (uint64_t) -1, 0)); + ASSERT_UINT64_EQ(1, uv_timer_get_due_in(&tiny_timer)); + ASSERT_UINT64_EQ(281474976710655, uv_timer_get_due_in(&huge_timer1)); + ASSERT_UINT64_LE(0, uv_timer_get_due_in(&huge_timer2)); ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); MAKE_VALGRIND_HAPPY(); return 0; diff --git a/deps/uv/test/test-udp-connect.c b/deps/uv/test/test-udp-connect.c index 58cf9475a40b57..41ace117a1bba2 100644 --- a/deps/uv/test/test-udp-connect.c +++ b/deps/uv/test/test-udp-connect.c @@ -124,6 +124,17 @@ TEST_IMPL(udp_connect) { buf = uv_buf_init("EXIT", 4); + // connect() to INADDR_ANY fails on Windows wih WSAEADDRNOTAVAIL + ASSERT_EQ(0, uv_ip4_addr("0.0.0.0", TEST_PORT, &tmp_addr)); + r = uv_udp_connect(&client, (const struct sockaddr*) &tmp_addr); +#ifdef _WIN32 + ASSERT_EQ(r, UV_EADDRNOTAVAIL); +#else + ASSERT_EQ(r, 0); + r = uv_udp_connect(&client, NULL); + ASSERT_EQ(r, 0); +#endif + ASSERT(0 == uv_ip4_addr("8.8.8.8", TEST_PORT, &ext_addr)); ASSERT(0 == uv_ip4_addr("127.0.0.1", TEST_PORT, &lo_addr)); diff --git a/deps/uv/test/test-udp-mmsg.c b/deps/uv/test/test-udp-mmsg.c index 94e8d5b82b9246..08628a5046fedc 100644 --- a/deps/uv/test/test-udp-mmsg.c +++ b/deps/uv/test/test-udp-mmsg.c @@ -74,16 +74,22 @@ static void recv_cb(uv_udp_t* handle, unsigned flags) { ASSERT_GE(nread, 0); - if (nread > 0) { - ASSERT_EQ(nread, 4); - ASSERT(addr != NULL); - ASSERT_MEM_EQ("PING", rcvbuf->base, nread); - - recv_cb_called++; - if (recv_cb_called == NUM_SENDS) { - uv_close((uv_handle_t*)handle, close_cb); - uv_close((uv_handle_t*)&sender, close_cb); - } + /* free and return if this is a mmsg free-only callback invocation */ + if (flags & UV_UDP_MMSG_FREE) { + ASSERT_EQ(nread, 0); + ASSERT(addr == NULL); + free(rcvbuf->base); + return; + } + + ASSERT_EQ(nread, 4); + ASSERT(addr != NULL); + ASSERT_MEM_EQ("PING", rcvbuf->base, nread); + + recv_cb_called++; + if (recv_cb_called == NUM_SENDS) { + uv_close((uv_handle_t*)handle, close_cb); + uv_close((uv_handle_t*)&sender, close_cb); } /* Don't free if the buffer could be reused via mmsg */ From f2635b317e9051694542572e3eedda2ae52e3712 Mon Sep 17 00:00:00 2001 From: "Pooja D.P" Date: Tue, 25 Aug 2020 11:53:32 +0000 Subject: [PATCH 30/42] test: replace annonymous functions with arrow PR-URL: https://github.com/nodejs/node/pull/34921 Reviewed-By: Harshitha K P Reviewed-By: Rich Trott Reviewed-By: Daijiro Wachi --- test/parallel/test-net-reconnect.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-net-reconnect.js b/test/parallel/test-net-reconnect.js index eb6b0728478a91..233f5b01e5445a 100644 --- a/test/parallel/test-net-reconnect.js +++ b/test/parallel/test-net-reconnect.js @@ -37,12 +37,12 @@ const server = net.createServer(function(socket) { console.error('SERVER connect, writing'); socket.write('hello\r\n'); - socket.on('end', function() { + socket.on('end', () => { console.error('SERVER socket end, calling end()'); socket.end(); }); - socket.on('close', function(had_error) { + socket.on('close', (had_error) => { console.log(`SERVER had_error: ${JSON.stringify(had_error)}`); assert.strictEqual(had_error, false); }); @@ -54,7 +54,7 @@ server.listen(0, function() { client.setEncoding('UTF8'); - client.on('connect', function() { + client.on('connect', () => { console.error('CLIENT connected', client._writableState); }); @@ -66,12 +66,12 @@ server.listen(0, function() { client.end(); }); - client.on('end', function() { + client.on('end', () => { console.error('CLIENT end'); client_end_count++; }); - client.on('close', function(had_error) { + client.on('close', (had_error) => { console.log('CLIENT disconnect'); assert.strictEqual(had_error, false); if (disconnect_count++ < N) @@ -81,7 +81,7 @@ server.listen(0, function() { }); }); -process.on('exit', function() { +process.on('exit', () => { assert.strictEqual(disconnect_count, N + 1); assert.strictEqual(client_recv_count, N + 1); assert.strictEqual(client_end_count, N + 1); From 857e321baf2fafcdf4cbc018d2f3ac07c78d6515 Mon Sep 17 00:00:00 2001 From: Victor Antonio Barzana Crespo Date: Fri, 25 Sep 2020 08:56:23 +0300 Subject: [PATCH 31/42] doc: set encoding to hex before piping hash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I found out that piping a hash to the stdout output would print a non-hex set of characters, however, the examples are intended to print out a hex-encoded output so, my proposal here is simple, we set the encoding to `hex` before piping the response of the hash algo by calling `hash.setEncoding('hex');`. With this the example is fixed PR-URL: https://github.com/nodejs/node/pull/35338 Reviewed-By: Anna Henningsen Reviewed-By: Tobias Nießen Reviewed-By: Daijiro Wachi Reviewed-By: Rich Trott --- doc/api/crypto.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 10c4fded8b6df4..35870965119eae 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1030,7 +1030,7 @@ const fs = require('fs'); const hash = crypto.createHash('sha256'); const input = fs.createReadStream('test.js'); -input.pipe(hash).pipe(process.stdout); +input.pipe(hash).setEncoding('hex').pipe(process.stdout); ``` Example: Using the [`hash.update()`][] and [`hash.digest()`][] methods: From 86ac7497e01008c4802f928d8e3c556664d6f70f Mon Sep 17 00:00:00 2001 From: Gil Pedersen Date: Thu, 24 Sep 2020 12:27:06 +0200 Subject: [PATCH 32/42] doc: add history entry for breaking destroy() change Refs: https://github.com/nodejs/node/pull/29197#issuecomment-698252186 PR-URL: https://github.com/nodejs/node/pull/35326 Reviewed-By: Anna Henningsen Reviewed-By: Rich Trott --- doc/api/stream.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index 5a2dc7b65afbfa..e3a3b7c3890015 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -379,6 +379,10 @@ See also: [`writable.uncork()`][], [`writable._writev()`][stream-_writev]. ##### `writable.destroy([error])` * `error` {Error} Optional, an error to emit with `'error'` event. @@ -961,6 +965,10 @@ called and `readableFlowing` is not `true`. ##### `readable.destroy([error])` * `error` {Error} Error which will be passed as payload in `'error'` event @@ -1525,6 +1533,10 @@ Examples of `Transform` streams include: ##### `transform.destroy([error])` * `error` {Error} From 0f4ecaa741dbb9d3478a929ab2b44bd6f6f57a3c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 19 Sep 2020 08:35:27 -0700 Subject: [PATCH 33/42] repl: standardize Control key indications Throughout our messages and docs, we refer to the Control key in a surprisingly varied number of ways: * Control * Ctrl * Cntl * varied capitalization on the above (e.g., ctrl vs. Ctrl) Then, in key combinations: * One of the items from the previous list followed by `-` * ... or followed by `+` * ... surrounded or not by `<` and `>` * ... and inside backticks or not * ... or just `^` This is the start of standardization on the formulation recommended by the Microsoft Style Guide (e.g., **Ctrl+C**). PR-URL: https://github.com/nodejs/node/pull/35270 Reviewed-By: Ruben Bridgewater --- doc/api/repl.md | 24 ++++++++++++------------ lib/repl.js | 14 ++++++++------ test/parallel/test-repl-editor.js | 9 +++++---- test/parallel/test-repl.js | 4 ++-- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/doc/api/repl.md b/doc/api/repl.md index fe8115a9536377..a194cf05a8148a 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -34,8 +34,8 @@ feature set. The following special commands are supported by all REPL instances: -* `.break`: When in the process of inputting a multi-line expression, entering - the `.break` command (or pressing the `-C` key combination) will abort +* `.break`: When in the process of inputting a multi-line expression, enter + the `.break` command (or press **Ctrl+C**) to abort further input or processing of that expression. * `.clear`: Resets the REPL `context` to an empty object and clears any multi-line expression being input. @@ -45,7 +45,7 @@ The following special commands are supported by all REPL instances: `> .save ./file/to/save.js` * `.load`: Load a file into the current REPL session. `> .load ./file/to/load.js` -* `.editor`: Enter editor mode (`-D` to finish, `-C` to cancel). +* `.editor`: Enter editor mode (**Ctrl+D** to finish, **Ctrl+C** to cancel). ```console > .editor @@ -63,10 +63,10 @@ welcome('Node.js User'); The following key combinations in the REPL have these special effects: -* `-C`: When pressed once, has the same effect as the `.break` command. +* **Ctrl+C**: When pressed once, has the same effect as the `.break` command. When pressed twice on a blank line, has the same effect as the `.exit` command. -* `-D`: Has the same effect as the `.exit` command. +* **Ctrl+D**: Has the same effect as the `.exit` command. * ``: When pressed on a blank line, displays global and local (scope) variables. When pressed while entering other input, displays relevant autocompletion options. @@ -246,14 +246,14 @@ added: v13.6.0 --> The REPL supports bi-directional reverse-i-search similar to [ZSH][]. It is -triggered with ` + R` to search backward and ` + S` to search -forward. +triggered with **Ctrl+R** to search backward and **Ctrl+S** to search +forwards. Duplicated history entires will be skipped. Entries are accepted as soon as any button is pressed that doesn't correspond -with the reverse search. Cancelling is possible by pressing `escape` or -` + C`. +with the reverse search. Cancelling is possible by pressing **Esc** or +**Ctrl+C**. Changing the direction immediately searches for the next entry in the expected direction from the current position on. @@ -282,7 +282,7 @@ repl.start({ prompt: '> ', eval: myEval }); #### Recoverable errors -As a user is typing input into the REPL prompt, pressing the `` key will +As a user is typing input into the REPL prompt, pressing **Enter** will send the current line of input to the `eval` function. In order to support multi-line input, the eval function can return an instance of `repl.Recoverable` to the provided callback function: @@ -379,8 +379,8 @@ added: v0.7.7 --> The `'exit'` event is emitted when the REPL is exited either by receiving the -`.exit` command as input, the user pressing `-C` twice to signal `SIGINT`, -or by pressing `-D` to signal `'end'` on the input stream. The listener +`.exit` command as input, the user pressing **Ctrl+C** twice to signal `SIGINT`, +or by pressing **Ctrl+D** to signal `'end'` on the input stream. The listener callback is invoked without any arguments. ```js diff --git a/lib/repl.js b/lib/repl.js index b13fece0713701..d178dbcefea43b 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -750,7 +750,9 @@ function REPLServer(prompt, sawSIGINT = false; return; } - self.output.write('(To exit, press ^C again or ^D or type .exit)\n'); + self.output.write( + '(To exit, press Ctrl+C again or Ctrl+D or type .exit)\n' + ); sawSIGINT = true; } else { sawSIGINT = false; @@ -815,7 +817,7 @@ function REPLServer(prompt, if (e && !self[kBufferedCommandSymbol] && cmd.trim().startsWith('npm ')) { self.output.write('npm should be run outside of the ' + 'Node.js REPL, in your normal shell.\n' + - '(Press Control-D to exit.)\n'); + '(Press Ctrl+D to exit.)\n'); self.displayPrompt(); return; } @@ -860,7 +862,7 @@ function REPLServer(prompt, if (self.editorMode) { self.output.write(`${self._initialPrompt}.editor\n`); self.output.write( - '// Entering editor mode (^D to finish, ^C to cancel)\n'); + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n'); self.output.write(`${self[kBufferedCommandSymbol]}\n`); self.prompt(true); } else { @@ -1542,8 +1544,8 @@ function defineDefaultCommands(repl) { const line = `.${name}${cmd.help ? spaces + cmd.help : ''}\n`; this.output.write(line); } - this.output.write('\nPress ^C to abort current expression, ' + - '^D to exit the REPL\n'); + this.output.write('\nPress Ctrl+C to abort current expression, ' + + 'Ctrl+D to exit the REPL\n'); this.displayPrompt(); } }); @@ -1589,7 +1591,7 @@ function defineDefaultCommands(repl) { action() { _turnOnEditorMode(this); this.output.write( - '// Entering editor mode (^D to finish, ^C to cancel)\n'); + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n'); } }); } diff --git a/test/parallel/test-repl-editor.js b/test/parallel/test-repl-editor.js index 41685f06e72c06..783d303b3aaf16 100644 --- a/test/parallel/test-repl-editor.js +++ b/test/parallel/test-repl-editor.js @@ -19,9 +19,10 @@ function run({ input, output, event, checkTerminalCodes = true }) { stream.write = (msg) => found += msg.replace('\r', ''); - let expected = `${terminalCode}.editor\n` + - '// Entering editor mode (^D to finish, ^C to cancel)\n' + - `${input}${output}\n${terminalCode}`; + let expected = + `${terminalCode}.editor\n` + + '// Entering editor mode (Ctrl+D to finish, Ctrl+C to cancel)\n' + + `${input}${output}\n${terminalCode}`; const replServer = repl.start({ prompt: '> ', @@ -47,7 +48,7 @@ function run({ input, output, event, checkTerminalCodes = true }) { const tests = [ { input: '', - output: '\n(To exit, press ^C again or ^D or type .exit)', + output: '\n(To exit, press Ctrl+C again or Ctrl+D or type .exit)', event: { ctrl: true, name: 'c' } }, { diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 8e3d1173b51131..e200ebbaeee4ea 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -373,7 +373,7 @@ const errorTests = [ send: 'npm install foobar', expect: [ 'npm should be run outside of the Node.js REPL, in your normal shell.', - '(Press Control-D to exit.)' + '(Press Ctrl+D to exit.)' ] }, { @@ -453,7 +453,7 @@ const errorTests = [ /\.load/, /\.save/, '', - 'Press ^C to abort current expression, ^D to exit the REPL', + 'Press Ctrl+C to abort current expression, Ctrl+D to exit the REPL', /'thefourtheye'/ ] }, From 010173a4b7e1df3b66308ee6b417960b88212c6a Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 26 Sep 2020 06:29:41 -0700 Subject: [PATCH 34/42] doc: edit n-api.md for minor improvements Not a comprehensive edit. Just a few things I noticed. * Favor present tense where there's a choice * Added a comma for clarity * Added a missing word ("in") PR-URL: https://github.com/nodejs/node/pull/35361 Reviewed-By: Chengzhong Wu Reviewed-By: Luigi Pinca Reviewed-By: Anna Henningsen --- doc/api/n-api.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 4306cf8a55d6d0..49e3986b418657 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -1526,11 +1526,11 @@ for a reference is 0, all subsequent calls to get the object associated with the reference [`napi_get_reference_value`][] will return `NULL` for the returned `napi_value`. An attempt to call [`napi_reference_ref`][] for a reference whose object has been collected -will result in an error. +results in an error. References must be deleted once they are no longer required by the addon. When -a reference is deleted it will no longer prevent the corresponding object from -being collected. Failure to delete a persistent reference will result in +a reference is deleted, it will no longer prevent the corresponding object from +being collected. Failure to delete a persistent reference results in a 'memory leak' with both the native memory for the persistent reference and the corresponding object on the heap being retained forever. @@ -3089,7 +3089,7 @@ napi_status napi_get_value_string_latin1(napi_env env, passed in, the length of the string in bytes and excluding the null terminator is returned in `result`. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated and null-terminated. + insufficient, the returned string is truncated and null-terminated. * `[out] result`: Number of bytes copied into the buffer, excluding the null terminator. @@ -3119,7 +3119,7 @@ napi_status napi_get_value_string_utf8(napi_env env, in, the length of the string in bytes and excluding the null terminator is returned in `result`. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated and null-terminated. + insufficient, the returned string is truncated and null-terminated. * `[out] result`: Number of bytes copied into the buffer, excluding the null terminator. @@ -3148,7 +3148,7 @@ napi_status napi_get_value_string_utf16(napi_env env, passed in, the length of the string in 2-byte code units and excluding the null terminator is returned. * `[in] bufsize`: Size of the destination buffer. When this value is - insufficient, the returned string will be truncated and null-terminated. + insufficient, the returned string is truncated and null-terminated. * `[out] result`: Number of 2-byte code units copied into the buffer, excluding the null terminator. @@ -5137,8 +5137,8 @@ napi_status napi_async_init(napi_env env, * `[in] async_resource`: Object associated with the async work that will be passed to possible `async_hooks` [`init` hooks][]. In order to retain ABI compatibility with previous versions, - passing `NULL` for `async_resource` will not result in an error, however, - this will result incorrect operation of async hooks for the + passing `NULL` for `async_resource` does not result in an error. However, + this results in incorrect operation of async hooks for the napi_async_context created. Potential issues include loss of async context when using the AsyncLocalStorage API. * `[in] async_resource_name`: Identifier for the kind of resource @@ -5190,7 +5190,7 @@ NAPI_EXTERN napi_status napi_make_callback(napi_env env, invoking the callback. This should normally be a value previously obtained from [`napi_async_init`][]. In order to retain ABI compatibility with previous versions, passing `NULL` - for `async_context` will not result in an error. However, this will result + for `async_context` does not result in an error. However, this results in incorrect operation of async hooks. Potential issues include loss of async context when using the `AsyncLocalStorage` API. * `[in] recv`: The `this` object passed to the called function. From f551f52f83b2349258167ceba6c49cc8bec8d2d1 Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Thu, 14 May 2020 22:40:37 -0700 Subject: [PATCH 35/42] module: named exports for CJS via static analysis MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/35249 Reviewed-By: Mary Marchini Reviewed-By: Geoffrey Booth Reviewed-By: Matteo Collina Reviewed-By: Myles Borins Reviewed-By: Michaël Zasso Reviewed-By: Zeyu Yang Reviewed-By: Richard Lau --- LICENSE | 14 + deps/cjs-module-lexer/.gitignore | 11 + deps/cjs-module-lexer/LICENSE | 10 + deps/cjs-module-lexer/README.md | 331 ++++++ deps/cjs-module-lexer/lexer.js | 1152 +++++++++++++++++++ deps/cjs-module-lexer/package.json | 41 + doc/api/esm.md | 123 +- lib/internal/modules/cjs/loader.js | 39 +- lib/internal/modules/esm/module_job.js | 27 +- lib/internal/modules/esm/translators.js | 101 +- node.gyp | 1 + src/node_native_module.cc | 6 +- test/es-module/test-esm-cjs-exports.js | 21 + test/es-module/test-esm-cjs-named-error.mjs | 42 +- test/fixtures/es-modules/cjs-exports.mjs | 34 + test/fixtures/es-modules/exports-cases.js | 7 + test/fixtures/es-modules/exports-cases2.js | 29 + test/fixtures/es-modules/exports-cases3.js | 25 + test/parallel/test-bootstrap-modules.js | 1 + tools/license-builder.sh | 1 + 20 files changed, 1929 insertions(+), 87 deletions(-) create mode 100755 deps/cjs-module-lexer/.gitignore create mode 100755 deps/cjs-module-lexer/LICENSE create mode 100755 deps/cjs-module-lexer/README.md create mode 100755 deps/cjs-module-lexer/lexer.js create mode 100755 deps/cjs-module-lexer/package.json create mode 100644 test/es-module/test-esm-cjs-exports.js create mode 100644 test/fixtures/es-modules/cjs-exports.mjs create mode 100644 test/fixtures/es-modules/exports-cases.js create mode 100644 test/fixtures/es-modules/exports-cases2.js create mode 100644 test/fixtures/es-modules/exports-cases3.js diff --git a/LICENSE b/LICENSE index 0443d15f3c60c2..1f20a4a22cab15 100644 --- a/LICENSE +++ b/LICENSE @@ -114,6 +114,20 @@ The externally maintained libraries used by Node.js are: purpose. It is provided "as is" without express or implied warranty. """ +- cjs-module-lexer, located at deps/cjs-module-lexer, is licensed as follows: + """ + MIT License + ----------- + + Copyright (C) 2018-2020 Guy Bedford + + 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. + """ + - ICU, located at deps/icu-small, is licensed as follows: """ COPYRIGHT AND PERMISSION NOTICE (ICU 58 and later) diff --git a/deps/cjs-module-lexer/.gitignore b/deps/cjs-module-lexer/.gitignore new file mode 100755 index 00000000000000..55ee2f0d6cfb5d --- /dev/null +++ b/deps/cjs-module-lexer/.gitignore @@ -0,0 +1,11 @@ +node_modules +*.lock +test +.* +Makefile +bench +build.js +include-wasm +include +lib +src diff --git a/deps/cjs-module-lexer/LICENSE b/deps/cjs-module-lexer/LICENSE new file mode 100755 index 00000000000000..935b357962d08b --- /dev/null +++ b/deps/cjs-module-lexer/LICENSE @@ -0,0 +1,10 @@ +MIT License +----------- + +Copyright (C) 2018-2020 Guy Bedford + +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. diff --git a/deps/cjs-module-lexer/README.md b/deps/cjs-module-lexer/README.md new file mode 100755 index 00000000000000..726dd407769398 --- /dev/null +++ b/deps/cjs-module-lexer/README.md @@ -0,0 +1,331 @@ +# CJS Module Lexer + +[![Build Status][travis-image]][travis-url] + +A [very fast](#benchmarks) JS CommonJS module syntax lexer used to detect the most likely list of named exports of a CommonJS module. + +Outputs the list of named exports (`exports.name = ...`) and possible module reexports (`module.exports = require('...')`), including the common transpiler variations of these cases. + +Forked from https://github.com/guybedford/es-module-lexer. + +_Comprehensively handles the JS language grammar while remaining small and fast. - ~90ms per MB of JS cold and ~15ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._ + +### Usage + +``` +npm install cjs-module-lexer +``` + +For use in CommonJS: + +```js +const parse = require('cjs-module-lexer'); + +const { exports, reexports } = parse(` + // named exports detection + module.exports.a = 'a'; + (function () { + exports.b = 'b'; + })(); + Object.defineProperty(exports, 'c', { value: 'c' }); + /* exports.d = 'not detected'; */ + + // reexports detection + if (maybe) module.exports = require('./dep1.js'); + if (another) module.exports = require('./dep2.js'); + + // literal exports assignments + module.exports = { a, b: c, d, 'e': f } + + // __esModule detection + Object.defineProperty(module.exports, '__esModule', { value: true }) +`); + +// exports === ['a', 'b', 'c', '__esModule'] +// reexports === ['./dep1.js', './dep2.js'] +``` + +When using the ESM version, Wasm is supported instead: + +```js +import { parse, init } from 'cjs-module-lexer'; +// init needs to be called and waited upon +await init(); +const { exports, reexports } = parse(source); +``` + +The Wasm build is around 1.5x faster and without a cold start. + +### Grammar + +CommonJS exports matches are run against the source token stream. + +The token grammar is: + +``` +IDENTIFIER: As defined by ECMA-262, without support for identifier `\` escapes, filtered to remove strict reserved words: + "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield", "enum" + +STRING_LITERAL: A `"` or `'` bounded ECMA-262 string literal. + +IDENTIFIER_STRING: ( `"` IDENTIFIER `"` | `'` IDENTIFIER `'` ) + +COMMENT_SPACE: Any ECMA-262 whitespace, ECMA-262 block comment or ECMA-262 line comment + +MODULE_EXPORTS: `module` COMMENT_SPACE `.` COMMENT_SPACE `exports` + +EXPORTS_IDENTIFIER: MODULE_EXPORTS_IDENTIFIER | `exports` + +EXPORTS_DOT_ASSIGN: EXPORTS_IDENTIFIER COMMENT_SPACE `.` COMMENT_SPACE IDENTIFIER COMMENT_SPACE `=` + +EXPORTS_LITERAL_COMPUTED_ASSIGN: EXPORTS_IDENTIFIER COMMENT_SPACE `[` COMMENT_SPACE IDENTIFIER_STRING COMMENT_SPACE `]` COMMENT_SPACE `=` + +EXPORTS_LITERAL_PROP: (IDENTIFIER (COMMENT_SPACE `:` COMMENT_SPACE IDENTIFIER)?) | (IDENTIFIER_STRING COMMENT_SPACE `:` COMMENT_SPACE IDENTIFIER) + +EXPORTS_MEMBER: EXPORTS_DOT_ASSIGN | EXPORTS_LITERAL_COMPUTED_ASSIGN + +EXPORTS_DEFINE: `Object` COMMENT_SPACE `.` COMMENT_SPACE `defineProperty COMMENT_SPACE `(` EXPORTS_IDENTIFIER COMMENT_SPACE `,` COMMENT_SPACE IDENTIFIER_STRING + +EXPORTS_LITERAL: MODULE_EXPORTS COMMENT_SPACE `=` COMMENT_SPACE `{` COMMENT_SPACE (EXPORTS_LITERAL_PROP COMMENT_SPACE `,` COMMENT_SPACE)+ `}` + +REQUIRE: `require` COMMENT_SPACE `(` COMMENT_SPACE STRING_LITERAL COMMENT_SPACE `)` + +EXPORTS_ASSIGN: (`var` | `const` | `let`) IDENTIFIER `=` REQUIRE + +MODULE_EXPORTS_ASSIGN: MODULE_EXPORTS COMMENT_SPACE `=` COMMENT_SPACE REQUIRE + +EXPORT_STAR: (`__export` | `__exportStar`) `(` REQUIRE + +EXPORT_STAR_LIB: `Object.keys(` IDENTIFIER$1 `).forEach(function (` IDENTIFIER$2 `) {` + ( + `if (` IDENTIFIER$2 `===` ( `'default'` | `"default"` ) `||` IDENTIFIER$2 `===` ( '__esModule' | `"__esModule"` ) `) return` `;`? | + `if (` IDENTIFIER$2 `!==` ( `'default'` | `"default"` ) `)` + ) + ( + EXPORTS_IDENTIFIER `[` IDENTIFIER$2 `] =` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? | + `Object.defineProperty(` EXPORTS_IDENTIFIER `, ` IDENTIFIER$2 `, { enumerable: true, get: function () { return ` IDENTIFIER$1 `[` IDENTIFIER$2 `]` `;`? } })` `;`? + ) + `})` +``` + +* The returned export names are the matched `IDENTIFIER` and `IDENTIFIER_STRING` slots for all `EXPORTS_MEMBER`, `EXPORTS_DEFINE` and `EXPORTS_LITERAL` matches. +* The reexport specifiers are taken to be the `STRING_LITERAL` slots of all `MODULE_EXPORTS_ASSIGN` as well as all _top-level_ `EXPORT_STAR` `REQUIRE` matches and `EXPORTS_ASSIGN` matches whose `IDENTIFIER` also matches the first `IDENTIFIER` in `EXPORT_STAR_LIB`. + +### Parsing Examples + +#### Named Exports Parsing + +The basic matching rules for named exports are `exports.name`, `exports['name']` or `Object.defineProperty(exports, 'name', ...)`. This matching is done without scope analysis and regardless of the expression position: + +```js +// DETECTS EXPORTS: a, b, c +(function (exports) { + exports.a = 'a'; + exports['b'] = 'b'; + Object.defineProperty(exports, 'c', { value: 'c' }); +})(exports); +``` + +Because there is no scope analysis, the above detection may overclassify: + +```js +// DETECTS EXPORTS: a, b, c +(function (exports, Object) { + exports.a = 'a'; + exports['b'] = 'b'; + if (false) + Object.defineProperty(exports, 'c', { value: 'c' }); +})(NOT_EXPORTS, NOT_OBJECT); +``` + +It will in turn underclassify in cases where the identifiers are renamed: + +```js +// DETECTS: NO EXPORTS +(function (e, defineProperty) { + e.a = 'a'; + e['b'] = 'b'; + defineProperty(e, 'c', { value: 'c' }); +})(exports, defineProperty); +``` + +#### Exports Object Assignment + +A best-effort is made to detect `module.exports` object assignments, but because this is not a full parser, arbitrary expressions are not handled in the +object parsing process. + +Simple object definitions are supported: + +```js +// DETECTS EXPORTS: a, b, c +module.exports = { + a, + b: 'c', + c: c +}; +``` + +Object properties that are not identifiers or string expressions will bail out of the object detection: + +```js +// DETECTS EXPORTS: a, b +module.exports = { + a, + b: require('c'), + c: "not detected since require('c') above bails the object detection" +} +``` + +`Object.defineProperties` is not currently supported either. + +#### module.exports reexport assignment + +Any `module.exports = require('mod')` assignment is detected as a reexport: + +```js +// DETECTS REEXPORTS: a, b, c +module.exports = require('a'); +(module => module.exports = require('b'))(NOT_MODULE); +if (false) module.exports = require('c'); +``` + +As a result, the total list of exports would be inferred as the union of all of these reexported modules, which can lead to possible over-classification. + +#### Transpiler Re-exports + +For named exports, transpiler output works well with the rules described above. + +But for star re-exports, special care is taken to support common patterns of transpiler outputs from Babel and TypeScript as well as bundlers like RollupJS. +These reexport and star reexport patterns are restricted to only be detected at the top-level as provided by the direct output of these tools. + +For example, `export * from 'external'` is output by Babel as: + +```js +"use strict"; + +exports.__esModule = true; + +var _external = require("external"); + +Object.keys(_external).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + exports[key] = _external[key]; +}); +``` + +Where the `var _external = require("external")` is specifically detected as well as the `Object.keys(_external)` statement, down to the exact +for of that entire expression including minor variations of the output. The `_external` and `key` identifiers are carefully matched in this +detection. + +Similarly for TypeScript, `export * from 'external'` is output as: + +```js +"use strict"; +function __export(m) { + for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p]; +} +Object.defineProperty(exports, "__esModule", { value: true }); +__export(require("external")); +``` + +Where the `__export(require("external"))` statement is explicitly detected as a reexport, including variations `tslib.__export` and `__exportStar`. + +### Environment Support + +Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm). + +### JS Grammar Support + +* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators. +* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking. +* Always correctly parses valid JS source, but may parse invalid JS source without errors. + +### Benchmarks + +Benchmarks can be run with `npm run bench`. + +Current results: + +JS Build: + +``` +Module load time +> 2ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 333ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 16.48ms +test/samples/angular.min.js (303 KiB) +> 5.36ms +test/samples/d3.js (553 KiB) +> 8.32ms +test/samples/d3.min.js (250 KiB) +> 4.28ms +test/samples/magic-string.js (34 KiB) +> 1ms +test/samples/magic-string.min.js (20 KiB) +> 0.36ms +test/samples/rollup.js (698 KiB) +> 10.48ms +test/samples/rollup.min.js (367 KiB) +> 6.64ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 49.28ms +``` + +Wasm Build: +``` +Module load time +> 11ms +Cold Run, All Samples +test/samples/*.js (3635 KiB) +> 48ms + +Warm Runs (average of 25 runs) +test/samples/angular.js (1410 KiB) +> 12.32ms +test/samples/angular.min.js (303 KiB) +> 3.76ms +test/samples/d3.js (553 KiB) +> 6.08ms +test/samples/d3.min.js (250 KiB) +> 3ms +test/samples/magic-string.js (34 KiB) +> 0.24ms +test/samples/magic-string.min.js (20 KiB) +> 0ms +test/samples/rollup.js (698 KiB) +> 7.2ms +test/samples/rollup.min.js (367 KiB) +> 4.2ms + +Warm Runs, All Samples (average of 25 runs) +test/samples/*.js (3635 KiB) +> 33.6ms +``` + +### Wasm Build Steps + +To build download the WASI SDK from https://github.com/CraneStation/wasi-sdk/releases. + +The Makefile assumes the existence of "wasi-sdk-10.0", "binaryen" and "wabt" (both optional) as sibling folders to this project. + +The build through the Makefile is then run via `make lib/lexer.wasm`, which can also be triggered via `npm run build-wasm` to create `dist/lexer.js`. + +On Windows it may be preferable to use the Linux subsystem. + +After the Web Assembly build, the CJS build can be triggered via `npm run build`. + +Optimization passes are run with [Binaryen](https://github.com/WebAssembly/binaryen) prior to publish to reduce the Web Assembly footprint. + +### License + +MIT + +[travis-url]: https://travis-ci.org/guybedford/es-module-lexer +[travis-image]: https://travis-ci.org/guybedford/es-module-lexer.svg?branch=master diff --git a/deps/cjs-module-lexer/lexer.js b/deps/cjs-module-lexer/lexer.js new file mode 100755 index 00000000000000..6a9eef9edd7c21 --- /dev/null +++ b/deps/cjs-module-lexer/lexer.js @@ -0,0 +1,1152 @@ +let source, pos, end; +let openTokenDepth, + templateDepth, + lastTokenPos, + lastSlashWasDivision, + templateStack, + templateStackDepth, + openTokenPosStack, + openClassPosStack, + nextBraceIsClass, + starExportMap, + lastStarExportSpecifier, + _exports, + reexports; + +function resetState () { + openTokenDepth = 0; + templateDepth = -1; + lastTokenPos = -1; + lastSlashWasDivision = false; + templateStack = new Array(1024); + templateStackDepth = 0; + openTokenPosStack = new Array(1024); + openClassPosStack = new Array(1024); + nextBraceIsClass = false; + starExportMap = Object.create(null); + lastStarExportSpecifier = null; + + _exports = new Set(); + reexports = new Set(); +} + +const strictReserved = new Set(['implements', 'interface', 'let', 'package', 'private', 'protected', 'public', 'static', 'yield', 'enum']); + +module.exports = function parseCJS (source, name = '@') { + resetState(); + try { + parseSource(source); + } + catch (e) { + e.message += `\n at ${name}:${source.slice(0, pos).split('\n').length}:${pos - source.lastIndexOf('\n', pos - 1)}`; + e.loc = pos; + throw e; + } + const result = { exports: [..._exports], reexports: [...reexports] }; + resetState(); + return result; +} + +function addExport (name) { + if (!strictReserved.has(name)) + _exports.add(name); +} + +function parseSource (cjsSource) { + source = cjsSource; + pos = -1; + end = source.length - 1; + let ch = 0; + + // Handle #! + if (source.charCodeAt(0) === 35/*#*/ && source.charCodeAt(1) === 33/*!*/) { + if (source.length === 2) + return true; + pos += 2; + while (pos++ < end) { + ch = source.charCodeAt(pos); + if (ch === 10/*\n*/ || ch === 13/*\r*/) + break; + } + } + + while (pos++ < end) { + ch = source.charCodeAt(pos); + + if (ch === 32 || ch < 14 && ch > 8) + continue; + + if (openTokenDepth === 0) { + switch (ch) { + case 105/*i*/: + if (source.slice(pos + 1, pos + 6) === 'mport' && keywordStart(pos)) + throwIfImportStatement(); + lastTokenPos = pos; + continue; + case 114/*r*/: + const startPos = pos; + if (tryParseRequire(false) && keywordStart(startPos)) + tryBacktrackAddStarExportBinding(startPos - 1); + lastTokenPos = pos; + continue; + case 95/*_*/: + if (source.slice(pos + 1, pos + 8) === '_export' && (keywordStart(pos) || source.charCodeAt(pos - 1) === 46/*.*/)) { + pos += 8; + if (source.slice(pos, pos + 4) === 'Star') + pos += 4; + if (source.charCodeAt(pos) === 40/*(*/) { + openTokenPosStack[openTokenDepth++] = lastTokenPos; + if (source.charCodeAt(++pos) === 114/*r*/) + tryParseRequire(true); + } + } + lastTokenPos = pos; + continue; + } + } + + switch (ch) { + case 101/*e*/: + if (source.slice(pos + 1, pos + 6) === 'xport' && keywordStart(pos)) { + if (source.charCodeAt(pos + 6) === 115/*s*/) + tryParseExportsDotAssign(false); + else if (openTokenDepth === 0) + throwIfExportStatement(); + } + break; + case 99/*c*/: + if (keywordStart(pos) && source.slice(pos + 1, pos + 5) === 'lass' && isBrOrWs(source.charCodeAt(pos + 5))) + nextBraceIsClass = true; + break; + case 109/*m*/: + if (source.slice(pos + 1, pos + 6) === 'odule' && keywordStart(pos)) + tryParseModuleExportsDotAssign(); + break; + case 79/*O*/: + if (source.slice(pos + 1, pos + 6) === 'bject' && keywordStart(pos)) + tryParseObjectDefineOrKeys(openTokenDepth === 0); + break; + case 40/*(*/: + openTokenPosStack[openTokenDepth++] = lastTokenPos; + break; + case 41/*)*/: + if (openTokenDepth === 0) + throw new Error('Unexpected closing bracket.'); + openTokenDepth--; + break; + case 123/*{*/: + openClassPosStack[openTokenDepth] = nextBraceIsClass; + nextBraceIsClass = false; + openTokenPosStack[openTokenDepth++] = lastTokenPos; + break; + case 125/*}*/: + if (openTokenDepth === 0) + throw new Error('Unexpected closing brace.'); + if (openTokenDepth-- === templateDepth) { + templateDepth = templateStack[--templateStackDepth]; + templateString(); + } + else { + if (templateDepth !== -1 && openTokenDepth < templateDepth) + throw new Error('Unexpected closing brace.'); + } + break; + case 60/*>*/: + // TODO: ```js -import packageMain from 'commonjs-package'; // Works +import { default as cjs } from 'cjs'; -import { method } from 'commonjs-package'; // Errors +// The following import statement is "syntax sugar" (equivalent but sweeter) +// for `{ default as cjsSugar }` in the above import statement: +import cjsSugar from 'cjs'; + +console.log(cjs); +console.log(cjs === cjsSugar); +// Prints: +// +// true ``` -It is also possible to -[import an ES or CommonJS module for its side effects only][]. +The ECMAScript Module Namespace representation of a CommonJS module will always +be a namespace with a `default` export key pointing to the CommonJS +`module.exports` value. -### `import()` expressions +This Module Namespace Exotic Object can be directly observed either when using +`import * as m from 'cjs'` or a dynamic import: -[Dynamic `import()`][] is supported in both CommonJS and ES modules. It can be -used to include ES module files from CommonJS code. + +```js +import * as m from 'cjs'; +console.log(m); +console.log(m === await import('cjs')); +// Prints: +// [Module] { default: } +// true +``` -## CommonJS, JSON, and native modules +For better compatibility with existing usage in the JS ecosystem, Node.js will +in addition attempt to determine the CommonJS named exports of every imported +CommonJS module to provide them as separate ES module exports using a static +analysis process. -CommonJS, JSON, and native modules can be used with -[`module.createRequire()`][]. +For example, a CommonJS module written: ```js // cjs.cjs -module.exports = 'cjs'; +exports.name = 'exported'; +``` -// esm.mjs -import { createRequire } from 'module'; +will support named imports in ES modules: -const require = createRequire(import.meta.url); + +```js +import { name } from './cjs.cjs'; +console.log(name); +// Prints: 'exported' -const cjs = require('./cjs.cjs'); -cjs === 'cjs'; // true +import cjs from './cjs.cjs'; +console.log(cjs); +// Prints: { name: 'exported' } + +import * as m from './cjs.cjs'; +console.log(m); +// Prints: [Module] { default: { name: 'exported' }, name: 'exported' } ``` +As can be seen from the last example of the Module Namespace Exotic Object being +logged, the `name` export is copied off of the `module.exports` object and set +directly on the ES module namespace when the module is imported. + +Live binding updates or new exports added to `module.exports` are not detected +for these named exports. + +The detection of named exports is based on common syntax patterns but will not +always correctly detect named exports, in these cases using the default +import form described above can be a better option. + +Named exports detection covers many common export patterns, reexport patterns +and build tool and transpiler outputs. See [cjs-module-lexer][] for the exact +semantics implemented. + ## Builtin modules [Core modules][] will provide named exports of their public API. A @@ -330,6 +390,24 @@ syncBuiltinESMExports(); fs.readFileSync === readFileSync; ``` +## CommonJS, JSON, and native modules + +CommonJS, JSON, and native modules can be used with +[`module.createRequire()`][]. + +```js +// cjs.cjs +module.exports = 'cjs'; + +// esm.mjs +import { createRequire } from 'module'; + +const require = createRequire(import.meta.url); + +const cjs = require('./cjs.cjs'); +cjs === 'cjs'; // true +``` + ## Experimental JSON modules Currently importing JSON modules are only supported in the `commonjs` mode @@ -1150,6 +1228,7 @@ $ node --experimental-specifier-resolution=node index success! ``` + [CommonJS]: modules.html [Conditional exports]: packages.html#packages_conditional_exports [Dynamic `import()`]: https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Dynamic_Imports @@ -1173,7 +1252,7 @@ success! [`TypedArray`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray [`Uint8Array`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array [`util.TextDecoder`]: util.html#util_class_util_textdecoder -[import an ES or CommonJS module for its side effects only]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Import_a_module_for_its_side_effects_only +[cjs-module-lexer]: https://github.com/guybedford/cjs-module-lexer/tree/0.3.1 [special scheme]: https://url.spec.whatwg.org/#special-scheme [the official standard format]: https://tc39.github.io/ecma262/#sec-modules [transpiler loader example]: #esm_transpiler_loader diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 99e0bdc5084ee8..17ee0324225393 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -21,12 +21,6 @@ 'use strict'; -// Set first due to cycle with ESM loader functions. -module.exports = { - wrapSafe, Module, toRealPath, readPackageScope, - get hasLoadedAnyUserCJSModule() { return hasLoadedAnyUserCJSModule; } -}; - const { ArrayIsArray, ArrayPrototypeJoin, @@ -44,6 +38,7 @@ const { ReflectSet, RegExpPrototypeTest, SafeMap, + SafeWeakMap, String, StringPrototypeEndsWith, StringPrototypeLastIndexOf, @@ -53,6 +48,15 @@ const { StringPrototypeStartsWith, } = primordials; +// Map used to store CJS parsing data. +const cjsParseCache = new SafeWeakMap(); + +// Set first due to cycle with ESM loader functions. +module.exports = { + wrapSafe, Module, toRealPath, readPackageScope, cjsParseCache, + get hasLoadedAnyUserCJSModule() { return hasLoadedAnyUserCJSModule; } +}; + const { NativeModule } = require('internal/bootstrap/loaders'); const { maybeCacheSourceMap, @@ -745,16 +749,21 @@ Module._load = function(request, parent, isMain) { const cachedModule = Module._cache[filename]; if (cachedModule !== undefined) { updateChildren(parent, cachedModule, true); - if (!cachedModule.loaded) - return getExportsForCircularRequire(cachedModule); - return cachedModule.exports; + if (!cachedModule.loaded) { + const parseCachedModule = cjsParseCache.get(cachedModule); + if (!parseCachedModule || parseCachedModule.loaded) + return getExportsForCircularRequire(cachedModule); + parseCachedModule.loaded = true; + } else { + return cachedModule.exports; + } } const mod = loadNativeModule(filename, request); if (mod && mod.canBeRequiredByUsers) return mod.exports; // Don't call updateChildren(), Module constructor already does. - const module = new Module(filename, parent); + const module = cachedModule || new Module(filename, parent); if (isMain) { process.mainModule = module; @@ -1093,7 +1102,15 @@ Module._extensions['.js'] = function(module, filename) { throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath); } } - const content = fs.readFileSync(filename, 'utf8'); + // If already analyzed the source, then it will be cached. + const cached = cjsParseCache.get(module); + let content; + if (cached && cached.source) { + content = cached.source; + cached.source = undefined; + } else { + content = fs.readFileSync(filename, 'utf8'); + } module._compile(content, filename); }; diff --git a/lib/internal/modules/esm/module_job.js b/lib/internal/modules/esm/module_job.js index dedfc54e7f3845..7b8f146771c530 100644 --- a/lib/internal/modules/esm/module_job.js +++ b/lib/internal/modules/esm/module_job.js @@ -103,28 +103,27 @@ class ModuleJob { ' does not provide an export named')) { const splitStack = StringPrototypeSplit(e.stack, '\n'); const parentFileUrl = splitStack[0]; - const childSpecifier = StringPrototypeMatch(e.message, /module '(.*)' does/)[1]; + const [, childSpecifier, name] = StringPrototypeMatch(e.message, + /module '(.*)' does not provide an export named '(.+)'/); const childFileURL = - await this.loader.resolve(childSpecifier, parentFileUrl); + await this.loader.resolve(childSpecifier, parentFileUrl); const format = await this.loader.getFormat(childFileURL); if (format === 'commonjs') { - e.message = `The requested module '${childSpecifier}' is expected ` + - 'to be of type CommonJS, which does not support named exports. ' + - 'CommonJS modules can be imported by importing the default ' + - 'export.'; + const importStatement = splitStack[1]; // TODO(@ctavan): The original error stack only provides the single // line which causes the error. For multi-line import statements we // cannot generate an equivalent object descructuring assignment by // just parsing the error stack. - const importStatement = splitStack[1]; const oneLineNamedImports = StringPrototypeMatch(importStatement, /{.*}/); - if (oneLineNamedImports) { - const destructuringAssignment = - StringPrototypeReplace(oneLineNamedImports[0], /\s+as\s+/g, ': '); - e.message += '\nFor example:\n' + - `import pkg from '${childSpecifier}';\n` + - `const ${destructuringAssignment} = pkg;`; - } + const destructuringAssignment = oneLineNamedImports && + StringPrototypeReplace(oneLineNamedImports, /\s+as\s+/g, ': '); + e.message = `Named export '${name}' not found. The requested module` + + ` '${childSpecifier}' is a CommonJS module, which may not support` + + ' all module.exports as named exports.\nCommonJS modules can ' + + 'always be imported via the default export, for example using:' + + `\n\nimport pkg from '${childSpecifier}';\n${ + destructuringAssignment ? + `const ${destructuringAssignment} = pkg;\n` : ''}`; const newStack = StringPrototypeSplit(e.stack, '\n'); newStack[3] = `SyntaxError: ${e.message}`; e.stack = ArrayPrototypeJoin(newStack, '\n'); diff --git a/lib/internal/modules/esm/translators.js b/lib/internal/modules/esm/translators.js index bb095446bc27eb..5e4de5d5af0f39 100644 --- a/lib/internal/modules/esm/translators.js +++ b/lib/internal/modules/esm/translators.js @@ -3,11 +3,14 @@ /* global WebAssembly */ const { + Boolean, JSONParse, + ObjectPrototypeHasOwnProperty, ObjectKeys, PromisePrototypeCatch, PromiseReject, SafeMap, + SafeSet, StringPrototypeReplace, } = primordials; @@ -17,11 +20,16 @@ function lazyTypes() { return _TYPES = require('internal/util/types'); } +const { readFileSync } = require('fs'); +const { extname } = require('path'); const { stripBOM, loadNativeModule } = require('internal/modules/cjs/helpers'); -const CJSModule = require('internal/modules/cjs/loader').Module; +const { + Module: CJSModule, + cjsParseCache +} = require('internal/modules/cjs/loader'); const internalURLModule = require('internal/url'); const { defaultGetSource } = require( 'internal/modules/esm/get_source'); @@ -44,12 +52,12 @@ const { ModuleWrap } = moduleWrap; const { getOptionValue } = require('internal/options'); const experimentalImportMetaResolve = getOptionValue('--experimental-import-meta-resolve'); +const asyncESM = require('internal/process/esm_loader'); +const cjsParse = require('internal/deps/cjs-module-lexer/lexer'); const translators = new SafeMap(); exports.translators = translators; -const asyncESM = require('internal/process/esm_loader'); - let DECODER = null; function assertBufferSource(body, allowString, hookName) { if (allowString && typeof body === 'string') { @@ -104,7 +112,7 @@ function initializeImportMeta(meta, { url }) { meta.url = url; } -// Strategy for loading a standard JavaScript module +// Strategy for loading a standard JavaScript module. translators.set('module', async function moduleStrategy(url) { let { source } = await this._getSource( url, { format: 'module' }, defaultGetSource); @@ -125,23 +133,92 @@ translators.set('module', async function moduleStrategy(url) { // Strategy for loading a node-style CommonJS module const isWindows = process.platform === 'win32'; const winSepRegEx = /\//g; -translators.set('commonjs', function commonjsStrategy(url, isMain) { +translators.set('commonjs', async function commonjsStrategy(url, isMain) { debug(`Translating CJSModule ${url}`); - return new ModuleWrap(url, undefined, ['default'], function() { + + let filename = internalURLModule.fileURLToPath(new URL(url)); + if (isWindows) + filename = StringPrototypeReplace(filename, winSepRegEx, '\\'); + + const { module, exportNames } = cjsPreparseModuleExports(filename); + const namesWithDefault = exportNames.has('default') ? + [...exportNames] : ['default', ...exportNames]; + + return new ModuleWrap(url, undefined, namesWithDefault, function() { debug(`Loading CJSModule ${url}`); - const pathname = internalURLModule.fileURLToPath(new URL(url)); + let exports; - const cachedModule = CJSModule._cache[pathname]; - if (cachedModule && asyncESM.ESMLoader.cjsCache.has(cachedModule)) { - exports = asyncESM.ESMLoader.cjsCache.get(cachedModule); - asyncESM.ESMLoader.cjsCache.delete(cachedModule); + if (asyncESM.ESMLoader.cjsCache.has(module)) { + exports = asyncESM.ESMLoader.cjsCache.get(module); + asyncESM.ESMLoader.cjsCache.delete(module); } else { - exports = CJSModule._load(pathname, undefined, isMain); + exports = CJSModule._load(filename, undefined, isMain); + } + + for (const exportName of exportNames) { + if (!ObjectPrototypeHasOwnProperty(exports, exportName) || + exportName === 'default') + continue; + // We might trigger a getter -> dont fail. + let value; + try { + value = exports[exportName]; + } catch {} + this.setExport(exportName, value); } this.setExport('default', exports); }); }); +function cjsPreparseModuleExports(filename) { + let module = CJSModule._cache[filename]; + if (module) { + const cached = cjsParseCache.get(module); + if (cached) + return { module, exportNames: cached.exportNames }; + } + const loaded = Boolean(module); + if (!loaded) { + module = new CJSModule(filename); + module.filename = filename; + module.paths = CJSModule._nodeModulePaths(module.path); + CJSModule._cache[filename] = module; + } + + let source; + try { + source = readFileSync(filename, 'utf8'); + } catch {} + + const { exports, reexports } = cjsParse(source || ''); + + const exportNames = new SafeSet(exports); + + // Set first for cycles. + cjsParseCache.set(module, { source, exportNames, loaded }); + + if (reexports.length) { + module.filename = filename; + module.paths = CJSModule._nodeModulePaths(module.path); + } + for (const reexport of reexports) { + let resolved; + try { + resolved = CJSModule._resolveFilename(reexport, module); + } catch { + continue; + } + const ext = extname(resolved); + if (ext === '.js' || ext === '.cjs' || !CJSModule._extensions[ext]) { + const { exportNames: reexportNames } = cjsPreparseModuleExports(resolved); + for (const name of reexportNames) + exportNames.add(name); + } + } + + return { module, exportNames }; +} + // Strategy for loading a node builtin CommonJS module that isn't // through normal resolution translators.set('builtin', async function builtinStrategy(url) { diff --git a/node.gyp b/node.gyp index 88942393ff3671..03f4db47acf35a 100644 --- a/node.gyp +++ b/node.gyp @@ -252,6 +252,7 @@ 'deps/acorn-plugins/acorn-private-class-elements/index.js', 'deps/acorn-plugins/acorn-private-methods/index.js', 'deps/acorn-plugins/acorn-static-class-features/index.js', + 'deps/cjs-module-lexer/lexer.js', ], 'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)', 'mkcodecache_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkcodecache<(EXECUTABLE_SUFFIX)', diff --git a/src/node_native_module.cc b/src/node_native_module.cc index 74729c412674be..4c3633e06c6026 100644 --- a/src/node_native_module.cc +++ b/src/node_native_module.cc @@ -78,6 +78,9 @@ void NativeModuleLoader::InitializeModuleCategories() { "internal/main/" }; + module_categories_.can_be_required.emplace( + "internal/deps/cjs-module-lexer/lexer"); + module_categories_.cannot_be_required = std::set { #if !HAVE_INSPECTOR "inspector", @@ -115,7 +118,8 @@ void NativeModuleLoader::InitializeModuleCategories() { if (prefix.length() > id.length()) { continue; } - if (id.find(prefix) == 0) { + if (id.find(prefix) == 0 && + module_categories_.can_be_required.count(id) == 0) { module_categories_.cannot_be_required.emplace(id); } } diff --git a/test/es-module/test-esm-cjs-exports.js b/test/es-module/test-esm-cjs-exports.js new file mode 100644 index 00000000000000..37aa70d3880f2b --- /dev/null +++ b/test/es-module/test-esm-cjs-exports.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); +const fixtures = require('../common/fixtures'); +const { spawn } = require('child_process'); +const assert = require('assert'); + +const entry = fixtures.path('/es-modules/cjs-exports.mjs'); + +const child = spawn(process.execPath, [entry]); +child.stderr.setEncoding('utf8'); +let stdout = ''; +child.stdout.setEncoding('utf8'); +child.stdout.on('data', (data) => { + stdout += data; +}); +child.on('close', common.mustCall((code, signal) => { + assert.strictEqual(code, 0); + assert.strictEqual(signal, null); + assert.strictEqual(stdout, 'ok\n'); +})); diff --git a/test/es-module/test-esm-cjs-named-error.mjs b/test/es-module/test-esm-cjs-named-error.mjs index e9ddc67c0fbcea..4ef75a22f92674 100644 --- a/test/es-module/test-esm-cjs-named-error.mjs +++ b/test/es-module/test-esm-cjs-named-error.mjs @@ -3,37 +3,25 @@ import { rejects } from 'assert'; const fixtureBase = '../fixtures/es-modules/package-cjs-named-error'; -const expectedRelative = 'The requested module \'./fail.cjs\' is expected to ' + - 'be of type CommonJS, which does not support named exports. CommonJS ' + - 'modules can be imported by importing the default export.\n' + - 'For example:\n' + - 'import pkg from \'./fail.cjs\';\n' + - 'const { comeOn } = pkg;'; +const errTemplate = (specifier, name, namedImports) => + `Named export '${name}' not found. The requested module` + + ` '${specifier}' is a CommonJS module, which may not support ` + + 'all module.exports as named exports.\nCommonJS modules can ' + + 'always be imported via the default export, for example using:' + + `\n\nimport pkg from '${specifier}';\n` + (namedImports ? + `const ${namedImports} = pkg;\n` : ''); -const expectedWithoutExample = 'The requested module \'./fail.cjs\' is ' + - 'expected to be of type CommonJS, which does not support named exports. ' + - 'CommonJS modules can be imported by importing the default export.'; +const expectedWithoutExample = errTemplate('./fail.cjs', 'comeOn'); -const expectedRenamed = 'The requested module \'./fail.cjs\' is expected to ' + - 'be of type CommonJS, which does not support named exports. CommonJS ' + - 'modules can be imported by importing the default export.\n' + - 'For example:\n' + - 'import pkg from \'./fail.cjs\';\n' + - 'const { comeOn: comeOnRenamed } = pkg;'; +const expectedRelative = errTemplate('./fail.cjs', 'comeOn', '{ comeOn }'); -const expectedPackageHack = 'The requested module \'./json-hack/fail.js\' is ' + - 'expected to be of type CommonJS, which does not support named exports. ' + - 'CommonJS modules can be imported by importing the default export.\n' + - 'For example:\n' + - 'import pkg from \'./json-hack/fail.js\';\n' + - 'const { comeOn } = pkg;'; +const expectedRenamed = errTemplate('./fail.cjs', 'comeOn', + '{ comeOn: comeOnRenamed }'); -const expectedBare = 'The requested module \'deep-fail\' is expected to ' + - 'be of type CommonJS, which does not support named exports. CommonJS ' + - 'modules can be imported by importing the default export.\n' + - 'For example:\n' + - 'import pkg from \'deep-fail\';\n' + - 'const { comeOn } = pkg;'; +const expectedPackageHack = + errTemplate('./json-hack/fail.js', 'comeOn', '{ comeOn }'); + +const expectedBare = errTemplate('deep-fail', 'comeOn', '{ comeOn }'); rejects(async () => { await import(`${fixtureBase}/single-quote.mjs`); diff --git a/test/fixtures/es-modules/cjs-exports.mjs b/test/fixtures/es-modules/cjs-exports.mjs new file mode 100644 index 00000000000000..47bb4926af03aa --- /dev/null +++ b/test/fixtures/es-modules/cjs-exports.mjs @@ -0,0 +1,34 @@ +import { strictEqual, deepEqual } from 'assert'; + +import m, { π, z } from './exports-cases.js'; +import * as ns from './exports-cases.js'; + +deepEqual(Object.keys(ns), ['default', 'isObject', 'z', 'π']); +strictEqual(π, 'yes'); +strictEqual(z, 'yes'); +strictEqual(typeof m.isObject, 'undefined'); +strictEqual(m.π, 'yes'); +strictEqual(m.z, 'yes'); + +import m2, { __esModule as __esModule2, name as name2 } from './exports-cases2.js'; +import * as ns2 from './exports-cases2.js'; + +strictEqual(__esModule2, true); +strictEqual(name2, 'name'); +strictEqual(typeof m2, 'object'); +strictEqual(m2.default, 'the default'); +strictEqual(ns2.__esModule, true); +strictEqual(ns2.name, 'name'); +deepEqual(Object.keys(ns2), ['__esModule', 'case2', 'default', 'name', 'pi']); + +import m3, { __esModule as __esModule3, name as name3 } from './exports-cases3.js'; +import * as ns3 from './exports-cases3.js'; + +strictEqual(__esModule3, true); +strictEqual(name3, 'name'); +deepEqual(Object.keys(m3), ['name', 'default', 'pi', 'case2']); +strictEqual(ns3.__esModule, true); +strictEqual(ns3.name, 'name'); +strictEqual(ns3.case2, 'case2'); + +console.log('ok'); diff --git a/test/fixtures/es-modules/exports-cases.js b/test/fixtures/es-modules/exports-cases.js new file mode 100644 index 00000000000000..eec3d31bc7290c --- /dev/null +++ b/test/fixtures/es-modules/exports-cases.js @@ -0,0 +1,7 @@ +if (global.maybe) + module.exports = require('../is-object'); +exports['invalid identifier'] = 'no'; +module.exports['?invalid'] = 'no'; +module.exports['π'] = 'yes'; +exports.package = 10; // reserved word -> not used +Object.defineProperty(exports, 'z', { value: 'yes' }); diff --git a/test/fixtures/es-modules/exports-cases2.js b/test/fixtures/es-modules/exports-cases2.js new file mode 100644 index 00000000000000..189eebb9f3b1b7 --- /dev/null +++ b/test/fixtures/es-modules/exports-cases2.js @@ -0,0 +1,29 @@ +/* + * Transpiled with Babel from: + * + * export { π as pi } from './exports-cases.js'; + * export default 'the default'; + * export const name = 'name'; + */ + +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "pi", { + enumerable: true, + get: function () { + return _exportsCases.π; + } +}); +exports.name = exports.default = void 0; + +var _exportsCases = require("./exports-cases.js"); + +var _default = 'the default'; +exports.default = _default; +const name = 'name'; +exports.name = name; + +exports.case2 = 'case2'; diff --git a/test/fixtures/es-modules/exports-cases3.js b/test/fixtures/es-modules/exports-cases3.js new file mode 100644 index 00000000000000..c48b78cc4106be --- /dev/null +++ b/test/fixtures/es-modules/exports-cases3.js @@ -0,0 +1,25 @@ +/* + * Transpiled with TypeScript from: + * + * export { π as pi } from './exports-cases.js'; + * export default 'the default'; + * export const name = 'name'; + */ + +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.name = void 0; +exports.default = 'the default'; +exports.name = 'name'; + +var _external = require("./exports-cases2.js"); + +Object.keys(_external).forEach(function (key) { + if (key === "default" || key === "__esModule") return; + Object.defineProperty(exports, key, { + enumerable: true, + get: function () { + return _external[key]; + } + }); +}); \ No newline at end of file diff --git a/test/parallel/test-bootstrap-modules.js b/test/parallel/test-bootstrap-modules.js index f7f1d2583d928c..5bb05d6f209116 100644 --- a/test/parallel/test-bootstrap-modules.js +++ b/test/parallel/test-bootstrap-modules.js @@ -53,6 +53,7 @@ const expectedModules = new Set([ 'NativeModule internal/modules/cjs/helpers', 'NativeModule internal/modules/cjs/loader', 'NativeModule internal/modules/esm/create_dynamic_module', + 'NativeModule internal/deps/cjs-module-lexer/lexer', 'NativeModule internal/modules/esm/get_format', 'NativeModule internal/modules/esm/get_source', 'NativeModule internal/modules/esm/loader', diff --git a/tools/license-builder.sh b/tools/license-builder.sh index 2da5a9954df0cb..50f4474c644441 100755 --- a/tools/license-builder.sh +++ b/tools/license-builder.sh @@ -32,6 +32,7 @@ fi addlicense "Acorn" "deps/acorn" "$(cat ${rootdir}/deps/acorn/acorn/LICENSE)" addlicense "Acorn plugins" "deps/acorn-plugins" "$(cat ${rootdir}/deps/acorn-plugins/acorn-class-fields/LICENSE)" addlicense "c-ares" "deps/cares" "$(tail -n +3 ${rootdir}/deps/cares/LICENSE.md)" +addlicense "cjs-module-lexer" "deps/cjs-module-lexer" "$(cat ${rootdir}/deps/cjs-module-lexer/LICENSE)" if [ -f "${rootdir}/deps/icu/LICENSE" ]; then # ICU 57 and following. Drop the BOM addlicense "ICU" "deps/icu" \ From 80eb22185e726d5a1efbd94da41728f307087310 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Sat, 26 Sep 2020 18:47:09 -0400 Subject: [PATCH 36/42] tools: update ESLint to 7.10.0 Update ESLint to 7.10.0 PR-URL: https://github.com/nodejs/node/pull/35366 Reviewed-By: Rich Trott Reviewed-By: Daijiro Wachi Reviewed-By: Ruben Bridgewater --- tools/node_modules/eslint/README.md | 2 +- .../eslint/lib/rules/no-inline-comments.js | 29 +- .../eslint/lib/rules/prefer-destructuring.js | 2 + .../node_modules/ajv/dist/ajv.bundle.js | 104 +- .../eslint/node_modules/ajv/dist/ajv.min.js | 4 +- .../node_modules/ajv/lib/compile/formats.js | 4 +- .../node_modules/ajv/lib/dot/definitions.def | 3 +- .../node_modules/ajv/lib/dot/validate.jst | 2 +- .../node_modules/ajv/lib/dotjs/allOf.js | 2 +- .../node_modules/ajv/lib/dotjs/anyOf.js | 2 +- .../node_modules/ajv/lib/dotjs/contains.js | 2 +- .../ajv/lib/dotjs/dependencies.js | 2 +- .../eslint/node_modules/ajv/lib/dotjs/if.js | 4 +- .../node_modules/ajv/lib/dotjs/items.js | 6 +- .../eslint/node_modules/ajv/lib/dotjs/not.js | 2 +- .../node_modules/ajv/lib/dotjs/oneOf.js | 2 +- .../node_modules/ajv/lib/dotjs/properties.js | 4 +- .../ajv/lib/dotjs/propertyNames.js | 2 +- .../node_modules/ajv/lib/dotjs/required.js | 2 +- .../node_modules/ajv/lib/dotjs/validate.js | 2 +- .../eslint/node_modules/ajv/package.json | 2 +- .../eslint/node_modules/debug/dist/debug.js | 912 ------------------ .../eslint/node_modules/debug/package.json | 41 +- .../eslint/node_modules/debug/src/browser.js | 15 +- .../eslint/node_modules/debug/src/common.js | 6 +- tools/node_modules/eslint/package.json | 4 +- 26 files changed, 160 insertions(+), 1002 deletions(-) delete mode 100644 tools/node_modules/eslint/node_modules/debug/dist/debug.js diff --git a/tools/node_modules/eslint/README.md b/tools/node_modules/eslint/README.md index 7f0a8cdbacfe53..1f778efdf4b8d1 100644 --- a/tools/node_modules/eslint/README.md +++ b/tools/node_modules/eslint/README.md @@ -251,7 +251,7 @@ The following companies, organizations, and individuals support ESLint's ongoing

Gold Sponsors

Salesforce Airbnb Microsoft FOSS Fund Sponsorships

Silver Sponsors

Liftoff AMP Project

Bronze Sponsors

-

Buy.Fineproxy.Org Veikkaajat.com Nettikasinot.media My True Media Norgekasino Japanesecasino CasinoTop.com Casino Topp Anagram Solver Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Bugsnag Stability Monitoring Mixpanel VPS Server Icons8: free icons, photos, illustrations, and music Discord ThemeIsle Marfeel Fire Stick Tricks

+

2021 calendar Buy.Fineproxy.Org Veikkaajat.com Nettikasinot.media My True Media Norgekasino Japanesecasino CasinoTop.com Casino Topp Anagram Solver Kasinot.fi Pelisivut Nettikasinot.org BonusFinder Deutschland Bugsnag Stability Monitoring Mixpanel VPS Server Icons8: free icons, photos, illustrations, and music Discord ThemeIsle Marfeel Fire Stick Tricks

## Technology Sponsors diff --git a/tools/node_modules/eslint/lib/rules/no-inline-comments.js b/tools/node_modules/eslint/lib/rules/no-inline-comments.js index 41b0f1e664c776..dec278615e2e12 100644 --- a/tools/node_modules/eslint/lib/rules/no-inline-comments.js +++ b/tools/node_modules/eslint/lib/rules/no-inline-comments.js @@ -21,7 +21,17 @@ module.exports = { url: "https://eslint.org/docs/rules/no-inline-comments" }, - schema: [], + schema: [ + { + type: "object", + properties: { + ignorePattern: { + type: "string" + } + }, + additionalProperties: false + } + ], messages: { unexpectedInlineComment: "Unexpected comment inline with code." @@ -30,6 +40,12 @@ module.exports = { create(context) { const sourceCode = context.getSourceCode(); + const options = context.options[0]; + let customIgnoreRegExp; + + if (options && options.ignorePattern) { + customIgnoreRegExp = new RegExp(options.ignorePattern, "u"); + } /** * Will check that comments are not on lines starting with or ending with code @@ -51,6 +67,11 @@ module.exports = { return; } + // Matches the ignore pattern + if (customIgnoreRegExp && customIgnoreRegExp.test(node.value)) { + return; + } + // JSX Exception if ( (isPreambleEmpty || preamble === "{") && @@ -80,9 +101,9 @@ module.exports = { return { Program() { - const comments = sourceCode.getAllComments(); - - comments.filter(token => token.type !== "Shebang").forEach(testCodeAroundComment); + sourceCode.getAllComments() + .filter(token => token.type !== "Shebang") + .forEach(testCodeAroundComment); } }; } diff --git a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js index d3314dc7e0de77..66e412fd3e3922 100644 --- a/tools/node_modules/eslint/lib/rules/prefer-destructuring.js +++ b/tools/node_modules/eslint/lib/rules/prefer-destructuring.js @@ -163,6 +163,8 @@ module.exports = { return node.type === "VariableDeclarator" && node.id.type === "Identifier" && node.init.type === "MemberExpression" && + !node.init.computed && + node.init.property.type === "Identifier" && node.id.name === node.init.property.name; } diff --git a/tools/node_modules/eslint/node_modules/ajv/dist/ajv.bundle.js b/tools/node_modules/eslint/node_modules/ajv/dist/ajv.bundle.js index b640d050a141f6..014fc2620ca2f9 100644 --- a/tools/node_modules/eslint/node_modules/ajv/dist/ajv.bundle.js +++ b/tools/node_modules/eslint/node_modules/ajv/dist/ajv.bundle.js @@ -193,8 +193,8 @@ formats.fast = { time: /^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, 'date-time': /^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, // uri: https://github.com/mafintosh/is-my-json-valid/blob/master/formats.js - uri: /^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i, - 'uri-reference': /^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, + uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i, + 'uri-reference': /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i, 'uri-template': URITEMPLATE, url: URL, // email (sources from jsen validator): @@ -1847,7 +1847,7 @@ module.exports = function generate_allOf(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $allSchemasEmpty = false; $it.schema = $sch; $it.schemaPath = $schemaPath + '[' + $i + ']'; @@ -1890,7 +1890,7 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) { $it.level++; var $nextValid = 'valid' + $it.level; var $noEmptySchema = $schema.every(function($sch) { - return (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)); + return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)); }); if ($noEmptySchema) { var $currentBaseId = $it.baseId; @@ -2043,7 +2043,7 @@ module.exports = function generate_contains(it, $keyword, $ruleType) { $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = 'data' + $dataNxt, $currentBaseId = it.baseId, - $nonEmptySchema = (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all)); + $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)); out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; if ($nonEmptySchema) { var $wasComposite = it.compositeRule; @@ -2481,7 +2481,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) { var $currentBaseId = $it.baseId; for (var $property in $schemaDeps) { var $sch = $schemaDeps[$property]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; if ($ownProperties) { out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; @@ -2744,8 +2744,8 @@ module.exports = function generate_if(it, $keyword, $ruleType) { var $nextValid = 'valid' + $it.level; var $thenSch = it.schema['then'], $elseSch = it.schema['else'], - $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 : it.util.schemaHasRules($thenSch, it.RULES.all)), - $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 : it.util.schemaHasRules($elseSch, it.RULES.all)), + $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)), + $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)), $currentBaseId = $it.baseId; if ($thenPresent || $elsePresent) { var $ifClause; @@ -2936,7 +2936,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { '; var $passData = $data + '[' + $i + ']'; $it.schema = $sch; @@ -2959,7 +2959,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { } } } - if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 : it.util.schemaHasRules($additionalItems, it.RULES.all))) { + if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) { $it.schema = $additionalItems; $it.schemaPath = it.schemaPath + '.additionalItems'; $it.errSchemaPath = it.errSchemaPath + '/additionalItems'; @@ -2983,7 +2983,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { $closingBraces += '}'; } } - } else if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; @@ -3104,7 +3104,7 @@ module.exports = function generate_not(it, $keyword, $ruleType) { var $it = it.util.copy(it); $it.level++; var $nextValid = 'valid' + $it.level; - if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; @@ -3204,7 +3204,7 @@ module.exports = function generate_oneOf(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $it.schema = $sch; $it.schemaPath = $schemaPath + '[' + $i + ']'; $it.errSchemaPath = $errSchemaPath + '/' + $i; @@ -3513,7 +3513,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { while (i3 < l3) { $propertyKey = arr3[i3 += 1]; var $sch = $schema[$propertyKey]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { var $prop = it.util.getProperty($propertyKey), $passData = $data + $prop, $hasDefault = $useDefaults && $sch.default !== undefined; @@ -3616,7 +3616,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { while (i4 < l4) { $pProperty = arr4[i4 += 1]; var $sch = $pProperties[$pProperty]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $it.schema = $sch; $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty); $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty); @@ -3676,7 +3676,7 @@ module.exports = function generate_propertyNames(it, $keyword, $ruleType) { $it.level++; var $nextValid = 'valid' + $it.level; out += 'var ' + ($errs) + ' = errors;'; - if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; @@ -3900,7 +3900,7 @@ module.exports = function generate_required(it, $keyword, $ruleType) { while (i1 < l1) { $property = arr1[i1 += 1]; var $propertySch = it.schema.properties[$property]; - if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 : it.util.schemaHasRules($propertySch, it.RULES.all)))) { + if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) { $required[$required.length] = $property; } } @@ -4323,7 +4323,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) { it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema)); it.baseId = it.baseId || it.rootId; delete it.isTop; - it.dataPathArr = [undefined]; + it.dataPathArr = [""]; if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { var $defaultMsg = 'default is ignored in the schema root'; if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); @@ -5255,7 +5255,7 @@ function escapeJsonPtr(str) { } },{}],45:[function(require,module,exports){ -/** @license URI.js v4.2.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */ +/** @license URI.js v4.4.0 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : @@ -6218,9 +6218,9 @@ function _recomposeAuthority(components, options) { return "[" + $1 + ($2 ? "%25" + $2 : "") + "]"; })); } - if (typeof components.port === "number") { + if (typeof components.port === "number" || typeof components.port === "string") { uriTokens.push(":"); - uriTokens.push(components.port.toString(10)); + uriTokens.push(String(components.port)); } return uriTokens.length ? uriTokens.join("") : undefined; } @@ -6423,8 +6423,9 @@ var handler = { return components; }, serialize: function serialize(components, options) { + var secure = String(components.scheme).toLowerCase() === "https"; //normalize the default port - if (components.port === (String(components.scheme).toLowerCase() !== "https" ? 80 : 443) || components.port === "") { + if (components.port === (secure ? 443 : 80) || components.port === "") { components.port = undefined; } //normalize the empty path @@ -6445,6 +6446,57 @@ var handler$1 = { serialize: handler.serialize }; +function isSecure(wsComponents) { + return typeof wsComponents.secure === 'boolean' ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss"; +} +//RFC 6455 +var handler$2 = { + scheme: "ws", + domainHost: true, + parse: function parse(components, options) { + var wsComponents = components; + //indicate if the secure flag is set + wsComponents.secure = isSecure(wsComponents); + //construct resouce name + wsComponents.resourceName = (wsComponents.path || '/') + (wsComponents.query ? '?' + wsComponents.query : ''); + wsComponents.path = undefined; + wsComponents.query = undefined; + return wsComponents; + }, + serialize: function serialize(wsComponents, options) { + //normalize the default port + if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") { + wsComponents.port = undefined; + } + //ensure scheme matches secure flag + if (typeof wsComponents.secure === 'boolean') { + wsComponents.scheme = wsComponents.secure ? 'wss' : 'ws'; + wsComponents.secure = undefined; + } + //reconstruct path from resource name + if (wsComponents.resourceName) { + var _wsComponents$resourc = wsComponents.resourceName.split('?'), + _wsComponents$resourc2 = slicedToArray(_wsComponents$resourc, 2), + path = _wsComponents$resourc2[0], + query = _wsComponents$resourc2[1]; + + wsComponents.path = path && path !== '/' ? path : undefined; + wsComponents.query = query; + wsComponents.resourceName = undefined; + } + //forbid fragment component + wsComponents.fragment = undefined; + return wsComponents; + } +}; + +var handler$3 = { + scheme: "wss", + domainHost: handler$2.domainHost, + parse: handler$2.parse, + serialize: handler$2.serialize +}; + var O = {}; var isIRI = true; //RFC 3986 @@ -6475,7 +6527,7 @@ function decodeUnreserved(str) { var decStr = pctDecChars(str); return !decStr.match(UNRESERVED) ? str : decStr; } -var handler$2 = { +var handler$4 = { scheme: "mailto", parse: function parse$$1(components, options) { var mailtoComponents = components; @@ -6563,7 +6615,7 @@ var handler$2 = { var URN_PARSE = /^([^\:]+)\:(.*)/; //RFC 2141 -var handler$3 = { +var handler$5 = { scheme: "urn", parse: function parse$$1(components, options) { var matches = components.path && components.path.match(URN_PARSE); @@ -6602,7 +6654,7 @@ var handler$3 = { var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/; //RFC 4122 -var handler$4 = { +var handler$6 = { scheme: "urn:uuid", parse: function parse(urnComponents, options) { var uuidComponents = urnComponents; @@ -6626,6 +6678,8 @@ SCHEMES[handler$1.scheme] = handler$1; SCHEMES[handler$2.scheme] = handler$2; SCHEMES[handler$3.scheme] = handler$3; SCHEMES[handler$4.scheme] = handler$4; +SCHEMES[handler$5.scheme] = handler$5; +SCHEMES[handler$6.scheme] = handler$6; exports.SCHEMES = SCHEMES; exports.pctEncChar = pctEncChar; diff --git a/tools/node_modules/eslint/node_modules/ajv/dist/ajv.min.js b/tools/node_modules/eslint/node_modules/ajv/dist/ajv.min.js index 77667f5f340fda..d02ec10a7feaee 100644 --- a/tools/node_modules/eslint/node_modules/ajv/dist/ajv.min.js +++ b/tools/node_modules/eslint/node_modules/ajv/dist/ajv.min.js @@ -1,3 +1,3 @@ -/* ajv 6.12.4: Another JSON Schema Validator */ -!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).Ajv=e()}(function(){return function o(i,n,l){function c(r,e){if(!n[r]){if(!i[r]){var t="function"==typeof require&&require;if(!e&&t)return t(r,!0);if(u)return u(r,!0);var a=new Error("Cannot find module '"+r+"'");throw a.code="MODULE_NOT_FOUND",a}var s=n[r]={exports:{}};i[r][0].call(s.exports,function(e){return c(i[r][1][e]||e)},s,s.exports,o,i,n,l)}return n[r].exports}for(var u="function"==typeof require&&require,e=0;e%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,h=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,d=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,f=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function m(e){return a.copy(m[e="full"==e?"full":"fast"])}function v(e){var r=e.match(o);if(!r)return!1;var t,a=+r[2],s=+r[3];return 1<=a&&a<=12&&1<=s&&s<=(2!=a||((t=+r[1])%4!=0||t%100==0&&t%400!=0)?i[a]:29)}function y(e,r){var t=e.match(n);if(!t)return!1;var a=t[1],s=t[2],o=t[3];return(a<=23&&s<=59&&o<=59||23==a&&59==s&&60==o)&&(!r||t[5])}(r.exports=m).fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:s,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,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f},m.full={date:v,time:y,"date-time":function(e){var r=e.split(g);return 2==r.length&&v(r[0])&&y(r[1],!0)},uri:function(e){return P.test(e)&&l.test(e)},"uri-reference":/^(?:[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":c,url:u,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:s,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,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f};var g=/t|\s/i;var P=/\/|:/;var E=/[^\\]\\Z/;function w(e){if(E.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}},{"./util":10}],5:[function(e,r,t){"use strict";var R=e("./resolve"),$=e("./util"),j=e("./error_classes"),D=e("fast-json-stable-stringify"),O=e("../dotjs/validate"),I=$.ucs2length,A=e("fast-deep-equal"),k=j.Validation;function C(e,c,u,r){var d=this,p=this._opts,h=[void 0],f={},l=[],t={},m=[],a={},v=[],s=function(e,r,t){var a=L.call(this,e,r,t);return 0<=a?{index:a,compiling:!0}:{index:a=this._compilations.length,compiling:!(this._compilations[a]={schema:e,root:r,baseId:t})}}.call(this,e,c=c||{schema:e,refVal:h,refs:f},r),o=this._compilations[s.index];if(s.compiling)return o.callValidate=P;var y=this._formats,g=this.RULES;try{var i=E(e,c,u,r);o.validate=i;var n=o.callValidate;return n&&(n.schema=i.schema,n.errors=null,n.refs=i.refs,n.refVal=i.refVal,n.root=i.root,n.$async=i.$async,p.sourceCode&&(n.source=i.source)),i}finally{(function(e,r,t){var a=L.call(this,e,r,t);0<=a&&this._compilations.splice(a,1)}).call(this,e,c,r)}function P(){var e=o.validate,r=e.apply(this,arguments);return P.errors=e.errors,r}function E(e,r,t,a){var s=!r||r&&r.schema==e;if(r.schema!=c.schema)return C.call(d,e,r,t,a);var o=!0===e.$async,i=O({isTop:!0,schema:e,isRoot:s,baseId:a,root:r,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:j.MissingRef,RULES:g,validate:O,util:$,resolve:R,resolveRef:w,usePattern:_,useDefault:F,useCustomRule:x,opts:p,formats:y,logger:d.logger,self:d}),i=Q(h,T)+Q(l,N)+Q(m,z)+Q(v,q)+i;p.processCode&&(i=p.processCode(i,e));try{var n=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",i)(d,g,y,c,h,m,v,A,I,k);h[0]=n}catch(e){throw d.logger.error("Error compiling schema, function code:",i),e}return n.schema=e,n.errors=null,n.refs=f,n.refVal=h,n.root=s?n:r,o&&(n.$async=!0),!0===p.sourceCode&&(n.source={code:i,patterns:l,defaults:m}),n}function w(e,r,t){r=R.url(e,r);var a,s,o=f[r];if(void 0!==o)return S(a=h[o],s="refVal["+o+"]");if(!t&&c.refs){var i=c.refs[r];if(void 0!==i)return S(a=c.refVal[i],s=b(r,a))}s=b(r);var n,l=R.call(d,E,c,r);if(void 0!==l||(n=u&&u[r])&&(l=R.inlineRef(n,p.inlineRefs)?n:C.call(d,n,c,u,e)),void 0!==l)return S(h[f[r]]=l,s);delete f[r]}function b(e,r){var t=h.length;return h[t]=r,"refVal"+(f[e]=t)}function S(e,r){return"object"==typeof e||"boolean"==typeof e?{code:r,schema:e,inline:!0}:{code:r,$async:e&&!!e.$async}}function _(e){var r=t[e];return void 0===r&&(r=t[e]=l.length,l[r]=e),"pattern"+r}function F(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return $.toQuotedString(e);case"object":if(null===e)return"null";var r=D(e),t=a[r];return void 0===t&&(t=a[r]=m.length,m[t]=e),"default"+t}}function x(e,r,t,a){if(!1!==d._opts.validateSchema){var s=e.definition.dependencies;if(s&&!s.every(function(e){return Object.prototype.hasOwnProperty.call(t,e)}))throw new Error("parent schema must have all required keywords: "+s.join(","));var o=e.definition.validateSchema;if(o)if(!o(r)){var i="keyword schema is invalid: "+d.errorsText(o.errors);if("log"!=d._opts.validateSchema)throw new Error(i);d.logger.error(i)}}var n,l=e.definition.compile,c=e.definition.inline,u=e.definition.macro;if(l)n=l.call(d,r,t,a);else if(u)n=u.call(d,r,t,a),!1!==p.validateSchema&&d.validateSchema(n,!0);else if(c)n=c.call(d,a,e.keyword,r,t);else if(!(n=e.definition.validate))return;if(void 0===n)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var h=v.length;return{code:"customRule"+h,validate:v[h]=n}}}function L(e,r,t){for(var a=0;a",_=P?">":"<",F=void 0;if(!y&&"number"!=typeof d&&void 0!==d)throw new Error(r+" must be number");if(!b&&void 0!==w&&"number"!=typeof w&&"boolean"!=typeof w)throw new Error(E+" must be number or boolean");b?(o="exclIsNumber"+u,i="' + "+(n="op"+u)+" + '",c+=" var schemaExcl"+u+" = "+(t=e.util.getData(w.$data,h,e.dataPathArr))+"; ",F=E,(l=l||[]).push(c+=" var "+(a="exclusive"+u)+"; var "+(s="exclType"+u)+" = typeof "+(t="schemaExcl"+u)+"; if ("+s+" != 'boolean' && "+s+" != 'undefined' && "+s+" != 'number') { "),c="",!1!==e.createErrors?(c+=" { keyword: '"+(F||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",!1!==e.opts.messages&&(c+=" , message: '"+E+" should be boolean' "),e.opts.verbose&&(c+=" , schema: validate.schema"+p+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+v+" "),c+=" } "):c+=" {} ",x=c,c=l.pop(),c+=!e.compositeRule&&m?e.async?" throw new ValidationError(["+x+"]); ":" validate.errors = ["+x+"]; return false; ":" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c+=" } else if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" "+s+" == 'number' ? ( ("+a+" = "+g+" === undefined || "+t+" "+S+"= "+g+") ? "+v+" "+_+"= "+t+" : "+v+" "+_+" "+g+" ) : ( ("+a+" = "+t+" === true) ? "+v+" "+_+"= "+g+" : "+v+" "+_+" "+g+" ) || "+v+" !== "+v+") { var op"+u+" = "+a+" ? '"+S+"' : '"+S+"='; ",void 0===d&&(f=e.errSchemaPath+"/"+(F=E),g=t,y=b)):(i=S,(o="number"==typeof w)&&y?(n="'"+i+"'",c+=" if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" ( "+g+" === undefined || "+w+" "+S+"= "+g+" ? "+v+" "+_+"= "+w+" : "+v+" "+_+" "+g+" ) || "+v+" !== "+v+") { "):(o&&void 0===d?(a=!0,f=e.errSchemaPath+"/"+(F=E),g=w,_+="="):(o&&(g=Math[P?"min":"max"](w,d)),w===(!o||g)?(a=!0,f=e.errSchemaPath+"/"+(F=E),_+="="):(a=!1,i+="=")),n="'"+i+"'",c+=" if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" "+v+" "+_+" "+g+" || "+v+" !== "+v+") { ")),F=F||r,(l=l||[]).push(c),c="",!1!==e.createErrors?(c+=" { keyword: '"+(F||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { comparison: "+n+", limit: "+g+", exclusive: "+a+" } ",!1!==e.opts.messages&&(c+=" , message: 'should be "+i+" ",c+=y?"' + "+g:g+"'"),e.opts.verbose&&(c+=" , schema: ",c+=y?"validate.schema"+p:""+d,c+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+v+" "),c+=" } "):c+=" {} ";var x=c;return c=l.pop(),c+=!e.compositeRule&&m?e.async?" throw new ValidationError(["+x+"]); ":" validate.errors = ["+x+"]; return false; ":" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c+=" } ",m&&(c+=" else { "),c}},{}],14:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || ");var d=r,p=p||[];p.push(t+=" "+c+".length "+("maxItems"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have ",t+="maxItems"==r?"more":"fewer",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" items' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],15:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),t+=!1===e.opts.unicode?" "+c+".length ":" ucs2length("+c+") ";var d=r,p=p||[];p.push(t+=" "+("maxLength"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT be ",t+="maxLength"==r?"longer":"shorter",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" characters' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],16:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || ");var d=r,p=p||[];p.push(t+=" Object.keys("+c+").length "+("maxProperties"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have ",t+="maxProperties"==r?"more":"fewer",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" properties' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],17:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.schema[r],s=e.schemaPath+e.util.getProperty(r),o=e.errSchemaPath+"/"+r,i=!e.opts.allErrors,n=e.util.copy(e),l="";n.level++;var c="valid"+n.level,u=n.baseId,h=!0,d=a;if(d)for(var p,f=-1,m=d.length-1;f "+_+") { ",x=c+"["+_+"]",d.schema=$,d.schemaPath=i+"["+_+"]",d.errSchemaPath=n+"/"+_,d.errorPath=e.util.getPathExpr(e.errorPath,_,e.opts.jsonPointers,!0),d.dataPathArr[v]=_,R=e.validate(d),d.baseId=g,e.util.varOccurences(R,y)<2?t+=" "+e.util.varReplace(R,y,x)+" ":t+=" var "+y+" = "+x+"; "+R+" ",t+=" } ",l&&(t+=" if ("+f+") { ",p+="}"))}"object"==typeof b&&(e.opts.strictKeywords?"object"==typeof b&&0 "+o.length+") { for (var "+m+" = "+o.length+"; "+m+" < "+c+".length; "+m+"++) { ",d.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0),x=c+"["+m+"]",d.dataPathArr[v]=m,R=e.validate(d),d.baseId=g,e.util.varOccurences(R,y)<2?t+=" "+e.util.varReplace(R,y,x)+" ":t+=" var "+y+" = "+x+"; "+R+" ",l&&(t+=" if (!"+f+") break; "),t+=" } } ",l&&(t+=" if ("+f+") { ",p+="}"))}else{(e.opts.strictKeywords?"object"==typeof o&&0 1e-"+e.opts.multipleOfPrecision+" ":" division"+a+" !== parseInt(division"+a+") ",t+=" ) ",u&&(t+=" ) ");var d=d||[];d.push(t+=" ) { "),t="",!1!==e.createErrors?(t+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { multipleOf: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should be multiple of ",t+=u?"' + "+h:h+"'"),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var p=t,t=d.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+p+"]); ":" validate.errors = ["+p+"]; return false; ":" var err = "+p+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],30:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u="errs__"+a,h=e.util.copy(e);h.level++;var d,p,f,m,v="valid"+h.level;return(e.opts.strictKeywords?"object"==typeof o&&0 1) { ",t=e.schema.items&&e.schema.items.type,a=Array.isArray(t),!t||"object"==t||"array"==t||a&&(0<=t.indexOf("object")||0<=t.indexOf("array"))?i+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+p+"[i], "+p+"[j])) { "+f+" = false; break outer; } } } ":(i+=" var itemIndices = {}, item; for (;i--;) { var item = "+p+"[i]; ",i+=" if ("+e.util["checkDataType"+(a?"s":"")](t,"item",e.opts.strictNumbers,!0)+") continue; ",a&&(i+=" if (typeof item == 'string') item = '\"' + item; "),i+=" if (typeof itemIndices[item] == 'number') { "+f+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "),i+=" } ",m&&(i+=" } "),(s=s||[]).push(i+=" if (!"+f+") { "),i="",!1!==e.createErrors?(i+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(h)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(i+=" , schema: ",i+=m?"validate.schema"+u:""+c,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),i+=" } "):i+=" {} ",o=i,i=s.pop(),i+=!e.compositeRule&&d?e.async?" throw new ValidationError(["+o+"]); ":" validate.errors = ["+o+"]; return false; ":" var err = "+o+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",d&&(i+=" else { ")):d&&(i+=" if (true) { "),i}},{}],38:[function(e,r,t){"use strict";r.exports=function(a,e){var r="",t=!0===a.schema.$async,s=a.util.schemaHasRulesExcept(a.schema,a.RULES.all,"$ref"),o=a.self._getId(a.schema);if(a.opts.strictKeywords){var i=a.util.schemaUnknownRules(a.schema,a.RULES.keywords);if(i){var n="unknown keyword: "+i;if("log"!==a.opts.strictKeywords)throw new Error(n);a.logger.warn(n)}}if(a.isTop&&(r+=" var validate = ",t&&(a.async=!0,r+="async "),r+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",o&&(a.opts.sourceCode||a.opts.processCode)&&(r+=" /*# sourceURL="+o+" */ ")),"boolean"==typeof a.schema||!s&&!a.schema.$ref){var l=a.level,c=a.dataLevel,u=a.schema[e="false schema"],h=a.schemaPath+a.util.getProperty(e),d=a.errSchemaPath+"/"+e,p=!a.opts.allErrors,f="data"+(c||""),m="valid"+l;return!1===a.schema?(a.isTop?p=!0:r+=" var "+m+" = false; ",(U=U||[]).push(r),r="",!1!==a.createErrors?(r+=" { keyword: 'false schema' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(d)+" , params: {} ",!1!==a.opts.messages&&(r+=" , message: 'boolean schema is false' "),a.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+a.schemaPath+" , data: "+f+" "),r+=" } "):r+=" {} ",D=r,r=U.pop(),r+=!a.compositeRule&&p?a.async?" throw new ValidationError(["+D+"]); ":" validate.errors = ["+D+"]; return false; ":" var err = "+D+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "):r+=a.isTop?t?" return data; ":" validate.errors = null; return true; ":" var "+m+" = true; ",a.isTop&&(r+=" }; return validate; "),r}if(a.isTop){var v=a.isTop,l=a.level=0,c=a.dataLevel=0,f="data";if(a.rootId=a.resolve.fullPath(a.self._getId(a.root.schema)),a.baseId=a.baseId||a.rootId,delete a.isTop,a.dataPathArr=[void 0],void 0!==a.schema.default&&a.opts.useDefaults&&a.opts.strictDefaults){var y="default is ignored in the schema root";if("log"!==a.opts.strictDefaults)throw new Error(y);a.logger.warn(y)}r+=" var vErrors = null; ",r+=" var errors = 0; ",r+=" if (rootData === undefined) rootData = data; "}else{l=a.level,f="data"+((c=a.dataLevel)||"");if(o&&(a.baseId=a.resolve.url(a.baseId,o)),t&&!a.async)throw new Error("async schema in sync schema");r+=" var errs_"+l+" = errors;"}var g,m="valid"+l,p=!a.opts.allErrors,P="",E="",w=a.schema.type,b=Array.isArray(w);if(w&&a.opts.nullable&&!0===a.schema.nullable&&(b?-1==w.indexOf("null")&&(w=w.concat("null")):"null"!=w&&(w=[w,"null"],b=!0)),b&&1==w.length&&(w=w[0],b=!1),a.schema.$ref&&s){if("fail"==a.opts.extendRefs)throw new Error('$ref: validation keywords used in schema at path "'+a.errSchemaPath+'" (see option extendRefs)');!0!==a.opts.extendRefs&&(s=!1,a.logger.warn('$ref: keywords ignored in schema at path "'+a.errSchemaPath+'"'))}if(a.schema.$comment&&a.opts.$comment&&(r+=" "+a.RULES.all.$comment.code(a,"$comment")),w){a.opts.coerceTypes&&(g=a.util.coerceToTypes(a.opts.coerceTypes,w));var S=a.RULES.types[w];if(g||b||!0===S||S&&!Z(S)){h=a.schemaPath+".type",d=a.errSchemaPath+"/type",h=a.schemaPath+".type",d=a.errSchemaPath+"/type";if(r+=" if ("+a.util[b?"checkDataTypes":"checkDataType"](w,f,a.opts.strictNumbers,!0)+") { ",g){var _="dataType"+l,F="coerced"+l;r+=" var "+_+" = typeof "+f+"; var "+F+" = undefined; ","array"==a.opts.coerceTypes&&(r+=" if ("+_+" == 'object' && Array.isArray("+f+") && "+f+".length == 1) { "+f+" = "+f+"[0]; "+_+" = typeof "+f+"; if ("+a.util.checkDataType(a.schema.type,f,a.opts.strictNumbers)+") "+F+" = "+f+"; } "),r+=" if ("+F+" !== undefined) ; ";var x=g;if(x)for(var R,$=-1,j=x.length-1;$= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=Math.floor,C=String.fromCharCode;function L(e){throw new RangeError(i[e])}function n(e,r){var t=e.split("@"),a="";return 1>1,e+=k(e/r);455k((A-a)/h))&&L("overflow"),a+=p*h;var f=d<=o?1:o+26<=d?26:d-o;if(pk(A/m)&&L("overflow"),h*=m}var v=r.length+1,o=T(a-u,v,0==u);k(a/v)>A-s&&L("overflow"),s+=k(a/v),a%=v,r.splice(a++,0,s)}return String.fromCodePoint.apply(String,r)}function c(e){var r=[],t=(e=N(e)).length,a=128,s=0,o=72,i=!0,n=!1,l=void 0;try{for(var c,u=e[Symbol.iterator]();!(i=(c=u.next()).done);i=!0){var h=c.value;h<128&&r.push(C(h))}}catch(e){n=!0,l=e}finally{try{!i&&u.return&&u.return()}finally{if(n)throw l}}var d=r.length,p=d;for(d&&r.push("-");pk((A-s)/w)&&L("overflow"),s+=(f-a)*w,a=f;var b=!0,S=!1,_=void 0;try{for(var F,x=e[Symbol.iterator]();!(b=(F=x.next()).done);b=!0){var R=F.value;if(RA&&L("overflow"),R==a){for(var $=s,j=36;;j+=36){var D=j<=o?1:o+26<=j?26:j-o;if($>6|192).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase():"%"+(r>>12|224).toString(16).toUpperCase()+"%"+(r>>6&63|128).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase()}function p(e){for(var r="",t=0,a=e.length;tA-Z\\x5E-\\x7E]",'[\\"\\\\]')),M=new RegExp(U,"g"),B=new RegExp("(?:(?:%[EFef][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f])|(?:%[89A-Fa-f][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f])|(?:%[0-9A-Fa-f][0-9A-Fa-f]))","g"),G=new RegExp(J("[^]","[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]","[\\.]",'[\\"]',K),"g"),Y=new RegExp(J("[^]",U,"[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"),"g"),W=Y;function X(e){var r=p(e);return r.match(M)?r:e}var ee={scheme:"mailto",parse:function(e,r){var t=e,a=t.to=t.path?t.path.split(","):[];if(t.path=void 0,t.query){for(var s=!1,o={},i=t.query.split("&"),n=0,l=i.length;n%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,u=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-?)*(?:[0-9KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[KSa-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,h=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,d=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,f=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;function m(e){return a.copy(m[e="full"==e?"full":"fast"])}function v(e){var r=e.match(o);if(!r)return!1;var t,a=+r[2],s=+r[3];return 1<=a&&a<=12&&1<=s&&s<=(2!=a||((t=+r[1])%4!=0||t%100==0&&t%400!=0)?i[a]:29)}function y(e,r){var t=e.match(n);if(!t)return!1;var a=t[1],s=t[2],o=t[3];return(a<=23&&s<=59&&o<=59||23==a&&59==s&&60==o)&&(!r||t[5])}(r.exports=m).fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":c,url:u,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:s,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,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f},m.full={date:v,time:y,"date-time":function(e){var r=e.split(g);return 2==r.length&&v(r[0])&&y(r[1],!0)},uri:function(e){return P.test(e)&&l.test(e)},"uri-reference":/^(?:[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":c,url:u,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:s,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,regex:w,uuid:h,"json-pointer":d,"json-pointer-uri-fragment":p,"relative-json-pointer":f};var g=/t|\s/i;var P=/\/|:/;var E=/[^\\]\\Z/;function w(e){if(E.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}},{"./util":10}],5:[function(e,r,t){"use strict";var R=e("./resolve"),$=e("./util"),j=e("./error_classes"),D=e("fast-json-stable-stringify"),O=e("../dotjs/validate"),I=$.ucs2length,A=e("fast-deep-equal"),k=j.Validation;function C(e,c,u,r){var d=this,p=this._opts,h=[void 0],f={},l=[],t={},m=[],a={},v=[],s=function(e,r,t){var a=L.call(this,e,r,t);return 0<=a?{index:a,compiling:!0}:{index:a=this._compilations.length,compiling:!(this._compilations[a]={schema:e,root:r,baseId:t})}}.call(this,e,c=c||{schema:e,refVal:h,refs:f},r),o=this._compilations[s.index];if(s.compiling)return o.callValidate=P;var y=this._formats,g=this.RULES;try{var i=E(e,c,u,r);o.validate=i;var n=o.callValidate;return n&&(n.schema=i.schema,n.errors=null,n.refs=i.refs,n.refVal=i.refVal,n.root=i.root,n.$async=i.$async,p.sourceCode&&(n.source=i.source)),i}finally{(function(e,r,t){var a=L.call(this,e,r,t);0<=a&&this._compilations.splice(a,1)}).call(this,e,c,r)}function P(){var e=o.validate,r=e.apply(this,arguments);return P.errors=e.errors,r}function E(e,r,t,a){var s=!r||r&&r.schema==e;if(r.schema!=c.schema)return C.call(d,e,r,t,a);var o=!0===e.$async,i=O({isTop:!0,schema:e,isRoot:s,baseId:a,root:r,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:j.MissingRef,RULES:g,validate:O,util:$,resolve:R,resolveRef:w,usePattern:_,useDefault:F,useCustomRule:x,opts:p,formats:y,logger:d.logger,self:d}),i=Q(h,z)+Q(l,N)+Q(m,q)+Q(v,T)+i;p.processCode&&(i=p.processCode(i,e));try{var n=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",i)(d,g,y,c,h,m,v,A,I,k);h[0]=n}catch(e){throw d.logger.error("Error compiling schema, function code:",i),e}return n.schema=e,n.errors=null,n.refs=f,n.refVal=h,n.root=s?n:r,o&&(n.$async=!0),!0===p.sourceCode&&(n.source={code:i,patterns:l,defaults:m}),n}function w(e,r,t){r=R.url(e,r);var a,s,o=f[r];if(void 0!==o)return S(a=h[o],s="refVal["+o+"]");if(!t&&c.refs){var i=c.refs[r];if(void 0!==i)return S(a=c.refVal[i],s=b(r,a))}s=b(r);var n,l=R.call(d,E,c,r);if(void 0!==l||(n=u&&u[r])&&(l=R.inlineRef(n,p.inlineRefs)?n:C.call(d,n,c,u,e)),void 0!==l)return S(h[f[r]]=l,s);delete f[r]}function b(e,r){var t=h.length;return h[t]=r,"refVal"+(f[e]=t)}function S(e,r){return"object"==typeof e||"boolean"==typeof e?{code:r,schema:e,inline:!0}:{code:r,$async:e&&!!e.$async}}function _(e){var r=t[e];return void 0===r&&(r=t[e]=l.length,l[r]=e),"pattern"+r}function F(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return $.toQuotedString(e);case"object":if(null===e)return"null";var r=D(e),t=a[r];return void 0===t&&(t=a[r]=m.length,m[t]=e),"default"+t}}function x(e,r,t,a){if(!1!==d._opts.validateSchema){var s=e.definition.dependencies;if(s&&!s.every(function(e){return Object.prototype.hasOwnProperty.call(t,e)}))throw new Error("parent schema must have all required keywords: "+s.join(","));var o=e.definition.validateSchema;if(o)if(!o(r)){var i="keyword schema is invalid: "+d.errorsText(o.errors);if("log"!=d._opts.validateSchema)throw new Error(i);d.logger.error(i)}}var n,l=e.definition.compile,c=e.definition.inline,u=e.definition.macro;if(l)n=l.call(d,r,t,a);else if(u)n=u.call(d,r,t,a),!1!==p.validateSchema&&d.validateSchema(n,!0);else if(c)n=c.call(d,a,e.keyword,r,t);else if(!(n=e.definition.validate))return;if(void 0===n)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var h=v.length;return{code:"customRule"+h,validate:v[h]=n}}}function L(e,r,t){for(var a=0;a",_=P?">":"<",F=void 0;if(!y&&"number"!=typeof d&&void 0!==d)throw new Error(r+" must be number");if(!b&&void 0!==w&&"number"!=typeof w&&"boolean"!=typeof w)throw new Error(E+" must be number or boolean");b?(o="exclIsNumber"+u,i="' + "+(n="op"+u)+" + '",c+=" var schemaExcl"+u+" = "+(t=e.util.getData(w.$data,h,e.dataPathArr))+"; ",F=E,(l=l||[]).push(c+=" var "+(a="exclusive"+u)+"; var "+(s="exclType"+u)+" = typeof "+(t="schemaExcl"+u)+"; if ("+s+" != 'boolean' && "+s+" != 'undefined' && "+s+" != 'number') { "),c="",!1!==e.createErrors?(c+=" { keyword: '"+(F||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: {} ",!1!==e.opts.messages&&(c+=" , message: '"+E+" should be boolean' "),e.opts.verbose&&(c+=" , schema: validate.schema"+p+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+v+" "),c+=" } "):c+=" {} ",x=c,c=l.pop(),c+=!e.compositeRule&&m?e.async?" throw new ValidationError(["+x+"]); ":" validate.errors = ["+x+"]; return false; ":" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c+=" } else if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" "+s+" == 'number' ? ( ("+a+" = "+g+" === undefined || "+t+" "+S+"= "+g+") ? "+v+" "+_+"= "+t+" : "+v+" "+_+" "+g+" ) : ( ("+a+" = "+t+" === true) ? "+v+" "+_+"= "+g+" : "+v+" "+_+" "+g+" ) || "+v+" !== "+v+") { var op"+u+" = "+a+" ? '"+S+"' : '"+S+"='; ",void 0===d&&(f=e.errSchemaPath+"/"+(F=E),g=t,y=b)):(i=S,(o="number"==typeof w)&&y?(n="'"+i+"'",c+=" if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" ( "+g+" === undefined || "+w+" "+S+"= "+g+" ? "+v+" "+_+"= "+w+" : "+v+" "+_+" "+g+" ) || "+v+" !== "+v+") { "):(o&&void 0===d?(a=!0,f=e.errSchemaPath+"/"+(F=E),g=w,_+="="):(o&&(g=Math[P?"min":"max"](w,d)),w===(!o||g)?(a=!0,f=e.errSchemaPath+"/"+(F=E),_+="="):(a=!1,i+="=")),n="'"+i+"'",c+=" if ( ",y&&(c+=" ("+g+" !== undefined && typeof "+g+" != 'number') || "),c+=" "+v+" "+_+" "+g+" || "+v+" !== "+v+") { ")),F=F||r,(l=l||[]).push(c),c="",!1!==e.createErrors?(c+=" { keyword: '"+(F||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(f)+" , params: { comparison: "+n+", limit: "+g+", exclusive: "+a+" } ",!1!==e.opts.messages&&(c+=" , message: 'should be "+i+" ",c+=y?"' + "+g:g+"'"),e.opts.verbose&&(c+=" , schema: ",c+=y?"validate.schema"+p:""+d,c+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+v+" "),c+=" } "):c+=" {} ";var x=c;return c=l.pop(),c+=!e.compositeRule&&m?e.async?" throw new ValidationError(["+x+"]); ":" validate.errors = ["+x+"]; return false; ":" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c+=" } ",m&&(c+=" else { "),c}},{}],14:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || ");var d=r,p=p||[];p.push(t+=" "+c+".length "+("maxItems"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have ",t+="maxItems"==r?"more":"fewer",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" items' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],15:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || "),t+=!1===e.opts.unicode?" "+c+".length ":" ucs2length("+c+") ";var d=r,p=p||[];p.push(t+=" "+("maxLength"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT be ",t+="maxLength"==r?"longer":"shorter",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" characters' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],16:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u=e.opts.$data&&o&&o.$data,h=u?(t+=" var schema"+a+" = "+e.util.getData(o.$data,s,e.dataPathArr)+"; ","schema"+a):o;if(!u&&"number"!=typeof o)throw new Error(r+" must be number");t+="if ( ",u&&(t+=" ("+h+" !== undefined && typeof "+h+" != 'number') || ");var d=r,p=p||[];p.push(t+=" Object.keys("+c+").length "+("maxProperties"==r?">":"<")+" "+h+") { "),t="",!1!==e.createErrors?(t+=" { keyword: '"+(d||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { limit: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should NOT have ",t+="maxProperties"==r?"more":"fewer",t+=" than ",t+=u?"' + "+h+" + '":""+o,t+=" properties' "),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var f=t,t=p.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+f+"]); ":" validate.errors = ["+f+"]; return false; ":" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],17:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.schema[r],s=e.schemaPath+e.util.getProperty(r),o=e.errSchemaPath+"/"+r,i=!e.opts.allErrors,n=e.util.copy(e),l="";n.level++;var c="valid"+n.level,u=n.baseId,h=!0,d=a;if(d)for(var p,f=-1,m=d.length-1;f "+_+") { ",x=c+"["+_+"]",d.schema=$,d.schemaPath=i+"["+_+"]",d.errSchemaPath=n+"/"+_,d.errorPath=e.util.getPathExpr(e.errorPath,_,e.opts.jsonPointers,!0),d.dataPathArr[v]=_,R=e.validate(d),d.baseId=g,e.util.varOccurences(R,y)<2?t+=" "+e.util.varReplace(R,y,x)+" ":t+=" var "+y+" = "+x+"; "+R+" ",t+=" } ",l&&(t+=" if ("+f+") { ",p+="}"))}"object"==typeof b&&(e.opts.strictKeywords?"object"==typeof b&&0 "+o.length+") { for (var "+m+" = "+o.length+"; "+m+" < "+c+".length; "+m+"++) { ",d.errorPath=e.util.getPathExpr(e.errorPath,m,e.opts.jsonPointers,!0),x=c+"["+m+"]",d.dataPathArr[v]=m,R=e.validate(d),d.baseId=g,e.util.varOccurences(R,y)<2?t+=" "+e.util.varReplace(R,y,x)+" ":t+=" var "+y+" = "+x+"; "+R+" ",l&&(t+=" if (!"+f+") break; "),t+=" } } ",l&&(t+=" if ("+f+") { ",p+="}"))}else{(e.opts.strictKeywords?"object"==typeof o&&0 1e-"+e.opts.multipleOfPrecision+" ":" division"+a+" !== parseInt(division"+a+") ",t+=" ) ",u&&(t+=" ) ");var d=d||[];d.push(t+=" ) { "),t="",!1!==e.createErrors?(t+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(n)+" , params: { multipleOf: "+h+" } ",!1!==e.opts.messages&&(t+=" , message: 'should be multiple of ",t+=u?"' + "+h:h+"'"),e.opts.verbose&&(t+=" , schema: ",t+=u?"validate.schema"+i:""+o,t+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+c+" "),t+=" } "):t+=" {} ";var p=t,t=d.pop();return t+=!e.compositeRule&&l?e.async?" throw new ValidationError(["+p+"]); ":" validate.errors = ["+p+"]; return false; ":" var err = "+p+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",t+="} ",l&&(t+=" else { "),t}},{}],30:[function(e,r,t){"use strict";r.exports=function(e,r){var t=" ",a=e.level,s=e.dataLevel,o=e.schema[r],i=e.schemaPath+e.util.getProperty(r),n=e.errSchemaPath+"/"+r,l=!e.opts.allErrors,c="data"+(s||""),u="errs__"+a,h=e.util.copy(e);h.level++;var d,p,f,m,v="valid"+h.level;return(e.opts.strictKeywords?"object"==typeof o&&0 1) { ",t=e.schema.items&&e.schema.items.type,a=Array.isArray(t),!t||"object"==t||"array"==t||a&&(0<=t.indexOf("object")||0<=t.indexOf("array"))?i+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+p+"[i], "+p+"[j])) { "+f+" = false; break outer; } } } ":(i+=" var itemIndices = {}, item; for (;i--;) { var item = "+p+"[i]; ",i+=" if ("+e.util["checkDataType"+(a?"s":"")](t,"item",e.opts.strictNumbers,!0)+") continue; ",a&&(i+=" if (typeof item == 'string') item = '\"' + item; "),i+=" if (typeof itemIndices[item] == 'number') { "+f+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "),i+=" } ",m&&(i+=" } "),(s=s||[]).push(i+=" if (!"+f+") { "),i="",!1!==e.createErrors?(i+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(h)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(i+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(i+=" , schema: ",i+=m?"validate.schema"+u:""+c,i+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+p+" "),i+=" } "):i+=" {} ",o=i,i=s.pop(),i+=!e.compositeRule&&d?e.async?" throw new ValidationError(["+o+"]); ":" validate.errors = ["+o+"]; return false; ":" var err = "+o+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",i+=" } ",d&&(i+=" else { ")):d&&(i+=" if (true) { "),i}},{}],38:[function(e,r,t){"use strict";r.exports=function(a,e){var r="",t=!0===a.schema.$async,s=a.util.schemaHasRulesExcept(a.schema,a.RULES.all,"$ref"),o=a.self._getId(a.schema);if(a.opts.strictKeywords){var i=a.util.schemaUnknownRules(a.schema,a.RULES.keywords);if(i){var n="unknown keyword: "+i;if("log"!==a.opts.strictKeywords)throw new Error(n);a.logger.warn(n)}}if(a.isTop&&(r+=" var validate = ",t&&(a.async=!0,r+="async "),r+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",o&&(a.opts.sourceCode||a.opts.processCode)&&(r+=" /*# sourceURL="+o+" */ ")),"boolean"==typeof a.schema||!s&&!a.schema.$ref){var l=a.level,c=a.dataLevel,u=a.schema[e="false schema"],h=a.schemaPath+a.util.getProperty(e),d=a.errSchemaPath+"/"+e,p=!a.opts.allErrors,f="data"+(c||""),m="valid"+l;return!1===a.schema?(a.isTop?p=!0:r+=" var "+m+" = false; ",(U=U||[]).push(r),r="",!1!==a.createErrors?(r+=" { keyword: 'false schema' , dataPath: (dataPath || '') + "+a.errorPath+" , schemaPath: "+a.util.toQuotedString(d)+" , params: {} ",!1!==a.opts.messages&&(r+=" , message: 'boolean schema is false' "),a.opts.verbose&&(r+=" , schema: false , parentSchema: validate.schema"+a.schemaPath+" , data: "+f+" "),r+=" } "):r+=" {} ",D=r,r=U.pop(),r+=!a.compositeRule&&p?a.async?" throw new ValidationError(["+D+"]); ":" validate.errors = ["+D+"]; return false; ":" var err = "+D+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "):r+=a.isTop?t?" return data; ":" validate.errors = null; return true; ":" var "+m+" = true; ",a.isTop&&(r+=" }; return validate; "),r}if(a.isTop){var v=a.isTop,l=a.level=0,c=a.dataLevel=0,f="data";if(a.rootId=a.resolve.fullPath(a.self._getId(a.root.schema)),a.baseId=a.baseId||a.rootId,delete a.isTop,a.dataPathArr=[""],void 0!==a.schema.default&&a.opts.useDefaults&&a.opts.strictDefaults){var y="default is ignored in the schema root";if("log"!==a.opts.strictDefaults)throw new Error(y);a.logger.warn(y)}r+=" var vErrors = null; ",r+=" var errors = 0; ",r+=" if (rootData === undefined) rootData = data; "}else{l=a.level,f="data"+((c=a.dataLevel)||"");if(o&&(a.baseId=a.resolve.url(a.baseId,o)),t&&!a.async)throw new Error("async schema in sync schema");r+=" var errs_"+l+" = errors;"}var g,m="valid"+l,p=!a.opts.allErrors,P="",E="",w=a.schema.type,b=Array.isArray(w);if(w&&a.opts.nullable&&!0===a.schema.nullable&&(b?-1==w.indexOf("null")&&(w=w.concat("null")):"null"!=w&&(w=[w,"null"],b=!0)),b&&1==w.length&&(w=w[0],b=!1),a.schema.$ref&&s){if("fail"==a.opts.extendRefs)throw new Error('$ref: validation keywords used in schema at path "'+a.errSchemaPath+'" (see option extendRefs)');!0!==a.opts.extendRefs&&(s=!1,a.logger.warn('$ref: keywords ignored in schema at path "'+a.errSchemaPath+'"'))}if(a.schema.$comment&&a.opts.$comment&&(r+=" "+a.RULES.all.$comment.code(a,"$comment")),w){a.opts.coerceTypes&&(g=a.util.coerceToTypes(a.opts.coerceTypes,w));var S=a.RULES.types[w];if(g||b||!0===S||S&&!Z(S)){h=a.schemaPath+".type",d=a.errSchemaPath+"/type",h=a.schemaPath+".type",d=a.errSchemaPath+"/type";if(r+=" if ("+a.util[b?"checkDataTypes":"checkDataType"](w,f,a.opts.strictNumbers,!0)+") { ",g){var _="dataType"+l,F="coerced"+l;r+=" var "+_+" = typeof "+f+"; var "+F+" = undefined; ","array"==a.opts.coerceTypes&&(r+=" if ("+_+" == 'object' && Array.isArray("+f+") && "+f+".length == 1) { "+f+" = "+f+"[0]; "+_+" = typeof "+f+"; if ("+a.util.checkDataType(a.schema.type,f,a.opts.strictNumbers)+") "+F+" = "+f+"; } "),r+=" if ("+F+" !== undefined) ; ";var x=g;if(x)for(var R,$=-1,j=x.length-1;$= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=Math.floor,C=String.fromCharCode;function L(e){throw new RangeError(i[e])}function n(e,r){var t=e.split("@"),a="";return 1>1,e+=k(e/r);455k((A-a)/h))&&L("overflow"),a+=p*h;var f=d<=o?1:o+26<=d?26:d-o;if(pk(A/m)&&L("overflow"),h*=m}var v=r.length+1,o=z(a-u,v,0==u);k(a/v)>A-s&&L("overflow"),s+=k(a/v),a%=v,r.splice(a++,0,s)}return String.fromCodePoint.apply(String,r)}function c(e){var r=[],t=(e=N(e)).length,a=128,s=0,o=72,i=!0,n=!1,l=void 0;try{for(var c,u=e[Symbol.iterator]();!(i=(c=u.next()).done);i=!0){var h=c.value;h<128&&r.push(C(h))}}catch(e){n=!0,l=e}finally{try{!i&&u.return&&u.return()}finally{if(n)throw l}}var d=r.length,p=d;for(d&&r.push("-");pk((A-s)/w)&&L("overflow"),s+=(f-a)*w,a=f;var b=!0,S=!1,_=void 0;try{for(var F,x=e[Symbol.iterator]();!(b=(F=x.next()).done);b=!0){var R=F.value;if(RA&&L("overflow"),R==a){for(var $=s,j=36;;j+=36){var D=j<=o?1:o+26<=j?26:j-o;if($>6|192).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase():"%"+(r>>12|224).toString(16).toUpperCase()+"%"+(r>>6&63|128).toString(16).toUpperCase()+"%"+(63&r|128).toString(16).toUpperCase()}function p(e){for(var r="",t=0,a=e.length;tA-Z\\x5E-\\x7E]",'[\\"\\\\]')),Y=new RegExp(M,"g"),W=new RegExp("(?:(?:%[EFef][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f])|(?:%[89A-Fa-f][0-9A-Fa-f]%[0-9A-Fa-f][0-9A-Fa-f])|(?:%[0-9A-Fa-f][0-9A-Fa-f]))","g"),X=new RegExp(J("[^]","[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]","[\\.]",'[\\"]',G),"g"),ee=new RegExp(J("[^]",M,"[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]"),"g"),re=ee;function te(e){var r=p(e);return r.match(Y)?r:e}var ae={scheme:"mailto",parse:function(e,r){var t=e,a=t.to=t.path?t.path.split(","):[];if(t.path=void 0,t.query){for(var s=!1,o={},i=t.query.split("&"),n=0,l=i.length;n 0 + ? (typeof _schema == 'object' && Object.keys(_schema).length > 0) + || _schema === false : it.util.schemaHasRules(_schema, it.RULES.all)) #}} diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dot/validate.jst b/tools/node_modules/eslint/node_modules/ajv/lib/dot/validate.jst index f8a1edfc0eb882..c152e66f169a29 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dot/validate.jst +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dot/validate.jst @@ -81,7 +81,7 @@ it.baseId = it.baseId || it.rootId; delete it.isTop; - it.dataPathArr = [undefined]; + it.dataPathArr = [""]; if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { var $defaultMsg = 'default is ignored in the schema root'; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/allOf.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/allOf.js index 4bad914d605cc5..9c89544429f973 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/allOf.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/allOf.js @@ -17,7 +17,7 @@ module.exports = function generate_allOf(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $allSchemasEmpty = false; $it.schema = $sch; $it.schemaPath = $schemaPath + '[' + $i + ']'; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/anyOf.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/anyOf.js index 01551d54b18dfc..926400e3743b65 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/anyOf.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/anyOf.js @@ -15,7 +15,7 @@ module.exports = function generate_anyOf(it, $keyword, $ruleType) { $it.level++; var $nextValid = 'valid' + $it.level; var $noEmptySchema = $schema.every(function($sch) { - return (it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all)); + return (it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all)); }); if ($noEmptySchema) { var $currentBaseId = $it.baseId; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/contains.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/contains.js index cd4dfabebfb52f..255f9654e6d0e3 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/contains.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/contains.js @@ -18,7 +18,7 @@ module.exports = function generate_contains(it, $keyword, $ruleType) { $dataNxt = $it.dataLevel = it.dataLevel + 1, $nextData = 'data' + $dataNxt, $currentBaseId = it.baseId, - $nonEmptySchema = (it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all)); + $nonEmptySchema = (it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all)); out += 'var ' + ($errs) + ' = errors;var ' + ($valid) + ';'; if ($nonEmptySchema) { var $wasComposite = it.compositeRule; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/dependencies.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/dependencies.js index 96789360ef30db..81c8eb385bdab2 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/dependencies.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/dependencies.js @@ -142,7 +142,7 @@ module.exports = function generate_dependencies(it, $keyword, $ruleType) { var $currentBaseId = $it.baseId; for (var $property in $schemaDeps) { var $sch = $schemaDeps[$property]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { out += ' ' + ($nextValid) + ' = true; if ( ' + ($data) + (it.util.getProperty($property)) + ' !== undefined '; if ($ownProperties) { out += ' && Object.prototype.hasOwnProperty.call(' + ($data) + ', \'' + (it.util.escapeQuotes($property)) + '\') '; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/if.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/if.js index 019f61ab511d5b..36e7200f13a124 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/if.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/if.js @@ -15,8 +15,8 @@ module.exports = function generate_if(it, $keyword, $ruleType) { var $nextValid = 'valid' + $it.level; var $thenSch = it.schema['then'], $elseSch = it.schema['else'], - $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? typeof $thenSch == 'object' && Object.keys($thenSch).length > 0 : it.util.schemaHasRules($thenSch, it.RULES.all)), - $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? typeof $elseSch == 'object' && Object.keys($elseSch).length > 0 : it.util.schemaHasRules($elseSch, it.RULES.all)), + $thenPresent = $thenSch !== undefined && (it.opts.strictKeywords ? (typeof $thenSch == 'object' && Object.keys($thenSch).length > 0) || $thenSch === false : it.util.schemaHasRules($thenSch, it.RULES.all)), + $elsePresent = $elseSch !== undefined && (it.opts.strictKeywords ? (typeof $elseSch == 'object' && Object.keys($elseSch).length > 0) || $elseSch === false : it.util.schemaHasRules($elseSch, it.RULES.all)), $currentBaseId = $it.baseId; if ($thenPresent || $elsePresent) { var $ifClause; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/items.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/items.js index d5532f07c59144..8f92224cc7eaf7 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/items.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/items.js @@ -66,7 +66,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { out += ' ' + ($nextValid) + ' = true; if (' + ($data) + '.length > ' + ($i) + ') { '; var $passData = $data + '[' + $i + ']'; $it.schema = $sch; @@ -89,7 +89,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { } } } - if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0 : it.util.schemaHasRules($additionalItems, it.RULES.all))) { + if (typeof $additionalItems == 'object' && (it.opts.strictKeywords ? (typeof $additionalItems == 'object' && Object.keys($additionalItems).length > 0) || $additionalItems === false : it.util.schemaHasRules($additionalItems, it.RULES.all))) { $it.schema = $additionalItems; $it.schemaPath = it.schemaPath + '.additionalItems'; $it.errSchemaPath = it.errSchemaPath + '/additionalItems'; @@ -113,7 +113,7 @@ module.exports = function generate_items(it, $keyword, $ruleType) { $closingBraces += '}'; } } - } else if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + } else if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/not.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/not.js index 6aea6599144f8f..f50c93785b7129 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/not.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/not.js @@ -12,7 +12,7 @@ module.exports = function generate_not(it, $keyword, $ruleType) { var $it = it.util.copy(it); $it.level++; var $nextValid = 'valid' + $it.level; - if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/oneOf.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/oneOf.js index 30988d5e3d73d6..dfe2fd550ef289 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/oneOf.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/oneOf.js @@ -26,7 +26,7 @@ module.exports = function generate_oneOf(it, $keyword, $ruleType) { l1 = arr1.length - 1; while ($i < l1) { $sch = arr1[$i += 1]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $it.schema = $sch; $it.schemaPath = $schemaPath + '[' + $i + ']'; $it.errSchemaPath = $errSchemaPath + '/' + $i; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/properties.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/properties.js index 34a82c62d5dac6..fb2c23393220b6 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/properties.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/properties.js @@ -183,7 +183,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { while (i3 < l3) { $propertyKey = arr3[i3 += 1]; var $sch = $schema[$propertyKey]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { var $prop = it.util.getProperty($propertyKey), $passData = $data + $prop, $hasDefault = $useDefaults && $sch.default !== undefined; @@ -286,7 +286,7 @@ module.exports = function generate_properties(it, $keyword, $ruleType) { while (i4 < l4) { $pProperty = arr4[i4 += 1]; var $sch = $pProperties[$pProperty]; - if ((it.opts.strictKeywords ? typeof $sch == 'object' && Object.keys($sch).length > 0 : it.util.schemaHasRules($sch, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $sch == 'object' && Object.keys($sch).length > 0) || $sch === false : it.util.schemaHasRules($sch, it.RULES.all))) { $it.schema = $sch; $it.schemaPath = it.schemaPath + '.patternProperties' + it.util.getProperty($pProperty); $it.errSchemaPath = it.errSchemaPath + '/patternProperties/' + it.util.escapeFragment($pProperty); diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/propertyNames.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/propertyNames.js index b2bf2954041212..2ca36e2c980db1 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/propertyNames.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/propertyNames.js @@ -14,7 +14,7 @@ module.exports = function generate_propertyNames(it, $keyword, $ruleType) { $it.level++; var $nextValid = 'valid' + $it.level; out += 'var ' + ($errs) + ' = errors;'; - if ((it.opts.strictKeywords ? typeof $schema == 'object' && Object.keys($schema).length > 0 : it.util.schemaHasRules($schema, it.RULES.all))) { + if ((it.opts.strictKeywords ? (typeof $schema == 'object' && Object.keys($schema).length > 0) || $schema === false : it.util.schemaHasRules($schema, it.RULES.all))) { $it.schema = $schema; $it.schemaPath = $schemaPath; $it.errSchemaPath = $errSchemaPath; diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/required.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/required.js index 12110a4a262b53..14873eee3d528e 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/required.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/required.js @@ -28,7 +28,7 @@ module.exports = function generate_required(it, $keyword, $ruleType) { while (i1 < l1) { $property = arr1[i1 += 1]; var $propertySch = it.schema.properties[$property]; - if (!($propertySch && (it.opts.strictKeywords ? typeof $propertySch == 'object' && Object.keys($propertySch).length > 0 : it.util.schemaHasRules($propertySch, it.RULES.all)))) { + if (!($propertySch && (it.opts.strictKeywords ? (typeof $propertySch == 'object' && Object.keys($propertySch).length > 0) || $propertySch === false : it.util.schemaHasRules($propertySch, it.RULES.all)))) { $required[$required.length] = $property; } } diff --git a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/validate.js b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/validate.js index 233bf3a8b66daa..563575641c5fe4 100644 --- a/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/validate.js +++ b/tools/node_modules/eslint/node_modules/ajv/lib/dotjs/validate.js @@ -91,7 +91,7 @@ module.exports = function generate_validate(it, $keyword, $ruleType) { it.rootId = it.resolve.fullPath(it.self._getId(it.root.schema)); it.baseId = it.baseId || it.rootId; delete it.isTop; - it.dataPathArr = [undefined]; + it.dataPathArr = [""]; if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { var $defaultMsg = 'default is ignored in the schema root'; if (it.opts.strictDefaults === 'log') it.logger.warn($defaultMsg); diff --git a/tools/node_modules/eslint/node_modules/ajv/package.json b/tools/node_modules/eslint/node_modules/ajv/package.json index 94e4655b335231..bda64eac7c4623 100644 --- a/tools/node_modules/eslint/node_modules/ajv/package.json +++ b/tools/node_modules/eslint/node_modules/ajv/package.json @@ -102,5 +102,5 @@ }, "tonicExampleFilename": ".tonic_example.js", "typings": "lib/ajv.d.ts", - "version": "6.12.4" + "version": "6.12.5" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/debug/dist/debug.js b/tools/node_modules/eslint/node_modules/debug/dist/debug.js deleted file mode 100644 index 89ad0c2175c3d6..00000000000000 --- a/tools/node_modules/eslint/node_modules/debug/dist/debug.js +++ /dev/null @@ -1,912 +0,0 @@ -"use strict"; - -function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); } - -function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); } - -function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); } - -function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } } - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -(function (f) { - if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) === "object" && typeof module !== "undefined") { - module.exports = f(); - } else if (typeof define === "function" && define.amd) { - define([], f); - } else { - var g; - - if (typeof window !== "undefined") { - g = window; - } else if (typeof global !== "undefined") { - g = global; - } else if (typeof self !== "undefined") { - g = self; - } else { - g = this; - } - - g.debug = f(); - } -})(function () { - var define, module, exports; - return function () { - function r(e, n, t) { - function o(i, f) { - if (!n[i]) { - if (!e[i]) { - var c = "function" == typeof require && require; - if (!f && c) return c(i, !0); - if (u) return u(i, !0); - var a = new Error("Cannot find module '" + i + "'"); - throw a.code = "MODULE_NOT_FOUND", a; - } - - var p = n[i] = { - exports: {} - }; - e[i][0].call(p.exports, function (r) { - var n = e[i][1][r]; - return o(n || r); - }, p, p.exports, r, e, n, t); - } - - return n[i].exports; - } - - for (var u = "function" == typeof require && require, i = 0; i < t.length; i++) { - o(t[i]); - } - - return o; - } - - return r; - }()({ - 1: [function (require, module, exports) { - /** - * Helpers. - */ - var s = 1000; - var m = s * 60; - var h = m * 60; - var d = h * 24; - var w = d * 7; - var y = d * 365.25; - /** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} [options] - * @throws {Error} throw an error if val is not a non-empty string or a number - * @return {String|Number} - * @api public - */ - - module.exports = function (val, options) { - options = options || {}; - - var type = _typeof(val); - - if (type === 'string' && val.length > 0) { - return parse(val); - } else if (type === 'number' && isNaN(val) === false) { - return options.long ? fmtLong(val) : fmtShort(val); - } - - throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val)); - }; - /** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - - - function parse(str) { - str = String(str); - - if (str.length > 100) { - return; - } - - var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(str); - - if (!match) { - return; - } - - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - - case 'weeks': - case 'week': - case 'w': - return n * w; - - case 'days': - case 'day': - case 'd': - return n * d; - - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - - default: - return undefined; - } - } - /** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - - - function fmtShort(ms) { - var msAbs = Math.abs(ms); - - if (msAbs >= d) { - return Math.round(ms / d) + 'd'; - } - - if (msAbs >= h) { - return Math.round(ms / h) + 'h'; - } - - if (msAbs >= m) { - return Math.round(ms / m) + 'm'; - } - - if (msAbs >= s) { - return Math.round(ms / s) + 's'; - } - - return ms + 'ms'; - } - /** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - - - function fmtLong(ms) { - var msAbs = Math.abs(ms); - - if (msAbs >= d) { - return plural(ms, msAbs, d, 'day'); - } - - if (msAbs >= h) { - return plural(ms, msAbs, h, 'hour'); - } - - if (msAbs >= m) { - return plural(ms, msAbs, m, 'minute'); - } - - if (msAbs >= s) { - return plural(ms, msAbs, s, 'second'); - } - - return ms + ' ms'; - } - /** - * Pluralization helper. - */ - - - function plural(ms, msAbs, n, name) { - var isPlural = msAbs >= n * 1.5; - return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); - } - }, {}], - 2: [function (require, module, exports) { - // shim for using process in browser - var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it - // don't break things. But we need to wrap it in a try catch in case it is - // wrapped in strict mode code which doesn't define any globals. It's inside a - // function because try/catches deoptimize in certain engines. - - var cachedSetTimeout; - var cachedClearTimeout; - - function defaultSetTimout() { - throw new Error('setTimeout has not been defined'); - } - - function defaultClearTimeout() { - throw new Error('clearTimeout has not been defined'); - } - - (function () { - try { - if (typeof setTimeout === 'function') { - cachedSetTimeout = setTimeout; - } else { - cachedSetTimeout = defaultSetTimout; - } - } catch (e) { - cachedSetTimeout = defaultSetTimout; - } - - try { - if (typeof clearTimeout === 'function') { - cachedClearTimeout = clearTimeout; - } else { - cachedClearTimeout = defaultClearTimeout; - } - } catch (e) { - cachedClearTimeout = defaultClearTimeout; - } - })(); - - function runTimeout(fun) { - if (cachedSetTimeout === setTimeout) { - //normal enviroments in sane situations - return setTimeout(fun, 0); - } // if setTimeout wasn't available but was latter defined - - - if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { - cachedSetTimeout = setTimeout; - return setTimeout(fun, 0); - } - - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedSetTimeout(fun, 0); - } catch (e) { - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedSetTimeout.call(null, fun, 0); - } catch (e) { - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error - return cachedSetTimeout.call(this, fun, 0); - } - } - } - - function runClearTimeout(marker) { - if (cachedClearTimeout === clearTimeout) { - //normal enviroments in sane situations - return clearTimeout(marker); - } // if clearTimeout wasn't available but was latter defined - - - if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { - cachedClearTimeout = clearTimeout; - return clearTimeout(marker); - } - - try { - // when when somebody has screwed with setTimeout but no I.E. maddness - return cachedClearTimeout(marker); - } catch (e) { - try { - // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally - return cachedClearTimeout.call(null, marker); - } catch (e) { - // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. - // Some versions of I.E. have different rules for clearTimeout vs setTimeout - return cachedClearTimeout.call(this, marker); - } - } - } - - var queue = []; - var draining = false; - var currentQueue; - var queueIndex = -1; - - function cleanUpNextTick() { - if (!draining || !currentQueue) { - return; - } - - draining = false; - - if (currentQueue.length) { - queue = currentQueue.concat(queue); - } else { - queueIndex = -1; - } - - if (queue.length) { - drainQueue(); - } - } - - function drainQueue() { - if (draining) { - return; - } - - var timeout = runTimeout(cleanUpNextTick); - draining = true; - var len = queue.length; - - while (len) { - currentQueue = queue; - queue = []; - - while (++queueIndex < len) { - if (currentQueue) { - currentQueue[queueIndex].run(); - } - } - - queueIndex = -1; - len = queue.length; - } - - currentQueue = null; - draining = false; - runClearTimeout(timeout); - } - - process.nextTick = function (fun) { - var args = new Array(arguments.length - 1); - - if (arguments.length > 1) { - for (var i = 1; i < arguments.length; i++) { - args[i - 1] = arguments[i]; - } - } - - queue.push(new Item(fun, args)); - - if (queue.length === 1 && !draining) { - runTimeout(drainQueue); - } - }; // v8 likes predictible objects - - - function Item(fun, array) { - this.fun = fun; - this.array = array; - } - - Item.prototype.run = function () { - this.fun.apply(null, this.array); - }; - - process.title = 'browser'; - process.browser = true; - process.env = {}; - process.argv = []; - process.version = ''; // empty string to avoid regexp issues - - process.versions = {}; - - function noop() {} - - process.on = noop; - process.addListener = noop; - process.once = noop; - process.off = noop; - process.removeListener = noop; - process.removeAllListeners = noop; - process.emit = noop; - process.prependListener = noop; - process.prependOnceListener = noop; - - process.listeners = function (name) { - return []; - }; - - process.binding = function (name) { - throw new Error('process.binding is not supported'); - }; - - process.cwd = function () { - return '/'; - }; - - process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); - }; - - process.umask = function () { - return 0; - }; - }, {}], - 3: [function (require, module, exports) { - /** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - */ - function setup(env) { - createDebug.debug = createDebug; - createDebug.default = createDebug; - createDebug.coerce = coerce; - createDebug.disable = disable; - createDebug.enable = enable; - createDebug.enabled = enabled; - createDebug.humanize = require('ms'); - Object.keys(env).forEach(function (key) { - createDebug[key] = env[key]; - }); - /** - * Active `debug` instances. - */ - - createDebug.instances = []; - /** - * The currently active debug mode names, and names to skip. - */ - - createDebug.names = []; - createDebug.skips = []; - /** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". - */ - - createDebug.formatters = {}; - /** - * Selects a color for a debug namespace - * @param {String} namespace The namespace string for the for the debug instance to be colored - * @return {Number|String} An ANSI color code for the given namespace - * @api private - */ - - function selectColor(namespace) { - var hash = 0; - - for (var i = 0; i < namespace.length; i++) { - hash = (hash << 5) - hash + namespace.charCodeAt(i); - hash |= 0; // Convert to 32bit integer - } - - return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; - } - - createDebug.selectColor = selectColor; - /** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - - function createDebug(namespace) { - var prevTime; - - function debug() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - // Disabled? - if (!debug.enabled) { - return; - } - - var self = debug; // Set `diff` timestamp - - var curr = Number(new Date()); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - args[0] = createDebug.coerce(args[0]); - - if (typeof args[0] !== 'string') { - // Anything else let's inspect with %O - args.unshift('%O'); - } // Apply any `formatters` transformations - - - var index = 0; - args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { - // If we encounter an escaped % then don't increase the array index - if (match === '%%') { - return match; - } - - index++; - var formatter = createDebug.formatters[format]; - - if (typeof formatter === 'function') { - var val = args[index]; - match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` - - args.splice(index, 1); - index--; - } - - return match; - }); // Apply env-specific formatting (colors, etc.) - - createDebug.formatArgs.call(self, args); - var logFn = self.log || createDebug.log; - logFn.apply(self, args); - } - - debug.namespace = namespace; - debug.enabled = createDebug.enabled(namespace); - debug.useColors = createDebug.useColors(); - debug.color = selectColor(namespace); - debug.destroy = destroy; - debug.extend = extend; // Debug.formatArgs = formatArgs; - // debug.rawLog = rawLog; - // env-specific initialization logic for debug instances - - if (typeof createDebug.init === 'function') { - createDebug.init(debug); - } - - createDebug.instances.push(debug); - return debug; - } - - function destroy() { - var index = createDebug.instances.indexOf(this); - - if (index !== -1) { - createDebug.instances.splice(index, 1); - return true; - } - - return false; - } - - function extend(namespace, delimiter) { - var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); - newDebug.log = this.log; - return newDebug; - } - /** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - - - function enable(namespaces) { - createDebug.save(namespaces); - createDebug.names = []; - createDebug.skips = []; - var i; - var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); - var len = split.length; - - for (i = 0; i < len; i++) { - if (!split[i]) { - // ignore empty strings - continue; - } - - namespaces = split[i].replace(/\*/g, '.*?'); - - if (namespaces[0] === '-') { - createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - createDebug.names.push(new RegExp('^' + namespaces + '$')); - } - } - - for (i = 0; i < createDebug.instances.length; i++) { - var instance = createDebug.instances[i]; - instance.enabled = createDebug.enabled(instance.namespace); - } - } - /** - * Disable debug output. - * - * @return {String} namespaces - * @api public - */ - - - function disable() { - var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) { - return '-' + namespace; - }))).join(','); - createDebug.enable(''); - return namespaces; - } - /** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - - - function enabled(name) { - if (name[name.length - 1] === '*') { - return true; - } - - var i; - var len; - - for (i = 0, len = createDebug.skips.length; i < len; i++) { - if (createDebug.skips[i].test(name)) { - return false; - } - } - - for (i = 0, len = createDebug.names.length; i < len; i++) { - if (createDebug.names[i].test(name)) { - return true; - } - } - - return false; - } - /** - * Convert regexp to namespace - * - * @param {RegExp} regxep - * @return {String} namespace - * @api private - */ - - - function toNamespace(regexp) { - return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*'); - } - /** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - - - function coerce(val) { - if (val instanceof Error) { - return val.stack || val.message; - } - - return val; - } - - createDebug.enable(createDebug.load()); - return createDebug; - } - - module.exports = setup; - }, { - "ms": 1 - }], - 4: [function (require, module, exports) { - (function (process) { - /* eslint-env browser */ - - /** - * This is the web browser implementation of `debug()`. - */ - exports.log = log; - exports.formatArgs = formatArgs; - exports.save = save; - exports.load = load; - exports.useColors = useColors; - exports.storage = localstorage(); - /** - * Colors. - */ - - exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33']; - /** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - // eslint-disable-next-line complexity - - function useColors() { - // NB: In an Electron preload script, document will be defined but not fully - // initialized. Since we know we're in Chrome, we'll just detect this case - // explicitly - if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { - return true; - } // Internet Explorer and Edge do not support colors. - - - if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { - return false; - } // Is webkit? http://stackoverflow.com/a/16459606/376773 - // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 - - - return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 - typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker - typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); - } - /** - * Colorize log arguments if enabled. - * - * @api public - */ - - - function formatArgs(args) { - args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); - - if (!this.useColors) { - return; - } - - var c = 'color: ' + this.color; - args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - - var index = 0; - var lastC = 0; - args[0].replace(/%[a-zA-Z%]/g, function (match) { - if (match === '%%') { - return; - } - - index++; - - if (match === '%c') { - // We only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - args.splice(lastC, 0, c); - } - /** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - - - function log() { - var _console; - - // This hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); - } - /** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - - - function save(namespaces) { - try { - if (namespaces) { - exports.storage.setItem('debug', namespaces); - } else { - exports.storage.removeItem('debug'); - } - } catch (error) {// Swallow - // XXX (@Qix-) should we be logging these? - } - } - /** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - - - function load() { - var r; - - try { - r = exports.storage.getItem('debug'); - } catch (error) {} // Swallow - // XXX (@Qix-) should we be logging these? - // If debug isn't set in LS, and we're in Electron, try to load $DEBUG - - - if (!r && typeof process !== 'undefined' && 'env' in process) { - r = process.env.DEBUG; - } - - return r; - } - /** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - - - function localstorage() { - try { - // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context - // The Browser also has localStorage in the global context. - return localStorage; - } catch (error) {// Swallow - // XXX (@Qix-) should we be logging these? - } - } - - module.exports = require('./common')(exports); - var formatters = module.exports.formatters; - /** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - - formatters.j = function (v) { - try { - return JSON.stringify(v); - } catch (error) { - return '[UnexpectedJSONParseError]: ' + error.message; - } - }; - }).call(this, require('_process')); - }, { - "./common": 3, - "_process": 2 - }] - }, {}, [4])(4); -}); diff --git a/tools/node_modules/eslint/node_modules/debug/package.json b/tools/node_modules/eslint/node_modules/debug/package.json index 7bc94f7f061070..5f2e838cb3d384 100644 --- a/tools/node_modules/eslint/node_modules/debug/package.json +++ b/tools/node_modules/eslint/node_modules/debug/package.json @@ -17,34 +17,35 @@ { "name": "Andrew Rhyne", "email": "rhyneandrew@gmail.com" + }, + { + "name": "Josh Junon", + "email": "josh@junon.me" } ], "dependencies": { - "ms": "^2.1.1" + "ms": "2.1.2" }, "deprecated": false, "description": "small debugging utility", "devDependencies": { - "@babel/cli": "^7.0.0", - "@babel/core": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "browserify": "14.4.0", - "chai": "^3.5.0", - "concurrently": "^3.1.0", + "brfs": "^2.0.1", + "browserify": "^16.2.3", "coveralls": "^3.0.2", "istanbul": "^0.4.5", - "karma": "^3.0.0", - "karma-chai": "^0.1.0", + "karma": "^3.1.4", + "karma-browserify": "^6.0.0", + "karma-chrome-launcher": "^2.2.0", "karma-mocha": "^1.3.0", - "karma-phantomjs-launcher": "^1.0.2", "mocha": "^5.2.0", "mocha-lcov-reporter": "^1.2.0", - "rimraf": "^2.5.4", "xo": "^0.23.0" }, + "engines": { + "node": ">=6.0" + }, "files": [ "src", - "dist/debug.js", "LICENSE", "README.md" ], @@ -57,23 +58,21 @@ "license": "MIT", "main": "./src/index.js", "name": "debug", + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + }, "repository": { "type": "git", "url": "git://github.com/visionmedia/debug.git" }, "scripts": { - "build": "npm run build:debug && npm run build:test", - "build:debug": "babel -o dist/debug.js dist/debug.es6.js > dist/debug.js", - "build:test": "babel -d dist test.js", - "clean": "rimraf dist coverage", "lint": "xo", - "prebuild:debug": "mkdir -p dist && browserify --standalone debug -o dist/debug.es6.js .", - "pretest:browser": "npm run build", - "test": "npm run test:node && npm run test:browser", + "test": "npm run test:node && npm run test:browser && npm run lint", "test:browser": "karma start --single-run", "test:coverage": "cat ./coverage/lcov.info | coveralls", "test:node": "istanbul cover _mocha -- test.js" }, - "unpkg": "./dist/debug.js", - "version": "4.1.1" + "version": "4.2.0" } \ No newline at end of file diff --git a/tools/node_modules/eslint/node_modules/debug/src/browser.js b/tools/node_modules/eslint/node_modules/debug/src/browser.js index 5f34c0d0a73f02..ac3f7e1339b985 100644 --- a/tools/node_modules/eslint/node_modules/debug/src/browser.js +++ b/tools/node_modules/eslint/node_modules/debug/src/browser.js @@ -4,7 +4,6 @@ * This is the web browser implementation of `debug()`. */ -exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; @@ -170,18 +169,14 @@ function formatArgs(args) { } /** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". + * Invokes `console.debug()` when available. + * No-op when `console.debug` is not a "function". + * If `console.debug` is not available, falls back + * to `console.log`. * * @api public */ -function log(...args) { - // This hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return typeof console === 'object' && - console.log && - console.log(...args); -} +exports.log = console.debug || console.log || (() => {}); /** * Save `namespaces`. diff --git a/tools/node_modules/eslint/node_modules/debug/src/common.js b/tools/node_modules/eslint/node_modules/debug/src/common.js index 2f82b8dc7d8865..da7eada619f824 100644 --- a/tools/node_modules/eslint/node_modules/debug/src/common.js +++ b/tools/node_modules/eslint/node_modules/debug/src/common.js @@ -117,13 +117,11 @@ function setup(env) { debug.namespace = namespace; debug.enabled = createDebug.enabled(namespace); debug.useColors = createDebug.useColors(); - debug.color = selectColor(namespace); + debug.color = createDebug.selectColor(namespace); debug.destroy = destroy; debug.extend = extend; - // Debug.formatArgs = formatArgs; - // debug.rawLog = rawLog; - // env-specific initialization logic for debug instances + // Env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } diff --git a/tools/node_modules/eslint/package.json b/tools/node_modules/eslint/package.json index 8801f73606f62c..3db68cf0490688 100644 --- a/tools/node_modules/eslint/package.json +++ b/tools/node_modules/eslint/package.json @@ -20,7 +20,7 @@ "doctrine": "^3.0.0", "enquirer": "^2.3.5", "eslint-plugin-markdown": "^1.0.2", - "eslint-scope": "^5.1.0", + "eslint-scope": "^5.1.1", "eslint-utils": "^2.1.0", "eslint-visitor-keys": "^1.3.0", "espree": "^7.3.0", @@ -154,5 +154,5 @@ "test:cli": "mocha", "webpack": "node Makefile.js webpack" }, - "version": "7.9.0" + "version": "7.10.0" } \ No newline at end of file From 70ad69ba462963ed1e249e3dbc37a0069cd4e22f Mon Sep 17 00:00:00 2001 From: Matthieu Larcher Date: Tue, 22 Sep 2020 14:43:32 +0200 Subject: [PATCH 37/42] doc: outline when origin is set to unhandledRejection PR-URL: https://github.com/nodejs/node/pull/35294 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Denys Otrishko Reviewed-By: Michael Dawson Reviewed-By: Rich Trott --- doc/api/process.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/process.md b/doc/api/process.md index 03733b2c7e8e4c..0f20ade9799225 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -237,7 +237,8 @@ changes: * `origin` {string} Indicates if the exception originates from an unhandled rejection or from an synchronous error. Can either be `'uncaughtException'` or `'unhandledRejection'`. The latter is only used in conjunction with the - [`--unhandled-rejections`][] flag set to `strict` and an unhandled rejection. + [`--unhandled-rejections`][] flag set to `strict` or `throw` and + an unhandled rejection. The `'uncaughtException'` event is emitted when an uncaught JavaScript exception bubbles all the way back to the event loop. By default, Node.js @@ -306,7 +307,9 @@ added: v13.7.0 * `err` {Error} The uncaught exception. * `origin` {string} Indicates if the exception originates from an unhandled rejection or from synchronous errors. Can either be `'uncaughtException'` or - `'unhandledRejection'`. + `'unhandledRejection'`. The latter is only used in conjunction with the + [`--unhandled-rejections`][] flag set to `strict` or `throw` and + an unhandled rejection. The `'uncaughtExceptionMonitor'` event is emitted before an `'uncaughtException'` event is emitted or a hook installed via From 99a79e32a6a8dfcad5c03430fb3ad863f7303201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sun, 27 Sep 2020 14:34:05 +0200 Subject: [PATCH 38/42] fs: fix fs.promises.writeFile with typed arrays Before this change, only the first part of typed arrays which have more than 1 byte per element (e.g. Uint16Array) would be written. This also removes the use of the `slice` method to avoid unnecessary copying the data. Fixes: https://github.com/nodejs/node/issues/35343 PR-URL: https://github.com/nodejs/node/pull/35376 Reviewed-By: Ruben Bridgewater Reviewed-By: Zeyu Yang Reviewed-By: Anna Henningsen --- lib/internal/fs/promises.js | 13 +++++++--- .../test-fs-promises-writefile-typedarray.js | 24 +++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 test/parallel/test-fs-promises-writefile-typedarray.js diff --git a/lib/internal/fs/promises.js b/lib/internal/fs/promises.js index a938b382eb1268..60a28735a982ec 100644 --- a/lib/internal/fs/promises.js +++ b/lib/internal/fs/promises.js @@ -10,12 +10,13 @@ const kReadFileMaxChunkSize = 2 ** 14; const kWriteFileMaxChunkSize = 2 ** 14; const { + Error, MathMax, MathMin, NumberIsSafeInteger, - Symbol, - Error, Promise, + Symbol, + Uint8Array, } = primordials; const { @@ -237,6 +238,8 @@ async function fsCall(fn, handle, ...args) { } async function writeFileHandle(filehandle, data) { + // `data` could be any kind of typed array. + data = new Uint8Array(data.buffer, data.byteOffset, data.byteLength); let remaining = data.length; if (remaining === 0) return; do { @@ -244,7 +247,11 @@ async function writeFileHandle(filehandle, data) { await write(filehandle, data, 0, MathMin(kWriteFileMaxChunkSize, data.length)); remaining -= bytesWritten; - data = data.slice(bytesWritten); + data = new Uint8Array( + data.buffer, + data.byteOffset + bytesWritten, + data.byteLength - bytesWritten + ); } while (remaining > 0); } diff --git a/test/parallel/test-fs-promises-writefile-typedarray.js b/test/parallel/test-fs-promises-writefile-typedarray.js new file mode 100644 index 00000000000000..32d9cffa236e57 --- /dev/null +++ b/test/parallel/test-fs-promises-writefile-typedarray.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +const fs = require('fs'); +const fsPromises = fs.promises; +const path = require('path'); +const tmpdir = require('../common/tmpdir'); +const assert = require('assert'); +const tmpDir = tmpdir.path; + +tmpdir.refresh(); + +const dest = path.resolve(tmpDir, 'tmp.txt'); +// Use a file size larger than `kReadFileMaxChunkSize`. +const buffer = Buffer.from('012'.repeat(2 ** 14)); + +(async () => { + for (const Constructor of [Uint8Array, Uint16Array, Uint32Array]) { + const array = new Constructor(buffer.buffer); + await fsPromises.writeFile(dest, array); + const data = await fsPromises.readFile(dest); + assert.deepStrictEqual(data, buffer); + } +})().then(common.mustCall()); From 46a4154cab38907aba2b58673c1f3f1627116d3f Mon Sep 17 00:00:00 2001 From: Guy Bedford Date: Sat, 26 Sep 2020 22:13:02 -0700 Subject: [PATCH 39/42] doc: packages docs feedback PR-URL: https://github.com/nodejs/node/pull/35370 Reviewed-By: Derek Lewis Reviewed-By: Geoffrey Booth Reviewed-By: Rich Trott --- doc/api/packages.md | 111 +++++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 58 deletions(-) diff --git a/doc/api/packages.md b/doc/api/packages.md index 737e777550c148..77183fb23ec499 100644 --- a/doc/api/packages.md +++ b/doc/api/packages.md @@ -4,11 +4,13 @@ ## Introduction -A package is a folder described by a `package.json` file. +A package is a folder tree described by a `package.json` file. The package +consists of the folder containing the `package.json` file and all subfolders +until the next folder containing another `package.json` file, or a folder +named `node_modules`. -A folder containing a `package.json` file, and all subfolders below that folder -until the next folder containing another `package.json` file, are a _package -scope_. +This page provides guidance for package authors writing `package.json` files +along with a reference for the [`package.json`][] fields defined by Node.js. ## Determining module system @@ -18,7 +20,7 @@ initial input, or when referenced by `import` statements within ES module code: * Files ending in `.mjs`. * Files ending in `.js` when the nearest parent `package.json` file contains a - top-level field [`"type"`][] with a value of `"module"`. + top-level [`"type"`][] field with a value of `"module"`. * Strings passed in as an argument to `--eval`, or piped to `node` via `STDIN`, with the flag `--input-type=module`. @@ -45,29 +47,25 @@ future-proof the package in case the default type of Node.js ever changes, and it will also make things easier for build tools and loaders to determine how the files in the package should be interpreted. -### Package scope and file extensions +### `package.json` and file extensions -A folder containing a `package.json` file, and all subfolders below that folder -until the next folder containing another [`package.json`][], are a -_package scope_. Package scopes do not carry through `node_modules` folders. - -Within a package scope, the [`package.json`][] [`"type"`][] field defines how +Within a package, the [`package.json`][] [`"type"`][] field defines how Node.js should interpret `.js` files. If a `package.json` file does not have a `"type"` field, `.js` files are treated as [CommonJS][]. A `package.json` `"type"` value of `"module"` tells Node.js to interpret `.js` -files within that package scope as using [ES module][] syntax. +files within that package as using [ES module][] syntax. -The package scope applies not only to initial entry points (`node my-app.js`) +The `"type"` field applies not only to initial entry points (`node my-app.js`) but also to files referenced by `import` statements and `import()` expressions. ```js -// my-app.js, in an ES module package scope because there is a package.json +// my-app.js, treated as an ES module because there is a package.json // file in the same folder with "type": "module". import './startup/init.js'; // Loaded as ES module since ./startup contains no package.json file, -// and therefore inherits the ES module package scope from one level up. +// and therefore inherits the "type" value from one level up. import 'commonjs-package'; // Loaded as CommonJS since ./node_modules/commonjs-package/package.json @@ -79,10 +77,10 @@ import './node_modules/commonjs-package/index.js'; ``` Files ending with `.mjs` are always loaded as [ES modules][] regardless of -package scope. +the nearest parent `package.json`. -Files ending with `.cjs` are always loaded as [CommonJS][] regardless of package -scope. +Files ending with `.cjs` are always loaded as [CommonJS][] regardless of the +nearest parent `package.json`. ```js import './legacy-file.cjs'; @@ -93,17 +91,17 @@ import 'commonjs-package/src/index.mjs'; ``` The `.mjs` and `.cjs` extensions may be used to mix types within the same -package scope: +package: -* Within a `"type": "module"` package scope, Node.js can be instructed to +* Within a `"type": "module"` package, Node.js can be instructed to interpret a particular file as [CommonJS][] by naming it with a `.cjs` extension (since both `.js` and `.mjs` files are treated as ES modules within - a `"module"` package scope). + a `"module"` package). -* Within a `"type": "commonjs"` package scope, Node.js can be instructed to +* Within a `"type": "commonjs"` package, Node.js can be instructed to interpret a particular file as an [ES module][] by naming it with an `.mjs` extension (since both `.js` and `.cjs` files are treated as CommonJS within a - `"commonjs"` package scope). + `"commonjs"` package). ### `--input-type` flag @@ -211,10 +209,10 @@ To set the main entry point for a package, it is advisable to define both } ``` -The benefit of doing this is that when using the [`"exports"`][] field all -subpaths of the package will no longer be available to importers under -`require('pkg/subpath.js')`, and instead they will get a new error, -`ERR_PACKAGE_PATH_NOT_EXPORTED`. +When defining the [`"exports"`][] field, all subpaths of the package will be +encapsulated and no longer available to importers. For example, +`require('pkg/subpath.js')` would throw an [`ERR_PACKAGE_PATH_NOT_EXPORTED`][] +error. This encapsulation of exports provides more reliable guarantees about package interfaces for tools and when handling semver upgrades for a @@ -295,24 +293,6 @@ treating the right hand side target pattern as a `**` glob against the list of files within the package. Because `node_modules` paths are forbidden in exports targets, this expansion is dependent on only the files of the package itself. -### Package exports fallbacks - -> Stability: 1 - Experimental - -For possible new specifier support in future, array fallbacks are -supported for all invalid specifiers: - -```json -{ - "exports": { - "./submodule": ["not:valid", "./submodule.js"] - } -} -``` - -Since `"not:valid"` is not a valid specifier, `"./submodule.js"` is used -instead as the fallback, as if it were the only target. - ### Exports sugar > Stability: 1 - Experimental @@ -560,9 +540,10 @@ could be intended only for other environments such as browsers. Such a package would be usable by any version of Node.js, since `import` can refer to CommonJS files; but it would not provide any of the advantages of using ES module syntax. -A package could also switch from CommonJS to ES module syntax in a breaking -change version bump. This has the disadvantage that the newest version -of the package would only be usable in ES module-supporting versions of Node.js. +A package could also switch from CommonJS to ES module syntax in a [breaking +change](https://semver.org/) version bump. This has the disadvantage that the +newest version of the package would only be usable in ES module-supporting +versions of Node.js. Every pattern has tradeoffs, but there are two broad approaches that satisfy the following conditions: @@ -773,6 +754,19 @@ This section describes the fields used by the Node.js runtime. Other tools (such as [npm](https://docs.npmjs.com/creating-a-package-json-file)) may use additional fields which are ignored by Node.js and not documented here. +The following fields in `package.json` files are used in Node.js: + +* [`"name"`][] - Relevant when using named imports within a package. Also used + by package managers as the name of the package. +* [`"type"`][] - The package type determining whether to load `.js` files as + CommonJS or ES modules. +* [`"exports"`][] - Package exports and conditional exports. When present, + limits which submodules may be loaded from within the package. +* [`"main"`][] - The default module when loading the package, if exports is not + specified, and in versions of Node.js prior to the introduction of exports. +* [`"imports"`][] - Package imports, for use by modules within the package + itself. + ### `"name"` -The vm context passed into the API is not yet initialized. This could happen -when an error occurs (and is caught) during the creation of the -context, for example, when the allocation fails or the maximum call stack -size is reached when the context is created. +A class constructor was called that is not callable. ### `ERR_CONSTRUCT_CALL_REQUIRED` A constructor for a class was called without `new`. - -### `ERR_CONSTRUCT_CALL_INVALID` - + +### `ERR_CONTEXT_NOT_INITIALIZED` -A class constructor was called that is not callable. +The vm context passed into the API is not yet initialized. This could happen +when an error occurs (and is caught) during the creation of the +context, for example, when the allocation fails or the maximum call stack +size is reached when the context is created. ### `ERR_CPU_USAGE` @@ -940,11 +940,6 @@ allowed size for a `Buffer`. An invalid symlink type was passed to the [`fs.symlink()`][] or [`fs.symlinkSync()`][] methods. - -### `ERR_HTTP_REQUEST_TIMEOUT` - -The client has not sent the entire request within the allowed time. - ### `ERR_HTTP_HEADERS_SENT` @@ -1005,6 +1000,12 @@ A non-specific HTTP/2 error has occurred. New HTTP/2 Streams may not be opened after the `Http2Session` has received a `GOAWAY` frame from the connected peer. + +### `ERR_HTTP2_HEADER_SINGLE_VALUE` + +Multiple values were provided for an HTTP/2 header field that was required to +have only a single value. + ### `ERR_HTTP2_HEADERS_AFTER_RESPOND` @@ -1015,12 +1016,6 @@ An additional headers was specified after an HTTP/2 response was initiated. An attempt was made to send multiple response headers. - -### `ERR_HTTP2_HEADER_SINGLE_VALUE` - -Multiple values were provided for an HTTP/2 header field that was required to -have only a single value. - ### `ERR_HTTP2_INFO_STATUS_NOT_ALLOWED` @@ -1221,12 +1216,6 @@ is set for the `Http2Stream`. `http2.connect()` was passed a URL that uses any protocol other than `http:` or `https:`. - -### `ERR_INTERNAL_ASSERTION` - -There was a bug in Node.js or incorrect usage of Node.js internals. -To fix the error, open an issue at . - ### `ERR_INCOMPATIBLE_OPTION_PAIR` @@ -1287,6 +1276,12 @@ before it was connected. An API was called on the main thread that can only be used from the worker thread. + +### `ERR_INTERNAL_ASSERTION` + +There was a bug in Node.js or incorrect usage of Node.js internals. +To fix the error, open an issue at . + ### `ERR_INVALID_ADDRESS_FAMILY` @@ -1598,12 +1593,6 @@ strict compliance with the API specification (which in some cases may accept `func(undefined)` and `func()` are treated identically, and the [`ERR_INVALID_ARG_TYPE`][] error code may be used instead. - -### `ERR_MISSING_OPTION` - -For APIs that accept options objects, some options might be mandatory. This code -is thrown if a required option is missing. - ### `ERR_MISSING_MESSAGE_PORT_IN_TRANSFER_LIST` @@ -1611,6 +1600,12 @@ An object that needs to be explicitly listed in the `transferList` argument is in the object passed to a `postMessage()` call, but is not provided in the `transferList` for that call. Usually, this is a `MessagePort`. + +### `ERR_MISSING_OPTION` + +For APIs that accept options objects, some options might be mandatory. This code +is thrown if a required option is missing. + ### `ERR_MISSING_PASSPHRASE` @@ -1818,6 +1813,12 @@ A string was provided for a Subresource Integrity check, but was unable to be parsed. Check the format of integrity attributes by looking at the [Subresource Integrity specification][]. + +### `ERR_STREAM_ALREADY_FINISHED` + +A stream method was called that cannot complete because the stream was +finished. + ### `ERR_STREAM_CANNOT_PIPE` @@ -1829,12 +1830,6 @@ An attempt was made to call [`stream.pipe()`][] on a [`Writable`][] stream. A stream method was called that cannot complete because the stream was destroyed using `stream.destroy()`. - -### `ERR_STREAM_ALREADY_FINISHED` - -A stream method was called that cannot complete because the stream was -finished. - ### `ERR_STREAM_NULL_VALUES` @@ -1924,15 +1919,6 @@ added: v13.3.0 The context must be a `SecureContext`. - -### `ERR_TLS_INVALID_STATE` - - -The TLS socket must be connected and securily established. Ensure the 'secure' -event is emitted before continuing. - ### `ERR_TLS_INVALID_PROTOCOL_METHOD` @@ -1944,12 +1930,28 @@ disabled because it is insecure. Valid TLS protocol versions are `'TLSv1'`, `'TLSv1.1'`, or `'TLSv1.2'`. + +### `ERR_TLS_INVALID_STATE` + + +The TLS socket must be connected and securily established. Ensure the 'secure' +event is emitted before continuing. + ### `ERR_TLS_PROTOCOL_VERSION_CONFLICT` Attempting to set a TLS protocol `minVersion` or `maxVersion` conflicts with an attempt to set the `secureProtocol` explicitly. Use one mechanism or the other. + +### `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` + +Failed to set PSK identity hint. Hint may be too long. + ### `ERR_TLS_RENEGOTIATION_DISABLED` @@ -1973,11 +1975,6 @@ vector for denial-of-service attacks. An attempt was made to issue Server Name Indication from a TLS server-side socket, which is only valid from a client. - -### `ERR_TLS_PSK_SET_IDENTIY_HINT_FAILED` - -Failed to set PSK identity hint. Hint may be too long. - ### `ERR_TRACE_EVENTS_CATEGORY_REQUIRED` @@ -2332,6 +2329,11 @@ removed: v10.0.0 Used when an invalid character is found in an HTTP response status message (reason phrase). + +### `ERR_HTTP_REQUEST_TIMEOUT` + +The client has not sent the entire request within the allowed time. + ### `ERR_INDEX_OUT_OF_RANGE` #### Error codes for `RST_STREAM` and `GOAWAY` - | Value | Name | Constant | |--------|---------------------|-----------------------------------------------| @@ -3697,5 +3696,5 @@ following additional properties: [`tls.TLSSocket`]: tls.html#tls_class_tls_tlssocket [`tls.connect()`]: tls.html#tls_tls_connect_options_callback [`tls.createServer()`]: tls.html#tls_tls_createserver_options_secureconnectionlistener -[error code]: #error_codes [`writable.writableFinished`]: stream.html#stream_writable_writablefinished +[error code]: #http2_error_codes_for_rst_stream_and_goaway From c0486072d1af16444b269524f46c8d20891d28b0 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 29 Sep 2020 12:16:55 -0400 Subject: [PATCH 42/42] 2020-09-29, Version 14.13.0 (Current) Notable changes: deps: * (SEMVER-MINOR) upgrade to libuv 1.40.0 (Colin Ihrig) https://github.com/nodejs/node/pull/35333 module: * (SEMVER-MINOR) named exports for CJS via static analysis (Guy Bedford) https://github.com/nodejs/node/pull/35249 * (SEMVER-MINOR) exports pattern support (Guy Bedford) https://github.com/nodejs/node/pull/34718 src: * (SEMVER-MINOR) allow N-API addon in `AddLinkedBinding()` (Anna Henningsen) https://github.com/nodejs/node/pull/35301 PR-URL: https://github.com/nodejs/node/pull/35419 --- CHANGELOG.md | 3 +- doc/changelogs/CHANGELOG_V14.md | 56 +++++++++++++++++++++++++++++++++ src/node_version.h | 6 ++-- 3 files changed, 61 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 079a83e9778817..ce5d46bf1382ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,8 @@ release. -14.12.0
+14.13.0
+14.12.0
14.11.0
14.10.1
14.10.0
diff --git a/doc/changelogs/CHANGELOG_V14.md b/doc/changelogs/CHANGELOG_V14.md index e26fc41877f30c..67ffe419e293ab 100644 --- a/doc/changelogs/CHANGELOG_V14.md +++ b/doc/changelogs/CHANGELOG_V14.md @@ -10,6 +10,8 @@ +14.13.0
+14.12.0
14.11.0
14.10.1
14.10.0
@@ -43,6 +45,60 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2020-09-29, Version 14.13.0 (Current), @MylesBorins + +### Notable Changes + +* [[`19b95a7fa9`](https://github.com/nodejs/node/commit/19b95a7fa9)] - **(SEMVER-MINOR)** **deps**: upgrade to libuv 1.40.0 (Colin Ihrig) [#35333](https://github.com/nodejs/node/pull/35333) +* [[`f551f52f83`](https://github.com/nodejs/node/commit/f551f52f83)] - **(SEMVER-MINOR)** **module**: named exports for CJS via static analysis (Guy Bedford) [#35249](https://github.com/nodejs/node/pull/35249) +* [[`505731871e`](https://github.com/nodejs/node/commit/505731871e)] - **(SEMVER-MINOR)** **module**: exports pattern support (Guy Bedford) [#34718](https://github.com/nodejs/node/pull/34718) +* [[`0d8eaa3942`](https://github.com/nodejs/node/commit/0d8eaa3942)] - **(SEMVER-MINOR)** **src**: allow N-API addon in `AddLinkedBinding()` (Anna Henningsen) [#35301](https://github.com/nodejs/node/pull/35301) + +### Commits + +* [[`19b95a7fa9`](https://github.com/nodejs/node/commit/19b95a7fa9)] - **(SEMVER-MINOR)** **deps**: upgrade to libuv 1.40.0 (Colin Ihrig) [#35333](https://github.com/nodejs/node/pull/35333) +* [[`353a567235`](https://github.com/nodejs/node/commit/353a567235)] - **deps**: upgrade to c-ares v1.16.1 (Shelley Vohr) [#35324](https://github.com/nodejs/node/pull/35324) +* [[`2e10616d48`](https://github.com/nodejs/node/commit/2e10616d48)] - **doc**: remove http2 non-link anchor tags (Rich Trott) [#35161](https://github.com/nodejs/node/pull/35161) +* [[`02db136c49`](https://github.com/nodejs/node/commit/02db136c49)] - **doc**: alphabetize error list (Rich Trott) [#35219](https://github.com/nodejs/node/pull/35219) +* [[`46a4154cab`](https://github.com/nodejs/node/commit/46a4154cab)] - **doc**: packages docs feedback (Guy Bedford) [#35370](https://github.com/nodejs/node/pull/35370) +* [[`70ad69ba46`](https://github.com/nodejs/node/commit/70ad69ba46)] - **doc**: outline when origin is set to unhandledRejection (Matthieu Larcher) [#35294](https://github.com/nodejs/node/pull/35294) +* [[`010173a4b7`](https://github.com/nodejs/node/commit/010173a4b7)] - **doc**: edit n-api.md for minor improvements (Rich Trott) [#35361](https://github.com/nodejs/node/pull/35361) +* [[`86ac7497e0`](https://github.com/nodejs/node/commit/86ac7497e0)] - **doc**: add history entry for breaking destroy() change (Gil Pedersen) [#35326](https://github.com/nodejs/node/pull/35326) +* [[`857e321baf`](https://github.com/nodejs/node/commit/857e321baf)] - **doc**: set encoding to hex before piping hash (Victor Antonio Barzana Crespo) [#35338](https://github.com/nodejs/node/pull/35338) +* [[`87dfed012c`](https://github.com/nodejs/node/commit/87dfed012c)] - **doc**: add gpg key export directions to releases doc (Danielle Adams) [#35298](https://github.com/nodejs/node/pull/35298) +* [[`1758ac8237`](https://github.com/nodejs/node/commit/1758ac8237)] - **doc**: added version 7 to N-API version matrix (NickNaso) [#35319](https://github.com/nodejs/node/pull/35319) +* [[`5da5d41b1c`](https://github.com/nodejs/node/commit/5da5d41b1c)] - **doc**: refine require/import conditions constraints (Guy Bedford) [#35311](https://github.com/nodejs/node/pull/35311) +* [[`482ce6ce1d`](https://github.com/nodejs/node/commit/482ce6ce1d)] - **doc**: improve N-API string-to-native doc (Gabriel Schulhof) [#35322](https://github.com/nodejs/node/pull/35322) +* [[`6dc6dadfc6`](https://github.com/nodejs/node/commit/6dc6dadfc6)] - **doc**: avoid referring to C array size (Tobias Nießen) [#35300](https://github.com/nodejs/node/pull/35300) +* [[`0a847ca729`](https://github.com/nodejs/node/commit/0a847ca729)] - **doc**: update napi\_make\_callback documentation (Gerhard Stoebich) [#35321](https://github.com/nodejs/node/pull/35321) +* [[`a8d3a7f742`](https://github.com/nodejs/node/commit/a8d3a7f742)] - **doc**: put landing specifics in details tag (Rich Trott) [#35296](https://github.com/nodejs/node/pull/35296) +* [[`dd530364d0`](https://github.com/nodejs/node/commit/dd530364d0)] - **doc**: fixup lutimes metadata (Anna Henningsen) [#35328](https://github.com/nodejs/node/pull/35328) +* [[`d7282c0ae3`](https://github.com/nodejs/node/commit/d7282c0ae3)] - **doc**: edit subpath export patterns introduction (Rich Trott) [#35254](https://github.com/nodejs/node/pull/35254) +* [[`1d1ce1fc2c`](https://github.com/nodejs/node/commit/1d1ce1fc2c)] - **doc**: document support for package.json fields (Antoine du HAMEL) [#34970](https://github.com/nodejs/node/pull/34970) +* [[`ef0d2ef5a2`](https://github.com/nodejs/node/commit/ef0d2ef5a2)] - **doc**: move package config docs to separate page (Antoine du HAMEL) [#34748](https://github.com/nodejs/node/pull/34748) +* [[`b9d767c4d5`](https://github.com/nodejs/node/commit/b9d767c4d5)] - **doc**: change type of child\_process.signalCode to string (Linn Dahlgren) [#35223](https://github.com/nodejs/node/pull/35223) +* [[`b4514d464d`](https://github.com/nodejs/node/commit/b4514d464d)] - **doc**: replace "this guide" link text with guide title (Rich Trott) [#35283](https://github.com/nodejs/node/pull/35283) +* [[`1893449724`](https://github.com/nodejs/node/commit/1893449724)] - **doc**: revise dependency redirection text in policy.md (Rich Trott) [#35276](https://github.com/nodejs/node/pull/35276) +* [[`0c4540b050`](https://github.com/nodejs/node/commit/0c4540b050)] - **doc**: fix heading space bug in assert.md (Thomas Hunter II) [#35310](https://github.com/nodejs/node/pull/35310) +* [[`ec6b78ae73`](https://github.com/nodejs/node/commit/ec6b78ae73)] - **doc**: add `socket.readyState` (Clark Kozak) [#35262](https://github.com/nodejs/node/pull/35262) +* [[`2a4ae0926d`](https://github.com/nodejs/node/commit/2a4ae0926d)] - **doc**: update crypto.createSecretKey accepted types (Filip Skokan) [#35246](https://github.com/nodejs/node/pull/35246) +* [[`c09f3dc2f3`](https://github.com/nodejs/node/commit/c09f3dc2f3)] - **doc**: put release script specifics in details (Myles Borins) [#35260](https://github.com/nodejs/node/pull/35260) +* [[`99a79e32a6`](https://github.com/nodejs/node/commit/99a79e32a6)] - **fs**: fix fs.promises.writeFile with typed arrays (Michaël Zasso) [#35376](https://github.com/nodejs/node/pull/35376) +* [[`ab7d0e92b1`](https://github.com/nodejs/node/commit/ab7d0e92b1)] - **meta**: update module pages in CODEOWNERS (Antoine du Hamel) [#34932](https://github.com/nodejs/node/pull/34932) +* [[`f551f52f83`](https://github.com/nodejs/node/commit/f551f52f83)] - **(SEMVER-MINOR)** **module**: named exports for CJS via static analysis (Guy Bedford) [#35249](https://github.com/nodejs/node/pull/35249) +* [[`505731871e`](https://github.com/nodejs/node/commit/505731871e)] - **(SEMVER-MINOR)** **module**: exports pattern support (Guy Bedford) [#34718](https://github.com/nodejs/node/pull/34718) +* [[`68ea7f5560`](https://github.com/nodejs/node/commit/68ea7f5560)] - **module**: fix crash on multiline named cjs imports (Christoph Tavan) [#35275](https://github.com/nodejs/node/pull/35275) +* [[`0f4ecaa741`](https://github.com/nodejs/node/commit/0f4ecaa741)] - **repl**: standardize Control key indications (Rich Trott) [#35270](https://github.com/nodejs/node/pull/35270) +* [[`1e1cb94e69`](https://github.com/nodejs/node/commit/1e1cb94e69)] - **src**: fix incorrect SIGSEGV handling in NODE\_USE\_V8\_WASM\_TRAP\_HANDLER (Anatoly Korniltsev) [#35282](https://github.com/nodejs/node/pull/35282) +* [[`0d8eaa3942`](https://github.com/nodejs/node/commit/0d8eaa3942)] - **(SEMVER-MINOR)** **src**: allow N-API addon in `AddLinkedBinding()` (Anna Henningsen) [#35301](https://github.com/nodejs/node/pull/35301) +* [[`f2635b317e`](https://github.com/nodejs/node/commit/f2635b317e)] - **test**: replace annonymous functions with arrow (Pooja D.P) [#34921](https://github.com/nodejs/node/pull/34921) +* [[`d7c28c9243`](https://github.com/nodejs/node/commit/d7c28c9243)] - **test,child_process**: add tests for signalCode value (Rich Trott) [#35327](https://github.com/nodejs/node/pull/35327) +* [[`80eb22185e`](https://github.com/nodejs/node/commit/80eb22185e)] - **tools**: update ESLint to 7.10.0 (Colin Ihrig) [#35366](https://github.com/nodejs/node/pull/35366) +* [[`7f355735df`](https://github.com/nodejs/node/commit/7f355735df)] - **tools**: ignore build folder when checking links (Ash Cripps) [#35315](https://github.com/nodejs/node/pull/35315) +* [[`c5d27e1e29`](https://github.com/nodejs/node/commit/c5d27e1e29)] - **tools,doc**: enforce alphabetical order for md refs (Antoine du Hamel) [#35244](https://github.com/nodejs/node/pull/35244) +* [[`9d91842a9d`](https://github.com/nodejs/node/commit/9d91842a9d)] - **tools,doc**: upgrade dependencies (Antoine du Hamel) [#35244](https://github.com/nodejs/node/pull/35244) + ## 2020-09-22, Version 14.12.0 (Current), @ruyadorno diff --git a/src/node_version.h b/src/node_version.h index 3ed00114a981e6..de11092c486214 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -23,13 +23,13 @@ #define SRC_NODE_VERSION_H_ #define NODE_MAJOR_VERSION 14 -#define NODE_MINOR_VERSION 12 -#define NODE_PATCH_VERSION 1 +#define NODE_MINOR_VERSION 13 +#define NODE_PATCH_VERSION 0 #define NODE_VERSION_IS_LTS 0 #define NODE_VERSION_LTS_CODENAME "" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)