From f744fae6df1bd3eba0390f3222d292e272fc6ff7 Mon Sep 17 00:00:00 2001 From: "street-side-software-automation[bot]" <74785433+street-side-software-automation[bot]@users.noreply.github.com> Date: Sat, 26 Nov 2022 16:30:46 +0100 Subject: [PATCH] feat: Update CSpell to (6.15.0) (main) (#1072) --- action-src/package.json | 4 +- action/node_modules/.bin/js-yaml | 1 + .../@cspell/cspell-bundled-dicts/package.json | 10 +- .../@cspell/cspell-pipe/package.json | 4 +- .../@cspell/cspell-service-bus/package.json | 4 +- .../@cspell/cspell-types/cspell.schema.json | 6 +- .../cspell-types/dist/DictionaryDefinition.js | 3 + .../@cspell/cspell-types/dist/index.js | 21 +- .../@cspell/cspell-types/package.json | 4 +- .../@cspell/strong-weak-map/package.json | 4 +- action/node_modules/@types/parse-json/LICENSE | 21 - .../node_modules/@types/parse-json/README.md | 16 - .../@types/parse-json/package.json | 22 - action/node_modules/argparse/CHANGELOG.md | 216 + action/node_modules/argparse/LICENSE | 254 ++ action/node_modules/argparse/README.md | 84 + action/node_modules/argparse/argparse.js | 3707 ++++++++++++++++ action/node_modules/argparse/lib/sub.js | 67 + action/node_modules/argparse/lib/textwrap.js | 440 ++ action/node_modules/argparse/package.json | 31 + action/node_modules/cosmiconfig/README.md | 9 +- .../node_modules/cosmiconfig/dist/Explorer.js | 17 +- .../cosmiconfig/dist/ExplorerSync.js | 17 +- .../node_modules/cosmiconfig/dist/loaders.js | 6 +- .../cosmiconfig/node_modules/.bin/js-yaml | 1 + action/node_modules/cosmiconfig/package.json | 13 +- .../SpellingDictionary/FlagWordsDictionary.js | 158 + .../ForbiddenWordsDictionary.js | 107 - .../IgnoreWordsDictionary.js | 2 +- .../SpellingDictionaryCollection.js | 42 +- .../SpellingDictionaryFromTrie.js | 10 +- .../dist/SpellingDictionary/Terms/index.js | 3 + .../dist/SpellingDictionary/Terms/terms.js | 3 + .../SpellingDictionary/Typos/typosParser.js | 11 +- .../dist/SpellingDictionary/Typos/util.js | 34 +- .../SpellingDictionary/TyposDictionary.js | 102 +- .../dist/SpellingDictionary/defaults.js | 3 +- .../dist/SpellingDictionary/index.js | 11 +- .../cspell-dictionary/dist/index.js | 3 +- .../dist/util/textMappers.js | 21 + .../cspell-dictionary/package.json | 10 +- .../cspell-gitignore/package.json | 6 +- action/node_modules/cspell-glob/package.json | 4 +- .../node_modules/cspell-grammar/package.json | 8 +- action/node_modules/cspell-io/package.json | 6 +- action/node_modules/cspell-lib/package.json | 28 +- .../dist/lib/suggestions/suggestCollector.js | 4 +- .../node_modules/cspell-trie-lib/package.json | 8 +- action/node_modules/cspell/package.json | 18 +- action/node_modules/js-yaml/CHANGELOG.md | 616 +++ action/node_modules/js-yaml/LICENSE | 21 + action/node_modules/js-yaml/README.md | 246 ++ action/node_modules/js-yaml/bin/js-yaml.js | 126 + action/node_modules/js-yaml/dist/js-yaml.js | 3874 +++++++++++++++++ .../node_modules/js-yaml/dist/js-yaml.min.js | 2 + action/node_modules/js-yaml/dist/js-yaml.mjs | 3851 ++++++++++++++++ action/node_modules/js-yaml/index.js | 47 + action/node_modules/js-yaml/lib/common.js | 59 + action/node_modules/js-yaml/lib/dumper.js | 965 ++++ action/node_modules/js-yaml/lib/exception.js | 55 + action/node_modules/js-yaml/lib/loader.js | 1727 ++++++++ action/node_modules/js-yaml/lib/schema.js | 121 + .../node_modules/js-yaml/lib/schema/core.js | 11 + .../js-yaml/lib/schema/default.js | 22 + .../js-yaml/lib/schema/failsafe.js | 17 + .../node_modules/js-yaml/lib/schema/json.js | 19 + action/node_modules/js-yaml/lib/snippet.js | 101 + action/node_modules/js-yaml/lib/type.js | 66 + .../node_modules/js-yaml/lib/type/binary.js | 125 + action/node_modules/js-yaml/lib/type/bool.js | 35 + action/node_modules/js-yaml/lib/type/float.js | 97 + action/node_modules/js-yaml/lib/type/int.js | 156 + action/node_modules/js-yaml/lib/type/map.js | 8 + action/node_modules/js-yaml/lib/type/merge.js | 12 + action/node_modules/js-yaml/lib/type/null.js | 35 + action/node_modules/js-yaml/lib/type/omap.js | 44 + action/node_modules/js-yaml/lib/type/pairs.js | 53 + action/node_modules/js-yaml/lib/type/seq.js | 8 + action/node_modules/js-yaml/lib/type/set.js | 29 + action/node_modules/js-yaml/lib/type/str.js | 8 + .../js-yaml/lib/type/timestamp.js | 88 + action/node_modules/js-yaml/package.json | 66 + action/node_modules/yaml/LICENSE | 13 - action/node_modules/yaml/README.md | 127 - .../yaml/browser/dist/PlainValue-b8036b75.js | 1275 ------ .../yaml/browser/dist/Schema-e94716c8.js | 682 --- .../node_modules/yaml/browser/dist/index.js | 1002 ----- .../yaml/browser/dist/legacy-exports.js | 3 - .../yaml/browser/dist/package.json | 1 - .../yaml/browser/dist/parse-cst.js | 1904 -------- .../yaml/browser/dist/resolveSeq-492ab440.js | 2419 ---------- .../node_modules/yaml/browser/dist/types.js | 4 - action/node_modules/yaml/browser/dist/util.js | 2 - .../yaml/browser/dist/warnings-df54cb69.js | 499 --- action/node_modules/yaml/browser/index.js | 1 - action/node_modules/yaml/browser/map.js | 2 - action/node_modules/yaml/browser/pair.js | 2 - action/node_modules/yaml/browser/parse-cst.js | 1 - action/node_modules/yaml/browser/scalar.js | 2 - action/node_modules/yaml/browser/schema.js | 9 - action/node_modules/yaml/browser/seq.js | 2 - action/node_modules/yaml/browser/types.js | 1 - .../node_modules/yaml/browser/types/binary.js | 8 - .../node_modules/yaml/browser/types/omap.js | 3 - .../node_modules/yaml/browser/types/pairs.js | 3 - action/node_modules/yaml/browser/types/set.js | 3 - .../yaml/browser/types/timestamp.js | 10 - action/node_modules/yaml/browser/util.js | 1 - .../yaml/dist/Document-9b4560a1.js | 757 ---- .../yaml/dist/PlainValue-ec8e588e.js | 876 ---- .../node_modules/yaml/dist/Schema-88e323a7.js | 525 --- action/node_modules/yaml/dist/index.js | 79 - .../node_modules/yaml/dist/legacy-exports.js | 16 - action/node_modules/yaml/dist/parse-cst.js | 1753 -------- .../yaml/dist/resolveSeq-d03cb037.js | 2161 --------- action/node_modules/yaml/dist/test-events.js | 162 - action/node_modules/yaml/dist/types.js | 23 - action/node_modules/yaml/dist/util.js | 19 - .../yaml/dist/warnings-1000a372.js | 416 -- action/node_modules/yaml/index.js | 1 - action/node_modules/yaml/map.js | 2 - action/node_modules/yaml/package.json | 106 - action/node_modules/yaml/pair.js | 2 - action/node_modules/yaml/parse-cst.js | 1 - action/node_modules/yaml/scalar.js | 2 - action/node_modules/yaml/schema.js | 9 - action/node_modules/yaml/seq.js | 2 - action/node_modules/yaml/types.js | 17 - action/node_modules/yaml/types.mjs | 17 - action/node_modules/yaml/types/binary.js | 8 - action/node_modules/yaml/types/omap.js | 3 - action/node_modules/yaml/types/pairs.js | 3 - action/node_modules/yaml/types/set.js | 3 - action/node_modules/yaml/types/timestamp.js | 10 - action/node_modules/yaml/util.js | 16 - action/node_modules/yaml/util.mjs | 18 - action/package.json | 4 +- yarn.lock | 175 +- 138 files changed, 18049 insertions(+), 15410 deletions(-) create mode 120000 action/node_modules/.bin/js-yaml create mode 100644 action/node_modules/@cspell/cspell-types/dist/DictionaryDefinition.js delete mode 100644 action/node_modules/@types/parse-json/LICENSE delete mode 100644 action/node_modules/@types/parse-json/README.md delete mode 100644 action/node_modules/@types/parse-json/package.json create mode 100644 action/node_modules/argparse/CHANGELOG.md create mode 100644 action/node_modules/argparse/LICENSE create mode 100644 action/node_modules/argparse/README.md create mode 100644 action/node_modules/argparse/argparse.js create mode 100644 action/node_modules/argparse/lib/sub.js create mode 100644 action/node_modules/argparse/lib/textwrap.js create mode 100644 action/node_modules/argparse/package.json create mode 120000 action/node_modules/cosmiconfig/node_modules/.bin/js-yaml create mode 100644 action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js delete mode 100644 action/node_modules/cspell-dictionary/dist/SpellingDictionary/ForbiddenWordsDictionary.js create mode 100644 action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js create mode 100644 action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js create mode 100644 action/node_modules/cspell-dictionary/dist/util/textMappers.js create mode 100644 action/node_modules/js-yaml/CHANGELOG.md create mode 100644 action/node_modules/js-yaml/LICENSE create mode 100644 action/node_modules/js-yaml/README.md create mode 100755 action/node_modules/js-yaml/bin/js-yaml.js create mode 100644 action/node_modules/js-yaml/dist/js-yaml.js create mode 100644 action/node_modules/js-yaml/dist/js-yaml.min.js create mode 100644 action/node_modules/js-yaml/dist/js-yaml.mjs create mode 100644 action/node_modules/js-yaml/index.js create mode 100644 action/node_modules/js-yaml/lib/common.js create mode 100644 action/node_modules/js-yaml/lib/dumper.js create mode 100644 action/node_modules/js-yaml/lib/exception.js create mode 100644 action/node_modules/js-yaml/lib/loader.js create mode 100644 action/node_modules/js-yaml/lib/schema.js create mode 100644 action/node_modules/js-yaml/lib/schema/core.js create mode 100644 action/node_modules/js-yaml/lib/schema/default.js create mode 100644 action/node_modules/js-yaml/lib/schema/failsafe.js create mode 100644 action/node_modules/js-yaml/lib/schema/json.js create mode 100644 action/node_modules/js-yaml/lib/snippet.js create mode 100644 action/node_modules/js-yaml/lib/type.js create mode 100644 action/node_modules/js-yaml/lib/type/binary.js create mode 100644 action/node_modules/js-yaml/lib/type/bool.js create mode 100644 action/node_modules/js-yaml/lib/type/float.js create mode 100644 action/node_modules/js-yaml/lib/type/int.js create mode 100644 action/node_modules/js-yaml/lib/type/map.js create mode 100644 action/node_modules/js-yaml/lib/type/merge.js create mode 100644 action/node_modules/js-yaml/lib/type/null.js create mode 100644 action/node_modules/js-yaml/lib/type/omap.js create mode 100644 action/node_modules/js-yaml/lib/type/pairs.js create mode 100644 action/node_modules/js-yaml/lib/type/seq.js create mode 100644 action/node_modules/js-yaml/lib/type/set.js create mode 100644 action/node_modules/js-yaml/lib/type/str.js create mode 100644 action/node_modules/js-yaml/lib/type/timestamp.js create mode 100644 action/node_modules/js-yaml/package.json delete mode 100644 action/node_modules/yaml/LICENSE delete mode 100644 action/node_modules/yaml/README.md delete mode 100644 action/node_modules/yaml/browser/dist/PlainValue-b8036b75.js delete mode 100644 action/node_modules/yaml/browser/dist/Schema-e94716c8.js delete mode 100644 action/node_modules/yaml/browser/dist/index.js delete mode 100644 action/node_modules/yaml/browser/dist/legacy-exports.js delete mode 100644 action/node_modules/yaml/browser/dist/package.json delete mode 100644 action/node_modules/yaml/browser/dist/parse-cst.js delete mode 100644 action/node_modules/yaml/browser/dist/resolveSeq-492ab440.js delete mode 100644 action/node_modules/yaml/browser/dist/types.js delete mode 100644 action/node_modules/yaml/browser/dist/util.js delete mode 100644 action/node_modules/yaml/browser/dist/warnings-df54cb69.js delete mode 100644 action/node_modules/yaml/browser/index.js delete mode 100644 action/node_modules/yaml/browser/map.js delete mode 100644 action/node_modules/yaml/browser/pair.js delete mode 100644 action/node_modules/yaml/browser/parse-cst.js delete mode 100644 action/node_modules/yaml/browser/scalar.js delete mode 100644 action/node_modules/yaml/browser/schema.js delete mode 100644 action/node_modules/yaml/browser/seq.js delete mode 100644 action/node_modules/yaml/browser/types.js delete mode 100644 action/node_modules/yaml/browser/types/binary.js delete mode 100644 action/node_modules/yaml/browser/types/omap.js delete mode 100644 action/node_modules/yaml/browser/types/pairs.js delete mode 100644 action/node_modules/yaml/browser/types/set.js delete mode 100644 action/node_modules/yaml/browser/types/timestamp.js delete mode 100644 action/node_modules/yaml/browser/util.js delete mode 100644 action/node_modules/yaml/dist/Document-9b4560a1.js delete mode 100644 action/node_modules/yaml/dist/PlainValue-ec8e588e.js delete mode 100644 action/node_modules/yaml/dist/Schema-88e323a7.js delete mode 100644 action/node_modules/yaml/dist/index.js delete mode 100644 action/node_modules/yaml/dist/legacy-exports.js delete mode 100644 action/node_modules/yaml/dist/parse-cst.js delete mode 100644 action/node_modules/yaml/dist/resolveSeq-d03cb037.js delete mode 100644 action/node_modules/yaml/dist/test-events.js delete mode 100644 action/node_modules/yaml/dist/types.js delete mode 100644 action/node_modules/yaml/dist/util.js delete mode 100644 action/node_modules/yaml/dist/warnings-1000a372.js delete mode 100644 action/node_modules/yaml/index.js delete mode 100644 action/node_modules/yaml/map.js delete mode 100644 action/node_modules/yaml/package.json delete mode 100644 action/node_modules/yaml/pair.js delete mode 100644 action/node_modules/yaml/parse-cst.js delete mode 100644 action/node_modules/yaml/scalar.js delete mode 100644 action/node_modules/yaml/schema.js delete mode 100644 action/node_modules/yaml/seq.js delete mode 100644 action/node_modules/yaml/types.js delete mode 100644 action/node_modules/yaml/types.mjs delete mode 100644 action/node_modules/yaml/types/binary.js delete mode 100644 action/node_modules/yaml/types/omap.js delete mode 100644 action/node_modules/yaml/types/pairs.js delete mode 100644 action/node_modules/yaml/types/set.js delete mode 100644 action/node_modules/yaml/types/timestamp.js delete mode 100644 action/node_modules/yaml/util.js delete mode 100644 action/node_modules/yaml/util.mjs diff --git a/action-src/package.json b/action-src/package.json index 6217cd714..3ba1e64fb 100644 --- a/action-src/package.json +++ b/action-src/package.json @@ -37,8 +37,8 @@ "@octokit/core": "^4.1.0", "@octokit/plugin-rest-endpoint-methods": "^6.7.0", "@octokit/rest": "^19.0.5", - "cspell": "^6.14.3", - "cspell-glob": "^6.14.3", + "cspell": "^6.15.0", + "cspell-glob": "^6.15.0", "vscode-uri": "^3.0.6" } } diff --git a/action/node_modules/.bin/js-yaml b/action/node_modules/.bin/js-yaml new file mode 120000 index 000000000..9dbd010d4 --- /dev/null +++ b/action/node_modules/.bin/js-yaml @@ -0,0 +1 @@ +../js-yaml/bin/js-yaml.js \ No newline at end of file diff --git a/action/node_modules/@cspell/cspell-bundled-dicts/package.json b/action/node_modules/@cspell/cspell-bundled-dicts/package.json index df56e9afb..38a2bd518 100644 --- a/action/node_modules/@cspell/cspell-bundled-dicts/package.json +++ b/action/node_modules/@cspell/cspell-bundled-dicts/package.json @@ -1,6 +1,6 @@ { "name": "@cspell/cspell-bundled-dicts", - "version": "6.14.3", + "version": "6.15.0", "description": "Dictionaries bundled with cspell", "publishConfig": { "access": "public" @@ -51,7 +51,7 @@ "@cspell/dict-companies": "^3.0.3", "@cspell/dict-cpp": "^4.0.0", "@cspell/dict-cryptocurrencies": "^3.0.1", - "@cspell/dict-csharp": "^4.0.1", + "@cspell/dict-csharp": "^4.0.2", "@cspell/dict-css": "^4.0.0", "@cspell/dict-dart": "^2.0.0", "@cspell/dict-django": "^4.0.0", @@ -92,8 +92,8 @@ "node": ">=14" }, "devDependencies": { - "@cspell/cspell-tools": "6.14.3", - "@cspell/cspell-types": "6.14.3" + "@cspell/cspell-tools": "6.15.0", + "@cspell/cspell-types": "6.15.0" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/@cspell/cspell-pipe/package.json b/action/node_modules/@cspell/cspell-pipe/package.json index 7c0cd6948..f33b1d2ab 100644 --- a/action/node_modules/@cspell/cspell-pipe/package.json +++ b/action/node_modules/@cspell/cspell-pipe/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.14.3", + "version": "6.15.0", "description": "Library to make working with Iterators/AsyncIterators easier.", "keywords": [ "cspell", @@ -114,5 +114,5 @@ "jest": "^29.3.1", "rimraf": "^3.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/@cspell/cspell-service-bus/package.json b/action/node_modules/@cspell/cspell-service-bus/package.json index ee624c8da..3ef7110ed 100644 --- a/action/node_modules/@cspell/cspell-service-bus/package.json +++ b/action/node_modules/@cspell/cspell-service-bus/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.14.3", + "version": "6.15.0", "description": "A Library for connecting requests to services that can fulfill them.", "keywords": [ "cspell" @@ -74,5 +74,5 @@ "jest": "^29.3.1", "rimraf": "^3.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/@cspell/cspell-types/cspell.schema.json b/action/node_modules/@cspell/cspell-types/cspell.schema.json index f330fa7e8..bfee7bfd7 100644 --- a/action/node_modules/@cspell/cspell-types/cspell.schema.json +++ b/action/node_modules/@cspell/cspell-types/cspell.schema.json @@ -171,7 +171,7 @@ "type": "object" }, "CustomDictionaryPath": { - "$ref": "#/definitions/FsPath", + "$ref": "#/definitions/FsDictionaryPath", "description": "A File System Path to a dictionary file." }, "CustomDictionaryScope": { @@ -535,6 +535,10 @@ }, "type": "object" }, + "FsDictionaryPath": { + "description": "A File System Path. Relative paths are relative to the configuration file.", + "type": "string" + }, "FsPath": { "description": "A File System Path. Relative paths are relative to the configuration file.", "type": "string" diff --git a/action/node_modules/@cspell/cspell-types/dist/DictionaryDefinition.js b/action/node_modules/@cspell/cspell-types/dist/DictionaryDefinition.js new file mode 100644 index 000000000..68b46c845 --- /dev/null +++ b/action/node_modules/@cspell/cspell-types/dist/DictionaryDefinition.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=DictionaryDefinition.js.map \ No newline at end of file diff --git a/action/node_modules/@cspell/cspell-types/dist/index.js b/action/node_modules/@cspell/cspell-types/dist/index.js index 88ee45b6d..bc6210975 100644 --- a/action/node_modules/@cspell/cspell-types/dist/index.js +++ b/action/node_modules/@cspell/cspell-types/dist/index.js @@ -1,23 +1,10 @@ "use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ConfigFields = void 0; +exports.MessageTypes = exports.IssueType = exports.ConfigFields = void 0; // Using old-style of `type` exports because the new style breaks some integrations. var configFields_1 = require("./configFields"); Object.defineProperty(exports, "ConfigFields", { enumerable: true, get: function () { return configFields_1.ConfigFields; } }); -__exportStar(require("./CSpellReporter"), exports); -__exportStar(require("./CSpellSettingsDef"), exports); +var CSpellReporter_1 = require("./CSpellReporter"); +Object.defineProperty(exports, "IssueType", { enumerable: true, get: function () { return CSpellReporter_1.IssueType; } }); +Object.defineProperty(exports, "MessageTypes", { enumerable: true, get: function () { return CSpellReporter_1.MessageTypes; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/@cspell/cspell-types/package.json b/action/node_modules/@cspell/cspell-types/package.json index ed9deecde..6d769354c 100644 --- a/action/node_modules/@cspell/cspell-types/package.json +++ b/action/node_modules/@cspell/cspell-types/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.14.3", + "version": "6.15.0", "description": "Types for cspell and cspell-lib", "type": "commonjs", "main": "dist/index.js", @@ -69,5 +69,5 @@ "ts-json-schema-generator": "^1.1.2", "typescript": "^4.9.3" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/@cspell/strong-weak-map/package.json b/action/node_modules/@cspell/strong-weak-map/package.json index 5dc02e01a..4afc5b7b0 100644 --- a/action/node_modules/@cspell/strong-weak-map/package.json +++ b/action/node_modules/@cspell/strong-weak-map/package.json @@ -3,7 +3,7 @@ "publishConfig": { "access": "public" }, - "version": "6.14.3", + "version": "6.15.0", "description": "A Map with weakly referenced values.", "keywords": [ "Map", @@ -69,5 +69,5 @@ "engines": { "node": ">=14.6" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/@types/parse-json/LICENSE b/action/node_modules/@types/parse-json/LICENSE deleted file mode 100644 index 4b1ad51b2..000000000 --- a/action/node_modules/@types/parse-json/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) Microsoft Corporation. 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 diff --git a/action/node_modules/@types/parse-json/README.md b/action/node_modules/@types/parse-json/README.md deleted file mode 100644 index 6c7d67d33..000000000 --- a/action/node_modules/@types/parse-json/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Installation -> `npm install --save @types/parse-json` - -# Summary -This package contains type definitions for parse-json (https://github.com/sindresorhus/parse-json). - -# Details -Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/parse-json - -Additional Details - * Last updated: Tue, 14 Nov 2017 00:30:05 GMT - * Dependencies: none - * Global values: none - -# Credits -These definitions were written by mrmlnc . diff --git a/action/node_modules/@types/parse-json/package.json b/action/node_modules/@types/parse-json/package.json deleted file mode 100644 index cdc08dc53..000000000 --- a/action/node_modules/@types/parse-json/package.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "@types/parse-json", - "version": "4.0.0", - "description": "TypeScript definitions for parse-json", - "license": "MIT", - "contributors": [ - { - "name": "mrmlnc", - "url": "https://github.com/mrmlnc", - "githubUsername": "mrmlnc" - } - ], - "main": "", - "repository": { - "type": "git", - "url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git" - }, - "scripts": {}, - "dependencies": {}, - "typesPublisherContentHash": "68b3120a3ffa0ae0c978a90b74a1e50adc0340a9d11f17cc1efb7bf2186e7751", - "typeScriptVersion": "2.0" -} \ No newline at end of file diff --git a/action/node_modules/argparse/CHANGELOG.md b/action/node_modules/argparse/CHANGELOG.md new file mode 100644 index 000000000..dc39ed695 --- /dev/null +++ b/action/node_modules/argparse/CHANGELOG.md @@ -0,0 +1,216 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [2.0.1] - 2020-08-29 +### Fixed +- Fix issue with `process.argv` when used with interpreters (`coffee`, `ts-node`, etc.), #150. + + +## [2.0.0] - 2020-08-14 +### Changed +- Full rewrite. Now port from python 3.9.0 & more precise following. + See [doc](./doc) for difference and migration info. +- node.js 10+ required +- Removed most of local docs in favour of original ones. + + +## [1.0.10] - 2018-02-15 +### Fixed +- Use .concat instead of + for arrays, #122. + + +## [1.0.9] - 2016-09-29 +### Changed +- Rerelease after 1.0.8 - deps cleanup. + + +## [1.0.8] - 2016-09-29 +### Changed +- Maintenance (deps bump, fix node 6.5+ tests, coverage report). + + +## [1.0.7] - 2016-03-17 +### Changed +- Teach `addArgument` to accept string arg names. #97, @tomxtobin. + + +## [1.0.6] - 2016-02-06 +### Changed +- Maintenance: moved to eslint & updated CS. + + +## [1.0.5] - 2016-02-05 +### Changed +- Removed lodash dependency to significantly reduce install size. + Thanks to @mourner. + + +## [1.0.4] - 2016-01-17 +### Changed +- Maintenance: lodash update to 4.0.0. + + +## [1.0.3] - 2015-10-27 +### Fixed +- Fix parse `=` in args: `--examplepath="C:\myfolder\env=x64"`. #84, @CatWithApple. + + +## [1.0.2] - 2015-03-22 +### Changed +- Relaxed lodash version dependency. + + +## [1.0.1] - 2015-02-20 +### Changed +- Changed dependencies to be compatible with ancient nodejs. + + +## [1.0.0] - 2015-02-19 +### Changed +- Maintenance release. +- Replaced `underscore` with `lodash`. +- Bumped version to 1.0.0 to better reflect semver meaning. +- HISTORY.md -> CHANGELOG.md + + +## [0.1.16] - 2013-12-01 +### Changed +- Maintenance release. Updated dependencies and docs. + + +## [0.1.15] - 2013-05-13 +### Fixed +- Fixed #55, @trebor89 + + +## [0.1.14] - 2013-05-12 +### Fixed +- Fixed #62, @maxtaco + + +## [0.1.13] - 2013-04-08 +### Changed +- Added `.npmignore` to reduce package size + + +## [0.1.12] - 2013-02-10 +### Fixed +- Fixed conflictHandler (#46), @hpaulj + + +## [0.1.11] - 2013-02-07 +### Added +- Added 70+ tests (ported from python), @hpaulj +- Added conflictHandler, @applepicke +- Added fromfilePrefixChar, @hpaulj + +### Fixed +- Multiple bugfixes, @hpaulj + + +## [0.1.10] - 2012-12-30 +### Added +- Added [mutual exclusion](http://docs.python.org/dev/library/argparse.html#mutual-exclusion) + support, thanks to @hpaulj + +### Fixed +- Fixed options check for `storeConst` & `appendConst` actions, thanks to @hpaulj + + +## [0.1.9] - 2012-12-27 +### Fixed +- Fixed option dest interferens with other options (issue #23), thanks to @hpaulj +- Fixed default value behavior with `*` positionals, thanks to @hpaulj +- Improve `getDefault()` behavior, thanks to @hpaulj +- Improve negative argument parsing, thanks to @hpaulj + + +## [0.1.8] - 2012-12-01 +### Fixed +- Fixed parser parents (issue #19), thanks to @hpaulj +- Fixed negative argument parse (issue #20), thanks to @hpaulj + + +## [0.1.7] - 2012-10-14 +### Fixed +- Fixed 'choices' argument parse (issue #16) +- Fixed stderr output (issue #15) + + +## [0.1.6] - 2012-09-09 +### Fixed +- Fixed check for conflict of options (thanks to @tomxtobin) + + +## [0.1.5] - 2012-09-03 +### Fixed +- Fix parser #setDefaults method (thanks to @tomxtobin) + + +## [0.1.4] - 2012-07-30 +### Fixed +- Fixed pseudo-argument support (thanks to @CGamesPlay) +- Fixed addHelp default (should be true), if not set (thanks to @benblank) + + +## [0.1.3] - 2012-06-27 +### Fixed +- Fixed formatter api name: Formatter -> HelpFormatter + + +## [0.1.2] - 2012-05-29 +### Fixed +- Removed excess whitespace in help +- Fixed error reporting, when parcer with subcommands + called with empty arguments + +### Added +- Added basic tests + + +## [0.1.1] - 2012-05-23 +### Fixed +- Fixed line wrapping in help formatter +- Added better error reporting on invalid arguments + + +## [0.1.0] - 2012-05-16 +### Added +- First release. + + +[2.0.1]: https://github.com/nodeca/argparse/compare/2.0.0...2.0.1 +[2.0.0]: https://github.com/nodeca/argparse/compare/1.0.10...2.0.0 +[1.0.10]: https://github.com/nodeca/argparse/compare/1.0.9...1.0.10 +[1.0.9]: https://github.com/nodeca/argparse/compare/1.0.8...1.0.9 +[1.0.8]: https://github.com/nodeca/argparse/compare/1.0.7...1.0.8 +[1.0.7]: https://github.com/nodeca/argparse/compare/1.0.6...1.0.7 +[1.0.6]: https://github.com/nodeca/argparse/compare/1.0.5...1.0.6 +[1.0.5]: https://github.com/nodeca/argparse/compare/1.0.4...1.0.5 +[1.0.4]: https://github.com/nodeca/argparse/compare/1.0.3...1.0.4 +[1.0.3]: https://github.com/nodeca/argparse/compare/1.0.2...1.0.3 +[1.0.2]: https://github.com/nodeca/argparse/compare/1.0.1...1.0.2 +[1.0.1]: https://github.com/nodeca/argparse/compare/1.0.0...1.0.1 +[1.0.0]: https://github.com/nodeca/argparse/compare/0.1.16...1.0.0 +[0.1.16]: https://github.com/nodeca/argparse/compare/0.1.15...0.1.16 +[0.1.15]: https://github.com/nodeca/argparse/compare/0.1.14...0.1.15 +[0.1.14]: https://github.com/nodeca/argparse/compare/0.1.13...0.1.14 +[0.1.13]: https://github.com/nodeca/argparse/compare/0.1.12...0.1.13 +[0.1.12]: https://github.com/nodeca/argparse/compare/0.1.11...0.1.12 +[0.1.11]: https://github.com/nodeca/argparse/compare/0.1.10...0.1.11 +[0.1.10]: https://github.com/nodeca/argparse/compare/0.1.9...0.1.10 +[0.1.9]: https://github.com/nodeca/argparse/compare/0.1.8...0.1.9 +[0.1.8]: https://github.com/nodeca/argparse/compare/0.1.7...0.1.8 +[0.1.7]: https://github.com/nodeca/argparse/compare/0.1.6...0.1.7 +[0.1.6]: https://github.com/nodeca/argparse/compare/0.1.5...0.1.6 +[0.1.5]: https://github.com/nodeca/argparse/compare/0.1.4...0.1.5 +[0.1.4]: https://github.com/nodeca/argparse/compare/0.1.3...0.1.4 +[0.1.3]: https://github.com/nodeca/argparse/compare/0.1.2...0.1.3 +[0.1.2]: https://github.com/nodeca/argparse/compare/0.1.1...0.1.2 +[0.1.1]: https://github.com/nodeca/argparse/compare/0.1.0...0.1.1 +[0.1.0]: https://github.com/nodeca/argparse/releases/tag/0.1.0 diff --git a/action/node_modules/argparse/LICENSE b/action/node_modules/argparse/LICENSE new file mode 100644 index 000000000..66a3ac80d --- /dev/null +++ b/action/node_modules/argparse/LICENSE @@ -0,0 +1,254 @@ +A. HISTORY OF THE SOFTWARE +========================== + +Python was created in the early 1990s by Guido van Rossum at Stichting +Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands +as a successor of a language called ABC. Guido remains Python's +principal author, although it includes many contributions from others. + +In 1995, Guido continued his work on Python at the Corporation for +National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) +in Reston, Virginia where he released several versions of the +software. + +In May 2000, Guido and the Python core development team moved to +BeOpen.com to form the BeOpen PythonLabs team. In October of the same +year, the PythonLabs team moved to Digital Creations, which became +Zope Corporation. In 2001, the Python Software Foundation (PSF, see +https://www.python.org/psf/) was formed, a non-profit organization +created specifically to own Python-related Intellectual Property. +Zope Corporation was a sponsoring member of the PSF. + +All Python releases are Open Source (see http://www.opensource.org for +the Open Source Definition). Historically, most, but not all, Python +releases have also been GPL-compatible; the table below summarizes +the various releases. + + Release Derived Year Owner GPL- + from compatible? (1) + + 0.9.0 thru 1.2 1991-1995 CWI yes + 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes + 1.6 1.5.2 2000 CNRI no + 2.0 1.6 2000 BeOpen.com no + 1.6.1 1.6 2001 CNRI yes (2) + 2.1 2.0+1.6.1 2001 PSF no + 2.0.1 2.0+1.6.1 2001 PSF yes + 2.1.1 2.1+2.0.1 2001 PSF yes + 2.1.2 2.1.1 2002 PSF yes + 2.1.3 2.1.2 2002 PSF yes + 2.2 and above 2.1.1 2001-now PSF yes + +Footnotes: + +(1) GPL-compatible doesn't mean that we're distributing Python under + the GPL. All Python licenses, unlike the GPL, let you distribute + a modified version without making your changes open source. The + GPL-compatible licenses make it possible to combine Python with + other software that is released under the GPL; the others don't. + +(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, + because its license has a choice of law clause. According to + CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 + is "not incompatible" with the GPL. + +Thanks to the many outside volunteers who have worked under Guido's +direction to make these releases possible. + + +B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON +=============================================================== + +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby +grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +analyze, test, perform and/or display publicly, prepare derivative works, +distribute, and otherwise use Python alone or in any derivative version, +provided, however, that PSF's License Agreement and PSF's notice of copyright, +i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Python Software Foundation; +All Rights Reserved" are retained in Python alone or in any derivative version +prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 +------------------------------------------- + +BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 + +1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an +office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the +Individual or Organization ("Licensee") accessing and otherwise using +this software in source or binary form and its associated +documentation ("the Software"). + +2. Subject to the terms and conditions of this BeOpen Python License +Agreement, BeOpen hereby grants Licensee a non-exclusive, +royalty-free, world-wide license to reproduce, analyze, test, perform +and/or display publicly, prepare derivative works, distribute, and +otherwise use the Software alone or in any derivative version, +provided, however, that the BeOpen Python License is retained in the +Software, alone or in any derivative version prepared by Licensee. + +3. BeOpen is making the Software available to Licensee on an "AS IS" +basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE +SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS +AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY +DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +5. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +6. This License Agreement shall be governed by and interpreted in all +respects by the law of the State of California, excluding conflict of +law provisions. Nothing in this License Agreement shall be deemed to +create any relationship of agency, partnership, or joint venture +between BeOpen and Licensee. This License Agreement does not grant +permission to use BeOpen trademarks or trade names in a trademark +sense to endorse or promote products or services of Licensee, or any +third party. As an exception, the "BeOpen Python" logos available at +http://www.pythonlabs.com/logos.html may be used according to the +permissions granted on that web page. + +7. By copying, installing or otherwise using the software, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 +--------------------------------------- + +1. This LICENSE AGREEMENT is between the Corporation for National +Research Initiatives, having an office at 1895 Preston White Drive, +Reston, VA 20191 ("CNRI"), and the Individual or Organization +("Licensee") accessing and otherwise using Python 1.6.1 software in +source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, CNRI +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 1.6.1 +alone or in any derivative version, provided, however, that CNRI's +License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) +1995-2001 Corporation for National Research Initiatives; All Rights +Reserved" are retained in Python 1.6.1 alone or in any derivative +version prepared by Licensee. Alternately, in lieu of CNRI's License +Agreement, Licensee may substitute the following text (omitting the +quotes): "Python 1.6.1 is made available subject to the terms and +conditions in CNRI's License Agreement. This Agreement together with +Python 1.6.1 may be located on the Internet using the following +unique, persistent identifier (known as a handle): 1895.22/1013. This +Agreement may also be obtained from a proxy server on the Internet +using the following URL: http://hdl.handle.net/1895.22/1013". + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 1.6.1 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 1.6.1. + +4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" +basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. This License Agreement shall be governed by the federal +intellectual property law of the United States, including without +limitation the federal copyright law, and, to the extent such +U.S. federal law does not apply, by the law of the Commonwealth of +Virginia, excluding Virginia's conflict of law provisions. +Notwithstanding the foregoing, with regard to derivative works based +on Python 1.6.1 that incorporate non-separable material that was +previously distributed under the GNU General Public License (GPL), the +law of the Commonwealth of Virginia shall govern this License +Agreement only as to issues arising under or with respect to +Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this +License Agreement shall be deemed to create any relationship of +agency, partnership, or joint venture between CNRI and Licensee. This +License Agreement does not grant permission to use CNRI trademarks or +trade name in a trademark sense to endorse or promote products or +services of Licensee, or any third party. + +8. By clicking on the "ACCEPT" button where indicated, or by copying, +installing or otherwise using Python 1.6.1, Licensee agrees to be +bound by the terms and conditions of this License Agreement. + + ACCEPT + + +CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 +-------------------------------------------------- + +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, +The Netherlands. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Stichting Mathematisch +Centrum or CWI not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/action/node_modules/argparse/README.md b/action/node_modules/argparse/README.md new file mode 100644 index 000000000..550b5c9b7 --- /dev/null +++ b/action/node_modules/argparse/README.md @@ -0,0 +1,84 @@ +argparse +======== + +[![Build Status](https://secure.travis-ci.org/nodeca/argparse.svg?branch=master)](http://travis-ci.org/nodeca/argparse) +[![NPM version](https://img.shields.io/npm/v/argparse.svg)](https://www.npmjs.org/package/argparse) + +CLI arguments parser for node.js, with [sub-commands](https://docs.python.org/3.9/library/argparse.html#sub-commands) support. Port of python's [argparse](http://docs.python.org/dev/library/argparse.html) (version [3.9.0](https://github.com/python/cpython/blob/v3.9.0rc1/Lib/argparse.py)). + +**Difference with original.** + +- JS has no keyword arguments support. + - Pass options instead: `new ArgumentParser({ description: 'example', add_help: true })`. +- JS has no python's types `int`, `float`, ... + - Use string-typed names: `.add_argument('-b', { type: 'int', help: 'help' })`. +- `%r` format specifier uses `require('util').inspect()`. + +More details in [doc](./doc). + + +Example +------- + +`test.js` file: + +```javascript +#!/usr/bin/env node +'use strict'; + +const { ArgumentParser } = require('argparse'); +const { version } = require('./package.json'); + +const parser = new ArgumentParser({ + description: 'Argparse example' +}); + +parser.add_argument('-v', '--version', { action: 'version', version }); +parser.add_argument('-f', '--foo', { help: 'foo bar' }); +parser.add_argument('-b', '--bar', { help: 'bar foo' }); +parser.add_argument('--baz', { help: 'baz bar' }); + +console.dir(parser.parse_args()); +``` + +Display help: + +``` +$ ./test.js -h +usage: test.js [-h] [-v] [-f FOO] [-b BAR] [--baz BAZ] + +Argparse example + +optional arguments: + -h, --help show this help message and exit + -v, --version show program's version number and exit + -f FOO, --foo FOO foo bar + -b BAR, --bar BAR bar foo + --baz BAZ baz bar +``` + +Parse arguments: + +``` +$ ./test.js -f=3 --bar=4 --baz 5 +{ foo: '3', bar: '4', baz: '5' } +``` + + +API docs +-------- + +Since this is a port with minimal divergence, there's no separate documentation. +Use original one instead, with notes about difference. + +1. [Original doc](https://docs.python.org/3.9/library/argparse.html). +2. [Original tutorial](https://docs.python.org/3.9/howto/argparse.html). +3. [Difference with python](./doc). + + +argparse for enterprise +----------------------- + +Available as part of the Tidelift Subscription + +The maintainers of argparse and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-argparse?utm_source=npm-argparse&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/action/node_modules/argparse/argparse.js b/action/node_modules/argparse/argparse.js new file mode 100644 index 000000000..2b8c8c631 --- /dev/null +++ b/action/node_modules/argparse/argparse.js @@ -0,0 +1,3707 @@ +// Port of python's argparse module, version 3.9.0: +// https://github.com/python/cpython/blob/v3.9.0rc1/Lib/argparse.py + +'use strict' + +// Copyright (C) 2010-2020 Python Software Foundation. +// Copyright (C) 2020 argparse.js authors + +/* + * Command-line parsing library + * + * This module is an optparse-inspired command-line parsing library that: + * + * - handles both optional and positional arguments + * - produces highly informative usage messages + * - supports parsers that dispatch to sub-parsers + * + * The following is a simple usage example that sums integers from the + * command-line and writes the result to a file:: + * + * parser = argparse.ArgumentParser( + * description='sum the integers at the command line') + * parser.add_argument( + * 'integers', metavar='int', nargs='+', type=int, + * help='an integer to be summed') + * parser.add_argument( + * '--log', default=sys.stdout, type=argparse.FileType('w'), + * help='the file where the sum should be written') + * args = parser.parse_args() + * args.log.write('%s' % sum(args.integers)) + * args.log.close() + * + * The module contains the following public classes: + * + * - ArgumentParser -- The main entry point for command-line parsing. As the + * example above shows, the add_argument() method is used to populate + * the parser with actions for optional and positional arguments. Then + * the parse_args() method is invoked to convert the args at the + * command-line into an object with attributes. + * + * - ArgumentError -- The exception raised by ArgumentParser objects when + * there are errors with the parser's actions. Errors raised while + * parsing the command-line are caught by ArgumentParser and emitted + * as command-line messages. + * + * - FileType -- A factory for defining types of files to be created. As the + * example above shows, instances of FileType are typically passed as + * the type= argument of add_argument() calls. + * + * - Action -- The base class for parser actions. Typically actions are + * selected by passing strings like 'store_true' or 'append_const' to + * the action= argument of add_argument(). However, for greater + * customization of ArgumentParser actions, subclasses of Action may + * be defined and passed as the action= argument. + * + * - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter, + * ArgumentDefaultsHelpFormatter -- Formatter classes which + * may be passed as the formatter_class= argument to the + * ArgumentParser constructor. HelpFormatter is the default, + * RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser + * not to change the formatting for help text, and + * ArgumentDefaultsHelpFormatter adds information about argument defaults + * to the help. + * + * All other classes in this module are considered implementation details. + * (Also note that HelpFormatter and RawDescriptionHelpFormatter are only + * considered public as object names -- the API of the formatter objects is + * still considered an implementation detail.) + */ + +const SUPPRESS = '==SUPPRESS==' + +const OPTIONAL = '?' +const ZERO_OR_MORE = '*' +const ONE_OR_MORE = '+' +const PARSER = 'A...' +const REMAINDER = '...' +const _UNRECOGNIZED_ARGS_ATTR = '_unrecognized_args' + + +// ================================== +// Utility functions used for porting +// ================================== +const assert = require('assert') +const util = require('util') +const fs = require('fs') +const sub = require('./lib/sub') +const path = require('path') +const repr = util.inspect + +function get_argv() { + // omit first argument (which is assumed to be interpreter - `node`, `coffee`, `ts-node`, etc.) + return process.argv.slice(1) +} + +function get_terminal_size() { + return { + columns: +process.env.COLUMNS || process.stdout.columns || 80 + } +} + +function hasattr(object, name) { + return Object.prototype.hasOwnProperty.call(object, name) +} + +function getattr(object, name, value) { + return hasattr(object, name) ? object[name] : value +} + +function setattr(object, name, value) { + object[name] = value +} + +function setdefault(object, name, value) { + if (!hasattr(object, name)) object[name] = value + return object[name] +} + +function delattr(object, name) { + delete object[name] +} + +function range(from, to, step=1) { + // range(10) is equivalent to range(0, 10) + if (arguments.length === 1) [ to, from ] = [ from, 0 ] + if (typeof from !== 'number' || typeof to !== 'number' || typeof step !== 'number') { + throw new TypeError('argument cannot be interpreted as an integer') + } + if (step === 0) throw new TypeError('range() arg 3 must not be zero') + + let result = [] + if (step > 0) { + for (let i = from; i < to; i += step) result.push(i) + } else { + for (let i = from; i > to; i += step) result.push(i) + } + return result +} + +function splitlines(str, keepends = false) { + let result + if (!keepends) { + result = str.split(/\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029]/) + } else { + result = [] + let parts = str.split(/(\r\n|[\n\r\v\f\x1c\x1d\x1e\x85\u2028\u2029])/) + for (let i = 0; i < parts.length; i += 2) { + result.push(parts[i] + (i + 1 < parts.length ? parts[i + 1] : '')) + } + } + if (!result[result.length - 1]) result.pop() + return result +} + +function _string_lstrip(string, prefix_chars) { + let idx = 0 + while (idx < string.length && prefix_chars.includes(string[idx])) idx++ + return idx ? string.slice(idx) : string +} + +function _string_split(string, sep, maxsplit) { + let result = string.split(sep) + if (result.length > maxsplit) { + result = result.slice(0, maxsplit).concat([ result.slice(maxsplit).join(sep) ]) + } + return result +} + +function _array_equal(array1, array2) { + if (array1.length !== array2.length) return false + for (let i = 0; i < array1.length; i++) { + if (array1[i] !== array2[i]) return false + } + return true +} + +function _array_remove(array, item) { + let idx = array.indexOf(item) + if (idx === -1) throw new TypeError(sub('%r not in list', item)) + array.splice(idx, 1) +} + +// normalize choices to array; +// this isn't required in python because `in` and `map` operators work with anything, +// but in js dealing with multiple types here is too clunky +function _choices_to_array(choices) { + if (choices === undefined) { + return [] + } else if (Array.isArray(choices)) { + return choices + } else if (choices !== null && typeof choices[Symbol.iterator] === 'function') { + return Array.from(choices) + } else if (typeof choices === 'object' && choices !== null) { + return Object.keys(choices) + } else { + throw new Error(sub('invalid choices value: %r', choices)) + } +} + +// decorator that allows a class to be called without new +function _callable(cls) { + let result = { // object is needed for inferred class name + [cls.name]: function (...args) { + let this_class = new.target === result || !new.target + return Reflect.construct(cls, args, this_class ? cls : new.target) + } + } + result[cls.name].prototype = cls.prototype + // fix default tag for toString, e.g. [object Action] instead of [object Object] + cls.prototype[Symbol.toStringTag] = cls.name + return result[cls.name] +} + +function _alias(object, from, to) { + try { + let name = object.constructor.name + Object.defineProperty(object, from, { + value: util.deprecate(object[to], sub('%s.%s() is renamed to %s.%s()', + name, from, name, to)), + enumerable: false + }) + } catch {} +} + +// decorator that allows snake_case class methods to be called with camelCase and vice versa +function _camelcase_alias(_class) { + for (let name of Object.getOwnPropertyNames(_class.prototype)) { + let camelcase = name.replace(/\w_[a-z]/g, s => s[0] + s[2].toUpperCase()) + if (camelcase !== name) _alias(_class.prototype, camelcase, name) + } + return _class +} + +function _to_legacy_name(key) { + key = key.replace(/\w_[a-z]/g, s => s[0] + s[2].toUpperCase()) + if (key === 'default') key = 'defaultValue' + if (key === 'const') key = 'constant' + return key +} + +function _to_new_name(key) { + if (key === 'defaultValue') key = 'default' + if (key === 'constant') key = 'const' + key = key.replace(/[A-Z]/g, c => '_' + c.toLowerCase()) + return key +} + +// parse options +let no_default = Symbol('no_default_value') +function _parse_opts(args, descriptor) { + function get_name() { + let stack = new Error().stack.split('\n') + .map(x => x.match(/^ at (.*) \(.*\)$/)) + .filter(Boolean) + .map(m => m[1]) + .map(fn => fn.match(/[^ .]*$/)[0]) + + if (stack.length && stack[0] === get_name.name) stack.shift() + if (stack.length && stack[0] === _parse_opts.name) stack.shift() + return stack.length ? stack[0] : '' + } + + args = Array.from(args) + let kwargs = {} + let result = [] + let last_opt = args.length && args[args.length - 1] + + if (typeof last_opt === 'object' && last_opt !== null && !Array.isArray(last_opt) && + (!last_opt.constructor || last_opt.constructor.name === 'Object')) { + kwargs = Object.assign({}, args.pop()) + } + + // LEGACY (v1 compatibility): camelcase + let renames = [] + for (let key of Object.keys(descriptor)) { + let old_name = _to_legacy_name(key) + if (old_name !== key && (old_name in kwargs)) { + if (key in kwargs) { + // default and defaultValue specified at the same time, happens often in old tests + //throw new TypeError(sub('%s() got multiple values for argument %r', get_name(), key)) + } else { + kwargs[key] = kwargs[old_name] + } + renames.push([ old_name, key ]) + delete kwargs[old_name] + } + } + if (renames.length) { + let name = get_name() + deprecate('camelcase_' + name, sub('%s(): following options are renamed: %s', + name, renames.map(([ a, b ]) => sub('%r -> %r', a, b)))) + } + // end + + let missing_positionals = [] + let positional_count = args.length + + for (let [ key, def ] of Object.entries(descriptor)) { + if (key[0] === '*') { + if (key.length > 0 && key[1] === '*') { + // LEGACY (v1 compatibility): camelcase + let renames = [] + for (let key of Object.keys(kwargs)) { + let new_name = _to_new_name(key) + if (new_name !== key && (key in kwargs)) { + if (new_name in kwargs) { + // default and defaultValue specified at the same time, happens often in old tests + //throw new TypeError(sub('%s() got multiple values for argument %r', get_name(), new_name)) + } else { + kwargs[new_name] = kwargs[key] + } + renames.push([ key, new_name ]) + delete kwargs[key] + } + } + if (renames.length) { + let name = get_name() + deprecate('camelcase_' + name, sub('%s(): following options are renamed: %s', + name, renames.map(([ a, b ]) => sub('%r -> %r', a, b)))) + } + // end + result.push(kwargs) + kwargs = {} + } else { + result.push(args) + args = [] + } + } else if (key in kwargs && args.length > 0) { + throw new TypeError(sub('%s() got multiple values for argument %r', get_name(), key)) + } else if (key in kwargs) { + result.push(kwargs[key]) + delete kwargs[key] + } else if (args.length > 0) { + result.push(args.shift()) + } else if (def !== no_default) { + result.push(def) + } else { + missing_positionals.push(key) + } + } + + if (Object.keys(kwargs).length) { + throw new TypeError(sub('%s() got an unexpected keyword argument %r', + get_name(), Object.keys(kwargs)[0])) + } + + if (args.length) { + let from = Object.entries(descriptor).filter(([ k, v ]) => k[0] !== '*' && v !== no_default).length + let to = Object.entries(descriptor).filter(([ k ]) => k[0] !== '*').length + throw new TypeError(sub('%s() takes %s positional argument%s but %s %s given', + get_name(), + from === to ? sub('from %s to %s', from, to) : to, + from === to && to === 1 ? '' : 's', + positional_count, + positional_count === 1 ? 'was' : 'were')) + } + + if (missing_positionals.length) { + let strs = missing_positionals.map(repr) + if (strs.length > 1) strs[strs.length - 1] = 'and ' + strs[strs.length - 1] + let str_joined = strs.join(strs.length === 2 ? '' : ', ') + throw new TypeError(sub('%s() missing %i required positional argument%s: %s', + get_name(), strs.length, strs.length === 1 ? '' : 's', str_joined)) + } + + return result +} + +let _deprecations = {} +function deprecate(id, string) { + _deprecations[id] = _deprecations[id] || util.deprecate(() => {}, string) + _deprecations[id]() +} + + +// ============================= +// Utility functions and classes +// ============================= +function _AttributeHolder(cls = Object) { + /* + * Abstract base class that provides __repr__. + * + * The __repr__ method returns a string in the format:: + * ClassName(attr=name, attr=name, ...) + * The attributes are determined either by a class-level attribute, + * '_kwarg_names', or by inspecting the instance __dict__. + */ + + return class _AttributeHolder extends cls { + [util.inspect.custom]() { + let type_name = this.constructor.name + let arg_strings = [] + let star_args = {} + for (let arg of this._get_args()) { + arg_strings.push(repr(arg)) + } + for (let [ name, value ] of this._get_kwargs()) { + if (/^[a-z_][a-z0-9_$]*$/i.test(name)) { + arg_strings.push(sub('%s=%r', name, value)) + } else { + star_args[name] = value + } + } + if (Object.keys(star_args).length) { + arg_strings.push(sub('**%s', repr(star_args))) + } + return sub('%s(%s)', type_name, arg_strings.join(', ')) + } + + toString() { + return this[util.inspect.custom]() + } + + _get_kwargs() { + return Object.entries(this) + } + + _get_args() { + return [] + } + } +} + + +function _copy_items(items) { + if (items === undefined) { + return [] + } + return items.slice(0) +} + + +// =============== +// Formatting Help +// =============== +const HelpFormatter = _camelcase_alias(_callable(class HelpFormatter { + /* + * Formatter for generating usage messages and argument help strings. + * + * Only the name of this class is considered a public API. All the methods + * provided by the class are considered an implementation detail. + */ + + constructor() { + let [ + prog, + indent_increment, + max_help_position, + width + ] = _parse_opts(arguments, { + prog: no_default, + indent_increment: 2, + max_help_position: 24, + width: undefined + }) + + // default setting for width + if (width === undefined) { + width = get_terminal_size().columns + width -= 2 + } + + this._prog = prog + this._indent_increment = indent_increment + this._max_help_position = Math.min(max_help_position, + Math.max(width - 20, indent_increment * 2)) + this._width = width + + this._current_indent = 0 + this._level = 0 + this._action_max_length = 0 + + this._root_section = this._Section(this, undefined) + this._current_section = this._root_section + + this._whitespace_matcher = /[ \t\n\r\f\v]+/g // equivalent to python /\s+/ with ASCII flag + this._long_break_matcher = /\n\n\n+/g + } + + // =============================== + // Section and indentation methods + // =============================== + _indent() { + this._current_indent += this._indent_increment + this._level += 1 + } + + _dedent() { + this._current_indent -= this._indent_increment + assert(this._current_indent >= 0, 'Indent decreased below 0.') + this._level -= 1 + } + + _add_item(func, args) { + this._current_section.items.push([ func, args ]) + } + + // ======================== + // Message building methods + // ======================== + start_section(heading) { + this._indent() + let section = this._Section(this, this._current_section, heading) + this._add_item(section.format_help.bind(section), []) + this._current_section = section + } + + end_section() { + this._current_section = this._current_section.parent + this._dedent() + } + + add_text(text) { + if (text !== SUPPRESS && text !== undefined) { + this._add_item(this._format_text.bind(this), [text]) + } + } + + add_usage(usage, actions, groups, prefix = undefined) { + if (usage !== SUPPRESS) { + let args = [ usage, actions, groups, prefix ] + this._add_item(this._format_usage.bind(this), args) + } + } + + add_argument(action) { + if (action.help !== SUPPRESS) { + + // find all invocations + let invocations = [this._format_action_invocation(action)] + for (let subaction of this._iter_indented_subactions(action)) { + invocations.push(this._format_action_invocation(subaction)) + } + + // update the maximum item length + let invocation_length = Math.max(...invocations.map(invocation => invocation.length)) + let action_length = invocation_length + this._current_indent + this._action_max_length = Math.max(this._action_max_length, + action_length) + + // add the item to the list + this._add_item(this._format_action.bind(this), [action]) + } + } + + add_arguments(actions) { + for (let action of actions) { + this.add_argument(action) + } + } + + // ======================= + // Help-formatting methods + // ======================= + format_help() { + let help = this._root_section.format_help() + if (help) { + help = help.replace(this._long_break_matcher, '\n\n') + help = help.replace(/^\n+|\n+$/g, '') + '\n' + } + return help + } + + _join_parts(part_strings) { + return part_strings.filter(part => part && part !== SUPPRESS).join('') + } + + _format_usage(usage, actions, groups, prefix) { + if (prefix === undefined) { + prefix = 'usage: ' + } + + // if usage is specified, use that + if (usage !== undefined) { + usage = sub(usage, { prog: this._prog }) + + // if no optionals or positionals are available, usage is just prog + } else if (usage === undefined && !actions.length) { + usage = sub('%(prog)s', { prog: this._prog }) + + // if optionals and positionals are available, calculate usage + } else if (usage === undefined) { + let prog = sub('%(prog)s', { prog: this._prog }) + + // split optionals from positionals + let optionals = [] + let positionals = [] + for (let action of actions) { + if (action.option_strings.length) { + optionals.push(action) + } else { + positionals.push(action) + } + } + + // build full usage string + let action_usage = this._format_actions_usage([].concat(optionals).concat(positionals), groups) + usage = [ prog, action_usage ].map(String).join(' ') + + // wrap the usage parts if it's too long + let text_width = this._width - this._current_indent + if (prefix.length + usage.length > text_width) { + + // break usage into wrappable parts + let part_regexp = /\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+/g + let opt_usage = this._format_actions_usage(optionals, groups) + let pos_usage = this._format_actions_usage(positionals, groups) + let opt_parts = opt_usage.match(part_regexp) || [] + let pos_parts = pos_usage.match(part_regexp) || [] + assert(opt_parts.join(' ') === opt_usage) + assert(pos_parts.join(' ') === pos_usage) + + // helper for wrapping lines + let get_lines = (parts, indent, prefix = undefined) => { + let lines = [] + let line = [] + let line_len + if (prefix !== undefined) { + line_len = prefix.length - 1 + } else { + line_len = indent.length - 1 + } + for (let part of parts) { + if (line_len + 1 + part.length > text_width && line) { + lines.push(indent + line.join(' ')) + line = [] + line_len = indent.length - 1 + } + line.push(part) + line_len += part.length + 1 + } + if (line.length) { + lines.push(indent + line.join(' ')) + } + if (prefix !== undefined) { + lines[0] = lines[0].slice(indent.length) + } + return lines + } + + let lines + + // if prog is short, follow it with optionals or positionals + if (prefix.length + prog.length <= 0.75 * text_width) { + let indent = ' '.repeat(prefix.length + prog.length + 1) + if (opt_parts.length) { + lines = get_lines([prog].concat(opt_parts), indent, prefix) + lines = lines.concat(get_lines(pos_parts, indent)) + } else if (pos_parts.length) { + lines = get_lines([prog].concat(pos_parts), indent, prefix) + } else { + lines = [prog] + } + + // if prog is long, put it on its own line + } else { + let indent = ' '.repeat(prefix.length) + let parts = [].concat(opt_parts).concat(pos_parts) + lines = get_lines(parts, indent) + if (lines.length > 1) { + lines = [] + lines = lines.concat(get_lines(opt_parts, indent)) + lines = lines.concat(get_lines(pos_parts, indent)) + } + lines = [prog].concat(lines) + } + + // join lines into usage + usage = lines.join('\n') + } + } + + // prefix with 'usage:' + return sub('%s%s\n\n', prefix, usage) + } + + _format_actions_usage(actions, groups) { + // find group indices and identify actions in groups + let group_actions = new Set() + let inserts = {} + for (let group of groups) { + let start = actions.indexOf(group._group_actions[0]) + if (start === -1) { + continue + } else { + let end = start + group._group_actions.length + if (_array_equal(actions.slice(start, end), group._group_actions)) { + for (let action of group._group_actions) { + group_actions.add(action) + } + if (!group.required) { + if (start in inserts) { + inserts[start] += ' [' + } else { + inserts[start] = '[' + } + if (end in inserts) { + inserts[end] += ']' + } else { + inserts[end] = ']' + } + } else { + if (start in inserts) { + inserts[start] += ' (' + } else { + inserts[start] = '(' + } + if (end in inserts) { + inserts[end] += ')' + } else { + inserts[end] = ')' + } + } + for (let i of range(start + 1, end)) { + inserts[i] = '|' + } + } + } + } + + // collect all actions format strings + let parts = [] + for (let [ i, action ] of Object.entries(actions)) { + + // suppressed arguments are marked with None + // remove | separators for suppressed arguments + if (action.help === SUPPRESS) { + parts.push(undefined) + if (inserts[+i] === '|') { + delete inserts[+i] + } else if (inserts[+i + 1] === '|') { + delete inserts[+i + 1] + } + + // produce all arg strings + } else if (!action.option_strings.length) { + let default_value = this._get_default_metavar_for_positional(action) + let part = this._format_args(action, default_value) + + // if it's in a group, strip the outer [] + if (group_actions.has(action)) { + if (part[0] === '[' && part[part.length - 1] === ']') { + part = part.slice(1, -1) + } + } + + // add the action string to the list + parts.push(part) + + // produce the first way to invoke the option in brackets + } else { + let option_string = action.option_strings[0] + let part + + // if the Optional doesn't take a value, format is: + // -s or --long + if (action.nargs === 0) { + part = action.format_usage() + + // if the Optional takes a value, format is: + // -s ARGS or --long ARGS + } else { + let default_value = this._get_default_metavar_for_optional(action) + let args_string = this._format_args(action, default_value) + part = sub('%s %s', option_string, args_string) + } + + // make it look optional if it's not required or in a group + if (!action.required && !group_actions.has(action)) { + part = sub('[%s]', part) + } + + // add the action string to the list + parts.push(part) + } + } + + // insert things at the necessary indices + for (let i of Object.keys(inserts).map(Number).sort((a, b) => b - a)) { + parts.splice(+i, 0, inserts[+i]) + } + + // join all the action items with spaces + let text = parts.filter(Boolean).join(' ') + + // clean up separators for mutually exclusive groups + text = text.replace(/([\[(]) /g, '$1') + text = text.replace(/ ([\])])/g, '$1') + text = text.replace(/[\[(] *[\])]/g, '') + text = text.replace(/\(([^|]*)\)/g, '$1', text) + text = text.trim() + + // return the text + return text + } + + _format_text(text) { + if (text.includes('%(prog)')) { + text = sub(text, { prog: this._prog }) + } + let text_width = Math.max(this._width - this._current_indent, 11) + let indent = ' '.repeat(this._current_indent) + return this._fill_text(text, text_width, indent) + '\n\n' + } + + _format_action(action) { + // determine the required width and the entry label + let help_position = Math.min(this._action_max_length + 2, + this._max_help_position) + let help_width = Math.max(this._width - help_position, 11) + let action_width = help_position - this._current_indent - 2 + let action_header = this._format_action_invocation(action) + let indent_first + + // no help; start on same line and add a final newline + if (!action.help) { + let tup = [ this._current_indent, '', action_header ] + action_header = sub('%*s%s\n', ...tup) + + // short action name; start on the same line and pad two spaces + } else if (action_header.length <= action_width) { + let tup = [ this._current_indent, '', action_width, action_header ] + action_header = sub('%*s%-*s ', ...tup) + indent_first = 0 + + // long action name; start on the next line + } else { + let tup = [ this._current_indent, '', action_header ] + action_header = sub('%*s%s\n', ...tup) + indent_first = help_position + } + + // collect the pieces of the action help + let parts = [action_header] + + // if there was help for the action, add lines of help text + if (action.help) { + let help_text = this._expand_help(action) + let help_lines = this._split_lines(help_text, help_width) + parts.push(sub('%*s%s\n', indent_first, '', help_lines[0])) + for (let line of help_lines.slice(1)) { + parts.push(sub('%*s%s\n', help_position, '', line)) + } + + // or add a newline if the description doesn't end with one + } else if (!action_header.endsWith('\n')) { + parts.push('\n') + } + + // if there are any sub-actions, add their help as well + for (let subaction of this._iter_indented_subactions(action)) { + parts.push(this._format_action(subaction)) + } + + // return a single string + return this._join_parts(parts) + } + + _format_action_invocation(action) { + if (!action.option_strings.length) { + let default_value = this._get_default_metavar_for_positional(action) + let metavar = this._metavar_formatter(action, default_value)(1)[0] + return metavar + + } else { + let parts = [] + + // if the Optional doesn't take a value, format is: + // -s, --long + if (action.nargs === 0) { + parts = parts.concat(action.option_strings) + + // if the Optional takes a value, format is: + // -s ARGS, --long ARGS + } else { + let default_value = this._get_default_metavar_for_optional(action) + let args_string = this._format_args(action, default_value) + for (let option_string of action.option_strings) { + parts.push(sub('%s %s', option_string, args_string)) + } + } + + return parts.join(', ') + } + } + + _metavar_formatter(action, default_metavar) { + let result + if (action.metavar !== undefined) { + result = action.metavar + } else if (action.choices !== undefined) { + let choice_strs = _choices_to_array(action.choices).map(String) + result = sub('{%s}', choice_strs.join(',')) + } else { + result = default_metavar + } + + function format(tuple_size) { + if (Array.isArray(result)) { + return result + } else { + return Array(tuple_size).fill(result) + } + } + return format + } + + _format_args(action, default_metavar) { + let get_metavar = this._metavar_formatter(action, default_metavar) + let result + if (action.nargs === undefined) { + result = sub('%s', ...get_metavar(1)) + } else if (action.nargs === OPTIONAL) { + result = sub('[%s]', ...get_metavar(1)) + } else if (action.nargs === ZERO_OR_MORE) { + let metavar = get_metavar(1) + if (metavar.length === 2) { + result = sub('[%s [%s ...]]', ...metavar) + } else { + result = sub('[%s ...]', ...metavar) + } + } else if (action.nargs === ONE_OR_MORE) { + result = sub('%s [%s ...]', ...get_metavar(2)) + } else if (action.nargs === REMAINDER) { + result = '...' + } else if (action.nargs === PARSER) { + result = sub('%s ...', ...get_metavar(1)) + } else if (action.nargs === SUPPRESS) { + result = '' + } else { + let formats + try { + formats = range(action.nargs).map(() => '%s') + } catch (err) { + throw new TypeError('invalid nargs value') + } + result = sub(formats.join(' '), ...get_metavar(action.nargs)) + } + return result + } + + _expand_help(action) { + let params = Object.assign({ prog: this._prog }, action) + for (let name of Object.keys(params)) { + if (params[name] === SUPPRESS) { + delete params[name] + } + } + for (let name of Object.keys(params)) { + if (params[name] && params[name].name) { + params[name] = params[name].name + } + } + if (params.choices !== undefined) { + let choices_str = _choices_to_array(params.choices).map(String).join(', ') + params.choices = choices_str + } + // LEGACY (v1 compatibility): camelcase + for (let key of Object.keys(params)) { + let old_name = _to_legacy_name(key) + if (old_name !== key) { + params[old_name] = params[key] + } + } + // end + return sub(this._get_help_string(action), params) + } + + * _iter_indented_subactions(action) { + if (typeof action._get_subactions === 'function') { + this._indent() + yield* action._get_subactions() + this._dedent() + } + } + + _split_lines(text, width) { + text = text.replace(this._whitespace_matcher, ' ').trim() + // The textwrap module is used only for formatting help. + // Delay its import for speeding up the common usage of argparse. + let textwrap = require('./lib/textwrap') + return textwrap.wrap(text, { width }) + } + + _fill_text(text, width, indent) { + text = text.replace(this._whitespace_matcher, ' ').trim() + let textwrap = require('./lib/textwrap') + return textwrap.fill(text, { width, + initial_indent: indent, + subsequent_indent: indent }) + } + + _get_help_string(action) { + return action.help + } + + _get_default_metavar_for_optional(action) { + return action.dest.toUpperCase() + } + + _get_default_metavar_for_positional(action) { + return action.dest + } +})) + +HelpFormatter.prototype._Section = _callable(class _Section { + + constructor(formatter, parent, heading = undefined) { + this.formatter = formatter + this.parent = parent + this.heading = heading + this.items = [] + } + + format_help() { + // format the indented section + if (this.parent !== undefined) { + this.formatter._indent() + } + let item_help = this.formatter._join_parts(this.items.map(([ func, args ]) => func.apply(null, args))) + if (this.parent !== undefined) { + this.formatter._dedent() + } + + // return nothing if the section was empty + if (!item_help) { + return '' + } + + // add the heading if the section was non-empty + let heading + if (this.heading !== SUPPRESS && this.heading !== undefined) { + let current_indent = this.formatter._current_indent + heading = sub('%*s%s:\n', current_indent, '', this.heading) + } else { + heading = '' + } + + // join the section-initial newline, the heading and the help + return this.formatter._join_parts(['\n', heading, item_help, '\n']) + } +}) + + +const RawDescriptionHelpFormatter = _camelcase_alias(_callable(class RawDescriptionHelpFormatter extends HelpFormatter { + /* + * Help message formatter which retains any formatting in descriptions. + * + * Only the name of this class is considered a public API. All the methods + * provided by the class are considered an implementation detail. + */ + + _fill_text(text, width, indent) { + return splitlines(text, true).map(line => indent + line).join('') + } +})) + + +const RawTextHelpFormatter = _camelcase_alias(_callable(class RawTextHelpFormatter extends RawDescriptionHelpFormatter { + /* + * Help message formatter which retains formatting of all help text. + * + * Only the name of this class is considered a public API. All the methods + * provided by the class are considered an implementation detail. + */ + + _split_lines(text/*, width*/) { + return splitlines(text) + } +})) + + +const ArgumentDefaultsHelpFormatter = _camelcase_alias(_callable(class ArgumentDefaultsHelpFormatter extends HelpFormatter { + /* + * Help message formatter which adds default values to argument help. + * + * Only the name of this class is considered a public API. All the methods + * provided by the class are considered an implementation detail. + */ + + _get_help_string(action) { + let help = action.help + // LEGACY (v1 compatibility): additional check for defaultValue needed + if (!action.help.includes('%(default)') && !action.help.includes('%(defaultValue)')) { + if (action.default !== SUPPRESS) { + let defaulting_nargs = [OPTIONAL, ZERO_OR_MORE] + if (action.option_strings.length || defaulting_nargs.includes(action.nargs)) { + help += ' (default: %(default)s)' + } + } + } + return help + } +})) + + +const MetavarTypeHelpFormatter = _camelcase_alias(_callable(class MetavarTypeHelpFormatter extends HelpFormatter { + /* + * Help message formatter which uses the argument 'type' as the default + * metavar value (instead of the argument 'dest') + * + * Only the name of this class is considered a public API. All the methods + * provided by the class are considered an implementation detail. + */ + + _get_default_metavar_for_optional(action) { + return typeof action.type === 'function' ? action.type.name : action.type + } + + _get_default_metavar_for_positional(action) { + return typeof action.type === 'function' ? action.type.name : action.type + } +})) + + +// ===================== +// Options and Arguments +// ===================== +function _get_action_name(argument) { + if (argument === undefined) { + return undefined + } else if (argument.option_strings.length) { + return argument.option_strings.join('/') + } else if (![ undefined, SUPPRESS ].includes(argument.metavar)) { + return argument.metavar + } else if (![ undefined, SUPPRESS ].includes(argument.dest)) { + return argument.dest + } else { + return undefined + } +} + + +const ArgumentError = _callable(class ArgumentError extends Error { + /* + * An error from creating or using an argument (optional or positional). + * + * The string value of this exception is the message, augmented with + * information about the argument that caused it. + */ + + constructor(argument, message) { + super() + this.name = 'ArgumentError' + this._argument_name = _get_action_name(argument) + this._message = message + this.message = this.str() + } + + str() { + let format + if (this._argument_name === undefined) { + format = '%(message)s' + } else { + format = 'argument %(argument_name)s: %(message)s' + } + return sub(format, { message: this._message, + argument_name: this._argument_name }) + } +}) + + +const ArgumentTypeError = _callable(class ArgumentTypeError extends Error { + /* + * An error from trying to convert a command line string to a type. + */ + + constructor(message) { + super(message) + this.name = 'ArgumentTypeError' + } +}) + + +// ============== +// Action classes +// ============== +const Action = _camelcase_alias(_callable(class Action extends _AttributeHolder(Function) { + /* + * Information about how to convert command line strings to Python objects. + * + * Action objects are used by an ArgumentParser to represent the information + * needed to parse a single argument from one or more strings from the + * command line. The keyword arguments to the Action constructor are also + * all attributes of Action instances. + * + * Keyword Arguments: + * + * - option_strings -- A list of command-line option strings which + * should be associated with this action. + * + * - dest -- The name of the attribute to hold the created object(s) + * + * - nargs -- The number of command-line arguments that should be + * consumed. By default, one argument will be consumed and a single + * value will be produced. Other values include: + * - N (an integer) consumes N arguments (and produces a list) + * - '?' consumes zero or one arguments + * - '*' consumes zero or more arguments (and produces a list) + * - '+' consumes one or more arguments (and produces a list) + * Note that the difference between the default and nargs=1 is that + * with the default, a single value will be produced, while with + * nargs=1, a list containing a single value will be produced. + * + * - const -- The value to be produced if the option is specified and the + * option uses an action that takes no values. + * + * - default -- The value to be produced if the option is not specified. + * + * - type -- A callable that accepts a single string argument, and + * returns the converted value. The standard Python types str, int, + * float, and complex are useful examples of such callables. If None, + * str is used. + * + * - choices -- A container of values that should be allowed. If not None, + * after a command-line argument has been converted to the appropriate + * type, an exception will be raised if it is not a member of this + * collection. + * + * - required -- True if the action must always be specified at the + * command line. This is only meaningful for optional command-line + * arguments. + * + * - help -- The help string describing the argument. + * + * - metavar -- The name to be used for the option's argument with the + * help string. If None, the 'dest' value will be used as the name. + */ + + constructor() { + let [ + option_strings, + dest, + nargs, + const_value, + default_value, + type, + choices, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + nargs: undefined, + const: undefined, + default: undefined, + type: undefined, + choices: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + // when this class is called as a function, redirect it to .call() method of itself + super('return arguments.callee.call.apply(arguments.callee, arguments)') + + this.option_strings = option_strings + this.dest = dest + this.nargs = nargs + this.const = const_value + this.default = default_value + this.type = type + this.choices = choices + this.required = required + this.help = help + this.metavar = metavar + } + + _get_kwargs() { + let names = [ + 'option_strings', + 'dest', + 'nargs', + 'const', + 'default', + 'type', + 'choices', + 'help', + 'metavar' + ] + return names.map(name => [ name, getattr(this, name) ]) + } + + format_usage() { + return this.option_strings[0] + } + + call(/*parser, namespace, values, option_string = undefined*/) { + throw new Error('.call() not defined') + } +})) + + +const BooleanOptionalAction = _camelcase_alias(_callable(class BooleanOptionalAction extends Action { + + constructor() { + let [ + option_strings, + dest, + default_value, + type, + choices, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + default: undefined, + type: undefined, + choices: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + let _option_strings = [] + for (let option_string of option_strings) { + _option_strings.push(option_string) + + if (option_string.startsWith('--')) { + option_string = '--no-' + option_string.slice(2) + _option_strings.push(option_string) + } + } + + if (help !== undefined && default_value !== undefined) { + help += ` (default: ${default_value})` + } + + super({ + option_strings: _option_strings, + dest, + nargs: 0, + default: default_value, + type, + choices, + required, + help, + metavar + }) + } + + call(parser, namespace, values, option_string = undefined) { + if (this.option_strings.includes(option_string)) { + setattr(namespace, this.dest, !option_string.startsWith('--no-')) + } + } + + format_usage() { + return this.option_strings.join(' | ') + } +})) + + +const _StoreAction = _callable(class _StoreAction extends Action { + + constructor() { + let [ + option_strings, + dest, + nargs, + const_value, + default_value, + type, + choices, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + nargs: undefined, + const: undefined, + default: undefined, + type: undefined, + choices: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + if (nargs === 0) { + throw new TypeError('nargs for store actions must be != 0; if you ' + + 'have nothing to store, actions such as store ' + + 'true or store const may be more appropriate') + } + if (const_value !== undefined && nargs !== OPTIONAL) { + throw new TypeError(sub('nargs must be %r to supply const', OPTIONAL)) + } + super({ + option_strings, + dest, + nargs, + const: const_value, + default: default_value, + type, + choices, + required, + help, + metavar + }) + } + + call(parser, namespace, values/*, option_string = undefined*/) { + setattr(namespace, this.dest, values) + } +}) + + +const _StoreConstAction = _callable(class _StoreConstAction extends Action { + + constructor() { + let [ + option_strings, + dest, + const_value, + default_value, + required, + help + //, metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + const: no_default, + default: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + super({ + option_strings, + dest, + nargs: 0, + const: const_value, + default: default_value, + required, + help + }) + } + + call(parser, namespace/*, values, option_string = undefined*/) { + setattr(namespace, this.dest, this.const) + } +}) + + +const _StoreTrueAction = _callable(class _StoreTrueAction extends _StoreConstAction { + + constructor() { + let [ + option_strings, + dest, + default_value, + required, + help + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + default: false, + required: false, + help: undefined + }) + + super({ + option_strings, + dest, + const: true, + default: default_value, + required, + help + }) + } +}) + + +const _StoreFalseAction = _callable(class _StoreFalseAction extends _StoreConstAction { + + constructor() { + let [ + option_strings, + dest, + default_value, + required, + help + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + default: true, + required: false, + help: undefined + }) + + super({ + option_strings, + dest, + const: false, + default: default_value, + required, + help + }) + } +}) + + +const _AppendAction = _callable(class _AppendAction extends Action { + + constructor() { + let [ + option_strings, + dest, + nargs, + const_value, + default_value, + type, + choices, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + nargs: undefined, + const: undefined, + default: undefined, + type: undefined, + choices: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + if (nargs === 0) { + throw new TypeError('nargs for append actions must be != 0; if arg ' + + 'strings are not supplying the value to append, ' + + 'the append const action may be more appropriate') + } + if (const_value !== undefined && nargs !== OPTIONAL) { + throw new TypeError(sub('nargs must be %r to supply const', OPTIONAL)) + } + super({ + option_strings, + dest, + nargs, + const: const_value, + default: default_value, + type, + choices, + required, + help, + metavar + }) + } + + call(parser, namespace, values/*, option_string = undefined*/) { + let items = getattr(namespace, this.dest, undefined) + items = _copy_items(items) + items.push(values) + setattr(namespace, this.dest, items) + } +}) + + +const _AppendConstAction = _callable(class _AppendConstAction extends Action { + + constructor() { + let [ + option_strings, + dest, + const_value, + default_value, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + const: no_default, + default: undefined, + required: false, + help: undefined, + metavar: undefined + }) + + super({ + option_strings, + dest, + nargs: 0, + const: const_value, + default: default_value, + required, + help, + metavar + }) + } + + call(parser, namespace/*, values, option_string = undefined*/) { + let items = getattr(namespace, this.dest, undefined) + items = _copy_items(items) + items.push(this.const) + setattr(namespace, this.dest, items) + } +}) + + +const _CountAction = _callable(class _CountAction extends Action { + + constructor() { + let [ + option_strings, + dest, + default_value, + required, + help + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: no_default, + default: undefined, + required: false, + help: undefined + }) + + super({ + option_strings, + dest, + nargs: 0, + default: default_value, + required, + help + }) + } + + call(parser, namespace/*, values, option_string = undefined*/) { + let count = getattr(namespace, this.dest, undefined) + if (count === undefined) { + count = 0 + } + setattr(namespace, this.dest, count + 1) + } +}) + + +const _HelpAction = _callable(class _HelpAction extends Action { + + constructor() { + let [ + option_strings, + dest, + default_value, + help + ] = _parse_opts(arguments, { + option_strings: no_default, + dest: SUPPRESS, + default: SUPPRESS, + help: undefined + }) + + super({ + option_strings, + dest, + default: default_value, + nargs: 0, + help + }) + } + + call(parser/*, namespace, values, option_string = undefined*/) { + parser.print_help() + parser.exit() + } +}) + + +const _VersionAction = _callable(class _VersionAction extends Action { + + constructor() { + let [ + option_strings, + version, + dest, + default_value, + help + ] = _parse_opts(arguments, { + option_strings: no_default, + version: undefined, + dest: SUPPRESS, + default: SUPPRESS, + help: "show program's version number and exit" + }) + + super({ + option_strings, + dest, + default: default_value, + nargs: 0, + help + }) + this.version = version + } + + call(parser/*, namespace, values, option_string = undefined*/) { + let version = this.version + if (version === undefined) { + version = parser.version + } + let formatter = parser._get_formatter() + formatter.add_text(version) + parser._print_message(formatter.format_help(), process.stdout) + parser.exit() + } +}) + + +const _SubParsersAction = _camelcase_alias(_callable(class _SubParsersAction extends Action { + + constructor() { + let [ + option_strings, + prog, + parser_class, + dest, + required, + help, + metavar + ] = _parse_opts(arguments, { + option_strings: no_default, + prog: no_default, + parser_class: no_default, + dest: SUPPRESS, + required: false, + help: undefined, + metavar: undefined + }) + + let name_parser_map = {} + + super({ + option_strings, + dest, + nargs: PARSER, + choices: name_parser_map, + required, + help, + metavar + }) + + this._prog_prefix = prog + this._parser_class = parser_class + this._name_parser_map = name_parser_map + this._choices_actions = [] + } + + add_parser() { + let [ + name, + kwargs + ] = _parse_opts(arguments, { + name: no_default, + '**kwargs': no_default + }) + + // set prog from the existing prefix + if (kwargs.prog === undefined) { + kwargs.prog = sub('%s %s', this._prog_prefix, name) + } + + let aliases = getattr(kwargs, 'aliases', []) + delete kwargs.aliases + + // create a pseudo-action to hold the choice help + if ('help' in kwargs) { + let help = kwargs.help + delete kwargs.help + let choice_action = this._ChoicesPseudoAction(name, aliases, help) + this._choices_actions.push(choice_action) + } + + // create the parser and add it to the map + let parser = new this._parser_class(kwargs) + this._name_parser_map[name] = parser + + // make parser available under aliases also + for (let alias of aliases) { + this._name_parser_map[alias] = parser + } + + return parser + } + + _get_subactions() { + return this._choices_actions + } + + call(parser, namespace, values/*, option_string = undefined*/) { + let parser_name = values[0] + let arg_strings = values.slice(1) + + // set the parser name if requested + if (this.dest !== SUPPRESS) { + setattr(namespace, this.dest, parser_name) + } + + // select the parser + if (hasattr(this._name_parser_map, parser_name)) { + parser = this._name_parser_map[parser_name] + } else { + let args = {parser_name, + choices: this._name_parser_map.join(', ')} + let msg = sub('unknown parser %(parser_name)r (choices: %(choices)s)', args) + throw new ArgumentError(this, msg) + } + + // parse all the remaining options into the namespace + // store any unrecognized options on the object, so that the top + // level parser can decide what to do with them + + // In case this subparser defines new defaults, we parse them + // in a new namespace object and then update the original + // namespace for the relevant parts. + let subnamespace + [ subnamespace, arg_strings ] = parser.parse_known_args(arg_strings, undefined) + for (let [ key, value ] of Object.entries(subnamespace)) { + setattr(namespace, key, value) + } + + if (arg_strings.length) { + setdefault(namespace, _UNRECOGNIZED_ARGS_ATTR, []) + getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).push(...arg_strings) + } + } +})) + + +_SubParsersAction.prototype._ChoicesPseudoAction = _callable(class _ChoicesPseudoAction extends Action { + constructor(name, aliases, help) { + let metavar = name, dest = name + if (aliases.length) { + metavar += sub(' (%s)', aliases.join(', ')) + } + super({ option_strings: [], dest, help, metavar }) + } +}) + + +const _ExtendAction = _callable(class _ExtendAction extends _AppendAction { + call(parser, namespace, values/*, option_string = undefined*/) { + let items = getattr(namespace, this.dest, undefined) + items = _copy_items(items) + items = items.concat(values) + setattr(namespace, this.dest, items) + } +}) + + +// ============== +// Type classes +// ============== +const FileType = _callable(class FileType extends Function { + /* + * Factory for creating file object types + * + * Instances of FileType are typically passed as type= arguments to the + * ArgumentParser add_argument() method. + * + * Keyword Arguments: + * - mode -- A string indicating how the file is to be opened. Accepts the + * same values as the builtin open() function. + * - bufsize -- The file's desired buffer size. Accepts the same values as + * the builtin open() function. + * - encoding -- The file's encoding. Accepts the same values as the + * builtin open() function. + * - errors -- A string indicating how encoding and decoding errors are to + * be handled. Accepts the same value as the builtin open() function. + */ + + constructor() { + let [ + flags, + encoding, + mode, + autoClose, + emitClose, + start, + end, + highWaterMark, + fs + ] = _parse_opts(arguments, { + flags: 'r', + encoding: undefined, + mode: undefined, // 0o666 + autoClose: undefined, // true + emitClose: undefined, // false + start: undefined, // 0 + end: undefined, // Infinity + highWaterMark: undefined, // 64 * 1024 + fs: undefined + }) + + // when this class is called as a function, redirect it to .call() method of itself + super('return arguments.callee.call.apply(arguments.callee, arguments)') + + Object.defineProperty(this, 'name', { + get() { + return sub('FileType(%r)', flags) + } + }) + this._flags = flags + this._options = {} + if (encoding !== undefined) this._options.encoding = encoding + if (mode !== undefined) this._options.mode = mode + if (autoClose !== undefined) this._options.autoClose = autoClose + if (emitClose !== undefined) this._options.emitClose = emitClose + if (start !== undefined) this._options.start = start + if (end !== undefined) this._options.end = end + if (highWaterMark !== undefined) this._options.highWaterMark = highWaterMark + if (fs !== undefined) this._options.fs = fs + } + + call(string) { + // the special argument "-" means sys.std{in,out} + if (string === '-') { + if (this._flags.includes('r')) { + return process.stdin + } else if (this._flags.includes('w')) { + return process.stdout + } else { + let msg = sub('argument "-" with mode %r', this._flags) + throw new TypeError(msg) + } + } + + // all other arguments are used as file names + let fd + try { + fd = fs.openSync(string, this._flags, this._options.mode) + } catch (e) { + let args = { filename: string, error: e.message } + let message = "can't open '%(filename)s': %(error)s" + throw new ArgumentTypeError(sub(message, args)) + } + + let options = Object.assign({ fd, flags: this._flags }, this._options) + if (this._flags.includes('r')) { + return fs.createReadStream(undefined, options) + } else if (this._flags.includes('w')) { + return fs.createWriteStream(undefined, options) + } else { + let msg = sub('argument "%s" with mode %r', string, this._flags) + throw new TypeError(msg) + } + } + + [util.inspect.custom]() { + let args = [ this._flags ] + let kwargs = Object.entries(this._options).map(([ k, v ]) => { + if (k === 'mode') v = { value: v, [util.inspect.custom]() { return '0o' + this.value.toString(8) } } + return [ k, v ] + }) + let args_str = [] + .concat(args.filter(arg => arg !== -1).map(repr)) + .concat(kwargs.filter(([/*kw*/, arg]) => arg !== undefined) + .map(([kw, arg]) => sub('%s=%r', kw, arg))) + .join(', ') + return sub('%s(%s)', this.constructor.name, args_str) + } + + toString() { + return this[util.inspect.custom]() + } +}) + +// =========================== +// Optional and Positional Parsing +// =========================== +const Namespace = _callable(class Namespace extends _AttributeHolder() { + /* + * Simple object for storing attributes. + * + * Implements equality by attribute names and values, and provides a simple + * string representation. + */ + + constructor(options = {}) { + super() + Object.assign(this, options) + } +}) + +// unset string tag to mimic plain object +Namespace.prototype[Symbol.toStringTag] = undefined + + +const _ActionsContainer = _camelcase_alias(_callable(class _ActionsContainer { + + constructor() { + let [ + description, + prefix_chars, + argument_default, + conflict_handler + ] = _parse_opts(arguments, { + description: no_default, + prefix_chars: no_default, + argument_default: no_default, + conflict_handler: no_default + }) + + this.description = description + this.argument_default = argument_default + this.prefix_chars = prefix_chars + this.conflict_handler = conflict_handler + + // set up registries + this._registries = {} + + // register actions + this.register('action', undefined, _StoreAction) + this.register('action', 'store', _StoreAction) + this.register('action', 'store_const', _StoreConstAction) + this.register('action', 'store_true', _StoreTrueAction) + this.register('action', 'store_false', _StoreFalseAction) + this.register('action', 'append', _AppendAction) + this.register('action', 'append_const', _AppendConstAction) + this.register('action', 'count', _CountAction) + this.register('action', 'help', _HelpAction) + this.register('action', 'version', _VersionAction) + this.register('action', 'parsers', _SubParsersAction) + this.register('action', 'extend', _ExtendAction) + // LEGACY (v1 compatibility): camelcase variants + ;[ 'storeConst', 'storeTrue', 'storeFalse', 'appendConst' ].forEach(old_name => { + let new_name = _to_new_name(old_name) + this.register('action', old_name, util.deprecate(this._registry_get('action', new_name), + sub('{action: "%s"} is renamed to {action: "%s"}', old_name, new_name))) + }) + // end + + // raise an exception if the conflict handler is invalid + this._get_handler() + + // action storage + this._actions = [] + this._option_string_actions = {} + + // groups + this._action_groups = [] + this._mutually_exclusive_groups = [] + + // defaults storage + this._defaults = {} + + // determines whether an "option" looks like a negative number + this._negative_number_matcher = /^-\d+$|^-\d*\.\d+$/ + + // whether or not there are any optionals that look like negative + // numbers -- uses a list so it can be shared and edited + this._has_negative_number_optionals = [] + } + + // ==================== + // Registration methods + // ==================== + register(registry_name, value, object) { + let registry = setdefault(this._registries, registry_name, {}) + registry[value] = object + } + + _registry_get(registry_name, value, default_value = undefined) { + return getattr(this._registries[registry_name], value, default_value) + } + + // ================================== + // Namespace default accessor methods + // ================================== + set_defaults(kwargs) { + Object.assign(this._defaults, kwargs) + + // if these defaults match any existing arguments, replace + // the previous default on the object with the new one + for (let action of this._actions) { + if (action.dest in kwargs) { + action.default = kwargs[action.dest] + } + } + } + + get_default(dest) { + for (let action of this._actions) { + if (action.dest === dest && action.default !== undefined) { + return action.default + } + } + return this._defaults[dest] + } + + + // ======================= + // Adding argument actions + // ======================= + add_argument() { + /* + * add_argument(dest, ..., name=value, ...) + * add_argument(option_string, option_string, ..., name=value, ...) + */ + let [ + args, + kwargs + ] = _parse_opts(arguments, { + '*args': no_default, + '**kwargs': no_default + }) + // LEGACY (v1 compatibility), old-style add_argument([ args ], { options }) + if (args.length === 1 && Array.isArray(args[0])) { + args = args[0] + deprecate('argument-array', + sub('use add_argument(%(args)s, {...}) instead of add_argument([ %(args)s ], { ... })', { + args: args.map(repr).join(', ') + })) + } + // end + + // if no positional args are supplied or only one is supplied and + // it doesn't look like an option string, parse a positional + // argument + let chars = this.prefix_chars + if (!args.length || args.length === 1 && !chars.includes(args[0][0])) { + if (args.length && 'dest' in kwargs) { + throw new TypeError('dest supplied twice for positional argument') + } + kwargs = this._get_positional_kwargs(...args, kwargs) + + // otherwise, we're adding an optional argument + } else { + kwargs = this._get_optional_kwargs(...args, kwargs) + } + + // if no default was supplied, use the parser-level default + if (!('default' in kwargs)) { + let dest = kwargs.dest + if (dest in this._defaults) { + kwargs.default = this._defaults[dest] + } else if (this.argument_default !== undefined) { + kwargs.default = this.argument_default + } + } + + // create the action object, and add it to the parser + let action_class = this._pop_action_class(kwargs) + if (typeof action_class !== 'function') { + throw new TypeError(sub('unknown action "%s"', action_class)) + } + // eslint-disable-next-line new-cap + let action = new action_class(kwargs) + + // raise an error if the action type is not callable + let type_func = this._registry_get('type', action.type, action.type) + if (typeof type_func !== 'function') { + throw new TypeError(sub('%r is not callable', type_func)) + } + + if (type_func === FileType) { + throw new TypeError(sub('%r is a FileType class object, instance of it' + + ' must be passed', type_func)) + } + + // raise an error if the metavar does not match the type + if ('_get_formatter' in this) { + try { + this._get_formatter()._format_args(action, undefined) + } catch (err) { + // check for 'invalid nargs value' is an artifact of TypeError and ValueError in js being the same + if (err instanceof TypeError && err.message !== 'invalid nargs value') { + throw new TypeError('length of metavar tuple does not match nargs') + } else { + throw err + } + } + } + + return this._add_action(action) + } + + add_argument_group() { + let group = _ArgumentGroup(this, ...arguments) + this._action_groups.push(group) + return group + } + + add_mutually_exclusive_group() { + // eslint-disable-next-line no-use-before-define + let group = _MutuallyExclusiveGroup(this, ...arguments) + this._mutually_exclusive_groups.push(group) + return group + } + + _add_action(action) { + // resolve any conflicts + this._check_conflict(action) + + // add to actions list + this._actions.push(action) + action.container = this + + // index the action by any option strings it has + for (let option_string of action.option_strings) { + this._option_string_actions[option_string] = action + } + + // set the flag if any option strings look like negative numbers + for (let option_string of action.option_strings) { + if (this._negative_number_matcher.test(option_string)) { + if (!this._has_negative_number_optionals.length) { + this._has_negative_number_optionals.push(true) + } + } + } + + // return the created action + return action + } + + _remove_action(action) { + _array_remove(this._actions, action) + } + + _add_container_actions(container) { + // collect groups by titles + let title_group_map = {} + for (let group of this._action_groups) { + if (group.title in title_group_map) { + let msg = 'cannot merge actions - two groups are named %r' + throw new TypeError(sub(msg, group.title)) + } + title_group_map[group.title] = group + } + + // map each action to its group + let group_map = new Map() + for (let group of container._action_groups) { + + // if a group with the title exists, use that, otherwise + // create a new group matching the container's group + if (!(group.title in title_group_map)) { + title_group_map[group.title] = this.add_argument_group({ + title: group.title, + description: group.description, + conflict_handler: group.conflict_handler + }) + } + + // map the actions to their new group + for (let action of group._group_actions) { + group_map.set(action, title_group_map[group.title]) + } + } + + // add container's mutually exclusive groups + // NOTE: if add_mutually_exclusive_group ever gains title= and + // description= then this code will need to be expanded as above + for (let group of container._mutually_exclusive_groups) { + let mutex_group = this.add_mutually_exclusive_group({ + required: group.required + }) + + // map the actions to their new mutex group + for (let action of group._group_actions) { + group_map.set(action, mutex_group) + } + } + + // add all actions to this container or their group + for (let action of container._actions) { + group_map.get(action)._add_action(action) + } + } + + _get_positional_kwargs() { + let [ + dest, + kwargs + ] = _parse_opts(arguments, { + dest: no_default, + '**kwargs': no_default + }) + + // make sure required is not specified + if ('required' in kwargs) { + let msg = "'required' is an invalid argument for positionals" + throw new TypeError(msg) + } + + // mark positional arguments as required if at least one is + // always required + if (![OPTIONAL, ZERO_OR_MORE].includes(kwargs.nargs)) { + kwargs.required = true + } + if (kwargs.nargs === ZERO_OR_MORE && !('default' in kwargs)) { + kwargs.required = true + } + + // return the keyword arguments with no option strings + return Object.assign(kwargs, { dest, option_strings: [] }) + } + + _get_optional_kwargs() { + let [ + args, + kwargs + ] = _parse_opts(arguments, { + '*args': no_default, + '**kwargs': no_default + }) + + // determine short and long option strings + let option_strings = [] + let long_option_strings = [] + let option_string + for (option_string of args) { + // error on strings that don't start with an appropriate prefix + if (!this.prefix_chars.includes(option_string[0])) { + let args = {option: option_string, + prefix_chars: this.prefix_chars} + let msg = 'invalid option string %(option)r: ' + + 'must start with a character %(prefix_chars)r' + throw new TypeError(sub(msg, args)) + } + + // strings starting with two prefix characters are long options + option_strings.push(option_string) + if (option_string.length > 1 && this.prefix_chars.includes(option_string[1])) { + long_option_strings.push(option_string) + } + } + + // infer destination, '--foo-bar' -> 'foo_bar' and '-x' -> 'x' + let dest = kwargs.dest + delete kwargs.dest + if (dest === undefined) { + let dest_option_string + if (long_option_strings.length) { + dest_option_string = long_option_strings[0] + } else { + dest_option_string = option_strings[0] + } + dest = _string_lstrip(dest_option_string, this.prefix_chars) + if (!dest) { + let msg = 'dest= is required for options like %r' + throw new TypeError(sub(msg, option_string)) + } + dest = dest.replace(/-/g, '_') + } + + // return the updated keyword arguments + return Object.assign(kwargs, { dest, option_strings }) + } + + _pop_action_class(kwargs, default_value = undefined) { + let action = getattr(kwargs, 'action', default_value) + delete kwargs.action + return this._registry_get('action', action, action) + } + + _get_handler() { + // determine function from conflict handler string + let handler_func_name = sub('_handle_conflict_%s', this.conflict_handler) + if (typeof this[handler_func_name] === 'function') { + return this[handler_func_name] + } else { + let msg = 'invalid conflict_resolution value: %r' + throw new TypeError(sub(msg, this.conflict_handler)) + } + } + + _check_conflict(action) { + + // find all options that conflict with this option + let confl_optionals = [] + for (let option_string of action.option_strings) { + if (hasattr(this._option_string_actions, option_string)) { + let confl_optional = this._option_string_actions[option_string] + confl_optionals.push([ option_string, confl_optional ]) + } + } + + // resolve any conflicts + if (confl_optionals.length) { + let conflict_handler = this._get_handler() + conflict_handler.call(this, action, confl_optionals) + } + } + + _handle_conflict_error(action, conflicting_actions) { + let message = conflicting_actions.length === 1 ? + 'conflicting option string: %s' : + 'conflicting option strings: %s' + let conflict_string = conflicting_actions.map(([ option_string/*, action*/ ]) => option_string).join(', ') + throw new ArgumentError(action, sub(message, conflict_string)) + } + + _handle_conflict_resolve(action, conflicting_actions) { + + // remove all conflicting options + for (let [ option_string, action ] of conflicting_actions) { + + // remove the conflicting option + _array_remove(action.option_strings, option_string) + delete this._option_string_actions[option_string] + + // if the option now has no option string, remove it from the + // container holding it + if (!action.option_strings.length) { + action.container._remove_action(action) + } + } + } +})) + + +const _ArgumentGroup = _callable(class _ArgumentGroup extends _ActionsContainer { + + constructor() { + let [ + container, + title, + description, + kwargs + ] = _parse_opts(arguments, { + container: no_default, + title: undefined, + description: undefined, + '**kwargs': no_default + }) + + // add any missing keyword arguments by checking the container + setdefault(kwargs, 'conflict_handler', container.conflict_handler) + setdefault(kwargs, 'prefix_chars', container.prefix_chars) + setdefault(kwargs, 'argument_default', container.argument_default) + super(Object.assign({ description }, kwargs)) + + // group attributes + this.title = title + this._group_actions = [] + + // share most attributes with the container + this._registries = container._registries + this._actions = container._actions + this._option_string_actions = container._option_string_actions + this._defaults = container._defaults + this._has_negative_number_optionals = + container._has_negative_number_optionals + this._mutually_exclusive_groups = container._mutually_exclusive_groups + } + + _add_action(action) { + action = super._add_action(action) + this._group_actions.push(action) + return action + } + + _remove_action(action) { + super._remove_action(action) + _array_remove(this._group_actions, action) + } +}) + + +const _MutuallyExclusiveGroup = _callable(class _MutuallyExclusiveGroup extends _ArgumentGroup { + + constructor() { + let [ + container, + required + ] = _parse_opts(arguments, { + container: no_default, + required: false + }) + + super(container) + this.required = required + this._container = container + } + + _add_action(action) { + if (action.required) { + let msg = 'mutually exclusive arguments must be optional' + throw new TypeError(msg) + } + action = this._container._add_action(action) + this._group_actions.push(action) + return action + } + + _remove_action(action) { + this._container._remove_action(action) + _array_remove(this._group_actions, action) + } +}) + + +const ArgumentParser = _camelcase_alias(_callable(class ArgumentParser extends _AttributeHolder(_ActionsContainer) { + /* + * Object for parsing command line strings into Python objects. + * + * Keyword Arguments: + * - prog -- The name of the program (default: sys.argv[0]) + * - usage -- A usage message (default: auto-generated from arguments) + * - description -- A description of what the program does + * - epilog -- Text following the argument descriptions + * - parents -- Parsers whose arguments should be copied into this one + * - formatter_class -- HelpFormatter class for printing help messages + * - prefix_chars -- Characters that prefix optional arguments + * - fromfile_prefix_chars -- Characters that prefix files containing + * additional arguments + * - argument_default -- The default value for all arguments + * - conflict_handler -- String indicating how to handle conflicts + * - add_help -- Add a -h/-help option + * - allow_abbrev -- Allow long options to be abbreviated unambiguously + * - exit_on_error -- Determines whether or not ArgumentParser exits with + * error info when an error occurs + */ + + constructor() { + let [ + prog, + usage, + description, + epilog, + parents, + formatter_class, + prefix_chars, + fromfile_prefix_chars, + argument_default, + conflict_handler, + add_help, + allow_abbrev, + exit_on_error, + debug, // LEGACY (v1 compatibility), debug mode + version // LEGACY (v1 compatibility), version + ] = _parse_opts(arguments, { + prog: undefined, + usage: undefined, + description: undefined, + epilog: undefined, + parents: [], + formatter_class: HelpFormatter, + prefix_chars: '-', + fromfile_prefix_chars: undefined, + argument_default: undefined, + conflict_handler: 'error', + add_help: true, + allow_abbrev: true, + exit_on_error: true, + debug: undefined, // LEGACY (v1 compatibility), debug mode + version: undefined // LEGACY (v1 compatibility), version + }) + + // LEGACY (v1 compatibility) + if (debug !== undefined) { + deprecate('debug', + 'The "debug" argument to ArgumentParser is deprecated. Please ' + + 'override ArgumentParser.exit function instead.' + ) + } + + if (version !== undefined) { + deprecate('version', + 'The "version" argument to ArgumentParser is deprecated. Please use ' + + "add_argument(..., { action: 'version', version: 'N', ... }) instead." + ) + } + // end + + super({ + description, + prefix_chars, + argument_default, + conflict_handler + }) + + // default setting for prog + if (prog === undefined) { + prog = path.basename(get_argv()[0] || '') + } + + this.prog = prog + this.usage = usage + this.epilog = epilog + this.formatter_class = formatter_class + this.fromfile_prefix_chars = fromfile_prefix_chars + this.add_help = add_help + this.allow_abbrev = allow_abbrev + this.exit_on_error = exit_on_error + // LEGACY (v1 compatibility), debug mode + this.debug = debug + // end + + this._positionals = this.add_argument_group('positional arguments') + this._optionals = this.add_argument_group('optional arguments') + this._subparsers = undefined + + // register types + function identity(string) { + return string + } + this.register('type', undefined, identity) + this.register('type', null, identity) + this.register('type', 'auto', identity) + this.register('type', 'int', function (x) { + let result = Number(x) + if (!Number.isInteger(result)) { + throw new TypeError(sub('could not convert string to int: %r', x)) + } + return result + }) + this.register('type', 'float', function (x) { + let result = Number(x) + if (isNaN(result)) { + throw new TypeError(sub('could not convert string to float: %r', x)) + } + return result + }) + this.register('type', 'str', String) + // LEGACY (v1 compatibility): custom types + this.register('type', 'string', + util.deprecate(String, 'use {type:"str"} or {type:String} instead of {type:"string"}')) + // end + + // add help argument if necessary + // (using explicit default to override global argument_default) + let default_prefix = prefix_chars.includes('-') ? '-' : prefix_chars[0] + if (this.add_help) { + this.add_argument( + default_prefix + 'h', + default_prefix.repeat(2) + 'help', + { + action: 'help', + default: SUPPRESS, + help: 'show this help message and exit' + } + ) + } + // LEGACY (v1 compatibility), version + if (version) { + this.add_argument( + default_prefix + 'v', + default_prefix.repeat(2) + 'version', + { + action: 'version', + default: SUPPRESS, + version: this.version, + help: "show program's version number and exit" + } + ) + } + // end + + // add parent arguments and defaults + for (let parent of parents) { + this._add_container_actions(parent) + Object.assign(this._defaults, parent._defaults) + } + } + + // ======================= + // Pretty __repr__ methods + // ======================= + _get_kwargs() { + let names = [ + 'prog', + 'usage', + 'description', + 'formatter_class', + 'conflict_handler', + 'add_help' + ] + return names.map(name => [ name, getattr(this, name) ]) + } + + // ================================== + // Optional/Positional adding methods + // ================================== + add_subparsers() { + let [ + kwargs + ] = _parse_opts(arguments, { + '**kwargs': no_default + }) + + if (this._subparsers !== undefined) { + this.error('cannot have multiple subparser arguments') + } + + // add the parser class to the arguments if it's not present + setdefault(kwargs, 'parser_class', this.constructor) + + if ('title' in kwargs || 'description' in kwargs) { + let title = getattr(kwargs, 'title', 'subcommands') + let description = getattr(kwargs, 'description', undefined) + delete kwargs.title + delete kwargs.description + this._subparsers = this.add_argument_group(title, description) + } else { + this._subparsers = this._positionals + } + + // prog defaults to the usage message of this parser, skipping + // optional arguments and with no "usage:" prefix + if (kwargs.prog === undefined) { + let formatter = this._get_formatter() + let positionals = this._get_positional_actions() + let groups = this._mutually_exclusive_groups + formatter.add_usage(this.usage, positionals, groups, '') + kwargs.prog = formatter.format_help().trim() + } + + // create the parsers action and add it to the positionals list + let parsers_class = this._pop_action_class(kwargs, 'parsers') + // eslint-disable-next-line new-cap + let action = new parsers_class(Object.assign({ option_strings: [] }, kwargs)) + this._subparsers._add_action(action) + + // return the created parsers action + return action + } + + _add_action(action) { + if (action.option_strings.length) { + this._optionals._add_action(action) + } else { + this._positionals._add_action(action) + } + return action + } + + _get_optional_actions() { + return this._actions.filter(action => action.option_strings.length) + } + + _get_positional_actions() { + return this._actions.filter(action => !action.option_strings.length) + } + + // ===================================== + // Command line argument parsing methods + // ===================================== + parse_args(args = undefined, namespace = undefined) { + let argv + [ args, argv ] = this.parse_known_args(args, namespace) + if (argv && argv.length > 0) { + let msg = 'unrecognized arguments: %s' + this.error(sub(msg, argv.join(' '))) + } + return args + } + + parse_known_args(args = undefined, namespace = undefined) { + if (args === undefined) { + args = get_argv().slice(1) + } + + // default Namespace built from parser defaults + if (namespace === undefined) { + namespace = new Namespace() + } + + // add any action defaults that aren't present + for (let action of this._actions) { + if (action.dest !== SUPPRESS) { + if (!hasattr(namespace, action.dest)) { + if (action.default !== SUPPRESS) { + setattr(namespace, action.dest, action.default) + } + } + } + } + + // add any parser defaults that aren't present + for (let dest of Object.keys(this._defaults)) { + if (!hasattr(namespace, dest)) { + setattr(namespace, dest, this._defaults[dest]) + } + } + + // parse the arguments and exit if there are any errors + if (this.exit_on_error) { + try { + [ namespace, args ] = this._parse_known_args(args, namespace) + } catch (err) { + if (err instanceof ArgumentError) { + this.error(err.message) + } else { + throw err + } + } + } else { + [ namespace, args ] = this._parse_known_args(args, namespace) + } + + if (hasattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) { + args = args.concat(getattr(namespace, _UNRECOGNIZED_ARGS_ATTR)) + delattr(namespace, _UNRECOGNIZED_ARGS_ATTR) + } + + return [ namespace, args ] + } + + _parse_known_args(arg_strings, namespace) { + // replace arg strings that are file references + if (this.fromfile_prefix_chars !== undefined) { + arg_strings = this._read_args_from_files(arg_strings) + } + + // map all mutually exclusive arguments to the other arguments + // they can't occur with + let action_conflicts = new Map() + for (let mutex_group of this._mutually_exclusive_groups) { + let group_actions = mutex_group._group_actions + for (let [ i, mutex_action ] of Object.entries(mutex_group._group_actions)) { + let conflicts = action_conflicts.get(mutex_action) || [] + conflicts = conflicts.concat(group_actions.slice(0, +i)) + conflicts = conflicts.concat(group_actions.slice(+i + 1)) + action_conflicts.set(mutex_action, conflicts) + } + } + + // find all option indices, and determine the arg_string_pattern + // which has an 'O' if there is an option at an index, + // an 'A' if there is an argument, or a '-' if there is a '--' + let option_string_indices = {} + let arg_string_pattern_parts = [] + let arg_strings_iter = Object.entries(arg_strings)[Symbol.iterator]() + for (let [ i, arg_string ] of arg_strings_iter) { + + // all args after -- are non-options + if (arg_string === '--') { + arg_string_pattern_parts.push('-') + for ([ i, arg_string ] of arg_strings_iter) { + arg_string_pattern_parts.push('A') + } + + // otherwise, add the arg to the arg strings + // and note the index if it was an option + } else { + let option_tuple = this._parse_optional(arg_string) + let pattern + if (option_tuple === undefined) { + pattern = 'A' + } else { + option_string_indices[i] = option_tuple + pattern = 'O' + } + arg_string_pattern_parts.push(pattern) + } + } + + // join the pieces together to form the pattern + let arg_strings_pattern = arg_string_pattern_parts.join('') + + // converts arg strings to the appropriate and then takes the action + let seen_actions = new Set() + let seen_non_default_actions = new Set() + let extras + + let take_action = (action, argument_strings, option_string = undefined) => { + seen_actions.add(action) + let argument_values = this._get_values(action, argument_strings) + + // error if this argument is not allowed with other previously + // seen arguments, assuming that actions that use the default + // value don't really count as "present" + if (argument_values !== action.default) { + seen_non_default_actions.add(action) + for (let conflict_action of action_conflicts.get(action) || []) { + if (seen_non_default_actions.has(conflict_action)) { + let msg = 'not allowed with argument %s' + let action_name = _get_action_name(conflict_action) + throw new ArgumentError(action, sub(msg, action_name)) + } + } + } + + // take the action if we didn't receive a SUPPRESS value + // (e.g. from a default) + if (argument_values !== SUPPRESS) { + action(this, namespace, argument_values, option_string) + } + } + + // function to convert arg_strings into an optional action + let consume_optional = start_index => { + + // get the optional identified at this index + let option_tuple = option_string_indices[start_index] + let [ action, option_string, explicit_arg ] = option_tuple + + // identify additional optionals in the same arg string + // (e.g. -xyz is the same as -x -y -z if no args are required) + let action_tuples = [] + let stop + for (;;) { + + // if we found no optional action, skip it + if (action === undefined) { + extras.push(arg_strings[start_index]) + return start_index + 1 + } + + // if there is an explicit argument, try to match the + // optional's string arguments to only this + if (explicit_arg !== undefined) { + let arg_count = this._match_argument(action, 'A') + + // if the action is a single-dash option and takes no + // arguments, try to parse more single-dash options out + // of the tail of the option string + let chars = this.prefix_chars + if (arg_count === 0 && !chars.includes(option_string[1])) { + action_tuples.push([ action, [], option_string ]) + let char = option_string[0] + option_string = char + explicit_arg[0] + let new_explicit_arg = explicit_arg.slice(1) || undefined + let optionals_map = this._option_string_actions + if (hasattr(optionals_map, option_string)) { + action = optionals_map[option_string] + explicit_arg = new_explicit_arg + } else { + let msg = 'ignored explicit argument %r' + throw new ArgumentError(action, sub(msg, explicit_arg)) + } + + // if the action expect exactly one argument, we've + // successfully matched the option; exit the loop + } else if (arg_count === 1) { + stop = start_index + 1 + let args = [ explicit_arg ] + action_tuples.push([ action, args, option_string ]) + break + + // error if a double-dash option did not use the + // explicit argument + } else { + let msg = 'ignored explicit argument %r' + throw new ArgumentError(action, sub(msg, explicit_arg)) + } + + // if there is no explicit argument, try to match the + // optional's string arguments with the following strings + // if successful, exit the loop + } else { + let start = start_index + 1 + let selected_patterns = arg_strings_pattern.slice(start) + let arg_count = this._match_argument(action, selected_patterns) + stop = start + arg_count + let args = arg_strings.slice(start, stop) + action_tuples.push([ action, args, option_string ]) + break + } + } + + // add the Optional to the list and return the index at which + // the Optional's string args stopped + assert(action_tuples.length) + for (let [ action, args, option_string ] of action_tuples) { + take_action(action, args, option_string) + } + return stop + } + + // the list of Positionals left to be parsed; this is modified + // by consume_positionals() + let positionals = this._get_positional_actions() + + // function to convert arg_strings into positional actions + let consume_positionals = start_index => { + // match as many Positionals as possible + let selected_pattern = arg_strings_pattern.slice(start_index) + let arg_counts = this._match_arguments_partial(positionals, selected_pattern) + + // slice off the appropriate arg strings for each Positional + // and add the Positional and its args to the list + for (let i = 0; i < positionals.length && i < arg_counts.length; i++) { + let action = positionals[i] + let arg_count = arg_counts[i] + let args = arg_strings.slice(start_index, start_index + arg_count) + start_index += arg_count + take_action(action, args) + } + + // slice off the Positionals that we just parsed and return the + // index at which the Positionals' string args stopped + positionals = positionals.slice(arg_counts.length) + return start_index + } + + // consume Positionals and Optionals alternately, until we have + // passed the last option string + extras = [] + let start_index = 0 + let max_option_string_index = Math.max(-1, ...Object.keys(option_string_indices).map(Number)) + while (start_index <= max_option_string_index) { + + // consume any Positionals preceding the next option + let next_option_string_index = Math.min( + // eslint-disable-next-line no-loop-func + ...Object.keys(option_string_indices).map(Number).filter(index => index >= start_index) + ) + if (start_index !== next_option_string_index) { + let positionals_end_index = consume_positionals(start_index) + + // only try to parse the next optional if we didn't consume + // the option string during the positionals parsing + if (positionals_end_index > start_index) { + start_index = positionals_end_index + continue + } else { + start_index = positionals_end_index + } + } + + // if we consumed all the positionals we could and we're not + // at the index of an option string, there were extra arguments + if (!(start_index in option_string_indices)) { + let strings = arg_strings.slice(start_index, next_option_string_index) + extras = extras.concat(strings) + start_index = next_option_string_index + } + + // consume the next optional and any arguments for it + start_index = consume_optional(start_index) + } + + // consume any positionals following the last Optional + let stop_index = consume_positionals(start_index) + + // if we didn't consume all the argument strings, there were extras + extras = extras.concat(arg_strings.slice(stop_index)) + + // make sure all required actions were present and also convert + // action defaults which were not given as arguments + let required_actions = [] + for (let action of this._actions) { + if (!seen_actions.has(action)) { + if (action.required) { + required_actions.push(_get_action_name(action)) + } else { + // Convert action default now instead of doing it before + // parsing arguments to avoid calling convert functions + // twice (which may fail) if the argument was given, but + // only if it was defined already in the namespace + if (action.default !== undefined && + typeof action.default === 'string' && + hasattr(namespace, action.dest) && + action.default === getattr(namespace, action.dest)) { + setattr(namespace, action.dest, + this._get_value(action, action.default)) + } + } + } + } + + if (required_actions.length) { + this.error(sub('the following arguments are required: %s', + required_actions.join(', '))) + } + + // make sure all required groups had one option present + for (let group of this._mutually_exclusive_groups) { + if (group.required) { + let no_actions_used = true + for (let action of group._group_actions) { + if (seen_non_default_actions.has(action)) { + no_actions_used = false + break + } + } + + // if no actions were used, report the error + if (no_actions_used) { + let names = group._group_actions + .filter(action => action.help !== SUPPRESS) + .map(action => _get_action_name(action)) + let msg = 'one of the arguments %s is required' + this.error(sub(msg, names.join(' '))) + } + } + } + + // return the updated namespace and the extra arguments + return [ namespace, extras ] + } + + _read_args_from_files(arg_strings) { + // expand arguments referencing files + let new_arg_strings = [] + for (let arg_string of arg_strings) { + + // for regular arguments, just add them back into the list + if (!arg_string || !this.fromfile_prefix_chars.includes(arg_string[0])) { + new_arg_strings.push(arg_string) + + // replace arguments referencing files with the file content + } else { + try { + let args_file = fs.readFileSync(arg_string.slice(1), 'utf8') + let arg_strings = [] + for (let arg_line of splitlines(args_file)) { + for (let arg of this.convert_arg_line_to_args(arg_line)) { + arg_strings.push(arg) + } + } + arg_strings = this._read_args_from_files(arg_strings) + new_arg_strings = new_arg_strings.concat(arg_strings) + } catch (err) { + this.error(err.message) + } + } + } + + // return the modified argument list + return new_arg_strings + } + + convert_arg_line_to_args(arg_line) { + return [arg_line] + } + + _match_argument(action, arg_strings_pattern) { + // match the pattern for this action to the arg strings + let nargs_pattern = this._get_nargs_pattern(action) + let match = arg_strings_pattern.match(new RegExp('^' + nargs_pattern)) + + // raise an exception if we weren't able to find a match + if (match === null) { + let nargs_errors = { + undefined: 'expected one argument', + [OPTIONAL]: 'expected at most one argument', + [ONE_OR_MORE]: 'expected at least one argument' + } + let msg = nargs_errors[action.nargs] + if (msg === undefined) { + msg = sub(action.nargs === 1 ? 'expected %s argument' : 'expected %s arguments', action.nargs) + } + throw new ArgumentError(action, msg) + } + + // return the number of arguments matched + return match[1].length + } + + _match_arguments_partial(actions, arg_strings_pattern) { + // progressively shorten the actions list by slicing off the + // final actions until we find a match + let result = [] + for (let i of range(actions.length, 0, -1)) { + let actions_slice = actions.slice(0, i) + let pattern = actions_slice.map(action => this._get_nargs_pattern(action)).join('') + let match = arg_strings_pattern.match(new RegExp('^' + pattern)) + if (match !== null) { + result = result.concat(match.slice(1).map(string => string.length)) + break + } + } + + // return the list of arg string counts + return result + } + + _parse_optional(arg_string) { + // if it's an empty string, it was meant to be a positional + if (!arg_string) { + return undefined + } + + // if it doesn't start with a prefix, it was meant to be positional + if (!this.prefix_chars.includes(arg_string[0])) { + return undefined + } + + // if the option string is present in the parser, return the action + if (arg_string in this._option_string_actions) { + let action = this._option_string_actions[arg_string] + return [ action, arg_string, undefined ] + } + + // if it's just a single character, it was meant to be positional + if (arg_string.length === 1) { + return undefined + } + + // if the option string before the "=" is present, return the action + if (arg_string.includes('=')) { + let [ option_string, explicit_arg ] = _string_split(arg_string, '=', 1) + if (option_string in this._option_string_actions) { + let action = this._option_string_actions[option_string] + return [ action, option_string, explicit_arg ] + } + } + + // search through all possible prefixes of the option string + // and all actions in the parser for possible interpretations + let option_tuples = this._get_option_tuples(arg_string) + + // if multiple actions match, the option string was ambiguous + if (option_tuples.length > 1) { + let options = option_tuples.map(([ /*action*/, option_string/*, explicit_arg*/ ]) => option_string).join(', ') + let args = {option: arg_string, matches: options} + let msg = 'ambiguous option: %(option)s could match %(matches)s' + this.error(sub(msg, args)) + + // if exactly one action matched, this segmentation is good, + // so return the parsed action + } else if (option_tuples.length === 1) { + let [ option_tuple ] = option_tuples + return option_tuple + } + + // if it was not found as an option, but it looks like a negative + // number, it was meant to be positional + // unless there are negative-number-like options + if (this._negative_number_matcher.test(arg_string)) { + if (!this._has_negative_number_optionals.length) { + return undefined + } + } + + // if it contains a space, it was meant to be a positional + if (arg_string.includes(' ')) { + return undefined + } + + // it was meant to be an optional but there is no such option + // in this parser (though it might be a valid option in a subparser) + return [ undefined, arg_string, undefined ] + } + + _get_option_tuples(option_string) { + let result = [] + + // option strings starting with two prefix characters are only + // split at the '=' + let chars = this.prefix_chars + if (chars.includes(option_string[0]) && chars.includes(option_string[1])) { + if (this.allow_abbrev) { + let option_prefix, explicit_arg + if (option_string.includes('=')) { + [ option_prefix, explicit_arg ] = _string_split(option_string, '=', 1) + } else { + option_prefix = option_string + explicit_arg = undefined + } + for (let option_string of Object.keys(this._option_string_actions)) { + if (option_string.startsWith(option_prefix)) { + let action = this._option_string_actions[option_string] + let tup = [ action, option_string, explicit_arg ] + result.push(tup) + } + } + } + + // single character options can be concatenated with their arguments + // but multiple character options always have to have their argument + // separate + } else if (chars.includes(option_string[0]) && !chars.includes(option_string[1])) { + let option_prefix = option_string + let explicit_arg = undefined + let short_option_prefix = option_string.slice(0, 2) + let short_explicit_arg = option_string.slice(2) + + for (let option_string of Object.keys(this._option_string_actions)) { + if (option_string === short_option_prefix) { + let action = this._option_string_actions[option_string] + let tup = [ action, option_string, short_explicit_arg ] + result.push(tup) + } else if (option_string.startsWith(option_prefix)) { + let action = this._option_string_actions[option_string] + let tup = [ action, option_string, explicit_arg ] + result.push(tup) + } + } + + // shouldn't ever get here + } else { + this.error(sub('unexpected option string: %s', option_string)) + } + + // return the collected option tuples + return result + } + + _get_nargs_pattern(action) { + // in all examples below, we have to allow for '--' args + // which are represented as '-' in the pattern + let nargs = action.nargs + let nargs_pattern + + // the default (None) is assumed to be a single argument + if (nargs === undefined) { + nargs_pattern = '(-*A-*)' + + // allow zero or one arguments + } else if (nargs === OPTIONAL) { + nargs_pattern = '(-*A?-*)' + + // allow zero or more arguments + } else if (nargs === ZERO_OR_MORE) { + nargs_pattern = '(-*[A-]*)' + + // allow one or more arguments + } else if (nargs === ONE_OR_MORE) { + nargs_pattern = '(-*A[A-]*)' + + // allow any number of options or arguments + } else if (nargs === REMAINDER) { + nargs_pattern = '([-AO]*)' + + // allow one argument followed by any number of options or arguments + } else if (nargs === PARSER) { + nargs_pattern = '(-*A[-AO]*)' + + // suppress action, like nargs=0 + } else if (nargs === SUPPRESS) { + nargs_pattern = '(-*-*)' + + // all others should be integers + } else { + nargs_pattern = sub('(-*%s-*)', 'A'.repeat(nargs).split('').join('-*')) + } + + // if this is an optional action, -- is not allowed + if (action.option_strings.length) { + nargs_pattern = nargs_pattern.replace(/-\*/g, '') + nargs_pattern = nargs_pattern.replace(/-/g, '') + } + + // return the pattern + return nargs_pattern + } + + // ======================== + // Alt command line argument parsing, allowing free intermix + // ======================== + + parse_intermixed_args(args = undefined, namespace = undefined) { + let argv + [ args, argv ] = this.parse_known_intermixed_args(args, namespace) + if (argv.length) { + let msg = 'unrecognized arguments: %s' + this.error(sub(msg, argv.join(' '))) + } + return args + } + + parse_known_intermixed_args(args = undefined, namespace = undefined) { + // returns a namespace and list of extras + // + // positional can be freely intermixed with optionals. optionals are + // first parsed with all positional arguments deactivated. The 'extras' + // are then parsed. If the parser definition is incompatible with the + // intermixed assumptions (e.g. use of REMAINDER, subparsers) a + // TypeError is raised. + // + // positionals are 'deactivated' by setting nargs and default to + // SUPPRESS. This blocks the addition of that positional to the + // namespace + + let extras + let positionals = this._get_positional_actions() + let a = positionals.filter(action => [ PARSER, REMAINDER ].includes(action.nargs)) + if (a.length) { + throw new TypeError(sub('parse_intermixed_args: positional arg' + + ' with nargs=%s', a[0].nargs)) + } + + for (let group of this._mutually_exclusive_groups) { + for (let action of group._group_actions) { + if (positionals.includes(action)) { + throw new TypeError('parse_intermixed_args: positional in' + + ' mutuallyExclusiveGroup') + } + } + } + + let save_usage + try { + save_usage = this.usage + let remaining_args + try { + if (this.usage === undefined) { + // capture the full usage for use in error messages + this.usage = this.format_usage().slice(7) + } + for (let action of positionals) { + // deactivate positionals + action.save_nargs = action.nargs + // action.nargs = 0 + action.nargs = SUPPRESS + action.save_default = action.default + action.default = SUPPRESS + } + [ namespace, remaining_args ] = this.parse_known_args(args, + namespace) + for (let action of positionals) { + // remove the empty positional values from namespace + let attr = getattr(namespace, action.dest) + if (Array.isArray(attr) && attr.length === 0) { + // eslint-disable-next-line no-console + console.warn(sub('Do not expect %s in %s', action.dest, namespace)) + delattr(namespace, action.dest) + } + } + } finally { + // restore nargs and usage before exiting + for (let action of positionals) { + action.nargs = action.save_nargs + action.default = action.save_default + } + } + let optionals = this._get_optional_actions() + try { + // parse positionals. optionals aren't normally required, but + // they could be, so make sure they aren't. + for (let action of optionals) { + action.save_required = action.required + action.required = false + } + for (let group of this._mutually_exclusive_groups) { + group.save_required = group.required + group.required = false + } + [ namespace, extras ] = this.parse_known_args(remaining_args, + namespace) + } finally { + // restore parser values before exiting + for (let action of optionals) { + action.required = action.save_required + } + for (let group of this._mutually_exclusive_groups) { + group.required = group.save_required + } + } + } finally { + this.usage = save_usage + } + return [ namespace, extras ] + } + + // ======================== + // Value conversion methods + // ======================== + _get_values(action, arg_strings) { + // for everything but PARSER, REMAINDER args, strip out first '--' + if (![PARSER, REMAINDER].includes(action.nargs)) { + try { + _array_remove(arg_strings, '--') + } catch (err) {} + } + + let value + // optional argument produces a default when not present + if (!arg_strings.length && action.nargs === OPTIONAL) { + if (action.option_strings.length) { + value = action.const + } else { + value = action.default + } + if (typeof value === 'string') { + value = this._get_value(action, value) + this._check_value(action, value) + } + + // when nargs='*' on a positional, if there were no command-line + // args, use the default if it is anything other than None + } else if (!arg_strings.length && action.nargs === ZERO_OR_MORE && + !action.option_strings.length) { + if (action.default !== undefined) { + value = action.default + } else { + value = arg_strings + } + this._check_value(action, value) + + // single argument or optional argument produces a single value + } else if (arg_strings.length === 1 && [undefined, OPTIONAL].includes(action.nargs)) { + let arg_string = arg_strings[0] + value = this._get_value(action, arg_string) + this._check_value(action, value) + + // REMAINDER arguments convert all values, checking none + } else if (action.nargs === REMAINDER) { + value = arg_strings.map(v => this._get_value(action, v)) + + // PARSER arguments convert all values, but check only the first + } else if (action.nargs === PARSER) { + value = arg_strings.map(v => this._get_value(action, v)) + this._check_value(action, value[0]) + + // SUPPRESS argument does not put anything in the namespace + } else if (action.nargs === SUPPRESS) { + value = SUPPRESS + + // all other types of nargs produce a list + } else { + value = arg_strings.map(v => this._get_value(action, v)) + for (let v of value) { + this._check_value(action, v) + } + } + + // return the converted value + return value + } + + _get_value(action, arg_string) { + let type_func = this._registry_get('type', action.type, action.type) + if (typeof type_func !== 'function') { + let msg = '%r is not callable' + throw new ArgumentError(action, sub(msg, type_func)) + } + + // convert the value to the appropriate type + let result + try { + try { + result = type_func(arg_string) + } catch (err) { + // Dear TC39, why would you ever consider making es6 classes not callable? + // We had one universal interface, [[Call]], which worked for anything + // (with familiar this-instanceof guard for classes). Now we have two. + if (err instanceof TypeError && + /Class constructor .* cannot be invoked without 'new'/.test(err.message)) { + // eslint-disable-next-line new-cap + result = new type_func(arg_string) + } else { + throw err + } + } + + } catch (err) { + // ArgumentTypeErrors indicate errors + if (err instanceof ArgumentTypeError) { + //let name = getattr(action.type, 'name', repr(action.type)) + let msg = err.message + throw new ArgumentError(action, msg) + + // TypeErrors or ValueErrors also indicate errors + } else if (err instanceof TypeError) { + let name = getattr(action.type, 'name', repr(action.type)) + let args = {type: name, value: arg_string} + let msg = 'invalid %(type)s value: %(value)r' + throw new ArgumentError(action, sub(msg, args)) + } else { + throw err + } + } + + // return the converted value + return result + } + + _check_value(action, value) { + // converted value must be one of the choices (if specified) + if (action.choices !== undefined && !_choices_to_array(action.choices).includes(value)) { + let args = {value, + choices: _choices_to_array(action.choices).map(repr).join(', ')} + let msg = 'invalid choice: %(value)r (choose from %(choices)s)' + throw new ArgumentError(action, sub(msg, args)) + } + } + + // ======================= + // Help-formatting methods + // ======================= + format_usage() { + let formatter = this._get_formatter() + formatter.add_usage(this.usage, this._actions, + this._mutually_exclusive_groups) + return formatter.format_help() + } + + format_help() { + let formatter = this._get_formatter() + + // usage + formatter.add_usage(this.usage, this._actions, + this._mutually_exclusive_groups) + + // description + formatter.add_text(this.description) + + // positionals, optionals and user-defined groups + for (let action_group of this._action_groups) { + formatter.start_section(action_group.title) + formatter.add_text(action_group.description) + formatter.add_arguments(action_group._group_actions) + formatter.end_section() + } + + // epilog + formatter.add_text(this.epilog) + + // determine help from format above + return formatter.format_help() + } + + _get_formatter() { + // eslint-disable-next-line new-cap + return new this.formatter_class({ prog: this.prog }) + } + + // ===================== + // Help-printing methods + // ===================== + print_usage(file = undefined) { + if (file === undefined) file = process.stdout + this._print_message(this.format_usage(), file) + } + + print_help(file = undefined) { + if (file === undefined) file = process.stdout + this._print_message(this.format_help(), file) + } + + _print_message(message, file = undefined) { + if (message) { + if (file === undefined) file = process.stderr + file.write(message) + } + } + + // =============== + // Exiting methods + // =============== + exit(status = 0, message = undefined) { + if (message) { + this._print_message(message, process.stderr) + } + process.exit(status) + } + + error(message) { + /* + * error(message: string) + * + * Prints a usage message incorporating the message to stderr and + * exits. + * + * If you override this in a subclass, it should not return -- it + * should either exit or raise an exception. + */ + + // LEGACY (v1 compatibility), debug mode + if (this.debug === true) throw new Error(message) + // end + this.print_usage(process.stderr) + let args = {prog: this.prog, message: message} + this.exit(2, sub('%(prog)s: error: %(message)s\n', args)) + } +})) + + +module.exports = { + ArgumentParser, + ArgumentError, + ArgumentTypeError, + BooleanOptionalAction, + FileType, + HelpFormatter, + ArgumentDefaultsHelpFormatter, + RawDescriptionHelpFormatter, + RawTextHelpFormatter, + MetavarTypeHelpFormatter, + Namespace, + Action, + ONE_OR_MORE, + OPTIONAL, + PARSER, + REMAINDER, + SUPPRESS, + ZERO_OR_MORE +} + +// LEGACY (v1 compatibility), Const alias +Object.defineProperty(module.exports, 'Const', { + get() { + let result = {} + Object.entries({ ONE_OR_MORE, OPTIONAL, PARSER, REMAINDER, SUPPRESS, ZERO_OR_MORE }).forEach(([ n, v ]) => { + Object.defineProperty(result, n, { + get() { + deprecate(n, sub('use argparse.%s instead of argparse.Const.%s', n, n)) + return v + } + }) + }) + Object.entries({ _UNRECOGNIZED_ARGS_ATTR }).forEach(([ n, v ]) => { + Object.defineProperty(result, n, { + get() { + deprecate(n, sub('argparse.Const.%s is an internal symbol and will no longer be available', n)) + return v + } + }) + }) + return result + }, + enumerable: false +}) +// end diff --git a/action/node_modules/argparse/lib/sub.js b/action/node_modules/argparse/lib/sub.js new file mode 100644 index 000000000..e3eb3215f --- /dev/null +++ b/action/node_modules/argparse/lib/sub.js @@ -0,0 +1,67 @@ +// Limited implementation of python % string operator, supports only %s and %r for now +// (other formats are not used here, but may appear in custom templates) + +'use strict' + +const { inspect } = require('util') + + +module.exports = function sub(pattern, ...values) { + let regex = /%(?:(%)|(-)?(\*)?(?:\((\w+)\))?([A-Za-z]))/g + + let result = pattern.replace(regex, function (_, is_literal, is_left_align, is_padded, name, format) { + if (is_literal) return '%' + + let padded_count = 0 + if (is_padded) { + if (values.length === 0) throw new TypeError('not enough arguments for format string') + padded_count = values.shift() + if (!Number.isInteger(padded_count)) throw new TypeError('* wants int') + } + + let str + if (name !== undefined) { + let dict = values[0] + if (typeof dict !== 'object' || dict === null) throw new TypeError('format requires a mapping') + if (!(name in dict)) throw new TypeError(`no such key: '${name}'`) + str = dict[name] + } else { + if (values.length === 0) throw new TypeError('not enough arguments for format string') + str = values.shift() + } + + switch (format) { + case 's': + str = String(str) + break + case 'r': + str = inspect(str) + break + case 'd': + case 'i': + if (typeof str !== 'number') { + throw new TypeError(`%${format} format: a number is required, not ${typeof str}`) + } + str = String(str.toFixed(0)) + break + default: + throw new TypeError(`unsupported format character '${format}'`) + } + + if (padded_count > 0) { + return is_left_align ? str.padEnd(padded_count) : str.padStart(padded_count) + } else { + return str + } + }) + + if (values.length) { + if (values.length === 1 && typeof values[0] === 'object' && values[0] !== null) { + // mapping + } else { + throw new TypeError('not all arguments converted during string formatting') + } + } + + return result +} diff --git a/action/node_modules/argparse/lib/textwrap.js b/action/node_modules/argparse/lib/textwrap.js new file mode 100644 index 000000000..23d51cdb9 --- /dev/null +++ b/action/node_modules/argparse/lib/textwrap.js @@ -0,0 +1,440 @@ +// Partial port of python's argparse module, version 3.9.0 (only wrap and fill functions): +// https://github.com/python/cpython/blob/v3.9.0b4/Lib/textwrap.py + +'use strict' + +/* + * Text wrapping and filling. + */ + +// Copyright (C) 1999-2001 Gregory P. Ward. +// Copyright (C) 2002, 2003 Python Software Foundation. +// Copyright (C) 2020 argparse.js authors +// Originally written by Greg Ward + +// Hardcode the recognized whitespace characters to the US-ASCII +// whitespace characters. The main reason for doing this is that +// some Unicode spaces (like \u00a0) are non-breaking whitespaces. +// +// This less funky little regex just split on recognized spaces. E.g. +// "Hello there -- you goof-ball, use the -b option!" +// splits into +// Hello/ /there/ /--/ /you/ /goof-ball,/ /use/ /the/ /-b/ /option!/ +const wordsep_simple_re = /([\t\n\x0b\x0c\r ]+)/ + +class TextWrapper { + /* + * Object for wrapping/filling text. The public interface consists of + * the wrap() and fill() methods; the other methods are just there for + * subclasses to override in order to tweak the default behaviour. + * If you want to completely replace the main wrapping algorithm, + * you'll probably have to override _wrap_chunks(). + * + * Several instance attributes control various aspects of wrapping: + * width (default: 70) + * the maximum width of wrapped lines (unless break_long_words + * is false) + * initial_indent (default: "") + * string that will be prepended to the first line of wrapped + * output. Counts towards the line's width. + * subsequent_indent (default: "") + * string that will be prepended to all lines save the first + * of wrapped output; also counts towards each line's width. + * expand_tabs (default: true) + * Expand tabs in input text to spaces before further processing. + * Each tab will become 0 .. 'tabsize' spaces, depending on its position + * in its line. If false, each tab is treated as a single character. + * tabsize (default: 8) + * Expand tabs in input text to 0 .. 'tabsize' spaces, unless + * 'expand_tabs' is false. + * replace_whitespace (default: true) + * Replace all whitespace characters in the input text by spaces + * after tab expansion. Note that if expand_tabs is false and + * replace_whitespace is true, every tab will be converted to a + * single space! + * fix_sentence_endings (default: false) + * Ensure that sentence-ending punctuation is always followed + * by two spaces. Off by default because the algorithm is + * (unavoidably) imperfect. + * break_long_words (default: true) + * Break words longer than 'width'. If false, those words will not + * be broken, and some lines might be longer than 'width'. + * break_on_hyphens (default: true) + * Allow breaking hyphenated words. If true, wrapping will occur + * preferably on whitespaces and right after hyphens part of + * compound words. + * drop_whitespace (default: true) + * Drop leading and trailing whitespace from lines. + * max_lines (default: None) + * Truncate wrapped lines. + * placeholder (default: ' [...]') + * Append to the last line of truncated text. + */ + + constructor(options = {}) { + let { + width = 70, + initial_indent = '', + subsequent_indent = '', + expand_tabs = true, + replace_whitespace = true, + fix_sentence_endings = false, + break_long_words = true, + drop_whitespace = true, + break_on_hyphens = true, + tabsize = 8, + max_lines = undefined, + placeholder=' [...]' + } = options + + this.width = width + this.initial_indent = initial_indent + this.subsequent_indent = subsequent_indent + this.expand_tabs = expand_tabs + this.replace_whitespace = replace_whitespace + this.fix_sentence_endings = fix_sentence_endings + this.break_long_words = break_long_words + this.drop_whitespace = drop_whitespace + this.break_on_hyphens = break_on_hyphens + this.tabsize = tabsize + this.max_lines = max_lines + this.placeholder = placeholder + } + + + // -- Private methods ----------------------------------------------- + // (possibly useful for subclasses to override) + + _munge_whitespace(text) { + /* + * _munge_whitespace(text : string) -> string + * + * Munge whitespace in text: expand tabs and convert all other + * whitespace characters to spaces. Eg. " foo\\tbar\\n\\nbaz" + * becomes " foo bar baz". + */ + if (this.expand_tabs) { + text = text.replace(/\t/g, ' '.repeat(this.tabsize)) // not strictly correct in js + } + if (this.replace_whitespace) { + text = text.replace(/[\t\n\x0b\x0c\r]/g, ' ') + } + return text + } + + _split(text) { + /* + * _split(text : string) -> [string] + * + * Split the text to wrap into indivisible chunks. Chunks are + * not quite the same as words; see _wrap_chunks() for full + * details. As an example, the text + * Look, goof-ball -- use the -b option! + * breaks into the following chunks: + * 'Look,', ' ', 'goof-', 'ball', ' ', '--', ' ', + * 'use', ' ', 'the', ' ', '-b', ' ', 'option!' + * if break_on_hyphens is True, or in: + * 'Look,', ' ', 'goof-ball', ' ', '--', ' ', + * 'use', ' ', 'the', ' ', '-b', ' ', option!' + * otherwise. + */ + let chunks = text.split(wordsep_simple_re) + chunks = chunks.filter(Boolean) + return chunks + } + + _handle_long_word(reversed_chunks, cur_line, cur_len, width) { + /* + * _handle_long_word(chunks : [string], + * cur_line : [string], + * cur_len : int, width : int) + * + * Handle a chunk of text (most likely a word, not whitespace) that + * is too long to fit in any line. + */ + // Figure out when indent is larger than the specified width, and make + // sure at least one character is stripped off on every pass + let space_left + if (width < 1) { + space_left = 1 + } else { + space_left = width - cur_len + } + + // If we're allowed to break long words, then do so: put as much + // of the next chunk onto the current line as will fit. + if (this.break_long_words) { + cur_line.push(reversed_chunks[reversed_chunks.length - 1].slice(0, space_left)) + reversed_chunks[reversed_chunks.length - 1] = reversed_chunks[reversed_chunks.length - 1].slice(space_left) + + // Otherwise, we have to preserve the long word intact. Only add + // it to the current line if there's nothing already there -- + // that minimizes how much we violate the width constraint. + } else if (!cur_line) { + cur_line.push(...reversed_chunks.pop()) + } + + // If we're not allowed to break long words, and there's already + // text on the current line, do nothing. Next time through the + // main loop of _wrap_chunks(), we'll wind up here again, but + // cur_len will be zero, so the next line will be entirely + // devoted to the long word that we can't handle right now. + } + + _wrap_chunks(chunks) { + /* + * _wrap_chunks(chunks : [string]) -> [string] + * + * Wrap a sequence of text chunks and return a list of lines of + * length 'self.width' or less. (If 'break_long_words' is false, + * some lines may be longer than this.) Chunks correspond roughly + * to words and the whitespace between them: each chunk is + * indivisible (modulo 'break_long_words'), but a line break can + * come between any two chunks. Chunks should not have internal + * whitespace; ie. a chunk is either all whitespace or a "word". + * Whitespace chunks will be removed from the beginning and end of + * lines, but apart from that whitespace is preserved. + */ + let lines = [] + let indent + if (this.width <= 0) { + throw Error(`invalid width ${this.width} (must be > 0)`) + } + if (this.max_lines !== undefined) { + if (this.max_lines > 1) { + indent = this.subsequent_indent + } else { + indent = this.initial_indent + } + if (indent.length + this.placeholder.trimStart().length > this.width) { + throw Error('placeholder too large for max width') + } + } + + // Arrange in reverse order so items can be efficiently popped + // from a stack of chucks. + chunks = chunks.reverse() + + while (chunks.length > 0) { + + // Start the list of chunks that will make up the current line. + // cur_len is just the length of all the chunks in cur_line. + let cur_line = [] + let cur_len = 0 + + // Figure out which static string will prefix this line. + let indent + if (lines) { + indent = this.subsequent_indent + } else { + indent = this.initial_indent + } + + // Maximum width for this line. + let width = this.width - indent.length + + // First chunk on line is whitespace -- drop it, unless this + // is the very beginning of the text (ie. no lines started yet). + if (this.drop_whitespace && chunks[chunks.length - 1].trim() === '' && lines.length > 0) { + chunks.pop() + } + + while (chunks.length > 0) { + let l = chunks[chunks.length - 1].length + + // Can at least squeeze this chunk onto the current line. + if (cur_len + l <= width) { + cur_line.push(chunks.pop()) + cur_len += l + + // Nope, this line is full. + } else { + break + } + } + + // The current line is full, and the next chunk is too big to + // fit on *any* line (not just this one). + if (chunks.length && chunks[chunks.length - 1].length > width) { + this._handle_long_word(chunks, cur_line, cur_len, width) + cur_len = cur_line.map(l => l.length).reduce((a, b) => a + b, 0) + } + + // If the last chunk on this line is all whitespace, drop it. + if (this.drop_whitespace && cur_line.length > 0 && cur_line[cur_line.length - 1].trim() === '') { + cur_len -= cur_line[cur_line.length - 1].length + cur_line.pop() + } + + if (cur_line) { + if (this.max_lines === undefined || + lines.length + 1 < this.max_lines || + (chunks.length === 0 || + this.drop_whitespace && + chunks.length === 1 && + !chunks[0].trim()) && cur_len <= width) { + // Convert current line back to a string and store it in + // list of all lines (return value). + lines.push(indent + cur_line.join('')) + } else { + let had_break = false + while (cur_line) { + if (cur_line[cur_line.length - 1].trim() && + cur_len + this.placeholder.length <= width) { + cur_line.push(this.placeholder) + lines.push(indent + cur_line.join('')) + had_break = true + break + } + cur_len -= cur_line[-1].length + cur_line.pop() + } + if (!had_break) { + if (lines) { + let prev_line = lines[lines.length - 1].trimEnd() + if (prev_line.length + this.placeholder.length <= + this.width) { + lines[lines.length - 1] = prev_line + this.placeholder + break + } + } + lines.push(indent + this.placeholder.lstrip()) + } + break + } + } + } + + return lines + } + + _split_chunks(text) { + text = this._munge_whitespace(text) + return this._split(text) + } + + // -- Public interface ---------------------------------------------- + + wrap(text) { + /* + * wrap(text : string) -> [string] + * + * Reformat the single paragraph in 'text' so it fits in lines of + * no more than 'self.width' columns, and return a list of wrapped + * lines. Tabs in 'text' are expanded with string.expandtabs(), + * and all other whitespace characters (including newline) are + * converted to space. + */ + let chunks = this._split_chunks(text) + // not implemented in js + //if (this.fix_sentence_endings) { + // this._fix_sentence_endings(chunks) + //} + return this._wrap_chunks(chunks) + } + + fill(text) { + /* + * fill(text : string) -> string + * + * Reformat the single paragraph in 'text' to fit in lines of no + * more than 'self.width' columns, and return a new string + * containing the entire wrapped paragraph. + */ + return this.wrap(text).join('\n') + } +} + + +// -- Convenience interface --------------------------------------------- + +function wrap(text, options = {}) { + /* + * Wrap a single paragraph of text, returning a list of wrapped lines. + * + * Reformat the single paragraph in 'text' so it fits in lines of no + * more than 'width' columns, and return a list of wrapped lines. By + * default, tabs in 'text' are expanded with string.expandtabs(), and + * all other whitespace characters (including newline) are converted to + * space. See TextWrapper class for available keyword args to customize + * wrapping behaviour. + */ + let { width = 70, ...kwargs } = options + let w = new TextWrapper(Object.assign({ width }, kwargs)) + return w.wrap(text) +} + +function fill(text, options = {}) { + /* + * Fill a single paragraph of text, returning a new string. + * + * Reformat the single paragraph in 'text' to fit in lines of no more + * than 'width' columns, and return a new string containing the entire + * wrapped paragraph. As with wrap(), tabs are expanded and other + * whitespace characters converted to space. See TextWrapper class for + * available keyword args to customize wrapping behaviour. + */ + let { width = 70, ...kwargs } = options + let w = new TextWrapper(Object.assign({ width }, kwargs)) + return w.fill(text) +} + +// -- Loosely related functionality ------------------------------------- + +let _whitespace_only_re = /^[ \t]+$/mg +let _leading_whitespace_re = /(^[ \t]*)(?:[^ \t\n])/mg + +function dedent(text) { + /* + * Remove any common leading whitespace from every line in `text`. + * + * This can be used to make triple-quoted strings line up with the left + * edge of the display, while still presenting them in the source code + * in indented form. + * + * Note that tabs and spaces are both treated as whitespace, but they + * are not equal: the lines " hello" and "\\thello" are + * considered to have no common leading whitespace. + * + * Entirely blank lines are normalized to a newline character. + */ + // Look for the longest leading string of spaces and tabs common to + // all lines. + let margin = undefined + text = text.replace(_whitespace_only_re, '') + let indents = text.match(_leading_whitespace_re) || [] + for (let indent of indents) { + indent = indent.slice(0, -1) + + if (margin === undefined) { + margin = indent + + // Current line more deeply indented than previous winner: + // no change (previous winner is still on top). + } else if (indent.startsWith(margin)) { + // pass + + // Current line consistent with and no deeper than previous winner: + // it's the new winner. + } else if (margin.startsWith(indent)) { + margin = indent + + // Find the largest common whitespace between current line and previous + // winner. + } else { + for (let i = 0; i < margin.length && i < indent.length; i++) { + if (margin[i] !== indent[i]) { + margin = margin.slice(0, i) + break + } + } + } + } + + if (margin) { + text = text.replace(new RegExp('^' + margin, 'mg'), '') + } + return text +} + +module.exports = { wrap, fill, dedent } diff --git a/action/node_modules/argparse/package.json b/action/node_modules/argparse/package.json new file mode 100644 index 000000000..647d2aff1 --- /dev/null +++ b/action/node_modules/argparse/package.json @@ -0,0 +1,31 @@ +{ + "name": "argparse", + "description": "CLI arguments parser. Native port of python's argparse.", + "version": "2.0.1", + "keywords": [ + "cli", + "parser", + "argparse", + "option", + "args" + ], + "main": "argparse.js", + "files": [ + "argparse.js", + "lib/" + ], + "license": "Python-2.0", + "repository": "nodeca/argparse", + "scripts": { + "lint": "eslint .", + "test": "npm run lint && nyc mocha", + "coverage": "npm run test && nyc report --reporter html" + }, + "devDependencies": { + "@babel/eslint-parser": "^7.11.0", + "@babel/plugin-syntax-class-properties": "^7.10.4", + "eslint": "^7.5.0", + "mocha": "^8.0.1", + "nyc": "^15.1.0" + } +} diff --git a/action/node_modules/cosmiconfig/README.md b/action/node_modules/cosmiconfig/README.md index 8195c91a2..1adb850b1 100644 --- a/action/node_modules/cosmiconfig/README.md +++ b/action/node_modules/cosmiconfig/README.md @@ -1,8 +1,9 @@ # cosmiconfig -[![Build Status](https://img.shields.io/travis/davidtheclark/cosmiconfig/main.svg?label=unix%20build)](https://travis-ci.org/davidtheclark/cosmiconfig) [![Build status](https://img.shields.io/appveyor/ci/davidtheclark/cosmiconfig/main.svg?label=windows%20build)](https://ci.appveyor.com/project/davidtheclark/cosmiconfig/branch/main) [![codecov](https://codecov.io/gh/davidtheclark/cosmiconfig/branch/main/graph/badge.svg)](https://codecov.io/gh/davidtheclark/cosmiconfig) +> **MAINTAINERS WANTED!** If you're interested in taking over and maintaining Cosmiconfig, please let @davidtheclark know (with an issue or email). I'd like to hand over the keys completely, so I'm looking for **owners**, not people who just want to merge a PR or two! You can make the decisions about what happens in v8 and subsequent versions, how the package balances stability and opinionated features, and so on. Take a look at open issues and PRs to learn about possibilities that have been on people's minds over the years. + Cosmiconfig searches for and loads configuration for your program. It features smart defaults based on conventional expectations in the JavaScript ecosystem. @@ -21,7 +22,7 @@ For example, if your module's name is "myapp", cosmiconfig will search up the di - a `myapp` property in `package.json` - a `.myapprc` file in JSON or YAML format - a `.myapprc.json`, `.myapprc.yaml`, `.myapprc.yml`, `.myapprc.js`, or `.myapprc.cjs` file -- a `myapprc`, `myapprc.json`, `myapprc.yaml`, `myapprc.yml`, `myapprc.js` or `myapprc.cjs` file inside a `.config` subdirectory` +- a `myapprc`, `myapprc.json`, `myapprc.yaml`, `myapprc.yml`, `myapprc.js` or `myapprc.cjs` file inside a `.config` subdirectory - a `myapp.config.js` or `myapp.config.cjs` CommonJS module exporting an object Cosmiconfig continues to search up the directory tree, checking each of these places in each directory, until it finds some acceptable configuration (or hits the home directory). @@ -63,7 +64,7 @@ Cosmiconfig continues to search up the directory tree, checking each of these pl npm install cosmiconfig ``` -Tested in Node 10+. +Tested in Node 14+. ## Usage @@ -211,7 +212,7 @@ const explorerSync = cosmiconfigSync(moduleName[, cosmiconfigOptions]) Creates a *synchronous* cosmiconfig instance ("explorerSync") configured according to the arguments, and initializes its caches. -See [`cosmiconfig()`]. +See [`cosmiconfig()`](#cosmiconfig-1). ### explorerSync.search() diff --git a/action/node_modules/cosmiconfig/dist/Explorer.js b/action/node_modules/cosmiconfig/dist/Explorer.js index b2f1425aa..621ea546b 100644 --- a/action/node_modules/cosmiconfig/dist/Explorer.js +++ b/action/node_modules/cosmiconfig/dist/Explorer.js @@ -7,14 +7,14 @@ exports.Explorer = void 0; var _path = _interopRequireDefault(require("path")); -var _ExplorerBase = require("./ExplorerBase"); - -var _readFile = require("./readFile"); - var _cacheWrapper = require("./cacheWrapper"); +var _ExplorerBase = require("./ExplorerBase"); + var _getDirectory = require("./getDirectory"); +var _readFile = require("./readFile"); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class Explorer extends _ExplorerBase.ExplorerBase { @@ -81,8 +81,13 @@ class Explorer extends _ExplorerBase.ExplorerBase { } const loader = this.getLoaderEntryForFile(filepath); - const loaderResult = await loader(filepath, content); - return loaderResult; + + try { + return await loader(filepath, content); + } catch (e) { + e.filepath = filepath; + throw e; + } } async createCosmiconfigResult(filepath, content) { diff --git a/action/node_modules/cosmiconfig/dist/ExplorerSync.js b/action/node_modules/cosmiconfig/dist/ExplorerSync.js index dd57ac41a..699c2762e 100644 --- a/action/node_modules/cosmiconfig/dist/ExplorerSync.js +++ b/action/node_modules/cosmiconfig/dist/ExplorerSync.js @@ -7,14 +7,14 @@ exports.ExplorerSync = void 0; var _path = _interopRequireDefault(require("path")); -var _ExplorerBase = require("./ExplorerBase"); - -var _readFile = require("./readFile"); - var _cacheWrapper = require("./cacheWrapper"); +var _ExplorerBase = require("./ExplorerBase"); + var _getDirectory = require("./getDirectory"); +var _readFile = require("./readFile"); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } class ExplorerSync extends _ExplorerBase.ExplorerBase { @@ -81,8 +81,13 @@ class ExplorerSync extends _ExplorerBase.ExplorerBase { } const loader = this.getLoaderEntryForFile(filepath); - const loaderResult = loader(filepath, content); - return loaderResult; + + try { + return loader(filepath, content); + } catch (e) { + e.filepath = filepath; + throw e; + } } createCosmiconfigResultSync(filepath, content) { diff --git a/action/node_modules/cosmiconfig/dist/loaders.js b/action/node_modules/cosmiconfig/dist/loaders.js index 43126afcd..57a2b102e 100644 --- a/action/node_modules/cosmiconfig/dist/loaders.js +++ b/action/node_modules/cosmiconfig/dist/loaders.js @@ -37,13 +37,11 @@ let yaml; const loadYaml = function loadYaml(filepath, content) { if (yaml === undefined) { - yaml = require('yaml'); + yaml = require('js-yaml'); } try { - const result = yaml.parse(content, { - prettyErrors: true - }); + const result = yaml.load(content); return result; } catch (error) { error.message = `YAML Error in ${filepath}:\n${error.message}`; diff --git a/action/node_modules/cosmiconfig/node_modules/.bin/js-yaml b/action/node_modules/cosmiconfig/node_modules/.bin/js-yaml new file mode 120000 index 000000000..daf9f1158 --- /dev/null +++ b/action/node_modules/cosmiconfig/node_modules/.bin/js-yaml @@ -0,0 +1 @@ +../../../js-yaml/bin/js-yaml.js \ No newline at end of file diff --git a/action/node_modules/cosmiconfig/package.json b/action/node_modules/cosmiconfig/package.json index 17241bb38..3ee42024a 100644 --- a/action/node_modules/cosmiconfig/package.json +++ b/action/node_modules/cosmiconfig/package.json @@ -1,6 +1,6 @@ { "name": "cosmiconfig", - "version": "7.1.0", + "version": "8.0.0", "description": "Find and load configuration from a package.json property, rc file, or CommonJS module", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -98,7 +98,7 @@ "@babel/preset-env", { "targets": { - "node": "10" + "node": "14" } } ], @@ -106,11 +106,10 @@ ] }, "dependencies": { - "@types/parse-json": "^4.0.0", "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", "parse-json": "^5.0.0", - "path-type": "^4.0.0", - "yaml": "^1.10.0" + "path-type": "^4.0.0" }, "devDependencies": { "@babel/cli": "^7.10.4", @@ -118,7 +117,9 @@ "@babel/preset-env": "^7.10.4", "@babel/preset-typescript": "^7.10.4", "@types/jest": "^26.0.4", + "@types/js-yaml": "^4.0.5", "@types/node": "^14.0.22", + "@types/parse-json": "^4.0.0", "@typescript-eslint/eslint-plugin": "^3.6.0", "@typescript-eslint/parser": "^3.6.0", "cross-env": "^7.0.2", @@ -140,6 +141,6 @@ "typescript": "^3.9.6" }, "engines": { - "node": ">=10" + "node": ">=14" } } diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js new file mode 100644 index 000000000..46150c44e --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/FlagWordsDictionary.js @@ -0,0 +1,158 @@ +"use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.createFlagWordsDictionary = void 0; +const sync_1 = require("@cspell/cspell-pipe/sync"); +const cspell_trie_lib_1 = require("cspell-trie-lib"); +const createSpellingDictionary_1 = require("./createSpellingDictionary"); +const Defaults = __importStar(require("./defaults")); +const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); +const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); +const TyposDictionary_1 = require("./TyposDictionary"); +class FlagWordsDictionaryTrie extends SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie { + constructor(trie, name, source) { + super(trie, name, createSpellingDictionary_1.defaultOptions, source); + this.name = name; + this.source = source; + this.containsNoSuggestWords = false; + this.options = {}; + this.isDictionaryCaseSensitive = true; + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param _word - the word + * @param _options - options + * @returns always false + */ + has(_word, _options) { + return false; + } + find(word, hasOptions) { + const f = super.find(word, hasOptions); + if (!f || !f.forbidden) + return undefined; + return f; + } + suggest() { + return []; + } + genSuggestions() { + return; + } +} +class FlagWordsDictionary { + constructor(name, source, dictTypos, dictTrie) { + this.name = name; + this.source = source; + this.dictTypos = dictTypos; + this.dictTrie = dictTrie; + this.containsNoSuggestWords = false; + this.options = {}; + this.type = 'flag-words'; + this.isDictionaryCaseSensitive = true; + } + /** + * A Forbidden word list does not "have" valid words. + * Therefore it always returns false. + * @param word - the word + * @param options - options + * @returns always false + */ + has(word, options) { + return this.dictTypos.has(word, options) || this.dictTrie?.has(word, options) || false; + } + /** A more detailed search for a word, might take longer than `has` */ + find(word, options) { + const findTypos = this.dictTypos.find(word, options); + if (findTypos) + return findTypos; + const ignoreCase = options?.ignoreCase ?? Defaults.ignoreCase; + if (this.dictTypos.isSuggestedWord(word, ignoreCase)) + return undefined; + return this.dictTrie?.find(word, options); + } + isForbidden(word, ignoreCaseAndAccents = Defaults.isForbiddenIgnoreCaseAndAccents) { + const findResult = this.find(word, { ignoreCase: ignoreCaseAndAccents }); + return findResult?.forbidden || false; + } + isNoSuggestWord(word, options) { + return this.dictTrie?.isNoSuggestWord(word, options) || this.dictTypos.isNoSuggestWord(word, options); + } + suggest(...args) { + const [word] = args; + const suggestOptions = (0, SpellingDictionaryMethods_1.suggestArgsToSuggestOptions)(args); + return this.dictTypos.suggest(word, suggestOptions); + } + genSuggestions() { + return; + } + mapWord(word) { + return word; + } + get size() { + return this.dictTypos.size + (this.dictTrie?.size || 0); + } + getErrors() { + return []; + } +} +/** + * Create a dictionary where all words are to be forbidden. + * @param wordList - list of words + * @param name + * @param source + * @param options + * @returns SpellingDictionary + */ +function createFlagWordsDictionary(wordList, name, source) { + const testSpecialCharacters = /[~*+]/; + const { t: specialWords, f: typoWords } = bisect((0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false }), (line) => testSpecialCharacters.test(line)); + const trieDict = specialWords.size ? buildTrieDict(specialWords, name, source) : undefined; + const typosDict = (0, TyposDictionary_1.createTyposDictionary)(typoWords, name, source); + if (!trieDict) + return typosDict; + return new FlagWordsDictionary(name, source, typosDict, trieDict); +} +exports.createFlagWordsDictionary = createFlagWordsDictionary; +const regExpCleanIgnore = /^(!!)+/; +function buildTrieDict(words, name, source) { + const trie = (0, cspell_trie_lib_1.buildTrieFast)((0, sync_1.pipe)(words, (0, sync_1.opMap)((w) => '!' + w), (0, sync_1.opMap)((w) => w.replace(regExpCleanIgnore, '')))); + return new FlagWordsDictionaryTrie(trie, name, source); +} +function bisect(values, predicate) { + const t = new Set(); + const f = new Set(); + for (const v of values) { + if (predicate(v)) { + t.add(v); + } + else { + f.add(v); + } + } + return { t, f }; +} +//# sourceMappingURL=FlagWordsDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/ForbiddenWordsDictionary.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/ForbiddenWordsDictionary.js deleted file mode 100644 index ed5a0a029..000000000 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/ForbiddenWordsDictionary.js +++ /dev/null @@ -1,107 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.createForbiddenWordsDictionary = void 0; -const cspell_trie_lib_1 = require("cspell-trie-lib"); -const createSpellingDictionary_1 = require("./createSpellingDictionary"); -const SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); -class ForbiddenWordsDictionaryTrie extends SpellingDictionaryFromTrie_1.SpellingDictionaryFromTrie { - constructor(trie, name, source) { - super(trie, name, createSpellingDictionary_1.defaultOptions, source); - this.name = name; - this.source = source; - this.containsNoSuggestWords = false; - this.options = {}; - this.isDictionaryCaseSensitive = true; - } - /** - * A Forbidden word list does not "have" valid words. - * Therefore it always returns false. - * @param _word - the word - * @param _options - options - * @returns always false - */ - has(_word, _options) { - return false; - } - find(word, hasOptions) { - const f = super.find(word, hasOptions); - if (!f || !f.forbidden) - return undefined; - return f; - } - suggest() { - return []; - } - genSuggestions() { - return; - } -} -class ForbiddenWordsDictionary { - constructor(name, source, words) { - this.name = name; - this.source = source; - this.containsNoSuggestWords = false; - this.options = {}; - this.type = 'forbidden'; - this.isDictionaryCaseSensitive = true; - this.dict = new Set(words); - this.dictIgnore = new Set(words.filter((w) => w.startsWith('!')).map((w) => w.slice(1))); - } - /** - * A Forbidden word list does not "have" valid words. - * Therefore it always returns false. - * @param _word - the word - * @param _options - options - * @returns always false - */ - has(_word, _options) { - return false; - } - /** A more detailed search for a word, might take longer than `has` */ - find(word, _options) { - const forbidden = this.isForbidden(word); - return forbidden ? { found: word, forbidden, noSuggest: false } : undefined; - } - isForbidden(word) { - return (this.dict.has(word) || this.dict.has(word.toLowerCase())) && !this.dictIgnore.has(word); - } - isNoSuggestWord(_word, _options) { - return false; - } - suggest() { - return []; - } - genSuggestions() { - return; - } - mapWord(word) { - return word; - } - get size() { - return this.dict.size; - } - getErrors() { - return []; - } -} -/** - * Create a dictionary where all words are to be forbidden. - * @param wordList - list of words - * @param name - * @param source - * @param options - * @returns - */ -function createForbiddenWordsDictionary(wordList, name, source) { - const testSpecialCharacters = /[~*+]/; - const regExpCleanIgnore = /^(!!)+/; - const words = [...(0, cspell_trie_lib_1.parseDictionaryLines)(wordList, { stripCaseAndAccents: false })]; - const hasSpecial = words.findIndex((word) => testSpecialCharacters.test(word)) >= 0; - if (hasSpecial) { - const trie = (0, cspell_trie_lib_1.buildTrieFast)(words.map((w) => '!' + w).map((w) => w.replace(regExpCleanIgnore, ''))); - return new ForbiddenWordsDictionaryTrie(trie, name, source); - } - return new ForbiddenWordsDictionary(name, source, words); -} -exports.createForbiddenWordsDictionary = createForbiddenWordsDictionary; -//# sourceMappingURL=ForbiddenWordsDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js index 87934fc78..531d38d11 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/IgnoreWordsDictionary.js @@ -72,7 +72,7 @@ class IgnoreWordsDictionary { return { found: nWord, forbidden: false, noSuggest: true }; return (this.dictNonStrict.has(lcWord) && { found: lcWord, forbidden: false, noSuggest: true }) || undefined; } - isForbidden(_word) { + isForbidden(_word, _ignoreCase) { return false; } isNoSuggestWord(word, options) { diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js index 7afabd478..18e61570d 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryCollection.js @@ -1,10 +1,34 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.isSpellingDictionaryCollection = exports.createCollection = void 0; const cspell_trie_lib_1 = require("cspell-trie-lib"); const gensequence_1 = require("gensequence"); -const util_1 = require("../util/util"); const clean_1 = require("../util/clean"); +const util_1 = require("../util/util"); +const Defaults = __importStar(require("./defaults")); const SpellingDictionary_1 = require("./SpellingDictionary"); const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); function identityString(w) { @@ -17,7 +41,6 @@ class SpellingDictionaryCollectionImpl { this.options = { weightMap: undefined }; this.mapWord = identityString; this.type = 'SpellingDictionaryCollection'; - this._isForbiddenInDict = (word) => isWordForbiddenInAnyDictionary(this.dictionaries, word); this._isNoSuggestWord = (word, options) => { if (!this.containsNoSuggestWords) return false; @@ -34,14 +57,14 @@ class SpellingDictionaryCollectionImpl { } find(word, hasOptions) { const options = (0, SpellingDictionaryMethods_1.hasOptionToSearchOption)(hasOptions); - const { found = false, forbidden = false, noSuggest = false, } = findInAnyDictionary(this.dictionaries, word, options) || {}; - return { found, forbidden, noSuggest }; + return findInAnyDictionary(this.dictionaries, word, options); } isNoSuggestWord(word, options) { return this._isNoSuggestWord(word, options); } - isForbidden(word) { - return !!this._isForbiddenInDict(word) && !this.isNoSuggestWord(word); + isForbidden(word, ignoreCaseAndAccents) { + const ignoreCase = ignoreCaseAndAccents ?? Defaults.isForbiddenIgnoreCaseAndAccents; + return !!this._isForbiddenInDict(word, ignoreCase) && !this.isNoSuggestWord(word, { ignoreCase }); } suggest(...args) { const [word] = args; @@ -79,6 +102,9 @@ class SpellingDictionaryCollectionImpl { getErrors() { return this.dictionaries.reduce((errors, dict) => errors.concat(dict.getErrors?.() || []), []); } + _isForbiddenInDict(word, ignoreCase) { + return isWordForbiddenInAnyDictionary(this.dictionaries, word, ignoreCase); + } } function createCollection(dictionaries, name) { return new SpellingDictionaryCollectionImpl(dictionaries, name); @@ -100,8 +126,8 @@ function findInAnyDictionary(dicts, word, options) { function isNoSuggestWordInAnyDictionary(dicts, word, options) { return (0, gensequence_1.genSequence)(dicts).first((dict) => dict.isNoSuggestWord(word, options)); } -function isWordForbiddenInAnyDictionary(dicts, word) { - return (0, gensequence_1.genSequence)(dicts).first((dict) => dict.isForbidden(word)); +function isWordForbiddenInAnyDictionary(dicts, word, ignoreCase) { + return (0, gensequence_1.genSequence)(dicts).first((dict) => dict.isForbidden(word, ignoreCase)); } function isSpellingDictionaryCollection(dict) { return dict instanceof SpellingDictionaryCollectionImpl; diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js index 491725008..668dce9ac 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/SpellingDictionaryFromTrie.js @@ -24,13 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.__testing__ = exports.createSpellingDictionaryFromTrieFile = exports.SpellingDictionaryFromTrie = void 0; +const sync_1 = require("@cspell/cspell-pipe/sync"); const cspell_trie_lib_1 = require("cspell-trie-lib"); -const repMap_1 = require("../util/repMap"); -const clean_1 = require("../util/clean"); -const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); const AutoCache_1 = require("../util/AutoCache"); -const sync_1 = require("@cspell/cspell-pipe/sync"); +const clean_1 = require("../util/clean"); +const repMap_1 = require("../util/repMap"); const Defaults = __importStar(require("./defaults")); +const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods"); const findWordOptionsCaseSensitive = Object.freeze({ caseSensitive: true }); const findWordOptionsNotCaseSensitive = Object.freeze({ caseSensitive: false }); class SpellingDictionaryFromTrie { @@ -124,7 +124,7 @@ class SpellingDictionaryFromTrie { isNoSuggestWord(word, options) { return this.containsNoSuggestWords ? this.has(word, options) : false; } - isForbidden(word) { + isForbidden(word, _ignoreCaseAndAccents) { return this._isForbidden(word); } suggest(...args) { diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js new file mode 100644 index 000000000..aa219d8f2 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/index.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js new file mode 100644 index 000000000..c836c2581 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Terms/terms.js @@ -0,0 +1,3 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +//# sourceMappingURL=terms.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js index 606a99d7a..b75c4f7b9 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/typosParser.js @@ -33,7 +33,7 @@ function trimAndFilter(lines) { } function cleanSugs(rawSugs) { const sugs = trimAndFilter(rawSugs); - return sugs.length === 1 ? sugs[0] : sugs.length ? sugs : null; + return sugs.length === 1 ? sugs[0] : sugs.length ? sugs : false; } function splitSuggestionsValue(value) { return cleanSugs(value.split(suggestionsSeparator)); @@ -55,8 +55,8 @@ function sanitizeIntoTypoDef(dirtyDef) { def[key] = sugs; continue; } - (0, assert_1.default)(value === null || value === undefined, 'Unexpected suggestion type.'); - def[key] = null; + (0, assert_1.default)(value === false, 'Unexpected suggestion type.'); + def[key] = false; } return def; } @@ -67,7 +67,7 @@ exports.sanitizeIntoTypoDef = sanitizeIntoTypoDef; * @returns a TyposDef */ function processEntriesToTyposDef(entries) { - const def = Array.isArray(entries) ? reduceToTyposDef(entries) : entries; + const def = isIterable(entries) ? reduceToTyposDef(entries) : entries; const result = sanitizeIntoTypoDef(def); (0, assert_1.default)(result); return result; @@ -120,4 +120,7 @@ function parseTyposFile(content) { return reduceToTyposDef(lines); } exports.parseTyposFile = parseTyposFile; +function isIterable(v) { + return Symbol.iterator in v; +} //# sourceMappingURL=typosParser.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js index 0a6cf55a6..5402512e7 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/Typos/util.js @@ -12,7 +12,7 @@ function appendToDef(def, entry) { if (!entry) return def; if (typeof entry === 'string') { - def[entry] = null; + def[entry] = false; return def; } if (Array.isArray(entry)) { @@ -20,7 +20,7 @@ function appendToDef(def, entry) { if (!key) return def; const s = sugs.map((s) => s.trim()).filter((s) => !!s); - def[key] = !s.length ? null : s.length === 1 ? s[0] : s; + def[key] = !s.length ? false : s.length === 1 ? s[0] : s; return def; } Object.assign(def, entry); @@ -32,26 +32,44 @@ function createTyposDef(entries) { if (!entries) return def; for (const [key, value] of entries) { - def[key] = value; + def[key] = isDefined(value) ? value : false; } return def; } exports.createTyposDef = createTyposDef; +/** + * Extract all suggestions. + * @param typosDef - the def + * @returns the set of suggestions. + */ function extractAllSuggestions(typosDef) { - const allSugs = (0, sync_1.pipe)(Object.values(typosDef), (0, sync_1.opFilter)(isDefined), (0, sync_1.opConcatMap)((v) => (Array.isArray(v) ? v : [v]))); + const allSugs = (0, sync_1.pipe)(Object.values(typosDef), (0, sync_1.opFilter)(hasSuggestions), (0, sync_1.opConcatMap)((v) => (Array.isArray(v) ? v : [v]))); return new Set(allSugs); } exports.extractAllSuggestions = extractAllSuggestions; +/** + * Extract all words that have been explicitly ignore because they contains the `ignorePrefix`. + * @param typosDef - the def + * @param ignorePrefix - prefix + * @returns set of ignored words with the prefix removed. + */ function extractIgnoreValues(typosDef, ignorePrefix) { - const sugs = extractAllSuggestions(typosDef); const pfxLen = ignorePrefix.length; - const ignoreKeys = Object.keys(typosDef) + return new Set(Object.keys(typosDef) .filter((k) => k.startsWith(ignorePrefix)) - .map((k) => k.slice(pfxLen)); - return (0, sync_1.reduce)(ignoreKeys, (sugs, word) => sugs.add(word), sugs); + .map((k) => k.slice(pfxLen))); } exports.extractIgnoreValues = extractIgnoreValues; function isDefined(v) { return v !== undefined && v !== null; } +function isString(v) { + return typeof v === 'string'; +} +function isArray(v) { + return Array.isArray(v); +} +function hasSuggestions(v) { + return isString(v) || isArray(v); +} //# sourceMappingURL=util.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js index e61e7490a..12a9db124 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/TyposDictionary.js @@ -1,21 +1,48 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +var __importStar = (this && this.__importStar) || function (mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +}; Object.defineProperty(exports, "__esModule", { value: true }); exports.createTyposDictionary = void 0; const sync_1 = require("@cspell/cspell-pipe/sync"); +const textMappers_1 = require("../util/textMappers"); +const defaults = __importStar(require("./defaults")); const Typos_1 = require("./Typos"); const util_1 = require("./Typos/util"); -const symIgnore = Symbol('ignored'); -class TyposDictionary { +class TyposDictionaryImpl { constructor(name, source, typosDef, ignoreList) { this.name = name; this.source = source; this.typosDef = typosDef; - this.containsNoSuggestWords = false; this.options = {}; this.type = 'typos'; this.isDictionaryCaseSensitive = true; this.size = Object.keys(typosDef).length; - this.ignoreWords = new Set((0, sync_1.pipe)((0, util_1.extractIgnoreValues)(typosDef, '!'), (0, sync_1.opAppend)(ignoreList || []))); + this.explicitIgnoreWords = (0, util_1.extractIgnoreValues)(typosDef, '!'); + this.suggestions = (0, util_1.extractAllSuggestions)(typosDef); + this.ignoreWords = new Set((0, sync_1.pipe)(this.explicitIgnoreWords, (0, sync_1.opAppend)(ignoreList || []))); + this.suggestionsLower = new Set((0, sync_1.pipe)(this.suggestions, textMappers_1.mapperRemoveCaseAndAccents)); + this.containsNoSuggestWords = this.ignoreWords.size > 0; } /** * A Forbidden word list does not "have" valid words. @@ -28,32 +55,54 @@ class TyposDictionary { return false; } /** A more detailed search for a word, might take longer than `has` */ - find(word, _options) { - const found = this._findForms(word); - return typeof found === 'string' ? { found, forbidden: true, noSuggest: false } : undefined; + find(word, options) { + const result = this._findForms(word, options?.ignoreCase ?? defaults.ignoreCase); + if (result === false) + return undefined; + const { found, ignore } = result; + return { found, forbidden: !ignore, noSuggest: ignore }; } - _findForms(word) { - const f = this._find(word); - if (f !== false) - return f; + _findForms(word, ignoreCaseAndAccents) { const lcWord = word.toLowerCase(); - if (lcWord === word) + if (this.ignoreWords.has(word)) { + return { found: word, ignore: true }; + } + if (this.suggestions.has(word)) { return false; - return this._find(lcWord); - } - _find(word) { - if (this.ignoreWords.has(word)) - return symIgnore; + } + if (ignoreCaseAndAccents) { + if (this.suggestionsLower.has(lcWord)) { + return false; + } + if (this.ignoreWords.has(lcWord)) { + return { found: lcWord, ignore: true }; + } + } if (word in this.typosDef) - return word; + return { found: word, ignore: false }; + if (lcWord in this.typosDef) + return { found: lcWord, ignore: false }; return false; } - isForbidden(word) { - const found = this._findForms(word); - return typeof found === 'string'; + isForbidden(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) { + const found = this._findForms(word, ignoreCaseAndAccents); + return found !== false && !found.ignore; } - isNoSuggestWord(_word, _options) { - return false; + isNoSuggestWord(word, options) { + const result = this.find(word, options); + return result?.noSuggest ?? false; + } + /** + * Determine if the word can appear in a list of suggestions. + * @param word - word + * @param ignoreCaseAndAccents - ignore case. + * @returns true if a word is suggested, otherwise false. + */ + isSuggestedWord(word, ignoreCaseAndAccents = defaults.isForbiddenIgnoreCaseAndAccents) { + if (this.suggestions.has(word)) + return true; + const lcWord = word.toLowerCase(); + return ignoreCaseAndAccents && (this.suggestions.has(lcWord) || this.suggestionsLower.has(lcWord)); } suggest(word) { return this._suggest(word) || this._suggest(word.toLowerCase()) || []; @@ -91,14 +140,13 @@ class TyposDictionary { /** * Create a dictionary where all words are to be forbidden. * @param entries - list of Typos Entries - * @param name - * @param source - * @param options + * @param name - name of dictionary + * @param source - source * @returns */ function createTyposDictionary(entries, name, source) { const def = (0, Typos_1.processEntriesToTyposDef)(entries); - return new TyposDictionary(name, source, def); + return new TyposDictionaryImpl(name, source, def); } exports.createTyposDictionary = createTyposDictionary; //# sourceMappingURL=TyposDictionary.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js index 6a0e9ca25..00859ceb1 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/defaults.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.ignoreCase = void 0; +exports.isForbiddenIgnoreCaseAndAccents = exports.ignoreCase = void 0; exports.ignoreCase = true; +exports.isForbiddenIgnoreCaseAndAccents = false; //# sourceMappingURL=defaults.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js index 4984fbeb3..1a94308b5 100644 --- a/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js +++ b/action/node_modules/cspell-dictionary/dist/SpellingDictionary/index.js @@ -1,17 +1,20 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFailedToLoadDictionary = exports.createSpellingDictionary = exports.createCachingDictionary = void 0; +exports.createTyposDictionary = exports.createSpellingDictionaryFromTrieFile = exports.createCollection = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createSpellingDictionary = exports.createFailedToLoadDictionary = exports.createCachingDictionary = void 0; var CachingDictionary_1 = require("./CachingDictionary"); Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return CachingDictionary_1.createCachingDictionary; } }); var createSpellingDictionary_1 = require("./createSpellingDictionary"); -Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } }); Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createFailedToLoadDictionary; } }); -var ForbiddenWordsDictionary_1 = require("./ForbiddenWordsDictionary"); -Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return ForbiddenWordsDictionary_1.createForbiddenWordsDictionary; } }); +Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return createSpellingDictionary_1.createSpellingDictionary; } }); +var FlagWordsDictionary_1 = require("./FlagWordsDictionary"); +Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } }); +Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return FlagWordsDictionary_1.createFlagWordsDictionary; } }); var IgnoreWordsDictionary_1 = require("./IgnoreWordsDictionary"); Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return IgnoreWordsDictionary_1.createIgnoreWordsDictionary; } }); var SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection"); Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionaryCollection_1.createCollection; } }); var SpellingDictionaryFromTrie_1 = require("./SpellingDictionaryFromTrie"); Object.defineProperty(exports, "createSpellingDictionaryFromTrieFile", { enumerable: true, get: function () { return SpellingDictionaryFromTrie_1.createSpellingDictionaryFromTrieFile; } }); +var TyposDictionary_1 = require("./TyposDictionary"); +Object.defineProperty(exports, "createTyposDictionary", { enumerable: true, get: function () { return TyposDictionary_1.createTyposDictionary; } }); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/dist/index.js b/action/node_modules/cspell-dictionary/dist/index.js index d12ab45b1..00ac49d52 100644 --- a/action/node_modules/cspell-dictionary/dist/index.js +++ b/action/node_modules/cspell-dictionary/dist/index.js @@ -1,10 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0; +exports.createSpellingDictionaryFromTrieFile = exports.createSpellingDictionary = exports.createIgnoreWordsDictionary = exports.createForbiddenWordsDictionary = exports.createFlagWordsDictionary = exports.createFailedToLoadDictionary = exports.createCollection = exports.createCachingDictionary = void 0; var SpellingDictionary_1 = require("./SpellingDictionary"); Object.defineProperty(exports, "createCachingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createCachingDictionary; } }); Object.defineProperty(exports, "createCollection", { enumerable: true, get: function () { return SpellingDictionary_1.createCollection; } }); Object.defineProperty(exports, "createFailedToLoadDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFailedToLoadDictionary; } }); +Object.defineProperty(exports, "createFlagWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createFlagWordsDictionary; } }); Object.defineProperty(exports, "createForbiddenWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createForbiddenWordsDictionary; } }); Object.defineProperty(exports, "createIgnoreWordsDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createIgnoreWordsDictionary; } }); Object.defineProperty(exports, "createSpellingDictionary", { enumerable: true, get: function () { return SpellingDictionary_1.createSpellingDictionary; } }); diff --git a/action/node_modules/cspell-dictionary/dist/util/textMappers.js b/action/node_modules/cspell-dictionary/dist/util/textMappers.js new file mode 100644 index 000000000..d033dc535 --- /dev/null +++ b/action/node_modules/cspell-dictionary/dist/util/textMappers.js @@ -0,0 +1,21 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.mapperRemoveCaseAndAccents = exports.mapperNormalizeNFC = void 0; +const text_1 = require("./text"); +function* mapperNormalizeNFC(words) { + for (const word of words) { + yield word.normalize('NFC'); + } +} +exports.mapperNormalizeNFC = mapperNormalizeNFC; +function* mapperRemoveCaseAndAccents(words) { + for (const word of words) { + const lc = word.toLowerCase(); + yield lc; + const woAccents = (0, text_1.removeAccents)(lc); + if (lc !== woAccents) + yield woAccents; + } +} +exports.mapperRemoveCaseAndAccents = mapperRemoveCaseAndAccents; +//# sourceMappingURL=textMappers.js.map \ No newline at end of file diff --git a/action/node_modules/cspell-dictionary/package.json b/action/node_modules/cspell-dictionary/package.json index 92daa6843..b3f1ece61 100644 --- a/action/node_modules/cspell-dictionary/package.json +++ b/action/node_modules/cspell-dictionary/package.json @@ -1,6 +1,6 @@ { "name": "cspell-dictionary", - "version": "6.14.3", + "version": "6.15.0", "description": "A spelling dictionary library useful for checking words and getting suggestions.", "main": "dist/index.js", "typings": "dist/index.d.ts", @@ -43,11 +43,11 @@ "ts-jest": "^29.0.3" }, "dependencies": { - "@cspell/cspell-pipe": "6.14.3", - "@cspell/cspell-types": "6.14.3", - "cspell-trie-lib": "6.14.3", + "@cspell/cspell-pipe": "6.15.0", + "@cspell/cspell-types": "6.15.0", + "cspell-trie-lib": "6.15.0", "fast-equals": "^4.0.3", "gensequence": "^4.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-gitignore/package.json b/action/node_modules/cspell-gitignore/package.json index 5c0ecd024..ecd63f5a4 100644 --- a/action/node_modules/cspell-gitignore/package.json +++ b/action/node_modules/cspell-gitignore/package.json @@ -1,6 +1,6 @@ { "name": "cspell-gitignore", - "version": "6.14.3", + "version": "6.15.0", "description": "Gitignore Glob matcher for cspell", "keywords": [ "cspell", @@ -47,7 +47,7 @@ "node": ">=14" }, "dependencies": { - "cspell-glob": "6.14.3", + "cspell-glob": "6.15.0", "find-up": "^5.0.0" }, "devDependencies": { @@ -55,5 +55,5 @@ "jest": "^29.3.1", "rimraf": "^3.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-glob/package.json b/action/node_modules/cspell-glob/package.json index ff3aba124..5406ec433 100644 --- a/action/node_modules/cspell-glob/package.json +++ b/action/node_modules/cspell-glob/package.json @@ -1,6 +1,6 @@ { "name": "cspell-glob", - "version": "6.14.3", + "version": "6.15.0", "description": "Glob matcher for cspell", "keywords": [ "cspell", @@ -50,5 +50,5 @@ "jest": "^29.3.1", "rimraf": "^3.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-grammar/package.json b/action/node_modules/cspell-grammar/package.json index ee7e04a42..327c7746f 100644 --- a/action/node_modules/cspell-grammar/package.json +++ b/action/node_modules/cspell-grammar/package.json @@ -1,6 +1,6 @@ { "name": "cspell-grammar", - "version": "6.14.3", + "version": "6.15.0", "description": "Grammar parsing support for cspell", "keywords": [ "cspell", @@ -69,8 +69,8 @@ "rimraf": "^3.0.2" }, "dependencies": { - "@cspell/cspell-pipe": "6.14.3", - "@cspell/cspell-types": "6.14.3" + "@cspell/cspell-pipe": "6.15.0", + "@cspell/cspell-types": "6.15.0" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-io/package.json b/action/node_modules/cspell-io/package.json index 116a25f49..cb5ee354a 100644 --- a/action/node_modules/cspell-io/package.json +++ b/action/node_modules/cspell-io/package.json @@ -1,6 +1,6 @@ { "name": "cspell-io", - "version": "6.14.3", + "version": "6.15.0", "description": "A library of useful I/O functions used across various cspell tools.", "main": "dist/index.js", "typings": "dist/index.d.ts", @@ -47,8 +47,8 @@ "rimraf": "^3.0.2" }, "dependencies": { - "@cspell/cspell-service-bus": "6.14.3", + "@cspell/cspell-service-bus": "6.15.0", "node-fetch": "^2.6.7" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-lib/package.json b/action/node_modules/cspell-lib/package.json index 4971e3c43..0716a2746 100644 --- a/action/node_modules/cspell-lib/package.json +++ b/action/node_modules/cspell-lib/package.json @@ -1,6 +1,6 @@ { "name": "cspell-lib", - "version": "6.14.3", + "version": "6.15.0", "description": "A library of useful functions used across various cspell tools.", "main": "dist/index.js", "typings": "dist/index.d.ts", @@ -48,19 +48,19 @@ }, "homepage": "https://github.com/streetsidesoftware/cspell#readme", "dependencies": { - "@cspell/cspell-bundled-dicts": "6.14.3", - "@cspell/cspell-pipe": "6.14.3", - "@cspell/cspell-types": "6.14.3", - "@cspell/strong-weak-map": "6.14.3", + "@cspell/cspell-bundled-dicts": "6.15.0", + "@cspell/cspell-pipe": "6.15.0", + "@cspell/cspell-types": "6.15.0", + "@cspell/strong-weak-map": "6.15.0", "clear-module": "^4.1.2", "comment-json": "^4.2.3", "configstore": "^5.0.1", - "cosmiconfig": "^7.1.0", - "cspell-dictionary": "6.14.3", - "cspell-glob": "6.14.3", - "cspell-grammar": "6.14.3", - "cspell-io": "6.14.3", - "cspell-trie-lib": "6.14.3", + "cosmiconfig": "^8.0.0", + "cspell-dictionary": "6.15.0", + "cspell-glob": "6.15.0", + "cspell-grammar": "6.15.0", + "cspell-io": "6.15.0", + "cspell-trie-lib": "6.15.0", "fast-equals": "^4.0.3", "find-up": "^5.0.0", "fs-extra": "^10.1.0", @@ -76,7 +76,7 @@ }, "devDependencies": { "@cspell/dict-cpp": "^4.0.0", - "@cspell/dict-csharp": "^4.0.1", + "@cspell/dict-csharp": "^4.0.2", "@cspell/dict-css": "^3.0.0", "@cspell/dict-fa-ir": "^2.0.0", "@cspell/dict-fr-fr": "^2.1.1", @@ -91,9 +91,9 @@ "jest": "^29.3.1", "lorem-ipsum": "^2.0.8", "rimraf": "^3.0.2", - "rollup": "^3.3.0", + "rollup": "^3.4.0", "rollup-plugin-dts": "^5.0.0", "ts-jest": "^29.0.3" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell-trie-lib/dist/lib/suggestions/suggestCollector.js b/action/node_modules/cspell-trie-lib/dist/lib/suggestions/suggestCollector.js index bcbdc9889..003452f4a 100644 --- a/action/node_modules/cspell-trie-lib/dist/lib/suggestions/suggestCollector.js +++ b/action/node_modules/cspell-trie-lib/dist/lib/suggestions/suggestCollector.js @@ -24,7 +24,9 @@ const DEFAULT_COLLECTOR_TIMEOUT = 1000; const symStopProcessing = Symbol('Collector Stop Processing'); // comparison function for Suggestion Results. function compSuggestionResults(a, b) { - return a.cost - b.cost || a.word.length - b.word.length || collator.compare(a.word, b.word); + const aPref = (a.isPreferred && -1) || 0; + const bPref = (b.isPreferred && -1) || 0; + return aPref - bPref || a.cost - b.cost || a.word.length - b.word.length || collator.compare(a.word, b.word); } exports.compSuggestionResults = compSuggestionResults; exports.defaultSuggestionCollectorOptions = Object.freeze({ diff --git a/action/node_modules/cspell-trie-lib/package.json b/action/node_modules/cspell-trie-lib/package.json index e9c4846c9..07705c82c 100644 --- a/action/node_modules/cspell-trie-lib/package.json +++ b/action/node_modules/cspell-trie-lib/package.json @@ -1,6 +1,6 @@ { "name": "cspell-trie-lib", - "version": "6.14.3", + "version": "6.15.0", "description": "Trie Data Structure to support cspell.", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -37,8 +37,8 @@ }, "homepage": "https://github.com/streetsidesoftware/cspell#readme", "dependencies": { - "@cspell/cspell-pipe": "6.14.3", - "@cspell/cspell-types": "6.14.3", + "@cspell/cspell-pipe": "6.15.0", + "@cspell/cspell-types": "6.15.0", "fs-extra": "^10.1.0", "gensequence": "^4.0.2" }, @@ -53,5 +53,5 @@ "jest": "^29.3.1", "rimraf": "^3.0.2" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/cspell/package.json b/action/node_modules/cspell/package.json index d4aee6e15..ee694167b 100644 --- a/action/node_modules/cspell/package.json +++ b/action/node_modules/cspell/package.json @@ -1,6 +1,6 @@ { "name": "cspell", - "version": "6.14.3", + "version": "6.15.0", "description": "A Spelling Checker for Code!", "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1", "main": "dist/index.js", @@ -70,12 +70,12 @@ }, "homepage": "https://streetsidesoftware.github.io/cspell/", "dependencies": { - "@cspell/cspell-pipe": "6.14.3", + "@cspell/cspell-pipe": "6.15.0", "chalk": "^4.1.2", "commander": "^9.4.1", - "cspell-gitignore": "6.14.3", - "cspell-glob": "6.14.3", - "cspell-lib": "6.14.3", + "cspell-gitignore": "6.15.0", + "cspell-glob": "6.15.0", + "cspell-lib": "6.15.0", "fast-json-stable-stringify": "^2.1.0", "file-entry-cache": "^6.0.1", "fs-extra": "^10.1.0", @@ -90,8 +90,8 @@ "node": ">=14" }, "devDependencies": { - "@cspell/cspell-json-reporter": "6.14.3", - "@cspell/cspell-types": "6.14.3", + "@cspell/cspell-json-reporter": "6.15.0", + "@cspell/cspell-types": "6.15.0", "@types/file-entry-cache": "^5.0.2", "@types/fs-extra": "^9.0.13", "@types/glob": "^8.0.0", @@ -103,8 +103,8 @@ "micromatch": "^4.0.5", "minimatch": "^5.1.0", "rimraf": "^3.0.2", - "rollup": "^3.3.0", + "rollup": "^3.4.0", "rollup-plugin-dts": "^5.0.0" }, - "gitHead": "df0efdbb0dc7b084579130ba5fe97441c0ab67ca" + "gitHead": "8bbc20a6fabe0b95caafb7dac2035764cc73ba13" } diff --git a/action/node_modules/js-yaml/CHANGELOG.md b/action/node_modules/js-yaml/CHANGELOG.md new file mode 100644 index 000000000..ff2375e05 --- /dev/null +++ b/action/node_modules/js-yaml/CHANGELOG.md @@ -0,0 +1,616 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + + +## [4.1.0] - 2021-04-15 +### Added +- Types are now exported as `yaml.types.XXX`. +- Every type now has `options` property with original arguments kept as they were + (see `yaml.types.int.options` as an example). + +### Changed +- `Schema.extend()` now keeps old type order in case of conflicts + (e.g. Schema.extend([ a, b, c ]).extend([ b, a, d ]) is now ordered as `abcd` instead of `cbad`). + + +## [4.0.0] - 2021-01-03 +### Changed +- Check [migration guide](migrate_v3_to_v4.md) to see details for all breaking changes. +- Breaking: "unsafe" tags `!!js/function`, `!!js/regexp`, `!!js/undefined` are + moved to [js-yaml-js-types](https://github.com/nodeca/js-yaml-js-types) package. +- Breaking: removed `safe*` functions. Use `load`, `loadAll`, `dump` + instead which are all now safe by default. +- `yaml.DEFAULT_SAFE_SCHEMA` and `yaml.DEFAULT_FULL_SCHEMA` are removed, use + `yaml.DEFAULT_SCHEMA` instead. +- `yaml.Schema.create(schema, tags)` is removed, use `schema.extend(tags)` instead. +- `!!binary` now always mapped to `Uint8Array` on load. +- Reduced nesting of `/lib` folder. +- Parse numbers according to YAML 1.2 instead of YAML 1.1 (`01234` is now decimal, + `0o1234` is octal, `1:23` is parsed as string instead of base60). +- `dump()` no longer quotes `:`, `[`, `]`, `(`, `)` except when necessary, #470, #557. +- Line and column in exceptions are now formatted as `(X:Y)` instead of + `at line X, column Y` (also present in compact format), #332. +- Code snippet created in exceptions now contains multiple lines with line numbers. +- `dump()` now serializes `undefined` as `null` in collections and removes keys with + `undefined` in mappings, #571. +- `dump()` with `skipInvalid=true` now serializes invalid items in collections as null. +- Custom tags starting with `!` are now dumped as `!tag` instead of `!`, #576. +- Custom tags starting with `tag:yaml.org,2002:` are now shorthanded using `!!`, #258. + +### Added +- Added `.mjs` (es modules) support. +- Added `quotingType` and `forceQuotes` options for dumper to configure + string literal style, #290, #529. +- Added `styles: { '!!null': 'empty' }` option for dumper + (serializes `{ foo: null }` as "`foo: `"), #570. +- Added `replacer` option (similar to option in JSON.stringify), #339. +- Custom `Tag` can now handle all tags or multiple tags with the same prefix, #385. + +### Fixed +- Astral characters are no longer encoded by `dump()`, #587. +- "duplicate mapping key" exception now points at the correct column, #452. +- Extra commas in flow collections (e.g. `[foo,,bar]`) now throw an exception + instead of producing null, #321. +- `__proto__` key no longer overrides object prototype, #164. +- Removed `bower.json`. +- Tags are now url-decoded in `load()` and url-encoded in `dump()` + (previously usage of custom non-ascii tags may have led to invalid YAML that can't be parsed). +- Anchors now work correctly with empty nodes, #301. +- Fix incorrect parsing of invalid block mapping syntax, #418. +- Throw an error if block sequence/mapping indent contains a tab, #80. + + +## [3.14.1] - 2020-12-07 +### Security +- Fix possible code execution in (already unsafe) `.load()` (in &anchor). + + +## [3.14.0] - 2020-05-22 +### Changed +- Support `safe/loadAll(input, options)` variant of call. +- CI: drop outdated nodejs versions. +- Dev deps bump. + +### Fixed +- Quote `=` in plain scalars #519. +- Check the node type for `!` tag in case user manually specifies it. +- Verify that there are no null-bytes in input. +- Fix wrong quote position when writing condensed flow, #526. + + +## [3.13.1] - 2019-04-05 +### Security +- Fix possible code execution in (already unsafe) `.load()`, #480. + + +## [3.13.0] - 2019-03-20 +### Security +- Security fix: `safeLoad()` can hang when arrays with nested refs + used as key. Now throws exception for nested arrays. #475. + + +## [3.12.2] - 2019-02-26 +### Fixed +- Fix `noArrayIndent` option for root level, #468. + + +## [3.12.1] - 2019-01-05 +### Added +- Added `noArrayIndent` option, #432. + + +## [3.12.0] - 2018-06-02 +### Changed +- Support arrow functions without a block statement, #421. + + +## [3.11.0] - 2018-03-05 +### Added +- Add arrow functions suport for `!!js/function`. + +### Fixed +- Fix dump in bin/octal/hex formats for negative integers, #399. + + +## [3.10.0] - 2017-09-10 +### Fixed +- Fix `condenseFlow` output (quote keys for sure, instead of spaces), #371, #370. +- Dump astrals as codepoints instead of surrogate pair, #368. + + +## [3.9.1] - 2017-07-08 +### Fixed +- Ensure stack is present for custom errors in node 7.+, #351. + + +## [3.9.0] - 2017-07-08 +### Added +- Add `condenseFlow` option (to create pretty URL query params), #346. + +### Fixed +- Support array return from safeLoadAll/loadAll, #350. + + +## [3.8.4] - 2017-05-08 +### Fixed +- Dumper: prevent space after dash for arrays that wrap, #343. + + +## [3.8.3] - 2017-04-05 +### Fixed +- Should not allow numbers to begin and end with underscore, #335. + + +## [3.8.2] - 2017-03-02 +### Fixed +- Fix `!!float 123` (integers) parse, #333. +- Don't allow leading zeros in floats (except 0, 0.xxx). +- Allow positive exponent without sign in floats. + + +## [3.8.1] - 2017-02-07 +### Changed +- Maintenance: update browserified build. + + +## [3.8.0] - 2017-02-07 +### Fixed +- Fix reported position for `duplicated mapping key` errors. + Now points to block start instead of block end. + (#243, thanks to @shockey). + + +## [3.7.0] - 2016-11-12 +### Added +- Support polymorphism for tags (#300, thanks to @monken). + +### Fixed +- Fix parsing of quotes followed by newlines (#304, thanks to @dplepage). + + +## [3.6.1] - 2016-05-11 +### Fixed +- Fix output cut on a pipe, #286. + + +## [3.6.0] - 2016-04-16 +### Fixed +- Dumper rewrite, fix multiple bugs with trailing `\n`. + Big thanks to @aepsilon! +- Loader: fix leading/trailing newlines in block scalars, @aepsilon. + + +## [3.5.5] - 2016-03-17 +### Fixed +- Date parse fix: don't allow dates with on digit in month and day, #268. + + +## [3.5.4] - 2016-03-09 +### Added +- `noCompatMode` for dumper, to disable quoting YAML 1.1 values. + + +## [3.5.3] - 2016-02-11 +### Changed +- Maintenance release. + + +## [3.5.2] - 2016-01-11 +### Changed +- Maintenance: missed comma in bower config. + + +## [3.5.1] - 2016-01-11 +### Changed +- Removed `inherit` dependency, #239. +- Better browserify workaround for esprima load. +- Demo rewrite. + + +## [3.5.0] - 2016-01-10 +### Fixed +- Dumper. Fold strings only, #217. +- Dumper. `norefs` option, to clone linked objects, #229. +- Loader. Throw a warning for duplicate keys, #166. +- Improved browserify support (mark `esprima` & `Buffer` excluded). + + +## [3.4.6] - 2015-11-26 +### Changed +- Use standalone `inherit` to keep browserified files clear. + + +## [3.4.5] - 2015-11-23 +### Added +- Added `lineWidth` option to dumper. + + +## [3.4.4] - 2015-11-21 +### Fixed +- Fixed floats dump (missed dot for scientific format), #220. +- Allow non-printable characters inside quoted scalars, #192. + + +## [3.4.3] - 2015-10-10 +### Changed +- Maintenance release - deps bump (esprima, argparse). + + +## [3.4.2] - 2015-09-09 +### Fixed +- Fixed serialization of duplicated entries in sequences, #205. + Thanks to @vogelsgesang. + + +## [3.4.1] - 2015-09-05 +### Fixed +- Fixed stacktrace handling in generated errors, for browsers (FF/IE). + + +## [3.4.0] - 2015-08-23 +### Changed +- Don't throw on warnings anymore. Use `onWarning` option to catch. +- Throw error on unknown tags (was warning before). +- Reworked internals of error class. + +### Fixed +- Fixed multiline keys dump, #197. Thanks to @tcr. +- Fixed heading line breaks in some scalars (regression). + + +## [3.3.1] - 2015-05-13 +### Added +- Added `.sortKeys` dumper option, thanks to @rjmunro. + +### Fixed +- Fixed astral characters support, #191. + + +## [3.3.0] - 2015-04-26 +### Changed +- Significantly improved long strings formatting in dumper, thanks to @isaacs. +- Strip BOM if exists. + + +## [3.2.7] - 2015-02-19 +### Changed +- Maintenance release. +- Updated dependencies. +- HISTORY.md -> CHANGELOG.md + + +## [3.2.6] - 2015-02-07 +### Fixed +- Fixed encoding of UTF-16 surrogate pairs. (e.g. "\U0001F431" CAT FACE). +- Fixed demo dates dump (#113, thanks to @Hypercubed). + + +## [3.2.5] - 2014-12-28 +### Fixed +- Fixed resolving of all built-in types on empty nodes. +- Fixed invalid warning on empty lines within quoted scalars and flow collections. +- Fixed bug: Tag on an empty node didn't resolve in some cases. + + +## [3.2.4] - 2014-12-19 +### Fixed +- Fixed resolving of !!null tag on an empty node. + + +## [3.2.3] - 2014-11-08 +### Fixed +- Implemented dumping of objects with circular and cross references. +- Partially fixed aliasing of constructed objects. (see issue #141 for details) + + +## [3.2.2] - 2014-09-07 +### Fixed +- Fixed infinite loop on unindented block scalars. +- Rewritten base64 encode/decode in binary type, to keep code licence clear. + + +## [3.2.1] - 2014-08-24 +### Fixed +- Nothig new. Just fix npm publish error. + + +## [3.2.0] - 2014-08-24 +### Added +- Added input piping support to CLI. + +### Fixed +- Fixed typo, that could cause hand on initial indent (#139). + + +## [3.1.0] - 2014-07-07 +### Changed +- 1.5x-2x speed boost. +- Removed deprecated `require('xxx.yml')` support. +- Significant code cleanup and refactoring. +- Internal API changed. If you used custom types - see updated examples. + Others are not affected. +- Even if the input string has no trailing line break character, + it will be parsed as if it has one. +- Added benchmark scripts. +- Moved bower files to /dist folder +- Bugfixes. + + +## [3.0.2] - 2014-02-27 +### Fixed +- Fixed bug: "constructor" string parsed as `null`. + + +## [3.0.1] - 2013-12-22 +### Fixed +- Fixed parsing of literal scalars. (issue #108) +- Prevented adding unnecessary spaces in object dumps. (issue #68) +- Fixed dumping of objects with very long (> 1024 in length) keys. + + +## [3.0.0] - 2013-12-16 +### Changed +- Refactored code. Changed API for custom types. +- Removed output colors in CLI, dump json by default. +- Removed big dependencies from browser version (esprima, buffer). Load `esprima` manually, if `!!js/function` needed. `!!bin` now returns Array in browser +- AMD support. +- Don't quote dumped strings because of `-` & `?` (if not first char). +- __Deprecated__ loading yaml files via `require()`, as not recommended + behaviour for node. + + +## [2.1.3] - 2013-10-16 +### Fixed +- Fix wrong loading of empty block scalars. + + +## [2.1.2] - 2013-10-07 +### Fixed +- Fix unwanted line breaks in folded scalars. + + +## [2.1.1] - 2013-10-02 +### Fixed +- Dumper now respects deprecated booleans syntax from YAML 1.0/1.1 +- Fixed reader bug in JSON-like sequences/mappings. + + +## [2.1.0] - 2013-06-05 +### Added +- Add standard YAML schemas: Failsafe (`FAILSAFE_SCHEMA`), + JSON (`JSON_SCHEMA`) and Core (`CORE_SCHEMA`). +- Add `skipInvalid` dumper option. + +### Changed +- Rename `DEFAULT_SCHEMA` to `DEFAULT_FULL_SCHEMA` + and `SAFE_SCHEMA` to `DEFAULT_SAFE_SCHEMA`. +- Use `safeLoad` for `require` extension. + +### Fixed +- Bug fix: export `NIL` constant from the public interface. + + +## [2.0.5] - 2013-04-26 +### Security +- Close security issue in !!js/function constructor. + Big thanks to @nealpoole for security audit. + + +## [2.0.4] - 2013-04-08 +### Changed +- Updated .npmignore to reduce package size + + +## [2.0.3] - 2013-02-26 +### Fixed +- Fixed dumping of empty arrays ans objects. ([] and {} instead of null) + + +## [2.0.2] - 2013-02-15 +### Fixed +- Fixed input validation: tabs are printable characters. + + +## [2.0.1] - 2013-02-09 +### Fixed +- Fixed error, when options not passed to function cass + + +## [2.0.0] - 2013-02-09 +### Changed +- Full rewrite. New architecture. Fast one-stage parsing. +- Changed custom types API. +- Added YAML dumper. + + +## [1.0.3] - 2012-11-05 +### Fixed +- Fixed utf-8 files loading. + + +## [1.0.2] - 2012-08-02 +### Fixed +- Pull out hand-written shims. Use ES5-Shims for old browsers support. See #44. +- Fix timstamps incorectly parsed in local time when no time part specified. + + +## [1.0.1] - 2012-07-07 +### Fixed +- Fixes `TypeError: 'undefined' is not an object` under Safari. Thanks Phuong. +- Fix timestamps incorrectly parsed in local time. Thanks @caolan. Closes #46. + + +## [1.0.0] - 2012-07-01 +### Changed +- `y`, `yes`, `n`, `no`, `on`, `off` are not converted to Booleans anymore. + Fixes #42. +- `require(filename)` now returns a single document and throws an Error if + file contains more than one document. +- CLI was merged back from js-yaml.bin + + +## [0.3.7] - 2012-02-28 +### Fixed +- Fix export of `addConstructor()`. Closes #39. + + +## [0.3.6] - 2012-02-22 +### Changed +- Removed AMD parts - too buggy to use. Need help to rewrite from scratch + +### Fixed +- Removed YUI compressor warning (renamed `double` variable). Closes #40. + + +## [0.3.5] - 2012-01-10 +### Fixed +- Workagound for .npmignore fuckup under windows. Thanks to airportyh. + + +## [0.3.4] - 2011-12-24 +### Fixed +- Fixes str[] for oldIEs support. +- Adds better has change support for browserified demo. +- improves compact output of Error. Closes #33. + + +## [0.3.3] - 2011-12-20 +### Added +- adds `compact` stringification of Errors. + +### Changed +- jsyaml executable moved to separate module. + + +## [0.3.2] - 2011-12-16 +### Added +- Added jsyaml executable. +- Added !!js/function support. Closes #12. + +### Fixed +- Fixes ug with block style scalars. Closes #26. +- All sources are passing JSLint now. +- Fixes bug in Safari. Closes #28. +- Fixes bug in Opers. Closes #29. +- Improves browser support. Closes #20. + + +## [0.3.1] - 2011-11-18 +### Added +- Added AMD support for browserified version. +- Added permalinks for online demo YAML snippets. Now we have YPaste service, lol. +- Added !!js/regexp and !!js/undefined types. Partially solves #12. + +### Changed +- Wrapped browserified js-yaml into closure. + +### Fixed +- Fixed the resolvement of non-specific tags. Closes #17. +- Fixed !!set mapping. +- Fixed month parse in dates. Closes #19. + + +## [0.3.0] - 2011-11-09 +### Added +- Added browserified version. Closes #13. +- Added live demo of browserified version. +- Ported some of the PyYAML tests. See #14. + +### Fixed +- Removed JS.Class dependency. Closes #3. +- Fixed timestamp bug when fraction was given. + + +## [0.2.2] - 2011-11-06 +### Fixed +- Fixed crash on docs without ---. Closes #8. +- Fixed multiline string parse +- Fixed tests/comments for using array as key + + +## [0.2.1] - 2011-11-02 +### Fixed +- Fixed short file read (<4k). Closes #9. + + +## [0.2.0] - 2011-11-02 +### Changed +- First public release + + +[4.1.0]: https://github.com/nodeca/js-yaml/compare/4.0.0...4.1.0 +[4.0.0]: https://github.com/nodeca/js-yaml/compare/3.14.0...4.0.0 +[3.14.0]: https://github.com/nodeca/js-yaml/compare/3.13.1...3.14.0 +[3.13.1]: https://github.com/nodeca/js-yaml/compare/3.13.0...3.13.1 +[3.13.0]: https://github.com/nodeca/js-yaml/compare/3.12.2...3.13.0 +[3.12.2]: https://github.com/nodeca/js-yaml/compare/3.12.1...3.12.2 +[3.12.1]: https://github.com/nodeca/js-yaml/compare/3.12.0...3.12.1 +[3.12.0]: https://github.com/nodeca/js-yaml/compare/3.11.0...3.12.0 +[3.11.0]: https://github.com/nodeca/js-yaml/compare/3.10.0...3.11.0 +[3.10.0]: https://github.com/nodeca/js-yaml/compare/3.9.1...3.10.0 +[3.9.1]: https://github.com/nodeca/js-yaml/compare/3.9.0...3.9.1 +[3.9.0]: https://github.com/nodeca/js-yaml/compare/3.8.4...3.9.0 +[3.8.4]: https://github.com/nodeca/js-yaml/compare/3.8.3...3.8.4 +[3.8.3]: https://github.com/nodeca/js-yaml/compare/3.8.2...3.8.3 +[3.8.2]: https://github.com/nodeca/js-yaml/compare/3.8.1...3.8.2 +[3.8.1]: https://github.com/nodeca/js-yaml/compare/3.8.0...3.8.1 +[3.8.0]: https://github.com/nodeca/js-yaml/compare/3.7.0...3.8.0 +[3.7.0]: https://github.com/nodeca/js-yaml/compare/3.6.1...3.7.0 +[3.6.1]: https://github.com/nodeca/js-yaml/compare/3.6.0...3.6.1 +[3.6.0]: https://github.com/nodeca/js-yaml/compare/3.5.5...3.6.0 +[3.5.5]: https://github.com/nodeca/js-yaml/compare/3.5.4...3.5.5 +[3.5.4]: https://github.com/nodeca/js-yaml/compare/3.5.3...3.5.4 +[3.5.3]: https://github.com/nodeca/js-yaml/compare/3.5.2...3.5.3 +[3.5.2]: https://github.com/nodeca/js-yaml/compare/3.5.1...3.5.2 +[3.5.1]: https://github.com/nodeca/js-yaml/compare/3.5.0...3.5.1 +[3.5.0]: https://github.com/nodeca/js-yaml/compare/3.4.6...3.5.0 +[3.4.6]: https://github.com/nodeca/js-yaml/compare/3.4.5...3.4.6 +[3.4.5]: https://github.com/nodeca/js-yaml/compare/3.4.4...3.4.5 +[3.4.4]: https://github.com/nodeca/js-yaml/compare/3.4.3...3.4.4 +[3.4.3]: https://github.com/nodeca/js-yaml/compare/3.4.2...3.4.3 +[3.4.2]: https://github.com/nodeca/js-yaml/compare/3.4.1...3.4.2 +[3.4.1]: https://github.com/nodeca/js-yaml/compare/3.4.0...3.4.1 +[3.4.0]: https://github.com/nodeca/js-yaml/compare/3.3.1...3.4.0 +[3.3.1]: https://github.com/nodeca/js-yaml/compare/3.3.0...3.3.1 +[3.3.0]: https://github.com/nodeca/js-yaml/compare/3.2.7...3.3.0 +[3.2.7]: https://github.com/nodeca/js-yaml/compare/3.2.6...3.2.7 +[3.2.6]: https://github.com/nodeca/js-yaml/compare/3.2.5...3.2.6 +[3.2.5]: https://github.com/nodeca/js-yaml/compare/3.2.4...3.2.5 +[3.2.4]: https://github.com/nodeca/js-yaml/compare/3.2.3...3.2.4 +[3.2.3]: https://github.com/nodeca/js-yaml/compare/3.2.2...3.2.3 +[3.2.2]: https://github.com/nodeca/js-yaml/compare/3.2.1...3.2.2 +[3.2.1]: https://github.com/nodeca/js-yaml/compare/3.2.0...3.2.1 +[3.2.0]: https://github.com/nodeca/js-yaml/compare/3.1.0...3.2.0 +[3.1.0]: https://github.com/nodeca/js-yaml/compare/3.0.2...3.1.0 +[3.0.2]: https://github.com/nodeca/js-yaml/compare/3.0.1...3.0.2 +[3.0.1]: https://github.com/nodeca/js-yaml/compare/3.0.0...3.0.1 +[3.0.0]: https://github.com/nodeca/js-yaml/compare/2.1.3...3.0.0 +[2.1.3]: https://github.com/nodeca/js-yaml/compare/2.1.2...2.1.3 +[2.1.2]: https://github.com/nodeca/js-yaml/compare/2.1.1...2.1.2 +[2.1.1]: https://github.com/nodeca/js-yaml/compare/2.1.0...2.1.1 +[2.1.0]: https://github.com/nodeca/js-yaml/compare/2.0.5...2.1.0 +[2.0.5]: https://github.com/nodeca/js-yaml/compare/2.0.4...2.0.5 +[2.0.4]: https://github.com/nodeca/js-yaml/compare/2.0.3...2.0.4 +[2.0.3]: https://github.com/nodeca/js-yaml/compare/2.0.2...2.0.3 +[2.0.2]: https://github.com/nodeca/js-yaml/compare/2.0.1...2.0.2 +[2.0.1]: https://github.com/nodeca/js-yaml/compare/2.0.0...2.0.1 +[2.0.0]: https://github.com/nodeca/js-yaml/compare/1.0.3...2.0.0 +[1.0.3]: https://github.com/nodeca/js-yaml/compare/1.0.2...1.0.3 +[1.0.2]: https://github.com/nodeca/js-yaml/compare/1.0.1...1.0.2 +[1.0.1]: https://github.com/nodeca/js-yaml/compare/1.0.0...1.0.1 +[1.0.0]: https://github.com/nodeca/js-yaml/compare/0.3.7...1.0.0 +[0.3.7]: https://github.com/nodeca/js-yaml/compare/0.3.6...0.3.7 +[0.3.6]: https://github.com/nodeca/js-yaml/compare/0.3.5...0.3.6 +[0.3.5]: https://github.com/nodeca/js-yaml/compare/0.3.4...0.3.5 +[0.3.4]: https://github.com/nodeca/js-yaml/compare/0.3.3...0.3.4 +[0.3.3]: https://github.com/nodeca/js-yaml/compare/0.3.2...0.3.3 +[0.3.2]: https://github.com/nodeca/js-yaml/compare/0.3.1...0.3.2 +[0.3.1]: https://github.com/nodeca/js-yaml/compare/0.3.0...0.3.1 +[0.3.0]: https://github.com/nodeca/js-yaml/compare/0.2.2...0.3.0 +[0.2.2]: https://github.com/nodeca/js-yaml/compare/0.2.1...0.2.2 +[0.2.1]: https://github.com/nodeca/js-yaml/compare/0.2.0...0.2.1 +[0.2.0]: https://github.com/nodeca/js-yaml/releases/tag/0.2.0 diff --git a/action/node_modules/js-yaml/LICENSE b/action/node_modules/js-yaml/LICENSE new file mode 100644 index 000000000..09d3a29e9 --- /dev/null +++ b/action/node_modules/js-yaml/LICENSE @@ -0,0 +1,21 @@ +(The MIT License) + +Copyright (C) 2011-2015 by Vitaly Puzrin + +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/action/node_modules/js-yaml/README.md b/action/node_modules/js-yaml/README.md new file mode 100644 index 000000000..3cbc4bd2d --- /dev/null +++ b/action/node_modules/js-yaml/README.md @@ -0,0 +1,246 @@ +JS-YAML - YAML 1.2 parser / writer for JavaScript +================================================= + +[![CI](https://github.com/nodeca/js-yaml/workflows/CI/badge.svg?branch=master)](https://github.com/nodeca/js-yaml/actions) +[![NPM version](https://img.shields.io/npm/v/js-yaml.svg)](https://www.npmjs.org/package/js-yaml) + +__[Online Demo](http://nodeca.github.com/js-yaml/)__ + + +This is an implementation of [YAML](http://yaml.org/), a human-friendly data +serialization language. Started as [PyYAML](http://pyyaml.org/) port, it was +completely rewritten from scratch. Now it's very fast, and supports 1.2 spec. + + +Installation +------------ + +### YAML module for node.js + +``` +npm install js-yaml +``` + + +### CLI executable + +If you want to inspect your YAML files from CLI, install js-yaml globally: + +``` +npm install -g js-yaml +``` + +#### Usage + +``` +usage: js-yaml [-h] [-v] [-c] [-t] file + +Positional arguments: + file File with YAML document(s) + +Optional arguments: + -h, --help Show this help message and exit. + -v, --version Show program's version number and exit. + -c, --compact Display errors in compact mode + -t, --trace Show stack trace on error +``` + + +API +--- + +Here we cover the most 'useful' methods. If you need advanced details (creating +your own tags), see [examples](https://github.com/nodeca/js-yaml/tree/master/examples) +for more info. + +``` javascript +const yaml = require('js-yaml'); +const fs = require('fs'); + +// Get document, or throw exception on error +try { + const doc = yaml.load(fs.readFileSync('/home/ixti/example.yml', 'utf8')); + console.log(doc); +} catch (e) { + console.log(e); +} +``` + + +### load (string [ , options ]) + +Parses `string` as single YAML document. Returns either a +plain object, a string, a number, `null` or `undefined`, or throws `YAMLException` on error. By default, does +not support regexps, functions and undefined. + +options: + +- `filename` _(default: null)_ - string to be used as a file path in + error/warning messages. +- `onWarning` _(default: null)_ - function to call on warning messages. + Loader will call this function with an instance of `YAMLException` for each warning. +- `schema` _(default: `DEFAULT_SCHEMA`)_ - specifies a schema to use. + - `FAILSAFE_SCHEMA` - only strings, arrays and plain objects: + http://www.yaml.org/spec/1.2/spec.html#id2802346 + - `JSON_SCHEMA` - all JSON-supported types: + http://www.yaml.org/spec/1.2/spec.html#id2803231 + - `CORE_SCHEMA` - same as `JSON_SCHEMA`: + http://www.yaml.org/spec/1.2/spec.html#id2804923 + - `DEFAULT_SCHEMA` - all supported YAML types. +- `json` _(default: false)_ - compatibility with JSON.parse behaviour. If true, then duplicate keys in a mapping will override values rather than throwing an error. + +NOTE: This function **does not** understand multi-document sources, it throws +exception on those. + +NOTE: JS-YAML **does not** support schema-specific tag resolution restrictions. +So, the JSON schema is not as strictly defined in the YAML specification. +It allows numbers in any notation, use `Null` and `NULL` as `null`, etc. +The core schema also has no such restrictions. It allows binary notation for integers. + + +### loadAll (string [, iterator] [, options ]) + +Same as `load()`, but understands multi-document sources. Applies +`iterator` to each document if specified, or returns array of documents. + +``` javascript +const yaml = require('js-yaml'); + +yaml.loadAll(data, function (doc) { + console.log(doc); +}); +``` + + +### dump (object [ , options ]) + +Serializes `object` as a YAML document. Uses `DEFAULT_SCHEMA`, so it will +throw an exception if you try to dump regexps or functions. However, you can +disable exceptions by setting the `skipInvalid` option to `true`. + +options: + +- `indent` _(default: 2)_ - indentation width to use (in spaces). +- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements +- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function + in the safe schema) and skip pairs and single values with such types. +- `flowLevel` _(default: -1)_ - specifies level of nesting, when to switch from + block to flow style for collections. -1 means block style everwhere +- `styles` - "tag" => "style" map. Each tag may have own set of styles. +- `schema` _(default: `DEFAULT_SCHEMA`)_ specifies a schema to use. +- `sortKeys` _(default: `false`)_ - if `true`, sort keys when dumping YAML. If a + function, use the function to sort the keys. +- `lineWidth` _(default: `80`)_ - set max line width. Set `-1` for unlimited width. +- `noRefs` _(default: `false`)_ - if `true`, don't convert duplicate objects into references +- `noCompatMode` _(default: `false`)_ - if `true` don't try to be compatible with older + yaml versions. Currently: don't quote "yes", "no" and so on, as required for YAML 1.1 +- `condenseFlow` _(default: `false`)_ - if `true` flow sequences will be condensed, omitting the space between `a, b`. Eg. `'[a,b]'`, and omitting the space between `key: value` and quoting the key. Eg. `'{"a":b}'` Can be useful when using yaml for pretty URL query params as spaces are %-encoded. +- `quotingType` _(`'` or `"`, default: `'`)_ - strings will be quoted using this quoting style. If you specify single quotes, double quotes will still be used for non-printable characters. +- `forceQuotes` _(default: `false`)_ - if `true`, all non-key strings will be quoted even if they normally don't need to. +- `replacer` - callback `function (key, value)` called recursively on each key/value in source object (see `replacer` docs for `JSON.stringify`). + +The following table show availlable styles (e.g. "canonical", +"binary"...) available for each tag (.e.g. !!null, !!int ...). Yaml +output is shown on the right side after `=>` (default setting) or `->`: + +``` none +!!null + "canonical" -> "~" + "lowercase" => "null" + "uppercase" -> "NULL" + "camelcase" -> "Null" + +!!int + "binary" -> "0b1", "0b101010", "0b1110001111010" + "octal" -> "0o1", "0o52", "0o16172" + "decimal" => "1", "42", "7290" + "hexadecimal" -> "0x1", "0x2A", "0x1C7A" + +!!bool + "lowercase" => "true", "false" + "uppercase" -> "TRUE", "FALSE" + "camelcase" -> "True", "False" + +!!float + "lowercase" => ".nan", '.inf' + "uppercase" -> ".NAN", '.INF' + "camelcase" -> ".NaN", '.Inf' +``` + +Example: + +``` javascript +dump(object, { + 'styles': { + '!!null': 'canonical' // dump null as ~ + }, + 'sortKeys': true // sort object keys +}); +``` + +Supported YAML types +-------------------- + +The list of standard YAML tags and corresponding JavaScript types. See also +[YAML tag discussion](http://pyyaml.org/wiki/YAMLTagDiscussion) and +[YAML types repository](http://yaml.org/type/). + +``` +!!null '' # null +!!bool 'yes' # bool +!!int '3...' # number +!!float '3.14...' # number +!!binary '...base64...' # buffer +!!timestamp 'YYYY-...' # date +!!omap [ ... ] # array of key-value pairs +!!pairs [ ... ] # array or array pairs +!!set { ... } # array of objects with given keys and null values +!!str '...' # string +!!seq [ ... ] # array +!!map { ... } # object +``` + +**JavaScript-specific tags** + +See [js-yaml-js-types](https://github.com/nodeca/js-yaml-js-types) for +extra types. + + +Caveats +------- + +Note, that you use arrays or objects as key in JS-YAML. JS does not allow objects +or arrays as keys, and stringifies (by calling `toString()` method) them at the +moment of adding them. + +``` yaml +--- +? [ foo, bar ] +: - baz +? { foo: bar } +: - baz + - baz +``` + +``` javascript +{ "foo,bar": ["baz"], "[object Object]": ["baz", "baz"] } +``` + +Also, reading of properties on implicit block mapping keys is not supported yet. +So, the following YAML document cannot be loaded. + +``` yaml +&anchor foo: + foo: bar + *anchor: duplicate key + baz: bat + *anchor: duplicate key +``` + + +js-yaml for enterprise +---------------------- + +Available as part of the Tidelift Subscription + +The maintainers of js-yaml and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-js-yaml?utm_source=npm-js-yaml&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) diff --git a/action/node_modules/js-yaml/bin/js-yaml.js b/action/node_modules/js-yaml/bin/js-yaml.js new file mode 100755 index 000000000..a182f1afb --- /dev/null +++ b/action/node_modules/js-yaml/bin/js-yaml.js @@ -0,0 +1,126 @@ +#!/usr/bin/env node + + +'use strict'; + +/*eslint-disable no-console*/ + + +var fs = require('fs'); +var argparse = require('argparse'); +var yaml = require('..'); + + +//////////////////////////////////////////////////////////////////////////////// + + +var cli = new argparse.ArgumentParser({ + prog: 'js-yaml', + add_help: true +}); + +cli.add_argument('-v', '--version', { + action: 'version', + version: require('../package.json').version +}); + +cli.add_argument('-c', '--compact', { + help: 'Display errors in compact mode', + action: 'store_true' +}); + +// deprecated (not needed after we removed output colors) +// option suppressed, but not completely removed for compatibility +cli.add_argument('-j', '--to-json', { + help: argparse.SUPPRESS, + dest: 'json', + action: 'store_true' +}); + +cli.add_argument('-t', '--trace', { + help: 'Show stack trace on error', + action: 'store_true' +}); + +cli.add_argument('file', { + help: 'File to read, utf-8 encoded without BOM', + nargs: '?', + default: '-' +}); + + +//////////////////////////////////////////////////////////////////////////////// + + +var options = cli.parse_args(); + + +//////////////////////////////////////////////////////////////////////////////// + +function readFile(filename, encoding, callback) { + if (options.file === '-') { + // read from stdin + + var chunks = []; + + process.stdin.on('data', function (chunk) { + chunks.push(chunk); + }); + + process.stdin.on('end', function () { + return callback(null, Buffer.concat(chunks).toString(encoding)); + }); + } else { + fs.readFile(filename, encoding, callback); + } +} + +readFile(options.file, 'utf8', function (error, input) { + var output, isYaml; + + if (error) { + if (error.code === 'ENOENT') { + console.error('File not found: ' + options.file); + process.exit(2); + } + + console.error( + options.trace && error.stack || + error.message || + String(error)); + + process.exit(1); + } + + try { + output = JSON.parse(input); + isYaml = false; + } catch (err) { + if (err instanceof SyntaxError) { + try { + output = []; + yaml.loadAll(input, function (doc) { output.push(doc); }, {}); + isYaml = true; + + if (output.length === 0) output = null; + else if (output.length === 1) output = output[0]; + + } catch (e) { + if (options.trace && err.stack) console.error(e.stack); + else console.error(e.toString(options.compact)); + + process.exit(1); + } + } else { + console.error( + options.trace && err.stack || + err.message || + String(err)); + + process.exit(1); + } + } + + if (isYaml) console.log(JSON.stringify(output, null, ' ')); + else console.log(yaml.dump(output)); +}); diff --git a/action/node_modules/js-yaml/dist/js-yaml.js b/action/node_modules/js-yaml/dist/js-yaml.js new file mode 100644 index 000000000..4cc0ddf6d --- /dev/null +++ b/action/node_modules/js-yaml/dist/js-yaml.js @@ -0,0 +1,3874 @@ + +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jsyaml = {})); +}(this, (function (exports) { 'use strict'; + + function isNothing(subject) { + return (typeof subject === 'undefined') || (subject === null); + } + + + function isObject(subject) { + return (typeof subject === 'object') && (subject !== null); + } + + + function toArray(sequence) { + if (Array.isArray(sequence)) return sequence; + else if (isNothing(sequence)) return []; + + return [ sequence ]; + } + + + function extend(target, source) { + var index, length, key, sourceKeys; + + if (source) { + sourceKeys = Object.keys(source); + + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + + return target; + } + + + function repeat(string, count) { + var result = '', cycle; + + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + + return result; + } + + + function isNegativeZero(number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); + } + + + var isNothing_1 = isNothing; + var isObject_1 = isObject; + var toArray_1 = toArray; + var repeat_1 = repeat; + var isNegativeZero_1 = isNegativeZero; + var extend_1 = extend; + + var common = { + isNothing: isNothing_1, + isObject: isObject_1, + toArray: toArray_1, + repeat: repeat_1, + isNegativeZero: isNegativeZero_1, + extend: extend_1 + }; + + // YAML error class. http://stackoverflow.com/questions/8458984 + + + function formatError(exception, compact) { + var where = '', message = exception.reason || '(unknown reason)'; + + if (!exception.mark) return message; + + if (exception.mark.name) { + where += 'in "' + exception.mark.name + '" '; + } + + where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; + + if (!compact && exception.mark.snippet) { + where += '\n\n' + exception.mark.snippet; + } + + return message + ' ' + where; + } + + + function YAMLException$1(reason, mark) { + // Super constructor + Error.call(this); + + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } + } + + + // Inherit from Error + YAMLException$1.prototype = Object.create(Error.prototype); + YAMLException$1.prototype.constructor = YAMLException$1; + + + YAMLException$1.prototype.toString = function toString(compact) { + return this.name + ': ' + formatError(this, compact); + }; + + + var exception = YAMLException$1; + + // get snippet for a single line, respecting maxLength + function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ''; + var tail = ''; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + + if (position - lineStart > maxHalfLength) { + head = ' ... '; + lineStart = position - maxHalfLength + head.length; + } + + if (lineEnd - position > maxHalfLength) { + tail = ' ...'; + lineEnd = position + maxHalfLength - tail.length; + } + + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, + pos: position - lineStart + head.length // relative position + }; + } + + + function padStart(string, max) { + return common.repeat(' ', max - string.length) + string; + } + + + function makeSnippet(mark, options) { + options = Object.create(options || null); + + if (!mark.buffer) return null; + + if (!options.maxLength) options.maxLength = 79; + if (typeof options.indent !== 'number') options.indent = 1; + if (typeof options.linesBefore !== 'number') options.linesBefore = 3; + if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + + var re = /\r?\n|\r|\0/g; + var lineStarts = [ 0 ]; + var lineEnds = []; + var match; + var foundLineNo = -1; + + while ((match = re.exec(mark.buffer))) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + + var result = '', i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n' + result; + } + + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + } + + return result.replace(/\n$/, ''); + } + + + var snippet = makeSnippet; + + var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'multi', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'representName', + 'defaultStyle', + 'styleAliases' + ]; + + var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' + ]; + + function compileStyleAliases(map) { + var result = {}; + + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } + + return result; + } + + function Type$1(tag, options) { + options = options || {}; + + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + + // TODO: Add tag format check. + this.options = options; // keep original options in case user wants to extend this type later + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.representName = options['representName'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.multi = options['multi'] || false; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } + } + + var type = Type$1; + + /*eslint-disable max-len*/ + + + + + + function compileList(schema, name) { + var result = []; + + schema[name].forEach(function (currentType) { + var newIndex = result.length; + + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && + previousType.kind === currentType.kind && + previousType.multi === currentType.multi) { + + newIndex = previousIndex; + } + }); + + result[newIndex] = currentType; + }); + + return result; + } + + + function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + + function collectType(type) { + if (type.multi) { + result.multi[type.kind].push(type); + result.multi['fallback'].push(type); + } else { + result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + } + + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; + } + + + function Schema$1(definition) { + return this.extend(definition); + } + + + Schema$1.prototype.extend = function extend(definition) { + var implicit = []; + var explicit = []; + + if (definition instanceof type) { + // Schema.extend(type) + explicit.push(definition); + + } else if (Array.isArray(definition)) { + // Schema.extend([ type1, type2, ... ]) + explicit = explicit.concat(definition); + + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) + if (definition.implicit) implicit = implicit.concat(definition.implicit); + if (definition.explicit) explicit = explicit.concat(definition.explicit); + + } else { + throw new exception('Schema.extend argument should be a Type, [ Type ], ' + + 'or a schema definition ({ implicit: [...], explicit: [...] })'); + } + + implicit.forEach(function (type$1) { + if (!(type$1 instanceof type)) { + throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + + if (type$1.loadKind && type$1.loadKind !== 'scalar') { + throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + + if (type$1.multi) { + throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + } + }); + + explicit.forEach(function (type$1) { + if (!(type$1 instanceof type)) { + throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + }); + + var result = Object.create(Schema$1.prototype); + + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + + result.compiledImplicit = compileList(result, 'implicit'); + result.compiledExplicit = compileList(result, 'explicit'); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + + return result; + }; + + + var schema = Schema$1; + + var str = new type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } + }); + + var seq = new type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } + }); + + var map = new type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } + }); + + var failsafe = new schema({ + explicit: [ + str, + seq, + map + ] + }); + + function resolveYamlNull(data) { + if (data === null) return true; + + var max = data.length; + + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); + } + + function constructYamlNull() { + return null; + } + + function isNull(object) { + return object === null; + } + + var _null = new type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; }, + empty: function () { return ''; } + }, + defaultStyle: 'lowercase' + }); + + function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); + } + + function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; + } + + function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; + } + + var bool = new type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' + }); + + function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); + } + + function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); + } + + function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); + } + + function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'x') { + // base 16 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'o') { + // base 8 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + } + + // base 10 (except 0) + + // value should not start with `_`; + if (ch === '_') return false; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; + + return true; + } + + function constructYamlInteger(data) { + var value = data, sign = 1, ch; + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } + + ch = value[0]; + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } + + if (value === '0') return 0; + + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); + if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); + } + + return sign * parseInt(value, 10); + } + + function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); + } + + var int = new type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, + octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, + decimal: function (obj) { return obj.toString(10); }, + /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } + }); + + var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + + function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; + } + + function constructYamlFloat(data) { + var value, sign; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + } + return sign * parseFloat(value, 10); + } + + + var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + + function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; + } + + function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); + } + + var float = new type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' + }); + + var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] + }); + + var core = json; + + var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day + + var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + + function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; + } + + function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; + } + + function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); + } + + var timestamp = new type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp + }); + + function resolveYamlMerge(data) { + return data === '<<' || data === null; + } + + var merge = new type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge + }); + + /*eslint-disable no-bitwise*/ + + + + + + // [ 64, 65, 66 ] -> [ padding, CR, LF ] + var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + + + function resolveYamlBinary(data) { + if (data === null) return false; + + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); + + // Skip CR/LF + if (code > 64) continue; + + // Fail on illegal characters + if (code < 0) return false; + + bitlen += 6; + } + + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; + } + + function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; + + // Collect by 6*4 bits (3 bytes) + + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } + + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } + + // Dump tail + + tailbits = (max % 4) * 6; + + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } + + return new Uint8Array(result); + } + + function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; + + // Convert every three bytes to 4 ASCII characters. + + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } + + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; + } + + function isBinary(obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]'; + } + + var binary = new type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary + }); + + var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; + var _toString$2 = Object.prototype.toString; + + function resolveYamlOmap(data) { + if (data === null) return true; + + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + + if (_toString$2.call(pair) !== '[object Object]') return false; + + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } + + if (!pairHasKey) return false; + + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } + + return true; + } + + function constructYamlOmap(data) { + return data !== null ? data : []; + } + + var omap = new type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap + }); + + var _toString$1 = Object.prototype.toString; + + function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString$1.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; + } + + function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; + } + + var pairs = new type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs + }); + + var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; + + function resolveYamlSet(data) { + if (data === null) return true; + + var key, object = data; + + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) return false; + } + } + + return true; + } + + function constructYamlSet(data) { + return data !== null ? data : {}; + } + + var set = new type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet + }); + + var _default = core.extend({ + implicit: [ + timestamp, + merge + ], + explicit: [ + binary, + omap, + pairs, + set + ] + }); + + /*eslint-disable max-len,no-use-before-define*/ + + + + + + + + var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; + + + var CONTEXT_FLOW_IN = 1; + var CONTEXT_FLOW_OUT = 2; + var CONTEXT_BLOCK_IN = 3; + var CONTEXT_BLOCK_OUT = 4; + + + var CHOMPING_CLIP = 1; + var CHOMPING_STRIP = 2; + var CHOMPING_KEEP = 3; + + + var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; + var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; + var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; + var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; + var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + + function _class(obj) { return Object.prototype.toString.call(obj); } + + function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); + } + + function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); + } + + function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); + } + + function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; + } + + function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; + } + + function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; + } + + function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; + } + + function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; + } + + function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); + } + + var simpleEscapeCheck = new Array(256); // integer, for fast access + var simpleEscapeMap = new Array(256); + for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); + } + + + function State$1(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || _default; + this.onWarning = options['onWarning'] || null; + // (Hidden) Remove? makes the loader to expect YAML 1.1 documents + // if such documents have no explicit %YAML directive + this.legacy = options['legacy'] || false; + + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + // position of first leading tab in the current line, + // used to make sure there are no tabs in the indentation + this.firstTabInLine = -1; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + + } + + + function generateError(state, message) { + var mark = { + name: state.filename, + buffer: state.input.slice(0, -1), // omit trailing \0 + position: state.position, + line: state.line, + column: state.position - state.lineStart + }; + + mark.snippet = snippet(mark); + + return new exception(message, mark); + } + + function throwError(state, message) { + throw generateError(state, message); + } + + function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } + } + + + var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty$1.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state, 'tag prefix is malformed: ' + prefix); + } + + state.tagMap[handle] = prefix; + } + }; + + + function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } + } + + function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } + } + + function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, + startLine, startLineStart, startPos) { + + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } + } + + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } + + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty$1.call(overridableKeys, keyNode) && + _hasOwnProperty$1.call(_result, keyNode)) { + state.line = startLine || state.line; + state.lineStart = startLineStart || state.lineStart; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + + // used for this specific key only because Object.defineProperty is slow + if (keyNode === '__proto__') { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + + return _result; + } + + function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; + state.firstTabInLine = -1; + } + + function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { + state.firstTabInLine = state.position; + } + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; + } + + function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; + } + + function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } + } + + + function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; + } + + function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); + } + + function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } + } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); + } + + function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _lineStart, + _pos, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = Object.create(null), + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } else if (ch === 0x2C/* , */) { + // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 + throwError(state, "expected the node content, but found ','"); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; // Save the current line. + _lineStart = state.lineStart; + _pos = state.position; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); + } + + function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; + } + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; + } + + function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; + } + + function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _keyLine, + _keyLineStart, + _keyPos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = Object.create(null), + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (!atExplicitKey && state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + + if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + // Neither implicit nor explicit notation. + // Reading is done. Go to the epilogue. + break; + } + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + } + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + } + + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; + } + + function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } + + ch = state.input.charCodeAt(++state.position); + } + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state, 'tag name is malformed: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; + } + + function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; + } + + function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; + } + + function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag === null) { + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + + } else if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (state.tag !== '!') { + if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + } else { + // looking for multi type + type = null; + typeList = state.typeMap.multi[state.kind || 'fallback']; + + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type = typeList[typeIndex]; + break; + } + } + } + + if (!type) { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result, state.tag); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; + } + + function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = Object.create(null); + state.anchorMap = Object.create(null); + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); + } + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } + } + + + function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State$1(input, options); + + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; + } + + + function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); + + if (typeof iterator !== 'function') { + return documents; + } + + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } + } + + + function load$1(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception('expected a single document in the stream, but found more'); + } + + + var loadAll_1 = loadAll$1; + var load_1 = load$1; + + var loader = { + loadAll: loadAll_1, + load: load_1 + }; + + /*eslint-disable no-use-before-define*/ + + + + + + var _toString = Object.prototype.toString; + var _hasOwnProperty = Object.prototype.hasOwnProperty; + + var CHAR_BOM = 0xFEFF; + var CHAR_TAB = 0x09; /* Tab */ + var CHAR_LINE_FEED = 0x0A; /* LF */ + var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ + var CHAR_SPACE = 0x20; /* Space */ + var CHAR_EXCLAMATION = 0x21; /* ! */ + var CHAR_DOUBLE_QUOTE = 0x22; /* " */ + var CHAR_SHARP = 0x23; /* # */ + var CHAR_PERCENT = 0x25; /* % */ + var CHAR_AMPERSAND = 0x26; /* & */ + var CHAR_SINGLE_QUOTE = 0x27; /* ' */ + var CHAR_ASTERISK = 0x2A; /* * */ + var CHAR_COMMA = 0x2C; /* , */ + var CHAR_MINUS = 0x2D; /* - */ + var CHAR_COLON = 0x3A; /* : */ + var CHAR_EQUALS = 0x3D; /* = */ + var CHAR_GREATER_THAN = 0x3E; /* > */ + var CHAR_QUESTION = 0x3F; /* ? */ + var CHAR_COMMERCIAL_AT = 0x40; /* @ */ + var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ + var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ + var CHAR_GRAVE_ACCENT = 0x60; /* ` */ + var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ + var CHAR_VERTICAL_LINE = 0x7C; /* | */ + var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + + var ESCAPE_SEQUENCES = {}; + + ESCAPE_SEQUENCES[0x00] = '\\0'; + ESCAPE_SEQUENCES[0x07] = '\\a'; + ESCAPE_SEQUENCES[0x08] = '\\b'; + ESCAPE_SEQUENCES[0x09] = '\\t'; + ESCAPE_SEQUENCES[0x0A] = '\\n'; + ESCAPE_SEQUENCES[0x0B] = '\\v'; + ESCAPE_SEQUENCES[0x0C] = '\\f'; + ESCAPE_SEQUENCES[0x0D] = '\\r'; + ESCAPE_SEQUENCES[0x1B] = '\\e'; + ESCAPE_SEQUENCES[0x22] = '\\"'; + ESCAPE_SEQUENCES[0x5C] = '\\\\'; + ESCAPE_SEQUENCES[0x85] = '\\N'; + ESCAPE_SEQUENCES[0xA0] = '\\_'; + ESCAPE_SEQUENCES[0x2028] = '\\L'; + ESCAPE_SEQUENCES[0x2029] = '\\P'; + + var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' + ]; + + var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; + + function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } + type = schema.compiledTypeMap['fallback'][tag]; + + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } + + result[tag] = style; + } + + return result; + } + + function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; + } + + + var QUOTING_TYPE_SINGLE = 1, + QUOTING_TYPE_DOUBLE = 2; + + function State(options) { + this.schema = options['schema'] || _default; + this.indent = Math.max(1, (options['indent'] || 2)); + this.noArrayIndent = options['noArrayIndent'] || false; + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + this.condenseFlow = options['condenseFlow'] || false; + this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; + this.forceQuotes = options['forceQuotes'] || false; + this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; + } + + // Indents every line in a string. Empty lines (\n only) are not indented. + function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } + + if (line.length && line !== '\n') result += ind; + + result += line; + } + + return result; + } + + function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); + } + + function testImplicitResolving(state, str) { + var index, length, type; + + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; + + if (type.resolve(str)) { + return true; + } + } + + return false; + } + + // [33] s-white ::= s-space | s-tab + function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; + } + + // Returns true if the character can be printed without escaping. + // From YAML 1.2: "any allowed characters known to be non-printable + // should also be escaped. [However,] This isn’t mandatory" + // Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. + function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) + || (0x10000 <= c && c <= 0x10FFFF); + } + + // [34] ns-char ::= nb-char - s-white + // [27] nb-char ::= c-printable - b-char - c-byte-order-mark + // [26] b-char ::= b-line-feed | b-carriage-return + // Including s-white (for some reason, examples doesn't match specs in this aspect) + // ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark + function isNsCharOrWhitespace(c) { + return isPrintable(c) + && c !== CHAR_BOM + // - b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; + } + + // [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out + // c = flow-in ⇒ ns-plain-safe-in + // c = block-key ⇒ ns-plain-safe-out + // c = flow-key ⇒ ns-plain-safe-in + // [128] ns-plain-safe-out ::= ns-char + // [129] ns-plain-safe-in ::= ns-char - c-flow-indicator + // [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) + // | ( /* An ns-char preceding */ “#” ) + // | ( “:” /* Followed by an ns-plain-safe(c) */ ) + function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); + return ( + // ns-plain-safe + inblock ? // c = flow-in + cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + ) + // ns-plain-char + && c !== CHAR_SHARP // false on '#' + && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' + || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' + || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' + } + + // Simplified test for values allowed as the first character in plain style. + function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part + return isPrintable(c) && c !== CHAR_BOM + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; + } + + // Simplified test for values allowed as the last character in plain style. + function isPlainSafeLast(c) { + // just not whitespace or colon, it will be checked to be plain character later + return !isWhitespace(c) && c !== CHAR_COLON; + } + + // Same as 'string'.codePointAt(pos), but works in older browsers. + function codePointAt(string, pos) { + var first = string.charCodeAt(pos), second; + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { + second = string.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; + } + + // Determines whether block indentation indicator is required. + function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); + } + + var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + + // Determines which scalar styles are possible and returns the preferred style. + // lineWidth = -1 => no limit. + // Pre-conditions: str.length > 0. + // Post-conditions: + // STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. + // STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). + // STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). + function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, + testAmbiguousType, quotingType, forceQuotes, inblock) { + + var i; + var char = 0; + var prevChar = null; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(codePointAt(string, 0)) + && isPlainSafeLast(codePointAt(string, string.length - 1)); + + if (singleLineOnly || forceQuotes) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + if (plain && !forceQuotes && !testAmbiguousType(string)) { + return STYLE_PLAIN; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + if (!forceQuotes) { + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + + // Note: line breaking/folding is implemented for only the folded style. + // NB. We drop the last trailing newline (if any) of a returned block scalar + // since the dumper adds its own newline. This always works: + // • No ending newline => unaffected; already using strip "-" chomping. + // • Ending newline => removed then restored. + // Importantly, this keeps the "+" chomp indicator from gaining an extra line. + function writeScalar(state, string, level, iskey, inblock) { + state.dump = (function () { + if (string.length === 0) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + } + if (!state.noCompatMode) { + if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); + } + } + + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } + + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, + testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { + + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string) + '"'; + default: + throw new exception('impossible error: invalid scalar style'); + } + }()); + } + + // Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. + function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; + } + + // (See the note for writeScalar.) + function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; + } + + // Note: a long line without a suitable break point will exceed the width limit. + // Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. + function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; + } + + // Greedy line breaking. + // Picks the longest line under the limit each time, + // otherwise settles for the shortest line over the limit. + // NB. More-indented lines *cannot* be folded, as that would add an extra \n. + function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner + } + + // Escapes a double-quoted string. + function escapeString(string) { + var result = ''; + var char = 0; + var escapeSeq; + + for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + escapeSeq = ESCAPE_SEQUENCES[char]; + + if (!escapeSeq && isPrintable(char)) { + result += string[i]; + if (char >= 0x10000) result += string[i + 1]; + } else { + result += escapeSeq || encodeHex(char); + } + } + + return result; + } + + function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level, value, false, false) || + (typeof value === 'undefined' && + writeNode(state, level, null, false, false))) { + + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; + } + + function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level + 1, value, true, true, false, true) || + (typeof value === 'undefined' && + writeNode(state, level + 1, null, true, true, false, true))) { + + if (!compact || _result !== '') { + _result += generateNextLine(state, level); + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } + + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. + } + + function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + + pairBuffer = ''; + if (_result !== '') pairBuffer += ', '; + + if (state.condenseFlow) pairBuffer += '"'; + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } + + if (state.dump.length > 1024) pairBuffer += '? '; + + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; + } + + function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new exception('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || _result !== '') { + pairBuffer += generateNextLine(state, level); + } + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } + + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); + + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } + + pairBuffer += state.dump; + + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } + + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. + } + + function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; + + typeList = explicit ? state.explicitTypes : state.implicitTypes; + + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; + + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { + + if (explicit) { + if (type.multi && type.representName) { + state.tag = type.representName(object); + } else { + state.tag = type.tag; + } + } else { + state.tag = '?'; + } + + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; + + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } + + state.dump = _result; + } + + return true; + } + } + + return false; + } + + // Serializes `object` and writes it to global `result`. + // Returns true on success, or false on invalid object. + // + function writeNode(state, level, object, block, compact, iskey, isblockseq) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + var inblock = block; + var tagStr; + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + if (state.noArrayIndent && !isblockseq && level > 0) { + writeBlockSequence(state, level - 1, state.dump, compact); + } else { + writeBlockSequence(state, level, state.dump, compact); + } + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey, inblock); + } + } else if (type === '[object Undefined]') { + return false; + } else { + if (state.skipInvalid) return false; + throw new exception('unacceptable kind of an object to dump ' + type); + } + + if (state.tag !== null && state.tag !== '?') { + // Need to encode all characters except those allowed by the spec: + // + // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ + // [36] ns-hex-digit ::= ns-dec-digit + // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ + // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ + // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” + // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” + // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” + // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” + // + // Also need to encode '!' because it has special meaning (end of tag prefix). + // + tagStr = encodeURI( + state.tag[0] === '!' ? state.tag.slice(1) : state.tag + ).replace(/!/g, '%21'); + + if (state.tag[0] === '!') { + tagStr = '!' + tagStr; + } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { + tagStr = '!!' + tagStr.slice(18); + } else { + tagStr = '!<' + tagStr + '>'; + } + + state.dump = tagStr + ' ' + state.dump; + } + } + + return true; + } + + function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); + } + + function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } + } + + function dump$1(input, options) { + options = options || {}; + + var state = new State(options); + + if (!state.noRefs) getDuplicateReferences(input, state); + + var value = input; + + if (state.replacer) { + value = state.replacer.call({ '': value }, '', value); + } + + if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; + + return ''; + } + + var dump_1 = dump$1; + + var dumper = { + dump: dump_1 + }; + + function renamed(from, to) { + return function () { + throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + + 'Use yaml.' + to + ' instead, which is now safe by default.'); + }; + } + + + var Type = type; + var Schema = schema; + var FAILSAFE_SCHEMA = failsafe; + var JSON_SCHEMA = json; + var CORE_SCHEMA = core; + var DEFAULT_SCHEMA = _default; + var load = loader.load; + var loadAll = loader.loadAll; + var dump = dumper.dump; + var YAMLException = exception; + + // Re-export all types in case user wants to create custom schema + var types = { + binary: binary, + float: float, + map: map, + null: _null, + pairs: pairs, + set: set, + timestamp: timestamp, + bool: bool, + int: int, + merge: merge, + omap: omap, + seq: seq, + str: str + }; + + // Removed functions from JS-YAML 3.0.x + var safeLoad = renamed('safeLoad', 'load'); + var safeLoadAll = renamed('safeLoadAll', 'loadAll'); + var safeDump = renamed('safeDump', 'dump'); + + var jsYaml = { + Type: Type, + Schema: Schema, + FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, + JSON_SCHEMA: JSON_SCHEMA, + CORE_SCHEMA: CORE_SCHEMA, + DEFAULT_SCHEMA: DEFAULT_SCHEMA, + load: load, + loadAll: loadAll, + dump: dump, + YAMLException: YAMLException, + types: types, + safeLoad: safeLoad, + safeLoadAll: safeLoadAll, + safeDump: safeDump + }; + + exports.CORE_SCHEMA = CORE_SCHEMA; + exports.DEFAULT_SCHEMA = DEFAULT_SCHEMA; + exports.FAILSAFE_SCHEMA = FAILSAFE_SCHEMA; + exports.JSON_SCHEMA = JSON_SCHEMA; + exports.Schema = Schema; + exports.Type = Type; + exports.YAMLException = YAMLException; + exports.default = jsYaml; + exports.dump = dump; + exports.load = load; + exports.loadAll = loadAll; + exports.safeDump = safeDump; + exports.safeLoad = safeLoad; + exports.safeLoadAll = safeLoadAll; + exports.types = types; + + Object.defineProperty(exports, '__esModule', { value: true }); + +}))); diff --git a/action/node_modules/js-yaml/dist/js-yaml.min.js b/action/node_modules/js-yaml/dist/js-yaml.min.js new file mode 100644 index 000000000..bdd8eef54 --- /dev/null +++ b/action/node_modules/js-yaml/dist/js-yaml.min.js @@ -0,0 +1,2 @@ +/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jsyaml={})}(this,(function(e){"use strict";function t(e){return null==e}var n={isNothing:t,isObject:function(e){return"object"==typeof e&&null!==e},toArray:function(e){return Array.isArray(e)?e:t(e)?[]:[e]},repeat:function(e,t){var n,i="";for(n=0;nl&&(t=i-l+(o=" ... ").length),n-i>l&&(n=i+l-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function l(e,t){return n.repeat(" ",t-e.length)+e}var c=function(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var i,r=/\r?\n|\r|\0/g,o=[0],c=[],s=-1;i=r.exec(e.buffer);)c.push(i.index),o.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var u,p,f="",d=Math.min(e.line+t.linesAfter,c.length).toString().length,h=t.maxLength-(t.indent+d+3);for(u=1;u<=t.linesBefore&&!(s-u<0);u++)p=a(e.buffer,o[s-u],c[s-u],e.position-(o[s]-o[s-u]),h),f=n.repeat(" ",t.indent)+l((e.line-u+1).toString(),d)+" | "+p.str+"\n"+f;for(p=a(e.buffer,o[s],c[s],e.position,h),f+=n.repeat(" ",t.indent)+l((e.line+1).toString(),d)+" | "+p.str+"\n",f+=n.repeat("-",t.indent+d+3+p.pos)+"^\n",u=1;u<=t.linesAfter&&!(s+u>=c.length);u++)p=a(e.buffer,o[s+u],c[s+u],e.position-(o[s]-o[s+u]),h),f+=n.repeat(" ",t.indent)+l((e.line+u+1).toString(),d)+" | "+p.str+"\n";return f.replace(/\n$/,"")},s=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],u=["scalar","sequence","mapping"];var p=function(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===s.indexOf(t))throw new o('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=function(e){var t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}(t.styleAliases||null),-1===u.indexOf(this.kind))throw new o('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')};function f(e,t){var n=[];return e[t].forEach((function(e){var t=n.length;n.forEach((function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)})),n[t]=e})),n}function d(e){return this.extend(e)}d.prototype.extend=function(e){var t=[],n=[];if(e instanceof p)n.push(e);else if(Array.isArray(e))n=n.concat(e);else{if(!e||!Array.isArray(e.implicit)&&!Array.isArray(e.explicit))throw new o("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");e.implicit&&(t=t.concat(e.implicit)),e.explicit&&(n=n.concat(e.explicit))}t.forEach((function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(e.loadKind&&"scalar"!==e.loadKind)throw new o("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(e.multi)throw new o("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")})),n.forEach((function(e){if(!(e instanceof p))throw new o("Specified list of YAML types (or a single Type object) contains a non-Type object.")}));var i=Object.create(d.prototype);return i.implicit=(this.implicit||[]).concat(t),i.explicit=(this.explicit||[]).concat(n),i.compiledImplicit=f(i,"implicit"),i.compiledExplicit=f(i,"explicit"),i.compiledTypeMap=function(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function i(e){e.multi?(n.multi[e.kind].push(e),n.multi.fallback.push(e)):n[e.kind][e.tag]=n.fallback[e.tag]=e}for(e=0,t=arguments.length;e=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),x=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");var I=/^[-+]?[0-9]+e/;var S=new p("tag:yaml.org,2002:float",{kind:"scalar",resolve:function(e){return null!==e&&!(!x.test(e)||"_"===e[e.length-1])},construct:function(e){var t,n;return n="-"===(t=e.replace(/_/g,"").toLowerCase())[0]?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),".inf"===t?1===n?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:".nan"===t?NaN:n*parseFloat(t,10)},predicate:function(e){return"[object Number]"===Object.prototype.toString.call(e)&&(e%1!=0||n.isNegativeZero(e))},represent:function(e,t){var i;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(n.isNegativeZero(e))return"-0.0";return i=e.toString(10),I.test(i)?i.replace("e",".e"):i},defaultStyle:"lowercase"}),O=b.extend({implicit:[A,v,C,S]}),j=O,T=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),N=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");var F=new p("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:function(e){return null!==e&&(null!==T.exec(e)||null!==N.exec(e))},construct:function(e){var t,n,i,r,o,a,l,c,s=0,u=null;if(null===(t=T.exec(e))&&(t=N.exec(e)),null===t)throw new Error("Date resolve error");if(n=+t[1],i=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,i,r));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(s=t[7].slice(0,3);s.length<3;)s+="0";s=+s}return t[9]&&(u=6e4*(60*+t[10]+ +(t[11]||0)),"-"===t[9]&&(u=-u)),c=new Date(Date.UTC(n,i,r,o,a,l,s)),u&&c.setTime(c.getTime()-u),c},instanceOf:Date,represent:function(e){return e.toISOString()}});var E=new p("tag:yaml.org,2002:merge",{kind:"scalar",resolve:function(e){return"<<"===e||null===e}}),M="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";var L=new p("tag:yaml.org,2002:binary",{kind:"scalar",resolve:function(e){if(null===e)return!1;var t,n,i=0,r=e.length,o=M;for(n=0;n64)){if(t<0)return!1;i+=6}return i%8==0},construct:function(e){var t,n,i=e.replace(/[\r\n=]/g,""),r=i.length,o=M,a=0,l=[];for(t=0;t>16&255),l.push(a>>8&255),l.push(255&a)),a=a<<6|o.indexOf(i.charAt(t));return 0===(n=r%4*6)?(l.push(a>>16&255),l.push(a>>8&255),l.push(255&a)):18===n?(l.push(a>>10&255),l.push(a>>2&255)):12===n&&l.push(a>>4&255),new Uint8Array(l)},predicate:function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)},represent:function(e){var t,n,i="",r=0,o=e.length,a=M;for(t=0;t>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]),r=(r<<8)+e[t];return 0===(n=o%3)?(i+=a[r>>18&63],i+=a[r>>12&63],i+=a[r>>6&63],i+=a[63&r]):2===n?(i+=a[r>>10&63],i+=a[r>>4&63],i+=a[r<<2&63],i+=a[64]):1===n&&(i+=a[r>>2&63],i+=a[r<<4&63],i+=a[64],i+=a[64]),i}}),_=Object.prototype.hasOwnProperty,D=Object.prototype.toString;var U=new p("tag:yaml.org,2002:omap",{kind:"sequence",resolve:function(e){if(null===e)return!0;var t,n,i,r,o,a=[],l=e;for(t=0,n=l.length;t>10),56320+(e-65536&1023))}for(var ie=new Array(256),re=new Array(256),oe=0;oe<256;oe++)ie[oe]=te(oe)?1:0,re[oe]=te(oe);function ae(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||K,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function le(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=c(n),new o(t,n)}function ce(e,t){throw le(e,t)}function se(e,t){e.onWarning&&e.onWarning.call(null,le(e,t))}var ue={YAML:function(e,t,n){var i,r,o;null!==e.version&&ce(e,"duplication of %YAML directive"),1!==n.length&&ce(e,"YAML directive accepts exactly one argument"),null===(i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]))&&ce(e,"ill-formed argument of the YAML directive"),r=parseInt(i[1],10),o=parseInt(i[2],10),1!==r&&ce(e,"unacceptable YAML version of the document"),e.version=n[0],e.checkLineBreaks=o<2,1!==o&&2!==o&&se(e,"unsupported YAML version of the document")},TAG:function(e,t,n){var i,r;2!==n.length&&ce(e,"TAG directive accepts exactly two arguments"),i=n[0],r=n[1],G.test(i)||ce(e,"ill-formed tag handle (first argument) of the TAG directive"),P.call(e.tagMap,i)&&ce(e,'there is a previously declared suffix for "'+i+'" tag handle'),V.test(r)||ce(e,"ill-formed tag prefix (second argument) of the TAG directive");try{r=decodeURIComponent(r)}catch(t){ce(e,"tag prefix is malformed: "+r)}e.tagMap[i]=r}};function pe(e,t,n,i){var r,o,a,l;if(t1&&(e.result+=n.repeat("\n",t-1))}function be(e,t){var n,i,r=e.tag,o=e.anchor,a=[],l=!1;if(-1!==e.firstTabInLine)return!1;for(null!==e.anchor&&(e.anchorMap[e.anchor]=a),i=e.input.charCodeAt(e.position);0!==i&&(-1!==e.firstTabInLine&&(e.position=e.firstTabInLine,ce(e,"tab characters must not be used in indentation")),45===i)&&z(e.input.charCodeAt(e.position+1));)if(l=!0,e.position++,ge(e,!0,-1)&&e.lineIndent<=t)a.push(null),i=e.input.charCodeAt(e.position);else if(n=e.line,we(e,t,3,!1,!0),a.push(e.result),ge(e,!0,-1),i=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&0!==i)ce(e,"bad indentation of a sequence entry");else if(e.lineIndentt?g=1:e.lineIndent===t?g=0:e.lineIndentt?g=1:e.lineIndent===t?g=0:e.lineIndentt)&&(y&&(a=e.line,l=e.lineStart,c=e.position),we(e,t,4,!0,r)&&(y?g=e.result:m=e.result),y||(de(e,f,d,h,g,m,a,l,c),h=g=m=null),ge(e,!0,-1),s=e.input.charCodeAt(e.position)),(e.line===o||e.lineIndent>t)&&0!==s)ce(e,"bad indentation of a mapping entry");else if(e.lineIndent=0))break;0===o?ce(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):u?ce(e,"repeat of an indentation width identifier"):(p=t+o-1,u=!0)}if(Q(a)){do{a=e.input.charCodeAt(++e.position)}while(Q(a));if(35===a)do{a=e.input.charCodeAt(++e.position)}while(!J(a)&&0!==a)}for(;0!==a;){for(he(e),e.lineIndent=0,a=e.input.charCodeAt(e.position);(!u||e.lineIndentp&&(p=e.lineIndent),J(a))f++;else{if(e.lineIndent0){for(r=a,o=0;r>0;r--)(a=ee(l=e.input.charCodeAt(++e.position)))>=0?o=(o<<4)+a:ce(e,"expected hexadecimal character");e.result+=ne(o),e.position++}else ce(e,"unknown escape sequence");n=i=e.position}else J(l)?(pe(e,n,i,!0),ye(e,ge(e,!1,t)),n=i=e.position):e.position===e.lineStart&&me(e)?ce(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}ce(e,"unexpected end of the stream within a double quoted scalar")}(e,d)?y=!0:!function(e){var t,n,i;if(42!==(i=e.input.charCodeAt(e.position)))return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;0!==i&&!z(i)&&!X(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&ce(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),P.call(e.anchorMap,n)||ce(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],ge(e,!0,-1),!0}(e)?function(e,t,n){var i,r,o,a,l,c,s,u,p=e.kind,f=e.result;if(z(u=e.input.charCodeAt(e.position))||X(u)||35===u||38===u||42===u||33===u||124===u||62===u||39===u||34===u||37===u||64===u||96===u)return!1;if((63===u||45===u)&&(z(i=e.input.charCodeAt(e.position+1))||n&&X(i)))return!1;for(e.kind="scalar",e.result="",r=o=e.position,a=!1;0!==u;){if(58===u){if(z(i=e.input.charCodeAt(e.position+1))||n&&X(i))break}else if(35===u){if(z(e.input.charCodeAt(e.position-1)))break}else{if(e.position===e.lineStart&&me(e)||n&&X(u))break;if(J(u)){if(l=e.line,c=e.lineStart,s=e.lineIndent,ge(e,!1,-1),e.lineIndent>=t){a=!0,u=e.input.charCodeAt(e.position);continue}e.position=o,e.line=l,e.lineStart=c,e.lineIndent=s;break}}a&&(pe(e,r,o,!1),ye(e,e.line-l),r=o=e.position,a=!1),Q(u)||(o=e.position+1),u=e.input.charCodeAt(++e.position)}return pe(e,r,o,!1),!!e.result||(e.kind=p,e.result=f,!1)}(e,d,1===i)&&(y=!0,null===e.tag&&(e.tag="?")):(y=!0,null===e.tag&&null===e.anchor||ce(e,"alias node should not have any properties")),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):0===g&&(y=c&&be(e,h))),null===e.tag)null!==e.anchor&&(e.anchorMap[e.anchor]=e.result);else if("?"===e.tag){for(null!==e.result&&"scalar"!==e.kind&&ce(e,'unacceptable node kind for ! tag; it should be "scalar", not "'+e.kind+'"'),s=0,u=e.implicitTypes.length;s"),null!==e.result&&f.kind!==e.kind&&ce(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result,e.tag)?(e.result=f.construct(e.result,e.tag),null!==e.anchor&&(e.anchorMap[e.anchor]=e.result)):ce(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return null!==e.listener&&e.listener("close",e),null!==e.tag||null!==e.anchor||y}function ke(e){var t,n,i,r,o=e.position,a=!1;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);0!==(r=e.input.charCodeAt(e.position))&&(ge(e,!0,-1),r=e.input.charCodeAt(e.position),!(e.lineIndent>0||37!==r));){for(a=!0,r=e.input.charCodeAt(++e.position),t=e.position;0!==r&&!z(r);)r=e.input.charCodeAt(++e.position);for(i=[],(n=e.input.slice(t,e.position)).length<1&&ce(e,"directive name must not be less than one character in length");0!==r;){for(;Q(r);)r=e.input.charCodeAt(++e.position);if(35===r){do{r=e.input.charCodeAt(++e.position)}while(0!==r&&!J(r));break}if(J(r))break;for(t=e.position;0!==r&&!z(r);)r=e.input.charCodeAt(++e.position);i.push(e.input.slice(t,e.position))}0!==r&&he(e),P.call(ue,n)?ue[n](e,n,i):se(e,'unknown document directive "'+n+'"')}ge(e,!0,-1),0===e.lineIndent&&45===e.input.charCodeAt(e.position)&&45===e.input.charCodeAt(e.position+1)&&45===e.input.charCodeAt(e.position+2)?(e.position+=3,ge(e,!0,-1)):a&&ce(e,"directives end mark is expected"),we(e,e.lineIndent-1,4,!1,!0),ge(e,!0,-1),e.checkLineBreaks&&H.test(e.input.slice(o,e.position))&&se(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&me(e)?46===e.input.charCodeAt(e.position)&&(e.position+=3,ge(e,!0,-1)):e.position=55296&&i<=56319&&t+1=56320&&n<=57343?1024*(i-55296)+n-56320+65536:i}function Re(e){return/^\n* /.test(e)}function Be(e,t,n,i,r,o,a,l){var c,s,u=0,p=null,f=!1,d=!1,h=-1!==i,g=-1,m=De(s=Ye(e,0))&&s!==Oe&&!_e(s)&&45!==s&&63!==s&&58!==s&&44!==s&&91!==s&&93!==s&&123!==s&&125!==s&&35!==s&&38!==s&&42!==s&&33!==s&&124!==s&&61!==s&&62!==s&&39!==s&&34!==s&&37!==s&&64!==s&&96!==s&&function(e){return!_e(e)&&58!==e}(Ye(e,e.length-1));if(t||a)for(c=0;c=65536?c+=2:c++){if(!De(u=Ye(e,c)))return 5;m=m&&qe(u,p,l),p=u}else{for(c=0;c=65536?c+=2:c++){if(10===(u=Ye(e,c)))f=!0,h&&(d=d||c-g-1>i&&" "!==e[g+1],g=c);else if(!De(u))return 5;m=m&&qe(u,p,l),p=u}d=d||h&&c-g-1>i&&" "!==e[g+1]}return f||d?n>9&&Re(e)?5:a?2===o?5:2:d?4:3:!m||a||r(e)?2===o?5:2:1}function Ke(e,t,n,i,r){e.dump=function(){if(0===t.length)return 2===e.quotingType?'""':"''";if(!e.noCompatMode&&(-1!==Te.indexOf(t)||Ne.test(t)))return 2===e.quotingType?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,n),l=-1===e.lineWidth?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),c=i||e.flowLevel>-1&&n>=e.flowLevel;switch(Be(t,c,e.indent,l,(function(t){return function(e,t){var n,i;for(n=0,i=e.implicitTypes.length;n"+Pe(t,e.indent)+We(Me(function(e,t){var n,i,r=/(\n+)([^\n]*)/g,o=(l=e.indexOf("\n"),l=-1!==l?l:e.length,r.lastIndex=l,He(e.slice(0,l),t)),a="\n"===e[0]||" "===e[0];var l;for(;i=r.exec(e);){var c=i[1],s=i[2];n=" "===s[0],o+=c+(a||n||""===s?"":"\n")+He(s,t),a=n}return o}(t,l),a));case 5:return'"'+function(e){for(var t,n="",i=0,r=0;r=65536?r+=2:r++)i=Ye(e,r),!(t=je[i])&&De(i)?(n+=e[r],i>=65536&&(n+=e[r+1])):n+=t||Fe(i);return n}(t)+'"';default:throw new o("impossible error: invalid scalar style")}}()}function Pe(e,t){var n=Re(e)?String(t):"",i="\n"===e[e.length-1];return n+(i&&("\n"===e[e.length-2]||"\n"===e)?"+":i?"":"-")+"\n"}function We(e){return"\n"===e[e.length-1]?e.slice(0,-1):e}function He(e,t){if(""===e||" "===e[0])return e;for(var n,i,r=/ [^ ]/g,o=0,a=0,l=0,c="";n=r.exec(e);)(l=n.index)-o>t&&(i=a>o?a:l,c+="\n"+e.slice(o,i),o=i+1),a=l;return c+="\n",e.length-o>t&&a>o?c+=e.slice(o,a)+"\n"+e.slice(a+1):c+=e.slice(o),c.slice(1)}function $e(e,t,n,i){var r,o,a,l="",c=e.tag;for(r=0,o=n.length;r tag resolver accepts not "'+s+'" style');i=c.represent[s](t,s)}e.dump=i}return!0}return!1}function Ve(e,t,n,i,r,a,l){e.tag=null,e.dump=n,Ge(e,n,!1)||Ge(e,n,!0);var c,s=Ie.call(e.dump),u=i;i&&(i=e.flowLevel<0||e.flowLevel>t);var p,f,d="[object Object]"===s||"[object Array]"===s;if(d&&(f=-1!==(p=e.duplicates.indexOf(n))),(null!==e.tag&&"?"!==e.tag||f||2!==e.indent&&t>0)&&(r=!1),f&&e.usedDuplicates[p])e.dump="*ref_"+p;else{if(d&&f&&!e.usedDuplicates[p]&&(e.usedDuplicates[p]=!0),"[object Object]"===s)i&&0!==Object.keys(e.dump).length?(!function(e,t,n,i){var r,a,l,c,s,u,p="",f=e.tag,d=Object.keys(n);if(!0===e.sortKeys)d.sort();else if("function"==typeof e.sortKeys)d.sort(e.sortKeys);else if(e.sortKeys)throw new o("sortKeys must be a boolean or a function");for(r=0,a=d.length;r1024)&&(e.dump&&10===e.dump.charCodeAt(0)?u+="?":u+="? "),u+=e.dump,s&&(u+=Le(e,t)),Ve(e,t+1,c,!0,s)&&(e.dump&&10===e.dump.charCodeAt(0)?u+=":":u+=": ",p+=u+=e.dump));e.tag=f,e.dump=p||"{}"}(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a,l,c="",s=e.tag,u=Object.keys(n);for(i=0,r=u.length;i1024&&(l+="? "),l+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),Ve(e,t,a,!1,!1)&&(c+=l+=e.dump));e.tag=s,e.dump="{"+c+"}"}(e,t,e.dump),f&&(e.dump="&ref_"+p+" "+e.dump));else if("[object Array]"===s)i&&0!==e.dump.length?(e.noArrayIndent&&!l&&t>0?$e(e,t-1,e.dump,r):$e(e,t,e.dump,r),f&&(e.dump="&ref_"+p+e.dump)):(!function(e,t,n){var i,r,o,a="",l=e.tag;for(i=0,r=n.length;i",e.dump=c+" "+e.dump)}return!0}function Ze(e,t){var n,i,r=[],o=[];for(Je(e,r,o),n=0,i=o.length;n maxHalfLength) { + head = ' ... '; + lineStart = position - maxHalfLength + head.length; + } + + if (lineEnd - position > maxHalfLength) { + tail = ' ...'; + lineEnd = position + maxHalfLength - tail.length; + } + + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, + pos: position - lineStart + head.length // relative position + }; +} + + +function padStart(string, max) { + return common.repeat(' ', max - string.length) + string; +} + + +function makeSnippet(mark, options) { + options = Object.create(options || null); + + if (!mark.buffer) return null; + + if (!options.maxLength) options.maxLength = 79; + if (typeof options.indent !== 'number') options.indent = 1; + if (typeof options.linesBefore !== 'number') options.linesBefore = 3; + if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + + var re = /\r?\n|\r|\0/g; + var lineStarts = [ 0 ]; + var lineEnds = []; + var match; + var foundLineNo = -1; + + while ((match = re.exec(mark.buffer))) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + + var result = '', i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n' + result; + } + + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + } + + return result.replace(/\n$/, ''); +} + + +var snippet = makeSnippet; + +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'multi', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'representName', + 'defaultStyle', + 'styleAliases' +]; + +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; + +function compileStyleAliases(map) { + var result = {}; + + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } + + return result; +} + +function Type$1(tag, options) { + options = options || {}; + + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + + // TODO: Add tag format check. + this.options = options; // keep original options in case user wants to extend this type later + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.representName = options['representName'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.multi = options['multi'] || false; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} + +var type = Type$1; + +/*eslint-disable max-len*/ + + + + + +function compileList(schema, name) { + var result = []; + + schema[name].forEach(function (currentType) { + var newIndex = result.length; + + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && + previousType.kind === currentType.kind && + previousType.multi === currentType.multi) { + + newIndex = previousIndex; + } + }); + + result[newIndex] = currentType; + }); + + return result; +} + + +function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + + function collectType(type) { + if (type.multi) { + result.multi[type.kind].push(type); + result.multi['fallback'].push(type); + } else { + result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + } + + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} + + +function Schema$1(definition) { + return this.extend(definition); +} + + +Schema$1.prototype.extend = function extend(definition) { + var implicit = []; + var explicit = []; + + if (definition instanceof type) { + // Schema.extend(type) + explicit.push(definition); + + } else if (Array.isArray(definition)) { + // Schema.extend([ type1, type2, ... ]) + explicit = explicit.concat(definition); + + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) + if (definition.implicit) implicit = implicit.concat(definition.implicit); + if (definition.explicit) explicit = explicit.concat(definition.explicit); + + } else { + throw new exception('Schema.extend argument should be a Type, [ Type ], ' + + 'or a schema definition ({ implicit: [...], explicit: [...] })'); + } + + implicit.forEach(function (type$1) { + if (!(type$1 instanceof type)) { + throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + + if (type$1.loadKind && type$1.loadKind !== 'scalar') { + throw new exception('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + + if (type$1.multi) { + throw new exception('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + } + }); + + explicit.forEach(function (type$1) { + if (!(type$1 instanceof type)) { + throw new exception('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + }); + + var result = Object.create(Schema$1.prototype); + + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + + result.compiledImplicit = compileList(result, 'implicit'); + result.compiledExplicit = compileList(result, 'explicit'); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + + return result; +}; + + +var schema = Schema$1; + +var str = new type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); + +var seq = new type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); + +var map = new type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); + +var failsafe = new schema({ + explicit: [ + str, + seq, + map + ] +}); + +function resolveYamlNull(data) { + if (data === null) return true; + + var max = data.length; + + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} + +function constructYamlNull() { + return null; +} + +function isNull(object) { + return object === null; +} + +var _null = new type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; }, + empty: function () { return ''; } + }, + defaultStyle: 'lowercase' +}); + +function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); +} + +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} + +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} + +var bool = new type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' +}); + +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} + +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +} + +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} + +function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'x') { + // base 16 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'o') { + // base 8 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + } + + // base 10 (except 0) + + // value should not start with `_`; + if (ch === '_') return false; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; + + return true; +} + +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } + + ch = value[0]; + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } + + if (value === '0') return 0; + + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); + if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); + } + + return sign * parseInt(value, 10); +} + +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); +} + +var int = new type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, + octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, + decimal: function (obj) { return obj.toString(10); }, + /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } +}); + +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; +} + +function constructYamlFloat(data) { + var value, sign; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + } + return sign * parseFloat(value, 10); +} + + +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + +function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +var float = new type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); + +var json = failsafe.extend({ + implicit: [ + _null, + bool, + int, + float + ] +}); + +var core = json; + +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day + +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} + +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; +} + +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} + +var timestamp = new type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); + +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} + +var merge = new type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); + +/*eslint-disable no-bitwise*/ + + + + + +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + + +function resolveYamlBinary(data) { + if (data === null) return false; + + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); + + // Skip CR/LF + if (code > 64) continue; + + // Fail on illegal characters + if (code < 0) return false; + + bitlen += 6; + } + + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} + +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; + + // Collect by 6*4 bits (3 bytes) + + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } + + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } + + // Dump tail + + tailbits = (max % 4) * 6; + + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } + + return new Uint8Array(result); +} + +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; + + // Convert every three bytes to 4 ASCII characters. + + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } + + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; +} + +function isBinary(obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]'; +} + +var binary = new type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); + +var _hasOwnProperty$3 = Object.prototype.hasOwnProperty; +var _toString$2 = Object.prototype.toString; + +function resolveYamlOmap(data) { + if (data === null) return true; + + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + + if (_toString$2.call(pair) !== '[object Object]') return false; + + for (pairKey in pair) { + if (_hasOwnProperty$3.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } + + if (!pairHasKey) return false; + + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } + + return true; +} + +function constructYamlOmap(data) { + return data !== null ? data : []; +} + +var omap = new type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); + +var _toString$1 = Object.prototype.toString; + +function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString$1.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; +} + +function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; +} + +var pairs = new type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); + +var _hasOwnProperty$2 = Object.prototype.hasOwnProperty; + +function resolveYamlSet(data) { + if (data === null) return true; + + var key, object = data; + + for (key in object) { + if (_hasOwnProperty$2.call(object, key)) { + if (object[key] !== null) return false; + } + } + + return true; +} + +function constructYamlSet(data) { + return data !== null ? data : {}; +} + +var set = new type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); + +var _default = core.extend({ + implicit: [ + timestamp, + merge + ], + explicit: [ + binary, + omap, + pairs, + set + ] +}); + +/*eslint-disable max-len,no-use-before-define*/ + + + + + + + +var _hasOwnProperty$1 = Object.prototype.hasOwnProperty; + + +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function _class(obj) { return Object.prototype.toString.call(obj); } + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} + +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; +} + +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); +} + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} + + +function State$1(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || _default; + this.onWarning = options['onWarning'] || null; + // (Hidden) Remove? makes the loader to expect YAML 1.1 documents + // if such documents have no explicit %YAML directive + this.legacy = options['legacy'] || false; + + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + // position of first leading tab in the current line, + // used to make sure there are no tabs in the indentation + this.firstTabInLine = -1; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + +} + + +function generateError(state, message) { + var mark = { + name: state.filename, + buffer: state.input.slice(0, -1), // omit trailing \0 + position: state.position, + line: state.line, + column: state.position - state.lineStart + }; + + mark.snippet = snippet(mark); + + return new exception(message, mark); +} + +function throwError(state, message) { + throw generateError(state, message); +} + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } +} + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty$1.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state, 'tag prefix is malformed: ' + prefix); + } + + state.tagMap[handle] = prefix; + } +}; + + +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } +} + +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty$1.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} + +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, + startLine, startLineStart, startPos) { + + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } + } + + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } + + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty$1.call(overridableKeys, keyNode) && + _hasOwnProperty$1.call(_result, keyNode)) { + state.line = startLine || state.line; + state.lineStart = startLineStart || state.lineStart; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + + // used for this specific key only because Object.defineProperty is slow + if (keyNode === '__proto__') { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + + return _result; +} + +function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; + state.firstTabInLine = -1; +} + +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { + state.firstTabInLine = state.position; + } + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; +} + +function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; +} + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } +} + + +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; +} + +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} + +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } + } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); +} + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _lineStart, + _pos, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = Object.create(null), + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } else if (ch === 0x2C/* , */) { + // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 + throwError(state, "expected the node content, but found ','"); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; // Save the current line. + _lineStart = state.lineStart; + _pos = state.position; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); +} + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; + } + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; +} + +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _keyLine, + _keyLineStart, + _keyPos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = Object.create(null), + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (!atExplicitKey && state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + + if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + // Neither implicit nor explicit notation. + // Reading is done. Go to the epilogue. + break; + } + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + } + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + } + + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } + + ch = state.input.charCodeAt(++state.position); + } + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state, 'tag name is malformed: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; +} + +function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; +} + +function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!_hasOwnProperty$1.call(state.anchorMap, alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} + +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag === null) { + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + + } else if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (state.tag !== '!') { + if (_hasOwnProperty$1.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + } else { + // looking for multi type + type = null; + typeList = state.typeMap.multi[state.kind || 'fallback']; + + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type = typeList[typeIndex]; + break; + } + } + } + + if (!type) { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result, state.tag); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = Object.create(null); + state.anchorMap = Object.create(null); + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); + } + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} + + +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State$1(input, options); + + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; +} + + +function loadAll$1(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); + + if (typeof iterator !== 'function') { + return documents; + } + + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} + + +function load$1(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new exception('expected a single document in the stream, but found more'); +} + + +var loadAll_1 = loadAll$1; +var load_1 = load$1; + +var loader = { + loadAll: loadAll_1, + load: load_1 +}; + +/*eslint-disable no-use-before-define*/ + + + + + +var _toString = Object.prototype.toString; +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +var CHAR_BOM = 0xFEFF; +var CHAR_TAB = 0x09; /* Tab */ +var CHAR_LINE_FEED = 0x0A; /* LF */ +var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ +var CHAR_SPACE = 0x20; /* Space */ +var CHAR_EXCLAMATION = 0x21; /* ! */ +var CHAR_DOUBLE_QUOTE = 0x22; /* " */ +var CHAR_SHARP = 0x23; /* # */ +var CHAR_PERCENT = 0x25; /* % */ +var CHAR_AMPERSAND = 0x26; /* & */ +var CHAR_SINGLE_QUOTE = 0x27; /* ' */ +var CHAR_ASTERISK = 0x2A; /* * */ +var CHAR_COMMA = 0x2C; /* , */ +var CHAR_MINUS = 0x2D; /* - */ +var CHAR_COLON = 0x3A; /* : */ +var CHAR_EQUALS = 0x3D; /* = */ +var CHAR_GREATER_THAN = 0x3E; /* > */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + +var ESCAPE_SEQUENCES = {}; + +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; + +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; + +var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; + +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } + type = schema.compiledTypeMap['fallback'][tag]; + + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } + + result[tag] = style; + } + + return result; +} + +function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new exception('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; +} + + +var QUOTING_TYPE_SINGLE = 1, + QUOTING_TYPE_DOUBLE = 2; + +function State(options) { + this.schema = options['schema'] || _default; + this.indent = Math.max(1, (options['indent'] || 2)); + this.noArrayIndent = options['noArrayIndent'] || false; + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + this.condenseFlow = options['condenseFlow'] || false; + this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; + this.forceQuotes = options['forceQuotes'] || false; + this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; +} + +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } + + if (line.length && line !== '\n') result += ind; + + result += line; + } + + return result; +} + +function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); +} + +function testImplicitResolving(state, str) { + var index, length, type; + + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; + + if (type.resolve(str)) { + return true; + } + } + + return false; +} + +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} + +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) + || (0x10000 <= c && c <= 0x10FFFF); +} + +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// Including s-white (for some reason, examples doesn't match specs in this aspect) +// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark +function isNsCharOrWhitespace(c) { + return isPrintable(c) + && c !== CHAR_BOM + // - b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} + +// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out +// c = flow-in ⇒ ns-plain-safe-in +// c = block-key ⇒ ns-plain-safe-out +// c = flow-key ⇒ ns-plain-safe-in +// [128] ns-plain-safe-out ::= ns-char +// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator +// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) +// | ( /* An ns-char preceding */ “#” ) +// | ( “:” /* Followed by an ns-plain-safe(c) */ ) +function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); + return ( + // ns-plain-safe + inblock ? // c = flow-in + cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + ) + // ns-plain-char + && c !== CHAR_SHARP // false on '#' + && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' + || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' + || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' +} + +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part + return isPrintable(c) && c !== CHAR_BOM + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; +} + +// Simplified test for values allowed as the last character in plain style. +function isPlainSafeLast(c) { + // just not whitespace or colon, it will be checked to be plain character later + return !isWhitespace(c) && c !== CHAR_COLON; +} + +// Same as 'string'.codePointAt(pos), but works in older browsers. +function codePointAt(string, pos) { + var first = string.charCodeAt(pos), second; + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { + second = string.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; +} + +// Determines whether block indentation indicator is required. +function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); +} + +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, + testAmbiguousType, quotingType, forceQuotes, inblock) { + + var i; + var char = 0; + var prevChar = null; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(codePointAt(string, 0)) + && isPlainSafeLast(codePointAt(string, string.length - 1)); + + if (singleLineOnly || forceQuotes) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + if (plain && !forceQuotes && !testAmbiguousType(string)) { + return STYLE_PLAIN; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + if (!forceQuotes) { + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; +} + +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +function writeScalar(state, string, level, iskey, inblock) { + state.dump = (function () { + if (string.length === 0) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + } + if (!state.noCompatMode) { + if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); + } + } + + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } + + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, + testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { + + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string) + '"'; + default: + throw new exception('impossible error: invalid scalar style'); + } + }()); +} + +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; +} + +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +} + +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; +} + +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner +} + +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char = 0; + var escapeSeq; + + for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + escapeSeq = ESCAPE_SEQUENCES[char]; + + if (!escapeSeq && isPrintable(char)) { + result += string[i]; + if (char >= 0x10000) result += string[i + 1]; + } else { + result += escapeSeq || encodeHex(char); + } + } + + return result; +} + +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level, value, false, false) || + (typeof value === 'undefined' && + writeNode(state, level, null, false, false))) { + + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; +} + +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level + 1, value, true, true, false, true) || + (typeof value === 'undefined' && + writeNode(state, level + 1, null, true, true, false, true))) { + + if (!compact || _result !== '') { + _result += generateNextLine(state, level); + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } + + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} + +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + + pairBuffer = ''; + if (_result !== '') pairBuffer += ', '; + + if (state.condenseFlow) pairBuffer += '"'; + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } + + if (state.dump.length > 1024) pairBuffer += '? '; + + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; +} + +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new exception('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || _result !== '') { + pairBuffer += generateNextLine(state, level); + } + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } + + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); + + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } + + pairBuffer += state.dump; + + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } + + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} + +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; + + typeList = explicit ? state.explicitTypes : state.implicitTypes; + + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; + + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { + + if (explicit) { + if (type.multi && type.representName) { + state.tag = type.representName(object); + } else { + state.tag = type.tag; + } + } else { + state.tag = '?'; + } + + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; + + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new exception('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } + + state.dump = _result; + } + + return true; + } + } + + return false; +} + +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey, isblockseq) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + var inblock = block; + var tagStr; + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + if (state.noArrayIndent && !isblockseq && level > 0) { + writeBlockSequence(state, level - 1, state.dump, compact); + } else { + writeBlockSequence(state, level, state.dump, compact); + } + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey, inblock); + } + } else if (type === '[object Undefined]') { + return false; + } else { + if (state.skipInvalid) return false; + throw new exception('unacceptable kind of an object to dump ' + type); + } + + if (state.tag !== null && state.tag !== '?') { + // Need to encode all characters except those allowed by the spec: + // + // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ + // [36] ns-hex-digit ::= ns-dec-digit + // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ + // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ + // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” + // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” + // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” + // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” + // + // Also need to encode '!' because it has special meaning (end of tag prefix). + // + tagStr = encodeURI( + state.tag[0] === '!' ? state.tag.slice(1) : state.tag + ).replace(/!/g, '%21'); + + if (state.tag[0] === '!') { + tagStr = '!' + tagStr; + } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { + tagStr = '!!' + tagStr.slice(18); + } else { + tagStr = '!<' + tagStr + '>'; + } + + state.dump = tagStr + ' ' + state.dump; + } + } + + return true; +} + +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); +} + +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} + +function dump$1(input, options) { + options = options || {}; + + var state = new State(options); + + if (!state.noRefs) getDuplicateReferences(input, state); + + var value = input; + + if (state.replacer) { + value = state.replacer.call({ '': value }, '', value); + } + + if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; + + return ''; +} + +var dump_1 = dump$1; + +var dumper = { + dump: dump_1 +}; + +function renamed(from, to) { + return function () { + throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + + 'Use yaml.' + to + ' instead, which is now safe by default.'); + }; +} + + +var Type = type; +var Schema = schema; +var FAILSAFE_SCHEMA = failsafe; +var JSON_SCHEMA = json; +var CORE_SCHEMA = core; +var DEFAULT_SCHEMA = _default; +var load = loader.load; +var loadAll = loader.loadAll; +var dump = dumper.dump; +var YAMLException = exception; + +// Re-export all types in case user wants to create custom schema +var types = { + binary: binary, + float: float, + map: map, + null: _null, + pairs: pairs, + set: set, + timestamp: timestamp, + bool: bool, + int: int, + merge: merge, + omap: omap, + seq: seq, + str: str +}; + +// Removed functions from JS-YAML 3.0.x +var safeLoad = renamed('safeLoad', 'load'); +var safeLoadAll = renamed('safeLoadAll', 'loadAll'); +var safeDump = renamed('safeDump', 'dump'); + +var jsYaml = { + Type: Type, + Schema: Schema, + FAILSAFE_SCHEMA: FAILSAFE_SCHEMA, + JSON_SCHEMA: JSON_SCHEMA, + CORE_SCHEMA: CORE_SCHEMA, + DEFAULT_SCHEMA: DEFAULT_SCHEMA, + load: load, + loadAll: loadAll, + dump: dump, + YAMLException: YAMLException, + types: types, + safeLoad: safeLoad, + safeLoadAll: safeLoadAll, + safeDump: safeDump +}; + +export default jsYaml; +export { CORE_SCHEMA, DEFAULT_SCHEMA, FAILSAFE_SCHEMA, JSON_SCHEMA, Schema, Type, YAMLException, dump, load, loadAll, safeDump, safeLoad, safeLoadAll, types }; diff --git a/action/node_modules/js-yaml/index.js b/action/node_modules/js-yaml/index.js new file mode 100644 index 000000000..bcb7eba7a --- /dev/null +++ b/action/node_modules/js-yaml/index.js @@ -0,0 +1,47 @@ +'use strict'; + + +var loader = require('./lib/loader'); +var dumper = require('./lib/dumper'); + + +function renamed(from, to) { + return function () { + throw new Error('Function yaml.' + from + ' is removed in js-yaml 4. ' + + 'Use yaml.' + to + ' instead, which is now safe by default.'); + }; +} + + +module.exports.Type = require('./lib/type'); +module.exports.Schema = require('./lib/schema'); +module.exports.FAILSAFE_SCHEMA = require('./lib/schema/failsafe'); +module.exports.JSON_SCHEMA = require('./lib/schema/json'); +module.exports.CORE_SCHEMA = require('./lib/schema/core'); +module.exports.DEFAULT_SCHEMA = require('./lib/schema/default'); +module.exports.load = loader.load; +module.exports.loadAll = loader.loadAll; +module.exports.dump = dumper.dump; +module.exports.YAMLException = require('./lib/exception'); + +// Re-export all types in case user wants to create custom schema +module.exports.types = { + binary: require('./lib/type/binary'), + float: require('./lib/type/float'), + map: require('./lib/type/map'), + null: require('./lib/type/null'), + pairs: require('./lib/type/pairs'), + set: require('./lib/type/set'), + timestamp: require('./lib/type/timestamp'), + bool: require('./lib/type/bool'), + int: require('./lib/type/int'), + merge: require('./lib/type/merge'), + omap: require('./lib/type/omap'), + seq: require('./lib/type/seq'), + str: require('./lib/type/str') +}; + +// Removed functions from JS-YAML 3.0.x +module.exports.safeLoad = renamed('safeLoad', 'load'); +module.exports.safeLoadAll = renamed('safeLoadAll', 'loadAll'); +module.exports.safeDump = renamed('safeDump', 'dump'); diff --git a/action/node_modules/js-yaml/lib/common.js b/action/node_modules/js-yaml/lib/common.js new file mode 100644 index 000000000..25ef7d8e4 --- /dev/null +++ b/action/node_modules/js-yaml/lib/common.js @@ -0,0 +1,59 @@ +'use strict'; + + +function isNothing(subject) { + return (typeof subject === 'undefined') || (subject === null); +} + + +function isObject(subject) { + return (typeof subject === 'object') && (subject !== null); +} + + +function toArray(sequence) { + if (Array.isArray(sequence)) return sequence; + else if (isNothing(sequence)) return []; + + return [ sequence ]; +} + + +function extend(target, source) { + var index, length, key, sourceKeys; + + if (source) { + sourceKeys = Object.keys(source); + + for (index = 0, length = sourceKeys.length; index < length; index += 1) { + key = sourceKeys[index]; + target[key] = source[key]; + } + } + + return target; +} + + +function repeat(string, count) { + var result = '', cycle; + + for (cycle = 0; cycle < count; cycle += 1) { + result += string; + } + + return result; +} + + +function isNegativeZero(number) { + return (number === 0) && (Number.NEGATIVE_INFINITY === 1 / number); +} + + +module.exports.isNothing = isNothing; +module.exports.isObject = isObject; +module.exports.toArray = toArray; +module.exports.repeat = repeat; +module.exports.isNegativeZero = isNegativeZero; +module.exports.extend = extend; diff --git a/action/node_modules/js-yaml/lib/dumper.js b/action/node_modules/js-yaml/lib/dumper.js new file mode 100644 index 000000000..f357a6aee --- /dev/null +++ b/action/node_modules/js-yaml/lib/dumper.js @@ -0,0 +1,965 @@ +'use strict'; + +/*eslint-disable no-use-before-define*/ + +var common = require('./common'); +var YAMLException = require('./exception'); +var DEFAULT_SCHEMA = require('./schema/default'); + +var _toString = Object.prototype.toString; +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +var CHAR_BOM = 0xFEFF; +var CHAR_TAB = 0x09; /* Tab */ +var CHAR_LINE_FEED = 0x0A; /* LF */ +var CHAR_CARRIAGE_RETURN = 0x0D; /* CR */ +var CHAR_SPACE = 0x20; /* Space */ +var CHAR_EXCLAMATION = 0x21; /* ! */ +var CHAR_DOUBLE_QUOTE = 0x22; /* " */ +var CHAR_SHARP = 0x23; /* # */ +var CHAR_PERCENT = 0x25; /* % */ +var CHAR_AMPERSAND = 0x26; /* & */ +var CHAR_SINGLE_QUOTE = 0x27; /* ' */ +var CHAR_ASTERISK = 0x2A; /* * */ +var CHAR_COMMA = 0x2C; /* , */ +var CHAR_MINUS = 0x2D; /* - */ +var CHAR_COLON = 0x3A; /* : */ +var CHAR_EQUALS = 0x3D; /* = */ +var CHAR_GREATER_THAN = 0x3E; /* > */ +var CHAR_QUESTION = 0x3F; /* ? */ +var CHAR_COMMERCIAL_AT = 0x40; /* @ */ +var CHAR_LEFT_SQUARE_BRACKET = 0x5B; /* [ */ +var CHAR_RIGHT_SQUARE_BRACKET = 0x5D; /* ] */ +var CHAR_GRAVE_ACCENT = 0x60; /* ` */ +var CHAR_LEFT_CURLY_BRACKET = 0x7B; /* { */ +var CHAR_VERTICAL_LINE = 0x7C; /* | */ +var CHAR_RIGHT_CURLY_BRACKET = 0x7D; /* } */ + +var ESCAPE_SEQUENCES = {}; + +ESCAPE_SEQUENCES[0x00] = '\\0'; +ESCAPE_SEQUENCES[0x07] = '\\a'; +ESCAPE_SEQUENCES[0x08] = '\\b'; +ESCAPE_SEQUENCES[0x09] = '\\t'; +ESCAPE_SEQUENCES[0x0A] = '\\n'; +ESCAPE_SEQUENCES[0x0B] = '\\v'; +ESCAPE_SEQUENCES[0x0C] = '\\f'; +ESCAPE_SEQUENCES[0x0D] = '\\r'; +ESCAPE_SEQUENCES[0x1B] = '\\e'; +ESCAPE_SEQUENCES[0x22] = '\\"'; +ESCAPE_SEQUENCES[0x5C] = '\\\\'; +ESCAPE_SEQUENCES[0x85] = '\\N'; +ESCAPE_SEQUENCES[0xA0] = '\\_'; +ESCAPE_SEQUENCES[0x2028] = '\\L'; +ESCAPE_SEQUENCES[0x2029] = '\\P'; + +var DEPRECATED_BOOLEANS_SYNTAX = [ + 'y', 'Y', 'yes', 'Yes', 'YES', 'on', 'On', 'ON', + 'n', 'N', 'no', 'No', 'NO', 'off', 'Off', 'OFF' +]; + +var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/; + +function compileStyleMap(schema, map) { + var result, keys, index, length, tag, style, type; + + if (map === null) return {}; + + result = {}; + keys = Object.keys(map); + + for (index = 0, length = keys.length; index < length; index += 1) { + tag = keys[index]; + style = String(map[tag]); + + if (tag.slice(0, 2) === '!!') { + tag = 'tag:yaml.org,2002:' + tag.slice(2); + } + type = schema.compiledTypeMap['fallback'][tag]; + + if (type && _hasOwnProperty.call(type.styleAliases, style)) { + style = type.styleAliases[style]; + } + + result[tag] = style; + } + + return result; +} + +function encodeHex(character) { + var string, handle, length; + + string = character.toString(16).toUpperCase(); + + if (character <= 0xFF) { + handle = 'x'; + length = 2; + } else if (character <= 0xFFFF) { + handle = 'u'; + length = 4; + } else if (character <= 0xFFFFFFFF) { + handle = 'U'; + length = 8; + } else { + throw new YAMLException('code point within a string may not be greater than 0xFFFFFFFF'); + } + + return '\\' + handle + common.repeat('0', length - string.length) + string; +} + + +var QUOTING_TYPE_SINGLE = 1, + QUOTING_TYPE_DOUBLE = 2; + +function State(options) { + this.schema = options['schema'] || DEFAULT_SCHEMA; + this.indent = Math.max(1, (options['indent'] || 2)); + this.noArrayIndent = options['noArrayIndent'] || false; + this.skipInvalid = options['skipInvalid'] || false; + this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']); + this.styleMap = compileStyleMap(this.schema, options['styles'] || null); + this.sortKeys = options['sortKeys'] || false; + this.lineWidth = options['lineWidth'] || 80; + this.noRefs = options['noRefs'] || false; + this.noCompatMode = options['noCompatMode'] || false; + this.condenseFlow = options['condenseFlow'] || false; + this.quotingType = options['quotingType'] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE; + this.forceQuotes = options['forceQuotes'] || false; + this.replacer = typeof options['replacer'] === 'function' ? options['replacer'] : null; + + this.implicitTypes = this.schema.compiledImplicit; + this.explicitTypes = this.schema.compiledExplicit; + + this.tag = null; + this.result = ''; + + this.duplicates = []; + this.usedDuplicates = null; +} + +// Indents every line in a string. Empty lines (\n only) are not indented. +function indentString(string, spaces) { + var ind = common.repeat(' ', spaces), + position = 0, + next = -1, + result = '', + line, + length = string.length; + + while (position < length) { + next = string.indexOf('\n', position); + if (next === -1) { + line = string.slice(position); + position = length; + } else { + line = string.slice(position, next + 1); + position = next + 1; + } + + if (line.length && line !== '\n') result += ind; + + result += line; + } + + return result; +} + +function generateNextLine(state, level) { + return '\n' + common.repeat(' ', state.indent * level); +} + +function testImplicitResolving(state, str) { + var index, length, type; + + for (index = 0, length = state.implicitTypes.length; index < length; index += 1) { + type = state.implicitTypes[index]; + + if (type.resolve(str)) { + return true; + } + } + + return false; +} + +// [33] s-white ::= s-space | s-tab +function isWhitespace(c) { + return c === CHAR_SPACE || c === CHAR_TAB; +} + +// Returns true if the character can be printed without escaping. +// From YAML 1.2: "any allowed characters known to be non-printable +// should also be escaped. [However,] This isn’t mandatory" +// Derived from nb-char - \t - #x85 - #xA0 - #x2028 - #x2029. +function isPrintable(c) { + return (0x00020 <= c && c <= 0x00007E) + || ((0x000A1 <= c && c <= 0x00D7FF) && c !== 0x2028 && c !== 0x2029) + || ((0x0E000 <= c && c <= 0x00FFFD) && c !== CHAR_BOM) + || (0x10000 <= c && c <= 0x10FFFF); +} + +// [34] ns-char ::= nb-char - s-white +// [27] nb-char ::= c-printable - b-char - c-byte-order-mark +// [26] b-char ::= b-line-feed | b-carriage-return +// Including s-white (for some reason, examples doesn't match specs in this aspect) +// ns-char ::= c-printable - b-line-feed - b-carriage-return - c-byte-order-mark +function isNsCharOrWhitespace(c) { + return isPrintable(c) + && c !== CHAR_BOM + // - b-char + && c !== CHAR_CARRIAGE_RETURN + && c !== CHAR_LINE_FEED; +} + +// [127] ns-plain-safe(c) ::= c = flow-out ⇒ ns-plain-safe-out +// c = flow-in ⇒ ns-plain-safe-in +// c = block-key ⇒ ns-plain-safe-out +// c = flow-key ⇒ ns-plain-safe-in +// [128] ns-plain-safe-out ::= ns-char +// [129] ns-plain-safe-in ::= ns-char - c-flow-indicator +// [130] ns-plain-char(c) ::= ( ns-plain-safe(c) - “:” - “#” ) +// | ( /* An ns-char preceding */ “#” ) +// | ( “:” /* Followed by an ns-plain-safe(c) */ ) +function isPlainSafe(c, prev, inblock) { + var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c); + var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c); + return ( + // ns-plain-safe + inblock ? // c = flow-in + cIsNsCharOrWhitespace + : cIsNsCharOrWhitespace + // - c-flow-indicator + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + ) + // ns-plain-char + && c !== CHAR_SHARP // false on '#' + && !(prev === CHAR_COLON && !cIsNsChar) // false on ': ' + || (isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP) // change to true on '[^ ]#' + || (prev === CHAR_COLON && cIsNsChar); // change to true on ':[^ ]' +} + +// Simplified test for values allowed as the first character in plain style. +function isPlainSafeFirst(c) { + // Uses a subset of ns-char - c-indicator + // where ns-char = nb-char - s-white. + // No support of ( ( “?” | “:” | “-” ) /* Followed by an ns-plain-safe(c)) */ ) part + return isPrintable(c) && c !== CHAR_BOM + && !isWhitespace(c) // - s-white + // - (c-indicator ::= + // “-” | “?” | “:” | “,” | “[” | “]” | “{” | “}” + && c !== CHAR_MINUS + && c !== CHAR_QUESTION + && c !== CHAR_COLON + && c !== CHAR_COMMA + && c !== CHAR_LEFT_SQUARE_BRACKET + && c !== CHAR_RIGHT_SQUARE_BRACKET + && c !== CHAR_LEFT_CURLY_BRACKET + && c !== CHAR_RIGHT_CURLY_BRACKET + // | “#” | “&” | “*” | “!” | “|” | “=” | “>” | “'” | “"” + && c !== CHAR_SHARP + && c !== CHAR_AMPERSAND + && c !== CHAR_ASTERISK + && c !== CHAR_EXCLAMATION + && c !== CHAR_VERTICAL_LINE + && c !== CHAR_EQUALS + && c !== CHAR_GREATER_THAN + && c !== CHAR_SINGLE_QUOTE + && c !== CHAR_DOUBLE_QUOTE + // | “%” | “@” | “`”) + && c !== CHAR_PERCENT + && c !== CHAR_COMMERCIAL_AT + && c !== CHAR_GRAVE_ACCENT; +} + +// Simplified test for values allowed as the last character in plain style. +function isPlainSafeLast(c) { + // just not whitespace or colon, it will be checked to be plain character later + return !isWhitespace(c) && c !== CHAR_COLON; +} + +// Same as 'string'.codePointAt(pos), but works in older browsers. +function codePointAt(string, pos) { + var first = string.charCodeAt(pos), second; + if (first >= 0xD800 && first <= 0xDBFF && pos + 1 < string.length) { + second = string.charCodeAt(pos + 1); + if (second >= 0xDC00 && second <= 0xDFFF) { + // https://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae + return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; + } + } + return first; +} + +// Determines whether block indentation indicator is required. +function needIndentIndicator(string) { + var leadingSpaceRe = /^\n* /; + return leadingSpaceRe.test(string); +} + +var STYLE_PLAIN = 1, + STYLE_SINGLE = 2, + STYLE_LITERAL = 3, + STYLE_FOLDED = 4, + STYLE_DOUBLE = 5; + +// Determines which scalar styles are possible and returns the preferred style. +// lineWidth = -1 => no limit. +// Pre-conditions: str.length > 0. +// Post-conditions: +// STYLE_PLAIN or STYLE_SINGLE => no \n are in the string. +// STYLE_LITERAL => no lines are suitable for folding (or lineWidth is -1). +// STYLE_FOLDED => a line > lineWidth and can be folded (and lineWidth != -1). +function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, + testAmbiguousType, quotingType, forceQuotes, inblock) { + + var i; + var char = 0; + var prevChar = null; + var hasLineBreak = false; + var hasFoldableLine = false; // only checked if shouldTrackWidth + var shouldTrackWidth = lineWidth !== -1; + var previousLineBreak = -1; // count the first line correctly + var plain = isPlainSafeFirst(codePointAt(string, 0)) + && isPlainSafeLast(codePointAt(string, string.length - 1)); + + if (singleLineOnly || forceQuotes) { + // Case: no block styles. + // Check for disallowed characters to rule out plain and single. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + } else { + // Case: block styles permitted. + for (i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + if (char === CHAR_LINE_FEED) { + hasLineBreak = true; + // Check if any line can be folded. + if (shouldTrackWidth) { + hasFoldableLine = hasFoldableLine || + // Foldable line = too long, and not more-indented. + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' '); + previousLineBreak = i; + } + } else if (!isPrintable(char)) { + return STYLE_DOUBLE; + } + plain = plain && isPlainSafe(char, prevChar, inblock); + prevChar = char; + } + // in case the end is missing a \n + hasFoldableLine = hasFoldableLine || (shouldTrackWidth && + (i - previousLineBreak - 1 > lineWidth && + string[previousLineBreak + 1] !== ' ')); + } + // Although every style can represent \n without escaping, prefer block styles + // for multiline, since they're more readable and they don't add empty lines. + // Also prefer folding a super-long line. + if (!hasLineBreak && !hasFoldableLine) { + // Strings interpretable as another type have to be quoted; + // e.g. the string 'true' vs. the boolean true. + if (plain && !forceQuotes && !testAmbiguousType(string)) { + return STYLE_PLAIN; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; + } + // Edge case: block indentation indicator can only have one digit. + if (indentPerLevel > 9 && needIndentIndicator(string)) { + return STYLE_DOUBLE; + } + // At this point we know block styles are valid. + // Prefer literal style unless we want to fold. + if (!forceQuotes) { + return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL; + } + return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE; +} + +// Note: line breaking/folding is implemented for only the folded style. +// NB. We drop the last trailing newline (if any) of a returned block scalar +// since the dumper adds its own newline. This always works: +// • No ending newline => unaffected; already using strip "-" chomping. +// • Ending newline => removed then restored. +// Importantly, this keeps the "+" chomp indicator from gaining an extra line. +function writeScalar(state, string, level, iskey, inblock) { + state.dump = (function () { + if (string.length === 0) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''"; + } + if (!state.noCompatMode) { + if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) { + return state.quotingType === QUOTING_TYPE_DOUBLE ? ('"' + string + '"') : ("'" + string + "'"); + } + } + + var indent = state.indent * Math.max(1, level); // no 0-indent scalars + // As indentation gets deeper, let the width decrease monotonically + // to the lower bound min(state.lineWidth, 40). + // Note that this implies + // state.lineWidth ≤ 40 + state.indent: width is fixed at the lower bound. + // state.lineWidth > 40 + state.indent: width decreases until the lower bound. + // This behaves better than a constant minimum width which disallows narrower options, + // or an indent threshold which causes the width to suddenly increase. + var lineWidth = state.lineWidth === -1 + ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent); + + // Without knowing if keys are implicit/explicit, assume implicit for safety. + var singleLineOnly = iskey + // No block styles in flow mode. + || (state.flowLevel > -1 && level >= state.flowLevel); + function testAmbiguity(string) { + return testImplicitResolving(state, string); + } + + switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, + testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) { + + case STYLE_PLAIN: + return string; + case STYLE_SINGLE: + return "'" + string.replace(/'/g, "''") + "'"; + case STYLE_LITERAL: + return '|' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(string, indent)); + case STYLE_FOLDED: + return '>' + blockHeader(string, state.indent) + + dropEndingNewline(indentString(foldString(string, lineWidth), indent)); + case STYLE_DOUBLE: + return '"' + escapeString(string, lineWidth) + '"'; + default: + throw new YAMLException('impossible error: invalid scalar style'); + } + }()); +} + +// Pre-conditions: string is valid for a block scalar, 1 <= indentPerLevel <= 9. +function blockHeader(string, indentPerLevel) { + var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : ''; + + // note the special case: the string '\n' counts as a "trailing" empty line. + var clip = string[string.length - 1] === '\n'; + var keep = clip && (string[string.length - 2] === '\n' || string === '\n'); + var chomp = keep ? '+' : (clip ? '' : '-'); + + return indentIndicator + chomp + '\n'; +} + +// (See the note for writeScalar.) +function dropEndingNewline(string) { + return string[string.length - 1] === '\n' ? string.slice(0, -1) : string; +} + +// Note: a long line without a suitable break point will exceed the width limit. +// Pre-conditions: every char in str isPrintable, str.length > 0, width > 0. +function foldString(string, width) { + // In folded style, $k$ consecutive newlines output as $k+1$ newlines— + // unless they're before or after a more-indented line, or at the very + // beginning or end, in which case $k$ maps to $k$. + // Therefore, parse each chunk as newline(s) followed by a content line. + var lineRe = /(\n+)([^\n]*)/g; + + // first line (possibly an empty line) + var result = (function () { + var nextLF = string.indexOf('\n'); + nextLF = nextLF !== -1 ? nextLF : string.length; + lineRe.lastIndex = nextLF; + return foldLine(string.slice(0, nextLF), width); + }()); + // If we haven't reached the first content line yet, don't add an extra \n. + var prevMoreIndented = string[0] === '\n' || string[0] === ' '; + var moreIndented; + + // rest of the lines + var match; + while ((match = lineRe.exec(string))) { + var prefix = match[1], line = match[2]; + moreIndented = (line[0] === ' '); + result += prefix + + (!prevMoreIndented && !moreIndented && line !== '' + ? '\n' : '') + + foldLine(line, width); + prevMoreIndented = moreIndented; + } + + return result; +} + +// Greedy line breaking. +// Picks the longest line under the limit each time, +// otherwise settles for the shortest line over the limit. +// NB. More-indented lines *cannot* be folded, as that would add an extra \n. +function foldLine(line, width) { + if (line === '' || line[0] === ' ') return line; + + // Since a more-indented line adds a \n, breaks can't be followed by a space. + var breakRe = / [^ ]/g; // note: the match index will always be <= length-2. + var match; + // start is an inclusive index. end, curr, and next are exclusive. + var start = 0, end, curr = 0, next = 0; + var result = ''; + + // Invariants: 0 <= start <= length-1. + // 0 <= curr <= next <= max(0, length-2). curr - start <= width. + // Inside the loop: + // A match implies length >= 2, so curr and next are <= length-2. + while ((match = breakRe.exec(line))) { + next = match.index; + // maintain invariant: curr - start <= width + if (next - start > width) { + end = (curr > start) ? curr : next; // derive end <= length-2 + result += '\n' + line.slice(start, end); + // skip the space that was output as \n + start = end + 1; // derive start <= length-1 + } + curr = next; + } + + // By the invariants, start <= length-1, so there is something left over. + // It is either the whole string or a part starting from non-whitespace. + result += '\n'; + // Insert a break if the remainder is too long and there is a break available. + if (line.length - start > width && curr > start) { + result += line.slice(start, curr) + '\n' + line.slice(curr + 1); + } else { + result += line.slice(start); + } + + return result.slice(1); // drop extra \n joiner +} + +// Escapes a double-quoted string. +function escapeString(string) { + var result = ''; + var char = 0; + var escapeSeq; + + for (var i = 0; i < string.length; char >= 0x10000 ? i += 2 : i++) { + char = codePointAt(string, i); + escapeSeq = ESCAPE_SEQUENCES[char]; + + if (!escapeSeq && isPrintable(char)) { + result += string[i]; + if (char >= 0x10000) result += string[i + 1]; + } else { + result += escapeSeq || encodeHex(char); + } + } + + return result; +} + +function writeFlowSequence(state, level, object) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level, value, false, false) || + (typeof value === 'undefined' && + writeNode(state, level, null, false, false))) { + + if (_result !== '') _result += ',' + (!state.condenseFlow ? ' ' : ''); + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = '[' + _result + ']'; +} + +function writeBlockSequence(state, level, object, compact) { + var _result = '', + _tag = state.tag, + index, + length, + value; + + for (index = 0, length = object.length; index < length; index += 1) { + value = object[index]; + + if (state.replacer) { + value = state.replacer.call(object, String(index), value); + } + + // Write only valid elements, put null instead of invalid elements. + if (writeNode(state, level + 1, value, true, true, false, true) || + (typeof value === 'undefined' && + writeNode(state, level + 1, null, true, true, false, true))) { + + if (!compact || _result !== '') { + _result += generateNextLine(state, level); + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + _result += '-'; + } else { + _result += '- '; + } + + _result += state.dump; + } + } + + state.tag = _tag; + state.dump = _result || '[]'; // Empty sequence if no valid values. +} + +function writeFlowMapping(state, level, object) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + pairBuffer; + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + + pairBuffer = ''; + if (_result !== '') pairBuffer += ', '; + + if (state.condenseFlow) pairBuffer += '"'; + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level, objectKey, false, false)) { + continue; // Skip this pair because of invalid key; + } + + if (state.dump.length > 1024) pairBuffer += '? '; + + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); + + if (!writeNode(state, level, objectValue, false, false)) { + continue; // Skip this pair because of invalid value. + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = '{' + _result + '}'; +} + +function writeBlockMapping(state, level, object, compact) { + var _result = '', + _tag = state.tag, + objectKeyList = Object.keys(object), + index, + length, + objectKey, + objectValue, + explicitPair, + pairBuffer; + + // Allow sorting keys so that the output file is deterministic + if (state.sortKeys === true) { + // Default sorting + objectKeyList.sort(); + } else if (typeof state.sortKeys === 'function') { + // Custom sort function + objectKeyList.sort(state.sortKeys); + } else if (state.sortKeys) { + // Something is wrong + throw new YAMLException('sortKeys must be a boolean or a function'); + } + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + pairBuffer = ''; + + if (!compact || _result !== '') { + pairBuffer += generateNextLine(state, level); + } + + objectKey = objectKeyList[index]; + objectValue = object[objectKey]; + + if (state.replacer) { + objectValue = state.replacer.call(object, objectKey, objectValue); + } + + if (!writeNode(state, level + 1, objectKey, true, true, true)) { + continue; // Skip this pair because of invalid key. + } + + explicitPair = (state.tag !== null && state.tag !== '?') || + (state.dump && state.dump.length > 1024); + + if (explicitPair) { + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += '?'; + } else { + pairBuffer += '? '; + } + } + + pairBuffer += state.dump; + + if (explicitPair) { + pairBuffer += generateNextLine(state, level); + } + + if (!writeNode(state, level + 1, objectValue, true, explicitPair)) { + continue; // Skip this pair because of invalid value. + } + + if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) { + pairBuffer += ':'; + } else { + pairBuffer += ': '; + } + + pairBuffer += state.dump; + + // Both key and value are valid. + _result += pairBuffer; + } + + state.tag = _tag; + state.dump = _result || '{}'; // Empty mapping if no valid pairs. +} + +function detectType(state, object, explicit) { + var _result, typeList, index, length, type, style; + + typeList = explicit ? state.explicitTypes : state.implicitTypes; + + for (index = 0, length = typeList.length; index < length; index += 1) { + type = typeList[index]; + + if ((type.instanceOf || type.predicate) && + (!type.instanceOf || ((typeof object === 'object') && (object instanceof type.instanceOf))) && + (!type.predicate || type.predicate(object))) { + + if (explicit) { + if (type.multi && type.representName) { + state.tag = type.representName(object); + } else { + state.tag = type.tag; + } + } else { + state.tag = '?'; + } + + if (type.represent) { + style = state.styleMap[type.tag] || type.defaultStyle; + + if (_toString.call(type.represent) === '[object Function]') { + _result = type.represent(object, style); + } else if (_hasOwnProperty.call(type.represent, style)) { + _result = type.represent[style](object, style); + } else { + throw new YAMLException('!<' + type.tag + '> tag resolver accepts not "' + style + '" style'); + } + + state.dump = _result; + } + + return true; + } + } + + return false; +} + +// Serializes `object` and writes it to global `result`. +// Returns true on success, or false on invalid object. +// +function writeNode(state, level, object, block, compact, iskey, isblockseq) { + state.tag = null; + state.dump = object; + + if (!detectType(state, object, false)) { + detectType(state, object, true); + } + + var type = _toString.call(state.dump); + var inblock = block; + var tagStr; + + if (block) { + block = (state.flowLevel < 0 || state.flowLevel > level); + } + + var objectOrArray = type === '[object Object]' || type === '[object Array]', + duplicateIndex, + duplicate; + + if (objectOrArray) { + duplicateIndex = state.duplicates.indexOf(object); + duplicate = duplicateIndex !== -1; + } + + if ((state.tag !== null && state.tag !== '?') || duplicate || (state.indent !== 2 && level > 0)) { + compact = false; + } + + if (duplicate && state.usedDuplicates[duplicateIndex]) { + state.dump = '*ref_' + duplicateIndex; + } else { + if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) { + state.usedDuplicates[duplicateIndex] = true; + } + if (type === '[object Object]') { + if (block && (Object.keys(state.dump).length !== 0)) { + writeBlockMapping(state, level, state.dump, compact); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowMapping(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object Array]') { + if (block && (state.dump.length !== 0)) { + if (state.noArrayIndent && !isblockseq && level > 0) { + writeBlockSequence(state, level - 1, state.dump, compact); + } else { + writeBlockSequence(state, level, state.dump, compact); + } + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + state.dump; + } + } else { + writeFlowSequence(state, level, state.dump); + if (duplicate) { + state.dump = '&ref_' + duplicateIndex + ' ' + state.dump; + } + } + } else if (type === '[object String]') { + if (state.tag !== '?') { + writeScalar(state, state.dump, level, iskey, inblock); + } + } else if (type === '[object Undefined]') { + return false; + } else { + if (state.skipInvalid) return false; + throw new YAMLException('unacceptable kind of an object to dump ' + type); + } + + if (state.tag !== null && state.tag !== '?') { + // Need to encode all characters except those allowed by the spec: + // + // [35] ns-dec-digit ::= [#x30-#x39] /* 0-9 */ + // [36] ns-hex-digit ::= ns-dec-digit + // | [#x41-#x46] /* A-F */ | [#x61-#x66] /* a-f */ + // [37] ns-ascii-letter ::= [#x41-#x5A] /* A-Z */ | [#x61-#x7A] /* a-z */ + // [38] ns-word-char ::= ns-dec-digit | ns-ascii-letter | “-” + // [39] ns-uri-char ::= “%” ns-hex-digit ns-hex-digit | ns-word-char | “#” + // | “;” | “/” | “?” | “:” | “@” | “&” | “=” | “+” | “$” | “,” + // | “_” | “.” | “!” | “~” | “*” | “'” | “(” | “)” | “[” | “]” + // + // Also need to encode '!' because it has special meaning (end of tag prefix). + // + tagStr = encodeURI( + state.tag[0] === '!' ? state.tag.slice(1) : state.tag + ).replace(/!/g, '%21'); + + if (state.tag[0] === '!') { + tagStr = '!' + tagStr; + } else if (tagStr.slice(0, 18) === 'tag:yaml.org,2002:') { + tagStr = '!!' + tagStr.slice(18); + } else { + tagStr = '!<' + tagStr + '>'; + } + + state.dump = tagStr + ' ' + state.dump; + } + } + + return true; +} + +function getDuplicateReferences(object, state) { + var objects = [], + duplicatesIndexes = [], + index, + length; + + inspectNode(object, objects, duplicatesIndexes); + + for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) { + state.duplicates.push(objects[duplicatesIndexes[index]]); + } + state.usedDuplicates = new Array(length); +} + +function inspectNode(object, objects, duplicatesIndexes) { + var objectKeyList, + index, + length; + + if (object !== null && typeof object === 'object') { + index = objects.indexOf(object); + if (index !== -1) { + if (duplicatesIndexes.indexOf(index) === -1) { + duplicatesIndexes.push(index); + } + } else { + objects.push(object); + + if (Array.isArray(object)) { + for (index = 0, length = object.length; index < length; index += 1) { + inspectNode(object[index], objects, duplicatesIndexes); + } + } else { + objectKeyList = Object.keys(object); + + for (index = 0, length = objectKeyList.length; index < length; index += 1) { + inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes); + } + } + } + } +} + +function dump(input, options) { + options = options || {}; + + var state = new State(options); + + if (!state.noRefs) getDuplicateReferences(input, state); + + var value = input; + + if (state.replacer) { + value = state.replacer.call({ '': value }, '', value); + } + + if (writeNode(state, 0, value, true, true)) return state.dump + '\n'; + + return ''; +} + +module.exports.dump = dump; diff --git a/action/node_modules/js-yaml/lib/exception.js b/action/node_modules/js-yaml/lib/exception.js new file mode 100644 index 000000000..7f62daaef --- /dev/null +++ b/action/node_modules/js-yaml/lib/exception.js @@ -0,0 +1,55 @@ +// YAML error class. http://stackoverflow.com/questions/8458984 +// +'use strict'; + + +function formatError(exception, compact) { + var where = '', message = exception.reason || '(unknown reason)'; + + if (!exception.mark) return message; + + if (exception.mark.name) { + where += 'in "' + exception.mark.name + '" '; + } + + where += '(' + (exception.mark.line + 1) + ':' + (exception.mark.column + 1) + ')'; + + if (!compact && exception.mark.snippet) { + where += '\n\n' + exception.mark.snippet; + } + + return message + ' ' + where; +} + + +function YAMLException(reason, mark) { + // Super constructor + Error.call(this); + + this.name = 'YAMLException'; + this.reason = reason; + this.mark = mark; + this.message = formatError(this, false); + + // Include stack trace in error object + if (Error.captureStackTrace) { + // Chrome and NodeJS + Error.captureStackTrace(this, this.constructor); + } else { + // FF, IE 10+ and Safari 6+. Fallback for others + this.stack = (new Error()).stack || ''; + } +} + + +// Inherit from Error +YAMLException.prototype = Object.create(Error.prototype); +YAMLException.prototype.constructor = YAMLException; + + +YAMLException.prototype.toString = function toString(compact) { + return this.name + ': ' + formatError(this, compact); +}; + + +module.exports = YAMLException; diff --git a/action/node_modules/js-yaml/lib/loader.js b/action/node_modules/js-yaml/lib/loader.js new file mode 100644 index 000000000..39f13f561 --- /dev/null +++ b/action/node_modules/js-yaml/lib/loader.js @@ -0,0 +1,1727 @@ +'use strict'; + +/*eslint-disable max-len,no-use-before-define*/ + +var common = require('./common'); +var YAMLException = require('./exception'); +var makeSnippet = require('./snippet'); +var DEFAULT_SCHEMA = require('./schema/default'); + + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + + +var CONTEXT_FLOW_IN = 1; +var CONTEXT_FLOW_OUT = 2; +var CONTEXT_BLOCK_IN = 3; +var CONTEXT_BLOCK_OUT = 4; + + +var CHOMPING_CLIP = 1; +var CHOMPING_STRIP = 2; +var CHOMPING_KEEP = 3; + + +var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/; +var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/; +var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/; +var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i; +var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i; + + +function _class(obj) { return Object.prototype.toString.call(obj); } + +function is_EOL(c) { + return (c === 0x0A/* LF */) || (c === 0x0D/* CR */); +} + +function is_WHITE_SPACE(c) { + return (c === 0x09/* Tab */) || (c === 0x20/* Space */); +} + +function is_WS_OR_EOL(c) { + return (c === 0x09/* Tab */) || + (c === 0x20/* Space */) || + (c === 0x0A/* LF */) || + (c === 0x0D/* CR */); +} + +function is_FLOW_INDICATOR(c) { + return c === 0x2C/* , */ || + c === 0x5B/* [ */ || + c === 0x5D/* ] */ || + c === 0x7B/* { */ || + c === 0x7D/* } */; +} + +function fromHexCode(c) { + var lc; + + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + /*eslint-disable no-bitwise*/ + lc = c | 0x20; + + if ((0x61/* a */ <= lc) && (lc <= 0x66/* f */)) { + return lc - 0x61 + 10; + } + + return -1; +} + +function escapedHexLen(c) { + if (c === 0x78/* x */) { return 2; } + if (c === 0x75/* u */) { return 4; } + if (c === 0x55/* U */) { return 8; } + return 0; +} + +function fromDecimalCode(c) { + if ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) { + return c - 0x30; + } + + return -1; +} + +function simpleEscapeSequence(c) { + /* eslint-disable indent */ + return (c === 0x30/* 0 */) ? '\x00' : + (c === 0x61/* a */) ? '\x07' : + (c === 0x62/* b */) ? '\x08' : + (c === 0x74/* t */) ? '\x09' : + (c === 0x09/* Tab */) ? '\x09' : + (c === 0x6E/* n */) ? '\x0A' : + (c === 0x76/* v */) ? '\x0B' : + (c === 0x66/* f */) ? '\x0C' : + (c === 0x72/* r */) ? '\x0D' : + (c === 0x65/* e */) ? '\x1B' : + (c === 0x20/* Space */) ? ' ' : + (c === 0x22/* " */) ? '\x22' : + (c === 0x2F/* / */) ? '/' : + (c === 0x5C/* \ */) ? '\x5C' : + (c === 0x4E/* N */) ? '\x85' : + (c === 0x5F/* _ */) ? '\xA0' : + (c === 0x4C/* L */) ? '\u2028' : + (c === 0x50/* P */) ? '\u2029' : ''; +} + +function charFromCodepoint(c) { + if (c <= 0xFFFF) { + return String.fromCharCode(c); + } + // Encode UTF-16 surrogate pair + // https://en.wikipedia.org/wiki/UTF-16#Code_points_U.2B010000_to_U.2B10FFFF + return String.fromCharCode( + ((c - 0x010000) >> 10) + 0xD800, + ((c - 0x010000) & 0x03FF) + 0xDC00 + ); +} + +var simpleEscapeCheck = new Array(256); // integer, for fast access +var simpleEscapeMap = new Array(256); +for (var i = 0; i < 256; i++) { + simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0; + simpleEscapeMap[i] = simpleEscapeSequence(i); +} + + +function State(input, options) { + this.input = input; + + this.filename = options['filename'] || null; + this.schema = options['schema'] || DEFAULT_SCHEMA; + this.onWarning = options['onWarning'] || null; + // (Hidden) Remove? makes the loader to expect YAML 1.1 documents + // if such documents have no explicit %YAML directive + this.legacy = options['legacy'] || false; + + this.json = options['json'] || false; + this.listener = options['listener'] || null; + + this.implicitTypes = this.schema.compiledImplicit; + this.typeMap = this.schema.compiledTypeMap; + + this.length = input.length; + this.position = 0; + this.line = 0; + this.lineStart = 0; + this.lineIndent = 0; + + // position of first leading tab in the current line, + // used to make sure there are no tabs in the indentation + this.firstTabInLine = -1; + + this.documents = []; + + /* + this.version; + this.checkLineBreaks; + this.tagMap; + this.anchorMap; + this.tag; + this.anchor; + this.kind; + this.result;*/ + +} + + +function generateError(state, message) { + var mark = { + name: state.filename, + buffer: state.input.slice(0, -1), // omit trailing \0 + position: state.position, + line: state.line, + column: state.position - state.lineStart + }; + + mark.snippet = makeSnippet(mark); + + return new YAMLException(message, mark); +} + +function throwError(state, message) { + throw generateError(state, message); +} + +function throwWarning(state, message) { + if (state.onWarning) { + state.onWarning.call(null, generateError(state, message)); + } +} + + +var directiveHandlers = { + + YAML: function handleYamlDirective(state, name, args) { + + var match, major, minor; + + if (state.version !== null) { + throwError(state, 'duplication of %YAML directive'); + } + + if (args.length !== 1) { + throwError(state, 'YAML directive accepts exactly one argument'); + } + + match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]); + + if (match === null) { + throwError(state, 'ill-formed argument of the YAML directive'); + } + + major = parseInt(match[1], 10); + minor = parseInt(match[2], 10); + + if (major !== 1) { + throwError(state, 'unacceptable YAML version of the document'); + } + + state.version = args[0]; + state.checkLineBreaks = (minor < 2); + + if (minor !== 1 && minor !== 2) { + throwWarning(state, 'unsupported YAML version of the document'); + } + }, + + TAG: function handleTagDirective(state, name, args) { + + var handle, prefix; + + if (args.length !== 2) { + throwError(state, 'TAG directive accepts exactly two arguments'); + } + + handle = args[0]; + prefix = args[1]; + + if (!PATTERN_TAG_HANDLE.test(handle)) { + throwError(state, 'ill-formed tag handle (first argument) of the TAG directive'); + } + + if (_hasOwnProperty.call(state.tagMap, handle)) { + throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle'); + } + + if (!PATTERN_TAG_URI.test(prefix)) { + throwError(state, 'ill-formed tag prefix (second argument) of the TAG directive'); + } + + try { + prefix = decodeURIComponent(prefix); + } catch (err) { + throwError(state, 'tag prefix is malformed: ' + prefix); + } + + state.tagMap[handle] = prefix; + } +}; + + +function captureSegment(state, start, end, checkJson) { + var _position, _length, _character, _result; + + if (start < end) { + _result = state.input.slice(start, end); + + if (checkJson) { + for (_position = 0, _length = _result.length; _position < _length; _position += 1) { + _character = _result.charCodeAt(_position); + if (!(_character === 0x09 || + (0x20 <= _character && _character <= 0x10FFFF))) { + throwError(state, 'expected valid JSON character'); + } + } + } else if (PATTERN_NON_PRINTABLE.test(_result)) { + throwError(state, 'the stream contains non-printable characters'); + } + + state.result += _result; + } +} + +function mergeMappings(state, destination, source, overridableKeys) { + var sourceKeys, key, index, quantity; + + if (!common.isObject(source)) { + throwError(state, 'cannot merge mappings; the provided source object is unacceptable'); + } + + sourceKeys = Object.keys(source); + + for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) { + key = sourceKeys[index]; + + if (!_hasOwnProperty.call(destination, key)) { + destination[key] = source[key]; + overridableKeys[key] = true; + } + } +} + +function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, + startLine, startLineStart, startPos) { + + var index, quantity; + + // The output is a plain object here, so keys can only be strings. + // We need to convert keyNode to a string, but doing so can hang the process + // (deeply nested arrays that explode exponentially using aliases). + if (Array.isArray(keyNode)) { + keyNode = Array.prototype.slice.call(keyNode); + + for (index = 0, quantity = keyNode.length; index < quantity; index += 1) { + if (Array.isArray(keyNode[index])) { + throwError(state, 'nested arrays are not supported inside keys'); + } + + if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') { + keyNode[index] = '[object Object]'; + } + } + } + + // Avoid code execution in load() via toString property + // (still use its own toString for arrays, timestamps, + // and whatever user schema extensions happen to have @@toStringTag) + if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') { + keyNode = '[object Object]'; + } + + + keyNode = String(keyNode); + + if (_result === null) { + _result = {}; + } + + if (keyTag === 'tag:yaml.org,2002:merge') { + if (Array.isArray(valueNode)) { + for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { + mergeMappings(state, _result, valueNode[index], overridableKeys); + } + } else { + mergeMappings(state, _result, valueNode, overridableKeys); + } + } else { + if (!state.json && + !_hasOwnProperty.call(overridableKeys, keyNode) && + _hasOwnProperty.call(_result, keyNode)) { + state.line = startLine || state.line; + state.lineStart = startLineStart || state.lineStart; + state.position = startPos || state.position; + throwError(state, 'duplicated mapping key'); + } + + // used for this specific key only because Object.defineProperty is slow + if (keyNode === '__proto__') { + Object.defineProperty(_result, keyNode, { + configurable: true, + enumerable: true, + writable: true, + value: valueNode + }); + } else { + _result[keyNode] = valueNode; + } + delete overridableKeys[keyNode]; + } + + return _result; +} + +function readLineBreak(state) { + var ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x0A/* LF */) { + state.position++; + } else if (ch === 0x0D/* CR */) { + state.position++; + if (state.input.charCodeAt(state.position) === 0x0A/* LF */) { + state.position++; + } + } else { + throwError(state, 'a line break is expected'); + } + + state.line += 1; + state.lineStart = state.position; + state.firstTabInLine = -1; +} + +function skipSeparationSpace(state, allowComments, checkIndent) { + var lineBreaks = 0, + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + if (ch === 0x09/* Tab */ && state.firstTabInLine === -1) { + state.firstTabInLine = state.position; + } + ch = state.input.charCodeAt(++state.position); + } + + if (allowComments && ch === 0x23/* # */) { + do { + ch = state.input.charCodeAt(++state.position); + } while (ch !== 0x0A/* LF */ && ch !== 0x0D/* CR */ && ch !== 0); + } + + if (is_EOL(ch)) { + readLineBreak(state); + + ch = state.input.charCodeAt(state.position); + lineBreaks++; + state.lineIndent = 0; + + while (ch === 0x20/* Space */) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + } else { + break; + } + } + + if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) { + throwWarning(state, 'deficient indentation'); + } + + return lineBreaks; +} + +function testDocumentSeparator(state) { + var _position = state.position, + ch; + + ch = state.input.charCodeAt(_position); + + // Condition state.position === state.lineStart is tested + // in parent on each call, for efficiency. No needs to test here again. + if ((ch === 0x2D/* - */ || ch === 0x2E/* . */) && + ch === state.input.charCodeAt(_position + 1) && + ch === state.input.charCodeAt(_position + 2)) { + + _position += 3; + + ch = state.input.charCodeAt(_position); + + if (ch === 0 || is_WS_OR_EOL(ch)) { + return true; + } + } + + return false; +} + +function writeFoldedLines(state, count) { + if (count === 1) { + state.result += ' '; + } else if (count > 1) { + state.result += common.repeat('\n', count - 1); + } +} + + +function readPlainScalar(state, nodeIndent, withinFlowCollection) { + var preceding, + following, + captureStart, + captureEnd, + hasPendingContent, + _line, + _lineStart, + _lineIndent, + _kind = state.kind, + _result = state.result, + ch; + + ch = state.input.charCodeAt(state.position); + + if (is_WS_OR_EOL(ch) || + is_FLOW_INDICATOR(ch) || + ch === 0x23/* # */ || + ch === 0x26/* & */ || + ch === 0x2A/* * */ || + ch === 0x21/* ! */ || + ch === 0x7C/* | */ || + ch === 0x3E/* > */ || + ch === 0x27/* ' */ || + ch === 0x22/* " */ || + ch === 0x25/* % */ || + ch === 0x40/* @ */ || + ch === 0x60/* ` */) { + return false; + } + + if (ch === 0x3F/* ? */ || ch === 0x2D/* - */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + return false; + } + } + + state.kind = 'scalar'; + state.result = ''; + captureStart = captureEnd = state.position; + hasPendingContent = false; + + while (ch !== 0) { + if (ch === 0x3A/* : */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following) || + withinFlowCollection && is_FLOW_INDICATOR(following)) { + break; + } + + } else if (ch === 0x23/* # */) { + preceding = state.input.charCodeAt(state.position - 1); + + if (is_WS_OR_EOL(preceding)) { + break; + } + + } else if ((state.position === state.lineStart && testDocumentSeparator(state)) || + withinFlowCollection && is_FLOW_INDICATOR(ch)) { + break; + + } else if (is_EOL(ch)) { + _line = state.line; + _lineStart = state.lineStart; + _lineIndent = state.lineIndent; + skipSeparationSpace(state, false, -1); + + if (state.lineIndent >= nodeIndent) { + hasPendingContent = true; + ch = state.input.charCodeAt(state.position); + continue; + } else { + state.position = captureEnd; + state.line = _line; + state.lineStart = _lineStart; + state.lineIndent = _lineIndent; + break; + } + } + + if (hasPendingContent) { + captureSegment(state, captureStart, captureEnd, false); + writeFoldedLines(state, state.line - _line); + captureStart = captureEnd = state.position; + hasPendingContent = false; + } + + if (!is_WHITE_SPACE(ch)) { + captureEnd = state.position + 1; + } + + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, captureEnd, false); + + if (state.result) { + return true; + } + + state.kind = _kind; + state.result = _result; + return false; +} + +function readSingleQuotedScalar(state, nodeIndent) { + var ch, + captureStart, captureEnd; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x27/* ' */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x27/* ' */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x27/* ' */) { + captureStart = state.position; + state.position++; + captureEnd = state.position; + } else { + return true; + } + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a single quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a single quoted scalar'); +} + +function readDoubleQuotedScalar(state, nodeIndent) { + var captureStart, + captureEnd, + hexLength, + hexResult, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x22/* " */) { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + state.position++; + captureStart = captureEnd = state.position; + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + if (ch === 0x22/* " */) { + captureSegment(state, captureStart, state.position, true); + state.position++; + return true; + + } else if (ch === 0x5C/* \ */) { + captureSegment(state, captureStart, state.position, true); + ch = state.input.charCodeAt(++state.position); + + if (is_EOL(ch)) { + skipSeparationSpace(state, false, nodeIndent); + + // TODO: rework to inline fn with no type cast? + } else if (ch < 256 && simpleEscapeCheck[ch]) { + state.result += simpleEscapeMap[ch]; + state.position++; + + } else if ((tmp = escapedHexLen(ch)) > 0) { + hexLength = tmp; + hexResult = 0; + + for (; hexLength > 0; hexLength--) { + ch = state.input.charCodeAt(++state.position); + + if ((tmp = fromHexCode(ch)) >= 0) { + hexResult = (hexResult << 4) + tmp; + + } else { + throwError(state, 'expected hexadecimal character'); + } + } + + state.result += charFromCodepoint(hexResult); + + state.position++; + + } else { + throwError(state, 'unknown escape sequence'); + } + + captureStart = captureEnd = state.position; + + } else if (is_EOL(ch)) { + captureSegment(state, captureStart, captureEnd, true); + writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent)); + captureStart = captureEnd = state.position; + + } else if (state.position === state.lineStart && testDocumentSeparator(state)) { + throwError(state, 'unexpected end of the document within a double quoted scalar'); + + } else { + state.position++; + captureEnd = state.position; + } + } + + throwError(state, 'unexpected end of the stream within a double quoted scalar'); +} + +function readFlowCollection(state, nodeIndent) { + var readNext = true, + _line, + _lineStart, + _pos, + _tag = state.tag, + _result, + _anchor = state.anchor, + following, + terminator, + isPair, + isExplicitPair, + isMapping, + overridableKeys = Object.create(null), + keyNode, + keyTag, + valueNode, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x5B/* [ */) { + terminator = 0x5D;/* ] */ + isMapping = false; + _result = []; + } else if (ch === 0x7B/* { */) { + terminator = 0x7D;/* } */ + isMapping = true; + _result = {}; + } else { + return false; + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(++state.position); + + while (ch !== 0) { + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === terminator) { + state.position++; + state.tag = _tag; + state.anchor = _anchor; + state.kind = isMapping ? 'mapping' : 'sequence'; + state.result = _result; + return true; + } else if (!readNext) { + throwError(state, 'missed comma between flow collection entries'); + } else if (ch === 0x2C/* , */) { + // "flow collection entries can never be completely empty", as per YAML 1.2, section 7.4 + throwError(state, "expected the node content, but found ','"); + } + + keyTag = keyNode = valueNode = null; + isPair = isExplicitPair = false; + + if (ch === 0x3F/* ? */) { + following = state.input.charCodeAt(state.position + 1); + + if (is_WS_OR_EOL(following)) { + isPair = isExplicitPair = true; + state.position++; + skipSeparationSpace(state, true, nodeIndent); + } + } + + _line = state.line; // Save the current line. + _lineStart = state.lineStart; + _pos = state.position; + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + keyTag = state.tag; + keyNode = state.result; + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if ((isExplicitPair || state.line === _line) && ch === 0x3A/* : */) { + isPair = true; + ch = state.input.charCodeAt(++state.position); + skipSeparationSpace(state, true, nodeIndent); + composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true); + valueNode = state.result; + } + + if (isMapping) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos); + } else if (isPair) { + _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos)); + } else { + _result.push(keyNode); + } + + skipSeparationSpace(state, true, nodeIndent); + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x2C/* , */) { + readNext = true; + ch = state.input.charCodeAt(++state.position); + } else { + readNext = false; + } + } + + throwError(state, 'unexpected end of the stream within a flow collection'); +} + +function readBlockScalar(state, nodeIndent) { + var captureStart, + folding, + chomping = CHOMPING_CLIP, + didReadContent = false, + detectedIndent = false, + textIndent = nodeIndent, + emptyLines = 0, + atMoreIndented = false, + tmp, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch === 0x7C/* | */) { + folding = false; + } else if (ch === 0x3E/* > */) { + folding = true; + } else { + return false; + } + + state.kind = 'scalar'; + state.result = ''; + + while (ch !== 0) { + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x2B/* + */ || ch === 0x2D/* - */) { + if (CHOMPING_CLIP === chomping) { + chomping = (ch === 0x2B/* + */) ? CHOMPING_KEEP : CHOMPING_STRIP; + } else { + throwError(state, 'repeat of a chomping mode identifier'); + } + + } else if ((tmp = fromDecimalCode(ch)) >= 0) { + if (tmp === 0) { + throwError(state, 'bad explicit indentation width of a block scalar; it cannot be less than one'); + } else if (!detectedIndent) { + textIndent = nodeIndent + tmp - 1; + detectedIndent = true; + } else { + throwError(state, 'repeat of an indentation width identifier'); + } + + } else { + break; + } + } + + if (is_WHITE_SPACE(ch)) { + do { ch = state.input.charCodeAt(++state.position); } + while (is_WHITE_SPACE(ch)); + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (!is_EOL(ch) && (ch !== 0)); + } + } + + while (ch !== 0) { + readLineBreak(state); + state.lineIndent = 0; + + ch = state.input.charCodeAt(state.position); + + while ((!detectedIndent || state.lineIndent < textIndent) && + (ch === 0x20/* Space */)) { + state.lineIndent++; + ch = state.input.charCodeAt(++state.position); + } + + if (!detectedIndent && state.lineIndent > textIndent) { + textIndent = state.lineIndent; + } + + if (is_EOL(ch)) { + emptyLines++; + continue; + } + + // End of the scalar. + if (state.lineIndent < textIndent) { + + // Perform the chomping. + if (chomping === CHOMPING_KEEP) { + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } else if (chomping === CHOMPING_CLIP) { + if (didReadContent) { // i.e. only if the scalar is not empty. + state.result += '\n'; + } + } + + // Break this `while` cycle and go to the funciton's epilogue. + break; + } + + // Folded style: use fancy rules to handle line breaks. + if (folding) { + + // Lines starting with white space characters (more-indented lines) are not folded. + if (is_WHITE_SPACE(ch)) { + atMoreIndented = true; + // except for the first content line (cf. Example 8.1) + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + + // End of more-indented block. + } else if (atMoreIndented) { + atMoreIndented = false; + state.result += common.repeat('\n', emptyLines + 1); + + // Just one line break - perceive as the same line. + } else if (emptyLines === 0) { + if (didReadContent) { // i.e. only if we have already read some scalar content. + state.result += ' '; + } + + // Several line breaks - perceive as different lines. + } else { + state.result += common.repeat('\n', emptyLines); + } + + // Literal style: just add exact number of line breaks between content lines. + } else { + // Keep all line breaks except the header line break. + state.result += common.repeat('\n', didReadContent ? 1 + emptyLines : emptyLines); + } + + didReadContent = true; + detectedIndent = true; + emptyLines = 0; + captureStart = state.position; + + while (!is_EOL(ch) && (ch !== 0)) { + ch = state.input.charCodeAt(++state.position); + } + + captureSegment(state, captureStart, state.position, false); + } + + return true; +} + +function readBlockSequence(state, nodeIndent) { + var _line, + _tag = state.tag, + _anchor = state.anchor, + _result = [], + following, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + if (ch !== 0x2D/* - */) { + break; + } + + following = state.input.charCodeAt(state.position + 1); + + if (!is_WS_OR_EOL(following)) { + break; + } + + detected = true; + state.position++; + + if (skipSeparationSpace(state, true, -1)) { + if (state.lineIndent <= nodeIndent) { + _result.push(null); + ch = state.input.charCodeAt(state.position); + continue; + } + } + + _line = state.line; + composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true); + _result.push(state.result); + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a sequence entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'sequence'; + state.result = _result; + return true; + } + return false; +} + +function readBlockMapping(state, nodeIndent, flowIndent) { + var following, + allowCompact, + _line, + _keyLine, + _keyLineStart, + _keyPos, + _tag = state.tag, + _anchor = state.anchor, + _result = {}, + overridableKeys = Object.create(null), + keyTag = null, + keyNode = null, + valueNode = null, + atExplicitKey = false, + detected = false, + ch; + + // there is a leading tab before this token, so it can't be a block sequence/mapping; + // it can still be flow sequence/mapping or a scalar + if (state.firstTabInLine !== -1) return false; + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = _result; + } + + ch = state.input.charCodeAt(state.position); + + while (ch !== 0) { + if (!atExplicitKey && state.firstTabInLine !== -1) { + state.position = state.firstTabInLine; + throwError(state, 'tab characters must not be used in indentation'); + } + + following = state.input.charCodeAt(state.position + 1); + _line = state.line; // Save the current line. + + // + // Explicit notation case. There are two separate blocks: + // first for the key (denoted by "?") and second for the value (denoted by ":") + // + if ((ch === 0x3F/* ? */ || ch === 0x3A/* : */) && is_WS_OR_EOL(following)) { + + if (ch === 0x3F/* ? */) { + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = true; + allowCompact = true; + + } else if (atExplicitKey) { + // i.e. 0x3A/* : */ === character after the explicit key. + atExplicitKey = false; + allowCompact = true; + + } else { + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); + } + + state.position += 1; + ch = following; + + // + // Implicit notation case. Flow-style node as the key first, then ":", and the value. + // + } else { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + + if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) { + // Neither implicit nor explicit notation. + // Reading is done. Go to the epilogue. + break; + } + + if (state.line === _line) { + ch = state.input.charCodeAt(state.position); + + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x3A/* : */) { + ch = state.input.charCodeAt(++state.position); + + if (!is_WS_OR_EOL(ch)) { + throwError(state, 'a whitespace character is expected after the key-value separator within a block mapping'); + } + + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + detected = true; + atExplicitKey = false; + allowCompact = false; + keyTag = state.tag; + keyNode = state.result; + + } else if (detected) { + throwError(state, 'can not read an implicit mapping pair; a colon is missed'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + + } else if (detected) { + throwError(state, 'can not read a block mapping entry; a multiline key may not be an implicit key'); + + } else { + state.tag = _tag; + state.anchor = _anchor; + return true; // Keep the result of `composeNode`. + } + } + + // + // Common reading code for both explicit and implicit notations. + // + if (state.line === _line || state.lineIndent > nodeIndent) { + if (atExplicitKey) { + _keyLine = state.line; + _keyLineStart = state.lineStart; + _keyPos = state.position; + } + + if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) { + if (atExplicitKey) { + keyNode = state.result; + } else { + valueNode = state.result; + } + } + + if (!atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos); + keyTag = keyNode = valueNode = null; + } + + skipSeparationSpace(state, true, -1); + ch = state.input.charCodeAt(state.position); + } + + if ((state.line === _line || state.lineIndent > nodeIndent) && (ch !== 0)) { + throwError(state, 'bad indentation of a mapping entry'); + } else if (state.lineIndent < nodeIndent) { + break; + } + } + + // + // Epilogue. + // + + // Special case: last mapping's node contains only the key in explicit notation. + if (atExplicitKey) { + storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos); + } + + // Expose the resulting mapping. + if (detected) { + state.tag = _tag; + state.anchor = _anchor; + state.kind = 'mapping'; + state.result = _result; + } + + return detected; +} + +function readTagProperty(state) { + var _position, + isVerbatim = false, + isNamed = false, + tagHandle, + tagName, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x21/* ! */) return false; + + if (state.tag !== null) { + throwError(state, 'duplication of a tag property'); + } + + ch = state.input.charCodeAt(++state.position); + + if (ch === 0x3C/* < */) { + isVerbatim = true; + ch = state.input.charCodeAt(++state.position); + + } else if (ch === 0x21/* ! */) { + isNamed = true; + tagHandle = '!!'; + ch = state.input.charCodeAt(++state.position); + + } else { + tagHandle = '!'; + } + + _position = state.position; + + if (isVerbatim) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && ch !== 0x3E/* > */); + + if (state.position < state.length) { + tagName = state.input.slice(_position, state.position); + ch = state.input.charCodeAt(++state.position); + } else { + throwError(state, 'unexpected end of the stream within a verbatim tag'); + } + } else { + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + + if (ch === 0x21/* ! */) { + if (!isNamed) { + tagHandle = state.input.slice(_position - 1, state.position + 1); + + if (!PATTERN_TAG_HANDLE.test(tagHandle)) { + throwError(state, 'named tag handle cannot contain such characters'); + } + + isNamed = true; + _position = state.position + 1; + } else { + throwError(state, 'tag suffix cannot contain exclamation marks'); + } + } + + ch = state.input.charCodeAt(++state.position); + } + + tagName = state.input.slice(_position, state.position); + + if (PATTERN_FLOW_INDICATORS.test(tagName)) { + throwError(state, 'tag suffix cannot contain flow indicator characters'); + } + } + + if (tagName && !PATTERN_TAG_URI.test(tagName)) { + throwError(state, 'tag name cannot contain such characters: ' + tagName); + } + + try { + tagName = decodeURIComponent(tagName); + } catch (err) { + throwError(state, 'tag name is malformed: ' + tagName); + } + + if (isVerbatim) { + state.tag = tagName; + + } else if (_hasOwnProperty.call(state.tagMap, tagHandle)) { + state.tag = state.tagMap[tagHandle] + tagName; + + } else if (tagHandle === '!') { + state.tag = '!' + tagName; + + } else if (tagHandle === '!!') { + state.tag = 'tag:yaml.org,2002:' + tagName; + + } else { + throwError(state, 'undeclared tag handle "' + tagHandle + '"'); + } + + return true; +} + +function readAnchorProperty(state) { + var _position, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x26/* & */) return false; + + if (state.anchor !== null) { + throwError(state, 'duplication of an anchor property'); + } + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an anchor node must contain at least one character'); + } + + state.anchor = state.input.slice(_position, state.position); + return true; +} + +function readAlias(state) { + var _position, alias, + ch; + + ch = state.input.charCodeAt(state.position); + + if (ch !== 0x2A/* * */) return false; + + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (state.position === _position) { + throwError(state, 'name of an alias node must contain at least one character'); + } + + alias = state.input.slice(_position, state.position); + + if (!_hasOwnProperty.call(state.anchorMap, alias)) { + throwError(state, 'unidentified alias "' + alias + '"'); + } + + state.result = state.anchorMap[alias]; + skipSeparationSpace(state, true, -1); + return true; +} + +function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) { + var allowBlockStyles, + allowBlockScalars, + allowBlockCollections, + indentStatus = 1, // 1: this>parent, 0: this=parent, -1: this parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } + } + + if (indentStatus === 1) { + while (readTagProperty(state) || readAnchorProperty(state)) { + if (skipSeparationSpace(state, true, -1)) { + atNewLine = true; + allowBlockCollections = allowBlockStyles; + + if (state.lineIndent > parentIndent) { + indentStatus = 1; + } else if (state.lineIndent === parentIndent) { + indentStatus = 0; + } else if (state.lineIndent < parentIndent) { + indentStatus = -1; + } + } else { + allowBlockCollections = false; + } + } + } + + if (allowBlockCollections) { + allowBlockCollections = atNewLine || allowCompact; + } + + if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) { + if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) { + flowIndent = parentIndent; + } else { + flowIndent = parentIndent + 1; + } + + blockIndent = state.position - state.lineStart; + + if (indentStatus === 1) { + if (allowBlockCollections && + (readBlockSequence(state, blockIndent) || + readBlockMapping(state, blockIndent, flowIndent)) || + readFlowCollection(state, flowIndent)) { + hasContent = true; + } else { + if ((allowBlockScalars && readBlockScalar(state, flowIndent)) || + readSingleQuotedScalar(state, flowIndent) || + readDoubleQuotedScalar(state, flowIndent)) { + hasContent = true; + + } else if (readAlias(state)) { + hasContent = true; + + if (state.tag !== null || state.anchor !== null) { + throwError(state, 'alias node should not have any properties'); + } + + } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) { + hasContent = true; + + if (state.tag === null) { + state.tag = '?'; + } + } + + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } else if (indentStatus === 0) { + // Special case: block sequences are allowed to have same indentation level as the parent. + // http://www.yaml.org/spec/1.2/spec.html#id2799784 + hasContent = allowBlockCollections && readBlockSequence(state, blockIndent); + } + } + + if (state.tag === null) { + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + + } else if (state.tag === '?') { + // Implicit resolving is not allowed for non-scalar types, and '?' + // non-specific tag is only automatically assigned to plain scalars. + // + // We only need to check kind conformity in case user explicitly assigns '?' + // tag, for example like this: "! [0]" + // + if (state.result !== null && state.kind !== 'scalar') { + throwError(state, 'unacceptable node kind for ! tag; it should be "scalar", not "' + state.kind + '"'); + } + + for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) { + type = state.implicitTypes[typeIndex]; + + if (type.resolve(state.result)) { // `state.result` updated in resolver if matched + state.result = type.construct(state.result); + state.tag = type.tag; + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + break; + } + } + } else if (state.tag !== '!') { + if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) { + type = state.typeMap[state.kind || 'fallback'][state.tag]; + } else { + // looking for multi type + type = null; + typeList = state.typeMap.multi[state.kind || 'fallback']; + + for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) { + if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) { + type = typeList[typeIndex]; + break; + } + } + } + + if (!type) { + throwError(state, 'unknown tag !<' + state.tag + '>'); + } + + if (state.result !== null && type.kind !== state.kind) { + throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"'); + } + + if (!type.resolve(state.result, state.tag)) { // `state.result` updated in resolver if matched + throwError(state, 'cannot resolve a node with !<' + state.tag + '> explicit tag'); + } else { + state.result = type.construct(state.result, state.tag); + if (state.anchor !== null) { + state.anchorMap[state.anchor] = state.result; + } + } + } + + if (state.listener !== null) { + state.listener('close', state); + } + return state.tag !== null || state.anchor !== null || hasContent; +} + +function readDocument(state) { + var documentStart = state.position, + _position, + directiveName, + directiveArgs, + hasDirectives = false, + ch; + + state.version = null; + state.checkLineBreaks = state.legacy; + state.tagMap = Object.create(null); + state.anchorMap = Object.create(null); + + while ((ch = state.input.charCodeAt(state.position)) !== 0) { + skipSeparationSpace(state, true, -1); + + ch = state.input.charCodeAt(state.position); + + if (state.lineIndent > 0 || ch !== 0x25/* % */) { + break; + } + + hasDirectives = true; + ch = state.input.charCodeAt(++state.position); + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveName = state.input.slice(_position, state.position); + directiveArgs = []; + + if (directiveName.length < 1) { + throwError(state, 'directive name must not be less than one character in length'); + } + + while (ch !== 0) { + while (is_WHITE_SPACE(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + if (ch === 0x23/* # */) { + do { ch = state.input.charCodeAt(++state.position); } + while (ch !== 0 && !is_EOL(ch)); + break; + } + + if (is_EOL(ch)) break; + + _position = state.position; + + while (ch !== 0 && !is_WS_OR_EOL(ch)) { + ch = state.input.charCodeAt(++state.position); + } + + directiveArgs.push(state.input.slice(_position, state.position)); + } + + if (ch !== 0) readLineBreak(state); + + if (_hasOwnProperty.call(directiveHandlers, directiveName)) { + directiveHandlers[directiveName](state, directiveName, directiveArgs); + } else { + throwWarning(state, 'unknown document directive "' + directiveName + '"'); + } + } + + skipSeparationSpace(state, true, -1); + + if (state.lineIndent === 0 && + state.input.charCodeAt(state.position) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 1) === 0x2D/* - */ && + state.input.charCodeAt(state.position + 2) === 0x2D/* - */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + + } else if (hasDirectives) { + throwError(state, 'directives end mark is expected'); + } + + composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true); + skipSeparationSpace(state, true, -1); + + if (state.checkLineBreaks && + PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) { + throwWarning(state, 'non-ASCII line breaks are interpreted as content'); + } + + state.documents.push(state.result); + + if (state.position === state.lineStart && testDocumentSeparator(state)) { + + if (state.input.charCodeAt(state.position) === 0x2E/* . */) { + state.position += 3; + skipSeparationSpace(state, true, -1); + } + return; + } + + if (state.position < (state.length - 1)) { + throwError(state, 'end of the stream or a document separator is expected'); + } else { + return; + } +} + + +function loadDocuments(input, options) { + input = String(input); + options = options || {}; + + if (input.length !== 0) { + + // Add tailing `\n` if not exists + if (input.charCodeAt(input.length - 1) !== 0x0A/* LF */ && + input.charCodeAt(input.length - 1) !== 0x0D/* CR */) { + input += '\n'; + } + + // Strip BOM + if (input.charCodeAt(0) === 0xFEFF) { + input = input.slice(1); + } + } + + var state = new State(input, options); + + var nullpos = input.indexOf('\0'); + + if (nullpos !== -1) { + state.position = nullpos; + throwError(state, 'null byte is not allowed in input'); + } + + // Use 0 as string terminator. That significantly simplifies bounds check. + state.input += '\0'; + + while (state.input.charCodeAt(state.position) === 0x20/* Space */) { + state.lineIndent += 1; + state.position += 1; + } + + while (state.position < (state.length - 1)) { + readDocument(state); + } + + return state.documents; +} + + +function loadAll(input, iterator, options) { + if (iterator !== null && typeof iterator === 'object' && typeof options === 'undefined') { + options = iterator; + iterator = null; + } + + var documents = loadDocuments(input, options); + + if (typeof iterator !== 'function') { + return documents; + } + + for (var index = 0, length = documents.length; index < length; index += 1) { + iterator(documents[index]); + } +} + + +function load(input, options) { + var documents = loadDocuments(input, options); + + if (documents.length === 0) { + /*eslint-disable no-undefined*/ + return undefined; + } else if (documents.length === 1) { + return documents[0]; + } + throw new YAMLException('expected a single document in the stream, but found more'); +} + + +module.exports.loadAll = loadAll; +module.exports.load = load; diff --git a/action/node_modules/js-yaml/lib/schema.js b/action/node_modules/js-yaml/lib/schema.js new file mode 100644 index 000000000..65b41f401 --- /dev/null +++ b/action/node_modules/js-yaml/lib/schema.js @@ -0,0 +1,121 @@ +'use strict'; + +/*eslint-disable max-len*/ + +var YAMLException = require('./exception'); +var Type = require('./type'); + + +function compileList(schema, name) { + var result = []; + + schema[name].forEach(function (currentType) { + var newIndex = result.length; + + result.forEach(function (previousType, previousIndex) { + if (previousType.tag === currentType.tag && + previousType.kind === currentType.kind && + previousType.multi === currentType.multi) { + + newIndex = previousIndex; + } + }); + + result[newIndex] = currentType; + }); + + return result; +} + + +function compileMap(/* lists... */) { + var result = { + scalar: {}, + sequence: {}, + mapping: {}, + fallback: {}, + multi: { + scalar: [], + sequence: [], + mapping: [], + fallback: [] + } + }, index, length; + + function collectType(type) { + if (type.multi) { + result.multi[type.kind].push(type); + result.multi['fallback'].push(type); + } else { + result[type.kind][type.tag] = result['fallback'][type.tag] = type; + } + } + + for (index = 0, length = arguments.length; index < length; index += 1) { + arguments[index].forEach(collectType); + } + return result; +} + + +function Schema(definition) { + return this.extend(definition); +} + + +Schema.prototype.extend = function extend(definition) { + var implicit = []; + var explicit = []; + + if (definition instanceof Type) { + // Schema.extend(type) + explicit.push(definition); + + } else if (Array.isArray(definition)) { + // Schema.extend([ type1, type2, ... ]) + explicit = explicit.concat(definition); + + } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) { + // Schema.extend({ explicit: [ type1, type2, ... ], implicit: [ type1, type2, ... ] }) + if (definition.implicit) implicit = implicit.concat(definition.implicit); + if (definition.explicit) explicit = explicit.concat(definition.explicit); + + } else { + throw new YAMLException('Schema.extend argument should be a Type, [ Type ], ' + + 'or a schema definition ({ implicit: [...], explicit: [...] })'); + } + + implicit.forEach(function (type) { + if (!(type instanceof Type)) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + + if (type.loadKind && type.loadKind !== 'scalar') { + throw new YAMLException('There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.'); + } + + if (type.multi) { + throw new YAMLException('There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.'); + } + }); + + explicit.forEach(function (type) { + if (!(type instanceof Type)) { + throw new YAMLException('Specified list of YAML types (or a single Type object) contains a non-Type object.'); + } + }); + + var result = Object.create(Schema.prototype); + + result.implicit = (this.implicit || []).concat(implicit); + result.explicit = (this.explicit || []).concat(explicit); + + result.compiledImplicit = compileList(result, 'implicit'); + result.compiledExplicit = compileList(result, 'explicit'); + result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit); + + return result; +}; + + +module.exports = Schema; diff --git a/action/node_modules/js-yaml/lib/schema/core.js b/action/node_modules/js-yaml/lib/schema/core.js new file mode 100644 index 000000000..608b26de2 --- /dev/null +++ b/action/node_modules/js-yaml/lib/schema/core.js @@ -0,0 +1,11 @@ +// Standard YAML's Core schema. +// http://www.yaml.org/spec/1.2/spec.html#id2804923 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, Core schema has no distinctions from JSON schema is JS-YAML. + + +'use strict'; + + +module.exports = require('./json'); diff --git a/action/node_modules/js-yaml/lib/schema/default.js b/action/node_modules/js-yaml/lib/schema/default.js new file mode 100644 index 000000000..3af0520d5 --- /dev/null +++ b/action/node_modules/js-yaml/lib/schema/default.js @@ -0,0 +1,22 @@ +// JS-YAML's default schema for `safeLoad` function. +// It is not described in the YAML specification. +// +// This schema is based on standard YAML's Core schema and includes most of +// extra types described at YAML tag repository. (http://yaml.org/type/) + + +'use strict'; + + +module.exports = require('./core').extend({ + implicit: [ + require('../type/timestamp'), + require('../type/merge') + ], + explicit: [ + require('../type/binary'), + require('../type/omap'), + require('../type/pairs'), + require('../type/set') + ] +}); diff --git a/action/node_modules/js-yaml/lib/schema/failsafe.js b/action/node_modules/js-yaml/lib/schema/failsafe.js new file mode 100644 index 000000000..b7a33eb7a --- /dev/null +++ b/action/node_modules/js-yaml/lib/schema/failsafe.js @@ -0,0 +1,17 @@ +// Standard YAML's Failsafe schema. +// http://www.yaml.org/spec/1.2/spec.html#id2802346 + + +'use strict'; + + +var Schema = require('../schema'); + + +module.exports = new Schema({ + explicit: [ + require('../type/str'), + require('../type/seq'), + require('../type/map') + ] +}); diff --git a/action/node_modules/js-yaml/lib/schema/json.js b/action/node_modules/js-yaml/lib/schema/json.js new file mode 100644 index 000000000..b73df78e5 --- /dev/null +++ b/action/node_modules/js-yaml/lib/schema/json.js @@ -0,0 +1,19 @@ +// Standard YAML's JSON schema. +// http://www.yaml.org/spec/1.2/spec.html#id2803231 +// +// NOTE: JS-YAML does not support schema-specific tag resolution restrictions. +// So, this schema is not such strict as defined in the YAML specification. +// It allows numbers in binary notaion, use `Null` and `NULL` as `null`, etc. + + +'use strict'; + + +module.exports = require('./failsafe').extend({ + implicit: [ + require('../type/null'), + require('../type/bool'), + require('../type/int'), + require('../type/float') + ] +}); diff --git a/action/node_modules/js-yaml/lib/snippet.js b/action/node_modules/js-yaml/lib/snippet.js new file mode 100644 index 000000000..00e2133c0 --- /dev/null +++ b/action/node_modules/js-yaml/lib/snippet.js @@ -0,0 +1,101 @@ +'use strict'; + + +var common = require('./common'); + + +// get snippet for a single line, respecting maxLength +function getLine(buffer, lineStart, lineEnd, position, maxLineLength) { + var head = ''; + var tail = ''; + var maxHalfLength = Math.floor(maxLineLength / 2) - 1; + + if (position - lineStart > maxHalfLength) { + head = ' ... '; + lineStart = position - maxHalfLength + head.length; + } + + if (lineEnd - position > maxHalfLength) { + tail = ' ...'; + lineEnd = position + maxHalfLength - tail.length; + } + + return { + str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, '→') + tail, + pos: position - lineStart + head.length // relative position + }; +} + + +function padStart(string, max) { + return common.repeat(' ', max - string.length) + string; +} + + +function makeSnippet(mark, options) { + options = Object.create(options || null); + + if (!mark.buffer) return null; + + if (!options.maxLength) options.maxLength = 79; + if (typeof options.indent !== 'number') options.indent = 1; + if (typeof options.linesBefore !== 'number') options.linesBefore = 3; + if (typeof options.linesAfter !== 'number') options.linesAfter = 2; + + var re = /\r?\n|\r|\0/g; + var lineStarts = [ 0 ]; + var lineEnds = []; + var match; + var foundLineNo = -1; + + while ((match = re.exec(mark.buffer))) { + lineEnds.push(match.index); + lineStarts.push(match.index + match[0].length); + + if (mark.position <= match.index && foundLineNo < 0) { + foundLineNo = lineStarts.length - 2; + } + } + + if (foundLineNo < 0) foundLineNo = lineStarts.length - 1; + + var result = '', i, line; + var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length; + var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3); + + for (i = 1; i <= options.linesBefore; i++) { + if (foundLineNo - i < 0) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo - i], + lineEnds[foundLineNo - i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), + maxLineLength + ); + result = common.repeat(' ', options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n' + result; + } + + line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength); + result += common.repeat(' ', options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + result += common.repeat('-', options.indent + lineNoLength + 3 + line.pos) + '^' + '\n'; + + for (i = 1; i <= options.linesAfter; i++) { + if (foundLineNo + i >= lineEnds.length) break; + line = getLine( + mark.buffer, + lineStarts[foundLineNo + i], + lineEnds[foundLineNo + i], + mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), + maxLineLength + ); + result += common.repeat(' ', options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + + ' | ' + line.str + '\n'; + } + + return result.replace(/\n$/, ''); +} + + +module.exports = makeSnippet; diff --git a/action/node_modules/js-yaml/lib/type.js b/action/node_modules/js-yaml/lib/type.js new file mode 100644 index 000000000..5e57877fe --- /dev/null +++ b/action/node_modules/js-yaml/lib/type.js @@ -0,0 +1,66 @@ +'use strict'; + +var YAMLException = require('./exception'); + +var TYPE_CONSTRUCTOR_OPTIONS = [ + 'kind', + 'multi', + 'resolve', + 'construct', + 'instanceOf', + 'predicate', + 'represent', + 'representName', + 'defaultStyle', + 'styleAliases' +]; + +var YAML_NODE_KINDS = [ + 'scalar', + 'sequence', + 'mapping' +]; + +function compileStyleAliases(map) { + var result = {}; + + if (map !== null) { + Object.keys(map).forEach(function (style) { + map[style].forEach(function (alias) { + result[String(alias)] = style; + }); + }); + } + + return result; +} + +function Type(tag, options) { + options = options || {}; + + Object.keys(options).forEach(function (name) { + if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) { + throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.'); + } + }); + + // TODO: Add tag format check. + this.options = options; // keep original options in case user wants to extend this type later + this.tag = tag; + this.kind = options['kind'] || null; + this.resolve = options['resolve'] || function () { return true; }; + this.construct = options['construct'] || function (data) { return data; }; + this.instanceOf = options['instanceOf'] || null; + this.predicate = options['predicate'] || null; + this.represent = options['represent'] || null; + this.representName = options['representName'] || null; + this.defaultStyle = options['defaultStyle'] || null; + this.multi = options['multi'] || false; + this.styleAliases = compileStyleAliases(options['styleAliases'] || null); + + if (YAML_NODE_KINDS.indexOf(this.kind) === -1) { + throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.'); + } +} + +module.exports = Type; diff --git a/action/node_modules/js-yaml/lib/type/binary.js b/action/node_modules/js-yaml/lib/type/binary.js new file mode 100644 index 000000000..e1523513d --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/binary.js @@ -0,0 +1,125 @@ +'use strict'; + +/*eslint-disable no-bitwise*/ + + +var Type = require('../type'); + + +// [ 64, 65, 66 ] -> [ padding, CR, LF ] +var BASE64_MAP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r'; + + +function resolveYamlBinary(data) { + if (data === null) return false; + + var code, idx, bitlen = 0, max = data.length, map = BASE64_MAP; + + // Convert one by one. + for (idx = 0; idx < max; idx++) { + code = map.indexOf(data.charAt(idx)); + + // Skip CR/LF + if (code > 64) continue; + + // Fail on illegal characters + if (code < 0) return false; + + bitlen += 6; + } + + // If there are any bits left, source was corrupted + return (bitlen % 8) === 0; +} + +function constructYamlBinary(data) { + var idx, tailbits, + input = data.replace(/[\r\n=]/g, ''), // remove CR/LF & padding to simplify scan + max = input.length, + map = BASE64_MAP, + bits = 0, + result = []; + + // Collect by 6*4 bits (3 bytes) + + for (idx = 0; idx < max; idx++) { + if ((idx % 4 === 0) && idx) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } + + bits = (bits << 6) | map.indexOf(input.charAt(idx)); + } + + // Dump tail + + tailbits = (max % 4) * 6; + + if (tailbits === 0) { + result.push((bits >> 16) & 0xFF); + result.push((bits >> 8) & 0xFF); + result.push(bits & 0xFF); + } else if (tailbits === 18) { + result.push((bits >> 10) & 0xFF); + result.push((bits >> 2) & 0xFF); + } else if (tailbits === 12) { + result.push((bits >> 4) & 0xFF); + } + + return new Uint8Array(result); +} + +function representYamlBinary(object /*, style*/) { + var result = '', bits = 0, idx, tail, + max = object.length, + map = BASE64_MAP; + + // Convert every three bytes to 4 ASCII characters. + + for (idx = 0; idx < max; idx++) { + if ((idx % 3 === 0) && idx) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } + + bits = (bits << 8) + object[idx]; + } + + // Dump tail + + tail = max % 3; + + if (tail === 0) { + result += map[(bits >> 18) & 0x3F]; + result += map[(bits >> 12) & 0x3F]; + result += map[(bits >> 6) & 0x3F]; + result += map[bits & 0x3F]; + } else if (tail === 2) { + result += map[(bits >> 10) & 0x3F]; + result += map[(bits >> 4) & 0x3F]; + result += map[(bits << 2) & 0x3F]; + result += map[64]; + } else if (tail === 1) { + result += map[(bits >> 2) & 0x3F]; + result += map[(bits << 4) & 0x3F]; + result += map[64]; + result += map[64]; + } + + return result; +} + +function isBinary(obj) { + return Object.prototype.toString.call(obj) === '[object Uint8Array]'; +} + +module.exports = new Type('tag:yaml.org,2002:binary', { + kind: 'scalar', + resolve: resolveYamlBinary, + construct: constructYamlBinary, + predicate: isBinary, + represent: representYamlBinary +}); diff --git a/action/node_modules/js-yaml/lib/type/bool.js b/action/node_modules/js-yaml/lib/type/bool.js new file mode 100644 index 000000000..cb7745930 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/bool.js @@ -0,0 +1,35 @@ +'use strict'; + +var Type = require('../type'); + +function resolveYamlBoolean(data) { + if (data === null) return false; + + var max = data.length; + + return (max === 4 && (data === 'true' || data === 'True' || data === 'TRUE')) || + (max === 5 && (data === 'false' || data === 'False' || data === 'FALSE')); +} + +function constructYamlBoolean(data) { + return data === 'true' || + data === 'True' || + data === 'TRUE'; +} + +function isBoolean(object) { + return Object.prototype.toString.call(object) === '[object Boolean]'; +} + +module.exports = new Type('tag:yaml.org,2002:bool', { + kind: 'scalar', + resolve: resolveYamlBoolean, + construct: constructYamlBoolean, + predicate: isBoolean, + represent: { + lowercase: function (object) { return object ? 'true' : 'false'; }, + uppercase: function (object) { return object ? 'TRUE' : 'FALSE'; }, + camelcase: function (object) { return object ? 'True' : 'False'; } + }, + defaultStyle: 'lowercase' +}); diff --git a/action/node_modules/js-yaml/lib/type/float.js b/action/node_modules/js-yaml/lib/type/float.js new file mode 100644 index 000000000..74d77ec2e --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/float.js @@ -0,0 +1,97 @@ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +var YAML_FLOAT_PATTERN = new RegExp( + // 2.5e4, 2.5 and integers + '^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?' + + // .2e4, .2 + // special case, seems not from spec + '|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?' + + // .inf + '|[-+]?\\.(?:inf|Inf|INF)' + + // .nan + '|\\.(?:nan|NaN|NAN))$'); + +function resolveYamlFloat(data) { + if (data === null) return false; + + if (!YAML_FLOAT_PATTERN.test(data) || + // Quick hack to not allow integers end with `_` + // Probably should update regexp & check speed + data[data.length - 1] === '_') { + return false; + } + + return true; +} + +function constructYamlFloat(data) { + var value, sign; + + value = data.replace(/_/g, '').toLowerCase(); + sign = value[0] === '-' ? -1 : 1; + + if ('+-'.indexOf(value[0]) >= 0) { + value = value.slice(1); + } + + if (value === '.inf') { + return (sign === 1) ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY; + + } else if (value === '.nan') { + return NaN; + } + return sign * parseFloat(value, 10); +} + + +var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/; + +function representYamlFloat(object, style) { + var res; + + if (isNaN(object)) { + switch (style) { + case 'lowercase': return '.nan'; + case 'uppercase': return '.NAN'; + case 'camelcase': return '.NaN'; + } + } else if (Number.POSITIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '.inf'; + case 'uppercase': return '.INF'; + case 'camelcase': return '.Inf'; + } + } else if (Number.NEGATIVE_INFINITY === object) { + switch (style) { + case 'lowercase': return '-.inf'; + case 'uppercase': return '-.INF'; + case 'camelcase': return '-.Inf'; + } + } else if (common.isNegativeZero(object)) { + return '-0.0'; + } + + res = object.toString(10); + + // JS stringifier can build scientific format without dots: 5e-100, + // while YAML requres dot: 5.e-100. Fix it with simple hack + + return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace('e', '.e') : res; +} + +function isFloat(object) { + return (Object.prototype.toString.call(object) === '[object Number]') && + (object % 1 !== 0 || common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:float', { + kind: 'scalar', + resolve: resolveYamlFloat, + construct: constructYamlFloat, + predicate: isFloat, + represent: representYamlFloat, + defaultStyle: 'lowercase' +}); diff --git a/action/node_modules/js-yaml/lib/type/int.js b/action/node_modules/js-yaml/lib/type/int.js new file mode 100644 index 000000000..3fe3a4437 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/int.js @@ -0,0 +1,156 @@ +'use strict'; + +var common = require('../common'); +var Type = require('../type'); + +function isHexCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)) || + ((0x41/* A */ <= c) && (c <= 0x46/* F */)) || + ((0x61/* a */ <= c) && (c <= 0x66/* f */)); +} + +function isOctCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x37/* 7 */)); +} + +function isDecCode(c) { + return ((0x30/* 0 */ <= c) && (c <= 0x39/* 9 */)); +} + +function resolveYamlInteger(data) { + if (data === null) return false; + + var max = data.length, + index = 0, + hasDigits = false, + ch; + + if (!max) return false; + + ch = data[index]; + + // sign + if (ch === '-' || ch === '+') { + ch = data[++index]; + } + + if (ch === '0') { + // 0 + if (index + 1 === max) return true; + ch = data[++index]; + + // base 2, base 8, base 16 + + if (ch === 'b') { + // base 2 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (ch !== '0' && ch !== '1') return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'x') { + // base 16 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isHexCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + + + if (ch === 'o') { + // base 8 + index++; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isOctCode(data.charCodeAt(index))) return false; + hasDigits = true; + } + return hasDigits && ch !== '_'; + } + } + + // base 10 (except 0) + + // value should not start with `_`; + if (ch === '_') return false; + + for (; index < max; index++) { + ch = data[index]; + if (ch === '_') continue; + if (!isDecCode(data.charCodeAt(index))) { + return false; + } + hasDigits = true; + } + + // Should have digits and should not end with `_` + if (!hasDigits || ch === '_') return false; + + return true; +} + +function constructYamlInteger(data) { + var value = data, sign = 1, ch; + + if (value.indexOf('_') !== -1) { + value = value.replace(/_/g, ''); + } + + ch = value[0]; + + if (ch === '-' || ch === '+') { + if (ch === '-') sign = -1; + value = value.slice(1); + ch = value[0]; + } + + if (value === '0') return 0; + + if (ch === '0') { + if (value[1] === 'b') return sign * parseInt(value.slice(2), 2); + if (value[1] === 'x') return sign * parseInt(value.slice(2), 16); + if (value[1] === 'o') return sign * parseInt(value.slice(2), 8); + } + + return sign * parseInt(value, 10); +} + +function isInteger(object) { + return (Object.prototype.toString.call(object)) === '[object Number]' && + (object % 1 === 0 && !common.isNegativeZero(object)); +} + +module.exports = new Type('tag:yaml.org,2002:int', { + kind: 'scalar', + resolve: resolveYamlInteger, + construct: constructYamlInteger, + predicate: isInteger, + represent: { + binary: function (obj) { return obj >= 0 ? '0b' + obj.toString(2) : '-0b' + obj.toString(2).slice(1); }, + octal: function (obj) { return obj >= 0 ? '0o' + obj.toString(8) : '-0o' + obj.toString(8).slice(1); }, + decimal: function (obj) { return obj.toString(10); }, + /* eslint-disable max-len */ + hexadecimal: function (obj) { return obj >= 0 ? '0x' + obj.toString(16).toUpperCase() : '-0x' + obj.toString(16).toUpperCase().slice(1); } + }, + defaultStyle: 'decimal', + styleAliases: { + binary: [ 2, 'bin' ], + octal: [ 8, 'oct' ], + decimal: [ 10, 'dec' ], + hexadecimal: [ 16, 'hex' ] + } +}); diff --git a/action/node_modules/js-yaml/lib/type/map.js b/action/node_modules/js-yaml/lib/type/map.js new file mode 100644 index 000000000..f327beebd --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/map.js @@ -0,0 +1,8 @@ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:map', { + kind: 'mapping', + construct: function (data) { return data !== null ? data : {}; } +}); diff --git a/action/node_modules/js-yaml/lib/type/merge.js b/action/node_modules/js-yaml/lib/type/merge.js new file mode 100644 index 000000000..ae08a8644 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/merge.js @@ -0,0 +1,12 @@ +'use strict'; + +var Type = require('../type'); + +function resolveYamlMerge(data) { + return data === '<<' || data === null; +} + +module.exports = new Type('tag:yaml.org,2002:merge', { + kind: 'scalar', + resolve: resolveYamlMerge +}); diff --git a/action/node_modules/js-yaml/lib/type/null.js b/action/node_modules/js-yaml/lib/type/null.js new file mode 100644 index 000000000..315ca4e23 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/null.js @@ -0,0 +1,35 @@ +'use strict'; + +var Type = require('../type'); + +function resolveYamlNull(data) { + if (data === null) return true; + + var max = data.length; + + return (max === 1 && data === '~') || + (max === 4 && (data === 'null' || data === 'Null' || data === 'NULL')); +} + +function constructYamlNull() { + return null; +} + +function isNull(object) { + return object === null; +} + +module.exports = new Type('tag:yaml.org,2002:null', { + kind: 'scalar', + resolve: resolveYamlNull, + construct: constructYamlNull, + predicate: isNull, + represent: { + canonical: function () { return '~'; }, + lowercase: function () { return 'null'; }, + uppercase: function () { return 'NULL'; }, + camelcase: function () { return 'Null'; }, + empty: function () { return ''; } + }, + defaultStyle: 'lowercase' +}); diff --git a/action/node_modules/js-yaml/lib/type/omap.js b/action/node_modules/js-yaml/lib/type/omap.js new file mode 100644 index 000000000..b2b5323bd --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/omap.js @@ -0,0 +1,44 @@ +'use strict'; + +var Type = require('../type'); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; +var _toString = Object.prototype.toString; + +function resolveYamlOmap(data) { + if (data === null) return true; + + var objectKeys = [], index, length, pair, pairKey, pairHasKey, + object = data; + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + pairHasKey = false; + + if (_toString.call(pair) !== '[object Object]') return false; + + for (pairKey in pair) { + if (_hasOwnProperty.call(pair, pairKey)) { + if (!pairHasKey) pairHasKey = true; + else return false; + } + } + + if (!pairHasKey) return false; + + if (objectKeys.indexOf(pairKey) === -1) objectKeys.push(pairKey); + else return false; + } + + return true; +} + +function constructYamlOmap(data) { + return data !== null ? data : []; +} + +module.exports = new Type('tag:yaml.org,2002:omap', { + kind: 'sequence', + resolve: resolveYamlOmap, + construct: constructYamlOmap +}); diff --git a/action/node_modules/js-yaml/lib/type/pairs.js b/action/node_modules/js-yaml/lib/type/pairs.js new file mode 100644 index 000000000..74b52403f --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/pairs.js @@ -0,0 +1,53 @@ +'use strict'; + +var Type = require('../type'); + +var _toString = Object.prototype.toString; + +function resolveYamlPairs(data) { + if (data === null) return true; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + if (_toString.call(pair) !== '[object Object]') return false; + + keys = Object.keys(pair); + + if (keys.length !== 1) return false; + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return true; +} + +function constructYamlPairs(data) { + if (data === null) return []; + + var index, length, pair, keys, result, + object = data; + + result = new Array(object.length); + + for (index = 0, length = object.length; index < length; index += 1) { + pair = object[index]; + + keys = Object.keys(pair); + + result[index] = [ keys[0], pair[keys[0]] ]; + } + + return result; +} + +module.exports = new Type('tag:yaml.org,2002:pairs', { + kind: 'sequence', + resolve: resolveYamlPairs, + construct: constructYamlPairs +}); diff --git a/action/node_modules/js-yaml/lib/type/seq.js b/action/node_modules/js-yaml/lib/type/seq.js new file mode 100644 index 000000000..be8f77f28 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/seq.js @@ -0,0 +1,8 @@ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:seq', { + kind: 'sequence', + construct: function (data) { return data !== null ? data : []; } +}); diff --git a/action/node_modules/js-yaml/lib/type/set.js b/action/node_modules/js-yaml/lib/type/set.js new file mode 100644 index 000000000..f885a329c --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/set.js @@ -0,0 +1,29 @@ +'use strict'; + +var Type = require('../type'); + +var _hasOwnProperty = Object.prototype.hasOwnProperty; + +function resolveYamlSet(data) { + if (data === null) return true; + + var key, object = data; + + for (key in object) { + if (_hasOwnProperty.call(object, key)) { + if (object[key] !== null) return false; + } + } + + return true; +} + +function constructYamlSet(data) { + return data !== null ? data : {}; +} + +module.exports = new Type('tag:yaml.org,2002:set', { + kind: 'mapping', + resolve: resolveYamlSet, + construct: constructYamlSet +}); diff --git a/action/node_modules/js-yaml/lib/type/str.js b/action/node_modules/js-yaml/lib/type/str.js new file mode 100644 index 000000000..27acc106c --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/str.js @@ -0,0 +1,8 @@ +'use strict'; + +var Type = require('../type'); + +module.exports = new Type('tag:yaml.org,2002:str', { + kind: 'scalar', + construct: function (data) { return data !== null ? data : ''; } +}); diff --git a/action/node_modules/js-yaml/lib/type/timestamp.js b/action/node_modules/js-yaml/lib/type/timestamp.js new file mode 100644 index 000000000..8fa9c5865 --- /dev/null +++ b/action/node_modules/js-yaml/lib/type/timestamp.js @@ -0,0 +1,88 @@ +'use strict'; + +var Type = require('../type'); + +var YAML_DATE_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9])' + // [2] month + '-([0-9][0-9])$'); // [3] day + +var YAML_TIMESTAMP_REGEXP = new RegExp( + '^([0-9][0-9][0-9][0-9])' + // [1] year + '-([0-9][0-9]?)' + // [2] month + '-([0-9][0-9]?)' + // [3] day + '(?:[Tt]|[ \\t]+)' + // ... + '([0-9][0-9]?)' + // [4] hour + ':([0-9][0-9])' + // [5] minute + ':([0-9][0-9])' + // [6] second + '(?:\\.([0-9]*))?' + // [7] fraction + '(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tz_hour + '(?::([0-9][0-9]))?))?$'); // [11] tz_minute + +function resolveYamlTimestamp(data) { + if (data === null) return false; + if (YAML_DATE_REGEXP.exec(data) !== null) return true; + if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true; + return false; +} + +function constructYamlTimestamp(data) { + var match, year, month, day, hour, minute, second, fraction = 0, + delta = null, tz_hour, tz_minute, date; + + match = YAML_DATE_REGEXP.exec(data); + if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data); + + if (match === null) throw new Error('Date resolve error'); + + // match: [1] year [2] month [3] day + + year = +(match[1]); + month = +(match[2]) - 1; // JS month starts with 0 + day = +(match[3]); + + if (!match[4]) { // no hour + return new Date(Date.UTC(year, month, day)); + } + + // match: [4] hour [5] minute [6] second [7] fraction + + hour = +(match[4]); + minute = +(match[5]); + second = +(match[6]); + + if (match[7]) { + fraction = match[7].slice(0, 3); + while (fraction.length < 3) { // milli-seconds + fraction += '0'; + } + fraction = +fraction; + } + + // match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute + + if (match[9]) { + tz_hour = +(match[10]); + tz_minute = +(match[11] || 0); + delta = (tz_hour * 60 + tz_minute) * 60000; // delta in mili-seconds + if (match[9] === '-') delta = -delta; + } + + date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction)); + + if (delta) date.setTime(date.getTime() - delta); + + return date; +} + +function representYamlTimestamp(object /*, style*/) { + return object.toISOString(); +} + +module.exports = new Type('tag:yaml.org,2002:timestamp', { + kind: 'scalar', + resolve: resolveYamlTimestamp, + construct: constructYamlTimestamp, + instanceOf: Date, + represent: representYamlTimestamp +}); diff --git a/action/node_modules/js-yaml/package.json b/action/node_modules/js-yaml/package.json new file mode 100644 index 000000000..17574da80 --- /dev/null +++ b/action/node_modules/js-yaml/package.json @@ -0,0 +1,66 @@ +{ + "name": "js-yaml", + "version": "4.1.0", + "description": "YAML 1.2 parser and serializer", + "keywords": [ + "yaml", + "parser", + "serializer", + "pyyaml" + ], + "author": "Vladimir Zapparov ", + "contributors": [ + "Aleksey V Zapparov (http://www.ixti.net/)", + "Vitaly Puzrin (https://github.com/puzrin)", + "Martin Grenfell (http://got-ravings.blogspot.com)" + ], + "license": "MIT", + "repository": "nodeca/js-yaml", + "files": [ + "index.js", + "lib/", + "bin/", + "dist/" + ], + "bin": { + "js-yaml": "bin/js-yaml.js" + }, + "module": "./dist/js-yaml.mjs", + "exports": { + ".": { + "import": "./dist/js-yaml.mjs", + "require": "./index.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "lint": "eslint .", + "test": "npm run lint && mocha", + "coverage": "npm run lint && nyc mocha && nyc report --reporter html", + "demo": "npm run lint && node support/build_demo.js", + "gh-demo": "npm run demo && gh-pages -d demo -f", + "browserify": "rollup -c support/rollup.config.js", + "prepublishOnly": "npm run gh-demo" + }, + "unpkg": "dist/js-yaml.min.js", + "jsdelivr": "dist/js-yaml.min.js", + "dependencies": { + "argparse": "^2.0.1" + }, + "devDependencies": { + "@rollup/plugin-commonjs": "^17.0.0", + "@rollup/plugin-node-resolve": "^11.0.0", + "ansi": "^0.3.1", + "benchmark": "^2.1.4", + "codemirror": "^5.13.4", + "eslint": "^7.0.0", + "fast-check": "^2.8.0", + "gh-pages": "^3.1.0", + "mocha": "^8.2.1", + "nyc": "^15.1.0", + "rollup": "^2.34.1", + "rollup-plugin-node-polyfills": "^0.2.1", + "rollup-plugin-terser": "^7.0.2", + "shelljs": "^0.8.4" + } +} diff --git a/action/node_modules/yaml/LICENSE b/action/node_modules/yaml/LICENSE deleted file mode 100644 index 7ca44e3ff..000000000 --- a/action/node_modules/yaml/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright 2018 Eemeli Aro - -Permission to use, copy, modify, and/or distribute this software for any purpose -with or without fee is hereby granted, provided that the above copyright notice -and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND -FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS -OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. diff --git a/action/node_modules/yaml/README.md b/action/node_modules/yaml/README.md deleted file mode 100644 index 2c51aea2a..000000000 --- a/action/node_modules/yaml/README.md +++ /dev/null @@ -1,127 +0,0 @@ -# YAML - -`yaml` is a JavaScript parser and stringifier for [YAML](http://yaml.org/), a human friendly data serialization standard. It supports both parsing and stringifying data using all versions of YAML, along with all common data schemas. As a particularly distinguishing feature, `yaml` fully supports reading and writing comments and blank lines in YAML documents. - -The library is released under the ISC open source license, and the code is [available on GitHub](https://github.com/eemeli/yaml/). It has no external dependencies and runs on Node.js 6 and later, and in browsers from IE 11 upwards. - -For the purposes of versioning, any changes that break any of the endpoints or APIs documented here will be considered semver-major breaking changes. Undocumented library internals may change between minor versions, and previous APIs may be deprecated (but not removed). - -For more information, see the project's documentation site: [**eemeli.org/yaml/v1**](https://eemeli.org/yaml/v1/) - -To install: - -```sh -npm install yaml -``` - -**Note:** This is `yaml@1`. You may also be interested in the next version, currently available as [`yaml@next`](https://www.npmjs.com/package/yaml/v/next). - -## API Overview - -The API provided by `yaml` has three layers, depending on how deep you need to go: [Parse & Stringify](https://eemeli.org/yaml/v1/#parse-amp-stringify), [Documents](https://eemeli.org/yaml/#documents), and the [CST Parser](https://eemeli.org/yaml/#cst-parser). The first has the simplest API and "just works", the second gets you all the bells and whistles supported by the library along with a decent [AST](https://eemeli.org/yaml/#content-nodes), and the third is the closest to YAML source, making it fast, raw, and crude. - -```js -import YAML from 'yaml' -// or -const YAML = require('yaml') -``` - -### Parse & Stringify - -- [`YAML.parse(str, options): value`](https://eemeli.org/yaml/v1/#yaml-parse) -- [`YAML.stringify(value, options): string`](https://eemeli.org/yaml/v1/#yaml-stringify) - -### YAML Documents - -- [`YAML.createNode(value, wrapScalars, tag): Node`](https://eemeli.org/yaml/v1/#creating-nodes) -- [`YAML.defaultOptions`](https://eemeli.org/yaml/v1/#options) -- [`YAML.Document`](https://eemeli.org/yaml/v1/#yaml-documents) - - [`constructor(options)`](https://eemeli.org/yaml/v1/#creating-documents) - - [`defaults`](https://eemeli.org/yaml/v1/#options) - - [`#anchors`](https://eemeli.org/yaml/v1/#working-with-anchors) - - [`#contents`](https://eemeli.org/yaml/v1/#content-nodes) - - [`#errors`](https://eemeli.org/yaml/v1/#errors) -- [`YAML.parseAllDocuments(str, options): YAML.Document[]`](https://eemeli.org/yaml/v1/#parsing-documents) -- [`YAML.parseDocument(str, options): YAML.Document`](https://eemeli.org/yaml/v1/#parsing-documents) - -```js -import { Pair, YAMLMap, YAMLSeq } from 'yaml/types' -``` - -- [`new Pair(key, value)`](https://eemeli.org/yaml/v1/#creating-nodes) -- [`new YAMLMap()`](https://eemeli.org/yaml/v1/#creating-nodes) -- [`new YAMLSeq()`](https://eemeli.org/yaml/v1/#creating-nodes) - -### CST Parser - -```js -import parseCST from 'yaml/parse-cst' -``` - -- [`parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst) -- [`YAML.parseCST(str): CSTDocument[]`](https://eemeli.org/yaml/v1/#parsecst) - -## YAML.parse - -```yaml -# file.yml -YAML: - - A human-readable data serialization language - - https://en.wikipedia.org/wiki/YAML -yaml: - - A complete JavaScript implementation - - https://www.npmjs.com/package/yaml -``` - -```js -import fs from 'fs' -import YAML from 'yaml' - -YAML.parse('3.14159') -// 3.14159 - -YAML.parse('[ true, false, maybe, null ]\n') -// [ true, false, 'maybe', null ] - -const file = fs.readFileSync('./file.yml', 'utf8') -YAML.parse(file) -// { YAML: -// [ 'A human-readable data serialization language', -// 'https://en.wikipedia.org/wiki/YAML' ], -// yaml: -// [ 'A complete JavaScript implementation', -// 'https://www.npmjs.com/package/yaml' ] } -``` - -## YAML.stringify - -```js -import YAML from 'yaml' - -YAML.stringify(3.14159) -// '3.14159\n' - -YAML.stringify([true, false, 'maybe', null]) -// `- true -// - false -// - maybe -// - null -// ` - -YAML.stringify({ number: 3, plain: 'string', block: 'two\nlines\n' }) -// `number: 3 -// plain: string -// block: > -// two -// -// lines -// ` -``` - ---- - -Browser testing provided by: - - - - diff --git a/action/node_modules/yaml/browser/dist/PlainValue-b8036b75.js b/action/node_modules/yaml/browser/dist/PlainValue-b8036b75.js deleted file mode 100644 index 2a4255a29..000000000 --- a/action/node_modules/yaml/browser/dist/PlainValue-b8036b75.js +++ /dev/null @@ -1,1275 +0,0 @@ -function _typeof(obj) { - "@babel/helpers - typeof"; - - if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { - _typeof = function (obj) { - return typeof obj; - }; - } else { - _typeof = function (obj) { - return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; - }; - } - - return _typeof(obj); -} - -function _classCallCheck(instance, Constructor) { - if (!(instance instanceof Constructor)) { - throw new TypeError("Cannot call a class as a function"); - } -} - -function _defineProperties(target, props) { - for (var i = 0; i < props.length; i++) { - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - -function _createClass(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -function _inherits(subClass, superClass) { - if (typeof superClass !== "function" && superClass !== null) { - throw new TypeError("Super expression must either be null or a function"); - } - - subClass.prototype = Object.create(superClass && superClass.prototype, { - constructor: { - value: subClass, - writable: true, - configurable: true - } - }); - if (superClass) _setPrototypeOf(subClass, superClass); -} - -function _getPrototypeOf(o) { - _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { - return o.__proto__ || Object.getPrototypeOf(o); - }; - return _getPrototypeOf(o); -} - -function _setPrototypeOf(o, p) { - _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { - o.__proto__ = p; - return o; - }; - - return _setPrototypeOf(o, p); -} - -function _isNativeReflectConstruct() { - if (typeof Reflect === "undefined" || !Reflect.construct) return false; - if (Reflect.construct.sham) return false; - if (typeof Proxy === "function") return true; - - try { - Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); - return true; - } catch (e) { - return false; - } -} - -function _construct(Parent, args, Class) { - if (_isNativeReflectConstruct()) { - _construct = Reflect.construct; - } else { - _construct = function _construct(Parent, args, Class) { - var a = [null]; - a.push.apply(a, args); - var Constructor = Function.bind.apply(Parent, a); - var instance = new Constructor(); - if (Class) _setPrototypeOf(instance, Class.prototype); - return instance; - }; - } - - return _construct.apply(null, arguments); -} - -function _isNativeFunction(fn) { - return Function.toString.call(fn).indexOf("[native code]") !== -1; -} - -function _wrapNativeSuper(Class) { - var _cache = typeof Map === "function" ? new Map() : undefined; - - _wrapNativeSuper = function _wrapNativeSuper(Class) { - if (Class === null || !_isNativeFunction(Class)) return Class; - - if (typeof Class !== "function") { - throw new TypeError("Super expression must either be null or a function"); - } - - if (typeof _cache !== "undefined") { - if (_cache.has(Class)) return _cache.get(Class); - - _cache.set(Class, Wrapper); - } - - function Wrapper() { - return _construct(Class, arguments, _getPrototypeOf(this).constructor); - } - - Wrapper.prototype = Object.create(Class.prototype, { - constructor: { - value: Wrapper, - enumerable: false, - writable: true, - configurable: true - } - }); - return _setPrototypeOf(Wrapper, Class); - }; - - return _wrapNativeSuper(Class); -} - -function _assertThisInitialized(self) { - if (self === void 0) { - throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); - } - - return self; -} - -function _possibleConstructorReturn(self, call) { - if (call && (typeof call === "object" || typeof call === "function")) { - return call; - } - - return _assertThisInitialized(self); -} - -function _createSuper(Derived) { - var hasNativeReflectConstruct = _isNativeReflectConstruct(); - - return function _createSuperInternal() { - var Super = _getPrototypeOf(Derived), - result; - - if (hasNativeReflectConstruct) { - var NewTarget = _getPrototypeOf(this).constructor; - - result = Reflect.construct(Super, arguments, NewTarget); - } else { - result = Super.apply(this, arguments); - } - - return _possibleConstructorReturn(this, result); - }; -} - -function _superPropBase(object, property) { - while (!Object.prototype.hasOwnProperty.call(object, property)) { - object = _getPrototypeOf(object); - if (object === null) break; - } - - return object; -} - -function _get(target, property, receiver) { - if (typeof Reflect !== "undefined" && Reflect.get) { - _get = Reflect.get; - } else { - _get = function _get(target, property, receiver) { - var base = _superPropBase(target, property); - - if (!base) return; - var desc = Object.getOwnPropertyDescriptor(base, property); - - if (desc.get) { - return desc.get.call(receiver); - } - - return desc.value; - }; - } - - return _get(target, property, receiver || target); -} - -function _slicedToArray(arr, i) { - return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); -} - -function _toArray(arr) { - return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); -} - -function _arrayWithHoles(arr) { - if (Array.isArray(arr)) return arr; -} - -function _iterableToArray(iter) { - if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); -} - -function _iterableToArrayLimit(arr, i) { - if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; - var _arr = []; - var _n = true; - var _d = false; - var _e = undefined; - - try { - for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { - _arr.push(_s.value); - - if (i && _arr.length === i) break; - } - } catch (err) { - _d = true; - _e = err; - } finally { - try { - if (!_n && _i["return"] != null) _i["return"](); - } finally { - if (_d) throw _e; - } - } - - return _arr; -} - -function _unsupportedIterableToArray(o, minLen) { - if (!o) return; - if (typeof o === "string") return _arrayLikeToArray(o, minLen); - var n = Object.prototype.toString.call(o).slice(8, -1); - if (n === "Object" && o.constructor) n = o.constructor.name; - if (n === "Map" || n === "Set") return Array.from(o); - if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); -} - -function _arrayLikeToArray(arr, len) { - if (len == null || len > arr.length) len = arr.length; - - for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; - - return arr2; -} - -function _nonIterableRest() { - throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); -} - -function _createForOfIteratorHelper(o, allowArrayLike) { - var it; - - if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { - if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { - if (it) o = it; - var i = 0; - - var F = function () {}; - - return { - s: F, - n: function () { - if (i >= o.length) return { - done: true - }; - return { - done: false, - value: o[i++] - }; - }, - e: function (e) { - throw e; - }, - f: F - }; - } - - throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); - } - - var normalCompletion = true, - didErr = false, - err; - return { - s: function () { - it = o[Symbol.iterator](); - }, - n: function () { - var step = it.next(); - normalCompletion = step.done; - return step; - }, - e: function (e) { - didErr = true; - err = e; - }, - f: function () { - try { - if (!normalCompletion && it.return != null) it.return(); - } finally { - if (didErr) throw err; - } - } - }; -} - -var Char = { - ANCHOR: '&', - COMMENT: '#', - TAG: '!', - DIRECTIVES_END: '-', - DOCUMENT_END: '.' -}; -var Type = { - ALIAS: 'ALIAS', - BLANK_LINE: 'BLANK_LINE', - BLOCK_FOLDED: 'BLOCK_FOLDED', - BLOCK_LITERAL: 'BLOCK_LITERAL', - COMMENT: 'COMMENT', - DIRECTIVE: 'DIRECTIVE', - DOCUMENT: 'DOCUMENT', - FLOW_MAP: 'FLOW_MAP', - FLOW_SEQ: 'FLOW_SEQ', - MAP: 'MAP', - MAP_KEY: 'MAP_KEY', - MAP_VALUE: 'MAP_VALUE', - PLAIN: 'PLAIN', - QUOTE_DOUBLE: 'QUOTE_DOUBLE', - QUOTE_SINGLE: 'QUOTE_SINGLE', - SEQ: 'SEQ', - SEQ_ITEM: 'SEQ_ITEM' -}; -var defaultTagPrefix = 'tag:yaml.org,2002:'; -var defaultTags = { - MAP: 'tag:yaml.org,2002:map', - SEQ: 'tag:yaml.org,2002:seq', - STR: 'tag:yaml.org,2002:str' -}; - -function findLineStarts(src) { - var ls = [0]; - var offset = src.indexOf('\n'); - - while (offset !== -1) { - offset += 1; - ls.push(offset); - offset = src.indexOf('\n', offset); - } - - return ls; -} - -function getSrcInfo(cst) { - var lineStarts, src; - - if (typeof cst === 'string') { - lineStarts = findLineStarts(cst); - src = cst; - } else { - if (Array.isArray(cst)) cst = cst[0]; - - if (cst && cst.context) { - if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src); - lineStarts = cst.lineStarts; - src = cst.context.src; - } - } - - return { - lineStarts: lineStarts, - src: src - }; -} -/** - * @typedef {Object} LinePos - One-indexed position in the source - * @property {number} line - * @property {number} col - */ - -/** - * Determine the line/col position matching a character offset. - * - * Accepts a source string or a CST document as the second parameter. With - * the latter, starting indices for lines are cached in the document as - * `lineStarts: number[]`. - * - * Returns a one-indexed `{ line, col }` location if found, or - * `undefined` otherwise. - * - * @param {number} offset - * @param {string|Document|Document[]} cst - * @returns {?LinePos} - */ - - -function getLinePos(offset, cst) { - if (typeof offset !== 'number' || offset < 0) return null; - - var _getSrcInfo = getSrcInfo(cst), - lineStarts = _getSrcInfo.lineStarts, - src = _getSrcInfo.src; - - if (!lineStarts || !src || offset > src.length) return null; - - for (var i = 0; i < lineStarts.length; ++i) { - var start = lineStarts[i]; - - if (offset < start) { - return { - line: i, - col: offset - lineStarts[i - 1] + 1 - }; - } - - if (offset === start) return { - line: i + 1, - col: 1 - }; - } - - var line = lineStarts.length; - return { - line: line, - col: offset - lineStarts[line - 1] + 1 - }; -} -/** - * Get a specified line from the source. - * - * Accepts a source string or a CST document as the second parameter. With - * the latter, starting indices for lines are cached in the document as - * `lineStarts: number[]`. - * - * Returns the line as a string if found, or `null` otherwise. - * - * @param {number} line One-indexed line number - * @param {string|Document|Document[]} cst - * @returns {?string} - */ - -function getLine(line, cst) { - var _getSrcInfo2 = getSrcInfo(cst), - lineStarts = _getSrcInfo2.lineStarts, - src = _getSrcInfo2.src; - - if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null; - var start = lineStarts[line - 1]; - var end = lineStarts[line]; // undefined for last line; that's ok for slice() - - while (end && end > start && src[end - 1] === '\n') { - --end; - } - - return src.slice(start, end); -} -/** - * Pretty-print the starting line from the source indicated by the range `pos` - * - * Trims output to `maxWidth` chars while keeping the starting column visible, - * using `…` at either end to indicate dropped characters. - * - * Returns a two-line string (or `null`) with `\n` as separator; the second line - * will hold appropriately indented `^` marks indicating the column range. - * - * @param {Object} pos - * @param {LinePos} pos.start - * @param {LinePos} [pos.end] - * @param {string|Document|Document[]*} cst - * @param {number} [maxWidth=80] - * @returns {?string} - */ - -function getPrettyContext(_ref, cst) { - var start = _ref.start, - end = _ref.end; - var maxWidth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 80; - var src = getLine(start.line, cst); - if (!src) return null; - var col = start.col; - - if (src.length > maxWidth) { - if (col <= maxWidth - 10) { - src = src.substr(0, maxWidth - 1) + '…'; - } else { - var halfWidth = Math.round(maxWidth / 2); - if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…'; - col -= src.length - maxWidth; - src = '…' + src.substr(1 - maxWidth); - } - } - - var errLen = 1; - var errEnd = ''; - - if (end) { - if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) { - errLen = end.col - start.col; - } else { - errLen = Math.min(src.length + 1, maxWidth) - col; - errEnd = '…'; - } - } - - var offset = col > 1 ? ' '.repeat(col - 1) : ''; - var err = '^'.repeat(errLen); - return "".concat(src, "\n").concat(offset).concat(err).concat(errEnd); -} - -var Range = /*#__PURE__*/function () { - function Range(start, end) { - _classCallCheck(this, Range); - - this.start = start; - this.end = end || start; - } - - _createClass(Range, [{ - key: "isEmpty", - value: function isEmpty() { - return typeof this.start !== 'number' || !this.end || this.end <= this.start; - } - /** - * Set `origStart` and `origEnd` to point to the original source range for - * this node, which may differ due to dropped CR characters. - * - * @param {number[]} cr - Positions of dropped CR characters - * @param {number} offset - Starting index of `cr` from the last call - * @returns {number} - The next offset, matching the one found for `origStart` - */ - - }, { - key: "setOrigRange", - value: function setOrigRange(cr, offset) { - var start = this.start, - end = this.end; - - if (cr.length === 0 || end <= cr[0]) { - this.origStart = start; - this.origEnd = end; - return offset; - } - - var i = offset; - - while (i < cr.length) { - if (cr[i] > start) break;else ++i; - } - - this.origStart = start + i; - var nextOffset = i; - - while (i < cr.length) { - // if end was at \n, it should now be at \r - if (cr[i] >= end) break;else ++i; - } - - this.origEnd = end + i; - return nextOffset; - } - }], [{ - key: "copy", - value: function copy(orig) { - return new Range(orig.start, orig.end); - } - }]); - - return Range; -}(); - -/** Root class of all nodes */ - -var Node = /*#__PURE__*/function () { - function Node(type, props, context) { - _classCallCheck(this, Node); - - Object.defineProperty(this, 'context', { - value: context || null, - writable: true - }); - this.error = null; - this.range = null; - this.valueRange = null; - this.props = props || []; - this.type = type; - this.value = null; - } - - _createClass(Node, [{ - key: "getPropValue", - value: function getPropValue(idx, key, skipKey) { - if (!this.context) return null; - var src = this.context.src; - var prop = this.props[idx]; - return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null; - } - }, { - key: "anchor", - get: function get() { - for (var i = 0; i < this.props.length; ++i) { - var anchor = this.getPropValue(i, Char.ANCHOR, true); - if (anchor != null) return anchor; - } - - return null; - } - }, { - key: "comment", - get: function get() { - var comments = []; - - for (var i = 0; i < this.props.length; ++i) { - var comment = this.getPropValue(i, Char.COMMENT, true); - if (comment != null) comments.push(comment); - } - - return comments.length > 0 ? comments.join('\n') : null; - } - }, { - key: "commentHasRequiredWhitespace", - value: function commentHasRequiredWhitespace(start) { - var src = this.context.src; - if (this.header && start === this.header.end) return false; - if (!this.valueRange) return false; - var end = this.valueRange.end; - return start !== end || Node.atBlank(src, end - 1); - } - }, { - key: "hasComment", - get: function get() { - if (this.context) { - var src = this.context.src; - - for (var i = 0; i < this.props.length; ++i) { - if (src[this.props[i].start] === Char.COMMENT) return true; - } - } - - return false; - } - }, { - key: "hasProps", - get: function get() { - if (this.context) { - var src = this.context.src; - - for (var i = 0; i < this.props.length; ++i) { - if (src[this.props[i].start] !== Char.COMMENT) return true; - } - } - - return false; - } - }, { - key: "includesTrailingLines", - get: function get() { - return false; - } - }, { - key: "jsonLike", - get: function get() { - var jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE]; - return jsonLikeTypes.indexOf(this.type) !== -1; - } - }, { - key: "rangeAsLinePos", - get: function get() { - if (!this.range || !this.context) return undefined; - var start = getLinePos(this.range.start, this.context.root); - if (!start) return undefined; - var end = getLinePos(this.range.end, this.context.root); - return { - start: start, - end: end - }; - } - }, { - key: "rawValue", - get: function get() { - if (!this.valueRange || !this.context) return null; - var _this$valueRange = this.valueRange, - start = _this$valueRange.start, - end = _this$valueRange.end; - return this.context.src.slice(start, end); - } - }, { - key: "tag", - get: function get() { - for (var i = 0; i < this.props.length; ++i) { - var tag = this.getPropValue(i, Char.TAG, false); - - if (tag != null) { - if (tag[1] === '<') { - return { - verbatim: tag.slice(2, -1) - }; - } else { - // eslint-disable-next-line no-unused-vars - var _tag$match = tag.match(/^(.*!)([^!]*)$/), - _tag$match2 = _slicedToArray(_tag$match, 3); - _tag$match2[0]; - var handle = _tag$match2[1], - suffix = _tag$match2[2]; - - return { - handle: handle, - suffix: suffix - }; - } - } - } - - return null; - } - }, { - key: "valueRangeContainsNewline", - get: function get() { - if (!this.valueRange || !this.context) return false; - var _this$valueRange2 = this.valueRange, - start = _this$valueRange2.start, - end = _this$valueRange2.end; - var src = this.context.src; - - for (var i = start; i < end; ++i) { - if (src[i] === '\n') return true; - } - - return false; - } - }, { - key: "parseComment", - value: function parseComment(start) { - var src = this.context.src; - - if (src[start] === Char.COMMENT) { - var end = Node.endOfLine(src, start + 1); - var commentRange = new Range(start, end); - this.props.push(commentRange); - return end; - } - - return start; - } - /** - * Populates the `origStart` and `origEnd` values of all ranges for this - * node. Extended by child classes to handle descendant nodes. - * - * @param {number[]} cr - Positions of dropped CR characters - * @param {number} offset - Starting index of `cr` from the last call - * @returns {number} - The next offset, matching the one found for `origStart` - */ - - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - if (this.range) offset = this.range.setOrigRange(cr, offset); - if (this.valueRange) this.valueRange.setOrigRange(cr, offset); - this.props.forEach(function (prop) { - return prop.setOrigRange(cr, offset); - }); - return offset; - } - }, { - key: "toString", - value: function toString() { - var src = this.context.src, - range = this.range, - value = this.value; - if (value != null) return value; - var str = src.slice(range.start, range.end); - return Node.addStringTerminator(src, range.end, str); - } - }], [{ - key: "addStringTerminator", - value: function addStringTerminator(src, offset, str) { - if (str[str.length - 1] === '\n') return str; - var next = Node.endOfWhiteSpace(src, offset); - return next >= src.length || src[next] === '\n' ? str + '\n' : str; - } // ^(---|...) - - }, { - key: "atDocumentBoundary", - value: function atDocumentBoundary(src, offset, sep) { - var ch0 = src[offset]; - if (!ch0) return true; - var prev = src[offset - 1]; - if (prev && prev !== '\n') return false; - - if (sep) { - if (ch0 !== sep) return false; - } else { - if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false; - } - - var ch1 = src[offset + 1]; - var ch2 = src[offset + 2]; - if (ch1 !== ch0 || ch2 !== ch0) return false; - var ch3 = src[offset + 3]; - return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' '; - } - }, { - key: "endOfIdentifier", - value: function endOfIdentifier(src, offset) { - var ch = src[offset]; - var isVerbatim = ch === '<'; - var notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ',']; - - while (ch && notOk.indexOf(ch) === -1) { - ch = src[offset += 1]; - } - - if (isVerbatim && ch === '>') offset += 1; - return offset; - } - }, { - key: "endOfIndent", - value: function endOfIndent(src, offset) { - var ch = src[offset]; - - while (ch === ' ') { - ch = src[offset += 1]; - } - - return offset; - } - }, { - key: "endOfLine", - value: function endOfLine(src, offset) { - var ch = src[offset]; - - while (ch && ch !== '\n') { - ch = src[offset += 1]; - } - - return offset; - } - }, { - key: "endOfWhiteSpace", - value: function endOfWhiteSpace(src, offset) { - var ch = src[offset]; - - while (ch === '\t' || ch === ' ') { - ch = src[offset += 1]; - } - - return offset; - } - }, { - key: "startOfLine", - value: function startOfLine(src, offset) { - var ch = src[offset - 1]; - if (ch === '\n') return offset; - - while (ch && ch !== '\n') { - ch = src[offset -= 1]; - } - - return offset + 1; - } - /** - * End of indentation, or null if the line's indent level is not more - * than `indent` - * - * @param {string} src - * @param {number} indent - * @param {number} lineStart - * @returns {?number} - */ - - }, { - key: "endOfBlockIndent", - value: function endOfBlockIndent(src, indent, lineStart) { - var inEnd = Node.endOfIndent(src, lineStart); - - if (inEnd > lineStart + indent) { - return inEnd; - } else { - var wsEnd = Node.endOfWhiteSpace(src, inEnd); - var ch = src[wsEnd]; - if (!ch || ch === '\n') return wsEnd; - } - - return null; - } - }, { - key: "atBlank", - value: function atBlank(src, offset, endAsBlank) { - var ch = src[offset]; - return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch; - } - }, { - key: "nextNodeIsIndented", - value: function nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) { - if (!ch || indentDiff < 0) return false; - if (indentDiff > 0) return true; - return indicatorAsIndent && ch === '-'; - } // should be at line or string end, or at next non-whitespace char - - }, { - key: "normalizeOffset", - value: function normalizeOffset(src, offset) { - var ch = src[offset]; - return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset); - } // fold single newline into space, multiple newlines to N - 1 newlines - // presumes src[offset] === '\n' - - }, { - key: "foldNewline", - value: function foldNewline(src, offset, indent) { - var inCount = 0; - var error = false; - var fold = ''; - var ch = src[offset + 1]; - - while (ch === ' ' || ch === '\t' || ch === '\n') { - switch (ch) { - case '\n': - inCount = 0; - offset += 1; - fold += '\n'; - break; - - case '\t': - if (inCount <= indent) error = true; - offset = Node.endOfWhiteSpace(src, offset + 2) - 1; - break; - - case ' ': - inCount += 1; - offset += 1; - break; - } - - ch = src[offset + 1]; - } - - if (!fold) fold = ' '; - if (ch && inCount <= indent) error = true; - return { - fold: fold, - offset: offset, - error: error - }; - } - }]); - - return Node; -}(); - -var YAMLError = /*#__PURE__*/function (_Error) { - _inherits(YAMLError, _Error); - - var _super = _createSuper(YAMLError); - - function YAMLError(name, source, message) { - var _this; - - _classCallCheck(this, YAMLError); - - if (!message || !(source instanceof Node)) throw new Error("Invalid arguments for new ".concat(name)); - _this = _super.call(this); - _this.name = name; - _this.message = message; - _this.source = source; - return _this; - } - - _createClass(YAMLError, [{ - key: "makePretty", - value: function makePretty() { - if (!this.source) return; - this.nodeType = this.source.type; - var cst = this.source.context && this.source.context.root; - - if (typeof this.offset === 'number') { - this.range = new Range(this.offset, this.offset + 1); - var start = cst && getLinePos(this.offset, cst); - - if (start) { - var end = { - line: start.line, - col: start.col + 1 - }; - this.linePos = { - start: start, - end: end - }; - } - - delete this.offset; - } else { - this.range = this.source.range; - this.linePos = this.source.rangeAsLinePos; - } - - if (this.linePos) { - var _this$linePos$start = this.linePos.start, - line = _this$linePos$start.line, - col = _this$linePos$start.col; - this.message += " at line ".concat(line, ", column ").concat(col); - var ctx = cst && getPrettyContext(this.linePos, cst); - if (ctx) this.message += ":\n\n".concat(ctx, "\n"); - } - - delete this.source; - } - }]); - - return YAMLError; -}( /*#__PURE__*/_wrapNativeSuper(Error)); -var YAMLReferenceError = /*#__PURE__*/function (_YAMLError) { - _inherits(YAMLReferenceError, _YAMLError); - - var _super2 = _createSuper(YAMLReferenceError); - - function YAMLReferenceError(source, message) { - _classCallCheck(this, YAMLReferenceError); - - return _super2.call(this, 'YAMLReferenceError', source, message); - } - - return YAMLReferenceError; -}(YAMLError); -var YAMLSemanticError = /*#__PURE__*/function (_YAMLError2) { - _inherits(YAMLSemanticError, _YAMLError2); - - var _super3 = _createSuper(YAMLSemanticError); - - function YAMLSemanticError(source, message) { - _classCallCheck(this, YAMLSemanticError); - - return _super3.call(this, 'YAMLSemanticError', source, message); - } - - return YAMLSemanticError; -}(YAMLError); -var YAMLSyntaxError = /*#__PURE__*/function (_YAMLError3) { - _inherits(YAMLSyntaxError, _YAMLError3); - - var _super4 = _createSuper(YAMLSyntaxError); - - function YAMLSyntaxError(source, message) { - _classCallCheck(this, YAMLSyntaxError); - - return _super4.call(this, 'YAMLSyntaxError', source, message); - } - - return YAMLSyntaxError; -}(YAMLError); -var YAMLWarning = /*#__PURE__*/function (_YAMLError4) { - _inherits(YAMLWarning, _YAMLError4); - - var _super5 = _createSuper(YAMLWarning); - - function YAMLWarning(source, message) { - _classCallCheck(this, YAMLWarning); - - return _super5.call(this, 'YAMLWarning', source, message); - } - - return YAMLWarning; -}(YAMLError); - -var PlainValue = /*#__PURE__*/function (_Node) { - _inherits(PlainValue, _Node); - - var _super = _createSuper(PlainValue); - - function PlainValue() { - _classCallCheck(this, PlainValue); - - return _super.apply(this, arguments); - } - - _createClass(PlainValue, [{ - key: "strValue", - get: function get() { - if (!this.valueRange || !this.context) return null; - var _this$valueRange = this.valueRange, - start = _this$valueRange.start, - end = _this$valueRange.end; - var src = this.context.src; - var ch = src[end - 1]; - - while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) { - ch = src[--end - 1]; - } - - var str = ''; - - for (var i = start; i < end; ++i) { - var _ch = src[i]; - - if (_ch === '\n') { - var _Node$foldNewline = Node.foldNewline(src, i, -1), - fold = _Node$foldNewline.fold, - offset = _Node$foldNewline.offset; - - str += fold; - i = offset; - } else if (_ch === ' ' || _ch === '\t') { - // trim trailing whitespace - var wsStart = i; - var next = src[i + 1]; - - while (i < end && (next === ' ' || next === '\t')) { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : _ch; - } else { - str += _ch; - } - } - - var ch0 = src[start]; - - switch (ch0) { - case '\t': - { - var msg = 'Plain value cannot start with a tab character'; - var errors = [new YAMLSemanticError(this, msg)]; - return { - errors: errors, - str: str - }; - } - - case '@': - case '`': - { - var _msg = "Plain value cannot start with reserved character ".concat(ch0); - - var _errors = [new YAMLSemanticError(this, _msg)]; - return { - errors: _errors, - str: str - }; - } - - default: - return str; - } - } - }, { - key: "parseBlockValue", - value: function parseBlockValue(start) { - var _this$context = this.context, - indent = _this$context.indent, - inFlow = _this$context.inFlow, - src = _this$context.src; - var offset = start; - var valueEnd = start; - - for (var ch = src[offset]; ch === '\n'; ch = src[offset]) { - if (Node.atDocumentBoundary(src, offset + 1)) break; - var end = Node.endOfBlockIndent(src, indent, offset + 1); - if (end === null || src[end] === '#') break; - - if (src[end] === '\n') { - offset = end; - } else { - valueEnd = PlainValue.endOfLine(src, end, inFlow); - offset = valueEnd; - } - } - - if (this.valueRange.isEmpty()) this.valueRange.start = start; - this.valueRange.end = valueEnd; - return valueEnd; - } - /** - * Parses a plain value from the source - * - * Accepted forms are: - * ``` - * #comment - * - * first line - * - * first line #comment - * - * first line - * block - * lines - * - * #comment - * block - * lines - * ``` - * where block lines are empty or have an indent level greater than `indent`. - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar, may be `\n` - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var inFlow = context.inFlow, - src = context.src; - var offset = start; - var ch = src[offset]; - - if (ch && ch !== '#' && ch !== '\n') { - offset = PlainValue.endOfLine(src, start, inFlow); - } - - this.valueRange = new Range(start, offset); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - - if (!this.hasComment || this.valueRange.isEmpty()) { - offset = this.parseBlockValue(offset); - } - - return offset; - } - }], [{ - key: "endOfLine", - value: function endOfLine(src, start, inFlow) { - var ch = src[start]; - var offset = start; - - while (ch && ch !== '\n') { - if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break; - var next = src[offset + 1]; - if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break; - if ((ch === ' ' || ch === '\t') && next === '#') break; - offset += 1; - ch = next; - } - - return offset; - } - }]); - - return PlainValue; -}(Node); - -export { Char as C, Node as N, PlainValue as P, Range as R, Type as T, YAMLSyntaxError as Y, _createForOfIteratorHelper as _, _typeof as a, _createClass as b, _classCallCheck as c, defaultTagPrefix as d, _defineProperty as e, YAMLWarning as f, YAMLSemanticError as g, _slicedToArray as h, YAMLError as i, _inherits as j, _createSuper as k, _get as l, _getPrototypeOf as m, defaultTags as n, YAMLReferenceError as o, _assertThisInitialized as p, _toArray as q, _possibleConstructorReturn as r }; diff --git a/action/node_modules/yaml/browser/dist/Schema-e94716c8.js b/action/node_modules/yaml/browser/dist/Schema-e94716c8.js deleted file mode 100644 index f18527dcf..000000000 --- a/action/node_modules/yaml/browser/dist/Schema-e94716c8.js +++ /dev/null @@ -1,682 +0,0 @@ -import { _ as _createForOfIteratorHelper, h as _slicedToArray, a as _typeof, b as _createClass, e as _defineProperty, c as _classCallCheck, d as defaultTagPrefix, n as defaultTags } from './PlainValue-b8036b75.js'; -import { d as YAMLMap, g as resolveMap, Y as YAMLSeq, h as resolveSeq, j as resolveString, c as stringifyString, s as strOptions, S as Scalar, n as nullOptions, a as boolOptions, i as intOptions, k as stringifyNumber, N as Node, A as Alias, P as Pair } from './resolveSeq-492ab440.js'; -import { b as binary, o as omap, p as pairs, s as set, i as intTime, f as floatTime, t as timestamp, a as warnOptionDeprecation } from './warnings-df54cb69.js'; - -function createMap(schema, obj, ctx) { - var map = new YAMLMap(schema); - - if (obj instanceof Map) { - var _iterator = _createForOfIteratorHelper(obj), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = _slicedToArray(_step.value, 2), - key = _step$value[0], - value = _step$value[1]; - - map.items.push(schema.createPair(key, value, ctx)); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } else if (obj && _typeof(obj) === 'object') { - for (var _i = 0, _Object$keys = Object.keys(obj); _i < _Object$keys.length; _i++) { - var _key = _Object$keys[_i]; - map.items.push(schema.createPair(_key, obj[_key], ctx)); - } - } - - if (typeof schema.sortMapEntries === 'function') { - map.items.sort(schema.sortMapEntries); - } - - return map; -} - -var map = { - createNode: createMap, - default: true, - nodeClass: YAMLMap, - tag: 'tag:yaml.org,2002:map', - resolve: resolveMap -}; - -function createSeq(schema, obj, ctx) { - var seq = new YAMLSeq(schema); - - if (obj && obj[Symbol.iterator]) { - var _iterator = _createForOfIteratorHelper(obj), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var it = _step.value; - var v = schema.createNode(it, ctx.wrapScalars, null, ctx); - seq.items.push(v); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } - - return seq; -} - -var seq = { - createNode: createSeq, - default: true, - nodeClass: YAMLSeq, - tag: 'tag:yaml.org,2002:seq', - resolve: resolveSeq -}; - -var string = { - identify: function identify(value) { - return typeof value === 'string'; - }, - default: true, - tag: 'tag:yaml.org,2002:str', - resolve: resolveString, - stringify: function stringify(item, ctx, onComment, onChompKeep) { - ctx = Object.assign({ - actualString: true - }, ctx); - return stringifyString(item, ctx, onComment, onChompKeep); - }, - options: strOptions -}; - -var failsafe = [map, seq, string]; - -/* global BigInt */ - -var intIdentify$2 = function intIdentify(value) { - return typeof value === 'bigint' || Number.isInteger(value); -}; - -var intResolve$1 = function intResolve(src, part, radix) { - return intOptions.asBigInt ? BigInt(src) : parseInt(part, radix); -}; - -function intStringify$1(node, radix, prefix) { - var value = node.value; - if (intIdentify$2(value) && value >= 0) return prefix + value.toString(radix); - return stringifyNumber(node); -} - -var nullObj = { - identify: function identify(value) { - return value == null; - }, - createNode: function createNode(schema, value, ctx) { - return ctx.wrapScalars ? new Scalar(null) : null; - }, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^(?:~|[Nn]ull|NULL)?$/, - resolve: function resolve() { - return null; - }, - options: nullOptions, - stringify: function stringify() { - return nullOptions.nullStr; - } -}; -var boolObj = { - identify: function identify(value) { - return typeof value === 'boolean'; - }, - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, - resolve: function resolve(str) { - return str[0] === 't' || str[0] === 'T'; - }, - options: boolOptions, - stringify: function stringify(_ref) { - var value = _ref.value; - return value ? boolOptions.trueStr : boolOptions.falseStr; - } -}; -var octObj = { - identify: function identify(value) { - return intIdentify$2(value) && value >= 0; - }, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'OCT', - test: /^0o([0-7]+)$/, - resolve: function resolve(str, oct) { - return intResolve$1(str, oct, 8); - }, - options: intOptions, - stringify: function stringify(node) { - return intStringify$1(node, 8, '0o'); - } -}; -var intObj = { - identify: intIdentify$2, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^[-+]?[0-9]+$/, - resolve: function resolve(str) { - return intResolve$1(str, str, 10); - }, - options: intOptions, - stringify: stringifyNumber -}; -var hexObj = { - identify: function identify(value) { - return intIdentify$2(value) && value >= 0; - }, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'HEX', - test: /^0x([0-9a-fA-F]+)$/, - resolve: function resolve(str, hex) { - return intResolve$1(str, hex, 16); - }, - options: intOptions, - stringify: function stringify(node) { - return intStringify$1(node, 16, '0x'); - } -}; -var nanObj = { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^(?:[-+]?\.inf|(\.nan))$/i, - resolve: function resolve(str, nan) { - return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY; - }, - stringify: stringifyNumber -}; -var expObj = { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'EXP', - test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/, - resolve: function resolve(str) { - return parseFloat(str); - }, - stringify: function stringify(_ref2) { - var value = _ref2.value; - return Number(value).toExponential(); - } -}; -var floatObj = { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/, - resolve: function resolve(str, frac1, frac2) { - var frac = frac1 || frac2; - var node = new Scalar(parseFloat(str)); - if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length; - return node; - }, - stringify: stringifyNumber -}; -var core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]); - -/* global BigInt */ - -var intIdentify$1 = function intIdentify(value) { - return typeof value === 'bigint' || Number.isInteger(value); -}; - -var stringifyJSON = function stringifyJSON(_ref) { - var value = _ref.value; - return JSON.stringify(value); -}; - -var json = [map, seq, { - identify: function identify(value) { - return typeof value === 'string'; - }, - default: true, - tag: 'tag:yaml.org,2002:str', - resolve: resolveString, - stringify: stringifyJSON -}, { - identify: function identify(value) { - return value == null; - }, - createNode: function createNode(schema, value, ctx) { - return ctx.wrapScalars ? new Scalar(null) : null; - }, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^null$/, - resolve: function resolve() { - return null; - }, - stringify: stringifyJSON -}, { - identify: function identify(value) { - return typeof value === 'boolean'; - }, - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^true|false$/, - resolve: function resolve(str) { - return str === 'true'; - }, - stringify: stringifyJSON -}, { - identify: intIdentify$1, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^-?(?:0|[1-9][0-9]*)$/, - resolve: function resolve(str) { - return intOptions.asBigInt ? BigInt(str) : parseInt(str, 10); - }, - stringify: function stringify(_ref2) { - var value = _ref2.value; - return intIdentify$1(value) ? value.toString() : JSON.stringify(value); - } -}, { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, - resolve: function resolve(str) { - return parseFloat(str); - }, - stringify: stringifyJSON -}]; - -json.scalarFallback = function (str) { - throw new SyntaxError("Unresolved plain scalar ".concat(JSON.stringify(str))); -}; - -/* global BigInt */ - -var boolStringify = function boolStringify(_ref) { - var value = _ref.value; - return value ? boolOptions.trueStr : boolOptions.falseStr; -}; - -var intIdentify = function intIdentify(value) { - return typeof value === 'bigint' || Number.isInteger(value); -}; - -function intResolve(sign, src, radix) { - var str = src.replace(/_/g, ''); - - if (intOptions.asBigInt) { - switch (radix) { - case 2: - str = "0b".concat(str); - break; - - case 8: - str = "0o".concat(str); - break; - - case 16: - str = "0x".concat(str); - break; - } - - var _n = BigInt(str); - - return sign === '-' ? BigInt(-1) * _n : _n; - } - - var n = parseInt(str, radix); - return sign === '-' ? -1 * n : n; -} - -function intStringify(node, radix, prefix) { - var value = node.value; - - if (intIdentify(value)) { - var str = value.toString(radix); - return value < 0 ? '-' + prefix + str.substr(1) : prefix + str; - } - - return stringifyNumber(node); -} - -var yaml11 = failsafe.concat([{ - identify: function identify(value) { - return value == null; - }, - createNode: function createNode(schema, value, ctx) { - return ctx.wrapScalars ? new Scalar(null) : null; - }, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^(?:~|[Nn]ull|NULL)?$/, - resolve: function resolve() { - return null; - }, - options: nullOptions, - stringify: function stringify() { - return nullOptions.nullStr; - } -}, { - identify: function identify(value) { - return typeof value === 'boolean'; - }, - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, - resolve: function resolve() { - return true; - }, - options: boolOptions, - stringify: boolStringify -}, { - identify: function identify(value) { - return typeof value === 'boolean'; - }, - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i, - resolve: function resolve() { - return false; - }, - options: boolOptions, - stringify: boolStringify -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'BIN', - test: /^([-+]?)0b([0-1_]+)$/, - resolve: function resolve(str, sign, bin) { - return intResolve(sign, bin, 2); - }, - stringify: function stringify(node) { - return intStringify(node, 2, '0b'); - } -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'OCT', - test: /^([-+]?)0([0-7_]+)$/, - resolve: function resolve(str, sign, oct) { - return intResolve(sign, oct, 8); - }, - stringify: function stringify(node) { - return intStringify(node, 8, '0'); - } -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^([-+]?)([0-9][0-9_]*)$/, - resolve: function resolve(str, sign, abs) { - return intResolve(sign, abs, 10); - }, - stringify: stringifyNumber -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'HEX', - test: /^([-+]?)0x([0-9a-fA-F_]+)$/, - resolve: function resolve(str, sign, hex) { - return intResolve(sign, hex, 16); - }, - stringify: function stringify(node) { - return intStringify(node, 16, '0x'); - } -}, { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^(?:[-+]?\.inf|(\.nan))$/i, - resolve: function resolve(str, nan) { - return nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY; - }, - stringify: stringifyNumber -}, { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'EXP', - test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/, - resolve: function resolve(str) { - return parseFloat(str.replace(/_/g, '')); - }, - stringify: function stringify(_ref2) { - var value = _ref2.value; - return Number(value).toExponential(); - } -}, { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/, - resolve: function resolve(str, frac) { - var node = new Scalar(parseFloat(str.replace(/_/g, ''))); - - if (frac) { - var f = frac.replace(/_/g, ''); - if (f[f.length - 1] === '0') node.minFractionDigits = f.length; - } - - return node; - }, - stringify: stringifyNumber -}], binary, omap, pairs, set, intTime, floatTime, timestamp); - -var schemas = { - core: core, - failsafe: failsafe, - json: json, - yaml11: yaml11 -}; -var tags = { - binary: binary, - bool: boolObj, - float: floatObj, - floatExp: expObj, - floatNaN: nanObj, - floatTime: floatTime, - int: intObj, - intHex: hexObj, - intOct: octObj, - intTime: intTime, - map: map, - null: nullObj, - omap: omap, - pairs: pairs, - seq: seq, - set: set, - timestamp: timestamp -}; - -function findTagObject(value, tagName, tags) { - if (tagName) { - var match = tags.filter(function (t) { - return t.tag === tagName; - }); - var tagObj = match.find(function (t) { - return !t.format; - }) || match[0]; - if (!tagObj) throw new Error("Tag ".concat(tagName, " not found")); - return tagObj; - } // TODO: deprecate/remove class check - - - return tags.find(function (t) { - return (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format; - }); -} - -function createNode(value, tagName, ctx) { - if (value instanceof Node) return value; - var defaultPrefix = ctx.defaultPrefix, - onTagObj = ctx.onTagObj, - prevObjects = ctx.prevObjects, - schema = ctx.schema, - wrapScalars = ctx.wrapScalars; - if (tagName && tagName.startsWith('!!')) tagName = defaultPrefix + tagName.slice(2); - var tagObj = findTagObject(value, tagName, schema.tags); - - if (!tagObj) { - if (typeof value.toJSON === 'function') value = value.toJSON(); - if (!value || _typeof(value) !== 'object') return wrapScalars ? new Scalar(value) : value; - tagObj = value instanceof Map ? map : value[Symbol.iterator] ? seq : map; - } - - if (onTagObj) { - onTagObj(tagObj); - delete ctx.onTagObj; - } // Detect duplicate references to the same object & use Alias nodes for all - // after first. The `obj` wrapper allows for circular references to resolve. - - - var obj = { - value: undefined, - node: undefined - }; - - if (value && _typeof(value) === 'object' && prevObjects) { - var prev = prevObjects.get(value); - - if (prev) { - var alias = new Alias(prev); // leaves source dirty; must be cleaned by caller - - ctx.aliasNodes.push(alias); // defined along with prevObjects - - return alias; - } - - obj.value = value; - prevObjects.set(value, obj); - } - - obj.node = tagObj.createNode ? tagObj.createNode(ctx.schema, value, ctx) : wrapScalars ? new Scalar(value) : value; - if (tagName && obj.node instanceof Node) obj.node.tag = tagName; - return obj.node; -} - -function getSchemaTags(schemas, knownTags, customTags, schemaId) { - var tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11' - - if (!tags) { - var keys = Object.keys(schemas).map(function (key) { - return JSON.stringify(key); - }).join(', '); - throw new Error("Unknown schema \"".concat(schemaId, "\"; use one of ").concat(keys)); - } - - if (Array.isArray(customTags)) { - var _iterator = _createForOfIteratorHelper(customTags), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var tag = _step.value; - tags = tags.concat(tag); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } else if (typeof customTags === 'function') { - tags = customTags(tags.slice()); - } - - for (var i = 0; i < tags.length; ++i) { - var _tag = tags[i]; - - if (typeof _tag === 'string') { - var tagObj = knownTags[_tag]; - - if (!tagObj) { - var _keys = Object.keys(knownTags).map(function (key) { - return JSON.stringify(key); - }).join(', '); - - throw new Error("Unknown custom tag \"".concat(_tag, "\"; use one of ").concat(_keys)); - } - - tags[i] = tagObj; - } - } - - return tags; -} - -var sortMapEntriesByKey = function sortMapEntriesByKey(a, b) { - return a.key < b.key ? -1 : a.key > b.key ? 1 : 0; -}; - -var Schema = /*#__PURE__*/function () { - // TODO: remove in v2 - // TODO: remove in v2 - function Schema(_ref) { - var customTags = _ref.customTags, - merge = _ref.merge, - schema = _ref.schema, - sortMapEntries = _ref.sortMapEntries, - deprecatedCustomTags = _ref.tags; - - _classCallCheck(this, Schema); - - this.merge = !!merge; - this.name = schema; - this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null; - if (!customTags && deprecatedCustomTags) warnOptionDeprecation('tags', 'customTags'); - this.tags = getSchemaTags(schemas, tags, customTags || deprecatedCustomTags, schema); - } - - _createClass(Schema, [{ - key: "createNode", - value: function createNode$1(value, wrapScalars, tagName, ctx) { - var baseCtx = { - defaultPrefix: Schema.defaultPrefix, - schema: this, - wrapScalars: wrapScalars - }; - var createCtx = ctx ? Object.assign(ctx, baseCtx) : baseCtx; - return createNode(value, tagName, createCtx); - } - }, { - key: "createPair", - value: function createPair(key, value, ctx) { - if (!ctx) ctx = { - wrapScalars: true - }; - var k = this.createNode(key, ctx.wrapScalars, null, ctx); - var v = this.createNode(value, ctx.wrapScalars, null, ctx); - return new Pair(k, v); - } - }]); - - return Schema; -}(); - -_defineProperty(Schema, "defaultPrefix", defaultTagPrefix); - -_defineProperty(Schema, "defaultTags", defaultTags); - -export { Schema as S }; diff --git a/action/node_modules/yaml/browser/dist/index.js b/action/node_modules/yaml/browser/dist/index.js deleted file mode 100644 index e67898bca..000000000 --- a/action/node_modules/yaml/browser/dist/index.js +++ /dev/null @@ -1,1002 +0,0 @@ -import { d as defaultTagPrefix, _ as _createForOfIteratorHelper, a as _typeof, b as _createClass, c as _classCallCheck, e as _defineProperty, Y as YAMLSyntaxError, T as Type, f as YAMLWarning, g as YAMLSemanticError, h as _slicedToArray, i as YAMLError, j as _inherits, k as _createSuper } from './PlainValue-b8036b75.js'; -import { parse as parse$1 } from './parse-cst.js'; -import { b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions, N as Node, P as Pair, S as Scalar, c as stringifyString, A as Alias, Y as YAMLSeq, d as YAMLMap, M as Merge, C as Collection, r as resolveNode, e as isEmptyPath, t as toJSON, f as addComment } from './resolveSeq-492ab440.js'; -import { S as Schema } from './Schema-e94716c8.js'; -import { w as warn } from './warnings-df54cb69.js'; - -var defaultOptions = { - anchorPrefix: 'a', - customTags: null, - indent: 2, - indentSeq: true, - keepCstNodes: false, - keepNodeTypes: true, - keepBlobsInJSON: true, - mapAsMap: false, - maxAliasCount: 100, - prettyErrors: false, - // TODO Set true in v2 - simpleKeys: false, - version: '1.2' -}; -var scalarOptions = { - get binary() { - return binaryOptions; - }, - - set binary(opt) { - Object.assign(binaryOptions, opt); - }, - - get bool() { - return boolOptions; - }, - - set bool(opt) { - Object.assign(boolOptions, opt); - }, - - get int() { - return intOptions; - }, - - set int(opt) { - Object.assign(intOptions, opt); - }, - - get null() { - return nullOptions; - }, - - set null(opt) { - Object.assign(nullOptions, opt); - }, - - get str() { - return strOptions; - }, - - set str(opt) { - Object.assign(strOptions, opt); - } - -}; -var documentOptions = { - '1.0': { - schema: 'yaml-1.1', - merge: true, - tagPrefixes: [{ - handle: '!', - prefix: defaultTagPrefix - }, { - handle: '!!', - prefix: 'tag:private.yaml.org,2002:' - }] - }, - 1.1: { - schema: 'yaml-1.1', - merge: true, - tagPrefixes: [{ - handle: '!', - prefix: '!' - }, { - handle: '!!', - prefix: defaultTagPrefix - }] - }, - 1.2: { - schema: 'core', - merge: false, - tagPrefixes: [{ - handle: '!', - prefix: '!' - }, { - handle: '!!', - prefix: defaultTagPrefix - }] - } -}; - -function stringifyTag(doc, tag) { - if ((doc.version || doc.options.version) === '1.0') { - var priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/); - if (priv) return '!' + priv[1]; - var vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/); - return vocab ? "!".concat(vocab[1], "/").concat(vocab[2]) : "!".concat(tag.replace(/^tag:/, '')); - } - - var p = doc.tagPrefixes.find(function (p) { - return tag.indexOf(p.prefix) === 0; - }); - - if (!p) { - var dtp = doc.getDefaults().tagPrefixes; - p = dtp && dtp.find(function (p) { - return tag.indexOf(p.prefix) === 0; - }); - } - - if (!p) return tag[0] === '!' ? tag : "!<".concat(tag, ">"); - var suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, function (ch) { - return { - '!': '%21', - ',': '%2C', - '[': '%5B', - ']': '%5D', - '{': '%7B', - '}': '%7D' - }[ch]; - }); - return p.handle + suffix; -} - -function getTagObject(tags, item) { - if (item instanceof Alias) return Alias; - - if (item.tag) { - var match = tags.filter(function (t) { - return t.tag === item.tag; - }); - if (match.length > 0) return match.find(function (t) { - return t.format === item.format; - }) || match[0]; - } - - var tagObj, obj; - - if (item instanceof Scalar) { - obj = item.value; // TODO: deprecate/remove class check - - var _match = tags.filter(function (t) { - return t.identify && t.identify(obj) || t.class && obj instanceof t.class; - }); - - tagObj = _match.find(function (t) { - return t.format === item.format; - }) || _match.find(function (t) { - return !t.format; - }); - } else { - obj = item; - tagObj = tags.find(function (t) { - return t.nodeClass && obj instanceof t.nodeClass; - }); - } - - if (!tagObj) { - var name = obj && obj.constructor ? obj.constructor.name : _typeof(obj); - throw new Error("Tag not resolved for ".concat(name, " value")); - } - - return tagObj; -} // needs to be called before value stringifier to allow for circular anchor refs - - -function stringifyProps(node, tagObj, _ref) { - var anchors = _ref.anchors, - doc = _ref.doc; - var props = []; - var anchor = doc.anchors.getName(node); - - if (anchor) { - anchors[anchor] = node; - props.push("&".concat(anchor)); - } - - if (node.tag) { - props.push(stringifyTag(doc, node.tag)); - } else if (!tagObj.default) { - props.push(stringifyTag(doc, tagObj.tag)); - } - - return props.join(' '); -} - -function stringify$1(item, ctx, onComment, onChompKeep) { - var _ctx$doc = ctx.doc, - anchors = _ctx$doc.anchors, - schema = _ctx$doc.schema; - var tagObj; - - if (!(item instanceof Node)) { - var createCtx = { - aliasNodes: [], - onTagObj: function onTagObj(o) { - return tagObj = o; - }, - prevObjects: new Map() - }; - item = schema.createNode(item, true, null, createCtx); - - var _iterator = _createForOfIteratorHelper(createCtx.aliasNodes), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var alias = _step.value; - alias.source = alias.source.node; - var name = anchors.getName(alias.source); - - if (!name) { - name = anchors.newName(); - anchors.map[name] = alias.source; - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - } - - if (item instanceof Pair) return item.toString(ctx, onComment, onChompKeep); - if (!tagObj) tagObj = getTagObject(schema.tags, item); - var props = stringifyProps(item, tagObj, ctx); - if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1; - var str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof Scalar ? stringifyString(item, ctx, onComment, onChompKeep) : item.toString(ctx, onComment, onChompKeep); - if (!props) return str; - return item instanceof Scalar || str[0] === '{' || str[0] === '[' ? "".concat(props, " ").concat(str) : "".concat(props, "\n").concat(ctx.indent).concat(str); -} - -var Anchors = /*#__PURE__*/function () { - function Anchors(prefix) { - _classCallCheck(this, Anchors); - - _defineProperty(this, "map", Object.create(null)); - - this.prefix = prefix; - } - - _createClass(Anchors, [{ - key: "createAlias", - value: function createAlias(node, name) { - this.setAnchor(node, name); - return new Alias(node); - } - }, { - key: "createMergePair", - value: function createMergePair() { - var _this = this; - - var merge = new Merge(); - - for (var _len = arguments.length, sources = new Array(_len), _key = 0; _key < _len; _key++) { - sources[_key] = arguments[_key]; - } - - merge.value.items = sources.map(function (s) { - if (s instanceof Alias) { - if (s.source instanceof YAMLMap) return s; - } else if (s instanceof YAMLMap) { - return _this.createAlias(s); - } - - throw new Error('Merge sources must be Map nodes or their Aliases'); - }); - return merge; - } - }, { - key: "getName", - value: function getName(node) { - var map = this.map; - return Object.keys(map).find(function (a) { - return map[a] === node; - }); - } - }, { - key: "getNames", - value: function getNames() { - return Object.keys(this.map); - } - }, { - key: "getNode", - value: function getNode(name) { - return this.map[name]; - } - }, { - key: "newName", - value: function newName(prefix) { - if (!prefix) prefix = this.prefix; - var names = Object.keys(this.map); - - for (var i = 1; true; ++i) { - var name = "".concat(prefix).concat(i); - if (!names.includes(name)) return name; - } - } // During parsing, map & aliases contain CST nodes - - }, { - key: "resolveNodes", - value: function resolveNodes() { - var map = this.map, - _cstAliases = this._cstAliases; - Object.keys(map).forEach(function (a) { - map[a] = map[a].resolved; - }); - - _cstAliases.forEach(function (a) { - a.source = a.source.resolved; - }); - - delete this._cstAliases; - } - }, { - key: "setAnchor", - value: function setAnchor(node, name) { - if (node != null && !Anchors.validAnchorNode(node)) { - throw new Error('Anchors may only be set for Scalar, Seq and Map nodes'); - } - - if (name && /[\x00-\x19\s,[\]{}]/.test(name)) { - throw new Error('Anchor names must not contain whitespace or control characters'); - } - - var map = this.map; - var prev = node && Object.keys(map).find(function (a) { - return map[a] === node; - }); - - if (prev) { - if (!name) { - return prev; - } else if (prev !== name) { - delete map[prev]; - map[name] = node; - } - } else { - if (!name) { - if (!node) return null; - name = this.newName(); - } - - map[name] = node; - } - - return name; - } - }], [{ - key: "validAnchorNode", - value: function validAnchorNode(node) { - return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap; - } - }]); - - return Anchors; -}(); - -var visit = function visit(node, tags) { - if (node && _typeof(node) === 'object') { - var tag = node.tag; - - if (node instanceof Collection) { - if (tag) tags[tag] = true; - node.items.forEach(function (n) { - return visit(n, tags); - }); - } else if (node instanceof Pair) { - visit(node.key, tags); - visit(node.value, tags); - } else if (node instanceof Scalar) { - if (tag) tags[tag] = true; - } - } - - return tags; -}; - -var listTagNames = function listTagNames(node) { - return Object.keys(visit(node, {})); -}; - -function parseContents(doc, contents) { - var comments = { - before: [], - after: [] - }; - var body = undefined; - var spaceBefore = false; - - var _iterator = _createForOfIteratorHelper(contents), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var node = _step.value; - - if (node.valueRange) { - if (body !== undefined) { - var msg = 'Document contains trailing content not separated by a ... or --- line'; - doc.errors.push(new YAMLSyntaxError(node, msg)); - break; - } - - var res = resolveNode(doc, node); - - if (spaceBefore) { - res.spaceBefore = true; - spaceBefore = false; - } - - body = res; - } else if (node.comment !== null) { - var cc = body === undefined ? comments.before : comments.after; - cc.push(node.comment); - } else if (node.type === Type.BLANK_LINE) { - spaceBefore = true; - - if (body === undefined && comments.before.length > 0 && !doc.commentBefore) { - // space-separated comments at start are parsed as document comments - doc.commentBefore = comments.before.join('\n'); - comments.before = []; - } - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - doc.contents = body || null; - - if (!body) { - doc.comment = comments.before.concat(comments.after).join('\n') || null; - } else { - var cb = comments.before.join('\n'); - - if (cb) { - var cbNode = body instanceof Collection && body.items[0] ? body.items[0] : body; - cbNode.commentBefore = cbNode.commentBefore ? "".concat(cb, "\n").concat(cbNode.commentBefore) : cb; - } - - doc.comment = comments.after.join('\n') || null; - } -} - -function resolveTagDirective(_ref, directive) { - var tagPrefixes = _ref.tagPrefixes; - - var _directive$parameters = _slicedToArray(directive.parameters, 2), - handle = _directive$parameters[0], - prefix = _directive$parameters[1]; - - if (!handle || !prefix) { - var msg = 'Insufficient parameters given for %TAG directive'; - throw new YAMLSemanticError(directive, msg); - } - - if (tagPrefixes.some(function (p) { - return p.handle === handle; - })) { - var _msg = 'The %TAG directive must only be given at most once per handle in the same document.'; - throw new YAMLSemanticError(directive, _msg); - } - - return { - handle: handle, - prefix: prefix - }; -} - -function resolveYamlDirective(doc, directive) { - var _directive$parameters2 = _slicedToArray(directive.parameters, 1), - version = _directive$parameters2[0]; - - if (directive.name === 'YAML:1.0') version = '1.0'; - - if (!version) { - var msg = 'Insufficient parameters given for %YAML directive'; - throw new YAMLSemanticError(directive, msg); - } - - if (!documentOptions[version]) { - var v0 = doc.version || doc.options.version; - - var _msg2 = "Document will be parsed as YAML ".concat(v0, " rather than YAML ").concat(version); - - doc.warnings.push(new YAMLWarning(directive, _msg2)); - } - - return version; -} - -function parseDirectives(doc, directives, prevDoc) { - var directiveComments = []; - var hasDirectives = false; - - var _iterator = _createForOfIteratorHelper(directives), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var directive = _step.value; - var comment = directive.comment, - name = directive.name; - - switch (name) { - case 'TAG': - try { - doc.tagPrefixes.push(resolveTagDirective(doc, directive)); - } catch (error) { - doc.errors.push(error); - } - - hasDirectives = true; - break; - - case 'YAML': - case 'YAML:1.0': - if (doc.version) { - var msg = 'The %YAML directive must only be given at most once per document.'; - doc.errors.push(new YAMLSemanticError(directive, msg)); - } - - try { - doc.version = resolveYamlDirective(doc, directive); - } catch (error) { - doc.errors.push(error); - } - - hasDirectives = true; - break; - - default: - if (name) { - var _msg3 = "YAML only supports %TAG and %YAML directives, and not %".concat(name); - - doc.warnings.push(new YAMLWarning(directive, _msg3)); - } - - } - - if (comment) directiveComments.push(comment); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) { - var copyTagPrefix = function copyTagPrefix(_ref2) { - var handle = _ref2.handle, - prefix = _ref2.prefix; - return { - handle: handle, - prefix: prefix - }; - }; - - doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix); - doc.version = prevDoc.version; - } - - doc.commentBefore = directiveComments.join('\n') || null; -} - -function assertCollection(contents) { - if (contents instanceof Collection) return true; - throw new Error('Expected a YAML collection as document contents'); -} - -var Document$1 = /*#__PURE__*/function () { - function Document(options) { - _classCallCheck(this, Document); - - this.anchors = new Anchors(options.anchorPrefix); - this.commentBefore = null; - this.comment = null; - this.contents = null; - this.directivesEndMarker = null; - this.errors = []; - this.options = options; - this.schema = null; - this.tagPrefixes = []; - this.version = null; - this.warnings = []; - } - - _createClass(Document, [{ - key: "add", - value: function add(value) { - assertCollection(this.contents); - return this.contents.add(value); - } - }, { - key: "addIn", - value: function addIn(path, value) { - assertCollection(this.contents); - this.contents.addIn(path, value); - } - }, { - key: "delete", - value: function _delete(key) { - assertCollection(this.contents); - return this.contents.delete(key); - } - }, { - key: "deleteIn", - value: function deleteIn(path) { - if (isEmptyPath(path)) { - if (this.contents == null) return false; - this.contents = null; - return true; - } - - assertCollection(this.contents); - return this.contents.deleteIn(path); - } - }, { - key: "getDefaults", - value: function getDefaults() { - return Document.defaults[this.version] || Document.defaults[this.options.version] || {}; - } - }, { - key: "get", - value: function get(key, keepScalar) { - return this.contents instanceof Collection ? this.contents.get(key, keepScalar) : undefined; - } - }, { - key: "getIn", - value: function getIn(path, keepScalar) { - if (isEmptyPath(path)) return !keepScalar && this.contents instanceof Scalar ? this.contents.value : this.contents; - return this.contents instanceof Collection ? this.contents.getIn(path, keepScalar) : undefined; - } - }, { - key: "has", - value: function has(key) { - return this.contents instanceof Collection ? this.contents.has(key) : false; - } - }, { - key: "hasIn", - value: function hasIn(path) { - if (isEmptyPath(path)) return this.contents !== undefined; - return this.contents instanceof Collection ? this.contents.hasIn(path) : false; - } - }, { - key: "set", - value: function set(key, value) { - assertCollection(this.contents); - this.contents.set(key, value); - } - }, { - key: "setIn", - value: function setIn(path, value) { - if (isEmptyPath(path)) this.contents = value;else { - assertCollection(this.contents); - this.contents.setIn(path, value); - } - } - }, { - key: "setSchema", - value: function setSchema(id, customTags) { - if (!id && !customTags && this.schema) return; - if (typeof id === 'number') id = id.toFixed(1); - - if (id === '1.0' || id === '1.1' || id === '1.2') { - if (this.version) this.version = id;else this.options.version = id; - delete this.options.schema; - } else if (id && typeof id === 'string') { - this.options.schema = id; - } - - if (Array.isArray(customTags)) this.options.customTags = customTags; - var opt = Object.assign({}, this.getDefaults(), this.options); - this.schema = new Schema(opt); - } - }, { - key: "parse", - value: function parse(node, prevDoc) { - if (this.options.keepCstNodes) this.cstNode = node; - if (this.options.keepNodeTypes) this.type = 'DOCUMENT'; - var _node$directives = node.directives, - directives = _node$directives === void 0 ? [] : _node$directives, - _node$contents = node.contents, - contents = _node$contents === void 0 ? [] : _node$contents, - directivesEndMarker = node.directivesEndMarker, - error = node.error, - valueRange = node.valueRange; - - if (error) { - if (!error.source) error.source = this; - this.errors.push(error); - } - - parseDirectives(this, directives, prevDoc); - if (directivesEndMarker) this.directivesEndMarker = true; - this.range = valueRange ? [valueRange.start, valueRange.end] : null; - this.setSchema(); - this.anchors._cstAliases = []; - parseContents(this, contents); - this.anchors.resolveNodes(); - - if (this.options.prettyErrors) { - var _iterator = _createForOfIteratorHelper(this.errors), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _error = _step.value; - if (_error instanceof YAMLError) _error.makePretty(); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - var _iterator2 = _createForOfIteratorHelper(this.warnings), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var warn = _step2.value; - if (warn instanceof YAMLError) warn.makePretty(); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - } - - return this; - } - }, { - key: "listNonDefaultTags", - value: function listNonDefaultTags() { - return listTagNames(this.contents).filter(function (t) { - return t.indexOf(Schema.defaultPrefix) !== 0; - }); - } - }, { - key: "setTagPrefix", - value: function setTagPrefix(handle, prefix) { - if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !'); - - if (prefix) { - var prev = this.tagPrefixes.find(function (p) { - return p.handle === handle; - }); - if (prev) prev.prefix = prefix;else this.tagPrefixes.push({ - handle: handle, - prefix: prefix - }); - } else { - this.tagPrefixes = this.tagPrefixes.filter(function (p) { - return p.handle !== handle; - }); - } - } - }, { - key: "toJSON", - value: function toJSON$1(arg, onAnchor) { - var _this = this; - - var _this$options = this.options, - keepBlobsInJSON = _this$options.keepBlobsInJSON, - mapAsMap = _this$options.mapAsMap, - maxAliasCount = _this$options.maxAliasCount; - var keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof Scalar)); - var ctx = { - doc: this, - indentStep: ' ', - keep: keep, - mapAsMap: keep && !!mapAsMap, - maxAliasCount: maxAliasCount, - stringify: stringify$1 // Requiring directly in Pair would create circular dependencies - - }; - var anchorNames = Object.keys(this.anchors.map); - if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(function (name) { - return [_this.anchors.map[name], { - alias: [], - aliasCount: 0, - count: 1 - }]; - })); - - var res = toJSON(this.contents, arg, ctx); - - if (typeof onAnchor === 'function' && ctx.anchors) { - var _iterator3 = _createForOfIteratorHelper(ctx.anchors.values()), - _step3; - - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var _step3$value = _step3.value, - count = _step3$value.count, - _res = _step3$value.res; - onAnchor(_res, count); - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - } - - return res; - } - }, { - key: "toString", - value: function toString() { - if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified'); - var indentSize = this.options.indent; - - if (!Number.isInteger(indentSize) || indentSize <= 0) { - var s = JSON.stringify(indentSize); - throw new Error("\"indent\" option must be a positive integer, not ".concat(s)); - } - - this.setSchema(); - var lines = []; - var hasDirectives = false; - - if (this.version) { - var vd = '%YAML 1.2'; - - if (this.schema.name === 'yaml-1.1') { - if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1'; - } - - lines.push(vd); - hasDirectives = true; - } - - var tagNames = this.listNonDefaultTags(); - this.tagPrefixes.forEach(function (_ref) { - var handle = _ref.handle, - prefix = _ref.prefix; - - if (tagNames.some(function (t) { - return t.indexOf(prefix) === 0; - })) { - lines.push("%TAG ".concat(handle, " ").concat(prefix)); - hasDirectives = true; - } - }); - if (hasDirectives || this.directivesEndMarker) lines.push('---'); - - if (this.commentBefore) { - if (hasDirectives || !this.directivesEndMarker) lines.unshift(''); - lines.unshift(this.commentBefore.replace(/^/gm, '#')); - } - - var ctx = { - anchors: Object.create(null), - doc: this, - indent: '', - indentStep: ' '.repeat(indentSize), - stringify: stringify$1 // Requiring directly in nodes would create circular dependencies - - }; - var chompKeep = false; - var contentComment = null; - - if (this.contents) { - if (this.contents instanceof Node) { - if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push(''); - if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment - - ctx.forceBlockIndent = !!this.comment; - contentComment = this.contents.comment; - } - - var onChompKeep = contentComment ? null : function () { - return chompKeep = true; - }; - var body = stringify$1(this.contents, ctx, function () { - return contentComment = null; - }, onChompKeep); - lines.push(addComment(body, '', contentComment)); - } else if (this.contents !== undefined) { - lines.push(stringify$1(this.contents, ctx)); - } - - if (this.comment) { - if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push(''); - lines.push(this.comment.replace(/^/gm, '#')); - } - - return lines.join('\n') + '\n'; - } - }]); - - return Document; -}(); - -_defineProperty(Document$1, "defaults", documentOptions); - -function createNode(value) { - var wrapScalars = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true; - var tag = arguments.length > 2 ? arguments[2] : undefined; - - if (tag === undefined && typeof wrapScalars === 'string') { - tag = wrapScalars; - wrapScalars = true; - } - - var options = Object.assign({}, Document$1.defaults[defaultOptions.version], defaultOptions); - var schema = new Schema(options); - return schema.createNode(value, wrapScalars, tag); -} - -var Document = /*#__PURE__*/function (_YAMLDocument) { - _inherits(Document, _YAMLDocument); - - var _super = _createSuper(Document); - - function Document(options) { - _classCallCheck(this, Document); - - return _super.call(this, Object.assign({}, defaultOptions, options)); - } - - return Document; -}(Document$1); - -function parseAllDocuments(src, options) { - var stream = []; - var prev; - - var _iterator = _createForOfIteratorHelper(parse$1(src)), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var cstDoc = _step.value; - var doc = new Document(options); - doc.parse(cstDoc, prev); - stream.push(doc); - prev = doc; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return stream; -} - -function parseDocument(src, options) { - var cst = parse$1(src); - var doc = new Document(options).parse(cst[0]); - - if (cst.length > 1) { - var errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()'; - doc.errors.unshift(new YAMLSemanticError(cst[1], errMsg)); - } - - return doc; -} - -function parse(src, options) { - var doc = parseDocument(src, options); - doc.warnings.forEach(function (warning) { - return warn(warning); - }); - if (doc.errors.length > 0) throw doc.errors[0]; - return doc.toJSON(); -} - -function stringify(value, options) { - var doc = new Document(options); - doc.contents = value; - return String(doc); -} - -var YAML = { - createNode: createNode, - defaultOptions: defaultOptions, - Document: Document, - parse: parse, - parseAllDocuments: parseAllDocuments, - parseCST: parse$1, - parseDocument: parseDocument, - scalarOptions: scalarOptions, - stringify: stringify -}; - -export { YAML }; diff --git a/action/node_modules/yaml/browser/dist/legacy-exports.js b/action/node_modules/yaml/browser/dist/legacy-exports.js deleted file mode 100644 index 4400ed652..000000000 --- a/action/node_modules/yaml/browser/dist/legacy-exports.js +++ /dev/null @@ -1,3 +0,0 @@ -export { b as binary, f as floatTime, i as intTime, o as omap, p as pairs, s as set, t as timestamp, c as warnFileDeprecation } from './warnings-df54cb69.js'; -import './PlainValue-b8036b75.js'; -import './resolveSeq-492ab440.js'; diff --git a/action/node_modules/yaml/browser/dist/package.json b/action/node_modules/yaml/browser/dist/package.json deleted file mode 100644 index 5ffd9800b..000000000 --- a/action/node_modules/yaml/browser/dist/package.json +++ /dev/null @@ -1 +0,0 @@ -{ "type": "module" } diff --git a/action/node_modules/yaml/browser/dist/parse-cst.js b/action/node_modules/yaml/browser/dist/parse-cst.js deleted file mode 100644 index b68cf3c6b..000000000 --- a/action/node_modules/yaml/browser/dist/parse-cst.js +++ /dev/null @@ -1,1904 +0,0 @@ -import { j as _inherits, k as _createSuper, c as _classCallCheck, T as Type, b as _createClass, R as Range, N as Node, g as YAMLSemanticError, l as _get, m as _getPrototypeOf, Y as YAMLSyntaxError, C as Char, e as _defineProperty, P as PlainValue } from './PlainValue-b8036b75.js'; - -var BlankLine = /*#__PURE__*/function (_Node) { - _inherits(BlankLine, _Node); - - var _super = _createSuper(BlankLine); - - function BlankLine() { - _classCallCheck(this, BlankLine); - - return _super.call(this, Type.BLANK_LINE); - } - /* istanbul ignore next */ - - - _createClass(BlankLine, [{ - key: "includesTrailingLines", - get: function get() { - // This is never called from anywhere, but if it were, - // this is the value it should return. - return true; - } - /** - * Parses a blank line from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first \n character - * @returns {number} - Index of the character after this - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - this.range = new Range(start, start + 1); - return start + 1; - } - }]); - - return BlankLine; -}(Node); - -var CollectionItem = /*#__PURE__*/function (_Node) { - _inherits(CollectionItem, _Node); - - var _super = _createSuper(CollectionItem); - - function CollectionItem(type, props) { - var _this; - - _classCallCheck(this, CollectionItem); - - _this = _super.call(this, type, props); - _this.node = null; - return _this; - } - - _createClass(CollectionItem, [{ - key: "includesTrailingLines", - get: function get() { - return !!this.node && this.node.includesTrailingLines; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var parseNode = context.parseNode, - src = context.src; - var atLineStart = context.atLineStart, - lineStart = context.lineStart; - if (!atLineStart && this.type === Type.SEQ_ITEM) this.error = new YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line'); - var indent = atLineStart ? start - lineStart : context.indent; - var offset = Node.endOfWhiteSpace(src, start + 1); - var ch = src[offset]; - var inlineComment = ch === '#'; - var comments = []; - var blankLine = null; - - while (ch === '\n' || ch === '#') { - if (ch === '#') { - var _end = Node.endOfLine(src, offset + 1); - - comments.push(new Range(offset, _end)); - offset = _end; - } else { - atLineStart = true; - lineStart = offset + 1; - var wsEnd = Node.endOfWhiteSpace(src, lineStart); - - if (src[wsEnd] === '\n' && comments.length === 0) { - blankLine = new BlankLine(); - lineStart = blankLine.parse({ - src: src - }, lineStart); - } - - offset = Node.endOfIndent(src, lineStart); - } - - ch = src[offset]; - } - - if (Node.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== Type.SEQ_ITEM)) { - this.node = parseNode({ - atLineStart: atLineStart, - inCollection: false, - indent: indent, - lineStart: lineStart, - parent: this - }, offset); - } else if (ch && lineStart > start + 1) { - offset = lineStart - 1; - } - - if (this.node) { - if (blankLine) { - // Only blank lines preceding non-empty nodes are captured. Note that - // this means that collection item range start indices do not always - // increase monotonically. -- eemeli/yaml#126 - var items = context.parent.items || context.parent.contents; - if (items) items.push(blankLine); - } - - if (comments.length) Array.prototype.push.apply(this.props, comments); - offset = this.node.range.end; - } else { - if (inlineComment) { - var c = comments[0]; - this.props.push(c); - offset = c.end; - } else { - offset = Node.endOfLine(src, start + 1); - } - } - - var end = this.node ? this.node.valueRange.end : offset; - this.valueRange = new Range(start, end); - return offset; - } - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - offset = _get(_getPrototypeOf(CollectionItem.prototype), "setOrigRanges", this).call(this, cr, offset); - return this.node ? this.node.setOrigRanges(cr, offset) : offset; - } - }, { - key: "toString", - value: function toString() { - var src = this.context.src, - node = this.node, - range = this.range, - value = this.value; - if (value != null) return value; - var str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end); - return Node.addStringTerminator(src, range.end, str); - } - }]); - - return CollectionItem; -}(Node); - -var Comment = /*#__PURE__*/function (_Node) { - _inherits(Comment, _Node); - - var _super = _createSuper(Comment); - - function Comment() { - _classCallCheck(this, Comment); - - return _super.call(this, Type.COMMENT); - } - /** - * Parses a comment line from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - - _createClass(Comment, [{ - key: "parse", - value: function parse(context, start) { - this.context = context; - var offset = this.parseComment(start); - this.range = new Range(start, offset); - return offset; - } - }]); - - return Comment; -}(Node); - -function grabCollectionEndComments(node) { - var cnode = node; - - while (cnode instanceof CollectionItem) { - cnode = cnode.node; - } - - if (!(cnode instanceof Collection)) return null; - var len = cnode.items.length; - var ci = -1; - - for (var i = len - 1; i >= 0; --i) { - var n = cnode.items[i]; - - if (n.type === Type.COMMENT) { - // Keep sufficiently indented comments with preceding node - var _n$context = n.context, - indent = _n$context.indent, - lineStart = _n$context.lineStart; - if (indent > 0 && n.range.start >= lineStart + indent) break; - ci = i; - } else if (n.type === Type.BLANK_LINE) ci = i;else break; - } - - if (ci === -1) return null; - var ca = cnode.items.splice(ci, len - ci); - var prevEnd = ca[0].range.start; - - while (true) { - cnode.range.end = prevEnd; - if (cnode.valueRange && cnode.valueRange.end > prevEnd) cnode.valueRange.end = prevEnd; - if (cnode === node) break; - cnode = cnode.context.parent; - } - - return ca; -} -var Collection = /*#__PURE__*/function (_Node) { - _inherits(Collection, _Node); - - var _super = _createSuper(Collection); - - function Collection(firstItem) { - var _this; - - _classCallCheck(this, Collection); - - _this = _super.call(this, firstItem.type === Type.SEQ_ITEM ? Type.SEQ : Type.MAP); - - for (var i = firstItem.props.length - 1; i >= 0; --i) { - if (firstItem.props[i].start < firstItem.context.lineStart) { - // props on previous line are assumed by the collection - _this.props = firstItem.props.slice(0, i + 1); - firstItem.props = firstItem.props.slice(i + 1); - var itemRange = firstItem.props[0] || firstItem.valueRange; - firstItem.range.start = itemRange.start; - break; - } - } - - _this.items = [firstItem]; - var ec = grabCollectionEndComments(firstItem); - if (ec) Array.prototype.push.apply(_this.items, ec); - return _this; - } - - _createClass(Collection, [{ - key: "includesTrailingLines", - get: function get() { - return this.items.length > 0; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var parseNode = context.parseNode, - src = context.src; // It's easier to recalculate lineStart here rather than tracking down the - // last context from which to read it -- eemeli/yaml#2 - - var lineStart = Node.startOfLine(src, start); - var firstItem = this.items[0]; // First-item context needs to be correct for later comment handling - // -- eemeli/yaml#17 - - firstItem.context.parent = this; - this.valueRange = Range.copy(firstItem.valueRange); - var indent = firstItem.range.start - firstItem.context.lineStart; - var offset = start; - offset = Node.normalizeOffset(src, offset); - var ch = src[offset]; - var atLineStart = Node.endOfWhiteSpace(src, lineStart) === offset; - var prevIncludesTrailingLines = false; - - while (ch) { - while (ch === '\n' || ch === '#') { - if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) { - var blankLine = new BlankLine(); - offset = blankLine.parse({ - src: src - }, offset); - this.valueRange.end = offset; - - if (offset >= src.length) { - ch = null; - break; - } - - this.items.push(blankLine); - offset -= 1; // blankLine.parse() consumes terminal newline - } else if (ch === '#') { - if (offset < lineStart + indent && !Collection.nextContentHasIndent(src, offset, indent)) { - return offset; - } - - var comment = new Comment(); - offset = comment.parse({ - indent: indent, - lineStart: lineStart, - src: src - }, offset); - this.items.push(comment); - this.valueRange.end = offset; - - if (offset >= src.length) { - ch = null; - break; - } - } - - lineStart = offset + 1; - offset = Node.endOfIndent(src, lineStart); - - if (Node.atBlank(src, offset)) { - var wsEnd = Node.endOfWhiteSpace(src, offset); - var next = src[wsEnd]; - - if (!next || next === '\n' || next === '#') { - offset = wsEnd; - } - } - - ch = src[offset]; - atLineStart = true; - } - - if (!ch) { - break; - } - - if (offset !== lineStart + indent && (atLineStart || ch !== ':')) { - if (offset < lineStart + indent) { - if (lineStart > start) offset = lineStart; - break; - } else if (!this.error) { - var msg = 'All collection items must start at the same column'; - this.error = new YAMLSyntaxError(this, msg); - } - } - - if (firstItem.type === Type.SEQ_ITEM) { - if (ch !== '-') { - if (lineStart > start) offset = lineStart; - break; - } - } else if (ch === '-' && !this.error) { - // map key may start with -, as long as it's followed by a non-whitespace char - var _next = src[offset + 1]; - - if (!_next || _next === '\n' || _next === '\t' || _next === ' ') { - var _msg = 'A collection cannot be both a mapping and a sequence'; - this.error = new YAMLSyntaxError(this, _msg); - } - } - - var node = parseNode({ - atLineStart: atLineStart, - inCollection: true, - indent: indent, - lineStart: lineStart, - parent: this - }, offset); - if (!node) return offset; // at next document start - - this.items.push(node); - this.valueRange.end = node.valueRange.end; - offset = Node.normalizeOffset(src, node.range.end); - ch = src[offset]; - atLineStart = false; - prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range - // has advanced to check the current line's indentation level - // -- eemeli/yaml#10 & eemeli/yaml#38 - - if (ch) { - var ls = offset - 1; - var prev = src[ls]; - - while (prev === ' ' || prev === '\t') { - prev = src[--ls]; - } - - if (prev === '\n') { - lineStart = ls + 1; - atLineStart = true; - } - } - - var ec = grabCollectionEndComments(node); - if (ec) Array.prototype.push.apply(this.items, ec); - } - - return offset; - } - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - offset = _get(_getPrototypeOf(Collection.prototype), "setOrigRanges", this).call(this, cr, offset); - this.items.forEach(function (node) { - offset = node.setOrigRanges(cr, offset); - }); - return offset; - } - }, { - key: "toString", - value: function toString() { - var src = this.context.src, - items = this.items, - range = this.range, - value = this.value; - if (value != null) return value; - var str = src.slice(range.start, items[0].range.start) + String(items[0]); - - for (var i = 1; i < items.length; ++i) { - var item = items[i]; - var _item$context = item.context, - atLineStart = _item$context.atLineStart, - indent = _item$context.indent; - if (atLineStart) for (var _i = 0; _i < indent; ++_i) { - str += ' '; - } - str += String(item); - } - - return Node.addStringTerminator(src, range.end, str); - } - }], [{ - key: "nextContentHasIndent", - value: function nextContentHasIndent(src, offset, indent) { - var lineStart = Node.endOfLine(src, offset) + 1; - offset = Node.endOfWhiteSpace(src, lineStart); - var ch = src[offset]; - if (!ch) return false; - if (offset >= lineStart + indent) return true; - if (ch !== '#' && ch !== '\n') return false; - return Collection.nextContentHasIndent(src, offset, indent); - } - }]); - - return Collection; -}(Node); - -var Directive = /*#__PURE__*/function (_Node) { - _inherits(Directive, _Node); - - var _super = _createSuper(Directive); - - function Directive() { - var _this; - - _classCallCheck(this, Directive); - - _this = _super.call(this, Type.DIRECTIVE); - _this.name = null; - return _this; - } - - _createClass(Directive, [{ - key: "parameters", - get: function get() { - var raw = this.rawValue; - return raw ? raw.trim().split(/[ \t]+/) : []; - } - }, { - key: "parseName", - value: function parseName(start) { - var src = this.context.src; - var offset = start; - var ch = src[offset]; - - while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') { - ch = src[offset += 1]; - } - - this.name = src.slice(start, offset); - return offset; - } - }, { - key: "parseParameters", - value: function parseParameters(start) { - var src = this.context.src; - var offset = start; - var ch = src[offset]; - - while (ch && ch !== '\n' && ch !== '#') { - ch = src[offset += 1]; - } - - this.valueRange = new Range(start, offset); - return offset; - } - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var offset = this.parseName(start + 1); - offset = this.parseParameters(offset); - offset = this.parseComment(offset); - this.range = new Range(start, offset); - return offset; - } - }]); - - return Directive; -}(Node); - -var Document = /*#__PURE__*/function (_Node) { - _inherits(Document, _Node); - - var _super = _createSuper(Document); - - function Document() { - var _this; - - _classCallCheck(this, Document); - - _this = _super.call(this, Type.DOCUMENT); - _this.directives = null; - _this.contents = null; - _this.directivesEndMarker = null; - _this.documentEndMarker = null; - return _this; - } - - _createClass(Document, [{ - key: "parseDirectives", - value: function parseDirectives(start) { - var src = this.context.src; - this.directives = []; - var atLineStart = true; - var hasDirectives = false; - var offset = start; - - while (!Node.atDocumentBoundary(src, offset, Char.DIRECTIVES_END)) { - offset = Document.startCommentOrEndBlankLine(src, offset); - - switch (src[offset]) { - case '\n': - if (atLineStart) { - var blankLine = new BlankLine(); - offset = blankLine.parse({ - src: src - }, offset); - - if (offset < src.length) { - this.directives.push(blankLine); - } - } else { - offset += 1; - atLineStart = true; - } - - break; - - case '#': - { - var comment = new Comment(); - offset = comment.parse({ - src: src - }, offset); - this.directives.push(comment); - atLineStart = false; - } - break; - - case '%': - { - var directive = new Directive(); - offset = directive.parse({ - parent: this, - src: src - }, offset); - this.directives.push(directive); - hasDirectives = true; - atLineStart = false; - } - break; - - default: - if (hasDirectives) { - this.error = new YAMLSemanticError(this, 'Missing directives-end indicator line'); - } else if (this.directives.length > 0) { - this.contents = this.directives; - this.directives = []; - } - - return offset; - } - } - - if (src[offset]) { - this.directivesEndMarker = new Range(offset, offset + 3); - return offset + 3; - } - - if (hasDirectives) { - this.error = new YAMLSemanticError(this, 'Missing directives-end indicator line'); - } else if (this.directives.length > 0) { - this.contents = this.directives; - this.directives = []; - } - - return offset; - } - }, { - key: "parseContents", - value: function parseContents(start) { - var _this$context = this.context, - parseNode = _this$context.parseNode, - src = _this$context.src; - if (!this.contents) this.contents = []; - var lineStart = start; - - while (src[lineStart - 1] === '-') { - lineStart -= 1; - } - - var offset = Node.endOfWhiteSpace(src, start); - var atLineStart = lineStart === start; - this.valueRange = new Range(offset); - - while (!Node.atDocumentBoundary(src, offset, Char.DOCUMENT_END)) { - switch (src[offset]) { - case '\n': - if (atLineStart) { - var blankLine = new BlankLine(); - offset = blankLine.parse({ - src: src - }, offset); - - if (offset < src.length) { - this.contents.push(blankLine); - } - } else { - offset += 1; - atLineStart = true; - } - - lineStart = offset; - break; - - case '#': - { - var comment = new Comment(); - offset = comment.parse({ - src: src - }, offset); - this.contents.push(comment); - atLineStart = false; - } - break; - - default: - { - var iEnd = Node.endOfIndent(src, offset); - var context = { - atLineStart: atLineStart, - indent: -1, - inFlow: false, - inCollection: false, - lineStart: lineStart, - parent: this - }; - var node = parseNode(context, iEnd); - if (!node) return this.valueRange.end = iEnd; // at next document start - - this.contents.push(node); - offset = node.range.end; - atLineStart = false; - var ec = grabCollectionEndComments(node); - if (ec) Array.prototype.push.apply(this.contents, ec); - } - } - - offset = Document.startCommentOrEndBlankLine(src, offset); - } - - this.valueRange.end = offset; - - if (src[offset]) { - this.documentEndMarker = new Range(offset, offset + 3); - offset += 3; - - if (src[offset]) { - offset = Node.endOfWhiteSpace(src, offset); - - if (src[offset] === '#') { - var _comment = new Comment(); - - offset = _comment.parse({ - src: src - }, offset); - this.contents.push(_comment); - } - - switch (src[offset]) { - case '\n': - offset += 1; - break; - - case undefined: - break; - - default: - this.error = new YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix'); - } - } - } - - return offset; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - }, { - key: "parse", - value: function parse(context, start) { - context.root = this; - this.context = context; - var src = context.src; - var offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM - - offset = this.parseDirectives(offset); - offset = this.parseContents(offset); - return offset; - } - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - offset = _get(_getPrototypeOf(Document.prototype), "setOrigRanges", this).call(this, cr, offset); - this.directives.forEach(function (node) { - offset = node.setOrigRanges(cr, offset); - }); - if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset); - this.contents.forEach(function (node) { - offset = node.setOrigRanges(cr, offset); - }); - if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset); - return offset; - } - }, { - key: "toString", - value: function toString() { - var contents = this.contents, - directives = this.directives, - value = this.value; - if (value != null) return value; - var str = directives.join(''); - - if (contents.length > 0) { - if (directives.length > 0 || contents[0].type === Type.COMMENT) str += '---\n'; - str += contents.join(''); - } - - if (str[str.length - 1] !== '\n') str += '\n'; - return str; - } - }], [{ - key: "startCommentOrEndBlankLine", - value: function startCommentOrEndBlankLine(src, start) { - var offset = Node.endOfWhiteSpace(src, start); - var ch = src[offset]; - return ch === '#' || ch === '\n' ? offset : start; - } - }]); - - return Document; -}(Node); - -var Alias = /*#__PURE__*/function (_Node) { - _inherits(Alias, _Node); - - var _super = _createSuper(Alias); - - function Alias() { - _classCallCheck(this, Alias); - - return _super.apply(this, arguments); - } - - _createClass(Alias, [{ - key: "parse", - value: - /** - * Parses an *alias from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - function parse(context, start) { - this.context = context; - var src = context.src; - var offset = Node.endOfIdentifier(src, start + 1); - this.valueRange = new Range(start + 1, offset); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - }]); - - return Alias; -}(Node); - -var Chomp = { - CLIP: 'CLIP', - KEEP: 'KEEP', - STRIP: 'STRIP' -}; -var BlockValue = /*#__PURE__*/function (_Node) { - _inherits(BlockValue, _Node); - - var _super = _createSuper(BlockValue); - - function BlockValue(type, props) { - var _this; - - _classCallCheck(this, BlockValue); - - _this = _super.call(this, type, props); - _this.blockIndent = null; - _this.chomping = Chomp.CLIP; - _this.header = null; - return _this; - } - - _createClass(BlockValue, [{ - key: "includesTrailingLines", - get: function get() { - return this.chomping === Chomp.KEEP; - } - }, { - key: "strValue", - get: function get() { - if (!this.valueRange || !this.context) return null; - var _this$valueRange = this.valueRange, - start = _this$valueRange.start, - end = _this$valueRange.end; - var _this$context = this.context, - indent = _this$context.indent, - src = _this$context.src; - if (this.valueRange.isEmpty()) return ''; - var lastNewLine = null; - var ch = src[end - 1]; - - while (ch === '\n' || ch === '\t' || ch === ' ') { - end -= 1; - - if (end <= start) { - if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens - } - - if (ch === '\n') lastNewLine = end; - ch = src[end - 1]; - } - - var keepStart = end + 1; - - if (lastNewLine) { - if (this.chomping === Chomp.KEEP) { - keepStart = lastNewLine; - end = this.valueRange.end; - } else { - end = lastNewLine; - } - } - - var bi = indent + this.blockIndent; - var folded = this.type === Type.BLOCK_FOLDED; - var atStart = true; - var str = ''; - var sep = ''; - var prevMoreIndented = false; - - for (var i = start; i < end; ++i) { - for (var j = 0; j < bi; ++j) { - if (src[i] !== ' ') break; - i += 1; - } - - var _ch = src[i]; - - if (_ch === '\n') { - if (sep === '\n') str += '\n';else sep = '\n'; - } else { - var lineEnd = Node.endOfLine(src, i); - var line = src.slice(i, lineEnd); - i = lineEnd; - - if (folded && (_ch === ' ' || _ch === '\t') && i < keepStart) { - if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n'; - str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '') - - sep = lineEnd < end && src[lineEnd] || ''; - prevMoreIndented = true; - } else { - str += sep + line; - sep = folded && i < keepStart ? ' ' : '\n'; - prevMoreIndented = false; - } - - if (atStart && line !== '') atStart = false; - } - } - - return this.chomping === Chomp.STRIP ? str : str + '\n'; - } - }, { - key: "parseBlockHeader", - value: function parseBlockHeader(start) { - var src = this.context.src; - var offset = start + 1; - var bi = ''; - - while (true) { - var ch = src[offset]; - - switch (ch) { - case '-': - this.chomping = Chomp.STRIP; - break; - - case '+': - this.chomping = Chomp.KEEP; - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - bi += ch; - break; - - default: - this.blockIndent = Number(bi) || null; - this.header = new Range(start, offset); - return offset; - } - - offset += 1; - } - } - }, { - key: "parseBlockValue", - value: function parseBlockValue(start) { - var _this$context2 = this.context, - indent = _this$context2.indent, - src = _this$context2.src; - var explicit = !!this.blockIndent; - var offset = start; - var valueEnd = start; - var minBlockIndent = 1; - - for (var ch = src[offset]; ch === '\n'; ch = src[offset]) { - offset += 1; - if (Node.atDocumentBoundary(src, offset)) break; - var end = Node.endOfBlockIndent(src, indent, offset); // should not include tab? - - if (end === null) break; - var _ch2 = src[end]; - var lineIndent = end - (offset + indent); - - if (!this.blockIndent) { - // no explicit block indent, none yet detected - if (src[end] !== '\n') { - // first line with non-whitespace content - if (lineIndent < minBlockIndent) { - var msg = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator'; - this.error = new YAMLSemanticError(this, msg); - } - - this.blockIndent = lineIndent; - } else if (lineIndent > minBlockIndent) { - // empty line with more whitespace - minBlockIndent = lineIndent; - } - } else if (_ch2 && _ch2 !== '\n' && lineIndent < this.blockIndent) { - if (src[end] === '#') break; - - if (!this.error) { - var _src = explicit ? 'explicit indentation indicator' : 'first line'; - - var _msg = "Block scalars must not be less indented than their ".concat(_src); - - this.error = new YAMLSemanticError(this, _msg); - } - } - - if (src[end] === '\n') { - offset = end; - } else { - offset = valueEnd = Node.endOfLine(src, end); - } - } - - if (this.chomping !== Chomp.KEEP) { - offset = src[valueEnd] ? valueEnd + 1 : valueEnd; - } - - this.valueRange = new Range(start + 1, offset); - return offset; - } - /** - * Parses a block value from the source - * - * Accepted forms are: - * ``` - * BS - * block - * lines - * - * BS #comment - * block - * lines - * ``` - * where the block style BS matches the regexp `[|>][-+1-9]*` and block lines - * are empty or have an indent level greater than `indent`. - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this block - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var src = context.src; - var offset = this.parseBlockHeader(start); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - offset = this.parseBlockValue(offset); - return offset; - } - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - offset = _get(_getPrototypeOf(BlockValue.prototype), "setOrigRanges", this).call(this, cr, offset); - return this.header ? this.header.setOrigRange(cr, offset) : offset; - } - }]); - - return BlockValue; -}(Node); - -var FlowCollection = /*#__PURE__*/function (_Node) { - _inherits(FlowCollection, _Node); - - var _super = _createSuper(FlowCollection); - - function FlowCollection(type, props) { - var _this; - - _classCallCheck(this, FlowCollection); - - _this = _super.call(this, type, props); - _this.items = null; - return _this; - } - - _createClass(FlowCollection, [{ - key: "prevNodeIsJsonLike", - value: function prevNodeIsJsonLike() { - var idx = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length; - var node = this.items[idx - 1]; - return !!node && (node.jsonLike || node.type === Type.COMMENT && this.prevNodeIsJsonLike(idx - 1)); - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var parseNode = context.parseNode, - src = context.src; - var indent = context.indent, - lineStart = context.lineStart; - var char = src[start]; // { or [ - - this.items = [{ - char: char, - offset: start - }]; - var offset = Node.endOfWhiteSpace(src, start + 1); - char = src[offset]; - - while (char && char !== ']' && char !== '}') { - switch (char) { - case '\n': - { - lineStart = offset + 1; - var wsEnd = Node.endOfWhiteSpace(src, lineStart); - - if (src[wsEnd] === '\n') { - var blankLine = new BlankLine(); - lineStart = blankLine.parse({ - src: src - }, lineStart); - this.items.push(blankLine); - } - - offset = Node.endOfIndent(src, lineStart); - - if (offset <= lineStart + indent) { - char = src[offset]; - - if (offset < lineStart + indent || char !== ']' && char !== '}') { - var msg = 'Insufficient indentation in flow collection'; - this.error = new YAMLSemanticError(this, msg); - } - } - } - break; - - case ',': - { - this.items.push({ - char: char, - offset: offset - }); - offset += 1; - } - break; - - case '#': - { - var comment = new Comment(); - offset = comment.parse({ - src: src - }, offset); - this.items.push(comment); - } - break; - - case '?': - case ':': - { - var next = src[offset + 1]; - - if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace - char === ':' && this.prevNodeIsJsonLike()) { - this.items.push({ - char: char, - offset: offset - }); - offset += 1; - break; - } - } - // fallthrough - - default: - { - var node = parseNode({ - atLineStart: false, - inCollection: false, - inFlow: true, - indent: -1, - lineStart: lineStart, - parent: this - }, offset); - - if (!node) { - // at next document start - this.valueRange = new Range(start, offset); - return offset; - } - - this.items.push(node); - offset = Node.normalizeOffset(src, node.range.end); - } - } - - offset = Node.endOfWhiteSpace(src, offset); - char = src[offset]; - } - - this.valueRange = new Range(start, offset + 1); - - if (char) { - this.items.push({ - char: char, - offset: offset - }); - offset = Node.endOfWhiteSpace(src, offset + 1); - offset = this.parseComment(offset); - } - - return offset; - } - }, { - key: "setOrigRanges", - value: function setOrigRanges(cr, offset) { - offset = _get(_getPrototypeOf(FlowCollection.prototype), "setOrigRanges", this).call(this, cr, offset); - this.items.forEach(function (node) { - if (node instanceof Node) { - offset = node.setOrigRanges(cr, offset); - } else if (cr.length === 0) { - node.origOffset = node.offset; - } else { - var i = offset; - - while (i < cr.length) { - if (cr[i] > node.offset) break;else ++i; - } - - node.origOffset = node.offset + i; - offset = i; - } - }); - return offset; - } - }, { - key: "toString", - value: function toString() { - var src = this.context.src, - items = this.items, - range = this.range, - value = this.value; - if (value != null) return value; - var nodes = items.filter(function (item) { - return item instanceof Node; - }); - var str = ''; - var prevEnd = range.start; - nodes.forEach(function (node) { - var prefix = src.slice(prevEnd, node.range.start); - prevEnd = node.range.end; - str += prefix + String(node); - - if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') { - // Comment range does not include the terminal newline, but its - // stringified value does. Without this fix, newlines at comment ends - // get duplicated. - prevEnd += 1; - } - }); - str += src.slice(prevEnd, range.end); - return Node.addStringTerminator(src, range.end, str); - } - }]); - - return FlowCollection; -}(Node); - -var QuoteDouble = /*#__PURE__*/function (_Node) { - _inherits(QuoteDouble, _Node); - - var _super = _createSuper(QuoteDouble); - - function QuoteDouble() { - _classCallCheck(this, QuoteDouble); - - return _super.apply(this, arguments); - } - - _createClass(QuoteDouble, [{ - key: "strValue", - get: - /** - * @returns {string | { str: string, errors: YAMLSyntaxError[] }} - */ - function get() { - if (!this.valueRange || !this.context) return null; - var errors = []; - var _this$valueRange = this.valueRange, - start = _this$valueRange.start, - end = _this$valueRange.end; - var _this$context = this.context, - indent = _this$context.indent, - src = _this$context.src; - if (src[end - 1] !== '"') errors.push(new YAMLSyntaxError(this, 'Missing closing "quote')); // Using String#replace is too painful with escaped newlines preceded by - // escaped backslashes; also, this should be faster. - - var str = ''; - - for (var i = start + 1; i < end - 1; ++i) { - var ch = src[i]; - - if (ch === '\n') { - if (Node.atDocumentBoundary(src, i + 1)) errors.push(new YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values')); - - var _Node$foldNewline = Node.foldNewline(src, i, indent), - fold = _Node$foldNewline.fold, - offset = _Node$foldNewline.offset, - error = _Node$foldNewline.error; - - str += fold; - i = offset; - if (error) errors.push(new YAMLSemanticError(this, 'Multi-line double-quoted string needs to be sufficiently indented')); - } else if (ch === '\\') { - i += 1; - - switch (src[i]) { - case '0': - str += '\0'; - break; - // null character - - case 'a': - str += '\x07'; - break; - // bell character - - case 'b': - str += '\b'; - break; - // backspace - - case 'e': - str += '\x1b'; - break; - // escape character - - case 'f': - str += '\f'; - break; - // form feed - - case 'n': - str += '\n'; - break; - // line feed - - case 'r': - str += '\r'; - break; - // carriage return - - case 't': - str += '\t'; - break; - // horizontal tab - - case 'v': - str += '\v'; - break; - // vertical tab - - case 'N': - str += "\x85"; - break; - // Unicode next line - - case '_': - str += "\xA0"; - break; - // Unicode non-breaking space - - case 'L': - str += "\u2028"; - break; - // Unicode line separator - - case 'P': - str += "\u2029"; - break; - // Unicode paragraph separator - - case ' ': - str += ' '; - break; - - case '"': - str += '"'; - break; - - case '/': - str += '/'; - break; - - case '\\': - str += '\\'; - break; - - case '\t': - str += '\t'; - break; - - case 'x': - str += this.parseCharCode(i + 1, 2, errors); - i += 2; - break; - - case 'u': - str += this.parseCharCode(i + 1, 4, errors); - i += 4; - break; - - case 'U': - str += this.parseCharCode(i + 1, 8, errors); - i += 8; - break; - - case '\n': - // skip escaped newlines, but still trim the following line - while (src[i + 1] === ' ' || src[i + 1] === '\t') { - i += 1; - } - - break; - - default: - errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(i - 1, 2)))); - str += '\\' + src[i]; - } - } else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - var wsStart = i; - var next = src[i + 1]; - - while (next === ' ' || next === '\t') { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch; - } else { - str += ch; - } - } - - return errors.length > 0 ? { - errors: errors, - str: str - } : str; - } - }, { - key: "parseCharCode", - value: function parseCharCode(offset, length, errors) { - var src = this.context.src; - var cc = src.substr(offset, length); - var ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); - var code = ok ? parseInt(cc, 16) : NaN; - - if (isNaN(code)) { - errors.push(new YAMLSyntaxError(this, "Invalid escape sequence ".concat(src.substr(offset - 2, length + 2)))); - return src.substr(offset - 2, length + 2); - } - - return String.fromCodePoint(code); - } - /** - * Parses a "double quoted" value from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var src = context.src; - var offset = QuoteDouble.endOfQuote(src, start + 1); - this.valueRange = new Range(start, offset); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - }], [{ - key: "endOfQuote", - value: function endOfQuote(src, offset) { - var ch = src[offset]; - - while (ch && ch !== '"') { - offset += ch === '\\' ? 2 : 1; - ch = src[offset]; - } - - return offset + 1; - } - }]); - - return QuoteDouble; -}(Node); - -var QuoteSingle = /*#__PURE__*/function (_Node) { - _inherits(QuoteSingle, _Node); - - var _super = _createSuper(QuoteSingle); - - function QuoteSingle() { - _classCallCheck(this, QuoteSingle); - - return _super.apply(this, arguments); - } - - _createClass(QuoteSingle, [{ - key: "strValue", - get: - /** - * @returns {string | { str: string, errors: YAMLSyntaxError[] }} - */ - function get() { - if (!this.valueRange || !this.context) return null; - var errors = []; - var _this$valueRange = this.valueRange, - start = _this$valueRange.start, - end = _this$valueRange.end; - var _this$context = this.context, - indent = _this$context.indent, - src = _this$context.src; - if (src[end - 1] !== "'") errors.push(new YAMLSyntaxError(this, "Missing closing 'quote")); - var str = ''; - - for (var i = start + 1; i < end - 1; ++i) { - var ch = src[i]; - - if (ch === '\n') { - if (Node.atDocumentBoundary(src, i + 1)) errors.push(new YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values')); - - var _Node$foldNewline = Node.foldNewline(src, i, indent), - fold = _Node$foldNewline.fold, - offset = _Node$foldNewline.offset, - error = _Node$foldNewline.error; - - str += fold; - i = offset; - if (error) errors.push(new YAMLSemanticError(this, 'Multi-line single-quoted string needs to be sufficiently indented')); - } else if (ch === "'") { - str += ch; - i += 1; - if (src[i] !== "'") errors.push(new YAMLSyntaxError(this, 'Unescaped single quote? This should not happen.')); - } else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - var wsStart = i; - var next = src[i + 1]; - - while (next === ' ' || next === '\t') { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch; - } else { - str += ch; - } - } - - return errors.length > 0 ? { - errors: errors, - str: str - } : str; - } - /** - * Parses a 'single quoted' value from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - }, { - key: "parse", - value: function parse(context, start) { - this.context = context; - var src = context.src; - var offset = QuoteSingle.endOfQuote(src, start + 1); - this.valueRange = new Range(start, offset); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - }], [{ - key: "endOfQuote", - value: function endOfQuote(src, offset) { - var ch = src[offset]; - - while (ch) { - if (ch === "'") { - if (src[offset + 1] !== "'") break; - ch = src[offset += 2]; - } else { - ch = src[offset += 1]; - } - } - - return offset + 1; - } - }]); - - return QuoteSingle; -}(Node); - -function createNewNode(type, props) { - switch (type) { - case Type.ALIAS: - return new Alias(type, props); - - case Type.BLOCK_FOLDED: - case Type.BLOCK_LITERAL: - return new BlockValue(type, props); - - case Type.FLOW_MAP: - case Type.FLOW_SEQ: - return new FlowCollection(type, props); - - case Type.MAP_KEY: - case Type.MAP_VALUE: - case Type.SEQ_ITEM: - return new CollectionItem(type, props); - - case Type.COMMENT: - case Type.PLAIN: - return new PlainValue(type, props); - - case Type.QUOTE_DOUBLE: - return new QuoteDouble(type, props); - - case Type.QUOTE_SINGLE: - return new QuoteSingle(type, props); - - /* istanbul ignore next */ - - default: - return null; - // should never happen - } -} -/** - * @param {boolean} atLineStart - Node starts at beginning of line - * @param {boolean} inFlow - true if currently in a flow context - * @param {boolean} inCollection - true if currently in a collection context - * @param {number} indent - Current level of indentation - * @param {number} lineStart - Start of the current line - * @param {Node} parent - The parent of the node - * @param {string} src - Source of the YAML document - */ - - -var ParseContext = /*#__PURE__*/function () { - function ParseContext() { - var _this = this; - - var orig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}, - atLineStart = _ref.atLineStart, - inCollection = _ref.inCollection, - inFlow = _ref.inFlow, - indent = _ref.indent, - lineStart = _ref.lineStart, - parent = _ref.parent; - - _classCallCheck(this, ParseContext); - - _defineProperty(this, "parseNode", function (overlay, start) { - if (Node.atDocumentBoundary(_this.src, start)) return null; - var context = new ParseContext(_this, overlay); - - var _context$parseProps = context.parseProps(start), - props = _context$parseProps.props, - type = _context$parseProps.type, - valueStart = _context$parseProps.valueStart; - - var node = createNewNode(type, props); - var offset = node.parse(context, valueStart); - node.range = new Range(start, offset); - /* istanbul ignore if */ - - if (offset <= start) { - // This should never happen, but if it does, let's make sure to at least - // step one character forward to avoid a busy loop. - node.error = new Error("Node#parse consumed no characters"); - node.error.parseEnd = offset; - node.error.source = node; - node.range.end = start + 1; - } - - if (context.nodeStartsCollection(node)) { - if (!node.error && !context.atLineStart && context.parent.type === Type.DOCUMENT) { - node.error = new YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)'); - } - - var collection = new Collection(node); - offset = collection.parse(new ParseContext(context), offset); - collection.range = new Range(start, offset); - return collection; - } - - return node; - }); - - this.atLineStart = atLineStart != null ? atLineStart : orig.atLineStart || false; - this.inCollection = inCollection != null ? inCollection : orig.inCollection || false; - this.inFlow = inFlow != null ? inFlow : orig.inFlow || false; - this.indent = indent != null ? indent : orig.indent; - this.lineStart = lineStart != null ? lineStart : orig.lineStart; - this.parent = parent != null ? parent : orig.parent || {}; - this.root = orig.root; - this.src = orig.src; - } - - _createClass(ParseContext, [{ - key: "nodeStartsCollection", - value: function nodeStartsCollection(node) { - var inCollection = this.inCollection, - inFlow = this.inFlow, - src = this.src; - if (inCollection || inFlow) return false; - if (node instanceof CollectionItem) return true; // check for implicit key - - var offset = node.range.end; - if (src[offset] === '\n' || src[offset - 1] === '\n') return false; - offset = Node.endOfWhiteSpace(src, offset); - return src[offset] === ':'; - } // Anchor and tag are before type, which determines the node implementation - // class; hence this intermediate step. - - }, { - key: "parseProps", - value: function parseProps(offset) { - var inFlow = this.inFlow, - parent = this.parent, - src = this.src; - var props = []; - var lineHasProps = false; - offset = this.atLineStart ? Node.endOfIndent(src, offset) : Node.endOfWhiteSpace(src, offset); - var ch = src[offset]; - - while (ch === Char.ANCHOR || ch === Char.COMMENT || ch === Char.TAG || ch === '\n') { - if (ch === '\n') { - var inEnd = offset; - var lineStart = void 0; - - do { - lineStart = inEnd + 1; - inEnd = Node.endOfIndent(src, lineStart); - } while (src[inEnd] === '\n'); - - var indentDiff = inEnd - (lineStart + this.indent); - var noIndicatorAsIndent = parent.type === Type.SEQ_ITEM && parent.context.atLineStart; - if (src[inEnd] !== '#' && !Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; - this.atLineStart = true; - this.lineStart = lineStart; - lineHasProps = false; - offset = inEnd; - } else if (ch === Char.COMMENT) { - var end = Node.endOfLine(src, offset + 1); - props.push(new Range(offset, end)); - offset = end; - } else { - var _end = Node.endOfIdentifier(src, offset + 1); - - if (ch === Char.TAG && src[_end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, _end + 13))) { - // Let's presume we're dealing with a YAML 1.0 domain tag here, rather - // than an empty but 'foo.bar' private-tagged node in a flow collection - // followed without whitespace by a plain string starting with a year - // or date divided by something. - _end = Node.endOfIdentifier(src, _end + 5); - } - - props.push(new Range(offset, _end)); - lineHasProps = true; - offset = Node.endOfWhiteSpace(src, _end); - } - - ch = src[offset]; - } // '- &a : b' has an anchor on an empty node - - - if (lineHasProps && ch === ':' && Node.atBlank(src, offset + 1, true)) offset -= 1; - var type = ParseContext.parseType(src, offset, inFlow); - return { - props: props, - type: type, - valueStart: offset - }; - } - /** - * Parses a node from the source - * @param {ParseContext} overlay - * @param {number} start - Index of first non-whitespace character for the node - * @returns {?Node} - null if at a document boundary - */ - - }], [{ - key: "parseType", - value: function parseType(src, offset, inFlow) { - switch (src[offset]) { - case '*': - return Type.ALIAS; - - case '>': - return Type.BLOCK_FOLDED; - - case '|': - return Type.BLOCK_LITERAL; - - case '{': - return Type.FLOW_MAP; - - case '[': - return Type.FLOW_SEQ; - - case '?': - return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_KEY : Type.PLAIN; - - case ':': - return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.MAP_VALUE : Type.PLAIN; - - case '-': - return !inFlow && Node.atBlank(src, offset + 1, true) ? Type.SEQ_ITEM : Type.PLAIN; - - case '"': - return Type.QUOTE_DOUBLE; - - case "'": - return Type.QUOTE_SINGLE; - - default: - return Type.PLAIN; - } - } - }]); - - return ParseContext; -}(); - -// Published as 'yaml/parse-cst' -function parse(src) { - var cr = []; - - if (src.indexOf('\r') !== -1) { - src = src.replace(/\r\n?/g, function (match, offset) { - if (match.length > 1) cr.push(offset); - return '\n'; - }); - } - - var documents = []; - var offset = 0; - - do { - var doc = new Document(); - var context = new ParseContext({ - src: src - }); - offset = doc.parse(context, offset); - documents.push(doc); - } while (offset < src.length); - - documents.setOrigRanges = function () { - if (cr.length === 0) return false; - - for (var i = 1; i < cr.length; ++i) { - cr[i] -= i; - } - - var crOffset = 0; - - for (var _i = 0; _i < documents.length; ++_i) { - crOffset = documents[_i].setOrigRanges(cr, crOffset); - } - - cr.splice(0, cr.length); - return true; - }; - - documents.toString = function () { - return documents.join('...\n'); - }; - - return documents; -} - -export { parse }; diff --git a/action/node_modules/yaml/browser/dist/resolveSeq-492ab440.js b/action/node_modules/yaml/browser/dist/resolveSeq-492ab440.js deleted file mode 100644 index 50c7c1960..000000000 --- a/action/node_modules/yaml/browser/dist/resolveSeq-492ab440.js +++ /dev/null @@ -1,2419 +0,0 @@ -import { c as _classCallCheck, j as _inherits, k as _createSuper, b as _createClass, e as _defineProperty, p as _assertThisInitialized, a as _typeof, q as _toArray, T as Type, _ as _createForOfIteratorHelper, l as _get, m as _getPrototypeOf, o as YAMLReferenceError, r as _possibleConstructorReturn, h as _slicedToArray, g as YAMLSemanticError, n as defaultTags, f as YAMLWarning, C as Char, Y as YAMLSyntaxError, P as PlainValue } from './PlainValue-b8036b75.js'; - -function addCommentBefore(str, indent, comment) { - if (!comment) return str; - var cc = comment.replace(/[\s\S]^/gm, "$&".concat(indent, "#")); - return "#".concat(cc, "\n").concat(indent).concat(str); -} -function addComment(str, indent, comment) { - return !comment ? str : comment.indexOf('\n') === -1 ? "".concat(str, " #").concat(comment) : "".concat(str, "\n") + comment.replace(/^/gm, "".concat(indent || '', "#")); -} - -var Node = function Node() { - _classCallCheck(this, Node); -}; - -function toJSON(value, arg, ctx) { - if (Array.isArray(value)) return value.map(function (v, i) { - return toJSON(v, String(i), ctx); - }); - - if (value && typeof value.toJSON === 'function') { - var anchor = ctx && ctx.anchors && ctx.anchors.get(value); - if (anchor) ctx.onCreate = function (res) { - anchor.res = res; - delete ctx.onCreate; - }; - var res = value.toJSON(arg, ctx); - if (anchor && ctx.onCreate) ctx.onCreate(res); - return res; - } - - if ((!ctx || !ctx.keep) && typeof value === 'bigint') return Number(value); - return value; -} - -var Scalar = /*#__PURE__*/function (_Node) { - _inherits(Scalar, _Node); - - var _super = _createSuper(Scalar); - - function Scalar(value) { - var _this; - - _classCallCheck(this, Scalar); - - _this = _super.call(this); - _this.value = value; - return _this; - } - - _createClass(Scalar, [{ - key: "toJSON", - value: function toJSON$1(arg, ctx) { - return ctx && ctx.keep ? this.value : toJSON(this.value, arg, ctx); - } - }, { - key: "toString", - value: function toString() { - return String(this.value); - } - }]); - - return Scalar; -}(Node); - -function collectionFromPath(schema, path, value) { - var v = value; - - for (var i = path.length - 1; i >= 0; --i) { - var k = path[i]; - - if (Number.isInteger(k) && k >= 0) { - var a = []; - a[k] = v; - v = a; - } else { - var o = {}; - Object.defineProperty(o, k, { - value: v, - writable: true, - enumerable: true, - configurable: true - }); - v = o; - } - } - - return schema.createNode(v, false); -} // null, undefined, or an empty non-string iterable (e.g. []) - - -var isEmptyPath = function isEmptyPath(path) { - return path == null || _typeof(path) === 'object' && path[Symbol.iterator]().next().done; -}; -var Collection = /*#__PURE__*/function (_Node) { - _inherits(Collection, _Node); - - var _super = _createSuper(Collection); - - function Collection(schema) { - var _this; - - _classCallCheck(this, Collection); - - _this = _super.call(this); - - _defineProperty(_assertThisInitialized(_this), "items", []); - - _this.schema = schema; - return _this; - } - - _createClass(Collection, [{ - key: "addIn", - value: function addIn(path, value) { - if (isEmptyPath(path)) this.add(value);else { - var _path = _toArray(path), - key = _path[0], - rest = _path.slice(1); - - var node = this.get(key, true); - if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest)); - } - } - }, { - key: "deleteIn", - value: function deleteIn(_ref) { - var _ref2 = _toArray(_ref), - key = _ref2[0], - rest = _ref2.slice(1); - - if (rest.length === 0) return this.delete(key); - var node = this.get(key, true); - if (node instanceof Collection) return node.deleteIn(rest);else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest)); - } - }, { - key: "getIn", - value: function getIn(_ref3, keepScalar) { - var _ref4 = _toArray(_ref3), - key = _ref4[0], - rest = _ref4.slice(1); - - var node = this.get(key, true); - if (rest.length === 0) return !keepScalar && node instanceof Scalar ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined; - } - }, { - key: "hasAllNullValues", - value: function hasAllNullValues() { - return this.items.every(function (node) { - if (!node || node.type !== 'PAIR') return false; - var n = node.value; - return n == null || n instanceof Scalar && n.value == null && !n.commentBefore && !n.comment && !n.tag; - }); - } - }, { - key: "hasIn", - value: function hasIn(_ref5) { - var _ref6 = _toArray(_ref5), - key = _ref6[0], - rest = _ref6.slice(1); - - if (rest.length === 0) return this.has(key); - var node = this.get(key, true); - return node instanceof Collection ? node.hasIn(rest) : false; - } - }, { - key: "setIn", - value: function setIn(_ref7, value) { - var _ref8 = _toArray(_ref7), - key = _ref8[0], - rest = _ref8.slice(1); - - if (rest.length === 0) { - this.set(key, value); - } else { - var node = this.get(key, true); - if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error("Expected YAML collection at ".concat(key, ". Remaining path: ").concat(rest)); - } - } // overridden in implementations - - /* istanbul ignore next */ - - }, { - key: "toJSON", - value: function toJSON() { - return null; - } - }, { - key: "toString", - value: function toString(ctx, _ref9, onComment, onChompKeep) { - var _this2 = this; - - var blockItem = _ref9.blockItem, - flowChars = _ref9.flowChars, - isMap = _ref9.isMap, - itemIndent = _ref9.itemIndent; - var _ctx = ctx, - indent = _ctx.indent, - indentStep = _ctx.indentStep, - stringify = _ctx.stringify; - var inFlow = this.type === Type.FLOW_MAP || this.type === Type.FLOW_SEQ || ctx.inFlow; - if (inFlow) itemIndent += indentStep; - var allNullValues = isMap && this.hasAllNullValues(); - ctx = Object.assign({}, ctx, { - allNullValues: allNullValues, - indent: itemIndent, - inFlow: inFlow, - type: null - }); - var chompKeep = false; - var hasItemWithNewLine = false; - var nodes = this.items.reduce(function (nodes, item, i) { - var comment; - - if (item) { - if (!chompKeep && item.spaceBefore) nodes.push({ - type: 'comment', - str: '' - }); - if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(function (line) { - nodes.push({ - type: 'comment', - str: "#".concat(line) - }); - }); - if (item.comment) comment = item.comment; - if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true; - } - - chompKeep = false; - var str = stringify(item, ctx, function () { - return comment = null; - }, function () { - return chompKeep = true; - }); - if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true; - if (inFlow && i < _this2.items.length - 1) str += ','; - str = addComment(str, itemIndent, comment); - if (chompKeep && (comment || inFlow)) chompKeep = false; - nodes.push({ - type: 'item', - str: str - }); - return nodes; - }, []); - var str; - - if (nodes.length === 0) { - str = flowChars.start + flowChars.end; - } else if (inFlow) { - var start = flowChars.start, - end = flowChars.end; - var strings = nodes.map(function (n) { - return n.str; - }); - - if (hasItemWithNewLine || strings.reduce(function (sum, str) { - return sum + str.length + 2; - }, 2) > Collection.maxFlowStringSingleLineLength) { - str = start; - - var _iterator = _createForOfIteratorHelper(strings), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var s = _step.value; - str += s ? "\n".concat(indentStep).concat(indent).concat(s) : '\n'; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - str += "\n".concat(indent).concat(end); - } else { - str = "".concat(start, " ").concat(strings.join(' '), " ").concat(end); - } - } else { - var _strings = nodes.map(blockItem); - - str = _strings.shift(); - - var _iterator2 = _createForOfIteratorHelper(_strings), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _s = _step2.value; - str += _s ? "\n".concat(indent).concat(_s) : '\n'; - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - } - - if (this.comment) { - str += '\n' + this.comment.replace(/^/gm, "".concat(indent, "#")); - if (onComment) onComment(); - } else if (chompKeep && onChompKeep) onChompKeep(); - - return str; - } - }]); - - return Collection; -}(Node); - -_defineProperty(Collection, "maxFlowStringSingleLineLength", 60); - -function asItemIndex(key) { - var idx = key instanceof Scalar ? key.value : key; - if (idx && typeof idx === 'string') idx = Number(idx); - return Number.isInteger(idx) && idx >= 0 ? idx : null; -} - -var YAMLSeq = /*#__PURE__*/function (_Collection) { - _inherits(YAMLSeq, _Collection); - - var _super = _createSuper(YAMLSeq); - - function YAMLSeq() { - _classCallCheck(this, YAMLSeq); - - return _super.apply(this, arguments); - } - - _createClass(YAMLSeq, [{ - key: "add", - value: function add(value) { - this.items.push(value); - } - }, { - key: "delete", - value: function _delete(key) { - var idx = asItemIndex(key); - if (typeof idx !== 'number') return false; - var del = this.items.splice(idx, 1); - return del.length > 0; - } - }, { - key: "get", - value: function get(key, keepScalar) { - var idx = asItemIndex(key); - if (typeof idx !== 'number') return undefined; - var it = this.items[idx]; - return !keepScalar && it instanceof Scalar ? it.value : it; - } - }, { - key: "has", - value: function has(key) { - var idx = asItemIndex(key); - return typeof idx === 'number' && idx < this.items.length; - } - }, { - key: "set", - value: function set(key, value) { - var idx = asItemIndex(key); - if (typeof idx !== 'number') throw new Error("Expected a valid index, not ".concat(key, ".")); - this.items[idx] = value; - } - }, { - key: "toJSON", - value: function toJSON$1(_, ctx) { - var seq = []; - if (ctx && ctx.onCreate) ctx.onCreate(seq); - var i = 0; - - var _iterator = _createForOfIteratorHelper(this.items), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var item = _step.value; - seq.push(toJSON(item, String(i++), ctx)); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return seq; - } - }, { - key: "toString", - value: function toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - return _get(_getPrototypeOf(YAMLSeq.prototype), "toString", this).call(this, ctx, { - blockItem: function blockItem(n) { - return n.type === 'comment' ? n.str : "- ".concat(n.str); - }, - flowChars: { - start: '[', - end: ']' - }, - isMap: false, - itemIndent: (ctx.indent || '') + ' ' - }, onComment, onChompKeep); - } - }]); - - return YAMLSeq; -}(Collection); - -var stringifyKey = function stringifyKey(key, jsKey, ctx) { - if (jsKey === null) return ''; - if (_typeof(jsKey) !== 'object') return String(jsKey); - if (key instanceof Node && ctx && ctx.doc) return key.toString({ - anchors: Object.create(null), - doc: ctx.doc, - indent: '', - indentStep: ctx.indentStep, - inFlow: true, - inStringifyKey: true, - stringify: ctx.stringify - }); - return JSON.stringify(jsKey); -}; - -var Pair = /*#__PURE__*/function (_Node) { - _inherits(Pair, _Node); - - var _super = _createSuper(Pair); - - function Pair(key) { - var _this; - - var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; - - _classCallCheck(this, Pair); - - _this = _super.call(this); - _this.key = key; - _this.value = value; - _this.type = Pair.Type.PAIR; - return _this; - } - - _createClass(Pair, [{ - key: "commentBefore", - get: function get() { - return this.key instanceof Node ? this.key.commentBefore : undefined; - }, - set: function set(cb) { - if (this.key == null) this.key = new Scalar(null); - if (this.key instanceof Node) this.key.commentBefore = cb;else { - var msg = 'Pair.commentBefore is an alias for Pair.key.commentBefore. To set it, the key must be a Node.'; - throw new Error(msg); - } - } - }, { - key: "addToJSMap", - value: function addToJSMap(ctx, map) { - var key = toJSON(this.key, '', ctx); - - if (map instanceof Map) { - var value = toJSON(this.value, key, ctx); - map.set(key, value); - } else if (map instanceof Set) { - map.add(key); - } else { - var stringKey = stringifyKey(this.key, key, ctx); - - var _value = toJSON(this.value, stringKey, ctx); - - if (stringKey in map) Object.defineProperty(map, stringKey, { - value: _value, - writable: true, - enumerable: true, - configurable: true - });else map[stringKey] = _value; - } - - return map; - } - }, { - key: "toJSON", - value: function toJSON(_, ctx) { - var pair = ctx && ctx.mapAsMap ? new Map() : {}; - return this.addToJSMap(ctx, pair); - } - }, { - key: "toString", - value: function toString(ctx, onComment, onChompKeep) { - if (!ctx || !ctx.doc) return JSON.stringify(this); - var _ctx$doc$options = ctx.doc.options, - indentSize = _ctx$doc$options.indent, - indentSeq = _ctx$doc$options.indentSeq, - simpleKeys = _ctx$doc$options.simpleKeys; - var key = this.key, - value = this.value; - var keyComment = key instanceof Node && key.comment; - - if (simpleKeys) { - if (keyComment) { - throw new Error('With simple keys, key nodes cannot have comments'); - } - - if (key instanceof Collection) { - var msg = 'With simple keys, collection cannot be used as a key value'; - throw new Error(msg); - } - } - - var explicitKey = !simpleKeys && (!key || keyComment || (key instanceof Node ? key instanceof Collection || key.type === Type.BLOCK_FOLDED || key.type === Type.BLOCK_LITERAL : _typeof(key) === 'object')); - var _ctx = ctx, - doc = _ctx.doc, - indent = _ctx.indent, - indentStep = _ctx.indentStep, - stringify = _ctx.stringify; - ctx = Object.assign({}, ctx, { - implicitKey: !explicitKey, - indent: indent + indentStep - }); - var chompKeep = false; - var str = stringify(key, ctx, function () { - return keyComment = null; - }, function () { - return chompKeep = true; - }); - str = addComment(str, ctx.indent, keyComment); - - if (!explicitKey && str.length > 1024) { - if (simpleKeys) throw new Error('With simple keys, single line scalar must not span more than 1024 characters'); - explicitKey = true; - } - - if (ctx.allNullValues && !simpleKeys) { - if (this.comment) { - str = addComment(str, ctx.indent, this.comment); - if (onComment) onComment(); - } else if (chompKeep && !keyComment && onChompKeep) onChompKeep(); - - return ctx.inFlow && !explicitKey ? str : "? ".concat(str); - } - - str = explicitKey ? "? ".concat(str, "\n").concat(indent, ":") : "".concat(str, ":"); - - if (this.comment) { - // expected (but not strictly required) to be a single-line comment - str = addComment(str, ctx.indent, this.comment); - if (onComment) onComment(); - } - - var vcb = ''; - var valueComment = null; - - if (value instanceof Node) { - if (value.spaceBefore) vcb = '\n'; - - if (value.commentBefore) { - var cs = value.commentBefore.replace(/^/gm, "".concat(ctx.indent, "#")); - vcb += "\n".concat(cs); - } - - valueComment = value.comment; - } else if (value && _typeof(value) === 'object') { - value = doc.schema.createNode(value, true); - } - - ctx.implicitKey = false; - if (!explicitKey && !this.comment && value instanceof Scalar) ctx.indentAtStart = str.length + 1; - chompKeep = false; - - if (!indentSeq && indentSize >= 2 && !ctx.inFlow && !explicitKey && value instanceof YAMLSeq && value.type !== Type.FLOW_SEQ && !value.tag && !doc.anchors.getName(value)) { - // If indentSeq === false, consider '- ' as part of indentation where possible - ctx.indent = ctx.indent.substr(2); - } - - var valueStr = stringify(value, ctx, function () { - return valueComment = null; - }, function () { - return chompKeep = true; - }); - var ws = ' '; - - if (vcb || this.comment) { - ws = "".concat(vcb, "\n").concat(ctx.indent); - } else if (!explicitKey && value instanceof Collection) { - var flow = valueStr[0] === '[' || valueStr[0] === '{'; - if (!flow || valueStr.includes('\n')) ws = "\n".concat(ctx.indent); - } else if (valueStr[0] === '\n') ws = ''; - - if (chompKeep && !valueComment && onChompKeep) onChompKeep(); - return addComment(str + ws + valueStr, ctx.indent, valueComment); - } - }]); - - return Pair; -}(Node); - -_defineProperty(Pair, "Type", { - PAIR: 'PAIR', - MERGE_PAIR: 'MERGE_PAIR' -}); - -var getAliasCount = function getAliasCount(node, anchors) { - if (node instanceof Alias) { - var anchor = anchors.get(node.source); - return anchor.count * anchor.aliasCount; - } else if (node instanceof Collection) { - var count = 0; - - var _iterator = _createForOfIteratorHelper(node.items), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var item = _step.value; - var c = getAliasCount(item, anchors); - if (c > count) count = c; - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return count; - } else if (node instanceof Pair) { - var kc = getAliasCount(node.key, anchors); - var vc = getAliasCount(node.value, anchors); - return Math.max(kc, vc); - } - - return 1; -}; - -var Alias = /*#__PURE__*/function (_Node) { - _inherits(Alias, _Node); - - var _super = _createSuper(Alias); - - function Alias(source) { - var _this; - - _classCallCheck(this, Alias); - - _this = _super.call(this); - _this.source = source; - _this.type = Type.ALIAS; - return _this; - } - - _createClass(Alias, [{ - key: "tag", - set: function set(t) { - throw new Error('Alias nodes cannot have tags'); - } - }, { - key: "toJSON", - value: function toJSON$1(arg, ctx) { - if (!ctx) return toJSON(this.source, arg, ctx); - var anchors = ctx.anchors, - maxAliasCount = ctx.maxAliasCount; - var anchor = anchors.get(this.source); - /* istanbul ignore if */ - - if (!anchor || anchor.res === undefined) { - var msg = 'This should not happen: Alias anchor was not resolved?'; - if (this.cstNode) throw new YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg); - } - - if (maxAliasCount >= 0) { - anchor.count += 1; - if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors); - - if (anchor.count * anchor.aliasCount > maxAliasCount) { - var _msg = 'Excessive alias count indicates a resource exhaustion attack'; - if (this.cstNode) throw new YAMLReferenceError(this.cstNode, _msg);else throw new ReferenceError(_msg); - } - } - - return anchor.res; - } // Only called when stringifying an alias mapping key while constructing - // Object output. - - }, { - key: "toString", - value: function toString(ctx) { - return Alias.stringify(this, ctx); - } - }], [{ - key: "stringify", - value: function stringify(_ref, _ref2) { - var range = _ref.range, - source = _ref.source; - var anchors = _ref2.anchors, - doc = _ref2.doc, - implicitKey = _ref2.implicitKey, - inStringifyKey = _ref2.inStringifyKey; - var anchor = Object.keys(anchors).find(function (a) { - return anchors[a] === source; - }); - if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName(); - if (anchor) return "*".concat(anchor).concat(implicitKey ? ' ' : ''); - var msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node'; - throw new Error("".concat(msg, " [").concat(range, "]")); - } - }]); - - return Alias; -}(Node); - -_defineProperty(Alias, "default", true); - -function findPair(items, key) { - var k = key instanceof Scalar ? key.value : key; - - var _iterator = _createForOfIteratorHelper(items), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var it = _step.value; - - if (it instanceof Pair) { - if (it.key === key || it.key === k) return it; - if (it.key && it.key.value === k) return it; - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return undefined; -} -var YAMLMap = /*#__PURE__*/function (_Collection) { - _inherits(YAMLMap, _Collection); - - var _super = _createSuper(YAMLMap); - - function YAMLMap() { - _classCallCheck(this, YAMLMap); - - return _super.apply(this, arguments); - } - - _createClass(YAMLMap, [{ - key: "add", - value: function add(pair, overwrite) { - if (!pair) pair = new Pair(pair);else if (!(pair instanceof Pair)) pair = new Pair(pair.key || pair, pair.value); - var prev = findPair(this.items, pair.key); - var sortEntries = this.schema && this.schema.sortMapEntries; - - if (prev) { - if (overwrite) prev.value = pair.value;else throw new Error("Key ".concat(pair.key, " already set")); - } else if (sortEntries) { - var i = this.items.findIndex(function (item) { - return sortEntries(pair, item) < 0; - }); - if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair); - } else { - this.items.push(pair); - } - } - }, { - key: "delete", - value: function _delete(key) { - var it = findPair(this.items, key); - if (!it) return false; - var del = this.items.splice(this.items.indexOf(it), 1); - return del.length > 0; - } - }, { - key: "get", - value: function get(key, keepScalar) { - var it = findPair(this.items, key); - var node = it && it.value; - return !keepScalar && node instanceof Scalar ? node.value : node; - } - }, { - key: "has", - value: function has(key) { - return !!findPair(this.items, key); - } - }, { - key: "set", - value: function set(key, value) { - this.add(new Pair(key, value), true); - } - /** - * @param {*} arg ignored - * @param {*} ctx Conversion context, originally set in Document#toJSON() - * @param {Class} Type If set, forces the returned collection type - * @returns {*} Instance of Type, Map, or Object - */ - - }, { - key: "toJSON", - value: function toJSON(_, ctx, Type) { - var map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {}; - if (ctx && ctx.onCreate) ctx.onCreate(map); - - var _iterator2 = _createForOfIteratorHelper(this.items), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var item = _step2.value; - item.addToJSMap(ctx, map); - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - - return map; - } - }, { - key: "toString", - value: function toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - - var _iterator3 = _createForOfIteratorHelper(this.items), - _step3; - - try { - for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { - var item = _step3.value; - if (!(item instanceof Pair)) throw new Error("Map items must all be pairs; found ".concat(JSON.stringify(item), " instead")); - } - } catch (err) { - _iterator3.e(err); - } finally { - _iterator3.f(); - } - - return _get(_getPrototypeOf(YAMLMap.prototype), "toString", this).call(this, ctx, { - blockItem: function blockItem(n) { - return n.str; - }, - flowChars: { - start: '{', - end: '}' - }, - isMap: true, - itemIndent: ctx.indent || '' - }, onComment, onChompKeep); - } - }]); - - return YAMLMap; -}(Collection); - -var MERGE_KEY = '<<'; -var Merge = /*#__PURE__*/function (_Pair) { - _inherits(Merge, _Pair); - - var _super = _createSuper(Merge); - - function Merge(pair) { - var _this; - - _classCallCheck(this, Merge); - - if (pair instanceof Pair) { - var seq = pair.value; - - if (!(seq instanceof YAMLSeq)) { - seq = new YAMLSeq(); - seq.items.push(pair.value); - seq.range = pair.value.range; - } - - _this = _super.call(this, pair.key, seq); - _this.range = pair.range; - } else { - _this = _super.call(this, new Scalar(MERGE_KEY), new YAMLSeq()); - } - - _this.type = Pair.Type.MERGE_PAIR; - return _possibleConstructorReturn(_this); - } // If the value associated with a merge key is a single mapping node, each of - // its key/value pairs is inserted into the current mapping, unless the key - // already exists in it. If the value associated with the merge key is a - // sequence, then this sequence is expected to contain mapping nodes and each - // of these nodes is merged in turn according to its order in the sequence. - // Keys in mapping nodes earlier in the sequence override keys specified in - // later mapping nodes. -- http://yaml.org/type/merge.html - - - _createClass(Merge, [{ - key: "addToJSMap", - value: function addToJSMap(ctx, map) { - var _iterator = _createForOfIteratorHelper(this.value.items), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var source = _step.value.source; - if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps'); - var srcMap = source.toJSON(null, ctx, Map); - - var _iterator2 = _createForOfIteratorHelper(srcMap), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var _step2$value = _slicedToArray(_step2.value, 2), - key = _step2$value[0], - value = _step2$value[1]; - - if (map instanceof Map) { - if (!map.has(key)) map.set(key, value); - } else if (map instanceof Set) { - map.add(key); - } else if (!Object.prototype.hasOwnProperty.call(map, key)) { - Object.defineProperty(map, key, { - value: value, - writable: true, - enumerable: true, - configurable: true - }); - } - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return map; - } - }, { - key: "toString", - value: function toString(ctx, onComment) { - var seq = this.value; - if (seq.items.length > 1) return _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment); - this.value = seq.items[0]; - - var str = _get(_getPrototypeOf(Merge.prototype), "toString", this).call(this, ctx, onComment); - - this.value = seq; - return str; - } - }]); - - return Merge; -}(Pair); - -var binaryOptions = { - defaultType: Type.BLOCK_LITERAL, - lineWidth: 76 -}; -var boolOptions = { - trueStr: 'true', - falseStr: 'false' -}; -var intOptions = { - asBigInt: false -}; -var nullOptions = { - nullStr: 'null' -}; -var strOptions = { - defaultType: Type.PLAIN, - doubleQuoted: { - jsonEncoding: false, - minMultiLineLength: 40 - }, - fold: { - lineWidth: 80, - minContentWidth: 20 - } -}; - -function resolveScalar(str, tags, scalarFallback) { - var _iterator = _createForOfIteratorHelper(tags), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = _step.value, - format = _step$value.format, - test = _step$value.test, - resolve = _step$value.resolve; - - if (test) { - var match = str.match(test); - - if (match) { - var res = resolve.apply(null, match); - if (!(res instanceof Scalar)) res = new Scalar(res); - if (format) res.format = format; - return res; - } - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - if (scalarFallback) str = scalarFallback(str); - return new Scalar(str); -} - -var FOLD_FLOW = 'flow'; -var FOLD_BLOCK = 'block'; -var FOLD_QUOTED = 'quoted'; // presumes i+1 is at the start of a line -// returns index of last newline in more-indented block - -var consumeMoreIndentedLines = function consumeMoreIndentedLines(text, i) { - var ch = text[i + 1]; - - while (ch === ' ' || ch === '\t') { - do { - ch = text[i += 1]; - } while (ch && ch !== '\n'); - - ch = text[i + 1]; - } - - return i; -}; -/** - * Tries to keep input at up to `lineWidth` characters, splitting only on spaces - * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are - * terminated with `\n` and started with `indent`. - * - * @param {string} text - * @param {string} indent - * @param {string} [mode='flow'] `'block'` prevents more-indented lines - * from being folded; `'quoted'` allows for `\` escapes, including escaped - * newlines - * @param {Object} options - * @param {number} [options.indentAtStart] Accounts for leading contents on - * the first line, defaulting to `indent.length` - * @param {number} [options.lineWidth=80] - * @param {number} [options.minContentWidth=20] Allow highly indented lines to - * stretch the line width or indent content from the start - * @param {function} options.onFold Called once if the text is folded - * @param {function} options.onFold Called once if any line of text exceeds - * lineWidth characters - */ - - -function foldFlowLines(text, indent, mode, _ref) { - var indentAtStart = _ref.indentAtStart, - _ref$lineWidth = _ref.lineWidth, - lineWidth = _ref$lineWidth === void 0 ? 80 : _ref$lineWidth, - _ref$minContentWidth = _ref.minContentWidth, - minContentWidth = _ref$minContentWidth === void 0 ? 20 : _ref$minContentWidth, - onFold = _ref.onFold, - onOverflow = _ref.onOverflow; - if (!lineWidth || lineWidth < 0) return text; - var endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); - if (text.length <= endStep) return text; - var folds = []; - var escapedFolds = {}; - var end = lineWidth - indent.length; - - if (typeof indentAtStart === 'number') { - if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0);else end = lineWidth - indentAtStart; - } - - var split = undefined; - var prev = undefined; - var overflow = false; - var i = -1; - var escStart = -1; - var escEnd = -1; - - if (mode === FOLD_BLOCK) { - i = consumeMoreIndentedLines(text, i); - if (i !== -1) end = i + endStep; - } - - for (var ch; ch = text[i += 1];) { - if (mode === FOLD_QUOTED && ch === '\\') { - escStart = i; - - switch (text[i + 1]) { - case 'x': - i += 3; - break; - - case 'u': - i += 5; - break; - - case 'U': - i += 9; - break; - - default: - i += 1; - } - - escEnd = i; - } - - if (ch === '\n') { - if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i); - end = i + endStep; - split = undefined; - } else { - if (ch === ' ' && prev && prev !== ' ' && prev !== '\n' && prev !== '\t') { - // space surrounded by non-space can be replaced with newline + indent - var next = text[i + 1]; - if (next && next !== ' ' && next !== '\n' && next !== '\t') split = i; - } - - if (i >= end) { - if (split) { - folds.push(split); - end = split + endStep; - split = undefined; - } else if (mode === FOLD_QUOTED) { - // white-space collected at end may stretch past lineWidth - while (prev === ' ' || prev === '\t') { - prev = ch; - ch = text[i += 1]; - overflow = true; - } // Account for newline escape, but don't break preceding escape - - - var j = i > escEnd + 1 ? i - 2 : escStart - 1; // Bail out if lineWidth & minContentWidth are shorter than an escape string - - if (escapedFolds[j]) return text; - folds.push(j); - escapedFolds[j] = true; - end = j + endStep; - split = undefined; - } else { - overflow = true; - } - } - } - - prev = ch; - } - - if (overflow && onOverflow) onOverflow(); - if (folds.length === 0) return text; - if (onFold) onFold(); - var res = text.slice(0, folds[0]); - - for (var _i = 0; _i < folds.length; ++_i) { - var fold = folds[_i]; - - var _end = folds[_i + 1] || text.length; - - if (fold === 0) res = "\n".concat(indent).concat(text.slice(0, _end));else { - if (mode === FOLD_QUOTED && escapedFolds[fold]) res += "".concat(text[fold], "\\"); - res += "\n".concat(indent).concat(text.slice(fold + 1, _end)); - } - } - - return res; -} - -var getFoldOptions = function getFoldOptions(_ref) { - var indentAtStart = _ref.indentAtStart; - return indentAtStart ? Object.assign({ - indentAtStart: indentAtStart - }, strOptions.fold) : strOptions.fold; -}; // Also checks for lines starting with %, as parsing the output as YAML 1.1 will -// presume that's starting a new document. - - -var containsDocumentMarker = function containsDocumentMarker(str) { - return /^(%|---|\.\.\.)/m.test(str); -}; - -function lineLengthOverLimit(str, lineWidth, indentLength) { - if (!lineWidth || lineWidth < 0) return false; - var limit = lineWidth - indentLength; - var strLen = str.length; - if (strLen <= limit) return false; - - for (var i = 0, start = 0; i < strLen; ++i) { - if (str[i] === '\n') { - if (i - start > limit) return true; - start = i + 1; - if (strLen - start <= limit) return false; - } - } - - return true; -} - -function doubleQuotedString(value, ctx) { - var implicitKey = ctx.implicitKey; - var _strOptions$doubleQuo = strOptions.doubleQuoted, - jsonEncoding = _strOptions$doubleQuo.jsonEncoding, - minMultiLineLength = _strOptions$doubleQuo.minMultiLineLength; - var json = JSON.stringify(value); - if (jsonEncoding) return json; - var indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : ''); - var str = ''; - var start = 0; - - for (var i = 0, ch = json[i]; ch; ch = json[++i]) { - if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') { - // space before newline needs to be escaped to not be folded - str += json.slice(start, i) + '\\ '; - i += 1; - start = i; - ch = '\\'; - } - - if (ch === '\\') switch (json[i + 1]) { - case 'u': - { - str += json.slice(start, i); - var code = json.substr(i + 2, 4); - - switch (code) { - case '0000': - str += '\\0'; - break; - - case '0007': - str += '\\a'; - break; - - case '000b': - str += '\\v'; - break; - - case '001b': - str += '\\e'; - break; - - case '0085': - str += '\\N'; - break; - - case '00a0': - str += '\\_'; - break; - - case '2028': - str += '\\L'; - break; - - case '2029': - str += '\\P'; - break; - - default: - if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6); - } - - i += 5; - start = i + 1; - } - break; - - case 'n': - if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) { - i += 1; - } else { - // folding will eat first newline - str += json.slice(start, i) + '\n\n'; - - while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') { - str += '\n'; - i += 2; - } - - str += indent; // space after newline needs to be escaped to not be folded - - if (json[i + 2] === ' ') str += '\\'; - i += 1; - start = i + 1; - } - - break; - - default: - i += 1; - } - } - - str = start ? str + json.slice(start) : json; - return implicitKey ? str : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx)); -} - -function singleQuotedString(value, ctx) { - if (ctx.implicitKey) { - if (/\n/.test(value)) return doubleQuotedString(value, ctx); - } else { - // single quoted string can't have leading or trailing whitespace around newline - if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx); - } - - var indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : ''); - var res = "'" + value.replace(/'/g, "''").replace(/\n+/g, "$&\n".concat(indent)) + "'"; - return ctx.implicitKey ? res : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx)); -} - -function blockString(_ref2, ctx, onComment, onChompKeep) { - var comment = _ref2.comment, - type = _ref2.type, - value = _ref2.value; - - // 1. Block can't end in whitespace unless the last line is non-empty. - // 2. Strings consisting of only whitespace are best rendered explicitly. - if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) { - return doubleQuotedString(value, ctx); - } - - var indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? ' ' : ''); - var indentSize = indent ? '2' : '1'; // root is at -1 - - var literal = type === Type.BLOCK_FOLDED ? false : type === Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, strOptions.fold.lineWidth, indent.length); - var header = literal ? '|' : '>'; - if (!value) return header + '\n'; - var wsStart = ''; - var wsEnd = ''; - value = value.replace(/[\n\t ]*$/, function (ws) { - var n = ws.indexOf('\n'); - - if (n === -1) { - header += '-'; // strip - } else if (value === ws || n !== ws.length - 1) { - header += '+'; // keep - - if (onChompKeep) onChompKeep(); - } - - wsEnd = ws.replace(/\n$/, ''); - return ''; - }).replace(/^[\n ]*/, function (ws) { - if (ws.indexOf(' ') !== -1) header += indentSize; - var m = ws.match(/ +$/); - - if (m) { - wsStart = ws.slice(0, -m[0].length); - return m[0]; - } else { - wsStart = ws; - return ''; - } - }); - if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, "$&".concat(indent)); - if (wsStart) wsStart = wsStart.replace(/\n+/g, "$&".concat(indent)); - - if (comment) { - header += ' #' + comment.replace(/ ?[\r\n]+/g, ' '); - if (onComment) onComment(); - } - - if (!value) return "".concat(header).concat(indentSize, "\n").concat(indent).concat(wsEnd); - - if (literal) { - value = value.replace(/\n+/g, "$&".concat(indent)); - return "".concat(header, "\n").concat(indent).concat(wsStart).concat(value).concat(wsEnd); - } - - value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded - // ^ ind.line ^ empty ^ capture next empty lines only at end of indent - .replace(/\n+/g, "$&".concat(indent)); - var body = foldFlowLines("".concat(wsStart).concat(value).concat(wsEnd), indent, FOLD_BLOCK, strOptions.fold); - return "".concat(header, "\n").concat(indent).concat(body); -} - -function plainString(item, ctx, onComment, onChompKeep) { - var comment = item.comment, - type = item.type, - value = item.value; - var actualString = ctx.actualString, - implicitKey = ctx.implicitKey, - indent = ctx.indent, - inFlow = ctx.inFlow; - - if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) { - return doubleQuotedString(value, ctx); - } - - if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) { - // not allowed: - // - empty string, '-' or '?' - // - start with an indicator character (except [?:-]) or /[?-] / - // - '\n ', ': ' or ' \n' anywhere - // - '#' not preceded by a non-space char - // - end with ' ' or ':' - return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep); - } - - if (!implicitKey && !inFlow && type !== Type.PLAIN && value.indexOf('\n') !== -1) { - // Where allowed & type not set explicitly, prefer block style for multiline strings - return blockString(item, ctx, onComment, onChompKeep); - } - - if (indent === '' && containsDocumentMarker(value)) { - ctx.forceBlockIndent = true; - return blockString(item, ctx, onComment, onChompKeep); - } - - var str = value.replace(/\n+/g, "$&\n".concat(indent)); // Verify that output will be parsed as a string, as e.g. plain numbers and - // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'), - // and others in v1.1. - - if (actualString) { - var tags = ctx.doc.schema.tags; - var resolved = resolveScalar(str, tags, tags.scalarFallback).value; - if (typeof resolved !== 'string') return doubleQuotedString(value, ctx); - } - - var body = implicitKey ? str : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx)); - - if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) { - if (onComment) onComment(); - return addCommentBefore(body, indent, comment); - } - - return body; -} - -function stringifyString(item, ctx, onComment, onChompKeep) { - var defaultType = strOptions.defaultType; - var implicitKey = ctx.implicitKey, - inFlow = ctx.inFlow; - var _item = item, - type = _item.type, - value = _item.value; - - if (typeof value !== 'string') { - value = String(value); - item = Object.assign({}, item, { - value: value - }); - } - - var _stringify = function _stringify(_type) { - switch (_type) { - case Type.BLOCK_FOLDED: - case Type.BLOCK_LITERAL: - return blockString(item, ctx, onComment, onChompKeep); - - case Type.QUOTE_DOUBLE: - return doubleQuotedString(value, ctx); - - case Type.QUOTE_SINGLE: - return singleQuotedString(value, ctx); - - case Type.PLAIN: - return plainString(item, ctx, onComment, onChompKeep); - - default: - return null; - } - }; - - if (type !== Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) { - // force double quotes on control characters - type = Type.QUOTE_DOUBLE; - } else if ((implicitKey || inFlow) && (type === Type.BLOCK_FOLDED || type === Type.BLOCK_LITERAL)) { - // should not happen; blocks are not valid inside flow containers - type = Type.QUOTE_DOUBLE; - } - - var res = _stringify(type); - - if (res === null) { - res = _stringify(defaultType); - if (res === null) throw new Error("Unsupported default string type ".concat(defaultType)); - } - - return res; -} - -function stringifyNumber(_ref) { - var format = _ref.format, - minFractionDigits = _ref.minFractionDigits, - tag = _ref.tag, - value = _ref.value; - if (typeof value === 'bigint') return String(value); - if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf'; - var n = JSON.stringify(value); - - if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) { - var i = n.indexOf('.'); - - if (i < 0) { - i = n.length; - n += '.'; - } - - var d = minFractionDigits - (n.length - i - 1); - - while (d-- > 0) { - n += '0'; - } - } - - return n; -} - -function checkFlowCollectionEnd(errors, cst) { - var char, name; - - switch (cst.type) { - case Type.FLOW_MAP: - char = '}'; - name = 'flow map'; - break; - - case Type.FLOW_SEQ: - char = ']'; - name = 'flow sequence'; - break; - - default: - errors.push(new YAMLSemanticError(cst, 'Not a flow collection!?')); - return; - } - - var lastItem; - - for (var i = cst.items.length - 1; i >= 0; --i) { - var item = cst.items[i]; - - if (!item || item.type !== Type.COMMENT) { - lastItem = item; - break; - } - } - - if (lastItem && lastItem.char !== char) { - var msg = "Expected ".concat(name, " to end with ").concat(char); - var err; - - if (typeof lastItem.offset === 'number') { - err = new YAMLSemanticError(cst, msg); - err.offset = lastItem.offset + 1; - } else { - err = new YAMLSemanticError(lastItem, msg); - if (lastItem.range && lastItem.range.end) err.offset = lastItem.range.end - lastItem.range.start; - } - - errors.push(err); - } -} -function checkFlowCommentSpace(errors, comment) { - var prev = comment.context.src[comment.range.start - 1]; - - if (prev !== '\n' && prev !== '\t' && prev !== ' ') { - var msg = 'Comments must be separated from other tokens by white space characters'; - errors.push(new YAMLSemanticError(comment, msg)); - } -} -function getLongKeyError(source, key) { - var sk = String(key); - var k = sk.substr(0, 8) + '...' + sk.substr(-8); - return new YAMLSemanticError(source, "The \"".concat(k, "\" key is too long")); -} -function resolveComments(collection, comments) { - var _iterator = _createForOfIteratorHelper(comments), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = _step.value, - afterKey = _step$value.afterKey, - before = _step$value.before, - comment = _step$value.comment; - var item = collection.items[before]; - - if (!item) { - if (comment !== undefined) { - if (collection.comment) collection.comment += '\n' + comment;else collection.comment = comment; - } - } else { - if (afterKey && item.value) item = item.value; - - if (comment === undefined) { - if (afterKey || !item.commentBefore) item.spaceBefore = true; - } else { - if (item.commentBefore) item.commentBefore += '\n' + comment;else item.commentBefore = comment; - } - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } -} - -// on error, will return { str: string, errors: Error[] } -function resolveString(doc, node) { - var res = node.strValue; - if (!res) return ''; - if (typeof res === 'string') return res; - res.errors.forEach(function (error) { - if (!error.source) error.source = node; - doc.errors.push(error); - }); - return res.str; -} - -function resolveTagHandle(doc, node) { - var _node$tag = node.tag, - handle = _node$tag.handle, - suffix = _node$tag.suffix; - var prefix = doc.tagPrefixes.find(function (p) { - return p.handle === handle; - }); - - if (!prefix) { - var dtp = doc.getDefaults().tagPrefixes; - if (dtp) prefix = dtp.find(function (p) { - return p.handle === handle; - }); - if (!prefix) throw new YAMLSemanticError(node, "The ".concat(handle, " tag handle is non-default and was not declared.")); - } - - if (!suffix) throw new YAMLSemanticError(node, "The ".concat(handle, " tag has no suffix.")); - - if (handle === '!' && (doc.version || doc.options.version) === '1.0') { - if (suffix[0] === '^') { - doc.warnings.push(new YAMLWarning(node, 'YAML 1.0 ^ tag expansion is not supported')); - return suffix; - } - - if (/[:/]/.test(suffix)) { - // word/foo -> tag:word.yaml.org,2002:foo - var vocab = suffix.match(/^([a-z0-9-]+)\/(.*)/i); - return vocab ? "tag:".concat(vocab[1], ".yaml.org,2002:").concat(vocab[2]) : "tag:".concat(suffix); - } - } - - return prefix.prefix + decodeURIComponent(suffix); -} - -function resolveTagName(doc, node) { - var tag = node.tag, - type = node.type; - var nonSpecific = false; - - if (tag) { - var handle = tag.handle, - suffix = tag.suffix, - verbatim = tag.verbatim; - - if (verbatim) { - if (verbatim !== '!' && verbatim !== '!!') return verbatim; - var msg = "Verbatim tags aren't resolved, so ".concat(verbatim, " is invalid."); - doc.errors.push(new YAMLSemanticError(node, msg)); - } else if (handle === '!' && !suffix) { - nonSpecific = true; - } else { - try { - return resolveTagHandle(doc, node); - } catch (error) { - doc.errors.push(error); - } - } - } - - switch (type) { - case Type.BLOCK_FOLDED: - case Type.BLOCK_LITERAL: - case Type.QUOTE_DOUBLE: - case Type.QUOTE_SINGLE: - return defaultTags.STR; - - case Type.FLOW_MAP: - case Type.MAP: - return defaultTags.MAP; - - case Type.FLOW_SEQ: - case Type.SEQ: - return defaultTags.SEQ; - - case Type.PLAIN: - return nonSpecific ? defaultTags.STR : null; - - default: - return null; - } -} - -function resolveByTagName(doc, node, tagName) { - var tags = doc.schema.tags; - var matchWithTest = []; - - var _iterator = _createForOfIteratorHelper(tags), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var tag = _step.value; - - if (tag.tag === tagName) { - if (tag.test) matchWithTest.push(tag);else { - var res = tag.resolve(doc, node); - return res instanceof Collection ? res : new Scalar(res); - } - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - var str = resolveString(doc, node); - if (typeof str === 'string' && matchWithTest.length > 0) return resolveScalar(str, matchWithTest, tags.scalarFallback); - return null; -} - -function getFallbackTagName(_ref) { - var type = _ref.type; - - switch (type) { - case Type.FLOW_MAP: - case Type.MAP: - return defaultTags.MAP; - - case Type.FLOW_SEQ: - case Type.SEQ: - return defaultTags.SEQ; - - default: - return defaultTags.STR; - } -} - -function resolveTag(doc, node, tagName) { - try { - var res = resolveByTagName(doc, node, tagName); - - if (res) { - if (tagName && node.tag) res.tag = tagName; - return res; - } - } catch (error) { - /* istanbul ignore if */ - if (!error.source) error.source = node; - doc.errors.push(error); - return null; - } - - try { - var fallback = getFallbackTagName(node); - if (!fallback) throw new Error("The tag ".concat(tagName, " is unavailable")); - var msg = "The tag ".concat(tagName, " is unavailable, falling back to ").concat(fallback); - doc.warnings.push(new YAMLWarning(node, msg)); - - var _res = resolveByTagName(doc, node, fallback); - - _res.tag = tagName; - return _res; - } catch (error) { - var refError = new YAMLReferenceError(node, error.message); - refError.stack = error.stack; - doc.errors.push(refError); - return null; - } -} - -var isCollectionItem = function isCollectionItem(node) { - if (!node) return false; - var type = node.type; - return type === Type.MAP_KEY || type === Type.MAP_VALUE || type === Type.SEQ_ITEM; -}; - -function resolveNodeProps(errors, node) { - var comments = { - before: [], - after: [] - }; - var hasAnchor = false; - var hasTag = false; - var props = isCollectionItem(node.context.parent) ? node.context.parent.props.concat(node.props) : node.props; - - var _iterator = _createForOfIteratorHelper(props), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var _step$value = _step.value, - start = _step$value.start, - end = _step$value.end; - - switch (node.context.src[start]) { - case Char.COMMENT: - { - if (!node.commentHasRequiredWhitespace(start)) { - var msg = 'Comments must be separated from other tokens by white space characters'; - errors.push(new YAMLSemanticError(node, msg)); - } - - var header = node.header, - valueRange = node.valueRange; - var cc = valueRange && (start > valueRange.start || header && start > header.start) ? comments.after : comments.before; - cc.push(node.context.src.slice(start + 1, end)); - break; - } - // Actual anchor & tag resolution is handled by schema, here we just complain - - case Char.ANCHOR: - if (hasAnchor) { - var _msg = 'A node can have at most one anchor'; - errors.push(new YAMLSemanticError(node, _msg)); - } - - hasAnchor = true; - break; - - case Char.TAG: - if (hasTag) { - var _msg2 = 'A node can have at most one tag'; - errors.push(new YAMLSemanticError(node, _msg2)); - } - - hasTag = true; - break; - } - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return { - comments: comments, - hasAnchor: hasAnchor, - hasTag: hasTag - }; -} - -function resolveNodeValue(doc, node) { - var anchors = doc.anchors, - errors = doc.errors, - schema = doc.schema; - - if (node.type === Type.ALIAS) { - var name = node.rawValue; - var src = anchors.getNode(name); - - if (!src) { - var msg = "Aliased anchor not found: ".concat(name); - errors.push(new YAMLReferenceError(node, msg)); - return null; - } // Lazy resolution for circular references - - - var res = new Alias(src); - - anchors._cstAliases.push(res); - - return res; - } - - var tagName = resolveTagName(doc, node); - if (tagName) return resolveTag(doc, node, tagName); - - if (node.type !== Type.PLAIN) { - var _msg3 = "Failed to resolve ".concat(node.type, " node here"); - - errors.push(new YAMLSyntaxError(node, _msg3)); - return null; - } - - try { - var str = resolveString(doc, node); - return resolveScalar(str, schema.tags, schema.tags.scalarFallback); - } catch (error) { - if (!error.source) error.source = node; - errors.push(error); - return null; - } -} // sets node.resolved on success - - -function resolveNode(doc, node) { - if (!node) return null; - if (node.error) doc.errors.push(node.error); - - var _resolveNodeProps = resolveNodeProps(doc.errors, node), - comments = _resolveNodeProps.comments, - hasAnchor = _resolveNodeProps.hasAnchor, - hasTag = _resolveNodeProps.hasTag; - - if (hasAnchor) { - var anchors = doc.anchors; - var name = node.anchor; - var prev = anchors.getNode(name); // At this point, aliases for any preceding node with the same anchor - // name have already been resolved, so it may safely be renamed. - - if (prev) anchors.map[anchors.newName(name)] = prev; // During parsing, we need to store the CST node in anchors.map as - // anchors need to be available during resolution to allow for - // circular references. - - anchors.map[name] = node; - } - - if (node.type === Type.ALIAS && (hasAnchor || hasTag)) { - var msg = 'An alias node must not specify any properties'; - doc.errors.push(new YAMLSemanticError(node, msg)); - } - - var res = resolveNodeValue(doc, node); - - if (res) { - res.range = [node.range.start, node.range.end]; - if (doc.options.keepCstNodes) res.cstNode = node; - if (doc.options.keepNodeTypes) res.type = node.type; - var cb = comments.before.join('\n'); - - if (cb) { - res.commentBefore = res.commentBefore ? "".concat(res.commentBefore, "\n").concat(cb) : cb; - } - - var ca = comments.after.join('\n'); - if (ca) res.comment = res.comment ? "".concat(res.comment, "\n").concat(ca) : ca; - } - - return node.resolved = res; -} - -function resolveMap(doc, cst) { - if (cst.type !== Type.MAP && cst.type !== Type.FLOW_MAP) { - var msg = "A ".concat(cst.type, " node cannot be resolved as a mapping"); - doc.errors.push(new YAMLSyntaxError(cst, msg)); - return null; - } - - var _ref = cst.type === Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst), - comments = _ref.comments, - items = _ref.items; - - var map = new YAMLMap(); - map.items = items; - resolveComments(map, comments); - var hasCollectionKey = false; - - for (var i = 0; i < items.length; ++i) { - var iKey = items[i].key; - if (iKey instanceof Collection) hasCollectionKey = true; - - if (doc.schema.merge && iKey && iKey.value === MERGE_KEY) { - items[i] = new Merge(items[i]); - var sources = items[i].value.items; - var error = null; - sources.some(function (node) { - if (node instanceof Alias) { - // During parsing, alias sources are CST nodes; to account for - // circular references their resolved values can't be used here. - var type = node.source.type; - if (type === Type.MAP || type === Type.FLOW_MAP) return false; - return error = 'Merge nodes aliases can only point to maps'; - } - - return error = 'Merge nodes can only have Alias nodes as values'; - }); - if (error) doc.errors.push(new YAMLSemanticError(cst, error)); - } else { - for (var j = i + 1; j < items.length; ++j) { - var jKey = items[j].key; - - if (iKey === jKey || iKey && jKey && Object.prototype.hasOwnProperty.call(iKey, 'value') && iKey.value === jKey.value) { - var _msg = "Map keys must be unique; \"".concat(iKey, "\" is repeated"); - - doc.errors.push(new YAMLSemanticError(cst, _msg)); - break; - } - } - } - } - - if (hasCollectionKey && !doc.options.mapAsMap) { - var warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; - doc.warnings.push(new YAMLWarning(cst, warn)); - } - - cst.resolved = map; - return map; -} - -var valueHasPairComment = function valueHasPairComment(_ref2) { - var _ref2$context = _ref2.context, - lineStart = _ref2$context.lineStart, - node = _ref2$context.node, - src = _ref2$context.src, - props = _ref2.props; - if (props.length === 0) return false; - var start = props[0].start; - if (node && start > node.valueRange.start) return false; - if (src[start] !== Char.COMMENT) return false; - - for (var i = lineStart; i < start; ++i) { - if (src[i] === '\n') return false; - } - - return true; -}; - -function resolvePairComment(item, pair) { - if (!valueHasPairComment(item)) return; - var comment = item.getPropValue(0, Char.COMMENT, true); - var found = false; - var cb = pair.value.commentBefore; - - if (cb && cb.startsWith(comment)) { - pair.value.commentBefore = cb.substr(comment.length + 1); - found = true; - } else { - var cc = pair.value.comment; - - if (!item.node && cc && cc.startsWith(comment)) { - pair.value.comment = cc.substr(comment.length + 1); - found = true; - } - } - - if (found) pair.comment = comment; -} - -function resolveBlockMapItems(doc, cst) { - var comments = []; - var items = []; - var key = undefined; - var keyStart = null; - - for (var i = 0; i < cst.items.length; ++i) { - var item = cst.items[i]; - - switch (item.type) { - case Type.BLANK_LINE: - comments.push({ - afterKey: !!key, - before: items.length - }); - break; - - case Type.COMMENT: - comments.push({ - afterKey: !!key, - before: items.length, - comment: item.comment - }); - break; - - case Type.MAP_KEY: - if (key !== undefined) items.push(new Pair(key)); - if (item.error) doc.errors.push(item.error); - key = resolveNode(doc, item.node); - keyStart = null; - break; - - case Type.MAP_VALUE: - { - if (key === undefined) key = null; - if (item.error) doc.errors.push(item.error); - - if (!item.context.atLineStart && item.node && item.node.type === Type.MAP && !item.node.context.atLineStart) { - var msg = 'Nested mappings are not allowed in compact mappings'; - doc.errors.push(new YAMLSemanticError(item.node, msg)); - } - - var valueNode = item.node; - - if (!valueNode && item.props.length > 0) { - // Comments on an empty mapping value need to be preserved, so we - // need to construct a minimal empty node here to use instead of the - // missing `item.node`. -- eemeli/yaml#19 - valueNode = new PlainValue(Type.PLAIN, []); - valueNode.context = { - parent: item, - src: item.context.src - }; - var pos = item.range.start + 1; - valueNode.range = { - start: pos, - end: pos - }; - valueNode.valueRange = { - start: pos, - end: pos - }; - - if (typeof item.range.origStart === 'number') { - var origPos = item.range.origStart + 1; - valueNode.range.origStart = valueNode.range.origEnd = origPos; - valueNode.valueRange.origStart = valueNode.valueRange.origEnd = origPos; - } - } - - var pair = new Pair(key, resolveNode(doc, valueNode)); - resolvePairComment(item, pair); - items.push(pair); - - if (key && typeof keyStart === 'number') { - if (item.range.start > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key)); - } - - key = undefined; - keyStart = null; - } - break; - - default: - if (key !== undefined) items.push(new Pair(key)); - key = resolveNode(doc, item); - keyStart = item.range.start; - if (item.error) doc.errors.push(item.error); - - next: for (var j = i + 1;; ++j) { - var nextItem = cst.items[j]; - - switch (nextItem && nextItem.type) { - case Type.BLANK_LINE: - case Type.COMMENT: - continue next; - - case Type.MAP_VALUE: - break next; - - default: - { - var _msg2 = 'Implicit map keys need to be followed by map values'; - doc.errors.push(new YAMLSemanticError(item, _msg2)); - break next; - } - } - } - - if (item.valueRangeContainsNewline) { - var _msg3 = 'Implicit map keys need to be on a single line'; - doc.errors.push(new YAMLSemanticError(item, _msg3)); - } - - } - } - - if (key !== undefined) items.push(new Pair(key)); - return { - comments: comments, - items: items - }; -} - -function resolveFlowMapItems(doc, cst) { - var comments = []; - var items = []; - var key = undefined; - var explicitKey = false; - var next = '{'; - - for (var i = 0; i < cst.items.length; ++i) { - var item = cst.items[i]; - - if (typeof item.char === 'string') { - var char = item.char, - offset = item.offset; - - if (char === '?' && key === undefined && !explicitKey) { - explicitKey = true; - next = ':'; - continue; - } - - if (char === ':') { - if (key === undefined) key = null; - - if (next === ':') { - next = ','; - continue; - } - } else { - if (explicitKey) { - if (key === undefined && char !== ',') key = null; - explicitKey = false; - } - - if (key !== undefined) { - items.push(new Pair(key)); - key = undefined; - - if (char === ',') { - next = ':'; - continue; - } - } - } - - if (char === '}') { - if (i === cst.items.length - 1) continue; - } else if (char === next) { - next = ':'; - continue; - } - - var msg = "Flow map contains an unexpected ".concat(char); - var err = new YAMLSyntaxError(cst, msg); - err.offset = offset; - doc.errors.push(err); - } else if (item.type === Type.BLANK_LINE) { - comments.push({ - afterKey: !!key, - before: items.length - }); - } else if (item.type === Type.COMMENT) { - checkFlowCommentSpace(doc.errors, item); - comments.push({ - afterKey: !!key, - before: items.length, - comment: item.comment - }); - } else if (key === undefined) { - if (next === ',') doc.errors.push(new YAMLSemanticError(item, 'Separator , missing in flow map')); - key = resolveNode(doc, item); - } else { - if (next !== ',') doc.errors.push(new YAMLSemanticError(item, 'Indicator : missing in flow map entry')); - items.push(new Pair(key, resolveNode(doc, item))); - key = undefined; - explicitKey = false; - } - } - - checkFlowCollectionEnd(doc.errors, cst); - if (key !== undefined) items.push(new Pair(key)); - return { - comments: comments, - items: items - }; -} - -function resolveSeq(doc, cst) { - if (cst.type !== Type.SEQ && cst.type !== Type.FLOW_SEQ) { - var msg = "A ".concat(cst.type, " node cannot be resolved as a sequence"); - doc.errors.push(new YAMLSyntaxError(cst, msg)); - return null; - } - - var _ref = cst.type === Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst), - comments = _ref.comments, - items = _ref.items; - - var seq = new YAMLSeq(); - seq.items = items; - resolveComments(seq, comments); - - if (!doc.options.mapAsMap && items.some(function (it) { - return it instanceof Pair && it.key instanceof Collection; - })) { - var warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; - doc.warnings.push(new YAMLWarning(cst, warn)); - } - - cst.resolved = seq; - return seq; -} - -function resolveBlockSeqItems(doc, cst) { - var comments = []; - var items = []; - - for (var i = 0; i < cst.items.length; ++i) { - var item = cst.items[i]; - - switch (item.type) { - case Type.BLANK_LINE: - comments.push({ - before: items.length - }); - break; - - case Type.COMMENT: - comments.push({ - comment: item.comment, - before: items.length - }); - break; - - case Type.SEQ_ITEM: - if (item.error) doc.errors.push(item.error); - items.push(resolveNode(doc, item.node)); - - if (item.hasProps) { - var msg = 'Sequence items cannot have tags or anchors before the - indicator'; - doc.errors.push(new YAMLSemanticError(item, msg)); - } - - break; - - default: - if (item.error) doc.errors.push(item.error); - doc.errors.push(new YAMLSyntaxError(item, "Unexpected ".concat(item.type, " node in sequence"))); - } - } - - return { - comments: comments, - items: items - }; -} - -function resolveFlowSeqItems(doc, cst) { - var comments = []; - var items = []; - var explicitKey = false; - var key = undefined; - var keyStart = null; - var next = '['; - var prevItem = null; - - for (var i = 0; i < cst.items.length; ++i) { - var item = cst.items[i]; - - if (typeof item.char === 'string') { - var char = item.char, - offset = item.offset; - - if (char !== ':' && (explicitKey || key !== undefined)) { - if (explicitKey && key === undefined) key = next ? items.pop() : null; - items.push(new Pair(key)); - explicitKey = false; - key = undefined; - keyStart = null; - } - - if (char === next) { - next = null; - } else if (!next && char === '?') { - explicitKey = true; - } else if (next !== '[' && char === ':' && key === undefined) { - if (next === ',') { - key = items.pop(); - - if (key instanceof Pair) { - var msg = 'Chaining flow sequence pairs is invalid'; - var err = new YAMLSemanticError(cst, msg); - err.offset = offset; - doc.errors.push(err); - } - - if (!explicitKey && typeof keyStart === 'number') { - var keyEnd = item.range ? item.range.start : item.offset; - if (keyEnd > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key)); - var src = prevItem.context.src; - - for (var _i = keyStart; _i < keyEnd; ++_i) { - if (src[_i] === '\n') { - var _msg = 'Implicit keys of flow sequence pairs need to be on a single line'; - doc.errors.push(new YAMLSemanticError(prevItem, _msg)); - break; - } - } - } - } else { - key = null; - } - - keyStart = null; - explicitKey = false; - next = null; - } else if (next === '[' || char !== ']' || i < cst.items.length - 1) { - var _msg2 = "Flow sequence contains an unexpected ".concat(char); - - var _err = new YAMLSyntaxError(cst, _msg2); - - _err.offset = offset; - doc.errors.push(_err); - } - } else if (item.type === Type.BLANK_LINE) { - comments.push({ - before: items.length - }); - } else if (item.type === Type.COMMENT) { - checkFlowCommentSpace(doc.errors, item); - comments.push({ - comment: item.comment, - before: items.length - }); - } else { - if (next) { - var _msg3 = "Expected a ".concat(next, " in flow sequence"); - - doc.errors.push(new YAMLSemanticError(item, _msg3)); - } - - var value = resolveNode(doc, item); - - if (key === undefined) { - items.push(value); - prevItem = item; - } else { - items.push(new Pair(key, value)); - key = undefined; - } - - keyStart = item.range.start; - next = ','; - } - } - - checkFlowCollectionEnd(doc.errors, cst); - if (key !== undefined) items.push(new Pair(key)); - return { - comments: comments, - items: items - }; -} - -export { Alias as A, Collection as C, Merge as M, Node as N, Pair as P, Scalar as S, YAMLSeq as Y, boolOptions as a, binaryOptions as b, stringifyString as c, YAMLMap as d, isEmptyPath as e, addComment as f, resolveMap as g, resolveSeq as h, intOptions as i, resolveString as j, stringifyNumber as k, findPair as l, nullOptions as n, resolveNode as r, strOptions as s, toJSON as t }; diff --git a/action/node_modules/yaml/browser/dist/types.js b/action/node_modules/yaml/browser/dist/types.js deleted file mode 100644 index da2288bc0..000000000 --- a/action/node_modules/yaml/browser/dist/types.js +++ /dev/null @@ -1,4 +0,0 @@ -export { A as Alias, C as Collection, M as Merge, N as Node, P as Pair, S as Scalar, d as YAMLMap, Y as YAMLSeq, b as binaryOptions, a as boolOptions, i as intOptions, n as nullOptions, s as strOptions } from './resolveSeq-492ab440.js'; -export { S as Schema } from './Schema-e94716c8.js'; -import './PlainValue-b8036b75.js'; -import './warnings-df54cb69.js'; diff --git a/action/node_modules/yaml/browser/dist/util.js b/action/node_modules/yaml/browser/dist/util.js deleted file mode 100644 index 29f4663d6..000000000 --- a/action/node_modules/yaml/browser/dist/util.js +++ /dev/null @@ -1,2 +0,0 @@ -export { l as findPair, g as parseMap, h as parseSeq, k as stringifyNumber, c as stringifyString, t as toJSON } from './resolveSeq-492ab440.js'; -export { T as Type, i as YAMLError, o as YAMLReferenceError, g as YAMLSemanticError, Y as YAMLSyntaxError, f as YAMLWarning } from './PlainValue-b8036b75.js'; diff --git a/action/node_modules/yaml/browser/dist/warnings-df54cb69.js b/action/node_modules/yaml/browser/dist/warnings-df54cb69.js deleted file mode 100644 index 9532e8322..000000000 --- a/action/node_modules/yaml/browser/dist/warnings-df54cb69.js +++ /dev/null @@ -1,499 +0,0 @@ -import { o as YAMLReferenceError, T as Type, g as YAMLSemanticError, _ as _createForOfIteratorHelper, e as _defineProperty, j as _inherits, k as _createSuper, c as _classCallCheck, p as _assertThisInitialized, b as _createClass, a as _typeof, l as _get, m as _getPrototypeOf } from './PlainValue-b8036b75.js'; -import { j as resolveString, b as binaryOptions, c as stringifyString, h as resolveSeq, P as Pair, d as YAMLMap, Y as YAMLSeq, t as toJSON, S as Scalar, l as findPair, g as resolveMap, k as stringifyNumber } from './resolveSeq-492ab440.js'; - -/* global atob, btoa, Buffer */ -var binary = { - identify: function identify(value) { - return value instanceof Uint8Array; - }, - // Buffer inherits from Uint8Array - default: false, - tag: 'tag:yaml.org,2002:binary', - - /** - * Returns a Buffer in node and an Uint8Array in browsers - * - * To use the resulting buffer as an image, you'll want to do something like: - * - * const blob = new Blob([buffer], { type: 'image/jpeg' }) - * document.querySelector('#photo').src = URL.createObjectURL(blob) - */ - resolve: function resolve(doc, node) { - var src = resolveString(doc, node); - - if (typeof Buffer === 'function') { - return Buffer.from(src, 'base64'); - } else if (typeof atob === 'function') { - // On IE 11, atob() can't handle newlines - var str = atob(src.replace(/[\n\r]/g, '')); - var buffer = new Uint8Array(str.length); - - for (var i = 0; i < str.length; ++i) { - buffer[i] = str.charCodeAt(i); - } - - return buffer; - } else { - var msg = 'This environment does not support reading binary tags; either Buffer or atob is required'; - doc.errors.push(new YAMLReferenceError(node, msg)); - return null; - } - }, - options: binaryOptions, - stringify: function stringify(_ref, ctx, onComment, onChompKeep) { - var comment = _ref.comment, - type = _ref.type, - value = _ref.value; - var src; - - if (typeof Buffer === 'function') { - src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64'); - } else if (typeof btoa === 'function') { - var s = ''; - - for (var i = 0; i < value.length; ++i) { - s += String.fromCharCode(value[i]); - } - - src = btoa(s); - } else { - throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required'); - } - - if (!type) type = binaryOptions.defaultType; - - if (type === Type.QUOTE_DOUBLE) { - value = src; - } else { - var lineWidth = binaryOptions.lineWidth; - var n = Math.ceil(src.length / lineWidth); - var lines = new Array(n); - - for (var _i = 0, o = 0; _i < n; ++_i, o += lineWidth) { - lines[_i] = src.substr(o, lineWidth); - } - - value = lines.join(type === Type.BLOCK_LITERAL ? '\n' : ' '); - } - - return stringifyString({ - comment: comment, - type: type, - value: value - }, ctx, onComment, onChompKeep); - } -}; - -function parsePairs(doc, cst) { - var seq = resolveSeq(doc, cst); - - for (var i = 0; i < seq.items.length; ++i) { - var item = seq.items[i]; - if (item instanceof Pair) continue;else if (item instanceof YAMLMap) { - if (item.items.length > 1) { - var msg = 'Each pair must have its own sequence indicator'; - throw new YAMLSemanticError(cst, msg); - } - - var pair = item.items[0] || new Pair(); - if (item.commentBefore) pair.commentBefore = pair.commentBefore ? "".concat(item.commentBefore, "\n").concat(pair.commentBefore) : item.commentBefore; - if (item.comment) pair.comment = pair.comment ? "".concat(item.comment, "\n").concat(pair.comment) : item.comment; - item = pair; - } - seq.items[i] = item instanceof Pair ? item : new Pair(item); - } - - return seq; -} -function createPairs(schema, iterable, ctx) { - var pairs = new YAMLSeq(schema); - pairs.tag = 'tag:yaml.org,2002:pairs'; - - var _iterator = _createForOfIteratorHelper(iterable), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var it = _step.value; - var key = void 0, - value = void 0; - - if (Array.isArray(it)) { - if (it.length === 2) { - key = it[0]; - value = it[1]; - } else throw new TypeError("Expected [key, value] tuple: ".concat(it)); - } else if (it && it instanceof Object) { - var keys = Object.keys(it); - - if (keys.length === 1) { - key = keys[0]; - value = it[key]; - } else throw new TypeError("Expected { key: value } tuple: ".concat(it)); - } else { - key = it; - } - - var pair = schema.createPair(key, value, ctx); - pairs.items.push(pair); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return pairs; -} -var pairs = { - default: false, - tag: 'tag:yaml.org,2002:pairs', - resolve: parsePairs, - createNode: createPairs -}; - -var YAMLOMap = /*#__PURE__*/function (_YAMLSeq) { - _inherits(YAMLOMap, _YAMLSeq); - - var _super = _createSuper(YAMLOMap); - - function YAMLOMap() { - var _this; - - _classCallCheck(this, YAMLOMap); - - _this = _super.call(this); - - _defineProperty(_assertThisInitialized(_this), "add", YAMLMap.prototype.add.bind(_assertThisInitialized(_this))); - - _defineProperty(_assertThisInitialized(_this), "delete", YAMLMap.prototype.delete.bind(_assertThisInitialized(_this))); - - _defineProperty(_assertThisInitialized(_this), "get", YAMLMap.prototype.get.bind(_assertThisInitialized(_this))); - - _defineProperty(_assertThisInitialized(_this), "has", YAMLMap.prototype.has.bind(_assertThisInitialized(_this))); - - _defineProperty(_assertThisInitialized(_this), "set", YAMLMap.prototype.set.bind(_assertThisInitialized(_this))); - - _this.tag = YAMLOMap.tag; - return _this; - } - - _createClass(YAMLOMap, [{ - key: "toJSON", - value: function toJSON$1(_, ctx) { - var map = new Map(); - if (ctx && ctx.onCreate) ctx.onCreate(map); - - var _iterator = _createForOfIteratorHelper(this.items), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var pair = _step.value; - var key = void 0, - value = void 0; - - if (pair instanceof Pair) { - key = toJSON(pair.key, '', ctx); - value = toJSON(pair.value, key, ctx); - } else { - key = toJSON(pair, '', ctx); - } - - if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys'); - map.set(key, value); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return map; - } - }]); - - return YAMLOMap; -}(YAMLSeq); - -_defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap'); - -function parseOMap(doc, cst) { - var pairs = parsePairs(doc, cst); - var seenKeys = []; - - var _iterator2 = _createForOfIteratorHelper(pairs.items), - _step2; - - try { - for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { - var key = _step2.value.key; - - if (key instanceof Scalar) { - if (seenKeys.includes(key.value)) { - var msg = 'Ordered maps must not include duplicate keys'; - throw new YAMLSemanticError(cst, msg); - } else { - seenKeys.push(key.value); - } - } - } - } catch (err) { - _iterator2.e(err); - } finally { - _iterator2.f(); - } - - return Object.assign(new YAMLOMap(), pairs); -} - -function createOMap(schema, iterable, ctx) { - var pairs = createPairs(schema, iterable, ctx); - var omap = new YAMLOMap(); - omap.items = pairs.items; - return omap; -} - -var omap = { - identify: function identify(value) { - return value instanceof Map; - }, - nodeClass: YAMLOMap, - default: false, - tag: 'tag:yaml.org,2002:omap', - resolve: parseOMap, - createNode: createOMap -}; - -var YAMLSet = /*#__PURE__*/function (_YAMLMap) { - _inherits(YAMLSet, _YAMLMap); - - var _super = _createSuper(YAMLSet); - - function YAMLSet() { - var _this; - - _classCallCheck(this, YAMLSet); - - _this = _super.call(this); - _this.tag = YAMLSet.tag; - return _this; - } - - _createClass(YAMLSet, [{ - key: "add", - value: function add(key) { - var pair = key instanceof Pair ? key : new Pair(key); - var prev = findPair(this.items, pair.key); - if (!prev) this.items.push(pair); - } - }, { - key: "get", - value: function get(key, keepPair) { - var pair = findPair(this.items, key); - return !keepPair && pair instanceof Pair ? pair.key instanceof Scalar ? pair.key.value : pair.key : pair; - } - }, { - key: "set", - value: function set(key, value) { - if (typeof value !== 'boolean') throw new Error("Expected boolean value for set(key, value) in a YAML set, not ".concat(_typeof(value))); - var prev = findPair(this.items, key); - - if (prev && !value) { - this.items.splice(this.items.indexOf(prev), 1); - } else if (!prev && value) { - this.items.push(new Pair(key)); - } - } - }, { - key: "toJSON", - value: function toJSON(_, ctx) { - return _get(_getPrototypeOf(YAMLSet.prototype), "toJSON", this).call(this, _, ctx, Set); - } - }, { - key: "toString", - value: function toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - if (this.hasAllNullValues()) return _get(_getPrototypeOf(YAMLSet.prototype), "toString", this).call(this, ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values'); - } - }]); - - return YAMLSet; -}(YAMLMap); - -_defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set'); - -function parseSet(doc, cst) { - var map = resolveMap(doc, cst); - if (!map.hasAllNullValues()) throw new YAMLSemanticError(cst, 'Set items must all have null values'); - return Object.assign(new YAMLSet(), map); -} - -function createSet(schema, iterable, ctx) { - var set = new YAMLSet(); - - var _iterator = _createForOfIteratorHelper(iterable), - _step; - - try { - for (_iterator.s(); !(_step = _iterator.n()).done;) { - var value = _step.value; - set.items.push(schema.createPair(value, null, ctx)); - } - } catch (err) { - _iterator.e(err); - } finally { - _iterator.f(); - } - - return set; -} - -var set = { - identify: function identify(value) { - return value instanceof Set; - }, - nodeClass: YAMLSet, - default: false, - tag: 'tag:yaml.org,2002:set', - resolve: parseSet, - createNode: createSet -}; - -var parseSexagesimal = function parseSexagesimal(sign, parts) { - var n = parts.split(':').reduce(function (n, p) { - return n * 60 + Number(p); - }, 0); - return sign === '-' ? -n : n; -}; // hhhh:mm:ss.sss - - -var stringifySexagesimal = function stringifySexagesimal(_ref) { - var value = _ref.value; - if (isNaN(value) || !isFinite(value)) return stringifyNumber(value); - var sign = ''; - - if (value < 0) { - sign = '-'; - value = Math.abs(value); - } - - var parts = [value % 60]; // seconds, including ms - - if (value < 60) { - parts.unshift(0); // at least one : is required - } else { - value = Math.round((value - parts[0]) / 60); - parts.unshift(value % 60); // minutes - - if (value >= 60) { - value = Math.round((value - parts[0]) / 60); - parts.unshift(value); // hours - } - } - - return sign + parts.map(function (n) { - return n < 10 ? '0' + String(n) : String(n); - }).join(':').replace(/000000\d*$/, '') // % 60 may introduce error - ; -}; - -var intTime = { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'TIME', - test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/, - resolve: function resolve(str, sign, parts) { - return parseSexagesimal(sign, parts.replace(/_/g, '')); - }, - stringify: stringifySexagesimal -}; -var floatTime = { - identify: function identify(value) { - return typeof value === 'number'; - }, - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'TIME', - test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/, - resolve: function resolve(str, sign, parts) { - return parseSexagesimal(sign, parts.replace(/_/g, '')); - }, - stringify: stringifySexagesimal -}; -var timestamp = { - identify: function identify(value) { - return value instanceof Date; - }, - default: true, - tag: 'tag:yaml.org,2002:timestamp', - // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part - // may be omitted altogether, resulting in a date format. In such a case, the time part is - // assumed to be 00:00:00Z (start of day, UTC). - test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd - '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace - '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)? - '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30 - ')?' + ')$'), - resolve: function resolve(str, year, month, day, hour, minute, second, millisec, tz) { - if (millisec) millisec = (millisec + '00').substr(1, 3); - var date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0); - - if (tz && tz !== 'Z') { - var d = parseSexagesimal(tz[0], tz.slice(1)); - if (Math.abs(d) < 30) d *= 60; - date -= 60000 * d; - } - - return new Date(date); - }, - stringify: function stringify(_ref2) { - var value = _ref2.value; - return value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, ''); - } -}; - -/* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */ -function shouldWarn(deprecation) { - var env = typeof process !== 'undefined' && process.env || {}; - - if (deprecation) { - if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS; - return !env.YAML_SILENCE_DEPRECATION_WARNINGS; - } - - if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS; - return !env.YAML_SILENCE_WARNINGS; -} - -function warn(warning, type) { - if (shouldWarn(false)) { - var emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to - // https://github.com/facebook/jest/issues/2549 - - if (emit) emit(warning, type);else { - // eslint-disable-next-line no-console - console.warn(type ? "".concat(type, ": ").concat(warning) : warning); - } - } -} -function warnFileDeprecation(filename) { - if (shouldWarn(true)) { - var path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/'); - warn("The endpoint 'yaml/".concat(path, "' will be removed in a future release."), 'DeprecationWarning'); - } -} -var warned = {}; -function warnOptionDeprecation(name, alternative) { - if (!warned[name] && shouldWarn(true)) { - warned[name] = true; - var msg = "The option '".concat(name, "' will be removed in a future release"); - msg += alternative ? ", use '".concat(alternative, "' instead.") : '.'; - warn(msg, 'DeprecationWarning'); - } -} - -export { warnOptionDeprecation as a, binary as b, warnFileDeprecation as c, floatTime as f, intTime as i, omap as o, pairs as p, set as s, timestamp as t, warn as w }; diff --git a/action/node_modules/yaml/browser/index.js b/action/node_modules/yaml/browser/index.js deleted file mode 100644 index b501ac4db..000000000 --- a/action/node_modules/yaml/browser/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist').YAML diff --git a/action/node_modules/yaml/browser/map.js b/action/node_modules/yaml/browser/map.js deleted file mode 100644 index 78f2ebc74..000000000 --- a/action/node_modules/yaml/browser/map.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').YAMLMap -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/pair.js b/action/node_modules/yaml/browser/pair.js deleted file mode 100644 index b2880a256..000000000 --- a/action/node_modules/yaml/browser/pair.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').Pair -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/parse-cst.js b/action/node_modules/yaml/browser/parse-cst.js deleted file mode 100644 index 806575652..000000000 --- a/action/node_modules/yaml/browser/parse-cst.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/parse-cst').parse diff --git a/action/node_modules/yaml/browser/scalar.js b/action/node_modules/yaml/browser/scalar.js deleted file mode 100644 index deee1b03a..000000000 --- a/action/node_modules/yaml/browser/scalar.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').Scalar -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/schema.js b/action/node_modules/yaml/browser/schema.js deleted file mode 100644 index 4139c4bf8..000000000 --- a/action/node_modules/yaml/browser/schema.js +++ /dev/null @@ -1,9 +0,0 @@ -const types = require('./dist/types') -const util = require('./dist/util') - -module.exports = types.Schema -module.exports.nullOptions = types.nullOptions -module.exports.strOptions = types.strOptions -module.exports.stringify = util.stringifyString - -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/seq.js b/action/node_modules/yaml/browser/seq.js deleted file mode 100644 index 66147df38..000000000 --- a/action/node_modules/yaml/browser/seq.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').YAMLSeq -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/types.js b/action/node_modules/yaml/browser/types.js deleted file mode 100644 index b1e46c47a..000000000 --- a/action/node_modules/yaml/browser/types.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/types') diff --git a/action/node_modules/yaml/browser/types/binary.js b/action/node_modules/yaml/browser/types/binary.js deleted file mode 100644 index 271b9de38..000000000 --- a/action/node_modules/yaml/browser/types/binary.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { value: true }) - -const legacy = require('../dist/legacy-exports') -exports.binary = legacy.binary -exports.default = [exports.binary] - -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/types/omap.js b/action/node_modules/yaml/browser/types/omap.js deleted file mode 100644 index 37b638b73..000000000 --- a/action/node_modules/yaml/browser/types/omap.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.omap -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/types/pairs.js b/action/node_modules/yaml/browser/types/pairs.js deleted file mode 100644 index f1df201ce..000000000 --- a/action/node_modules/yaml/browser/types/pairs.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.pairs -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/types/set.js b/action/node_modules/yaml/browser/types/set.js deleted file mode 100644 index e7dc9d42c..000000000 --- a/action/node_modules/yaml/browser/types/set.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.set -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/types/timestamp.js b/action/node_modules/yaml/browser/types/timestamp.js deleted file mode 100644 index 39c5b6dd4..000000000 --- a/action/node_modules/yaml/browser/types/timestamp.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { value: true }) - -const legacy = require('../dist/legacy-exports') -exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp] -exports.floatTime = legacy.floatTime -exports.intTime = legacy.intTime -exports.timestamp = legacy.timestamp - -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/browser/util.js b/action/node_modules/yaml/browser/util.js deleted file mode 100644 index bf3845621..000000000 --- a/action/node_modules/yaml/browser/util.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/util') diff --git a/action/node_modules/yaml/dist/Document-9b4560a1.js b/action/node_modules/yaml/dist/Document-9b4560a1.js deleted file mode 100644 index a2613db28..000000000 --- a/action/node_modules/yaml/dist/Document-9b4560a1.js +++ /dev/null @@ -1,757 +0,0 @@ -'use strict'; - -var PlainValue = require('./PlainValue-ec8e588e.js'); -var resolveSeq = require('./resolveSeq-d03cb037.js'); -var Schema = require('./Schema-88e323a7.js'); - -const defaultOptions = { - anchorPrefix: 'a', - customTags: null, - indent: 2, - indentSeq: true, - keepCstNodes: false, - keepNodeTypes: true, - keepBlobsInJSON: true, - mapAsMap: false, - maxAliasCount: 100, - prettyErrors: false, - // TODO Set true in v2 - simpleKeys: false, - version: '1.2' -}; -const scalarOptions = { - get binary() { - return resolveSeq.binaryOptions; - }, - - set binary(opt) { - Object.assign(resolveSeq.binaryOptions, opt); - }, - - get bool() { - return resolveSeq.boolOptions; - }, - - set bool(opt) { - Object.assign(resolveSeq.boolOptions, opt); - }, - - get int() { - return resolveSeq.intOptions; - }, - - set int(opt) { - Object.assign(resolveSeq.intOptions, opt); - }, - - get null() { - return resolveSeq.nullOptions; - }, - - set null(opt) { - Object.assign(resolveSeq.nullOptions, opt); - }, - - get str() { - return resolveSeq.strOptions; - }, - - set str(opt) { - Object.assign(resolveSeq.strOptions, opt); - } - -}; -const documentOptions = { - '1.0': { - schema: 'yaml-1.1', - merge: true, - tagPrefixes: [{ - handle: '!', - prefix: PlainValue.defaultTagPrefix - }, { - handle: '!!', - prefix: 'tag:private.yaml.org,2002:' - }] - }, - 1.1: { - schema: 'yaml-1.1', - merge: true, - tagPrefixes: [{ - handle: '!', - prefix: '!' - }, { - handle: '!!', - prefix: PlainValue.defaultTagPrefix - }] - }, - 1.2: { - schema: 'core', - merge: false, - tagPrefixes: [{ - handle: '!', - prefix: '!' - }, { - handle: '!!', - prefix: PlainValue.defaultTagPrefix - }] - } -}; - -function stringifyTag(doc, tag) { - if ((doc.version || doc.options.version) === '1.0') { - const priv = tag.match(/^tag:private\.yaml\.org,2002:([^:/]+)$/); - if (priv) return '!' + priv[1]; - const vocab = tag.match(/^tag:([a-zA-Z0-9-]+)\.yaml\.org,2002:(.*)/); - return vocab ? `!${vocab[1]}/${vocab[2]}` : `!${tag.replace(/^tag:/, '')}`; - } - - let p = doc.tagPrefixes.find(p => tag.indexOf(p.prefix) === 0); - - if (!p) { - const dtp = doc.getDefaults().tagPrefixes; - p = dtp && dtp.find(p => tag.indexOf(p.prefix) === 0); - } - - if (!p) return tag[0] === '!' ? tag : `!<${tag}>`; - const suffix = tag.substr(p.prefix.length).replace(/[!,[\]{}]/g, ch => ({ - '!': '%21', - ',': '%2C', - '[': '%5B', - ']': '%5D', - '{': '%7B', - '}': '%7D' - })[ch]); - return p.handle + suffix; -} - -function getTagObject(tags, item) { - if (item instanceof resolveSeq.Alias) return resolveSeq.Alias; - - if (item.tag) { - const match = tags.filter(t => t.tag === item.tag); - if (match.length > 0) return match.find(t => t.format === item.format) || match[0]; - } - - let tagObj, obj; - - if (item instanceof resolveSeq.Scalar) { - obj = item.value; // TODO: deprecate/remove class check - - const match = tags.filter(t => t.identify && t.identify(obj) || t.class && obj instanceof t.class); - tagObj = match.find(t => t.format === item.format) || match.find(t => !t.format); - } else { - obj = item; - tagObj = tags.find(t => t.nodeClass && obj instanceof t.nodeClass); - } - - if (!tagObj) { - const name = obj && obj.constructor ? obj.constructor.name : typeof obj; - throw new Error(`Tag not resolved for ${name} value`); - } - - return tagObj; -} // needs to be called before value stringifier to allow for circular anchor refs - - -function stringifyProps(node, tagObj, { - anchors, - doc -}) { - const props = []; - const anchor = doc.anchors.getName(node); - - if (anchor) { - anchors[anchor] = node; - props.push(`&${anchor}`); - } - - if (node.tag) { - props.push(stringifyTag(doc, node.tag)); - } else if (!tagObj.default) { - props.push(stringifyTag(doc, tagObj.tag)); - } - - return props.join(' '); -} - -function stringify(item, ctx, onComment, onChompKeep) { - const { - anchors, - schema - } = ctx.doc; - let tagObj; - - if (!(item instanceof resolveSeq.Node)) { - const createCtx = { - aliasNodes: [], - onTagObj: o => tagObj = o, - prevObjects: new Map() - }; - item = schema.createNode(item, true, null, createCtx); - - for (const alias of createCtx.aliasNodes) { - alias.source = alias.source.node; - let name = anchors.getName(alias.source); - - if (!name) { - name = anchors.newName(); - anchors.map[name] = alias.source; - } - } - } - - if (item instanceof resolveSeq.Pair) return item.toString(ctx, onComment, onChompKeep); - if (!tagObj) tagObj = getTagObject(schema.tags, item); - const props = stringifyProps(item, tagObj, ctx); - if (props.length > 0) ctx.indentAtStart = (ctx.indentAtStart || 0) + props.length + 1; - const str = typeof tagObj.stringify === 'function' ? tagObj.stringify(item, ctx, onComment, onChompKeep) : item instanceof resolveSeq.Scalar ? resolveSeq.stringifyString(item, ctx, onComment, onChompKeep) : item.toString(ctx, onComment, onChompKeep); - if (!props) return str; - return item instanceof resolveSeq.Scalar || str[0] === '{' || str[0] === '[' ? `${props} ${str}` : `${props}\n${ctx.indent}${str}`; -} - -class Anchors { - static validAnchorNode(node) { - return node instanceof resolveSeq.Scalar || node instanceof resolveSeq.YAMLSeq || node instanceof resolveSeq.YAMLMap; - } - - constructor(prefix) { - PlainValue._defineProperty(this, "map", Object.create(null)); - - this.prefix = prefix; - } - - createAlias(node, name) { - this.setAnchor(node, name); - return new resolveSeq.Alias(node); - } - - createMergePair(...sources) { - const merge = new resolveSeq.Merge(); - merge.value.items = sources.map(s => { - if (s instanceof resolveSeq.Alias) { - if (s.source instanceof resolveSeq.YAMLMap) return s; - } else if (s instanceof resolveSeq.YAMLMap) { - return this.createAlias(s); - } - - throw new Error('Merge sources must be Map nodes or their Aliases'); - }); - return merge; - } - - getName(node) { - const { - map - } = this; - return Object.keys(map).find(a => map[a] === node); - } - - getNames() { - return Object.keys(this.map); - } - - getNode(name) { - return this.map[name]; - } - - newName(prefix) { - if (!prefix) prefix = this.prefix; - const names = Object.keys(this.map); - - for (let i = 1; true; ++i) { - const name = `${prefix}${i}`; - if (!names.includes(name)) return name; - } - } // During parsing, map & aliases contain CST nodes - - - resolveNodes() { - const { - map, - _cstAliases - } = this; - Object.keys(map).forEach(a => { - map[a] = map[a].resolved; - }); - - _cstAliases.forEach(a => { - a.source = a.source.resolved; - }); - - delete this._cstAliases; - } - - setAnchor(node, name) { - if (node != null && !Anchors.validAnchorNode(node)) { - throw new Error('Anchors may only be set for Scalar, Seq and Map nodes'); - } - - if (name && /[\x00-\x19\s,[\]{}]/.test(name)) { - throw new Error('Anchor names must not contain whitespace or control characters'); - } - - const { - map - } = this; - const prev = node && Object.keys(map).find(a => map[a] === node); - - if (prev) { - if (!name) { - return prev; - } else if (prev !== name) { - delete map[prev]; - map[name] = node; - } - } else { - if (!name) { - if (!node) return null; - name = this.newName(); - } - - map[name] = node; - } - - return name; - } - -} - -const visit = (node, tags) => { - if (node && typeof node === 'object') { - const { - tag - } = node; - - if (node instanceof resolveSeq.Collection) { - if (tag) tags[tag] = true; - node.items.forEach(n => visit(n, tags)); - } else if (node instanceof resolveSeq.Pair) { - visit(node.key, tags); - visit(node.value, tags); - } else if (node instanceof resolveSeq.Scalar) { - if (tag) tags[tag] = true; - } - } - - return tags; -}; - -const listTagNames = node => Object.keys(visit(node, {})); - -function parseContents(doc, contents) { - const comments = { - before: [], - after: [] - }; - let body = undefined; - let spaceBefore = false; - - for (const node of contents) { - if (node.valueRange) { - if (body !== undefined) { - const msg = 'Document contains trailing content not separated by a ... or --- line'; - doc.errors.push(new PlainValue.YAMLSyntaxError(node, msg)); - break; - } - - const res = resolveSeq.resolveNode(doc, node); - - if (spaceBefore) { - res.spaceBefore = true; - spaceBefore = false; - } - - body = res; - } else if (node.comment !== null) { - const cc = body === undefined ? comments.before : comments.after; - cc.push(node.comment); - } else if (node.type === PlainValue.Type.BLANK_LINE) { - spaceBefore = true; - - if (body === undefined && comments.before.length > 0 && !doc.commentBefore) { - // space-separated comments at start are parsed as document comments - doc.commentBefore = comments.before.join('\n'); - comments.before = []; - } - } - } - - doc.contents = body || null; - - if (!body) { - doc.comment = comments.before.concat(comments.after).join('\n') || null; - } else { - const cb = comments.before.join('\n'); - - if (cb) { - const cbNode = body instanceof resolveSeq.Collection && body.items[0] ? body.items[0] : body; - cbNode.commentBefore = cbNode.commentBefore ? `${cb}\n${cbNode.commentBefore}` : cb; - } - - doc.comment = comments.after.join('\n') || null; - } -} - -function resolveTagDirective({ - tagPrefixes -}, directive) { - const [handle, prefix] = directive.parameters; - - if (!handle || !prefix) { - const msg = 'Insufficient parameters given for %TAG directive'; - throw new PlainValue.YAMLSemanticError(directive, msg); - } - - if (tagPrefixes.some(p => p.handle === handle)) { - const msg = 'The %TAG directive must only be given at most once per handle in the same document.'; - throw new PlainValue.YAMLSemanticError(directive, msg); - } - - return { - handle, - prefix - }; -} - -function resolveYamlDirective(doc, directive) { - let [version] = directive.parameters; - if (directive.name === 'YAML:1.0') version = '1.0'; - - if (!version) { - const msg = 'Insufficient parameters given for %YAML directive'; - throw new PlainValue.YAMLSemanticError(directive, msg); - } - - if (!documentOptions[version]) { - const v0 = doc.version || doc.options.version; - const msg = `Document will be parsed as YAML ${v0} rather than YAML ${version}`; - doc.warnings.push(new PlainValue.YAMLWarning(directive, msg)); - } - - return version; -} - -function parseDirectives(doc, directives, prevDoc) { - const directiveComments = []; - let hasDirectives = false; - - for (const directive of directives) { - const { - comment, - name - } = directive; - - switch (name) { - case 'TAG': - try { - doc.tagPrefixes.push(resolveTagDirective(doc, directive)); - } catch (error) { - doc.errors.push(error); - } - - hasDirectives = true; - break; - - case 'YAML': - case 'YAML:1.0': - if (doc.version) { - const msg = 'The %YAML directive must only be given at most once per document.'; - doc.errors.push(new PlainValue.YAMLSemanticError(directive, msg)); - } - - try { - doc.version = resolveYamlDirective(doc, directive); - } catch (error) { - doc.errors.push(error); - } - - hasDirectives = true; - break; - - default: - if (name) { - const msg = `YAML only supports %TAG and %YAML directives, and not %${name}`; - doc.warnings.push(new PlainValue.YAMLWarning(directive, msg)); - } - - } - - if (comment) directiveComments.push(comment); - } - - if (prevDoc && !hasDirectives && '1.1' === (doc.version || prevDoc.version || doc.options.version)) { - const copyTagPrefix = ({ - handle, - prefix - }) => ({ - handle, - prefix - }); - - doc.tagPrefixes = prevDoc.tagPrefixes.map(copyTagPrefix); - doc.version = prevDoc.version; - } - - doc.commentBefore = directiveComments.join('\n') || null; -} - -function assertCollection(contents) { - if (contents instanceof resolveSeq.Collection) return true; - throw new Error('Expected a YAML collection as document contents'); -} - -class Document { - constructor(options) { - this.anchors = new Anchors(options.anchorPrefix); - this.commentBefore = null; - this.comment = null; - this.contents = null; - this.directivesEndMarker = null; - this.errors = []; - this.options = options; - this.schema = null; - this.tagPrefixes = []; - this.version = null; - this.warnings = []; - } - - add(value) { - assertCollection(this.contents); - return this.contents.add(value); - } - - addIn(path, value) { - assertCollection(this.contents); - this.contents.addIn(path, value); - } - - delete(key) { - assertCollection(this.contents); - return this.contents.delete(key); - } - - deleteIn(path) { - if (resolveSeq.isEmptyPath(path)) { - if (this.contents == null) return false; - this.contents = null; - return true; - } - - assertCollection(this.contents); - return this.contents.deleteIn(path); - } - - getDefaults() { - return Document.defaults[this.version] || Document.defaults[this.options.version] || {}; - } - - get(key, keepScalar) { - return this.contents instanceof resolveSeq.Collection ? this.contents.get(key, keepScalar) : undefined; - } - - getIn(path, keepScalar) { - if (resolveSeq.isEmptyPath(path)) return !keepScalar && this.contents instanceof resolveSeq.Scalar ? this.contents.value : this.contents; - return this.contents instanceof resolveSeq.Collection ? this.contents.getIn(path, keepScalar) : undefined; - } - - has(key) { - return this.contents instanceof resolveSeq.Collection ? this.contents.has(key) : false; - } - - hasIn(path) { - if (resolveSeq.isEmptyPath(path)) return this.contents !== undefined; - return this.contents instanceof resolveSeq.Collection ? this.contents.hasIn(path) : false; - } - - set(key, value) { - assertCollection(this.contents); - this.contents.set(key, value); - } - - setIn(path, value) { - if (resolveSeq.isEmptyPath(path)) this.contents = value;else { - assertCollection(this.contents); - this.contents.setIn(path, value); - } - } - - setSchema(id, customTags) { - if (!id && !customTags && this.schema) return; - if (typeof id === 'number') id = id.toFixed(1); - - if (id === '1.0' || id === '1.1' || id === '1.2') { - if (this.version) this.version = id;else this.options.version = id; - delete this.options.schema; - } else if (id && typeof id === 'string') { - this.options.schema = id; - } - - if (Array.isArray(customTags)) this.options.customTags = customTags; - const opt = Object.assign({}, this.getDefaults(), this.options); - this.schema = new Schema.Schema(opt); - } - - parse(node, prevDoc) { - if (this.options.keepCstNodes) this.cstNode = node; - if (this.options.keepNodeTypes) this.type = 'DOCUMENT'; - const { - directives = [], - contents = [], - directivesEndMarker, - error, - valueRange - } = node; - - if (error) { - if (!error.source) error.source = this; - this.errors.push(error); - } - - parseDirectives(this, directives, prevDoc); - if (directivesEndMarker) this.directivesEndMarker = true; - this.range = valueRange ? [valueRange.start, valueRange.end] : null; - this.setSchema(); - this.anchors._cstAliases = []; - parseContents(this, contents); - this.anchors.resolveNodes(); - - if (this.options.prettyErrors) { - for (const error of this.errors) if (error instanceof PlainValue.YAMLError) error.makePretty(); - - for (const warn of this.warnings) if (warn instanceof PlainValue.YAMLError) warn.makePretty(); - } - - return this; - } - - listNonDefaultTags() { - return listTagNames(this.contents).filter(t => t.indexOf(Schema.Schema.defaultPrefix) !== 0); - } - - setTagPrefix(handle, prefix) { - if (handle[0] !== '!' || handle[handle.length - 1] !== '!') throw new Error('Handle must start and end with !'); - - if (prefix) { - const prev = this.tagPrefixes.find(p => p.handle === handle); - if (prev) prev.prefix = prefix;else this.tagPrefixes.push({ - handle, - prefix - }); - } else { - this.tagPrefixes = this.tagPrefixes.filter(p => p.handle !== handle); - } - } - - toJSON(arg, onAnchor) { - const { - keepBlobsInJSON, - mapAsMap, - maxAliasCount - } = this.options; - const keep = keepBlobsInJSON && (typeof arg !== 'string' || !(this.contents instanceof resolveSeq.Scalar)); - const ctx = { - doc: this, - indentStep: ' ', - keep, - mapAsMap: keep && !!mapAsMap, - maxAliasCount, - stringify // Requiring directly in Pair would create circular dependencies - - }; - const anchorNames = Object.keys(this.anchors.map); - if (anchorNames.length > 0) ctx.anchors = new Map(anchorNames.map(name => [this.anchors.map[name], { - alias: [], - aliasCount: 0, - count: 1 - }])); - const res = resolveSeq.toJSON(this.contents, arg, ctx); - if (typeof onAnchor === 'function' && ctx.anchors) for (const { - count, - res - } of ctx.anchors.values()) onAnchor(res, count); - return res; - } - - toString() { - if (this.errors.length > 0) throw new Error('Document with errors cannot be stringified'); - const indentSize = this.options.indent; - - if (!Number.isInteger(indentSize) || indentSize <= 0) { - const s = JSON.stringify(indentSize); - throw new Error(`"indent" option must be a positive integer, not ${s}`); - } - - this.setSchema(); - const lines = []; - let hasDirectives = false; - - if (this.version) { - let vd = '%YAML 1.2'; - - if (this.schema.name === 'yaml-1.1') { - if (this.version === '1.0') vd = '%YAML:1.0';else if (this.version === '1.1') vd = '%YAML 1.1'; - } - - lines.push(vd); - hasDirectives = true; - } - - const tagNames = this.listNonDefaultTags(); - this.tagPrefixes.forEach(({ - handle, - prefix - }) => { - if (tagNames.some(t => t.indexOf(prefix) === 0)) { - lines.push(`%TAG ${handle} ${prefix}`); - hasDirectives = true; - } - }); - if (hasDirectives || this.directivesEndMarker) lines.push('---'); - - if (this.commentBefore) { - if (hasDirectives || !this.directivesEndMarker) lines.unshift(''); - lines.unshift(this.commentBefore.replace(/^/gm, '#')); - } - - const ctx = { - anchors: Object.create(null), - doc: this, - indent: '', - indentStep: ' '.repeat(indentSize), - stringify // Requiring directly in nodes would create circular dependencies - - }; - let chompKeep = false; - let contentComment = null; - - if (this.contents) { - if (this.contents instanceof resolveSeq.Node) { - if (this.contents.spaceBefore && (hasDirectives || this.directivesEndMarker)) lines.push(''); - if (this.contents.commentBefore) lines.push(this.contents.commentBefore.replace(/^/gm, '#')); // top-level block scalars need to be indented if followed by a comment - - ctx.forceBlockIndent = !!this.comment; - contentComment = this.contents.comment; - } - - const onChompKeep = contentComment ? null : () => chompKeep = true; - const body = stringify(this.contents, ctx, () => contentComment = null, onChompKeep); - lines.push(resolveSeq.addComment(body, '', contentComment)); - } else if (this.contents !== undefined) { - lines.push(stringify(this.contents, ctx)); - } - - if (this.comment) { - if ((!chompKeep || contentComment) && lines[lines.length - 1] !== '') lines.push(''); - lines.push(this.comment.replace(/^/gm, '#')); - } - - return lines.join('\n') + '\n'; - } - -} - -PlainValue._defineProperty(Document, "defaults", documentOptions); - -exports.Document = Document; -exports.defaultOptions = defaultOptions; -exports.scalarOptions = scalarOptions; diff --git a/action/node_modules/yaml/dist/PlainValue-ec8e588e.js b/action/node_modules/yaml/dist/PlainValue-ec8e588e.js deleted file mode 100644 index db8a14e3c..000000000 --- a/action/node_modules/yaml/dist/PlainValue-ec8e588e.js +++ /dev/null @@ -1,876 +0,0 @@ -'use strict'; - -const Char = { - ANCHOR: '&', - COMMENT: '#', - TAG: '!', - DIRECTIVES_END: '-', - DOCUMENT_END: '.' -}; -const Type = { - ALIAS: 'ALIAS', - BLANK_LINE: 'BLANK_LINE', - BLOCK_FOLDED: 'BLOCK_FOLDED', - BLOCK_LITERAL: 'BLOCK_LITERAL', - COMMENT: 'COMMENT', - DIRECTIVE: 'DIRECTIVE', - DOCUMENT: 'DOCUMENT', - FLOW_MAP: 'FLOW_MAP', - FLOW_SEQ: 'FLOW_SEQ', - MAP: 'MAP', - MAP_KEY: 'MAP_KEY', - MAP_VALUE: 'MAP_VALUE', - PLAIN: 'PLAIN', - QUOTE_DOUBLE: 'QUOTE_DOUBLE', - QUOTE_SINGLE: 'QUOTE_SINGLE', - SEQ: 'SEQ', - SEQ_ITEM: 'SEQ_ITEM' -}; -const defaultTagPrefix = 'tag:yaml.org,2002:'; -const defaultTags = { - MAP: 'tag:yaml.org,2002:map', - SEQ: 'tag:yaml.org,2002:seq', - STR: 'tag:yaml.org,2002:str' -}; - -function findLineStarts(src) { - const ls = [0]; - let offset = src.indexOf('\n'); - - while (offset !== -1) { - offset += 1; - ls.push(offset); - offset = src.indexOf('\n', offset); - } - - return ls; -} - -function getSrcInfo(cst) { - let lineStarts, src; - - if (typeof cst === 'string') { - lineStarts = findLineStarts(cst); - src = cst; - } else { - if (Array.isArray(cst)) cst = cst[0]; - - if (cst && cst.context) { - if (!cst.lineStarts) cst.lineStarts = findLineStarts(cst.context.src); - lineStarts = cst.lineStarts; - src = cst.context.src; - } - } - - return { - lineStarts, - src - }; -} -/** - * @typedef {Object} LinePos - One-indexed position in the source - * @property {number} line - * @property {number} col - */ - -/** - * Determine the line/col position matching a character offset. - * - * Accepts a source string or a CST document as the second parameter. With - * the latter, starting indices for lines are cached in the document as - * `lineStarts: number[]`. - * - * Returns a one-indexed `{ line, col }` location if found, or - * `undefined` otherwise. - * - * @param {number} offset - * @param {string|Document|Document[]} cst - * @returns {?LinePos} - */ - - -function getLinePos(offset, cst) { - if (typeof offset !== 'number' || offset < 0) return null; - const { - lineStarts, - src - } = getSrcInfo(cst); - if (!lineStarts || !src || offset > src.length) return null; - - for (let i = 0; i < lineStarts.length; ++i) { - const start = lineStarts[i]; - - if (offset < start) { - return { - line: i, - col: offset - lineStarts[i - 1] + 1 - }; - } - - if (offset === start) return { - line: i + 1, - col: 1 - }; - } - - const line = lineStarts.length; - return { - line, - col: offset - lineStarts[line - 1] + 1 - }; -} -/** - * Get a specified line from the source. - * - * Accepts a source string or a CST document as the second parameter. With - * the latter, starting indices for lines are cached in the document as - * `lineStarts: number[]`. - * - * Returns the line as a string if found, or `null` otherwise. - * - * @param {number} line One-indexed line number - * @param {string|Document|Document[]} cst - * @returns {?string} - */ - -function getLine(line, cst) { - const { - lineStarts, - src - } = getSrcInfo(cst); - if (!lineStarts || !(line >= 1) || line > lineStarts.length) return null; - const start = lineStarts[line - 1]; - let end = lineStarts[line]; // undefined for last line; that's ok for slice() - - while (end && end > start && src[end - 1] === '\n') --end; - - return src.slice(start, end); -} -/** - * Pretty-print the starting line from the source indicated by the range `pos` - * - * Trims output to `maxWidth` chars while keeping the starting column visible, - * using `…` at either end to indicate dropped characters. - * - * Returns a two-line string (or `null`) with `\n` as separator; the second line - * will hold appropriately indented `^` marks indicating the column range. - * - * @param {Object} pos - * @param {LinePos} pos.start - * @param {LinePos} [pos.end] - * @param {string|Document|Document[]*} cst - * @param {number} [maxWidth=80] - * @returns {?string} - */ - -function getPrettyContext({ - start, - end -}, cst, maxWidth = 80) { - let src = getLine(start.line, cst); - if (!src) return null; - let { - col - } = start; - - if (src.length > maxWidth) { - if (col <= maxWidth - 10) { - src = src.substr(0, maxWidth - 1) + '…'; - } else { - const halfWidth = Math.round(maxWidth / 2); - if (src.length > col + halfWidth) src = src.substr(0, col + halfWidth - 1) + '…'; - col -= src.length - maxWidth; - src = '…' + src.substr(1 - maxWidth); - } - } - - let errLen = 1; - let errEnd = ''; - - if (end) { - if (end.line === start.line && col + (end.col - start.col) <= maxWidth + 1) { - errLen = end.col - start.col; - } else { - errLen = Math.min(src.length + 1, maxWidth) - col; - errEnd = '…'; - } - } - - const offset = col > 1 ? ' '.repeat(col - 1) : ''; - const err = '^'.repeat(errLen); - return `${src}\n${offset}${err}${errEnd}`; -} - -class Range { - static copy(orig) { - return new Range(orig.start, orig.end); - } - - constructor(start, end) { - this.start = start; - this.end = end || start; - } - - isEmpty() { - return typeof this.start !== 'number' || !this.end || this.end <= this.start; - } - /** - * Set `origStart` and `origEnd` to point to the original source range for - * this node, which may differ due to dropped CR characters. - * - * @param {number[]} cr - Positions of dropped CR characters - * @param {number} offset - Starting index of `cr` from the last call - * @returns {number} - The next offset, matching the one found for `origStart` - */ - - - setOrigRange(cr, offset) { - const { - start, - end - } = this; - - if (cr.length === 0 || end <= cr[0]) { - this.origStart = start; - this.origEnd = end; - return offset; - } - - let i = offset; - - while (i < cr.length) { - if (cr[i] > start) break;else ++i; - } - - this.origStart = start + i; - const nextOffset = i; - - while (i < cr.length) { - // if end was at \n, it should now be at \r - if (cr[i] >= end) break;else ++i; - } - - this.origEnd = end + i; - return nextOffset; - } - -} - -/** Root class of all nodes */ - -class Node { - static addStringTerminator(src, offset, str) { - if (str[str.length - 1] === '\n') return str; - const next = Node.endOfWhiteSpace(src, offset); - return next >= src.length || src[next] === '\n' ? str + '\n' : str; - } // ^(---|...) - - - static atDocumentBoundary(src, offset, sep) { - const ch0 = src[offset]; - if (!ch0) return true; - const prev = src[offset - 1]; - if (prev && prev !== '\n') return false; - - if (sep) { - if (ch0 !== sep) return false; - } else { - if (ch0 !== Char.DIRECTIVES_END && ch0 !== Char.DOCUMENT_END) return false; - } - - const ch1 = src[offset + 1]; - const ch2 = src[offset + 2]; - if (ch1 !== ch0 || ch2 !== ch0) return false; - const ch3 = src[offset + 3]; - return !ch3 || ch3 === '\n' || ch3 === '\t' || ch3 === ' '; - } - - static endOfIdentifier(src, offset) { - let ch = src[offset]; - const isVerbatim = ch === '<'; - const notOk = isVerbatim ? ['\n', '\t', ' ', '>'] : ['\n', '\t', ' ', '[', ']', '{', '}', ',']; - - while (ch && notOk.indexOf(ch) === -1) ch = src[offset += 1]; - - if (isVerbatim && ch === '>') offset += 1; - return offset; - } - - static endOfIndent(src, offset) { - let ch = src[offset]; - - while (ch === ' ') ch = src[offset += 1]; - - return offset; - } - - static endOfLine(src, offset) { - let ch = src[offset]; - - while (ch && ch !== '\n') ch = src[offset += 1]; - - return offset; - } - - static endOfWhiteSpace(src, offset) { - let ch = src[offset]; - - while (ch === '\t' || ch === ' ') ch = src[offset += 1]; - - return offset; - } - - static startOfLine(src, offset) { - let ch = src[offset - 1]; - if (ch === '\n') return offset; - - while (ch && ch !== '\n') ch = src[offset -= 1]; - - return offset + 1; - } - /** - * End of indentation, or null if the line's indent level is not more - * than `indent` - * - * @param {string} src - * @param {number} indent - * @param {number} lineStart - * @returns {?number} - */ - - - static endOfBlockIndent(src, indent, lineStart) { - const inEnd = Node.endOfIndent(src, lineStart); - - if (inEnd > lineStart + indent) { - return inEnd; - } else { - const wsEnd = Node.endOfWhiteSpace(src, inEnd); - const ch = src[wsEnd]; - if (!ch || ch === '\n') return wsEnd; - } - - return null; - } - - static atBlank(src, offset, endAsBlank) { - const ch = src[offset]; - return ch === '\n' || ch === '\t' || ch === ' ' || endAsBlank && !ch; - } - - static nextNodeIsIndented(ch, indentDiff, indicatorAsIndent) { - if (!ch || indentDiff < 0) return false; - if (indentDiff > 0) return true; - return indicatorAsIndent && ch === '-'; - } // should be at line or string end, or at next non-whitespace char - - - static normalizeOffset(src, offset) { - const ch = src[offset]; - return !ch ? offset : ch !== '\n' && src[offset - 1] === '\n' ? offset - 1 : Node.endOfWhiteSpace(src, offset); - } // fold single newline into space, multiple newlines to N - 1 newlines - // presumes src[offset] === '\n' - - - static foldNewline(src, offset, indent) { - let inCount = 0; - let error = false; - let fold = ''; - let ch = src[offset + 1]; - - while (ch === ' ' || ch === '\t' || ch === '\n') { - switch (ch) { - case '\n': - inCount = 0; - offset += 1; - fold += '\n'; - break; - - case '\t': - if (inCount <= indent) error = true; - offset = Node.endOfWhiteSpace(src, offset + 2) - 1; - break; - - case ' ': - inCount += 1; - offset += 1; - break; - } - - ch = src[offset + 1]; - } - - if (!fold) fold = ' '; - if (ch && inCount <= indent) error = true; - return { - fold, - offset, - error - }; - } - - constructor(type, props, context) { - Object.defineProperty(this, 'context', { - value: context || null, - writable: true - }); - this.error = null; - this.range = null; - this.valueRange = null; - this.props = props || []; - this.type = type; - this.value = null; - } - - getPropValue(idx, key, skipKey) { - if (!this.context) return null; - const { - src - } = this.context; - const prop = this.props[idx]; - return prop && src[prop.start] === key ? src.slice(prop.start + (skipKey ? 1 : 0), prop.end) : null; - } - - get anchor() { - for (let i = 0; i < this.props.length; ++i) { - const anchor = this.getPropValue(i, Char.ANCHOR, true); - if (anchor != null) return anchor; - } - - return null; - } - - get comment() { - const comments = []; - - for (let i = 0; i < this.props.length; ++i) { - const comment = this.getPropValue(i, Char.COMMENT, true); - if (comment != null) comments.push(comment); - } - - return comments.length > 0 ? comments.join('\n') : null; - } - - commentHasRequiredWhitespace(start) { - const { - src - } = this.context; - if (this.header && start === this.header.end) return false; - if (!this.valueRange) return false; - const { - end - } = this.valueRange; - return start !== end || Node.atBlank(src, end - 1); - } - - get hasComment() { - if (this.context) { - const { - src - } = this.context; - - for (let i = 0; i < this.props.length; ++i) { - if (src[this.props[i].start] === Char.COMMENT) return true; - } - } - - return false; - } - - get hasProps() { - if (this.context) { - const { - src - } = this.context; - - for (let i = 0; i < this.props.length; ++i) { - if (src[this.props[i].start] !== Char.COMMENT) return true; - } - } - - return false; - } - - get includesTrailingLines() { - return false; - } - - get jsonLike() { - const jsonLikeTypes = [Type.FLOW_MAP, Type.FLOW_SEQ, Type.QUOTE_DOUBLE, Type.QUOTE_SINGLE]; - return jsonLikeTypes.indexOf(this.type) !== -1; - } - - get rangeAsLinePos() { - if (!this.range || !this.context) return undefined; - const start = getLinePos(this.range.start, this.context.root); - if (!start) return undefined; - const end = getLinePos(this.range.end, this.context.root); - return { - start, - end - }; - } - - get rawValue() { - if (!this.valueRange || !this.context) return null; - const { - start, - end - } = this.valueRange; - return this.context.src.slice(start, end); - } - - get tag() { - for (let i = 0; i < this.props.length; ++i) { - const tag = this.getPropValue(i, Char.TAG, false); - - if (tag != null) { - if (tag[1] === '<') { - return { - verbatim: tag.slice(2, -1) - }; - } else { - // eslint-disable-next-line no-unused-vars - const [_, handle, suffix] = tag.match(/^(.*!)([^!]*)$/); - return { - handle, - suffix - }; - } - } - } - - return null; - } - - get valueRangeContainsNewline() { - if (!this.valueRange || !this.context) return false; - const { - start, - end - } = this.valueRange; - const { - src - } = this.context; - - for (let i = start; i < end; ++i) { - if (src[i] === '\n') return true; - } - - return false; - } - - parseComment(start) { - const { - src - } = this.context; - - if (src[start] === Char.COMMENT) { - const end = Node.endOfLine(src, start + 1); - const commentRange = new Range(start, end); - this.props.push(commentRange); - return end; - } - - return start; - } - /** - * Populates the `origStart` and `origEnd` values of all ranges for this - * node. Extended by child classes to handle descendant nodes. - * - * @param {number[]} cr - Positions of dropped CR characters - * @param {number} offset - Starting index of `cr` from the last call - * @returns {number} - The next offset, matching the one found for `origStart` - */ - - - setOrigRanges(cr, offset) { - if (this.range) offset = this.range.setOrigRange(cr, offset); - if (this.valueRange) this.valueRange.setOrigRange(cr, offset); - this.props.forEach(prop => prop.setOrigRange(cr, offset)); - return offset; - } - - toString() { - const { - context: { - src - }, - range, - value - } = this; - if (value != null) return value; - const str = src.slice(range.start, range.end); - return Node.addStringTerminator(src, range.end, str); - } - -} - -class YAMLError extends Error { - constructor(name, source, message) { - if (!message || !(source instanceof Node)) throw new Error(`Invalid arguments for new ${name}`); - super(); - this.name = name; - this.message = message; - this.source = source; - } - - makePretty() { - if (!this.source) return; - this.nodeType = this.source.type; - const cst = this.source.context && this.source.context.root; - - if (typeof this.offset === 'number') { - this.range = new Range(this.offset, this.offset + 1); - const start = cst && getLinePos(this.offset, cst); - - if (start) { - const end = { - line: start.line, - col: start.col + 1 - }; - this.linePos = { - start, - end - }; - } - - delete this.offset; - } else { - this.range = this.source.range; - this.linePos = this.source.rangeAsLinePos; - } - - if (this.linePos) { - const { - line, - col - } = this.linePos.start; - this.message += ` at line ${line}, column ${col}`; - const ctx = cst && getPrettyContext(this.linePos, cst); - if (ctx) this.message += `:\n\n${ctx}\n`; - } - - delete this.source; - } - -} -class YAMLReferenceError extends YAMLError { - constructor(source, message) { - super('YAMLReferenceError', source, message); - } - -} -class YAMLSemanticError extends YAMLError { - constructor(source, message) { - super('YAMLSemanticError', source, message); - } - -} -class YAMLSyntaxError extends YAMLError { - constructor(source, message) { - super('YAMLSyntaxError', source, message); - } - -} -class YAMLWarning extends YAMLError { - constructor(source, message) { - super('YAMLWarning', source, message); - } - -} - -function _defineProperty(obj, key, value) { - if (key in obj) { - Object.defineProperty(obj, key, { - value: value, - enumerable: true, - configurable: true, - writable: true - }); - } else { - obj[key] = value; - } - - return obj; -} - -class PlainValue extends Node { - static endOfLine(src, start, inFlow) { - let ch = src[start]; - let offset = start; - - while (ch && ch !== '\n') { - if (inFlow && (ch === '[' || ch === ']' || ch === '{' || ch === '}' || ch === ',')) break; - const next = src[offset + 1]; - if (ch === ':' && (!next || next === '\n' || next === '\t' || next === ' ' || inFlow && next === ',')) break; - if ((ch === ' ' || ch === '\t') && next === '#') break; - offset += 1; - ch = next; - } - - return offset; - } - - get strValue() { - if (!this.valueRange || !this.context) return null; - let { - start, - end - } = this.valueRange; - const { - src - } = this.context; - let ch = src[end - 1]; - - while (start < end && (ch === '\n' || ch === '\t' || ch === ' ')) ch = src[--end - 1]; - - let str = ''; - - for (let i = start; i < end; ++i) { - const ch = src[i]; - - if (ch === '\n') { - const { - fold, - offset - } = Node.foldNewline(src, i, -1); - str += fold; - i = offset; - } else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - const wsStart = i; - let next = src[i + 1]; - - while (i < end && (next === ' ' || next === '\t')) { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch; - } else { - str += ch; - } - } - - const ch0 = src[start]; - - switch (ch0) { - case '\t': - { - const msg = 'Plain value cannot start with a tab character'; - const errors = [new YAMLSemanticError(this, msg)]; - return { - errors, - str - }; - } - - case '@': - case '`': - { - const msg = `Plain value cannot start with reserved character ${ch0}`; - const errors = [new YAMLSemanticError(this, msg)]; - return { - errors, - str - }; - } - - default: - return str; - } - } - - parseBlockValue(start) { - const { - indent, - inFlow, - src - } = this.context; - let offset = start; - let valueEnd = start; - - for (let ch = src[offset]; ch === '\n'; ch = src[offset]) { - if (Node.atDocumentBoundary(src, offset + 1)) break; - const end = Node.endOfBlockIndent(src, indent, offset + 1); - if (end === null || src[end] === '#') break; - - if (src[end] === '\n') { - offset = end; - } else { - valueEnd = PlainValue.endOfLine(src, end, inFlow); - offset = valueEnd; - } - } - - if (this.valueRange.isEmpty()) this.valueRange.start = start; - this.valueRange.end = valueEnd; - return valueEnd; - } - /** - * Parses a plain value from the source - * - * Accepted forms are: - * ``` - * #comment - * - * first line - * - * first line #comment - * - * first line - * block - * lines - * - * #comment - * block - * lines - * ``` - * where block lines are empty or have an indent level greater than `indent`. - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar, may be `\n` - */ - - - parse(context, start) { - this.context = context; - const { - inFlow, - src - } = context; - let offset = start; - const ch = src[offset]; - - if (ch && ch !== '#' && ch !== '\n') { - offset = PlainValue.endOfLine(src, start, inFlow); - } - - this.valueRange = new Range(start, offset); - offset = Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - - if (!this.hasComment || this.valueRange.isEmpty()) { - offset = this.parseBlockValue(offset); - } - - return offset; - } - -} - -exports.Char = Char; -exports.Node = Node; -exports.PlainValue = PlainValue; -exports.Range = Range; -exports.Type = Type; -exports.YAMLError = YAMLError; -exports.YAMLReferenceError = YAMLReferenceError; -exports.YAMLSemanticError = YAMLSemanticError; -exports.YAMLSyntaxError = YAMLSyntaxError; -exports.YAMLWarning = YAMLWarning; -exports._defineProperty = _defineProperty; -exports.defaultTagPrefix = defaultTagPrefix; -exports.defaultTags = defaultTags; diff --git a/action/node_modules/yaml/dist/Schema-88e323a7.js b/action/node_modules/yaml/dist/Schema-88e323a7.js deleted file mode 100644 index 5de109f3f..000000000 --- a/action/node_modules/yaml/dist/Schema-88e323a7.js +++ /dev/null @@ -1,525 +0,0 @@ -'use strict'; - -var PlainValue = require('./PlainValue-ec8e588e.js'); -var resolveSeq = require('./resolveSeq-d03cb037.js'); -var warnings = require('./warnings-1000a372.js'); - -function createMap(schema, obj, ctx) { - const map = new resolveSeq.YAMLMap(schema); - - if (obj instanceof Map) { - for (const [key, value] of obj) map.items.push(schema.createPair(key, value, ctx)); - } else if (obj && typeof obj === 'object') { - for (const key of Object.keys(obj)) map.items.push(schema.createPair(key, obj[key], ctx)); - } - - if (typeof schema.sortMapEntries === 'function') { - map.items.sort(schema.sortMapEntries); - } - - return map; -} - -const map = { - createNode: createMap, - default: true, - nodeClass: resolveSeq.YAMLMap, - tag: 'tag:yaml.org,2002:map', - resolve: resolveSeq.resolveMap -}; - -function createSeq(schema, obj, ctx) { - const seq = new resolveSeq.YAMLSeq(schema); - - if (obj && obj[Symbol.iterator]) { - for (const it of obj) { - const v = schema.createNode(it, ctx.wrapScalars, null, ctx); - seq.items.push(v); - } - } - - return seq; -} - -const seq = { - createNode: createSeq, - default: true, - nodeClass: resolveSeq.YAMLSeq, - tag: 'tag:yaml.org,2002:seq', - resolve: resolveSeq.resolveSeq -}; - -const string = { - identify: value => typeof value === 'string', - default: true, - tag: 'tag:yaml.org,2002:str', - resolve: resolveSeq.resolveString, - - stringify(item, ctx, onComment, onChompKeep) { - ctx = Object.assign({ - actualString: true - }, ctx); - return resolveSeq.stringifyString(item, ctx, onComment, onChompKeep); - }, - - options: resolveSeq.strOptions -}; - -const failsafe = [map, seq, string]; - -/* global BigInt */ - -const intIdentify$2 = value => typeof value === 'bigint' || Number.isInteger(value); - -const intResolve$1 = (src, part, radix) => resolveSeq.intOptions.asBigInt ? BigInt(src) : parseInt(part, radix); - -function intStringify$1(node, radix, prefix) { - const { - value - } = node; - if (intIdentify$2(value) && value >= 0) return prefix + value.toString(radix); - return resolveSeq.stringifyNumber(node); -} - -const nullObj = { - identify: value => value == null, - createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq.Scalar(null) : null, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^(?:~|[Nn]ull|NULL)?$/, - resolve: () => null, - options: resolveSeq.nullOptions, - stringify: () => resolveSeq.nullOptions.nullStr -}; -const boolObj = { - identify: value => typeof value === 'boolean', - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/, - resolve: str => str[0] === 't' || str[0] === 'T', - options: resolveSeq.boolOptions, - stringify: ({ - value - }) => value ? resolveSeq.boolOptions.trueStr : resolveSeq.boolOptions.falseStr -}; -const octObj = { - identify: value => intIdentify$2(value) && value >= 0, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'OCT', - test: /^0o([0-7]+)$/, - resolve: (str, oct) => intResolve$1(str, oct, 8), - options: resolveSeq.intOptions, - stringify: node => intStringify$1(node, 8, '0o') -}; -const intObj = { - identify: intIdentify$2, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^[-+]?[0-9]+$/, - resolve: str => intResolve$1(str, str, 10), - options: resolveSeq.intOptions, - stringify: resolveSeq.stringifyNumber -}; -const hexObj = { - identify: value => intIdentify$2(value) && value >= 0, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'HEX', - test: /^0x([0-9a-fA-F]+)$/, - resolve: (str, hex) => intResolve$1(str, hex, 16), - options: resolveSeq.intOptions, - stringify: node => intStringify$1(node, 16, '0x') -}; -const nanObj = { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^(?:[-+]?\.inf|(\.nan))$/i, - resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, - stringify: resolveSeq.stringifyNumber -}; -const expObj = { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'EXP', - test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/, - resolve: str => parseFloat(str), - stringify: ({ - value - }) => Number(value).toExponential() -}; -const floatObj = { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^[-+]?(?:\.([0-9]+)|[0-9]+\.([0-9]*))$/, - - resolve(str, frac1, frac2) { - const frac = frac1 || frac2; - const node = new resolveSeq.Scalar(parseFloat(str)); - if (frac && frac[frac.length - 1] === '0') node.minFractionDigits = frac.length; - return node; - }, - - stringify: resolveSeq.stringifyNumber -}; -const core = failsafe.concat([nullObj, boolObj, octObj, intObj, hexObj, nanObj, expObj, floatObj]); - -/* global BigInt */ - -const intIdentify$1 = value => typeof value === 'bigint' || Number.isInteger(value); - -const stringifyJSON = ({ - value -}) => JSON.stringify(value); - -const json = [map, seq, { - identify: value => typeof value === 'string', - default: true, - tag: 'tag:yaml.org,2002:str', - resolve: resolveSeq.resolveString, - stringify: stringifyJSON -}, { - identify: value => value == null, - createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq.Scalar(null) : null, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^null$/, - resolve: () => null, - stringify: stringifyJSON -}, { - identify: value => typeof value === 'boolean', - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^true|false$/, - resolve: str => str === 'true', - stringify: stringifyJSON -}, { - identify: intIdentify$1, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^-?(?:0|[1-9][0-9]*)$/, - resolve: str => resolveSeq.intOptions.asBigInt ? BigInt(str) : parseInt(str, 10), - stringify: ({ - value - }) => intIdentify$1(value) ? value.toString() : JSON.stringify(value) -}, { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/, - resolve: str => parseFloat(str), - stringify: stringifyJSON -}]; - -json.scalarFallback = str => { - throw new SyntaxError(`Unresolved plain scalar ${JSON.stringify(str)}`); -}; - -/* global BigInt */ - -const boolStringify = ({ - value -}) => value ? resolveSeq.boolOptions.trueStr : resolveSeq.boolOptions.falseStr; - -const intIdentify = value => typeof value === 'bigint' || Number.isInteger(value); - -function intResolve(sign, src, radix) { - let str = src.replace(/_/g, ''); - - if (resolveSeq.intOptions.asBigInt) { - switch (radix) { - case 2: - str = `0b${str}`; - break; - - case 8: - str = `0o${str}`; - break; - - case 16: - str = `0x${str}`; - break; - } - - const n = BigInt(str); - return sign === '-' ? BigInt(-1) * n : n; - } - - const n = parseInt(str, radix); - return sign === '-' ? -1 * n : n; -} - -function intStringify(node, radix, prefix) { - const { - value - } = node; - - if (intIdentify(value)) { - const str = value.toString(radix); - return value < 0 ? '-' + prefix + str.substr(1) : prefix + str; - } - - return resolveSeq.stringifyNumber(node); -} - -const yaml11 = failsafe.concat([{ - identify: value => value == null, - createNode: (schema, value, ctx) => ctx.wrapScalars ? new resolveSeq.Scalar(null) : null, - default: true, - tag: 'tag:yaml.org,2002:null', - test: /^(?:~|[Nn]ull|NULL)?$/, - resolve: () => null, - options: resolveSeq.nullOptions, - stringify: () => resolveSeq.nullOptions.nullStr -}, { - identify: value => typeof value === 'boolean', - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/, - resolve: () => true, - options: resolveSeq.boolOptions, - stringify: boolStringify -}, { - identify: value => typeof value === 'boolean', - default: true, - tag: 'tag:yaml.org,2002:bool', - test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/i, - resolve: () => false, - options: resolveSeq.boolOptions, - stringify: boolStringify -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'BIN', - test: /^([-+]?)0b([0-1_]+)$/, - resolve: (str, sign, bin) => intResolve(sign, bin, 2), - stringify: node => intStringify(node, 2, '0b') -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'OCT', - test: /^([-+]?)0([0-7_]+)$/, - resolve: (str, sign, oct) => intResolve(sign, oct, 8), - stringify: node => intStringify(node, 8, '0') -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - test: /^([-+]?)([0-9][0-9_]*)$/, - resolve: (str, sign, abs) => intResolve(sign, abs, 10), - stringify: resolveSeq.stringifyNumber -}, { - identify: intIdentify, - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'HEX', - test: /^([-+]?)0x([0-9a-fA-F_]+)$/, - resolve: (str, sign, hex) => intResolve(sign, hex, 16), - stringify: node => intStringify(node, 16, '0x') -}, { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^(?:[-+]?\.inf|(\.nan))$/i, - resolve: (str, nan) => nan ? NaN : str[0] === '-' ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, - stringify: resolveSeq.stringifyNumber -}, { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'EXP', - test: /^[-+]?([0-9][0-9_]*)?(\.[0-9_]*)?[eE][-+]?[0-9]+$/, - resolve: str => parseFloat(str.replace(/_/g, '')), - stringify: ({ - value - }) => Number(value).toExponential() -}, { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - test: /^[-+]?(?:[0-9][0-9_]*)?\.([0-9_]*)$/, - - resolve(str, frac) { - const node = new resolveSeq.Scalar(parseFloat(str.replace(/_/g, ''))); - - if (frac) { - const f = frac.replace(/_/g, ''); - if (f[f.length - 1] === '0') node.minFractionDigits = f.length; - } - - return node; - }, - - stringify: resolveSeq.stringifyNumber -}], warnings.binary, warnings.omap, warnings.pairs, warnings.set, warnings.intTime, warnings.floatTime, warnings.timestamp); - -const schemas = { - core, - failsafe, - json, - yaml11 -}; -const tags = { - binary: warnings.binary, - bool: boolObj, - float: floatObj, - floatExp: expObj, - floatNaN: nanObj, - floatTime: warnings.floatTime, - int: intObj, - intHex: hexObj, - intOct: octObj, - intTime: warnings.intTime, - map, - null: nullObj, - omap: warnings.omap, - pairs: warnings.pairs, - seq, - set: warnings.set, - timestamp: warnings.timestamp -}; - -function findTagObject(value, tagName, tags) { - if (tagName) { - const match = tags.filter(t => t.tag === tagName); - const tagObj = match.find(t => !t.format) || match[0]; - if (!tagObj) throw new Error(`Tag ${tagName} not found`); - return tagObj; - } // TODO: deprecate/remove class check - - - return tags.find(t => (t.identify && t.identify(value) || t.class && value instanceof t.class) && !t.format); -} - -function createNode(value, tagName, ctx) { - if (value instanceof resolveSeq.Node) return value; - const { - defaultPrefix, - onTagObj, - prevObjects, - schema, - wrapScalars - } = ctx; - if (tagName && tagName.startsWith('!!')) tagName = defaultPrefix + tagName.slice(2); - let tagObj = findTagObject(value, tagName, schema.tags); - - if (!tagObj) { - if (typeof value.toJSON === 'function') value = value.toJSON(); - if (!value || typeof value !== 'object') return wrapScalars ? new resolveSeq.Scalar(value) : value; - tagObj = value instanceof Map ? map : value[Symbol.iterator] ? seq : map; - } - - if (onTagObj) { - onTagObj(tagObj); - delete ctx.onTagObj; - } // Detect duplicate references to the same object & use Alias nodes for all - // after first. The `obj` wrapper allows for circular references to resolve. - - - const obj = { - value: undefined, - node: undefined - }; - - if (value && typeof value === 'object' && prevObjects) { - const prev = prevObjects.get(value); - - if (prev) { - const alias = new resolveSeq.Alias(prev); // leaves source dirty; must be cleaned by caller - - ctx.aliasNodes.push(alias); // defined along with prevObjects - - return alias; - } - - obj.value = value; - prevObjects.set(value, obj); - } - - obj.node = tagObj.createNode ? tagObj.createNode(ctx.schema, value, ctx) : wrapScalars ? new resolveSeq.Scalar(value) : value; - if (tagName && obj.node instanceof resolveSeq.Node) obj.node.tag = tagName; - return obj.node; -} - -function getSchemaTags(schemas, knownTags, customTags, schemaId) { - let tags = schemas[schemaId.replace(/\W/g, '')]; // 'yaml-1.1' -> 'yaml11' - - if (!tags) { - const keys = Object.keys(schemas).map(key => JSON.stringify(key)).join(', '); - throw new Error(`Unknown schema "${schemaId}"; use one of ${keys}`); - } - - if (Array.isArray(customTags)) { - for (const tag of customTags) tags = tags.concat(tag); - } else if (typeof customTags === 'function') { - tags = customTags(tags.slice()); - } - - for (let i = 0; i < tags.length; ++i) { - const tag = tags[i]; - - if (typeof tag === 'string') { - const tagObj = knownTags[tag]; - - if (!tagObj) { - const keys = Object.keys(knownTags).map(key => JSON.stringify(key)).join(', '); - throw new Error(`Unknown custom tag "${tag}"; use one of ${keys}`); - } - - tags[i] = tagObj; - } - } - - return tags; -} - -const sortMapEntriesByKey = (a, b) => a.key < b.key ? -1 : a.key > b.key ? 1 : 0; - -class Schema { - // TODO: remove in v2 - // TODO: remove in v2 - constructor({ - customTags, - merge, - schema, - sortMapEntries, - tags: deprecatedCustomTags - }) { - this.merge = !!merge; - this.name = schema; - this.sortMapEntries = sortMapEntries === true ? sortMapEntriesByKey : sortMapEntries || null; - if (!customTags && deprecatedCustomTags) warnings.warnOptionDeprecation('tags', 'customTags'); - this.tags = getSchemaTags(schemas, tags, customTags || deprecatedCustomTags, schema); - } - - createNode(value, wrapScalars, tagName, ctx) { - const baseCtx = { - defaultPrefix: Schema.defaultPrefix, - schema: this, - wrapScalars - }; - const createCtx = ctx ? Object.assign(ctx, baseCtx) : baseCtx; - return createNode(value, tagName, createCtx); - } - - createPair(key, value, ctx) { - if (!ctx) ctx = { - wrapScalars: true - }; - const k = this.createNode(key, ctx.wrapScalars, null, ctx); - const v = this.createNode(value, ctx.wrapScalars, null, ctx); - return new resolveSeq.Pair(k, v); - } - -} - -PlainValue._defineProperty(Schema, "defaultPrefix", PlainValue.defaultTagPrefix); - -PlainValue._defineProperty(Schema, "defaultTags", PlainValue.defaultTags); - -exports.Schema = Schema; diff --git a/action/node_modules/yaml/dist/index.js b/action/node_modules/yaml/dist/index.js deleted file mode 100644 index 6df1c7774..000000000 --- a/action/node_modules/yaml/dist/index.js +++ /dev/null @@ -1,79 +0,0 @@ -'use strict'; - -var parseCst = require('./parse-cst.js'); -var Document$1 = require('./Document-9b4560a1.js'); -var Schema = require('./Schema-88e323a7.js'); -var PlainValue = require('./PlainValue-ec8e588e.js'); -var warnings = require('./warnings-1000a372.js'); -require('./resolveSeq-d03cb037.js'); - -function createNode(value, wrapScalars = true, tag) { - if (tag === undefined && typeof wrapScalars === 'string') { - tag = wrapScalars; - wrapScalars = true; - } - - const options = Object.assign({}, Document$1.Document.defaults[Document$1.defaultOptions.version], Document$1.defaultOptions); - const schema = new Schema.Schema(options); - return schema.createNode(value, wrapScalars, tag); -} - -class Document extends Document$1.Document { - constructor(options) { - super(Object.assign({}, Document$1.defaultOptions, options)); - } - -} - -function parseAllDocuments(src, options) { - const stream = []; - let prev; - - for (const cstDoc of parseCst.parse(src)) { - const doc = new Document(options); - doc.parse(cstDoc, prev); - stream.push(doc); - prev = doc; - } - - return stream; -} - -function parseDocument(src, options) { - const cst = parseCst.parse(src); - const doc = new Document(options).parse(cst[0]); - - if (cst.length > 1) { - const errMsg = 'Source contains multiple documents; please use YAML.parseAllDocuments()'; - doc.errors.unshift(new PlainValue.YAMLSemanticError(cst[1], errMsg)); - } - - return doc; -} - -function parse(src, options) { - const doc = parseDocument(src, options); - doc.warnings.forEach(warning => warnings.warn(warning)); - if (doc.errors.length > 0) throw doc.errors[0]; - return doc.toJSON(); -} - -function stringify(value, options) { - const doc = new Document(options); - doc.contents = value; - return String(doc); -} - -const YAML = { - createNode, - defaultOptions: Document$1.defaultOptions, - Document, - parse, - parseAllDocuments, - parseCST: parseCst.parse, - parseDocument, - scalarOptions: Document$1.scalarOptions, - stringify -}; - -exports.YAML = YAML; diff --git a/action/node_modules/yaml/dist/legacy-exports.js b/action/node_modules/yaml/dist/legacy-exports.js deleted file mode 100644 index 9a5d037b7..000000000 --- a/action/node_modules/yaml/dist/legacy-exports.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var warnings = require('./warnings-1000a372.js'); -require('./PlainValue-ec8e588e.js'); -require('./resolveSeq-d03cb037.js'); - - - -exports.binary = warnings.binary; -exports.floatTime = warnings.floatTime; -exports.intTime = warnings.intTime; -exports.omap = warnings.omap; -exports.pairs = warnings.pairs; -exports.set = warnings.set; -exports.timestamp = warnings.timestamp; -exports.warnFileDeprecation = warnings.warnFileDeprecation; diff --git a/action/node_modules/yaml/dist/parse-cst.js b/action/node_modules/yaml/dist/parse-cst.js deleted file mode 100644 index d69bedc66..000000000 --- a/action/node_modules/yaml/dist/parse-cst.js +++ /dev/null @@ -1,1753 +0,0 @@ -'use strict'; - -var PlainValue = require('./PlainValue-ec8e588e.js'); - -class BlankLine extends PlainValue.Node { - constructor() { - super(PlainValue.Type.BLANK_LINE); - } - /* istanbul ignore next */ - - - get includesTrailingLines() { - // This is never called from anywhere, but if it were, - // this is the value it should return. - return true; - } - /** - * Parses a blank line from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first \n character - * @returns {number} - Index of the character after this - */ - - - parse(context, start) { - this.context = context; - this.range = new PlainValue.Range(start, start + 1); - return start + 1; - } - -} - -class CollectionItem extends PlainValue.Node { - constructor(type, props) { - super(type, props); - this.node = null; - } - - get includesTrailingLines() { - return !!this.node && this.node.includesTrailingLines; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - - parse(context, start) { - this.context = context; - const { - parseNode, - src - } = context; - let { - atLineStart, - lineStart - } = context; - if (!atLineStart && this.type === PlainValue.Type.SEQ_ITEM) this.error = new PlainValue.YAMLSemanticError(this, 'Sequence items must not have preceding content on the same line'); - const indent = atLineStart ? start - lineStart : context.indent; - let offset = PlainValue.Node.endOfWhiteSpace(src, start + 1); - let ch = src[offset]; - const inlineComment = ch === '#'; - const comments = []; - let blankLine = null; - - while (ch === '\n' || ch === '#') { - if (ch === '#') { - const end = PlainValue.Node.endOfLine(src, offset + 1); - comments.push(new PlainValue.Range(offset, end)); - offset = end; - } else { - atLineStart = true; - lineStart = offset + 1; - const wsEnd = PlainValue.Node.endOfWhiteSpace(src, lineStart); - - if (src[wsEnd] === '\n' && comments.length === 0) { - blankLine = new BlankLine(); - lineStart = blankLine.parse({ - src - }, lineStart); - } - - offset = PlainValue.Node.endOfIndent(src, lineStart); - } - - ch = src[offset]; - } - - if (PlainValue.Node.nextNodeIsIndented(ch, offset - (lineStart + indent), this.type !== PlainValue.Type.SEQ_ITEM)) { - this.node = parseNode({ - atLineStart, - inCollection: false, - indent, - lineStart, - parent: this - }, offset); - } else if (ch && lineStart > start + 1) { - offset = lineStart - 1; - } - - if (this.node) { - if (blankLine) { - // Only blank lines preceding non-empty nodes are captured. Note that - // this means that collection item range start indices do not always - // increase monotonically. -- eemeli/yaml#126 - const items = context.parent.items || context.parent.contents; - if (items) items.push(blankLine); - } - - if (comments.length) Array.prototype.push.apply(this.props, comments); - offset = this.node.range.end; - } else { - if (inlineComment) { - const c = comments[0]; - this.props.push(c); - offset = c.end; - } else { - offset = PlainValue.Node.endOfLine(src, start + 1); - } - } - - const end = this.node ? this.node.valueRange.end : offset; - this.valueRange = new PlainValue.Range(start, end); - return offset; - } - - setOrigRanges(cr, offset) { - offset = super.setOrigRanges(cr, offset); - return this.node ? this.node.setOrigRanges(cr, offset) : offset; - } - - toString() { - const { - context: { - src - }, - node, - range, - value - } = this; - if (value != null) return value; - const str = node ? src.slice(range.start, node.range.start) + String(node) : src.slice(range.start, range.end); - return PlainValue.Node.addStringTerminator(src, range.end, str); - } - -} - -class Comment extends PlainValue.Node { - constructor() { - super(PlainValue.Type.COMMENT); - } - /** - * Parses a comment line from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - - parse(context, start) { - this.context = context; - const offset = this.parseComment(start); - this.range = new PlainValue.Range(start, offset); - return offset; - } - -} - -function grabCollectionEndComments(node) { - let cnode = node; - - while (cnode instanceof CollectionItem) cnode = cnode.node; - - if (!(cnode instanceof Collection)) return null; - const len = cnode.items.length; - let ci = -1; - - for (let i = len - 1; i >= 0; --i) { - const n = cnode.items[i]; - - if (n.type === PlainValue.Type.COMMENT) { - // Keep sufficiently indented comments with preceding node - const { - indent, - lineStart - } = n.context; - if (indent > 0 && n.range.start >= lineStart + indent) break; - ci = i; - } else if (n.type === PlainValue.Type.BLANK_LINE) ci = i;else break; - } - - if (ci === -1) return null; - const ca = cnode.items.splice(ci, len - ci); - const prevEnd = ca[0].range.start; - - while (true) { - cnode.range.end = prevEnd; - if (cnode.valueRange && cnode.valueRange.end > prevEnd) cnode.valueRange.end = prevEnd; - if (cnode === node) break; - cnode = cnode.context.parent; - } - - return ca; -} -class Collection extends PlainValue.Node { - static nextContentHasIndent(src, offset, indent) { - const lineStart = PlainValue.Node.endOfLine(src, offset) + 1; - offset = PlainValue.Node.endOfWhiteSpace(src, lineStart); - const ch = src[offset]; - if (!ch) return false; - if (offset >= lineStart + indent) return true; - if (ch !== '#' && ch !== '\n') return false; - return Collection.nextContentHasIndent(src, offset, indent); - } - - constructor(firstItem) { - super(firstItem.type === PlainValue.Type.SEQ_ITEM ? PlainValue.Type.SEQ : PlainValue.Type.MAP); - - for (let i = firstItem.props.length - 1; i >= 0; --i) { - if (firstItem.props[i].start < firstItem.context.lineStart) { - // props on previous line are assumed by the collection - this.props = firstItem.props.slice(0, i + 1); - firstItem.props = firstItem.props.slice(i + 1); - const itemRange = firstItem.props[0] || firstItem.valueRange; - firstItem.range.start = itemRange.start; - break; - } - } - - this.items = [firstItem]; - const ec = grabCollectionEndComments(firstItem); - if (ec) Array.prototype.push.apply(this.items, ec); - } - - get includesTrailingLines() { - return this.items.length > 0; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - - parse(context, start) { - this.context = context; - const { - parseNode, - src - } = context; // It's easier to recalculate lineStart here rather than tracking down the - // last context from which to read it -- eemeli/yaml#2 - - let lineStart = PlainValue.Node.startOfLine(src, start); - const firstItem = this.items[0]; // First-item context needs to be correct for later comment handling - // -- eemeli/yaml#17 - - firstItem.context.parent = this; - this.valueRange = PlainValue.Range.copy(firstItem.valueRange); - const indent = firstItem.range.start - firstItem.context.lineStart; - let offset = start; - offset = PlainValue.Node.normalizeOffset(src, offset); - let ch = src[offset]; - let atLineStart = PlainValue.Node.endOfWhiteSpace(src, lineStart) === offset; - let prevIncludesTrailingLines = false; - - while (ch) { - while (ch === '\n' || ch === '#') { - if (atLineStart && ch === '\n' && !prevIncludesTrailingLines) { - const blankLine = new BlankLine(); - offset = blankLine.parse({ - src - }, offset); - this.valueRange.end = offset; - - if (offset >= src.length) { - ch = null; - break; - } - - this.items.push(blankLine); - offset -= 1; // blankLine.parse() consumes terminal newline - } else if (ch === '#') { - if (offset < lineStart + indent && !Collection.nextContentHasIndent(src, offset, indent)) { - return offset; - } - - const comment = new Comment(); - offset = comment.parse({ - indent, - lineStart, - src - }, offset); - this.items.push(comment); - this.valueRange.end = offset; - - if (offset >= src.length) { - ch = null; - break; - } - } - - lineStart = offset + 1; - offset = PlainValue.Node.endOfIndent(src, lineStart); - - if (PlainValue.Node.atBlank(src, offset)) { - const wsEnd = PlainValue.Node.endOfWhiteSpace(src, offset); - const next = src[wsEnd]; - - if (!next || next === '\n' || next === '#') { - offset = wsEnd; - } - } - - ch = src[offset]; - atLineStart = true; - } - - if (!ch) { - break; - } - - if (offset !== lineStart + indent && (atLineStart || ch !== ':')) { - if (offset < lineStart + indent) { - if (lineStart > start) offset = lineStart; - break; - } else if (!this.error) { - const msg = 'All collection items must start at the same column'; - this.error = new PlainValue.YAMLSyntaxError(this, msg); - } - } - - if (firstItem.type === PlainValue.Type.SEQ_ITEM) { - if (ch !== '-') { - if (lineStart > start) offset = lineStart; - break; - } - } else if (ch === '-' && !this.error) { - // map key may start with -, as long as it's followed by a non-whitespace char - const next = src[offset + 1]; - - if (!next || next === '\n' || next === '\t' || next === ' ') { - const msg = 'A collection cannot be both a mapping and a sequence'; - this.error = new PlainValue.YAMLSyntaxError(this, msg); - } - } - - const node = parseNode({ - atLineStart, - inCollection: true, - indent, - lineStart, - parent: this - }, offset); - if (!node) return offset; // at next document start - - this.items.push(node); - this.valueRange.end = node.valueRange.end; - offset = PlainValue.Node.normalizeOffset(src, node.range.end); - ch = src[offset]; - atLineStart = false; - prevIncludesTrailingLines = node.includesTrailingLines; // Need to reset lineStart and atLineStart here if preceding node's range - // has advanced to check the current line's indentation level - // -- eemeli/yaml#10 & eemeli/yaml#38 - - if (ch) { - let ls = offset - 1; - let prev = src[ls]; - - while (prev === ' ' || prev === '\t') prev = src[--ls]; - - if (prev === '\n') { - lineStart = ls + 1; - atLineStart = true; - } - } - - const ec = grabCollectionEndComments(node); - if (ec) Array.prototype.push.apply(this.items, ec); - } - - return offset; - } - - setOrigRanges(cr, offset) { - offset = super.setOrigRanges(cr, offset); - this.items.forEach(node => { - offset = node.setOrigRanges(cr, offset); - }); - return offset; - } - - toString() { - const { - context: { - src - }, - items, - range, - value - } = this; - if (value != null) return value; - let str = src.slice(range.start, items[0].range.start) + String(items[0]); - - for (let i = 1; i < items.length; ++i) { - const item = items[i]; - const { - atLineStart, - indent - } = item.context; - if (atLineStart) for (let i = 0; i < indent; ++i) str += ' '; - str += String(item); - } - - return PlainValue.Node.addStringTerminator(src, range.end, str); - } - -} - -class Directive extends PlainValue.Node { - constructor() { - super(PlainValue.Type.DIRECTIVE); - this.name = null; - } - - get parameters() { - const raw = this.rawValue; - return raw ? raw.trim().split(/[ \t]+/) : []; - } - - parseName(start) { - const { - src - } = this.context; - let offset = start; - let ch = src[offset]; - - while (ch && ch !== '\n' && ch !== '\t' && ch !== ' ') ch = src[offset += 1]; - - this.name = src.slice(start, offset); - return offset; - } - - parseParameters(start) { - const { - src - } = this.context; - let offset = start; - let ch = src[offset]; - - while (ch && ch !== '\n' && ch !== '#') ch = src[offset += 1]; - - this.valueRange = new PlainValue.Range(start, offset); - return offset; - } - - parse(context, start) { - this.context = context; - let offset = this.parseName(start + 1); - offset = this.parseParameters(offset); - offset = this.parseComment(offset); - this.range = new PlainValue.Range(start, offset); - return offset; - } - -} - -class Document extends PlainValue.Node { - static startCommentOrEndBlankLine(src, start) { - const offset = PlainValue.Node.endOfWhiteSpace(src, start); - const ch = src[offset]; - return ch === '#' || ch === '\n' ? offset : start; - } - - constructor() { - super(PlainValue.Type.DOCUMENT); - this.directives = null; - this.contents = null; - this.directivesEndMarker = null; - this.documentEndMarker = null; - } - - parseDirectives(start) { - const { - src - } = this.context; - this.directives = []; - let atLineStart = true; - let hasDirectives = false; - let offset = start; - - while (!PlainValue.Node.atDocumentBoundary(src, offset, PlainValue.Char.DIRECTIVES_END)) { - offset = Document.startCommentOrEndBlankLine(src, offset); - - switch (src[offset]) { - case '\n': - if (atLineStart) { - const blankLine = new BlankLine(); - offset = blankLine.parse({ - src - }, offset); - - if (offset < src.length) { - this.directives.push(blankLine); - } - } else { - offset += 1; - atLineStart = true; - } - - break; - - case '#': - { - const comment = new Comment(); - offset = comment.parse({ - src - }, offset); - this.directives.push(comment); - atLineStart = false; - } - break; - - case '%': - { - const directive = new Directive(); - offset = directive.parse({ - parent: this, - src - }, offset); - this.directives.push(directive); - hasDirectives = true; - atLineStart = false; - } - break; - - default: - if (hasDirectives) { - this.error = new PlainValue.YAMLSemanticError(this, 'Missing directives-end indicator line'); - } else if (this.directives.length > 0) { - this.contents = this.directives; - this.directives = []; - } - - return offset; - } - } - - if (src[offset]) { - this.directivesEndMarker = new PlainValue.Range(offset, offset + 3); - return offset + 3; - } - - if (hasDirectives) { - this.error = new PlainValue.YAMLSemanticError(this, 'Missing directives-end indicator line'); - } else if (this.directives.length > 0) { - this.contents = this.directives; - this.directives = []; - } - - return offset; - } - - parseContents(start) { - const { - parseNode, - src - } = this.context; - if (!this.contents) this.contents = []; - let lineStart = start; - - while (src[lineStart - 1] === '-') lineStart -= 1; - - let offset = PlainValue.Node.endOfWhiteSpace(src, start); - let atLineStart = lineStart === start; - this.valueRange = new PlainValue.Range(offset); - - while (!PlainValue.Node.atDocumentBoundary(src, offset, PlainValue.Char.DOCUMENT_END)) { - switch (src[offset]) { - case '\n': - if (atLineStart) { - const blankLine = new BlankLine(); - offset = blankLine.parse({ - src - }, offset); - - if (offset < src.length) { - this.contents.push(blankLine); - } - } else { - offset += 1; - atLineStart = true; - } - - lineStart = offset; - break; - - case '#': - { - const comment = new Comment(); - offset = comment.parse({ - src - }, offset); - this.contents.push(comment); - atLineStart = false; - } - break; - - default: - { - const iEnd = PlainValue.Node.endOfIndent(src, offset); - const context = { - atLineStart, - indent: -1, - inFlow: false, - inCollection: false, - lineStart, - parent: this - }; - const node = parseNode(context, iEnd); - if (!node) return this.valueRange.end = iEnd; // at next document start - - this.contents.push(node); - offset = node.range.end; - atLineStart = false; - const ec = grabCollectionEndComments(node); - if (ec) Array.prototype.push.apply(this.contents, ec); - } - } - - offset = Document.startCommentOrEndBlankLine(src, offset); - } - - this.valueRange.end = offset; - - if (src[offset]) { - this.documentEndMarker = new PlainValue.Range(offset, offset + 3); - offset += 3; - - if (src[offset]) { - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - - if (src[offset] === '#') { - const comment = new Comment(); - offset = comment.parse({ - src - }, offset); - this.contents.push(comment); - } - - switch (src[offset]) { - case '\n': - offset += 1; - break; - - case undefined: - break; - - default: - this.error = new PlainValue.YAMLSyntaxError(this, 'Document end marker line cannot have a non-comment suffix'); - } - } - } - - return offset; - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - - parse(context, start) { - context.root = this; - this.context = context; - const { - src - } = context; - let offset = src.charCodeAt(start) === 0xfeff ? start + 1 : start; // skip BOM - - offset = this.parseDirectives(offset); - offset = this.parseContents(offset); - return offset; - } - - setOrigRanges(cr, offset) { - offset = super.setOrigRanges(cr, offset); - this.directives.forEach(node => { - offset = node.setOrigRanges(cr, offset); - }); - if (this.directivesEndMarker) offset = this.directivesEndMarker.setOrigRange(cr, offset); - this.contents.forEach(node => { - offset = node.setOrigRanges(cr, offset); - }); - if (this.documentEndMarker) offset = this.documentEndMarker.setOrigRange(cr, offset); - return offset; - } - - toString() { - const { - contents, - directives, - value - } = this; - if (value != null) return value; - let str = directives.join(''); - - if (contents.length > 0) { - if (directives.length > 0 || contents[0].type === PlainValue.Type.COMMENT) str += '---\n'; - str += contents.join(''); - } - - if (str[str.length - 1] !== '\n') str += '\n'; - return str; - } - -} - -class Alias extends PlainValue.Node { - /** - * Parses an *alias from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - parse(context, start) { - this.context = context; - const { - src - } = context; - let offset = PlainValue.Node.endOfIdentifier(src, start + 1); - this.valueRange = new PlainValue.Range(start + 1, offset); - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - -} - -const Chomp = { - CLIP: 'CLIP', - KEEP: 'KEEP', - STRIP: 'STRIP' -}; -class BlockValue extends PlainValue.Node { - constructor(type, props) { - super(type, props); - this.blockIndent = null; - this.chomping = Chomp.CLIP; - this.header = null; - } - - get includesTrailingLines() { - return this.chomping === Chomp.KEEP; - } - - get strValue() { - if (!this.valueRange || !this.context) return null; - let { - start, - end - } = this.valueRange; - const { - indent, - src - } = this.context; - if (this.valueRange.isEmpty()) return ''; - let lastNewLine = null; - let ch = src[end - 1]; - - while (ch === '\n' || ch === '\t' || ch === ' ') { - end -= 1; - - if (end <= start) { - if (this.chomping === Chomp.KEEP) break;else return ''; // probably never happens - } - - if (ch === '\n') lastNewLine = end; - ch = src[end - 1]; - } - - let keepStart = end + 1; - - if (lastNewLine) { - if (this.chomping === Chomp.KEEP) { - keepStart = lastNewLine; - end = this.valueRange.end; - } else { - end = lastNewLine; - } - } - - const bi = indent + this.blockIndent; - const folded = this.type === PlainValue.Type.BLOCK_FOLDED; - let atStart = true; - let str = ''; - let sep = ''; - let prevMoreIndented = false; - - for (let i = start; i < end; ++i) { - for (let j = 0; j < bi; ++j) { - if (src[i] !== ' ') break; - i += 1; - } - - const ch = src[i]; - - if (ch === '\n') { - if (sep === '\n') str += '\n';else sep = '\n'; - } else { - const lineEnd = PlainValue.Node.endOfLine(src, i); - const line = src.slice(i, lineEnd); - i = lineEnd; - - if (folded && (ch === ' ' || ch === '\t') && i < keepStart) { - if (sep === ' ') sep = '\n';else if (!prevMoreIndented && !atStart && sep === '\n') sep = '\n\n'; - str += sep + line; //+ ((lineEnd < end && src[lineEnd]) || '') - - sep = lineEnd < end && src[lineEnd] || ''; - prevMoreIndented = true; - } else { - str += sep + line; - sep = folded && i < keepStart ? ' ' : '\n'; - prevMoreIndented = false; - } - - if (atStart && line !== '') atStart = false; - } - } - - return this.chomping === Chomp.STRIP ? str : str + '\n'; - } - - parseBlockHeader(start) { - const { - src - } = this.context; - let offset = start + 1; - let bi = ''; - - while (true) { - const ch = src[offset]; - - switch (ch) { - case '-': - this.chomping = Chomp.STRIP; - break; - - case '+': - this.chomping = Chomp.KEEP; - break; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - bi += ch; - break; - - default: - this.blockIndent = Number(bi) || null; - this.header = new PlainValue.Range(start, offset); - return offset; - } - - offset += 1; - } - } - - parseBlockValue(start) { - const { - indent, - src - } = this.context; - const explicit = !!this.blockIndent; - let offset = start; - let valueEnd = start; - let minBlockIndent = 1; - - for (let ch = src[offset]; ch === '\n'; ch = src[offset]) { - offset += 1; - if (PlainValue.Node.atDocumentBoundary(src, offset)) break; - const end = PlainValue.Node.endOfBlockIndent(src, indent, offset); // should not include tab? - - if (end === null) break; - const ch = src[end]; - const lineIndent = end - (offset + indent); - - if (!this.blockIndent) { - // no explicit block indent, none yet detected - if (src[end] !== '\n') { - // first line with non-whitespace content - if (lineIndent < minBlockIndent) { - const msg = 'Block scalars with more-indented leading empty lines must use an explicit indentation indicator'; - this.error = new PlainValue.YAMLSemanticError(this, msg); - } - - this.blockIndent = lineIndent; - } else if (lineIndent > minBlockIndent) { - // empty line with more whitespace - minBlockIndent = lineIndent; - } - } else if (ch && ch !== '\n' && lineIndent < this.blockIndent) { - if (src[end] === '#') break; - - if (!this.error) { - const src = explicit ? 'explicit indentation indicator' : 'first line'; - const msg = `Block scalars must not be less indented than their ${src}`; - this.error = new PlainValue.YAMLSemanticError(this, msg); - } - } - - if (src[end] === '\n') { - offset = end; - } else { - offset = valueEnd = PlainValue.Node.endOfLine(src, end); - } - } - - if (this.chomping !== Chomp.KEEP) { - offset = src[valueEnd] ? valueEnd + 1 : valueEnd; - } - - this.valueRange = new PlainValue.Range(start + 1, offset); - return offset; - } - /** - * Parses a block value from the source - * - * Accepted forms are: - * ``` - * BS - * block - * lines - * - * BS #comment - * block - * lines - * ``` - * where the block style BS matches the regexp `[|>][-+1-9]*` and block lines - * are empty or have an indent level greater than `indent`. - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this block - */ - - - parse(context, start) { - this.context = context; - const { - src - } = context; - let offset = this.parseBlockHeader(start); - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - offset = this.parseBlockValue(offset); - return offset; - } - - setOrigRanges(cr, offset) { - offset = super.setOrigRanges(cr, offset); - return this.header ? this.header.setOrigRange(cr, offset) : offset; - } - -} - -class FlowCollection extends PlainValue.Node { - constructor(type, props) { - super(type, props); - this.items = null; - } - - prevNodeIsJsonLike(idx = this.items.length) { - const node = this.items[idx - 1]; - return !!node && (node.jsonLike || node.type === PlainValue.Type.COMMENT && this.prevNodeIsJsonLike(idx - 1)); - } - /** - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this - */ - - - parse(context, start) { - this.context = context; - const { - parseNode, - src - } = context; - let { - indent, - lineStart - } = context; - let char = src[start]; // { or [ - - this.items = [{ - char, - offset: start - }]; - let offset = PlainValue.Node.endOfWhiteSpace(src, start + 1); - char = src[offset]; - - while (char && char !== ']' && char !== '}') { - switch (char) { - case '\n': - { - lineStart = offset + 1; - const wsEnd = PlainValue.Node.endOfWhiteSpace(src, lineStart); - - if (src[wsEnd] === '\n') { - const blankLine = new BlankLine(); - lineStart = blankLine.parse({ - src - }, lineStart); - this.items.push(blankLine); - } - - offset = PlainValue.Node.endOfIndent(src, lineStart); - - if (offset <= lineStart + indent) { - char = src[offset]; - - if (offset < lineStart + indent || char !== ']' && char !== '}') { - const msg = 'Insufficient indentation in flow collection'; - this.error = new PlainValue.YAMLSemanticError(this, msg); - } - } - } - break; - - case ',': - { - this.items.push({ - char, - offset - }); - offset += 1; - } - break; - - case '#': - { - const comment = new Comment(); - offset = comment.parse({ - src - }, offset); - this.items.push(comment); - } - break; - - case '?': - case ':': - { - const next = src[offset + 1]; - - if (next === '\n' || next === '\t' || next === ' ' || next === ',' || // in-flow : after JSON-like key does not need to be followed by whitespace - char === ':' && this.prevNodeIsJsonLike()) { - this.items.push({ - char, - offset - }); - offset += 1; - break; - } - } - // fallthrough - - default: - { - const node = parseNode({ - atLineStart: false, - inCollection: false, - inFlow: true, - indent: -1, - lineStart, - parent: this - }, offset); - - if (!node) { - // at next document start - this.valueRange = new PlainValue.Range(start, offset); - return offset; - } - - this.items.push(node); - offset = PlainValue.Node.normalizeOffset(src, node.range.end); - } - } - - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - char = src[offset]; - } - - this.valueRange = new PlainValue.Range(start, offset + 1); - - if (char) { - this.items.push({ - char, - offset - }); - offset = PlainValue.Node.endOfWhiteSpace(src, offset + 1); - offset = this.parseComment(offset); - } - - return offset; - } - - setOrigRanges(cr, offset) { - offset = super.setOrigRanges(cr, offset); - this.items.forEach(node => { - if (node instanceof PlainValue.Node) { - offset = node.setOrigRanges(cr, offset); - } else if (cr.length === 0) { - node.origOffset = node.offset; - } else { - let i = offset; - - while (i < cr.length) { - if (cr[i] > node.offset) break;else ++i; - } - - node.origOffset = node.offset + i; - offset = i; - } - }); - return offset; - } - - toString() { - const { - context: { - src - }, - items, - range, - value - } = this; - if (value != null) return value; - const nodes = items.filter(item => item instanceof PlainValue.Node); - let str = ''; - let prevEnd = range.start; - nodes.forEach(node => { - const prefix = src.slice(prevEnd, node.range.start); - prevEnd = node.range.end; - str += prefix + String(node); - - if (str[str.length - 1] === '\n' && src[prevEnd - 1] !== '\n' && src[prevEnd] === '\n') { - // Comment range does not include the terminal newline, but its - // stringified value does. Without this fix, newlines at comment ends - // get duplicated. - prevEnd += 1; - } - }); - str += src.slice(prevEnd, range.end); - return PlainValue.Node.addStringTerminator(src, range.end, str); - } - -} - -class QuoteDouble extends PlainValue.Node { - static endOfQuote(src, offset) { - let ch = src[offset]; - - while (ch && ch !== '"') { - offset += ch === '\\' ? 2 : 1; - ch = src[offset]; - } - - return offset + 1; - } - /** - * @returns {string | { str: string, errors: YAMLSyntaxError[] }} - */ - - - get strValue() { - if (!this.valueRange || !this.context) return null; - const errors = []; - const { - start, - end - } = this.valueRange; - const { - indent, - src - } = this.context; - if (src[end - 1] !== '"') errors.push(new PlainValue.YAMLSyntaxError(this, 'Missing closing "quote')); // Using String#replace is too painful with escaped newlines preceded by - // escaped backslashes; also, this should be faster. - - let str = ''; - - for (let i = start + 1; i < end - 1; ++i) { - const ch = src[i]; - - if (ch === '\n') { - if (PlainValue.Node.atDocumentBoundary(src, i + 1)) errors.push(new PlainValue.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values')); - const { - fold, - offset, - error - } = PlainValue.Node.foldNewline(src, i, indent); - str += fold; - i = offset; - if (error) errors.push(new PlainValue.YAMLSemanticError(this, 'Multi-line double-quoted string needs to be sufficiently indented')); - } else if (ch === '\\') { - i += 1; - - switch (src[i]) { - case '0': - str += '\0'; - break; - // null character - - case 'a': - str += '\x07'; - break; - // bell character - - case 'b': - str += '\b'; - break; - // backspace - - case 'e': - str += '\x1b'; - break; - // escape character - - case 'f': - str += '\f'; - break; - // form feed - - case 'n': - str += '\n'; - break; - // line feed - - case 'r': - str += '\r'; - break; - // carriage return - - case 't': - str += '\t'; - break; - // horizontal tab - - case 'v': - str += '\v'; - break; - // vertical tab - - case 'N': - str += '\u0085'; - break; - // Unicode next line - - case '_': - str += '\u00a0'; - break; - // Unicode non-breaking space - - case 'L': - str += '\u2028'; - break; - // Unicode line separator - - case 'P': - str += '\u2029'; - break; - // Unicode paragraph separator - - case ' ': - str += ' '; - break; - - case '"': - str += '"'; - break; - - case '/': - str += '/'; - break; - - case '\\': - str += '\\'; - break; - - case '\t': - str += '\t'; - break; - - case 'x': - str += this.parseCharCode(i + 1, 2, errors); - i += 2; - break; - - case 'u': - str += this.parseCharCode(i + 1, 4, errors); - i += 4; - break; - - case 'U': - str += this.parseCharCode(i + 1, 8, errors); - i += 8; - break; - - case '\n': - // skip escaped newlines, but still trim the following line - while (src[i + 1] === ' ' || src[i + 1] === '\t') i += 1; - - break; - - default: - errors.push(new PlainValue.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(i - 1, 2)}`)); - str += '\\' + src[i]; - } - } else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - const wsStart = i; - let next = src[i + 1]; - - while (next === ' ' || next === '\t') { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch; - } else { - str += ch; - } - } - - return errors.length > 0 ? { - errors, - str - } : str; - } - - parseCharCode(offset, length, errors) { - const { - src - } = this.context; - const cc = src.substr(offset, length); - const ok = cc.length === length && /^[0-9a-fA-F]+$/.test(cc); - const code = ok ? parseInt(cc, 16) : NaN; - - if (isNaN(code)) { - errors.push(new PlainValue.YAMLSyntaxError(this, `Invalid escape sequence ${src.substr(offset - 2, length + 2)}`)); - return src.substr(offset - 2, length + 2); - } - - return String.fromCodePoint(code); - } - /** - * Parses a "double quoted" value from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - - parse(context, start) { - this.context = context; - const { - src - } = context; - let offset = QuoteDouble.endOfQuote(src, start + 1); - this.valueRange = new PlainValue.Range(start, offset); - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - -} - -class QuoteSingle extends PlainValue.Node { - static endOfQuote(src, offset) { - let ch = src[offset]; - - while (ch) { - if (ch === "'") { - if (src[offset + 1] !== "'") break; - ch = src[offset += 2]; - } else { - ch = src[offset += 1]; - } - } - - return offset + 1; - } - /** - * @returns {string | { str: string, errors: YAMLSyntaxError[] }} - */ - - - get strValue() { - if (!this.valueRange || !this.context) return null; - const errors = []; - const { - start, - end - } = this.valueRange; - const { - indent, - src - } = this.context; - if (src[end - 1] !== "'") errors.push(new PlainValue.YAMLSyntaxError(this, "Missing closing 'quote")); - let str = ''; - - for (let i = start + 1; i < end - 1; ++i) { - const ch = src[i]; - - if (ch === '\n') { - if (PlainValue.Node.atDocumentBoundary(src, i + 1)) errors.push(new PlainValue.YAMLSemanticError(this, 'Document boundary indicators are not allowed within string values')); - const { - fold, - offset, - error - } = PlainValue.Node.foldNewline(src, i, indent); - str += fold; - i = offset; - if (error) errors.push(new PlainValue.YAMLSemanticError(this, 'Multi-line single-quoted string needs to be sufficiently indented')); - } else if (ch === "'") { - str += ch; - i += 1; - if (src[i] !== "'") errors.push(new PlainValue.YAMLSyntaxError(this, 'Unescaped single quote? This should not happen.')); - } else if (ch === ' ' || ch === '\t') { - // trim trailing whitespace - const wsStart = i; - let next = src[i + 1]; - - while (next === ' ' || next === '\t') { - i += 1; - next = src[i + 1]; - } - - if (next !== '\n') str += i > wsStart ? src.slice(wsStart, i + 1) : ch; - } else { - str += ch; - } - } - - return errors.length > 0 ? { - errors, - str - } : str; - } - /** - * Parses a 'single quoted' value from the source - * - * @param {ParseContext} context - * @param {number} start - Index of first character - * @returns {number} - Index of the character after this scalar - */ - - - parse(context, start) { - this.context = context; - const { - src - } = context; - let offset = QuoteSingle.endOfQuote(src, start + 1); - this.valueRange = new PlainValue.Range(start, offset); - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - offset = this.parseComment(offset); - return offset; - } - -} - -function createNewNode(type, props) { - switch (type) { - case PlainValue.Type.ALIAS: - return new Alias(type, props); - - case PlainValue.Type.BLOCK_FOLDED: - case PlainValue.Type.BLOCK_LITERAL: - return new BlockValue(type, props); - - case PlainValue.Type.FLOW_MAP: - case PlainValue.Type.FLOW_SEQ: - return new FlowCollection(type, props); - - case PlainValue.Type.MAP_KEY: - case PlainValue.Type.MAP_VALUE: - case PlainValue.Type.SEQ_ITEM: - return new CollectionItem(type, props); - - case PlainValue.Type.COMMENT: - case PlainValue.Type.PLAIN: - return new PlainValue.PlainValue(type, props); - - case PlainValue.Type.QUOTE_DOUBLE: - return new QuoteDouble(type, props); - - case PlainValue.Type.QUOTE_SINGLE: - return new QuoteSingle(type, props); - - /* istanbul ignore next */ - - default: - return null; - // should never happen - } -} -/** - * @param {boolean} atLineStart - Node starts at beginning of line - * @param {boolean} inFlow - true if currently in a flow context - * @param {boolean} inCollection - true if currently in a collection context - * @param {number} indent - Current level of indentation - * @param {number} lineStart - Start of the current line - * @param {Node} parent - The parent of the node - * @param {string} src - Source of the YAML document - */ - - -class ParseContext { - static parseType(src, offset, inFlow) { - switch (src[offset]) { - case '*': - return PlainValue.Type.ALIAS; - - case '>': - return PlainValue.Type.BLOCK_FOLDED; - - case '|': - return PlainValue.Type.BLOCK_LITERAL; - - case '{': - return PlainValue.Type.FLOW_MAP; - - case '[': - return PlainValue.Type.FLOW_SEQ; - - case '?': - return !inFlow && PlainValue.Node.atBlank(src, offset + 1, true) ? PlainValue.Type.MAP_KEY : PlainValue.Type.PLAIN; - - case ':': - return !inFlow && PlainValue.Node.atBlank(src, offset + 1, true) ? PlainValue.Type.MAP_VALUE : PlainValue.Type.PLAIN; - - case '-': - return !inFlow && PlainValue.Node.atBlank(src, offset + 1, true) ? PlainValue.Type.SEQ_ITEM : PlainValue.Type.PLAIN; - - case '"': - return PlainValue.Type.QUOTE_DOUBLE; - - case "'": - return PlainValue.Type.QUOTE_SINGLE; - - default: - return PlainValue.Type.PLAIN; - } - } - - constructor(orig = {}, { - atLineStart, - inCollection, - inFlow, - indent, - lineStart, - parent - } = {}) { - PlainValue._defineProperty(this, "parseNode", (overlay, start) => { - if (PlainValue.Node.atDocumentBoundary(this.src, start)) return null; - const context = new ParseContext(this, overlay); - const { - props, - type, - valueStart - } = context.parseProps(start); - const node = createNewNode(type, props); - let offset = node.parse(context, valueStart); - node.range = new PlainValue.Range(start, offset); - /* istanbul ignore if */ - - if (offset <= start) { - // This should never happen, but if it does, let's make sure to at least - // step one character forward to avoid a busy loop. - node.error = new Error(`Node#parse consumed no characters`); - node.error.parseEnd = offset; - node.error.source = node; - node.range.end = start + 1; - } - - if (context.nodeStartsCollection(node)) { - if (!node.error && !context.atLineStart && context.parent.type === PlainValue.Type.DOCUMENT) { - node.error = new PlainValue.YAMLSyntaxError(node, 'Block collection must not have preceding content here (e.g. directives-end indicator)'); - } - - const collection = new Collection(node); - offset = collection.parse(new ParseContext(context), offset); - collection.range = new PlainValue.Range(start, offset); - return collection; - } - - return node; - }); - - this.atLineStart = atLineStart != null ? atLineStart : orig.atLineStart || false; - this.inCollection = inCollection != null ? inCollection : orig.inCollection || false; - this.inFlow = inFlow != null ? inFlow : orig.inFlow || false; - this.indent = indent != null ? indent : orig.indent; - this.lineStart = lineStart != null ? lineStart : orig.lineStart; - this.parent = parent != null ? parent : orig.parent || {}; - this.root = orig.root; - this.src = orig.src; - } - - nodeStartsCollection(node) { - const { - inCollection, - inFlow, - src - } = this; - if (inCollection || inFlow) return false; - if (node instanceof CollectionItem) return true; // check for implicit key - - let offset = node.range.end; - if (src[offset] === '\n' || src[offset - 1] === '\n') return false; - offset = PlainValue.Node.endOfWhiteSpace(src, offset); - return src[offset] === ':'; - } // Anchor and tag are before type, which determines the node implementation - // class; hence this intermediate step. - - - parseProps(offset) { - const { - inFlow, - parent, - src - } = this; - const props = []; - let lineHasProps = false; - offset = this.atLineStart ? PlainValue.Node.endOfIndent(src, offset) : PlainValue.Node.endOfWhiteSpace(src, offset); - let ch = src[offset]; - - while (ch === PlainValue.Char.ANCHOR || ch === PlainValue.Char.COMMENT || ch === PlainValue.Char.TAG || ch === '\n') { - if (ch === '\n') { - let inEnd = offset; - let lineStart; - - do { - lineStart = inEnd + 1; - inEnd = PlainValue.Node.endOfIndent(src, lineStart); - } while (src[inEnd] === '\n'); - - const indentDiff = inEnd - (lineStart + this.indent); - const noIndicatorAsIndent = parent.type === PlainValue.Type.SEQ_ITEM && parent.context.atLineStart; - if (src[inEnd] !== '#' && !PlainValue.Node.nextNodeIsIndented(src[inEnd], indentDiff, !noIndicatorAsIndent)) break; - this.atLineStart = true; - this.lineStart = lineStart; - lineHasProps = false; - offset = inEnd; - } else if (ch === PlainValue.Char.COMMENT) { - const end = PlainValue.Node.endOfLine(src, offset + 1); - props.push(new PlainValue.Range(offset, end)); - offset = end; - } else { - let end = PlainValue.Node.endOfIdentifier(src, offset + 1); - - if (ch === PlainValue.Char.TAG && src[end] === ',' && /^[a-zA-Z0-9-]+\.[a-zA-Z0-9-]+,\d\d\d\d(-\d\d){0,2}\/\S/.test(src.slice(offset + 1, end + 13))) { - // Let's presume we're dealing with a YAML 1.0 domain tag here, rather - // than an empty but 'foo.bar' private-tagged node in a flow collection - // followed without whitespace by a plain string starting with a year - // or date divided by something. - end = PlainValue.Node.endOfIdentifier(src, end + 5); - } - - props.push(new PlainValue.Range(offset, end)); - lineHasProps = true; - offset = PlainValue.Node.endOfWhiteSpace(src, end); - } - - ch = src[offset]; - } // '- &a : b' has an anchor on an empty node - - - if (lineHasProps && ch === ':' && PlainValue.Node.atBlank(src, offset + 1, true)) offset -= 1; - const type = ParseContext.parseType(src, offset, inFlow); - return { - props, - type, - valueStart: offset - }; - } - /** - * Parses a node from the source - * @param {ParseContext} overlay - * @param {number} start - Index of first non-whitespace character for the node - * @returns {?Node} - null if at a document boundary - */ - - -} - -// Published as 'yaml/parse-cst' -function parse(src) { - const cr = []; - - if (src.indexOf('\r') !== -1) { - src = src.replace(/\r\n?/g, (match, offset) => { - if (match.length > 1) cr.push(offset); - return '\n'; - }); - } - - const documents = []; - let offset = 0; - - do { - const doc = new Document(); - const context = new ParseContext({ - src - }); - offset = doc.parse(context, offset); - documents.push(doc); - } while (offset < src.length); - - documents.setOrigRanges = () => { - if (cr.length === 0) return false; - - for (let i = 1; i < cr.length; ++i) cr[i] -= i; - - let crOffset = 0; - - for (let i = 0; i < documents.length; ++i) { - crOffset = documents[i].setOrigRanges(cr, crOffset); - } - - cr.splice(0, cr.length); - return true; - }; - - documents.toString = () => documents.join('...\n'); - - return documents; -} - -exports.parse = parse; diff --git a/action/node_modules/yaml/dist/resolveSeq-d03cb037.js b/action/node_modules/yaml/dist/resolveSeq-d03cb037.js deleted file mode 100644 index d7c7c8c3c..000000000 --- a/action/node_modules/yaml/dist/resolveSeq-d03cb037.js +++ /dev/null @@ -1,2161 +0,0 @@ -'use strict'; - -var PlainValue = require('./PlainValue-ec8e588e.js'); - -function addCommentBefore(str, indent, comment) { - if (!comment) return str; - const cc = comment.replace(/[\s\S]^/gm, `$&${indent}#`); - return `#${cc}\n${indent}${str}`; -} -function addComment(str, indent, comment) { - return !comment ? str : comment.indexOf('\n') === -1 ? `${str} #${comment}` : `${str}\n` + comment.replace(/^/gm, `${indent || ''}#`); -} - -class Node {} - -function toJSON(value, arg, ctx) { - if (Array.isArray(value)) return value.map((v, i) => toJSON(v, String(i), ctx)); - - if (value && typeof value.toJSON === 'function') { - const anchor = ctx && ctx.anchors && ctx.anchors.get(value); - if (anchor) ctx.onCreate = res => { - anchor.res = res; - delete ctx.onCreate; - }; - const res = value.toJSON(arg, ctx); - if (anchor && ctx.onCreate) ctx.onCreate(res); - return res; - } - - if ((!ctx || !ctx.keep) && typeof value === 'bigint') return Number(value); - return value; -} - -class Scalar extends Node { - constructor(value) { - super(); - this.value = value; - } - - toJSON(arg, ctx) { - return ctx && ctx.keep ? this.value : toJSON(this.value, arg, ctx); - } - - toString() { - return String(this.value); - } - -} - -function collectionFromPath(schema, path, value) { - let v = value; - - for (let i = path.length - 1; i >= 0; --i) { - const k = path[i]; - - if (Number.isInteger(k) && k >= 0) { - const a = []; - a[k] = v; - v = a; - } else { - const o = {}; - Object.defineProperty(o, k, { - value: v, - writable: true, - enumerable: true, - configurable: true - }); - v = o; - } - } - - return schema.createNode(v, false); -} // null, undefined, or an empty non-string iterable (e.g. []) - - -const isEmptyPath = path => path == null || typeof path === 'object' && path[Symbol.iterator]().next().done; -class Collection extends Node { - constructor(schema) { - super(); - - PlainValue._defineProperty(this, "items", []); - - this.schema = schema; - } - - addIn(path, value) { - if (isEmptyPath(path)) this.add(value);else { - const [key, ...rest] = path; - const node = this.get(key, true); - if (node instanceof Collection) node.addIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); - } - } - - deleteIn([key, ...rest]) { - if (rest.length === 0) return this.delete(key); - const node = this.get(key, true); - if (node instanceof Collection) return node.deleteIn(rest);else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); - } - - getIn([key, ...rest], keepScalar) { - const node = this.get(key, true); - if (rest.length === 0) return !keepScalar && node instanceof Scalar ? node.value : node;else return node instanceof Collection ? node.getIn(rest, keepScalar) : undefined; - } - - hasAllNullValues() { - return this.items.every(node => { - if (!node || node.type !== 'PAIR') return false; - const n = node.value; - return n == null || n instanceof Scalar && n.value == null && !n.commentBefore && !n.comment && !n.tag; - }); - } - - hasIn([key, ...rest]) { - if (rest.length === 0) return this.has(key); - const node = this.get(key, true); - return node instanceof Collection ? node.hasIn(rest) : false; - } - - setIn([key, ...rest], value) { - if (rest.length === 0) { - this.set(key, value); - } else { - const node = this.get(key, true); - if (node instanceof Collection) node.setIn(rest, value);else if (node === undefined && this.schema) this.set(key, collectionFromPath(this.schema, rest, value));else throw new Error(`Expected YAML collection at ${key}. Remaining path: ${rest}`); - } - } // overridden in implementations - - /* istanbul ignore next */ - - - toJSON() { - return null; - } - - toString(ctx, { - blockItem, - flowChars, - isMap, - itemIndent - }, onComment, onChompKeep) { - const { - indent, - indentStep, - stringify - } = ctx; - const inFlow = this.type === PlainValue.Type.FLOW_MAP || this.type === PlainValue.Type.FLOW_SEQ || ctx.inFlow; - if (inFlow) itemIndent += indentStep; - const allNullValues = isMap && this.hasAllNullValues(); - ctx = Object.assign({}, ctx, { - allNullValues, - indent: itemIndent, - inFlow, - type: null - }); - let chompKeep = false; - let hasItemWithNewLine = false; - const nodes = this.items.reduce((nodes, item, i) => { - let comment; - - if (item) { - if (!chompKeep && item.spaceBefore) nodes.push({ - type: 'comment', - str: '' - }); - if (item.commentBefore) item.commentBefore.match(/^.*$/gm).forEach(line => { - nodes.push({ - type: 'comment', - str: `#${line}` - }); - }); - if (item.comment) comment = item.comment; - if (inFlow && (!chompKeep && item.spaceBefore || item.commentBefore || item.comment || item.key && (item.key.commentBefore || item.key.comment) || item.value && (item.value.commentBefore || item.value.comment))) hasItemWithNewLine = true; - } - - chompKeep = false; - let str = stringify(item, ctx, () => comment = null, () => chompKeep = true); - if (inFlow && !hasItemWithNewLine && str.includes('\n')) hasItemWithNewLine = true; - if (inFlow && i < this.items.length - 1) str += ','; - str = addComment(str, itemIndent, comment); - if (chompKeep && (comment || inFlow)) chompKeep = false; - nodes.push({ - type: 'item', - str - }); - return nodes; - }, []); - let str; - - if (nodes.length === 0) { - str = flowChars.start + flowChars.end; - } else if (inFlow) { - const { - start, - end - } = flowChars; - const strings = nodes.map(n => n.str); - - if (hasItemWithNewLine || strings.reduce((sum, str) => sum + str.length + 2, 2) > Collection.maxFlowStringSingleLineLength) { - str = start; - - for (const s of strings) { - str += s ? `\n${indentStep}${indent}${s}` : '\n'; - } - - str += `\n${indent}${end}`; - } else { - str = `${start} ${strings.join(' ')} ${end}`; - } - } else { - const strings = nodes.map(blockItem); - str = strings.shift(); - - for (const s of strings) str += s ? `\n${indent}${s}` : '\n'; - } - - if (this.comment) { - str += '\n' + this.comment.replace(/^/gm, `${indent}#`); - if (onComment) onComment(); - } else if (chompKeep && onChompKeep) onChompKeep(); - - return str; - } - -} - -PlainValue._defineProperty(Collection, "maxFlowStringSingleLineLength", 60); - -function asItemIndex(key) { - let idx = key instanceof Scalar ? key.value : key; - if (idx && typeof idx === 'string') idx = Number(idx); - return Number.isInteger(idx) && idx >= 0 ? idx : null; -} - -class YAMLSeq extends Collection { - add(value) { - this.items.push(value); - } - - delete(key) { - const idx = asItemIndex(key); - if (typeof idx !== 'number') return false; - const del = this.items.splice(idx, 1); - return del.length > 0; - } - - get(key, keepScalar) { - const idx = asItemIndex(key); - if (typeof idx !== 'number') return undefined; - const it = this.items[idx]; - return !keepScalar && it instanceof Scalar ? it.value : it; - } - - has(key) { - const idx = asItemIndex(key); - return typeof idx === 'number' && idx < this.items.length; - } - - set(key, value) { - const idx = asItemIndex(key); - if (typeof idx !== 'number') throw new Error(`Expected a valid index, not ${key}.`); - this.items[idx] = value; - } - - toJSON(_, ctx) { - const seq = []; - if (ctx && ctx.onCreate) ctx.onCreate(seq); - let i = 0; - - for (const item of this.items) seq.push(toJSON(item, String(i++), ctx)); - - return seq; - } - - toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - return super.toString(ctx, { - blockItem: n => n.type === 'comment' ? n.str : `- ${n.str}`, - flowChars: { - start: '[', - end: ']' - }, - isMap: false, - itemIndent: (ctx.indent || '') + ' ' - }, onComment, onChompKeep); - } - -} - -const stringifyKey = (key, jsKey, ctx) => { - if (jsKey === null) return ''; - if (typeof jsKey !== 'object') return String(jsKey); - if (key instanceof Node && ctx && ctx.doc) return key.toString({ - anchors: Object.create(null), - doc: ctx.doc, - indent: '', - indentStep: ctx.indentStep, - inFlow: true, - inStringifyKey: true, - stringify: ctx.stringify - }); - return JSON.stringify(jsKey); -}; - -class Pair extends Node { - constructor(key, value = null) { - super(); - this.key = key; - this.value = value; - this.type = Pair.Type.PAIR; - } - - get commentBefore() { - return this.key instanceof Node ? this.key.commentBefore : undefined; - } - - set commentBefore(cb) { - if (this.key == null) this.key = new Scalar(null); - if (this.key instanceof Node) this.key.commentBefore = cb;else { - const msg = 'Pair.commentBefore is an alias for Pair.key.commentBefore. To set it, the key must be a Node.'; - throw new Error(msg); - } - } - - addToJSMap(ctx, map) { - const key = toJSON(this.key, '', ctx); - - if (map instanceof Map) { - const value = toJSON(this.value, key, ctx); - map.set(key, value); - } else if (map instanceof Set) { - map.add(key); - } else { - const stringKey = stringifyKey(this.key, key, ctx); - const value = toJSON(this.value, stringKey, ctx); - if (stringKey in map) Object.defineProperty(map, stringKey, { - value, - writable: true, - enumerable: true, - configurable: true - });else map[stringKey] = value; - } - - return map; - } - - toJSON(_, ctx) { - const pair = ctx && ctx.mapAsMap ? new Map() : {}; - return this.addToJSMap(ctx, pair); - } - - toString(ctx, onComment, onChompKeep) { - if (!ctx || !ctx.doc) return JSON.stringify(this); - const { - indent: indentSize, - indentSeq, - simpleKeys - } = ctx.doc.options; - let { - key, - value - } = this; - let keyComment = key instanceof Node && key.comment; - - if (simpleKeys) { - if (keyComment) { - throw new Error('With simple keys, key nodes cannot have comments'); - } - - if (key instanceof Collection) { - const msg = 'With simple keys, collection cannot be used as a key value'; - throw new Error(msg); - } - } - - let explicitKey = !simpleKeys && (!key || keyComment || (key instanceof Node ? key instanceof Collection || key.type === PlainValue.Type.BLOCK_FOLDED || key.type === PlainValue.Type.BLOCK_LITERAL : typeof key === 'object')); - const { - doc, - indent, - indentStep, - stringify - } = ctx; - ctx = Object.assign({}, ctx, { - implicitKey: !explicitKey, - indent: indent + indentStep - }); - let chompKeep = false; - let str = stringify(key, ctx, () => keyComment = null, () => chompKeep = true); - str = addComment(str, ctx.indent, keyComment); - - if (!explicitKey && str.length > 1024) { - if (simpleKeys) throw new Error('With simple keys, single line scalar must not span more than 1024 characters'); - explicitKey = true; - } - - if (ctx.allNullValues && !simpleKeys) { - if (this.comment) { - str = addComment(str, ctx.indent, this.comment); - if (onComment) onComment(); - } else if (chompKeep && !keyComment && onChompKeep) onChompKeep(); - - return ctx.inFlow && !explicitKey ? str : `? ${str}`; - } - - str = explicitKey ? `? ${str}\n${indent}:` : `${str}:`; - - if (this.comment) { - // expected (but not strictly required) to be a single-line comment - str = addComment(str, ctx.indent, this.comment); - if (onComment) onComment(); - } - - let vcb = ''; - let valueComment = null; - - if (value instanceof Node) { - if (value.spaceBefore) vcb = '\n'; - - if (value.commentBefore) { - const cs = value.commentBefore.replace(/^/gm, `${ctx.indent}#`); - vcb += `\n${cs}`; - } - - valueComment = value.comment; - } else if (value && typeof value === 'object') { - value = doc.schema.createNode(value, true); - } - - ctx.implicitKey = false; - if (!explicitKey && !this.comment && value instanceof Scalar) ctx.indentAtStart = str.length + 1; - chompKeep = false; - - if (!indentSeq && indentSize >= 2 && !ctx.inFlow && !explicitKey && value instanceof YAMLSeq && value.type !== PlainValue.Type.FLOW_SEQ && !value.tag && !doc.anchors.getName(value)) { - // If indentSeq === false, consider '- ' as part of indentation where possible - ctx.indent = ctx.indent.substr(2); - } - - const valueStr = stringify(value, ctx, () => valueComment = null, () => chompKeep = true); - let ws = ' '; - - if (vcb || this.comment) { - ws = `${vcb}\n${ctx.indent}`; - } else if (!explicitKey && value instanceof Collection) { - const flow = valueStr[0] === '[' || valueStr[0] === '{'; - if (!flow || valueStr.includes('\n')) ws = `\n${ctx.indent}`; - } else if (valueStr[0] === '\n') ws = ''; - - if (chompKeep && !valueComment && onChompKeep) onChompKeep(); - return addComment(str + ws + valueStr, ctx.indent, valueComment); - } - -} - -PlainValue._defineProperty(Pair, "Type", { - PAIR: 'PAIR', - MERGE_PAIR: 'MERGE_PAIR' -}); - -const getAliasCount = (node, anchors) => { - if (node instanceof Alias) { - const anchor = anchors.get(node.source); - return anchor.count * anchor.aliasCount; - } else if (node instanceof Collection) { - let count = 0; - - for (const item of node.items) { - const c = getAliasCount(item, anchors); - if (c > count) count = c; - } - - return count; - } else if (node instanceof Pair) { - const kc = getAliasCount(node.key, anchors); - const vc = getAliasCount(node.value, anchors); - return Math.max(kc, vc); - } - - return 1; -}; - -class Alias extends Node { - static stringify({ - range, - source - }, { - anchors, - doc, - implicitKey, - inStringifyKey - }) { - let anchor = Object.keys(anchors).find(a => anchors[a] === source); - if (!anchor && inStringifyKey) anchor = doc.anchors.getName(source) || doc.anchors.newName(); - if (anchor) return `*${anchor}${implicitKey ? ' ' : ''}`; - const msg = doc.anchors.getName(source) ? 'Alias node must be after source node' : 'Source node not found for alias node'; - throw new Error(`${msg} [${range}]`); - } - - constructor(source) { - super(); - this.source = source; - this.type = PlainValue.Type.ALIAS; - } - - set tag(t) { - throw new Error('Alias nodes cannot have tags'); - } - - toJSON(arg, ctx) { - if (!ctx) return toJSON(this.source, arg, ctx); - const { - anchors, - maxAliasCount - } = ctx; - const anchor = anchors.get(this.source); - /* istanbul ignore if */ - - if (!anchor || anchor.res === undefined) { - const msg = 'This should not happen: Alias anchor was not resolved?'; - if (this.cstNode) throw new PlainValue.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg); - } - - if (maxAliasCount >= 0) { - anchor.count += 1; - if (anchor.aliasCount === 0) anchor.aliasCount = getAliasCount(this.source, anchors); - - if (anchor.count * anchor.aliasCount > maxAliasCount) { - const msg = 'Excessive alias count indicates a resource exhaustion attack'; - if (this.cstNode) throw new PlainValue.YAMLReferenceError(this.cstNode, msg);else throw new ReferenceError(msg); - } - } - - return anchor.res; - } // Only called when stringifying an alias mapping key while constructing - // Object output. - - - toString(ctx) { - return Alias.stringify(this, ctx); - } - -} - -PlainValue._defineProperty(Alias, "default", true); - -function findPair(items, key) { - const k = key instanceof Scalar ? key.value : key; - - for (const it of items) { - if (it instanceof Pair) { - if (it.key === key || it.key === k) return it; - if (it.key && it.key.value === k) return it; - } - } - - return undefined; -} -class YAMLMap extends Collection { - add(pair, overwrite) { - if (!pair) pair = new Pair(pair);else if (!(pair instanceof Pair)) pair = new Pair(pair.key || pair, pair.value); - const prev = findPair(this.items, pair.key); - const sortEntries = this.schema && this.schema.sortMapEntries; - - if (prev) { - if (overwrite) prev.value = pair.value;else throw new Error(`Key ${pair.key} already set`); - } else if (sortEntries) { - const i = this.items.findIndex(item => sortEntries(pair, item) < 0); - if (i === -1) this.items.push(pair);else this.items.splice(i, 0, pair); - } else { - this.items.push(pair); - } - } - - delete(key) { - const it = findPair(this.items, key); - if (!it) return false; - const del = this.items.splice(this.items.indexOf(it), 1); - return del.length > 0; - } - - get(key, keepScalar) { - const it = findPair(this.items, key); - const node = it && it.value; - return !keepScalar && node instanceof Scalar ? node.value : node; - } - - has(key) { - return !!findPair(this.items, key); - } - - set(key, value) { - this.add(new Pair(key, value), true); - } - /** - * @param {*} arg ignored - * @param {*} ctx Conversion context, originally set in Document#toJSON() - * @param {Class} Type If set, forces the returned collection type - * @returns {*} Instance of Type, Map, or Object - */ - - - toJSON(_, ctx, Type) { - const map = Type ? new Type() : ctx && ctx.mapAsMap ? new Map() : {}; - if (ctx && ctx.onCreate) ctx.onCreate(map); - - for (const item of this.items) item.addToJSMap(ctx, map); - - return map; - } - - toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - - for (const item of this.items) { - if (!(item instanceof Pair)) throw new Error(`Map items must all be pairs; found ${JSON.stringify(item)} instead`); - } - - return super.toString(ctx, { - blockItem: n => n.str, - flowChars: { - start: '{', - end: '}' - }, - isMap: true, - itemIndent: ctx.indent || '' - }, onComment, onChompKeep); - } - -} - -const MERGE_KEY = '<<'; -class Merge extends Pair { - constructor(pair) { - if (pair instanceof Pair) { - let seq = pair.value; - - if (!(seq instanceof YAMLSeq)) { - seq = new YAMLSeq(); - seq.items.push(pair.value); - seq.range = pair.value.range; - } - - super(pair.key, seq); - this.range = pair.range; - } else { - super(new Scalar(MERGE_KEY), new YAMLSeq()); - } - - this.type = Pair.Type.MERGE_PAIR; - } // If the value associated with a merge key is a single mapping node, each of - // its key/value pairs is inserted into the current mapping, unless the key - // already exists in it. If the value associated with the merge key is a - // sequence, then this sequence is expected to contain mapping nodes and each - // of these nodes is merged in turn according to its order in the sequence. - // Keys in mapping nodes earlier in the sequence override keys specified in - // later mapping nodes. -- http://yaml.org/type/merge.html - - - addToJSMap(ctx, map) { - for (const { - source - } of this.value.items) { - if (!(source instanceof YAMLMap)) throw new Error('Merge sources must be maps'); - const srcMap = source.toJSON(null, ctx, Map); - - for (const [key, value] of srcMap) { - if (map instanceof Map) { - if (!map.has(key)) map.set(key, value); - } else if (map instanceof Set) { - map.add(key); - } else if (!Object.prototype.hasOwnProperty.call(map, key)) { - Object.defineProperty(map, key, { - value, - writable: true, - enumerable: true, - configurable: true - }); - } - } - } - - return map; - } - - toString(ctx, onComment) { - const seq = this.value; - if (seq.items.length > 1) return super.toString(ctx, onComment); - this.value = seq.items[0]; - const str = super.toString(ctx, onComment); - this.value = seq; - return str; - } - -} - -const binaryOptions = { - defaultType: PlainValue.Type.BLOCK_LITERAL, - lineWidth: 76 -}; -const boolOptions = { - trueStr: 'true', - falseStr: 'false' -}; -const intOptions = { - asBigInt: false -}; -const nullOptions = { - nullStr: 'null' -}; -const strOptions = { - defaultType: PlainValue.Type.PLAIN, - doubleQuoted: { - jsonEncoding: false, - minMultiLineLength: 40 - }, - fold: { - lineWidth: 80, - minContentWidth: 20 - } -}; - -function resolveScalar(str, tags, scalarFallback) { - for (const { - format, - test, - resolve - } of tags) { - if (test) { - const match = str.match(test); - - if (match) { - let res = resolve.apply(null, match); - if (!(res instanceof Scalar)) res = new Scalar(res); - if (format) res.format = format; - return res; - } - } - } - - if (scalarFallback) str = scalarFallback(str); - return new Scalar(str); -} - -const FOLD_FLOW = 'flow'; -const FOLD_BLOCK = 'block'; -const FOLD_QUOTED = 'quoted'; // presumes i+1 is at the start of a line -// returns index of last newline in more-indented block - -const consumeMoreIndentedLines = (text, i) => { - let ch = text[i + 1]; - - while (ch === ' ' || ch === '\t') { - do { - ch = text[i += 1]; - } while (ch && ch !== '\n'); - - ch = text[i + 1]; - } - - return i; -}; -/** - * Tries to keep input at up to `lineWidth` characters, splitting only on spaces - * not followed by newlines or spaces unless `mode` is `'quoted'`. Lines are - * terminated with `\n` and started with `indent`. - * - * @param {string} text - * @param {string} indent - * @param {string} [mode='flow'] `'block'` prevents more-indented lines - * from being folded; `'quoted'` allows for `\` escapes, including escaped - * newlines - * @param {Object} options - * @param {number} [options.indentAtStart] Accounts for leading contents on - * the first line, defaulting to `indent.length` - * @param {number} [options.lineWidth=80] - * @param {number} [options.minContentWidth=20] Allow highly indented lines to - * stretch the line width or indent content from the start - * @param {function} options.onFold Called once if the text is folded - * @param {function} options.onFold Called once if any line of text exceeds - * lineWidth characters - */ - - -function foldFlowLines(text, indent, mode, { - indentAtStart, - lineWidth = 80, - minContentWidth = 20, - onFold, - onOverflow -}) { - if (!lineWidth || lineWidth < 0) return text; - const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length); - if (text.length <= endStep) return text; - const folds = []; - const escapedFolds = {}; - let end = lineWidth - indent.length; - - if (typeof indentAtStart === 'number') { - if (indentAtStart > lineWidth - Math.max(2, minContentWidth)) folds.push(0);else end = lineWidth - indentAtStart; - } - - let split = undefined; - let prev = undefined; - let overflow = false; - let i = -1; - let escStart = -1; - let escEnd = -1; - - if (mode === FOLD_BLOCK) { - i = consumeMoreIndentedLines(text, i); - if (i !== -1) end = i + endStep; - } - - for (let ch; ch = text[i += 1];) { - if (mode === FOLD_QUOTED && ch === '\\') { - escStart = i; - - switch (text[i + 1]) { - case 'x': - i += 3; - break; - - case 'u': - i += 5; - break; - - case 'U': - i += 9; - break; - - default: - i += 1; - } - - escEnd = i; - } - - if (ch === '\n') { - if (mode === FOLD_BLOCK) i = consumeMoreIndentedLines(text, i); - end = i + endStep; - split = undefined; - } else { - if (ch === ' ' && prev && prev !== ' ' && prev !== '\n' && prev !== '\t') { - // space surrounded by non-space can be replaced with newline + indent - const next = text[i + 1]; - if (next && next !== ' ' && next !== '\n' && next !== '\t') split = i; - } - - if (i >= end) { - if (split) { - folds.push(split); - end = split + endStep; - split = undefined; - } else if (mode === FOLD_QUOTED) { - // white-space collected at end may stretch past lineWidth - while (prev === ' ' || prev === '\t') { - prev = ch; - ch = text[i += 1]; - overflow = true; - } // Account for newline escape, but don't break preceding escape - - - const j = i > escEnd + 1 ? i - 2 : escStart - 1; // Bail out if lineWidth & minContentWidth are shorter than an escape string - - if (escapedFolds[j]) return text; - folds.push(j); - escapedFolds[j] = true; - end = j + endStep; - split = undefined; - } else { - overflow = true; - } - } - } - - prev = ch; - } - - if (overflow && onOverflow) onOverflow(); - if (folds.length === 0) return text; - if (onFold) onFold(); - let res = text.slice(0, folds[0]); - - for (let i = 0; i < folds.length; ++i) { - const fold = folds[i]; - const end = folds[i + 1] || text.length; - if (fold === 0) res = `\n${indent}${text.slice(0, end)}`;else { - if (mode === FOLD_QUOTED && escapedFolds[fold]) res += `${text[fold]}\\`; - res += `\n${indent}${text.slice(fold + 1, end)}`; - } - } - - return res; -} - -const getFoldOptions = ({ - indentAtStart -}) => indentAtStart ? Object.assign({ - indentAtStart -}, strOptions.fold) : strOptions.fold; // Also checks for lines starting with %, as parsing the output as YAML 1.1 will -// presume that's starting a new document. - - -const containsDocumentMarker = str => /^(%|---|\.\.\.)/m.test(str); - -function lineLengthOverLimit(str, lineWidth, indentLength) { - if (!lineWidth || lineWidth < 0) return false; - const limit = lineWidth - indentLength; - const strLen = str.length; - if (strLen <= limit) return false; - - for (let i = 0, start = 0; i < strLen; ++i) { - if (str[i] === '\n') { - if (i - start > limit) return true; - start = i + 1; - if (strLen - start <= limit) return false; - } - } - - return true; -} - -function doubleQuotedString(value, ctx) { - const { - implicitKey - } = ctx; - const { - jsonEncoding, - minMultiLineLength - } = strOptions.doubleQuoted; - const json = JSON.stringify(value); - if (jsonEncoding) return json; - const indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : ''); - let str = ''; - let start = 0; - - for (let i = 0, ch = json[i]; ch; ch = json[++i]) { - if (ch === ' ' && json[i + 1] === '\\' && json[i + 2] === 'n') { - // space before newline needs to be escaped to not be folded - str += json.slice(start, i) + '\\ '; - i += 1; - start = i; - ch = '\\'; - } - - if (ch === '\\') switch (json[i + 1]) { - case 'u': - { - str += json.slice(start, i); - const code = json.substr(i + 2, 4); - - switch (code) { - case '0000': - str += '\\0'; - break; - - case '0007': - str += '\\a'; - break; - - case '000b': - str += '\\v'; - break; - - case '001b': - str += '\\e'; - break; - - case '0085': - str += '\\N'; - break; - - case '00a0': - str += '\\_'; - break; - - case '2028': - str += '\\L'; - break; - - case '2029': - str += '\\P'; - break; - - default: - if (code.substr(0, 2) === '00') str += '\\x' + code.substr(2);else str += json.substr(i, 6); - } - - i += 5; - start = i + 1; - } - break; - - case 'n': - if (implicitKey || json[i + 2] === '"' || json.length < minMultiLineLength) { - i += 1; - } else { - // folding will eat first newline - str += json.slice(start, i) + '\n\n'; - - while (json[i + 2] === '\\' && json[i + 3] === 'n' && json[i + 4] !== '"') { - str += '\n'; - i += 2; - } - - str += indent; // space after newline needs to be escaped to not be folded - - if (json[i + 2] === ' ') str += '\\'; - i += 1; - start = i + 1; - } - - break; - - default: - i += 1; - } - } - - str = start ? str + json.slice(start) : json; - return implicitKey ? str : foldFlowLines(str, indent, FOLD_QUOTED, getFoldOptions(ctx)); -} - -function singleQuotedString(value, ctx) { - if (ctx.implicitKey) { - if (/\n/.test(value)) return doubleQuotedString(value, ctx); - } else { - // single quoted string can't have leading or trailing whitespace around newline - if (/[ \t]\n|\n[ \t]/.test(value)) return doubleQuotedString(value, ctx); - } - - const indent = ctx.indent || (containsDocumentMarker(value) ? ' ' : ''); - const res = "'" + value.replace(/'/g, "''").replace(/\n+/g, `$&\n${indent}`) + "'"; - return ctx.implicitKey ? res : foldFlowLines(res, indent, FOLD_FLOW, getFoldOptions(ctx)); -} - -function blockString({ - comment, - type, - value -}, ctx, onComment, onChompKeep) { - // 1. Block can't end in whitespace unless the last line is non-empty. - // 2. Strings consisting of only whitespace are best rendered explicitly. - if (/\n[\t ]+$/.test(value) || /^\s*$/.test(value)) { - return doubleQuotedString(value, ctx); - } - - const indent = ctx.indent || (ctx.forceBlockIndent || containsDocumentMarker(value) ? ' ' : ''); - const indentSize = indent ? '2' : '1'; // root is at -1 - - const literal = type === PlainValue.Type.BLOCK_FOLDED ? false : type === PlainValue.Type.BLOCK_LITERAL ? true : !lineLengthOverLimit(value, strOptions.fold.lineWidth, indent.length); - let header = literal ? '|' : '>'; - if (!value) return header + '\n'; - let wsStart = ''; - let wsEnd = ''; - value = value.replace(/[\n\t ]*$/, ws => { - const n = ws.indexOf('\n'); - - if (n === -1) { - header += '-'; // strip - } else if (value === ws || n !== ws.length - 1) { - header += '+'; // keep - - if (onChompKeep) onChompKeep(); - } - - wsEnd = ws.replace(/\n$/, ''); - return ''; - }).replace(/^[\n ]*/, ws => { - if (ws.indexOf(' ') !== -1) header += indentSize; - const m = ws.match(/ +$/); - - if (m) { - wsStart = ws.slice(0, -m[0].length); - return m[0]; - } else { - wsStart = ws; - return ''; - } - }); - if (wsEnd) wsEnd = wsEnd.replace(/\n+(?!\n|$)/g, `$&${indent}`); - if (wsStart) wsStart = wsStart.replace(/\n+/g, `$&${indent}`); - - if (comment) { - header += ' #' + comment.replace(/ ?[\r\n]+/g, ' '); - if (onComment) onComment(); - } - - if (!value) return `${header}${indentSize}\n${indent}${wsEnd}`; - - if (literal) { - value = value.replace(/\n+/g, `$&${indent}`); - return `${header}\n${indent}${wsStart}${value}${wsEnd}`; - } - - value = value.replace(/\n+/g, '\n$&').replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, '$1$2') // more-indented lines aren't folded - // ^ ind.line ^ empty ^ capture next empty lines only at end of indent - .replace(/\n+/g, `$&${indent}`); - const body = foldFlowLines(`${wsStart}${value}${wsEnd}`, indent, FOLD_BLOCK, strOptions.fold); - return `${header}\n${indent}${body}`; -} - -function plainString(item, ctx, onComment, onChompKeep) { - const { - comment, - type, - value - } = item; - const { - actualString, - implicitKey, - indent, - inFlow - } = ctx; - - if (implicitKey && /[\n[\]{},]/.test(value) || inFlow && /[[\]{},]/.test(value)) { - return doubleQuotedString(value, ctx); - } - - if (!value || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(value)) { - // not allowed: - // - empty string, '-' or '?' - // - start with an indicator character (except [?:-]) or /[?-] / - // - '\n ', ': ' or ' \n' anywhere - // - '#' not preceded by a non-space char - // - end with ' ' or ':' - return implicitKey || inFlow || value.indexOf('\n') === -1 ? value.indexOf('"') !== -1 && value.indexOf("'") === -1 ? singleQuotedString(value, ctx) : doubleQuotedString(value, ctx) : blockString(item, ctx, onComment, onChompKeep); - } - - if (!implicitKey && !inFlow && type !== PlainValue.Type.PLAIN && value.indexOf('\n') !== -1) { - // Where allowed & type not set explicitly, prefer block style for multiline strings - return blockString(item, ctx, onComment, onChompKeep); - } - - if (indent === '' && containsDocumentMarker(value)) { - ctx.forceBlockIndent = true; - return blockString(item, ctx, onComment, onChompKeep); - } - - const str = value.replace(/\n+/g, `$&\n${indent}`); // Verify that output will be parsed as a string, as e.g. plain numbers and - // booleans get parsed with those types in v1.2 (e.g. '42', 'true' & '0.9e-3'), - // and others in v1.1. - - if (actualString) { - const { - tags - } = ctx.doc.schema; - const resolved = resolveScalar(str, tags, tags.scalarFallback).value; - if (typeof resolved !== 'string') return doubleQuotedString(value, ctx); - } - - const body = implicitKey ? str : foldFlowLines(str, indent, FOLD_FLOW, getFoldOptions(ctx)); - - if (comment && !inFlow && (body.indexOf('\n') !== -1 || comment.indexOf('\n') !== -1)) { - if (onComment) onComment(); - return addCommentBefore(body, indent, comment); - } - - return body; -} - -function stringifyString(item, ctx, onComment, onChompKeep) { - const { - defaultType - } = strOptions; - const { - implicitKey, - inFlow - } = ctx; - let { - type, - value - } = item; - - if (typeof value !== 'string') { - value = String(value); - item = Object.assign({}, item, { - value - }); - } - - const _stringify = _type => { - switch (_type) { - case PlainValue.Type.BLOCK_FOLDED: - case PlainValue.Type.BLOCK_LITERAL: - return blockString(item, ctx, onComment, onChompKeep); - - case PlainValue.Type.QUOTE_DOUBLE: - return doubleQuotedString(value, ctx); - - case PlainValue.Type.QUOTE_SINGLE: - return singleQuotedString(value, ctx); - - case PlainValue.Type.PLAIN: - return plainString(item, ctx, onComment, onChompKeep); - - default: - return null; - } - }; - - if (type !== PlainValue.Type.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(value)) { - // force double quotes on control characters - type = PlainValue.Type.QUOTE_DOUBLE; - } else if ((implicitKey || inFlow) && (type === PlainValue.Type.BLOCK_FOLDED || type === PlainValue.Type.BLOCK_LITERAL)) { - // should not happen; blocks are not valid inside flow containers - type = PlainValue.Type.QUOTE_DOUBLE; - } - - let res = _stringify(type); - - if (res === null) { - res = _stringify(defaultType); - if (res === null) throw new Error(`Unsupported default string type ${defaultType}`); - } - - return res; -} - -function stringifyNumber({ - format, - minFractionDigits, - tag, - value -}) { - if (typeof value === 'bigint') return String(value); - if (!isFinite(value)) return isNaN(value) ? '.nan' : value < 0 ? '-.inf' : '.inf'; - let n = JSON.stringify(value); - - if (!format && minFractionDigits && (!tag || tag === 'tag:yaml.org,2002:float') && /^\d/.test(n)) { - let i = n.indexOf('.'); - - if (i < 0) { - i = n.length; - n += '.'; - } - - let d = minFractionDigits - (n.length - i - 1); - - while (d-- > 0) n += '0'; - } - - return n; -} - -function checkFlowCollectionEnd(errors, cst) { - let char, name; - - switch (cst.type) { - case PlainValue.Type.FLOW_MAP: - char = '}'; - name = 'flow map'; - break; - - case PlainValue.Type.FLOW_SEQ: - char = ']'; - name = 'flow sequence'; - break; - - default: - errors.push(new PlainValue.YAMLSemanticError(cst, 'Not a flow collection!?')); - return; - } - - let lastItem; - - for (let i = cst.items.length - 1; i >= 0; --i) { - const item = cst.items[i]; - - if (!item || item.type !== PlainValue.Type.COMMENT) { - lastItem = item; - break; - } - } - - if (lastItem && lastItem.char !== char) { - const msg = `Expected ${name} to end with ${char}`; - let err; - - if (typeof lastItem.offset === 'number') { - err = new PlainValue.YAMLSemanticError(cst, msg); - err.offset = lastItem.offset + 1; - } else { - err = new PlainValue.YAMLSemanticError(lastItem, msg); - if (lastItem.range && lastItem.range.end) err.offset = lastItem.range.end - lastItem.range.start; - } - - errors.push(err); - } -} -function checkFlowCommentSpace(errors, comment) { - const prev = comment.context.src[comment.range.start - 1]; - - if (prev !== '\n' && prev !== '\t' && prev !== ' ') { - const msg = 'Comments must be separated from other tokens by white space characters'; - errors.push(new PlainValue.YAMLSemanticError(comment, msg)); - } -} -function getLongKeyError(source, key) { - const sk = String(key); - const k = sk.substr(0, 8) + '...' + sk.substr(-8); - return new PlainValue.YAMLSemanticError(source, `The "${k}" key is too long`); -} -function resolveComments(collection, comments) { - for (const { - afterKey, - before, - comment - } of comments) { - let item = collection.items[before]; - - if (!item) { - if (comment !== undefined) { - if (collection.comment) collection.comment += '\n' + comment;else collection.comment = comment; - } - } else { - if (afterKey && item.value) item = item.value; - - if (comment === undefined) { - if (afterKey || !item.commentBefore) item.spaceBefore = true; - } else { - if (item.commentBefore) item.commentBefore += '\n' + comment;else item.commentBefore = comment; - } - } - } -} - -// on error, will return { str: string, errors: Error[] } -function resolveString(doc, node) { - const res = node.strValue; - if (!res) return ''; - if (typeof res === 'string') return res; - res.errors.forEach(error => { - if (!error.source) error.source = node; - doc.errors.push(error); - }); - return res.str; -} - -function resolveTagHandle(doc, node) { - const { - handle, - suffix - } = node.tag; - let prefix = doc.tagPrefixes.find(p => p.handle === handle); - - if (!prefix) { - const dtp = doc.getDefaults().tagPrefixes; - if (dtp) prefix = dtp.find(p => p.handle === handle); - if (!prefix) throw new PlainValue.YAMLSemanticError(node, `The ${handle} tag handle is non-default and was not declared.`); - } - - if (!suffix) throw new PlainValue.YAMLSemanticError(node, `The ${handle} tag has no suffix.`); - - if (handle === '!' && (doc.version || doc.options.version) === '1.0') { - if (suffix[0] === '^') { - doc.warnings.push(new PlainValue.YAMLWarning(node, 'YAML 1.0 ^ tag expansion is not supported')); - return suffix; - } - - if (/[:/]/.test(suffix)) { - // word/foo -> tag:word.yaml.org,2002:foo - const vocab = suffix.match(/^([a-z0-9-]+)\/(.*)/i); - return vocab ? `tag:${vocab[1]}.yaml.org,2002:${vocab[2]}` : `tag:${suffix}`; - } - } - - return prefix.prefix + decodeURIComponent(suffix); -} - -function resolveTagName(doc, node) { - const { - tag, - type - } = node; - let nonSpecific = false; - - if (tag) { - const { - handle, - suffix, - verbatim - } = tag; - - if (verbatim) { - if (verbatim !== '!' && verbatim !== '!!') return verbatim; - const msg = `Verbatim tags aren't resolved, so ${verbatim} is invalid.`; - doc.errors.push(new PlainValue.YAMLSemanticError(node, msg)); - } else if (handle === '!' && !suffix) { - nonSpecific = true; - } else { - try { - return resolveTagHandle(doc, node); - } catch (error) { - doc.errors.push(error); - } - } - } - - switch (type) { - case PlainValue.Type.BLOCK_FOLDED: - case PlainValue.Type.BLOCK_LITERAL: - case PlainValue.Type.QUOTE_DOUBLE: - case PlainValue.Type.QUOTE_SINGLE: - return PlainValue.defaultTags.STR; - - case PlainValue.Type.FLOW_MAP: - case PlainValue.Type.MAP: - return PlainValue.defaultTags.MAP; - - case PlainValue.Type.FLOW_SEQ: - case PlainValue.Type.SEQ: - return PlainValue.defaultTags.SEQ; - - case PlainValue.Type.PLAIN: - return nonSpecific ? PlainValue.defaultTags.STR : null; - - default: - return null; - } -} - -function resolveByTagName(doc, node, tagName) { - const { - tags - } = doc.schema; - const matchWithTest = []; - - for (const tag of tags) { - if (tag.tag === tagName) { - if (tag.test) matchWithTest.push(tag);else { - const res = tag.resolve(doc, node); - return res instanceof Collection ? res : new Scalar(res); - } - } - } - - const str = resolveString(doc, node); - if (typeof str === 'string' && matchWithTest.length > 0) return resolveScalar(str, matchWithTest, tags.scalarFallback); - return null; -} - -function getFallbackTagName({ - type -}) { - switch (type) { - case PlainValue.Type.FLOW_MAP: - case PlainValue.Type.MAP: - return PlainValue.defaultTags.MAP; - - case PlainValue.Type.FLOW_SEQ: - case PlainValue.Type.SEQ: - return PlainValue.defaultTags.SEQ; - - default: - return PlainValue.defaultTags.STR; - } -} - -function resolveTag(doc, node, tagName) { - try { - const res = resolveByTagName(doc, node, tagName); - - if (res) { - if (tagName && node.tag) res.tag = tagName; - return res; - } - } catch (error) { - /* istanbul ignore if */ - if (!error.source) error.source = node; - doc.errors.push(error); - return null; - } - - try { - const fallback = getFallbackTagName(node); - if (!fallback) throw new Error(`The tag ${tagName} is unavailable`); - const msg = `The tag ${tagName} is unavailable, falling back to ${fallback}`; - doc.warnings.push(new PlainValue.YAMLWarning(node, msg)); - const res = resolveByTagName(doc, node, fallback); - res.tag = tagName; - return res; - } catch (error) { - const refError = new PlainValue.YAMLReferenceError(node, error.message); - refError.stack = error.stack; - doc.errors.push(refError); - return null; - } -} - -const isCollectionItem = node => { - if (!node) return false; - const { - type - } = node; - return type === PlainValue.Type.MAP_KEY || type === PlainValue.Type.MAP_VALUE || type === PlainValue.Type.SEQ_ITEM; -}; - -function resolveNodeProps(errors, node) { - const comments = { - before: [], - after: [] - }; - let hasAnchor = false; - let hasTag = false; - const props = isCollectionItem(node.context.parent) ? node.context.parent.props.concat(node.props) : node.props; - - for (const { - start, - end - } of props) { - switch (node.context.src[start]) { - case PlainValue.Char.COMMENT: - { - if (!node.commentHasRequiredWhitespace(start)) { - const msg = 'Comments must be separated from other tokens by white space characters'; - errors.push(new PlainValue.YAMLSemanticError(node, msg)); - } - - const { - header, - valueRange - } = node; - const cc = valueRange && (start > valueRange.start || header && start > header.start) ? comments.after : comments.before; - cc.push(node.context.src.slice(start + 1, end)); - break; - } - // Actual anchor & tag resolution is handled by schema, here we just complain - - case PlainValue.Char.ANCHOR: - if (hasAnchor) { - const msg = 'A node can have at most one anchor'; - errors.push(new PlainValue.YAMLSemanticError(node, msg)); - } - - hasAnchor = true; - break; - - case PlainValue.Char.TAG: - if (hasTag) { - const msg = 'A node can have at most one tag'; - errors.push(new PlainValue.YAMLSemanticError(node, msg)); - } - - hasTag = true; - break; - } - } - - return { - comments, - hasAnchor, - hasTag - }; -} - -function resolveNodeValue(doc, node) { - const { - anchors, - errors, - schema - } = doc; - - if (node.type === PlainValue.Type.ALIAS) { - const name = node.rawValue; - const src = anchors.getNode(name); - - if (!src) { - const msg = `Aliased anchor not found: ${name}`; - errors.push(new PlainValue.YAMLReferenceError(node, msg)); - return null; - } // Lazy resolution for circular references - - - const res = new Alias(src); - - anchors._cstAliases.push(res); - - return res; - } - - const tagName = resolveTagName(doc, node); - if (tagName) return resolveTag(doc, node, tagName); - - if (node.type !== PlainValue.Type.PLAIN) { - const msg = `Failed to resolve ${node.type} node here`; - errors.push(new PlainValue.YAMLSyntaxError(node, msg)); - return null; - } - - try { - const str = resolveString(doc, node); - return resolveScalar(str, schema.tags, schema.tags.scalarFallback); - } catch (error) { - if (!error.source) error.source = node; - errors.push(error); - return null; - } -} // sets node.resolved on success - - -function resolveNode(doc, node) { - if (!node) return null; - if (node.error) doc.errors.push(node.error); - const { - comments, - hasAnchor, - hasTag - } = resolveNodeProps(doc.errors, node); - - if (hasAnchor) { - const { - anchors - } = doc; - const name = node.anchor; - const prev = anchors.getNode(name); // At this point, aliases for any preceding node with the same anchor - // name have already been resolved, so it may safely be renamed. - - if (prev) anchors.map[anchors.newName(name)] = prev; // During parsing, we need to store the CST node in anchors.map as - // anchors need to be available during resolution to allow for - // circular references. - - anchors.map[name] = node; - } - - if (node.type === PlainValue.Type.ALIAS && (hasAnchor || hasTag)) { - const msg = 'An alias node must not specify any properties'; - doc.errors.push(new PlainValue.YAMLSemanticError(node, msg)); - } - - const res = resolveNodeValue(doc, node); - - if (res) { - res.range = [node.range.start, node.range.end]; - if (doc.options.keepCstNodes) res.cstNode = node; - if (doc.options.keepNodeTypes) res.type = node.type; - const cb = comments.before.join('\n'); - - if (cb) { - res.commentBefore = res.commentBefore ? `${res.commentBefore}\n${cb}` : cb; - } - - const ca = comments.after.join('\n'); - if (ca) res.comment = res.comment ? `${res.comment}\n${ca}` : ca; - } - - return node.resolved = res; -} - -function resolveMap(doc, cst) { - if (cst.type !== PlainValue.Type.MAP && cst.type !== PlainValue.Type.FLOW_MAP) { - const msg = `A ${cst.type} node cannot be resolved as a mapping`; - doc.errors.push(new PlainValue.YAMLSyntaxError(cst, msg)); - return null; - } - - const { - comments, - items - } = cst.type === PlainValue.Type.FLOW_MAP ? resolveFlowMapItems(doc, cst) : resolveBlockMapItems(doc, cst); - const map = new YAMLMap(); - map.items = items; - resolveComments(map, comments); - let hasCollectionKey = false; - - for (let i = 0; i < items.length; ++i) { - const { - key: iKey - } = items[i]; - if (iKey instanceof Collection) hasCollectionKey = true; - - if (doc.schema.merge && iKey && iKey.value === MERGE_KEY) { - items[i] = new Merge(items[i]); - const sources = items[i].value.items; - let error = null; - sources.some(node => { - if (node instanceof Alias) { - // During parsing, alias sources are CST nodes; to account for - // circular references their resolved values can't be used here. - const { - type - } = node.source; - if (type === PlainValue.Type.MAP || type === PlainValue.Type.FLOW_MAP) return false; - return error = 'Merge nodes aliases can only point to maps'; - } - - return error = 'Merge nodes can only have Alias nodes as values'; - }); - if (error) doc.errors.push(new PlainValue.YAMLSemanticError(cst, error)); - } else { - for (let j = i + 1; j < items.length; ++j) { - const { - key: jKey - } = items[j]; - - if (iKey === jKey || iKey && jKey && Object.prototype.hasOwnProperty.call(iKey, 'value') && iKey.value === jKey.value) { - const msg = `Map keys must be unique; "${iKey}" is repeated`; - doc.errors.push(new PlainValue.YAMLSemanticError(cst, msg)); - break; - } - } - } - } - - if (hasCollectionKey && !doc.options.mapAsMap) { - const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; - doc.warnings.push(new PlainValue.YAMLWarning(cst, warn)); - } - - cst.resolved = map; - return map; -} - -const valueHasPairComment = ({ - context: { - lineStart, - node, - src - }, - props -}) => { - if (props.length === 0) return false; - const { - start - } = props[0]; - if (node && start > node.valueRange.start) return false; - if (src[start] !== PlainValue.Char.COMMENT) return false; - - for (let i = lineStart; i < start; ++i) if (src[i] === '\n') return false; - - return true; -}; - -function resolvePairComment(item, pair) { - if (!valueHasPairComment(item)) return; - const comment = item.getPropValue(0, PlainValue.Char.COMMENT, true); - let found = false; - const cb = pair.value.commentBefore; - - if (cb && cb.startsWith(comment)) { - pair.value.commentBefore = cb.substr(comment.length + 1); - found = true; - } else { - const cc = pair.value.comment; - - if (!item.node && cc && cc.startsWith(comment)) { - pair.value.comment = cc.substr(comment.length + 1); - found = true; - } - } - - if (found) pair.comment = comment; -} - -function resolveBlockMapItems(doc, cst) { - const comments = []; - const items = []; - let key = undefined; - let keyStart = null; - - for (let i = 0; i < cst.items.length; ++i) { - const item = cst.items[i]; - - switch (item.type) { - case PlainValue.Type.BLANK_LINE: - comments.push({ - afterKey: !!key, - before: items.length - }); - break; - - case PlainValue.Type.COMMENT: - comments.push({ - afterKey: !!key, - before: items.length, - comment: item.comment - }); - break; - - case PlainValue.Type.MAP_KEY: - if (key !== undefined) items.push(new Pair(key)); - if (item.error) doc.errors.push(item.error); - key = resolveNode(doc, item.node); - keyStart = null; - break; - - case PlainValue.Type.MAP_VALUE: - { - if (key === undefined) key = null; - if (item.error) doc.errors.push(item.error); - - if (!item.context.atLineStart && item.node && item.node.type === PlainValue.Type.MAP && !item.node.context.atLineStart) { - const msg = 'Nested mappings are not allowed in compact mappings'; - doc.errors.push(new PlainValue.YAMLSemanticError(item.node, msg)); - } - - let valueNode = item.node; - - if (!valueNode && item.props.length > 0) { - // Comments on an empty mapping value need to be preserved, so we - // need to construct a minimal empty node here to use instead of the - // missing `item.node`. -- eemeli/yaml#19 - valueNode = new PlainValue.PlainValue(PlainValue.Type.PLAIN, []); - valueNode.context = { - parent: item, - src: item.context.src - }; - const pos = item.range.start + 1; - valueNode.range = { - start: pos, - end: pos - }; - valueNode.valueRange = { - start: pos, - end: pos - }; - - if (typeof item.range.origStart === 'number') { - const origPos = item.range.origStart + 1; - valueNode.range.origStart = valueNode.range.origEnd = origPos; - valueNode.valueRange.origStart = valueNode.valueRange.origEnd = origPos; - } - } - - const pair = new Pair(key, resolveNode(doc, valueNode)); - resolvePairComment(item, pair); - items.push(pair); - - if (key && typeof keyStart === 'number') { - if (item.range.start > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key)); - } - - key = undefined; - keyStart = null; - } - break; - - default: - if (key !== undefined) items.push(new Pair(key)); - key = resolveNode(doc, item); - keyStart = item.range.start; - if (item.error) doc.errors.push(item.error); - - next: for (let j = i + 1;; ++j) { - const nextItem = cst.items[j]; - - switch (nextItem && nextItem.type) { - case PlainValue.Type.BLANK_LINE: - case PlainValue.Type.COMMENT: - continue next; - - case PlainValue.Type.MAP_VALUE: - break next; - - default: - { - const msg = 'Implicit map keys need to be followed by map values'; - doc.errors.push(new PlainValue.YAMLSemanticError(item, msg)); - break next; - } - } - } - - if (item.valueRangeContainsNewline) { - const msg = 'Implicit map keys need to be on a single line'; - doc.errors.push(new PlainValue.YAMLSemanticError(item, msg)); - } - - } - } - - if (key !== undefined) items.push(new Pair(key)); - return { - comments, - items - }; -} - -function resolveFlowMapItems(doc, cst) { - const comments = []; - const items = []; - let key = undefined; - let explicitKey = false; - let next = '{'; - - for (let i = 0; i < cst.items.length; ++i) { - const item = cst.items[i]; - - if (typeof item.char === 'string') { - const { - char, - offset - } = item; - - if (char === '?' && key === undefined && !explicitKey) { - explicitKey = true; - next = ':'; - continue; - } - - if (char === ':') { - if (key === undefined) key = null; - - if (next === ':') { - next = ','; - continue; - } - } else { - if (explicitKey) { - if (key === undefined && char !== ',') key = null; - explicitKey = false; - } - - if (key !== undefined) { - items.push(new Pair(key)); - key = undefined; - - if (char === ',') { - next = ':'; - continue; - } - } - } - - if (char === '}') { - if (i === cst.items.length - 1) continue; - } else if (char === next) { - next = ':'; - continue; - } - - const msg = `Flow map contains an unexpected ${char}`; - const err = new PlainValue.YAMLSyntaxError(cst, msg); - err.offset = offset; - doc.errors.push(err); - } else if (item.type === PlainValue.Type.BLANK_LINE) { - comments.push({ - afterKey: !!key, - before: items.length - }); - } else if (item.type === PlainValue.Type.COMMENT) { - checkFlowCommentSpace(doc.errors, item); - comments.push({ - afterKey: !!key, - before: items.length, - comment: item.comment - }); - } else if (key === undefined) { - if (next === ',') doc.errors.push(new PlainValue.YAMLSemanticError(item, 'Separator , missing in flow map')); - key = resolveNode(doc, item); - } else { - if (next !== ',') doc.errors.push(new PlainValue.YAMLSemanticError(item, 'Indicator : missing in flow map entry')); - items.push(new Pair(key, resolveNode(doc, item))); - key = undefined; - explicitKey = false; - } - } - - checkFlowCollectionEnd(doc.errors, cst); - if (key !== undefined) items.push(new Pair(key)); - return { - comments, - items - }; -} - -function resolveSeq(doc, cst) { - if (cst.type !== PlainValue.Type.SEQ && cst.type !== PlainValue.Type.FLOW_SEQ) { - const msg = `A ${cst.type} node cannot be resolved as a sequence`; - doc.errors.push(new PlainValue.YAMLSyntaxError(cst, msg)); - return null; - } - - const { - comments, - items - } = cst.type === PlainValue.Type.FLOW_SEQ ? resolveFlowSeqItems(doc, cst) : resolveBlockSeqItems(doc, cst); - const seq = new YAMLSeq(); - seq.items = items; - resolveComments(seq, comments); - - if (!doc.options.mapAsMap && items.some(it => it instanceof Pair && it.key instanceof Collection)) { - const warn = 'Keys with collection values will be stringified as YAML due to JS Object restrictions. Use mapAsMap: true to avoid this.'; - doc.warnings.push(new PlainValue.YAMLWarning(cst, warn)); - } - - cst.resolved = seq; - return seq; -} - -function resolveBlockSeqItems(doc, cst) { - const comments = []; - const items = []; - - for (let i = 0; i < cst.items.length; ++i) { - const item = cst.items[i]; - - switch (item.type) { - case PlainValue.Type.BLANK_LINE: - comments.push({ - before: items.length - }); - break; - - case PlainValue.Type.COMMENT: - comments.push({ - comment: item.comment, - before: items.length - }); - break; - - case PlainValue.Type.SEQ_ITEM: - if (item.error) doc.errors.push(item.error); - items.push(resolveNode(doc, item.node)); - - if (item.hasProps) { - const msg = 'Sequence items cannot have tags or anchors before the - indicator'; - doc.errors.push(new PlainValue.YAMLSemanticError(item, msg)); - } - - break; - - default: - if (item.error) doc.errors.push(item.error); - doc.errors.push(new PlainValue.YAMLSyntaxError(item, `Unexpected ${item.type} node in sequence`)); - } - } - - return { - comments, - items - }; -} - -function resolveFlowSeqItems(doc, cst) { - const comments = []; - const items = []; - let explicitKey = false; - let key = undefined; - let keyStart = null; - let next = '['; - let prevItem = null; - - for (let i = 0; i < cst.items.length; ++i) { - const item = cst.items[i]; - - if (typeof item.char === 'string') { - const { - char, - offset - } = item; - - if (char !== ':' && (explicitKey || key !== undefined)) { - if (explicitKey && key === undefined) key = next ? items.pop() : null; - items.push(new Pair(key)); - explicitKey = false; - key = undefined; - keyStart = null; - } - - if (char === next) { - next = null; - } else if (!next && char === '?') { - explicitKey = true; - } else if (next !== '[' && char === ':' && key === undefined) { - if (next === ',') { - key = items.pop(); - - if (key instanceof Pair) { - const msg = 'Chaining flow sequence pairs is invalid'; - const err = new PlainValue.YAMLSemanticError(cst, msg); - err.offset = offset; - doc.errors.push(err); - } - - if (!explicitKey && typeof keyStart === 'number') { - const keyEnd = item.range ? item.range.start : item.offset; - if (keyEnd > keyStart + 1024) doc.errors.push(getLongKeyError(cst, key)); - const { - src - } = prevItem.context; - - for (let i = keyStart; i < keyEnd; ++i) if (src[i] === '\n') { - const msg = 'Implicit keys of flow sequence pairs need to be on a single line'; - doc.errors.push(new PlainValue.YAMLSemanticError(prevItem, msg)); - break; - } - } - } else { - key = null; - } - - keyStart = null; - explicitKey = false; - next = null; - } else if (next === '[' || char !== ']' || i < cst.items.length - 1) { - const msg = `Flow sequence contains an unexpected ${char}`; - const err = new PlainValue.YAMLSyntaxError(cst, msg); - err.offset = offset; - doc.errors.push(err); - } - } else if (item.type === PlainValue.Type.BLANK_LINE) { - comments.push({ - before: items.length - }); - } else if (item.type === PlainValue.Type.COMMENT) { - checkFlowCommentSpace(doc.errors, item); - comments.push({ - comment: item.comment, - before: items.length - }); - } else { - if (next) { - const msg = `Expected a ${next} in flow sequence`; - doc.errors.push(new PlainValue.YAMLSemanticError(item, msg)); - } - - const value = resolveNode(doc, item); - - if (key === undefined) { - items.push(value); - prevItem = item; - } else { - items.push(new Pair(key, value)); - key = undefined; - } - - keyStart = item.range.start; - next = ','; - } - } - - checkFlowCollectionEnd(doc.errors, cst); - if (key !== undefined) items.push(new Pair(key)); - return { - comments, - items - }; -} - -exports.Alias = Alias; -exports.Collection = Collection; -exports.Merge = Merge; -exports.Node = Node; -exports.Pair = Pair; -exports.Scalar = Scalar; -exports.YAMLMap = YAMLMap; -exports.YAMLSeq = YAMLSeq; -exports.addComment = addComment; -exports.binaryOptions = binaryOptions; -exports.boolOptions = boolOptions; -exports.findPair = findPair; -exports.intOptions = intOptions; -exports.isEmptyPath = isEmptyPath; -exports.nullOptions = nullOptions; -exports.resolveMap = resolveMap; -exports.resolveNode = resolveNode; -exports.resolveSeq = resolveSeq; -exports.resolveString = resolveString; -exports.strOptions = strOptions; -exports.stringifyNumber = stringifyNumber; -exports.stringifyString = stringifyString; -exports.toJSON = toJSON; diff --git a/action/node_modules/yaml/dist/test-events.js b/action/node_modules/yaml/dist/test-events.js deleted file mode 100644 index 2b856e186..000000000 --- a/action/node_modules/yaml/dist/test-events.js +++ /dev/null @@ -1,162 +0,0 @@ -'use strict'; - -var parseCst = require('./parse-cst.js'); -var Document = require('./Document-9b4560a1.js'); -require('./PlainValue-ec8e588e.js'); -require('./resolveSeq-d03cb037.js'); -require('./Schema-88e323a7.js'); -require('./warnings-1000a372.js'); - -function testEvents(src, options) { - const opt = Object.assign({ - keepCstNodes: true, - keepNodeTypes: true, - version: '1.2' - }, options); - const docs = parseCst.parse(src).map(cstDoc => new Document.Document(opt).parse(cstDoc)); - const errDoc = docs.find(doc => doc.errors.length > 0); - const error = errDoc ? errDoc.errors[0].message : null; - const events = ['+STR']; - - try { - for (let i = 0; i < docs.length; ++i) { - const doc = docs[i]; - let root = doc.contents; - if (Array.isArray(root)) root = root[0]; - const [rootStart, rootEnd] = doc.range || [0, 0]; - let e = doc.errors[0] && doc.errors[0].source; - if (e && e.type === 'SEQ_ITEM') e = e.node; - if (e && (e.type === 'DOCUMENT' || e.range.start < rootStart)) throw new Error(); - let docStart = '+DOC'; - const pre = src.slice(0, rootStart); - const explicitDoc = /---\s*$/.test(pre); - if (explicitDoc) docStart += ' ---';else if (!doc.contents) continue; - events.push(docStart); - addEvents(events, doc, e, root); - if (doc.contents && doc.contents.length > 1) throw new Error(); - let docEnd = '-DOC'; - - if (rootEnd) { - const post = src.slice(rootEnd); - if (/^\.\.\./.test(post)) docEnd += ' ...'; - } - - events.push(docEnd); - } - } catch (e) { - return { - events, - error: error || e - }; - } - - events.push('-STR'); - return { - events, - error - }; -} - -function addEvents(events, doc, e, node) { - if (!node) { - events.push('=VAL :'); - return; - } - - if (e && node.cstNode === e) throw new Error(); - let props = ''; - let anchor = doc.anchors.getName(node); - - if (anchor) { - if (/\d$/.test(anchor)) { - const alt = anchor.replace(/\d$/, ''); - if (doc.anchors.getNode(alt)) anchor = alt; - } - - props = ` &${anchor}`; - } - - if (node.cstNode && node.cstNode.tag) { - const { - handle, - suffix - } = node.cstNode.tag; - props += handle === '!' && !suffix ? ' ' : ` <${node.tag}>`; - } - - let scalar = null; - - switch (node.type) { - case 'ALIAS': - { - let alias = doc.anchors.getName(node.source); - - if (/\d$/.test(alias)) { - const alt = alias.replace(/\d$/, ''); - if (doc.anchors.getNode(alt)) alias = alt; - } - - events.push(`=ALI${props} *${alias}`); - } - break; - - case 'BLOCK_FOLDED': - scalar = '>'; - break; - - case 'BLOCK_LITERAL': - scalar = '|'; - break; - - case 'PLAIN': - scalar = ':'; - break; - - case 'QUOTE_DOUBLE': - scalar = '"'; - break; - - case 'QUOTE_SINGLE': - scalar = "'"; - break; - - case 'PAIR': - events.push(`+MAP${props}`); - addEvents(events, doc, e, node.key); - addEvents(events, doc, e, node.value); - events.push('-MAP'); - break; - - case 'FLOW_SEQ': - case 'SEQ': - events.push(`+SEQ${props}`); - node.items.forEach(item => { - addEvents(events, doc, e, item); - }); - events.push('-SEQ'); - break; - - case 'FLOW_MAP': - case 'MAP': - events.push(`+MAP${props}`); - node.items.forEach(({ - key, - value - }) => { - addEvents(events, doc, e, key); - addEvents(events, doc, e, value); - }); - events.push('-MAP'); - break; - - default: - throw new Error(`Unexpected node type ${node.type}`); - } - - if (scalar) { - const value = node.cstNode.strValue.replace(/\\/g, '\\\\').replace(/\0/g, '\\0').replace(/\x07/g, '\\a').replace(/\x08/g, '\\b').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\v/g, '\\v').replace(/\f/g, '\\f').replace(/\r/g, '\\r').replace(/\x1b/g, '\\e'); - events.push(`=VAL${props} ${scalar}${value}`); - } -} - -exports.testEvents = testEvents; diff --git a/action/node_modules/yaml/dist/types.js b/action/node_modules/yaml/dist/types.js deleted file mode 100644 index 967c04e09..000000000 --- a/action/node_modules/yaml/dist/types.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var resolveSeq = require('./resolveSeq-d03cb037.js'); -var Schema = require('./Schema-88e323a7.js'); -require('./PlainValue-ec8e588e.js'); -require('./warnings-1000a372.js'); - - - -exports.Alias = resolveSeq.Alias; -exports.Collection = resolveSeq.Collection; -exports.Merge = resolveSeq.Merge; -exports.Node = resolveSeq.Node; -exports.Pair = resolveSeq.Pair; -exports.Scalar = resolveSeq.Scalar; -exports.YAMLMap = resolveSeq.YAMLMap; -exports.YAMLSeq = resolveSeq.YAMLSeq; -exports.binaryOptions = resolveSeq.binaryOptions; -exports.boolOptions = resolveSeq.boolOptions; -exports.intOptions = resolveSeq.intOptions; -exports.nullOptions = resolveSeq.nullOptions; -exports.strOptions = resolveSeq.strOptions; -exports.Schema = Schema.Schema; diff --git a/action/node_modules/yaml/dist/util.js b/action/node_modules/yaml/dist/util.js deleted file mode 100644 index bc1e079ac..000000000 --- a/action/node_modules/yaml/dist/util.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var resolveSeq = require('./resolveSeq-d03cb037.js'); -var PlainValue = require('./PlainValue-ec8e588e.js'); - - - -exports.findPair = resolveSeq.findPair; -exports.parseMap = resolveSeq.resolveMap; -exports.parseSeq = resolveSeq.resolveSeq; -exports.stringifyNumber = resolveSeq.stringifyNumber; -exports.stringifyString = resolveSeq.stringifyString; -exports.toJSON = resolveSeq.toJSON; -exports.Type = PlainValue.Type; -exports.YAMLError = PlainValue.YAMLError; -exports.YAMLReferenceError = PlainValue.YAMLReferenceError; -exports.YAMLSemanticError = PlainValue.YAMLSemanticError; -exports.YAMLSyntaxError = PlainValue.YAMLSyntaxError; -exports.YAMLWarning = PlainValue.YAMLWarning; diff --git a/action/node_modules/yaml/dist/warnings-1000a372.js b/action/node_modules/yaml/dist/warnings-1000a372.js deleted file mode 100644 index 7776d9fc2..000000000 --- a/action/node_modules/yaml/dist/warnings-1000a372.js +++ /dev/null @@ -1,416 +0,0 @@ -'use strict'; - -var PlainValue = require('./PlainValue-ec8e588e.js'); -var resolveSeq = require('./resolveSeq-d03cb037.js'); - -/* global atob, btoa, Buffer */ -const binary = { - identify: value => value instanceof Uint8Array, - // Buffer inherits from Uint8Array - default: false, - tag: 'tag:yaml.org,2002:binary', - - /** - * Returns a Buffer in node and an Uint8Array in browsers - * - * To use the resulting buffer as an image, you'll want to do something like: - * - * const blob = new Blob([buffer], { type: 'image/jpeg' }) - * document.querySelector('#photo').src = URL.createObjectURL(blob) - */ - resolve: (doc, node) => { - const src = resolveSeq.resolveString(doc, node); - - if (typeof Buffer === 'function') { - return Buffer.from(src, 'base64'); - } else if (typeof atob === 'function') { - // On IE 11, atob() can't handle newlines - const str = atob(src.replace(/[\n\r]/g, '')); - const buffer = new Uint8Array(str.length); - - for (let i = 0; i < str.length; ++i) buffer[i] = str.charCodeAt(i); - - return buffer; - } else { - const msg = 'This environment does not support reading binary tags; either Buffer or atob is required'; - doc.errors.push(new PlainValue.YAMLReferenceError(node, msg)); - return null; - } - }, - options: resolveSeq.binaryOptions, - stringify: ({ - comment, - type, - value - }, ctx, onComment, onChompKeep) => { - let src; - - if (typeof Buffer === 'function') { - src = value instanceof Buffer ? value.toString('base64') : Buffer.from(value.buffer).toString('base64'); - } else if (typeof btoa === 'function') { - let s = ''; - - for (let i = 0; i < value.length; ++i) s += String.fromCharCode(value[i]); - - src = btoa(s); - } else { - throw new Error('This environment does not support writing binary tags; either Buffer or btoa is required'); - } - - if (!type) type = resolveSeq.binaryOptions.defaultType; - - if (type === PlainValue.Type.QUOTE_DOUBLE) { - value = src; - } else { - const { - lineWidth - } = resolveSeq.binaryOptions; - const n = Math.ceil(src.length / lineWidth); - const lines = new Array(n); - - for (let i = 0, o = 0; i < n; ++i, o += lineWidth) { - lines[i] = src.substr(o, lineWidth); - } - - value = lines.join(type === PlainValue.Type.BLOCK_LITERAL ? '\n' : ' '); - } - - return resolveSeq.stringifyString({ - comment, - type, - value - }, ctx, onComment, onChompKeep); - } -}; - -function parsePairs(doc, cst) { - const seq = resolveSeq.resolveSeq(doc, cst); - - for (let i = 0; i < seq.items.length; ++i) { - let item = seq.items[i]; - if (item instanceof resolveSeq.Pair) continue;else if (item instanceof resolveSeq.YAMLMap) { - if (item.items.length > 1) { - const msg = 'Each pair must have its own sequence indicator'; - throw new PlainValue.YAMLSemanticError(cst, msg); - } - - const pair = item.items[0] || new resolveSeq.Pair(); - if (item.commentBefore) pair.commentBefore = pair.commentBefore ? `${item.commentBefore}\n${pair.commentBefore}` : item.commentBefore; - if (item.comment) pair.comment = pair.comment ? `${item.comment}\n${pair.comment}` : item.comment; - item = pair; - } - seq.items[i] = item instanceof resolveSeq.Pair ? item : new resolveSeq.Pair(item); - } - - return seq; -} -function createPairs(schema, iterable, ctx) { - const pairs = new resolveSeq.YAMLSeq(schema); - pairs.tag = 'tag:yaml.org,2002:pairs'; - - for (const it of iterable) { - let key, value; - - if (Array.isArray(it)) { - if (it.length === 2) { - key = it[0]; - value = it[1]; - } else throw new TypeError(`Expected [key, value] tuple: ${it}`); - } else if (it && it instanceof Object) { - const keys = Object.keys(it); - - if (keys.length === 1) { - key = keys[0]; - value = it[key]; - } else throw new TypeError(`Expected { key: value } tuple: ${it}`); - } else { - key = it; - } - - const pair = schema.createPair(key, value, ctx); - pairs.items.push(pair); - } - - return pairs; -} -const pairs = { - default: false, - tag: 'tag:yaml.org,2002:pairs', - resolve: parsePairs, - createNode: createPairs -}; - -class YAMLOMap extends resolveSeq.YAMLSeq { - constructor() { - super(); - - PlainValue._defineProperty(this, "add", resolveSeq.YAMLMap.prototype.add.bind(this)); - - PlainValue._defineProperty(this, "delete", resolveSeq.YAMLMap.prototype.delete.bind(this)); - - PlainValue._defineProperty(this, "get", resolveSeq.YAMLMap.prototype.get.bind(this)); - - PlainValue._defineProperty(this, "has", resolveSeq.YAMLMap.prototype.has.bind(this)); - - PlainValue._defineProperty(this, "set", resolveSeq.YAMLMap.prototype.set.bind(this)); - - this.tag = YAMLOMap.tag; - } - - toJSON(_, ctx) { - const map = new Map(); - if (ctx && ctx.onCreate) ctx.onCreate(map); - - for (const pair of this.items) { - let key, value; - - if (pair instanceof resolveSeq.Pair) { - key = resolveSeq.toJSON(pair.key, '', ctx); - value = resolveSeq.toJSON(pair.value, key, ctx); - } else { - key = resolveSeq.toJSON(pair, '', ctx); - } - - if (map.has(key)) throw new Error('Ordered maps must not include duplicate keys'); - map.set(key, value); - } - - return map; - } - -} - -PlainValue._defineProperty(YAMLOMap, "tag", 'tag:yaml.org,2002:omap'); - -function parseOMap(doc, cst) { - const pairs = parsePairs(doc, cst); - const seenKeys = []; - - for (const { - key - } of pairs.items) { - if (key instanceof resolveSeq.Scalar) { - if (seenKeys.includes(key.value)) { - const msg = 'Ordered maps must not include duplicate keys'; - throw new PlainValue.YAMLSemanticError(cst, msg); - } else { - seenKeys.push(key.value); - } - } - } - - return Object.assign(new YAMLOMap(), pairs); -} - -function createOMap(schema, iterable, ctx) { - const pairs = createPairs(schema, iterable, ctx); - const omap = new YAMLOMap(); - omap.items = pairs.items; - return omap; -} - -const omap = { - identify: value => value instanceof Map, - nodeClass: YAMLOMap, - default: false, - tag: 'tag:yaml.org,2002:omap', - resolve: parseOMap, - createNode: createOMap -}; - -class YAMLSet extends resolveSeq.YAMLMap { - constructor() { - super(); - this.tag = YAMLSet.tag; - } - - add(key) { - const pair = key instanceof resolveSeq.Pair ? key : new resolveSeq.Pair(key); - const prev = resolveSeq.findPair(this.items, pair.key); - if (!prev) this.items.push(pair); - } - - get(key, keepPair) { - const pair = resolveSeq.findPair(this.items, key); - return !keepPair && pair instanceof resolveSeq.Pair ? pair.key instanceof resolveSeq.Scalar ? pair.key.value : pair.key : pair; - } - - set(key, value) { - if (typeof value !== 'boolean') throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof value}`); - const prev = resolveSeq.findPair(this.items, key); - - if (prev && !value) { - this.items.splice(this.items.indexOf(prev), 1); - } else if (!prev && value) { - this.items.push(new resolveSeq.Pair(key)); - } - } - - toJSON(_, ctx) { - return super.toJSON(_, ctx, Set); - } - - toString(ctx, onComment, onChompKeep) { - if (!ctx) return JSON.stringify(this); - if (this.hasAllNullValues()) return super.toString(ctx, onComment, onChompKeep);else throw new Error('Set items must all have null values'); - } - -} - -PlainValue._defineProperty(YAMLSet, "tag", 'tag:yaml.org,2002:set'); - -function parseSet(doc, cst) { - const map = resolveSeq.resolveMap(doc, cst); - if (!map.hasAllNullValues()) throw new PlainValue.YAMLSemanticError(cst, 'Set items must all have null values'); - return Object.assign(new YAMLSet(), map); -} - -function createSet(schema, iterable, ctx) { - const set = new YAMLSet(); - - for (const value of iterable) set.items.push(schema.createPair(value, null, ctx)); - - return set; -} - -const set = { - identify: value => value instanceof Set, - nodeClass: YAMLSet, - default: false, - tag: 'tag:yaml.org,2002:set', - resolve: parseSet, - createNode: createSet -}; - -const parseSexagesimal = (sign, parts) => { - const n = parts.split(':').reduce((n, p) => n * 60 + Number(p), 0); - return sign === '-' ? -n : n; -}; // hhhh:mm:ss.sss - - -const stringifySexagesimal = ({ - value -}) => { - if (isNaN(value) || !isFinite(value)) return resolveSeq.stringifyNumber(value); - let sign = ''; - - if (value < 0) { - sign = '-'; - value = Math.abs(value); - } - - const parts = [value % 60]; // seconds, including ms - - if (value < 60) { - parts.unshift(0); // at least one : is required - } else { - value = Math.round((value - parts[0]) / 60); - parts.unshift(value % 60); // minutes - - if (value >= 60) { - value = Math.round((value - parts[0]) / 60); - parts.unshift(value); // hours - } - } - - return sign + parts.map(n => n < 10 ? '0' + String(n) : String(n)).join(':').replace(/000000\d*$/, '') // % 60 may introduce error - ; -}; - -const intTime = { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:int', - format: 'TIME', - test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+)$/, - resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')), - stringify: stringifySexagesimal -}; -const floatTime = { - identify: value => typeof value === 'number', - default: true, - tag: 'tag:yaml.org,2002:float', - format: 'TIME', - test: /^([-+]?)([0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*)$/, - resolve: (str, sign, parts) => parseSexagesimal(sign, parts.replace(/_/g, '')), - stringify: stringifySexagesimal -}; -const timestamp = { - identify: value => value instanceof Date, - default: true, - tag: 'tag:yaml.org,2002:timestamp', - // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part - // may be omitted altogether, resulting in a date format. In such a case, the time part is - // assumed to be 00:00:00Z (start of day, UTC). - test: RegExp('^(?:' + '([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})' + // YYYY-Mm-Dd - '(?:(?:t|T|[ \\t]+)' + // t | T | whitespace - '([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)' + // Hh:Mm:Ss(.ss)? - '(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?' + // Z | +5 | -03:30 - ')?' + ')$'), - resolve: (str, year, month, day, hour, minute, second, millisec, tz) => { - if (millisec) millisec = (millisec + '00').substr(1, 3); - let date = Date.UTC(year, month - 1, day, hour || 0, minute || 0, second || 0, millisec || 0); - - if (tz && tz !== 'Z') { - let d = parseSexagesimal(tz[0], tz.slice(1)); - if (Math.abs(d) < 30) d *= 60; - date -= 60000 * d; - } - - return new Date(date); - }, - stringify: ({ - value - }) => value.toISOString().replace(/((T00:00)?:00)?\.000Z$/, '') -}; - -/* global console, process, YAML_SILENCE_DEPRECATION_WARNINGS, YAML_SILENCE_WARNINGS */ -function shouldWarn(deprecation) { - const env = typeof process !== 'undefined' && process.env || {}; - - if (deprecation) { - if (typeof YAML_SILENCE_DEPRECATION_WARNINGS !== 'undefined') return !YAML_SILENCE_DEPRECATION_WARNINGS; - return !env.YAML_SILENCE_DEPRECATION_WARNINGS; - } - - if (typeof YAML_SILENCE_WARNINGS !== 'undefined') return !YAML_SILENCE_WARNINGS; - return !env.YAML_SILENCE_WARNINGS; -} - -function warn(warning, type) { - if (shouldWarn(false)) { - const emit = typeof process !== 'undefined' && process.emitWarning; // This will throw in Jest if `warning` is an Error instance due to - // https://github.com/facebook/jest/issues/2549 - - if (emit) emit(warning, type);else { - // eslint-disable-next-line no-console - console.warn(type ? `${type}: ${warning}` : warning); - } - } -} -function warnFileDeprecation(filename) { - if (shouldWarn(true)) { - const path = filename.replace(/.*yaml[/\\]/i, '').replace(/\.js$/, '').replace(/\\/g, '/'); - warn(`The endpoint 'yaml/${path}' will be removed in a future release.`, 'DeprecationWarning'); - } -} -const warned = {}; -function warnOptionDeprecation(name, alternative) { - if (!warned[name] && shouldWarn(true)) { - warned[name] = true; - let msg = `The option '${name}' will be removed in a future release`; - msg += alternative ? `, use '${alternative}' instead.` : '.'; - warn(msg, 'DeprecationWarning'); - } -} - -exports.binary = binary; -exports.floatTime = floatTime; -exports.intTime = intTime; -exports.omap = omap; -exports.pairs = pairs; -exports.set = set; -exports.timestamp = timestamp; -exports.warn = warn; -exports.warnFileDeprecation = warnFileDeprecation; -exports.warnOptionDeprecation = warnOptionDeprecation; diff --git a/action/node_modules/yaml/index.js b/action/node_modules/yaml/index.js deleted file mode 100644 index b501ac4db..000000000 --- a/action/node_modules/yaml/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist').YAML diff --git a/action/node_modules/yaml/map.js b/action/node_modules/yaml/map.js deleted file mode 100644 index 78f2ebc74..000000000 --- a/action/node_modules/yaml/map.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').YAMLMap -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/package.json b/action/node_modules/yaml/package.json deleted file mode 100644 index d91b0dd13..000000000 --- a/action/node_modules/yaml/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "name": "yaml", - "version": "1.10.2", - "license": "ISC", - "author": "Eemeli Aro ", - "repository": "github:eemeli/yaml", - "description": "JavaScript parser and stringifier for YAML", - "keywords": [ - "YAML", - "parser", - "stringifier" - ], - "homepage": "https://eemeli.org/yaml/v1/", - "files": [ - "browser/", - "dist/", - "types/", - "*.d.ts", - "*.js", - "*.mjs", - "!*config.js" - ], - "type": "commonjs", - "main": "./index.js", - "browser": { - "./index.js": "./browser/index.js", - "./map.js": "./browser/map.js", - "./pair.js": "./browser/pair.js", - "./parse-cst.js": "./browser/parse-cst.js", - "./scalar.js": "./browser/scalar.js", - "./schema.js": "./browser/schema.js", - "./seq.js": "./browser/seq.js", - "./types.js": "./browser/types.js", - "./types.mjs": "./browser/types.js", - "./types/binary.js": "./browser/types/binary.js", - "./types/omap.js": "./browser/types/omap.js", - "./types/pairs.js": "./browser/types/pairs.js", - "./types/set.js": "./browser/types/set.js", - "./types/timestamp.js": "./browser/types/timestamp.js", - "./util.js": "./browser/util.js", - "./util.mjs": "./browser/util.js" - }, - "exports": { - ".": "./index.js", - "./parse-cst": "./parse-cst.js", - "./types": [ - { - "import": "./types.mjs" - }, - "./types.js" - ], - "./util": [ - { - "import": "./util.mjs" - }, - "./util.js" - ], - "./": "./" - }, - "scripts": { - "build": "npm run build:node && npm run build:browser", - "build:browser": "rollup -c rollup.browser-config.js", - "build:node": "rollup -c rollup.node-config.js", - "clean": "git clean -fdxe node_modules", - "lint": "eslint src/", - "prettier": "prettier --write .", - "start": "cross-env TRACE_LEVEL=log npm run build:node && node -i -e 'YAML=require(\".\")'", - "test": "jest", - "test:browsers": "cd playground && npm test", - "test:dist": "npm run build:node && jest", - "test:types": "tsc --lib ES2017 --noEmit tests/typings.ts", - "docs:install": "cd docs-slate && bundle install", - "docs:deploy": "cd docs-slate && ./deploy.sh", - "docs": "cd docs-slate && bundle exec middleman server", - "preversion": "npm test && npm run build", - "prepublishOnly": "npm run clean && npm test && npm run build" - }, - "browserslist": "> 0.5%, not dead", - "prettier": { - "arrowParens": "avoid", - "semi": false, - "singleQuote": true, - "trailingComma": "none" - }, - "devDependencies": { - "@babel/core": "^7.12.10", - "@babel/plugin-proposal-class-properties": "^7.12.1", - "@babel/preset-env": "^7.12.11", - "@rollup/plugin-babel": "^5.2.3", - "babel-eslint": "^10.1.0", - "babel-jest": "^26.6.3", - "babel-plugin-trace": "^1.1.0", - "common-tags": "^1.8.0", - "cross-env": "^7.0.3", - "eslint": "^7.19.0", - "eslint-config-prettier": "^7.2.0", - "fast-check": "^2.12.0", - "jest": "^26.6.3", - "prettier": "^2.2.1", - "rollup": "^2.38.2", - "typescript": "^4.1.3" - }, - "engines": { - "node": ">= 6" - } -} diff --git a/action/node_modules/yaml/pair.js b/action/node_modules/yaml/pair.js deleted file mode 100644 index b2880a256..000000000 --- a/action/node_modules/yaml/pair.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').Pair -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/parse-cst.js b/action/node_modules/yaml/parse-cst.js deleted file mode 100644 index 806575652..000000000 --- a/action/node_modules/yaml/parse-cst.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require('./dist/parse-cst').parse diff --git a/action/node_modules/yaml/scalar.js b/action/node_modules/yaml/scalar.js deleted file mode 100644 index deee1b03a..000000000 --- a/action/node_modules/yaml/scalar.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').Scalar -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/schema.js b/action/node_modules/yaml/schema.js deleted file mode 100644 index 4139c4bf8..000000000 --- a/action/node_modules/yaml/schema.js +++ /dev/null @@ -1,9 +0,0 @@ -const types = require('./dist/types') -const util = require('./dist/util') - -module.exports = types.Schema -module.exports.nullOptions = types.nullOptions -module.exports.strOptions = types.strOptions -module.exports.stringify = util.stringifyString - -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/seq.js b/action/node_modules/yaml/seq.js deleted file mode 100644 index 66147df38..000000000 --- a/action/node_modules/yaml/seq.js +++ /dev/null @@ -1,2 +0,0 @@ -module.exports = require('./dist/types').YAMLSeq -require('./dist/legacy-exports').warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/types.js b/action/node_modules/yaml/types.js deleted file mode 100644 index 88747498d..000000000 --- a/action/node_modules/yaml/types.js +++ /dev/null @@ -1,17 +0,0 @@ -const types = require('./dist/types') - -exports.binaryOptions = types.binaryOptions -exports.boolOptions = types.boolOptions -exports.intOptions = types.intOptions -exports.nullOptions = types.nullOptions -exports.strOptions = types.strOptions - -exports.Schema = types.Schema -exports.Alias = types.Alias -exports.Collection = types.Collection -exports.Merge = types.Merge -exports.Node = types.Node -exports.Pair = types.Pair -exports.Scalar = types.Scalar -exports.YAMLMap = types.YAMLMap -exports.YAMLSeq = types.YAMLSeq diff --git a/action/node_modules/yaml/types.mjs b/action/node_modules/yaml/types.mjs deleted file mode 100644 index 71322884c..000000000 --- a/action/node_modules/yaml/types.mjs +++ /dev/null @@ -1,17 +0,0 @@ -import types from './dist/types.js' - -export const binaryOptions = types.binaryOptions -export const boolOptions = types.boolOptions -export const intOptions = types.intOptions -export const nullOptions = types.nullOptions -export const strOptions = types.strOptions - -export const Schema = types.Schema -export const Alias = types.Alias -export const Collection = types.Collection -export const Merge = types.Merge -export const Node = types.Node -export const Pair = types.Pair -export const Scalar = types.Scalar -export const YAMLMap = types.YAMLMap -export const YAMLSeq = types.YAMLSeq diff --git a/action/node_modules/yaml/types/binary.js b/action/node_modules/yaml/types/binary.js deleted file mode 100644 index 271b9de38..000000000 --- a/action/node_modules/yaml/types/binary.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { value: true }) - -const legacy = require('../dist/legacy-exports') -exports.binary = legacy.binary -exports.default = [exports.binary] - -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/types/omap.js b/action/node_modules/yaml/types/omap.js deleted file mode 100644 index 37b638b73..000000000 --- a/action/node_modules/yaml/types/omap.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.omap -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/types/pairs.js b/action/node_modules/yaml/types/pairs.js deleted file mode 100644 index f1df201ce..000000000 --- a/action/node_modules/yaml/types/pairs.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.pairs -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/types/set.js b/action/node_modules/yaml/types/set.js deleted file mode 100644 index e7dc9d42c..000000000 --- a/action/node_modules/yaml/types/set.js +++ /dev/null @@ -1,3 +0,0 @@ -const legacy = require('../dist/legacy-exports') -module.exports = legacy.set -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/types/timestamp.js b/action/node_modules/yaml/types/timestamp.js deleted file mode 100644 index 39c5b6dd4..000000000 --- a/action/node_modules/yaml/types/timestamp.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict' -Object.defineProperty(exports, '__esModule', { value: true }) - -const legacy = require('../dist/legacy-exports') -exports.default = [legacy.intTime, legacy.floatTime, legacy.timestamp] -exports.floatTime = legacy.floatTime -exports.intTime = legacy.intTime -exports.timestamp = legacy.timestamp - -legacy.warnFileDeprecation(__filename) diff --git a/action/node_modules/yaml/util.js b/action/node_modules/yaml/util.js deleted file mode 100644 index 06dd2c994..000000000 --- a/action/node_modules/yaml/util.js +++ /dev/null @@ -1,16 +0,0 @@ -const util = require('./dist/util') - -exports.findPair = util.findPair -exports.toJSON = util.toJSON -exports.parseMap = util.parseMap -exports.parseSeq = util.parseSeq - -exports.stringifyNumber = util.stringifyNumber -exports.stringifyString = util.stringifyString -exports.Type = util.Type - -exports.YAMLError = util.YAMLError -exports.YAMLReferenceError = util.YAMLReferenceError -exports.YAMLSemanticError = util.YAMLSemanticError -exports.YAMLSyntaxError = util.YAMLSyntaxError -exports.YAMLWarning = util.YAMLWarning diff --git a/action/node_modules/yaml/util.mjs b/action/node_modules/yaml/util.mjs deleted file mode 100644 index 89e654abe..000000000 --- a/action/node_modules/yaml/util.mjs +++ /dev/null @@ -1,18 +0,0 @@ -import util from './dist/util.js' - -export const findPair = util.findPair -export const toJSON = util.toJSON - -export const parseMap = util.parseMap -export const parseSeq = util.parseSeq - -export const stringifyNumber = util.stringifyNumber -export const stringifyString = util.stringifyString - -export const Type = util.Type - -export const YAMLError = util.YAMLError -export const YAMLReferenceError = util.YAMLReferenceError -export const YAMLSemanticError = util.YAMLSemanticError -export const YAMLSyntaxError = util.YAMLSyntaxError -export const YAMLWarning = util.YAMLWarning diff --git a/action/package.json b/action/package.json index e126cbf55..3d47073bc 100644 --- a/action/package.json +++ b/action/package.json @@ -14,8 +14,8 @@ "@octokit/core": "^4.1.0", "@octokit/plugin-rest-endpoint-methods": "^6.7.0", "@octokit/rest": "^19.0.5", - "cspell": "^6.14.3", - "cspell-glob": "^6.14.3", + "cspell": "^6.15.0", + "cspell-glob": "^6.15.0", "vscode-uri": "^3.0.6" } } diff --git a/yarn.lock b/yarn.lock index addaba3b7..dba4c1215 100644 --- a/yarn.lock +++ b/yarn.lock @@ -322,10 +322,10 @@ resolved "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@cspell/cspell-bundled-dicts@6.14.3": - version "6.14.3" - resolved "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-6.14.3.tgz#6874be5fd8132ea705193cda9fa5c32f5f3effca" - integrity sha512-bgPBduoDi1jkrcLkmAwRG1c6F1iprF2yfBgEDT19dRG1kYuq/fLGNOcSmEp4CbApn8m0MmxsrhEp8O0Q9owQRQ== +"@cspell/cspell-bundled-dicts@6.15.0": + version "6.15.0" + resolved "https://registry.npmjs.org/@cspell/cspell-bundled-dicts/-/cspell-bundled-dicts-6.15.0.tgz#197083c1e9e201e9555d9b8cd448b600c1fbc964" + integrity sha512-Kc9sGeJN3yUiOgFS6LZrdtsONCgsp33PKXxCfDN/7E6iV5b3hbIXR7rjQZ3oS+oJmNGHMtn4CumwY6ogL+s8Iw== dependencies: "@cspell/dict-ada" "^4.0.0" "@cspell/dict-aws" "^3.0.0" @@ -333,7 +333,7 @@ "@cspell/dict-companies" "^3.0.3" "@cspell/dict-cpp" "^4.0.0" "@cspell/dict-cryptocurrencies" "^3.0.1" - "@cspell/dict-csharp" "^4.0.1" + "@cspell/dict-csharp" "^4.0.2" "@cspell/dict-css" "^4.0.0" "@cspell/dict-dart" "^2.0.0" "@cspell/dict-django" "^4.0.0" @@ -370,20 +370,20 @@ "@cspell/dict-typescript" "^3.0.1" "@cspell/dict-vue" "^3.0.0" -"@cspell/cspell-pipe@6.14.3": - version "6.14.3" - resolved "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-6.14.3.tgz#82a19bb56edb605495a3382bbe1069367fe4c42a" - integrity sha512-/mLZxJOK3/UFpnR4jrImKY5W4cn5XWjvQPXnFCEzpU0tAAF6GboJgWl30TegqFJjLVCKTNRMOtT1r6kgvb66zw== +"@cspell/cspell-pipe@6.15.0": + version "6.15.0" + resolved "https://registry.npmjs.org/@cspell/cspell-pipe/-/cspell-pipe-6.15.0.tgz#ca866ba325ae76704db83e5f2ed548e788e4f30a" + integrity sha512-LXEICxtCOJLRBeIHzljLzLakMSz/iusSQF2PbQrBOdh15Xd0BGFuQnlH0PaKqKa3BVgfaKbEjVpYbu68JWzL0w== -"@cspell/cspell-service-bus@6.14.3": - version "6.14.3" - resolved "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-6.14.3.tgz#66bc85981bf99c794c98bac462f63ae65bb8c104" - integrity sha512-89OWGBzhorhiWcFqFTeHl9Y6WTdd5MGC2XNNCVZLM3VTYaFx4DVkiyxWdkE7gHjYxvNdGSH54/fE18TqLc//dQ== +"@cspell/cspell-service-bus@6.15.0": + version "6.15.0" + resolved "https://registry.npmjs.org/@cspell/cspell-service-bus/-/cspell-service-bus-6.15.0.tgz#ff62eab49d561d4a36711e76493a5284aaef534c" + integrity sha512-lFhKcVd2wGL67xT1SVTNmfovNP/Cu5uYVKbKbsTy72XqCpX23daVuFlCZsIY1nxSUh60yAq9mZy7K5BvwFrd9w== -"@cspell/cspell-types@6.14.3": - version "6.14.3" - resolved "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-6.14.3.tgz#b585280fd85927abe301b7f31cbd2a5f521d05d2" - integrity sha512-u4Hun0vOQVkk3tJ6VzPjHVmv2dq0D6jYqX8pWLKWRwo38rdoIkdWseN359sWCz96tDM8g5rpSFdmecbWLU7BYg== +"@cspell/cspell-types@6.15.0": + version "6.15.0" + resolved "https://registry.npmjs.org/@cspell/cspell-types/-/cspell-types-6.15.0.tgz#878553d2729e011359a0a8c12add36d9bbd580e3" + integrity sha512-fS2kV+sV4sfUIy6uQX1H91tZNCWl3nOYfHv1+EI4JnCVnxcFO8EuLgybxUw3w4PbcchyAJaq0Nxa/WxJJnZUyw== "@cspell/dict-ada@^4.0.0": version "4.0.0" @@ -415,7 +415,7 @@ resolved "https://registry.npmjs.org/@cspell/dict-cryptocurrencies/-/dict-cryptocurrencies-3.0.1.tgz#de1c235d6427946b679d23aacff12fea94e6385b" integrity sha512-Tdlr0Ahpp5yxtwM0ukC13V6+uYCI0p9fCRGMGZt36rWv8JQZHIuHfehNl7FB/Qc09NCF7p5ep0GXbL+sVTd/+w== -"@cspell/dict-csharp@^4.0.1": +"@cspell/dict-csharp@^4.0.2": version "4.0.2" resolved "https://registry.npmjs.org/@cspell/dict-csharp/-/dict-csharp-4.0.2.tgz#e55659dbe594e744d86b1baf0f3397fe57b1e283" integrity sha512-1JMofhLK+4p4KairF75D3A924m5ERMgd1GvzhwK2geuYgd2ZKuGW72gvXpIV7aGf52E3Uu1kDXxxGAiZ5uVG7g== @@ -595,10 +595,10 @@ resolved "https://registry.npmjs.org/@cspell/dict-vue/-/dict-vue-3.0.0.tgz#68ccb432ad93fcb0fd665352d075ae9a64ea9250" integrity sha512-niiEMPWPV9IeRBRzZ0TBZmNnkK3olkOPYxC1Ny2AX4TGlYRajcW0WUtoSHmvvjZNfWLSg2L6ruiBeuPSbjnG6A== -"@cspell/strong-weak-map@6.14.3": - version "6.14.3" - resolved "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-6.14.3.tgz#841d2a8a4b6e37aa294f6c50ed09a165308dd93f" - integrity sha512-/FTvcywuwfFTMEpRabL8+rqB/ezSjvMp6todO0SwL/agYQmRIuTvTYLh0Ikq430oVnjo7LDgztW0tHq38UlFLw== +"@cspell/strong-weak-map@6.15.0": + version "6.15.0" + resolved "https://registry.npmjs.org/@cspell/strong-weak-map/-/strong-weak-map-6.15.0.tgz#0e9c6265f589e3eaaad3626076e0eb4edfb1d40b" + integrity sha512-OqeqapBKdtkwazBXzlRj42niJBFAveoZSC9M0/gCJ0TVWEURuOFUKRm+LprOMy+Kc0MTUEIIJ0wbpMZNclR6Lw== "@eslint/eslintrc@^1.3.3": version "1.3.3" @@ -1271,11 +1271,6 @@ resolved "https://registry.npmjs.org/@types/node/-/node-18.11.9.tgz#02d013de7058cea16d36168ef2fc653464cfbad4" integrity sha512-CRpX21/kGdzjOpFsZSkcrXMGIBWMGNIHXXBVFSH+ggkftxg+XYP20TESbh+zFvFj3EQOl5byk0HTRn1IL6hbqg== -"@types/parse-json@^4.0.0": - version "4.0.0" - resolved "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0" - integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA== - "@types/prettier@^2.1.5": version "2.7.1" resolved "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.1.tgz#dfd20e2dc35f027cdd6c1908e80a5ddc7499670e" @@ -1842,16 +1837,15 @@ cors@^2.8.5: object-assign "^4" vary "^1" -cosmiconfig@^7.1.0: - version "7.1.0" - resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" - integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== +cosmiconfig@^8.0.0: + version "8.0.0" + resolved "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-8.0.0.tgz#e9feae014eab580f858f8a0288f38997a7bebe97" + integrity sha512-da1EafcpH6b/TD8vDRaWV7xFINlHlF6zKsGwS1TsuVJTZRkquaS5HTMq7uq6h31619QjbsYl21gVDOm32KM1vQ== dependencies: - "@types/parse-json" "^4.0.0" import-fresh "^3.2.1" + js-yaml "^4.1.0" parse-json "^5.0.0" path-type "^4.0.0" - yaml "^1.10.0" cross-spawn@^7.0.0, cross-spawn@^7.0.2, cross-spawn@^7.0.3: version "7.0.3" @@ -1867,66 +1861,66 @@ crypto-random-string@^2.0.0: resolved "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-2.0.0.tgz#ef2a7a966ec11083388369baa02ebead229b30d5" integrity sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA== -cspell-dictionary@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-6.14.3.tgz#d583feff383414128471a2ca3571e64077e0edc0" - integrity sha512-yIqJEZZj36j1CmmjAiuQOYZM6T62Ih7k35DhAU1hYVARUEEnFN/Uz72UkDj2SAmURVn2On+bAmZ5zCx0JZzf2g== +cspell-dictionary@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-dictionary/-/cspell-dictionary-6.15.0.tgz#7da35a82778848c05d68a80fc6f041f0415eae34" + integrity sha512-DX5MmXq+uPLdqKhOdYMFx0sLNawOakZwnXOI+UJ1T1joQMjiuiAxjmIzj2+iMFRZ4RgwjUhAu/FJ0FWJp4ev1A== dependencies: - "@cspell/cspell-pipe" "6.14.3" - "@cspell/cspell-types" "6.14.3" - cspell-trie-lib "6.14.3" + "@cspell/cspell-pipe" "6.15.0" + "@cspell/cspell-types" "6.15.0" + cspell-trie-lib "6.15.0" fast-equals "^4.0.3" gensequence "^4.0.2" -cspell-gitignore@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-6.14.3.tgz#ff008cf4d9a9ba358eb831120d4aef6e101fd6fd" - integrity sha512-CZTGxx3msF6p1Z0xgLe5LXXvve7DooSuRMBMdGn230usce1nKoxpPoPxgs+zXeCpi+FanykKnoZkdRvjolMpOA== +cspell-gitignore@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-gitignore/-/cspell-gitignore-6.15.0.tgz#805a0f8977c3fa031f2418170eaeab39ccc14a31" + integrity sha512-d+mzVtZBq/HRxYyXW6nfptnefyjIhV+goM5cTY/1Fg9tN+wfhn0g1pd9IU72BWmmlQGUBXrJzCSqgZYU9PZmRw== dependencies: - cspell-glob "6.14.3" + cspell-glob "6.15.0" find-up "^5.0.0" -cspell-glob@6.14.3, cspell-glob@^6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-glob/-/cspell-glob-6.14.3.tgz#840755d527907e262d204cad4b36482ce96df00f" - integrity sha512-ISwCK8GqM/dnvtaxA17w1MPmMzFLOqdTz+JWIcR4at47T9qd8bNB0X0P4eqyuqgsbKkWbfnSlsYlEjRHTi4a7A== +cspell-glob@6.15.0, cspell-glob@^6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-glob/-/cspell-glob-6.15.0.tgz#b2b0ed539fa84a9a9c7875cfd5adfc482f4e9748" + integrity sha512-FJ/aG/FKJ2qEZgO2wLFWJk3ljAA/HAYsXBq3Z6l8bUyYlkAjBwuToZCM6VE0owcRRCUr+onYNBKX1m1weDgAkQ== dependencies: micromatch "^4.0.5" -cspell-grammar@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-6.14.3.tgz#7ddcada41b6e80176b178e7fbbf74859b440eb26" - integrity sha512-Nz8tYUmstyKcFlXbxdw4N8NsQ2ZY/5ztNfouokk47LKaTAS0LyWlLSkZUxN016fMY2h+C+3dI+jaut2H/rtNew== +cspell-grammar@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-grammar/-/cspell-grammar-6.15.0.tgz#286d9ac862485d0f4fda385fc010c75c9dffaf90" + integrity sha512-inpGd+tqtvHVr1fX5Zx/VgSXWPRatvoaQgq3uI7a4JAXJmNLjOF4+l8g0ylIVFhZBIPLazFOr9bm35NjVpk5GA== dependencies: - "@cspell/cspell-pipe" "6.14.3" - "@cspell/cspell-types" "6.14.3" + "@cspell/cspell-pipe" "6.15.0" + "@cspell/cspell-types" "6.15.0" -cspell-io@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-io/-/cspell-io-6.14.3.tgz#2bd1bf11900c0b24fa9a8471b2531a019da576ad" - integrity sha512-EbH+qopgWIzr9SZCGDsF4AWYgucN4QzYeAgyXjTbV9RnNIGKOKovMe3vN9nxjOZyPKv2TvmgU+uMXDM61iObRw== +cspell-io@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-io/-/cspell-io-6.15.0.tgz#7bf64ea8d087a38fad850a121ade7c1caa89608e" + integrity sha512-rZIHcxV3bUZCqqJN1oesdN1Sk/bulGifHZ+3b4l/xHOW0PZwDyvOry/Xu41f5DGIfBoiNeYUmeS78klDA5yODQ== dependencies: - "@cspell/cspell-service-bus" "6.14.3" + "@cspell/cspell-service-bus" "6.15.0" node-fetch "^2.6.7" -cspell-lib@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-lib/-/cspell-lib-6.14.3.tgz#dc21b618719b131721a19487e6b553d4fab01078" - integrity sha512-RJT5Tbe0UCMCtqDWRujjxq9u23sc2XylIpDP7MnpLx8wLVgFv2WPzESYNRGZqceqZYwBAPnpqS9h2ANxXSi8UQ== +cspell-lib@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-lib/-/cspell-lib-6.15.0.tgz#bb2881367650b398fbd29a77b2bb4e7122344734" + integrity sha512-cjNiCKJ1SuCzvPrw3msZKy3qRztJhj2brvyCEjVKJs/FwzoMQBtGBlUVitRyfmx5TPdJsSWPdr/YbmMltBbAGQ== dependencies: - "@cspell/cspell-bundled-dicts" "6.14.3" - "@cspell/cspell-pipe" "6.14.3" - "@cspell/cspell-types" "6.14.3" - "@cspell/strong-weak-map" "6.14.3" + "@cspell/cspell-bundled-dicts" "6.15.0" + "@cspell/cspell-pipe" "6.15.0" + "@cspell/cspell-types" "6.15.0" + "@cspell/strong-weak-map" "6.15.0" clear-module "^4.1.2" comment-json "^4.2.3" configstore "^5.0.1" - cosmiconfig "^7.1.0" - cspell-dictionary "6.14.3" - cspell-glob "6.14.3" - cspell-grammar "6.14.3" - cspell-io "6.14.3" - cspell-trie-lib "6.14.3" + cosmiconfig "^8.0.0" + cspell-dictionary "6.15.0" + cspell-glob "6.15.0" + cspell-grammar "6.15.0" + cspell-io "6.15.0" + cspell-trie-lib "6.15.0" fast-equals "^4.0.3" find-up "^5.0.0" fs-extra "^10.1.0" @@ -1937,27 +1931,27 @@ cspell-lib@6.14.3: vscode-languageserver-textdocument "^1.0.7" vscode-uri "^3.0.6" -cspell-trie-lib@6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-6.14.3.tgz#2725856d0ca33b641f82c34705cb8f1bf7151eb3" - integrity sha512-WVa5gbD9glsZ4c60qPD5RTwojKc5ooxw/Gn+HC9CBdWv5rE1AmM1V3yVWhYx2ZMbJufboBrzmSjJB9qdmUl3oA== +cspell-trie-lib@6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell-trie-lib/-/cspell-trie-lib-6.15.0.tgz#39533f636b8460d03b3d0103ff4693c5d5bda683" + integrity sha512-d4+F3pNGv50MHj6Skb8/yTPCQyKbVYfERryClM3QnpSpvXGP7VAUHTNHJocR/UTAI5Gs1KdbbU+S9aCAZsZ9lQ== dependencies: - "@cspell/cspell-pipe" "6.14.3" - "@cspell/cspell-types" "6.14.3" + "@cspell/cspell-pipe" "6.15.0" + "@cspell/cspell-types" "6.15.0" fs-extra "^10.1.0" gensequence "^4.0.2" -cspell@^6.14.3: - version "6.14.3" - resolved "https://registry.npmjs.org/cspell/-/cspell-6.14.3.tgz#fc3bb5e32cfa633e31a7f21b4213c3b6ee0b584f" - integrity sha512-DimVpUiw2iOSvO1daOTtOWjmryVZdFnPmjPhyhWZUqakOEgE2MgoBuk3cFzXqb8GsGXHQh5PqiWr1rqIkQ99qA== +cspell@^6.15.0: + version "6.15.0" + resolved "https://registry.npmjs.org/cspell/-/cspell-6.15.0.tgz#bf846fe8af10d12b31578c8f9b6f0c44d92710b5" + integrity sha512-8Nx2nKHi45GQshDbxQcB9xZjNrMwWnL2D4i5w8vA1WffAhLZpgE7zmudjyELPfhhvOEd0hspY8lh79lZSLtvrg== dependencies: - "@cspell/cspell-pipe" "6.14.3" + "@cspell/cspell-pipe" "6.15.0" chalk "^4.1.2" commander "^9.4.1" - cspell-gitignore "6.14.3" - cspell-glob "6.14.3" - cspell-lib "6.14.3" + cspell-gitignore "6.15.0" + cspell-glob "6.15.0" + cspell-lib "6.15.0" fast-json-stable-stringify "^2.1.0" file-entry-cache "^6.0.1" fs-extra "^10.1.0" @@ -4260,11 +4254,6 @@ yallist@^4.0.0: resolved "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== -yaml@^1.10.0: - version "1.10.2" - resolved "https://registry.npmjs.org/yaml/-/yaml-1.10.2.tgz#2301c5ffbf12b467de8da2333a459e29e7920e4b" - integrity sha512-r3vXyErRCYJ7wg28yvBY5VSoAF8ZvlcW9/BwUzEtUsjvX/DKs24dIkuwjtuprwJJHsbyUbLApepYTR1BN4uHrg== - yargs-parser@^21.0.1, yargs-parser@^21.1.1: version "21.1.1" resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35"