diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d1c49a97..143eb387 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,13 +1,43 @@ +name: pypi-publish + +on: push + jobs: - pypi-publish: - name: upload release to PyPI + build: + name: Build distribution runs-on: ubuntu-latest - # Specifying a GitHub environment is optional, but strongly encouraged - environment: release - permissions: - # IMPORTANT: this permission is mandatory for trusted publishing - id-token: write steps: # retrieve your distributions here - - name: Publish package distributions to PyPI + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.x" + - name: Install required packages + run: pip install setuptools zenodo_get + - name: Build a source tarball + run: python3 setup.py sdist + - name: Upload all the dists + uses: actions/upload-artifact@v4 + with: + name: python-package-distributions + path: dist/ + + publish-to-pypi: + name: Publish to PyPI + needs: + - build + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/pymoog # Replace with your PyPI project name + permissions: + id-token: write # IMPORTANT: mandatory for trusted publishing + steps: + - name: Download all the dists + uses: actions/download-artifact@v4 + with: + name: python-package-distributions + path: dist/ + - name: Publish distribution to PyPI uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index bf42633c..a4e743b1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,4 @@ __pycache__/ docs/_build/ build/ *.pyc -dist/ node_modeules/ \ No newline at end of file diff --git a/dist/pymoog-0.1.3.tar.gz b/dist/pymoog-0.1.3.tar.gz new file mode 100644 index 00000000..8570f1e4 Binary files /dev/null and b/dist/pymoog-0.1.3.tar.gz differ diff --git a/dist/pymoog-0.0.1.tar.gz b/dist_old/pymoog-0.0.1.tar.gz similarity index 100% rename from dist/pymoog-0.0.1.tar.gz rename to dist_old/pymoog-0.0.1.tar.gz diff --git a/dist/pymoog-0.0.2.tar.gz b/dist_old/pymoog-0.0.2.tar.gz similarity index 100% rename from dist/pymoog-0.0.2.tar.gz rename to dist_old/pymoog-0.0.2.tar.gz diff --git a/dist_old/pymoog-0.1.1.tar.gz b/dist_old/pymoog-0.1.1.tar.gz new file mode 100644 index 00000000..6cc1590b Binary files /dev/null and b/dist_old/pymoog-0.1.1.tar.gz differ diff --git a/dist_old/pymoog-0.1.2.tar.gz b/dist_old/pymoog-0.1.2.tar.gz new file mode 100644 index 00000000..026360b9 Binary files /dev/null and b/dist_old/pymoog-0.1.2.tar.gz differ diff --git a/node_modules/commitizen/dist/cli/commitizen.js b/node_modules/commitizen/dist/cli/commitizen.js new file mode 100644 index 00000000..21520b94 --- /dev/null +++ b/node_modules/commitizen/dist/cli/commitizen.js @@ -0,0 +1,89 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.bootstrap = bootstrap; + +var _commitizen = require("../commitizen"); + +var _parsers = require("./parsers"); + +let { + parse +} = _parsers.commitizen; + +/** + * This is the main cli entry point. + * environment may be used for debugging. + */ +function bootstrap(environment = {}, argv = process.argv) { + // Get cli args + let rawGitArgs = argv.slice(2, argv.length); // Parse the args + + let parsedArgs = parse(rawGitArgs); + let command = parsedArgs._[0]; // Do actions based on commands + + if (command === "init") { + let adapterNpmName = parsedArgs._[1]; + + if (adapterNpmName) { + console.log(`Attempting to initialize using the npm package ${adapterNpmName}`); + + try { + (0, _commitizen.init)(process.cwd(), adapterNpmName, parsedArgs); + } catch (e) { + console.error(`Error: ${e}`); + } + } else { + console.error('Error: You must provide an adapter name as the second argument.'); + } + } else { + console.log(` + + Commitizen has two command line tools: + + 1) commitizen -- used for installing adapters into your project + 2) git-cz -- used for making commits according to convention + note: you can run 'git cz' if installed with -g + + Generally if you're using someone else's repo and they've already set up an + adapter, you're going to just be running: + + git-cz + + However, if you create a new repo and you want to make it easier for future + contributors to follow your commit message conventions using commitizen then + you'll need to run a command like this one to add this adapter to your config: + + commitizen init cz-conventional-changelog --save + + You should swap out cz-conventional-changelog for the NPM package name of the + adapter you wish you install in your project's package.json. + + Detailed usage: + + 1) commitizen + + init [args] + + description: Install a commitizen adapter from npm and adds it to your + config.commitizen in your package.json file. + + args: + --save Install the adapter to package.json dependencies + --save-dev Install the adapter to devDependencies + --save-exact Install an exact version instead of a range + --force Force install the adapter, even if a previous one exists. + + 2) git-cz + + description: Runs the commitizen prompter, asking you questions so that you + follow the commit conventions of the repository of the current + directory. + + note: git-cz may even be run as 'git cz' if installed with -g. + + `); + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/git-cz.js b/node_modules/commitizen/dist/cli/git-cz.js new file mode 100644 index 00000000..c800b271 --- /dev/null +++ b/node_modules/commitizen/dist/cli/git-cz.js @@ -0,0 +1,30 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.bootstrap = bootstrap; + +var _commitizen = require("../commitizen"); + +var _strategies = require("./strategies"); + +/** + * This is the main cli entry point. + * environment may be used for debugging. + */ +function bootstrap(environment = {}, argv = process.argv) { + // Get cli args + let rawGitArgs = argv.slice(2, argv.length); + + let adapterConfig = environment.config || _commitizen.configLoader.load(); // Choose a strategy based on the existance the adapter config + + + if (typeof adapterConfig !== 'undefined') { + // This tells commitizen we're in business + (0, _strategies.gitCz)(rawGitArgs, environment, adapterConfig); + } else { + // This tells commitizen that it is not needed, just use git + (0, _strategies.git)(rawGitArgs, environment); + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/parsers.js b/node_modules/commitizen/dist/cli/parsers.js new file mode 100644 index 00000000..0395b467 --- /dev/null +++ b/node_modules/commitizen/dist/cli/parsers.js @@ -0,0 +1,16 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.gitCz = exports.commitizen = void 0; + +var commitizen = _interopRequireWildcard(require("./parsers/commitizen")); + +exports.commitizen = commitizen; + +var gitCz = _interopRequireWildcard(require("./parsers/git-cz")); + +exports.gitCz = gitCz; + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/parsers/commitizen.js b/node_modules/commitizen/dist/cli/parsers/commitizen.js new file mode 100644 index 00000000..9a7f1431 --- /dev/null +++ b/node_modules/commitizen/dist/cli/parsers/commitizen.js @@ -0,0 +1,22 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.parse = parse; + +var _minimist = _interopRequireDefault(require("minimist")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Takes args, parses with minimist and some ugly vudoo, returns output + * + * TODO: Aww shit this is ugly. Rewrite with mega leet tests plz, kthnx. + */ +function parse(rawGitArgs) { + var args = (0, _minimist.default)(rawGitArgs, { + boolean: true + }); + return args; +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/parsers/git-cz.js b/node_modules/commitizen/dist/cli/parsers/git-cz.js new file mode 100644 index 00000000..12c247d6 --- /dev/null +++ b/node_modules/commitizen/dist/cli/parsers/git-cz.js @@ -0,0 +1,53 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.parse = parse; +const reShortMessage = /^-([a-zA-Z]*)m(.*)$/; +const reLongMessage = /^--message(=.*)?$/; +/** + * Strip message declaration from git arguments + */ + +function parse(rawGitArgs) { + let result = []; + let skipNext = false; + + for (const arg of rawGitArgs) { + let match; + + if (skipNext) { + skipNext = false; + continue; + } + + match = reShortMessage.exec(arg); + + if (match) { + if (match[1]) { + result.push(`-${match[1]}`); + } + + if (!match[2]) { + skipNext = true; + } + + continue; + } + + match = reLongMessage.exec(arg); + + if (match) { + if (!match[1]) { + skipNext = true; + } + + continue; + } + + result.push(arg); + } + + return result; +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/strategies.js b/node_modules/commitizen/dist/cli/strategies.js new file mode 100644 index 00000000..a7562013 --- /dev/null +++ b/node_modules/commitizen/dist/cli/strategies.js @@ -0,0 +1,23 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "git", { + enumerable: true, + get: function () { + return _git.default; + } +}); +Object.defineProperty(exports, "gitCz", { + enumerable: true, + get: function () { + return _gitCz.default; + } +}); + +var _git = _interopRequireDefault(require("./strategies/git")); + +var _gitCz = _interopRequireDefault(require("./strategies/git-cz")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/strategies/git-cz.js b/node_modules/commitizen/dist/cli/strategies/git-cz.js new file mode 100644 index 00000000..d1ba2d11 --- /dev/null +++ b/node_modules/commitizen/dist/cli/strategies/git-cz.js @@ -0,0 +1,87 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _inquirer = _interopRequireDefault(require("inquirer")); + +var _findRoot = _interopRequireDefault(require("find-root")); + +var _util = require("../../common/util"); + +var _parsers = require("../parsers"); + +var _commitizen = require("../../commitizen"); + +var gitStrategy = _interopRequireWildcard(require("./git")); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// destructure for shorter apis +let { + parse +} = _parsers.gitCz; +let { + getPrompter, + resolveAdapterPath +} = _commitizen.adapter; +let { + isClean +} = _commitizen.staging; +var _default = gitCz; +exports.default = _default; + +function gitCz(rawGitArgs, environment, adapterConfig) { + // See if any override conditions exist. + // In these very specific scenarios we may want to use a different + // commit strategy than git-cz. For example, in the case of --amend + let parsedCommitizenArgs = _parsers.commitizen.parse(rawGitArgs); + + if (parsedCommitizenArgs.amend) { + // console.log('override --amend in place'); + gitStrategy.default(rawGitArgs, environment); + return; + } // Now, if we've made it past overrides, proceed with the git-cz strategy + + + let parsedGitCzArgs = parse(rawGitArgs); // Determine if we need to process this commit as a retry instead of a + // normal commit. + + let retryLastCommit = rawGitArgs && rawGitArgs[0] === '--retry'; // Determine if we need to process this commit using interactive hook mode + // for husky prepare-commit-message + + let hookMode = !(typeof parsedCommitizenArgs.hook === 'undefined'); + let resolvedAdapterConfigPath = resolveAdapterPath(adapterConfig.path); + let resolvedAdapterRootPath = (0, _findRoot.default)(resolvedAdapterConfigPath); + let prompter = getPrompter(adapterConfig.path); + isClean(process.cwd(), function (error, stagingIsClean) { + if (error) { + throw error; + } + + if (stagingIsClean && !parsedGitCzArgs.includes('--allow-empty')) { + throw new Error('No files added to staging! Did you forget to run git add?'); + } // OH GOD IM SORRY FOR THIS SECTION + + + let adapterPackageJson = (0, _util.getParsedPackageJsonFromPath)(resolvedAdapterRootPath); + let cliPackageJson = (0, _util.getParsedPackageJsonFromPath)(environment.cliPath); + console.log(`cz-cli@${cliPackageJson.version}, ${adapterPackageJson.name}@${adapterPackageJson.version}\n`); + (0, _commitizen.commit)(_inquirer.default, process.cwd(), prompter, { + args: parsedGitCzArgs, + disableAppendPaths: true, + emitData: true, + quiet: false, + retryLastCommit, + hookMode + }, function (error) { + if (error) { + throw error; + } + }); + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/cli/strategies/git.js b/node_modules/commitizen/dist/cli/strategies/git.js new file mode 100644 index 00000000..7b5eb942 --- /dev/null +++ b/node_modules/commitizen/dist/cli/strategies/git.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _child_process = _interopRequireDefault(require("child_process")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = git; // We don't have a config, so either we use raw args to try to commit +// or if debug is enabled then we do a strict check for a config file. + +exports.default = _default; + +function git(rawGitArgs, environment) { + if (environment.debug === true) { + console.error('COMMITIZEN DEBUG: No git-cz friendly config was detected. I looked for .czrc, .cz.json, or czConfig in package.json.'); + } else { + var vanillaGitArgs = ["commit"].concat(rawGitArgs); + + var child = _child_process.default.spawn('git', vanillaGitArgs, { + stdio: 'inherit' + }); + + child.on('error', function (e, code) { + console.error(e); + throw e; + }); + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen.js b/node_modules/commitizen/dist/commitizen.js new file mode 100644 index 00000000..25cd0da2 --- /dev/null +++ b/node_modules/commitizen/dist/commitizen.js @@ -0,0 +1,42 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "commit", { + enumerable: true, + get: function () { + return _commit.default; + } +}); +Object.defineProperty(exports, "init", { + enumerable: true, + get: function () { + return _init.default; + } +}); +exports.staging = exports.configLoader = exports.cache = exports.adapter = void 0; + +var adapter = _interopRequireWildcard(require("./commitizen/adapter")); + +exports.adapter = adapter; + +var cache = _interopRequireWildcard(require("./commitizen/cache")); + +exports.cache = cache; + +var _commit = _interopRequireDefault(require("./commitizen/commit")); + +var configLoader = _interopRequireWildcard(require("./commitizen/configLoader")); + +exports.configLoader = configLoader; + +var _init = _interopRequireDefault(require("./commitizen/init")); + +var staging = _interopRequireWildcard(require("./commitizen/staging")); + +exports.staging = staging; + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/adapter.js b/node_modules/commitizen/dist/commitizen/adapter.js new file mode 100644 index 00000000..e09ee7cc --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/adapter.js @@ -0,0 +1,1435 @@ +"use strict"; + +var cov_8emx7ww64 = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/adapter.js"; + var hash = "0e2eb6a3ba3ae63c400df0a46a58dce2c73634fa"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/adapter.js", + statementMap: { + "0": { + start: { + line: 37, + column: 32 + }, + end: { + line: 43, + column: 3 + } + }, + "1": { + start: { + line: 45, + column: 24 + }, + end: { + line: 45, + column: 91 + } + }, + "2": { + start: { + line: 46, + column: 26 + }, + end: { + line: 46, + column: 67 + } + }, + "3": { + start: { + line: 48, + column: 15 + }, + end: { + line: 48, + column: 61 + } + }, + "4": { + start: { + line: 49, + column: 27 + }, + end: { + line: 49, + column: 56 + } + }, + "5": { + start: { + line: 50, + column: 30 + }, + end: { + line: 50, + column: 32 + } + }, + "6": { + start: { + line: 51, + column: 2 + }, + end: { + line: 53, + column: 3 + } + }, + "7": { + start: { + line: 52, + column: 4 + }, + end: { + line: 52, + column: 81 + } + }, + "8": { + start: { + line: 54, + column: 2 + }, + end: { + line: 54, + column: 96 + } + }, + "9": { + start: { + line: 63, + column: 30 + }, + end: { + line: 63, + column: 61 + } + }, + "10": { + start: { + line: 66, + column: 2 + }, + end: { + line: 70, + column: 3 + } + }, + "11": { + start: { + line: 67, + column: 4 + }, + end: { + line: 69, + column: 5 + } + }, + "12": { + start: { + line: 68, + column: 6 + }, + end: { + line: 68, + column: 66 + } + }, + "13": { + start: { + line: 72, + column: 2 + }, + end: { + line: 72, + column: 31 + } + }, + "14": { + start: { + line: 81, + column: 30 + }, + end: { + line: 81, + column: 58 + } + }, + "15": { + start: { + line: 84, + column: 2 + }, + end: { + line: 88, + column: 3 + } + }, + "16": { + start: { + line: 85, + column: 4 + }, + end: { + line: 87, + column: 5 + } + }, + "17": { + start: { + line: 86, + column: 6 + }, + end: { + line: 86, + column: 66 + } + }, + "18": { + start: { + line: 90, + column: 2 + }, + end: { + line: 90, + column: 31 + } + }, + "19": { + start: { + line: 99, + column: 31 + }, + end: { + line: 99, + column: 55 + } + }, + "20": { + start: { + line: 104, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }, + "21": { + start: { + line: 105, + column: 4 + }, + end: { + line: 105, + column: 37 + } + }, + "22": { + start: { + line: 115, + column: 2 + }, + end: { + line: 115, + column: 78 + } + }, + "23": { + start: { + line: 122, + column: 2 + }, + end: { + line: 126, + column: 49 + } + }, + "24": { + start: { + line: 133, + column: 2 + }, + end: { + line: 136, + column: 49 + } + }, + "25": { + start: { + line: 144, + column: 28 + }, + end: { + line: 144, + column: 59 + } + }, + "26": { + start: { + line: 147, + column: 16 + }, + end: { + line: 147, + column: 44 + } + }, + "27": { + start: { + line: 165, + column: 15 + }, + end: { + line: 165, + column: 45 + } + }, + "28": { + start: { + line: 166, + column: 15 + }, + end: { + line: 166, + column: 68 + } + }, + "29": { + start: { + line: 169, + column: 28 + }, + end: { + line: 171, + column: 22 + } + }, + "30": { + start: { + line: 173, + column: 2 + }, + end: { + line: 179, + column: 3 + } + }, + "31": { + start: { + line: 175, + column: 4 + }, + end: { + line: 175, + column: 48 + } + }, + "32": { + start: { + line: 177, + column: 4 + }, + end: { + line: 177, + column: 86 + } + }, + "33": { + start: { + line: 178, + column: 4 + }, + end: { + line: 178, + column: 16 + } + }, + "34": { + start: { + line: 183, + column: 2 + }, + end: { + line: 183, + column: 109 + } + } + }, + fnMap: { + "0": { + name: "addPathToAdapterConfig", + decl: { + start: { + line: 35, + column: 9 + }, + end: { + line: 35, + column: 31 + } + }, + loc: { + start: { + line: 35, + column: 68 + }, + end: { + line: 55, + column: 1 + } + }, + line: 35 + }, + "1": { + name: "generateNpmInstallAdapterCommand", + decl: { + start: { + line: 60, + column: 9 + }, + end: { + line: 60, + column: 41 + } + }, + loc: { + start: { + line: 60, + column: 75 + }, + end: { + line: 73, + column: 1 + } + }, + line: 60 + }, + "2": { + name: "generateYarnAddAdapterCommand", + decl: { + start: { + line: 78, + column: 9 + }, + end: { + line: 78, + column: 38 + } + }, + loc: { + start: { + line: 78, + column: 72 + }, + end: { + line: 91, + column: 1 + } + }, + line: 78 + }, + "3": { + name: "getNearestNodeModulesDirectory", + decl: { + start: { + line: 96, + column: 9 + }, + end: { + line: 96, + column: 39 + } + }, + loc: { + start: { + line: 96, + column: 50 + }, + end: { + line: 109, + column: 1 + } + }, + line: 96 + }, + "4": { + name: "getNearestProjectRootDirectory", + decl: { + start: { + line: 114, + column: 9 + }, + end: { + line: 114, + column: 39 + } + }, + loc: { + start: { + line: 114, + column: 60 + }, + end: { + line: 116, + column: 1 + } + }, + line: 114 + }, + "5": { + name: "getNpmInstallStringMappings", + decl: { + start: { + line: 121, + column: 9 + }, + end: { + line: 121, + column: 36 + } + }, + loc: { + start: { + line: 121, + column: 71 + }, + end: { + line: 127, + column: 1 + } + }, + line: 121 + }, + "6": { + name: "getYarnAddStringMappings", + decl: { + start: { + line: 132, + column: 9 + }, + end: { + line: 132, + column: 33 + } + }, + loc: { + start: { + line: 132, + column: 54 + }, + end: { + line: 137, + column: 1 + } + }, + line: 132 + }, + "7": { + name: "getPrompter", + decl: { + start: { + line: 142, + column: 9 + }, + end: { + line: 142, + column: 20 + } + }, + loc: { + start: { + line: 142, + column: 35 + }, + end: { + line: 157, + column: 1 + } + }, + line: 142 + }, + "8": { + name: "resolveAdapterPath", + decl: { + start: { + line: 163, + column: 9 + }, + end: { + line: 163, + column: 27 + } + }, + loc: { + start: { + line: 163, + column: 49 + }, + end: { + line: 180, + column: 1 + } + }, + line: 163 + }, + "9": { + name: "getGitRootPath", + decl: { + start: { + line: 182, + column: 9 + }, + end: { + line: 182, + column: 23 + } + }, + loc: { + start: { + line: 182, + column: 27 + }, + end: { + line: 184, + column: 1 + } + }, + line: 182 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 48, + column: 15 + }, + end: { + line: 48, + column: 61 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 48, + column: 15 + }, + end: { + line: 48, + column: 53 + } + }, { + start: { + line: 48, + column: 57 + }, + end: { + line: 48, + column: 61 + } + }], + line: 48 + }, + "1": { + loc: { + start: { + line: 51, + column: 2 + }, + end: { + line: 53, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 51, + column: 2 + }, + end: { + line: 53, + column: 3 + } + }, { + start: { + line: 51, + column: 2 + }, + end: { + line: 53, + column: 3 + } + }], + line: 51 + }, + "2": { + loc: { + start: { + line: 67, + column: 4 + }, + end: { + line: 69, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 67, + column: 4 + }, + end: { + line: 69, + column: 5 + } + }, { + start: { + line: 67, + column: 4 + }, + end: { + line: 69, + column: 5 + } + }], + line: 67 + }, + "3": { + loc: { + start: { + line: 85, + column: 4 + }, + end: { + line: 87, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 85, + column: 4 + }, + end: { + line: 87, + column: 5 + } + }, { + start: { + line: 85, + column: 4 + }, + end: { + line: 87, + column: 5 + } + }], + line: 85 + }, + "4": { + loc: { + start: { + line: 104, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 104, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }], + line: 104 + }, + "5": { + loc: { + start: { + line: 104, + column: 6 + }, + end: { + line: 104, + column: 65 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 104, + column: 6 + }, + end: { + line: 104, + column: 28 + } + }, { + start: { + line: 104, + column: 32 + }, + end: { + line: 104, + column: 65 + } + }], + line: 104 + }, + "6": { + loc: { + start: { + line: 123, + column: 17 + }, + end: { + line: 123, + column: 58 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 123, + column: 38 + }, + end: { + line: 123, + column: 46 + } + }, { + start: { + line: 123, + column: 49 + }, + end: { + line: 123, + column: 58 + } + }], + line: 123 + }, + "7": { + loc: { + start: { + line: 123, + column: 18 + }, + end: { + line: 123, + column: 34 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 123, + column: 18 + }, + end: { + line: 123, + column: 22 + } + }, { + start: { + line: 123, + column: 26 + }, + end: { + line: 123, + column: 34 + } + }], + line: 123 + }, + "8": { + loc: { + start: { + line: 124, + column: 20 + }, + end: { + line: 124, + column: 54 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 124, + column: 30 + }, + end: { + line: 124, + column: 42 + } + }, { + start: { + line: 124, + column: 45 + }, + end: { + line: 124, + column: 54 + } + }], + line: 124 + }, + "9": { + loc: { + start: { + line: 125, + column: 22 + }, + end: { + line: 125, + column: 60 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 125, + column: 34 + }, + end: { + line: 125, + column: 48 + } + }, { + start: { + line: 125, + column: 51 + }, + end: { + line: 125, + column: 60 + } + }], + line: 125 + }, + "10": { + loc: { + start: { + line: 126, + column: 18 + }, + end: { + line: 126, + column: 47 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 126, + column: 26 + }, + end: { + line: 126, + column: 35 + } + }, { + start: { + line: 126, + column: 38 + }, + end: { + line: 126, + column: 47 + } + }], + line: 126 + }, + "11": { + loc: { + start: { + line: 134, + column: 16 + }, + end: { + line: 134, + column: 41 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 134, + column: 22 + }, + end: { + line: 134, + column: 29 + } + }, { + start: { + line: 134, + column: 32 + }, + end: { + line: 134, + column: 41 + } + }], + line: 134 + }, + "12": { + loc: { + start: { + line: 135, + column: 18 + }, + end: { + line: 135, + column: 47 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 135, + column: 26 + }, + end: { + line: 135, + column: 35 + } + }, { + start: { + line: 135, + column: 38 + }, + end: { + line: 135, + column: 47 + } + }], + line: 135 + }, + "13": { + loc: { + start: { + line: 136, + column: 18 + }, + end: { + line: 136, + column: 47 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 136, + column: 26 + }, + end: { + line: 136, + column: 35 + } + }, { + start: { + line: 136, + column: 38 + }, + end: { + line: 136, + column: 47 + } + }], + line: 136 + }, + "14": { + loc: { + start: { + line: 166, + column: 15 + }, + end: { + line: 166, + column: 68 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 166, + column: 15 + }, + end: { + line: 166, + column: 36 + } + }, { + start: { + line: 166, + column: 40 + }, + end: { + line: 166, + column: 68 + } + }], + line: 166 + }, + "15": { + loc: { + start: { + line: 169, + column: 28 + }, + end: { + line: 171, + column: 22 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 170, + column: 4 + }, + end: { + line: 170, + column: 54 + } + }, { + start: { + line: 171, + column: 4 + }, + end: { + line: 171, + column: 22 + } + }], + line: 169 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0, + "12": 0, + "13": 0, + "14": 0, + "15": 0, + "16": 0, + "17": 0, + "18": 0, + "19": 0, + "20": 0, + "21": 0, + "22": 0, + "23": 0, + "24": 0, + "25": 0, + "26": 0, + "27": 0, + "28": 0, + "29": 0, + "30": 0, + "31": 0, + "32": 0, + "33": 0, + "34": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0], + "4": [0], + "5": [0, 0], + "6": [0, 0], + "7": [0, 0], + "8": [0, 0], + "9": [0, 0], + "10": [0, 0], + "11": [0, 0], + "12": [0, 0], + "13": [0, 0], + "14": [0, 0], + "15": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "0e2eb6a3ba3ae63c400df0a46a58dce2c73634fa" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.addPathToAdapterConfig = addPathToAdapterConfig; +exports.getNearestNodeModulesDirectory = getNearestNodeModulesDirectory; +exports.getNearestProjectRootDirectory = getNearestProjectRootDirectory; +exports.getNpmInstallStringMappings = getNpmInstallStringMappings; +exports.getPrompter = getPrompter; +exports.generateNpmInstallAdapterCommand = generateNpmInstallAdapterCommand; +exports.resolveAdapterPath = resolveAdapterPath; +exports.getYarnAddStringMappings = getYarnAddStringMappings; +exports.generateYarnAddAdapterCommand = generateYarnAddAdapterCommand; + +var _child_process = _interopRequireDefault(require("child_process")); + +var _path = _interopRequireDefault(require("path")); + +var _fs = _interopRequireDefault(require("fs")); + +var _findNodeModules = _interopRequireDefault(require("find-node-modules")); + +var _lodash = _interopRequireDefault(require("lodash")); + +var _detectIndent = _interopRequireDefault(require("detect-indent")); + +var _util = require("../common/util"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * ADAPTER + * + * Adapter is generally responsible for actually installing adapters to an + * end user's project. It does not perform checks to determine if there is + * a previous commitizen adapter installed or if the proper fields were + * provided. It defers that responsibility to init. + */ + +/** + * Modifies the package.json, sets config.commitizen.path to the path of the adapter + * Must be passed an absolute path to the cli's root + */ +function addPathToAdapterConfig(cliPath, repoPath, adapterNpmName) { + cov_8emx7ww64.f[0]++; + let commitizenAdapterConfig = (cov_8emx7ww64.s[0]++, { + config: { + commitizen: { + path: `./node_modules/${adapterNpmName}` + } + } + }); + let packageJsonPath = (cov_8emx7ww64.s[1]++, _path.default.join(getNearestProjectRootDirectory(repoPath), 'package.json')); + let packageJsonString = (cov_8emx7ww64.s[2]++, _fs.default.readFileSync(packageJsonPath, 'utf-8')); // tries to detect the indentation and falls back to a default if it can't + + let indent = (cov_8emx7ww64.s[3]++, (cov_8emx7ww64.b[0][0]++, (0, _detectIndent.default)(packageJsonString).indent) || (cov_8emx7ww64.b[0][1]++, ' ')); + let packageJsonContent = (cov_8emx7ww64.s[4]++, JSON.parse(packageJsonString)); + let newPackageJsonContent = (cov_8emx7ww64.s[5]++, ''); + cov_8emx7ww64.s[6]++; + + if (_lodash.default.get(packageJsonContent, 'config.commitizen.path') !== adapterNpmName) { + cov_8emx7ww64.b[1][0]++; + cov_8emx7ww64.s[7]++; + newPackageJsonContent = _lodash.default.merge(packageJsonContent, commitizenAdapterConfig); + } else { + cov_8emx7ww64.b[1][1]++; + } + + cov_8emx7ww64.s[8]++; + + _fs.default.writeFileSync(packageJsonPath, JSON.stringify(newPackageJsonContent, null, indent) + '\n'); +} +/** + * Generates an npm install command given a map of strings and a package name + */ + + +function generateNpmInstallAdapterCommand(stringMappings, adapterNpmName) { + cov_8emx7ww64.f[1]++; + // Start with an initial npm install command + let installAdapterCommand = (cov_8emx7ww64.s[9]++, `npm install ${adapterNpmName}`); // Append the neccesary arguments to it based on user preferences + + cov_8emx7ww64.s[10]++; + + for (let value of stringMappings.values()) { + cov_8emx7ww64.s[11]++; + + if (value) { + cov_8emx7ww64.b[2][0]++; + cov_8emx7ww64.s[12]++; + installAdapterCommand = installAdapterCommand + ' ' + value; + } else { + cov_8emx7ww64.b[2][1]++; + } + } + + cov_8emx7ww64.s[13]++; + return installAdapterCommand; +} +/** + * Generates an yarn add command given a map of strings and a package name + */ + + +function generateYarnAddAdapterCommand(stringMappings, adapterNpmName) { + cov_8emx7ww64.f[2]++; + // Start with an initial yarn add command + let installAdapterCommand = (cov_8emx7ww64.s[14]++, `yarn add ${adapterNpmName}`); // Append the necessary arguments to it based on user preferences + + cov_8emx7ww64.s[15]++; + + for (let value of stringMappings.values()) { + cov_8emx7ww64.s[16]++; + + if (value) { + cov_8emx7ww64.b[3][0]++; + cov_8emx7ww64.s[17]++; + installAdapterCommand = installAdapterCommand + ' ' + value; + } else { + cov_8emx7ww64.b[3][1]++; + } + } + + cov_8emx7ww64.s[18]++; + return installAdapterCommand; +} +/** + * Gets the nearest npm_modules directory + */ + + +function getNearestNodeModulesDirectory(options) { + cov_8emx7ww64.f[3]++; + // Get the nearest node_modules directories to the current working directory + let nodeModulesDirectories = (cov_8emx7ww64.s[19]++, (0, _findNodeModules.default)(options)); // Make sure we find a node_modules folder + + /* istanbul ignore else */ + + cov_8emx7ww64.s[20]++; + + if ((cov_8emx7ww64.b[5][0]++, nodeModulesDirectories) && (cov_8emx7ww64.b[5][1]++, nodeModulesDirectories.length > 0)) { + cov_8emx7ww64.b[4][0]++; + cov_8emx7ww64.s[21]++; + return nodeModulesDirectories[0]; + } else { + console.error(`Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?`); + } +} +/** + * Gets the nearest project root directory + */ + + +function getNearestProjectRootDirectory(repoPath, options) { + cov_8emx7ww64.f[4]++; + cov_8emx7ww64.s[22]++; + return _path.default.join(repoPath, getNearestNodeModulesDirectory(options), '/../'); +} +/** + * Gets a map of arguments where the value is the corresponding npm strings + */ + + +function getNpmInstallStringMappings(save, saveDev, saveExact, force) { + cov_8emx7ww64.f[5]++; + cov_8emx7ww64.s[23]++; + return new Map().set('save', (cov_8emx7ww64.b[7][0]++, save) && (cov_8emx7ww64.b[7][1]++, !saveDev) ? (cov_8emx7ww64.b[6][0]++, '--save') : (cov_8emx7ww64.b[6][1]++, undefined)).set('saveDev', saveDev ? (cov_8emx7ww64.b[8][0]++, '--save-dev') : (cov_8emx7ww64.b[8][1]++, undefined)).set('saveExact', saveExact ? (cov_8emx7ww64.b[9][0]++, '--save-exact') : (cov_8emx7ww64.b[9][1]++, undefined)).set('force', force ? (cov_8emx7ww64.b[10][0]++, '--force') : (cov_8emx7ww64.b[10][1]++, undefined)); +} +/** + * Gets a map of arguments where the value is the corresponding yarn strings + */ + + +function getYarnAddStringMappings(dev, exact, force) { + cov_8emx7ww64.f[6]++; + cov_8emx7ww64.s[24]++; + return new Map().set('dev', dev ? (cov_8emx7ww64.b[11][0]++, '--dev') : (cov_8emx7ww64.b[11][1]++, undefined)).set('exact', exact ? (cov_8emx7ww64.b[12][0]++, '--exact') : (cov_8emx7ww64.b[12][1]++, undefined)).set('force', force ? (cov_8emx7ww64.b[13][0]++, '--force') : (cov_8emx7ww64.b[13][1]++, undefined)); +} +/** + * Gets the prompter from an adapter given an adapter path + */ + + +function getPrompter(adapterPath) { + cov_8emx7ww64.f[7]++; + // Resolve the adapter path + let resolvedAdapterPath = (cov_8emx7ww64.s[25]++, resolveAdapterPath(adapterPath)); // Load the adapter + + let adapter = (cov_8emx7ww64.s[26]++, require(resolvedAdapterPath)); + /* istanbul ignore next */ + + if (adapter && adapter.prompter && (0, _util.isFunction)(adapter.prompter)) { + return adapter.prompter; + } else if (adapter && adapter.default && adapter.default.prompter && (0, _util.isFunction)(adapter.default.prompter)) { + return adapter.default.prompter; + } else { + throw new Error(`Could not find prompter method in the provided adapter module: ${adapterPath}`); + } +} +/** + * Given a resolvable module name or path, which can be a directory or file, will + * return a located adapter path or will throw. + */ + + +function resolveAdapterPath(inboundAdapterPath) { + cov_8emx7ww64.f[8]++; + // Check if inboundAdapterPath is a path or node module name + let parsed = (cov_8emx7ww64.s[27]++, _path.default.parse(inboundAdapterPath)); + let isPath = (cov_8emx7ww64.s[28]++, (cov_8emx7ww64.b[14][0]++, parsed.dir.length > 0) && (cov_8emx7ww64.b[14][1]++, parsed.dir.charAt(0) !== "@")); // Resolve from the root of the git repo if inboundAdapterPath is a path + + let absoluteAdapterPath = (cov_8emx7ww64.s[29]++, isPath ? (cov_8emx7ww64.b[15][0]++, _path.default.resolve(getGitRootPath(), inboundAdapterPath)) : (cov_8emx7ww64.b[15][1]++, inboundAdapterPath)); + cov_8emx7ww64.s[30]++; + + try { + cov_8emx7ww64.s[31]++; + // try to resolve the given path + return require.resolve(absoluteAdapterPath); + } catch (error) { + cov_8emx7ww64.s[32]++; + error.message = "Could not resolve " + absoluteAdapterPath + ". " + error.message; + cov_8emx7ww64.s[33]++; + throw error; + } +} + +function getGitRootPath() { + cov_8emx7ww64.f[9]++; + cov_8emx7ww64.s[34]++; + return _child_process.default.spawnSync('git', ['rev-parse', '--show-toplevel'], { + encoding: 'utf8' + }).stdout.trim(); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/cache.js b/node_modules/commitizen/dist/commitizen/cache.js new file mode 100644 index 00000000..3a5a425c --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/cache.js @@ -0,0 +1,280 @@ +"use strict"; + +var cov_1n5kj1atco = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/cache.js"; + var hash = "eaa1323be747e42b3e17d11202bfcb8d4966dc0d"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/cache.js", + statementMap: { + "0": { + start: { + line: 14, + column: 2 + }, + end: { + line: 14, + column: 56 + } + }, + "1": { + start: { + line: 22, + column: 2 + }, + end: { + line: 26, + column: 3 + } + }, + "2": { + start: { + line: 23, + column: 4 + }, + end: { + line: 23, + column: 45 + } + }, + "3": { + start: { + line: 25, + column: 4 + }, + end: { + line: 25, + column: 23 + } + }, + "4": { + start: { + line: 27, + column: 17 + }, + end: { + line: 29, + column: 4 + } + }, + "5": { + start: { + line: 30, + column: 2 + }, + end: { + line: 30, + column: 68 + } + }, + "6": { + start: { + line: 31, + column: 2 + }, + end: { + line: 31, + column: 18 + } + }, + "7": { + start: { + line: 38, + column: 2 + }, + end: { + line: 43, + column: 3 + } + }, + "8": { + start: { + line: 39, + column: 16 + }, + end: { + line: 39, + column: 40 + } + }, + "9": { + start: { + line: 40, + column: 4 + }, + end: { + line: 40, + column: 27 + } + } + }, + fnMap: { + "0": { + name: "readCacheSync", + decl: { + start: { + line: 13, + column: 9 + }, + end: { + line: 13, + column: 22 + } + }, + loc: { + start: { + line: 13, + column: 35 + }, + end: { + line: 15, + column: 1 + } + }, + line: 13 + }, + "1": { + name: "setCacheValueSync", + decl: { + start: { + line: 20, + column: 9 + }, + end: { + line: 20, + column: 26 + } + }, + loc: { + start: { + line: 20, + column: 51 + }, + end: { + line: 32, + column: 1 + } + }, + line: 20 + }, + "2": { + name: "getCacheValueSync", + decl: { + start: { + line: 37, + column: 9 + }, + end: { + line: 37, + column: 26 + } + }, + loc: { + start: { + line: 37, + column: 49 + }, + end: { + line: 44, + column: 1 + } + }, + line: 37 + } + }, + branchMap: {}, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0 + }, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "eaa1323be747e42b3e17d11202bfcb8d4966dc0d" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getCacheValueSync = getCacheValueSync; +exports.readCacheSync = readCacheSync; +exports.setCacheValueSync = setCacheValueSync; + +var _fs = _interopRequireDefault(require("fs")); + +var _lodash = _interopRequireDefault(require("lodash")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Reads the entire cache + */ +function readCacheSync(cachePath) { + cov_1n5kj1atco.f[0]++; + cov_1n5kj1atco.s[0]++; + return JSON.parse(_fs.default.readFileSync(cachePath, 'utf8')); +} +/** + * Sets a cache value and writes the file to disk + */ + + +function setCacheValueSync(cachePath, key, value) { + cov_1n5kj1atco.f[1]++; + var originalCache; + cov_1n5kj1atco.s[1]++; + + try { + cov_1n5kj1atco.s[2]++; + originalCache = readCacheSync(cachePath); + } catch (e) { + cov_1n5kj1atco.s[3]++; + originalCache = {}; + } + + var newCache = (cov_1n5kj1atco.s[4]++, _lodash.default.assign(originalCache, { + [key]: value + })); + cov_1n5kj1atco.s[5]++; + + _fs.default.writeFileSync(cachePath, JSON.stringify(newCache, null, ' ')); + + cov_1n5kj1atco.s[6]++; + return newCache; +} +/** + * Gets a single value from the cache given a key + */ + + +function getCacheValueSync(cachePath, repoPath) { + cov_1n5kj1atco.f[2]++; + cov_1n5kj1atco.s[7]++; + + try { + let cache = (cov_1n5kj1atco.s[8]++, readCacheSync(cachePath)); + cov_1n5kj1atco.s[9]++; + return cache[repoPath]; + } catch (e) {} +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/commit.js b/node_modules/commitizen/dist/commitizen/commit.js new file mode 100644 index 00000000..f2fc2d51 --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/commit.js @@ -0,0 +1,635 @@ +"use strict"; + +var cov_29br46dhp = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/commit.js"; + var hash = "278239d97c93019a25911186df022c8cb60dab67"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/commit.js", + statementMap: { + "0": { + start: { + line: 15, + column: 4 + }, + end: { + line: 17, + column: 7 + } + }, + "1": { + start: { + line: 16, + column: 6 + }, + end: { + line: 16, + column: 28 + } + }, + "2": { + start: { + line: 24, + column: 23 + }, + end: { + line: 24, + column: 45 + } + }, + "3": { + start: { + line: 25, + column: 18 + }, + end: { + line: 25, + column: 62 + } + }, + "4": { + start: { + line: 27, + column: 2 + }, + end: { + line: 66, + column: 5 + } + }, + "5": { + start: { + line: 28, + column: 4 + }, + end: { + line: 65, + column: 5 + } + }, + "6": { + start: { + line: 29, + column: 6 + }, + end: { + line: 29, + column: 75 + } + }, + "7": { + start: { + line: 32, + column: 6 + }, + end: { + line: 64, + column: 7 + } + }, + "8": { + start: { + line: 34, + column: 8 + }, + end: { + line: 34, + column: 53 + } + }, + "9": { + start: { + line: 42, + column: 12 + }, + end: { + line: 42, + column: 56 + } + }, + "10": { + start: { + line: 43, + column: 8 + }, + end: { + line: 43, + column: 93 + } + }, + "11": { + start: { + line: 47, + column: 8 + }, + end: { + line: 63, + column: 11 + } + }, + "12": { + start: { + line: 50, + column: 10 + }, + end: { + line: 54, + column: 11 + } + }, + "13": { + start: { + line: 51, + column: 12 + }, + end: { + line: 51, + column: 39 + } + }, + "14": { + start: { + line: 52, + column: 12 + }, + end: { + line: 52, + column: 29 + } + }, + "15": { + start: { + line: 53, + column: 12 + }, + end: { + line: 53, + column: 25 + } + }, + "16": { + start: { + line: 56, + column: 10 + }, + end: { + line: 58, + column: 11 + } + }, + "17": { + start: { + line: 57, + column: 12 + }, + end: { + line: 57, + column: 31 + } + }, + "18": { + start: { + line: 61, + column: 10 + }, + end: { + line: 61, + column: 95 + } + }, + "19": { + start: { + line: 62, + column: 10 + }, + end: { + line: 62, + column: 80 + } + } + }, + fnMap: { + "0": { + name: "dispatchGitCommit", + decl: { + start: { + line: 13, + column: 9 + }, + end: { + line: 13, + column: 26 + } + }, + loc: { + start: { + line: 13, + column: 80 + }, + end: { + line: 18, + column: 1 + } + }, + line: 13 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 15, + column: 70 + }, + end: { + line: 15, + column: 71 + } + }, + loc: { + start: { + line: 15, + column: 87 + }, + end: { + line: 17, + column: 5 + } + }, + line: 15 + }, + "2": { + name: "commit", + decl: { + start: { + line: 23, + column: 9 + }, + end: { + line: 23, + column: 15 + } + }, + loc: { + start: { + line: 23, + column: 62 + }, + end: { + line: 68, + column: 1 + } + }, + line: 23 + }, + "3": { + name: "(anonymous_3)", + decl: { + start: { + line: 27, + column: 28 + }, + end: { + line: 27, + column: 29 + } + }, + loc: { + start: { + line: 27, + column: 45 + }, + end: { + line: 66, + column: 3 + } + }, + line: 27 + }, + "4": { + name: "(anonymous_4)", + decl: { + start: { + line: 47, + column: 27 + }, + end: { + line: 47, + column: 28 + } + }, + loc: { + start: { + line: 47, + column: 71 + }, + end: { + line: 63, + column: 9 + } + }, + line: 47 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 28, + column: 4 + }, + end: { + line: 65, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 28, + column: 4 + }, + end: { + line: 65, + column: 5 + } + }, { + start: { + line: 28, + column: 4 + }, + end: { + line: 65, + column: 5 + } + }], + line: 28 + }, + "1": { + loc: { + start: { + line: 32, + column: 6 + }, + end: { + line: 64, + column: 7 + } + }, + type: "if", + locations: [{ + start: { + line: 32, + column: 6 + }, + end: { + line: 64, + column: 7 + } + }, { + start: { + line: 32, + column: 6 + }, + end: { + line: 64, + column: 7 + } + }], + line: 32 + }, + "2": { + loc: { + start: { + line: 50, + column: 10 + }, + end: { + line: 54, + column: 11 + } + }, + type: "if", + locations: [{ + start: { + line: 50, + column: 10 + }, + end: { + line: 54, + column: 11 + } + }, { + start: { + line: 50, + column: 10 + }, + end: { + line: 54, + column: 11 + } + }], + line: 50 + }, + "3": { + loc: { + start: { + line: 56, + column: 10 + }, + end: { + line: 58, + column: 11 + } + }, + type: "if", + locations: [{ + start: { + line: 56, + column: 10 + }, + end: { + line: 58, + column: 11 + } + }, { + start: { + line: 56, + column: 10 + }, + end: { + line: 58, + column: 11 + } + }], + line: 56 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0, + "12": 0, + "13": 0, + "14": 0, + "15": 0, + "16": 0, + "17": 0, + "18": 0, + "19": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "278239d97c93019a25911186df022c8cb60dab67" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _cachedir = _interopRequireDefault(require("cachedir")); + +var _fsExtra = require("fs-extra"); + +var _git = require("../git"); + +var cache = _interopRequireWildcard(require("./cache")); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +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; } + +var _default = commit; +/** + * Takes all of the final inputs needed in order to make dispatch a git commit + */ + +exports.default = _default; + +function dispatchGitCommit(repoPath, template, options, overrideOptions, done) { + cov_29br46dhp.f[0]++; + cov_29br46dhp.s[0]++; + // Commit the user input -- side effect that we'll test + (0, _git.commit)(repoPath, template, _objectSpread2({}, options, {}, overrideOptions), function (error) { + cov_29br46dhp.f[1]++; + cov_29br46dhp.s[1]++; + done(error, template); + }); +} +/** + * Asynchronously commits files using commitizen + */ + + +function commit(inquirer, repoPath, prompter, options, done) { + cov_29br46dhp.f[2]++; + var cacheDirectory = (cov_29br46dhp.s[2]++, (0, _cachedir.default)('commitizen')); + var cachePath = (cov_29br46dhp.s[3]++, _path.default.join(cacheDirectory, 'commitizen.json')); + cov_29br46dhp.s[4]++; + (0, _fsExtra.ensureDir)(cacheDirectory, function (error) { + cov_29br46dhp.f[3]++; + cov_29br46dhp.s[5]++; + + if (error) { + cov_29br46dhp.b[0][0]++; + cov_29br46dhp.s[6]++; + console.error("Couldn't create commitizen cache directory: ", error); // TODO: properly handle error? + } else { + cov_29br46dhp.b[0][1]++; + cov_29br46dhp.s[7]++; + + if (options.retryLastCommit) { + cov_29br46dhp.b[1][0]++; + cov_29br46dhp.s[8]++; + console.log('Retrying last commit attempt.'); // We want to use the last commit instead of the current commit, + // so lets override some options using the values from cache. + + let { + options: retryOptions, + overrideOptions: retryOverrideOptions, + template: retryTemplate + } = (cov_29br46dhp.s[9]++, cache.getCacheValueSync(cachePath, repoPath)); + cov_29br46dhp.s[10]++; + dispatchGitCommit(repoPath, retryTemplate, retryOptions, retryOverrideOptions, done); + } else { + cov_29br46dhp.b[1][1]++; + cov_29br46dhp.s[11]++; + // Get user input -- side effect that is hard to test + prompter(inquirer, function (error, template, overrideOptions) { + cov_29br46dhp.f[4]++; + cov_29br46dhp.s[12]++; + + // Allow adapters to error out + // (error: Error?, template: String, overrideOptions: Object) + if (!(error instanceof Error)) { + cov_29br46dhp.b[2][0]++; + cov_29br46dhp.s[13]++; + overrideOptions = template; + cov_29br46dhp.s[14]++; + template = error; + cov_29br46dhp.s[15]++; + error = null; + } else { + cov_29br46dhp.b[2][1]++; + } + + cov_29br46dhp.s[16]++; + + if (error) { + cov_29br46dhp.b[3][0]++; + cov_29br46dhp.s[17]++; + return done(error); + } else { + cov_29br46dhp.b[3][1]++; + } // We don't want to add retries to the cache, only actual commands + + + cov_29br46dhp.s[18]++; + cache.setCacheValueSync(cachePath, repoPath, { + template, + options, + overrideOptions + }); + cov_29br46dhp.s[19]++; + dispatchGitCommit(repoPath, template, options, overrideOptions, done); + }); + } + } + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/configLoader.js b/node_modules/commitizen/dist/commitizen/configLoader.js new file mode 100644 index 00000000..4c520ee6 --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/configLoader.js @@ -0,0 +1,93 @@ +"use strict"; + +var cov_udgjkeujl = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/configLoader.js"; + var hash = "36788d360cc402c80406bfe7481fca6df3978a56"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/configLoader.js", + statementMap: { + "0": { + start: { + line: 6, + column: 14 + }, + end: { + line: 6, + column: 51 + } + }, + "1": { + start: { + line: 9, + column: 2 + }, + end: { + line: 9, + column: 38 + } + } + }, + fnMap: { + "0": { + name: "load", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 13 + } + }, + loc: { + start: { + line: 8, + column: 28 + }, + end: { + line: 10, + column: 1 + } + }, + line: 8 + } + }, + branchMap: {}, + s: { + "0": 0, + "1": 0 + }, + f: { + "0": 0 + }, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "36788d360cc402c80406bfe7481fca6df3978a56" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.load = load; + +var _configLoader = require("../configLoader"); + +// Configuration sources in priority order. +var configs = (cov_udgjkeujl.s[0]++, ['.czrc', '.cz.json', 'package.json']); + +function load(config, cwd) { + cov_udgjkeujl.f[0]++; + cov_udgjkeujl.s[1]++; + return (0, _configLoader.loader)(configs, config, cwd); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/init.js b/node_modules/commitizen/dist/commitizen/init.js new file mode 100644 index 00000000..da14fc04 --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/init.js @@ -0,0 +1,1085 @@ +"use strict"; + +var cov_2ale029yls = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/init.js"; + var hash = "338dde00e6bc74cf76624a22bb02140620560f29"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/init.js", + statementMap: { + "0": { + start: { + line: 12, + column: 4 + }, + end: { + line: 12, + column: 11 + } + }, + "1": { + start: { + line: 16, + column: 17 + }, + end: { + line: 16, + column: 63 + } + }, + "2": { + start: { + line: 35, + column: 27 + }, + end: { + line: 46, + column: 1 + } + }, + "3": { + start: { + line: 63, + column: 2 + }, + end: { + line: 63, + column: 51 + } + }, + "4": { + start: { + line: 66, + column: 22 + }, + end: { + line: 66, + column: 49 + } + }, + "5": { + start: { + line: 69, + column: 23 + }, + end: { + line: 69, + column: 136 + } + }, + "6": { + start: { + line: 72, + column: 30 + }, + end: { + line: 72, + column: 165 + } + }, + "7": { + start: { + line: 74, + column: 33 + }, + end: { + line: 74, + column: 164 + } + }, + "8": { + start: { + line: 77, + column: 2 + }, + end: { + line: 85, + column: 3 + } + }, + "9": { + start: { + line: 78, + column: 4 + }, + end: { + line: 84, + column: 7 + } + }, + "10": { + start: { + line: 87, + column: 2 + }, + end: { + line: 95, + column: 3 + } + }, + "11": { + start: { + line: 88, + column: 4 + }, + end: { + line: 88, + column: 68 + } + }, + "12": { + start: { + line: 89, + column: 4 + }, + end: { + line: 91, + column: 5 + } + }, + "13": { + start: { + line: 90, + column: 6 + }, + end: { + line: 90, + column: 73 + } + }, + "14": { + start: { + line: 92, + column: 4 + }, + end: { + line: 92, + column: 63 + } + }, + "15": { + start: { + line: 94, + column: 4 + }, + end: { + line: 94, + column: 21 + } + }, + "16": { + start: { + line: 103, + column: 2 + }, + end: { + line: 105, + column: 3 + } + }, + "17": { + start: { + line: 104, + column: 4 + }, + end: { + line: 104, + column: 59 + } + }, + "18": { + start: { + line: 106, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }, + "19": { + start: { + line: 107, + column: 4 + }, + end: { + line: 107, + column: 77 + } + }, + "20": { + start: { + line: 116, + column: 15 + }, + end: { + line: 116, + column: 43 + } + }, + "21": { + start: { + line: 117, + column: 2 + }, + end: { + line: 121, + column: 3 + } + }, + "22": { + start: { + line: 118, + column: 4 + }, + end: { + line: 118, + column: 18 + } + } + }, + fnMap: { + "0": { + name: "init", + decl: { + start: { + line: 51, + column: 9 + }, + end: { + line: 51, + column: 13 + } + }, + loc: { + start: { + line: 60, + column: 24 + }, + end: { + line: 96, + column: 1 + } + }, + line: 60 + }, + "1": { + name: "checkRequiredArguments", + decl: { + start: { + line: 102, + column: 9 + }, + end: { + line: 102, + column: 31 + } + }, + loc: { + start: { + line: 102, + column: 55 + }, + end: { + line: 109, + column: 1 + } + }, + line: 102 + }, + "2": { + name: "loadAdapterConfig", + decl: { + start: { + line: 115, + column: 9 + }, + end: { + line: 115, + column: 26 + } + }, + loc: { + start: { + line: 115, + column: 33 + }, + end: { + line: 122, + column: 1 + } + }, + line: 115 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 51, + column: 41 + }, + end: { + line: 60, + column: 22 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 60, + column: 4 + }, + end: { + line: 60, + column: 22 + } + }], + line: 51 + }, + "1": { + loc: { + start: { + line: 52, + column: 2 + }, + end: { + line: 52, + column: 14 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 52, + column: 9 + }, + end: { + line: 52, + column: 14 + } + }], + line: 52 + }, + "2": { + loc: { + start: { + line: 53, + column: 2 + }, + end: { + line: 53, + column: 16 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 53, + column: 12 + }, + end: { + line: 53, + column: 16 + } + }], + line: 53 + }, + "3": { + loc: { + start: { + line: 54, + column: 2 + }, + end: { + line: 54, + column: 19 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 54, + column: 14 + }, + end: { + line: 54, + column: 19 + } + }], + line: 54 + }, + "4": { + loc: { + start: { + line: 55, + column: 2 + }, + end: { + line: 55, + column: 15 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 55, + column: 10 + }, + end: { + line: 55, + column: 15 + } + }], + line: 55 + }, + "5": { + loc: { + start: { + line: 56, + column: 2 + }, + end: { + line: 56, + column: 14 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 56, + column: 9 + }, + end: { + line: 56, + column: 14 + } + }], + line: 56 + }, + "6": { + loc: { + start: { + line: 57, + column: 2 + }, + end: { + line: 57, + column: 13 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 57, + column: 8 + }, + end: { + line: 57, + column: 13 + } + }], + line: 57 + }, + "7": { + loc: { + start: { + line: 58, + column: 2 + }, + end: { + line: 58, + column: 15 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 58, + column: 10 + }, + end: { + line: 58, + column: 15 + } + }], + line: 58 + }, + "8": { + loc: { + start: { + line: 59, + column: 2 + }, + end: { + line: 59, + column: 27 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 59, + column: 22 + }, + end: { + line: 59, + column: 27 + } + }], + line: 59 + }, + "9": { + loc: { + start: { + line: 69, + column: 23 + }, + end: { + line: 69, + column: 136 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 69, + column: 30 + }, + end: { + line: 69, + column: 73 + } + }, { + start: { + line: 69, + column: 76 + }, + end: { + line: 69, + column: 136 + } + }], + line: 69 + }, + "10": { + loc: { + start: { + line: 72, + column: 30 + }, + end: { + line: 72, + column: 165 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 72, + column: 37 + }, + end: { + line: 72, + column: 98 + } + }, { + start: { + line: 72, + column: 101 + }, + end: { + line: 72, + column: 165 + } + }], + line: 72 + }, + "11": { + loc: { + start: { + line: 74, + column: 33 + }, + end: { + line: 74, + column: 164 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 74, + column: 40 + }, + end: { + line: 74, + column: 99 + } + }, { + start: { + line: 74, + column: 102 + }, + end: { + line: 74, + column: 164 + } + }], + line: 74 + }, + "12": { + loc: { + start: { + line: 77, + column: 2 + }, + end: { + line: 85, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 77, + column: 2 + }, + end: { + line: 85, + column: 3 + } + }, { + start: { + line: 77, + column: 2 + }, + end: { + line: 85, + column: 3 + } + }], + line: 77 + }, + "13": { + loc: { + start: { + line: 77, + column: 6 + }, + end: { + line: 77, + column: 84 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 77, + column: 6 + }, + end: { + line: 77, + column: 19 + } + }, { + start: { + line: 77, + column: 23 + }, + end: { + line: 77, + column: 41 + } + }, { + start: { + line: 77, + column: 45 + }, + end: { + line: 77, + column: 74 + } + }, { + start: { + line: 77, + column: 78 + }, + end: { + line: 77, + column: 84 + } + }], + line: 77 + }, + "14": { + loc: { + start: { + line: 89, + column: 4 + }, + end: { + line: 91, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 89, + column: 4 + }, + end: { + line: 91, + column: 5 + } + }, { + start: { + line: 89, + column: 4 + }, + end: { + line: 91, + column: 5 + } + }], + line: 89 + }, + "15": { + loc: { + start: { + line: 103, + column: 2 + }, + end: { + line: 105, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 103, + column: 2 + }, + end: { + line: 105, + column: 3 + } + }, { + start: { + line: 103, + column: 2 + }, + end: { + line: 105, + column: 3 + } + }], + line: 103 + }, + "16": { + loc: { + start: { + line: 106, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 106, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }, { + start: { + line: 106, + column: 2 + }, + end: { + line: 108, + column: 3 + } + }], + line: 106 + }, + "17": { + loc: { + start: { + line: 117, + column: 2 + }, + end: { + line: 121, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 117, + column: 2 + }, + end: { + line: 121, + column: 3 + } + }, { + start: { + line: 117, + column: 2 + }, + end: { + line: 121, + column: 3 + } + }], + line: 117 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0, + "12": 0, + "13": 0, + "14": 0, + "15": 0, + "16": 0, + "17": 0, + "18": 0, + "19": 0, + "20": 0, + "21": 0, + "22": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0 + }, + b: { + "0": [0], + "1": [0], + "2": [0], + "3": [0], + "4": [0], + "5": [0], + "6": [0], + "7": [0], + "8": [0], + "9": [0, 0], + "10": [0, 0], + "11": [0, 0], + "12": [0, 0], + "13": [0, 0, 0, 0], + "14": [0, 0], + "15": [0, 0], + "16": [0, 0], + "17": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "338dde00e6bc74cf76624a22bb02140620560f29" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _child_process = _interopRequireDefault(require("child_process")); + +var _path = _interopRequireDefault(require("path")); + +var configLoader = _interopRequireWildcard(require("./configLoader")); + +var adapter = _interopRequireWildcard(require("./adapter")); + +function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } } + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +let { + addPathToAdapterConfig, + generateNpmInstallAdapterCommand, + getNpmInstallStringMappings, + generateYarnAddAdapterCommand, + getYarnAddStringMappings +} = (cov_2ale029yls.s[0]++, adapter); +var _default = init; +exports.default = _default; +const CLI_PATH = (cov_2ale029yls.s[1]++, _path.default.normalize(_path.default.join(__dirname, '../../'))); +/** + * CZ INIT + * + * Init is generally responsible for initializing an adapter in + * a user's project. The goal is to be able to run + * `commitizen init` and be prompted for certain fields which + * will help you install the proper adapter for your project. + * + * Init does not actually create the adapter (it defers to adapter + * for this). Instead, it is specifically designed to help gather + * and validate the information needed to install the adapter + * properly without interfering with a previous adapter config. + */ + +/** + * The defaults for init + */ + +const defaultInitOptions = (cov_2ale029yls.s[2]++, { + save: false, + saveDev: true, + saveExact: false, + force: false, + // for --yarn use + // @see https://github.com/commitizen/cz-cli/issues/527#issuecomment-392653897 + yarn: false, + dev: true, + exact: false // should add trailing comma, thus next developer doesn't got blamed for this line + +}); +/** + * Runs npm install for the adapter then modifies the config.commitizen as needed + */ + +function init(repoPath, adapterNpmName, { + save = (cov_2ale029yls.b[1][0]++, false), + saveDev = (cov_2ale029yls.b[2][0]++, true), + saveExact = (cov_2ale029yls.b[3][0]++, false), + force = (cov_2ale029yls.b[4][0]++, false), + yarn = (cov_2ale029yls.b[5][0]++, false), + dev = (cov_2ale029yls.b[6][0]++, false), + exact = (cov_2ale029yls.b[7][0]++, false), + includeCommitizen = (cov_2ale029yls.b[8][0]++, false) +} = (cov_2ale029yls.b[0][0]++, defaultInitOptions)) { + cov_2ale029yls.f[0]++; + cov_2ale029yls.s[3]++; + // Don't let things move forward if required args are missing + checkRequiredArguments(repoPath, adapterNpmName); // Load the current adapter config + + let adapterConfig = (cov_2ale029yls.s[4]++, loadAdapterConfig(repoPath)); // Get the npm string mappings based on the arguments provided + + let stringMappings = (cov_2ale029yls.s[5]++, yarn ? (cov_2ale029yls.b[9][0]++, getYarnAddStringMappings(dev, exact, force)) : (cov_2ale029yls.b[9][1]++, getNpmInstallStringMappings(save, saveDev, saveExact, force))); // Generate a string that represents the npm install command + + let installAdapterCommand = (cov_2ale029yls.s[6]++, yarn ? (cov_2ale029yls.b[10][0]++, generateYarnAddAdapterCommand(stringMappings, adapterNpmName)) : (cov_2ale029yls.b[10][1]++, generateNpmInstallAdapterCommand(stringMappings, adapterNpmName))); + let installCommitizenCommand = (cov_2ale029yls.s[7]++, yarn ? (cov_2ale029yls.b[11][0]++, generateYarnAddAdapterCommand(stringMappings, "commitizen")) : (cov_2ale029yls.b[11][1]++, generateNpmInstallAdapterCommand(stringMappings, "commitizen"))); // Check for previously installed adapters + + cov_2ale029yls.s[8]++; + + if ((cov_2ale029yls.b[13][0]++, adapterConfig) && (cov_2ale029yls.b[13][1]++, adapterConfig.path) && (cov_2ale029yls.b[13][2]++, adapterConfig.path.length > 0) && (cov_2ale029yls.b[13][3]++, !force)) { + cov_2ale029yls.b[12][0]++; + cov_2ale029yls.s[9]++; + throw new Error(`A previous adapter is already configured. Use --force to override + adapterConfig.path: ${adapterConfig.path} + repoPath: ${repoPath} + CLI_PATH: ${CLI_PATH} + installAdapterCommand: ${installAdapterCommand} + adapterNpmName: ${adapterNpmName} + `); + } else { + cov_2ale029yls.b[12][1]++; + } + + cov_2ale029yls.s[10]++; + + try { + cov_2ale029yls.s[11]++; + + _child_process.default.execSync(installAdapterCommand, { + cwd: repoPath + }); + + cov_2ale029yls.s[12]++; + + if (includeCommitizen) { + cov_2ale029yls.b[14][0]++; + cov_2ale029yls.s[13]++; + + _child_process.default.execSync(installCommitizenCommand, { + cwd: repoPath + }); + } else { + cov_2ale029yls.b[14][1]++; + } + + cov_2ale029yls.s[14]++; + addPathToAdapterConfig(CLI_PATH, repoPath, adapterNpmName); + } catch (e) { + cov_2ale029yls.s[15]++; + console.error(e); + } +} +/** + * Checks to make sure that the required arguments are passed + * Throws an exception if any are not. + */ + + +function checkRequiredArguments(path, adapterNpmName) { + cov_2ale029yls.f[1]++; + cov_2ale029yls.s[16]++; + + if (!path) { + cov_2ale029yls.b[15][0]++; + cov_2ale029yls.s[17]++; + throw new Error("Path is required when running init."); + } else { + cov_2ale029yls.b[15][1]++; + } + + cov_2ale029yls.s[18]++; + + if (!adapterNpmName) { + cov_2ale029yls.b[16][0]++; + cov_2ale029yls.s[19]++; + throw new Error("The adapter's npm name is required when running init."); + } else { + cov_2ale029yls.b[16][1]++; + } +} +/** + * CONFIG + * Loads and returns the adapter config at key config.commitizen, if it exists + */ + + +function loadAdapterConfig(cwd) { + cov_2ale029yls.f[2]++; + let config = (cov_2ale029yls.s[20]++, configLoader.load(null, cwd)); + cov_2ale029yls.s[21]++; + + if (config) { + cov_2ale029yls.b[17][0]++; + cov_2ale029yls.s[22]++; + return config; + } else { + cov_2ale029yls.b[17][1]++; + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/commitizen/staging.js b/node_modules/commitizen/dist/commitizen/staging.js new file mode 100644 index 00000000..1b41a71c --- /dev/null +++ b/node_modules/commitizen/dist/commitizen/staging.js @@ -0,0 +1,239 @@ +"use strict"; + +var cov_270ou9i6pi = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/commitizen/staging.js"; + var hash = "f47101f60ab6c7dca389fc1f0eed484161a1b996"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/commitizen/staging.js", + statementMap: { + "0": { + start: { + line: 9, + column: 2 + }, + end: { + line: 18, + column: 5 + } + }, + "1": { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + "2": { + start: { + line: 14, + column: 6 + }, + end: { + line: 14, + column: 25 + } + }, + "3": { + start: { + line: 16, + column: 17 + }, + end: { + line: 16, + column: 29 + } + }, + "4": { + start: { + line: 17, + column: 4 + }, + end: { + line: 17, + column: 43 + } + } + }, + fnMap: { + "0": { + name: "isClean", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 16 + } + }, + loc: { + start: { + line: 8, + column: 34 + }, + end: { + line: 19, + column: 1 + } + }, + line: 8 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 12, + column: 5 + }, + end: { + line: 12, + column: 6 + } + }, + loc: { + start: { + line: 12, + column: 30 + }, + end: { + line: 18, + column: 3 + } + }, + line: 12 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }], + line: 13 + }, + "1": { + loc: { + start: { + line: 16, + column: 17 + }, + end: { + line: 16, + column: 29 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 16, + column: 17 + }, + end: { + line: 16, + column: 23 + } + }, { + start: { + line: 16, + column: 27 + }, + end: { + line: 16, + column: 29 + } + }], + line: 16 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "f47101f60ab6c7dca389fc1f0eed484161a1b996" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.isClean = isClean; + +var _child_process = require("child_process"); + +/** + * Asynchrounously determines if the staging area is clean + */ +function isClean(repoPath, done) { + cov_270ou9i6pi.f[0]++; + cov_270ou9i6pi.s[0]++; + (0, _child_process.exec)('git diff --no-ext-diff --name-only && git diff --no-ext-diff --cached --name-only', { + maxBuffer: Infinity, + cwd: repoPath + }, function (error, stdout) { + cov_270ou9i6pi.f[1]++; + cov_270ou9i6pi.s[1]++; + + if (error) { + cov_270ou9i6pi.b[0][0]++; + cov_270ou9i6pi.s[2]++; + return done(error); + } else { + cov_270ou9i6pi.b[0][1]++; + } + + let output = (cov_270ou9i6pi.s[3]++, (cov_270ou9i6pi.b[1][0]++, stdout) || (cov_270ou9i6pi.b[1][1]++, '')); + cov_270ou9i6pi.s[4]++; + done(null, output.trim().length === 0); + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/common/util.js b/node_modules/commitizen/dist/common/util.js new file mode 100644 index 00000000..0f6da863 --- /dev/null +++ b/node_modules/commitizen/dist/common/util.js @@ -0,0 +1,467 @@ +"use strict"; + +var cov_242ewvhlu5 = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/common/util.js"; + var hash = "bc7147643a51aded92d9cfa9976b5026f592e01a"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/common/util.js", + statementMap: { + "0": { + start: { + line: 15, + column: 2 + }, + end: { + line: 20, + column: 3 + } + }, + "1": { + start: { + line: 16, + column: 30 + }, + end: { + line: 16, + column: 86 + } + }, + "2": { + start: { + line: 17, + column: 4 + }, + end: { + line: 17, + column: 43 + } + }, + "3": { + start: { + line: 19, + column: 4 + }, + end: { + line: 19, + column: 21 + } + }, + "4": { + start: { + line: 27, + column: 2 + }, + end: { + line: 27, + column: 53 + } + }, + "5": { + start: { + line: 34, + column: 2 + }, + end: { + line: 42, + column: 3 + } + }, + "6": { + start: { + line: 36, + column: 4 + }, + end: { + line: 36, + column: 17 + } + }, + "7": { + start: { + line: 37, + column: 9 + }, + end: { + line: 42, + column: 3 + } + }, + "8": { + start: { + line: 38, + column: 4 + }, + end: { + line: 38, + column: 17 + } + }, + "9": { + start: { + line: 40, + column: 18 + }, + end: { + line: 40, + column: 20 + } + }, + "10": { + start: { + line: 41, + column: 4 + }, + end: { + line: 41, + column: 93 + } + }, + "11": { + start: { + line: 46, + column: 2 + }, + end: { + line: 46, + column: 41 + } + } + }, + fnMap: { + "0": { + name: "getParsedJsonFromFile", + decl: { + start: { + line: 14, + column: 9 + }, + end: { + line: 14, + column: 30 + } + }, + loc: { + start: { + line: 14, + column: 71 + }, + end: { + line: 21, + column: 1 + } + }, + line: 14 + }, + "1": { + name: "getParsedPackageJsonFromPath", + decl: { + start: { + line: 26, + column: 9 + }, + end: { + line: 26, + column: 37 + } + }, + loc: { + start: { + line: 26, + column: 45 + }, + end: { + line: 28, + column: 1 + } + }, + line: 26 + }, + "2": { + name: "isFunction", + decl: { + start: { + line: 33, + column: 9 + }, + end: { + line: 33, + column: 19 + } + }, + loc: { + start: { + line: 33, + column: 38 + }, + end: { + line: 43, + column: 1 + } + }, + line: 33 + }, + "3": { + name: "isInTest", + decl: { + start: { + line: 45, + column: 9 + }, + end: { + line: 45, + column: 17 + } + }, + loc: { + start: { + line: 45, + column: 21 + }, + end: { + line: 47, + column: 1 + } + }, + line: 45 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 14, + column: 52 + }, + end: { + line: 14, + column: 69 + } + }, + type: "default-arg", + locations: [{ + start: { + line: 14, + column: 63 + }, + end: { + line: 14, + column: 69 + } + }], + line: 14 + }, + "1": { + loc: { + start: { + line: 34, + column: 2 + }, + end: { + line: 42, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 34, + column: 2 + }, + end: { + line: 42, + column: 3 + } + }, { + start: { + line: 34, + column: 2 + }, + end: { + line: 42, + column: 3 + } + }], + line: 34 + }, + "2": { + loc: { + start: { + line: 37, + column: 9 + }, + end: { + line: 42, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 37, + column: 9 + }, + end: { + line: 42, + column: 3 + } + }, { + start: { + line: 37, + column: 9 + }, + end: { + line: 42, + column: 3 + } + }], + line: 37 + }, + "3": { + loc: { + start: { + line: 41, + column: 11 + }, + end: { + line: 41, + column: 92 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 41, + column: 11 + }, + end: { + line: 41, + column: 26 + } + }, { + start: { + line: 41, + column: 30 + }, + end: { + line: 41, + column: 92 + } + }], + line: 41 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0, + "3": 0 + }, + b: { + "0": [0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "bc7147643a51aded92d9cfa9976b5026f592e01a" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getParsedJsonFromFile = getParsedJsonFromFile; +exports.getParsedPackageJsonFromPath = getParsedPackageJsonFromPath; +exports.isFunction = isFunction; +exports.isInTest = isInTest; + +var _fs = _interopRequireDefault(require("fs")); + +var _path = _interopRequireDefault(require("path")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Gets the parsed contents of a json file + */ +function getParsedJsonFromFile(filePath, fileName, encoding = (cov_242ewvhlu5.b[0][0]++, 'utf8')) { + cov_242ewvhlu5.f[0]++; + cov_242ewvhlu5.s[0]++; + + try { + var packageJsonContents = (cov_242ewvhlu5.s[1]++, _fs.default.readFileSync(_path.default.join(filePath, fileName), encoding)); + cov_242ewvhlu5.s[2]++; + return JSON.parse(packageJsonContents); + } catch (e) { + cov_242ewvhlu5.s[3]++; + console.error(e); + } +} +/** + * A helper method for getting the contents of package.json at a given path + */ + + +function getParsedPackageJsonFromPath(path) { + cov_242ewvhlu5.f[1]++; + cov_242ewvhlu5.s[4]++; + return getParsedJsonFromFile(path, 'package.json'); +} +/** + * Test if the passed argument is a function + */ + + +function isFunction(functionToCheck) { + cov_242ewvhlu5.f[2]++; + cov_242ewvhlu5.s[5]++; + + if (typeof functionToCheck === "undefined") { + cov_242ewvhlu5.b[1][0]++; + cov_242ewvhlu5.s[6]++; + return false; + } else { + cov_242ewvhlu5.b[1][1]++; + cov_242ewvhlu5.s[7]++; + + if (functionToCheck === null) { + cov_242ewvhlu5.b[2][0]++; + cov_242ewvhlu5.s[8]++; + return false; + } else { + cov_242ewvhlu5.b[2][1]++; + var getType = (cov_242ewvhlu5.s[9]++, {}); + cov_242ewvhlu5.s[10]++; + return (cov_242ewvhlu5.b[3][0]++, functionToCheck) && (cov_242ewvhlu5.b[3][1]++, getType.toString.call(functionToCheck) === '[object Function]'); + } + } +} + +function isInTest() { + cov_242ewvhlu5.f[3]++; + cov_242ewvhlu5.s[11]++; + return typeof global.it === 'function'; +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/configLoader.js b/node_modules/commitizen/dist/configLoader.js new file mode 100644 index 00000000..ce9518e9 --- /dev/null +++ b/node_modules/commitizen/dist/configLoader.js @@ -0,0 +1,39 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "findup", { + enumerable: true, + get: function () { + return _findup.default; + } +}); +Object.defineProperty(exports, "getContent", { + enumerable: true, + get: function () { + return _getContent.default; + } +}); +Object.defineProperty(exports, "getNormalizedConfig", { + enumerable: true, + get: function () { + return _getNormalizedConfig.default; + } +}); +Object.defineProperty(exports, "loader", { + enumerable: true, + get: function () { + return _loader.default; + } +}); + +var _findup = _interopRequireDefault(require("./configLoader/findup")); + +var _getContent = _interopRequireDefault(require("./configLoader/getContent")); + +var _getNormalizedConfig = _interopRequireDefault(require("./configLoader/getNormalizedConfig")); + +var _loader = _interopRequireDefault(require("./configLoader/loader")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } \ No newline at end of file diff --git a/node_modules/commitizen/dist/configLoader/findup.js b/node_modules/commitizen/dist/configLoader/findup.js new file mode 100644 index 00000000..26086f12 --- /dev/null +++ b/node_modules/commitizen/dist/configLoader/findup.js @@ -0,0 +1,344 @@ +"use strict"; + +var cov_1ay4fgfkgb = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/configLoader/findup.js"; + var hash = "ce6c9abea21cfa20eb8e2216f6356b94004ae2d4"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/configLoader/findup.js", + statementMap: { + "0": { + start: { + line: 14, + column: 4 + }, + end: { + line: 14, + column: 37 + } + }, + "1": { + start: { + line: 15, + column: 4 + }, + end: { + line: 15, + column: 25 + } + }, + "2": { + start: { + line: 16, + column: 4 + }, + end: { + line: 16, + column: 44 + } + }, + "3": { + start: { + line: 18, + column: 4 + }, + end: { + line: 33, + column: 39 + } + }, + "4": { + start: { + line: 19, + column: 8 + }, + end: { + line: 25, + column: 14 + } + }, + "5": { + start: { + line: 20, + column: 29 + }, + end: { + line: 20, + column: 59 + } + }, + "6": { + start: { + line: 22, + column: 12 + }, + end: { + line: 24, + column: 13 + } + }, + "7": { + start: { + line: 23, + column: 16 + }, + end: { + line: 23, + column: 62 + } + }, + "8": { + start: { + line: 27, + column: 8 + }, + end: { + line: 29, + column: 9 + } + }, + "9": { + start: { + line: 28, + column: 12 + }, + end: { + line: 28, + column: 48 + } + }, + "10": { + start: { + line: 31, + column: 8 + }, + end: { + line: 31, + column: 31 + } + }, + "11": { + start: { + line: 32, + column: 8 + }, + end: { + line: 32, + column: 54 + } + } + }, + fnMap: { + "0": { + name: "findup", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 15 + } + }, + loc: { + start: { + line: 8, + column: 40 + }, + end: { + line: 34, + column: 1 + } + }, + line: 8 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 19, + column: 31 + }, + end: { + line: 19, + column: 32 + } + }, + loc: { + start: { + line: 19, + column: 50 + }, + end: { + line: 25, + column: 9 + } + }, + line: 19 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 22, + column: 12 + }, + end: { + line: 24, + column: 13 + } + }, + type: "if", + locations: [{ + start: { + line: 22, + column: 12 + }, + end: { + line: 24, + column: 13 + } + }, { + start: { + line: 22, + column: 12 + }, + end: { + line: 24, + column: 13 + } + }], + line: 22 + }, + "1": { + loc: { + start: { + line: 27, + column: 8 + }, + end: { + line: 29, + column: 9 + } + }, + type: "if", + locations: [{ + start: { + line: 27, + column: 8 + }, + end: { + line: 29, + column: 9 + } + }, { + start: { + line: 27, + column: 8 + }, + end: { + line: 29, + column: 9 + } + }], + line: 27 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "ce6c9abea21cfa20eb8e2216f6356b94004ae2d4" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _glob = _interopRequireDefault(require("glob")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = findup; // Before, "findup-sync" package was used, +// but it does not provide filter callback + +exports.default = _default; + +function findup(patterns, options, fn) { + cov_1ay4fgfkgb.f[0]++; + + /* jshint -W083 */ + var lastpath; + var file; + cov_1ay4fgfkgb.s[0]++; + options = Object.create(options); + cov_1ay4fgfkgb.s[1]++; + options.maxDepth = 1; + cov_1ay4fgfkgb.s[2]++; + options.cwd = _path.default.resolve(options.cwd); + cov_1ay4fgfkgb.s[3]++; + + do { + cov_1ay4fgfkgb.s[4]++; + file = patterns.filter(function (pattern) { + cov_1ay4fgfkgb.f[1]++; + var configPath = (cov_1ay4fgfkgb.s[5]++, _glob.default.sync(pattern, options)[0]); + cov_1ay4fgfkgb.s[6]++; + + if (configPath) { + cov_1ay4fgfkgb.b[0][0]++; + cov_1ay4fgfkgb.s[7]++; + return fn(_path.default.join(options.cwd, configPath)); + } else { + cov_1ay4fgfkgb.b[0][1]++; + } + })[0]; + cov_1ay4fgfkgb.s[8]++; + + if (file) { + cov_1ay4fgfkgb.b[1][0]++; + cov_1ay4fgfkgb.s[9]++; + return _path.default.join(options.cwd, file); + } else { + cov_1ay4fgfkgb.b[1][1]++; + } + + cov_1ay4fgfkgb.s[10]++; + lastpath = options.cwd; + cov_1ay4fgfkgb.s[11]++; + options.cwd = _path.default.resolve(options.cwd, '..'); + } while (options.cwd !== lastpath); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/configLoader/getContent.js b/node_modules/commitizen/dist/configLoader/getContent.js new file mode 100644 index 00000000..5fa3aa5b --- /dev/null +++ b/node_modules/commitizen/dist/configLoader/getContent.js @@ -0,0 +1,714 @@ +"use strict"; + +var cov_1ia30hret7 = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/configLoader/getContent.js"; + var hash = "dd54b9863cc28669094c54e487b6ac45b6fa0f1b"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/configLoader/getContent.js", + statementMap: { + "0": { + start: { + line: 20, + column: 23 + }, + end: { + line: 20, + column: 45 + } + }, + "1": { + start: { + line: 21, + column: 21 + }, + end: { + line: 21, + column: 75 + } + }, + "2": { + start: { + line: 22, + column: 23 + }, + end: { + line: 22, + column: 56 + } + }, + "3": { + start: { + line: 23, + column: 18 + }, + end: { + line: 25, + column: 40 + } + }, + "4": { + start: { + line: 24, + column: 20 + }, + end: { + line: 24, + column: 59 + } + }, + "5": { + start: { + line: 25, + column: 20 + }, + end: { + line: 25, + column: 40 + } + }, + "6": { + start: { + line: 27, + column: 4 + }, + end: { + line: 42, + column: 5 + } + }, + "7": { + start: { + line: 28, + column: 23 + }, + end: { + line: 28, + column: 40 + } + }, + "8": { + start: { + line: 30, + column: 8 + }, + end: { + line: 32, + column: 11 + } + }, + "9": { + start: { + line: 34, + column: 8 + }, + end: { + line: 34, + column: 22 + } + }, + "10": { + start: { + line: 36, + column: 8 + }, + end: { + line: 39, + column: 21 + } + }, + "11": { + start: { + line: 41, + column: 8 + }, + end: { + line: 41, + column: 20 + } + }, + "12": { + start: { + line: 52, + column: 4 + }, + end: { + line: 54, + column: 5 + } + }, + "13": { + start: { + line: 53, + column: 6 + }, + end: { + line: 53, + column: 13 + } + }, + "14": { + start: { + line: 56, + column: 25 + }, + end: { + line: 56, + column: 64 + } + }, + "15": { + start: { + line: 57, + column: 27 + }, + end: { + line: 57, + column: 54 + } + }, + "16": { + start: { + line: 59, + column: 4 + }, + end: { + line: 61, + column: 5 + } + }, + "17": { + start: { + line: 60, + column: 6 + }, + end: { + line: 60, + column: 47 + } + }, + "18": { + start: { + line: 63, + column: 20 + }, + end: { + line: 63, + column: 51 + } + }, + "19": { + start: { + line: 64, + column: 4 + }, + end: { + line: 64, + column: 56 + } + }, + "20": { + start: { + line: 75, + column: 22 + }, + end: { + line: 75, + column: 49 + } + }, + "21": { + start: { + line: 77, + column: 2 + }, + end: { + line: 79, + column: 3 + } + }, + "22": { + start: { + line: 78, + column: 4 + }, + end: { + line: 78, + column: 96 + } + }, + "23": { + start: { + line: 81, + column: 2 + }, + end: { + line: 81, + column: 50 + } + } + }, + fnMap: { + "0": { + name: "readConfigContent", + decl: { + start: { + line: 19, + column: 9 + }, + end: { + line: 19, + column: 26 + } + }, + loc: { + start: { + line: 19, + column: 40 + }, + end: { + line: 43, + column: 1 + } + }, + line: 19 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 24, + column: 6 + }, + end: { + line: 24, + column: 7 + } + }, + loc: { + start: { + line: 24, + column: 20 + }, + end: { + line: 24, + column: 59 + } + }, + line: 24 + }, + "2": { + name: "(anonymous_2)", + decl: { + start: { + line: 25, + column: 6 + }, + end: { + line: 25, + column: 7 + } + }, + loc: { + start: { + line: 25, + column: 20 + }, + end: { + line: 25, + column: 40 + } + }, + line: 25 + }, + "3": { + name: "getConfigContent", + decl: { + start: { + line: 51, + column: 9 + }, + end: { + line: 51, + column: 25 + } + }, + loc: { + start: { + line: 51, + column: 54 + }, + end: { + line: 65, + column: 1 + } + }, + line: 51 + }, + "4": { + name: "readConfigFileContent", + decl: { + start: { + line: 73, + column: 9 + }, + end: { + line: 73, + column: 30 + } + }, + loc: { + start: { + line: 73, + column: 44 + }, + end: { + line: 82, + column: 1 + } + }, + line: 73 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 21, + column: 21 + }, + end: { + line: 21, + column: 75 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 21, + column: 21 + }, + end: { + line: 21, + column: 45 + } + }, { + start: { + line: 21, + column: 49 + }, + end: { + line: 21, + column: 75 + } + }], + line: 21 + }, + "1": { + loc: { + start: { + line: 23, + column: 18 + }, + end: { + line: 25, + column: 40 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 24, + column: 6 + }, + end: { + line: 24, + column: 59 + } + }, { + start: { + line: 25, + column: 6 + }, + end: { + line: 25, + column: 40 + } + }], + line: 23 + }, + "2": { + loc: { + start: { + line: 52, + column: 4 + }, + end: { + line: 54, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 52, + column: 4 + }, + end: { + line: 54, + column: 5 + } + }, { + start: { + line: 52, + column: 4 + }, + end: { + line: 54, + column: 5 + } + }], + line: 52 + }, + "3": { + loc: { + start: { + line: 59, + column: 4 + }, + end: { + line: 61, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 59, + column: 4 + }, + end: { + line: 61, + column: 5 + } + }, { + start: { + line: 59, + column: 4 + }, + end: { + line: 61, + column: 5 + } + }], + line: 59 + }, + "4": { + loc: { + start: { + line: 77, + column: 2 + }, + end: { + line: 79, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 77, + column: 2 + }, + end: { + line: 79, + column: 3 + } + }, { + start: { + line: 77, + column: 2 + }, + end: { + line: 79, + column: 3 + } + }], + line: 77 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0, + "12": 0, + "13": 0, + "14": 0, + "15": 0, + "16": 0, + "17": 0, + "18": 0, + "19": 0, + "20": 0, + "21": 0, + "22": 0, + "23": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0], + "4": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "dd54b9863cc28669094c54e487b6ac45b6fa0f1b" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _fs = _interopRequireDefault(require("fs")); + +var _path = _interopRequireDefault(require("path")); + +var _stripJsonComments = _interopRequireDefault(require("strip-json-comments")); + +var _isUtf = _interopRequireDefault(require("is-utf8")); + +var _stripBom = _interopRequireDefault(require("strip-bom")); + +var _configLoader = require("../configLoader"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = getConfigContent; +/** + * Read the content of a configuration file + * - if not js or json: strip any comments + * - if js or json: require it + * @param {String} configPath - full path to configuration file + * @return {Object} + */ + +exports.default = _default; + +function readConfigContent(configPath) { + cov_1ia30hret7.f[0]++; + const parsedPath = (cov_1ia30hret7.s[0]++, _path.default.parse(configPath)); + const isRcFile = (cov_1ia30hret7.s[1]++, (cov_1ia30hret7.b[0][0]++, parsedPath.ext !== '.js') && (cov_1ia30hret7.b[0][1]++, parsedPath.ext !== '.json')); + const jsonString = (cov_1ia30hret7.s[2]++, readConfigFileContent(configPath)); + const parse = (cov_1ia30hret7.s[3]++, isRcFile ? (cov_1ia30hret7.b[1][0]++, contents => { + cov_1ia30hret7.f[1]++; + cov_1ia30hret7.s[4]++; + return JSON.parse((0, _stripJsonComments.default)(contents)); + }) : (cov_1ia30hret7.b[1][1]++, contents => { + cov_1ia30hret7.f[2]++; + cov_1ia30hret7.s[5]++; + return JSON.parse(contents); + })); + cov_1ia30hret7.s[6]++; + + try { + const parsed = (cov_1ia30hret7.s[7]++, parse(jsonString)); + cov_1ia30hret7.s[8]++; + Object.defineProperty(parsed, 'configPath', { + value: configPath + }); + cov_1ia30hret7.s[9]++; + return parsed; + } catch (error) { + cov_1ia30hret7.s[10]++; + error.message = [`Parsing JSON at ${configPath} for commitizen config failed:`, error.mesasge].join('\n'); + cov_1ia30hret7.s[11]++; + throw error; + } +} +/** + * Get content of the configuration file + * @param {String} configPath - partial path to configuration file + * @param {String} directory - directory path which will be joined with config argument + * @return {Object} + */ + + +function getConfigContent(configPath, baseDirectory) { + cov_1ia30hret7.f[3]++; + cov_1ia30hret7.s[12]++; + + if (!configPath) { + cov_1ia30hret7.b[2][0]++; + cov_1ia30hret7.s[13]++; + return; + } else { + cov_1ia30hret7.b[2][1]++; + } + + const resolvedPath = (cov_1ia30hret7.s[14]++, _path.default.resolve(baseDirectory, configPath)); + const configBasename = (cov_1ia30hret7.s[15]++, _path.default.basename(resolvedPath)); + cov_1ia30hret7.s[16]++; + + if (!_fs.default.existsSync(resolvedPath)) { + cov_1ia30hret7.b[3][0]++; + cov_1ia30hret7.s[17]++; + return (0, _configLoader.getNormalizedConfig)(resolvedPath); + } else { + cov_1ia30hret7.b[3][1]++; + } + + const content = (cov_1ia30hret7.s[18]++, readConfigContent(resolvedPath)); + cov_1ia30hret7.s[19]++; + return (0, _configLoader.getNormalizedConfig)(configBasename, content); +} + +; +/** + * Read proper content from config file. + * If the chartset of the config file is not utf-8, one error will be thrown. + * @param {String} configPath + * @return {String} + */ + +function readConfigFileContent(configPath) { + cov_1ia30hret7.f[4]++; + let rawBufContent = (cov_1ia30hret7.s[20]++, _fs.default.readFileSync(configPath)); + cov_1ia30hret7.s[21]++; + + if (!(0, _isUtf.default)(rawBufContent)) { + cov_1ia30hret7.b[4][0]++; + cov_1ia30hret7.s[22]++; + throw new Error(`The config file at "${configPath}" contains invalid charset, expect utf8`); + } else { + cov_1ia30hret7.b[4][1]++; + } + + cov_1ia30hret7.s[23]++; + return (0, _stripBom.default)(rawBufContent.toString("utf8")); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/configLoader/getNormalizedConfig.js b/node_modules/commitizen/dist/configLoader/getNormalizedConfig.js new file mode 100644 index 00000000..d0f2a961 --- /dev/null +++ b/node_modules/commitizen/dist/configLoader/getNormalizedConfig.js @@ -0,0 +1,404 @@ +"use strict"; + +var cov_163hsz6de = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/configLoader/getNormalizedConfig.js"; + var hash = "b5cc48d90f0f7346dcf9aa20c44722c91cbdc976"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/configLoader/getNormalizedConfig.js", + statementMap: { + "0": { + start: { + line: 7, + column: 2 + }, + end: { + line: 26, + column: 3 + } + }, + "1": { + start: { + line: 12, + column: 4 + }, + end: { + line: 22, + column: 5 + } + }, + "2": { + start: { + line: 13, + column: 6 + }, + end: { + line: 13, + column: 39 + } + }, + "3": { + start: { + line: 14, + column: 11 + }, + end: { + line: 22, + column: 5 + } + }, + "4": { + start: { + line: 17, + column: 6 + }, + end: { + line: 20, + column: 7 + } + }, + "5": { + start: { + line: 19, + column: 8 + }, + end: { + line: 19, + column: 341 + } + }, + "6": { + start: { + line: 21, + column: 6 + }, + end: { + line: 21, + column: 30 + } + }, + "7": { + start: { + line: 25, + column: 4 + }, + end: { + line: 25, + column: 19 + } + } + }, + fnMap: { + "0": { + name: "getNormalizedConfig", + decl: { + start: { + line: 5, + column: 9 + }, + end: { + line: 5, + column: 28 + } + }, + loc: { + start: { + line: 5, + column: 47 + }, + end: { + line: 28, + column: 1 + } + }, + line: 5 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 7, + column: 2 + }, + end: { + line: 26, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 7, + column: 2 + }, + end: { + line: 26, + column: 3 + } + }, { + start: { + line: 7, + column: 2 + }, + end: { + line: 26, + column: 3 + } + }], + line: 7 + }, + "1": { + loc: { + start: { + line: 7, + column: 6 + }, + end: { + line: 7, + column: 44 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 7, + column: 6 + }, + end: { + line: 7, + column: 13 + } + }, { + start: { + line: 7, + column: 18 + }, + end: { + line: 7, + column: 43 + } + }], + line: 7 + }, + "2": { + loc: { + start: { + line: 12, + column: 4 + }, + end: { + line: 22, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 12, + column: 4 + }, + end: { + line: 22, + column: 5 + } + }, { + start: { + line: 12, + column: 4 + }, + end: { + line: 22, + column: 5 + } + }], + line: 12 + }, + "3": { + loc: { + start: { + line: 12, + column: 8 + }, + end: { + line: 12, + column: 51 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 12, + column: 8 + }, + end: { + line: 12, + column: 22 + } + }, { + start: { + line: 12, + column: 26 + }, + end: { + line: 12, + column: 51 + } + }], + line: 12 + }, + "4": { + loc: { + start: { + line: 14, + column: 11 + }, + end: { + line: 22, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 14, + column: 11 + }, + end: { + line: 22, + column: 5 + } + }, { + start: { + line: 14, + column: 11 + }, + end: { + line: 22, + column: 5 + } + }], + line: 14 + }, + "5": { + loc: { + start: { + line: 17, + column: 6 + }, + end: { + line: 20, + column: 7 + } + }, + type: "if", + locations: [{ + start: { + line: 17, + column: 6 + }, + end: { + line: 20, + column: 7 + } + }, { + start: { + line: 17, + column: 6 + }, + end: { + line: 20, + column: 7 + } + }], + line: 17 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0 + }, + f: { + "0": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0], + "4": [0, 0], + "5": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "b5cc48d90f0f7346dcf9aa20c44722c91cbdc976" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +var _default = getNormalizedConfig; // Given a config and content, plucks the actual +// settings that we're interested in + +exports.default = _default; + +function getNormalizedConfig(config, content) { + cov_163hsz6de.f[0]++; + cov_163hsz6de.s[0]++; + + if ((cov_163hsz6de.b[1][0]++, content) && (cov_163hsz6de.b[1][1]++, config === 'package.json')) { + cov_163hsz6de.b[0][0]++; + cov_163hsz6de.s[1]++; + + // PACKAGE.JSON + // Use the npm config key, be good citizens + if ((cov_163hsz6de.b[3][0]++, content.config) && (cov_163hsz6de.b[3][1]++, content.config.commitizen)) { + cov_163hsz6de.b[2][0]++; + cov_163hsz6de.s[2]++; + return content.config.commitizen; + } else { + cov_163hsz6de.b[2][1]++; + cov_163hsz6de.s[3]++; + + if (content.czConfig) { + cov_163hsz6de.b[4][0]++; + cov_163hsz6de.s[4]++; + + // Old method, will be deprecated in 3.0.0 + // Suppress during test + if (typeof global.it !== 'function') { + cov_163hsz6de.b[5][0]++; + cov_163hsz6de.s[5]++; + console.error("\n********\nWARNING: This repository's package.json is using czConfig. czConfig will be deprecated in Commitizen 3. \nPlease use this instead:\n{\n \"config\": {\n \"commitizen\": {\n \"path\": \"./path/to/adapter\"\n }\n }\n}\nFor more information, see: http://commitizen.github.io/cz-cli/\n********\n"); + } else { + cov_163hsz6de.b[5][1]++; + } + + cov_163hsz6de.s[6]++; + return content.czConfig; + } else { + cov_163hsz6de.b[4][1]++; + } + } + } else { + cov_163hsz6de.b[0][1]++; + cov_163hsz6de.s[7]++; + // .cz.json or .czrc + return content; + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/configLoader/loader.js b/node_modules/commitizen/dist/configLoader/loader.js new file mode 100644 index 00000000..bb91f5cd --- /dev/null +++ b/node_modules/commitizen/dist/configLoader/loader.js @@ -0,0 +1,440 @@ +"use strict"; + +var cov_2972gu8ttd = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/configLoader/loader.js"; + var hash = "666b77714f71f6dbe5310b913cdea790fc9c2e39"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/configLoader/loader.js", + statementMap: { + "0": { + start: { + line: 22, + column: 20 + }, + end: { + line: 22, + column: 40 + } + }, + "1": { + start: { + line: 25, + column: 4 + }, + end: { + line: 27, + column: 5 + } + }, + "2": { + start: { + line: 26, + column: 8 + }, + end: { + line: 26, + column: 45 + } + }, + "3": { + start: { + line: 29, + column: 4 + }, + end: { + line: 37, + column: 6 + } + }, + "4": { + start: { + line: 31, + column: 12 + }, + end: { + line: 33, + column: 13 + } + }, + "5": { + start: { + line: 35, + column: 12 + }, + end: { + line: 35, + column: 24 + } + }, + "6": { + start: { + line: 39, + column: 4 + }, + end: { + line: 41, + column: 5 + } + }, + "7": { + start: { + line: 40, + column: 8 + }, + end: { + line: 40, + column: 23 + } + }, + "8": { + start: { + line: 43, + column: 4 + }, + end: { + line: 59, + column: 5 + } + } + }, + fnMap: { + "0": { + name: "loader", + decl: { + start: { + line: 20, + column: 9 + }, + end: { + line: 20, + column: 15 + } + }, + loc: { + start: { + line: 20, + column: 39 + }, + end: { + line: 60, + column: 1 + } + }, + line: 20 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 30, + column: 58 + }, + end: { + line: 30, + column: 59 + } + }, + loc: { + start: { + line: 30, + column: 80 + }, + end: { + line: 36, + column: 9 + } + }, + line: 30 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 22, + column: 20 + }, + end: { + line: 22, + column: 40 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 22, + column: 20 + }, + end: { + line: 22, + column: 23 + } + }, { + start: { + line: 22, + column: 27 + }, + end: { + line: 22, + column: 40 + } + }], + line: 22 + }, + "1": { + loc: { + start: { + line: 25, + column: 4 + }, + end: { + line: 27, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 25, + column: 4 + }, + end: { + line: 27, + column: 5 + } + }, { + start: { + line: 25, + column: 4 + }, + end: { + line: 27, + column: 5 + } + }], + line: 25 + }, + "2": { + loc: { + start: { + line: 31, + column: 12 + }, + end: { + line: 33, + column: 13 + } + }, + type: "if", + locations: [{ + start: { + line: 31, + column: 12 + }, + end: { + line: 33, + column: 13 + } + }, { + start: { + line: 31, + column: 12 + }, + end: { + line: 33, + column: 13 + } + }], + line: 31 + }, + "3": { + loc: { + start: { + line: 39, + column: 4 + }, + end: { + line: 41, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 39, + column: 4 + }, + end: { + line: 41, + column: 5 + } + }, { + start: { + line: 39, + column: 4 + }, + end: { + line: 41, + column: 5 + } + }], + line: 39 + }, + "4": { + loc: { + start: { + line: 43, + column: 4 + }, + end: { + line: 59, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 43, + column: 4 + }, + end: { + line: 59, + column: 5 + } + }], + line: 43 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0], + "4": [0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "666b77714f71f6dbe5310b913cdea790fc9c2e39" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _configLoader = require("../configLoader"); + +var _util = require("../common/util.js"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = loader; +/** + * Command line config helpers + * Shamelessly ripped from with slight modifications: + * https://github.com/jscs-dev/node-jscs/blob/master/lib/cli-config.js + */ + +/** + * Get content of the configuration file + * @param {String} config - partial path to configuration file + * @param {String} [cwd = process.cwd()] - directory path which will be joined with config argument + * @return {Object|undefined} + */ + +exports.default = _default; + +function loader(configs, config, cwd) { + cov_2972gu8ttd.f[0]++; + var content; + var directory = (cov_2972gu8ttd.s[0]++, (cov_2972gu8ttd.b[0][0]++, cwd) || (cov_2972gu8ttd.b[0][1]++, process.cwd())); // If config option is given, attempt to load it + + cov_2972gu8ttd.s[1]++; + + if (config) { + cov_2972gu8ttd.b[1][0]++; + cov_2972gu8ttd.s[2]++; + return (0, _configLoader.getContent)(config, directory); + } else { + cov_2972gu8ttd.b[1][1]++; + } + + cov_2972gu8ttd.s[3]++; + content = (0, _configLoader.getContent)((0, _configLoader.findup)(configs, { + nocase: true, + cwd: directory + }, function (configPath) { + cov_2972gu8ttd.f[1]++; + cov_2972gu8ttd.s[4]++; + + if (_path.default.basename(configPath) === 'package.json') {// return !!this.getContent(configPath); + + cov_2972gu8ttd.b[2][0]++; + } else { + cov_2972gu8ttd.b[2][1]++; + } + + cov_2972gu8ttd.s[5]++; + return true; + })); + cov_2972gu8ttd.s[6]++; + + if (content) { + cov_2972gu8ttd.b[3][0]++; + cov_2972gu8ttd.s[7]++; + return content; + } else { + cov_2972gu8ttd.b[3][1]++; + } + /* istanbul ignore if */ + + + cov_2972gu8ttd.s[8]++; + + if (!(0, _util.isInTest)()) { + // Try to load standard configs from home dir + var directoryArr = [process.env.USERPROFILE, process.env.HOMEPATH, process.env.HOME]; + + for (var i = 0, dirLen = directoryArr.length; i < dirLen; i++) { + if (!directoryArr[i]) { + continue; + } + + for (var j = 0, len = configs.length; j < len; j++) { + content = (0, _configLoader.getContent)(configs[j], directoryArr[i]); + + if (content) { + return content; + } + } + } + } else { + cov_2972gu8ttd.b[4][0]++; + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/git.js b/node_modules/commitizen/dist/git.js new file mode 100644 index 00000000..6401a062 --- /dev/null +++ b/node_modules/commitizen/dist/git.js @@ -0,0 +1,51 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +Object.defineProperty(exports, "addPath", { + enumerable: true, + get: function () { + return _add.addPath; + } +}); +Object.defineProperty(exports, "addFile", { + enumerable: true, + get: function () { + return _add.addFile; + } +}); +Object.defineProperty(exports, "commit", { + enumerable: true, + get: function () { + return _commit.commit; + } +}); +Object.defineProperty(exports, "init", { + enumerable: true, + get: function () { + return _init.init; + } +}); +Object.defineProperty(exports, "log", { + enumerable: true, + get: function () { + return _log.log; + } +}); +Object.defineProperty(exports, "whatChanged", { + enumerable: true, + get: function () { + return _whatChanged.whatChanged; + } +}); + +var _add = require("./git/add"); + +var _commit = require("./git/commit"); + +var _init = require("./git/init"); + +var _log = require("./git/log"); + +var _whatChanged = require("./git/whatChanged"); \ No newline at end of file diff --git a/node_modules/commitizen/dist/git/add.js b/node_modules/commitizen/dist/git/add.js new file mode 100644 index 00000000..541afed3 --- /dev/null +++ b/node_modules/commitizen/dist/git/add.js @@ -0,0 +1,137 @@ +"use strict"; + +var cov_v1ucos01h = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/git/add.js"; + var hash = "de42aff6417c2d8c31ffa220f836616b163f9dfc"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/git/add.js", + statementMap: { + "0": { + start: { + line: 12, + column: 2 + }, + end: { + line: 12, + column: 65 + } + }, + "1": { + start: { + line: 19, + column: 2 + }, + end: { + line: 19, + column: 70 + } + } + }, + fnMap: { + "0": { + name: "addPath", + decl: { + start: { + line: 11, + column: 9 + }, + end: { + line: 11, + column: 16 + } + }, + loc: { + start: { + line: 11, + column: 28 + }, + end: { + line: 13, + column: 1 + } + }, + line: 11 + }, + "1": { + name: "addFile", + decl: { + start: { + line: 18, + column: 9 + }, + end: { + line: 18, + column: 16 + } + }, + loc: { + start: { + line: 18, + column: 38 + }, + end: { + line: 20, + column: 1 + } + }, + line: 18 + } + }, + branchMap: {}, + s: { + "0": 0, + "1": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "de42aff6417c2d8c31ffa220f836616b163f9dfc" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.addPath = addPath; +exports.addFile = addFile; + +var _child_process = _interopRequireDefault(require("child_process")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Synchronously adds a path to git staging + */ +function addPath(repoPath) { + cov_v1ucos01h.f[0]++; + cov_v1ucos01h.s[0]++; + + _child_process.default.spawnSync('git', ['add', '.'], { + cwd: repoPath + }); +} +/** + * Synchronously adds a file to git staging + */ + + +function addFile(repoPath, filename) { + cov_v1ucos01h.f[1]++; + cov_v1ucos01h.s[1]++; + + _child_process.default.spawnSync('git', ['add', filename], { + cwd: repoPath + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/git/commit.js b/node_modules/commitizen/dist/git/commit.js new file mode 100644 index 00000000..8895e6d8 --- /dev/null +++ b/node_modules/commitizen/dist/git/commit.js @@ -0,0 +1,865 @@ +"use strict"; + +var cov_2p3l72uoj0 = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/git/commit.js"; + var hash = "c9997db9a0fd1e02a729beec4d51316bd4c3dc83"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/git/commit.js", + statementMap: { + "0": { + start: { + line: 15, + column: 15 + }, + end: { + line: 15, + column: 20 + } + }, + "1": { + start: { + line: 20, + column: 2 + }, + end: { + line: 81, + column: 3 + } + }, + "2": { + start: { + line: 21, + column: 15 + }, + end: { + line: 21, + column: 73 + } + }, + "3": { + start: { + line: 22, + column: 16 + }, + end: { + line: 25, + column: 6 + } + }, + "4": { + start: { + line: 27, + column: 4 + }, + end: { + line: 32, + column: 7 + } + }, + "5": { + start: { + line: 28, + column: 6 + }, + end: { + line: 28, + column: 25 + } + }, + "6": { + start: { + line: 28, + column: 18 + }, + end: { + line: 28, + column: 25 + } + }, + "7": { + start: { + line: 29, + column: 6 + }, + end: { + line: 29, + column: 20 + } + }, + "8": { + start: { + line: 31, + column: 6 + }, + end: { + line: 31, + column: 16 + } + }, + "9": { + start: { + line: 34, + column: 4 + }, + end: { + line: 51, + column: 7 + } + }, + "10": { + start: { + line: 35, + column: 6 + }, + end: { + line: 35, + column: 25 + } + }, + "11": { + start: { + line: 35, + column: 18 + }, + end: { + line: 35, + column: 25 + } + }, + "12": { + start: { + line: 36, + column: 6 + }, + end: { + line: 36, + column: 20 + } + }, + "13": { + start: { + line: 38, + column: 6 + }, + end: { + line: 50, + column: 7 + } + }, + "14": { + start: { + line: 39, + column: 8 + }, + end: { + line: 46, + column: 9 + } + }, + "15": { + start: { + line: 40, + column: 10 + }, + end: { + line: 45, + column: 14 + } + }, + "16": { + start: { + line: 47, + column: 8 + }, + end: { + line: 47, + column: 95 + } + }, + "17": { + start: { + line: 49, + column: 8 + }, + end: { + line: 49, + column: 19 + } + }, + "18": { + start: { + line: 53, + column: 27 + }, + end: { + line: 53, + column: 70 + } + }, + "19": { + start: { + line: 54, + column: 4 + }, + end: { + line: 80, + column: 5 + } + }, + "20": { + start: { + line: 55, + column: 17 + }, + end: { + line: 55, + column: 46 + } + }, + "21": { + start: { + line: 56, + column: 6 + }, + end: { + line: 63, + column: 7 + } + }, + "22": { + start: { + line: 57, + column: 8 + }, + end: { + line: 57, + column: 43 + } + }, + "23": { + start: { + line: 58, + column: 8 + }, + end: { + line: 58, + column: 19 + } + }, + "24": { + start: { + line: 60, + column: 8 + }, + end: { + line: 60, + column: 16 + } + }, + "25": { + start: { + line: 62, + column: 8 + }, + end: { + line: 62, + column: 22 + } + }, + "26": { + start: { + line: 67, + column: 6 + }, + end: { + line: 79, + column: 7 + } + }, + "27": { + start: { + line: 68, + column: 19 + }, + end: { + line: 68, + column: 49 + } + }, + "28": { + start: { + line: 69, + column: 8 + }, + end: { + line: 76, + column: 9 + } + }, + "29": { + start: { + line: 70, + column: 10 + }, + end: { + line: 70, + column: 45 + } + }, + "30": { + start: { + line: 71, + column: 10 + }, + end: { + line: 71, + column: 21 + } + }, + "31": { + start: { + line: 73, + column: 10 + }, + end: { + line: 73, + column: 18 + } + }, + "32": { + start: { + line: 75, + column: 10 + }, + end: { + line: 75, + column: 24 + } + }, + "33": { + start: { + line: 78, + column: 8 + }, + end: { + line: 78, + column: 16 + } + } + }, + fnMap: { + "0": { + name: "commit", + decl: { + start: { + line: 14, + column: 9 + }, + end: { + line: 14, + column: 15 + } + }, + loc: { + start: { + line: 14, + column: 51 + }, + end: { + line: 82, + column: 1 + } + }, + line: 14 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 27, + column: 22 + }, + end: { + line: 27, + column: 23 + } + }, + loc: { + start: { + line: 27, + column: 37 + }, + end: { + line: 32, + column: 5 + } + }, + line: 27 + }, + "2": { + name: "(anonymous_2)", + decl: { + start: { + line: 34, + column: 21 + }, + end: { + line: 34, + column: 22 + } + }, + loc: { + start: { + line: 34, + column: 45 + }, + end: { + line: 51, + column: 5 + } + }, + line: 34 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 20, + column: 2 + }, + end: { + line: 81, + column: 3 + } + }, + type: "if", + locations: [{ + start: { + line: 20, + column: 2 + }, + end: { + line: 81, + column: 3 + } + }, { + start: { + line: 20, + column: 2 + }, + end: { + line: 81, + column: 3 + } + }], + line: 20 + }, + "1": { + loc: { + start: { + line: 21, + column: 53 + }, + end: { + line: 21, + column: 71 + } + }, + type: "binary-expr", + locations: [{ + start: { + line: 21, + column: 53 + }, + end: { + line: 21, + column: 65 + } + }, { + start: { + line: 21, + column: 69 + }, + end: { + line: 21, + column: 71 + } + }], + line: 21 + }, + "2": { + loc: { + start: { + line: 24, + column: 13 + }, + end: { + line: 24, + column: 49 + } + }, + type: "cond-expr", + locations: [{ + start: { + line: 24, + column: 29 + }, + end: { + line: 24, + column: 37 + } + }, { + start: { + line: 24, + column: 40 + }, + end: { + line: 24, + column: 49 + } + }], + line: 24 + }, + "3": { + loc: { + start: { + line: 28, + column: 6 + }, + end: { + line: 28, + column: 25 + } + }, + type: "if", + locations: [{ + start: { + line: 28, + column: 6 + }, + end: { + line: 28, + column: 25 + } + }, { + start: { + line: 28, + column: 6 + }, + end: { + line: 28, + column: 25 + } + }], + line: 28 + }, + "4": { + loc: { + start: { + line: 35, + column: 6 + }, + end: { + line: 35, + column: 25 + } + }, + type: "if", + locations: [{ + start: { + line: 35, + column: 6 + }, + end: { + line: 35, + column: 25 + } + }, { + start: { + line: 35, + column: 6 + }, + end: { + line: 35, + column: 25 + } + }], + line: 35 + }, + "5": { + loc: { + start: { + line: 38, + column: 6 + }, + end: { + line: 50, + column: 7 + } + }, + type: "if", + locations: [{ + start: { + line: 38, + column: 6 + }, + end: { + line: 50, + column: 7 + } + }, { + start: { + line: 38, + column: 6 + }, + end: { + line: 50, + column: 7 + } + }], + line: 38 + }, + "6": { + loc: { + start: { + line: 39, + column: 8 + }, + end: { + line: 46, + column: 9 + } + }, + type: "if", + locations: [{ + start: { + line: 39, + column: 8 + }, + end: { + line: 46, + column: 9 + } + }, { + start: { + line: 39, + column: 8 + }, + end: { + line: 46, + column: 9 + } + }], + line: 39 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0, + "4": 0, + "5": 0, + "6": 0, + "7": 0, + "8": 0, + "9": 0, + "10": 0, + "11": 0, + "12": 0, + "13": 0, + "14": 0, + "15": 0, + "16": 0, + "17": 0, + "18": 0, + "19": 0, + "20": 0, + "21": 0, + "22": 0, + "23": 0, + "24": 0, + "25": 0, + "26": 0, + "27": 0, + "28": 0, + "29": 0, + "30": 0, + "31": 0, + "32": 0, + "33": 0 + }, + f: { + "0": 0, + "1": 0, + "2": 0 + }, + b: { + "0": [0, 0], + "1": [0, 0], + "2": [0, 0], + "3": [0, 0], + "4": [0, 0], + "5": [0, 0], + "6": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "c9997db9a0fd1e02a729beec4d51316bd4c3dc83" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.commit = commit; + +var _child_process = require("child_process"); + +var _path = _interopRequireDefault(require("path")); + +var _fs = require("fs"); + +var _dedent = _interopRequireDefault(require("dedent")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Asynchronously git commit at a given path with a message + */ +function commit(repoPath, message, options, done) { + cov_2p3l72uoj0.f[0]++; + let called = (cov_2p3l72uoj0.s[0]++, false); // commit the file by spawning a git process, unless the --hook + // option was provided. in that case, write the commit message into + // the .git/COMMIT_EDITMSG file + + cov_2p3l72uoj0.s[1]++; + + if (!options.hookMode) { + cov_2p3l72uoj0.b[0][0]++; + let args = (cov_2p3l72uoj0.s[2]++, ['commit', '-m', (0, _dedent.default)(message), ...((cov_2p3l72uoj0.b[1][0]++, options.args) || (cov_2p3l72uoj0.b[1][1]++, []))]); + let child = (cov_2p3l72uoj0.s[3]++, (0, _child_process.spawn)('git', args, { + cwd: repoPath, + stdio: options.quiet ? (cov_2p3l72uoj0.b[2][0]++, 'ignore') : (cov_2p3l72uoj0.b[2][1]++, 'inherit') + })); + cov_2p3l72uoj0.s[4]++; + child.on('error', function (err) { + cov_2p3l72uoj0.f[1]++; + cov_2p3l72uoj0.s[5]++; + + if (called) { + cov_2p3l72uoj0.b[3][0]++; + cov_2p3l72uoj0.s[6]++; + return; + } else { + cov_2p3l72uoj0.b[3][1]++; + } + + cov_2p3l72uoj0.s[7]++; + called = true; + cov_2p3l72uoj0.s[8]++; + done(err); + }); + cov_2p3l72uoj0.s[9]++; + child.on('exit', function (code, signal) { + cov_2p3l72uoj0.f[2]++; + cov_2p3l72uoj0.s[10]++; + + if (called) { + cov_2p3l72uoj0.b[4][0]++; + cov_2p3l72uoj0.s[11]++; + return; + } else { + cov_2p3l72uoj0.b[4][1]++; + } + + cov_2p3l72uoj0.s[12]++; + called = true; + cov_2p3l72uoj0.s[13]++; + + if (code) { + cov_2p3l72uoj0.b[5][0]++; + cov_2p3l72uoj0.s[14]++; + + if (code === 128) { + cov_2p3l72uoj0.b[6][0]++; + cov_2p3l72uoj0.s[15]++; + console.warn(` + Git exited with code 128. Did you forget to run: + + git config --global user.email "you@example.com" + git config --global user.name "Your Name" + `); + } else { + cov_2p3l72uoj0.b[6][1]++; + } + + cov_2p3l72uoj0.s[16]++; + done(Object.assign(new Error(`git exited with error code ${code}`), { + code, + signal + })); + } else { + cov_2p3l72uoj0.b[5][1]++; + cov_2p3l72uoj0.s[17]++; + done(null); + } + }); + } else { + cov_2p3l72uoj0.b[0][1]++; + const commitFilePath = (cov_2p3l72uoj0.s[18]++, _path.default.join(repoPath, '/.git/COMMIT_EDITMSG')); + cov_2p3l72uoj0.s[19]++; + + try { + const fd = (cov_2p3l72uoj0.s[20]++, (0, _fs.openSync)(commitFilePath, 'w')); + cov_2p3l72uoj0.s[21]++; + + try { + cov_2p3l72uoj0.s[22]++; + (0, _fs.writeFileSync)(fd, (0, _dedent.default)(message)); + cov_2p3l72uoj0.s[23]++; + done(null); + } catch (e) { + cov_2p3l72uoj0.s[24]++; + done(e); + } finally { + cov_2p3l72uoj0.s[25]++; + (0, _fs.closeSync)(fd); + } + } catch (e) { + cov_2p3l72uoj0.s[26]++; + + // windows doesn't allow opening existing hidden files + // in 'w' mode... but it does let you do 'r+'! + try { + const fd = (cov_2p3l72uoj0.s[27]++, (0, _fs.openSync)(commitFilePath, 'r+')); + cov_2p3l72uoj0.s[28]++; + + try { + cov_2p3l72uoj0.s[29]++; + (0, _fs.writeFileSync)(fd, (0, _dedent.default)(message)); + cov_2p3l72uoj0.s[30]++; + done(null); + } catch (e) { + cov_2p3l72uoj0.s[31]++; + done(e); + } finally { + cov_2p3l72uoj0.s[32]++; + (0, _fs.closeSync)(fd); + } + } catch (e) { + cov_2p3l72uoj0.s[33]++; + done(e); + } + } + } +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/git/init.js b/node_modules/commitizen/dist/git/init.js new file mode 100644 index 00000000..5d65517e --- /dev/null +++ b/node_modules/commitizen/dist/git/init.js @@ -0,0 +1,87 @@ +"use strict"; + +var cov_1vuql1smi = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/git/init.js"; + var hash = "ae5fc5e3b2317c0b2f76888f1b605cc82480e6b1"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/git/init.js", + statementMap: { + "0": { + start: { + line: 9, + column: 2 + }, + end: { + line: 9, + column: 61 + } + } + }, + fnMap: { + "0": { + name: "init", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 13 + } + }, + loc: { + start: { + line: 8, + column: 25 + }, + end: { + line: 10, + column: 1 + } + }, + line: 8 + } + }, + branchMap: {}, + s: { + "0": 0 + }, + f: { + "0": 0 + }, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "ae5fc5e3b2317c0b2f76888f1b605cc82480e6b1" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.init = init; + +var _child_process = _interopRequireDefault(require("child_process")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +/** + * Synchronously creates a new git repo at a path + */ +function init(repoPath) { + cov_1vuql1smi.f[0]++; + cov_1vuql1smi.s[0]++; + + _child_process.default.spawnSync('git', ['init'], { + cwd: repoPath + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/git/log.js b/node_modules/commitizen/dist/git/log.js new file mode 100644 index 00000000..5e19a636 --- /dev/null +++ b/node_modules/commitizen/dist/git/log.js @@ -0,0 +1,193 @@ +"use strict"; + +var cov_1pcjxy17rs = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/git/log.js"; + var hash = "a2f2b5ee5865d599f5247bc5491d4c7f473032c3"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/git/log.js", + statementMap: { + "0": { + start: { + line: 9, + column: 2 + }, + end: { + line: 17, + column: 5 + } + }, + "1": { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + "2": { + start: { + line: 14, + column: 6 + }, + end: { + line: 14, + column: 18 + } + }, + "3": { + start: { + line: 16, + column: 4 + }, + end: { + line: 16, + column: 17 + } + } + }, + fnMap: { + "0": { + name: "log", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 12 + } + }, + loc: { + start: { + line: 8, + column: 30 + }, + end: { + line: 18, + column: 1 + } + }, + line: 8 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 12, + column: 5 + }, + end: { + line: 12, + column: 6 + } + }, + loc: { + start: { + line: 12, + column: 38 + }, + end: { + line: 17, + column: 3 + } + }, + line: 12 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }], + line: 13 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: { + "0": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "a2f2b5ee5865d599f5247bc5491d4c7f473032c3" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.log = log; + +var _child_process = require("child_process"); + +/** + * Asynchronously gets the git log output + */ +function log(repoPath, done) { + cov_1pcjxy17rs.f[0]++; + cov_1pcjxy17rs.s[0]++; + (0, _child_process.exec)('git log', { + maxBuffer: Infinity, + cwd: repoPath + }, function (error, stdout, stderr) { + cov_1pcjxy17rs.f[1]++; + cov_1pcjxy17rs.s[1]++; + + if (error) { + cov_1pcjxy17rs.b[0][0]++; + cov_1pcjxy17rs.s[2]++; + throw error; + } else { + cov_1pcjxy17rs.b[0][1]++; + } + + cov_1pcjxy17rs.s[3]++; + done(stdout); + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/git/whatChanged.js b/node_modules/commitizen/dist/git/whatChanged.js new file mode 100644 index 00000000..3cb9df00 --- /dev/null +++ b/node_modules/commitizen/dist/git/whatChanged.js @@ -0,0 +1,193 @@ +"use strict"; + +var cov_kjeoodjke = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/git/whatChanged.js"; + var hash = "569386e530959b14e2de565d34b864abdea6e704"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/git/whatChanged.js", + statementMap: { + "0": { + start: { + line: 9, + column: 2 + }, + end: { + line: 17, + column: 5 + } + }, + "1": { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + "2": { + start: { + line: 14, + column: 6 + }, + end: { + line: 14, + column: 18 + } + }, + "3": { + start: { + line: 16, + column: 4 + }, + end: { + line: 16, + column: 17 + } + } + }, + fnMap: { + "0": { + name: "whatChanged", + decl: { + start: { + line: 8, + column: 9 + }, + end: { + line: 8, + column: 20 + } + }, + loc: { + start: { + line: 8, + column: 38 + }, + end: { + line: 18, + column: 1 + } + }, + line: 8 + }, + "1": { + name: "(anonymous_1)", + decl: { + start: { + line: 12, + column: 5 + }, + end: { + line: 12, + column: 6 + } + }, + loc: { + start: { + line: 12, + column: 38 + }, + end: { + line: 17, + column: 3 + } + }, + line: 12 + } + }, + branchMap: { + "0": { + loc: { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, + type: "if", + locations: [{ + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }, { + start: { + line: 13, + column: 4 + }, + end: { + line: 15, + column: 5 + } + }], + line: 13 + } + }, + s: { + "0": 0, + "1": 0, + "2": 0, + "3": 0 + }, + f: { + "0": 0, + "1": 0 + }, + b: { + "0": [0, 0] + }, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "569386e530959b14e2de565d34b864abdea6e704" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.whatChanged = whatChanged; + +var _child_process = require("child_process"); + +/** + * Asynchronously gets the git whatchanged output + */ +function whatChanged(repoPath, done) { + cov_kjeoodjke.f[0]++; + cov_kjeoodjke.s[0]++; + (0, _child_process.exec)('git whatchanged', { + maxBuffer: Infinity, + cwd: repoPath + }, function (error, stdout, stderr) { + cov_kjeoodjke.f[1]++; + cov_kjeoodjke.s[1]++; + + if (error) { + cov_kjeoodjke.b[0][0]++; + cov_kjeoodjke.s[2]++; + throw error; + } else { + cov_kjeoodjke.b[0][1]++; + } + + cov_kjeoodjke.s[3]++; + done(stdout); + }); +} \ No newline at end of file diff --git a/node_modules/commitizen/dist/index.js b/node_modules/commitizen/dist/index.js new file mode 100644 index 00000000..9470efe6 --- /dev/null +++ b/node_modules/commitizen/dist/index.js @@ -0,0 +1,54 @@ +"use strict"; + +var cov_xhq5bzbsy = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/index.js"; + var hash = "de9384b8be06a959156af3fb18997c6ed8feb51b"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/index.js", + statementMap: { + "0": { + start: { + line: 1, + column: 17 + }, + end: { + line: 1, + column: 40 + } + }, + "1": { + start: { + line: 2, + column: 0 + }, + end: { + line: 2, + column: 28 + } + } + }, + fnMap: {}, + branchMap: {}, + s: { + "0": 0, + "1": 0 + }, + f: {}, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "de9384b8be06a959156af3fb18997c6ed8feb51b" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); + +var commitizen = (cov_xhq5bzbsy.s[0]++, require('./commitizen')); +cov_xhq5bzbsy.s[1]++; +module.exports = commitizen; \ No newline at end of file diff --git a/node_modules/commitizen/dist/npm.js b/node_modules/commitizen/dist/npm.js new file mode 100644 index 00000000..0eedbc9b --- /dev/null +++ b/node_modules/commitizen/dist/npm.js @@ -0,0 +1,27 @@ +// this file left blank until npm init is implemented +"use strict"; + +var cov_178kuy9ip = function () { + var path = "/home/travis/build/commitizen/cz-cli/src/npm.js"; + var hash = "bd1b4e9fdc894ac590ec57daa6833d10968fbc27"; + var global = new Function("return this")(); + var gcv = "__coverage__"; + var coverageData = { + path: "/home/travis/build/commitizen/cz-cli/src/npm.js", + statementMap: {}, + fnMap: {}, + branchMap: {}, + s: {}, + f: {}, + b: {}, + _coverageSchema: "43e27e138ebf9cfc5966b082cf9a028302ed4184", + hash: "bd1b4e9fdc894ac590ec57daa6833d10968fbc27" + }; + var coverage = global[gcv] || (global[gcv] = {}); + + if (coverage[path] && coverage[path].hash === hash) { + return coverage[path]; + } + + return coverage[path] = coverageData; +}(); \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/Explorer.d.ts b/node_modules/cosmiconfig/dist/Explorer.d.ts new file mode 100644 index 00000000..ffc1719e --- /dev/null +++ b/node_modules/cosmiconfig/dist/Explorer.d.ts @@ -0,0 +1,14 @@ +import { ExplorerBase } from './ExplorerBase'; +import { CosmiconfigResult, ExplorerOptions } from './types'; +declare class Explorer extends ExplorerBase { + constructor(options: ExplorerOptions); + search(searchFrom?: string): Promise; + private searchFromDirectory; + private searchDirectory; + private loadSearchPlace; + private loadFileContent; + private createCosmiconfigResult; + load(filepath: string): Promise; +} +export { Explorer }; +//# sourceMappingURL=Explorer.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/Explorer.d.ts.map b/node_modules/cosmiconfig/dist/Explorer.d.ts.map new file mode 100644 index 00000000..2d62edc1 --- /dev/null +++ b/node_modules/cosmiconfig/dist/Explorer.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"Explorer.d.ts","sourceRoot":"","sources":["../src/Explorer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAEhF,cAAM,QAAS,SAAQ,YAAY,CAAC,eAAe,CAAC;gBAC/B,OAAO,EAAE,eAAe;IAI9B,MAAM,CACjB,UAAU,GAAE,MAAsB,GACjC,OAAO,CAAC,iBAAiB,CAAC;YAOf,mBAAmB;YAuBnB,eAAe;YAaf,eAAe;YAYf,eAAe;YAef,uBAAuB;IAUxB,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAyBhE;AAED,OAAO,EAAE,QAAQ,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/Explorer.js b/node_modules/cosmiconfig/dist/Explorer.js new file mode 100644 index 00000000..17559950 --- /dev/null +++ b/node_modules/cosmiconfig/dist/Explorer.js @@ -0,0 +1,141 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.Explorer = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _ExplorerBase = require("./ExplorerBase"); + +var _readFile = require("./readFile"); + +var _cacheWrapper = require("./cacheWrapper"); + +var _getDirectory = require("./getDirectory"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function _asyncIterator(iterable) { var method; if (typeof Symbol !== "undefined") { if (Symbol.asyncIterator) { method = iterable[Symbol.asyncIterator]; if (method != null) return method.call(iterable); } if (Symbol.iterator) { method = iterable[Symbol.iterator]; if (method != null) return method.call(iterable); } } throw new TypeError("Object is not async iterable"); } + +class Explorer extends _ExplorerBase.ExplorerBase { + constructor(options) { + super(options); + } + + async search(searchFrom = process.cwd()) { + const startDirectory = await (0, _getDirectory.getDirectory)(searchFrom); + const result = await this.searchFromDirectory(startDirectory); + return result; + } + + async searchFromDirectory(dir) { + const absoluteDir = _path.default.resolve(process.cwd(), dir); + + const run = async () => { + const result = await this.searchDirectory(absoluteDir); + const nextDir = this.nextDirectoryToSearch(absoluteDir, result); + + if (nextDir) { + return this.searchFromDirectory(nextDir); + } + + const transformResult = await this.config.transform(result); + return transformResult; + }; + + if (this.searchCache) { + return (0, _cacheWrapper.cacheWrapper)(this.searchCache, absoluteDir, run); + } + + return run(); + } + + async searchDirectory(dir) { + var _iteratorNormalCompletion = true; + var _didIteratorError = false; + + var _iteratorError; + + try { + for (var _iterator = _asyncIterator(this.config.searchPlaces), _step, _value; _step = await _iterator.next(), _iteratorNormalCompletion = _step.done, _value = await _step.value, !_iteratorNormalCompletion; _iteratorNormalCompletion = true) { + const place = _value; + const placeResult = await this.loadSearchPlace(dir, place); + + if (this.shouldSearchStopWithResult(placeResult) === true) { + return placeResult; + } + } // config not found + + } catch (err) { + _didIteratorError = true; + _iteratorError = err; + } finally { + try { + if (!_iteratorNormalCompletion && _iterator.return != null) { + await _iterator.return(); + } + } finally { + if (_didIteratorError) { + throw _iteratorError; + } + } + } + + return null; + } + + async loadSearchPlace(dir, place) { + const filepath = _path.default.join(dir, place); + + const fileContents = await (0, _readFile.readFile)(filepath); + const result = await this.createCosmiconfigResult(filepath, fileContents); + return result; + } + + async loadFileContent(filepath, content) { + if (content === null) { + return null; + } + + if (content.trim() === '') { + return undefined; + } + + const loader = this.getLoaderEntryForFile(filepath); + const loaderResult = await loader(filepath, content); + return loaderResult; + } + + async createCosmiconfigResult(filepath, content) { + const fileContent = await this.loadFileContent(filepath, content); + const result = this.loadedContentToCosmiconfigResult(filepath, fileContent); + return result; + } + + async load(filepath) { + this.validateFilePath(filepath); + + const absoluteFilePath = _path.default.resolve(process.cwd(), filepath); + + const runLoad = async () => { + const fileContents = await (0, _readFile.readFile)(absoluteFilePath, { + throwNotFound: true + }); + const result = await this.createCosmiconfigResult(absoluteFilePath, fileContents); + const transformResult = await this.config.transform(result); + return transformResult; + }; + + if (this.loadCache) { + return (0, _cacheWrapper.cacheWrapper)(this.loadCache, absoluteFilePath, runLoad); + } + + return runLoad(); + } + +} + +exports.Explorer = Explorer; +//# sourceMappingURL=Explorer.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/Explorer.js.map b/node_modules/cosmiconfig/dist/Explorer.js.map new file mode 100644 index 00000000..c4f608f7 --- /dev/null +++ b/node_modules/cosmiconfig/dist/Explorer.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/Explorer.ts"],"names":["Explorer","ExplorerBase","constructor","options","search","searchFrom","process","cwd","startDirectory","result","searchFromDirectory","dir","absoluteDir","path","resolve","run","searchDirectory","nextDir","nextDirectoryToSearch","transformResult","config","transform","searchCache","searchPlaces","place","placeResult","loadSearchPlace","shouldSearchStopWithResult","filepath","join","fileContents","createCosmiconfigResult","loadFileContent","content","trim","undefined","loader","getLoaderEntryForFile","loaderResult","fileContent","loadedContentToCosmiconfigResult","load","validateFilePath","absoluteFilePath","runLoad","throwNotFound","loadCache"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAGA,MAAMA,QAAN,SAAuBC,0BAAvB,CAAqD;AAC5CC,EAAAA,WAAP,CAAmBC,OAAnB,EAA6C;AAC3C,UAAMA,OAAN;AACD;;AAED,QAAaC,MAAb,CACEC,UAAkB,GAAGC,OAAO,CAACC,GAAR,EADvB,EAE8B;AAC5B,UAAMC,cAAc,GAAG,MAAM,gCAAaH,UAAb,CAA7B;AACA,UAAMI,MAAM,GAAG,MAAM,KAAKC,mBAAL,CAAyBF,cAAzB,CAArB;AAEA,W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EA,aAAOU,eAAP;AACD,KAbD;;AAeA,QAAI,KAAK2B,SAAT,EAAoB;AAClB,aAAO,gCAAa,KAAKA,SAAlB,EAA6BH,gBAA7B,EAA+CC,OAA/C,CAAP;AACD;;AAED,WAAOA,OAAO,EAAd;AACD;;AA/GkD","sourcesContent":["import path from 'path';\nimport { ExplorerBase } from './ExplorerBase';\nimport { readFile } from './readFile';\nimport { cacheWrapper } from './cacheWrapper';\nimport { getDirectory } from './getDirectory';\nimport { CosmiconfigResult, ExplorerOptions, LoadedFileContent } from './types';\n\nclass Explorer extends ExplorerBase {\n public constructor(options: ExplorerOptions) {\n super(options);\n }\n\n public async search(\n searchFrom: string = process.cwd(),\n ): Promise {\n const startDirectory = await getDirectory(searchFrom);\n const result = await this.searchFromDirectory(startDirectory);\n\n return result;\n }\n\n private async searchFromDirectory(dir: string): Promise {\n const absoluteDir = path.resolve(process.cwd(), dir);\n\n const run = async (): Promise => {\n const result = await this.searchDirectory(absoluteDir);\n const nextDir = this.nextDirectoryToSearch(absoluteDir, result);\n\n if (nextDir) {\n return this.searchFromDirectory(nextDir);\n }\n\n const transformResult = await this.config.transform(result);\n\n return transformResult;\n };\n\n if (this.searchCache) {\n return cacheWrapper(this.searchCache, absoluteDir, run);\n }\n\n return run();\n }\n\n private async searchDirectory(dir: string): Promise {\n for await (const place of this.config.searchPlaces) {\n const placeResult = await this.loadSearchPlace(dir, place);\n\n if (this.shouldSearchStopWithResult(placeResult) === true) {\n return placeResult;\n }\n }\n\n // config not found\n return null;\n }\n\n private async loadSearchPlace(\n dir: string,\n place: string,\n ): Promise {\n const filepath = path.join(dir, place);\n const fileContents = await readFile(filepath);\n\n const result = await this.createCosmiconfigResult(filepath, fileContents);\n\n return result;\n }\n\n private async loadFileContent(\n filepath: string,\n content: string | null,\n ): Promise {\n if (content === null) {\n return null;\n }\n if (content.trim() === '') {\n return undefined;\n }\n const loader = this.getLoaderEntryForFile(filepath);\n const loaderResult = await loader(filepath, content);\n return loaderResult;\n }\n\n private async createCosmiconfigResult(\n filepath: string,\n content: string | null,\n ): Promise {\n const fileContent = await this.loadFileContent(filepath, content);\n const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);\n\n return result;\n }\n\n public async load(filepath: string): Promise {\n this.validateFilePath(filepath);\n const absoluteFilePath = path.resolve(process.cwd(), filepath);\n\n const runLoad = async (): Promise => {\n const fileContents = await readFile(absoluteFilePath, {\n throwNotFound: true,\n });\n\n const result = await this.createCosmiconfigResult(\n absoluteFilePath,\n fileContents,\n );\n\n const transformResult = await this.config.transform(result);\n\n return transformResult;\n };\n\n if (this.loadCache) {\n return cacheWrapper(this.loadCache, absoluteFilePath, runLoad);\n }\n\n return runLoad();\n }\n}\n\nexport { Explorer };\n"],"file":"Explorer.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerBase.d.ts b/node_modules/cosmiconfig/dist/ExplorerBase.d.ts new file mode 100644 index 00000000..77497032 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerBase.d.ts @@ -0,0 +1,21 @@ +import { CosmiconfigResult, ExplorerOptions, ExplorerOptionsSync, Cache, LoadedFileContent } from './types'; +import { Loader } from './index'; +declare class ExplorerBase { + protected readonly loadCache?: Cache; + protected readonly searchCache?: Cache; + protected readonly config: T; + constructor(options: T); + clearLoadCache(): void; + clearSearchCache(): void; + clearCaches(): void; + private validateConfig; + protected shouldSearchStopWithResult(result: CosmiconfigResult): boolean; + protected nextDirectoryToSearch(currentDir: string, currentResult: CosmiconfigResult): string | null; + private loadPackageProp; + protected getLoaderEntryForFile(filepath: string): Loader; + protected loadedContentToCosmiconfigResult(filepath: string, loadedContent: LoadedFileContent): CosmiconfigResult; + protected validateFilePath(filepath: string): void; +} +declare function getExtensionDescription(filepath: string): string; +export { ExplorerBase, getExtensionDescription }; +//# sourceMappingURL=ExplorerBase.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerBase.d.ts.map b/node_modules/cosmiconfig/dist/ExplorerBase.d.ts.map new file mode 100644 index 00000000..a55e67f2 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerBase.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ExplorerBase.d.ts","sourceRoot":"","sources":["../src/ExplorerBase.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,KAAK,EACL,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEjC,cAAM,YAAY,CAAC,CAAC,SAAS,eAAe,GAAG,mBAAmB;IAChE,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC;IACrC,SAAS,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IACvC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;gBAEV,OAAO,EAAE,CAAC;IAUtB,cAAc,IAAI,IAAI;IAMtB,gBAAgB,IAAI,IAAI;IAMxB,WAAW,IAAI,IAAI;IAK1B,OAAO,CAAC,cAAc;IAwBtB,SAAS,CAAC,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO;IAMxE,SAAS,CAAC,qBAAqB,CAC7B,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,iBAAiB,GAC/B,MAAM,GAAG,IAAI;IAWhB,OAAO,CAAC,eAAe;IASvB,SAAS,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAmBzD,SAAS,CAAC,gCAAgC,CACxC,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,iBAAiB,GAC/B,iBAAiB;IAUpB,SAAS,CAAC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;CAKnD;AAMD,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGzD;AAED,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerBase.js b/node_modules/cosmiconfig/dist/ExplorerBase.js new file mode 100644 index 00000000..213d34cb --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerBase.js @@ -0,0 +1,142 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getExtensionDescription = getExtensionDescription; +exports.ExplorerBase = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _loaders = require("./loaders"); + +var _getPropertyByPath = require("./getPropertyByPath"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +class ExplorerBase { + constructor(options) { + if (options.cache === true) { + this.loadCache = new Map(); + this.searchCache = new Map(); + } + + this.config = options; + this.validateConfig(); + } + + clearLoadCache() { + if (this.loadCache) { + this.loadCache.clear(); + } + } + + clearSearchCache() { + if (this.searchCache) { + this.searchCache.clear(); + } + } + + clearCaches() { + this.clearLoadCache(); + this.clearSearchCache(); + } + + validateConfig() { + const config = this.config; + config.searchPlaces.forEach(place => { + const loaderKey = _path.default.extname(place) || 'noExt'; + const loader = config.loaders[loaderKey]; + + if (!loader) { + throw new Error(`No loader specified for ${getExtensionDescription(place)}, so searchPlaces item "${place}" is invalid`); + } + + if (typeof loader !== 'function') { + throw new Error(`loader for ${getExtensionDescription(place)} is not a function (type provided: "${typeof loader}"), so searchPlaces item "${place}" is invalid`); + } + }); + } + + shouldSearchStopWithResult(result) { + if (result === null) return false; + if (result.isEmpty && this.config.ignoreEmptySearchPlaces) return false; + return true; + } + + nextDirectoryToSearch(currentDir, currentResult) { + if (this.shouldSearchStopWithResult(currentResult)) { + return null; + } + + const nextDir = nextDirUp(currentDir); + + if (nextDir === currentDir || currentDir === this.config.stopDir) { + return null; + } + + return nextDir; + } + + loadPackageProp(filepath, content) { + const parsedContent = _loaders.loaders.loadJson(filepath, content); + + const packagePropValue = (0, _getPropertyByPath.getPropertyByPath)(parsedContent, this.config.packageProp); + return packagePropValue || null; + } + + getLoaderEntryForFile(filepath) { + if (_path.default.basename(filepath) === 'package.json') { + const loader = this.loadPackageProp.bind(this); + return loader; + } + + const loaderKey = _path.default.extname(filepath) || 'noExt'; + const loader = this.config.loaders[loaderKey]; + + if (!loader) { + throw new Error(`No loader specified for ${getExtensionDescription(filepath)}`); + } + + return loader; + } + + loadedContentToCosmiconfigResult(filepath, loadedContent) { + if (loadedContent === null) { + return null; + } + + if (loadedContent === undefined) { + return { + filepath, + config: undefined, + isEmpty: true + }; + } + + return { + config: loadedContent, + filepath + }; + } + + validateFilePath(filepath) { + if (!filepath) { + throw new Error('load must pass a non-empty string'); + } + } + +} + +exports.ExplorerBase = ExplorerBase; + +function nextDirUp(dir) { + return _path.default.dirname(dir); +} + +function getExtensionDescription(filepath) { + const ext = _path.default.extname(filepath); + + return ext ? `extension "${ext}"` : 'files without extensions'; +} +//# sourceMappingURL=ExplorerBase.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerBase.js.map b/node_modules/cosmiconfig/dist/ExplorerBase.js.map new file mode 100644 index 00000000..90d7a543 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerBase.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/ExplorerBase.ts"],"names":["ExplorerBase","constructor","options","cache","loadCache","Map","searchCache","config","validateConfig","clearLoadCache","clear","clearSearchCache","clearCaches","searchPlaces","forEach","place","loaderKey","path","extname","loader","loaders","Error","getExtensionDescription","shouldSearchStopWithResult","result","isEmpty","ignoreEmptySearchPlaces","nextDirectoryToSearch","currentDir","currentResult","nextDir","nextDirUp","stopDir","loadPackageProp","filepath","content","parsedContent","loadJson","packagePropValue","packageProp","getLoaderEntryForFile","basename","bind","loadedContentToCosmiconfigResult","loadedContent","undefined","validateFilePath","dir","dirname","ext"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;;;AAUA,MAAMA,YAAN,CAAoE;AAK3DC,EAAAA,WAAP,CAAmBC,OAAnB,EAA+B;AAC7B,QAAIA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AO,IAAP;AACD;;AACD,QAAIA,aAAa,KAAKC,SAAtB,EAAiC;AAC/B,aAAO;AAAEX,QAAAA,QAAF;AAAY3B,QAAAA,MAAM,EAAEsC,SAApB;AAA+BpB,QAAAA,OAAO,EAAE;AAAxC,OAAP;AACD;;AACD,WAAO;AAAElB,MAAAA,MAAM,EAAEqC,aAAV;AAAyBV,MAAAA;AAAzB,KAAP;AACD;;AAESY,EAAAA,gBAAV,CAA2BZ,QAA3B,EAAmD;AACjD,QAAI,CAACA,QAAL,EAAe;AACb,YAAM,IAAIb,KAAJ,CAAU,mCAAV,CAAN;AACD;AACF;;AAzHiE;;;;AA4HpE,SAASU,SAAT,CAAmBgB,GAAnB,EAAwC;AACtC,SAAO9B,cAAK+B,OAAL,CAAaD,GAAb,CAAP;AACD;;AAED,SAASzB,uBAAT,CAAiCY,QAAjC,EAA2D;AACzD,QAAMe,GAAG,GAAGhC,cAAKC,OAAL,CAAagB,QAAb,CAAZ;;AACA,SAAOe,GAAG,GAAI,cAAaA,GAAI,GAArB,GAA0B,0BAApC;AACD","sourcesContent":["import path from 'path';\nimport { loaders } from './loaders';\nimport { getPropertyByPath } from './getPropertyByPath';\nimport {\n CosmiconfigResult,\n ExplorerOptions,\n ExplorerOptionsSync,\n Cache,\n LoadedFileContent,\n} from './types';\nimport { Loader } from './index';\n\nclass ExplorerBase {\n protected readonly loadCache?: Cache;\n protected readonly searchCache?: Cache;\n protected readonly config: T;\n\n public constructor(options: T) {\n if (options.cache === true) {\n this.loadCache = new Map();\n this.searchCache = new Map();\n }\n\n this.config = options;\n this.validateConfig();\n }\n\n public clearLoadCache(): void {\n if (this.loadCache) {\n this.loadCache.clear();\n }\n }\n\n public clearSearchCache(): void {\n if (this.searchCache) {\n this.searchCache.clear();\n }\n }\n\n public clearCaches(): void {\n this.clearLoadCache();\n this.clearSearchCache();\n }\n\n private validateConfig(): void {\n const config = this.config;\n\n config.searchPlaces.forEach((place): void => {\n const loaderKey = path.extname(place) || 'noExt';\n const loader = config.loaders[loaderKey];\n if (!loader) {\n throw new Error(\n `No loader specified for ${getExtensionDescription(\n place,\n )}, so searchPlaces item \"${place}\" is invalid`,\n );\n }\n\n if (typeof loader !== 'function') {\n throw new Error(\n `loader for ${getExtensionDescription(\n place,\n )} is not a function (type provided: \"${typeof loader}\"), so searchPlaces item \"${place}\" is invalid`,\n );\n }\n });\n }\n\n protected shouldSearchStopWithResult(result: CosmiconfigResult): boolean {\n if (result === null) return false;\n if (result.isEmpty && this.config.ignoreEmptySearchPlaces) return false;\n return true;\n }\n\n protected nextDirectoryToSearch(\n currentDir: string,\n currentResult: CosmiconfigResult,\n ): string | null {\n if (this.shouldSearchStopWithResult(currentResult)) {\n return null;\n }\n const nextDir = nextDirUp(currentDir);\n if (nextDir === currentDir || currentDir === this.config.stopDir) {\n return null;\n }\n return nextDir;\n }\n\n private loadPackageProp(filepath: string, content: string): unknown {\n const parsedContent = loaders.loadJson(filepath, content);\n const packagePropValue = getPropertyByPath(\n parsedContent,\n this.config.packageProp,\n );\n return packagePropValue || null;\n }\n\n protected getLoaderEntryForFile(filepath: string): Loader {\n if (path.basename(filepath) === 'package.json') {\n const loader = this.loadPackageProp.bind(this);\n return loader;\n }\n\n const loaderKey = path.extname(filepath) || 'noExt';\n\n const loader = this.config.loaders[loaderKey];\n\n if (!loader) {\n throw new Error(\n `No loader specified for ${getExtensionDescription(filepath)}`,\n );\n }\n\n return loader;\n }\n\n protected loadedContentToCosmiconfigResult(\n filepath: string,\n loadedContent: LoadedFileContent,\n ): CosmiconfigResult {\n if (loadedContent === null) {\n return null;\n }\n if (loadedContent === undefined) {\n return { filepath, config: undefined, isEmpty: true };\n }\n return { config: loadedContent, filepath };\n }\n\n protected validateFilePath(filepath: string): void {\n if (!filepath) {\n throw new Error('load must pass a non-empty string');\n }\n }\n}\n\nfunction nextDirUp(dir: string): string {\n return path.dirname(dir);\n}\n\nfunction getExtensionDescription(filepath: string): string {\n const ext = path.extname(filepath);\n return ext ? `extension \"${ext}\"` : 'files without extensions';\n}\n\nexport { ExplorerBase, getExtensionDescription };\n"],"file":"ExplorerBase.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerSync.d.ts b/node_modules/cosmiconfig/dist/ExplorerSync.d.ts new file mode 100644 index 00000000..458fbc41 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerSync.d.ts @@ -0,0 +1,14 @@ +import { ExplorerBase } from './ExplorerBase'; +import { CosmiconfigResult, ExplorerOptionsSync } from './types'; +declare class ExplorerSync extends ExplorerBase { + constructor(options: ExplorerOptionsSync); + searchSync(searchFrom?: string): CosmiconfigResult; + private searchFromDirectorySync; + private searchDirectorySync; + private loadSearchPlaceSync; + private loadFileContentSync; + private createCosmiconfigResultSync; + loadSync(filepath: string): CosmiconfigResult; +} +export { ExplorerSync }; +//# sourceMappingURL=ExplorerSync.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerSync.d.ts.map b/node_modules/cosmiconfig/dist/ExplorerSync.d.ts.map new file mode 100644 index 00000000..c3dae5d6 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerSync.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"ExplorerSync.d.ts","sourceRoot":"","sources":["../src/ExplorerSync.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAEjB,cAAM,YAAa,SAAQ,YAAY,CAAC,mBAAmB,CAAC;gBACvC,OAAO,EAAE,mBAAmB;IAIxC,UAAU,CAAC,UAAU,GAAE,MAAsB,GAAG,iBAAiB;IAOxE,OAAO,CAAC,uBAAuB;IAuB/B,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,mBAAmB;IAgB3B,OAAO,CAAC,2BAA2B;IAU5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB;CAsBrD;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerSync.js b/node_modules/cosmiconfig/dist/ExplorerSync.js new file mode 100644 index 00000000..dd57ac41 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerSync.js @@ -0,0 +1,118 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.ExplorerSync = void 0; + +var _path = _interopRequireDefault(require("path")); + +var _ExplorerBase = require("./ExplorerBase"); + +var _readFile = require("./readFile"); + +var _cacheWrapper = require("./cacheWrapper"); + +var _getDirectory = require("./getDirectory"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +class ExplorerSync extends _ExplorerBase.ExplorerBase { + constructor(options) { + super(options); + } + + searchSync(searchFrom = process.cwd()) { + const startDirectory = (0, _getDirectory.getDirectorySync)(searchFrom); + const result = this.searchFromDirectorySync(startDirectory); + return result; + } + + searchFromDirectorySync(dir) { + const absoluteDir = _path.default.resolve(process.cwd(), dir); + + const run = () => { + const result = this.searchDirectorySync(absoluteDir); + const nextDir = this.nextDirectoryToSearch(absoluteDir, result); + + if (nextDir) { + return this.searchFromDirectorySync(nextDir); + } + + const transformResult = this.config.transform(result); + return transformResult; + }; + + if (this.searchCache) { + return (0, _cacheWrapper.cacheWrapperSync)(this.searchCache, absoluteDir, run); + } + + return run(); + } + + searchDirectorySync(dir) { + for (const place of this.config.searchPlaces) { + const placeResult = this.loadSearchPlaceSync(dir, place); + + if (this.shouldSearchStopWithResult(placeResult) === true) { + return placeResult; + } + } // config not found + + + return null; + } + + loadSearchPlaceSync(dir, place) { + const filepath = _path.default.join(dir, place); + + const content = (0, _readFile.readFileSync)(filepath); + const result = this.createCosmiconfigResultSync(filepath, content); + return result; + } + + loadFileContentSync(filepath, content) { + if (content === null) { + return null; + } + + if (content.trim() === '') { + return undefined; + } + + const loader = this.getLoaderEntryForFile(filepath); + const loaderResult = loader(filepath, content); + return loaderResult; + } + + createCosmiconfigResultSync(filepath, content) { + const fileContent = this.loadFileContentSync(filepath, content); + const result = this.loadedContentToCosmiconfigResult(filepath, fileContent); + return result; + } + + loadSync(filepath) { + this.validateFilePath(filepath); + + const absoluteFilePath = _path.default.resolve(process.cwd(), filepath); + + const runLoadSync = () => { + const content = (0, _readFile.readFileSync)(absoluteFilePath, { + throwNotFound: true + }); + const cosmiconfigResult = this.createCosmiconfigResultSync(absoluteFilePath, content); + const transformResult = this.config.transform(cosmiconfigResult); + return transformResult; + }; + + if (this.loadCache) { + return (0, _cacheWrapper.cacheWrapperSync)(this.loadCache, absoluteFilePath, runLoadSync); + } + + return runLoadSync(); + } + +} + +exports.ExplorerSync = ExplorerSync; +//# sourceMappingURL=ExplorerSync.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/ExplorerSync.js.map b/node_modules/cosmiconfig/dist/ExplorerSync.js.map new file mode 100644 index 00000000..f9528e09 --- /dev/null +++ b/node_modules/cosmiconfig/dist/ExplorerSync.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/ExplorerSync.ts"],"names":["ExplorerSync","ExplorerBase","constructor","options","searchSync","searchFrom","process","cwd","startDirectory","result","searchFromDirectorySync","dir","absoluteDir","path","resolve","run","searchDirectorySync","nextDir","nextDirectoryToSearch","transformResult","config","transform","searchCache","place","searchPlaces","placeResult","loadSearchPlaceSync","shouldSearchStopWithResult","filepath","join","content","createCosmiconfigResultSync","loadFileContentSync","trim","undefined","loader","getLoaderEntryForFile","loaderResult","fileContent","loadedContentToCosmiconfigResult","loadSync","validateFilePath","absoluteFilePath","runLoadSync","throwNotFound","cosmiconfigResult","loadCache"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAOA,MAAMA,YAAN,SAA2BC,0BAA3B,CAA6D;AACpDC,EAAAA,WAAP,CAAmBC,OAAnB,EAAiD;AAC/C,UAAMA,OAAN;AACD;;AAEMC,EAAAA,UA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,SAAZ,CAAsBwB,iBAAtB,CAAxB;AAEA,aAAO1B,eAAP;AACD,KAVD;;AAYA,QAAI,KAAK2B,SAAT,EAAoB;AAClB,aAAO,oCAAiB,KAAKA,SAAtB,EAAiCJ,gBAAjC,EAAmDC,WAAnD,CAAP;AACD;;AAED,WAAOA,WAAW,EAAlB;AACD;;AAxG0D","sourcesContent":["import path from 'path';\nimport { ExplorerBase } from './ExplorerBase';\nimport { readFileSync } from './readFile';\nimport { cacheWrapperSync } from './cacheWrapper';\nimport { getDirectorySync } from './getDirectory';\nimport {\n CosmiconfigResult,\n ExplorerOptionsSync,\n LoadedFileContent,\n} from './types';\n\nclass ExplorerSync extends ExplorerBase {\n public constructor(options: ExplorerOptionsSync) {\n super(options);\n }\n\n public searchSync(searchFrom: string = process.cwd()): CosmiconfigResult {\n const startDirectory = getDirectorySync(searchFrom);\n const result = this.searchFromDirectorySync(startDirectory);\n\n return result;\n }\n\n private searchFromDirectorySync(dir: string): CosmiconfigResult {\n const absoluteDir = path.resolve(process.cwd(), dir);\n\n const run = (): CosmiconfigResult => {\n const result = this.searchDirectorySync(absoluteDir);\n const nextDir = this.nextDirectoryToSearch(absoluteDir, result);\n\n if (nextDir) {\n return this.searchFromDirectorySync(nextDir);\n }\n\n const transformResult = this.config.transform(result);\n\n return transformResult;\n };\n\n if (this.searchCache) {\n return cacheWrapperSync(this.searchCache, absoluteDir, run);\n }\n\n return run();\n }\n\n private searchDirectorySync(dir: string): CosmiconfigResult {\n for (const place of this.config.searchPlaces) {\n const placeResult = this.loadSearchPlaceSync(dir, place);\n\n if (this.shouldSearchStopWithResult(placeResult) === true) {\n return placeResult;\n }\n }\n\n // config not found\n return null;\n }\n\n private loadSearchPlaceSync(dir: string, place: string): CosmiconfigResult {\n const filepath = path.join(dir, place);\n const content = readFileSync(filepath);\n\n const result = this.createCosmiconfigResultSync(filepath, content);\n\n return result;\n }\n\n private loadFileContentSync(\n filepath: string,\n content: string | null,\n ): LoadedFileContent {\n if (content === null) {\n return null;\n }\n if (content.trim() === '') {\n return undefined;\n }\n const loader = this.getLoaderEntryForFile(filepath);\n const loaderResult = loader(filepath, content);\n\n return loaderResult;\n }\n\n private createCosmiconfigResultSync(\n filepath: string,\n content: string | null,\n ): CosmiconfigResult {\n const fileContent = this.loadFileContentSync(filepath, content);\n const result = this.loadedContentToCosmiconfigResult(filepath, fileContent);\n\n return result;\n }\n\n public loadSync(filepath: string): CosmiconfigResult {\n this.validateFilePath(filepath);\n const absoluteFilePath = path.resolve(process.cwd(), filepath);\n\n const runLoadSync = (): CosmiconfigResult => {\n const content = readFileSync(absoluteFilePath, { throwNotFound: true });\n const cosmiconfigResult = this.createCosmiconfigResultSync(\n absoluteFilePath,\n content,\n );\n\n const transformResult = this.config.transform(cosmiconfigResult);\n\n return transformResult;\n };\n\n if (this.loadCache) {\n return cacheWrapperSync(this.loadCache, absoluteFilePath, runLoadSync);\n }\n\n return runLoadSync();\n }\n}\n\nexport { ExplorerSync };\n"],"file":"ExplorerSync.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/cacheWrapper.d.ts b/node_modules/cosmiconfig/dist/cacheWrapper.d.ts new file mode 100644 index 00000000..adb569e8 --- /dev/null +++ b/node_modules/cosmiconfig/dist/cacheWrapper.d.ts @@ -0,0 +1,5 @@ +import { Cache, CosmiconfigResult } from './types'; +declare function cacheWrapper(cache: Cache, key: string, fn: () => Promise): Promise; +declare function cacheWrapperSync(cache: Cache, key: string, fn: () => CosmiconfigResult): CosmiconfigResult; +export { cacheWrapper, cacheWrapperSync }; +//# sourceMappingURL=cacheWrapper.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/cacheWrapper.d.ts.map b/node_modules/cosmiconfig/dist/cacheWrapper.d.ts.map new file mode 100644 index 00000000..dc7e73fc --- /dev/null +++ b/node_modules/cosmiconfig/dist/cacheWrapper.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"cacheWrapper.d.ts","sourceRoot":"","sources":["../src/cacheWrapper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAEnD,iBAAe,YAAY,CACzB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,OAAO,CAAC,iBAAiB,CAAC,GACnC,OAAO,CAAC,iBAAiB,CAAC,CAS5B;AAED,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,GAAG,EAAE,MAAM,EACX,EAAE,EAAE,MAAM,iBAAiB,GAC1B,iBAAiB,CASnB;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/cacheWrapper.js b/node_modules/cosmiconfig/dist/cacheWrapper.js new file mode 100644 index 00000000..712db922 --- /dev/null +++ b/node_modules/cosmiconfig/dist/cacheWrapper.js @@ -0,0 +1,32 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.cacheWrapper = cacheWrapper; +exports.cacheWrapperSync = cacheWrapperSync; + +async function cacheWrapper(cache, key, fn) { + const cached = cache.get(key); + + if (cached !== undefined) { + return cached; + } + + const result = await fn(); + cache.set(key, result); + return result; +} + +function cacheWrapperSync(cache, key, fn) { + const cached = cache.get(key); + + if (cached !== undefined) { + return cached; + } + + const result = fn(); + cache.set(key, result); + return result; +} +//# sourceMappingURL=cacheWrapper.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/cacheWrapper.js.map b/node_modules/cosmiconfig/dist/cacheWrapper.js.map new file mode 100644 index 00000000..a9ead967 --- /dev/null +++ b/node_modules/cosmiconfig/dist/cacheWrapper.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/cacheWrapper.ts"],"names":["cacheWrapper","cache","key","fn","cached","get","undefined","result","set","cacheWrapperSync"],"mappings":";;;;;;;;AAEA,eAAeA,YAAf,CACEC,KADF,EAEEC,GAFF,EAGEC,EAHF,EAI8B;AAC5B,QAAMC,MAAM,GAAGH,KAAK,CAACI,GAAN,CAAUH,GAAV,CAAf;;AACA,MAAIE,MAAM,KAAKE,SAAf,EAA0B;AACxB,WAAOF,MAAP;AACD;;AAED,QAAMG,MAAM,GAAG,MAAMJ,EAAE,EAAvB;AACAF,EAAAA,KAAK,CAACO,GAAN,CAAUN,GAAV,EAAeK,MAAf;AACA,SAAOA,MAAP;AACD;;AAED,SAASE,gBAAT,CACER,KADF,EAEEC,GAFF,EAGEC,EAHF,EAIqB;AACnB,QAAMC,MAAM,GAAGH,KAAK,CAACI,GAAN,CAAUH,GAAV,CAAf;;AACA,MAAIE,MAAM,KAAKE,SAAf,EAA0B;AACxB,WAAOF,MAAP;AACD;;AAED,QAAMG,MAAM,GAAGJ,EAAE,EAAjB;AACAF,EAAAA,KAAK,CAACO,GAAN,CAAUN,GAAV,EAAeK,MAAf;AACA,SAAOA,MAAP;AACD","sourcesContent":["import { Cache, CosmiconfigResult } from './types';\n\nasync function cacheWrapper(\n cache: Cache,\n key: string,\n fn: () => Promise,\n): Promise {\n const cached = cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n\n const result = await fn();\n cache.set(key, result);\n return result;\n}\n\nfunction cacheWrapperSync(\n cache: Cache,\n key: string,\n fn: () => CosmiconfigResult,\n): CosmiconfigResult {\n const cached = cache.get(key);\n if (cached !== undefined) {\n return cached;\n }\n\n const result = fn();\n cache.set(key, result);\n return result;\n}\n\nexport { cacheWrapper, cacheWrapperSync };\n"],"file":"cacheWrapper.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getDirectory.d.ts b/node_modules/cosmiconfig/dist/getDirectory.d.ts new file mode 100644 index 00000000..3b53068f --- /dev/null +++ b/node_modules/cosmiconfig/dist/getDirectory.d.ts @@ -0,0 +1,4 @@ +declare function getDirectory(filepath: string): Promise; +declare function getDirectorySync(filepath: string): string; +export { getDirectory, getDirectorySync }; +//# sourceMappingURL=getDirectory.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getDirectory.d.ts.map b/node_modules/cosmiconfig/dist/getDirectory.d.ts.map new file mode 100644 index 00000000..37288a72 --- /dev/null +++ b/node_modules/cosmiconfig/dist/getDirectory.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"getDirectory.d.ts","sourceRoot":"","sources":["../src/getDirectory.ts"],"names":[],"mappings":"AAGA,iBAAe,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAU7D;AAED,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUlD;AAED,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getDirectory.js b/node_modules/cosmiconfig/dist/getDirectory.js new file mode 100644 index 00000000..e0f0a69d --- /dev/null +++ b/node_modules/cosmiconfig/dist/getDirectory.js @@ -0,0 +1,38 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getDirectory = getDirectory; +exports.getDirectorySync = getDirectorySync; + +var _path = _interopRequireDefault(require("path")); + +var _pathType = require("path-type"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +async function getDirectory(filepath) { + const filePathIsDirectory = await (0, _pathType.isDirectory)(filepath); + + if (filePathIsDirectory === true) { + return filepath; + } + + const directory = _path.default.dirname(filepath); + + return directory; +} + +function getDirectorySync(filepath) { + const filePathIsDirectory = (0, _pathType.isDirectorySync)(filepath); + + if (filePathIsDirectory === true) { + return filepath; + } + + const directory = _path.default.dirname(filepath); + + return directory; +} +//# sourceMappingURL=getDirectory.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getDirectory.js.map b/node_modules/cosmiconfig/dist/getDirectory.js.map new file mode 100644 index 00000000..361d53af --- /dev/null +++ b/node_modules/cosmiconfig/dist/getDirectory.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/getDirectory.ts"],"names":["getDirectory","filepath","filePathIsDirectory","directory","path","dirname","getDirectorySync"],"mappings":";;;;;;;;AAAA;;AACA;;;;AAEA,eAAeA,YAAf,CAA4BC,QAA5B,EAA+D;AAC7D,QAAMC,mBAAmB,GAAG,MAAM,2BAAYD,QAAZ,CAAlC;;AAEA,MAAIC,mBAAmB,KAAK,IAA5B,EAAkC;AAChC,WAAOD,QAAP;AACD;;AAED,QAAME,SAAS,GAAGC,cAAKC,OAAL,CAAaJ,QAAb,CAAlB;;AAEA,SAAOE,SAAP;AACD;;AAED,SAASG,gBAAT,CAA0BL,QAA1B,EAAoD;AAClD,QAAMC,mBAAmB,GAAG,+BAAgBD,QAAhB,CAA5B;;AAEA,MAAIC,mBAAmB,KAAK,IAA5B,EAAkC;AAChC,WAAOD,QAAP;AACD;;AAED,QAAME,SAAS,GAAGC,cAAKC,OAAL,CAAaJ,QAAb,CAAlB;;AAEA,SAAOE,SAAP;AACD","sourcesContent":["import path from 'path';\nimport { isDirectory, isDirectorySync } from 'path-type';\n\nasync function getDirectory(filepath: string): Promise {\n const filePathIsDirectory = await isDirectory(filepath);\n\n if (filePathIsDirectory === true) {\n return filepath;\n }\n\n const directory = path.dirname(filepath);\n\n return directory;\n}\n\nfunction getDirectorySync(filepath: string): string {\n const filePathIsDirectory = isDirectorySync(filepath);\n\n if (filePathIsDirectory === true) {\n return filepath;\n }\n\n const directory = path.dirname(filepath);\n\n return directory;\n}\n\nexport { getDirectory, getDirectorySync };\n"],"file":"getDirectory.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts b/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts new file mode 100644 index 00000000..0b89fa71 --- /dev/null +++ b/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts @@ -0,0 +1,5 @@ +declare function getPropertyByPath(source: { + [key: string]: unknown; +}, path: string | Array): unknown; +export { getPropertyByPath }; +//# sourceMappingURL=getPropertyByPath.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts.map b/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts.map new file mode 100644 index 00000000..cbb44eb2 --- /dev/null +++ b/node_modules/cosmiconfig/dist/getPropertyByPath.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"getPropertyByPath.d.ts","sourceRoot":"","sources":["../src/getPropertyByPath.ts"],"names":[],"mappings":"AAKA,iBAAS,iBAAiB,CACxB,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,EAClC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAC3B,OAAO,CAgBT;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getPropertyByPath.js b/node_modules/cosmiconfig/dist/getPropertyByPath.js new file mode 100644 index 00000000..564972c9 --- /dev/null +++ b/node_modules/cosmiconfig/dist/getPropertyByPath.js @@ -0,0 +1,28 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.getPropertyByPath = getPropertyByPath; + +// Resolves property names or property paths defined with period-delimited +// strings or arrays of strings. Property names that are found on the source +// object are used directly (even if they include a period). +// Nested property names that include periods, within a path, are only +// understood in array paths. +function getPropertyByPath(source, path) { + if (typeof path === 'string' && Object.prototype.hasOwnProperty.call(source, path)) { + return source[path]; + } + + const parsedPath = typeof path === 'string' ? path.split('.') : path; // eslint-disable-next-line @typescript-eslint/no-explicit-any + + return parsedPath.reduce((previous, key) => { + if (previous === undefined) { + return previous; + } + + return previous[key]; + }, source); +} +//# sourceMappingURL=getPropertyByPath.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/getPropertyByPath.js.map b/node_modules/cosmiconfig/dist/getPropertyByPath.js.map new file mode 100644 index 00000000..0b96ff41 --- /dev/null +++ b/node_modules/cosmiconfig/dist/getPropertyByPath.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/getPropertyByPath.ts"],"names":["getPropertyByPath","source","path","Object","prototype","hasOwnProperty","call","parsedPath","split","reduce","previous","key","undefined"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA,SAASA,iBAAT,CACEC,MADF,EAEEC,IAFF,EAGW;AACT,MACE,OAAOA,IAAP,KAAgB,QAAhB,IACAC,MAAM,CAACC,SAAP,CAAiBC,cAAjB,CAAgCC,IAAhC,CAAqCL,MAArC,EAA6CC,IAA7C,CAFF,EAGE;AACA,WAAOD,MAAM,CAACC,IAAD,CAAb;AACD;;AAED,QAAMK,UAAU,GAAG,OAAOL,IAAP,KAAgB,QAAhB,GAA2BA,IAAI,CAACM,KAAL,CAAW,GAAX,CAA3B,GAA6CN,IAAhE,CARS,CAST;;AACA,SAAOK,UAAU,CAACE,MAAX,CAAkB,CAACC,QAAD,EAAgBC,GAAhB,KAAiC;AACxD,QAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1B,aAAOF,QAAP;AACD;;AACD,WAAOA,QAAQ,CAACC,GAAD,CAAf;AACD,GALM,EAKJV,MALI,CAAP;AAMD","sourcesContent":["// Resolves property names or property paths defined with period-delimited\n// strings or arrays of strings. Property names that are found on the source\n// object are used directly (even if they include a period).\n// Nested property names that include periods, within a path, are only\n// understood in array paths.\nfunction getPropertyByPath(\n source: { [key: string]: unknown },\n path: string | Array,\n): unknown {\n if (\n typeof path === 'string' &&\n Object.prototype.hasOwnProperty.call(source, path)\n ) {\n return source[path];\n }\n\n const parsedPath = typeof path === 'string' ? path.split('.') : path;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n return parsedPath.reduce((previous: any, key): unknown => {\n if (previous === undefined) {\n return previous;\n }\n return previous[key];\n }, source);\n}\n\nexport { getPropertyByPath };\n"],"file":"getPropertyByPath.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/index.d.ts b/node_modules/cosmiconfig/dist/index.d.ts new file mode 100644 index 00000000..7c205f50 --- /dev/null +++ b/node_modules/cosmiconfig/dist/index.d.ts @@ -0,0 +1,44 @@ +import { Config, CosmiconfigResult, Loaders, LoadersSync } from './types'; +declare type LoaderResult = Config | null; +export declare type Loader = ((filepath: string, content: string) => Promise) | LoaderSync; +export declare type LoaderSync = (filepath: string, content: string) => LoaderResult; +export declare type Transform = ((CosmiconfigResult: CosmiconfigResult) => Promise) | TransformSync; +export declare type TransformSync = (CosmiconfigResult: CosmiconfigResult) => CosmiconfigResult; +interface OptionsBase { + packageProp?: string; + searchPlaces?: Array; + ignoreEmptySearchPlaces?: boolean; + stopDir?: string; + cache?: boolean; +} +export interface Options extends OptionsBase { + loaders?: Loaders; + transform?: Transform; +} +export interface OptionsSync extends OptionsBase { + loaders?: LoadersSync; + transform?: TransformSync; +} +declare function cosmiconfig(moduleName: string, options?: Options): { + readonly search: (searchFrom?: string) => Promise; + readonly load: (filepath: string) => Promise; + readonly clearLoadCache: () => void; + readonly clearSearchCache: () => void; + readonly clearCaches: () => void; +}; +declare function cosmiconfigSync(moduleName: string, options?: OptionsSync): { + readonly search: (searchFrom?: string) => CosmiconfigResult; + readonly load: (filepath: string) => CosmiconfigResult; + readonly clearLoadCache: () => void; + readonly clearSearchCache: () => void; + readonly clearCaches: () => void; +}; +declare const defaultLoaders: Readonly<{ + readonly '.js': LoaderSync; + readonly '.json': LoaderSync; + readonly '.yaml': LoaderSync; + readonly '.yml': LoaderSync; + readonly noExt: LoaderSync; +}>; +export { cosmiconfig, cosmiconfigSync, defaultLoaders }; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/index.d.ts.map b/node_modules/cosmiconfig/dist/index.d.ts.map new file mode 100644 index 00000000..5385ad05 --- /dev/null +++ b/node_modules/cosmiconfig/dist/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,iBAAiB,EAGjB,OAAO,EACP,WAAW,EACZ,MAAM,SAAS,CAAC;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ist/index.js b/node_modules/cosmiconfig/dist/index.js new file mode 100644 index 00000000..5f789cf1 --- /dev/null +++ b/node_modules/cosmiconfig/dist/index.js @@ -0,0 +1,80 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.cosmiconfig = cosmiconfig; +exports.cosmiconfigSync = cosmiconfigSync; +exports.defaultLoaders = void 0; + +var _os = _interopRequireDefault(require("os")); + +var _Explorer = require("./Explorer"); + +var _ExplorerSync = require("./ExplorerSync"); + +var _loaders = require("./loaders"); + +var _types = require("./types"); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +// eslint-disable-next-line @typescript-eslint/explicit-function-return-type +function cosmiconfig(moduleName, options = {}) { + const normalizedOptions = normalizeOptions(moduleName, options); + const explorer = new _Explorer.Explorer(normalizedOptions); + return { + search: explorer.search.bind(explorer), + load: explorer.load.bind(explorer), + clearLoadCache: explorer.clearLoadCache.bind(explorer), + clearSearchCache: explorer.clearSearchCache.bind(explorer), + clearCaches: explorer.clearCaches.bind(explorer) + }; +} // eslint-disable-next-line @typescript-eslint/explicit-function-return-type + + +function cosmiconfigSync(moduleName, options = {}) { + const normalizedOptions = normalizeOptions(moduleName, options); + const explorerSync = new _ExplorerSync.ExplorerSync(normalizedOptions); + return { + search: explorerSync.searchSync.bind(explorerSync), + load: explorerSync.loadSync.bind(explorerSync), + clearLoadCache: explorerSync.clearLoadCache.bind(explorerSync), + clearSearchCache: explorerSync.clearSearchCache.bind(explorerSync), + clearCaches: explorerSync.clearCaches.bind(explorerSync) + }; +} // do not allow mutation of default loaders. Make sure it is set inside options + + +const defaultLoaders = Object.freeze({ + '.js': _loaders.loaders.loadJs, + '.json': _loaders.loaders.loadJson, + '.yaml': _loaders.loaders.loadYaml, + '.yml': _loaders.loaders.loadYaml, + noExt: _loaders.loaders.loadYaml +}); +exports.defaultLoaders = defaultLoaders; + +function normalizeOptions(moduleName, options) { + const defaults = { + packageProp: moduleName, + searchPlaces: ['package.json', `.${moduleName}rc`, `.${moduleName}rc.json`, `.${moduleName}rc.yaml`, `.${moduleName}rc.yml`, `.${moduleName}rc.js`, `${moduleName}.config.js`], + ignoreEmptySearchPlaces: true, + stopDir: _os.default.homedir(), + cache: true, + transform: identity, + loaders: defaultLoaders + }; + const normalizedOptions = { ...defaults, + ...options, + loaders: { ...defaults.loaders, + ...options.loaders + } + }; + return normalizedOptions; +} + +const identity = function identity(x) { + return x; +}; +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/index.js.map b/node_modules/cosmiconfig/dist/index.js.map new file mode 100644 index 00000000..502a0902 --- /dev/null +++ b/node_modules/cosmiconfig/dist/index.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/index.ts"],"names":["cosmiconfig","moduleName","options","normalizedOptions","normalizeOptions","explorer","Explorer","search","bind","load","clearLoadCache","clearSearchCache","clearCaches","cosmiconfigSync","explorerSync","ExplorerSync","searchSync","loadSync","defaultLoaders","Object","freeze","loaders","loadJs","loadJson","loadYaml","noExt","defaults","packageProp","searchPlaces","ignoreEmptySearchPlaces","stopDir","os","homedir","cache","transform","identity","x"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;AAyCA;AACA,SAASA,WAAT,CAAqBC,UAArB,EAAyCC,OAAgB,GAAG,EAA5D,EAAgE;AAC9D,QAAMC,iBAAkC,GAAGC,gBAAgB,CACzDH,UADyD,EAEzDC,OAFyD,CAA3D;AAKA,QAAMG,QAAQ,GAAG,IAAIC,kBAAJ,CAAaH,iBAAb,CAAjB;AAEA,SAAO;AACLI,IAAAA,MAAM,EAAEF,QAAQ,CAACE,MAAT,CAAgBC,IAAhB,CAAqBH,QAArB,CADH;AAELI,IAAAA,IAAI,EAAEJ,QAAQ,CAACI,IAAT,CAAcD,IAAd,CAAmBH,QAAnB,CAFD;AAGLK,IAAAA,cAAc,EAAEL,QAAQ,CAACK,cAAT,CAAwBF,IAAxB,CAA6BH,QAA7B,CAHX;A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EX,IAAG3B,UAAW,IAFH,EAGX,IAAGA,UAAW,SAHH,EAIX,IAAGA,UAAW,SAJH,EAKX,IAAGA,UAAW,QALH,EAMX,IAAGA,UAAW,OANH,EAOX,GAAEA,UAAW,YAPF,CAFwC;AAWtD4B,IAAAA,uBAAuB,EAAE,IAX6B;AAYtDC,IAAAA,OAAO,EAAEC,YAAGC,OAAH,EAZ6C;AAatDC,IAAAA,KAAK,EAAE,IAb+C;AActDC,IAAAA,SAAS,EAAEC,QAd2C;AAetDd,IAAAA,OAAO,EAAEH;AAf6C,GAAxD;AAkBA,QAAMf,iBAAwD,GAAG,EAC/D,GAAGuB,QAD4D;AAE/D,OAAGxB,OAF4D;AAG/DmB,IAAAA,OAAO,EAAE,EACP,GAAGK,QAAQ,CAACL,OADL;AAEP,SAAGnB,OAAO,CAACmB;AAFJ;AAHsD,GAAjE;AASA,SAAOlB,iBAAP;AACD;;AAED,MAAMgC,QAAuB,GAAG,SAASA,QAAT,CAAkBC,CAAlB,EAAqB;AACnD,SAAOA,CAAP;AACD,CAFD","sourcesContent":["import os from 'os';\nimport { Explorer } from './Explorer';\nimport { ExplorerSync } from './ExplorerSync';\nimport { loaders } from './loaders';\nimport {\n Config,\n CosmiconfigResult,\n ExplorerOptions,\n ExplorerOptionsSync,\n Loaders,\n LoadersSync,\n} from './types';\n\ntype LoaderResult = Config | null;\nexport type Loader =\n | ((filepath: string, content: string) => Promise)\n | LoaderSync;\nexport type LoaderSync = (filepath: string, content: string) => LoaderResult;\n\nexport type Transform =\n | ((CosmiconfigResult: CosmiconfigResult) => Promise)\n | TransformSync;\n\nexport type TransformSync = (\n CosmiconfigResult: CosmiconfigResult,\n) => CosmiconfigResult;\n\ninterface OptionsBase {\n packageProp?: string;\n searchPlaces?: Array;\n ignoreEmptySearchPlaces?: boolean;\n stopDir?: string;\n cache?: boolean;\n}\n\nexport interface Options extends OptionsBase {\n loaders?: Loaders;\n transform?: Transform;\n}\n\nexport interface OptionsSync extends OptionsBase {\n loaders?: LoadersSync;\n transform?: TransformSync;\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction cosmiconfig(moduleName: string, options: Options = {}) {\n const normalizedOptions: ExplorerOptions = normalizeOptions(\n moduleName,\n options,\n );\n\n const explorer = new Explorer(normalizedOptions);\n\n return {\n search: explorer.search.bind(explorer),\n load: explorer.load.bind(explorer),\n clearLoadCache: explorer.clearLoadCache.bind(explorer),\n clearSearchCache: explorer.clearSearchCache.bind(explorer),\n clearCaches: explorer.clearCaches.bind(explorer),\n } as const;\n}\n\n// eslint-disable-next-line @typescript-eslint/explicit-function-return-type\nfunction cosmiconfigSync(moduleName: string, options: OptionsSync = {}) {\n const normalizedOptions: ExplorerOptionsSync = normalizeOptions(\n moduleName,\n options,\n );\n\n const explorerSync = new ExplorerSync(normalizedOptions);\n\n return {\n search: explorerSync.searchSync.bind(explorerSync),\n load: explorerSync.loadSync.bind(explorerSync),\n clearLoadCache: explorerSync.clearLoadCache.bind(explorerSync),\n clearSearchCache: explorerSync.clearSearchCache.bind(explorerSync),\n clearCaches: explorerSync.clearCaches.bind(explorerSync),\n } as const;\n}\n\n// do not allow mutation of default loaders. Make sure it is set inside options\nconst defaultLoaders = Object.freeze({\n '.js': loaders.loadJs,\n '.json': loaders.loadJson,\n '.yaml': loaders.loadYaml,\n '.yml': loaders.loadYaml,\n noExt: loaders.loadYaml,\n} as const);\n\nfunction normalizeOptions(\n moduleName: string,\n options: OptionsSync,\n): ExplorerOptionsSync;\nfunction normalizeOptions(\n moduleName: string,\n options: Options,\n): ExplorerOptions;\nfunction normalizeOptions(\n moduleName: string,\n options: Options | OptionsSync,\n): ExplorerOptions | ExplorerOptionsSync {\n const defaults: ExplorerOptions | ExplorerOptionsSync = {\n packageProp: moduleName,\n searchPlaces: [\n 'package.json',\n `.${moduleName}rc`,\n `.${moduleName}rc.json`,\n `.${moduleName}rc.yaml`,\n `.${moduleName}rc.yml`,\n `.${moduleName}rc.js`,\n `${moduleName}.config.js`,\n ],\n ignoreEmptySearchPlaces: true,\n stopDir: os.homedir(),\n cache: true,\n transform: identity,\n loaders: defaultLoaders,\n };\n\n const normalizedOptions: ExplorerOptions | ExplorerOptionsSync = {\n ...defaults,\n ...options,\n loaders: {\n ...defaults.loaders,\n ...options.loaders,\n },\n };\n\n return normalizedOptions;\n}\n\nconst identity: TransformSync = function identity(x) {\n return x;\n};\n\nexport { cosmiconfig, cosmiconfigSync, defaultLoaders };\n"],"file":"index.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/loaders.d.ts b/node_modules/cosmiconfig/dist/loaders.d.ts new file mode 100644 index 00000000..44f788f8 --- /dev/null +++ b/node_modules/cosmiconfig/dist/loaders.d.ts @@ -0,0 +1,4 @@ +import { LoadersSync } from './types'; +declare const loaders: LoadersSync; +export { loaders }; +//# sourceMappingURL=loaders.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/loaders.d.ts.map b/node_modules/cosmiconfig/dist/loaders.d.ts.map new file mode 100644 index 00000000..6937f323 --- /dev/null +++ b/node_modules/cosmiconfig/dist/loaders.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"loaders.d.ts","sourceRoot":"","sources":["../src/loaders.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AA0CtC,QAAA,MAAM,OAAO,EAAE,WAA4C,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/loaders.js b/node_modules/cosmiconfig/dist/loaders.js new file mode 100644 index 00000000..43126afc --- /dev/null +++ b/node_modules/cosmiconfig/dist/loaders.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.loaders = void 0; + +/* eslint-disable @typescript-eslint/no-require-imports */ +let importFresh; + +const loadJs = function loadJs(filepath) { + if (importFresh === undefined) { + importFresh = require('import-fresh'); + } + + const result = importFresh(filepath); + return result; +}; + +let parseJson; + +const loadJson = function loadJson(filepath, content) { + if (parseJson === undefined) { + parseJson = require('parse-json'); + } + + try { + const result = parseJson(content); + return result; + } catch (error) { + error.message = `JSON Error in ${filepath}:\n${error.message}`; + throw error; + } +}; + +let yaml; + +const loadYaml = function loadYaml(filepath, content) { + if (yaml === undefined) { + yaml = require('yaml'); + } + + try { + const result = yaml.parse(content, { + prettyErrors: true + }); + return result; + } catch (error) { + error.message = `YAML Error in ${filepath}:\n${error.message}`; + throw error; + } +}; + +const loaders = { + loadJs, + loadJson, + loadYaml +}; +exports.loaders = loaders; +//# sourceMappingURL=loaders.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/loaders.js.map b/node_modules/cosmiconfig/dist/loaders.js.map new file mode 100644 index 00000000..34110c40 --- /dev/null +++ b/node_modules/cosmiconfig/dist/loaders.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/loaders.ts"],"names":["importFresh","loadJs","filepath","undefined","require","result","parseJson","loadJson","content","error","message","yaml","loadYaml","parse","prettyErrors","loaders"],"mappings":";;;;;;;AAAA;AAQA,IAAIA,WAAJ;;AACA,MAAMC,MAAkB,GAAG,SAASA,MAAT,CAAgBC,QAAhB,EAA0B;AACnD,MAAIF,WAAW,KAAKG,SAApB,EAA+B;AAC7BH,IAAAA,WAAW,GAAGI,OAAO,CAAC,cAAD,CAArB;AACD;;AAED,QAAMC,MAAM,GAAGL,WAAW,CAACE,QAAD,CAA1B;AACA,SAAOG,MAAP;AACD,CAPD;;AASA,IAAIC,SAAJ;;AACA,MAAMC,QAAoB,GAAG,SAASA,QAAT,CAAkBL,QAAlB,EAA4BM,OAA5B,EAAqC;AAChE,MAAIF,SAAS,KAAKH,SAAlB,EAA6B;AAC3BG,IAAAA,SAAS,GAAGF,OAAO,CAAC,YAAD,CAAnB;AACD;;AAED,MAAI;AACF,UAAMC,MAAM,GAAGC,SAAS,CAACE,OAAD,CAAxB;AACA,WAAOH,MAAP;AACD,GAHD,CAGE,OAAOI,KAAP,EAAc;AACdA,IAAAA,KAAK,CAACC,OAAN,GAAiB,iBAAgBR,QAAS,MAAKO,KAAK,CAACC,OAAQ,EAA7D;AACA,UAAMD,KAAN;AACD;AACF,CAZD;;AAcA,IAAIE,IAAJ;;AACA,MAAMC,QAAoB,GAAG,SAASA,QAAT,CAAkBV,QAAlB,EAA4BM,OAA5B,EAAqC;AAChE,MAAIG,IAAI,KAAKR,SAAb,EAAwB;AACtBQ,IAAAA,IAAI,GAAGP,OAAO,CAAC,MAAD,CAAd;AACD;;AAED,MAAI;AACF,UAAMC,MAAM,GAAGM,IAAI,CAACE,KAAL,CAAWL,OAAX,EAAoB;AAAEM,MAAAA,YAAY,EAAE;AAAhB,KAApB,CAAf;AACA,WAAOT,MAAP;AACD,GAHD,CAGE,OAAOI,KAAP,EAAc;AACdA,IAAAA,KAAK,CAACC,OAAN,GAAiB,iBAAgBR,QAAS,MAAKO,KAAK,CAACC,OAAQ,EAA7D;AACA,UAAMD,KAAN;AACD;AACF,CAZD;;AAcA,MAAMM,OAAoB,GAAG;AAAEd,EAAAA,MAAF;AAAUM,EAAAA,QAAV;AAAoBK,EAAAA;AAApB,CAA7B","sourcesContent":["/* eslint-disable @typescript-eslint/no-require-imports */\n\nimport parseJsonType from 'parse-json';\nimport yamlType from 'yaml';\nimport importFreshType from 'import-fresh';\nimport { LoaderSync } from './index';\nimport { LoadersSync } from './types';\n\nlet importFresh: typeof importFreshType;\nconst loadJs: LoaderSync = function loadJs(filepath) {\n if (importFresh === undefined) {\n importFresh = require('import-fresh');\n }\n\n const result = importFresh(filepath);\n return result;\n};\n\nlet parseJson: typeof parseJsonType;\nconst loadJson: LoaderSync = function loadJson(filepath, content) {\n if (parseJson === undefined) {\n parseJson = require('parse-json');\n }\n\n try {\n const result = parseJson(content);\n return result;\n } catch (error) {\n error.message = `JSON Error in ${filepath}:\\n${error.message}`;\n throw error;\n }\n};\n\nlet yaml: typeof yamlType;\nconst loadYaml: LoaderSync = function loadYaml(filepath, content) {\n if (yaml === undefined) {\n yaml = require('yaml');\n }\n\n try {\n const result = yaml.parse(content, { prettyErrors: true });\n return result;\n } catch (error) {\n error.message = `YAML Error in ${filepath}:\\n${error.message}`;\n throw error;\n }\n};\n\nconst loaders: LoadersSync = { loadJs, loadJson, loadYaml };\n\nexport { loaders };\n"],"file":"loaders.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/readFile.d.ts b/node_modules/cosmiconfig/dist/readFile.d.ts new file mode 100644 index 00000000..c59e12ea --- /dev/null +++ b/node_modules/cosmiconfig/dist/readFile.d.ts @@ -0,0 +1,7 @@ +interface Options { + throwNotFound?: boolean; +} +declare function readFile(filepath: string, options?: Options): Promise; +declare function readFileSync(filepath: string, options?: Options): string | null; +export { readFile, readFileSync }; +//# sourceMappingURL=readFile.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/readFile.d.ts.map b/node_modules/cosmiconfig/dist/readFile.d.ts.map new file mode 100644 index 00000000..5bf4769b --- /dev/null +++ b/node_modules/cosmiconfig/dist/readFile.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"readFile.d.ts","sourceRoot":"","sources":["../src/readFile.ts"],"names":[],"mappings":"AAkBA,UAAU,OAAO;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,iBAAe,QAAQ,CACrB,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,OAAY,GACpB,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcxB;AAED,iBAAS,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,OAAY,GAAG,MAAM,GAAG,IAAI,CAc5E;AAED,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/readFile.js b/node_modules/cosmiconfig/dist/readFile.js new file mode 100644 index 00000000..d62129b3 --- /dev/null +++ b/node_modules/cosmiconfig/dist/readFile.js @@ -0,0 +1,56 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.readFile = readFile; +exports.readFileSync = readFileSync; + +var _fs = _interopRequireDefault(require("fs")); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +async function fsReadFileAsync(pathname, encoding) { + return new Promise((resolve, reject) => { + _fs.default.readFile(pathname, encoding, (error, contents) => { + if (error) { + reject(error); + return; + } + + resolve(contents); + }); + }); +} + +async function readFile(filepath, options = {}) { + const throwNotFound = options.throwNotFound === true; + + try { + const content = await fsReadFileAsync(filepath, 'utf8'); + return content; + } catch (error) { + if (throwNotFound === false && error.code === 'ENOENT') { + return null; + } + + throw error; + } +} + +function readFileSync(filepath, options = {}) { + const throwNotFound = options.throwNotFound === true; + + try { + const content = _fs.default.readFileSync(filepath, 'utf8'); + + return content; + } catch (error) { + if (throwNotFound === false && error.code === 'ENOENT') { + return null; + } + + throw error; + } +} +//# sourceMappingURL=readFile.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/readFile.js.map b/node_modules/cosmiconfig/dist/readFile.js.map new file mode 100644 index 00000000..d1f54d06 --- /dev/null +++ b/node_modules/cosmiconfig/dist/readFile.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/readFile.ts"],"names":["fsReadFileAsync","pathname","encoding","Promise","resolve","reject","fs","readFile","error","contents","filepath","options","throwNotFound","content","code","readFileSync"],"mappings":";;;;;;;;AAAA;;;;AAEA,eAAeA,eAAf,CACEC,QADF,EAEEC,QAFF,EAGmB;AACjB,SAAO,IAAIC,OAAJ,CAAY,CAACC,OAAD,EAAUC,MAAV,KAA2B;AAC5CC,gBAAGC,QAAH,CAAYN,QAAZ,EAAsBC,QAAtB,EAAgC,CAACM,KAAD,EAAQC,QAAR,KAA2B;AACzD,UAAID,KAAJ,EAAW;AACTH,QAAAA,MAAM,CAACG,KAAD,CAAN;AACA;AACD;;AAEDJ,MAAAA,OAAO,CAACK,QAAD,CAAP;AACD,KAPD;AAQD,GATM,CAAP;AAUD;;AAMD,eAAeF,QAAf,CACEG,QADF,EAEEC,OAAgB,GAAG,EAFrB,EAG0B;AACxB,QAAMC,aAAa,GAAGD,OAAO,CAACC,aAAR,KAA0B,IAAhD;;AAEA,MAAI;AACF,UAAMC,OAAO,GAAG,MAAMb,eAAe,CAACU,QAAD,EAAW,MAAX,CAArC;AAEA,WAAOG,OAAP;AACD,GAJD,CAIE,OAAOL,KAAP,EAAc;AACd,QAAII,aAAa,KAAK,KAAlB,IAA2BJ,KAAK,CAACM,IAAN,KAAe,QAA9C,EAAwD;AACtD,aAAO,IAAP;AACD;;AAED,UAAMN,KAAN;AACD;AACF;;AAED,SAASO,YAAT,CAAsBL,QAAtB,EAAwCC,OAAgB,GAAG,EAA3D,EAA8E;AAC5E,QAAMC,aAAa,GAAGD,OAAO,CAACC,aAAR,KAA0B,IAAhD;;AAEA,MAAI;AACF,UAAMC,OAAO,GAAGP,YAAGS,YAAH,CAAgBL,QAAhB,EAA0B,MAA1B,CAAhB;;AAEA,WAAOG,OAAP;AACD,GAJD,CAIE,OAAOL,KAAP,EAAc;AACd,QAAII,aAAa,KAAK,KAAlB,IAA2BJ,KAAK,CAACM,IAAN,KAAe,QAA9C,EAAwD;AACtD,aAAO,IAAP;AACD;;AAED,UAAMN,KAAN;AACD;AACF","sourcesContent":["import fs from 'fs';\n\nasync function fsReadFileAsync(\n pathname: string,\n encoding: string,\n): Promise {\n return new Promise((resolve, reject): void => {\n fs.readFile(pathname, encoding, (error, contents): void => {\n if (error) {\n reject(error);\n return;\n }\n\n resolve(contents);\n });\n });\n}\n\ninterface Options {\n throwNotFound?: boolean;\n}\n\nasync function readFile(\n filepath: string,\n options: Options = {},\n): Promise {\n const throwNotFound = options.throwNotFound === true;\n\n try {\n const content = await fsReadFileAsync(filepath, 'utf8');\n\n return content;\n } catch (error) {\n if (throwNotFound === false && error.code === 'ENOENT') {\n return null;\n }\n\n throw error;\n }\n}\n\nfunction readFileSync(filepath: string, options: Options = {}): string | null {\n const throwNotFound = options.throwNotFound === true;\n\n try {\n const content = fs.readFileSync(filepath, 'utf8');\n\n return content;\n } catch (error) {\n if (throwNotFound === false && error.code === 'ENOENT') {\n return null;\n }\n\n throw error;\n }\n}\n\nexport { readFile, readFileSync };\n"],"file":"readFile.js"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/types.d.ts b/node_modules/cosmiconfig/dist/types.d.ts new file mode 100644 index 00000000..90726153 --- /dev/null +++ b/node_modules/cosmiconfig/dist/types.d.ts @@ -0,0 +1,20 @@ +import { Loader, LoaderSync, Options, OptionsSync } from './index'; +export declare type Config = any; +export declare type CosmiconfigResult = { + config: Config; + filepath: string; + isEmpty?: boolean; +} | null; +export interface ExplorerOptions extends Required { +} +export interface ExplorerOptionsSync extends Required { +} +export declare type Cache = Map; +export declare type LoadedFileContent = Config | null | undefined; +export interface Loaders { + [key: string]: Loader; +} +export interface LoadersSync { + [key: string]: LoaderSync; +} +//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/types.d.ts.map b/node_modules/cosmiconfig/dist/types.d.ts.map new file mode 100644 index 00000000..dff2f98d --- /dev/null +++ b/node_modules/cosmiconfig/dist/types.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGnE,oBAAY,MAAM,GAAG,GAAG,CAAC;AAEzB,oBAAY,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,GAAG,IAAI,CAAC;AAIT,MAAM,WAAW,eAAgB,SAAQ,QAAQ,CAAC,OAAO,CAAC;CAAG;AAC7D,MAAM,WAAW,mBAAoB,SAAQ,QAAQ,CAAC,WAAW,CAAC;CAAG;AAGrE,oBAAY,KAAK,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAMnD,oBAAY,iBAAiB,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;CAC3B"} \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/types.js b/node_modules/cosmiconfig/dist/types.js new file mode 100644 index 00000000..2f0e4146 --- /dev/null +++ b/node_modules/cosmiconfig/dist/types.js @@ -0,0 +1,2 @@ +"use strict"; +//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/node_modules/cosmiconfig/dist/types.js.map b/node_modules/cosmiconfig/dist/types.js.map new file mode 100644 index 00000000..036ac15b --- /dev/null +++ b/node_modules/cosmiconfig/dist/types.js.map @@ -0,0 +1 @@ +{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"types.js"} \ No newline at end of file diff --git a/node_modules/dedent/dist/dedent.js b/node_modules/dedent/dist/dedent.js new file mode 100644 index 00000000..8979b573 --- /dev/null +++ b/node_modules/dedent/dist/dedent.js @@ -0,0 +1,59 @@ +"use strict"; + +function dedent(strings) { + + var raw = void 0; + if (typeof strings === "string") { + // dedent can be used as a plain function + raw = [strings]; + } else { + raw = strings.raw; + } + + // first, perform interpolation + var result = ""; + for (var i = 0; i < raw.length; i++) { + result += raw[i]. + // join lines when there is a suppressed newline + replace(/\\\n[ \t]*/g, ""). + + // handle escaped backticks + replace(/\\`/g, "`"); + + if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) { + result += arguments.length <= i + 1 ? undefined : arguments[i + 1]; + } + } + + // now strip indentation + var lines = result.split("\n"); + var mindent = null; + lines.forEach(function (l) { + var m = l.match(/^(\s+)\S+/); + if (m) { + var indent = m[1].length; + if (!mindent) { + // this is the first indented line + mindent = indent; + } else { + mindent = Math.min(mindent, indent); + } + } + }); + + if (mindent !== null) { + result = lines.map(function (l) { + return l[0] === " " ? l.slice(mindent) : l; + }).join("\n"); + } + + // dedent eats leading and trailing whitespace too + result = result.trim(); + + // handle escaped newlines at the end to ensure they don't get stripped too + return result.replace(/\\n/g, "\n"); +} + +if (typeof module !== "undefined") { + module.exports = dedent; +} diff --git a/node_modules/lines-and-columns/dist/index.d.ts b/node_modules/lines-and-columns/dist/index.d.ts new file mode 100644 index 00000000..93341f54 --- /dev/null +++ b/node_modules/lines-and-columns/dist/index.d.ts @@ -0,0 +1,12 @@ +export declare type SourceLocation = { + line: number; + column: number; +}; +export default class LinesAndColumns { + private string; + private offsets; + constructor(string: string); + locationForIndex(index: number): SourceLocation | null; + indexForLocation(location: SourceLocation): number | null; + private lengthOfLine(line); +} diff --git a/node_modules/lines-and-columns/dist/index.js b/node_modules/lines-and-columns/dist/index.js new file mode 100644 index 00000000..a2469c63 --- /dev/null +++ b/node_modules/lines-and-columns/dist/index.js @@ -0,0 +1,58 @@ +"use strict"; +var LF = '\n'; +var CR = '\r'; +var LinesAndColumns = (function () { + function LinesAndColumns(string) { + this.string = string; + var offsets = [0]; + for (var offset = 0; offset < string.length;) { + switch (string[offset]) { + case LF: + offset += LF.length; + offsets.push(offset); + break; + case CR: + offset += CR.length; + if (string[offset] === LF) { + offset += LF.length; + } + offsets.push(offset); + break; + default: + offset++; + break; + } + } + this.offsets = offsets; + } + LinesAndColumns.prototype.locationForIndex = function (index) { + if (index < 0 || index > this.string.length) { + return null; + } + var line = 0; + var offsets = this.offsets; + while (offsets[line + 1] <= index) { + line++; + } + var column = index - offsets[line]; + return { line: line, column: column }; + }; + LinesAndColumns.prototype.indexForLocation = function (location) { + var line = location.line, column = location.column; + if (line < 0 || line >= this.offsets.length) { + return null; + } + if (column < 0 || column > this.lengthOfLine(line)) { + return null; + } + return this.offsets[line] + column; + }; + LinesAndColumns.prototype.lengthOfLine = function (line) { + var offset = this.offsets[line]; + var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1]; + return nextOffset - offset; + }; + return LinesAndColumns; +}()); +exports.__esModule = true; +exports["default"] = LinesAndColumns; diff --git a/node_modules/lines-and-columns/dist/index.mjs b/node_modules/lines-and-columns/dist/index.mjs new file mode 100644 index 00000000..e8519eec --- /dev/null +++ b/node_modules/lines-and-columns/dist/index.mjs @@ -0,0 +1,56 @@ +var LF = '\n'; +var CR = '\r'; +var LinesAndColumns = (function () { + function LinesAndColumns(string) { + this.string = string; + var offsets = [0]; + for (var offset = 0; offset < string.length;) { + switch (string[offset]) { + case LF: + offset += LF.length; + offsets.push(offset); + break; + case CR: + offset += CR.length; + if (string[offset] === LF) { + offset += LF.length; + } + offsets.push(offset); + break; + default: + offset++; + break; + } + } + this.offsets = offsets; + } + LinesAndColumns.prototype.locationForIndex = function (index) { + if (index < 0 || index > this.string.length) { + return null; + } + var line = 0; + var offsets = this.offsets; + while (offsets[line + 1] <= index) { + line++; + } + var column = index - offsets[line]; + return { line: line, column: column }; + }; + LinesAndColumns.prototype.indexForLocation = function (location) { + var line = location.line, column = location.column; + if (line < 0 || line >= this.offsets.length) { + return null; + } + if (column < 0 || column > this.lengthOfLine(line)) { + return null; + } + return this.offsets[line] + column; + }; + LinesAndColumns.prototype.lengthOfLine = function (line) { + var offset = this.offsets[line]; + var nextOffset = line === this.offsets.length - 1 ? this.string.length : this.offsets[line + 1]; + return nextOffset - offset; + }; + return LinesAndColumns; +}()); +export default LinesAndColumns; diff --git a/node_modules/source-map/dist/source-map.debug.js b/node_modules/source-map/dist/source-map.debug.js new file mode 100644 index 00000000..b5ab6382 --- /dev/null +++ b/node_modules/source-map/dist/source-map.debug.js @@ -0,0 +1,3091 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["sourceMap"] = factory(); + else + root["sourceMap"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + /* + * Copyright 2009-2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE.txt or: + * http://opensource.org/licenses/BSD-3-Clause + */ + exports.SourceMapGenerator = __webpack_require__(1).SourceMapGenerator; + exports.SourceMapConsumer = __webpack_require__(7).SourceMapConsumer; + exports.SourceNode = __webpack_require__(10).SourceNode; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var base64VLQ = __webpack_require__(2); + var util = __webpack_require__(4); + var ArraySet = __webpack_require__(5).ArraySet; + var MappingList = __webpack_require__(6).MappingList; + + /** + * An instance of the SourceMapGenerator represents a source map which is + * being built incrementally. You may pass an object with the following + * properties: + * + * - file: The filename of the generated source. + * - sourceRoot: A root for all relative URLs in this source map. + */ + function SourceMapGenerator(aArgs) { + if (!aArgs) { + aArgs = {}; + } + this._file = util.getArg(aArgs, 'file', null); + this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); + this._skipValidation = util.getArg(aArgs, 'skipValidation', false); + this._sources = new ArraySet(); + this._names = new ArraySet(); + this._mappings = new MappingList(); + this._sourcesContents = null; + } + + SourceMapGenerator.prototype._version = 3; + + /** + * Creates a new SourceMapGenerator based on a SourceMapConsumer + * + * @param aSourceMapConsumer The SourceMap. + */ + SourceMapGenerator.fromSourceMap = + function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { + var sourceRoot = aSourceMapConsumer.sourceRoot; + var generator = new SourceMapGenerator({ + file: aSourceMapConsumer.file, + sourceRoot: sourceRoot + }); + aSourceMapConsumer.eachMapping(function (mapping) { + var newMapping = { + generated: { + line: mapping.generatedLine, + column: mapping.generatedColumn + } + }; + + if (mapping.source != null) { + newMapping.source = mapping.source; + if (sourceRoot != null) { + newMapping.source = util.relative(sourceRoot, newMapping.source); + } + + newMapping.original = { + line: mapping.originalLine, + column: mapping.originalColumn + }; + + if (mapping.name != null) { + newMapping.name = mapping.name; + } + } + + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; + + /** + * Add a single mapping from original source line and column to the generated + * source's line and column for this source map being created. The mapping + * object should have the following properties: + * + * - generated: An object with the generated line and column positions. + * - original: An object with the original line and column positions. + * - source: The original source file (relative to the sourceRoot). + * - name: An optional original token name for this mapping. + */ + SourceMapGenerator.prototype.addMapping = + function SourceMapGenerator_addMapping(aArgs) { + var generated = util.getArg(aArgs, 'generated'); + var original = util.getArg(aArgs, 'original', null); + var source = util.getArg(aArgs, 'source', null); + var name = util.getArg(aArgs, 'name', null); + + if (!this._skipValidation) { + this._validateMapping(generated, original, source, name); + } + + if (source != null) { + source = String(source); + if (!this._sources.has(source)) { + this._sources.add(source); + } + } + + if (name != null) { + name = String(name); + if (!this._names.has(name)) { + this._names.add(name); + } + } + + this._mappings.add({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + + /** + * Set the source content for a source file. + */ + SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot != null) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent != null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = Object.create(null); + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else if (this._sourcesContents) { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + + /** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + * @param aSourceMapPath Optional. The dirname of the path to the source map + * to be applied. If relative, it is relative to the SourceMapConsumer. + * This parameter is needed when the two source maps aren't in the same + * directory, and the source map to be applied contains relative source + * paths. If so, those relative source paths need to be rewritten + * relative to the SourceMapGenerator. + */ + SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { + var sourceFile = aSourceFile; + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (aSourceFile == null) { + if (aSourceMapConsumer.file == null) { + throw new Error( + 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + + 'or the source map\'s "file" property. Both were omitted.' + ); + } + sourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "sourceFile" relative if an absolute Url is passed. + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "sourceFile" + this._mappings.unsortedForEach(function (mapping) { + if (mapping.source === sourceFile && mapping.originalLine != null) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source != null) { + // Copy mapping + mapping.source = original.source; + if (aSourceMapPath != null) { + mapping.source = util.join(aSourceMapPath, mapping.source) + } + if (sourceRoot != null) { + mapping.source = util.relative(sourceRoot, mapping.source); + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name != null) { + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source != null && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name != null && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aSourceMapPath != null) { + sourceFile = util.join(aSourceMapPath, sourceFile); + } + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + + /** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ + SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + // When aOriginal is truthy but has empty values for .line and .column, + // it is most likely a programmer error. In this case we throw a very + // specific error message to try to guide them the right way. + // For example: https://github.com/Polymer/polymer-bundler/pull/519 + if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { + throw new Error( + 'original.line and original.column are not numbers -- you probably meant to omit ' + + 'the original mapping entirely and only map the generated position. If so, pass ' + + 'null for the original mapping instead of an object with empty or null values.' + ); + } + + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + original: aOriginal, + name: aName + })); + } + }; + + /** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ + SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var next; + var mapping; + var nameIdx; + var sourceIdx; + + var mappings = this._mappings.toArray(); + for (var i = 0, len = mappings.length; i < len; i++) { + mapping = mappings[i]; + next = '' + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + next += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { + continue; + } + next += ','; + } + } + + next += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source != null) { + sourceIdx = this._sources.indexOf(mapping.source); + next += base64VLQ.encode(sourceIdx - previousSource); + previousSource = sourceIdx; + + // lines are stored 0-based in SourceMap spec version 3 + next += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + next += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name != null) { + nameIdx = this._names.indexOf(mapping.name); + next += base64VLQ.encode(nameIdx - previousName); + previousName = nameIdx; + } + } + + result += next; + } + + return result; + }; + + SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot != null) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) + ? this._sourcesContents[key] + : null; + }, this); + }; + + /** + * Externalize the source map. + */ + SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._file != null) { + map.file = this._file; + } + if (this._sourceRoot != null) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + + /** + * Render the source map being generated to a string. + */ + SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this.toJSON()); + }; + + exports.SourceMapGenerator = SourceMapGenerator; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + * + * Based on the Base 64 VLQ implementation in Closure Compiler: + * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java + * + * Copyright 2011 The Closure Compiler Authors. All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + var base64 = __webpack_require__(3); + + // A single base 64 digit can contain 6 bits of data. For the base 64 variable + // length quantities we use in the source map spec, the first bit is the sign, + // the next four bits are the actual value, and the 6th bit is the + // continuation bit. The continuation bit tells us whether there are more + // digits in this value following this digit. + // + // Continuation + // | Sign + // | | + // V V + // 101011 + + var VLQ_BASE_SHIFT = 5; + + // binary: 100000 + var VLQ_BASE = 1 << VLQ_BASE_SHIFT; + + // binary: 011111 + var VLQ_BASE_MASK = VLQ_BASE - 1; + + // binary: 100000 + var VLQ_CONTINUATION_BIT = VLQ_BASE; + + /** + * Converts from a two-complement value to a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) + * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) + */ + function toVLQSigned(aValue) { + return aValue < 0 + ? ((-aValue) << 1) + 1 + : (aValue << 1) + 0; + } + + /** + * Converts to a two-complement value from a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 + * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 + */ + function fromVLQSigned(aValue) { + var isNegative = (aValue & 1) === 1; + var shifted = aValue >> 1; + return isNegative + ? -shifted + : shifted; + } + + /** + * Returns the base 64 VLQ encoded value. + */ + exports.encode = function base64VLQ_encode(aValue) { + var encoded = ""; + var digit; + + var vlq = toVLQSigned(aValue); + + do { + digit = vlq & VLQ_BASE_MASK; + vlq >>>= VLQ_BASE_SHIFT; + if (vlq > 0) { + // There are still more digits in this value, so we must make sure the + // continuation bit is marked. + digit |= VLQ_CONTINUATION_BIT; + } + encoded += base64.encode(digit); + } while (vlq > 0); + + return encoded; + }; + + /** + * Decodes the next base 64 VLQ value from the given string and returns the + * value and the rest of the string via the out parameter. + */ + exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { + var strLen = aStr.length; + var result = 0; + var shift = 0; + var continuation, digit; + + do { + if (aIndex >= strLen) { + throw new Error("Expected more digits in base 64 VLQ value."); + } + + digit = base64.decode(aStr.charCodeAt(aIndex++)); + if (digit === -1) { + throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); + } + + continuation = !!(digit & VLQ_CONTINUATION_BIT); + digit &= VLQ_BASE_MASK; + result = result + (digit << shift); + shift += VLQ_BASE_SHIFT; + } while (continuation); + + aOutParam.value = fromVLQSigned(result); + aOutParam.rest = aIndex; + }; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); + + /** + * Encode an integer in the range of 0 to 63 to a single base 64 digit. + */ + exports.encode = function (number) { + if (0 <= number && number < intToCharMap.length) { + return intToCharMap[number]; + } + throw new TypeError("Must be between 0 and 63: " + number); + }; + + /** + * Decode a single base 64 character code digit to an integer. Returns -1 on + * failure. + */ + exports.decode = function (charCode) { + var bigA = 65; // 'A' + var bigZ = 90; // 'Z' + + var littleA = 97; // 'a' + var littleZ = 122; // 'z' + + var zero = 48; // '0' + var nine = 57; // '9' + + var plus = 43; // '+' + var slash = 47; // '/' + + var littleOffset = 26; + var numberOffset = 52; + + // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ + if (bigA <= charCode && charCode <= bigZ) { + return (charCode - bigA); + } + + // 26 - 51: abcdefghijklmnopqrstuvwxyz + if (littleA <= charCode && charCode <= littleZ) { + return (charCode - littleA + littleOffset); + } + + // 52 - 61: 0123456789 + if (zero <= charCode && charCode <= nine) { + return (charCode - zero + numberOffset); + } + + // 62: + + if (charCode == plus) { + return 62; + } + + // 63: / + if (charCode == slash) { + return 63; + } + + // Invalid base64 digit. + return -1; + }; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + /** + * This is a helper function for getting values from parameter/options + * objects. + * + * @param args The object we are extracting values from + * @param name The name of the property we are getting. + * @param defaultValue An optional value to return if the property is missing + * from the object. If this is not specified and the property is missing, an + * error will be thrown. + */ + function getArg(aArgs, aName, aDefaultValue) { + if (aName in aArgs) { + return aArgs[aName]; + } else if (arguments.length === 3) { + return aDefaultValue; + } else { + throw new Error('"' + aName + '" is a required argument.'); + } + } + exports.getArg = getArg; + + var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; + var dataUrlRegexp = /^data:.+\,.+$/; + + function urlParse(aUrl) { + var match = aUrl.match(urlRegexp); + if (!match) { + return null; + } + return { + scheme: match[1], + auth: match[2], + host: match[3], + port: match[4], + path: match[5] + }; + } + exports.urlParse = urlParse; + + function urlGenerate(aParsedUrl) { + var url = ''; + if (aParsedUrl.scheme) { + url += aParsedUrl.scheme + ':'; + } + url += '//'; + if (aParsedUrl.auth) { + url += aParsedUrl.auth + '@'; + } + if (aParsedUrl.host) { + url += aParsedUrl.host; + } + if (aParsedUrl.port) { + url += ":" + aParsedUrl.port + } + if (aParsedUrl.path) { + url += aParsedUrl.path; + } + return url; + } + exports.urlGenerate = urlGenerate; + + /** + * Normalizes a path, or the path portion of a URL: + * + * - Replaces consecutive slashes with one slash. + * - Removes unnecessary '.' parts. + * - Removes unnecessary '/..' parts. + * + * Based on code in the Node.js 'path' core module. + * + * @param aPath The path or url to normalize. + */ + function normalize(aPath) { + var path = aPath; + var url = urlParse(aPath); + if (url) { + if (!url.path) { + return aPath; + } + path = url.path; + } + var isAbsolute = exports.isAbsolute(path); + + var parts = path.split(/\/+/); + for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { + part = parts[i]; + if (part === '.') { + parts.splice(i, 1); + } else if (part === '..') { + up++; + } else if (up > 0) { + if (part === '') { + // The first part is blank if the path is absolute. Trying to go + // above the root is a no-op. Therefore we can remove all '..' parts + // directly after the root. + parts.splice(i + 1, up); + up = 0; + } else { + parts.splice(i, 2); + up--; + } + } + } + path = parts.join('/'); + + if (path === '') { + path = isAbsolute ? '/' : '.'; + } + + if (url) { + url.path = path; + return urlGenerate(url); + } + return path; + } + exports.normalize = normalize; + + /** + * Joins two paths/URLs. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be joined with the root. + * + * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a + * scheme-relative URL: Then the scheme of aRoot, if any, is prepended + * first. + * - Otherwise aPath is a path. If aRoot is a URL, then its path portion + * is updated with the result and aRoot is returned. Otherwise the result + * is returned. + * - If aPath is absolute, the result is aPath. + * - Otherwise the two paths are joined with a slash. + * - Joining for example 'http://' and 'www.example.com' is also supported. + */ + function join(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + if (aPath === "") { + aPath = "."; + } + var aPathUrl = urlParse(aPath); + var aRootUrl = urlParse(aRoot); + if (aRootUrl) { + aRoot = aRootUrl.path || '/'; + } + + // `join(foo, '//www.example.org')` + if (aPathUrl && !aPathUrl.scheme) { + if (aRootUrl) { + aPathUrl.scheme = aRootUrl.scheme; + } + return urlGenerate(aPathUrl); + } + + if (aPathUrl || aPath.match(dataUrlRegexp)) { + return aPath; + } + + // `join('http://', 'www.example.com')` + if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { + aRootUrl.host = aPath; + return urlGenerate(aRootUrl); + } + + var joined = aPath.charAt(0) === '/' + ? aPath + : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); + + if (aRootUrl) { + aRootUrl.path = joined; + return urlGenerate(aRootUrl); + } + return joined; + } + exports.join = join; + + exports.isAbsolute = function (aPath) { + return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp); + }; + + /** + * Make a path relative to a URL or another path. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be made relative to aRoot. + */ + function relative(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + + aRoot = aRoot.replace(/\/$/, ''); + + // It is possible for the path to be above the root. In this case, simply + // checking whether the root is a prefix of the path won't work. Instead, we + // need to remove components from the root one by one, until either we find + // a prefix that fits, or we run out of components to remove. + var level = 0; + while (aPath.indexOf(aRoot + '/') !== 0) { + var index = aRoot.lastIndexOf("/"); + if (index < 0) { + return aPath; + } + + // If the only part of the root that is left is the scheme (i.e. http://, + // file:///, etc.), one or more slashes (/), or simply nothing at all, we + // have exhausted all components, so the path is not relative to the root. + aRoot = aRoot.slice(0, index); + if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { + return aPath; + } + + ++level; + } + + // Make sure we add a "../" for each component we removed from the root. + return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); + } + exports.relative = relative; + + var supportsNullProto = (function () { + var obj = Object.create(null); + return !('__proto__' in obj); + }()); + + function identity (s) { + return s; + } + + /** + * Because behavior goes wacky when you set `__proto__` on objects, we + * have to prefix all the strings in our set with an arbitrary character. + * + * See https://github.com/mozilla/source-map/pull/31 and + * https://github.com/mozilla/source-map/issues/30 + * + * @param String aStr + */ + function toSetString(aStr) { + if (isProtoString(aStr)) { + return '$' + aStr; + } + + return aStr; + } + exports.toSetString = supportsNullProto ? identity : toSetString; + + function fromSetString(aStr) { + if (isProtoString(aStr)) { + return aStr.slice(1); + } + + return aStr; + } + exports.fromSetString = supportsNullProto ? identity : fromSetString; + + function isProtoString(s) { + if (!s) { + return false; + } + + var length = s.length; + + if (length < 9 /* "__proto__".length */) { + return false; + } + + if (s.charCodeAt(length - 1) !== 95 /* '_' */ || + s.charCodeAt(length - 2) !== 95 /* '_' */ || + s.charCodeAt(length - 3) !== 111 /* 'o' */ || + s.charCodeAt(length - 4) !== 116 /* 't' */ || + s.charCodeAt(length - 5) !== 111 /* 'o' */ || + s.charCodeAt(length - 6) !== 114 /* 'r' */ || + s.charCodeAt(length - 7) !== 112 /* 'p' */ || + s.charCodeAt(length - 8) !== 95 /* '_' */ || + s.charCodeAt(length - 9) !== 95 /* '_' */) { + return false; + } + + for (var i = length - 10; i >= 0; i--) { + if (s.charCodeAt(i) !== 36 /* '$' */) { + return false; + } + } + + return true; + } + + /** + * Comparator between two mappings where the original positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same original source/line/column, but different generated + * line and column the same. Useful when searching for a mapping with a + * stubbed out mapping. + */ + function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { + var cmp = mappingA.source - mappingB.source; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0 || onlyCompareOriginal) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + return mappingA.name - mappingB.name; + } + exports.compareByOriginalPositions = compareByOriginalPositions; + + /** + * Comparator between two mappings with deflated source and name indices where + * the generated positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same generated line and column, but different + * source/name/original line and column the same. Useful when searching for a + * mapping with a stubbed out mapping. + */ + function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { + var cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0 || onlyCompareGenerated) { + return cmp; + } + + cmp = mappingA.source - mappingB.source; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; + } + + return mappingA.name - mappingB.name; + } + exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; + + function strcmp(aStr1, aStr2) { + if (aStr1 === aStr2) { + return 0; + } + + if (aStr1 > aStr2) { + return 1; + } + + return -1; + } + + /** + * Comparator between two mappings with inflated source and name strings where + * the generated positions are compared. + */ + function compareByGeneratedPositionsInflated(mappingA, mappingB) { + var cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } + + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; + } + + return strcmp(mappingA.name, mappingB.name); + } + exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + var has = Object.prototype.hasOwnProperty; + var hasNativeMap = typeof Map !== "undefined"; + + /** + * A data structure which is a combination of an array and a set. Adding a new + * member is O(1), testing for membership is O(1), and finding the index of an + * element is O(1). Removing elements from the set is not supported. Only + * strings are supported for membership. + */ + function ArraySet() { + this._array = []; + this._set = hasNativeMap ? new Map() : Object.create(null); + } + + /** + * Static method for creating ArraySet instances from an existing array. + */ + ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { + var set = new ArraySet(); + for (var i = 0, len = aArray.length; i < len; i++) { + set.add(aArray[i], aAllowDuplicates); + } + return set; + }; + + /** + * Return how many unique items are in this ArraySet. If duplicates have been + * added, than those do not count towards the size. + * + * @returns Number + */ + ArraySet.prototype.size = function ArraySet_size() { + return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; + }; + + /** + * Add the given string to this set. + * + * @param String aStr + */ + ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { + var sStr = hasNativeMap ? aStr : util.toSetString(aStr); + var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); + var idx = this._array.length; + if (!isDuplicate || aAllowDuplicates) { + this._array.push(aStr); + } + if (!isDuplicate) { + if (hasNativeMap) { + this._set.set(aStr, idx); + } else { + this._set[sStr] = idx; + } + } + }; + + /** + * Is the given string a member of this set? + * + * @param String aStr + */ + ArraySet.prototype.has = function ArraySet_has(aStr) { + if (hasNativeMap) { + return this._set.has(aStr); + } else { + var sStr = util.toSetString(aStr); + return has.call(this._set, sStr); + } + }; + + /** + * What is the index of the given string in the array? + * + * @param String aStr + */ + ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { + if (hasNativeMap) { + var idx = this._set.get(aStr); + if (idx >= 0) { + return idx; + } + } else { + var sStr = util.toSetString(aStr); + if (has.call(this._set, sStr)) { + return this._set[sStr]; + } + } + + throw new Error('"' + aStr + '" is not in the set.'); + }; + + /** + * What is the element at the given index? + * + * @param Number aIdx + */ + ArraySet.prototype.at = function ArraySet_at(aIdx) { + if (aIdx >= 0 && aIdx < this._array.length) { + return this._array[aIdx]; + } + throw new Error('No element indexed by ' + aIdx); + }; + + /** + * Returns the array representation of this set (which has the proper indices + * indicated by indexOf). Note that this is a copy of the internal array used + * for storing the members so that no one can mess with internal state. + */ + ArraySet.prototype.toArray = function ArraySet_toArray() { + return this._array.slice(); + }; + + exports.ArraySet = ArraySet; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2014 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + + /** + * Determine whether mappingB is after mappingA with respect to generated + * position. + */ + function generatedPositionAfter(mappingA, mappingB) { + // Optimized for most common case + var lineA = mappingA.generatedLine; + var lineB = mappingB.generatedLine; + var columnA = mappingA.generatedColumn; + var columnB = mappingB.generatedColumn; + return lineB > lineA || lineB == lineA && columnB >= columnA || + util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; + } + + /** + * A data structure to provide a sorted view of accumulated mappings in a + * performance conscious manner. It trades a neglibable overhead in general + * case for a large speedup in case of mappings being added in order. + */ + function MappingList() { + this._array = []; + this._sorted = true; + // Serves as infimum + this._last = {generatedLine: -1, generatedColumn: 0}; + } + + /** + * Iterate through internal items. This method takes the same arguments that + * `Array.prototype.forEach` takes. + * + * NOTE: The order of the mappings is NOT guaranteed. + */ + MappingList.prototype.unsortedForEach = + function MappingList_forEach(aCallback, aThisArg) { + this._array.forEach(aCallback, aThisArg); + }; + + /** + * Add the given source mapping. + * + * @param Object aMapping + */ + MappingList.prototype.add = function MappingList_add(aMapping) { + if (generatedPositionAfter(this._last, aMapping)) { + this._last = aMapping; + this._array.push(aMapping); + } else { + this._sorted = false; + this._array.push(aMapping); + } + }; + + /** + * Returns the flat, sorted array of mappings. The mappings are sorted by + * generated position. + * + * WARNING: This method returns internal data without copying, for + * performance. The return value must NOT be mutated, and should be treated as + * an immutable borrow. If you want to take ownership, you must make your own + * copy. + */ + MappingList.prototype.toArray = function MappingList_toArray() { + if (!this._sorted) { + this._array.sort(util.compareByGeneratedPositionsInflated); + this._sorted = true; + } + return this._array; + }; + + exports.MappingList = MappingList; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + var binarySearch = __webpack_require__(8); + var ArraySet = __webpack_require__(5).ArraySet; + var base64VLQ = __webpack_require__(2); + var quickSort = __webpack_require__(9).quickSort; + + function SourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + return sourceMap.sections != null + ? new IndexedSourceMapConsumer(sourceMap) + : new BasicSourceMapConsumer(sourceMap); + } + + SourceMapConsumer.fromSourceMap = function(aSourceMap) { + return BasicSourceMapConsumer.fromSourceMap(aSourceMap); + } + + /** + * The version of the source mapping spec that we are consuming. + */ + SourceMapConsumer.prototype._version = 3; + + // `__generatedMappings` and `__originalMappings` are arrays that hold the + // parsed mapping coordinates from the source map's "mappings" attribute. They + // are lazily instantiated, accessed via the `_generatedMappings` and + // `_originalMappings` getters respectively, and we only parse the mappings + // and create these arrays once queried for a source location. We jump through + // these hoops because there can be many thousands of mappings, and parsing + // them is expensive, so we only want to do it if we must. + // + // Each object in the arrays is of the form: + // + // { + // generatedLine: The line number in the generated code, + // generatedColumn: The column number in the generated code, + // source: The path to the original source file that generated this + // chunk of code, + // originalLine: The line number in the original source that + // corresponds to this chunk of generated code, + // originalColumn: The column number in the original source that + // corresponds to this chunk of generated code, + // name: The name of the original symbol which generated this chunk of + // code. + // } + // + // All properties except for `generatedLine` and `generatedColumn` can be + // `null`. + // + // `_generatedMappings` is ordered by the generated positions. + // + // `_originalMappings` is ordered by the original positions. + + SourceMapConsumer.prototype.__generatedMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { + get: function () { + if (!this.__generatedMappings) { + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__generatedMappings; + } + }); + + SourceMapConsumer.prototype.__originalMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { + get: function () { + if (!this.__originalMappings) { + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__originalMappings; + } + }); + + SourceMapConsumer.prototype._charIsMappingSeparator = + function SourceMapConsumer_charIsMappingSeparator(aStr, index) { + var c = aStr.charAt(index); + return c === ";" || c === ","; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + SourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + throw new Error("Subclasses must implement _parseMappings"); + }; + + SourceMapConsumer.GENERATED_ORDER = 1; + SourceMapConsumer.ORIGINAL_ORDER = 2; + + SourceMapConsumer.GREATEST_LOWER_BOUND = 1; + SourceMapConsumer.LEAST_UPPER_BOUND = 2; + + /** + * Iterate over each mapping between an original source/line/column and a + * generated line/column in this source map. + * + * @param Function aCallback + * The function that is called with each mapping. + * @param Object aContext + * Optional. If specified, this object will be the value of `this` every + * time that `aCallback` is called. + * @param aOrder + * Either `SourceMapConsumer.GENERATED_ORDER` or + * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to + * iterate over the mappings sorted by the generated file's line/column + * order or the original's source/line/column order, respectively. Defaults to + * `SourceMapConsumer.GENERATED_ORDER`. + */ + SourceMapConsumer.prototype.eachMapping = + function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { + var context = aContext || null; + var order = aOrder || SourceMapConsumer.GENERATED_ORDER; + + var mappings; + switch (order) { + case SourceMapConsumer.GENERATED_ORDER: + mappings = this._generatedMappings; + break; + case SourceMapConsumer.ORIGINAL_ORDER: + mappings = this._originalMappings; + break; + default: + throw new Error("Unknown order of iteration."); + } + + var sourceRoot = this.sourceRoot; + mappings.map(function (mapping) { + var source = mapping.source === null ? null : this._sources.at(mapping.source); + if (source != null && sourceRoot != null) { + source = util.join(sourceRoot, source); + } + return { + source: source, + generatedLine: mapping.generatedLine, + generatedColumn: mapping.generatedColumn, + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: mapping.name === null ? null : this._names.at(mapping.name) + }; + }, this).forEach(aCallback, context); + }; + + /** + * Returns all generated line and column information for the original source, + * line, and column provided. If no column is provided, returns all mappings + * corresponding to a either the line we are searching for or the next + * closest line that has any mappings. Otherwise, returns all mappings + * corresponding to the given line and either the column we are searching for + * or the next closest column that has any offsets. + * + * The only argument is an object with the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: Optional. the column number in the original source. + * + * and an array of objects is returned, each with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + SourceMapConsumer.prototype.allGeneratedPositionsFor = + function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { + var line = util.getArg(aArgs, 'line'); + + // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping + // returns the index of the closest mapping less than the needle. By + // setting needle.originalColumn to 0, we thus find the last mapping for + // the given line, provided such a mapping exists. + var needle = { + source: util.getArg(aArgs, 'source'), + originalLine: line, + originalColumn: util.getArg(aArgs, 'column', 0) + }; + + if (this.sourceRoot != null) { + needle.source = util.relative(this.sourceRoot, needle.source); + } + if (!this._sources.has(needle.source)) { + return []; + } + needle.source = this._sources.indexOf(needle.source); + + var mappings = []; + + var index = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + binarySearch.LEAST_UPPER_BOUND); + if (index >= 0) { + var mapping = this._originalMappings[index]; + + if (aArgs.column === undefined) { + var originalLine = mapping.originalLine; + + // Iterate until either we run out of mappings, or we run into + // a mapping for a different line than the one we found. Since + // mappings are sorted, this is guaranteed to find all mappings for + // the line we found. + while (mapping && mapping.originalLine === originalLine) { + mappings.push({ + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }); + + mapping = this._originalMappings[++index]; + } + } else { + var originalColumn = mapping.originalColumn; + + // Iterate until either we run out of mappings, or we run into + // a mapping for a different line than the one we were searching for. + // Since mappings are sorted, this is guaranteed to find all mappings for + // the line we are searching for. + while (mapping && + mapping.originalLine === line && + mapping.originalColumn == originalColumn) { + mappings.push({ + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }); + + mapping = this._originalMappings[++index]; + } + } + } + + return mappings; + }; + + exports.SourceMapConsumer = SourceMapConsumer; + + /** + * A BasicSourceMapConsumer instance represents a parsed source map which we can + * query for information about the original file positions by giving it a file + * position in the generated source. + * + * The only parameter is the raw source map (either as a JSON string, or + * already parsed to an object). According to the spec, source maps have the + * following attributes: + * + * - version: Which version of the source map spec this map is following. + * - sources: An array of URLs to the original source files. + * - names: An array of identifiers which can be referrenced by individual mappings. + * - sourceRoot: Optional. The URL root from which all sources are relative. + * - sourcesContent: Optional. An array of contents of the original source files. + * - mappings: A string of base64 VLQs which contain the actual mappings. + * - file: Optional. The generated file this source map is associated with. + * + * Here is an example source map, taken from the source map spec[0]: + * + * { + * version : 3, + * file: "out.js", + * sourceRoot : "", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AA,AB;;ABCDE;" + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# + */ + function BasicSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sources = util.getArg(sourceMap, 'sources'); + // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which + // requires the array) to play nice here. + var names = util.getArg(sourceMap, 'names', []); + var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); + var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); + var mappings = util.getArg(sourceMap, 'mappings'); + var file = util.getArg(sourceMap, 'file', null); + + // Once again, Sass deviates from the spec and supplies the version as a + // string rather than a number, so we use loose equality checking here. + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + sources = sources + .map(String) + // Some source maps produce relative source paths like "./foo.js" instead of + // "foo.js". Normalize these first so that future comparisons will succeed. + // See bugzil.la/1090768. + .map(util.normalize) + // Always ensure that absolute sources are internally stored relative to + // the source root, if the source root is absolute. Not doing this would + // be particularly problematic when the source root is a prefix of the + // source (valid, but why??). See github issue #199 and bugzil.la/1188982. + .map(function (source) { + return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) + ? util.relative(sourceRoot, source) + : source; + }); + + // Pass `true` below to allow duplicate names and sources. While source maps + // are intended to be compressed and deduplicated, the TypeScript compiler + // sometimes generates source maps with duplicates in them. See Github issue + // #72 and bugzil.la/889492. + this._names = ArraySet.fromArray(names.map(String), true); + this._sources = ArraySet.fromArray(sources, true); + + this.sourceRoot = sourceRoot; + this.sourcesContent = sourcesContent; + this._mappings = mappings; + this.file = file; + } + + BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; + + /** + * Create a BasicSourceMapConsumer from a SourceMapGenerator. + * + * @param SourceMapGenerator aSourceMap + * The source map that will be consumed. + * @returns BasicSourceMapConsumer + */ + BasicSourceMapConsumer.fromSourceMap = + function SourceMapConsumer_fromSourceMap(aSourceMap) { + var smc = Object.create(BasicSourceMapConsumer.prototype); + + var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); + var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); + smc.sourceRoot = aSourceMap._sourceRoot; + smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), + smc.sourceRoot); + smc.file = aSourceMap._file; + + // Because we are modifying the entries (by converting string sources and + // names to indices into the sources and names ArraySets), we have to make + // a copy of the entry or else bad things happen. Shared mutable state + // strikes again! See github issue #191. + + var generatedMappings = aSourceMap._mappings.toArray().slice(); + var destGeneratedMappings = smc.__generatedMappings = []; + var destOriginalMappings = smc.__originalMappings = []; + + for (var i = 0, length = generatedMappings.length; i < length; i++) { + var srcMapping = generatedMappings[i]; + var destMapping = new Mapping; + destMapping.generatedLine = srcMapping.generatedLine; + destMapping.generatedColumn = srcMapping.generatedColumn; + + if (srcMapping.source) { + destMapping.source = sources.indexOf(srcMapping.source); + destMapping.originalLine = srcMapping.originalLine; + destMapping.originalColumn = srcMapping.originalColumn; + + if (srcMapping.name) { + destMapping.name = names.indexOf(srcMapping.name); + } + + destOriginalMappings.push(destMapping); + } + + destGeneratedMappings.push(destMapping); + } + + quickSort(smc.__originalMappings, util.compareByOriginalPositions); + + return smc; + }; + + /** + * The version of the source mapping spec that we are consuming. + */ + BasicSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { + get: function () { + return this._sources.toArray().map(function (s) { + return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; + }, this); + } + }); + + /** + * Provide the JIT with a nice shape / hidden class. + */ + function Mapping() { + this.generatedLine = 0; + this.generatedColumn = 0; + this.source = null; + this.originalLine = null; + this.originalColumn = null; + this.name = null; + } + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + BasicSourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + var generatedLine = 1; + var previousGeneratedColumn = 0; + var previousOriginalLine = 0; + var previousOriginalColumn = 0; + var previousSource = 0; + var previousName = 0; + var length = aStr.length; + var index = 0; + var cachedSegments = {}; + var temp = {}; + var originalMappings = []; + var generatedMappings = []; + var mapping, str, segment, end, value; + + while (index < length) { + if (aStr.charAt(index) === ';') { + generatedLine++; + index++; + previousGeneratedColumn = 0; + } + else if (aStr.charAt(index) === ',') { + index++; + } + else { + mapping = new Mapping(); + mapping.generatedLine = generatedLine; + + // Because each offset is encoded relative to the previous one, + // many segments often have the same encoding. We can exploit this + // fact by caching the parsed variable length fields of each segment, + // allowing us to avoid a second parse if we encounter the same + // segment again. + for (end = index; end < length; end++) { + if (this._charIsMappingSeparator(aStr, end)) { + break; + } + } + str = aStr.slice(index, end); + + segment = cachedSegments[str]; + if (segment) { + index += str.length; + } else { + segment = []; + while (index < end) { + base64VLQ.decode(aStr, index, temp); + value = temp.value; + index = temp.rest; + segment.push(value); + } + + if (segment.length === 2) { + throw new Error('Found a source, but no line and column'); + } + + if (segment.length === 3) { + throw new Error('Found a source and line, but no column'); + } + + cachedSegments[str] = segment; + } + + // Generated column. + mapping.generatedColumn = previousGeneratedColumn + segment[0]; + previousGeneratedColumn = mapping.generatedColumn; + + if (segment.length > 1) { + // Original source. + mapping.source = previousSource + segment[1]; + previousSource += segment[1]; + + // Original line. + mapping.originalLine = previousOriginalLine + segment[2]; + previousOriginalLine = mapping.originalLine; + // Lines are stored 0-based + mapping.originalLine += 1; + + // Original column. + mapping.originalColumn = previousOriginalColumn + segment[3]; + previousOriginalColumn = mapping.originalColumn; + + if (segment.length > 4) { + // Original name. + mapping.name = previousName + segment[4]; + previousName += segment[4]; + } + } + + generatedMappings.push(mapping); + if (typeof mapping.originalLine === 'number') { + originalMappings.push(mapping); + } + } + } + + quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); + this.__generatedMappings = generatedMappings; + + quickSort(originalMappings, util.compareByOriginalPositions); + this.__originalMappings = originalMappings; + }; + + /** + * Find the mapping that best matches the hypothetical "needle" mapping that + * we are searching for in the given "haystack" of mappings. + */ + BasicSourceMapConsumer.prototype._findMapping = + function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, + aColumnName, aComparator, aBias) { + // To return the position we are searching for, we must first find the + // mapping for the given position and then return the opposite position it + // points to. Because the mappings are sorted, we can use binary search to + // find the best mapping. + + if (aNeedle[aLineName] <= 0) { + throw new TypeError('Line must be greater than or equal to 1, got ' + + aNeedle[aLineName]); + } + if (aNeedle[aColumnName] < 0) { + throw new TypeError('Column must be greater than or equal to 0, got ' + + aNeedle[aColumnName]); + } + + return binarySearch.search(aNeedle, aMappings, aComparator, aBias); + }; + + /** + * Compute the last column for each generated mapping. The last column is + * inclusive. + */ + BasicSourceMapConsumer.prototype.computeColumnSpans = + function SourceMapConsumer_computeColumnSpans() { + for (var index = 0; index < this._generatedMappings.length; ++index) { + var mapping = this._generatedMappings[index]; + + // Mappings do not contain a field for the last generated columnt. We + // can come up with an optimistic estimate, however, by assuming that + // mappings are contiguous (i.e. given two consecutive mappings, the + // first mapping ends where the second one starts). + if (index + 1 < this._generatedMappings.length) { + var nextMapping = this._generatedMappings[index + 1]; + + if (mapping.generatedLine === nextMapping.generatedLine) { + mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; + continue; + } + } + + // The last mapping for each line spans the entire line. + mapping.lastGeneratedColumn = Infinity; + } + }; + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or + * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + BasicSourceMapConsumer.prototype.originalPositionFor = + function SourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + var index = this._findMapping( + needle, + this._generatedMappings, + "generatedLine", + "generatedColumn", + util.compareByGeneratedPositionsDeflated, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); + + if (index >= 0) { + var mapping = this._generatedMappings[index]; + + if (mapping.generatedLine === needle.generatedLine) { + var source = util.getArg(mapping, 'source', null); + if (source !== null) { + source = this._sources.at(source); + if (this.sourceRoot != null) { + source = util.join(this.sourceRoot, source); + } + } + var name = util.getArg(mapping, 'name', null); + if (name !== null) { + name = this._names.at(name); + } + return { + source: source, + line: util.getArg(mapping, 'originalLine', null), + column: util.getArg(mapping, 'originalColumn', null), + name: name + }; + } + } + + return { + source: null, + line: null, + column: null, + name: null + }; + }; + + /** + * Return true if we have the source content for every source in the source + * map, false otherwise. + */ + BasicSourceMapConsumer.prototype.hasContentsOfAllSources = + function BasicSourceMapConsumer_hasContentsOfAllSources() { + if (!this.sourcesContent) { + return false; + } + return this.sourcesContent.length >= this._sources.size() && + !this.sourcesContent.some(function (sc) { return sc == null; }); + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ + BasicSourceMapConsumer.prototype.sourceContentFor = + function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + if (!this.sourcesContent) { + return null; + } + + if (this.sourceRoot != null) { + aSource = util.relative(this.sourceRoot, aSource); + } + + if (this._sources.has(aSource)) { + return this.sourcesContent[this._sources.indexOf(aSource)]; + } + + var url; + if (this.sourceRoot != null + && (url = util.urlParse(this.sourceRoot))) { + // XXX: file:// URIs and absolute paths lead to unexpected behavior for + // many users. We can help them out when they expect file:// URIs to + // behave like it would if they were running a local HTTP server. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. + var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); + if (url.scheme == "file" + && this._sources.has(fileUriAbsPath)) { + return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] + } + + if ((!url.path || url.path == "/") + && this._sources.has("/" + aSource)) { + return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + } + } + + // This function is used recursively from + // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we + // don't want to throw if we can't find the source - we just want to + // return null, so we provide a flag to exit gracefully. + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or + * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + BasicSourceMapConsumer.prototype.generatedPositionFor = + function SourceMapConsumer_generatedPositionFor(aArgs) { + var source = util.getArg(aArgs, 'source'); + if (this.sourceRoot != null) { + source = util.relative(this.sourceRoot, source); + } + if (!this._sources.has(source)) { + return { + line: null, + column: null, + lastColumn: null + }; + } + source = this._sources.indexOf(source); + + var needle = { + source: source, + originalLine: util.getArg(aArgs, 'line'), + originalColumn: util.getArg(aArgs, 'column') + }; + + var index = this._findMapping( + needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); + + if (index >= 0) { + var mapping = this._originalMappings[index]; + + if (mapping.source === needle.source) { + return { + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }; + } + } + + return { + line: null, + column: null, + lastColumn: null + }; + }; + + exports.BasicSourceMapConsumer = BasicSourceMapConsumer; + + /** + * An IndexedSourceMapConsumer instance represents a parsed source map which + * we can query for information. It differs from BasicSourceMapConsumer in + * that it takes "indexed" source maps (i.e. ones with a "sections" field) as + * input. + * + * The only parameter is a raw source map (either as a JSON string, or already + * parsed to an object). According to the spec for indexed source maps, they + * have the following attributes: + * + * - version: Which version of the source map spec this map is following. + * - file: Optional. The generated file this source map is associated with. + * - sections: A list of section definitions. + * + * Each value under the "sections" field has two fields: + * - offset: The offset into the original specified at which this section + * begins to apply, defined as an object with a "line" and "column" + * field. + * - map: A source map definition. This source map could also be indexed, + * but doesn't have to be. + * + * Instead of the "map" field, it's also possible to have a "url" field + * specifying a URL to retrieve a source map from, but that's currently + * unsupported. + * + * Here's an example source map, taken from the source map spec[0], but + * modified to omit a section which uses the "url" field. + * + * { + * version : 3, + * file: "app.js", + * sections: [{ + * offset: {line:100, column:10}, + * map: { + * version : 3, + * file: "section.js", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AAAA,E;;ABCDE;" + * } + * }], + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt + */ + function IndexedSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sections = util.getArg(sourceMap, 'sections'); + + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + this._sources = new ArraySet(); + this._names = new ArraySet(); + + var lastOffset = { + line: -1, + column: 0 + }; + this._sections = sections.map(function (s) { + if (s.url) { + // The url field will require support for asynchronicity. + // See https://github.com/mozilla/source-map/issues/16 + throw new Error('Support for url field in sections not implemented.'); + } + var offset = util.getArg(s, 'offset'); + var offsetLine = util.getArg(offset, 'line'); + var offsetColumn = util.getArg(offset, 'column'); + + if (offsetLine < lastOffset.line || + (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { + throw new Error('Section offsets must be ordered and non-overlapping.'); + } + lastOffset = offset; + + return { + generatedOffset: { + // The offset fields are 0-based, but we use 1-based indices when + // encoding/decoding from VLQ. + generatedLine: offsetLine + 1, + generatedColumn: offsetColumn + 1 + }, + consumer: new SourceMapConsumer(util.getArg(s, 'map')) + } + }); + } + + IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; + + /** + * The version of the source mapping spec that we are consuming. + */ + IndexedSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { + get: function () { + var sources = []; + for (var i = 0; i < this._sections.length; i++) { + for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { + sources.push(this._sections[i].consumer.sources[j]); + } + } + return sources; + } + }); + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + IndexedSourceMapConsumer.prototype.originalPositionFor = + function IndexedSourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + // Find the section containing the generated position we're trying to map + // to an original position. + var sectionIndex = binarySearch.search(needle, this._sections, + function(needle, section) { + var cmp = needle.generatedLine - section.generatedOffset.generatedLine; + if (cmp) { + return cmp; + } + + return (needle.generatedColumn - + section.generatedOffset.generatedColumn); + }); + var section = this._sections[sectionIndex]; + + if (!section) { + return { + source: null, + line: null, + column: null, + name: null + }; + } + + return section.consumer.originalPositionFor({ + line: needle.generatedLine - + (section.generatedOffset.generatedLine - 1), + column: needle.generatedColumn - + (section.generatedOffset.generatedLine === needle.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0), + bias: aArgs.bias + }); + }; + + /** + * Return true if we have the source content for every source in the source + * map, false otherwise. + */ + IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = + function IndexedSourceMapConsumer_hasContentsOfAllSources() { + return this._sections.every(function (s) { + return s.consumer.hasContentsOfAllSources(); + }); + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ + IndexedSourceMapConsumer.prototype.sourceContentFor = + function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + var content = section.consumer.sourceContentFor(aSource, true); + if (content) { + return content; + } + } + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + IndexedSourceMapConsumer.prototype.generatedPositionFor = + function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + // Only consider this section if the requested source is in the list of + // sources of the consumer. + if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) { + continue; + } + var generatedPosition = section.consumer.generatedPositionFor(aArgs); + if (generatedPosition) { + var ret = { + line: generatedPosition.line + + (section.generatedOffset.generatedLine - 1), + column: generatedPosition.column + + (section.generatedOffset.generatedLine === generatedPosition.line + ? section.generatedOffset.generatedColumn - 1 + : 0) + }; + return ret; + } + } + + return { + line: null, + column: null + }; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + IndexedSourceMapConsumer.prototype._parseMappings = + function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { + this.__generatedMappings = []; + this.__originalMappings = []; + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + var sectionMappings = section.consumer._generatedMappings; + for (var j = 0; j < sectionMappings.length; j++) { + var mapping = sectionMappings[j]; + + var source = section.consumer._sources.at(mapping.source); + if (section.consumer.sourceRoot !== null) { + source = util.join(section.consumer.sourceRoot, source); + } + this._sources.add(source); + source = this._sources.indexOf(source); + + var name = section.consumer._names.at(mapping.name); + this._names.add(name); + name = this._names.indexOf(name); + + // The mappings coming from the consumer for the section have + // generated positions relative to the start of the section, so we + // need to offset them to be relative to the start of the concatenated + // generated file. + var adjustedMapping = { + source: source, + generatedLine: mapping.generatedLine + + (section.generatedOffset.generatedLine - 1), + generatedColumn: mapping.generatedColumn + + (section.generatedOffset.generatedLine === mapping.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0), + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: name + }; + + this.__generatedMappings.push(adjustedMapping); + if (typeof adjustedMapping.originalLine === 'number') { + this.__originalMappings.push(adjustedMapping); + } + } + } + + quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); + quickSort(this.__originalMappings, util.compareByOriginalPositions); + }; + + exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + exports.GREATEST_LOWER_BOUND = 1; + exports.LEAST_UPPER_BOUND = 2; + + /** + * Recursive implementation of binary search. + * + * @param aLow Indices here and lower do not contain the needle. + * @param aHigh Indices here and higher do not contain the needle. + * @param aNeedle The element being searched for. + * @param aHaystack The non-empty array being searched. + * @param aCompare Function which takes two elements and returns -1, 0, or 1. + * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or + * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + */ + function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { + // This function terminates when one of the following is true: + // + // 1. We find the exact element we are looking for. + // + // 2. We did not find the exact element, but we can return the index of + // the next-closest element. + // + // 3. We did not find the exact element, and there is no next-closest + // element than the one we are searching for, so we return -1. + var mid = Math.floor((aHigh - aLow) / 2) + aLow; + var cmp = aCompare(aNeedle, aHaystack[mid], true); + if (cmp === 0) { + // Found the element we are looking for. + return mid; + } + else if (cmp > 0) { + // Our needle is greater than aHaystack[mid]. + if (aHigh - mid > 1) { + // The element is in the upper half. + return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); + } + + // The exact needle element was not found in this haystack. Determine if + // we are in termination case (3) or (2) and return the appropriate thing. + if (aBias == exports.LEAST_UPPER_BOUND) { + return aHigh < aHaystack.length ? aHigh : -1; + } else { + return mid; + } + } + else { + // Our needle is less than aHaystack[mid]. + if (mid - aLow > 1) { + // The element is in the lower half. + return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); + } + + // we are in termination case (3) or (2) and return the appropriate thing. + if (aBias == exports.LEAST_UPPER_BOUND) { + return mid; + } else { + return aLow < 0 ? -1 : aLow; + } + } + } + + /** + * This is an implementation of binary search which will always try and return + * the index of the closest element if there is no exact hit. This is because + * mappings between original and generated line/col pairs are single points, + * and there is an implicit region between each of them, so a miss just means + * that you aren't on the very start of a region. + * + * @param aNeedle The element you are looking for. + * @param aHaystack The array that is being searched. + * @param aCompare A function which takes the needle and an element in the + * array and returns -1, 0, or 1 depending on whether the needle is less + * than, equal to, or greater than the element, respectively. + * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or + * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. + */ + exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { + if (aHaystack.length === 0) { + return -1; + } + + var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, + aCompare, aBias || exports.GREATEST_LOWER_BOUND); + if (index < 0) { + return -1; + } + + // We have found either the exact element, or the next-closest element than + // the one we are searching for. However, there may be more than one such + // element. Make sure we always return the smallest of these. + while (index - 1 >= 0) { + if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { + break; + } + --index; + } + + return index; + }; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + // It turns out that some (most?) JavaScript engines don't self-host + // `Array.prototype.sort`. This makes sense because C++ will likely remain + // faster than JS when doing raw CPU-intensive sorting. However, when using a + // custom comparator function, calling back and forth between the VM's C++ and + // JIT'd JS is rather slow *and* loses JIT type information, resulting in + // worse generated code for the comparator function than would be optimal. In + // fact, when sorting with a comparator, these costs outweigh the benefits of + // sorting in C++. By using our own JS-implemented Quick Sort (below), we get + // a ~3500ms mean speed-up in `bench/bench.html`. + + /** + * Swap the elements indexed by `x` and `y` in the array `ary`. + * + * @param {Array} ary + * The array. + * @param {Number} x + * The index of the first item. + * @param {Number} y + * The index of the second item. + */ + function swap(ary, x, y) { + var temp = ary[x]; + ary[x] = ary[y]; + ary[y] = temp; + } + + /** + * Returns a random integer within the range `low .. high` inclusive. + * + * @param {Number} low + * The lower bound on the range. + * @param {Number} high + * The upper bound on the range. + */ + function randomIntInRange(low, high) { + return Math.round(low + (Math.random() * (high - low))); + } + + /** + * The Quick Sort algorithm. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + * @param {Number} p + * Start index of the array + * @param {Number} r + * End index of the array + */ + function doQuickSort(ary, comparator, p, r) { + // If our lower bound is less than our upper bound, we (1) partition the + // array into two pieces and (2) recurse on each half. If it is not, this is + // the empty array and our base case. + + if (p < r) { + // (1) Partitioning. + // + // The partitioning chooses a pivot between `p` and `r` and moves all + // elements that are less than or equal to the pivot to the before it, and + // all the elements that are greater than it after it. The effect is that + // once partition is done, the pivot is in the exact place it will be when + // the array is put in sorted order, and it will not need to be moved + // again. This runs in O(n) time. + + // Always choose a random pivot so that an input array which is reverse + // sorted does not cause O(n^2) running time. + var pivotIndex = randomIntInRange(p, r); + var i = p - 1; + + swap(ary, pivotIndex, r); + var pivot = ary[r]; + + // Immediately after `j` is incremented in this loop, the following hold + // true: + // + // * Every element in `ary[p .. i]` is less than or equal to the pivot. + // + // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. + for (var j = p; j < r; j++) { + if (comparator(ary[j], pivot) <= 0) { + i += 1; + swap(ary, i, j); + } + } + + swap(ary, i + 1, j); + var q = i + 1; + + // (2) Recurse on each half. + + doQuickSort(ary, comparator, p, q - 1); + doQuickSort(ary, comparator, q + 1, r); + } + } + + /** + * Sort the given array in-place with the given comparator function. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + */ + exports.quickSort = function (ary, comparator) { + doQuickSort(ary, comparator, 0, ary.length - 1); + }; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var SourceMapGenerator = __webpack_require__(1).SourceMapGenerator; + var util = __webpack_require__(4); + + // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other + // operating systems these days (capturing the result). + var REGEX_NEWLINE = /(\r?\n)/; + + // Newline character code for charCodeAt() comparisons + var NEWLINE_CODE = 10; + + // Private symbol for identifying `SourceNode`s when multiple versions of + // the source-map library are loaded. This MUST NOT CHANGE across + // versions! + var isSourceNode = "$$$isSourceNode$$$"; + + /** + * SourceNodes provide a way to abstract over interpolating/concatenating + * snippets of generated JavaScript source code while maintaining the line and + * column information associated with the original source code. + * + * @param aLine The original line number. + * @param aColumn The original column number. + * @param aSource The original source's filename. + * @param aChunks Optional. An array of strings which are snippets of + * generated JS, or other SourceNodes. + * @param aName The original identifier. + */ + function SourceNode(aLine, aColumn, aSource, aChunks, aName) { + this.children = []; + this.sourceContents = {}; + this.line = aLine == null ? null : aLine; + this.column = aColumn == null ? null : aColumn; + this.source = aSource == null ? null : aSource; + this.name = aName == null ? null : aName; + this[isSourceNode] = true; + if (aChunks != null) this.add(aChunks); + } + + /** + * Creates a SourceNode from generated code and a SourceMapConsumer. + * + * @param aGeneratedCode The generated code + * @param aSourceMapConsumer The SourceMap for the generated code + * @param aRelativePath Optional. The path that relative sources in the + * SourceMapConsumer should be relative to. + */ + SourceNode.fromStringWithSourceMap = + function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { + // The SourceNode we want to fill with the generated code + // and the SourceMap + var node = new SourceNode(); + + // All even indices of this array are one line of the generated code, + // while all odd indices are the newlines between two adjacent lines + // (since `REGEX_NEWLINE` captures its match). + // Processed fragments are accessed by calling `shiftNextLine`. + var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); + var remainingLinesIndex = 0; + var shiftNextLine = function() { + var lineContents = getNextLine(); + // The last line of a file might not have a newline. + var newLine = getNextLine() || ""; + return lineContents + newLine; + + function getNextLine() { + return remainingLinesIndex < remainingLines.length ? + remainingLines[remainingLinesIndex++] : undefined; + } + }; + + // We need to remember the position of "remainingLines" + var lastGeneratedLine = 1, lastGeneratedColumn = 0; + + // The generate SourceNodes we need a code range. + // To extract it current and last mapping is used. + // Here we store the last mapping. + var lastMapping = null; + + aSourceMapConsumer.eachMapping(function (mapping) { + if (lastMapping !== null) { + // We add the code from "lastMapping" to "mapping": + // First check if there is a new line in between. + if (lastGeneratedLine < mapping.generatedLine) { + // Associate first line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + lastGeneratedLine++; + lastGeneratedColumn = 0; + // The remaining code is added without mapping + } else { + // There is no new line in between. + // Associate the code between "lastGeneratedColumn" and + // "mapping.generatedColumn" with "lastMapping" + var nextLine = remainingLines[remainingLinesIndex]; + var code = nextLine.substr(0, mapping.generatedColumn - + lastGeneratedColumn); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - + lastGeneratedColumn); + lastGeneratedColumn = mapping.generatedColumn; + addMappingWithCode(lastMapping, code); + // No more remaining code, continue + lastMapping = mapping; + return; + } + } + // We add the generated code until the first mapping + // to the SourceNode without any mapping. + // Each line is added as separate string. + while (lastGeneratedLine < mapping.generatedLine) { + node.add(shiftNextLine()); + lastGeneratedLine++; + } + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[remainingLinesIndex]; + node.add(nextLine.substr(0, mapping.generatedColumn)); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + lastMapping = mapping; + }, this); + // We have processed all mappings. + if (remainingLinesIndex < remainingLines.length) { + if (lastMapping) { + // Associate the remaining code in the current line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + } + // and add the remaining lines without any mapping + node.add(remainingLines.splice(remainingLinesIndex).join("")); + } + + // Copy sourcesContent into SourceNode + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aRelativePath != null) { + sourceFile = util.join(aRelativePath, sourceFile); + } + node.setSourceContent(sourceFile, content); + } + }); + + return node; + + function addMappingWithCode(mapping, code) { + if (mapping === null || mapping.source === undefined) { + node.add(code); + } else { + var source = aRelativePath + ? util.join(aRelativePath, mapping.source) + : mapping.source; + node.add(new SourceNode(mapping.originalLine, + mapping.originalColumn, + source, + code, + mapping.name)); + } + } + }; + + /** + * Add a chunk of generated JS to this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.add = function SourceNode_add(aChunk) { + if (Array.isArray(aChunk)) { + aChunk.forEach(function (chunk) { + this.add(chunk); + }, this); + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + if (aChunk) { + this.children.push(aChunk); + } + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Add a chunk of generated JS to the beginning of this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { + if (Array.isArray(aChunk)) { + for (var i = aChunk.length-1; i >= 0; i--) { + this.prepend(aChunk[i]); + } + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + this.children.unshift(aChunk); + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Walk over the tree of JS snippets in this node and its children. The + * walking function is called once for each snippet of JS and is passed that + * snippet and the its original associated source's line/column location. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walk = function SourceNode_walk(aFn) { + var chunk; + for (var i = 0, len = this.children.length; i < len; i++) { + chunk = this.children[i]; + if (chunk[isSourceNode]) { + chunk.walk(aFn); + } + else { + if (chunk !== '') { + aFn(chunk, { source: this.source, + line: this.line, + column: this.column, + name: this.name }); + } + } + } + }; + + /** + * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between + * each of `this.children`. + * + * @param aSep The separator. + */ + SourceNode.prototype.join = function SourceNode_join(aSep) { + var newChildren; + var i; + var len = this.children.length; + if (len > 0) { + newChildren = []; + for (i = 0; i < len-1; i++) { + newChildren.push(this.children[i]); + newChildren.push(aSep); + } + newChildren.push(this.children[i]); + this.children = newChildren; + } + return this; + }; + + /** + * Call String.prototype.replace on the very right-most source snippet. Useful + * for trimming whitespace from the end of a source node, etc. + * + * @param aPattern The pattern to replace. + * @param aReplacement The thing to replace the pattern with. + */ + SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { + var lastChild = this.children[this.children.length - 1]; + if (lastChild[isSourceNode]) { + lastChild.replaceRight(aPattern, aReplacement); + } + else if (typeof lastChild === 'string') { + this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); + } + else { + this.children.push(''.replace(aPattern, aReplacement)); + } + return this; + }; + + /** + * Set the source content for a source file. This will be added to the SourceMapGenerator + * in the sourcesContent field. + * + * @param aSourceFile The filename of the source file + * @param aSourceContent The content of the source file + */ + SourceNode.prototype.setSourceContent = + function SourceNode_setSourceContent(aSourceFile, aSourceContent) { + this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; + }; + + /** + * Walk over the tree of SourceNodes. The walking function is called for each + * source file content and is passed the filename and source content. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walkSourceContents = + function SourceNode_walkSourceContents(aFn) { + for (var i = 0, len = this.children.length; i < len; i++) { + if (this.children[i][isSourceNode]) { + this.children[i].walkSourceContents(aFn); + } + } + + var sources = Object.keys(this.sourceContents); + for (var i = 0, len = sources.length; i < len; i++) { + aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); + } + }; + + /** + * Return the string representation of this source node. Walks over the tree + * and concatenates all the various snippets together to one string. + */ + SourceNode.prototype.toString = function SourceNode_toString() { + var str = ""; + this.walk(function (chunk) { + str += chunk; + }); + return str; + }; + + /** + * Returns the string representation of this source node along with a source + * map. + */ + SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { + var generated = { + code: "", + line: 1, + column: 0 + }; + var map = new SourceMapGenerator(aArgs); + var sourceMappingActive = false; + var lastOriginalSource = null; + var lastOriginalLine = null; + var lastOriginalColumn = null; + var lastOriginalName = null; + this.walk(function (chunk, original) { + generated.code += chunk; + if (original.source !== null + && original.line !== null + && original.column !== null) { + if(lastOriginalSource !== original.source + || lastOriginalLine !== original.line + || lastOriginalColumn !== original.column + || lastOriginalName !== original.name) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + lastOriginalSource = original.source; + lastOriginalLine = original.line; + lastOriginalColumn = original.column; + lastOriginalName = original.name; + sourceMappingActive = true; + } else if (sourceMappingActive) { + map.addMapping({ + generated: { + line: generated.line, + column: generated.column + } + }); + lastOriginalSource = null; + sourceMappingActive = false; + } + for (var idx = 0, length = chunk.length; idx < length; idx++) { + if (chunk.charCodeAt(idx) === NEWLINE_CODE) { + generated.line++; + generated.column = 0; + // Mappings end at eol + if (idx + 1 === length) { + lastOriginalSource = null; + sourceMappingActive = false; + } else if (sourceMappingActive) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + } else { + generated.column++; + } + } + }); + this.walkSourceContents(function (sourceFile, sourceContent) { + map.setSourceContent(sourceFile, sourceContent); + }); + + return { code: generated.code, map: map }; + }; + + exports.SourceNode = SourceNode; + + +/***/ }) +/******/ ]) +}); +; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vd2VicGFjay91bml2ZXJzYWxNb2R1bGVEZWZpbml0aW9uIiwid2VicGFjazovLy93ZWJwYWNrL2Jvb3RzdHJhcCBlNDczOGZjNzJhN2IyMzAzOTg4OSIsIndlYnBhY2s6Ly8vLi9zb3VyY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blxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSBwcmV2aW91c0dlbmVyYXRlZENvbHVtbik7XG4gICAgICBwcmV2aW91c0dlbmVyYXRlZENvbHVtbiA9IG1hcHBpbmcuZ2VuZXJhdGVkQ29sdW1uO1xuXG4gICAgICBpZiAobWFwcGluZy5zb3VyY2UgIT0gbnVsbCkge1xuICAgICAgICBzb3VyY2VJZHggPSB0aGlzLl9zb3VyY2VzLmluZGV4T2YobWFwcGluZy5zb3VyY2UpO1xuICAgICAgICBuZXh0ICs9IGJhc2U2NFZMUS5lbmNvZGUoc291cmNlSWR4IC0gcHJldmlvdXNTb3VyY2UpO1xuICAgICAgICBwcmV2aW91c1NvdXJjZSA9IHNvdXJjZUlkeDtcblxuICAgICAgICAvLyBsaW5lcyBhcmUgc3RvcmVkIDAtYmFzZWQgaW4gU291cmNlTWFwIHNwZWMgdmVyc2lvbiAzXG4gICAgICAgIG5leHQgKz0gYmFzZTY0VkxRLmVuY29kZShtYXBwaW5nLm9yaWdpbmFsTGluZSAtIDFcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLSBwcmV2aW91c09yaWdpbmFsTGluZSk7XG4gICAgICAgIHByZXZpb3VzT3JpZ2luYWxMaW5lID0gbWFwcGluZy5vcmlnaW5hbExpbmUgLSAxO1xuXG4gICAgICAgIG5leHQgKz0gYmFzZTY0VkxRLmVuY29kZShtYXBwaW5nLm9yaWdpbmFsQ29sdW1uXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC0gcHJldmlvdXNPcmlnaW5hbENvbHVtbik7XG4gICAgICAgIHByZXZpb3VzT3JpZ2luYWxDb2x1bW4gPSBtYXBwaW5nLm9yaWdpbmFsQ29sdW1uO1xuXG4gICAgICAgIGlmIChtYXBwaW5nLm5hbWUgIT0gbnVsbCkge1xuICAgICAgICAgIG5hbWVJZHggPSB0aGlzLl9uYW1lcy5pbmRleE9mKG1hcHBpbmcubmFtZSk7XG4gICAgIC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sdW1uICsgc2VnbWVudFswXTtcbiAgICAgICAgcHJldmlvdXNHZW5lcmF0ZWRDb2x1bW4gPSBtYXBwaW5nLmdlbmVyYXRlZENvbHVtbjtcblxuICAgICAgICBpZiAoc2VnbWVudC5sZW5ndGggPiAxKSB7XG4gICAgICAgICAgLy8gT3JpZ2luYWwgc291cmNlLlxuICAgICAgICAgIG1hcHBpbmcuc291cmNlID0gcHJldmlvdXNTb3VyY2UgKyBzZWdtZW50WzFdO1xuICAgICAgICAgIHByZXZpb3VzU291cmNlICs9IHNlZ21lbnRbMV07XG5cbiAgICAgICAgICAvLyBPcmlnaW5hbCBsaW5lLlxuICAgICAgICAgIG1hcHBpbmcub3JpZ2luYWxMaW5lID0gcHJldmlvdXNPcmlnaW5hbExpbmUgKyBzZWdtZW50WzJdO1xuICAgICAgICAgIHByZXZpb3VzT3JpZ2luYWxMaW5lID0gbWFwcGluZy5vcmlnaW5hbExpbmU7XG4gICAgICAgICAgLy8gTGluZXMgYXJlIHN0b3JlZCAwLWJhc2VkXG4gICAgICAgICAgbWFwcGluZy5vcmlnaW5hbExpbmUgKz0gMTtcblxuICAgICAgICAgIC8vIE9yaWdpbmFsIGNvbHVtbi5cbiAgICAgICAgICBtYXBwaW5nLm9yaWdpbmFsQ29sdW1uID0gcHJldmlvdXNPcmlnaW5hbENvbHVtbiArIHNlZ21lbnRbM107XG4gICAgICAgICAgcHJldmlvdXNPcmlnaW5hbENvbHVtbiA9IG1hcHBpbmcub3JpZ2luYWxDb2x1bW47XG5cbiAgICAgICAgICBpZiAoc2VnbWVudC5sZW5ndGggPiA0KSB7XG4gICAgICAgICAgICAvLyBPcmlnaW5hbCBuYW1lLlxuICAgICAgICAgICAgbWFwcGluZy5uYW1lID0gcHJldmlvdXNOYW1lICsgc2VnbWVudFs0XTtcbiAgICAgICAgICAgIHByZXZpb3VzTmFtZSArPSBzZWdtZW50WzRdO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGdlbmVyYX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NYXBwaW5nc1tpbmRleF07XG5cbiAgICAgIGlmIChtYXBwaW5nLmdlbmVyYXRlZExpbmUgPT09IG5lZWRsZS5nZW5lcmF0ZWRMaW5lKSB7XG4gICAgICAgIHZhciBzb3VyY2UgPSB1dGlsLmdldEFyZyhtYXBwaW5nLCAnc291cmNlJywgbnVsbCk7XG4gICAgICAgIGlmIChzb3VyY2UgIT09IG51bGwpIHtcbiAgICAgICAgICBzb3VyY2UgPSB0aGlzLl9zb3VyY2VzLmF0KHNvdXJjZSk7XG4gICAgICAgICAgaWYgKHRoaXMuc291cmNlUm9vdCAhPSBudWxsKSB7XG4gICAgICAgICAgICBzb3VyY2UgPSB1dGlsLmpvaW4odGhpcy5zb3VyY2VSb290LCBzb3VyY2UpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB2YXIgbmFtZSA9IHV0aWwuZ2V0QXJnKG1hcHBpbmcsICduYW1lJywgbnVsbCk7XG4gICAgICAgIGlmIChuYW1lICE9PSBudWxsKSB7XG4gICAgICAgICAgbmFtZSA9IHRoaXMuX25hbWVzLmF0KG5hbWUpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgc291cmNlOiBzb3VyY2UsXG4gICAgICAgICAgbGluZTogdXRpbC5nZXRBcmcobWFwcGluZywgJ29yaWdpbmFsTGluZScsIG51bGwpLFxuICAgICAgICAgIGNvbHVtbjogdXRpbC5nZXRBcmcobWFwcGluZywgJ29yaWdpbmFsQ29sdW1uJywgbnVsbCksXG4gICAgICAgICAgbmFtZTogbmFtZVxuICAgICAgICB9O1xuICAgICAgfVxuICAgIH1cblxuICAgIHJldHVybiB7XG4gICAgICBzb3VyY2U6IG51bGwsXG4gICAgICBsaW5lOiBudWxsLFxuICAgICAgY29sdW1uOiBudWxsLFxuICAgICAgbmFtZTogbnVsbFxuICAgIH07XG4gIH07XG5cbi8qKlxuICogUmV0dXJuIHRydWUgaWYgd2UgaGF2ZSB0aGUgc291cmNlIGNvb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HNlIHtcbiAgICAgICAgdmFyIHNvdXJjZSA9IGFSZWxhdGl2ZVBhdGhcbiAgICAgICAgICA/IHV0aWwuam9pbihhUmVsYXRpdmVQYXRoLCBtYXBwaW5nLnNvdXJjZSlcbiAgICAgICAgICA6IG1hcHBpbmcuc291cmNlO1xuICAgICAgICBub2RlLmFkZChuZXcgU291cmNlTm9kZShtYXBwaW5nLm9yaWdpbmFsTGluZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbWFwcGluZy5vcmlnaW5hbENvbHVtbixcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc291cmNlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYXBwaW5nLm5hbWUpKTtcbiAgICAgIH1cbiAgICB9XG4gIH07XG5cbi8qKlxuICogQWRkIGEgY2h1bmsgb2YgZ2VuZXJhdGVkIEpTIHRvIHRoaXMgc291cmNlIG5vZGUuXG4gKlxuICogQHBhcmFtIGFDaHVuayBBIHN0cmluZyBzbmlwcGV0IG9mIGdlbmVyYXRlZCBKUyBjb2RlLCBhbm90aGVyIGluc3RhbmNlIG9mXG4gKiAgICAgICAgU291cmNlTm9kZSwgb3IgYW4gYXJyYXkgd2hlcmUgZWFjaCBtZW1iZXIgaXMgb25lIG9mIHRob3NlIHRoaW5ncy5cbiAqL1xuU291cmNlTm9kZS5wcm90b3R5cGUuYWRkID0gZnVuY3Rpb24gU291cmNlTm9kZV9hZGQoYUNodW5rKSB7XG4gIGlmIChBcnJheS5pc0FycmF5KGFDaHVuaykpIHtcbiAgICBhQ2h1bmsuZm9yRWFjaChmdW5jdGlvbiAoY2h1bmspIHtcbiAgICAgIHRoaXMuYWRkKGNodW5rKTtcbiAgICB9LCB0aGlzKTtcbiAgfVxuICBlbHNlIGlmIChhQ2h1bmtbaXNTb3VyY2VOb2RlXSB8fCB0eXBlb2YgYUNodW5rID09PSBcInN0cmlu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hbDoge1xuICAgICAgICAgICAgICBsaW5lOiBvcmlnaW5hbC5saW5lLFxuICAgICAgICAgICAgICBjb2x1bW46IG9yaWdpbmFsLmNvbHVtblxuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIGdlbmVyYXRlZDoge1xuICAgICAgICAgICAgICBsaW5lOiBnZW5lcmF0ZWQubGluZSxcbiAgICAgICAgICAgICAgY29sdW1uOiBnZW5lcmF0ZWQuY29sdW1uXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICAgbmFtZTogb3JpZ2luYWwubmFtZVxuICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBnZW5lcmF0ZWQuY29sdW1uKys7XG4gICAgICB9XG4gICAgfVxuICB9KTtcbiAgdGhpcy53YWxrU291cmNlQ29udGVudHMoZnVuY3Rpb24gKHNvdXJjZUZpbGUsIHNvdXJjZUNvbnRlbnQpIHtcbiAgICBtYXAuc2V0U291cmNlQ29udGVudChzb3VyY2VGaWxlLCBzb3VyY2VDb250ZW50KTtcbiAgfSk7XG5cbiAgcmV0dXJuIHsgY29kZTogZ2VuZXJhdGVkLmNvZGUsIG1hcDogbWFwIH07XG59O1xuXG5leHBvcnRzLlNvdXJjZU5vZGUgPSBTb3VyY2VOb2RlO1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gLi9saWIvc291cmNlLW5vZGUuanNcbi8vIG1vZHVsZSBpZCA9IDEwXG4vLyBtb2R1bGUgY2h1bmtzID0gMCJdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/node_modules/source-map/dist/source-map.js b/node_modules/source-map/dist/source-map.js new file mode 100644 index 00000000..4e630e29 --- /dev/null +++ b/node_modules/source-map/dist/source-map.js @@ -0,0 +1,3090 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(); + else if(typeof define === 'function' && define.amd) + define([], factory); + else if(typeof exports === 'object') + exports["sourceMap"] = factory(); + else + root["sourceMap"] = factory(); +})(this, function() { +return /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; + +/******/ // The require function +/******/ function __webpack_require__(moduleId) { + +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; + +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; + +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); + +/******/ // Flag the module as loaded +/******/ module.loaded = true; + +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } + + +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; + +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; + +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; + +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, exports, __webpack_require__) { + + /* + * Copyright 2009-2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE.txt or: + * http://opensource.org/licenses/BSD-3-Clause + */ + exports.SourceMapGenerator = __webpack_require__(1).SourceMapGenerator; + exports.SourceMapConsumer = __webpack_require__(7).SourceMapConsumer; + exports.SourceNode = __webpack_require__(10).SourceNode; + + +/***/ }), +/* 1 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var base64VLQ = __webpack_require__(2); + var util = __webpack_require__(4); + var ArraySet = __webpack_require__(5).ArraySet; + var MappingList = __webpack_require__(6).MappingList; + + /** + * An instance of the SourceMapGenerator represents a source map which is + * being built incrementally. You may pass an object with the following + * properties: + * + * - file: The filename of the generated source. + * - sourceRoot: A root for all relative URLs in this source map. + */ + function SourceMapGenerator(aArgs) { + if (!aArgs) { + aArgs = {}; + } + this._file = util.getArg(aArgs, 'file', null); + this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); + this._skipValidation = util.getArg(aArgs, 'skipValidation', false); + this._sources = new ArraySet(); + this._names = new ArraySet(); + this._mappings = new MappingList(); + this._sourcesContents = null; + } + + SourceMapGenerator.prototype._version = 3; + + /** + * Creates a new SourceMapGenerator based on a SourceMapConsumer + * + * @param aSourceMapConsumer The SourceMap. + */ + SourceMapGenerator.fromSourceMap = + function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { + var sourceRoot = aSourceMapConsumer.sourceRoot; + var generator = new SourceMapGenerator({ + file: aSourceMapConsumer.file, + sourceRoot: sourceRoot + }); + aSourceMapConsumer.eachMapping(function (mapping) { + var newMapping = { + generated: { + line: mapping.generatedLine, + column: mapping.generatedColumn + } + }; + + if (mapping.source != null) { + newMapping.source = mapping.source; + if (sourceRoot != null) { + newMapping.source = util.relative(sourceRoot, newMapping.source); + } + + newMapping.original = { + line: mapping.originalLine, + column: mapping.originalColumn + }; + + if (mapping.name != null) { + newMapping.name = mapping.name; + } + } + + generator.addMapping(newMapping); + }); + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + generator.setSourceContent(sourceFile, content); + } + }); + return generator; + }; + + /** + * Add a single mapping from original source line and column to the generated + * source's line and column for this source map being created. The mapping + * object should have the following properties: + * + * - generated: An object with the generated line and column positions. + * - original: An object with the original line and column positions. + * - source: The original source file (relative to the sourceRoot). + * - name: An optional original token name for this mapping. + */ + SourceMapGenerator.prototype.addMapping = + function SourceMapGenerator_addMapping(aArgs) { + var generated = util.getArg(aArgs, 'generated'); + var original = util.getArg(aArgs, 'original', null); + var source = util.getArg(aArgs, 'source', null); + var name = util.getArg(aArgs, 'name', null); + + if (!this._skipValidation) { + this._validateMapping(generated, original, source, name); + } + + if (source != null) { + source = String(source); + if (!this._sources.has(source)) { + this._sources.add(source); + } + } + + if (name != null) { + name = String(name); + if (!this._names.has(name)) { + this._names.add(name); + } + } + + this._mappings.add({ + generatedLine: generated.line, + generatedColumn: generated.column, + originalLine: original != null && original.line, + originalColumn: original != null && original.column, + source: source, + name: name + }); + }; + + /** + * Set the source content for a source file. + */ + SourceMapGenerator.prototype.setSourceContent = + function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { + var source = aSourceFile; + if (this._sourceRoot != null) { + source = util.relative(this._sourceRoot, source); + } + + if (aSourceContent != null) { + // Add the source content to the _sourcesContents map. + // Create a new _sourcesContents map if the property is null. + if (!this._sourcesContents) { + this._sourcesContents = Object.create(null); + } + this._sourcesContents[util.toSetString(source)] = aSourceContent; + } else if (this._sourcesContents) { + // Remove the source file from the _sourcesContents map. + // If the _sourcesContents map is empty, set the property to null. + delete this._sourcesContents[util.toSetString(source)]; + if (Object.keys(this._sourcesContents).length === 0) { + this._sourcesContents = null; + } + } + }; + + /** + * Applies the mappings of a sub-source-map for a specific source file to the + * source map being generated. Each mapping to the supplied source file is + * rewritten using the supplied source map. Note: The resolution for the + * resulting mappings is the minimium of this map and the supplied map. + * + * @param aSourceMapConsumer The source map to be applied. + * @param aSourceFile Optional. The filename of the source file. + * If omitted, SourceMapConsumer's file property will be used. + * @param aSourceMapPath Optional. The dirname of the path to the source map + * to be applied. If relative, it is relative to the SourceMapConsumer. + * This parameter is needed when the two source maps aren't in the same + * directory, and the source map to be applied contains relative source + * paths. If so, those relative source paths need to be rewritten + * relative to the SourceMapGenerator. + */ + SourceMapGenerator.prototype.applySourceMap = + function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { + var sourceFile = aSourceFile; + // If aSourceFile is omitted, we will use the file property of the SourceMap + if (aSourceFile == null) { + if (aSourceMapConsumer.file == null) { + throw new Error( + 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + + 'or the source map\'s "file" property. Both were omitted.' + ); + } + sourceFile = aSourceMapConsumer.file; + } + var sourceRoot = this._sourceRoot; + // Make "sourceFile" relative if an absolute Url is passed. + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + // Applying the SourceMap can add and remove items from the sources and + // the names array. + var newSources = new ArraySet(); + var newNames = new ArraySet(); + + // Find mappings for the "sourceFile" + this._mappings.unsortedForEach(function (mapping) { + if (mapping.source === sourceFile && mapping.originalLine != null) { + // Check if it can be mapped by the source map, then update the mapping. + var original = aSourceMapConsumer.originalPositionFor({ + line: mapping.originalLine, + column: mapping.originalColumn + }); + if (original.source != null) { + // Copy mapping + mapping.source = original.source; + if (aSourceMapPath != null) { + mapping.source = util.join(aSourceMapPath, mapping.source) + } + if (sourceRoot != null) { + mapping.source = util.relative(sourceRoot, mapping.source); + } + mapping.originalLine = original.line; + mapping.originalColumn = original.column; + if (original.name != null) { + mapping.name = original.name; + } + } + } + + var source = mapping.source; + if (source != null && !newSources.has(source)) { + newSources.add(source); + } + + var name = mapping.name; + if (name != null && !newNames.has(name)) { + newNames.add(name); + } + + }, this); + this._sources = newSources; + this._names = newNames; + + // Copy sourcesContents of applied map. + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aSourceMapPath != null) { + sourceFile = util.join(aSourceMapPath, sourceFile); + } + if (sourceRoot != null) { + sourceFile = util.relative(sourceRoot, sourceFile); + } + this.setSourceContent(sourceFile, content); + } + }, this); + }; + + /** + * A mapping can have one of the three levels of data: + * + * 1. Just the generated position. + * 2. The Generated position, original position, and original source. + * 3. Generated and original position, original source, as well as a name + * token. + * + * To maintain consistency, we validate that any new mapping being added falls + * in to one of these categories. + */ + SourceMapGenerator.prototype._validateMapping = + function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, + aName) { + // When aOriginal is truthy but has empty values for .line and .column, + // it is most likely a programmer error. In this case we throw a very + // specific error message to try to guide them the right way. + // For example: https://github.com/Polymer/polymer-bundler/pull/519 + if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { + throw new Error( + 'original.line and original.column are not numbers -- you probably meant to omit ' + + 'the original mapping entirely and only map the generated position. If so, pass ' + + 'null for the original mapping instead of an object with empty or null values.' + ); + } + + if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aGenerated.line > 0 && aGenerated.column >= 0 + && !aOriginal && !aSource && !aName) { + // Case 1. + return; + } + else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated + && aOriginal && 'line' in aOriginal && 'column' in aOriginal + && aGenerated.line > 0 && aGenerated.column >= 0 + && aOriginal.line > 0 && aOriginal.column >= 0 + && aSource) { + // Cases 2 and 3. + return; + } + else { + throw new Error('Invalid mapping: ' + JSON.stringify({ + generated: aGenerated, + source: aSource, + original: aOriginal, + name: aName + })); + } + }; + + /** + * Serialize the accumulated mappings in to the stream of base 64 VLQs + * specified by the source map format. + */ + SourceMapGenerator.prototype._serializeMappings = + function SourceMapGenerator_serializeMappings() { + var previousGeneratedColumn = 0; + var previousGeneratedLine = 1; + var previousOriginalColumn = 0; + var previousOriginalLine = 0; + var previousName = 0; + var previousSource = 0; + var result = ''; + var next; + var mapping; + var nameIdx; + var sourceIdx; + + var mappings = this._mappings.toArray(); + for (var i = 0, len = mappings.length; i < len; i++) { + mapping = mappings[i]; + next = '' + + if (mapping.generatedLine !== previousGeneratedLine) { + previousGeneratedColumn = 0; + while (mapping.generatedLine !== previousGeneratedLine) { + next += ';'; + previousGeneratedLine++; + } + } + else { + if (i > 0) { + if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { + continue; + } + next += ','; + } + } + + next += base64VLQ.encode(mapping.generatedColumn + - previousGeneratedColumn); + previousGeneratedColumn = mapping.generatedColumn; + + if (mapping.source != null) { + sourceIdx = this._sources.indexOf(mapping.source); + next += base64VLQ.encode(sourceIdx - previousSource); + previousSource = sourceIdx; + + // lines are stored 0-based in SourceMap spec version 3 + next += base64VLQ.encode(mapping.originalLine - 1 + - previousOriginalLine); + previousOriginalLine = mapping.originalLine - 1; + + next += base64VLQ.encode(mapping.originalColumn + - previousOriginalColumn); + previousOriginalColumn = mapping.originalColumn; + + if (mapping.name != null) { + nameIdx = this._names.indexOf(mapping.name); + next += base64VLQ.encode(nameIdx - previousName); + previousName = nameIdx; + } + } + + result += next; + } + + return result; + }; + + SourceMapGenerator.prototype._generateSourcesContent = + function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { + return aSources.map(function (source) { + if (!this._sourcesContents) { + return null; + } + if (aSourceRoot != null) { + source = util.relative(aSourceRoot, source); + } + var key = util.toSetString(source); + return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) + ? this._sourcesContents[key] + : null; + }, this); + }; + + /** + * Externalize the source map. + */ + SourceMapGenerator.prototype.toJSON = + function SourceMapGenerator_toJSON() { + var map = { + version: this._version, + sources: this._sources.toArray(), + names: this._names.toArray(), + mappings: this._serializeMappings() + }; + if (this._file != null) { + map.file = this._file; + } + if (this._sourceRoot != null) { + map.sourceRoot = this._sourceRoot; + } + if (this._sourcesContents) { + map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); + } + + return map; + }; + + /** + * Render the source map being generated to a string. + */ + SourceMapGenerator.prototype.toString = + function SourceMapGenerator_toString() { + return JSON.stringify(this.toJSON()); + }; + + exports.SourceMapGenerator = SourceMapGenerator; + + +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + * + * Based on the Base 64 VLQ implementation in Closure Compiler: + * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java + * + * Copyright 2011 The Closure Compiler Authors. All rights reserved. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + var base64 = __webpack_require__(3); + + // A single base 64 digit can contain 6 bits of data. For the base 64 variable + // length quantities we use in the source map spec, the first bit is the sign, + // the next four bits are the actual value, and the 6th bit is the + // continuation bit. The continuation bit tells us whether there are more + // digits in this value following this digit. + // + // Continuation + // | Sign + // | | + // V V + // 101011 + + var VLQ_BASE_SHIFT = 5; + + // binary: 100000 + var VLQ_BASE = 1 << VLQ_BASE_SHIFT; + + // binary: 011111 + var VLQ_BASE_MASK = VLQ_BASE - 1; + + // binary: 100000 + var VLQ_CONTINUATION_BIT = VLQ_BASE; + + /** + * Converts from a two-complement value to a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) + * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) + */ + function toVLQSigned(aValue) { + return aValue < 0 + ? ((-aValue) << 1) + 1 + : (aValue << 1) + 0; + } + + /** + * Converts to a two-complement value from a value where the sign bit is + * placed in the least significant bit. For example, as decimals: + * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 + * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 + */ + function fromVLQSigned(aValue) { + var isNegative = (aValue & 1) === 1; + var shifted = aValue >> 1; + return isNegative + ? -shifted + : shifted; + } + + /** + * Returns the base 64 VLQ encoded value. + */ + exports.encode = function base64VLQ_encode(aValue) { + var encoded = ""; + var digit; + + var vlq = toVLQSigned(aValue); + + do { + digit = vlq & VLQ_BASE_MASK; + vlq >>>= VLQ_BASE_SHIFT; + if (vlq > 0) { + // There are still more digits in this value, so we must make sure the + // continuation bit is marked. + digit |= VLQ_CONTINUATION_BIT; + } + encoded += base64.encode(digit); + } while (vlq > 0); + + return encoded; + }; + + /** + * Decodes the next base 64 VLQ value from the given string and returns the + * value and the rest of the string via the out parameter. + */ + exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { + var strLen = aStr.length; + var result = 0; + var shift = 0; + var continuation, digit; + + do { + if (aIndex >= strLen) { + throw new Error("Expected more digits in base 64 VLQ value."); + } + + digit = base64.decode(aStr.charCodeAt(aIndex++)); + if (digit === -1) { + throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); + } + + continuation = !!(digit & VLQ_CONTINUATION_BIT); + digit &= VLQ_BASE_MASK; + result = result + (digit << shift); + shift += VLQ_BASE_SHIFT; + } while (continuation); + + aOutParam.value = fromVLQSigned(result); + aOutParam.rest = aIndex; + }; + + +/***/ }), +/* 3 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); + + /** + * Encode an integer in the range of 0 to 63 to a single base 64 digit. + */ + exports.encode = function (number) { + if (0 <= number && number < intToCharMap.length) { + return intToCharMap[number]; + } + throw new TypeError("Must be between 0 and 63: " + number); + }; + + /** + * Decode a single base 64 character code digit to an integer. Returns -1 on + * failure. + */ + exports.decode = function (charCode) { + var bigA = 65; // 'A' + var bigZ = 90; // 'Z' + + var littleA = 97; // 'a' + var littleZ = 122; // 'z' + + var zero = 48; // '0' + var nine = 57; // '9' + + var plus = 43; // '+' + var slash = 47; // '/' + + var littleOffset = 26; + var numberOffset = 52; + + // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ + if (bigA <= charCode && charCode <= bigZ) { + return (charCode - bigA); + } + + // 26 - 51: abcdefghijklmnopqrstuvwxyz + if (littleA <= charCode && charCode <= littleZ) { + return (charCode - littleA + littleOffset); + } + + // 52 - 61: 0123456789 + if (zero <= charCode && charCode <= nine) { + return (charCode - zero + numberOffset); + } + + // 62: + + if (charCode == plus) { + return 62; + } + + // 63: / + if (charCode == slash) { + return 63; + } + + // Invalid base64 digit. + return -1; + }; + + +/***/ }), +/* 4 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + /** + * This is a helper function for getting values from parameter/options + * objects. + * + * @param args The object we are extracting values from + * @param name The name of the property we are getting. + * @param defaultValue An optional value to return if the property is missing + * from the object. If this is not specified and the property is missing, an + * error will be thrown. + */ + function getArg(aArgs, aName, aDefaultValue) { + if (aName in aArgs) { + return aArgs[aName]; + } else if (arguments.length === 3) { + return aDefaultValue; + } else { + throw new Error('"' + aName + '" is a required argument.'); + } + } + exports.getArg = getArg; + + var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; + var dataUrlRegexp = /^data:.+\,.+$/; + + function urlParse(aUrl) { + var match = aUrl.match(urlRegexp); + if (!match) { + return null; + } + return { + scheme: match[1], + auth: match[2], + host: match[3], + port: match[4], + path: match[5] + }; + } + exports.urlParse = urlParse; + + function urlGenerate(aParsedUrl) { + var url = ''; + if (aParsedUrl.scheme) { + url += aParsedUrl.scheme + ':'; + } + url += '//'; + if (aParsedUrl.auth) { + url += aParsedUrl.auth + '@'; + } + if (aParsedUrl.host) { + url += aParsedUrl.host; + } + if (aParsedUrl.port) { + url += ":" + aParsedUrl.port + } + if (aParsedUrl.path) { + url += aParsedUrl.path; + } + return url; + } + exports.urlGenerate = urlGenerate; + + /** + * Normalizes a path, or the path portion of a URL: + * + * - Replaces consecutive slashes with one slash. + * - Removes unnecessary '.' parts. + * - Removes unnecessary '/..' parts. + * + * Based on code in the Node.js 'path' core module. + * + * @param aPath The path or url to normalize. + */ + function normalize(aPath) { + var path = aPath; + var url = urlParse(aPath); + if (url) { + if (!url.path) { + return aPath; + } + path = url.path; + } + var isAbsolute = exports.isAbsolute(path); + + var parts = path.split(/\/+/); + for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { + part = parts[i]; + if (part === '.') { + parts.splice(i, 1); + } else if (part === '..') { + up++; + } else if (up > 0) { + if (part === '') { + // The first part is blank if the path is absolute. Trying to go + // above the root is a no-op. Therefore we can remove all '..' parts + // directly after the root. + parts.splice(i + 1, up); + up = 0; + } else { + parts.splice(i, 2); + up--; + } + } + } + path = parts.join('/'); + + if (path === '') { + path = isAbsolute ? '/' : '.'; + } + + if (url) { + url.path = path; + return urlGenerate(url); + } + return path; + } + exports.normalize = normalize; + + /** + * Joins two paths/URLs. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be joined with the root. + * + * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a + * scheme-relative URL: Then the scheme of aRoot, if any, is prepended + * first. + * - Otherwise aPath is a path. If aRoot is a URL, then its path portion + * is updated with the result and aRoot is returned. Otherwise the result + * is returned. + * - If aPath is absolute, the result is aPath. + * - Otherwise the two paths are joined with a slash. + * - Joining for example 'http://' and 'www.example.com' is also supported. + */ + function join(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + if (aPath === "") { + aPath = "."; + } + var aPathUrl = urlParse(aPath); + var aRootUrl = urlParse(aRoot); + if (aRootUrl) { + aRoot = aRootUrl.path || '/'; + } + + // `join(foo, '//www.example.org')` + if (aPathUrl && !aPathUrl.scheme) { + if (aRootUrl) { + aPathUrl.scheme = aRootUrl.scheme; + } + return urlGenerate(aPathUrl); + } + + if (aPathUrl || aPath.match(dataUrlRegexp)) { + return aPath; + } + + // `join('http://', 'www.example.com')` + if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { + aRootUrl.host = aPath; + return urlGenerate(aRootUrl); + } + + var joined = aPath.charAt(0) === '/' + ? aPath + : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); + + if (aRootUrl) { + aRootUrl.path = joined; + return urlGenerate(aRootUrl); + } + return joined; + } + exports.join = join; + + exports.isAbsolute = function (aPath) { + return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp); + }; + + /** + * Make a path relative to a URL or another path. + * + * @param aRoot The root path or URL. + * @param aPath The path or URL to be made relative to aRoot. + */ + function relative(aRoot, aPath) { + if (aRoot === "") { + aRoot = "."; + } + + aRoot = aRoot.replace(/\/$/, ''); + + // It is possible for the path to be above the root. In this case, simply + // checking whether the root is a prefix of the path won't work. Instead, we + // need to remove components from the root one by one, until either we find + // a prefix that fits, or we run out of components to remove. + var level = 0; + while (aPath.indexOf(aRoot + '/') !== 0) { + var index = aRoot.lastIndexOf("/"); + if (index < 0) { + return aPath; + } + + // If the only part of the root that is left is the scheme (i.e. http://, + // file:///, etc.), one or more slashes (/), or simply nothing at all, we + // have exhausted all components, so the path is not relative to the root. + aRoot = aRoot.slice(0, index); + if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { + return aPath; + } + + ++level; + } + + // Make sure we add a "../" for each component we removed from the root. + return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); + } + exports.relative = relative; + + var supportsNullProto = (function () { + var obj = Object.create(null); + return !('__proto__' in obj); + }()); + + function identity (s) { + return s; + } + + /** + * Because behavior goes wacky when you set `__proto__` on objects, we + * have to prefix all the strings in our set with an arbitrary character. + * + * See https://github.com/mozilla/source-map/pull/31 and + * https://github.com/mozilla/source-map/issues/30 + * + * @param String aStr + */ + function toSetString(aStr) { + if (isProtoString(aStr)) { + return '$' + aStr; + } + + return aStr; + } + exports.toSetString = supportsNullProto ? identity : toSetString; + + function fromSetString(aStr) { + if (isProtoString(aStr)) { + return aStr.slice(1); + } + + return aStr; + } + exports.fromSetString = supportsNullProto ? identity : fromSetString; + + function isProtoString(s) { + if (!s) { + return false; + } + + var length = s.length; + + if (length < 9 /* "__proto__".length */) { + return false; + } + + if (s.charCodeAt(length - 1) !== 95 /* '_' */ || + s.charCodeAt(length - 2) !== 95 /* '_' */ || + s.charCodeAt(length - 3) !== 111 /* 'o' */ || + s.charCodeAt(length - 4) !== 116 /* 't' */ || + s.charCodeAt(length - 5) !== 111 /* 'o' */ || + s.charCodeAt(length - 6) !== 114 /* 'r' */ || + s.charCodeAt(length - 7) !== 112 /* 'p' */ || + s.charCodeAt(length - 8) !== 95 /* '_' */ || + s.charCodeAt(length - 9) !== 95 /* '_' */) { + return false; + } + + for (var i = length - 10; i >= 0; i--) { + if (s.charCodeAt(i) !== 36 /* '$' */) { + return false; + } + } + + return true; + } + + /** + * Comparator between two mappings where the original positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same original source/line/column, but different generated + * line and column the same. Useful when searching for a mapping with a + * stubbed out mapping. + */ + function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { + var cmp = mappingA.source - mappingB.source; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0 || onlyCompareOriginal) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + return mappingA.name - mappingB.name; + } + exports.compareByOriginalPositions = compareByOriginalPositions; + + /** + * Comparator between two mappings with deflated source and name indices where + * the generated positions are compared. + * + * Optionally pass in `true` as `onlyCompareGenerated` to consider two + * mappings with the same generated line and column, but different + * source/name/original line and column the same. Useful when searching for a + * mapping with a stubbed out mapping. + */ + function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { + var cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0 || onlyCompareGenerated) { + return cmp; + } + + cmp = mappingA.source - mappingB.source; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; + } + + return mappingA.name - mappingB.name; + } + exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; + + function strcmp(aStr1, aStr2) { + if (aStr1 === aStr2) { + return 0; + } + + if (aStr1 > aStr2) { + return 1; + } + + return -1; + } + + /** + * Comparator between two mappings with inflated source and name strings where + * the generated positions are compared. + */ + function compareByGeneratedPositionsInflated(mappingA, mappingB) { + var cmp = mappingA.generatedLine - mappingB.generatedLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.generatedColumn - mappingB.generatedColumn; + if (cmp !== 0) { + return cmp; + } + + cmp = strcmp(mappingA.source, mappingB.source); + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalLine - mappingB.originalLine; + if (cmp !== 0) { + return cmp; + } + + cmp = mappingA.originalColumn - mappingB.originalColumn; + if (cmp !== 0) { + return cmp; + } + + return strcmp(mappingA.name, mappingB.name); + } + exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; + + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + var has = Object.prototype.hasOwnProperty; + var hasNativeMap = typeof Map !== "undefined"; + + /** + * A data structure which is a combination of an array and a set. Adding a new + * member is O(1), testing for membership is O(1), and finding the index of an + * element is O(1). Removing elements from the set is not supported. Only + * strings are supported for membership. + */ + function ArraySet() { + this._array = []; + this._set = hasNativeMap ? new Map() : Object.create(null); + } + + /** + * Static method for creating ArraySet instances from an existing array. + */ + ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { + var set = new ArraySet(); + for (var i = 0, len = aArray.length; i < len; i++) { + set.add(aArray[i], aAllowDuplicates); + } + return set; + }; + + /** + * Return how many unique items are in this ArraySet. If duplicates have been + * added, than those do not count towards the size. + * + * @returns Number + */ + ArraySet.prototype.size = function ArraySet_size() { + return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; + }; + + /** + * Add the given string to this set. + * + * @param String aStr + */ + ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { + var sStr = hasNativeMap ? aStr : util.toSetString(aStr); + var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); + var idx = this._array.length; + if (!isDuplicate || aAllowDuplicates) { + this._array.push(aStr); + } + if (!isDuplicate) { + if (hasNativeMap) { + this._set.set(aStr, idx); + } else { + this._set[sStr] = idx; + } + } + }; + + /** + * Is the given string a member of this set? + * + * @param String aStr + */ + ArraySet.prototype.has = function ArraySet_has(aStr) { + if (hasNativeMap) { + return this._set.has(aStr); + } else { + var sStr = util.toSetString(aStr); + return has.call(this._set, sStr); + } + }; + + /** + * What is the index of the given string in the array? + * + * @param String aStr + */ + ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { + if (hasNativeMap) { + var idx = this._set.get(aStr); + if (idx >= 0) { + return idx; + } + } else { + var sStr = util.toSetString(aStr); + if (has.call(this._set, sStr)) { + return this._set[sStr]; + } + } + + throw new Error('"' + aStr + '" is not in the set.'); + }; + + /** + * What is the element at the given index? + * + * @param Number aIdx + */ + ArraySet.prototype.at = function ArraySet_at(aIdx) { + if (aIdx >= 0 && aIdx < this._array.length) { + return this._array[aIdx]; + } + throw new Error('No element indexed by ' + aIdx); + }; + + /** + * Returns the array representation of this set (which has the proper indices + * indicated by indexOf). Note that this is a copy of the internal array used + * for storing the members so that no one can mess with internal state. + */ + ArraySet.prototype.toArray = function ArraySet_toArray() { + return this._array.slice(); + }; + + exports.ArraySet = ArraySet; + + +/***/ }), +/* 6 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2014 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + + /** + * Determine whether mappingB is after mappingA with respect to generated + * position. + */ + function generatedPositionAfter(mappingA, mappingB) { + // Optimized for most common case + var lineA = mappingA.generatedLine; + var lineB = mappingB.generatedLine; + var columnA = mappingA.generatedColumn; + var columnB = mappingB.generatedColumn; + return lineB > lineA || lineB == lineA && columnB >= columnA || + util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; + } + + /** + * A data structure to provide a sorted view of accumulated mappings in a + * performance conscious manner. It trades a neglibable overhead in general + * case for a large speedup in case of mappings being added in order. + */ + function MappingList() { + this._array = []; + this._sorted = true; + // Serves as infimum + this._last = {generatedLine: -1, generatedColumn: 0}; + } + + /** + * Iterate through internal items. This method takes the same arguments that + * `Array.prototype.forEach` takes. + * + * NOTE: The order of the mappings is NOT guaranteed. + */ + MappingList.prototype.unsortedForEach = + function MappingList_forEach(aCallback, aThisArg) { + this._array.forEach(aCallback, aThisArg); + }; + + /** + * Add the given source mapping. + * + * @param Object aMapping + */ + MappingList.prototype.add = function MappingList_add(aMapping) { + if (generatedPositionAfter(this._last, aMapping)) { + this._last = aMapping; + this._array.push(aMapping); + } else { + this._sorted = false; + this._array.push(aMapping); + } + }; + + /** + * Returns the flat, sorted array of mappings. The mappings are sorted by + * generated position. + * + * WARNING: This method returns internal data without copying, for + * performance. The return value must NOT be mutated, and should be treated as + * an immutable borrow. If you want to take ownership, you must make your own + * copy. + */ + MappingList.prototype.toArray = function MappingList_toArray() { + if (!this._sorted) { + this._array.sort(util.compareByGeneratedPositionsInflated); + this._sorted = true; + } + return this._array; + }; + + exports.MappingList = MappingList; + + +/***/ }), +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var util = __webpack_require__(4); + var binarySearch = __webpack_require__(8); + var ArraySet = __webpack_require__(5).ArraySet; + var base64VLQ = __webpack_require__(2); + var quickSort = __webpack_require__(9).quickSort; + + function SourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + return sourceMap.sections != null + ? new IndexedSourceMapConsumer(sourceMap) + : new BasicSourceMapConsumer(sourceMap); + } + + SourceMapConsumer.fromSourceMap = function(aSourceMap) { + return BasicSourceMapConsumer.fromSourceMap(aSourceMap); + } + + /** + * The version of the source mapping spec that we are consuming. + */ + SourceMapConsumer.prototype._version = 3; + + // `__generatedMappings` and `__originalMappings` are arrays that hold the + // parsed mapping coordinates from the source map's "mappings" attribute. They + // are lazily instantiated, accessed via the `_generatedMappings` and + // `_originalMappings` getters respectively, and we only parse the mappings + // and create these arrays once queried for a source location. We jump through + // these hoops because there can be many thousands of mappings, and parsing + // them is expensive, so we only want to do it if we must. + // + // Each object in the arrays is of the form: + // + // { + // generatedLine: The line number in the generated code, + // generatedColumn: The column number in the generated code, + // source: The path to the original source file that generated this + // chunk of code, + // originalLine: The line number in the original source that + // corresponds to this chunk of generated code, + // originalColumn: The column number in the original source that + // corresponds to this chunk of generated code, + // name: The name of the original symbol which generated this chunk of + // code. + // } + // + // All properties except for `generatedLine` and `generatedColumn` can be + // `null`. + // + // `_generatedMappings` is ordered by the generated positions. + // + // `_originalMappings` is ordered by the original positions. + + SourceMapConsumer.prototype.__generatedMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { + get: function () { + if (!this.__generatedMappings) { + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__generatedMappings; + } + }); + + SourceMapConsumer.prototype.__originalMappings = null; + Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { + get: function () { + if (!this.__originalMappings) { + this._parseMappings(this._mappings, this.sourceRoot); + } + + return this.__originalMappings; + } + }); + + SourceMapConsumer.prototype._charIsMappingSeparator = + function SourceMapConsumer_charIsMappingSeparator(aStr, index) { + var c = aStr.charAt(index); + return c === ";" || c === ","; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + SourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + throw new Error("Subclasses must implement _parseMappings"); + }; + + SourceMapConsumer.GENERATED_ORDER = 1; + SourceMapConsumer.ORIGINAL_ORDER = 2; + + SourceMapConsumer.GREATEST_LOWER_BOUND = 1; + SourceMapConsumer.LEAST_UPPER_BOUND = 2; + + /** + * Iterate over each mapping between an original source/line/column and a + * generated line/column in this source map. + * + * @param Function aCallback + * The function that is called with each mapping. + * @param Object aContext + * Optional. If specified, this object will be the value of `this` every + * time that `aCallback` is called. + * @param aOrder + * Either `SourceMapConsumer.GENERATED_ORDER` or + * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to + * iterate over the mappings sorted by the generated file's line/column + * order or the original's source/line/column order, respectively. Defaults to + * `SourceMapConsumer.GENERATED_ORDER`. + */ + SourceMapConsumer.prototype.eachMapping = + function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { + var context = aContext || null; + var order = aOrder || SourceMapConsumer.GENERATED_ORDER; + + var mappings; + switch (order) { + case SourceMapConsumer.GENERATED_ORDER: + mappings = this._generatedMappings; + break; + case SourceMapConsumer.ORIGINAL_ORDER: + mappings = this._originalMappings; + break; + default: + throw new Error("Unknown order of iteration."); + } + + var sourceRoot = this.sourceRoot; + mappings.map(function (mapping) { + var source = mapping.source === null ? null : this._sources.at(mapping.source); + if (source != null && sourceRoot != null) { + source = util.join(sourceRoot, source); + } + return { + source: source, + generatedLine: mapping.generatedLine, + generatedColumn: mapping.generatedColumn, + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: mapping.name === null ? null : this._names.at(mapping.name) + }; + }, this).forEach(aCallback, context); + }; + + /** + * Returns all generated line and column information for the original source, + * line, and column provided. If no column is provided, returns all mappings + * corresponding to a either the line we are searching for or the next + * closest line that has any mappings. Otherwise, returns all mappings + * corresponding to the given line and either the column we are searching for + * or the next closest column that has any offsets. + * + * The only argument is an object with the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: Optional. the column number in the original source. + * + * and an array of objects is returned, each with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + SourceMapConsumer.prototype.allGeneratedPositionsFor = + function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { + var line = util.getArg(aArgs, 'line'); + + // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping + // returns the index of the closest mapping less than the needle. By + // setting needle.originalColumn to 0, we thus find the last mapping for + // the given line, provided such a mapping exists. + var needle = { + source: util.getArg(aArgs, 'source'), + originalLine: line, + originalColumn: util.getArg(aArgs, 'column', 0) + }; + + if (this.sourceRoot != null) { + needle.source = util.relative(this.sourceRoot, needle.source); + } + if (!this._sources.has(needle.source)) { + return []; + } + needle.source = this._sources.indexOf(needle.source); + + var mappings = []; + + var index = this._findMapping(needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + binarySearch.LEAST_UPPER_BOUND); + if (index >= 0) { + var mapping = this._originalMappings[index]; + + if (aArgs.column === undefined) { + var originalLine = mapping.originalLine; + + // Iterate until either we run out of mappings, or we run into + // a mapping for a different line than the one we found. Since + // mappings are sorted, this is guaranteed to find all mappings for + // the line we found. + while (mapping && mapping.originalLine === originalLine) { + mappings.push({ + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }); + + mapping = this._originalMappings[++index]; + } + } else { + var originalColumn = mapping.originalColumn; + + // Iterate until either we run out of mappings, or we run into + // a mapping for a different line than the one we were searching for. + // Since mappings are sorted, this is guaranteed to find all mappings for + // the line we are searching for. + while (mapping && + mapping.originalLine === line && + mapping.originalColumn == originalColumn) { + mappings.push({ + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }); + + mapping = this._originalMappings[++index]; + } + } + } + + return mappings; + }; + + exports.SourceMapConsumer = SourceMapConsumer; + + /** + * A BasicSourceMapConsumer instance represents a parsed source map which we can + * query for information about the original file positions by giving it a file + * position in the generated source. + * + * The only parameter is the raw source map (either as a JSON string, or + * already parsed to an object). According to the spec, source maps have the + * following attributes: + * + * - version: Which version of the source map spec this map is following. + * - sources: An array of URLs to the original source files. + * - names: An array of identifiers which can be referrenced by individual mappings. + * - sourceRoot: Optional. The URL root from which all sources are relative. + * - sourcesContent: Optional. An array of contents of the original source files. + * - mappings: A string of base64 VLQs which contain the actual mappings. + * - file: Optional. The generated file this source map is associated with. + * + * Here is an example source map, taken from the source map spec[0]: + * + * { + * version : 3, + * file: "out.js", + * sourceRoot : "", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AA,AB;;ABCDE;" + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# + */ + function BasicSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sources = util.getArg(sourceMap, 'sources'); + // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which + // requires the array) to play nice here. + var names = util.getArg(sourceMap, 'names', []); + var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); + var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); + var mappings = util.getArg(sourceMap, 'mappings'); + var file = util.getArg(sourceMap, 'file', null); + + // Once again, Sass deviates from the spec and supplies the version as a + // string rather than a number, so we use loose equality checking here. + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + sources = sources + .map(String) + // Some source maps produce relative source paths like "./foo.js" instead of + // "foo.js". Normalize these first so that future comparisons will succeed. + // See bugzil.la/1090768. + .map(util.normalize) + // Always ensure that absolute sources are internally stored relative to + // the source root, if the source root is absolute. Not doing this would + // be particularly problematic when the source root is a prefix of the + // source (valid, but why??). See github issue #199 and bugzil.la/1188982. + .map(function (source) { + return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) + ? util.relative(sourceRoot, source) + : source; + }); + + // Pass `true` below to allow duplicate names and sources. While source maps + // are intended to be compressed and deduplicated, the TypeScript compiler + // sometimes generates source maps with duplicates in them. See Github issue + // #72 and bugzil.la/889492. + this._names = ArraySet.fromArray(names.map(String), true); + this._sources = ArraySet.fromArray(sources, true); + + this.sourceRoot = sourceRoot; + this.sourcesContent = sourcesContent; + this._mappings = mappings; + this.file = file; + } + + BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; + + /** + * Create a BasicSourceMapConsumer from a SourceMapGenerator. + * + * @param SourceMapGenerator aSourceMap + * The source map that will be consumed. + * @returns BasicSourceMapConsumer + */ + BasicSourceMapConsumer.fromSourceMap = + function SourceMapConsumer_fromSourceMap(aSourceMap) { + var smc = Object.create(BasicSourceMapConsumer.prototype); + + var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); + var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); + smc.sourceRoot = aSourceMap._sourceRoot; + smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), + smc.sourceRoot); + smc.file = aSourceMap._file; + + // Because we are modifying the entries (by converting string sources and + // names to indices into the sources and names ArraySets), we have to make + // a copy of the entry or else bad things happen. Shared mutable state + // strikes again! See github issue #191. + + var generatedMappings = aSourceMap._mappings.toArray().slice(); + var destGeneratedMappings = smc.__generatedMappings = []; + var destOriginalMappings = smc.__originalMappings = []; + + for (var i = 0, length = generatedMappings.length; i < length; i++) { + var srcMapping = generatedMappings[i]; + var destMapping = new Mapping; + destMapping.generatedLine = srcMapping.generatedLine; + destMapping.generatedColumn = srcMapping.generatedColumn; + + if (srcMapping.source) { + destMapping.source = sources.indexOf(srcMapping.source); + destMapping.originalLine = srcMapping.originalLine; + destMapping.originalColumn = srcMapping.originalColumn; + + if (srcMapping.name) { + destMapping.name = names.indexOf(srcMapping.name); + } + + destOriginalMappings.push(destMapping); + } + + destGeneratedMappings.push(destMapping); + } + + quickSort(smc.__originalMappings, util.compareByOriginalPositions); + + return smc; + }; + + /** + * The version of the source mapping spec that we are consuming. + */ + BasicSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { + get: function () { + return this._sources.toArray().map(function (s) { + return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; + }, this); + } + }); + + /** + * Provide the JIT with a nice shape / hidden class. + */ + function Mapping() { + this.generatedLine = 0; + this.generatedColumn = 0; + this.source = null; + this.originalLine = null; + this.originalColumn = null; + this.name = null; + } + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + BasicSourceMapConsumer.prototype._parseMappings = + function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { + var generatedLine = 1; + var previousGeneratedColumn = 0; + var previousOriginalLine = 0; + var previousOriginalColumn = 0; + var previousSource = 0; + var previousName = 0; + var length = aStr.length; + var index = 0; + var cachedSegments = {}; + var temp = {}; + var originalMappings = []; + var generatedMappings = []; + var mapping, str, segment, end, value; + + while (index < length) { + if (aStr.charAt(index) === ';') { + generatedLine++; + index++; + previousGeneratedColumn = 0; + } + else if (aStr.charAt(index) === ',') { + index++; + } + else { + mapping = new Mapping(); + mapping.generatedLine = generatedLine; + + // Because each offset is encoded relative to the previous one, + // many segments often have the same encoding. We can exploit this + // fact by caching the parsed variable length fields of each segment, + // allowing us to avoid a second parse if we encounter the same + // segment again. + for (end = index; end < length; end++) { + if (this._charIsMappingSeparator(aStr, end)) { + break; + } + } + str = aStr.slice(index, end); + + segment = cachedSegments[str]; + if (segment) { + index += str.length; + } else { + segment = []; + while (index < end) { + base64VLQ.decode(aStr, index, temp); + value = temp.value; + index = temp.rest; + segment.push(value); + } + + if (segment.length === 2) { + throw new Error('Found a source, but no line and column'); + } + + if (segment.length === 3) { + throw new Error('Found a source and line, but no column'); + } + + cachedSegments[str] = segment; + } + + // Generated column. + mapping.generatedColumn = previousGeneratedColumn + segment[0]; + previousGeneratedColumn = mapping.generatedColumn; + + if (segment.length > 1) { + // Original source. + mapping.source = previousSource + segment[1]; + previousSource += segment[1]; + + // Original line. + mapping.originalLine = previousOriginalLine + segment[2]; + previousOriginalLine = mapping.originalLine; + // Lines are stored 0-based + mapping.originalLine += 1; + + // Original column. + mapping.originalColumn = previousOriginalColumn + segment[3]; + previousOriginalColumn = mapping.originalColumn; + + if (segment.length > 4) { + // Original name. + mapping.name = previousName + segment[4]; + previousName += segment[4]; + } + } + + generatedMappings.push(mapping); + if (typeof mapping.originalLine === 'number') { + originalMappings.push(mapping); + } + } + } + + quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); + this.__generatedMappings = generatedMappings; + + quickSort(originalMappings, util.compareByOriginalPositions); + this.__originalMappings = originalMappings; + }; + + /** + * Find the mapping that best matches the hypothetical "needle" mapping that + * we are searching for in the given "haystack" of mappings. + */ + BasicSourceMapConsumer.prototype._findMapping = + function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, + aColumnName, aComparator, aBias) { + // To return the position we are searching for, we must first find the + // mapping for the given position and then return the opposite position it + // points to. Because the mappings are sorted, we can use binary search to + // find the best mapping. + + if (aNeedle[aLineName] <= 0) { + throw new TypeError('Line must be greater than or equal to 1, got ' + + aNeedle[aLineName]); + } + if (aNeedle[aColumnName] < 0) { + throw new TypeError('Column must be greater than or equal to 0, got ' + + aNeedle[aColumnName]); + } + + return binarySearch.search(aNeedle, aMappings, aComparator, aBias); + }; + + /** + * Compute the last column for each generated mapping. The last column is + * inclusive. + */ + BasicSourceMapConsumer.prototype.computeColumnSpans = + function SourceMapConsumer_computeColumnSpans() { + for (var index = 0; index < this._generatedMappings.length; ++index) { + var mapping = this._generatedMappings[index]; + + // Mappings do not contain a field for the last generated columnt. We + // can come up with an optimistic estimate, however, by assuming that + // mappings are contiguous (i.e. given two consecutive mappings, the + // first mapping ends where the second one starts). + if (index + 1 < this._generatedMappings.length) { + var nextMapping = this._generatedMappings[index + 1]; + + if (mapping.generatedLine === nextMapping.generatedLine) { + mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; + continue; + } + } + + // The last mapping for each line spans the entire line. + mapping.lastGeneratedColumn = Infinity; + } + }; + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or + * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + BasicSourceMapConsumer.prototype.originalPositionFor = + function SourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + var index = this._findMapping( + needle, + this._generatedMappings, + "generatedLine", + "generatedColumn", + util.compareByGeneratedPositionsDeflated, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); + + if (index >= 0) { + var mapping = this._generatedMappings[index]; + + if (mapping.generatedLine === needle.generatedLine) { + var source = util.getArg(mapping, 'source', null); + if (source !== null) { + source = this._sources.at(source); + if (this.sourceRoot != null) { + source = util.join(this.sourceRoot, source); + } + } + var name = util.getArg(mapping, 'name', null); + if (name !== null) { + name = this._names.at(name); + } + return { + source: source, + line: util.getArg(mapping, 'originalLine', null), + column: util.getArg(mapping, 'originalColumn', null), + name: name + }; + } + } + + return { + source: null, + line: null, + column: null, + name: null + }; + }; + + /** + * Return true if we have the source content for every source in the source + * map, false otherwise. + */ + BasicSourceMapConsumer.prototype.hasContentsOfAllSources = + function BasicSourceMapConsumer_hasContentsOfAllSources() { + if (!this.sourcesContent) { + return false; + } + return this.sourcesContent.length >= this._sources.size() && + !this.sourcesContent.some(function (sc) { return sc == null; }); + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ + BasicSourceMapConsumer.prototype.sourceContentFor = + function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + if (!this.sourcesContent) { + return null; + } + + if (this.sourceRoot != null) { + aSource = util.relative(this.sourceRoot, aSource); + } + + if (this._sources.has(aSource)) { + return this.sourcesContent[this._sources.indexOf(aSource)]; + } + + var url; + if (this.sourceRoot != null + && (url = util.urlParse(this.sourceRoot))) { + // XXX: file:// URIs and absolute paths lead to unexpected behavior for + // many users. We can help them out when they expect file:// URIs to + // behave like it would if they were running a local HTTP server. See + // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. + var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); + if (url.scheme == "file" + && this._sources.has(fileUriAbsPath)) { + return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] + } + + if ((!url.path || url.path == "/") + && this._sources.has("/" + aSource)) { + return this.sourcesContent[this._sources.indexOf("/" + aSource)]; + } + } + + // This function is used recursively from + // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we + // don't want to throw if we can't find the source - we just want to + // return null, so we provide a flag to exit gracefully. + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or + * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + BasicSourceMapConsumer.prototype.generatedPositionFor = + function SourceMapConsumer_generatedPositionFor(aArgs) { + var source = util.getArg(aArgs, 'source'); + if (this.sourceRoot != null) { + source = util.relative(this.sourceRoot, source); + } + if (!this._sources.has(source)) { + return { + line: null, + column: null, + lastColumn: null + }; + } + source = this._sources.indexOf(source); + + var needle = { + source: source, + originalLine: util.getArg(aArgs, 'line'), + originalColumn: util.getArg(aArgs, 'column') + }; + + var index = this._findMapping( + needle, + this._originalMappings, + "originalLine", + "originalColumn", + util.compareByOriginalPositions, + util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) + ); + + if (index >= 0) { + var mapping = this._originalMappings[index]; + + if (mapping.source === needle.source) { + return { + line: util.getArg(mapping, 'generatedLine', null), + column: util.getArg(mapping, 'generatedColumn', null), + lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) + }; + } + } + + return { + line: null, + column: null, + lastColumn: null + }; + }; + + exports.BasicSourceMapConsumer = BasicSourceMapConsumer; + + /** + * An IndexedSourceMapConsumer instance represents a parsed source map which + * we can query for information. It differs from BasicSourceMapConsumer in + * that it takes "indexed" source maps (i.e. ones with a "sections" field) as + * input. + * + * The only parameter is a raw source map (either as a JSON string, or already + * parsed to an object). According to the spec for indexed source maps, they + * have the following attributes: + * + * - version: Which version of the source map spec this map is following. + * - file: Optional. The generated file this source map is associated with. + * - sections: A list of section definitions. + * + * Each value under the "sections" field has two fields: + * - offset: The offset into the original specified at which this section + * begins to apply, defined as an object with a "line" and "column" + * field. + * - map: A source map definition. This source map could also be indexed, + * but doesn't have to be. + * + * Instead of the "map" field, it's also possible to have a "url" field + * specifying a URL to retrieve a source map from, but that's currently + * unsupported. + * + * Here's an example source map, taken from the source map spec[0], but + * modified to omit a section which uses the "url" field. + * + * { + * version : 3, + * file: "app.js", + * sections: [{ + * offset: {line:100, column:10}, + * map: { + * version : 3, + * file: "section.js", + * sources: ["foo.js", "bar.js"], + * names: ["src", "maps", "are", "fun"], + * mappings: "AAAA,E;;ABCDE;" + * } + * }], + * } + * + * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt + */ + function IndexedSourceMapConsumer(aSourceMap) { + var sourceMap = aSourceMap; + if (typeof aSourceMap === 'string') { + sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); + } + + var version = util.getArg(sourceMap, 'version'); + var sections = util.getArg(sourceMap, 'sections'); + + if (version != this._version) { + throw new Error('Unsupported version: ' + version); + } + + this._sources = new ArraySet(); + this._names = new ArraySet(); + + var lastOffset = { + line: -1, + column: 0 + }; + this._sections = sections.map(function (s) { + if (s.url) { + // The url field will require support for asynchronicity. + // See https://github.com/mozilla/source-map/issues/16 + throw new Error('Support for url field in sections not implemented.'); + } + var offset = util.getArg(s, 'offset'); + var offsetLine = util.getArg(offset, 'line'); + var offsetColumn = util.getArg(offset, 'column'); + + if (offsetLine < lastOffset.line || + (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { + throw new Error('Section offsets must be ordered and non-overlapping.'); + } + lastOffset = offset; + + return { + generatedOffset: { + // The offset fields are 0-based, but we use 1-based indices when + // encoding/decoding from VLQ. + generatedLine: offsetLine + 1, + generatedColumn: offsetColumn + 1 + }, + consumer: new SourceMapConsumer(util.getArg(s, 'map')) + } + }); + } + + IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); + IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; + + /** + * The version of the source mapping spec that we are consuming. + */ + IndexedSourceMapConsumer.prototype._version = 3; + + /** + * The list of original sources. + */ + Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { + get: function () { + var sources = []; + for (var i = 0; i < this._sections.length; i++) { + for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { + sources.push(this._sections[i].consumer.sources[j]); + } + } + return sources; + } + }); + + /** + * Returns the original source, line, and column information for the generated + * source's line and column positions provided. The only argument is an object + * with the following properties: + * + * - line: The line number in the generated source. + * - column: The column number in the generated source. + * + * and an object is returned with the following properties: + * + * - source: The original source file, or null. + * - line: The line number in the original source, or null. + * - column: The column number in the original source, or null. + * - name: The original identifier, or null. + */ + IndexedSourceMapConsumer.prototype.originalPositionFor = + function IndexedSourceMapConsumer_originalPositionFor(aArgs) { + var needle = { + generatedLine: util.getArg(aArgs, 'line'), + generatedColumn: util.getArg(aArgs, 'column') + }; + + // Find the section containing the generated position we're trying to map + // to an original position. + var sectionIndex = binarySearch.search(needle, this._sections, + function(needle, section) { + var cmp = needle.generatedLine - section.generatedOffset.generatedLine; + if (cmp) { + return cmp; + } + + return (needle.generatedColumn - + section.generatedOffset.generatedColumn); + }); + var section = this._sections[sectionIndex]; + + if (!section) { + return { + source: null, + line: null, + column: null, + name: null + }; + } + + return section.consumer.originalPositionFor({ + line: needle.generatedLine - + (section.generatedOffset.generatedLine - 1), + column: needle.generatedColumn - + (section.generatedOffset.generatedLine === needle.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0), + bias: aArgs.bias + }); + }; + + /** + * Return true if we have the source content for every source in the source + * map, false otherwise. + */ + IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = + function IndexedSourceMapConsumer_hasContentsOfAllSources() { + return this._sections.every(function (s) { + return s.consumer.hasContentsOfAllSources(); + }); + }; + + /** + * Returns the original source content. The only argument is the url of the + * original source file. Returns null if no original source content is + * available. + */ + IndexedSourceMapConsumer.prototype.sourceContentFor = + function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + var content = section.consumer.sourceContentFor(aSource, true); + if (content) { + return content; + } + } + if (nullOnMissing) { + return null; + } + else { + throw new Error('"' + aSource + '" is not in the SourceMap.'); + } + }; + + /** + * Returns the generated line and column information for the original source, + * line, and column positions provided. The only argument is an object with + * the following properties: + * + * - source: The filename of the original source. + * - line: The line number in the original source. + * - column: The column number in the original source. + * + * and an object is returned with the following properties: + * + * - line: The line number in the generated source, or null. + * - column: The column number in the generated source, or null. + */ + IndexedSourceMapConsumer.prototype.generatedPositionFor = + function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + + // Only consider this section if the requested source is in the list of + // sources of the consumer. + if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) { + continue; + } + var generatedPosition = section.consumer.generatedPositionFor(aArgs); + if (generatedPosition) { + var ret = { + line: generatedPosition.line + + (section.generatedOffset.generatedLine - 1), + column: generatedPosition.column + + (section.generatedOffset.generatedLine === generatedPosition.line + ? section.generatedOffset.generatedColumn - 1 + : 0) + }; + return ret; + } + } + + return { + line: null, + column: null + }; + }; + + /** + * Parse the mappings in a string in to a data structure which we can easily + * query (the ordered arrays in the `this.__generatedMappings` and + * `this.__originalMappings` properties). + */ + IndexedSourceMapConsumer.prototype._parseMappings = + function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { + this.__generatedMappings = []; + this.__originalMappings = []; + for (var i = 0; i < this._sections.length; i++) { + var section = this._sections[i]; + var sectionMappings = section.consumer._generatedMappings; + for (var j = 0; j < sectionMappings.length; j++) { + var mapping = sectionMappings[j]; + + var source = section.consumer._sources.at(mapping.source); + if (section.consumer.sourceRoot !== null) { + source = util.join(section.consumer.sourceRoot, source); + } + this._sources.add(source); + source = this._sources.indexOf(source); + + var name = section.consumer._names.at(mapping.name); + this._names.add(name); + name = this._names.indexOf(name); + + // The mappings coming from the consumer for the section have + // generated positions relative to the start of the section, so we + // need to offset them to be relative to the start of the concatenated + // generated file. + var adjustedMapping = { + source: source, + generatedLine: mapping.generatedLine + + (section.generatedOffset.generatedLine - 1), + generatedColumn: mapping.generatedColumn + + (section.generatedOffset.generatedLine === mapping.generatedLine + ? section.generatedOffset.generatedColumn - 1 + : 0), + originalLine: mapping.originalLine, + originalColumn: mapping.originalColumn, + name: name + }; + + this.__generatedMappings.push(adjustedMapping); + if (typeof adjustedMapping.originalLine === 'number') { + this.__originalMappings.push(adjustedMapping); + } + } + } + + quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); + quickSort(this.__originalMappings, util.compareByOriginalPositions); + }; + + exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer; + + +/***/ }), +/* 8 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + exports.GREATEST_LOWER_BOUND = 1; + exports.LEAST_UPPER_BOUND = 2; + + /** + * Recursive implementation of binary search. + * + * @param aLow Indices here and lower do not contain the needle. + * @param aHigh Indices here and higher do not contain the needle. + * @param aNeedle The element being searched for. + * @param aHaystack The non-empty array being searched. + * @param aCompare Function which takes two elements and returns -1, 0, or 1. + * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or + * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + */ + function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { + // This function terminates when one of the following is true: + // + // 1. We find the exact element we are looking for. + // + // 2. We did not find the exact element, but we can return the index of + // the next-closest element. + // + // 3. We did not find the exact element, and there is no next-closest + // element than the one we are searching for, so we return -1. + var mid = Math.floor((aHigh - aLow) / 2) + aLow; + var cmp = aCompare(aNeedle, aHaystack[mid], true); + if (cmp === 0) { + // Found the element we are looking for. + return mid; + } + else if (cmp > 0) { + // Our needle is greater than aHaystack[mid]. + if (aHigh - mid > 1) { + // The element is in the upper half. + return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); + } + + // The exact needle element was not found in this haystack. Determine if + // we are in termination case (3) or (2) and return the appropriate thing. + if (aBias == exports.LEAST_UPPER_BOUND) { + return aHigh < aHaystack.length ? aHigh : -1; + } else { + return mid; + } + } + else { + // Our needle is less than aHaystack[mid]. + if (mid - aLow > 1) { + // The element is in the lower half. + return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); + } + + // we are in termination case (3) or (2) and return the appropriate thing. + if (aBias == exports.LEAST_UPPER_BOUND) { + return mid; + } else { + return aLow < 0 ? -1 : aLow; + } + } + } + + /** + * This is an implementation of binary search which will always try and return + * the index of the closest element if there is no exact hit. This is because + * mappings between original and generated line/col pairs are single points, + * and there is an implicit region between each of them, so a miss just means + * that you aren't on the very start of a region. + * + * @param aNeedle The element you are looking for. + * @param aHaystack The array that is being searched. + * @param aCompare A function which takes the needle and an element in the + * array and returns -1, 0, or 1 depending on whether the needle is less + * than, equal to, or greater than the element, respectively. + * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or + * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the + * closest element that is smaller than or greater than the one we are + * searching for, respectively, if the exact element cannot be found. + * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. + */ + exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { + if (aHaystack.length === 0) { + return -1; + } + + var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, + aCompare, aBias || exports.GREATEST_LOWER_BOUND); + if (index < 0) { + return -1; + } + + // We have found either the exact element, or the next-closest element than + // the one we are searching for. However, there may be more than one such + // element. Make sure we always return the smallest of these. + while (index - 1 >= 0) { + if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { + break; + } + --index; + } + + return index; + }; + + +/***/ }), +/* 9 */ +/***/ (function(module, exports) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + // It turns out that some (most?) JavaScript engines don't self-host + // `Array.prototype.sort`. This makes sense because C++ will likely remain + // faster than JS when doing raw CPU-intensive sorting. However, when using a + // custom comparator function, calling back and forth between the VM's C++ and + // JIT'd JS is rather slow *and* loses JIT type information, resulting in + // worse generated code for the comparator function than would be optimal. In + // fact, when sorting with a comparator, these costs outweigh the benefits of + // sorting in C++. By using our own JS-implemented Quick Sort (below), we get + // a ~3500ms mean speed-up in `bench/bench.html`. + + /** + * Swap the elements indexed by `x` and `y` in the array `ary`. + * + * @param {Array} ary + * The array. + * @param {Number} x + * The index of the first item. + * @param {Number} y + * The index of the second item. + */ + function swap(ary, x, y) { + var temp = ary[x]; + ary[x] = ary[y]; + ary[y] = temp; + } + + /** + * Returns a random integer within the range `low .. high` inclusive. + * + * @param {Number} low + * The lower bound on the range. + * @param {Number} high + * The upper bound on the range. + */ + function randomIntInRange(low, high) { + return Math.round(low + (Math.random() * (high - low))); + } + + /** + * The Quick Sort algorithm. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + * @param {Number} p + * Start index of the array + * @param {Number} r + * End index of the array + */ + function doQuickSort(ary, comparator, p, r) { + // If our lower bound is less than our upper bound, we (1) partition the + // array into two pieces and (2) recurse on each half. If it is not, this is + // the empty array and our base case. + + if (p < r) { + // (1) Partitioning. + // + // The partitioning chooses a pivot between `p` and `r` and moves all + // elements that are less than or equal to the pivot to the before it, and + // all the elements that are greater than it after it. The effect is that + // once partition is done, the pivot is in the exact place it will be when + // the array is put in sorted order, and it will not need to be moved + // again. This runs in O(n) time. + + // Always choose a random pivot so that an input array which is reverse + // sorted does not cause O(n^2) running time. + var pivotIndex = randomIntInRange(p, r); + var i = p - 1; + + swap(ary, pivotIndex, r); + var pivot = ary[r]; + + // Immediately after `j` is incremented in this loop, the following hold + // true: + // + // * Every element in `ary[p .. i]` is less than or equal to the pivot. + // + // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. + for (var j = p; j < r; j++) { + if (comparator(ary[j], pivot) <= 0) { + i += 1; + swap(ary, i, j); + } + } + + swap(ary, i + 1, j); + var q = i + 1; + + // (2) Recurse on each half. + + doQuickSort(ary, comparator, p, q - 1); + doQuickSort(ary, comparator, q + 1, r); + } + } + + /** + * Sort the given array in-place with the given comparator function. + * + * @param {Array} ary + * An array to sort. + * @param {function} comparator + * Function to use to compare two items. + */ + exports.quickSort = function (ary, comparator) { + doQuickSort(ary, comparator, 0, ary.length - 1); + }; + + +/***/ }), +/* 10 */ +/***/ (function(module, exports, __webpack_require__) { + + /* -*- Mode: js; js-indent-level: 2; -*- */ + /* + * Copyright 2011 Mozilla Foundation and contributors + * Licensed under the New BSD license. See LICENSE or: + * http://opensource.org/licenses/BSD-3-Clause + */ + + var SourceMapGenerator = __webpack_require__(1).SourceMapGenerator; + var util = __webpack_require__(4); + + // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other + // operating systems these days (capturing the result). + var REGEX_NEWLINE = /(\r?\n)/; + + // Newline character code for charCodeAt() comparisons + var NEWLINE_CODE = 10; + + // Private symbol for identifying `SourceNode`s when multiple versions of + // the source-map library are loaded. This MUST NOT CHANGE across + // versions! + var isSourceNode = "$$$isSourceNode$$$"; + + /** + * SourceNodes provide a way to abstract over interpolating/concatenating + * snippets of generated JavaScript source code while maintaining the line and + * column information associated with the original source code. + * + * @param aLine The original line number. + * @param aColumn The original column number. + * @param aSource The original source's filename. + * @param aChunks Optional. An array of strings which are snippets of + * generated JS, or other SourceNodes. + * @param aName The original identifier. + */ + function SourceNode(aLine, aColumn, aSource, aChunks, aName) { + this.children = []; + this.sourceContents = {}; + this.line = aLine == null ? null : aLine; + this.column = aColumn == null ? null : aColumn; + this.source = aSource == null ? null : aSource; + this.name = aName == null ? null : aName; + this[isSourceNode] = true; + if (aChunks != null) this.add(aChunks); + } + + /** + * Creates a SourceNode from generated code and a SourceMapConsumer. + * + * @param aGeneratedCode The generated code + * @param aSourceMapConsumer The SourceMap for the generated code + * @param aRelativePath Optional. The path that relative sources in the + * SourceMapConsumer should be relative to. + */ + SourceNode.fromStringWithSourceMap = + function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { + // The SourceNode we want to fill with the generated code + // and the SourceMap + var node = new SourceNode(); + + // All even indices of this array are one line of the generated code, + // while all odd indices are the newlines between two adjacent lines + // (since `REGEX_NEWLINE` captures its match). + // Processed fragments are accessed by calling `shiftNextLine`. + var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); + var remainingLinesIndex = 0; + var shiftNextLine = function() { + var lineContents = getNextLine(); + // The last line of a file might not have a newline. + var newLine = getNextLine() || ""; + return lineContents + newLine; + + function getNextLine() { + return remainingLinesIndex < remainingLines.length ? + remainingLines[remainingLinesIndex++] : undefined; + } + }; + + // We need to remember the position of "remainingLines" + var lastGeneratedLine = 1, lastGeneratedColumn = 0; + + // The generate SourceNodes we need a code range. + // To extract it current and last mapping is used. + // Here we store the last mapping. + var lastMapping = null; + + aSourceMapConsumer.eachMapping(function (mapping) { + if (lastMapping !== null) { + // We add the code from "lastMapping" to "mapping": + // First check if there is a new line in between. + if (lastGeneratedLine < mapping.generatedLine) { + // Associate first line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + lastGeneratedLine++; + lastGeneratedColumn = 0; + // The remaining code is added without mapping + } else { + // There is no new line in between. + // Associate the code between "lastGeneratedColumn" and + // "mapping.generatedColumn" with "lastMapping" + var nextLine = remainingLines[remainingLinesIndex]; + var code = nextLine.substr(0, mapping.generatedColumn - + lastGeneratedColumn); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - + lastGeneratedColumn); + lastGeneratedColumn = mapping.generatedColumn; + addMappingWithCode(lastMapping, code); + // No more remaining code, continue + lastMapping = mapping; + return; + } + } + // We add the generated code until the first mapping + // to the SourceNode without any mapping. + // Each line is added as separate string. + while (lastGeneratedLine < mapping.generatedLine) { + node.add(shiftNextLine()); + lastGeneratedLine++; + } + if (lastGeneratedColumn < mapping.generatedColumn) { + var nextLine = remainingLines[remainingLinesIndex]; + node.add(nextLine.substr(0, mapping.generatedColumn)); + remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); + lastGeneratedColumn = mapping.generatedColumn; + } + lastMapping = mapping; + }, this); + // We have processed all mappings. + if (remainingLinesIndex < remainingLines.length) { + if (lastMapping) { + // Associate the remaining code in the current line with "lastMapping" + addMappingWithCode(lastMapping, shiftNextLine()); + } + // and add the remaining lines without any mapping + node.add(remainingLines.splice(remainingLinesIndex).join("")); + } + + // Copy sourcesContent into SourceNode + aSourceMapConsumer.sources.forEach(function (sourceFile) { + var content = aSourceMapConsumer.sourceContentFor(sourceFile); + if (content != null) { + if (aRelativePath != null) { + sourceFile = util.join(aRelativePath, sourceFile); + } + node.setSourceContent(sourceFile, content); + } + }); + + return node; + + function addMappingWithCode(mapping, code) { + if (mapping === null || mapping.source === undefined) { + node.add(code); + } else { + var source = aRelativePath + ? util.join(aRelativePath, mapping.source) + : mapping.source; + node.add(new SourceNode(mapping.originalLine, + mapping.originalColumn, + source, + code, + mapping.name)); + } + } + }; + + /** + * Add a chunk of generated JS to this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.add = function SourceNode_add(aChunk) { + if (Array.isArray(aChunk)) { + aChunk.forEach(function (chunk) { + this.add(chunk); + }, this); + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + if (aChunk) { + this.children.push(aChunk); + } + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Add a chunk of generated JS to the beginning of this source node. + * + * @param aChunk A string snippet of generated JS code, another instance of + * SourceNode, or an array where each member is one of those things. + */ + SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { + if (Array.isArray(aChunk)) { + for (var i = aChunk.length-1; i >= 0; i--) { + this.prepend(aChunk[i]); + } + } + else if (aChunk[isSourceNode] || typeof aChunk === "string") { + this.children.unshift(aChunk); + } + else { + throw new TypeError( + "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk + ); + } + return this; + }; + + /** + * Walk over the tree of JS snippets in this node and its children. The + * walking function is called once for each snippet of JS and is passed that + * snippet and the its original associated source's line/column location. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walk = function SourceNode_walk(aFn) { + var chunk; + for (var i = 0, len = this.children.length; i < len; i++) { + chunk = this.children[i]; + if (chunk[isSourceNode]) { + chunk.walk(aFn); + } + else { + if (chunk !== '') { + aFn(chunk, { source: this.source, + line: this.line, + column: this.column, + name: this.name }); + } + } + } + }; + + /** + * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between + * each of `this.children`. + * + * @param aSep The separator. + */ + SourceNode.prototype.join = function SourceNode_join(aSep) { + var newChildren; + var i; + var len = this.children.length; + if (len > 0) { + newChildren = []; + for (i = 0; i < len-1; i++) { + newChildren.push(this.children[i]); + newChildren.push(aSep); + } + newChildren.push(this.children[i]); + this.children = newChildren; + } + return this; + }; + + /** + * Call String.prototype.replace on the very right-most source snippet. Useful + * for trimming whitespace from the end of a source node, etc. + * + * @param aPattern The pattern to replace. + * @param aReplacement The thing to replace the pattern with. + */ + SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { + var lastChild = this.children[this.children.length - 1]; + if (lastChild[isSourceNode]) { + lastChild.replaceRight(aPattern, aReplacement); + } + else if (typeof lastChild === 'string') { + this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); + } + else { + this.children.push(''.replace(aPattern, aReplacement)); + } + return this; + }; + + /** + * Set the source content for a source file. This will be added to the SourceMapGenerator + * in the sourcesContent field. + * + * @param aSourceFile The filename of the source file + * @param aSourceContent The content of the source file + */ + SourceNode.prototype.setSourceContent = + function SourceNode_setSourceContent(aSourceFile, aSourceContent) { + this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; + }; + + /** + * Walk over the tree of SourceNodes. The walking function is called for each + * source file content and is passed the filename and source content. + * + * @param aFn The traversal function. + */ + SourceNode.prototype.walkSourceContents = + function SourceNode_walkSourceContents(aFn) { + for (var i = 0, len = this.children.length; i < len; i++) { + if (this.children[i][isSourceNode]) { + this.children[i].walkSourceContents(aFn); + } + } + + var sources = Object.keys(this.sourceContents); + for (var i = 0, len = sources.length; i < len; i++) { + aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); + } + }; + + /** + * Return the string representation of this source node. Walks over the tree + * and concatenates all the various snippets together to one string. + */ + SourceNode.prototype.toString = function SourceNode_toString() { + var str = ""; + this.walk(function (chunk) { + str += chunk; + }); + return str; + }; + + /** + * Returns the string representation of this source node along with a source + * map. + */ + SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { + var generated = { + code: "", + line: 1, + column: 0 + }; + var map = new SourceMapGenerator(aArgs); + var sourceMappingActive = false; + var lastOriginalSource = null; + var lastOriginalLine = null; + var lastOriginalColumn = null; + var lastOriginalName = null; + this.walk(function (chunk, original) { + generated.code += chunk; + if (original.source !== null + && original.line !== null + && original.column !== null) { + if(lastOriginalSource !== original.source + || lastOriginalLine !== original.line + || lastOriginalColumn !== original.column + || lastOriginalName !== original.name) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + lastOriginalSource = original.source; + lastOriginalLine = original.line; + lastOriginalColumn = original.column; + lastOriginalName = original.name; + sourceMappingActive = true; + } else if (sourceMappingActive) { + map.addMapping({ + generated: { + line: generated.line, + column: generated.column + } + }); + lastOriginalSource = null; + sourceMappingActive = false; + } + for (var idx = 0, length = chunk.length; idx < length; idx++) { + if (chunk.charCodeAt(idx) === NEWLINE_CODE) { + generated.line++; + generated.column = 0; + // Mappings end at eol + if (idx + 1 === length) { + lastOriginalSource = null; + sourceMappingActive = false; + } else if (sourceMappingActive) { + map.addMapping({ + source: original.source, + original: { + line: original.line, + column: original.column + }, + generated: { + line: generated.line, + column: generated.column + }, + name: original.name + }); + } + } else { + generated.column++; + } + } + }); + this.walkSourceContents(function (sourceFile, sourceContent) { + map.setSourceContent(sourceFile, sourceContent); + }); + + return { code: generated.code, map: map }; + }; + + exports.SourceNode = SourceNode; + + +/***/ }) +/******/ ]) +}); +; \ No newline at end of file diff --git a/node_modules/source-map/dist/source-map.min.js b/node_modules/source-map/dist/source-map.min.js new file mode 100644 index 00000000..f2a46bd0 --- /dev/null +++ b/node_modules/source-map/dist/source-map.min.js @@ -0,0 +1,2 @@ +!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports.sourceMap=n():e.sourceMap=n()}(this,function(){return function(e){function n(t){if(r[t])return r[t].exports;var o=r[t]={exports:{},id:t,loaded:!1};return e[t].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}var r={};return n.m=e,n.c=r,n.p="",n(0)}([function(e,n,r){n.SourceMapGenerator=r(1).SourceMapGenerator,n.SourceMapConsumer=r(7).SourceMapConsumer,n.SourceNode=r(10).SourceNode},function(e,n,r){function t(e){e||(e={}),this._file=i.getArg(e,"file",null),this._sourceRoot=i.getArg(e,"sourceRoot",null),this._skipValidation=i.getArg(e,"skipValidation",!1),this._sources=new s,this._names=new s,this._mappings=new a,this._sourcesContents=null}var o=r(2),i=r(4),s=r(5).ArraySet,a=r(6).MappingList;t.prototype._version=3,t.fromSourceMap=function(e){var n=e.sourceRoot,r=new t({file:e.file,sourceRoot:n});return e.eachMapping(function(e){var t={generated:{line:e.generatedLine,column:e.generatedColumn}};null!=e.source&&(t.source=e.source,null!=n&&(t.source=i.relative(n,t.source)),t.original={line:e.originalLine,column:e.originalColumn},null!=e.name&&(t.name=e.name)),r.addMapping(t)}),e.sources.forEach(function(n){var t=e.sourceContentFor(n);null!=t&&r.setSourceContent(n,t)}),r},t.prototype.addMapping=function(e){var n=i.getArg(e,"generated"),r=i.getArg(e,"original",null),t=i.getArg(e,"source",null),o=i.getArg(e,"name",null);this._skipValidation||this._validateMapping(n,r,t,o),null!=t&&(t=String(t),this._sources.has(t)||this._sources.add(t)),null!=o&&(o=String(o),this._names.has(o)||this._names.add(o)),this._mappings.add({generatedLine:n.line,generatedColumn:n.column,originalLine:null!=r&&r.line,originalColumn:null!=r&&r.column,source:t,name:o})},t.prototype.setSourceContent=function(e,n){var r=e;null!=this._sourceRoot&&(r=i.relative(this._sourceRoot,r)),null!=n?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[i.toSetString(r)]=n):this._sourcesContents&&(delete this._sourcesContents[i.toSetString(r)],0===Object.keys(this._sourcesContents).length&&(this._sourcesContents=null))},t.prototype.applySourceMap=function(e,n,r){var t=n;if(null==n){if(null==e.file)throw new Error('SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map\'s "file" property. Both were omitted.');t=e.file}var o=this._sourceRoot;null!=o&&(t=i.relative(o,t));var a=new s,u=new s;this._mappings.unsortedForEach(function(n){if(n.source===t&&null!=n.originalLine){var s=e.originalPositionFor({line:n.originalLine,column:n.originalColumn});null!=s.source&&(n.source=s.source,null!=r&&(n.source=i.join(r,n.source)),null!=o&&(n.source=i.relative(o,n.source)),n.originalLine=s.line,n.originalColumn=s.column,null!=s.name&&(n.name=s.name))}var l=n.source;null==l||a.has(l)||a.add(l);var c=n.name;null==c||u.has(c)||u.add(c)},this),this._sources=a,this._names=u,e.sources.forEach(function(n){var t=e.sourceContentFor(n);null!=t&&(null!=r&&(n=i.join(r,n)),null!=o&&(n=i.relative(o,n)),this.setSourceContent(n,t))},this)},t.prototype._validateMapping=function(e,n,r,t){if(n&&"number"!=typeof n.line&&"number"!=typeof n.column)throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if((!(e&&"line"in e&&"column"in e&&e.line>0&&e.column>=0)||n||r||t)&&!(e&&"line"in e&&"column"in e&&n&&"line"in n&&"column"in n&&e.line>0&&e.column>=0&&n.line>0&&n.column>=0&&r))throw new Error("Invalid mapping: "+JSON.stringify({generated:e,source:r,original:n,name:t}))},t.prototype._serializeMappings=function(){for(var e,n,r,t,s=0,a=1,u=0,l=0,c=0,g=0,p="",h=this._mappings.toArray(),f=0,d=h.length;f0){if(!i.compareByGeneratedPositionsInflated(n,h[f-1]))continue;e+=","}e+=o.encode(n.generatedColumn-s),s=n.generatedColumn,null!=n.source&&(t=this._sources.indexOf(n.source),e+=o.encode(t-g),g=t,e+=o.encode(n.originalLine-1-l),l=n.originalLine-1,e+=o.encode(n.originalColumn-u),u=n.originalColumn,null!=n.name&&(r=this._names.indexOf(n.name),e+=o.encode(r-c),c=r)),p+=e}return p},t.prototype._generateSourcesContent=function(e,n){return e.map(function(e){if(!this._sourcesContents)return null;null!=n&&(e=i.relative(n,e));var r=i.toSetString(e);return Object.prototype.hasOwnProperty.call(this._sourcesContents,r)?this._sourcesContents[r]:null},this)},t.prototype.toJSON=function(){var e={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return null!=this._file&&(e.file=this._file),null!=this._sourceRoot&&(e.sourceRoot=this._sourceRoot),this._sourcesContents&&(e.sourcesContent=this._generateSourcesContent(e.sources,e.sourceRoot)),e},t.prototype.toString=function(){return JSON.stringify(this.toJSON())},n.SourceMapGenerator=t},function(e,n,r){function t(e){return e<0?(-e<<1)+1:(e<<1)+0}function o(e){var n=1===(1&e),r=e>>1;return n?-r:r}var i=r(3),s=5,a=1<>>=s,o>0&&(n|=l),r+=i.encode(n);while(o>0);return r},n.decode=function(e,n,r){var t,a,c=e.length,g=0,p=0;do{if(n>=c)throw new Error("Expected more digits in base 64 VLQ value.");if(a=i.decode(e.charCodeAt(n++)),a===-1)throw new Error("Invalid base64 digit: "+e.charAt(n-1));t=!!(a&l),a&=u,g+=a<=0;c--)s=u[c],"."===s?u.splice(c,1):".."===s?l++:l>0&&(""===s?(u.splice(c+1,l),l=0):(u.splice(c,2),l--));return r=u.join("/"),""===r&&(r=a?"/":"."),i?(i.path=r,o(i)):r}function s(e,n){""===e&&(e="."),""===n&&(n=".");var r=t(n),s=t(e);if(s&&(e=s.path||"/"),r&&!r.scheme)return s&&(r.scheme=s.scheme),o(r);if(r||n.match(_))return n;if(s&&!s.host&&!s.path)return s.host=n,o(s);var a="/"===n.charAt(0)?n:i(e.replace(/\/+$/,"")+"/"+n);return s?(s.path=a,o(s)):a}function a(e,n){""===e&&(e="."),e=e.replace(/\/$/,"");for(var r=0;0!==n.indexOf(e+"/");){var t=e.lastIndexOf("/");if(t<0)return n;if(e=e.slice(0,t),e.match(/^([^\/]+:\/)?\/*$/))return n;++r}return Array(r+1).join("../")+n.substr(e.length+1)}function u(e){return e}function l(e){return g(e)?"$"+e:e}function c(e){return g(e)?e.slice(1):e}function g(e){if(!e)return!1;var n=e.length;if(n<9)return!1;if(95!==e.charCodeAt(n-1)||95!==e.charCodeAt(n-2)||111!==e.charCodeAt(n-3)||116!==e.charCodeAt(n-4)||111!==e.charCodeAt(n-5)||114!==e.charCodeAt(n-6)||112!==e.charCodeAt(n-7)||95!==e.charCodeAt(n-8)||95!==e.charCodeAt(n-9))return!1;for(var r=n-10;r>=0;r--)if(36!==e.charCodeAt(r))return!1;return!0}function p(e,n,r){var t=e.source-n.source;return 0!==t?t:(t=e.originalLine-n.originalLine,0!==t?t:(t=e.originalColumn-n.originalColumn,0!==t||r?t:(t=e.generatedColumn-n.generatedColumn,0!==t?t:(t=e.generatedLine-n.generatedLine,0!==t?t:e.name-n.name))))}function h(e,n,r){var t=e.generatedLine-n.generatedLine;return 0!==t?t:(t=e.generatedColumn-n.generatedColumn,0!==t||r?t:(t=e.source-n.source,0!==t?t:(t=e.originalLine-n.originalLine,0!==t?t:(t=e.originalColumn-n.originalColumn,0!==t?t:e.name-n.name))))}function f(e,n){return e===n?0:e>n?1:-1}function d(e,n){var r=e.generatedLine-n.generatedLine;return 0!==r?r:(r=e.generatedColumn-n.generatedColumn,0!==r?r:(r=f(e.source,n.source),0!==r?r:(r=e.originalLine-n.originalLine,0!==r?r:(r=e.originalColumn-n.originalColumn,0!==r?r:f(e.name,n.name)))))}n.getArg=r;var m=/^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/,_=/^data:.+\,.+$/;n.urlParse=t,n.urlGenerate=o,n.normalize=i,n.join=s,n.isAbsolute=function(e){return"/"===e.charAt(0)||!!e.match(m)},n.relative=a;var v=function(){var e=Object.create(null);return!("__proto__"in e)}();n.toSetString=v?u:l,n.fromSetString=v?u:c,n.compareByOriginalPositions=p,n.compareByGeneratedPositionsDeflated=h,n.compareByGeneratedPositionsInflated=d},function(e,n,r){function t(){this._array=[],this._set=s?new Map:Object.create(null)}var o=r(4),i=Object.prototype.hasOwnProperty,s="undefined"!=typeof Map;t.fromArray=function(e,n){for(var r=new t,o=0,i=e.length;o=0)return n}else{var r=o.toSetString(e);if(i.call(this._set,r))return this._set[r]}throw new Error('"'+e+'" is not in the set.')},t.prototype.at=function(e){if(e>=0&&er||t==r&&s>=o||i.compareByGeneratedPositionsInflated(e,n)<=0}function o(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}var i=r(4);o.prototype.unsortedForEach=function(e,n){this._array.forEach(e,n)},o.prototype.add=function(e){t(this._last,e)?(this._last=e,this._array.push(e)):(this._sorted=!1,this._array.push(e))},o.prototype.toArray=function(){return this._sorted||(this._array.sort(i.compareByGeneratedPositionsInflated),this._sorted=!0),this._array},n.MappingList=o},function(e,n,r){function t(e){var n=e;return"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,""))),null!=n.sections?new s(n):new o(n)}function o(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=a.getArg(n,"version"),t=a.getArg(n,"sources"),o=a.getArg(n,"names",[]),i=a.getArg(n,"sourceRoot",null),s=a.getArg(n,"sourcesContent",null),u=a.getArg(n,"mappings"),c=a.getArg(n,"file",null);if(r!=this._version)throw new Error("Unsupported version: "+r);t=t.map(String).map(a.normalize).map(function(e){return i&&a.isAbsolute(i)&&a.isAbsolute(e)?a.relative(i,e):e}),this._names=l.fromArray(o.map(String),!0),this._sources=l.fromArray(t,!0),this.sourceRoot=i,this.sourcesContent=s,this._mappings=u,this.file=c}function i(){this.generatedLine=0,this.generatedColumn=0,this.source=null,this.originalLine=null,this.originalColumn=null,this.name=null}function s(e){var n=e;"string"==typeof e&&(n=JSON.parse(e.replace(/^\)\]\}'/,"")));var r=a.getArg(n,"version"),o=a.getArg(n,"sections");if(r!=this._version)throw new Error("Unsupported version: "+r);this._sources=new l,this._names=new l;var i={line:-1,column:0};this._sections=o.map(function(e){if(e.url)throw new Error("Support for url field in sections not implemented.");var n=a.getArg(e,"offset"),r=a.getArg(n,"line"),o=a.getArg(n,"column");if(r=0){var i=this._originalMappings[o];if(void 0===e.column)for(var s=i.originalLine;i&&i.originalLine===s;)t.push({line:a.getArg(i,"generatedLine",null),column:a.getArg(i,"generatedColumn",null),lastColumn:a.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o];else for(var l=i.originalColumn;i&&i.originalLine===n&&i.originalColumn==l;)t.push({line:a.getArg(i,"generatedLine",null),column:a.getArg(i,"generatedColumn",null),lastColumn:a.getArg(i,"lastGeneratedColumn",null)}),i=this._originalMappings[++o]}return t},n.SourceMapConsumer=t,o.prototype=Object.create(t.prototype),o.prototype.consumer=t,o.fromSourceMap=function(e){var n=Object.create(o.prototype),r=n._names=l.fromArray(e._names.toArray(),!0),t=n._sources=l.fromArray(e._sources.toArray(),!0);n.sourceRoot=e._sourceRoot,n.sourcesContent=e._generateSourcesContent(n._sources.toArray(),n.sourceRoot),n.file=e._file;for(var s=e._mappings.toArray().slice(),u=n.__generatedMappings=[],c=n.__originalMappings=[],p=0,h=s.length;p1&&(r.source=d+o[1],d+=o[1],r.originalLine=h+o[2],h=r.originalLine,r.originalLine+=1,r.originalColumn=f+o[3],f=r.originalColumn,o.length>4&&(r.name=m+o[4],m+=o[4])),S.push(r),"number"==typeof r.originalLine&&A.push(r)}g(S,a.compareByGeneratedPositionsDeflated),this.__generatedMappings=S,g(A,a.compareByOriginalPositions),this.__originalMappings=A},o.prototype._findMapping=function(e,n,r,t,o,i){if(e[r]<=0)throw new TypeError("Line must be greater than or equal to 1, got "+e[r]);if(e[t]<0)throw new TypeError("Column must be greater than or equal to 0, got "+e[t]);return u.search(e,n,o,i)},o.prototype.computeColumnSpans=function(){for(var e=0;e=0){var o=this._generatedMappings[r];if(o.generatedLine===n.generatedLine){var i=a.getArg(o,"source",null);null!==i&&(i=this._sources.at(i),null!=this.sourceRoot&&(i=a.join(this.sourceRoot,i)));var s=a.getArg(o,"name",null);return null!==s&&(s=this._names.at(s)),{source:i,line:a.getArg(o,"originalLine",null),column:a.getArg(o,"originalColumn",null),name:s}}}return{source:null,line:null,column:null,name:null}},o.prototype.hasContentsOfAllSources=function(){return!!this.sourcesContent&&(this.sourcesContent.length>=this._sources.size()&&!this.sourcesContent.some(function(e){return null==e}))},o.prototype.sourceContentFor=function(e,n){if(!this.sourcesContent)return null;if(null!=this.sourceRoot&&(e=a.relative(this.sourceRoot,e)),this._sources.has(e))return this.sourcesContent[this._sources.indexOf(e)];var r;if(null!=this.sourceRoot&&(r=a.urlParse(this.sourceRoot))){var t=e.replace(/^file:\/\//,"");if("file"==r.scheme&&this._sources.has(t))return this.sourcesContent[this._sources.indexOf(t)];if((!r.path||"/"==r.path)&&this._sources.has("/"+e))return this.sourcesContent[this._sources.indexOf("/"+e)]}if(n)return null;throw new Error('"'+e+'" is not in the SourceMap.')},o.prototype.generatedPositionFor=function(e){var n=a.getArg(e,"source");if(null!=this.sourceRoot&&(n=a.relative(this.sourceRoot,n)),!this._sources.has(n))return{line:null,column:null,lastColumn:null};n=this._sources.indexOf(n);var r={source:n,originalLine:a.getArg(e,"line"),originalColumn:a.getArg(e,"column")},o=this._findMapping(r,this._originalMappings,"originalLine","originalColumn",a.compareByOriginalPositions,a.getArg(e,"bias",t.GREATEST_LOWER_BOUND));if(o>=0){var i=this._originalMappings[o];if(i.source===r.source)return{line:a.getArg(i,"generatedLine",null),column:a.getArg(i,"generatedColumn",null),lastColumn:a.getArg(i,"lastGeneratedColumn",null)}}return{line:null,column:null,lastColumn:null}},n.BasicSourceMapConsumer=o,s.prototype=Object.create(t.prototype),s.prototype.constructor=t,s.prototype._version=3,Object.defineProperty(s.prototype,"sources",{get:function(){for(var e=[],n=0;n0?t-u>1?r(u,t,o,i,s,a):a==n.LEAST_UPPER_BOUND?t1?r(e,u,o,i,s,a):a==n.LEAST_UPPER_BOUND?u:e<0?-1:e}n.GREATEST_LOWER_BOUND=1,n.LEAST_UPPER_BOUND=2,n.search=function(e,t,o,i){if(0===t.length)return-1;var s=r(-1,t.length,e,t,o,i||n.GREATEST_LOWER_BOUND);if(s<0)return-1;for(;s-1>=0&&0===o(t[s],t[s-1],!0);)--s;return s}},function(e,n){function r(e,n,r){var t=e[n];e[n]=e[r],e[r]=t}function t(e,n){return Math.round(e+Math.random()*(n-e))}function o(e,n,i,s){if(i=0;n--)this.prepend(e[n]);else{if(!e[u]&&"string"!=typeof e)throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+e);this.children.unshift(e)}return this},t.prototype.walk=function(e){for(var n,r=0,t=this.children.length;r0){for(n=[],r=0;r 0 && aGenerated.column >= 0\n\t && !aOriginal && !aSource && !aName) {\n\t // Case 1.\n\t return;\n\t }\n\t else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated\n\t && aOriginal && 'line' in aOriginal && 'column' in aOriginal\n\t && aGenerated.line > 0 && aGenerated.column >= 0\n\t && aOriginal.line > 0 && aOriginal.column >= 0\n\t && aSource) {\n\t // Cases 2 and 3.\n\t return;\n\t }\n\t else {\n\t throw new Error('Invalid mapping: ' + JSON.stringify({\n\t generated: aGenerated,\n\t source: aSource,\n\t original: aOriginal,\n\t name: aName\n\t }));\n\t }\n\t };\n\t\n\t/**\n\t * Serialize the accumulated mappings in to the stream of base 64 VLQs\n\t * specified by the source map format.\n\t */\n\tSourceMapGenerator.prototype._serializeMappings =\n\t function SourceMapGenerator_serializeMappings() {\n\t var previousGeneratedColumn = 0;\n\t var previousGeneratedLine = 1;\n\t var previousOriginalColumn = 0;\n\t var previousOriginalLine = 0;\n\t var previousName = 0;\n\t var previousSource = 0;\n\t var result = '';\n\t var next;\n\t var mapping;\n\t var nameIdx;\n\t var sourceIdx;\n\t\n\t var mappings = this._mappings.toArray();\n\t for (var i = 0, len = mappings.length; i < len; i++) {\n\t mapping = mappings[i];\n\t next = ''\n\t\n\t if (mapping.generatedLine !== previousGeneratedLine) {\n\t previousGeneratedColumn = 0;\n\t while (mapping.generatedLine !== previousGeneratedLine) {\n\t next += ';';\n\t previousGeneratedLine++;\n\t }\n\t }\n\t else {\n\t if (i > 0) {\n\t if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {\n\t continue;\n\t }\n\t next += ',';\n\t }\n\t }\n\t\n\t next += base64VLQ.encode(mapping.generatedColumn\n\t - previousGeneratedColumn);\n\t previousGeneratedColumn = mapping.generatedColumn;\n\t\n\t if (mapping.source != null) {\n\t sourceIdx = this._sources.indexOf(mapping.source);\n\t next += base64VLQ.encode(sourceIdx - previousSource);\n\t previousSource = sourceIdx;\n\t\n\t // lines are stored 0-based in SourceMap spec version 3\n\t next += base64VLQ.encode(mapping.originalLine - 1\n\t - previousOriginalLine);\n\t previousOriginalLine = mapping.originalLine - 1;\n\t\n\t next += base64VLQ.encode(mapping.originalColumn\n\t - previousOriginalColumn);\n\t previousOriginalColumn = mapping.originalColumn;\n\t\n\t if (mapping.name != null) {\n\t nameIdx = this._names.indexOf(mapping.name);\n\t next += base64VLQ.encode(nameIdx - previousName);\n\t previousName = nameIdx;\n\t }\n\t }\n\t\n\t result += next;\n\t }\n\t\n\t return result;\n\t };\n\t\n\tSourceMapGenerator.prototype._generateSourcesContent =\n\t function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {\n\t return aSources.map(function (source) {\n\t if (!this._sourcesContents) {\n\t return null;\n\t }\n\t if (aSourceRoot != null) {\n\t source = util.relative(aSourceRoot, source);\n\t }\n\t var key = util.toSetString(source);\n\t return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)\n\t ? this._sourcesContents[key]\n\t : null;\n\t }, this);\n\t };\n\t\n\t/**\n\t * Externalize the source map.\n\t */\n\tSourceMapGenerator.prototype.toJSON =\n\t function SourceMapGenerator_toJSON() {\n\t var map = {\n\t version: this._version,\n\t sources: this._sources.toArray(),\n\t names: this._names.toArray(),\n\t mappings: this._serializeMappings()\n\t };\n\t if (this._file != null) {\n\t map.file = this._file;\n\t }\n\t if (this._sourceRoot != null) {\n\t map.sourceRoot = this._sourceRoot;\n\t }\n\t if (this._sourcesContents) {\n\t map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);\n\t }\n\t\n\t return map;\n\t };\n\t\n\t/**\n\t * Render the source map being generated to a string.\n\t */\n\tSourceMapGenerator.prototype.toString =\n\t function SourceMapGenerator_toString() {\n\t return JSON.stringify(this.toJSON());\n\t };\n\t\n\texports.SourceMapGenerator = SourceMapGenerator;\n\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t *\n\t * Based on the Base 64 VLQ implementation in Closure Compiler:\n\t * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java\n\t *\n\t * Copyright 2011 The Closure Compiler Authors. All rights reserved.\n\t * Redistribution and use in source and binary forms, with or without\n\t * modification, are permitted provided that the following conditions are\n\t * met:\n\t *\n\t * * Redistributions of source code must retain the above copyright\n\t * notice, this list of conditions and the following disclaimer.\n\t * * Redistributions in binary form must reproduce the above\n\t * copyright notice, this list of conditions and the following\n\t * disclaimer in the documentation and/or other materials provided\n\t * with the distribution.\n\t * * Neither the name of Google Inc. nor the names of its\n\t * contributors may be used to endorse or promote products derived\n\t * from this software without specific prior written permission.\n\t *\n\t * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\t * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n\t * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n\t * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n\t * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n\t * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n\t * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n\t * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n\t * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n\t * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n\t * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\t */\n\t\n\tvar base64 = __webpack_require__(3);\n\t\n\t// A single base 64 digit can contain 6 bits of data. For the base 64 variable\n\t// length quantities we use in the source map spec, the first bit is the sign,\n\t// the next four bits are the actual value, and the 6th bit is the\n\t// continuation bit. The continuation bit tells us whether there are more\n\t// digits in this value following this digit.\n\t//\n\t// Continuation\n\t// | Sign\n\t// | |\n\t// V V\n\t// 101011\n\t\n\tvar VLQ_BASE_SHIFT = 5;\n\t\n\t// binary: 100000\n\tvar VLQ_BASE = 1 << VLQ_BASE_SHIFT;\n\t\n\t// binary: 011111\n\tvar VLQ_BASE_MASK = VLQ_BASE - 1;\n\t\n\t// binary: 100000\n\tvar VLQ_CONTINUATION_BIT = VLQ_BASE;\n\t\n\t/**\n\t * Converts from a two-complement value to a value where the sign bit is\n\t * placed in the least significant bit. For example, as decimals:\n\t * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)\n\t * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)\n\t */\n\tfunction toVLQSigned(aValue) {\n\t return aValue < 0\n\t ? ((-aValue) << 1) + 1\n\t : (aValue << 1) + 0;\n\t}\n\t\n\t/**\n\t * Converts to a two-complement value from a value where the sign bit is\n\t * placed in the least significant bit. For example, as decimals:\n\t * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1\n\t * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2\n\t */\n\tfunction fromVLQSigned(aValue) {\n\t var isNegative = (aValue & 1) === 1;\n\t var shifted = aValue >> 1;\n\t return isNegative\n\t ? -shifted\n\t : shifted;\n\t}\n\t\n\t/**\n\t * Returns the base 64 VLQ encoded value.\n\t */\n\texports.encode = function base64VLQ_encode(aValue) {\n\t var encoded = \"\";\n\t var digit;\n\t\n\t var vlq = toVLQSigned(aValue);\n\t\n\t do {\n\t digit = vlq & VLQ_BASE_MASK;\n\t vlq >>>= VLQ_BASE_SHIFT;\n\t if (vlq > 0) {\n\t // There are still more digits in this value, so we must make sure the\n\t // continuation bit is marked.\n\t digit |= VLQ_CONTINUATION_BIT;\n\t }\n\t encoded += base64.encode(digit);\n\t } while (vlq > 0);\n\t\n\t return encoded;\n\t};\n\t\n\t/**\n\t * Decodes the next base 64 VLQ value from the given string and returns the\n\t * value and the rest of the string via the out parameter.\n\t */\n\texports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {\n\t var strLen = aStr.length;\n\t var result = 0;\n\t var shift = 0;\n\t var continuation, digit;\n\t\n\t do {\n\t if (aIndex >= strLen) {\n\t throw new Error(\"Expected more digits in base 64 VLQ value.\");\n\t }\n\t\n\t digit = base64.decode(aStr.charCodeAt(aIndex++));\n\t if (digit === -1) {\n\t throw new Error(\"Invalid base64 digit: \" + aStr.charAt(aIndex - 1));\n\t }\n\t\n\t continuation = !!(digit & VLQ_CONTINUATION_BIT);\n\t digit &= VLQ_BASE_MASK;\n\t result = result + (digit << shift);\n\t shift += VLQ_BASE_SHIFT;\n\t } while (continuation);\n\t\n\t aOutParam.value = fromVLQSigned(result);\n\t aOutParam.rest = aIndex;\n\t};\n\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\tvar intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\t\n\t/**\n\t * Encode an integer in the range of 0 to 63 to a single base 64 digit.\n\t */\n\texports.encode = function (number) {\n\t if (0 <= number && number < intToCharMap.length) {\n\t return intToCharMap[number];\n\t }\n\t throw new TypeError(\"Must be between 0 and 63: \" + number);\n\t};\n\t\n\t/**\n\t * Decode a single base 64 character code digit to an integer. Returns -1 on\n\t * failure.\n\t */\n\texports.decode = function (charCode) {\n\t var bigA = 65; // 'A'\n\t var bigZ = 90; // 'Z'\n\t\n\t var littleA = 97; // 'a'\n\t var littleZ = 122; // 'z'\n\t\n\t var zero = 48; // '0'\n\t var nine = 57; // '9'\n\t\n\t var plus = 43; // '+'\n\t var slash = 47; // '/'\n\t\n\t var littleOffset = 26;\n\t var numberOffset = 52;\n\t\n\t // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ\n\t if (bigA <= charCode && charCode <= bigZ) {\n\t return (charCode - bigA);\n\t }\n\t\n\t // 26 - 51: abcdefghijklmnopqrstuvwxyz\n\t if (littleA <= charCode && charCode <= littleZ) {\n\t return (charCode - littleA + littleOffset);\n\t }\n\t\n\t // 52 - 61: 0123456789\n\t if (zero <= charCode && charCode <= nine) {\n\t return (charCode - zero + numberOffset);\n\t }\n\t\n\t // 62: +\n\t if (charCode == plus) {\n\t return 62;\n\t }\n\t\n\t // 63: /\n\t if (charCode == slash) {\n\t return 63;\n\t }\n\t\n\t // Invalid base64 digit.\n\t return -1;\n\t};\n\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\t/**\n\t * This is a helper function for getting values from parameter/options\n\t * objects.\n\t *\n\t * @param args The object we are extracting values from\n\t * @param name The name of the property we are getting.\n\t * @param defaultValue An optional value to return if the property is missing\n\t * from the object. If this is not specified and the property is missing, an\n\t * error will be thrown.\n\t */\n\tfunction getArg(aArgs, aName, aDefaultValue) {\n\t if (aName in aArgs) {\n\t return aArgs[aName];\n\t } else if (arguments.length === 3) {\n\t return aDefaultValue;\n\t } else {\n\t throw new Error('\"' + aName + '\" is a required argument.');\n\t }\n\t}\n\texports.getArg = getArg;\n\t\n\tvar urlRegexp = /^(?:([\\w+\\-.]+):)?\\/\\/(?:(\\w+:\\w+)@)?([\\w.]*)(?::(\\d+))?(\\S*)$/;\n\tvar dataUrlRegexp = /^data:.+\\,.+$/;\n\t\n\tfunction urlParse(aUrl) {\n\t var match = aUrl.match(urlRegexp);\n\t if (!match) {\n\t return null;\n\t }\n\t return {\n\t scheme: match[1],\n\t auth: match[2],\n\t host: match[3],\n\t port: match[4],\n\t path: match[5]\n\t };\n\t}\n\texports.urlParse = urlParse;\n\t\n\tfunction urlGenerate(aParsedUrl) {\n\t var url = '';\n\t if (aParsedUrl.scheme) {\n\t url += aParsedUrl.scheme + ':';\n\t }\n\t url += '//';\n\t if (aParsedUrl.auth) {\n\t url += aParsedUrl.auth + '@';\n\t }\n\t if (aParsedUrl.host) {\n\t url += aParsedUrl.host;\n\t }\n\t if (aParsedUrl.port) {\n\t url += \":\" + aParsedUrl.port\n\t }\n\t if (aParsedUrl.path) {\n\t url += aParsedUrl.path;\n\t }\n\t return url;\n\t}\n\texports.urlGenerate = urlGenerate;\n\t\n\t/**\n\t * Normalizes a path, or the path portion of a URL:\n\t *\n\t * - Replaces consecutive slashes with one slash.\n\t * - Removes unnecessary '.' parts.\n\t * - Removes unnecessary '/..' parts.\n\t *\n\t * Based on code in the Node.js 'path' core module.\n\t *\n\t * @param aPath The path or url to normalize.\n\t */\n\tfunction normalize(aPath) {\n\t var path = aPath;\n\t var url = urlParse(aPath);\n\t if (url) {\n\t if (!url.path) {\n\t return aPath;\n\t }\n\t path = url.path;\n\t }\n\t var isAbsolute = exports.isAbsolute(path);\n\t\n\t var parts = path.split(/\\/+/);\n\t for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {\n\t part = parts[i];\n\t if (part === '.') {\n\t parts.splice(i, 1);\n\t } else if (part === '..') {\n\t up++;\n\t } else if (up > 0) {\n\t if (part === '') {\n\t // The first part is blank if the path is absolute. Trying to go\n\t // above the root is a no-op. Therefore we can remove all '..' parts\n\t // directly after the root.\n\t parts.splice(i + 1, up);\n\t up = 0;\n\t } else {\n\t parts.splice(i, 2);\n\t up--;\n\t }\n\t }\n\t }\n\t path = parts.join('/');\n\t\n\t if (path === '') {\n\t path = isAbsolute ? '/' : '.';\n\t }\n\t\n\t if (url) {\n\t url.path = path;\n\t return urlGenerate(url);\n\t }\n\t return path;\n\t}\n\texports.normalize = normalize;\n\t\n\t/**\n\t * Joins two paths/URLs.\n\t *\n\t * @param aRoot The root path or URL.\n\t * @param aPath The path or URL to be joined with the root.\n\t *\n\t * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a\n\t * scheme-relative URL: Then the scheme of aRoot, if any, is prepended\n\t * first.\n\t * - Otherwise aPath is a path. If aRoot is a URL, then its path portion\n\t * is updated with the result and aRoot is returned. Otherwise the result\n\t * is returned.\n\t * - If aPath is absolute, the result is aPath.\n\t * - Otherwise the two paths are joined with a slash.\n\t * - Joining for example 'http://' and 'www.example.com' is also supported.\n\t */\n\tfunction join(aRoot, aPath) {\n\t if (aRoot === \"\") {\n\t aRoot = \".\";\n\t }\n\t if (aPath === \"\") {\n\t aPath = \".\";\n\t }\n\t var aPathUrl = urlParse(aPath);\n\t var aRootUrl = urlParse(aRoot);\n\t if (aRootUrl) {\n\t aRoot = aRootUrl.path || '/';\n\t }\n\t\n\t // `join(foo, '//www.example.org')`\n\t if (aPathUrl && !aPathUrl.scheme) {\n\t if (aRootUrl) {\n\t aPathUrl.scheme = aRootUrl.scheme;\n\t }\n\t return urlGenerate(aPathUrl);\n\t }\n\t\n\t if (aPathUrl || aPath.match(dataUrlRegexp)) {\n\t return aPath;\n\t }\n\t\n\t // `join('http://', 'www.example.com')`\n\t if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {\n\t aRootUrl.host = aPath;\n\t return urlGenerate(aRootUrl);\n\t }\n\t\n\t var joined = aPath.charAt(0) === '/'\n\t ? aPath\n\t : normalize(aRoot.replace(/\\/+$/, '') + '/' + aPath);\n\t\n\t if (aRootUrl) {\n\t aRootUrl.path = joined;\n\t return urlGenerate(aRootUrl);\n\t }\n\t return joined;\n\t}\n\texports.join = join;\n\t\n\texports.isAbsolute = function (aPath) {\n\t return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);\n\t};\n\t\n\t/**\n\t * Make a path relative to a URL or another path.\n\t *\n\t * @param aRoot The root path or URL.\n\t * @param aPath The path or URL to be made relative to aRoot.\n\t */\n\tfunction relative(aRoot, aPath) {\n\t if (aRoot === \"\") {\n\t aRoot = \".\";\n\t }\n\t\n\t aRoot = aRoot.replace(/\\/$/, '');\n\t\n\t // It is possible for the path to be above the root. In this case, simply\n\t // checking whether the root is a prefix of the path won't work. Instead, we\n\t // need to remove components from the root one by one, until either we find\n\t // a prefix that fits, or we run out of components to remove.\n\t var level = 0;\n\t while (aPath.indexOf(aRoot + '/') !== 0) {\n\t var index = aRoot.lastIndexOf(\"/\");\n\t if (index < 0) {\n\t return aPath;\n\t }\n\t\n\t // If the only part of the root that is left is the scheme (i.e. http://,\n\t // file:///, etc.), one or more slashes (/), or simply nothing at all, we\n\t // have exhausted all components, so the path is not relative to the root.\n\t aRoot = aRoot.slice(0, index);\n\t if (aRoot.match(/^([^\\/]+:\\/)?\\/*$/)) {\n\t return aPath;\n\t }\n\t\n\t ++level;\n\t }\n\t\n\t // Make sure we add a \"../\" for each component we removed from the root.\n\t return Array(level + 1).join(\"../\") + aPath.substr(aRoot.length + 1);\n\t}\n\texports.relative = relative;\n\t\n\tvar supportsNullProto = (function () {\n\t var obj = Object.create(null);\n\t return !('__proto__' in obj);\n\t}());\n\t\n\tfunction identity (s) {\n\t return s;\n\t}\n\t\n\t/**\n\t * Because behavior goes wacky when you set `__proto__` on objects, we\n\t * have to prefix all the strings in our set with an arbitrary character.\n\t *\n\t * See https://github.com/mozilla/source-map/pull/31 and\n\t * https://github.com/mozilla/source-map/issues/30\n\t *\n\t * @param String aStr\n\t */\n\tfunction toSetString(aStr) {\n\t if (isProtoString(aStr)) {\n\t return '$' + aStr;\n\t }\n\t\n\t return aStr;\n\t}\n\texports.toSetString = supportsNullProto ? identity : toSetString;\n\t\n\tfunction fromSetString(aStr) {\n\t if (isProtoString(aStr)) {\n\t return aStr.slice(1);\n\t }\n\t\n\t return aStr;\n\t}\n\texports.fromSetString = supportsNullProto ? identity : fromSetString;\n\t\n\tfunction isProtoString(s) {\n\t if (!s) {\n\t return false;\n\t }\n\t\n\t var length = s.length;\n\t\n\t if (length < 9 /* \"__proto__\".length */) {\n\t return false;\n\t }\n\t\n\t if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||\n\t s.charCodeAt(length - 2) !== 95 /* '_' */ ||\n\t s.charCodeAt(length - 3) !== 111 /* 'o' */ ||\n\t s.charCodeAt(length - 4) !== 116 /* 't' */ ||\n\t s.charCodeAt(length - 5) !== 111 /* 'o' */ ||\n\t s.charCodeAt(length - 6) !== 114 /* 'r' */ ||\n\t s.charCodeAt(length - 7) !== 112 /* 'p' */ ||\n\t s.charCodeAt(length - 8) !== 95 /* '_' */ ||\n\t s.charCodeAt(length - 9) !== 95 /* '_' */) {\n\t return false;\n\t }\n\t\n\t for (var i = length - 10; i >= 0; i--) {\n\t if (s.charCodeAt(i) !== 36 /* '$' */) {\n\t return false;\n\t }\n\t }\n\t\n\t return true;\n\t}\n\t\n\t/**\n\t * Comparator between two mappings where the original positions are compared.\n\t *\n\t * Optionally pass in `true` as `onlyCompareGenerated` to consider two\n\t * mappings with the same original source/line/column, but different generated\n\t * line and column the same. Useful when searching for a mapping with a\n\t * stubbed out mapping.\n\t */\n\tfunction compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {\n\t var cmp = mappingA.source - mappingB.source;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalLine - mappingB.originalLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalColumn - mappingB.originalColumn;\n\t if (cmp !== 0 || onlyCompareOriginal) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.generatedLine - mappingB.generatedLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t return mappingA.name - mappingB.name;\n\t}\n\texports.compareByOriginalPositions = compareByOriginalPositions;\n\t\n\t/**\n\t * Comparator between two mappings with deflated source and name indices where\n\t * the generated positions are compared.\n\t *\n\t * Optionally pass in `true` as `onlyCompareGenerated` to consider two\n\t * mappings with the same generated line and column, but different\n\t * source/name/original line and column the same. Useful when searching for a\n\t * mapping with a stubbed out mapping.\n\t */\n\tfunction compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {\n\t var cmp = mappingA.generatedLine - mappingB.generatedLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n\t if (cmp !== 0 || onlyCompareGenerated) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.source - mappingB.source;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalLine - mappingB.originalLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalColumn - mappingB.originalColumn;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t return mappingA.name - mappingB.name;\n\t}\n\texports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;\n\t\n\tfunction strcmp(aStr1, aStr2) {\n\t if (aStr1 === aStr2) {\n\t return 0;\n\t }\n\t\n\t if (aStr1 > aStr2) {\n\t return 1;\n\t }\n\t\n\t return -1;\n\t}\n\t\n\t/**\n\t * Comparator between two mappings with inflated source and name strings where\n\t * the generated positions are compared.\n\t */\n\tfunction compareByGeneratedPositionsInflated(mappingA, mappingB) {\n\t var cmp = mappingA.generatedLine - mappingB.generatedLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = strcmp(mappingA.source, mappingB.source);\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalLine - mappingB.originalLine;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t cmp = mappingA.originalColumn - mappingB.originalColumn;\n\t if (cmp !== 0) {\n\t return cmp;\n\t }\n\t\n\t return strcmp(mappingA.name, mappingB.name);\n\t}\n\texports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;\n\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\tvar util = __webpack_require__(4);\n\tvar has = Object.prototype.hasOwnProperty;\n\tvar hasNativeMap = typeof Map !== \"undefined\";\n\t\n\t/**\n\t * A data structure which is a combination of an array and a set. Adding a new\n\t * member is O(1), testing for membership is O(1), and finding the index of an\n\t * element is O(1). Removing elements from the set is not supported. Only\n\t * strings are supported for membership.\n\t */\n\tfunction ArraySet() {\n\t this._array = [];\n\t this._set = hasNativeMap ? new Map() : Object.create(null);\n\t}\n\t\n\t/**\n\t * Static method for creating ArraySet instances from an existing array.\n\t */\n\tArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {\n\t var set = new ArraySet();\n\t for (var i = 0, len = aArray.length; i < len; i++) {\n\t set.add(aArray[i], aAllowDuplicates);\n\t }\n\t return set;\n\t};\n\t\n\t/**\n\t * Return how many unique items are in this ArraySet. If duplicates have been\n\t * added, than those do not count towards the size.\n\t *\n\t * @returns Number\n\t */\n\tArraySet.prototype.size = function ArraySet_size() {\n\t return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;\n\t};\n\t\n\t/**\n\t * Add the given string to this set.\n\t *\n\t * @param String aStr\n\t */\n\tArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {\n\t var sStr = hasNativeMap ? aStr : util.toSetString(aStr);\n\t var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);\n\t var idx = this._array.length;\n\t if (!isDuplicate || aAllowDuplicates) {\n\t this._array.push(aStr);\n\t }\n\t if (!isDuplicate) {\n\t if (hasNativeMap) {\n\t this._set.set(aStr, idx);\n\t } else {\n\t this._set[sStr] = idx;\n\t }\n\t }\n\t};\n\t\n\t/**\n\t * Is the given string a member of this set?\n\t *\n\t * @param String aStr\n\t */\n\tArraySet.prototype.has = function ArraySet_has(aStr) {\n\t if (hasNativeMap) {\n\t return this._set.has(aStr);\n\t } else {\n\t var sStr = util.toSetString(aStr);\n\t return has.call(this._set, sStr);\n\t }\n\t};\n\t\n\t/**\n\t * What is the index of the given string in the array?\n\t *\n\t * @param String aStr\n\t */\n\tArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {\n\t if (hasNativeMap) {\n\t var idx = this._set.get(aStr);\n\t if (idx >= 0) {\n\t return idx;\n\t }\n\t } else {\n\t var sStr = util.toSetString(aStr);\n\t if (has.call(this._set, sStr)) {\n\t return this._set[sStr];\n\t }\n\t }\n\t\n\t throw new Error('\"' + aStr + '\" is not in the set.');\n\t};\n\t\n\t/**\n\t * What is the element at the given index?\n\t *\n\t * @param Number aIdx\n\t */\n\tArraySet.prototype.at = function ArraySet_at(aIdx) {\n\t if (aIdx >= 0 && aIdx < this._array.length) {\n\t return this._array[aIdx];\n\t }\n\t throw new Error('No element indexed by ' + aIdx);\n\t};\n\t\n\t/**\n\t * Returns the array representation of this set (which has the proper indices\n\t * indicated by indexOf). Note that this is a copy of the internal array used\n\t * for storing the members so that no one can mess with internal state.\n\t */\n\tArraySet.prototype.toArray = function ArraySet_toArray() {\n\t return this._array.slice();\n\t};\n\t\n\texports.ArraySet = ArraySet;\n\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2014 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\tvar util = __webpack_require__(4);\n\t\n\t/**\n\t * Determine whether mappingB is after mappingA with respect to generated\n\t * position.\n\t */\n\tfunction generatedPositionAfter(mappingA, mappingB) {\n\t // Optimized for most common case\n\t var lineA = mappingA.generatedLine;\n\t var lineB = mappingB.generatedLine;\n\t var columnA = mappingA.generatedColumn;\n\t var columnB = mappingB.generatedColumn;\n\t return lineB > lineA || lineB == lineA && columnB >= columnA ||\n\t util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;\n\t}\n\t\n\t/**\n\t * A data structure to provide a sorted view of accumulated mappings in a\n\t * performance conscious manner. It trades a neglibable overhead in general\n\t * case for a large speedup in case of mappings being added in order.\n\t */\n\tfunction MappingList() {\n\t this._array = [];\n\t this._sorted = true;\n\t // Serves as infimum\n\t this._last = {generatedLine: -1, generatedColumn: 0};\n\t}\n\t\n\t/**\n\t * Iterate through internal items. This method takes the same arguments that\n\t * `Array.prototype.forEach` takes.\n\t *\n\t * NOTE: The order of the mappings is NOT guaranteed.\n\t */\n\tMappingList.prototype.unsortedForEach =\n\t function MappingList_forEach(aCallback, aThisArg) {\n\t this._array.forEach(aCallback, aThisArg);\n\t };\n\t\n\t/**\n\t * Add the given source mapping.\n\t *\n\t * @param Object aMapping\n\t */\n\tMappingList.prototype.add = function MappingList_add(aMapping) {\n\t if (generatedPositionAfter(this._last, aMapping)) {\n\t this._last = aMapping;\n\t this._array.push(aMapping);\n\t } else {\n\t this._sorted = false;\n\t this._array.push(aMapping);\n\t }\n\t};\n\t\n\t/**\n\t * Returns the flat, sorted array of mappings. The mappings are sorted by\n\t * generated position.\n\t *\n\t * WARNING: This method returns internal data without copying, for\n\t * performance. The return value must NOT be mutated, and should be treated as\n\t * an immutable borrow. If you want to take ownership, you must make your own\n\t * copy.\n\t */\n\tMappingList.prototype.toArray = function MappingList_toArray() {\n\t if (!this._sorted) {\n\t this._array.sort(util.compareByGeneratedPositionsInflated);\n\t this._sorted = true;\n\t }\n\t return this._array;\n\t};\n\t\n\texports.MappingList = MappingList;\n\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\tvar util = __webpack_require__(4);\n\tvar binarySearch = __webpack_require__(8);\n\tvar ArraySet = __webpack_require__(5).ArraySet;\n\tvar base64VLQ = __webpack_require__(2);\n\tvar quickSort = __webpack_require__(9).quickSort;\n\t\n\tfunction SourceMapConsumer(aSourceMap) {\n\t var sourceMap = aSourceMap;\n\t if (typeof aSourceMap === 'string') {\n\t sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n\t }\n\t\n\t return sourceMap.sections != null\n\t ? new IndexedSourceMapConsumer(sourceMap)\n\t : new BasicSourceMapConsumer(sourceMap);\n\t}\n\t\n\tSourceMapConsumer.fromSourceMap = function(aSourceMap) {\n\t return BasicSourceMapConsumer.fromSourceMap(aSourceMap);\n\t}\n\t\n\t/**\n\t * The version of the source mapping spec that we are consuming.\n\t */\n\tSourceMapConsumer.prototype._version = 3;\n\t\n\t// `__generatedMappings` and `__originalMappings` are arrays that hold the\n\t// parsed mapping coordinates from the source map's \"mappings\" attribute. They\n\t// are lazily instantiated, accessed via the `_generatedMappings` and\n\t// `_originalMappings` getters respectively, and we only parse the mappings\n\t// and create these arrays once queried for a source location. We jump through\n\t// these hoops because there can be many thousands of mappings, and parsing\n\t// them is expensive, so we only want to do it if we must.\n\t//\n\t// Each object in the arrays is of the form:\n\t//\n\t// {\n\t// generatedLine: The line number in the generated code,\n\t// generatedColumn: The column number in the generated code,\n\t// source: The path to the original source file that generated this\n\t// chunk of code,\n\t// originalLine: The line number in the original source that\n\t// corresponds to this chunk of generated code,\n\t// originalColumn: The column number in the original source that\n\t// corresponds to this chunk of generated code,\n\t// name: The name of the original symbol which generated this chunk of\n\t// code.\n\t// }\n\t//\n\t// All properties except for `generatedLine` and `generatedColumn` can be\n\t// `null`.\n\t//\n\t// `_generatedMappings` is ordered by the generated positions.\n\t//\n\t// `_originalMappings` is ordered by the original positions.\n\t\n\tSourceMapConsumer.prototype.__generatedMappings = null;\n\tObject.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {\n\t get: function () {\n\t if (!this.__generatedMappings) {\n\t this._parseMappings(this._mappings, this.sourceRoot);\n\t }\n\t\n\t return this.__generatedMappings;\n\t }\n\t});\n\t\n\tSourceMapConsumer.prototype.__originalMappings = null;\n\tObject.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {\n\t get: function () {\n\t if (!this.__originalMappings) {\n\t this._parseMappings(this._mappings, this.sourceRoot);\n\t }\n\t\n\t return this.__originalMappings;\n\t }\n\t});\n\t\n\tSourceMapConsumer.prototype._charIsMappingSeparator =\n\t function SourceMapConsumer_charIsMappingSeparator(aStr, index) {\n\t var c = aStr.charAt(index);\n\t return c === \";\" || c === \",\";\n\t };\n\t\n\t/**\n\t * Parse the mappings in a string in to a data structure which we can easily\n\t * query (the ordered arrays in the `this.__generatedMappings` and\n\t * `this.__originalMappings` properties).\n\t */\n\tSourceMapConsumer.prototype._parseMappings =\n\t function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n\t throw new Error(\"Subclasses must implement _parseMappings\");\n\t };\n\t\n\tSourceMapConsumer.GENERATED_ORDER = 1;\n\tSourceMapConsumer.ORIGINAL_ORDER = 2;\n\t\n\tSourceMapConsumer.GREATEST_LOWER_BOUND = 1;\n\tSourceMapConsumer.LEAST_UPPER_BOUND = 2;\n\t\n\t/**\n\t * Iterate over each mapping between an original source/line/column and a\n\t * generated line/column in this source map.\n\t *\n\t * @param Function aCallback\n\t * The function that is called with each mapping.\n\t * @param Object aContext\n\t * Optional. If specified, this object will be the value of `this` every\n\t * time that `aCallback` is called.\n\t * @param aOrder\n\t * Either `SourceMapConsumer.GENERATED_ORDER` or\n\t * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to\n\t * iterate over the mappings sorted by the generated file's line/column\n\t * order or the original's source/line/column order, respectively. Defaults to\n\t * `SourceMapConsumer.GENERATED_ORDER`.\n\t */\n\tSourceMapConsumer.prototype.eachMapping =\n\t function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {\n\t var context = aContext || null;\n\t var order = aOrder || SourceMapConsumer.GENERATED_ORDER;\n\t\n\t var mappings;\n\t switch (order) {\n\t case SourceMapConsumer.GENERATED_ORDER:\n\t mappings = this._generatedMappings;\n\t break;\n\t case SourceMapConsumer.ORIGINAL_ORDER:\n\t mappings = this._originalMappings;\n\t break;\n\t default:\n\t throw new Error(\"Unknown order of iteration.\");\n\t }\n\t\n\t var sourceRoot = this.sourceRoot;\n\t mappings.map(function (mapping) {\n\t var source = mapping.source === null ? null : this._sources.at(mapping.source);\n\t if (source != null && sourceRoot != null) {\n\t source = util.join(sourceRoot, source);\n\t }\n\t return {\n\t source: source,\n\t generatedLine: mapping.generatedLine,\n\t generatedColumn: mapping.generatedColumn,\n\t originalLine: mapping.originalLine,\n\t originalColumn: mapping.originalColumn,\n\t name: mapping.name === null ? null : this._names.at(mapping.name)\n\t };\n\t }, this).forEach(aCallback, context);\n\t };\n\t\n\t/**\n\t * Returns all generated line and column information for the original source,\n\t * line, and column provided. If no column is provided, returns all mappings\n\t * corresponding to a either the line we are searching for or the next\n\t * closest line that has any mappings. Otherwise, returns all mappings\n\t * corresponding to the given line and either the column we are searching for\n\t * or the next closest column that has any offsets.\n\t *\n\t * The only argument is an object with the following properties:\n\t *\n\t * - source: The filename of the original source.\n\t * - line: The line number in the original source.\n\t * - column: Optional. the column number in the original source.\n\t *\n\t * and an array of objects is returned, each with the following properties:\n\t *\n\t * - line: The line number in the generated source, or null.\n\t * - column: The column number in the generated source, or null.\n\t */\n\tSourceMapConsumer.prototype.allGeneratedPositionsFor =\n\t function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {\n\t var line = util.getArg(aArgs, 'line');\n\t\n\t // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping\n\t // returns the index of the closest mapping less than the needle. By\n\t // setting needle.originalColumn to 0, we thus find the last mapping for\n\t // the given line, provided such a mapping exists.\n\t var needle = {\n\t source: util.getArg(aArgs, 'source'),\n\t originalLine: line,\n\t originalColumn: util.getArg(aArgs, 'column', 0)\n\t };\n\t\n\t if (this.sourceRoot != null) {\n\t needle.source = util.relative(this.sourceRoot, needle.source);\n\t }\n\t if (!this._sources.has(needle.source)) {\n\t return [];\n\t }\n\t needle.source = this._sources.indexOf(needle.source);\n\t\n\t var mappings = [];\n\t\n\t var index = this._findMapping(needle,\n\t this._originalMappings,\n\t \"originalLine\",\n\t \"originalColumn\",\n\t util.compareByOriginalPositions,\n\t binarySearch.LEAST_UPPER_BOUND);\n\t if (index >= 0) {\n\t var mapping = this._originalMappings[index];\n\t\n\t if (aArgs.column === undefined) {\n\t var originalLine = mapping.originalLine;\n\t\n\t // Iterate until either we run out of mappings, or we run into\n\t // a mapping for a different line than the one we found. Since\n\t // mappings are sorted, this is guaranteed to find all mappings for\n\t // the line we found.\n\t while (mapping && mapping.originalLine === originalLine) {\n\t mappings.push({\n\t line: util.getArg(mapping, 'generatedLine', null),\n\t column: util.getArg(mapping, 'generatedColumn', null),\n\t lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n\t });\n\t\n\t mapping = this._originalMappings[++index];\n\t }\n\t } else {\n\t var originalColumn = mapping.originalColumn;\n\t\n\t // Iterate until either we run out of mappings, or we run into\n\t // a mapping for a different line than the one we were searching for.\n\t // Since mappings are sorted, this is guaranteed to find all mappings for\n\t // the line we are searching for.\n\t while (mapping &&\n\t mapping.originalLine === line &&\n\t mapping.originalColumn == originalColumn) {\n\t mappings.push({\n\t line: util.getArg(mapping, 'generatedLine', null),\n\t column: util.getArg(mapping, 'generatedColumn', null),\n\t lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n\t });\n\t\n\t mapping = this._originalMappings[++index];\n\t }\n\t }\n\t }\n\t\n\t return mappings;\n\t };\n\t\n\texports.SourceMapConsumer = SourceMapConsumer;\n\t\n\t/**\n\t * A BasicSourceMapConsumer instance represents a parsed source map which we can\n\t * query for information about the original file positions by giving it a file\n\t * position in the generated source.\n\t *\n\t * The only parameter is the raw source map (either as a JSON string, or\n\t * already parsed to an object). According to the spec, source maps have the\n\t * following attributes:\n\t *\n\t * - version: Which version of the source map spec this map is following.\n\t * - sources: An array of URLs to the original source files.\n\t * - names: An array of identifiers which can be referrenced by individual mappings.\n\t * - sourceRoot: Optional. The URL root from which all sources are relative.\n\t * - sourcesContent: Optional. An array of contents of the original source files.\n\t * - mappings: A string of base64 VLQs which contain the actual mappings.\n\t * - file: Optional. The generated file this source map is associated with.\n\t *\n\t * Here is an example source map, taken from the source map spec[0]:\n\t *\n\t * {\n\t * version : 3,\n\t * file: \"out.js\",\n\t * sourceRoot : \"\",\n\t * sources: [\"foo.js\", \"bar.js\"],\n\t * names: [\"src\", \"maps\", \"are\", \"fun\"],\n\t * mappings: \"AA,AB;;ABCDE;\"\n\t * }\n\t *\n\t * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#\n\t */\n\tfunction BasicSourceMapConsumer(aSourceMap) {\n\t var sourceMap = aSourceMap;\n\t if (typeof aSourceMap === 'string') {\n\t sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n\t }\n\t\n\t var version = util.getArg(sourceMap, 'version');\n\t var sources = util.getArg(sourceMap, 'sources');\n\t // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which\n\t // requires the array) to play nice here.\n\t var names = util.getArg(sourceMap, 'names', []);\n\t var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);\n\t var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);\n\t var mappings = util.getArg(sourceMap, 'mappings');\n\t var file = util.getArg(sourceMap, 'file', null);\n\t\n\t // Once again, Sass deviates from the spec and supplies the version as a\n\t // string rather than a number, so we use loose equality checking here.\n\t if (version != this._version) {\n\t throw new Error('Unsupported version: ' + version);\n\t }\n\t\n\t sources = sources\n\t .map(String)\n\t // Some source maps produce relative source paths like \"./foo.js\" instead of\n\t // \"foo.js\". Normalize these first so that future comparisons will succeed.\n\t // See bugzil.la/1090768.\n\t .map(util.normalize)\n\t // Always ensure that absolute sources are internally stored relative to\n\t // the source root, if the source root is absolute. Not doing this would\n\t // be particularly problematic when the source root is a prefix of the\n\t // source (valid, but why??). See github issue #199 and bugzil.la/1188982.\n\t .map(function (source) {\n\t return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)\n\t ? util.relative(sourceRoot, source)\n\t : source;\n\t });\n\t\n\t // Pass `true` below to allow duplicate names and sources. While source maps\n\t // are intended to be compressed and deduplicated, the TypeScript compiler\n\t // sometimes generates source maps with duplicates in them. See Github issue\n\t // #72 and bugzil.la/889492.\n\t this._names = ArraySet.fromArray(names.map(String), true);\n\t this._sources = ArraySet.fromArray(sources, true);\n\t\n\t this.sourceRoot = sourceRoot;\n\t this.sourcesContent = sourcesContent;\n\t this._mappings = mappings;\n\t this.file = file;\n\t}\n\t\n\tBasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);\n\tBasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;\n\t\n\t/**\n\t * Create a BasicSourceMapConsumer from a SourceMapGenerator.\n\t *\n\t * @param SourceMapGenerator aSourceMap\n\t * The source map that will be consumed.\n\t * @returns BasicSourceMapConsumer\n\t */\n\tBasicSourceMapConsumer.fromSourceMap =\n\t function SourceMapConsumer_fromSourceMap(aSourceMap) {\n\t var smc = Object.create(BasicSourceMapConsumer.prototype);\n\t\n\t var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);\n\t var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);\n\t smc.sourceRoot = aSourceMap._sourceRoot;\n\t smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),\n\t smc.sourceRoot);\n\t smc.file = aSourceMap._file;\n\t\n\t // Because we are modifying the entries (by converting string sources and\n\t // names to indices into the sources and names ArraySets), we have to make\n\t // a copy of the entry or else bad things happen. Shared mutable state\n\t // strikes again! See github issue #191.\n\t\n\t var generatedMappings = aSourceMap._mappings.toArray().slice();\n\t var destGeneratedMappings = smc.__generatedMappings = [];\n\t var destOriginalMappings = smc.__originalMappings = [];\n\t\n\t for (var i = 0, length = generatedMappings.length; i < length; i++) {\n\t var srcMapping = generatedMappings[i];\n\t var destMapping = new Mapping;\n\t destMapping.generatedLine = srcMapping.generatedLine;\n\t destMapping.generatedColumn = srcMapping.generatedColumn;\n\t\n\t if (srcMapping.source) {\n\t destMapping.source = sources.indexOf(srcMapping.source);\n\t destMapping.originalLine = srcMapping.originalLine;\n\t destMapping.originalColumn = srcMapping.originalColumn;\n\t\n\t if (srcMapping.name) {\n\t destMapping.name = names.indexOf(srcMapping.name);\n\t }\n\t\n\t destOriginalMappings.push(destMapping);\n\t }\n\t\n\t destGeneratedMappings.push(destMapping);\n\t }\n\t\n\t quickSort(smc.__originalMappings, util.compareByOriginalPositions);\n\t\n\t return smc;\n\t };\n\t\n\t/**\n\t * The version of the source mapping spec that we are consuming.\n\t */\n\tBasicSourceMapConsumer.prototype._version = 3;\n\t\n\t/**\n\t * The list of original sources.\n\t */\n\tObject.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {\n\t get: function () {\n\t return this._sources.toArray().map(function (s) {\n\t return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;\n\t }, this);\n\t }\n\t});\n\t\n\t/**\n\t * Provide the JIT with a nice shape / hidden class.\n\t */\n\tfunction Mapping() {\n\t this.generatedLine = 0;\n\t this.generatedColumn = 0;\n\t this.source = null;\n\t this.originalLine = null;\n\t this.originalColumn = null;\n\t this.name = null;\n\t}\n\t\n\t/**\n\t * Parse the mappings in a string in to a data structure which we can easily\n\t * query (the ordered arrays in the `this.__generatedMappings` and\n\t * `this.__originalMappings` properties).\n\t */\n\tBasicSourceMapConsumer.prototype._parseMappings =\n\t function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n\t var generatedLine = 1;\n\t var previousGeneratedColumn = 0;\n\t var previousOriginalLine = 0;\n\t var previousOriginalColumn = 0;\n\t var previousSource = 0;\n\t var previousName = 0;\n\t var length = aStr.length;\n\t var index = 0;\n\t var cachedSegments = {};\n\t var temp = {};\n\t var originalMappings = [];\n\t var generatedMappings = [];\n\t var mapping, str, segment, end, value;\n\t\n\t while (index < length) {\n\t if (aStr.charAt(index) === ';') {\n\t generatedLine++;\n\t index++;\n\t previousGeneratedColumn = 0;\n\t }\n\t else if (aStr.charAt(index) === ',') {\n\t index++;\n\t }\n\t else {\n\t mapping = new Mapping();\n\t mapping.generatedLine = generatedLine;\n\t\n\t // Because each offset is encoded relative to the previous one,\n\t // many segments often have the same encoding. We can exploit this\n\t // fact by caching the parsed variable length fields of each segment,\n\t // allowing us to avoid a second parse if we encounter the same\n\t // segment again.\n\t for (end = index; end < length; end++) {\n\t if (this._charIsMappingSeparator(aStr, end)) {\n\t break;\n\t }\n\t }\n\t str = aStr.slice(index, end);\n\t\n\t segment = cachedSegments[str];\n\t if (segment) {\n\t index += str.length;\n\t } else {\n\t segment = [];\n\t while (index < end) {\n\t base64VLQ.decode(aStr, index, temp);\n\t value = temp.value;\n\t index = temp.rest;\n\t segment.push(value);\n\t }\n\t\n\t if (segment.length === 2) {\n\t throw new Error('Found a source, but no line and column');\n\t }\n\t\n\t if (segment.length === 3) {\n\t throw new Error('Found a source and line, but no column');\n\t }\n\t\n\t cachedSegments[str] = segment;\n\t }\n\t\n\t // Generated column.\n\t mapping.generatedColumn = previousGeneratedColumn + segment[0];\n\t previousGeneratedColumn = mapping.generatedColumn;\n\t\n\t if (segment.length > 1) {\n\t // Original source.\n\t mapping.source = previousSource + segment[1];\n\t previousSource += segment[1];\n\t\n\t // Original line.\n\t mapping.originalLine = previousOriginalLine + segment[2];\n\t previousOriginalLine = mapping.originalLine;\n\t // Lines are stored 0-based\n\t mapping.originalLine += 1;\n\t\n\t // Original column.\n\t mapping.originalColumn = previousOriginalColumn + segment[3];\n\t previousOriginalColumn = mapping.originalColumn;\n\t\n\t if (segment.length > 4) {\n\t // Original name.\n\t mapping.name = previousName + segment[4];\n\t previousName += segment[4];\n\t }\n\t }\n\t\n\t generatedMappings.push(mapping);\n\t if (typeof mapping.originalLine === 'number') {\n\t originalMappings.push(mapping);\n\t }\n\t }\n\t }\n\t\n\t quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);\n\t this.__generatedMappings = generatedMappings;\n\t\n\t quickSort(originalMappings, util.compareByOriginalPositions);\n\t this.__originalMappings = originalMappings;\n\t };\n\t\n\t/**\n\t * Find the mapping that best matches the hypothetical \"needle\" mapping that\n\t * we are searching for in the given \"haystack\" of mappings.\n\t */\n\tBasicSourceMapConsumer.prototype._findMapping =\n\t function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,\n\t aColumnName, aComparator, aBias) {\n\t // To return the position we are searching for, we must first find the\n\t // mapping for the given position and then return the opposite position it\n\t // points to. Because the mappings are sorted, we can use binary search to\n\t // find the best mapping.\n\t\n\t if (aNeedle[aLineName] <= 0) {\n\t throw new TypeError('Line must be greater than or equal to 1, got '\n\t + aNeedle[aLineName]);\n\t }\n\t if (aNeedle[aColumnName] < 0) {\n\t throw new TypeError('Column must be greater than or equal to 0, got '\n\t + aNeedle[aColumnName]);\n\t }\n\t\n\t return binarySearch.search(aNeedle, aMappings, aComparator, aBias);\n\t };\n\t\n\t/**\n\t * Compute the last column for each generated mapping. The last column is\n\t * inclusive.\n\t */\n\tBasicSourceMapConsumer.prototype.computeColumnSpans =\n\t function SourceMapConsumer_computeColumnSpans() {\n\t for (var index = 0; index < this._generatedMappings.length; ++index) {\n\t var mapping = this._generatedMappings[index];\n\t\n\t // Mappings do not contain a field for the last generated columnt. We\n\t // can come up with an optimistic estimate, however, by assuming that\n\t // mappings are contiguous (i.e. given two consecutive mappings, the\n\t // first mapping ends where the second one starts).\n\t if (index + 1 < this._generatedMappings.length) {\n\t var nextMapping = this._generatedMappings[index + 1];\n\t\n\t if (mapping.generatedLine === nextMapping.generatedLine) {\n\t mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;\n\t continue;\n\t }\n\t }\n\t\n\t // The last mapping for each line spans the entire line.\n\t mapping.lastGeneratedColumn = Infinity;\n\t }\n\t };\n\t\n\t/**\n\t * Returns the original source, line, and column information for the generated\n\t * source's line and column positions provided. The only argument is an object\n\t * with the following properties:\n\t *\n\t * - line: The line number in the generated source.\n\t * - column: The column number in the generated source.\n\t * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or\n\t * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the\n\t * closest element that is smaller than or greater than the one we are\n\t * searching for, respectively, if the exact element cannot be found.\n\t * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.\n\t *\n\t * and an object is returned with the following properties:\n\t *\n\t * - source: The original source file, or null.\n\t * - line: The line number in the original source, or null.\n\t * - column: The column number in the original source, or null.\n\t * - name: The original identifier, or null.\n\t */\n\tBasicSourceMapConsumer.prototype.originalPositionFor =\n\t function SourceMapConsumer_originalPositionFor(aArgs) {\n\t var needle = {\n\t generatedLine: util.getArg(aArgs, 'line'),\n\t generatedColumn: util.getArg(aArgs, 'column')\n\t };\n\t\n\t var index = this._findMapping(\n\t needle,\n\t this._generatedMappings,\n\t \"generatedLine\",\n\t \"generatedColumn\",\n\t util.compareByGeneratedPositionsDeflated,\n\t util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)\n\t );\n\t\n\t if (index >= 0) {\n\t var mapping = this._generatedMappings[index];\n\t\n\t if (mapping.generatedLine === needle.generatedLine) {\n\t var source = util.getArg(mapping, 'source', null);\n\t if (source !== null) {\n\t source = this._sources.at(source);\n\t if (this.sourceRoot != null) {\n\t source = util.join(this.sourceRoot, source);\n\t }\n\t }\n\t var name = util.getArg(mapping, 'name', null);\n\t if (name !== null) {\n\t name = this._names.at(name);\n\t }\n\t return {\n\t source: source,\n\t line: util.getArg(mapping, 'originalLine', null),\n\t column: util.getArg(mapping, 'originalColumn', null),\n\t name: name\n\t };\n\t }\n\t }\n\t\n\t return {\n\t source: null,\n\t line: null,\n\t column: null,\n\t name: null\n\t };\n\t };\n\t\n\t/**\n\t * Return true if we have the source content for every source in the source\n\t * map, false otherwise.\n\t */\n\tBasicSourceMapConsumer.prototype.hasContentsOfAllSources =\n\t function BasicSourceMapConsumer_hasContentsOfAllSources() {\n\t if (!this.sourcesContent) {\n\t return false;\n\t }\n\t return this.sourcesContent.length >= this._sources.size() &&\n\t !this.sourcesContent.some(function (sc) { return sc == null; });\n\t };\n\t\n\t/**\n\t * Returns the original source content. The only argument is the url of the\n\t * original source file. Returns null if no original source content is\n\t * available.\n\t */\n\tBasicSourceMapConsumer.prototype.sourceContentFor =\n\t function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {\n\t if (!this.sourcesContent) {\n\t return null;\n\t }\n\t\n\t if (this.sourceRoot != null) {\n\t aSource = util.relative(this.sourceRoot, aSource);\n\t }\n\t\n\t if (this._sources.has(aSource)) {\n\t return this.sourcesContent[this._sources.indexOf(aSource)];\n\t }\n\t\n\t var url;\n\t if (this.sourceRoot != null\n\t && (url = util.urlParse(this.sourceRoot))) {\n\t // XXX: file:// URIs and absolute paths lead to unexpected behavior for\n\t // many users. We can help them out when they expect file:// URIs to\n\t // behave like it would if they were running a local HTTP server. See\n\t // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.\n\t var fileUriAbsPath = aSource.replace(/^file:\\/\\//, \"\");\n\t if (url.scheme == \"file\"\n\t && this._sources.has(fileUriAbsPath)) {\n\t return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]\n\t }\n\t\n\t if ((!url.path || url.path == \"/\")\n\t && this._sources.has(\"/\" + aSource)) {\n\t return this.sourcesContent[this._sources.indexOf(\"/\" + aSource)];\n\t }\n\t }\n\t\n\t // This function is used recursively from\n\t // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we\n\t // don't want to throw if we can't find the source - we just want to\n\t // return null, so we provide a flag to exit gracefully.\n\t if (nullOnMissing) {\n\t return null;\n\t }\n\t else {\n\t throw new Error('\"' + aSource + '\" is not in the SourceMap.');\n\t }\n\t };\n\t\n\t/**\n\t * Returns the generated line and column information for the original source,\n\t * line, and column positions provided. The only argument is an object with\n\t * the following properties:\n\t *\n\t * - source: The filename of the original source.\n\t * - line: The line number in the original source.\n\t * - column: The column number in the original source.\n\t * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or\n\t * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the\n\t * closest element that is smaller than or greater than the one we are\n\t * searching for, respectively, if the exact element cannot be found.\n\t * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.\n\t *\n\t * and an object is returned with the following properties:\n\t *\n\t * - line: The line number in the generated source, or null.\n\t * - column: The column number in the generated source, or null.\n\t */\n\tBasicSourceMapConsumer.prototype.generatedPositionFor =\n\t function SourceMapConsumer_generatedPositionFor(aArgs) {\n\t var source = util.getArg(aArgs, 'source');\n\t if (this.sourceRoot != null) {\n\t source = util.relative(this.sourceRoot, source);\n\t }\n\t if (!this._sources.has(source)) {\n\t return {\n\t line: null,\n\t column: null,\n\t lastColumn: null\n\t };\n\t }\n\t source = this._sources.indexOf(source);\n\t\n\t var needle = {\n\t source: source,\n\t originalLine: util.getArg(aArgs, 'line'),\n\t originalColumn: util.getArg(aArgs, 'column')\n\t };\n\t\n\t var index = this._findMapping(\n\t needle,\n\t this._originalMappings,\n\t \"originalLine\",\n\t \"originalColumn\",\n\t util.compareByOriginalPositions,\n\t util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)\n\t );\n\t\n\t if (index >= 0) {\n\t var mapping = this._originalMappings[index];\n\t\n\t if (mapping.source === needle.source) {\n\t return {\n\t line: util.getArg(mapping, 'generatedLine', null),\n\t column: util.getArg(mapping, 'generatedColumn', null),\n\t lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n\t };\n\t }\n\t }\n\t\n\t return {\n\t line: null,\n\t column: null,\n\t lastColumn: null\n\t };\n\t };\n\t\n\texports.BasicSourceMapConsumer = BasicSourceMapConsumer;\n\t\n\t/**\n\t * An IndexedSourceMapConsumer instance represents a parsed source map which\n\t * we can query for information. It differs from BasicSourceMapConsumer in\n\t * that it takes \"indexed\" source maps (i.e. ones with a \"sections\" field) as\n\t * input.\n\t *\n\t * The only parameter is a raw source map (either as a JSON string, or already\n\t * parsed to an object). According to the spec for indexed source maps, they\n\t * have the following attributes:\n\t *\n\t * - version: Which version of the source map spec this map is following.\n\t * - file: Optional. The generated file this source map is associated with.\n\t * - sections: A list of section definitions.\n\t *\n\t * Each value under the \"sections\" field has two fields:\n\t * - offset: The offset into the original specified at which this section\n\t * begins to apply, defined as an object with a \"line\" and \"column\"\n\t * field.\n\t * - map: A source map definition. This source map could also be indexed,\n\t * but doesn't have to be.\n\t *\n\t * Instead of the \"map\" field, it's also possible to have a \"url\" field\n\t * specifying a URL to retrieve a source map from, but that's currently\n\t * unsupported.\n\t *\n\t * Here's an example source map, taken from the source map spec[0], but\n\t * modified to omit a section which uses the \"url\" field.\n\t *\n\t * {\n\t * version : 3,\n\t * file: \"app.js\",\n\t * sections: [{\n\t * offset: {line:100, column:10},\n\t * map: {\n\t * version : 3,\n\t * file: \"section.js\",\n\t * sources: [\"foo.js\", \"bar.js\"],\n\t * names: [\"src\", \"maps\", \"are\", \"fun\"],\n\t * mappings: \"AAAA,E;;ABCDE;\"\n\t * }\n\t * }],\n\t * }\n\t *\n\t * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt\n\t */\n\tfunction IndexedSourceMapConsumer(aSourceMap) {\n\t var sourceMap = aSourceMap;\n\t if (typeof aSourceMap === 'string') {\n\t sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n\t }\n\t\n\t var version = util.getArg(sourceMap, 'version');\n\t var sections = util.getArg(sourceMap, 'sections');\n\t\n\t if (version != this._version) {\n\t throw new Error('Unsupported version: ' + version);\n\t }\n\t\n\t this._sources = new ArraySet();\n\t this._names = new ArraySet();\n\t\n\t var lastOffset = {\n\t line: -1,\n\t column: 0\n\t };\n\t this._sections = sections.map(function (s) {\n\t if (s.url) {\n\t // The url field will require support for asynchronicity.\n\t // See https://github.com/mozilla/source-map/issues/16\n\t throw new Error('Support for url field in sections not implemented.');\n\t }\n\t var offset = util.getArg(s, 'offset');\n\t var offsetLine = util.getArg(offset, 'line');\n\t var offsetColumn = util.getArg(offset, 'column');\n\t\n\t if (offsetLine < lastOffset.line ||\n\t (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {\n\t throw new Error('Section offsets must be ordered and non-overlapping.');\n\t }\n\t lastOffset = offset;\n\t\n\t return {\n\t generatedOffset: {\n\t // The offset fields are 0-based, but we use 1-based indices when\n\t // encoding/decoding from VLQ.\n\t generatedLine: offsetLine + 1,\n\t generatedColumn: offsetColumn + 1\n\t },\n\t consumer: new SourceMapConsumer(util.getArg(s, 'map'))\n\t }\n\t });\n\t}\n\t\n\tIndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);\n\tIndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;\n\t\n\t/**\n\t * The version of the source mapping spec that we are consuming.\n\t */\n\tIndexedSourceMapConsumer.prototype._version = 3;\n\t\n\t/**\n\t * The list of original sources.\n\t */\n\tObject.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {\n\t get: function () {\n\t var sources = [];\n\t for (var i = 0; i < this._sections.length; i++) {\n\t for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {\n\t sources.push(this._sections[i].consumer.sources[j]);\n\t }\n\t }\n\t return sources;\n\t }\n\t});\n\t\n\t/**\n\t * Returns the original source, line, and column information for the generated\n\t * source's line and column positions provided. The only argument is an object\n\t * with the following properties:\n\t *\n\t * - line: The line number in the generated source.\n\t * - column: The column number in the generated source.\n\t *\n\t * and an object is returned with the following properties:\n\t *\n\t * - source: The original source file, or null.\n\t * - line: The line number in the original source, or null.\n\t * - column: The column number in the original source, or null.\n\t * - name: The original identifier, or null.\n\t */\n\tIndexedSourceMapConsumer.prototype.originalPositionFor =\n\t function IndexedSourceMapConsumer_originalPositionFor(aArgs) {\n\t var needle = {\n\t generatedLine: util.getArg(aArgs, 'line'),\n\t generatedColumn: util.getArg(aArgs, 'column')\n\t };\n\t\n\t // Find the section containing the generated position we're trying to map\n\t // to an original position.\n\t var sectionIndex = binarySearch.search(needle, this._sections,\n\t function(needle, section) {\n\t var cmp = needle.generatedLine - section.generatedOffset.generatedLine;\n\t if (cmp) {\n\t return cmp;\n\t }\n\t\n\t return (needle.generatedColumn -\n\t section.generatedOffset.generatedColumn);\n\t });\n\t var section = this._sections[sectionIndex];\n\t\n\t if (!section) {\n\t return {\n\t source: null,\n\t line: null,\n\t column: null,\n\t name: null\n\t };\n\t }\n\t\n\t return section.consumer.originalPositionFor({\n\t line: needle.generatedLine -\n\t (section.generatedOffset.generatedLine - 1),\n\t column: needle.generatedColumn -\n\t (section.generatedOffset.generatedLine === needle.generatedLine\n\t ? section.generatedOffset.generatedColumn - 1\n\t : 0),\n\t bias: aArgs.bias\n\t });\n\t };\n\t\n\t/**\n\t * Return true if we have the source content for every source in the source\n\t * map, false otherwise.\n\t */\n\tIndexedSourceMapConsumer.prototype.hasContentsOfAllSources =\n\t function IndexedSourceMapConsumer_hasContentsOfAllSources() {\n\t return this._sections.every(function (s) {\n\t return s.consumer.hasContentsOfAllSources();\n\t });\n\t };\n\t\n\t/**\n\t * Returns the original source content. The only argument is the url of the\n\t * original source file. Returns null if no original source content is\n\t * available.\n\t */\n\tIndexedSourceMapConsumer.prototype.sourceContentFor =\n\t function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {\n\t for (var i = 0; i < this._sections.length; i++) {\n\t var section = this._sections[i];\n\t\n\t var content = section.consumer.sourceContentFor(aSource, true);\n\t if (content) {\n\t return content;\n\t }\n\t }\n\t if (nullOnMissing) {\n\t return null;\n\t }\n\t else {\n\t throw new Error('\"' + aSource + '\" is not in the SourceMap.');\n\t }\n\t };\n\t\n\t/**\n\t * Returns the generated line and column information for the original source,\n\t * line, and column positions provided. The only argument is an object with\n\t * the following properties:\n\t *\n\t * - source: The filename of the original source.\n\t * - line: The line number in the original source.\n\t * - column: The column number in the original source.\n\t *\n\t * and an object is returned with the following properties:\n\t *\n\t * - line: The line number in the generated source, or null.\n\t * - column: The column number in the generated source, or null.\n\t */\n\tIndexedSourceMapConsumer.prototype.generatedPositionFor =\n\t function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {\n\t for (var i = 0; i < this._sections.length; i++) {\n\t var section = this._sections[i];\n\t\n\t // Only consider this section if the requested source is in the list of\n\t // sources of the consumer.\n\t if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {\n\t continue;\n\t }\n\t var generatedPosition = section.consumer.generatedPositionFor(aArgs);\n\t if (generatedPosition) {\n\t var ret = {\n\t line: generatedPosition.line +\n\t (section.generatedOffset.generatedLine - 1),\n\t column: generatedPosition.column +\n\t (section.generatedOffset.generatedLine === generatedPosition.line\n\t ? section.generatedOffset.generatedColumn - 1\n\t : 0)\n\t };\n\t return ret;\n\t }\n\t }\n\t\n\t return {\n\t line: null,\n\t column: null\n\t };\n\t };\n\t\n\t/**\n\t * Parse the mappings in a string in to a data structure which we can easily\n\t * query (the ordered arrays in the `this.__generatedMappings` and\n\t * `this.__originalMappings` properties).\n\t */\n\tIndexedSourceMapConsumer.prototype._parseMappings =\n\t function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n\t this.__generatedMappings = [];\n\t this.__originalMappings = [];\n\t for (var i = 0; i < this._sections.length; i++) {\n\t var section = this._sections[i];\n\t var sectionMappings = section.consumer._generatedMappings;\n\t for (var j = 0; j < sectionMappings.length; j++) {\n\t var mapping = sectionMappings[j];\n\t\n\t var source = section.consumer._sources.at(mapping.source);\n\t if (section.consumer.sourceRoot !== null) {\n\t source = util.join(section.consumer.sourceRoot, source);\n\t }\n\t this._sources.add(source);\n\t source = this._sources.indexOf(source);\n\t\n\t var name = section.consumer._names.at(mapping.name);\n\t this._names.add(name);\n\t name = this._names.indexOf(name);\n\t\n\t // The mappings coming from the consumer for the section have\n\t // generated positions relative to the start of the section, so we\n\t // need to offset them to be relative to the start of the concatenated\n\t // generated file.\n\t var adjustedMapping = {\n\t source: source,\n\t generatedLine: mapping.generatedLine +\n\t (section.generatedOffset.generatedLine - 1),\n\t generatedColumn: mapping.generatedColumn +\n\t (section.generatedOffset.generatedLine === mapping.generatedLine\n\t ? section.generatedOffset.generatedColumn - 1\n\t : 0),\n\t originalLine: mapping.originalLine,\n\t originalColumn: mapping.originalColumn,\n\t name: name\n\t };\n\t\n\t this.__generatedMappings.push(adjustedMapping);\n\t if (typeof adjustedMapping.originalLine === 'number') {\n\t this.__originalMappings.push(adjustedMapping);\n\t }\n\t }\n\t }\n\t\n\t quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);\n\t quickSort(this.__originalMappings, util.compareByOriginalPositions);\n\t };\n\t\n\texports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;\n\n\n/***/ }),\n/* 8 */\n/***/ (function(module, exports) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\texports.GREATEST_LOWER_BOUND = 1;\n\texports.LEAST_UPPER_BOUND = 2;\n\t\n\t/**\n\t * Recursive implementation of binary search.\n\t *\n\t * @param aLow Indices here and lower do not contain the needle.\n\t * @param aHigh Indices here and higher do not contain the needle.\n\t * @param aNeedle The element being searched for.\n\t * @param aHaystack The non-empty array being searched.\n\t * @param aCompare Function which takes two elements and returns -1, 0, or 1.\n\t * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or\n\t * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the\n\t * closest element that is smaller than or greater than the one we are\n\t * searching for, respectively, if the exact element cannot be found.\n\t */\n\tfunction recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {\n\t // This function terminates when one of the following is true:\n\t //\n\t // 1. We find the exact element we are looking for.\n\t //\n\t // 2. We did not find the exact element, but we can return the index of\n\t // the next-closest element.\n\t //\n\t // 3. We did not find the exact element, and there is no next-closest\n\t // element than the one we are searching for, so we return -1.\n\t var mid = Math.floor((aHigh - aLow) / 2) + aLow;\n\t var cmp = aCompare(aNeedle, aHaystack[mid], true);\n\t if (cmp === 0) {\n\t // Found the element we are looking for.\n\t return mid;\n\t }\n\t else if (cmp > 0) {\n\t // Our needle is greater than aHaystack[mid].\n\t if (aHigh - mid > 1) {\n\t // The element is in the upper half.\n\t return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);\n\t }\n\t\n\t // The exact needle element was not found in this haystack. Determine if\n\t // we are in termination case (3) or (2) and return the appropriate thing.\n\t if (aBias == exports.LEAST_UPPER_BOUND) {\n\t return aHigh < aHaystack.length ? aHigh : -1;\n\t } else {\n\t return mid;\n\t }\n\t }\n\t else {\n\t // Our needle is less than aHaystack[mid].\n\t if (mid - aLow > 1) {\n\t // The element is in the lower half.\n\t return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);\n\t }\n\t\n\t // we are in termination case (3) or (2) and return the appropriate thing.\n\t if (aBias == exports.LEAST_UPPER_BOUND) {\n\t return mid;\n\t } else {\n\t return aLow < 0 ? -1 : aLow;\n\t }\n\t }\n\t}\n\t\n\t/**\n\t * This is an implementation of binary search which will always try and return\n\t * the index of the closest element if there is no exact hit. This is because\n\t * mappings between original and generated line/col pairs are single points,\n\t * and there is an implicit region between each of them, so a miss just means\n\t * that you aren't on the very start of a region.\n\t *\n\t * @param aNeedle The element you are looking for.\n\t * @param aHaystack The array that is being searched.\n\t * @param aCompare A function which takes the needle and an element in the\n\t * array and returns -1, 0, or 1 depending on whether the needle is less\n\t * than, equal to, or greater than the element, respectively.\n\t * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or\n\t * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the\n\t * closest element that is smaller than or greater than the one we are\n\t * searching for, respectively, if the exact element cannot be found.\n\t * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.\n\t */\n\texports.search = function search(aNeedle, aHaystack, aCompare, aBias) {\n\t if (aHaystack.length === 0) {\n\t return -1;\n\t }\n\t\n\t var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,\n\t aCompare, aBias || exports.GREATEST_LOWER_BOUND);\n\t if (index < 0) {\n\t return -1;\n\t }\n\t\n\t // We have found either the exact element, or the next-closest element than\n\t // the one we are searching for. However, there may be more than one such\n\t // element. Make sure we always return the smallest of these.\n\t while (index - 1 >= 0) {\n\t if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {\n\t break;\n\t }\n\t --index;\n\t }\n\t\n\t return index;\n\t};\n\n\n/***/ }),\n/* 9 */\n/***/ (function(module, exports) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\t// It turns out that some (most?) JavaScript engines don't self-host\n\t// `Array.prototype.sort`. This makes sense because C++ will likely remain\n\t// faster than JS when doing raw CPU-intensive sorting. However, when using a\n\t// custom comparator function, calling back and forth between the VM's C++ and\n\t// JIT'd JS is rather slow *and* loses JIT type information, resulting in\n\t// worse generated code for the comparator function than would be optimal. In\n\t// fact, when sorting with a comparator, these costs outweigh the benefits of\n\t// sorting in C++. By using our own JS-implemented Quick Sort (below), we get\n\t// a ~3500ms mean speed-up in `bench/bench.html`.\n\t\n\t/**\n\t * Swap the elements indexed by `x` and `y` in the array `ary`.\n\t *\n\t * @param {Array} ary\n\t * The array.\n\t * @param {Number} x\n\t * The index of the first item.\n\t * @param {Number} y\n\t * The index of the second item.\n\t */\n\tfunction swap(ary, x, y) {\n\t var temp = ary[x];\n\t ary[x] = ary[y];\n\t ary[y] = temp;\n\t}\n\t\n\t/**\n\t * Returns a random integer within the range `low .. high` inclusive.\n\t *\n\t * @param {Number} low\n\t * The lower bound on the range.\n\t * @param {Number} high\n\t * The upper bound on the range.\n\t */\n\tfunction randomIntInRange(low, high) {\n\t return Math.round(low + (Math.random() * (high - low)));\n\t}\n\t\n\t/**\n\t * The Quick Sort algorithm.\n\t *\n\t * @param {Array} ary\n\t * An array to sort.\n\t * @param {function} comparator\n\t * Function to use to compare two items.\n\t * @param {Number} p\n\t * Start index of the array\n\t * @param {Number} r\n\t * End index of the array\n\t */\n\tfunction doQuickSort(ary, comparator, p, r) {\n\t // If our lower bound is less than our upper bound, we (1) partition the\n\t // array into two pieces and (2) recurse on each half. If it is not, this is\n\t // the empty array and our base case.\n\t\n\t if (p < r) {\n\t // (1) Partitioning.\n\t //\n\t // The partitioning chooses a pivot between `p` and `r` and moves all\n\t // elements that are less than or equal to the pivot to the before it, and\n\t // all the elements that are greater than it after it. The effect is that\n\t // once partition is done, the pivot is in the exact place it will be when\n\t // the array is put in sorted order, and it will not need to be moved\n\t // again. This runs in O(n) time.\n\t\n\t // Always choose a random pivot so that an input array which is reverse\n\t // sorted does not cause O(n^2) running time.\n\t var pivotIndex = randomIntInRange(p, r);\n\t var i = p - 1;\n\t\n\t swap(ary, pivotIndex, r);\n\t var pivot = ary[r];\n\t\n\t // Immediately after `j` is incremented in this loop, the following hold\n\t // true:\n\t //\n\t // * Every element in `ary[p .. i]` is less than or equal to the pivot.\n\t //\n\t // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.\n\t for (var j = p; j < r; j++) {\n\t if (comparator(ary[j], pivot) <= 0) {\n\t i += 1;\n\t swap(ary, i, j);\n\t }\n\t }\n\t\n\t swap(ary, i + 1, j);\n\t var q = i + 1;\n\t\n\t // (2) Recurse on each half.\n\t\n\t doQuickSort(ary, comparator, p, q - 1);\n\t doQuickSort(ary, comparator, q + 1, r);\n\t }\n\t}\n\t\n\t/**\n\t * Sort the given array in-place with the given comparator function.\n\t *\n\t * @param {Array} ary\n\t * An array to sort.\n\t * @param {function} comparator\n\t * Function to use to compare two items.\n\t */\n\texports.quickSort = function (ary, comparator) {\n\t doQuickSort(ary, comparator, 0, ary.length - 1);\n\t};\n\n\n/***/ }),\n/* 10 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\t/* -*- Mode: js; js-indent-level: 2; -*- */\n\t/*\n\t * Copyright 2011 Mozilla Foundation and contributors\n\t * Licensed under the New BSD license. See LICENSE or:\n\t * http://opensource.org/licenses/BSD-3-Clause\n\t */\n\t\n\tvar SourceMapGenerator = __webpack_require__(1).SourceMapGenerator;\n\tvar util = __webpack_require__(4);\n\t\n\t// Matches a Windows-style `\\r\\n` newline or a `\\n` newline used by all other\n\t// operating systems these days (capturing the result).\n\tvar REGEX_NEWLINE = /(\\r?\\n)/;\n\t\n\t// Newline character code for charCodeAt() comparisons\n\tvar NEWLINE_CODE = 10;\n\t\n\t// Private symbol for identifying `SourceNode`s when multiple versions of\n\t// the source-map library are loaded. This MUST NOT CHANGE across\n\t// versions!\n\tvar isSourceNode = \"$$$isSourceNode$$$\";\n\t\n\t/**\n\t * SourceNodes provide a way to abstract over interpolating/concatenating\n\t * snippets of generated JavaScript source code while maintaining the line and\n\t * column information associated with the original source code.\n\t *\n\t * @param aLine The original line number.\n\t * @param aColumn The original column number.\n\t * @param aSource The original source's filename.\n\t * @param aChunks Optional. An array of strings which are snippets of\n\t * generated JS, or other SourceNodes.\n\t * @param aName The original identifier.\n\t */\n\tfunction SourceNode(aLine, aColumn, aSource, aChunks, aName) {\n\t this.children = [];\n\t this.sourceContents = {};\n\t this.line = aLine == null ? null : aLine;\n\t this.column = aColumn == null ? null : aColumn;\n\t this.source = aSource == null ? null : aSource;\n\t this.name = aName == null ? null : aName;\n\t this[isSourceNode] = true;\n\t if (aChunks != null) this.add(aChunks);\n\t}\n\t\n\t/**\n\t * Creates a SourceNode from generated code and a SourceMapConsumer.\n\t *\n\t * @param aGeneratedCode The generated code\n\t * @param aSourceMapConsumer The SourceMap for the generated code\n\t * @param aRelativePath Optional. The path that relative sources in the\n\t * SourceMapConsumer should be relative to.\n\t */\n\tSourceNode.fromStringWithSourceMap =\n\t function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {\n\t // The SourceNode we want to fill with the generated code\n\t // and the SourceMap\n\t var node = new SourceNode();\n\t\n\t // All even indices of this array are one line of the generated code,\n\t // while all odd indices are the newlines between two adjacent lines\n\t // (since `REGEX_NEWLINE` captures its match).\n\t // Processed fragments are accessed by calling `shiftNextLine`.\n\t var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);\n\t var remainingLinesIndex = 0;\n\t var shiftNextLine = function() {\n\t var lineContents = getNextLine();\n\t // The last line of a file might not have a newline.\n\t var newLine = getNextLine() || \"\";\n\t return lineContents + newLine;\n\t\n\t function getNextLine() {\n\t return remainingLinesIndex < remainingLines.length ?\n\t remainingLines[remainingLinesIndex++] : undefined;\n\t }\n\t };\n\t\n\t // We need to remember the position of \"remainingLines\"\n\t var lastGeneratedLine = 1, lastGeneratedColumn = 0;\n\t\n\t // The generate SourceNodes we need a code range.\n\t // To extract it current and last mapping is used.\n\t // Here we store the last mapping.\n\t var lastMapping = null;\n\t\n\t aSourceMapConsumer.eachMapping(function (mapping) {\n\t if (lastMapping !== null) {\n\t // We add the code from \"lastMapping\" to \"mapping\":\n\t // First check if there is a new line in between.\n\t if (lastGeneratedLine < mapping.generatedLine) {\n\t // Associate first line with \"lastMapping\"\n\t addMappingWithCode(lastMapping, shiftNextLine());\n\t lastGeneratedLine++;\n\t lastGeneratedColumn = 0;\n\t // The remaining code is added without mapping\n\t } else {\n\t // There is no new line in between.\n\t // Associate the code between \"lastGeneratedColumn\" and\n\t // \"mapping.generatedColumn\" with \"lastMapping\"\n\t var nextLine = remainingLines[remainingLinesIndex];\n\t var code = nextLine.substr(0, mapping.generatedColumn -\n\t lastGeneratedColumn);\n\t remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -\n\t lastGeneratedColumn);\n\t lastGeneratedColumn = mapping.generatedColumn;\n\t addMappingWithCode(lastMapping, code);\n\t // No more remaining code, continue\n\t lastMapping = mapping;\n\t return;\n\t }\n\t }\n\t // We add the generated code until the first mapping\n\t // to the SourceNode without any mapping.\n\t // Each line is added as separate string.\n\t while (lastGeneratedLine < mapping.generatedLine) {\n\t node.add(shiftNextLine());\n\t lastGeneratedLine++;\n\t }\n\t if (lastGeneratedColumn < mapping.generatedColumn) {\n\t var nextLine = remainingLines[remainingLinesIndex];\n\t node.add(nextLine.substr(0, mapping.generatedColumn));\n\t remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);\n\t lastGeneratedColumn = mapping.generatedColumn;\n\t }\n\t lastMapping = mapping;\n\t }, this);\n\t // We have processed all mappings.\n\t if (remainingLinesIndex < remainingLines.length) {\n\t if (lastMapping) {\n\t // Associate the remaining code in the current line with \"lastMapping\"\n\t addMappingWithCode(lastMapping, shiftNextLine());\n\t }\n\t // and add the remaining lines without any mapping\n\t node.add(remainingLines.splice(remainingLinesIndex).join(\"\"));\n\t }\n\t\n\t // Copy sourcesContent into SourceNode\n\t aSourceMapConsumer.sources.forEach(function (sourceFile) {\n\t var content = aSourceMapConsumer.sourceContentFor(sourceFile);\n\t if (content != null) {\n\t if (aRelativePath != null) {\n\t sourceFile = util.join(aRelativePath, sourceFile);\n\t }\n\t node.setSourceContent(sourceFile, content);\n\t }\n\t });\n\t\n\t return node;\n\t\n\t function addMappingWithCode(mapping, code) {\n\t if (mapping === null || mapping.source === undefined) {\n\t node.add(code);\n\t } else {\n\t var source = aRelativePath\n\t ? util.join(aRelativePath, mapping.source)\n\t : mapping.source;\n\t node.add(new SourceNode(mapping.originalLine,\n\t mapping.originalColumn,\n\t source,\n\t code,\n\t mapping.name));\n\t }\n\t }\n\t };\n\t\n\t/**\n\t * Add a chunk of generated JS to this source node.\n\t *\n\t * @param aChunk A string snippet of generated JS code, another instance of\n\t * SourceNode, or an array where each member is one of those things.\n\t */\n\tSourceNode.prototype.add = function SourceNode_add(aChunk) {\n\t if (Array.isArray(aChunk)) {\n\t aChunk.forEach(function (chunk) {\n\t this.add(chunk);\n\t }, this);\n\t }\n\t else if (aChunk[isSourceNode] || typeof aChunk === \"string\") {\n\t if (aChunk) {\n\t this.children.push(aChunk);\n\t }\n\t }\n\t else {\n\t throw new TypeError(\n\t \"Expected a SourceNode, string, or an array of SourceNodes and strings. Got \" + aChunk\n\t );\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Add a chunk of generated JS to the beginning of this source node.\n\t *\n\t * @param aChunk A string snippet of generated JS code, another instance of\n\t * SourceNode, or an array where each member is one of those things.\n\t */\n\tSourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {\n\t if (Array.isArray(aChunk)) {\n\t for (var i = aChunk.length-1; i >= 0; i--) {\n\t this.prepend(aChunk[i]);\n\t }\n\t }\n\t else if (aChunk[isSourceNode] || typeof aChunk === \"string\") {\n\t this.children.unshift(aChunk);\n\t }\n\t else {\n\t throw new TypeError(\n\t \"Expected a SourceNode, string, or an array of SourceNodes and strings. Got \" + aChunk\n\t );\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Walk over the tree of JS snippets in this node and its children. The\n\t * walking function is called once for each snippet of JS and is passed that\n\t * snippet and the its original associated source's line/column location.\n\t *\n\t * @param aFn The traversal function.\n\t */\n\tSourceNode.prototype.walk = function SourceNode_walk(aFn) {\n\t var chunk;\n\t for (var i = 0, len = this.children.length; i < len; i++) {\n\t chunk = this.children[i];\n\t if (chunk[isSourceNode]) {\n\t chunk.walk(aFn);\n\t }\n\t else {\n\t if (chunk !== '') {\n\t aFn(chunk, { source: this.source,\n\t line: this.line,\n\t column: this.column,\n\t name: this.name });\n\t }\n\t }\n\t }\n\t};\n\t\n\t/**\n\t * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between\n\t * each of `this.children`.\n\t *\n\t * @param aSep The separator.\n\t */\n\tSourceNode.prototype.join = function SourceNode_join(aSep) {\n\t var newChildren;\n\t var i;\n\t var len = this.children.length;\n\t if (len > 0) {\n\t newChildren = [];\n\t for (i = 0; i < len-1; i++) {\n\t newChildren.push(this.children[i]);\n\t newChildren.push(aSep);\n\t }\n\t newChildren.push(this.children[i]);\n\t this.children = newChildren;\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Call String.prototype.replace on the very right-most source snippet. Useful\n\t * for trimming whitespace from the end of a source node, etc.\n\t *\n\t * @param aPattern The pattern to replace.\n\t * @param aReplacement The thing to replace the pattern with.\n\t */\n\tSourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {\n\t var lastChild = this.children[this.children.length - 1];\n\t if (lastChild[isSourceNode]) {\n\t lastChild.replaceRight(aPattern, aReplacement);\n\t }\n\t else if (typeof lastChild === 'string') {\n\t this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);\n\t }\n\t else {\n\t this.children.push(''.replace(aPattern, aReplacement));\n\t }\n\t return this;\n\t};\n\t\n\t/**\n\t * Set the source content for a source file. This will be added to the SourceMapGenerator\n\t * in the sourcesContent field.\n\t *\n\t * @param aSourceFile The filename of the source file\n\t * @param aSourceContent The content of the source file\n\t */\n\tSourceNode.prototype.setSourceContent =\n\t function SourceNode_setSourceContent(aSourceFile, aSourceContent) {\n\t this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;\n\t };\n\t\n\t/**\n\t * Walk over the tree of SourceNodes. The walking function is called for each\n\t * source file content and is passed the filename and source content.\n\t *\n\t * @param aFn The traversal function.\n\t */\n\tSourceNode.prototype.walkSourceContents =\n\t function SourceNode_walkSourceContents(aFn) {\n\t for (var i = 0, len = this.children.length; i < len; i++) {\n\t if (this.children[i][isSourceNode]) {\n\t this.children[i].walkSourceContents(aFn);\n\t }\n\t }\n\t\n\t var sources = Object.keys(this.sourceContents);\n\t for (var i = 0, len = sources.length; i < len; i++) {\n\t aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);\n\t }\n\t };\n\t\n\t/**\n\t * Return the string representation of this source node. Walks over the tree\n\t * and concatenates all the various snippets together to one string.\n\t */\n\tSourceNode.prototype.toString = function SourceNode_toString() {\n\t var str = \"\";\n\t this.walk(function (chunk) {\n\t str += chunk;\n\t });\n\t return str;\n\t};\n\t\n\t/**\n\t * Returns the string representation of this source node along with a source\n\t * map.\n\t */\n\tSourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {\n\t var generated = {\n\t code: \"\",\n\t line: 1,\n\t column: 0\n\t };\n\t var map = new SourceMapGenerator(aArgs);\n\t var sourceMappingActive = false;\n\t var lastOriginalSource = null;\n\t var lastOriginalLine = null;\n\t var lastOriginalColumn = null;\n\t var lastOriginalName = null;\n\t this.walk(function (chunk, original) {\n\t generated.code += chunk;\n\t if (original.source !== null\n\t && original.line !== null\n\t && original.column !== null) {\n\t if(lastOriginalSource !== original.source\n\t || lastOriginalLine !== original.line\n\t || lastOriginalColumn !== original.column\n\t || lastOriginalName !== original.name) {\n\t map.addMapping({\n\t source: original.source,\n\t original: {\n\t line: original.line,\n\t column: original.column\n\t },\n\t generated: {\n\t line: generated.line,\n\t column: generated.column\n\t },\n\t name: original.name\n\t });\n\t }\n\t lastOriginalSource = original.source;\n\t lastOriginalLine = original.line;\n\t lastOriginalColumn = original.column;\n\t lastOriginalName = original.name;\n\t sourceMappingActive = true;\n\t } else if (sourceMappingActive) {\n\t map.addMapping({\n\t generated: {\n\t line: generated.line,\n\t column: generated.column\n\t }\n\t });\n\t lastOriginalSource = null;\n\t sourceMappingActive = false;\n\t }\n\t for (var idx = 0, length = chunk.length; idx < length; idx++) {\n\t if (chunk.charCodeAt(idx) === NEWLINE_CODE) {\n\t generated.line++;\n\t generated.column = 0;\n\t // Mappings end at eol\n\t if (idx + 1 === length) {\n\t lastOriginalSource = null;\n\t sourceMappingActive = false;\n\t } else if (sourceMappingActive) {\n\t map.addMapping({\n\t source: original.source,\n\t original: {\n\t line: original.line,\n\t column: original.column\n\t },\n\t generated: {\n\t line: generated.line,\n\t column: generated.column\n\t },\n\t name: original.name\n\t });\n\t }\n\t } else {\n\t generated.column++;\n\t }\n\t }\n\t });\n\t this.walkSourceContents(function (sourceFile, sourceContent) {\n\t map.setSourceContent(sourceFile, sourceContent);\n\t });\n\t\n\t return { code: generated.code, map: map };\n\t};\n\t\n\texports.SourceNode = SourceNode;\n\n\n/***/ })\n/******/ ])\n});\n;\n\n\n// WEBPACK FOOTER //\n// source-map.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 42c329f865e32e011afb","/*\n * Copyright 2009-2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE.txt or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\nexports.SourceMapGenerator = require('./lib/source-map-generator').SourceMapGenerator;\nexports.SourceMapConsumer = require('./lib/source-map-consumer').SourceMapConsumer;\nexports.SourceNode = require('./lib/source-node').SourceNode;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./source-map.js\n// module id = 0\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar base64VLQ = require('./base64-vlq');\nvar util = require('./util');\nvar ArraySet = require('./array-set').ArraySet;\nvar MappingList = require('./mapping-list').MappingList;\n\n/**\n * An instance of the SourceMapGenerator represents a source map which is\n * being built incrementally. You may pass an object with the following\n * properties:\n *\n * - file: The filename of the generated source.\n * - sourceRoot: A root for all relative URLs in this source map.\n */\nfunction SourceMapGenerator(aArgs) {\n if (!aArgs) {\n aArgs = {};\n }\n this._file = util.getArg(aArgs, 'file', null);\n this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);\n this._skipValidation = util.getArg(aArgs, 'skipValidation', false);\n this._sources = new ArraySet();\n this._names = new ArraySet();\n this._mappings = new MappingList();\n this._sourcesContents = null;\n}\n\nSourceMapGenerator.prototype._version = 3;\n\n/**\n * Creates a new SourceMapGenerator based on a SourceMapConsumer\n *\n * @param aSourceMapConsumer The SourceMap.\n */\nSourceMapGenerator.fromSourceMap =\n function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {\n var sourceRoot = aSourceMapConsumer.sourceRoot;\n var generator = new SourceMapGenerator({\n file: aSourceMapConsumer.file,\n sourceRoot: sourceRoot\n });\n aSourceMapConsumer.eachMapping(function (mapping) {\n var newMapping = {\n generated: {\n line: mapping.generatedLine,\n column: mapping.generatedColumn\n }\n };\n\n if (mapping.source != null) {\n newMapping.source = mapping.source;\n if (sourceRoot != null) {\n newMapping.source = util.relative(sourceRoot, newMapping.source);\n }\n\n newMapping.original = {\n line: mapping.originalLine,\n column: mapping.originalColumn\n };\n\n if (mapping.name != null) {\n newMapping.name = mapping.name;\n }\n }\n\n generator.addMapping(newMapping);\n });\n aSourceMapConsumer.sources.forEach(function (sourceFile) {\n var content = aSourceMapConsumer.sourceContentFor(sourceFile);\n if (content != null) {\n generator.setSourceContent(sourceFile, content);\n }\n });\n return generator;\n };\n\n/**\n * Add a single mapping from original source line and column to the generated\n * source's line and column for this source map being created. The mapping\n * object should have the following properties:\n *\n * - generated: An object with the generated line and column positions.\n * - original: An object with the original line and column positions.\n * - source: The original source file (relative to the sourceRoot).\n * - name: An optional original token name for this mapping.\n */\nSourceMapGenerator.prototype.addMapping =\n function SourceMapGenerator_addMapping(aArgs) {\n var generated = util.getArg(aArgs, 'generated');\n var original = util.getArg(aArgs, 'original', null);\n var source = util.getArg(aArgs, 'source', null);\n var name = util.getArg(aArgs, 'name', null);\n\n if (!this._skipValidation) {\n this._validateMapping(generated, original, source, name);\n }\n\n if (source != null) {\n source = String(source);\n if (!this._sources.has(source)) {\n this._sources.add(source);\n }\n }\n\n if (name != null) {\n name = String(name);\n if (!this._names.has(name)) {\n this._names.add(name);\n }\n }\n\n this._mappings.add({\n generatedLine: generated.line,\n generatedColumn: generated.column,\n originalLine: original != null && original.line,\n originalColumn: original != null && original.column,\n source: source,\n name: name\n });\n };\n\n/**\n * Set the source content for a source file.\n */\nSourceMapGenerator.prototype.setSourceContent =\n function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {\n var source = aSourceFile;\n if (this._sourceRoot != null) {\n source = util.relative(this._sourceRoot, source);\n }\n\n if (aSourceContent != null) {\n // Add the source content to the _sourcesContents map.\n // Create a new _sourcesContents map if the property is null.\n if (!this._sourcesContents) {\n this._sourcesContents = Object.create(null);\n }\n this._sourcesContents[util.toSetString(source)] = aSourceContent;\n } else if (this._sourcesContents) {\n // Remove the source file from the _sourcesContents map.\n // If the _sourcesContents map is empty, set the property to null.\n delete this._sourcesContents[util.toSetString(source)];\n if (Object.keys(this._sourcesContents).length === 0) {\n this._sourcesContents = null;\n }\n }\n };\n\n/**\n * Applies the mappings of a sub-source-map for a specific source file to the\n * source map being generated. Each mapping to the supplied source file is\n * rewritten using the supplied source map. Note: The resolution for the\n * resulting mappings is the minimium of this map and the supplied map.\n *\n * @param aSourceMapConsumer The source map to be applied.\n * @param aSourceFile Optional. The filename of the source file.\n * If omitted, SourceMapConsumer's file property will be used.\n * @param aSourceMapPath Optional. The dirname of the path to the source map\n * to be applied. If relative, it is relative to the SourceMapConsumer.\n * This parameter is needed when the two source maps aren't in the same\n * directory, and the source map to be applied contains relative source\n * paths. If so, those relative source paths need to be rewritten\n * relative to the SourceMapGenerator.\n */\nSourceMapGenerator.prototype.applySourceMap =\n function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {\n var sourceFile = aSourceFile;\n // If aSourceFile is omitted, we will use the file property of the SourceMap\n if (aSourceFile == null) {\n if (aSourceMapConsumer.file == null) {\n throw new Error(\n 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +\n 'or the source map\\'s \"file\" property. Both were omitted.'\n );\n }\n sourceFile = aSourceMapConsumer.file;\n }\n var sourceRoot = this._sourceRoot;\n // Make \"sourceFile\" relative if an absolute Url is passed.\n if (sourceRoot != null) {\n sourceFile = util.relative(sourceRoot, sourceFile);\n }\n // Applying the SourceMap can add and remove items from the sources and\n // the names array.\n var newSources = new ArraySet();\n var newNames = new ArraySet();\n\n // Find mappings for the \"sourceFile\"\n this._mappings.unsortedForEach(function (mapping) {\n if (mapping.source === sourceFile && mapping.originalLine != null) {\n // Check if it can be mapped by the source map, then update the mapping.\n var original = aSourceMapConsumer.originalPositionFor({\n line: mapping.originalLine,\n column: mapping.originalColumn\n });\n if (original.source != null) {\n // Copy mapping\n mapping.source = original.source;\n if (aSourceMapPath != null) {\n mapping.source = util.join(aSourceMapPath, mapping.source)\n }\n if (sourceRoot != null) {\n mapping.source = util.relative(sourceRoot, mapping.source);\n }\n mapping.originalLine = original.line;\n mapping.originalColumn = original.column;\n if (original.name != null) {\n mapping.name = original.name;\n }\n }\n }\n\n var source = mapping.source;\n if (source != null && !newSources.has(source)) {\n newSources.add(source);\n }\n\n var name = mapping.name;\n if (name != null && !newNames.has(name)) {\n newNames.add(name);\n }\n\n }, this);\n this._sources = newSources;\n this._names = newNames;\n\n // Copy sourcesContents of applied map.\n aSourceMapConsumer.sources.forEach(function (sourceFile) {\n var content = aSourceMapConsumer.sourceContentFor(sourceFile);\n if (content != null) {\n if (aSourceMapPath != null) {\n sourceFile = util.join(aSourceMapPath, sourceFile);\n }\n if (sourceRoot != null) {\n sourceFile = util.relative(sourceRoot, sourceFile);\n }\n this.setSourceContent(sourceFile, content);\n }\n }, this);\n };\n\n/**\n * A mapping can have one of the three levels of data:\n *\n * 1. Just the generated position.\n * 2. The Generated position, original position, and original source.\n * 3. Generated and original position, original source, as well as a name\n * token.\n *\n * To maintain consistency, we validate that any new mapping being added falls\n * in to one of these categories.\n */\nSourceMapGenerator.prototype._validateMapping =\n function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,\n aName) {\n // When aOriginal is truthy but has empty values for .line and .column,\n // it is most likely a programmer error. In this case we throw a very\n // specific error message to try to guide them the right way.\n // For example: https://github.com/Polymer/polymer-bundler/pull/519\n if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') {\n throw new Error(\n 'original.line and original.column are not numbers -- you probably meant to omit ' +\n 'the original mapping entirely and only map the generated position. If so, pass ' +\n 'null for the original mapping instead of an object with empty or null values.'\n );\n }\n\n if (aGenerated && 'line' in aGenerated && 'column' in aGenerated\n && aGenerated.line > 0 && aGenerated.column >= 0\n && !aOriginal && !aSource && !aName) {\n // Case 1.\n return;\n }\n else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated\n && aOriginal && 'line' in aOriginal && 'column' in aOriginal\n && aGenerated.line > 0 && aGenerated.column >= 0\n && aOriginal.line > 0 && aOriginal.column >= 0\n && aSource) {\n // Cases 2 and 3.\n return;\n }\n else {\n throw new Error('Invalid mapping: ' + JSON.stringify({\n generated: aGenerated,\n source: aSource,\n original: aOriginal,\n name: aName\n }));\n }\n };\n\n/**\n * Serialize the accumulated mappings in to the stream of base 64 VLQs\n * specified by the source map format.\n */\nSourceMapGenerator.prototype._serializeMappings =\n function SourceMapGenerator_serializeMappings() {\n var previousGeneratedColumn = 0;\n var previousGeneratedLine = 1;\n var previousOriginalColumn = 0;\n var previousOriginalLine = 0;\n var previousName = 0;\n var previousSource = 0;\n var result = '';\n var next;\n var mapping;\n var nameIdx;\n var sourceIdx;\n\n var mappings = this._mappings.toArray();\n for (var i = 0, len = mappings.length; i < len; i++) {\n mapping = mappings[i];\n next = ''\n\n if (mapping.generatedLine !== previousGeneratedLine) {\n previousGeneratedColumn = 0;\n while (mapping.generatedLine !== previousGeneratedLine) {\n next += ';';\n previousGeneratedLine++;\n }\n }\n else {\n if (i > 0) {\n if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {\n continue;\n }\n next += ',';\n }\n }\n\n next += base64VLQ.encode(mapping.generatedColumn\n - previousGeneratedColumn);\n previousGeneratedColumn = mapping.generatedColumn;\n\n if (mapping.source != null) {\n sourceIdx = this._sources.indexOf(mapping.source);\n next += base64VLQ.encode(sourceIdx - previousSource);\n previousSource = sourceIdx;\n\n // lines are stored 0-based in SourceMap spec version 3\n next += base64VLQ.encode(mapping.originalLine - 1\n - previousOriginalLine);\n previousOriginalLine = mapping.originalLine - 1;\n\n next += base64VLQ.encode(mapping.originalColumn\n - previousOriginalColumn);\n previousOriginalColumn = mapping.originalColumn;\n\n if (mapping.name != null) {\n nameIdx = this._names.indexOf(mapping.name);\n next += base64VLQ.encode(nameIdx - previousName);\n previousName = nameIdx;\n }\n }\n\n result += next;\n }\n\n return result;\n };\n\nSourceMapGenerator.prototype._generateSourcesContent =\n function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {\n return aSources.map(function (source) {\n if (!this._sourcesContents) {\n return null;\n }\n if (aSourceRoot != null) {\n source = util.relative(aSourceRoot, source);\n }\n var key = util.toSetString(source);\n return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)\n ? this._sourcesContents[key]\n : null;\n }, this);\n };\n\n/**\n * Externalize the source map.\n */\nSourceMapGenerator.prototype.toJSON =\n function SourceMapGenerator_toJSON() {\n var map = {\n version: this._version,\n sources: this._sources.toArray(),\n names: this._names.toArray(),\n mappings: this._serializeMappings()\n };\n if (this._file != null) {\n map.file = this._file;\n }\n if (this._sourceRoot != null) {\n map.sourceRoot = this._sourceRoot;\n }\n if (this._sourcesContents) {\n map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);\n }\n\n return map;\n };\n\n/**\n * Render the source map being generated to a string.\n */\nSourceMapGenerator.prototype.toString =\n function SourceMapGenerator_toString() {\n return JSON.stringify(this.toJSON());\n };\n\nexports.SourceMapGenerator = SourceMapGenerator;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/source-map-generator.js\n// module id = 1\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n *\n * Based on the Base 64 VLQ implementation in Closure Compiler:\n * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java\n *\n * Copyright 2011 The Closure Compiler Authors. All rights reserved.\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following\n * disclaimer in the documentation and/or other materials provided\n * with the distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\nvar base64 = require('./base64');\n\n// A single base 64 digit can contain 6 bits of data. For the base 64 variable\n// length quantities we use in the source map spec, the first bit is the sign,\n// the next four bits are the actual value, and the 6th bit is the\n// continuation bit. The continuation bit tells us whether there are more\n// digits in this value following this digit.\n//\n// Continuation\n// | Sign\n// | |\n// V V\n// 101011\n\nvar VLQ_BASE_SHIFT = 5;\n\n// binary: 100000\nvar VLQ_BASE = 1 << VLQ_BASE_SHIFT;\n\n// binary: 011111\nvar VLQ_BASE_MASK = VLQ_BASE - 1;\n\n// binary: 100000\nvar VLQ_CONTINUATION_BIT = VLQ_BASE;\n\n/**\n * Converts from a two-complement value to a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary)\n * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary)\n */\nfunction toVLQSigned(aValue) {\n return aValue < 0\n ? ((-aValue) << 1) + 1\n : (aValue << 1) + 0;\n}\n\n/**\n * Converts to a two-complement value from a value where the sign bit is\n * placed in the least significant bit. For example, as decimals:\n * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1\n * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2\n */\nfunction fromVLQSigned(aValue) {\n var isNegative = (aValue & 1) === 1;\n var shifted = aValue >> 1;\n return isNegative\n ? -shifted\n : shifted;\n}\n\n/**\n * Returns the base 64 VLQ encoded value.\n */\nexports.encode = function base64VLQ_encode(aValue) {\n var encoded = \"\";\n var digit;\n\n var vlq = toVLQSigned(aValue);\n\n do {\n digit = vlq & VLQ_BASE_MASK;\n vlq >>>= VLQ_BASE_SHIFT;\n if (vlq > 0) {\n // There are still more digits in this value, so we must make sure the\n // continuation bit is marked.\n digit |= VLQ_CONTINUATION_BIT;\n }\n encoded += base64.encode(digit);\n } while (vlq > 0);\n\n return encoded;\n};\n\n/**\n * Decodes the next base 64 VLQ value from the given string and returns the\n * value and the rest of the string via the out parameter.\n */\nexports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {\n var strLen = aStr.length;\n var result = 0;\n var shift = 0;\n var continuation, digit;\n\n do {\n if (aIndex >= strLen) {\n throw new Error(\"Expected more digits in base 64 VLQ value.\");\n }\n\n digit = base64.decode(aStr.charCodeAt(aIndex++));\n if (digit === -1) {\n throw new Error(\"Invalid base64 digit: \" + aStr.charAt(aIndex - 1));\n }\n\n continuation = !!(digit & VLQ_CONTINUATION_BIT);\n digit &= VLQ_BASE_MASK;\n result = result + (digit << shift);\n shift += VLQ_BASE_SHIFT;\n } while (continuation);\n\n aOutParam.value = fromVLQSigned(result);\n aOutParam.rest = aIndex;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/base64-vlq.js\n// module id = 2\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');\n\n/**\n * Encode an integer in the range of 0 to 63 to a single base 64 digit.\n */\nexports.encode = function (number) {\n if (0 <= number && number < intToCharMap.length) {\n return intToCharMap[number];\n }\n throw new TypeError(\"Must be between 0 and 63: \" + number);\n};\n\n/**\n * Decode a single base 64 character code digit to an integer. Returns -1 on\n * failure.\n */\nexports.decode = function (charCode) {\n var bigA = 65; // 'A'\n var bigZ = 90; // 'Z'\n\n var littleA = 97; // 'a'\n var littleZ = 122; // 'z'\n\n var zero = 48; // '0'\n var nine = 57; // '9'\n\n var plus = 43; // '+'\n var slash = 47; // '/'\n\n var littleOffset = 26;\n var numberOffset = 52;\n\n // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ\n if (bigA <= charCode && charCode <= bigZ) {\n return (charCode - bigA);\n }\n\n // 26 - 51: abcdefghijklmnopqrstuvwxyz\n if (littleA <= charCode && charCode <= littleZ) {\n return (charCode - littleA + littleOffset);\n }\n\n // 52 - 61: 0123456789\n if (zero <= charCode && charCode <= nine) {\n return (charCode - zero + numberOffset);\n }\n\n // 62: +\n if (charCode == plus) {\n return 62;\n }\n\n // 63: /\n if (charCode == slash) {\n return 63;\n }\n\n // Invalid base64 digit.\n return -1;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/base64.js\n// module id = 3\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\n/**\n * This is a helper function for getting values from parameter/options\n * objects.\n *\n * @param args The object we are extracting values from\n * @param name The name of the property we are getting.\n * @param defaultValue An optional value to return if the property is missing\n * from the object. If this is not specified and the property is missing, an\n * error will be thrown.\n */\nfunction getArg(aArgs, aName, aDefaultValue) {\n if (aName in aArgs) {\n return aArgs[aName];\n } else if (arguments.length === 3) {\n return aDefaultValue;\n } else {\n throw new Error('\"' + aName + '\" is a required argument.');\n }\n}\nexports.getArg = getArg;\n\nvar urlRegexp = /^(?:([\\w+\\-.]+):)?\\/\\/(?:(\\w+:\\w+)@)?([\\w.]*)(?::(\\d+))?(\\S*)$/;\nvar dataUrlRegexp = /^data:.+\\,.+$/;\n\nfunction urlParse(aUrl) {\n var match = aUrl.match(urlRegexp);\n if (!match) {\n return null;\n }\n return {\n scheme: match[1],\n auth: match[2],\n host: match[3],\n port: match[4],\n path: match[5]\n };\n}\nexports.urlParse = urlParse;\n\nfunction urlGenerate(aParsedUrl) {\n var url = '';\n if (aParsedUrl.scheme) {\n url += aParsedUrl.scheme + ':';\n }\n url += '//';\n if (aParsedUrl.auth) {\n url += aParsedUrl.auth + '@';\n }\n if (aParsedUrl.host) {\n url += aParsedUrl.host;\n }\n if (aParsedUrl.port) {\n url += \":\" + aParsedUrl.port\n }\n if (aParsedUrl.path) {\n url += aParsedUrl.path;\n }\n return url;\n}\nexports.urlGenerate = urlGenerate;\n\n/**\n * Normalizes a path, or the path portion of a URL:\n *\n * - Replaces consecutive slashes with one slash.\n * - Removes unnecessary '.' parts.\n * - Removes unnecessary '/..' parts.\n *\n * Based on code in the Node.js 'path' core module.\n *\n * @param aPath The path or url to normalize.\n */\nfunction normalize(aPath) {\n var path = aPath;\n var url = urlParse(aPath);\n if (url) {\n if (!url.path) {\n return aPath;\n }\n path = url.path;\n }\n var isAbsolute = exports.isAbsolute(path);\n\n var parts = path.split(/\\/+/);\n for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {\n part = parts[i];\n if (part === '.') {\n parts.splice(i, 1);\n } else if (part === '..') {\n up++;\n } else if (up > 0) {\n if (part === '') {\n // The first part is blank if the path is absolute. Trying to go\n // above the root is a no-op. Therefore we can remove all '..' parts\n // directly after the root.\n parts.splice(i + 1, up);\n up = 0;\n } else {\n parts.splice(i, 2);\n up--;\n }\n }\n }\n path = parts.join('/');\n\n if (path === '') {\n path = isAbsolute ? '/' : '.';\n }\n\n if (url) {\n url.path = path;\n return urlGenerate(url);\n }\n return path;\n}\nexports.normalize = normalize;\n\n/**\n * Joins two paths/URLs.\n *\n * @param aRoot The root path or URL.\n * @param aPath The path or URL to be joined with the root.\n *\n * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a\n * scheme-relative URL: Then the scheme of aRoot, if any, is prepended\n * first.\n * - Otherwise aPath is a path. If aRoot is a URL, then its path portion\n * is updated with the result and aRoot is returned. Otherwise the result\n * is returned.\n * - If aPath is absolute, the result is aPath.\n * - Otherwise the two paths are joined with a slash.\n * - Joining for example 'http://' and 'www.example.com' is also supported.\n */\nfunction join(aRoot, aPath) {\n if (aRoot === \"\") {\n aRoot = \".\";\n }\n if (aPath === \"\") {\n aPath = \".\";\n }\n var aPathUrl = urlParse(aPath);\n var aRootUrl = urlParse(aRoot);\n if (aRootUrl) {\n aRoot = aRootUrl.path || '/';\n }\n\n // `join(foo, '//www.example.org')`\n if (aPathUrl && !aPathUrl.scheme) {\n if (aRootUrl) {\n aPathUrl.scheme = aRootUrl.scheme;\n }\n return urlGenerate(aPathUrl);\n }\n\n if (aPathUrl || aPath.match(dataUrlRegexp)) {\n return aPath;\n }\n\n // `join('http://', 'www.example.com')`\n if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {\n aRootUrl.host = aPath;\n return urlGenerate(aRootUrl);\n }\n\n var joined = aPath.charAt(0) === '/'\n ? aPath\n : normalize(aRoot.replace(/\\/+$/, '') + '/' + aPath);\n\n if (aRootUrl) {\n aRootUrl.path = joined;\n return urlGenerate(aRootUrl);\n }\n return joined;\n}\nexports.join = join;\n\nexports.isAbsolute = function (aPath) {\n return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);\n};\n\n/**\n * Make a path relative to a URL or another path.\n *\n * @param aRoot The root path or URL.\n * @param aPath The path or URL to be made relative to aRoot.\n */\nfunction relative(aRoot, aPath) {\n if (aRoot === \"\") {\n aRoot = \".\";\n }\n\n aRoot = aRoot.replace(/\\/$/, '');\n\n // It is possible for the path to be above the root. In this case, simply\n // checking whether the root is a prefix of the path won't work. Instead, we\n // need to remove components from the root one by one, until either we find\n // a prefix that fits, or we run out of components to remove.\n var level = 0;\n while (aPath.indexOf(aRoot + '/') !== 0) {\n var index = aRoot.lastIndexOf(\"/\");\n if (index < 0) {\n return aPath;\n }\n\n // If the only part of the root that is left is the scheme (i.e. http://,\n // file:///, etc.), one or more slashes (/), or simply nothing at all, we\n // have exhausted all components, so the path is not relative to the root.\n aRoot = aRoot.slice(0, index);\n if (aRoot.match(/^([^\\/]+:\\/)?\\/*$/)) {\n return aPath;\n }\n\n ++level;\n }\n\n // Make sure we add a \"../\" for each component we removed from the root.\n return Array(level + 1).join(\"../\") + aPath.substr(aRoot.length + 1);\n}\nexports.relative = relative;\n\nvar supportsNullProto = (function () {\n var obj = Object.create(null);\n return !('__proto__' in obj);\n}());\n\nfunction identity (s) {\n return s;\n}\n\n/**\n * Because behavior goes wacky when you set `__proto__` on objects, we\n * have to prefix all the strings in our set with an arbitrary character.\n *\n * See https://github.com/mozilla/source-map/pull/31 and\n * https://github.com/mozilla/source-map/issues/30\n *\n * @param String aStr\n */\nfunction toSetString(aStr) {\n if (isProtoString(aStr)) {\n return '$' + aStr;\n }\n\n return aStr;\n}\nexports.toSetString = supportsNullProto ? identity : toSetString;\n\nfunction fromSetString(aStr) {\n if (isProtoString(aStr)) {\n return aStr.slice(1);\n }\n\n return aStr;\n}\nexports.fromSetString = supportsNullProto ? identity : fromSetString;\n\nfunction isProtoString(s) {\n if (!s) {\n return false;\n }\n\n var length = s.length;\n\n if (length < 9 /* \"__proto__\".length */) {\n return false;\n }\n\n if (s.charCodeAt(length - 1) !== 95 /* '_' */ ||\n s.charCodeAt(length - 2) !== 95 /* '_' */ ||\n s.charCodeAt(length - 3) !== 111 /* 'o' */ ||\n s.charCodeAt(length - 4) !== 116 /* 't' */ ||\n s.charCodeAt(length - 5) !== 111 /* 'o' */ ||\n s.charCodeAt(length - 6) !== 114 /* 'r' */ ||\n s.charCodeAt(length - 7) !== 112 /* 'p' */ ||\n s.charCodeAt(length - 8) !== 95 /* '_' */ ||\n s.charCodeAt(length - 9) !== 95 /* '_' */) {\n return false;\n }\n\n for (var i = length - 10; i >= 0; i--) {\n if (s.charCodeAt(i) !== 36 /* '$' */) {\n return false;\n }\n }\n\n return true;\n}\n\n/**\n * Comparator between two mappings where the original positions are compared.\n *\n * Optionally pass in `true` as `onlyCompareGenerated` to consider two\n * mappings with the same original source/line/column, but different generated\n * line and column the same. Useful when searching for a mapping with a\n * stubbed out mapping.\n */\nfunction compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {\n var cmp = mappingA.source - mappingB.source;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalLine - mappingB.originalLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalColumn - mappingB.originalColumn;\n if (cmp !== 0 || onlyCompareOriginal) {\n return cmp;\n }\n\n cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.generatedLine - mappingB.generatedLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n return mappingA.name - mappingB.name;\n}\nexports.compareByOriginalPositions = compareByOriginalPositions;\n\n/**\n * Comparator between two mappings with deflated source and name indices where\n * the generated positions are compared.\n *\n * Optionally pass in `true` as `onlyCompareGenerated` to consider two\n * mappings with the same generated line and column, but different\n * source/name/original line and column the same. Useful when searching for a\n * mapping with a stubbed out mapping.\n */\nfunction compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {\n var cmp = mappingA.generatedLine - mappingB.generatedLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n if (cmp !== 0 || onlyCompareGenerated) {\n return cmp;\n }\n\n cmp = mappingA.source - mappingB.source;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalLine - mappingB.originalLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalColumn - mappingB.originalColumn;\n if (cmp !== 0) {\n return cmp;\n }\n\n return mappingA.name - mappingB.name;\n}\nexports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;\n\nfunction strcmp(aStr1, aStr2) {\n if (aStr1 === aStr2) {\n return 0;\n }\n\n if (aStr1 > aStr2) {\n return 1;\n }\n\n return -1;\n}\n\n/**\n * Comparator between two mappings with inflated source and name strings where\n * the generated positions are compared.\n */\nfunction compareByGeneratedPositionsInflated(mappingA, mappingB) {\n var cmp = mappingA.generatedLine - mappingB.generatedLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.generatedColumn - mappingB.generatedColumn;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = strcmp(mappingA.source, mappingB.source);\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalLine - mappingB.originalLine;\n if (cmp !== 0) {\n return cmp;\n }\n\n cmp = mappingA.originalColumn - mappingB.originalColumn;\n if (cmp !== 0) {\n return cmp;\n }\n\n return strcmp(mappingA.name, mappingB.name);\n}\nexports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/util.js\n// module id = 4\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar util = require('./util');\nvar has = Object.prototype.hasOwnProperty;\nvar hasNativeMap = typeof Map !== \"undefined\";\n\n/**\n * A data structure which is a combination of an array and a set. Adding a new\n * member is O(1), testing for membership is O(1), and finding the index of an\n * element is O(1). Removing elements from the set is not supported. Only\n * strings are supported for membership.\n */\nfunction ArraySet() {\n this._array = [];\n this._set = hasNativeMap ? new Map() : Object.create(null);\n}\n\n/**\n * Static method for creating ArraySet instances from an existing array.\n */\nArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {\n var set = new ArraySet();\n for (var i = 0, len = aArray.length; i < len; i++) {\n set.add(aArray[i], aAllowDuplicates);\n }\n return set;\n};\n\n/**\n * Return how many unique items are in this ArraySet. If duplicates have been\n * added, than those do not count towards the size.\n *\n * @returns Number\n */\nArraySet.prototype.size = function ArraySet_size() {\n return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length;\n};\n\n/**\n * Add the given string to this set.\n *\n * @param String aStr\n */\nArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {\n var sStr = hasNativeMap ? aStr : util.toSetString(aStr);\n var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr);\n var idx = this._array.length;\n if (!isDuplicate || aAllowDuplicates) {\n this._array.push(aStr);\n }\n if (!isDuplicate) {\n if (hasNativeMap) {\n this._set.set(aStr, idx);\n } else {\n this._set[sStr] = idx;\n }\n }\n};\n\n/**\n * Is the given string a member of this set?\n *\n * @param String aStr\n */\nArraySet.prototype.has = function ArraySet_has(aStr) {\n if (hasNativeMap) {\n return this._set.has(aStr);\n } else {\n var sStr = util.toSetString(aStr);\n return has.call(this._set, sStr);\n }\n};\n\n/**\n * What is the index of the given string in the array?\n *\n * @param String aStr\n */\nArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {\n if (hasNativeMap) {\n var idx = this._set.get(aStr);\n if (idx >= 0) {\n return idx;\n }\n } else {\n var sStr = util.toSetString(aStr);\n if (has.call(this._set, sStr)) {\n return this._set[sStr];\n }\n }\n\n throw new Error('\"' + aStr + '\" is not in the set.');\n};\n\n/**\n * What is the element at the given index?\n *\n * @param Number aIdx\n */\nArraySet.prototype.at = function ArraySet_at(aIdx) {\n if (aIdx >= 0 && aIdx < this._array.length) {\n return this._array[aIdx];\n }\n throw new Error('No element indexed by ' + aIdx);\n};\n\n/**\n * Returns the array representation of this set (which has the proper indices\n * indicated by indexOf). Note that this is a copy of the internal array used\n * for storing the members so that no one can mess with internal state.\n */\nArraySet.prototype.toArray = function ArraySet_toArray() {\n return this._array.slice();\n};\n\nexports.ArraySet = ArraySet;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/array-set.js\n// module id = 5\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2014 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar util = require('./util');\n\n/**\n * Determine whether mappingB is after mappingA with respect to generated\n * position.\n */\nfunction generatedPositionAfter(mappingA, mappingB) {\n // Optimized for most common case\n var lineA = mappingA.generatedLine;\n var lineB = mappingB.generatedLine;\n var columnA = mappingA.generatedColumn;\n var columnB = mappingB.generatedColumn;\n return lineB > lineA || lineB == lineA && columnB >= columnA ||\n util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;\n}\n\n/**\n * A data structure to provide a sorted view of accumulated mappings in a\n * performance conscious manner. It trades a neglibable overhead in general\n * case for a large speedup in case of mappings being added in order.\n */\nfunction MappingList() {\n this._array = [];\n this._sorted = true;\n // Serves as infimum\n this._last = {generatedLine: -1, generatedColumn: 0};\n}\n\n/**\n * Iterate through internal items. This method takes the same arguments that\n * `Array.prototype.forEach` takes.\n *\n * NOTE: The order of the mappings is NOT guaranteed.\n */\nMappingList.prototype.unsortedForEach =\n function MappingList_forEach(aCallback, aThisArg) {\n this._array.forEach(aCallback, aThisArg);\n };\n\n/**\n * Add the given source mapping.\n *\n * @param Object aMapping\n */\nMappingList.prototype.add = function MappingList_add(aMapping) {\n if (generatedPositionAfter(this._last, aMapping)) {\n this._last = aMapping;\n this._array.push(aMapping);\n } else {\n this._sorted = false;\n this._array.push(aMapping);\n }\n};\n\n/**\n * Returns the flat, sorted array of mappings. The mappings are sorted by\n * generated position.\n *\n * WARNING: This method returns internal data without copying, for\n * performance. The return value must NOT be mutated, and should be treated as\n * an immutable borrow. If you want to take ownership, you must make your own\n * copy.\n */\nMappingList.prototype.toArray = function MappingList_toArray() {\n if (!this._sorted) {\n this._array.sort(util.compareByGeneratedPositionsInflated);\n this._sorted = true;\n }\n return this._array;\n};\n\nexports.MappingList = MappingList;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/mapping-list.js\n// module id = 6\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar util = require('./util');\nvar binarySearch = require('./binary-search');\nvar ArraySet = require('./array-set').ArraySet;\nvar base64VLQ = require('./base64-vlq');\nvar quickSort = require('./quick-sort').quickSort;\n\nfunction SourceMapConsumer(aSourceMap) {\n var sourceMap = aSourceMap;\n if (typeof aSourceMap === 'string') {\n sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n }\n\n return sourceMap.sections != null\n ? new IndexedSourceMapConsumer(sourceMap)\n : new BasicSourceMapConsumer(sourceMap);\n}\n\nSourceMapConsumer.fromSourceMap = function(aSourceMap) {\n return BasicSourceMapConsumer.fromSourceMap(aSourceMap);\n}\n\n/**\n * The version of the source mapping spec that we are consuming.\n */\nSourceMapConsumer.prototype._version = 3;\n\n// `__generatedMappings` and `__originalMappings` are arrays that hold the\n// parsed mapping coordinates from the source map's \"mappings\" attribute. They\n// are lazily instantiated, accessed via the `_generatedMappings` and\n// `_originalMappings` getters respectively, and we only parse the mappings\n// and create these arrays once queried for a source location. We jump through\n// these hoops because there can be many thousands of mappings, and parsing\n// them is expensive, so we only want to do it if we must.\n//\n// Each object in the arrays is of the form:\n//\n// {\n// generatedLine: The line number in the generated code,\n// generatedColumn: The column number in the generated code,\n// source: The path to the original source file that generated this\n// chunk of code,\n// originalLine: The line number in the original source that\n// corresponds to this chunk of generated code,\n// originalColumn: The column number in the original source that\n// corresponds to this chunk of generated code,\n// name: The name of the original symbol which generated this chunk of\n// code.\n// }\n//\n// All properties except for `generatedLine` and `generatedColumn` can be\n// `null`.\n//\n// `_generatedMappings` is ordered by the generated positions.\n//\n// `_originalMappings` is ordered by the original positions.\n\nSourceMapConsumer.prototype.__generatedMappings = null;\nObject.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {\n get: function () {\n if (!this.__generatedMappings) {\n this._parseMappings(this._mappings, this.sourceRoot);\n }\n\n return this.__generatedMappings;\n }\n});\n\nSourceMapConsumer.prototype.__originalMappings = null;\nObject.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {\n get: function () {\n if (!this.__originalMappings) {\n this._parseMappings(this._mappings, this.sourceRoot);\n }\n\n return this.__originalMappings;\n }\n});\n\nSourceMapConsumer.prototype._charIsMappingSeparator =\n function SourceMapConsumer_charIsMappingSeparator(aStr, index) {\n var c = aStr.charAt(index);\n return c === \";\" || c === \",\";\n };\n\n/**\n * Parse the mappings in a string in to a data structure which we can easily\n * query (the ordered arrays in the `this.__generatedMappings` and\n * `this.__originalMappings` properties).\n */\nSourceMapConsumer.prototype._parseMappings =\n function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n throw new Error(\"Subclasses must implement _parseMappings\");\n };\n\nSourceMapConsumer.GENERATED_ORDER = 1;\nSourceMapConsumer.ORIGINAL_ORDER = 2;\n\nSourceMapConsumer.GREATEST_LOWER_BOUND = 1;\nSourceMapConsumer.LEAST_UPPER_BOUND = 2;\n\n/**\n * Iterate over each mapping between an original source/line/column and a\n * generated line/column in this source map.\n *\n * @param Function aCallback\n * The function that is called with each mapping.\n * @param Object aContext\n * Optional. If specified, this object will be the value of `this` every\n * time that `aCallback` is called.\n * @param aOrder\n * Either `SourceMapConsumer.GENERATED_ORDER` or\n * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to\n * iterate over the mappings sorted by the generated file's line/column\n * order or the original's source/line/column order, respectively. Defaults to\n * `SourceMapConsumer.GENERATED_ORDER`.\n */\nSourceMapConsumer.prototype.eachMapping =\n function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {\n var context = aContext || null;\n var order = aOrder || SourceMapConsumer.GENERATED_ORDER;\n\n var mappings;\n switch (order) {\n case SourceMapConsumer.GENERATED_ORDER:\n mappings = this._generatedMappings;\n break;\n case SourceMapConsumer.ORIGINAL_ORDER:\n mappings = this._originalMappings;\n break;\n default:\n throw new Error(\"Unknown order of iteration.\");\n }\n\n var sourceRoot = this.sourceRoot;\n mappings.map(function (mapping) {\n var source = mapping.source === null ? null : this._sources.at(mapping.source);\n if (source != null && sourceRoot != null) {\n source = util.join(sourceRoot, source);\n }\n return {\n source: source,\n generatedLine: mapping.generatedLine,\n generatedColumn: mapping.generatedColumn,\n originalLine: mapping.originalLine,\n originalColumn: mapping.originalColumn,\n name: mapping.name === null ? null : this._names.at(mapping.name)\n };\n }, this).forEach(aCallback, context);\n };\n\n/**\n * Returns all generated line and column information for the original source,\n * line, and column provided. If no column is provided, returns all mappings\n * corresponding to a either the line we are searching for or the next\n * closest line that has any mappings. Otherwise, returns all mappings\n * corresponding to the given line and either the column we are searching for\n * or the next closest column that has any offsets.\n *\n * The only argument is an object with the following properties:\n *\n * - source: The filename of the original source.\n * - line: The line number in the original source.\n * - column: Optional. the column number in the original source.\n *\n * and an array of objects is returned, each with the following properties:\n *\n * - line: The line number in the generated source, or null.\n * - column: The column number in the generated source, or null.\n */\nSourceMapConsumer.prototype.allGeneratedPositionsFor =\n function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {\n var line = util.getArg(aArgs, 'line');\n\n // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping\n // returns the index of the closest mapping less than the needle. By\n // setting needle.originalColumn to 0, we thus find the last mapping for\n // the given line, provided such a mapping exists.\n var needle = {\n source: util.getArg(aArgs, 'source'),\n originalLine: line,\n originalColumn: util.getArg(aArgs, 'column', 0)\n };\n\n if (this.sourceRoot != null) {\n needle.source = util.relative(this.sourceRoot, needle.source);\n }\n if (!this._sources.has(needle.source)) {\n return [];\n }\n needle.source = this._sources.indexOf(needle.source);\n\n var mappings = [];\n\n var index = this._findMapping(needle,\n this._originalMappings,\n \"originalLine\",\n \"originalColumn\",\n util.compareByOriginalPositions,\n binarySearch.LEAST_UPPER_BOUND);\n if (index >= 0) {\n var mapping = this._originalMappings[index];\n\n if (aArgs.column === undefined) {\n var originalLine = mapping.originalLine;\n\n // Iterate until either we run out of mappings, or we run into\n // a mapping for a different line than the one we found. Since\n // mappings are sorted, this is guaranteed to find all mappings for\n // the line we found.\n while (mapping && mapping.originalLine === originalLine) {\n mappings.push({\n line: util.getArg(mapping, 'generatedLine', null),\n column: util.getArg(mapping, 'generatedColumn', null),\n lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n });\n\n mapping = this._originalMappings[++index];\n }\n } else {\n var originalColumn = mapping.originalColumn;\n\n // Iterate until either we run out of mappings, or we run into\n // a mapping for a different line than the one we were searching for.\n // Since mappings are sorted, this is guaranteed to find all mappings for\n // the line we are searching for.\n while (mapping &&\n mapping.originalLine === line &&\n mapping.originalColumn == originalColumn) {\n mappings.push({\n line: util.getArg(mapping, 'generatedLine', null),\n column: util.getArg(mapping, 'generatedColumn', null),\n lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n });\n\n mapping = this._originalMappings[++index];\n }\n }\n }\n\n return mappings;\n };\n\nexports.SourceMapConsumer = SourceMapConsumer;\n\n/**\n * A BasicSourceMapConsumer instance represents a parsed source map which we can\n * query for information about the original file positions by giving it a file\n * position in the generated source.\n *\n * The only parameter is the raw source map (either as a JSON string, or\n * already parsed to an object). According to the spec, source maps have the\n * following attributes:\n *\n * - version: Which version of the source map spec this map is following.\n * - sources: An array of URLs to the original source files.\n * - names: An array of identifiers which can be referrenced by individual mappings.\n * - sourceRoot: Optional. The URL root from which all sources are relative.\n * - sourcesContent: Optional. An array of contents of the original source files.\n * - mappings: A string of base64 VLQs which contain the actual mappings.\n * - file: Optional. The generated file this source map is associated with.\n *\n * Here is an example source map, taken from the source map spec[0]:\n *\n * {\n * version : 3,\n * file: \"out.js\",\n * sourceRoot : \"\",\n * sources: [\"foo.js\", \"bar.js\"],\n * names: [\"src\", \"maps\", \"are\", \"fun\"],\n * mappings: \"AA,AB;;ABCDE;\"\n * }\n *\n * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#\n */\nfunction BasicSourceMapConsumer(aSourceMap) {\n var sourceMap = aSourceMap;\n if (typeof aSourceMap === 'string') {\n sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n }\n\n var version = util.getArg(sourceMap, 'version');\n var sources = util.getArg(sourceMap, 'sources');\n // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which\n // requires the array) to play nice here.\n var names = util.getArg(sourceMap, 'names', []);\n var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);\n var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);\n var mappings = util.getArg(sourceMap, 'mappings');\n var file = util.getArg(sourceMap, 'file', null);\n\n // Once again, Sass deviates from the spec and supplies the version as a\n // string rather than a number, so we use loose equality checking here.\n if (version != this._version) {\n throw new Error('Unsupported version: ' + version);\n }\n\n sources = sources\n .map(String)\n // Some source maps produce relative source paths like \"./foo.js\" instead of\n // \"foo.js\". Normalize these first so that future comparisons will succeed.\n // See bugzil.la/1090768.\n .map(util.normalize)\n // Always ensure that absolute sources are internally stored relative to\n // the source root, if the source root is absolute. Not doing this would\n // be particularly problematic when the source root is a prefix of the\n // source (valid, but why??). See github issue #199 and bugzil.la/1188982.\n .map(function (source) {\n return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)\n ? util.relative(sourceRoot, source)\n : source;\n });\n\n // Pass `true` below to allow duplicate names and sources. While source maps\n // are intended to be compressed and deduplicated, the TypeScript compiler\n // sometimes generates source maps with duplicates in them. See Github issue\n // #72 and bugzil.la/889492.\n this._names = ArraySet.fromArray(names.map(String), true);\n this._sources = ArraySet.fromArray(sources, true);\n\n this.sourceRoot = sourceRoot;\n this.sourcesContent = sourcesContent;\n this._mappings = mappings;\n this.file = file;\n}\n\nBasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);\nBasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;\n\n/**\n * Create a BasicSourceMapConsumer from a SourceMapGenerator.\n *\n * @param SourceMapGenerator aSourceMap\n * The source map that will be consumed.\n * @returns BasicSourceMapConsumer\n */\nBasicSourceMapConsumer.fromSourceMap =\n function SourceMapConsumer_fromSourceMap(aSourceMap) {\n var smc = Object.create(BasicSourceMapConsumer.prototype);\n\n var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);\n var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);\n smc.sourceRoot = aSourceMap._sourceRoot;\n smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),\n smc.sourceRoot);\n smc.file = aSourceMap._file;\n\n // Because we are modifying the entries (by converting string sources and\n // names to indices into the sources and names ArraySets), we have to make\n // a copy of the entry or else bad things happen. Shared mutable state\n // strikes again! See github issue #191.\n\n var generatedMappings = aSourceMap._mappings.toArray().slice();\n var destGeneratedMappings = smc.__generatedMappings = [];\n var destOriginalMappings = smc.__originalMappings = [];\n\n for (var i = 0, length = generatedMappings.length; i < length; i++) {\n var srcMapping = generatedMappings[i];\n var destMapping = new Mapping;\n destMapping.generatedLine = srcMapping.generatedLine;\n destMapping.generatedColumn = srcMapping.generatedColumn;\n\n if (srcMapping.source) {\n destMapping.source = sources.indexOf(srcMapping.source);\n destMapping.originalLine = srcMapping.originalLine;\n destMapping.originalColumn = srcMapping.originalColumn;\n\n if (srcMapping.name) {\n destMapping.name = names.indexOf(srcMapping.name);\n }\n\n destOriginalMappings.push(destMapping);\n }\n\n destGeneratedMappings.push(destMapping);\n }\n\n quickSort(smc.__originalMappings, util.compareByOriginalPositions);\n\n return smc;\n };\n\n/**\n * The version of the source mapping spec that we are consuming.\n */\nBasicSourceMapConsumer.prototype._version = 3;\n\n/**\n * The list of original sources.\n */\nObject.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {\n get: function () {\n return this._sources.toArray().map(function (s) {\n return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;\n }, this);\n }\n});\n\n/**\n * Provide the JIT with a nice shape / hidden class.\n */\nfunction Mapping() {\n this.generatedLine = 0;\n this.generatedColumn = 0;\n this.source = null;\n this.originalLine = null;\n this.originalColumn = null;\n this.name = null;\n}\n\n/**\n * Parse the mappings in a string in to a data structure which we can easily\n * query (the ordered arrays in the `this.__generatedMappings` and\n * `this.__originalMappings` properties).\n */\nBasicSourceMapConsumer.prototype._parseMappings =\n function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n var generatedLine = 1;\n var previousGeneratedColumn = 0;\n var previousOriginalLine = 0;\n var previousOriginalColumn = 0;\n var previousSource = 0;\n var previousName = 0;\n var length = aStr.length;\n var index = 0;\n var cachedSegments = {};\n var temp = {};\n var originalMappings = [];\n var generatedMappings = [];\n var mapping, str, segment, end, value;\n\n while (index < length) {\n if (aStr.charAt(index) === ';') {\n generatedLine++;\n index++;\n previousGeneratedColumn = 0;\n }\n else if (aStr.charAt(index) === ',') {\n index++;\n }\n else {\n mapping = new Mapping();\n mapping.generatedLine = generatedLine;\n\n // Because each offset is encoded relative to the previous one,\n // many segments often have the same encoding. We can exploit this\n // fact by caching the parsed variable length fields of each segment,\n // allowing us to avoid a second parse if we encounter the same\n // segment again.\n for (end = index; end < length; end++) {\n if (this._charIsMappingSeparator(aStr, end)) {\n break;\n }\n }\n str = aStr.slice(index, end);\n\n segment = cachedSegments[str];\n if (segment) {\n index += str.length;\n } else {\n segment = [];\n while (index < end) {\n base64VLQ.decode(aStr, index, temp);\n value = temp.value;\n index = temp.rest;\n segment.push(value);\n }\n\n if (segment.length === 2) {\n throw new Error('Found a source, but no line and column');\n }\n\n if (segment.length === 3) {\n throw new Error('Found a source and line, but no column');\n }\n\n cachedSegments[str] = segment;\n }\n\n // Generated column.\n mapping.generatedColumn = previousGeneratedColumn + segment[0];\n previousGeneratedColumn = mapping.generatedColumn;\n\n if (segment.length > 1) {\n // Original source.\n mapping.source = previousSource + segment[1];\n previousSource += segment[1];\n\n // Original line.\n mapping.originalLine = previousOriginalLine + segment[2];\n previousOriginalLine = mapping.originalLine;\n // Lines are stored 0-based\n mapping.originalLine += 1;\n\n // Original column.\n mapping.originalColumn = previousOriginalColumn + segment[3];\n previousOriginalColumn = mapping.originalColumn;\n\n if (segment.length > 4) {\n // Original name.\n mapping.name = previousName + segment[4];\n previousName += segment[4];\n }\n }\n\n generatedMappings.push(mapping);\n if (typeof mapping.originalLine === 'number') {\n originalMappings.push(mapping);\n }\n }\n }\n\n quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);\n this.__generatedMappings = generatedMappings;\n\n quickSort(originalMappings, util.compareByOriginalPositions);\n this.__originalMappings = originalMappings;\n };\n\n/**\n * Find the mapping that best matches the hypothetical \"needle\" mapping that\n * we are searching for in the given \"haystack\" of mappings.\n */\nBasicSourceMapConsumer.prototype._findMapping =\n function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,\n aColumnName, aComparator, aBias) {\n // To return the position we are searching for, we must first find the\n // mapping for the given position and then return the opposite position it\n // points to. Because the mappings are sorted, we can use binary search to\n // find the best mapping.\n\n if (aNeedle[aLineName] <= 0) {\n throw new TypeError('Line must be greater than or equal to 1, got '\n + aNeedle[aLineName]);\n }\n if (aNeedle[aColumnName] < 0) {\n throw new TypeError('Column must be greater than or equal to 0, got '\n + aNeedle[aColumnName]);\n }\n\n return binarySearch.search(aNeedle, aMappings, aComparator, aBias);\n };\n\n/**\n * Compute the last column for each generated mapping. The last column is\n * inclusive.\n */\nBasicSourceMapConsumer.prototype.computeColumnSpans =\n function SourceMapConsumer_computeColumnSpans() {\n for (var index = 0; index < this._generatedMappings.length; ++index) {\n var mapping = this._generatedMappings[index];\n\n // Mappings do not contain a field for the last generated columnt. We\n // can come up with an optimistic estimate, however, by assuming that\n // mappings are contiguous (i.e. given two consecutive mappings, the\n // first mapping ends where the second one starts).\n if (index + 1 < this._generatedMappings.length) {\n var nextMapping = this._generatedMappings[index + 1];\n\n if (mapping.generatedLine === nextMapping.generatedLine) {\n mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;\n continue;\n }\n }\n\n // The last mapping for each line spans the entire line.\n mapping.lastGeneratedColumn = Infinity;\n }\n };\n\n/**\n * Returns the original source, line, and column information for the generated\n * source's line and column positions provided. The only argument is an object\n * with the following properties:\n *\n * - line: The line number in the generated source.\n * - column: The column number in the generated source.\n * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or\n * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the\n * closest element that is smaller than or greater than the one we are\n * searching for, respectively, if the exact element cannot be found.\n * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.\n *\n * and an object is returned with the following properties:\n *\n * - source: The original source file, or null.\n * - line: The line number in the original source, or null.\n * - column: The column number in the original source, or null.\n * - name: The original identifier, or null.\n */\nBasicSourceMapConsumer.prototype.originalPositionFor =\n function SourceMapConsumer_originalPositionFor(aArgs) {\n var needle = {\n generatedLine: util.getArg(aArgs, 'line'),\n generatedColumn: util.getArg(aArgs, 'column')\n };\n\n var index = this._findMapping(\n needle,\n this._generatedMappings,\n \"generatedLine\",\n \"generatedColumn\",\n util.compareByGeneratedPositionsDeflated,\n util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)\n );\n\n if (index >= 0) {\n var mapping = this._generatedMappings[index];\n\n if (mapping.generatedLine === needle.generatedLine) {\n var source = util.getArg(mapping, 'source', null);\n if (source !== null) {\n source = this._sources.at(source);\n if (this.sourceRoot != null) {\n source = util.join(this.sourceRoot, source);\n }\n }\n var name = util.getArg(mapping, 'name', null);\n if (name !== null) {\n name = this._names.at(name);\n }\n return {\n source: source,\n line: util.getArg(mapping, 'originalLine', null),\n column: util.getArg(mapping, 'originalColumn', null),\n name: name\n };\n }\n }\n\n return {\n source: null,\n line: null,\n column: null,\n name: null\n };\n };\n\n/**\n * Return true if we have the source content for every source in the source\n * map, false otherwise.\n */\nBasicSourceMapConsumer.prototype.hasContentsOfAllSources =\n function BasicSourceMapConsumer_hasContentsOfAllSources() {\n if (!this.sourcesContent) {\n return false;\n }\n return this.sourcesContent.length >= this._sources.size() &&\n !this.sourcesContent.some(function (sc) { return sc == null; });\n };\n\n/**\n * Returns the original source content. The only argument is the url of the\n * original source file. Returns null if no original source content is\n * available.\n */\nBasicSourceMapConsumer.prototype.sourceContentFor =\n function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {\n if (!this.sourcesContent) {\n return null;\n }\n\n if (this.sourceRoot != null) {\n aSource = util.relative(this.sourceRoot, aSource);\n }\n\n if (this._sources.has(aSource)) {\n return this.sourcesContent[this._sources.indexOf(aSource)];\n }\n\n var url;\n if (this.sourceRoot != null\n && (url = util.urlParse(this.sourceRoot))) {\n // XXX: file:// URIs and absolute paths lead to unexpected behavior for\n // many users. We can help them out when they expect file:// URIs to\n // behave like it would if they were running a local HTTP server. See\n // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.\n var fileUriAbsPath = aSource.replace(/^file:\\/\\//, \"\");\n if (url.scheme == \"file\"\n && this._sources.has(fileUriAbsPath)) {\n return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]\n }\n\n if ((!url.path || url.path == \"/\")\n && this._sources.has(\"/\" + aSource)) {\n return this.sourcesContent[this._sources.indexOf(\"/\" + aSource)];\n }\n }\n\n // This function is used recursively from\n // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we\n // don't want to throw if we can't find the source - we just want to\n // return null, so we provide a flag to exit gracefully.\n if (nullOnMissing) {\n return null;\n }\n else {\n throw new Error('\"' + aSource + '\" is not in the SourceMap.');\n }\n };\n\n/**\n * Returns the generated line and column information for the original source,\n * line, and column positions provided. The only argument is an object with\n * the following properties:\n *\n * - source: The filename of the original source.\n * - line: The line number in the original source.\n * - column: The column number in the original source.\n * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or\n * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the\n * closest element that is smaller than or greater than the one we are\n * searching for, respectively, if the exact element cannot be found.\n * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.\n *\n * and an object is returned with the following properties:\n *\n * - line: The line number in the generated source, or null.\n * - column: The column number in the generated source, or null.\n */\nBasicSourceMapConsumer.prototype.generatedPositionFor =\n function SourceMapConsumer_generatedPositionFor(aArgs) {\n var source = util.getArg(aArgs, 'source');\n if (this.sourceRoot != null) {\n source = util.relative(this.sourceRoot, source);\n }\n if (!this._sources.has(source)) {\n return {\n line: null,\n column: null,\n lastColumn: null\n };\n }\n source = this._sources.indexOf(source);\n\n var needle = {\n source: source,\n originalLine: util.getArg(aArgs, 'line'),\n originalColumn: util.getArg(aArgs, 'column')\n };\n\n var index = this._findMapping(\n needle,\n this._originalMappings,\n \"originalLine\",\n \"originalColumn\",\n util.compareByOriginalPositions,\n util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)\n );\n\n if (index >= 0) {\n var mapping = this._originalMappings[index];\n\n if (mapping.source === needle.source) {\n return {\n line: util.getArg(mapping, 'generatedLine', null),\n column: util.getArg(mapping, 'generatedColumn', null),\n lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)\n };\n }\n }\n\n return {\n line: null,\n column: null,\n lastColumn: null\n };\n };\n\nexports.BasicSourceMapConsumer = BasicSourceMapConsumer;\n\n/**\n * An IndexedSourceMapConsumer instance represents a parsed source map which\n * we can query for information. It differs from BasicSourceMapConsumer in\n * that it takes \"indexed\" source maps (i.e. ones with a \"sections\" field) as\n * input.\n *\n * The only parameter is a raw source map (either as a JSON string, or already\n * parsed to an object). According to the spec for indexed source maps, they\n * have the following attributes:\n *\n * - version: Which version of the source map spec this map is following.\n * - file: Optional. The generated file this source map is associated with.\n * - sections: A list of section definitions.\n *\n * Each value under the \"sections\" field has two fields:\n * - offset: The offset into the original specified at which this section\n * begins to apply, defined as an object with a \"line\" and \"column\"\n * field.\n * - map: A source map definition. This source map could also be indexed,\n * but doesn't have to be.\n *\n * Instead of the \"map\" field, it's also possible to have a \"url\" field\n * specifying a URL to retrieve a source map from, but that's currently\n * unsupported.\n *\n * Here's an example source map, taken from the source map spec[0], but\n * modified to omit a section which uses the \"url\" field.\n *\n * {\n * version : 3,\n * file: \"app.js\",\n * sections: [{\n * offset: {line:100, column:10},\n * map: {\n * version : 3,\n * file: \"section.js\",\n * sources: [\"foo.js\", \"bar.js\"],\n * names: [\"src\", \"maps\", \"are\", \"fun\"],\n * mappings: \"AAAA,E;;ABCDE;\"\n * }\n * }],\n * }\n *\n * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt\n */\nfunction IndexedSourceMapConsumer(aSourceMap) {\n var sourceMap = aSourceMap;\n if (typeof aSourceMap === 'string') {\n sourceMap = JSON.parse(aSourceMap.replace(/^\\)\\]\\}'/, ''));\n }\n\n var version = util.getArg(sourceMap, 'version');\n var sections = util.getArg(sourceMap, 'sections');\n\n if (version != this._version) {\n throw new Error('Unsupported version: ' + version);\n }\n\n this._sources = new ArraySet();\n this._names = new ArraySet();\n\n var lastOffset = {\n line: -1,\n column: 0\n };\n this._sections = sections.map(function (s) {\n if (s.url) {\n // The url field will require support for asynchronicity.\n // See https://github.com/mozilla/source-map/issues/16\n throw new Error('Support for url field in sections not implemented.');\n }\n var offset = util.getArg(s, 'offset');\n var offsetLine = util.getArg(offset, 'line');\n var offsetColumn = util.getArg(offset, 'column');\n\n if (offsetLine < lastOffset.line ||\n (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {\n throw new Error('Section offsets must be ordered and non-overlapping.');\n }\n lastOffset = offset;\n\n return {\n generatedOffset: {\n // The offset fields are 0-based, but we use 1-based indices when\n // encoding/decoding from VLQ.\n generatedLine: offsetLine + 1,\n generatedColumn: offsetColumn + 1\n },\n consumer: new SourceMapConsumer(util.getArg(s, 'map'))\n }\n });\n}\n\nIndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);\nIndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;\n\n/**\n * The version of the source mapping spec that we are consuming.\n */\nIndexedSourceMapConsumer.prototype._version = 3;\n\n/**\n * The list of original sources.\n */\nObject.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {\n get: function () {\n var sources = [];\n for (var i = 0; i < this._sections.length; i++) {\n for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {\n sources.push(this._sections[i].consumer.sources[j]);\n }\n }\n return sources;\n }\n});\n\n/**\n * Returns the original source, line, and column information for the generated\n * source's line and column positions provided. The only argument is an object\n * with the following properties:\n *\n * - line: The line number in the generated source.\n * - column: The column number in the generated source.\n *\n * and an object is returned with the following properties:\n *\n * - source: The original source file, or null.\n * - line: The line number in the original source, or null.\n * - column: The column number in the original source, or null.\n * - name: The original identifier, or null.\n */\nIndexedSourceMapConsumer.prototype.originalPositionFor =\n function IndexedSourceMapConsumer_originalPositionFor(aArgs) {\n var needle = {\n generatedLine: util.getArg(aArgs, 'line'),\n generatedColumn: util.getArg(aArgs, 'column')\n };\n\n // Find the section containing the generated position we're trying to map\n // to an original position.\n var sectionIndex = binarySearch.search(needle, this._sections,\n function(needle, section) {\n var cmp = needle.generatedLine - section.generatedOffset.generatedLine;\n if (cmp) {\n return cmp;\n }\n\n return (needle.generatedColumn -\n section.generatedOffset.generatedColumn);\n });\n var section = this._sections[sectionIndex];\n\n if (!section) {\n return {\n source: null,\n line: null,\n column: null,\n name: null\n };\n }\n\n return section.consumer.originalPositionFor({\n line: needle.generatedLine -\n (section.generatedOffset.generatedLine - 1),\n column: needle.generatedColumn -\n (section.generatedOffset.generatedLine === needle.generatedLine\n ? section.generatedOffset.generatedColumn - 1\n : 0),\n bias: aArgs.bias\n });\n };\n\n/**\n * Return true if we have the source content for every source in the source\n * map, false otherwise.\n */\nIndexedSourceMapConsumer.prototype.hasContentsOfAllSources =\n function IndexedSourceMapConsumer_hasContentsOfAllSources() {\n return this._sections.every(function (s) {\n return s.consumer.hasContentsOfAllSources();\n });\n };\n\n/**\n * Returns the original source content. The only argument is the url of the\n * original source file. Returns null if no original source content is\n * available.\n */\nIndexedSourceMapConsumer.prototype.sourceContentFor =\n function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {\n for (var i = 0; i < this._sections.length; i++) {\n var section = this._sections[i];\n\n var content = section.consumer.sourceContentFor(aSource, true);\n if (content) {\n return content;\n }\n }\n if (nullOnMissing) {\n return null;\n }\n else {\n throw new Error('\"' + aSource + '\" is not in the SourceMap.');\n }\n };\n\n/**\n * Returns the generated line and column information for the original source,\n * line, and column positions provided. The only argument is an object with\n * the following properties:\n *\n * - source: The filename of the original source.\n * - line: The line number in the original source.\n * - column: The column number in the original source.\n *\n * and an object is returned with the following properties:\n *\n * - line: The line number in the generated source, or null.\n * - column: The column number in the generated source, or null.\n */\nIndexedSourceMapConsumer.prototype.generatedPositionFor =\n function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {\n for (var i = 0; i < this._sections.length; i++) {\n var section = this._sections[i];\n\n // Only consider this section if the requested source is in the list of\n // sources of the consumer.\n if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {\n continue;\n }\n var generatedPosition = section.consumer.generatedPositionFor(aArgs);\n if (generatedPosition) {\n var ret = {\n line: generatedPosition.line +\n (section.generatedOffset.generatedLine - 1),\n column: generatedPosition.column +\n (section.generatedOffset.generatedLine === generatedPosition.line\n ? section.generatedOffset.generatedColumn - 1\n : 0)\n };\n return ret;\n }\n }\n\n return {\n line: null,\n column: null\n };\n };\n\n/**\n * Parse the mappings in a string in to a data structure which we can easily\n * query (the ordered arrays in the `this.__generatedMappings` and\n * `this.__originalMappings` properties).\n */\nIndexedSourceMapConsumer.prototype._parseMappings =\n function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {\n this.__generatedMappings = [];\n this.__originalMappings = [];\n for (var i = 0; i < this._sections.length; i++) {\n var section = this._sections[i];\n var sectionMappings = section.consumer._generatedMappings;\n for (var j = 0; j < sectionMappings.length; j++) {\n var mapping = sectionMappings[j];\n\n var source = section.consumer._sources.at(mapping.source);\n if (section.consumer.sourceRoot !== null) {\n source = util.join(section.consumer.sourceRoot, source);\n }\n this._sources.add(source);\n source = this._sources.indexOf(source);\n\n var name = section.consumer._names.at(mapping.name);\n this._names.add(name);\n name = this._names.indexOf(name);\n\n // The mappings coming from the consumer for the section have\n // generated positions relative to the start of the section, so we\n // need to offset them to be relative to the start of the concatenated\n // generated file.\n var adjustedMapping = {\n source: source,\n generatedLine: mapping.generatedLine +\n (section.generatedOffset.generatedLine - 1),\n generatedColumn: mapping.generatedColumn +\n (section.generatedOffset.generatedLine === mapping.generatedLine\n ? section.generatedOffset.generatedColumn - 1\n : 0),\n originalLine: mapping.originalLine,\n originalColumn: mapping.originalColumn,\n name: name\n };\n\n this.__generatedMappings.push(adjustedMapping);\n if (typeof adjustedMapping.originalLine === 'number') {\n this.__originalMappings.push(adjustedMapping);\n }\n }\n }\n\n quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);\n quickSort(this.__originalMappings, util.compareByOriginalPositions);\n };\n\nexports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/source-map-consumer.js\n// module id = 7\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nexports.GREATEST_LOWER_BOUND = 1;\nexports.LEAST_UPPER_BOUND = 2;\n\n/**\n * Recursive implementation of binary search.\n *\n * @param aLow Indices here and lower do not contain the needle.\n * @param aHigh Indices here and higher do not contain the needle.\n * @param aNeedle The element being searched for.\n * @param aHaystack The non-empty array being searched.\n * @param aCompare Function which takes two elements and returns -1, 0, or 1.\n * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or\n * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the\n * closest element that is smaller than or greater than the one we are\n * searching for, respectively, if the exact element cannot be found.\n */\nfunction recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {\n // This function terminates when one of the following is true:\n //\n // 1. We find the exact element we are looking for.\n //\n // 2. We did not find the exact element, but we can return the index of\n // the next-closest element.\n //\n // 3. We did not find the exact element, and there is no next-closest\n // element than the one we are searching for, so we return -1.\n var mid = Math.floor((aHigh - aLow) / 2) + aLow;\n var cmp = aCompare(aNeedle, aHaystack[mid], true);\n if (cmp === 0) {\n // Found the element we are looking for.\n return mid;\n }\n else if (cmp > 0) {\n // Our needle is greater than aHaystack[mid].\n if (aHigh - mid > 1) {\n // The element is in the upper half.\n return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);\n }\n\n // The exact needle element was not found in this haystack. Determine if\n // we are in termination case (3) or (2) and return the appropriate thing.\n if (aBias == exports.LEAST_UPPER_BOUND) {\n return aHigh < aHaystack.length ? aHigh : -1;\n } else {\n return mid;\n }\n }\n else {\n // Our needle is less than aHaystack[mid].\n if (mid - aLow > 1) {\n // The element is in the lower half.\n return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);\n }\n\n // we are in termination case (3) or (2) and return the appropriate thing.\n if (aBias == exports.LEAST_UPPER_BOUND) {\n return mid;\n } else {\n return aLow < 0 ? -1 : aLow;\n }\n }\n}\n\n/**\n * This is an implementation of binary search which will always try and return\n * the index of the closest element if there is no exact hit. This is because\n * mappings between original and generated line/col pairs are single points,\n * and there is an implicit region between each of them, so a miss just means\n * that you aren't on the very start of a region.\n *\n * @param aNeedle The element you are looking for.\n * @param aHaystack The array that is being searched.\n * @param aCompare A function which takes the needle and an element in the\n * array and returns -1, 0, or 1 depending on whether the needle is less\n * than, equal to, or greater than the element, respectively.\n * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or\n * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the\n * closest element that is smaller than or greater than the one we are\n * searching for, respectively, if the exact element cannot be found.\n * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.\n */\nexports.search = function search(aNeedle, aHaystack, aCompare, aBias) {\n if (aHaystack.length === 0) {\n return -1;\n }\n\n var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,\n aCompare, aBias || exports.GREATEST_LOWER_BOUND);\n if (index < 0) {\n return -1;\n }\n\n // We have found either the exact element, or the next-closest element than\n // the one we are searching for. However, there may be more than one such\n // element. Make sure we always return the smallest of these.\n while (index - 1 >= 0) {\n if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {\n break;\n }\n --index;\n }\n\n return index;\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/binary-search.js\n// module id = 8\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\n// It turns out that some (most?) JavaScript engines don't self-host\n// `Array.prototype.sort`. This makes sense because C++ will likely remain\n// faster than JS when doing raw CPU-intensive sorting. However, when using a\n// custom comparator function, calling back and forth between the VM's C++ and\n// JIT'd JS is rather slow *and* loses JIT type information, resulting in\n// worse generated code for the comparator function than would be optimal. In\n// fact, when sorting with a comparator, these costs outweigh the benefits of\n// sorting in C++. By using our own JS-implemented Quick Sort (below), we get\n// a ~3500ms mean speed-up in `bench/bench.html`.\n\n/**\n * Swap the elements indexed by `x` and `y` in the array `ary`.\n *\n * @param {Array} ary\n * The array.\n * @param {Number} x\n * The index of the first item.\n * @param {Number} y\n * The index of the second item.\n */\nfunction swap(ary, x, y) {\n var temp = ary[x];\n ary[x] = ary[y];\n ary[y] = temp;\n}\n\n/**\n * Returns a random integer within the range `low .. high` inclusive.\n *\n * @param {Number} low\n * The lower bound on the range.\n * @param {Number} high\n * The upper bound on the range.\n */\nfunction randomIntInRange(low, high) {\n return Math.round(low + (Math.random() * (high - low)));\n}\n\n/**\n * The Quick Sort algorithm.\n *\n * @param {Array} ary\n * An array to sort.\n * @param {function} comparator\n * Function to use to compare two items.\n * @param {Number} p\n * Start index of the array\n * @param {Number} r\n * End index of the array\n */\nfunction doQuickSort(ary, comparator, p, r) {\n // If our lower bound is less than our upper bound, we (1) partition the\n // array into two pieces and (2) recurse on each half. If it is not, this is\n // the empty array and our base case.\n\n if (p < r) {\n // (1) Partitioning.\n //\n // The partitioning chooses a pivot between `p` and `r` and moves all\n // elements that are less than or equal to the pivot to the before it, and\n // all the elements that are greater than it after it. The effect is that\n // once partition is done, the pivot is in the exact place it will be when\n // the array is put in sorted order, and it will not need to be moved\n // again. This runs in O(n) time.\n\n // Always choose a random pivot so that an input array which is reverse\n // sorted does not cause O(n^2) running time.\n var pivotIndex = randomIntInRange(p, r);\n var i = p - 1;\n\n swap(ary, pivotIndex, r);\n var pivot = ary[r];\n\n // Immediately after `j` is incremented in this loop, the following hold\n // true:\n //\n // * Every element in `ary[p .. i]` is less than or equal to the pivot.\n //\n // * Every element in `ary[i+1 .. j-1]` is greater than the pivot.\n for (var j = p; j < r; j++) {\n if (comparator(ary[j], pivot) <= 0) {\n i += 1;\n swap(ary, i, j);\n }\n }\n\n swap(ary, i + 1, j);\n var q = i + 1;\n\n // (2) Recurse on each half.\n\n doQuickSort(ary, comparator, p, q - 1);\n doQuickSort(ary, comparator, q + 1, r);\n }\n}\n\n/**\n * Sort the given array in-place with the given comparator function.\n *\n * @param {Array} ary\n * An array to sort.\n * @param {function} comparator\n * Function to use to compare two items.\n */\nexports.quickSort = function (ary, comparator) {\n doQuickSort(ary, comparator, 0, ary.length - 1);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/quick-sort.js\n// module id = 9\n// module chunks = 0","/* -*- Mode: js; js-indent-level: 2; -*- */\n/*\n * Copyright 2011 Mozilla Foundation and contributors\n * Licensed under the New BSD license. See LICENSE or:\n * http://opensource.org/licenses/BSD-3-Clause\n */\n\nvar SourceMapGenerator = require('./source-map-generator').SourceMapGenerator;\nvar util = require('./util');\n\n// Matches a Windows-style `\\r\\n` newline or a `\\n` newline used by all other\n// operating systems these days (capturing the result).\nvar REGEX_NEWLINE = /(\\r?\\n)/;\n\n// Newline character code for charCodeAt() comparisons\nvar NEWLINE_CODE = 10;\n\n// Private symbol for identifying `SourceNode`s when multiple versions of\n// the source-map library are loaded. This MUST NOT CHANGE across\n// versions!\nvar isSourceNode = \"$$$isSourceNode$$$\";\n\n/**\n * SourceNodes provide a way to abstract over interpolating/concatenating\n * snippets of generated JavaScript source code while maintaining the line and\n * column information associated with the original source code.\n *\n * @param aLine The original line number.\n * @param aColumn The original column number.\n * @param aSource The original source's filename.\n * @param aChunks Optional. An array of strings which are snippets of\n * generated JS, or other SourceNodes.\n * @param aName The original identifier.\n */\nfunction SourceNode(aLine, aColumn, aSource, aChunks, aName) {\n this.children = [];\n this.sourceContents = {};\n this.line = aLine == null ? null : aLine;\n this.column = aColumn == null ? null : aColumn;\n this.source = aSource == null ? null : aSource;\n this.name = aName == null ? null : aName;\n this[isSourceNode] = true;\n if (aChunks != null) this.add(aChunks);\n}\n\n/**\n * Creates a SourceNode from generated code and a SourceMapConsumer.\n *\n * @param aGeneratedCode The generated code\n * @param aSourceMapConsumer The SourceMap for the generated code\n * @param aRelativePath Optional. The path that relative sources in the\n * SourceMapConsumer should be relative to.\n */\nSourceNode.fromStringWithSourceMap =\n function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {\n // The SourceNode we want to fill with the generated code\n // and the SourceMap\n var node = new SourceNode();\n\n // All even indices of this array are one line of the generated code,\n // while all odd indices are the newlines between two adjacent lines\n // (since `REGEX_NEWLINE` captures its match).\n // Processed fragments are accessed by calling `shiftNextLine`.\n var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);\n var remainingLinesIndex = 0;\n var shiftNextLine = function() {\n var lineContents = getNextLine();\n // The last line of a file might not have a newline.\n var newLine = getNextLine() || \"\";\n return lineContents + newLine;\n\n function getNextLine() {\n return remainingLinesIndex < remainingLines.length ?\n remainingLines[remainingLinesIndex++] : undefined;\n }\n };\n\n // We need to remember the position of \"remainingLines\"\n var lastGeneratedLine = 1, lastGeneratedColumn = 0;\n\n // The generate SourceNodes we need a code range.\n // To extract it current and last mapping is used.\n // Here we store the last mapping.\n var lastMapping = null;\n\n aSourceMapConsumer.eachMapping(function (mapping) {\n if (lastMapping !== null) {\n // We add the code from \"lastMapping\" to \"mapping\":\n // First check if there is a new line in between.\n if (lastGeneratedLine < mapping.generatedLine) {\n // Associate first line with \"lastMapping\"\n addMappingWithCode(lastMapping, shiftNextLine());\n lastGeneratedLine++;\n lastGeneratedColumn = 0;\n // The remaining code is added without mapping\n } else {\n // There is no new line in between.\n // Associate the code between \"lastGeneratedColumn\" and\n // \"mapping.generatedColumn\" with \"lastMapping\"\n var nextLine = remainingLines[remainingLinesIndex];\n var code = nextLine.substr(0, mapping.generatedColumn -\n lastGeneratedColumn);\n remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn -\n lastGeneratedColumn);\n lastGeneratedColumn = mapping.generatedColumn;\n addMappingWithCode(lastMapping, code);\n // No more remaining code, continue\n lastMapping = mapping;\n return;\n }\n }\n // We add the generated code until the first mapping\n // to the SourceNode without any mapping.\n // Each line is added as separate string.\n while (lastGeneratedLine < mapping.generatedLine) {\n node.add(shiftNextLine());\n lastGeneratedLine++;\n }\n if (lastGeneratedColumn < mapping.generatedColumn) {\n var nextLine = remainingLines[remainingLinesIndex];\n node.add(nextLine.substr(0, mapping.generatedColumn));\n remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn);\n lastGeneratedColumn = mapping.generatedColumn;\n }\n lastMapping = mapping;\n }, this);\n // We have processed all mappings.\n if (remainingLinesIndex < remainingLines.length) {\n if (lastMapping) {\n // Associate the remaining code in the current line with \"lastMapping\"\n addMappingWithCode(lastMapping, shiftNextLine());\n }\n // and add the remaining lines without any mapping\n node.add(remainingLines.splice(remainingLinesIndex).join(\"\"));\n }\n\n // Copy sourcesContent into SourceNode\n aSourceMapConsumer.sources.forEach(function (sourceFile) {\n var content = aSourceMapConsumer.sourceContentFor(sourceFile);\n if (content != null) {\n if (aRelativePath != null) {\n sourceFile = util.join(aRelativePath, sourceFile);\n }\n node.setSourceContent(sourceFile, content);\n }\n });\n\n return node;\n\n function addMappingWithCode(mapping, code) {\n if (mapping === null || mapping.source === undefined) {\n node.add(code);\n } else {\n var source = aRelativePath\n ? util.join(aRelativePath, mapping.source)\n : mapping.source;\n node.add(new SourceNode(mapping.originalLine,\n mapping.originalColumn,\n source,\n code,\n mapping.name));\n }\n }\n };\n\n/**\n * Add a chunk of generated JS to this source node.\n *\n * @param aChunk A string snippet of generated JS code, another instance of\n * SourceNode, or an array where each member is one of those things.\n */\nSourceNode.prototype.add = function SourceNode_add(aChunk) {\n if (Array.isArray(aChunk)) {\n aChunk.forEach(function (chunk) {\n this.add(chunk);\n }, this);\n }\n else if (aChunk[isSourceNode] || typeof aChunk === \"string\") {\n if (aChunk) {\n this.children.push(aChunk);\n }\n }\n else {\n throw new TypeError(\n \"Expected a SourceNode, string, or an array of SourceNodes and strings. Got \" + aChunk\n );\n }\n return this;\n};\n\n/**\n * Add a chunk of generated JS to the beginning of this source node.\n *\n * @param aChunk A string snippet of generated JS code, another instance of\n * SourceNode, or an array where each member is one of those things.\n */\nSourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {\n if (Array.isArray(aChunk)) {\n for (var i = aChunk.length-1; i >= 0; i--) {\n this.prepend(aChunk[i]);\n }\n }\n else if (aChunk[isSourceNode] || typeof aChunk === \"string\") {\n this.children.unshift(aChunk);\n }\n else {\n throw new TypeError(\n \"Expected a SourceNode, string, or an array of SourceNodes and strings. Got \" + aChunk\n );\n }\n return this;\n};\n\n/**\n * Walk over the tree of JS snippets in this node and its children. The\n * walking function is called once for each snippet of JS and is passed that\n * snippet and the its original associated source's line/column location.\n *\n * @param aFn The traversal function.\n */\nSourceNode.prototype.walk = function SourceNode_walk(aFn) {\n var chunk;\n for (var i = 0, len = this.children.length; i < len; i++) {\n chunk = this.children[i];\n if (chunk[isSourceNode]) {\n chunk.walk(aFn);\n }\n else {\n if (chunk !== '') {\n aFn(chunk, { source: this.source,\n line: this.line,\n column: this.column,\n name: this.name });\n }\n }\n }\n};\n\n/**\n * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between\n * each of `this.children`.\n *\n * @param aSep The separator.\n */\nSourceNode.prototype.join = function SourceNode_join(aSep) {\n var newChildren;\n var i;\n var len = this.children.length;\n if (len > 0) {\n newChildren = [];\n for (i = 0; i < len-1; i++) {\n newChildren.push(this.children[i]);\n newChildren.push(aSep);\n }\n newChildren.push(this.children[i]);\n this.children = newChildren;\n }\n return this;\n};\n\n/**\n * Call String.prototype.replace on the very right-most source snippet. Useful\n * for trimming whitespace from the end of a source node, etc.\n *\n * @param aPattern The pattern to replace.\n * @param aReplacement The thing to replace the pattern with.\n */\nSourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {\n var lastChild = this.children[this.children.length - 1];\n if (lastChild[isSourceNode]) {\n lastChild.replaceRight(aPattern, aReplacement);\n }\n else if (typeof lastChild === 'string') {\n this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);\n }\n else {\n this.children.push(''.replace(aPattern, aReplacement));\n }\n return this;\n};\n\n/**\n * Set the source content for a source file. This will be added to the SourceMapGenerator\n * in the sourcesContent field.\n *\n * @param aSourceFile The filename of the source file\n * @param aSourceContent The content of the source file\n */\nSourceNode.prototype.setSourceContent =\n function SourceNode_setSourceContent(aSourceFile, aSourceContent) {\n this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;\n };\n\n/**\n * Walk over the tree of SourceNodes. The walking function is called for each\n * source file content and is passed the filename and source content.\n *\n * @param aFn The traversal function.\n */\nSourceNode.prototype.walkSourceContents =\n function SourceNode_walkSourceContents(aFn) {\n for (var i = 0, len = this.children.length; i < len; i++) {\n if (this.children[i][isSourceNode]) {\n this.children[i].walkSourceContents(aFn);\n }\n }\n\n var sources = Object.keys(this.sourceContents);\n for (var i = 0, len = sources.length; i < len; i++) {\n aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);\n }\n };\n\n/**\n * Return the string representation of this source node. Walks over the tree\n * and concatenates all the various snippets together to one string.\n */\nSourceNode.prototype.toString = function SourceNode_toString() {\n var str = \"\";\n this.walk(function (chunk) {\n str += chunk;\n });\n return str;\n};\n\n/**\n * Returns the string representation of this source node along with a source\n * map.\n */\nSourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {\n var generated = {\n code: \"\",\n line: 1,\n column: 0\n };\n var map = new SourceMapGenerator(aArgs);\n var sourceMappingActive = false;\n var lastOriginalSource = null;\n var lastOriginalLine = null;\n var lastOriginalColumn = null;\n var lastOriginalName = null;\n this.walk(function (chunk, original) {\n generated.code += chunk;\n if (original.source !== null\n && original.line !== null\n && original.column !== null) {\n if(lastOriginalSource !== original.source\n || lastOriginalLine !== original.line\n || lastOriginalColumn !== original.column\n || lastOriginalName !== original.name) {\n map.addMapping({\n source: original.source,\n original: {\n line: original.line,\n column: original.column\n },\n generated: {\n line: generated.line,\n column: generated.column\n },\n name: original.name\n });\n }\n lastOriginalSource = original.source;\n lastOriginalLine = original.line;\n lastOriginalColumn = original.column;\n lastOriginalName = original.name;\n sourceMappingActive = true;\n } else if (sourceMappingActive) {\n map.addMapping({\n generated: {\n line: generated.line,\n column: generated.column\n }\n });\n lastOriginalSource = null;\n sourceMappingActive = false;\n }\n for (var idx = 0, length = chunk.length; idx < length; idx++) {\n if (chunk.charCodeAt(idx) === NEWLINE_CODE) {\n generated.line++;\n generated.column = 0;\n // Mappings end at eol\n if (idx + 1 === length) {\n lastOriginalSource = null;\n sourceMappingActive = false;\n } else if (sourceMappingActive) {\n map.addMapping({\n source: original.source,\n original: {\n line: original.line,\n column: original.column\n },\n generated: {\n line: generated.line,\n column: generated.column\n },\n name: original.name\n });\n }\n } else {\n generated.column++;\n }\n }\n });\n this.walkSourceContents(function (sourceFile, sourceContent) {\n map.setSourceContent(sourceFile, sourceContent);\n });\n\n return { code: generated.code, map: map };\n};\n\nexports.SourceNode = SourceNode;\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// ./lib/source-node.js\n// module id = 10\n// module chunks = 0"],"sourceRoot":""} \ No newline at end of file diff --git a/node_modules/yaml/browser/dist/PlainValue-ff5147c6.js b/node_modules/yaml/browser/dist/PlainValue-ff5147c6.js new file mode 100644 index 00000000..0456a481 --- /dev/null +++ b/node_modules/yaml/browser/dist/PlainValue-ff5147c6.js @@ -0,0 +1,1277 @@ +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 { + Date.prototype.toString.call(Reflect.construct(Date, [], 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 () { + 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) { + if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { + if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { + 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 it, + 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 () { + _createClass(Range, null, [{ + key: "copy", + value: function copy(orig) { + return new Range(orig.start, orig.end); + } + }]); + + 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; + } + }]); + + return Range; +}(); + +/** Root class of all nodes */ + +var Node = /*#__PURE__*/function () { + _createClass(Node, null, [{ + 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 + }; + } + }]); + + 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: "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: "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: "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: "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], + 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; + } + }]); + + 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: "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: "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: "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/node_modules/yaml/browser/dist/Schema-2bf2c74e.js b/node_modules/yaml/browser/dist/Schema-2bf2c74e.js new file mode 100644 index 00000000..1f1c0135 --- /dev/null +++ b/node_modules/yaml/browser/dist/Schema-2bf2c74e.js @@ -0,0 +1,679 @@ +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-ff5147c6.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-04825f30.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-0e4b70d3.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 = function intIdentify(value) { + return typeof value === 'bigint' || Number.isInteger(value); +}; + +var intResolve = function intResolve(src, part, radix) { + return intOptions.asBigInt ? BigInt(src) : parseInt(part, radix); +}; + +function intStringify(node, radix, prefix) { + var value = node.value; + if (intIdentify(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(value) && value >= 0; + }, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'OCT', + test: /^0o([0-7]+)$/, + resolve: function resolve(str, oct) { + return intResolve(str, oct, 8); + }, + options: intOptions, + stringify: function stringify(node) { + return intStringify(node, 8, '0o'); + } +}; +var intObj = { + identify: intIdentify, + default: true, + tag: 'tag:yaml.org,2002:int', + test: /^[-+]?[0-9]+$/, + resolve: function resolve(str) { + return intResolve(str, str, 10); + }, + options: intOptions, + stringify: stringifyNumber +}; +var hexObj = { + identify: function identify(value) { + return intIdentify(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(str, hex, 16); + }, + options: intOptions, + stringify: function stringify(node) { + return intStringify(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$2 = function intIdentify(value) { + return typeof value === 'bigint' || Number.isInteger(value); +}; + +function intResolve$1(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$1(node, radix, prefix) { + var value = node.value; + + if (intIdentify$2(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$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'BIN', + test: /^([-+]?)0b([0-1_]+)$/, + resolve: function resolve(str, sign, bin) { + return intResolve$1(sign, bin, 2); + }, + stringify: function stringify(node) { + return intStringify$1(node, 2, '0b'); + } +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'OCT', + test: /^([-+]?)0([0-7_]+)$/, + resolve: function resolve(str, sign, oct) { + return intResolve$1(sign, oct, 8); + }, + stringify: function stringify(node) { + return intStringify$1(node, 8, '0'); + } +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + test: /^([-+]?)([0-9][0-9_]*)$/, + resolve: function resolve(str, sign, abs) { + return intResolve$1(sign, abs, 10); + }, + stringify: stringifyNumber +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'HEX', + test: /^([-+]?)0x([0-9a-fA-F_]+)$/, + resolve: function resolve(str, sign, hex) { + return intResolve$1(sign, hex, 16); + }, + stringify: function stringify(node) { + return intStringify$1(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 (_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 = {}; + + 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/node_modules/yaml/browser/dist/index.js b/node_modules/yaml/browser/dist/index.js new file mode 100644 index 00000000..2d654369 --- /dev/null +++ b/node_modules/yaml/browser/dist/index.js @@ -0,0 +1,1004 @@ +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-ff5147c6.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-04825f30.js'; +import { S as Schema } from './Schema-2bf2c74e.js'; +import { w as warn } from './warnings-0e4b70d3.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(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 () { + _createClass(Anchors, null, [{ + key: "validAnchorNode", + value: function validAnchorNode(node) { + return node instanceof Scalar || node instanceof YAMLSeq || node instanceof YAMLMap; + } + }]); + + function Anchors(prefix) { + _classCallCheck(this, Anchors); + + _defineProperty(this, "map", {}); + + 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; + } + }]); + + 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 = /*#__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 // 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: {}, + doc: this, + indent: '', + indentStep: ' '.repeat(indentSize), + stringify: stringify // 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(this.contents, ctx, function () { + return contentComment = null; + }, onChompKeep); + lines.push(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'; + } + }]); + + return Document; +}(); + +_defineProperty(Document, "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.defaults[defaultOptions.version], defaultOptions); + var schema = new Schema(options); + return schema.createNode(value, wrapScalars, tag); +} + +var Document$1 = /*#__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); + +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$1(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$1(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$1(value, options) { + var doc = new Document$1(options); + doc.contents = value; + return String(doc); +} + +var YAML = { + createNode: createNode, + defaultOptions: defaultOptions, + Document: Document$1, + parse: parse, + parseAllDocuments: parseAllDocuments, + parseCST: parse$1, + parseDocument: parseDocument, + scalarOptions: scalarOptions, + stringify: stringify$1 +}; + +export { YAML }; diff --git a/node_modules/yaml/browser/dist/legacy-exports.js b/node_modules/yaml/browser/dist/legacy-exports.js new file mode 100644 index 00000000..88242642 --- /dev/null +++ b/node_modules/yaml/browser/dist/legacy-exports.js @@ -0,0 +1,3 @@ +import './PlainValue-ff5147c6.js'; +import './resolveSeq-04825f30.js'; +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-0e4b70d3.js'; diff --git a/node_modules/yaml/browser/dist/parse-cst.js b/node_modules/yaml/browser/dist/parse-cst.js new file mode 100644 index 00000000..2789fad0 --- /dev/null +++ b/node_modules/yaml/browser/dist/parse-cst.js @@ -0,0 +1,1904 @@ +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-ff5147c6.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: "parse", + + /** + * 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 + */ + value: function parse(context, start) { + this.context = context; + this.range = new Range(start, start + 1); + return start + 1; + } + }, { + key: "includesTrailingLines", + get: function get() { + // This is never called from anywhere, but if it were, + // this is the value it should return. + return true; + } + }]); + + 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: "parse", + + /** + * @param {ParseContext} context + * @param {number} start - Index of first character + * @returns {number} - Index of the character after this + */ + 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); + } + }, { + key: "includesTrailingLines", + get: function get() { + return !!this.node && this.node.includesTrailingLines; + } + }]); + + 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); + + _createClass(Collection, null, [{ + 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); + } + }]); + + 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: "parse", + + /** + * @param {ParseContext} context + * @param {number} start - Index of first character + * @returns {number} - Index of the character after this + */ + 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: "includesTrailingLines", + get: function get() { + return this.items.length > 0; + } + }]); + + 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: "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; + } + }, { + key: "parameters", + get: function get() { + var raw = this.rawValue; + return raw ? raw.trim().split(/[ \t]+/) : []; + } + }]); + + return Directive; +}(Node); + +var Document = /*#__PURE__*/function (_Node) { + _inherits(Document, _Node); + + var _super = _createSuper(Document); + + _createClass(Document, null, [{ + key: "startCommentOrEndBlankLine", + value: function startCommentOrEndBlankLine(src, start) { + var offset = Node.endOfWhiteSpace(src, start); + var ch = src[offset]; + return ch === '#' || ch === '\n' ? offset : start; + } + }]); + + 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; + } + }]); + + 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", + + /** + * 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 + */ + value: 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: "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$context = this.context, + indent = _this$context.indent, + src = _this$context.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 _ch = 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 (_ch && _ch !== '\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; + } + }, { + 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$context2 = this.context, + indent = _this$context2.indent, + src = _this$context2.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 _ch2 = src[i]; + + if (_ch2 === '\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 && (_ch2 === ' ' || _ch2 === '\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'; + } + }]); + + 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: "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: "strValue", + + /** + * @returns {string | { str: string, errors: YAMLSyntaxError[] }} + */ + get: 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: "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: "parse", + + /** + * 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 + */ + 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: "strValue", + + /** + * @returns {string | { str: string, errors: YAMLSyntaxError[] }} + */ + get: 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; + } + }], [{ + 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 () { + _createClass(ParseContext, null, [{ + 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; + } + } + }]); + + 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 lineStart = offset + 1; + var inEnd = Node.endOfIndent(src, lineStart); + var indentDiff = inEnd - (lineStart + this.indent); + var noIndicatorAsIndent = parent.type === Type.SEQ_ITEM && parent.context.atLineStart; + if (!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 + */ + + }]); + + 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/node_modules/yaml/browser/dist/resolveSeq-04825f30.js b/node_modules/yaml/browser/dist/resolveSeq-04825f30.js new file mode 100644 index 00000000..231fd7e6 --- /dev/null +++ b/node_modules/yaml/browser/dist/resolveSeq-04825f30.js @@ -0,0 +1,2373 @@ +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-ff5147c6.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]; + var o = Number.isInteger(k) && k >= 0 ? [] : {}; + o[k] = v; + 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: {}, + 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: "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); + map[stringKey] = toJSON(this.value, stringKey, ctx); + } + + 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 Collection || key.type === Type.BLOCK_FOLDED || key.type === Type.BLOCK_LITERAL); + 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 (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 ? 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); + } + + if (chompKeep && !valueComment && onChompKeep) onChompKeep(); + return addComment(str + ws + valueStr, ctx.indent, valueComment); + } + }, { + 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); + } + } + }]); + + 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); + + _createClass(Alias, null, [{ + 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, "]")); + } + }]); + + function Alias(source) { + var _this; + + _classCallCheck(this, Alias); + + _this = _super.call(this); + _this.source = source; + _this.type = Type.ALIAS; + return _this; + } + + _createClass(Alias, [{ + 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: "tag", + set: function set(t) { + throw new Error('Alias nodes cannot have tags'); + } + }]); + + 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)) map[key] = value; + } + } + } 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 + * @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 - (typeof indentAtStart === 'number' ? indentAtStart : indent.length); + var split = undefined; + var prev = undefined; + var overflow = false; + var i = -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 === '\\') { + switch (text[i + 1]) { + case 'x': + i += 3; + break; + + case 'u': + i += 5; + break; + + case 'U': + i += 9; + break; + + default: + i += 1; + } + } + + 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; + } // i - 2 accounts for not-dropped last char + newline-escaping \ + + + folds.push(i - 2); + escapedFolds[i - 2] = true; + end = i - 2 + 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 (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, limit) { + 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/node_modules/yaml/browser/dist/types.js b/node_modules/yaml/browser/dist/types.js new file mode 100644 index 00000000..01b525fb --- /dev/null +++ b/node_modules/yaml/browser/dist/types.js @@ -0,0 +1,4 @@ +import './PlainValue-ff5147c6.js'; +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-04825f30.js'; +export { S as Schema } from './Schema-2bf2c74e.js'; +import './warnings-0e4b70d3.js'; diff --git a/node_modules/yaml/browser/dist/util.js b/node_modules/yaml/browser/dist/util.js new file mode 100644 index 00000000..987eab87 --- /dev/null +++ b/node_modules/yaml/browser/dist/util.js @@ -0,0 +1,2 @@ +export { T as Type, i as YAMLError, o as YAMLReferenceError, g as YAMLSemanticError, Y as YAMLSyntaxError, f as YAMLWarning } from './PlainValue-ff5147c6.js'; +export { l as findPair, g as parseMap, h as parseSeq, k as stringifyNumber, c as stringifyString, t as toJSON } from './resolveSeq-04825f30.js'; diff --git a/node_modules/yaml/browser/dist/warnings-0e4b70d3.js b/node_modules/yaml/browser/dist/warnings-0e4b70d3.js new file mode 100644 index 00000000..41504921 --- /dev/null +++ b/node_modules/yaml/browser/dist/warnings-0e4b70d3.js @@ -0,0 +1,499 @@ +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-ff5147c6.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-04825f30.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/node_modules/yaml/dist/Document-2cf6b08c.js b/node_modules/yaml/dist/Document-2cf6b08c.js new file mode 100644 index 00000000..6a3b9479 --- /dev/null +++ b/node_modules/yaml/dist/Document-2cf6b08c.js @@ -0,0 +1,757 @@ +'use strict'; + +var PlainValue = require('./PlainValue-ec8e588e.js'); +var resolveSeq = require('./resolveSeq-4a68b39b.js'); +var Schema = require('./Schema-42e9705c.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", {}); + + 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: {}, + 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/node_modules/yaml/dist/PlainValue-ec8e588e.js b/node_modules/yaml/dist/PlainValue-ec8e588e.js new file mode 100644 index 00000000..db8a14e3 --- /dev/null +++ b/node_modules/yaml/dist/PlainValue-ec8e588e.js @@ -0,0 +1,876 @@ +'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/node_modules/yaml/dist/Schema-42e9705c.js b/node_modules/yaml/dist/Schema-42e9705c.js new file mode 100644 index 00000000..172f3e8e --- /dev/null +++ b/node_modules/yaml/dist/Schema-42e9705c.js @@ -0,0 +1,522 @@ +'use strict'; + +var PlainValue = require('./PlainValue-ec8e588e.js'); +var resolveSeq = require('./resolveSeq-4a68b39b.js'); +var warnings = require('./warnings-39684f17.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 = value => typeof value === 'bigint' || Number.isInteger(value); + +const intResolve = (src, part, radix) => resolveSeq.intOptions.asBigInt ? BigInt(src) : parseInt(part, radix); + +function intStringify(node, radix, prefix) { + const { + value + } = node; + if (intIdentify(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(value) && value >= 0, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'OCT', + test: /^0o([0-7]+)$/, + resolve: (str, oct) => intResolve(str, oct, 8), + options: resolveSeq.intOptions, + stringify: node => intStringify(node, 8, '0o') +}; +const intObj = { + identify: intIdentify, + default: true, + tag: 'tag:yaml.org,2002:int', + test: /^[-+]?[0-9]+$/, + resolve: str => intResolve(str, str, 10), + options: resolveSeq.intOptions, + stringify: resolveSeq.stringifyNumber +}; +const hexObj = { + identify: value => intIdentify(value) && value >= 0, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'HEX', + test: /^0x([0-9a-fA-F]+)$/, + resolve: (str, hex) => intResolve(str, hex, 16), + options: resolveSeq.intOptions, + stringify: node => intStringify(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$2 = value => typeof value === 'bigint' || Number.isInteger(value); + +function intResolve$1(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$1(node, radix, prefix) { + const { + value + } = node; + + if (intIdentify$2(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$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'BIN', + test: /^([-+]?)0b([0-1_]+)$/, + resolve: (str, sign, bin) => intResolve$1(sign, bin, 2), + stringify: node => intStringify$1(node, 2, '0b') +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'OCT', + test: /^([-+]?)0([0-7_]+)$/, + resolve: (str, sign, oct) => intResolve$1(sign, oct, 8), + stringify: node => intStringify$1(node, 8, '0') +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + test: /^([-+]?)([0-9][0-9_]*)$/, + resolve: (str, sign, abs) => intResolve$1(sign, abs, 10), + stringify: resolveSeq.stringifyNumber +}, { + identify: intIdentify$2, + default: true, + tag: 'tag:yaml.org,2002:int', + format: 'HEX', + test: /^([-+]?)0x([0-9a-fA-F_]+)$/, + resolve: (str, sign, hex) => intResolve$1(sign, hex, 16), + stringify: node => intStringify$1(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 (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 = {}; + + 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/node_modules/yaml/dist/index.js b/node_modules/yaml/dist/index.js new file mode 100644 index 00000000..df2f8b02 --- /dev/null +++ b/node_modules/yaml/dist/index.js @@ -0,0 +1,79 @@ +'use strict'; + +var PlainValue = require('./PlainValue-ec8e588e.js'); +var parseCst = require('./parse-cst.js'); +require('./resolveSeq-4a68b39b.js'); +var Document$1 = require('./Document-2cf6b08c.js'); +var Schema = require('./Schema-42e9705c.js'); +var warnings = require('./warnings-39684f17.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/node_modules/yaml/dist/legacy-exports.js b/node_modules/yaml/dist/legacy-exports.js new file mode 100644 index 00000000..11d78868 --- /dev/null +++ b/node_modules/yaml/dist/legacy-exports.js @@ -0,0 +1,16 @@ +'use strict'; + +require('./PlainValue-ec8e588e.js'); +require('./resolveSeq-4a68b39b.js'); +var warnings = require('./warnings-39684f17.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/node_modules/yaml/dist/parse-cst.js b/node_modules/yaml/dist/parse-cst.js new file mode 100644 index 00000000..c0520275 --- /dev/null +++ b/node_modules/yaml/dist/parse-cst.js @@ -0,0 +1,1747 @@ +'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') { + const lineStart = offset + 1; + const inEnd = PlainValue.Node.endOfIndent(src, lineStart); + const indentDiff = inEnd - (lineStart + this.indent); + const noIndicatorAsIndent = parent.type === PlainValue.Type.SEQ_ITEM && parent.context.atLineStart; + if (!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/node_modules/yaml/dist/resolveSeq-4a68b39b.js b/node_modules/yaml/dist/resolveSeq-4a68b39b.js new file mode 100644 index 00000000..da211e43 --- /dev/null +++ b/node_modules/yaml/dist/resolveSeq-4a68b39b.js @@ -0,0 +1,2115 @@ +'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]; + const o = Number.isInteger(k) && k >= 0 ? [] : {}; + o[k] = v; + 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: {}, + 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); + map[stringKey] = toJSON(this.value, stringKey, ctx); + } + + 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); + } + } + + const explicitKey = !simpleKeys && (!key || keyComment || key instanceof Collection || key.type === PlainValue.Type.BLOCK_FOLDED || key.type === PlainValue.Type.BLOCK_LITERAL); + 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 (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 ? 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}`; + } + + 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)) map[key] = value; + } + } + } + + 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 + * @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 - (typeof indentAtStart === 'number' ? indentAtStart : indent.length); + let split = undefined; + let prev = undefined; + let overflow = false; + let i = -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 === '\\') { + switch (text[i + 1]) { + case 'x': + i += 3; + break; + + case 'u': + i += 5; + break; + + case 'U': + i += 9; + break; + + default: + i += 1; + } + } + + 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; + } // i - 2 accounts for not-dropped last char + newline-escaping \ + + + folds.push(i - 2); + escapedFolds[i - 2] = true; + end = i - 2 + 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 (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, limit) { + 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/node_modules/yaml/dist/test-events.js b/node_modules/yaml/dist/test-events.js new file mode 100644 index 00000000..1337aceb --- /dev/null +++ b/node_modules/yaml/dist/test-events.js @@ -0,0 +1,162 @@ +'use strict'; + +require('./PlainValue-ec8e588e.js'); +var parseCst = require('./parse-cst.js'); +require('./resolveSeq-4a68b39b.js'); +var Document$1 = require('./Document-2cf6b08c.js'); +require('./Schema-42e9705c.js'); +require('./warnings-39684f17.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$1.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/node_modules/yaml/dist/types.js b/node_modules/yaml/dist/types.js new file mode 100644 index 00000000..515f0b6e --- /dev/null +++ b/node_modules/yaml/dist/types.js @@ -0,0 +1,23 @@ +'use strict'; + +require('./PlainValue-ec8e588e.js'); +var resolveSeq = require('./resolveSeq-4a68b39b.js'); +var Schema = require('./Schema-42e9705c.js'); +require('./warnings-39684f17.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/node_modules/yaml/dist/util.js b/node_modules/yaml/dist/util.js new file mode 100644 index 00000000..3fc35d13 --- /dev/null +++ b/node_modules/yaml/dist/util.js @@ -0,0 +1,19 @@ +'use strict'; + +var PlainValue = require('./PlainValue-ec8e588e.js'); +var resolveSeq = require('./resolveSeq-4a68b39b.js'); + + + +exports.Type = PlainValue.Type; +exports.YAMLError = PlainValue.YAMLError; +exports.YAMLReferenceError = PlainValue.YAMLReferenceError; +exports.YAMLSemanticError = PlainValue.YAMLSemanticError; +exports.YAMLSyntaxError = PlainValue.YAMLSyntaxError; +exports.YAMLWarning = PlainValue.YAMLWarning; +exports.findPair = resolveSeq.findPair; +exports.parseMap = resolveSeq.resolveMap; +exports.parseSeq = resolveSeq.resolveSeq; +exports.stringifyNumber = resolveSeq.stringifyNumber; +exports.stringifyString = resolveSeq.stringifyString; +exports.toJSON = resolveSeq.toJSON; diff --git a/node_modules/yaml/dist/warnings-39684f17.js b/node_modules/yaml/dist/warnings-39684f17.js new file mode 100644 index 00000000..edc19405 --- /dev/null +++ b/node_modules/yaml/dist/warnings-39684f17.js @@ -0,0 +1,416 @@ +'use strict'; + +var PlainValue = require('./PlainValue-ec8e588e.js'); +var resolveSeq = require('./resolveSeq-4a68b39b.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/pymoog.egg-info/PKG-INFO b/pymoog.egg-info/PKG-INFO index 54281111..97234a91 100644 --- a/pymoog.egg-info/PKG-INFO +++ b/pymoog.egg-info/PKG-INFO @@ -14,15 +14,6 @@ Classifier: Topic :: Scientific/Engineering :: Astronomy Requires-Python: >=3.5 Description-Content-Type: text/markdown License-File: LICENCE -Requires-Dist: numpy>=1.18.0 -Requires-Dist: pandas>=1.0.0 -Requires-Dist: matplotlib>=3.1.0 -Requires-Dist: mendeleev>=0.6.0 -Requires-Dist: scipy>=1.4.0 -Requires-Dist: astropy>=4.0 -Requires-Dist: spectres -Requires-Dist: tqdm -Requires-Dist: zenodo_get # pymoog