├── jest.config.js ├── src ├── constants.ts ├── index.ts ├── utils.ts └── awsUtils.ts ├── tsconfig.json ├── action.yml ├── LICENSE ├── package.json ├── .eslintrc.json ├── __tests__ ├── utils.test.ts └── index.test.ts ├── __mocks__ └── aws-sdk.js ├── .github └── workflows │ └── tests.yml ├── .gitignore ├── README.md └── dist ├── licenses.txt └── sourcemap-register.js /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | preset: 'ts-jest', 3 | testEnvironment: 'node', 4 | } -------------------------------------------------------------------------------- /src/constants.ts: -------------------------------------------------------------------------------- 1 | export enum Inputs { 2 | SECRETS = 'secrets', 3 | PARSE_JSON = 'parse-json', 4 | DISABLE_WARNINGS = 'disable-warnings' 5 | } 6 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es2018", 4 | "moduleResolution": "node", 5 | "esModuleInterop": true 6 | }, 7 | } -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'AWS Secrets Manager Action' 2 | author: 'Abhilash Kishore' 3 | description: 'Use secrets from AWS Secrets Manager as environment variables in your GitHub Actions workflow' 4 | inputs: 5 | secrets: 6 | description: 'List of secret names you want to fetch secret values for' 7 | required: true 8 | parse-json: 9 | description: 'If true and secret values are stringified JSON objects, they will be parsed and flattened. Its key value pairs will become individual secrets' 10 | required: false 11 | default: 'false' 12 | disable-warnings: 13 | description: 'If true, disable annotation warnings in the GitHub Actions output.' 14 | required: false 15 | default: 'false' 16 | runs: 17 | using: 'node12' 18 | main: 'dist/index.js' 19 | branding: 20 | icon: lock 21 | color: blue 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Action Factory 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | 3 | import { Inputs } from './constants' 4 | import { getSecretsManagerClient, getSecretNamesToFetch, fetchAndInject } from './awsUtils' 5 | 6 | // secretNames input string is a new line separated list of secret names. Take distinct secret names. 7 | const inputSecretNames: string[] = [...new Set(core.getMultilineInput(Inputs.SECRETS))] 8 | 9 | // Check if any secret name contains a wildcard '*' 10 | const hasWildcard: boolean = inputSecretNames.some(secretName => secretName.includes('*')) 11 | 12 | const shouldParseJSON = core.getBooleanInput(Inputs.PARSE_JSON) 13 | 14 | const AWSConfig = {} 15 | 16 | const secretsManagerClient = getSecretsManagerClient(AWSConfig) 17 | 18 | if (hasWildcard) { 19 | core.debug('Found wildcard secret names') 20 | getSecretNamesToFetch(secretsManagerClient, inputSecretNames) 21 | .then(secretNamesToFetch => { 22 | fetchAndInject(secretsManagerClient, secretNamesToFetch, shouldParseJSON) 23 | }) 24 | .catch(err => { 25 | core.setFailed(`Action failed with error: ${err}`) 26 | }) 27 | } else { 28 | fetchAndInject(secretsManagerClient, inputSecretNames, shouldParseJSON) 29 | } 30 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "aws-secrets-manager-action", 3 | "version": "2.1.0", 4 | "description": "Use secrets from AWS Secrets Manager as environment variables in your GitHub Actions workflow", 5 | "main": "index.js", 6 | "scripts": { 7 | "lint": "eslint src/**", 8 | "lint:fix": "eslint src/** --fix", 9 | "package": "ncc build src/index.ts --license licenses.txt --source-map -o dist", 10 | "test": "eslint src/** && jest --verbose --coverage=true" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/abhilash1in/aws-secrets-manager-action.git" 15 | }, 16 | "keywords": [ 17 | "Github", 18 | "Actions", 19 | "JavaScript", 20 | "AWS", 21 | "AWS Secrets Manager" 22 | ], 23 | "author": "Abhilash Kishore", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/abhilash1in/aws-secrets-manager-action/issues" 27 | }, 28 | "homepage": "https://github.com/abhilash1in/aws-secrets-manager-action#readme", 29 | "dependencies": { 30 | "@actions/core": "^1.2.6", 31 | "aws-sdk": "^2.792.0" 32 | }, 33 | "devDependencies": { 34 | "@typescript-eslint/eslint-plugin": "^4.7.0", 35 | "@typescript-eslint/parser": "^4.7.0", 36 | "@vercel/ncc": "^0.25.1", 37 | "dotenv": "^8.2.0", 38 | "eslint": "^7.13.0", 39 | "eslint-plugin-spellcheck": "0.0.17", 40 | "@types/jest": "^26.0.15", 41 | "jest": "^26.6.3", 42 | "ts-jest": "^26.4.4", 43 | "typescript": "^4.0.5" 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "es6": true, 4 | "node": true, 5 | "jest": true 6 | }, 7 | "parser": "@typescript-eslint/parser", 8 | "parserOptions": { 9 | "sourceType": "module", 10 | "ecmaVersion": 2018 11 | }, 12 | "extends": [ 13 | "eslint:recommended", 14 | "plugin:@typescript-eslint/eslint-recommended", 15 | "plugin:@typescript-eslint/recommended" 16 | ], 17 | "plugins": [ 18 | "@typescript-eslint", 19 | "spellcheck" 20 | ], 21 | "globals": { 22 | "Atomics": "readonly", 23 | "SharedArrayBuffer": "readonly" 24 | }, 25 | "rules": { 26 | "quotes": ["error", "single"], 27 | "eqeqeq": "error", 28 | "camelcase": "error", 29 | "eol-last": ["error", "always"], 30 | "no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1 }], 31 | "no-trailing-spaces": "error", 32 | "indent": ["error", 2], 33 | "key-spacing": ["error", { "beforeColon": false }], 34 | "linebreak-style": ["error", "unix"], 35 | "semi": ["error", "never"], 36 | "semi-spacing": ["error", {"before": false, "after": true}], 37 | "spellcheck/spell-checker": ["warn", { 38 | "lang": "en_US", 39 | "skipWords": ["aws", "posix", "rethrow", "ascii", "recurse", "typeof", "falsy"], 40 | "skipIfMatch": ["[Dd]ecrypt.?", "[Ww]ildcard.?"] 41 | } 42 | ], 43 | "max-len": ["error", { "code": 120 }] 44 | } 45 | } -------------------------------------------------------------------------------- /__tests__/utils.test.ts: -------------------------------------------------------------------------------- 1 | import { isJSONObject, isJSONObjectString, flattenJSONObject, filterBy, getPOSIXString } from '../src/utils' 2 | 3 | test('Invaid JSON object string test 1', () => { 4 | expect(isJSONObjectString('["abcd"]')).toBe(false) 5 | }) 6 | 7 | test('Invaid JSON object string test 2', () => { 8 | expect(isJSONObjectString('100')).toBe(false) 9 | }) 10 | 11 | test('Valid JSON object string test', () => { 12 | expect(isJSONObjectString('{"foo": "bar"}')).toBe(true) 13 | }) 14 | 15 | test('Invaid JSON object', () => { 16 | expect(isJSONObject(["foo", "bar", "baz"])).toBe(false) 17 | }) 18 | 19 | test('Valid JSON object', () => { 20 | expect(isJSONObject({"foo": {"bar": "baz"}})).toBe(true) 21 | }) 22 | 23 | test('Valid JSON object string test', () => { 24 | expect(flattenJSONObject({"foo": {"bar": "baz"}})).toMatchObject({"foo_bar": "baz"}) 25 | }) 26 | 27 | test('FilterBy test', () => { 28 | const items = ['Banana', 'Apple', 'Melon'] 29 | expect(filterBy(items, 'e')).toMatchObject([]) 30 | expect(filterBy(items, '*e')).toMatchObject(['Apple']) 31 | expect(filterBy(items, '*e*')).toMatchObject(['Apple', 'Melon']) 32 | expect(filterBy(items, 'ana')).toMatchObject([]) 33 | expect(filterBy(items, '*ana')).toMatchObject(['Banana']) 34 | expect(filterBy(items, '*an')).toMatchObject([]) 35 | expect(filterBy(items, '*an*')).toMatchObject(['Banana']) 36 | }) 37 | 38 | test('getPOSIXString tests', () => { 39 | expect(getPOSIXString("abcd")).toEqual("ABCD") 40 | expect(getPOSIXString("100")).toEqual("_100") 41 | expect(getPOSIXString("100/my/test/2")).toEqual("_100_MY_TEST_2") 42 | expect(getPOSIXString("my/test/3")).toEqual("MY_TEST_3") 43 | expect(getPOSIXString("my/test/3.foo")).toEqual("MY_TEST_3_FOO") 44 | expect(getPOSIXString("/my_test/4")).toEqual("_MY_TEST_4") 45 | }) 46 | -------------------------------------------------------------------------------- /__mocks__/aws-sdk.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const AWS = jest.createMockFromModule('aws-sdk') 4 | 5 | const mockSecrets = { 6 | my_secret_1: { 7 | ARN: 'arn:aws:mock-secretsmanager:mock-region:mock-account-id:secret:my_secret_1-XXXXXX', 8 | VersionId: 'mock-version-id', 9 | Name: 'my_secret_1', 10 | SecretString: 'test-value-1', 11 | }, 12 | my_secret_2: { 13 | ARN: 'arn:aws:mock-secretsmanager:mock-region:mock-account-id:secret:my_secret_2-XXXXXX', 14 | VersionId: 'mock-version-id', 15 | Name: 'my_secret_2', 16 | SecretString: '{"foo" : "bar"}', 17 | }, 18 | 'my/secret/3': { 19 | ARN: 'arn:aws:mock-secretsmanager:mock-region:mock-account-id:secret:my/secret/3-XXXXXX', 20 | VersionId: 'mock-version-id', 21 | Name: 'my/secret/3', 22 | SecretBinary: 'eyJmb28iIDogImJhciJ9', 23 | }, 24 | deleted_secret: { 25 | ARN: 'arn:aws:mock-secretsmanager:mock-region:mock-account-id:secret:deleted_secret-XXXXXX', 26 | VersionId: 'mock-version-id', 27 | Name: 'deleted_secret', 28 | DeletedDate: Date.now() 29 | } 30 | } 31 | 32 | const keys = Object.keys(mockSecrets) 33 | const values = [] 34 | for (var key in mockSecrets) { 35 | values.push(mockSecrets[key]) 36 | } 37 | 38 | const mockSecretsManager = jest.fn((secretsManagerConfig) => { 39 | return { 40 | getSecretValue: jest.fn(({ SecretId }) => ({ 41 | promise: jest.fn(() => { 42 | if (SecretId in mockSecrets) { 43 | return Promise.resolve(mockSecrets[SecretId]) 44 | } else { 45 | return Promise.reject(new Error('SecretId not in mockSecrets')) 46 | } 47 | }) 48 | })), 49 | listSecrets: jest.fn().mockReturnValue({ 50 | promise: jest.fn().mockResolvedValue({ 51 | SecretList: values 52 | }) 53 | }) 54 | } 55 | }) 56 | 57 | AWS.SecretsManager = mockSecretsManager 58 | 59 | module.exports = AWS -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | on: 3 | workflow_dispatch: 4 | pull_request: 5 | branches: 6 | - master 7 | push: 8 | branches: 9 | - master 10 | tags: 11 | - '*' 12 | 13 | jobs: 14 | # unit tests 15 | unit-tests: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - uses: actions/checkout@v1 19 | - run: npm ci 20 | - run: npm test 21 | 22 | integration-test-latest: 23 | # Run only on 'push' or 'pull_request within same repository (not from a fork)' 24 | # since workflows triggered for PRs from a fork will not have access to GitHub secrets 25 | if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.base.repo.html_url == github.event.pull_request.head.repo.html_url) }} 26 | needs: [unit-tests] 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v1 30 | - name: Configure AWS Credentials 31 | uses: aws-actions/configure-aws-credentials@v1 32 | with: 33 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 34 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 35 | aws-region: ${{ secrets.AWS_REGION }} 36 | - uses: ./ 37 | with: 38 | secrets: '*secret*' 39 | parse-json: true 40 | 41 | integration-test-release: 42 | # Run only on 'push' or 'pull_request within same repository (not from a fork)' 43 | # since workflows triggered for PRs from a fork will not have access to GitHub secrets 44 | if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.base.repo.html_url == github.event.pull_request.head.repo.html_url) }} 45 | needs: [unit-tests] 46 | runs-on: ubuntu-latest 47 | steps: 48 | - name: Configure AWS Credentials 49 | uses: aws-actions/configure-aws-credentials@v1 50 | with: 51 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 52 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 53 | aws-region: ${{ secrets.AWS_REGION }} 54 | - uses: abhilash1in/aws-secrets-manager-action@v2.1.0 55 | with: 56 | secrets: 'my_secret*' 57 | parse-json: true 58 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # Snowpack dependency directory (https://snowpack.dev/) 45 | web_modules/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | dist/**/*.env 75 | 76 | # parcel-bundler cache (https://parceljs.org/) 77 | .cache 78 | .parcel-cache 79 | 80 | # Next.js build output 81 | .next 82 | out 83 | 84 | # Nuxt.js build / generate output 85 | .nuxt 86 | 87 | # Gatsby files 88 | .cache/ 89 | # Comment in the public line in if your project uses Gatsby and not Next.js 90 | # https://nextjs.org/blog/next-9-1#public-directory-support 91 | # public 92 | 93 | # vuepress build output 94 | .vuepress/dist 95 | 96 | # Serverless directories 97 | .serverless/ 98 | 99 | # FuseBox cache 100 | .fusebox/ 101 | 102 | # DynamoDB Local files 103 | .dynamodb/ 104 | 105 | # TernJS port file 106 | .tern-port 107 | 108 | # Stores VSCode versions used for testing VSCode extensions 109 | .vscode-test 110 | 111 | # yarn v2 112 | .yarn/cache 113 | .yarn/unplugged 114 | .yarn/build-state.yml 115 | .pnp.* 116 | 117 | # Editors 118 | .vscode 119 | *.iml 120 | .idea -------------------------------------------------------------------------------- /__tests__/index.test.ts: -------------------------------------------------------------------------------- 1 | import { getSecretValue, listSecrets, getSecretValueMap, getSecretNamesToFetch } from '../src/awsUtils' 2 | import { SecretsManager } from 'aws-sdk' 3 | import { resolve } from "path" 4 | import { config } from "dotenv" 5 | 6 | jest.mock('aws-sdk') 7 | 8 | config({ path: resolve(__dirname, "../.env") }) 9 | 10 | const secretsManagerClient = new SecretsManager({}) 11 | 12 | test('Fetch Secret Value: Valid Secret Name', () => { 13 | expect.assertions(2) 14 | return getSecretValue(secretsManagerClient, 'my_secret_1').then(secretValue => { 15 | expect(Object.keys(secretValue)).toContain('SecretString') 16 | expect(secretValue['SecretString']).toEqual('test-value-1') 17 | }) 18 | }) 19 | 20 | test('Fetch Secret Value: Invalid Secret Name', () => { 21 | expect.assertions(1) 22 | return getSecretValue(secretsManagerClient, 'foobarbaz').catch(err => { 23 | expect(err).not.toBeNull() 24 | }) 25 | }) 26 | 27 | 28 | test('List Secrets', () => { 29 | expect.assertions(1) 30 | return listSecrets(secretsManagerClient).then(secretNames => { 31 | expect(secretNames.sort()).toEqual(['my_secret_1', 'my_secret_2', 'my/secret/3'].sort()) 32 | }) 33 | }) 34 | 35 | test('Get Secret Value Map: parse=true, plain-text value', () => { 36 | expect.assertions(1) 37 | return getSecretValueMap(secretsManagerClient, 'my_secret_1', true).then(secretValueMap => { 38 | expect(secretValueMap).toMatchObject({ 'my_secret_1': 'test-value-1' }) 39 | }) 40 | }) 41 | 42 | test('Get Secret Value Map: parse=false, plain-text value', () => { 43 | expect.assertions(1) 44 | return getSecretValueMap(secretsManagerClient, 'my_secret_1', false).then(secretValueMap => { 45 | expect(secretValueMap).toMatchObject({ 'my_secret_1': 'test-value-1' }) 46 | }) 47 | }) 48 | 49 | test('Get Secret Value Map: parse=true, JSON string value', () => { 50 | expect.assertions(1) 51 | return getSecretValueMap(secretsManagerClient, 'my_secret_2', true).then(secretValueMap => { 52 | expect(secretValueMap).toMatchObject({ 'my_secret_2_foo': 'bar' }) 53 | }) 54 | }) 55 | 56 | test('Get Secret Value Map: parse=false, JSON string value', () => { 57 | expect.assertions(1) 58 | return getSecretValueMap(secretsManagerClient, 'my_secret_2', false).then(secretValueMap => { 59 | expect(secretValueMap).toMatchObject({ 'my_secret_2': '{"foo" : "bar"}' }) 60 | }) 61 | }) 62 | 63 | test('Get Secret Value Map: parse=true, Base64 encoded JSON string value', () => { 64 | expect.assertions(1) 65 | return getSecretValueMap(secretsManagerClient, 'my/secret/3', true).then(secretValueMap => { 66 | expect(secretValueMap).toMatchObject({ 'my/secret/3_foo': 'bar' }) 67 | }) 68 | }) 69 | 70 | test('Get Secret Value Map: Invalid Secret Name', () => { 71 | expect.assertions(1) 72 | return getSecretValueMap(secretsManagerClient, 'foobarbaz', false).catch(err => { 73 | expect(err).not.toBeNull() 74 | }) 75 | }) 76 | 77 | test('Get Secret Names To Fetch: Single Wild Card Name', () => { 78 | expect.assertions(1) 79 | return getSecretNamesToFetch(secretsManagerClient, ['*secret*']).then(secretNames => { 80 | expect(secretNames.sort()).toEqual(['my_secret_1', 'my_secret_2', 'my/secret/3'].sort()) 81 | }) 82 | }) 83 | 84 | test('Get Secret Names To Fetch: Multiple Wild Card Names', () => { 85 | expect.assertions(1) 86 | return getSecretNamesToFetch(secretsManagerClient, ['my*', 'my_secret*', 'invalidfoobarbaz']).then(secretNames => { 87 | expect(secretNames.sort()).toEqual(['my_secret_1', 'my_secret_2', 'my/secret/3'].sort()) 88 | }) 89 | }) 90 | -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import { Inputs } from './constants' 3 | 4 | /* Validate a possible object i.e., o = { "a": 2 } */ 5 | export const isJSONObject = (o: Record): boolean => 6 | !!o && (typeof o === 'object') && !Array.isArray(o) && 7 | ((): boolean => { try { return Boolean(JSON.stringify(o)) } catch { return false } })() 8 | 9 | /* Validate a possible JSON object represented as string i.e., s = '{ "a": 3 }' */ 10 | export const isJSONObjectString = (s: string): boolean => { 11 | try { 12 | const o = JSON.parse(s) 13 | return !!o && (typeof o === 'object') && !Array.isArray(o) 14 | } catch { 15 | return false 16 | } 17 | } 18 | 19 | // Code Explanation: 20 | // - !!o - Not falsy (excludes null, which registers as typeof 'object') 21 | // - (typeof o === 'object') - Excludes boolean, number, and string 22 | // - !Array.isArray(o) - Exclude arrays (which register as typeof 'object') 23 | // - try ... JSON.stringify / JSON.parse - Asks JavaScript engine to determine if valid JSON 24 | 25 | 26 | export const flattenJSONObject = (data: Record): Record => { 27 | if (!isJSONObject(data)) { 28 | throw TypeError('Cannot flatten non JSON arguments') 29 | } 30 | const result = {} 31 | function recurse(cur, prop): void { 32 | if (Object(cur) !== cur) { 33 | result[prop] = cur 34 | } else if (Array.isArray(cur)) { 35 | const l = cur.length 36 | for (let i = 0; i < l; i++) 37 | recurse(cur[i], prop + '[' + i + ']') 38 | if (l === 0) 39 | result[prop] = [] 40 | } else { 41 | let isEmpty = true 42 | for (const p in cur) { 43 | isEmpty = false 44 | recurse(cur[p], prop ? prop + '_' + p : p) 45 | } 46 | if (isEmpty && prop) 47 | result[prop] = {} 48 | } 49 | } 50 | recurse(data, '') 51 | return result 52 | } 53 | 54 | export const filterBy = (items: Array, filter: string): Array => { 55 | return items.filter(item => new RegExp('^' + filter.replace(/\*/g, '.*') + '$').test(item)) 56 | } 57 | 58 | export const getPOSIXString = (data: string): string => { 59 | if (data.match(/^[0-9]/)) 60 | data = '_'.concat(data) 61 | return data.replace(/[^a-zA-Z0-9_]/g, '_').toUpperCase() 62 | } 63 | 64 | export const injectSecretValueMapToEnvironment = (secretValueMap: Record): void => { 65 | const disableWarnings = core.getBooleanInput(Inputs.DISABLE_WARNINGS) 66 | 67 | for (const secretName in secretValueMap) { 68 | const secretValue: string = secretValueMap[secretName] 69 | core.setSecret(secretValue) 70 | // If secretName contains non-posix characters, it can't be read by the shell 71 | // Get POSIX compliant name secondary env name that can be read by the shell 72 | const secretNamePOSIX = getPOSIXString(secretName) 73 | if (secretName !== secretNamePOSIX && !disableWarnings) { 74 | core.warning('One of the secrets has a name that is not POSIX compliant and hence cannot directly \ 75 | be used/injected as an environment variable name. Therefore, it will be transformed into a POSIX compliant \ 76 | environment variable name. Enable GitHub Actions Debug Logging \ 77 | (https://docs.github.com/en/free-pro-team@latest/actions/managing-workflow-runs/enabling-debug-logging) to \ 78 | see the transformed environment variable name.\nPOSIX compliance: environment variable names can only contain \ 79 | upper case letters, digits and underscores. It cannot begin with a digit.') 80 | core.debug(`Secret name '${secretName}' is not POSIX compliant. It will be transformed to '${secretNamePOSIX}'.`) 81 | } 82 | core.debug(`Injecting environment variable '${secretNamePOSIX}'.`) 83 | core.exportVariable(secretNamePOSIX, secretValue) 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/awsUtils.ts: -------------------------------------------------------------------------------- 1 | import * as core from '@actions/core' 2 | import { AWSError, SecretsManager } from 'aws-sdk' 3 | import { GetSecretValueResponse } from 'aws-sdk/clients/secretsmanager' 4 | import { PromiseResult } from 'aws-sdk/lib/request' 5 | import { flattenJSONObject, isJSONObjectString, filterBy, injectSecretValueMapToEnvironment } from './utils' 6 | 7 | const getSecretsManagerClient = (config: Record): SecretsManager => new SecretsManager(config) 8 | 9 | const getSecretValue = (secretsManagerClient: SecretsManager, secretName: string): 10 | Promise> => { 11 | core.debug(`Fetching '${secretName}'`) 12 | return secretsManagerClient.getSecretValue({ SecretId: secretName }).promise() 13 | } 14 | 15 | const listSecretsPaginated = (secretsManagerClient, nextToken) => 16 | secretsManagerClient.listSecrets({ NextToken: nextToken }).promise() 17 | 18 | const listSecrets = (secretsManagerClient: SecretsManager): Promise> => { 19 | return new Promise>((resolve, reject) => { 20 | let nextToken: string = null 21 | const allSecretNames: string[] = [] 22 | do { 23 | listSecretsPaginated(secretsManagerClient, nextToken) 24 | .then(res => { 25 | // fetch nextToken if it exists, reset to null otherwise 26 | if ('NextToken' in res) { 27 | nextToken = res['NextToken'] 28 | } else { 29 | nextToken = null 30 | } 31 | // get all non-deleted secret names 32 | res['SecretList'].forEach(secret => { 33 | if (!('DeletedDate' in secret)) { 34 | allSecretNames.push(secret['Name']) 35 | } 36 | }) 37 | resolve(allSecretNames) 38 | }) 39 | .catch(err => { 40 | reject(err) 41 | }) 42 | } 43 | while (nextToken) 44 | }) 45 | } 46 | 47 | const getSecretValueMap = (secretsManagerClient: SecretsManager, secretName: string, shouldParseJSON = false) => { 48 | return new Promise((resolve, reject) => { 49 | getSecretValue(secretsManagerClient, secretName) 50 | .then(data => { 51 | let secretValue 52 | // Decrypts secret using the associated KMS CMK. 53 | // Depending on whether the secret is a string or binary, one of these fields will be populated. 54 | if ('SecretString' in data) { 55 | secretValue = data['SecretString'] 56 | } else { 57 | const buff = Buffer.from(data['SecretBinary'].toString(), 'base64') 58 | secretValue = buff.toString('ascii') 59 | } 60 | let secretValueMap = {} 61 | 62 | // If secretName = 'mySecret' and secretValue='{ "foo": "bar" }' 63 | // and if secretValue is a valid JSON object string and shouldParseJSON = true, 64 | // injected secrets will be of the form 'mySecret.foo' = 'bar' 65 | if (isJSONObjectString(secretValue) && shouldParseJSON) { 66 | const secretJSON = JSON.parse(secretValue) 67 | const secretJSONWrapped = {} 68 | secretJSONWrapped[secretName] = secretJSON 69 | const secretJSONFlattened = flattenJSONObject(secretJSONWrapped) 70 | secretValueMap = secretJSONFlattened 71 | } 72 | // Else, injected secrets will be of the form 'mySecret' = '{ "foo": "bar" }' (raw secret value string) 73 | else { 74 | secretValueMap[secretName] = secretValue 75 | } 76 | resolve(secretValueMap) 77 | }) 78 | .catch(err => { 79 | if ('code' in err) { 80 | if (err.code === 'DecryptionFailureException') 81 | // Secrets Manager can't decrypt the protected secret text using the provided KMS key. 82 | // Deal with the exception here, and/or rethrow at your discretion. 83 | return reject(err) 84 | else if (err.code === 'InternalServiceErrorException') 85 | // An error occurred on the server side. 86 | // Deal with the exception here, and/or rethrow at your discretion. 87 | return reject(err) 88 | else if (err.code === 'InvalidParameterException') 89 | // You provided an invalid value for a parameter. 90 | // Deal with the exception here, and/or rethrow at your discretion. 91 | return reject(err) 92 | else if (err.code === 'InvalidRequestException') 93 | // You provided a parameter value that is not valid for the current state of the resource. 94 | // Deal with the exception here, and/or rethrow at your discretion. 95 | return reject(err) 96 | else if (err.code === 'ResourceNotFoundException') 97 | // We can't find the resource that you asked for. 98 | // Deal with the exception here, and/or rethrow at your discretion. 99 | return reject(err) 100 | else if (err.code === 'AccessDeniedException') 101 | // We don't have access to the resource that you asked for. 102 | // Deal with the exception here, and/or rethrow at your discretion. 103 | return reject(err) 104 | else 105 | // Fetch failed due to an unrecognized error code 106 | return reject(err) 107 | } 108 | // Fetch failed for some other reason 109 | return reject(err) 110 | }) 111 | }) 112 | } 113 | 114 | const getSecretNamesToFetch = 115 | (secretsManagerClient: SecretsManager, inputSecretNames: string[]): Promise> => { 116 | return new Promise>((resolve, reject) => { 117 | // list secrets, filter against wildcards and fetch filtered secrets 118 | // else, fetch specified secrets directly 119 | const secretNames: string[] = [] 120 | listSecrets(secretsManagerClient) 121 | .then(secrets => { 122 | inputSecretNames.forEach(inputSecretName => { 123 | secretNames.push(...filterBy(secrets, inputSecretName)) 124 | }) 125 | resolve([...new Set(secretNames)]) 126 | }) 127 | .catch(err => { 128 | reject(err) 129 | }) 130 | }) 131 | } 132 | 133 | const fetchAndInject = (secretsManagerClient: SecretsManager, 134 | secretNamesToFetch: Array, shouldParseJSON: boolean): void => { 135 | core.debug(`Will fetch ${secretNamesToFetch.length} secrets: ${secretNamesToFetch}`) 136 | secretNamesToFetch.forEach((secretName) => { 137 | getSecretValueMap(secretsManagerClient, secretName, shouldParseJSON) 138 | .then(map => { 139 | injectSecretValueMapToEnvironment(map) 140 | }) 141 | .catch(err => { 142 | core.setFailed(`Failed to fetch '${secretName}'. Error: ${err}.`) 143 | }) 144 | }) 145 | } 146 | export { 147 | getSecretsManagerClient, 148 | getSecretValue, 149 | listSecrets, 150 | getSecretValueMap, 151 | getSecretNamesToFetch, 152 | fetchAndInject 153 | } 154 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AWS Secrets Manager GitHub Action 2 | [![Tests](https://github.com/abhilash1in/aws-secrets-manager-action/actions/workflows/tests.yml/badge.svg)](https://github.com/abhilash1in/aws-secrets-manager-action/actions/workflows/tests.yml) 3 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/abhilash1in/aws-secrets-manager-action/blob/master/LICENSE) 4 | 5 | GitHub Action to fetch secrets from AWS Secrets Manager and inject them as environment variables into your GitHub Actions workflow. 6 | 7 | The injected environment variable names will only contain upper case letters, digits and underscores. It will not begin with a digit. 8 | 9 | If your secret name contains any characters other than upper case letters, digits and underscores, it will not be used directly as the environment variable name. Rather, it will be transformed into a string that only contains upper case letters, digits and underscores. 10 | 11 | For example: 12 | - If your secret name is `dev.foo`, the injected environment variable name will be `DEV_FOO`. 13 | - If your secret name is `1/dev/foo`, the injected environment variable name will be `_1_DEV_FOO`. 14 | - If your secret name is `dev/foo`, value is `{ "bar": "baz" }` and `parse-json` is set to `true`, the injected environment variable name will be `DEV_FOO_BAR` (and value will be `baz`). 15 | 16 | ## Usage 17 | > Refer [Configure AWS Credentials](https://github.com/aws-actions/configure-aws-credentials) for AWS recommended best practices on how to configure AWS credentials for use with GitHub Actions. 18 | 19 | ```yaml 20 | steps: 21 | - name: Configure AWS Credentials 22 | uses: aws-actions/configure-aws-credentials@v1 23 | with: 24 | aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} 25 | aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 26 | aws-region: ${{ secrets.AWS_REGION }} 27 | 28 | - name: Read secrets from AWS Secrets Manager into environment variables 29 | uses: abhilash1in/aws-secrets-manager-action@v2.1.0 30 | with: 31 | secrets: | 32 | my_secret_1 33 | app1/dev/* 34 | parse-json: true 35 | 36 | - name: Check if env variable is set after fetching secrets 37 | run: if [ -z ${MY_SECRET_1+x} ]; then echo "MY_SECRET_1 is unset"; else echo "MY_SECRET_1 is set to '$MY_SECRET_1'"; fi 38 | ``` 39 | 40 | - `secrets`: 41 | - List of secret names to be retrieved. 42 | - Examples: 43 | - To retrieve a single secret, use `secrets: my_secret_1`. 44 | - To retrieve multiple secrets, use: 45 | ```yaml 46 | secrets: | 47 | my_secret_1 48 | my_secret_2 49 | ``` 50 | - To retrieve "all secrets having names that contain `dev`" or "begin with `app1/dev/`", use: 51 | ```yaml 52 | secrets: | 53 | *dev* 54 | app1/dev/* 55 | ``` 56 | - `parse-json` 57 | - If `parse-json: true` and secret value is a **valid** stringified JSON object, it will be parsed and flattened. Each of the key value pairs in the flattened JSON object will become individual secrets. The original secret name will be used as a prefix. 58 | - Examples: 59 | 60 | | `parse-json` | AWS Secrets Manager Secret
(`name` = `value`) | Injected Environment Variable
(`name` = `value`) | Explanation | 61 | |--------------|--------------------------------------------------|-----------------------------------------------------|-----------------------------------------------------------------------------------------| 62 | | `true` | `foo` = `{ "bar": "baz" }` | `FOO_BAR` = `baz` | Values that can be parsed into a JSON will be parsed and flattened | 63 | | `true` | `1/dev/foo` = `{ "bar" = "baz" }` | `_1_DEV_FOO` = `{ "bar" = "baz" }` | Values that cannot be parsed into a JSON will NOT be parsed | 64 | | `true` | `foo` = `{ "bar": "baz" }`
`ham` = `eggs` | `FOO_BAR` = `baz` AND
`ham` = `eggs` | If multiple secrets, values that can be parsed into a JSON will be parsed and flattened | 65 | | `false` | `dev_foo` = `{ "bar": "baz" }` | `DEV_FOO` = `{ "bar": "baz" }` | Not parsed | 66 | 67 | - `disable-warnings` 68 | - If `disable-warnings: true`, warnings regarding POSIX compliance in GitHub Actions output will be suppressed. 69 | 70 | #### Note: 71 | - `${{ secrets.AWS_ACCESS_KEY_ID }}`, `${{ secrets.AWS_SECRET_ACCESS_KEY }}` and `${{ secrets.AWS_REGION }}` refers to [GitHub Secrets](https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets). Create the required secrets in your GitHub repository before using them in this GitHub Action. 72 | - If your AWS Secrets Manager secret name contains any characters other than upper case letters, digits and underscores, it will not be used directly as the environment variable name. Rather, it will be transformed into a string that only contains upper case letters, digits and underscores. Refer the table above for examples. 73 | 74 | ## Features 75 | - Can fetch secrets from AWS Secrets Manager and inject them into environment variables which can be used in subsequent steps in your GitHub Actions workflow. 76 | - Injects environment variables in a format compatible with most shells. 77 | - Can fetch multiple secrets at once. 78 | - Supports wildcards 79 | - `secrets: 'app1/dev/*'` will fetch all secrets having names that begin with `app1/dev/`. 80 | - `secrets: '*dev*'` will fetch all secrets that have `dev` in their names. 81 | 82 | ## IAM Policy 83 | The `aws-access-key-id` and `aws-secret-access-key` provided by you should belong to an IAM user with the following minimum permissions: 84 | - `secretsmanager:GetSecretValue` 85 | - `kms:Decrypt` 86 | - Required only if you use a customer-managed AWS KMS key to encrypt the secret. You do not need this permission to use your account's default AWS managed encryption key for Secrets Manager. 87 | 88 | #### Example 1 (Simple): 89 | If your secrets are encrypted using the default AWS managed encryption key, then the IAM user needs to have a policy attached similar to: 90 | ```json 91 | { 92 | "Version": "2012-10-17", 93 | "Statement": [ 94 | { 95 | "Action": [ 96 | "secretsmanager:GetSecretValue" 97 | ], 98 | "Effect": "Allow", 99 | "Resource": "*" 100 | } 101 | ] 102 | } 103 | ``` 104 | 105 | #### Example 2 (Advanced): 106 | If your secrets are encrypted using a customer managed AWS Key Management Service (KMS) key, then the IAM user needs a policy similar to the one below. We can restrict access to specific secrets (resources) in a specific region or we can use `*` for 'Any'. 107 | ```json 108 | { 109 | "Version": "2012-10-17", 110 | "Statement": [ 111 | { 112 | "Action": [ 113 | "secretsmanager:GetSecretValue", 114 | "kms:Decrypt" 115 | ], 116 | "Effect": "Allow", 117 | "Resource": [ 118 | "arn:aws:secretsmanager:*:000000000000:secret:*", 119 | "arn:aws:secretsmanager:us-east-1:000000000000:secret:mySecretID" 120 | ] 121 | } 122 | ] 123 | } 124 | ``` 125 | Here `000000000000` is your [AWS account ID](https://console.aws.amazon.com/billing/home?#/account), `us-east-1` is the AWS region code which has the secret(s) and `mySecretID` is the ID of your secret (usually different from a secret name). Please refer your AWS Secrets Manager console for the exact resource ARN. 126 | 127 | ## Contributing 128 | We would love for you to contribute to [`@abhilash1in/aws-secrets-manager-action`](https://github.com/abhilash1in/aws-secrets-manager-action). [Issues](https://github.com/abhilash1in/aws-secrets-manager-action/issues) and [Pull Requests](https://github.com/abhilash1in/aws-secrets-manager-action/pulls) are welcome! 129 | 130 | ## License 131 | The scripts and documentation in this project are released under the [MIT License](https://github.com/abhilash1in/aws-secrets-manager-action/blob/master/LICENSE). 132 | -------------------------------------------------------------------------------- /dist/licenses.txt: -------------------------------------------------------------------------------- 1 | @actions/core 2 | MIT 3 | The MIT License (MIT) 4 | 5 | Copyright 2019 GitHub 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | 13 | @actions/http-client 14 | MIT 15 | Actions Http Client for Node.js 16 | 17 | Copyright (c) GitHub, Inc. 18 | 19 | All rights reserved. 20 | 21 | MIT License 22 | 23 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and 24 | associated documentation files (the "Software"), to deal in the Software without restriction, 25 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, 26 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, 27 | subject to the following conditions: 28 | 29 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 30 | 31 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT 32 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 33 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 34 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 35 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 36 | 37 | 38 | aws-sdk 39 | Apache-2.0 40 | 41 | Apache License 42 | Version 2.0, January 2004 43 | http://www.apache.org/licenses/ 44 | 45 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 46 | 47 | 1. Definitions. 48 | 49 | "License" shall mean the terms and conditions for use, reproduction, 50 | and distribution as defined by Sections 1 through 9 of this document. 51 | 52 | "Licensor" shall mean the copyright owner or entity authorized by 53 | the copyright owner that is granting the License. 54 | 55 | "Legal Entity" shall mean the union of the acting entity and all 56 | other entities that control, are controlled by, or are under common 57 | control with that entity. For the purposes of this definition, 58 | "control" means (i) the power, direct or indirect, to cause the 59 | direction or management of such entity, whether by contract or 60 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 61 | outstanding shares, or (iii) beneficial ownership of such entity. 62 | 63 | "You" (or "Your") shall mean an individual or Legal Entity 64 | exercising permissions granted by this License. 65 | 66 | "Source" form shall mean the preferred form for making modifications, 67 | including but not limited to software source code, documentation 68 | source, and configuration files. 69 | 70 | "Object" form shall mean any form resulting from mechanical 71 | transformation or translation of a Source form, including but 72 | not limited to compiled object code, generated documentation, 73 | and conversions to other media types. 74 | 75 | "Work" shall mean the work of authorship, whether in Source or 76 | Object form, made available under the License, as indicated by a 77 | copyright notice that is included in or attached to the work 78 | (an example is provided in the Appendix below). 79 | 80 | "Derivative Works" shall mean any work, whether in Source or Object 81 | form, that is based on (or derived from) the Work and for which the 82 | editorial revisions, annotations, elaborations, or other modifications 83 | represent, as a whole, an original work of authorship. For the purposes 84 | of this License, Derivative Works shall not include works that remain 85 | separable from, or merely link (or bind by name) to the interfaces of, 86 | the Work and Derivative Works thereof. 87 | 88 | "Contribution" shall mean any work of authorship, including 89 | the original version of the Work and any modifications or additions 90 | to that Work or Derivative Works thereof, that is intentionally 91 | submitted to Licensor for inclusion in the Work by the copyright owner 92 | or by an individual or Legal Entity authorized to submit on behalf of 93 | the copyright owner. For the purposes of this definition, "submitted" 94 | means any form of electronic, verbal, or written communication sent 95 | to the Licensor or its representatives, including but not limited to 96 | communication on electronic mailing lists, source code control systems, 97 | and issue tracking systems that are managed by, or on behalf of, the 98 | Licensor for the purpose of discussing and improving the Work, but 99 | excluding communication that is conspicuously marked or otherwise 100 | designated in writing by the copyright owner as "Not a Contribution." 101 | 102 | "Contributor" shall mean Licensor and any individual or Legal Entity 103 | on behalf of whom a Contribution has been received by Licensor and 104 | subsequently incorporated within the Work. 105 | 106 | 2. Grant of Copyright License. Subject to the terms and conditions of 107 | this License, each Contributor hereby grants to You a perpetual, 108 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 109 | copyright license to reproduce, prepare Derivative Works of, 110 | publicly display, publicly perform, sublicense, and distribute the 111 | Work and such Derivative Works in Source or Object form. 112 | 113 | 3. Grant of Patent License. Subject to the terms and conditions of 114 | this License, each Contributor hereby grants to You a perpetual, 115 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 116 | (except as stated in this section) patent license to make, have made, 117 | use, offer to sell, sell, import, and otherwise transfer the Work, 118 | where such license applies only to those patent claims licensable 119 | by such Contributor that are necessarily infringed by their 120 | Contribution(s) alone or by combination of their Contribution(s) 121 | with the Work to which such Contribution(s) was submitted. If You 122 | institute patent litigation against any entity (including a 123 | cross-claim or counterclaim in a lawsuit) alleging that the Work 124 | or a Contribution incorporated within the Work constitutes direct 125 | or contributory patent infringement, then any patent licenses 126 | granted to You under this License for that Work shall terminate 127 | as of the date such litigation is filed. 128 | 129 | 4. Redistribution. You may reproduce and distribute copies of the 130 | Work or Derivative Works thereof in any medium, with or without 131 | modifications, and in Source or Object form, provided that You 132 | meet the following conditions: 133 | 134 | (a) You must give any other recipients of the Work or 135 | Derivative Works a copy of this License; and 136 | 137 | (b) You must cause any modified files to carry prominent notices 138 | stating that You changed the files; and 139 | 140 | (c) You must retain, in the Source form of any Derivative Works 141 | that You distribute, all copyright, patent, trademark, and 142 | attribution notices from the Source form of the Work, 143 | excluding those notices that do not pertain to any part of 144 | the Derivative Works; and 145 | 146 | (d) If the Work includes a "NOTICE" text file as part of its 147 | distribution, then any Derivative Works that You distribute must 148 | include a readable copy of the attribution notices contained 149 | within such NOTICE file, excluding those notices that do not 150 | pertain to any part of the Derivative Works, in at least one 151 | of the following places: within a NOTICE text file distributed 152 | as part of the Derivative Works; within the Source form or 153 | documentation, if provided along with the Derivative Works; or, 154 | within a display generated by the Derivative Works, if and 155 | wherever such third-party notices normally appear. The contents 156 | of the NOTICE file are for informational purposes only and 157 | do not modify the License. You may add Your own attribution 158 | notices within Derivative Works that You distribute, alongside 159 | or as an addendum to the NOTICE text from the Work, provided 160 | that such additional attribution notices cannot be construed 161 | as modifying the License. 162 | 163 | You may add Your own copyright statement to Your modifications and 164 | may provide additional or different license terms and conditions 165 | for use, reproduction, or distribution of Your modifications, or 166 | for any such Derivative Works as a whole, provided Your use, 167 | reproduction, and distribution of the Work otherwise complies with 168 | the conditions stated in this License. 169 | 170 | 5. Submission of Contributions. Unless You explicitly state otherwise, 171 | any Contribution intentionally submitted for inclusion in the Work 172 | by You to the Licensor shall be under the terms and conditions of 173 | this License, without any additional terms or conditions. 174 | Notwithstanding the above, nothing herein shall supersede or modify 175 | the terms of any separate license agreement you may have executed 176 | with Licensor regarding such Contributions. 177 | 178 | 6. Trademarks. This License does not grant permission to use the trade 179 | names, trademarks, service marks, or product names of the Licensor, 180 | except as required for reasonable and customary use in describing the 181 | origin of the Work and reproducing the content of the NOTICE file. 182 | 183 | 7. Disclaimer of Warranty. Unless required by applicable law or 184 | agreed to in writing, Licensor provides the Work (and each 185 | Contributor provides its Contributions) on an "AS IS" BASIS, 186 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 187 | implied, including, without limitation, any warranties or conditions 188 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 189 | PARTICULAR PURPOSE. You are solely responsible for determining the 190 | appropriateness of using or redistributing the Work and assume any 191 | risks associated with Your exercise of permissions under this License. 192 | 193 | 8. Limitation of Liability. In no event and under no legal theory, 194 | whether in tort (including negligence), contract, or otherwise, 195 | unless required by applicable law (such as deliberate and grossly 196 | negligent acts) or agreed to in writing, shall any Contributor be 197 | liable to You for damages, including any direct, indirect, special, 198 | incidental, or consequential damages of any character arising as a 199 | result of this License or out of the use or inability to use the 200 | Work (including but not limited to damages for loss of goodwill, 201 | work stoppage, computer failure or malfunction, or any and all 202 | other commercial damages or losses), even if such Contributor 203 | has been advised of the possibility of such damages. 204 | 205 | 9. Accepting Warranty or Additional Liability. While redistributing 206 | the Work or Derivative Works thereof, You may choose to offer, 207 | and charge a fee for, acceptance of support, warranty, indemnity, 208 | or other liability obligations and/or rights consistent with this 209 | License. However, in accepting such obligations, You may act only 210 | on Your own behalf and on Your sole responsibility, not on behalf 211 | of any other Contributor, and only if You agree to indemnify, 212 | defend, and hold each Contributor harmless for any liability 213 | incurred by, or claims asserted against, such Contributor by reason 214 | of your accepting any such warranty or additional liability. 215 | 216 | END OF TERMS AND CONDITIONS 217 | 218 | APPENDIX: How to apply the Apache License to your work. 219 | 220 | To apply the Apache License to your work, attach the following 221 | boilerplate notice, with the fields enclosed by brackets "[]" 222 | replaced with your own identifying information. (Don't include 223 | the brackets!) The text should be enclosed in the appropriate 224 | comment syntax for the file format. We also recommend that a 225 | file or class name and description of purpose be included on the 226 | same "printed page" as the copyright notice for easier 227 | identification within third-party archives. 228 | 229 | Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. 230 | 231 | Licensed under the Apache License, Version 2.0 (the "License"); 232 | you may not use this file except in compliance with the License. 233 | You may obtain a copy of the License at 234 | 235 | http://www.apache.org/licenses/LICENSE-2.0 236 | 237 | Unless required by applicable law or agreed to in writing, software 238 | distributed under the License is distributed on an "AS IS" BASIS, 239 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 240 | See the License for the specific language governing permissions and 241 | limitations under the License. 242 | 243 | 244 | jmespath 245 | Apache-2.0 246 | Copyright 2014 James Saryerwinnie 247 | 248 | Licensed under the Apache License, Version 2.0 (the "License"); 249 | you may not use this file except in compliance with the License. 250 | You may obtain a copy of the License at 251 | 252 | http://www.apache.org/licenses/LICENSE-2.0 253 | 254 | Unless required by applicable law or agreed to in writing, software 255 | distributed under the License is distributed on an "AS IS" BASIS, 256 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 257 | See the License for the specific language governing permissions and 258 | limitations under the License. 259 | 260 | 261 | sax 262 | ISC 263 | The ISC License 264 | 265 | Copyright (c) Isaac Z. Schlueter and Contributors 266 | 267 | Permission to use, copy, modify, and/or distribute this software for any 268 | purpose with or without fee is hereby granted, provided that the above 269 | copyright notice and this permission notice appear in all copies. 270 | 271 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 272 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 273 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 274 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 275 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 276 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR 277 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 278 | 279 | ==== 280 | 281 | `String.fromCodePoint` by Mathias Bynens used according to terms of MIT 282 | License, as follows: 283 | 284 | Copyright Mathias Bynens 285 | 286 | Permission is hereby granted, free of charge, to any person obtaining 287 | a copy of this software and associated documentation files (the 288 | "Software"), to deal in the Software without restriction, including 289 | without limitation the rights to use, copy, modify, merge, publish, 290 | distribute, sublicense, and/or sell copies of the Software, and to 291 | permit persons to whom the Software is furnished to do so, subject to 292 | the following conditions: 293 | 294 | The above copyright notice and this permission notice shall be 295 | included in all copies or substantial portions of the Software. 296 | 297 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 298 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 299 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 300 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 301 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 302 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 303 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 304 | 305 | 306 | tunnel 307 | MIT 308 | The MIT License (MIT) 309 | 310 | Copyright (c) 2012 Koichi Kobayashi 311 | 312 | Permission is hereby granted, free of charge, to any person obtaining a copy 313 | of this software and associated documentation files (the "Software"), to deal 314 | in the Software without restriction, including without limitation the rights 315 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 316 | copies of the Software, and to permit persons to whom the Software is 317 | furnished to do so, subject to the following conditions: 318 | 319 | The above copyright notice and this permission notice shall be included in 320 | all copies or substantial portions of the Software. 321 | 322 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 323 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 324 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 325 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 326 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 327 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 328 | THE SOFTWARE. 329 | 330 | 331 | uuid 332 | MIT 333 | The MIT License (MIT) 334 | 335 | Copyright (c) 2010-2016 Robert Kieffer and other contributors 336 | 337 | Permission is hereby granted, free of charge, to any person obtaining a copy 338 | of this software and associated documentation files (the "Software"), to deal 339 | in the Software without restriction, including without limitation the rights 340 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 341 | copies of the Software, and to permit persons to whom the Software is 342 | furnished to do so, subject to the following conditions: 343 | 344 | The above copyright notice and this permission notice shall be included in all 345 | copies or substantial portions of the Software. 346 | 347 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 348 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 349 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 350 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 351 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 352 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 353 | SOFTWARE. 354 | 355 | 356 | xml2js 357 | MIT 358 | Copyright 2010, 2011, 2012, 2013. All rights reserved. 359 | 360 | Permission is hereby granted, free of charge, to any person obtaining a copy 361 | of this software and associated documentation files (the "Software"), to 362 | deal in the Software without restriction, including without limitation the 363 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 364 | sell copies of the Software, and to permit persons to whom the Software is 365 | furnished to do so, subject to the following conditions: 366 | 367 | The above copyright notice and this permission notice shall be included in 368 | all copies or substantial portions of the Software. 369 | 370 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 371 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 372 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 373 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 374 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 375 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 376 | IN THE SOFTWARE. 377 | 378 | 379 | xmlbuilder 380 | MIT 381 | The MIT License (MIT) 382 | 383 | Copyright (c) 2013 Ozgur Ozcitak 384 | 385 | Permission is hereby granted, free of charge, to any person obtaining a copy 386 | of this software and associated documentation files (the "Software"), to deal 387 | in the Software without restriction, including without limitation the rights 388 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 389 | copies of the Software, and to permit persons to whom the Software is 390 | furnished to do so, subject to the following conditions: 391 | 392 | The above copyright notice and this permission notice shall be included in 393 | all copies or substantial portions of the Software. 394 | 395 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 396 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 397 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 398 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 399 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 400 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 401 | THE SOFTWARE. 402 | -------------------------------------------------------------------------------- /dist/sourcemap-register.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | /******/ (() => { // webpackBootstrap 3 | /******/ var __webpack_modules__ = ({ 4 | 5 | /***/ 650: 6 | /***/ ((module) => { 7 | 8 | var toString = Object.prototype.toString 9 | 10 | var isModern = ( 11 | typeof Buffer.alloc === 'function' && 12 | typeof Buffer.allocUnsafe === 'function' && 13 | typeof Buffer.from === 'function' 14 | ) 15 | 16 | function isArrayBuffer (input) { 17 | return toString.call(input).slice(8, -1) === 'ArrayBuffer' 18 | } 19 | 20 | function fromArrayBuffer (obj, byteOffset, length) { 21 | byteOffset >>>= 0 22 | 23 | var maxLength = obj.byteLength - byteOffset 24 | 25 | if (maxLength < 0) { 26 | throw new RangeError("'offset' is out of bounds") 27 | } 28 | 29 | if (length === undefined) { 30 | length = maxLength 31 | } else { 32 | length >>>= 0 33 | 34 | if (length > maxLength) { 35 | throw new RangeError("'length' is out of bounds") 36 | } 37 | } 38 | 39 | return isModern 40 | ? Buffer.from(obj.slice(byteOffset, byteOffset + length)) 41 | : new Buffer(new Uint8Array(obj.slice(byteOffset, byteOffset + length))) 42 | } 43 | 44 | function fromString (string, encoding) { 45 | if (typeof encoding !== 'string' || encoding === '') { 46 | encoding = 'utf8' 47 | } 48 | 49 | if (!Buffer.isEncoding(encoding)) { 50 | throw new TypeError('"encoding" must be a valid string encoding') 51 | } 52 | 53 | return isModern 54 | ? Buffer.from(string, encoding) 55 | : new Buffer(string, encoding) 56 | } 57 | 58 | function bufferFrom (value, encodingOrOffset, length) { 59 | if (typeof value === 'number') { 60 | throw new TypeError('"value" argument must not be a number') 61 | } 62 | 63 | if (isArrayBuffer(value)) { 64 | return fromArrayBuffer(value, encodingOrOffset, length) 65 | } 66 | 67 | if (typeof value === 'string') { 68 | return fromString(value, encodingOrOffset) 69 | } 70 | 71 | return isModern 72 | ? Buffer.from(value) 73 | : new Buffer(value) 74 | } 75 | 76 | module.exports = bufferFrom 77 | 78 | 79 | /***/ }), 80 | 81 | /***/ 645: 82 | /***/ ((__unused_webpack_module, __unused_webpack_exports, __webpack_require__) => { 83 | 84 | __webpack_require__(284).install(); 85 | 86 | 87 | /***/ }), 88 | 89 | /***/ 284: 90 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 91 | 92 | var SourceMapConsumer = __webpack_require__(596).SourceMapConsumer; 93 | var path = __webpack_require__(622); 94 | 95 | var fs; 96 | try { 97 | fs = __webpack_require__(747); 98 | if (!fs.existsSync || !fs.readFileSync) { 99 | // fs doesn't have all methods we need 100 | fs = null; 101 | } 102 | } catch (err) { 103 | /* nop */ 104 | } 105 | 106 | var bufferFrom = __webpack_require__(650); 107 | 108 | // Only install once if called multiple times 109 | var errorFormatterInstalled = false; 110 | var uncaughtShimInstalled = false; 111 | 112 | // If true, the caches are reset before a stack trace formatting operation 113 | var emptyCacheBetweenOperations = false; 114 | 115 | // Supports {browser, node, auto} 116 | var environment = "auto"; 117 | 118 | // Maps a file path to a string containing the file contents 119 | var fileContentsCache = {}; 120 | 121 | // Maps a file path to a source map for that file 122 | var sourceMapCache = {}; 123 | 124 | // Regex for detecting source maps 125 | var reSourceMap = /^data:application\/json[^,]+base64,/; 126 | 127 | // Priority list of retrieve handlers 128 | var retrieveFileHandlers = []; 129 | var retrieveMapHandlers = []; 130 | 131 | function isInBrowser() { 132 | if (environment === "browser") 133 | return true; 134 | if (environment === "node") 135 | return false; 136 | return ((typeof window !== 'undefined') && (typeof XMLHttpRequest === 'function') && !(window.require && window.module && window.process && window.process.type === "renderer")); 137 | } 138 | 139 | function hasGlobalProcessEventEmitter() { 140 | return ((typeof process === 'object') && (process !== null) && (typeof process.on === 'function')); 141 | } 142 | 143 | function handlerExec(list) { 144 | return function(arg) { 145 | for (var i = 0; i < list.length; i++) { 146 | var ret = list[i](arg); 147 | if (ret) { 148 | return ret; 149 | } 150 | } 151 | return null; 152 | }; 153 | } 154 | 155 | var retrieveFile = handlerExec(retrieveFileHandlers); 156 | 157 | retrieveFileHandlers.push(function(path) { 158 | // Trim the path to make sure there is no extra whitespace. 159 | path = path.trim(); 160 | if (/^file:/.test(path)) { 161 | // existsSync/readFileSync can't handle file protocol, but once stripped, it works 162 | path = path.replace(/file:\/\/\/(\w:)?/, function(protocol, drive) { 163 | return drive ? 164 | '' : // file:///C:/dir/file -> C:/dir/file 165 | '/'; // file:///root-dir/file -> /root-dir/file 166 | }); 167 | } 168 | if (path in fileContentsCache) { 169 | return fileContentsCache[path]; 170 | } 171 | 172 | var contents = ''; 173 | try { 174 | if (!fs) { 175 | // Use SJAX if we are in the browser 176 | var xhr = new XMLHttpRequest(); 177 | xhr.open('GET', path, /** async */ false); 178 | xhr.send(null); 179 | if (xhr.readyState === 4 && xhr.status === 200) { 180 | contents = xhr.responseText; 181 | } 182 | } else if (fs.existsSync(path)) { 183 | // Otherwise, use the filesystem 184 | contents = fs.readFileSync(path, 'utf8'); 185 | } 186 | } catch (er) { 187 | /* ignore any errors */ 188 | } 189 | 190 | return fileContentsCache[path] = contents; 191 | }); 192 | 193 | // Support URLs relative to a directory, but be careful about a protocol prefix 194 | // in case we are in the browser (i.e. directories may start with "http://" or "file:///") 195 | function supportRelativeURL(file, url) { 196 | if (!file) return url; 197 | var dir = path.dirname(file); 198 | var match = /^\w+:\/\/[^\/]*/.exec(dir); 199 | var protocol = match ? match[0] : ''; 200 | var startPath = dir.slice(protocol.length); 201 | if (protocol && /^\/\w\:/.test(startPath)) { 202 | // handle file:///C:/ paths 203 | protocol += '/'; 204 | return protocol + path.resolve(dir.slice(protocol.length), url).replace(/\\/g, '/'); 205 | } 206 | return protocol + path.resolve(dir.slice(protocol.length), url); 207 | } 208 | 209 | function retrieveSourceMapURL(source) { 210 | var fileData; 211 | 212 | if (isInBrowser()) { 213 | try { 214 | var xhr = new XMLHttpRequest(); 215 | xhr.open('GET', source, false); 216 | xhr.send(null); 217 | fileData = xhr.readyState === 4 ? xhr.responseText : null; 218 | 219 | // Support providing a sourceMappingURL via the SourceMap header 220 | var sourceMapHeader = xhr.getResponseHeader("SourceMap") || 221 | xhr.getResponseHeader("X-SourceMap"); 222 | if (sourceMapHeader) { 223 | return sourceMapHeader; 224 | } 225 | } catch (e) { 226 | } 227 | } 228 | 229 | // Get the URL of the source map 230 | fileData = retrieveFile(source); 231 | var re = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/)[ \t]*$)/mg; 232 | // Keep executing the search to find the *last* sourceMappingURL to avoid 233 | // picking up sourceMappingURLs from comments, strings, etc. 234 | var lastMatch, match; 235 | while (match = re.exec(fileData)) lastMatch = match; 236 | if (!lastMatch) return null; 237 | return lastMatch[1]; 238 | }; 239 | 240 | // Can be overridden by the retrieveSourceMap option to install. Takes a 241 | // generated source filename; returns a {map, optional url} object, or null if 242 | // there is no source map. The map field may be either a string or the parsed 243 | // JSON object (ie, it must be a valid argument to the SourceMapConsumer 244 | // constructor). 245 | var retrieveSourceMap = handlerExec(retrieveMapHandlers); 246 | retrieveMapHandlers.push(function(source) { 247 | var sourceMappingURL = retrieveSourceMapURL(source); 248 | if (!sourceMappingURL) return null; 249 | 250 | // Read the contents of the source map 251 | var sourceMapData; 252 | if (reSourceMap.test(sourceMappingURL)) { 253 | // Support source map URL as a data url 254 | var rawData = sourceMappingURL.slice(sourceMappingURL.indexOf(',') + 1); 255 | sourceMapData = bufferFrom(rawData, "base64").toString(); 256 | sourceMappingURL = source; 257 | } else { 258 | // Support source map URLs relative to the source URL 259 | sourceMappingURL = supportRelativeURL(source, sourceMappingURL); 260 | sourceMapData = retrieveFile(sourceMappingURL); 261 | } 262 | 263 | if (!sourceMapData) { 264 | return null; 265 | } 266 | 267 | return { 268 | url: sourceMappingURL, 269 | map: sourceMapData 270 | }; 271 | }); 272 | 273 | function mapSourcePosition(position) { 274 | var sourceMap = sourceMapCache[position.source]; 275 | if (!sourceMap) { 276 | // Call the (overrideable) retrieveSourceMap function to get the source map. 277 | var urlAndMap = retrieveSourceMap(position.source); 278 | if (urlAndMap) { 279 | sourceMap = sourceMapCache[position.source] = { 280 | url: urlAndMap.url, 281 | map: new SourceMapConsumer(urlAndMap.map) 282 | }; 283 | 284 | // Load all sources stored inline with the source map into the file cache 285 | // to pretend like they are already loaded. They may not exist on disk. 286 | if (sourceMap.map.sourcesContent) { 287 | sourceMap.map.sources.forEach(function(source, i) { 288 | var contents = sourceMap.map.sourcesContent[i]; 289 | if (contents) { 290 | var url = supportRelativeURL(sourceMap.url, source); 291 | fileContentsCache[url] = contents; 292 | } 293 | }); 294 | } 295 | } else { 296 | sourceMap = sourceMapCache[position.source] = { 297 | url: null, 298 | map: null 299 | }; 300 | } 301 | } 302 | 303 | // Resolve the source URL relative to the URL of the source map 304 | if (sourceMap && sourceMap.map) { 305 | var originalPosition = sourceMap.map.originalPositionFor(position); 306 | 307 | // Only return the original position if a matching line was found. If no 308 | // matching line is found then we return position instead, which will cause 309 | // the stack trace to print the path and line for the compiled file. It is 310 | // better to give a precise location in the compiled file than a vague 311 | // location in the original file. 312 | if (originalPosition.source !== null) { 313 | originalPosition.source = supportRelativeURL( 314 | sourceMap.url, originalPosition.source); 315 | return originalPosition; 316 | } 317 | } 318 | 319 | return position; 320 | } 321 | 322 | // Parses code generated by FormatEvalOrigin(), a function inside V8: 323 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js 324 | function mapEvalOrigin(origin) { 325 | // Most eval() calls are in this format 326 | var match = /^eval at ([^(]+) \((.+):(\d+):(\d+)\)$/.exec(origin); 327 | if (match) { 328 | var position = mapSourcePosition({ 329 | source: match[2], 330 | line: +match[3], 331 | column: match[4] - 1 332 | }); 333 | return 'eval at ' + match[1] + ' (' + position.source + ':' + 334 | position.line + ':' + (position.column + 1) + ')'; 335 | } 336 | 337 | // Parse nested eval() calls using recursion 338 | match = /^eval at ([^(]+) \((.+)\)$/.exec(origin); 339 | if (match) { 340 | return 'eval at ' + match[1] + ' (' + mapEvalOrigin(match[2]) + ')'; 341 | } 342 | 343 | // Make sure we still return useful information if we didn't find anything 344 | return origin; 345 | } 346 | 347 | // This is copied almost verbatim from the V8 source code at 348 | // https://code.google.com/p/v8/source/browse/trunk/src/messages.js. The 349 | // implementation of wrapCallSite() used to just forward to the actual source 350 | // code of CallSite.prototype.toString but unfortunately a new release of V8 351 | // did something to the prototype chain and broke the shim. The only fix I 352 | // could find was copy/paste. 353 | function CallSiteToString() { 354 | var fileName; 355 | var fileLocation = ""; 356 | if (this.isNative()) { 357 | fileLocation = "native"; 358 | } else { 359 | fileName = this.getScriptNameOrSourceURL(); 360 | if (!fileName && this.isEval()) { 361 | fileLocation = this.getEvalOrigin(); 362 | fileLocation += ", "; // Expecting source position to follow. 363 | } 364 | 365 | if (fileName) { 366 | fileLocation += fileName; 367 | } else { 368 | // Source code does not originate from a file and is not native, but we 369 | // can still get the source position inside the source string, e.g. in 370 | // an eval string. 371 | fileLocation += ""; 372 | } 373 | var lineNumber = this.getLineNumber(); 374 | if (lineNumber != null) { 375 | fileLocation += ":" + lineNumber; 376 | var columnNumber = this.getColumnNumber(); 377 | if (columnNumber) { 378 | fileLocation += ":" + columnNumber; 379 | } 380 | } 381 | } 382 | 383 | var line = ""; 384 | var functionName = this.getFunctionName(); 385 | var addSuffix = true; 386 | var isConstructor = this.isConstructor(); 387 | var isMethodCall = !(this.isToplevel() || isConstructor); 388 | if (isMethodCall) { 389 | var typeName = this.getTypeName(); 390 | // Fixes shim to be backward compatable with Node v0 to v4 391 | if (typeName === "[object Object]") { 392 | typeName = "null"; 393 | } 394 | var methodName = this.getMethodName(); 395 | if (functionName) { 396 | if (typeName && functionName.indexOf(typeName) != 0) { 397 | line += typeName + "."; 398 | } 399 | line += functionName; 400 | if (methodName && functionName.indexOf("." + methodName) != functionName.length - methodName.length - 1) { 401 | line += " [as " + methodName + "]"; 402 | } 403 | } else { 404 | line += typeName + "." + (methodName || ""); 405 | } 406 | } else if (isConstructor) { 407 | line += "new " + (functionName || ""); 408 | } else if (functionName) { 409 | line += functionName; 410 | } else { 411 | line += fileLocation; 412 | addSuffix = false; 413 | } 414 | if (addSuffix) { 415 | line += " (" + fileLocation + ")"; 416 | } 417 | return line; 418 | } 419 | 420 | function cloneCallSite(frame) { 421 | var object = {}; 422 | Object.getOwnPropertyNames(Object.getPrototypeOf(frame)).forEach(function(name) { 423 | object[name] = /^(?:is|get)/.test(name) ? function() { return frame[name].call(frame); } : frame[name]; 424 | }); 425 | object.toString = CallSiteToString; 426 | return object; 427 | } 428 | 429 | function wrapCallSite(frame) { 430 | if(frame.isNative()) { 431 | return frame; 432 | } 433 | 434 | // Most call sites will return the source file from getFileName(), but code 435 | // passed to eval() ending in "//# sourceURL=..." will return the source file 436 | // from getScriptNameOrSourceURL() instead 437 | var source = frame.getFileName() || frame.getScriptNameOrSourceURL(); 438 | if (source) { 439 | var line = frame.getLineNumber(); 440 | var column = frame.getColumnNumber() - 1; 441 | 442 | // Fix position in Node where some (internal) code is prepended. 443 | // See https://github.com/evanw/node-source-map-support/issues/36 444 | var headerLength = 62; 445 | if (line === 1 && column > headerLength && !isInBrowser() && !frame.isEval()) { 446 | column -= headerLength; 447 | } 448 | 449 | var position = mapSourcePosition({ 450 | source: source, 451 | line: line, 452 | column: column 453 | }); 454 | frame = cloneCallSite(frame); 455 | var originalFunctionName = frame.getFunctionName; 456 | frame.getFunctionName = function() { return position.name || originalFunctionName(); }; 457 | frame.getFileName = function() { return position.source; }; 458 | frame.getLineNumber = function() { return position.line; }; 459 | frame.getColumnNumber = function() { return position.column + 1; }; 460 | frame.getScriptNameOrSourceURL = function() { return position.source; }; 461 | return frame; 462 | } 463 | 464 | // Code called using eval() needs special handling 465 | var origin = frame.isEval() && frame.getEvalOrigin(); 466 | if (origin) { 467 | origin = mapEvalOrigin(origin); 468 | frame = cloneCallSite(frame); 469 | frame.getEvalOrigin = function() { return origin; }; 470 | return frame; 471 | } 472 | 473 | // If we get here then we were unable to change the source position 474 | return frame; 475 | } 476 | 477 | // This function is part of the V8 stack trace API, for more info see: 478 | // http://code.google.com/p/v8/wiki/JavaScriptStackTraceApi 479 | function prepareStackTrace(error, stack) { 480 | if (emptyCacheBetweenOperations) { 481 | fileContentsCache = {}; 482 | sourceMapCache = {}; 483 | } 484 | 485 | return error + stack.map(function(frame) { 486 | return '\n at ' + wrapCallSite(frame); 487 | }).join(''); 488 | } 489 | 490 | // Generate position and snippet of original source with pointer 491 | function getErrorSource(error) { 492 | var match = /\n at [^(]+ \((.*):(\d+):(\d+)\)/.exec(error.stack); 493 | if (match) { 494 | var source = match[1]; 495 | var line = +match[2]; 496 | var column = +match[3]; 497 | 498 | // Support the inline sourceContents inside the source map 499 | var contents = fileContentsCache[source]; 500 | 501 | // Support files on disk 502 | if (!contents && fs && fs.existsSync(source)) { 503 | try { 504 | contents = fs.readFileSync(source, 'utf8'); 505 | } catch (er) { 506 | contents = ''; 507 | } 508 | } 509 | 510 | // Format the line from the original source code like node does 511 | if (contents) { 512 | var code = contents.split(/(?:\r\n|\r|\n)/)[line - 1]; 513 | if (code) { 514 | return source + ':' + line + '\n' + code + '\n' + 515 | new Array(column).join(' ') + '^'; 516 | } 517 | } 518 | } 519 | return null; 520 | } 521 | 522 | function printErrorAndExit (error) { 523 | var source = getErrorSource(error); 524 | 525 | // Ensure error is printed synchronously and not truncated 526 | if (process.stderr._handle && process.stderr._handle.setBlocking) { 527 | process.stderr._handle.setBlocking(true); 528 | } 529 | 530 | if (source) { 531 | console.error(); 532 | console.error(source); 533 | } 534 | 535 | console.error(error.stack); 536 | process.exit(1); 537 | } 538 | 539 | function shimEmitUncaughtException () { 540 | var origEmit = process.emit; 541 | 542 | process.emit = function (type) { 543 | if (type === 'uncaughtException') { 544 | var hasStack = (arguments[1] && arguments[1].stack); 545 | var hasListeners = (this.listeners(type).length > 0); 546 | 547 | if (hasStack && !hasListeners) { 548 | return printErrorAndExit(arguments[1]); 549 | } 550 | } 551 | 552 | return origEmit.apply(this, arguments); 553 | }; 554 | } 555 | 556 | var originalRetrieveFileHandlers = retrieveFileHandlers.slice(0); 557 | var originalRetrieveMapHandlers = retrieveMapHandlers.slice(0); 558 | 559 | exports.wrapCallSite = wrapCallSite; 560 | exports.getErrorSource = getErrorSource; 561 | exports.mapSourcePosition = mapSourcePosition; 562 | exports.retrieveSourceMap = retrieveSourceMap; 563 | 564 | exports.install = function(options) { 565 | options = options || {}; 566 | 567 | if (options.environment) { 568 | environment = options.environment; 569 | if (["node", "browser", "auto"].indexOf(environment) === -1) { 570 | throw new Error("environment " + environment + " was unknown. Available options are {auto, browser, node}") 571 | } 572 | } 573 | 574 | // Allow sources to be found by methods other than reading the files 575 | // directly from disk. 576 | if (options.retrieveFile) { 577 | if (options.overrideRetrieveFile) { 578 | retrieveFileHandlers.length = 0; 579 | } 580 | 581 | retrieveFileHandlers.unshift(options.retrieveFile); 582 | } 583 | 584 | // Allow source maps to be found by methods other than reading the files 585 | // directly from disk. 586 | if (options.retrieveSourceMap) { 587 | if (options.overrideRetrieveSourceMap) { 588 | retrieveMapHandlers.length = 0; 589 | } 590 | 591 | retrieveMapHandlers.unshift(options.retrieveSourceMap); 592 | } 593 | 594 | // Support runtime transpilers that include inline source maps 595 | if (options.hookRequire && !isInBrowser()) { 596 | var Module; 597 | try { 598 | Module = __webpack_require__(282); 599 | } catch (err) { 600 | // NOP: Loading in catch block to convert webpack error to warning. 601 | } 602 | var $compile = Module.prototype._compile; 603 | 604 | if (!$compile.__sourceMapSupport) { 605 | Module.prototype._compile = function(content, filename) { 606 | fileContentsCache[filename] = content; 607 | sourceMapCache[filename] = undefined; 608 | return $compile.call(this, content, filename); 609 | }; 610 | 611 | Module.prototype._compile.__sourceMapSupport = true; 612 | } 613 | } 614 | 615 | // Configure options 616 | if (!emptyCacheBetweenOperations) { 617 | emptyCacheBetweenOperations = 'emptyCacheBetweenOperations' in options ? 618 | options.emptyCacheBetweenOperations : false; 619 | } 620 | 621 | // Install the error reformatter 622 | if (!errorFormatterInstalled) { 623 | errorFormatterInstalled = true; 624 | Error.prepareStackTrace = prepareStackTrace; 625 | } 626 | 627 | if (!uncaughtShimInstalled) { 628 | var installHandler = 'handleUncaughtExceptions' in options ? 629 | options.handleUncaughtExceptions : true; 630 | 631 | // Provide the option to not install the uncaught exception handler. This is 632 | // to support other uncaught exception handlers (in test frameworks, for 633 | // example). If this handler is not installed and there are no other uncaught 634 | // exception handlers, uncaught exceptions will be caught by node's built-in 635 | // exception handler and the process will still be terminated. However, the 636 | // generated JavaScript code will be shown above the stack trace instead of 637 | // the original source code. 638 | if (installHandler && hasGlobalProcessEventEmitter()) { 639 | uncaughtShimInstalled = true; 640 | shimEmitUncaughtException(); 641 | } 642 | } 643 | }; 644 | 645 | exports.resetRetrieveHandlers = function() { 646 | retrieveFileHandlers.length = 0; 647 | retrieveMapHandlers.length = 0; 648 | 649 | retrieveFileHandlers = originalRetrieveFileHandlers.slice(0); 650 | retrieveMapHandlers = originalRetrieveMapHandlers.slice(0); 651 | } 652 | 653 | 654 | /***/ }), 655 | 656 | /***/ 837: 657 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 658 | 659 | /* -*- Mode: js; js-indent-level: 2; -*- */ 660 | /* 661 | * Copyright 2011 Mozilla Foundation and contributors 662 | * Licensed under the New BSD license. See LICENSE or: 663 | * http://opensource.org/licenses/BSD-3-Clause 664 | */ 665 | 666 | var util = __webpack_require__(983); 667 | var has = Object.prototype.hasOwnProperty; 668 | var hasNativeMap = typeof Map !== "undefined"; 669 | 670 | /** 671 | * A data structure which is a combination of an array and a set. Adding a new 672 | * member is O(1), testing for membership is O(1), and finding the index of an 673 | * element is O(1). Removing elements from the set is not supported. Only 674 | * strings are supported for membership. 675 | */ 676 | function ArraySet() { 677 | this._array = []; 678 | this._set = hasNativeMap ? new Map() : Object.create(null); 679 | } 680 | 681 | /** 682 | * Static method for creating ArraySet instances from an existing array. 683 | */ 684 | ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { 685 | var set = new ArraySet(); 686 | for (var i = 0, len = aArray.length; i < len; i++) { 687 | set.add(aArray[i], aAllowDuplicates); 688 | } 689 | return set; 690 | }; 691 | 692 | /** 693 | * Return how many unique items are in this ArraySet. If duplicates have been 694 | * added, than those do not count towards the size. 695 | * 696 | * @returns Number 697 | */ 698 | ArraySet.prototype.size = function ArraySet_size() { 699 | return hasNativeMap ? this._set.size : Object.getOwnPropertyNames(this._set).length; 700 | }; 701 | 702 | /** 703 | * Add the given string to this set. 704 | * 705 | * @param String aStr 706 | */ 707 | ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { 708 | var sStr = hasNativeMap ? aStr : util.toSetString(aStr); 709 | var isDuplicate = hasNativeMap ? this.has(aStr) : has.call(this._set, sStr); 710 | var idx = this._array.length; 711 | if (!isDuplicate || aAllowDuplicates) { 712 | this._array.push(aStr); 713 | } 714 | if (!isDuplicate) { 715 | if (hasNativeMap) { 716 | this._set.set(aStr, idx); 717 | } else { 718 | this._set[sStr] = idx; 719 | } 720 | } 721 | }; 722 | 723 | /** 724 | * Is the given string a member of this set? 725 | * 726 | * @param String aStr 727 | */ 728 | ArraySet.prototype.has = function ArraySet_has(aStr) { 729 | if (hasNativeMap) { 730 | return this._set.has(aStr); 731 | } else { 732 | var sStr = util.toSetString(aStr); 733 | return has.call(this._set, sStr); 734 | } 735 | }; 736 | 737 | /** 738 | * What is the index of the given string in the array? 739 | * 740 | * @param String aStr 741 | */ 742 | ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { 743 | if (hasNativeMap) { 744 | var idx = this._set.get(aStr); 745 | if (idx >= 0) { 746 | return idx; 747 | } 748 | } else { 749 | var sStr = util.toSetString(aStr); 750 | if (has.call(this._set, sStr)) { 751 | return this._set[sStr]; 752 | } 753 | } 754 | 755 | throw new Error('"' + aStr + '" is not in the set.'); 756 | }; 757 | 758 | /** 759 | * What is the element at the given index? 760 | * 761 | * @param Number aIdx 762 | */ 763 | ArraySet.prototype.at = function ArraySet_at(aIdx) { 764 | if (aIdx >= 0 && aIdx < this._array.length) { 765 | return this._array[aIdx]; 766 | } 767 | throw new Error('No element indexed by ' + aIdx); 768 | }; 769 | 770 | /** 771 | * Returns the array representation of this set (which has the proper indices 772 | * indicated by indexOf). Note that this is a copy of the internal array used 773 | * for storing the members so that no one can mess with internal state. 774 | */ 775 | ArraySet.prototype.toArray = function ArraySet_toArray() { 776 | return this._array.slice(); 777 | }; 778 | 779 | exports.I = ArraySet; 780 | 781 | 782 | /***/ }), 783 | 784 | /***/ 215: 785 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 786 | 787 | /* -*- Mode: js; js-indent-level: 2; -*- */ 788 | /* 789 | * Copyright 2011 Mozilla Foundation and contributors 790 | * Licensed under the New BSD license. See LICENSE or: 791 | * http://opensource.org/licenses/BSD-3-Clause 792 | * 793 | * Based on the Base 64 VLQ implementation in Closure Compiler: 794 | * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java 795 | * 796 | * Copyright 2011 The Closure Compiler Authors. All rights reserved. 797 | * Redistribution and use in source and binary forms, with or without 798 | * modification, are permitted provided that the following conditions are 799 | * met: 800 | * 801 | * * Redistributions of source code must retain the above copyright 802 | * notice, this list of conditions and the following disclaimer. 803 | * * Redistributions in binary form must reproduce the above 804 | * copyright notice, this list of conditions and the following 805 | * disclaimer in the documentation and/or other materials provided 806 | * with the distribution. 807 | * * Neither the name of Google Inc. nor the names of its 808 | * contributors may be used to endorse or promote products derived 809 | * from this software without specific prior written permission. 810 | * 811 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 812 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 813 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 814 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 815 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 816 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 817 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 818 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 819 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 820 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 821 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 822 | */ 823 | 824 | var base64 = __webpack_require__(537); 825 | 826 | // A single base 64 digit can contain 6 bits of data. For the base 64 variable 827 | // length quantities we use in the source map spec, the first bit is the sign, 828 | // the next four bits are the actual value, and the 6th bit is the 829 | // continuation bit. The continuation bit tells us whether there are more 830 | // digits in this value following this digit. 831 | // 832 | // Continuation 833 | // | Sign 834 | // | | 835 | // V V 836 | // 101011 837 | 838 | var VLQ_BASE_SHIFT = 5; 839 | 840 | // binary: 100000 841 | var VLQ_BASE = 1 << VLQ_BASE_SHIFT; 842 | 843 | // binary: 011111 844 | var VLQ_BASE_MASK = VLQ_BASE - 1; 845 | 846 | // binary: 100000 847 | var VLQ_CONTINUATION_BIT = VLQ_BASE; 848 | 849 | /** 850 | * Converts from a two-complement value to a value where the sign bit is 851 | * placed in the least significant bit. For example, as decimals: 852 | * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 853 | * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) 854 | */ 855 | function toVLQSigned(aValue) { 856 | return aValue < 0 857 | ? ((-aValue) << 1) + 1 858 | : (aValue << 1) + 0; 859 | } 860 | 861 | /** 862 | * Converts to a two-complement value from a value where the sign bit is 863 | * placed in the least significant bit. For example, as decimals: 864 | * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 865 | * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 866 | */ 867 | function fromVLQSigned(aValue) { 868 | var isNegative = (aValue & 1) === 1; 869 | var shifted = aValue >> 1; 870 | return isNegative 871 | ? -shifted 872 | : shifted; 873 | } 874 | 875 | /** 876 | * Returns the base 64 VLQ encoded value. 877 | */ 878 | exports.encode = function base64VLQ_encode(aValue) { 879 | var encoded = ""; 880 | var digit; 881 | 882 | var vlq = toVLQSigned(aValue); 883 | 884 | do { 885 | digit = vlq & VLQ_BASE_MASK; 886 | vlq >>>= VLQ_BASE_SHIFT; 887 | if (vlq > 0) { 888 | // There are still more digits in this value, so we must make sure the 889 | // continuation bit is marked. 890 | digit |= VLQ_CONTINUATION_BIT; 891 | } 892 | encoded += base64.encode(digit); 893 | } while (vlq > 0); 894 | 895 | return encoded; 896 | }; 897 | 898 | /** 899 | * Decodes the next base 64 VLQ value from the given string and returns the 900 | * value and the rest of the string via the out parameter. 901 | */ 902 | exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) { 903 | var strLen = aStr.length; 904 | var result = 0; 905 | var shift = 0; 906 | var continuation, digit; 907 | 908 | do { 909 | if (aIndex >= strLen) { 910 | throw new Error("Expected more digits in base 64 VLQ value."); 911 | } 912 | 913 | digit = base64.decode(aStr.charCodeAt(aIndex++)); 914 | if (digit === -1) { 915 | throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1)); 916 | } 917 | 918 | continuation = !!(digit & VLQ_CONTINUATION_BIT); 919 | digit &= VLQ_BASE_MASK; 920 | result = result + (digit << shift); 921 | shift += VLQ_BASE_SHIFT; 922 | } while (continuation); 923 | 924 | aOutParam.value = fromVLQSigned(result); 925 | aOutParam.rest = aIndex; 926 | }; 927 | 928 | 929 | /***/ }), 930 | 931 | /***/ 537: 932 | /***/ ((__unused_webpack_module, exports) => { 933 | 934 | /* -*- Mode: js; js-indent-level: 2; -*- */ 935 | /* 936 | * Copyright 2011 Mozilla Foundation and contributors 937 | * Licensed under the New BSD license. See LICENSE or: 938 | * http://opensource.org/licenses/BSD-3-Clause 939 | */ 940 | 941 | var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split(''); 942 | 943 | /** 944 | * Encode an integer in the range of 0 to 63 to a single base 64 digit. 945 | */ 946 | exports.encode = function (number) { 947 | if (0 <= number && number < intToCharMap.length) { 948 | return intToCharMap[number]; 949 | } 950 | throw new TypeError("Must be between 0 and 63: " + number); 951 | }; 952 | 953 | /** 954 | * Decode a single base 64 character code digit to an integer. Returns -1 on 955 | * failure. 956 | */ 957 | exports.decode = function (charCode) { 958 | var bigA = 65; // 'A' 959 | var bigZ = 90; // 'Z' 960 | 961 | var littleA = 97; // 'a' 962 | var littleZ = 122; // 'z' 963 | 964 | var zero = 48; // '0' 965 | var nine = 57; // '9' 966 | 967 | var plus = 43; // '+' 968 | var slash = 47; // '/' 969 | 970 | var littleOffset = 26; 971 | var numberOffset = 52; 972 | 973 | // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ 974 | if (bigA <= charCode && charCode <= bigZ) { 975 | return (charCode - bigA); 976 | } 977 | 978 | // 26 - 51: abcdefghijklmnopqrstuvwxyz 979 | if (littleA <= charCode && charCode <= littleZ) { 980 | return (charCode - littleA + littleOffset); 981 | } 982 | 983 | // 52 - 61: 0123456789 984 | if (zero <= charCode && charCode <= nine) { 985 | return (charCode - zero + numberOffset); 986 | } 987 | 988 | // 62: + 989 | if (charCode == plus) { 990 | return 62; 991 | } 992 | 993 | // 63: / 994 | if (charCode == slash) { 995 | return 63; 996 | } 997 | 998 | // Invalid base64 digit. 999 | return -1; 1000 | }; 1001 | 1002 | 1003 | /***/ }), 1004 | 1005 | /***/ 164: 1006 | /***/ ((__unused_webpack_module, exports) => { 1007 | 1008 | /* -*- Mode: js; js-indent-level: 2; -*- */ 1009 | /* 1010 | * Copyright 2011 Mozilla Foundation and contributors 1011 | * Licensed under the New BSD license. See LICENSE or: 1012 | * http://opensource.org/licenses/BSD-3-Clause 1013 | */ 1014 | 1015 | exports.GREATEST_LOWER_BOUND = 1; 1016 | exports.LEAST_UPPER_BOUND = 2; 1017 | 1018 | /** 1019 | * Recursive implementation of binary search. 1020 | * 1021 | * @param aLow Indices here and lower do not contain the needle. 1022 | * @param aHigh Indices here and higher do not contain the needle. 1023 | * @param aNeedle The element being searched for. 1024 | * @param aHaystack The non-empty array being searched. 1025 | * @param aCompare Function which takes two elements and returns -1, 0, or 1. 1026 | * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or 1027 | * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the 1028 | * closest element that is smaller than or greater than the one we are 1029 | * searching for, respectively, if the exact element cannot be found. 1030 | */ 1031 | function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) { 1032 | // This function terminates when one of the following is true: 1033 | // 1034 | // 1. We find the exact element we are looking for. 1035 | // 1036 | // 2. We did not find the exact element, but we can return the index of 1037 | // the next-closest element. 1038 | // 1039 | // 3. We did not find the exact element, and there is no next-closest 1040 | // element than the one we are searching for, so we return -1. 1041 | var mid = Math.floor((aHigh - aLow) / 2) + aLow; 1042 | var cmp = aCompare(aNeedle, aHaystack[mid], true); 1043 | if (cmp === 0) { 1044 | // Found the element we are looking for. 1045 | return mid; 1046 | } 1047 | else if (cmp > 0) { 1048 | // Our needle is greater than aHaystack[mid]. 1049 | if (aHigh - mid > 1) { 1050 | // The element is in the upper half. 1051 | return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias); 1052 | } 1053 | 1054 | // The exact needle element was not found in this haystack. Determine if 1055 | // we are in termination case (3) or (2) and return the appropriate thing. 1056 | if (aBias == exports.LEAST_UPPER_BOUND) { 1057 | return aHigh < aHaystack.length ? aHigh : -1; 1058 | } else { 1059 | return mid; 1060 | } 1061 | } 1062 | else { 1063 | // Our needle is less than aHaystack[mid]. 1064 | if (mid - aLow > 1) { 1065 | // The element is in the lower half. 1066 | return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias); 1067 | } 1068 | 1069 | // we are in termination case (3) or (2) and return the appropriate thing. 1070 | if (aBias == exports.LEAST_UPPER_BOUND) { 1071 | return mid; 1072 | } else { 1073 | return aLow < 0 ? -1 : aLow; 1074 | } 1075 | } 1076 | } 1077 | 1078 | /** 1079 | * This is an implementation of binary search which will always try and return 1080 | * the index of the closest element if there is no exact hit. This is because 1081 | * mappings between original and generated line/col pairs are single points, 1082 | * and there is an implicit region between each of them, so a miss just means 1083 | * that you aren't on the very start of a region. 1084 | * 1085 | * @param aNeedle The element you are looking for. 1086 | * @param aHaystack The array that is being searched. 1087 | * @param aCompare A function which takes the needle and an element in the 1088 | * array and returns -1, 0, or 1 depending on whether the needle is less 1089 | * than, equal to, or greater than the element, respectively. 1090 | * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or 1091 | * 'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the 1092 | * closest element that is smaller than or greater than the one we are 1093 | * searching for, respectively, if the exact element cannot be found. 1094 | * Defaults to 'binarySearch.GREATEST_LOWER_BOUND'. 1095 | */ 1096 | exports.search = function search(aNeedle, aHaystack, aCompare, aBias) { 1097 | if (aHaystack.length === 0) { 1098 | return -1; 1099 | } 1100 | 1101 | var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, 1102 | aCompare, aBias || exports.GREATEST_LOWER_BOUND); 1103 | if (index < 0) { 1104 | return -1; 1105 | } 1106 | 1107 | // We have found either the exact element, or the next-closest element than 1108 | // the one we are searching for. However, there may be more than one such 1109 | // element. Make sure we always return the smallest of these. 1110 | while (index - 1 >= 0) { 1111 | if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) { 1112 | break; 1113 | } 1114 | --index; 1115 | } 1116 | 1117 | return index; 1118 | }; 1119 | 1120 | 1121 | /***/ }), 1122 | 1123 | /***/ 740: 1124 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 1125 | 1126 | /* -*- Mode: js; js-indent-level: 2; -*- */ 1127 | /* 1128 | * Copyright 2014 Mozilla Foundation and contributors 1129 | * Licensed under the New BSD license. See LICENSE or: 1130 | * http://opensource.org/licenses/BSD-3-Clause 1131 | */ 1132 | 1133 | var util = __webpack_require__(983); 1134 | 1135 | /** 1136 | * Determine whether mappingB is after mappingA with respect to generated 1137 | * position. 1138 | */ 1139 | function generatedPositionAfter(mappingA, mappingB) { 1140 | // Optimized for most common case 1141 | var lineA = mappingA.generatedLine; 1142 | var lineB = mappingB.generatedLine; 1143 | var columnA = mappingA.generatedColumn; 1144 | var columnB = mappingB.generatedColumn; 1145 | return lineB > lineA || lineB == lineA && columnB >= columnA || 1146 | util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0; 1147 | } 1148 | 1149 | /** 1150 | * A data structure to provide a sorted view of accumulated mappings in a 1151 | * performance conscious manner. It trades a neglibable overhead in general 1152 | * case for a large speedup in case of mappings being added in order. 1153 | */ 1154 | function MappingList() { 1155 | this._array = []; 1156 | this._sorted = true; 1157 | // Serves as infimum 1158 | this._last = {generatedLine: -1, generatedColumn: 0}; 1159 | } 1160 | 1161 | /** 1162 | * Iterate through internal items. This method takes the same arguments that 1163 | * `Array.prototype.forEach` takes. 1164 | * 1165 | * NOTE: The order of the mappings is NOT guaranteed. 1166 | */ 1167 | MappingList.prototype.unsortedForEach = 1168 | function MappingList_forEach(aCallback, aThisArg) { 1169 | this._array.forEach(aCallback, aThisArg); 1170 | }; 1171 | 1172 | /** 1173 | * Add the given source mapping. 1174 | * 1175 | * @param Object aMapping 1176 | */ 1177 | MappingList.prototype.add = function MappingList_add(aMapping) { 1178 | if (generatedPositionAfter(this._last, aMapping)) { 1179 | this._last = aMapping; 1180 | this._array.push(aMapping); 1181 | } else { 1182 | this._sorted = false; 1183 | this._array.push(aMapping); 1184 | } 1185 | }; 1186 | 1187 | /** 1188 | * Returns the flat, sorted array of mappings. The mappings are sorted by 1189 | * generated position. 1190 | * 1191 | * WARNING: This method returns internal data without copying, for 1192 | * performance. The return value must NOT be mutated, and should be treated as 1193 | * an immutable borrow. If you want to take ownership, you must make your own 1194 | * copy. 1195 | */ 1196 | MappingList.prototype.toArray = function MappingList_toArray() { 1197 | if (!this._sorted) { 1198 | this._array.sort(util.compareByGeneratedPositionsInflated); 1199 | this._sorted = true; 1200 | } 1201 | return this._array; 1202 | }; 1203 | 1204 | exports.H = MappingList; 1205 | 1206 | 1207 | /***/ }), 1208 | 1209 | /***/ 226: 1210 | /***/ ((__unused_webpack_module, exports) => { 1211 | 1212 | /* -*- Mode: js; js-indent-level: 2; -*- */ 1213 | /* 1214 | * Copyright 2011 Mozilla Foundation and contributors 1215 | * Licensed under the New BSD license. See LICENSE or: 1216 | * http://opensource.org/licenses/BSD-3-Clause 1217 | */ 1218 | 1219 | // It turns out that some (most?) JavaScript engines don't self-host 1220 | // `Array.prototype.sort`. This makes sense because C++ will likely remain 1221 | // faster than JS when doing raw CPU-intensive sorting. However, when using a 1222 | // custom comparator function, calling back and forth between the VM's C++ and 1223 | // JIT'd JS is rather slow *and* loses JIT type information, resulting in 1224 | // worse generated code for the comparator function than would be optimal. In 1225 | // fact, when sorting with a comparator, these costs outweigh the benefits of 1226 | // sorting in C++. By using our own JS-implemented Quick Sort (below), we get 1227 | // a ~3500ms mean speed-up in `bench/bench.html`. 1228 | 1229 | /** 1230 | * Swap the elements indexed by `x` and `y` in the array `ary`. 1231 | * 1232 | * @param {Array} ary 1233 | * The array. 1234 | * @param {Number} x 1235 | * The index of the first item. 1236 | * @param {Number} y 1237 | * The index of the second item. 1238 | */ 1239 | function swap(ary, x, y) { 1240 | var temp = ary[x]; 1241 | ary[x] = ary[y]; 1242 | ary[y] = temp; 1243 | } 1244 | 1245 | /** 1246 | * Returns a random integer within the range `low .. high` inclusive. 1247 | * 1248 | * @param {Number} low 1249 | * The lower bound on the range. 1250 | * @param {Number} high 1251 | * The upper bound on the range. 1252 | */ 1253 | function randomIntInRange(low, high) { 1254 | return Math.round(low + (Math.random() * (high - low))); 1255 | } 1256 | 1257 | /** 1258 | * The Quick Sort algorithm. 1259 | * 1260 | * @param {Array} ary 1261 | * An array to sort. 1262 | * @param {function} comparator 1263 | * Function to use to compare two items. 1264 | * @param {Number} p 1265 | * Start index of the array 1266 | * @param {Number} r 1267 | * End index of the array 1268 | */ 1269 | function doQuickSort(ary, comparator, p, r) { 1270 | // If our lower bound is less than our upper bound, we (1) partition the 1271 | // array into two pieces and (2) recurse on each half. If it is not, this is 1272 | // the empty array and our base case. 1273 | 1274 | if (p < r) { 1275 | // (1) Partitioning. 1276 | // 1277 | // The partitioning chooses a pivot between `p` and `r` and moves all 1278 | // elements that are less than or equal to the pivot to the before it, and 1279 | // all the elements that are greater than it after it. The effect is that 1280 | // once partition is done, the pivot is in the exact place it will be when 1281 | // the array is put in sorted order, and it will not need to be moved 1282 | // again. This runs in O(n) time. 1283 | 1284 | // Always choose a random pivot so that an input array which is reverse 1285 | // sorted does not cause O(n^2) running time. 1286 | var pivotIndex = randomIntInRange(p, r); 1287 | var i = p - 1; 1288 | 1289 | swap(ary, pivotIndex, r); 1290 | var pivot = ary[r]; 1291 | 1292 | // Immediately after `j` is incremented in this loop, the following hold 1293 | // true: 1294 | // 1295 | // * Every element in `ary[p .. i]` is less than or equal to the pivot. 1296 | // 1297 | // * Every element in `ary[i+1 .. j-1]` is greater than the pivot. 1298 | for (var j = p; j < r; j++) { 1299 | if (comparator(ary[j], pivot) <= 0) { 1300 | i += 1; 1301 | swap(ary, i, j); 1302 | } 1303 | } 1304 | 1305 | swap(ary, i + 1, j); 1306 | var q = i + 1; 1307 | 1308 | // (2) Recurse on each half. 1309 | 1310 | doQuickSort(ary, comparator, p, q - 1); 1311 | doQuickSort(ary, comparator, q + 1, r); 1312 | } 1313 | } 1314 | 1315 | /** 1316 | * Sort the given array in-place with the given comparator function. 1317 | * 1318 | * @param {Array} ary 1319 | * An array to sort. 1320 | * @param {function} comparator 1321 | * Function to use to compare two items. 1322 | */ 1323 | exports.U = function (ary, comparator) { 1324 | doQuickSort(ary, comparator, 0, ary.length - 1); 1325 | }; 1326 | 1327 | 1328 | /***/ }), 1329 | 1330 | /***/ 327: 1331 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 1332 | 1333 | var __webpack_unused_export__; 1334 | /* -*- Mode: js; js-indent-level: 2; -*- */ 1335 | /* 1336 | * Copyright 2011 Mozilla Foundation and contributors 1337 | * Licensed under the New BSD license. See LICENSE or: 1338 | * http://opensource.org/licenses/BSD-3-Clause 1339 | */ 1340 | 1341 | var util = __webpack_require__(983); 1342 | var binarySearch = __webpack_require__(164); 1343 | var ArraySet = __webpack_require__(837)/* .ArraySet */ .I; 1344 | var base64VLQ = __webpack_require__(215); 1345 | var quickSort = __webpack_require__(226)/* .quickSort */ .U; 1346 | 1347 | function SourceMapConsumer(aSourceMap, aSourceMapURL) { 1348 | var sourceMap = aSourceMap; 1349 | if (typeof aSourceMap === 'string') { 1350 | sourceMap = util.parseSourceMapInput(aSourceMap); 1351 | } 1352 | 1353 | return sourceMap.sections != null 1354 | ? new IndexedSourceMapConsumer(sourceMap, aSourceMapURL) 1355 | : new BasicSourceMapConsumer(sourceMap, aSourceMapURL); 1356 | } 1357 | 1358 | SourceMapConsumer.fromSourceMap = function(aSourceMap, aSourceMapURL) { 1359 | return BasicSourceMapConsumer.fromSourceMap(aSourceMap, aSourceMapURL); 1360 | } 1361 | 1362 | /** 1363 | * The version of the source mapping spec that we are consuming. 1364 | */ 1365 | SourceMapConsumer.prototype._version = 3; 1366 | 1367 | // `__generatedMappings` and `__originalMappings` are arrays that hold the 1368 | // parsed mapping coordinates from the source map's "mappings" attribute. They 1369 | // are lazily instantiated, accessed via the `_generatedMappings` and 1370 | // `_originalMappings` getters respectively, and we only parse the mappings 1371 | // and create these arrays once queried for a source location. We jump through 1372 | // these hoops because there can be many thousands of mappings, and parsing 1373 | // them is expensive, so we only want to do it if we must. 1374 | // 1375 | // Each object in the arrays is of the form: 1376 | // 1377 | // { 1378 | // generatedLine: The line number in the generated code, 1379 | // generatedColumn: The column number in the generated code, 1380 | // source: The path to the original source file that generated this 1381 | // chunk of code, 1382 | // originalLine: The line number in the original source that 1383 | // corresponds to this chunk of generated code, 1384 | // originalColumn: The column number in the original source that 1385 | // corresponds to this chunk of generated code, 1386 | // name: The name of the original symbol which generated this chunk of 1387 | // code. 1388 | // } 1389 | // 1390 | // All properties except for `generatedLine` and `generatedColumn` can be 1391 | // `null`. 1392 | // 1393 | // `_generatedMappings` is ordered by the generated positions. 1394 | // 1395 | // `_originalMappings` is ordered by the original positions. 1396 | 1397 | SourceMapConsumer.prototype.__generatedMappings = null; 1398 | Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { 1399 | configurable: true, 1400 | enumerable: true, 1401 | get: function () { 1402 | if (!this.__generatedMappings) { 1403 | this._parseMappings(this._mappings, this.sourceRoot); 1404 | } 1405 | 1406 | return this.__generatedMappings; 1407 | } 1408 | }); 1409 | 1410 | SourceMapConsumer.prototype.__originalMappings = null; 1411 | Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { 1412 | configurable: true, 1413 | enumerable: true, 1414 | get: function () { 1415 | if (!this.__originalMappings) { 1416 | this._parseMappings(this._mappings, this.sourceRoot); 1417 | } 1418 | 1419 | return this.__originalMappings; 1420 | } 1421 | }); 1422 | 1423 | SourceMapConsumer.prototype._charIsMappingSeparator = 1424 | function SourceMapConsumer_charIsMappingSeparator(aStr, index) { 1425 | var c = aStr.charAt(index); 1426 | return c === ";" || c === ","; 1427 | }; 1428 | 1429 | /** 1430 | * Parse the mappings in a string in to a data structure which we can easily 1431 | * query (the ordered arrays in the `this.__generatedMappings` and 1432 | * `this.__originalMappings` properties). 1433 | */ 1434 | SourceMapConsumer.prototype._parseMappings = 1435 | function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { 1436 | throw new Error("Subclasses must implement _parseMappings"); 1437 | }; 1438 | 1439 | SourceMapConsumer.GENERATED_ORDER = 1; 1440 | SourceMapConsumer.ORIGINAL_ORDER = 2; 1441 | 1442 | SourceMapConsumer.GREATEST_LOWER_BOUND = 1; 1443 | SourceMapConsumer.LEAST_UPPER_BOUND = 2; 1444 | 1445 | /** 1446 | * Iterate over each mapping between an original source/line/column and a 1447 | * generated line/column in this source map. 1448 | * 1449 | * @param Function aCallback 1450 | * The function that is called with each mapping. 1451 | * @param Object aContext 1452 | * Optional. If specified, this object will be the value of `this` every 1453 | * time that `aCallback` is called. 1454 | * @param aOrder 1455 | * Either `SourceMapConsumer.GENERATED_ORDER` or 1456 | * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to 1457 | * iterate over the mappings sorted by the generated file's line/column 1458 | * order or the original's source/line/column order, respectively. Defaults to 1459 | * `SourceMapConsumer.GENERATED_ORDER`. 1460 | */ 1461 | SourceMapConsumer.prototype.eachMapping = 1462 | function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { 1463 | var context = aContext || null; 1464 | var order = aOrder || SourceMapConsumer.GENERATED_ORDER; 1465 | 1466 | var mappings; 1467 | switch (order) { 1468 | case SourceMapConsumer.GENERATED_ORDER: 1469 | mappings = this._generatedMappings; 1470 | break; 1471 | case SourceMapConsumer.ORIGINAL_ORDER: 1472 | mappings = this._originalMappings; 1473 | break; 1474 | default: 1475 | throw new Error("Unknown order of iteration."); 1476 | } 1477 | 1478 | var sourceRoot = this.sourceRoot; 1479 | mappings.map(function (mapping) { 1480 | var source = mapping.source === null ? null : this._sources.at(mapping.source); 1481 | source = util.computeSourceURL(sourceRoot, source, this._sourceMapURL); 1482 | return { 1483 | source: source, 1484 | generatedLine: mapping.generatedLine, 1485 | generatedColumn: mapping.generatedColumn, 1486 | originalLine: mapping.originalLine, 1487 | originalColumn: mapping.originalColumn, 1488 | name: mapping.name === null ? null : this._names.at(mapping.name) 1489 | }; 1490 | }, this).forEach(aCallback, context); 1491 | }; 1492 | 1493 | /** 1494 | * Returns all generated line and column information for the original source, 1495 | * line, and column provided. If no column is provided, returns all mappings 1496 | * corresponding to a either the line we are searching for or the next 1497 | * closest line that has any mappings. Otherwise, returns all mappings 1498 | * corresponding to the given line and either the column we are searching for 1499 | * or the next closest column that has any offsets. 1500 | * 1501 | * The only argument is an object with the following properties: 1502 | * 1503 | * - source: The filename of the original source. 1504 | * - line: The line number in the original source. The line number is 1-based. 1505 | * - column: Optional. the column number in the original source. 1506 | * The column number is 0-based. 1507 | * 1508 | * and an array of objects is returned, each with the following properties: 1509 | * 1510 | * - line: The line number in the generated source, or null. The 1511 | * line number is 1-based. 1512 | * - column: The column number in the generated source, or null. 1513 | * The column number is 0-based. 1514 | */ 1515 | SourceMapConsumer.prototype.allGeneratedPositionsFor = 1516 | function SourceMapConsumer_allGeneratedPositionsFor(aArgs) { 1517 | var line = util.getArg(aArgs, 'line'); 1518 | 1519 | // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping 1520 | // returns the index of the closest mapping less than the needle. By 1521 | // setting needle.originalColumn to 0, we thus find the last mapping for 1522 | // the given line, provided such a mapping exists. 1523 | var needle = { 1524 | source: util.getArg(aArgs, 'source'), 1525 | originalLine: line, 1526 | originalColumn: util.getArg(aArgs, 'column', 0) 1527 | }; 1528 | 1529 | needle.source = this._findSourceIndex(needle.source); 1530 | if (needle.source < 0) { 1531 | return []; 1532 | } 1533 | 1534 | var mappings = []; 1535 | 1536 | var index = this._findMapping(needle, 1537 | this._originalMappings, 1538 | "originalLine", 1539 | "originalColumn", 1540 | util.compareByOriginalPositions, 1541 | binarySearch.LEAST_UPPER_BOUND); 1542 | if (index >= 0) { 1543 | var mapping = this._originalMappings[index]; 1544 | 1545 | if (aArgs.column === undefined) { 1546 | var originalLine = mapping.originalLine; 1547 | 1548 | // Iterate until either we run out of mappings, or we run into 1549 | // a mapping for a different line than the one we found. Since 1550 | // mappings are sorted, this is guaranteed to find all mappings for 1551 | // the line we found. 1552 | while (mapping && mapping.originalLine === originalLine) { 1553 | mappings.push({ 1554 | line: util.getArg(mapping, 'generatedLine', null), 1555 | column: util.getArg(mapping, 'generatedColumn', null), 1556 | lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 1557 | }); 1558 | 1559 | mapping = this._originalMappings[++index]; 1560 | } 1561 | } else { 1562 | var originalColumn = mapping.originalColumn; 1563 | 1564 | // Iterate until either we run out of mappings, or we run into 1565 | // a mapping for a different line than the one we were searching for. 1566 | // Since mappings are sorted, this is guaranteed to find all mappings for 1567 | // the line we are searching for. 1568 | while (mapping && 1569 | mapping.originalLine === line && 1570 | mapping.originalColumn == originalColumn) { 1571 | mappings.push({ 1572 | line: util.getArg(mapping, 'generatedLine', null), 1573 | column: util.getArg(mapping, 'generatedColumn', null), 1574 | lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 1575 | }); 1576 | 1577 | mapping = this._originalMappings[++index]; 1578 | } 1579 | } 1580 | } 1581 | 1582 | return mappings; 1583 | }; 1584 | 1585 | exports.SourceMapConsumer = SourceMapConsumer; 1586 | 1587 | /** 1588 | * A BasicSourceMapConsumer instance represents a parsed source map which we can 1589 | * query for information about the original file positions by giving it a file 1590 | * position in the generated source. 1591 | * 1592 | * The first parameter is the raw source map (either as a JSON string, or 1593 | * already parsed to an object). According to the spec, source maps have the 1594 | * following attributes: 1595 | * 1596 | * - version: Which version of the source map spec this map is following. 1597 | * - sources: An array of URLs to the original source files. 1598 | * - names: An array of identifiers which can be referrenced by individual mappings. 1599 | * - sourceRoot: Optional. The URL root from which all sources are relative. 1600 | * - sourcesContent: Optional. An array of contents of the original source files. 1601 | * - mappings: A string of base64 VLQs which contain the actual mappings. 1602 | * - file: Optional. The generated file this source map is associated with. 1603 | * 1604 | * Here is an example source map, taken from the source map spec[0]: 1605 | * 1606 | * { 1607 | * version : 3, 1608 | * file: "out.js", 1609 | * sourceRoot : "", 1610 | * sources: ["foo.js", "bar.js"], 1611 | * names: ["src", "maps", "are", "fun"], 1612 | * mappings: "AA,AB;;ABCDE;" 1613 | * } 1614 | * 1615 | * The second parameter, if given, is a string whose value is the URL 1616 | * at which the source map was found. This URL is used to compute the 1617 | * sources array. 1618 | * 1619 | * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# 1620 | */ 1621 | function BasicSourceMapConsumer(aSourceMap, aSourceMapURL) { 1622 | var sourceMap = aSourceMap; 1623 | if (typeof aSourceMap === 'string') { 1624 | sourceMap = util.parseSourceMapInput(aSourceMap); 1625 | } 1626 | 1627 | var version = util.getArg(sourceMap, 'version'); 1628 | var sources = util.getArg(sourceMap, 'sources'); 1629 | // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which 1630 | // requires the array) to play nice here. 1631 | var names = util.getArg(sourceMap, 'names', []); 1632 | var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); 1633 | var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); 1634 | var mappings = util.getArg(sourceMap, 'mappings'); 1635 | var file = util.getArg(sourceMap, 'file', null); 1636 | 1637 | // Once again, Sass deviates from the spec and supplies the version as a 1638 | // string rather than a number, so we use loose equality checking here. 1639 | if (version != this._version) { 1640 | throw new Error('Unsupported version: ' + version); 1641 | } 1642 | 1643 | if (sourceRoot) { 1644 | sourceRoot = util.normalize(sourceRoot); 1645 | } 1646 | 1647 | sources = sources 1648 | .map(String) 1649 | // Some source maps produce relative source paths like "./foo.js" instead of 1650 | // "foo.js". Normalize these first so that future comparisons will succeed. 1651 | // See bugzil.la/1090768. 1652 | .map(util.normalize) 1653 | // Always ensure that absolute sources are internally stored relative to 1654 | // the source root, if the source root is absolute. Not doing this would 1655 | // be particularly problematic when the source root is a prefix of the 1656 | // source (valid, but why??). See github issue #199 and bugzil.la/1188982. 1657 | .map(function (source) { 1658 | return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source) 1659 | ? util.relative(sourceRoot, source) 1660 | : source; 1661 | }); 1662 | 1663 | // Pass `true` below to allow duplicate names and sources. While source maps 1664 | // are intended to be compressed and deduplicated, the TypeScript compiler 1665 | // sometimes generates source maps with duplicates in them. See Github issue 1666 | // #72 and bugzil.la/889492. 1667 | this._names = ArraySet.fromArray(names.map(String), true); 1668 | this._sources = ArraySet.fromArray(sources, true); 1669 | 1670 | this._absoluteSources = this._sources.toArray().map(function (s) { 1671 | return util.computeSourceURL(sourceRoot, s, aSourceMapURL); 1672 | }); 1673 | 1674 | this.sourceRoot = sourceRoot; 1675 | this.sourcesContent = sourcesContent; 1676 | this._mappings = mappings; 1677 | this._sourceMapURL = aSourceMapURL; 1678 | this.file = file; 1679 | } 1680 | 1681 | BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); 1682 | BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer; 1683 | 1684 | /** 1685 | * Utility function to find the index of a source. Returns -1 if not 1686 | * found. 1687 | */ 1688 | BasicSourceMapConsumer.prototype._findSourceIndex = function(aSource) { 1689 | var relativeSource = aSource; 1690 | if (this.sourceRoot != null) { 1691 | relativeSource = util.relative(this.sourceRoot, relativeSource); 1692 | } 1693 | 1694 | if (this._sources.has(relativeSource)) { 1695 | return this._sources.indexOf(relativeSource); 1696 | } 1697 | 1698 | // Maybe aSource is an absolute URL as returned by |sources|. In 1699 | // this case we can't simply undo the transform. 1700 | var i; 1701 | for (i = 0; i < this._absoluteSources.length; ++i) { 1702 | if (this._absoluteSources[i] == aSource) { 1703 | return i; 1704 | } 1705 | } 1706 | 1707 | return -1; 1708 | }; 1709 | 1710 | /** 1711 | * Create a BasicSourceMapConsumer from a SourceMapGenerator. 1712 | * 1713 | * @param SourceMapGenerator aSourceMap 1714 | * The source map that will be consumed. 1715 | * @param String aSourceMapURL 1716 | * The URL at which the source map can be found (optional) 1717 | * @returns BasicSourceMapConsumer 1718 | */ 1719 | BasicSourceMapConsumer.fromSourceMap = 1720 | function SourceMapConsumer_fromSourceMap(aSourceMap, aSourceMapURL) { 1721 | var smc = Object.create(BasicSourceMapConsumer.prototype); 1722 | 1723 | var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); 1724 | var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); 1725 | smc.sourceRoot = aSourceMap._sourceRoot; 1726 | smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), 1727 | smc.sourceRoot); 1728 | smc.file = aSourceMap._file; 1729 | smc._sourceMapURL = aSourceMapURL; 1730 | smc._absoluteSources = smc._sources.toArray().map(function (s) { 1731 | return util.computeSourceURL(smc.sourceRoot, s, aSourceMapURL); 1732 | }); 1733 | 1734 | // Because we are modifying the entries (by converting string sources and 1735 | // names to indices into the sources and names ArraySets), we have to make 1736 | // a copy of the entry or else bad things happen. Shared mutable state 1737 | // strikes again! See github issue #191. 1738 | 1739 | var generatedMappings = aSourceMap._mappings.toArray().slice(); 1740 | var destGeneratedMappings = smc.__generatedMappings = []; 1741 | var destOriginalMappings = smc.__originalMappings = []; 1742 | 1743 | for (var i = 0, length = generatedMappings.length; i < length; i++) { 1744 | var srcMapping = generatedMappings[i]; 1745 | var destMapping = new Mapping; 1746 | destMapping.generatedLine = srcMapping.generatedLine; 1747 | destMapping.generatedColumn = srcMapping.generatedColumn; 1748 | 1749 | if (srcMapping.source) { 1750 | destMapping.source = sources.indexOf(srcMapping.source); 1751 | destMapping.originalLine = srcMapping.originalLine; 1752 | destMapping.originalColumn = srcMapping.originalColumn; 1753 | 1754 | if (srcMapping.name) { 1755 | destMapping.name = names.indexOf(srcMapping.name); 1756 | } 1757 | 1758 | destOriginalMappings.push(destMapping); 1759 | } 1760 | 1761 | destGeneratedMappings.push(destMapping); 1762 | } 1763 | 1764 | quickSort(smc.__originalMappings, util.compareByOriginalPositions); 1765 | 1766 | return smc; 1767 | }; 1768 | 1769 | /** 1770 | * The version of the source mapping spec that we are consuming. 1771 | */ 1772 | BasicSourceMapConsumer.prototype._version = 3; 1773 | 1774 | /** 1775 | * The list of original sources. 1776 | */ 1777 | Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', { 1778 | get: function () { 1779 | return this._absoluteSources.slice(); 1780 | } 1781 | }); 1782 | 1783 | /** 1784 | * Provide the JIT with a nice shape / hidden class. 1785 | */ 1786 | function Mapping() { 1787 | this.generatedLine = 0; 1788 | this.generatedColumn = 0; 1789 | this.source = null; 1790 | this.originalLine = null; 1791 | this.originalColumn = null; 1792 | this.name = null; 1793 | } 1794 | 1795 | /** 1796 | * Parse the mappings in a string in to a data structure which we can easily 1797 | * query (the ordered arrays in the `this.__generatedMappings` and 1798 | * `this.__originalMappings` properties). 1799 | */ 1800 | BasicSourceMapConsumer.prototype._parseMappings = 1801 | function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { 1802 | var generatedLine = 1; 1803 | var previousGeneratedColumn = 0; 1804 | var previousOriginalLine = 0; 1805 | var previousOriginalColumn = 0; 1806 | var previousSource = 0; 1807 | var previousName = 0; 1808 | var length = aStr.length; 1809 | var index = 0; 1810 | var cachedSegments = {}; 1811 | var temp = {}; 1812 | var originalMappings = []; 1813 | var generatedMappings = []; 1814 | var mapping, str, segment, end, value; 1815 | 1816 | while (index < length) { 1817 | if (aStr.charAt(index) === ';') { 1818 | generatedLine++; 1819 | index++; 1820 | previousGeneratedColumn = 0; 1821 | } 1822 | else if (aStr.charAt(index) === ',') { 1823 | index++; 1824 | } 1825 | else { 1826 | mapping = new Mapping(); 1827 | mapping.generatedLine = generatedLine; 1828 | 1829 | // Because each offset is encoded relative to the previous one, 1830 | // many segments often have the same encoding. We can exploit this 1831 | // fact by caching the parsed variable length fields of each segment, 1832 | // allowing us to avoid a second parse if we encounter the same 1833 | // segment again. 1834 | for (end = index; end < length; end++) { 1835 | if (this._charIsMappingSeparator(aStr, end)) { 1836 | break; 1837 | } 1838 | } 1839 | str = aStr.slice(index, end); 1840 | 1841 | segment = cachedSegments[str]; 1842 | if (segment) { 1843 | index += str.length; 1844 | } else { 1845 | segment = []; 1846 | while (index < end) { 1847 | base64VLQ.decode(aStr, index, temp); 1848 | value = temp.value; 1849 | index = temp.rest; 1850 | segment.push(value); 1851 | } 1852 | 1853 | if (segment.length === 2) { 1854 | throw new Error('Found a source, but no line and column'); 1855 | } 1856 | 1857 | if (segment.length === 3) { 1858 | throw new Error('Found a source and line, but no column'); 1859 | } 1860 | 1861 | cachedSegments[str] = segment; 1862 | } 1863 | 1864 | // Generated column. 1865 | mapping.generatedColumn = previousGeneratedColumn + segment[0]; 1866 | previousGeneratedColumn = mapping.generatedColumn; 1867 | 1868 | if (segment.length > 1) { 1869 | // Original source. 1870 | mapping.source = previousSource + segment[1]; 1871 | previousSource += segment[1]; 1872 | 1873 | // Original line. 1874 | mapping.originalLine = previousOriginalLine + segment[2]; 1875 | previousOriginalLine = mapping.originalLine; 1876 | // Lines are stored 0-based 1877 | mapping.originalLine += 1; 1878 | 1879 | // Original column. 1880 | mapping.originalColumn = previousOriginalColumn + segment[3]; 1881 | previousOriginalColumn = mapping.originalColumn; 1882 | 1883 | if (segment.length > 4) { 1884 | // Original name. 1885 | mapping.name = previousName + segment[4]; 1886 | previousName += segment[4]; 1887 | } 1888 | } 1889 | 1890 | generatedMappings.push(mapping); 1891 | if (typeof mapping.originalLine === 'number') { 1892 | originalMappings.push(mapping); 1893 | } 1894 | } 1895 | } 1896 | 1897 | quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated); 1898 | this.__generatedMappings = generatedMappings; 1899 | 1900 | quickSort(originalMappings, util.compareByOriginalPositions); 1901 | this.__originalMappings = originalMappings; 1902 | }; 1903 | 1904 | /** 1905 | * Find the mapping that best matches the hypothetical "needle" mapping that 1906 | * we are searching for in the given "haystack" of mappings. 1907 | */ 1908 | BasicSourceMapConsumer.prototype._findMapping = 1909 | function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, 1910 | aColumnName, aComparator, aBias) { 1911 | // To return the position we are searching for, we must first find the 1912 | // mapping for the given position and then return the opposite position it 1913 | // points to. Because the mappings are sorted, we can use binary search to 1914 | // find the best mapping. 1915 | 1916 | if (aNeedle[aLineName] <= 0) { 1917 | throw new TypeError('Line must be greater than or equal to 1, got ' 1918 | + aNeedle[aLineName]); 1919 | } 1920 | if (aNeedle[aColumnName] < 0) { 1921 | throw new TypeError('Column must be greater than or equal to 0, got ' 1922 | + aNeedle[aColumnName]); 1923 | } 1924 | 1925 | return binarySearch.search(aNeedle, aMappings, aComparator, aBias); 1926 | }; 1927 | 1928 | /** 1929 | * Compute the last column for each generated mapping. The last column is 1930 | * inclusive. 1931 | */ 1932 | BasicSourceMapConsumer.prototype.computeColumnSpans = 1933 | function SourceMapConsumer_computeColumnSpans() { 1934 | for (var index = 0; index < this._generatedMappings.length; ++index) { 1935 | var mapping = this._generatedMappings[index]; 1936 | 1937 | // Mappings do not contain a field for the last generated columnt. We 1938 | // can come up with an optimistic estimate, however, by assuming that 1939 | // mappings are contiguous (i.e. given two consecutive mappings, the 1940 | // first mapping ends where the second one starts). 1941 | if (index + 1 < this._generatedMappings.length) { 1942 | var nextMapping = this._generatedMappings[index + 1]; 1943 | 1944 | if (mapping.generatedLine === nextMapping.generatedLine) { 1945 | mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1; 1946 | continue; 1947 | } 1948 | } 1949 | 1950 | // The last mapping for each line spans the entire line. 1951 | mapping.lastGeneratedColumn = Infinity; 1952 | } 1953 | }; 1954 | 1955 | /** 1956 | * Returns the original source, line, and column information for the generated 1957 | * source's line and column positions provided. The only argument is an object 1958 | * with the following properties: 1959 | * 1960 | * - line: The line number in the generated source. The line number 1961 | * is 1-based. 1962 | * - column: The column number in the generated source. The column 1963 | * number is 0-based. 1964 | * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 1965 | * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the 1966 | * closest element that is smaller than or greater than the one we are 1967 | * searching for, respectively, if the exact element cannot be found. 1968 | * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. 1969 | * 1970 | * and an object is returned with the following properties: 1971 | * 1972 | * - source: The original source file, or null. 1973 | * - line: The line number in the original source, or null. The 1974 | * line number is 1-based. 1975 | * - column: The column number in the original source, or null. The 1976 | * column number is 0-based. 1977 | * - name: The original identifier, or null. 1978 | */ 1979 | BasicSourceMapConsumer.prototype.originalPositionFor = 1980 | function SourceMapConsumer_originalPositionFor(aArgs) { 1981 | var needle = { 1982 | generatedLine: util.getArg(aArgs, 'line'), 1983 | generatedColumn: util.getArg(aArgs, 'column') 1984 | }; 1985 | 1986 | var index = this._findMapping( 1987 | needle, 1988 | this._generatedMappings, 1989 | "generatedLine", 1990 | "generatedColumn", 1991 | util.compareByGeneratedPositionsDeflated, 1992 | util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) 1993 | ); 1994 | 1995 | if (index >= 0) { 1996 | var mapping = this._generatedMappings[index]; 1997 | 1998 | if (mapping.generatedLine === needle.generatedLine) { 1999 | var source = util.getArg(mapping, 'source', null); 2000 | if (source !== null) { 2001 | source = this._sources.at(source); 2002 | source = util.computeSourceURL(this.sourceRoot, source, this._sourceMapURL); 2003 | } 2004 | var name = util.getArg(mapping, 'name', null); 2005 | if (name !== null) { 2006 | name = this._names.at(name); 2007 | } 2008 | return { 2009 | source: source, 2010 | line: util.getArg(mapping, 'originalLine', null), 2011 | column: util.getArg(mapping, 'originalColumn', null), 2012 | name: name 2013 | }; 2014 | } 2015 | } 2016 | 2017 | return { 2018 | source: null, 2019 | line: null, 2020 | column: null, 2021 | name: null 2022 | }; 2023 | }; 2024 | 2025 | /** 2026 | * Return true if we have the source content for every source in the source 2027 | * map, false otherwise. 2028 | */ 2029 | BasicSourceMapConsumer.prototype.hasContentsOfAllSources = 2030 | function BasicSourceMapConsumer_hasContentsOfAllSources() { 2031 | if (!this.sourcesContent) { 2032 | return false; 2033 | } 2034 | return this.sourcesContent.length >= this._sources.size() && 2035 | !this.sourcesContent.some(function (sc) { return sc == null; }); 2036 | }; 2037 | 2038 | /** 2039 | * Returns the original source content. The only argument is the url of the 2040 | * original source file. Returns null if no original source content is 2041 | * available. 2042 | */ 2043 | BasicSourceMapConsumer.prototype.sourceContentFor = 2044 | function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { 2045 | if (!this.sourcesContent) { 2046 | return null; 2047 | } 2048 | 2049 | var index = this._findSourceIndex(aSource); 2050 | if (index >= 0) { 2051 | return this.sourcesContent[index]; 2052 | } 2053 | 2054 | var relativeSource = aSource; 2055 | if (this.sourceRoot != null) { 2056 | relativeSource = util.relative(this.sourceRoot, relativeSource); 2057 | } 2058 | 2059 | var url; 2060 | if (this.sourceRoot != null 2061 | && (url = util.urlParse(this.sourceRoot))) { 2062 | // XXX: file:// URIs and absolute paths lead to unexpected behavior for 2063 | // many users. We can help them out when they expect file:// URIs to 2064 | // behave like it would if they were running a local HTTP server. See 2065 | // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. 2066 | var fileUriAbsPath = relativeSource.replace(/^file:\/\//, ""); 2067 | if (url.scheme == "file" 2068 | && this._sources.has(fileUriAbsPath)) { 2069 | return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] 2070 | } 2071 | 2072 | if ((!url.path || url.path == "/") 2073 | && this._sources.has("/" + relativeSource)) { 2074 | return this.sourcesContent[this._sources.indexOf("/" + relativeSource)]; 2075 | } 2076 | } 2077 | 2078 | // This function is used recursively from 2079 | // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we 2080 | // don't want to throw if we can't find the source - we just want to 2081 | // return null, so we provide a flag to exit gracefully. 2082 | if (nullOnMissing) { 2083 | return null; 2084 | } 2085 | else { 2086 | throw new Error('"' + relativeSource + '" is not in the SourceMap.'); 2087 | } 2088 | }; 2089 | 2090 | /** 2091 | * Returns the generated line and column information for the original source, 2092 | * line, and column positions provided. The only argument is an object with 2093 | * the following properties: 2094 | * 2095 | * - source: The filename of the original source. 2096 | * - line: The line number in the original source. The line number 2097 | * is 1-based. 2098 | * - column: The column number in the original source. The column 2099 | * number is 0-based. 2100 | * - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or 2101 | * 'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the 2102 | * closest element that is smaller than or greater than the one we are 2103 | * searching for, respectively, if the exact element cannot be found. 2104 | * Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'. 2105 | * 2106 | * and an object is returned with the following properties: 2107 | * 2108 | * - line: The line number in the generated source, or null. The 2109 | * line number is 1-based. 2110 | * - column: The column number in the generated source, or null. 2111 | * The column number is 0-based. 2112 | */ 2113 | BasicSourceMapConsumer.prototype.generatedPositionFor = 2114 | function SourceMapConsumer_generatedPositionFor(aArgs) { 2115 | var source = util.getArg(aArgs, 'source'); 2116 | source = this._findSourceIndex(source); 2117 | if (source < 0) { 2118 | return { 2119 | line: null, 2120 | column: null, 2121 | lastColumn: null 2122 | }; 2123 | } 2124 | 2125 | var needle = { 2126 | source: source, 2127 | originalLine: util.getArg(aArgs, 'line'), 2128 | originalColumn: util.getArg(aArgs, 'column') 2129 | }; 2130 | 2131 | var index = this._findMapping( 2132 | needle, 2133 | this._originalMappings, 2134 | "originalLine", 2135 | "originalColumn", 2136 | util.compareByOriginalPositions, 2137 | util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND) 2138 | ); 2139 | 2140 | if (index >= 0) { 2141 | var mapping = this._originalMappings[index]; 2142 | 2143 | if (mapping.source === needle.source) { 2144 | return { 2145 | line: util.getArg(mapping, 'generatedLine', null), 2146 | column: util.getArg(mapping, 'generatedColumn', null), 2147 | lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null) 2148 | }; 2149 | } 2150 | } 2151 | 2152 | return { 2153 | line: null, 2154 | column: null, 2155 | lastColumn: null 2156 | }; 2157 | }; 2158 | 2159 | __webpack_unused_export__ = BasicSourceMapConsumer; 2160 | 2161 | /** 2162 | * An IndexedSourceMapConsumer instance represents a parsed source map which 2163 | * we can query for information. It differs from BasicSourceMapConsumer in 2164 | * that it takes "indexed" source maps (i.e. ones with a "sections" field) as 2165 | * input. 2166 | * 2167 | * The first parameter is a raw source map (either as a JSON string, or already 2168 | * parsed to an object). According to the spec for indexed source maps, they 2169 | * have the following attributes: 2170 | * 2171 | * - version: Which version of the source map spec this map is following. 2172 | * - file: Optional. The generated file this source map is associated with. 2173 | * - sections: A list of section definitions. 2174 | * 2175 | * Each value under the "sections" field has two fields: 2176 | * - offset: The offset into the original specified at which this section 2177 | * begins to apply, defined as an object with a "line" and "column" 2178 | * field. 2179 | * - map: A source map definition. This source map could also be indexed, 2180 | * but doesn't have to be. 2181 | * 2182 | * Instead of the "map" field, it's also possible to have a "url" field 2183 | * specifying a URL to retrieve a source map from, but that's currently 2184 | * unsupported. 2185 | * 2186 | * Here's an example source map, taken from the source map spec[0], but 2187 | * modified to omit a section which uses the "url" field. 2188 | * 2189 | * { 2190 | * version : 3, 2191 | * file: "app.js", 2192 | * sections: [{ 2193 | * offset: {line:100, column:10}, 2194 | * map: { 2195 | * version : 3, 2196 | * file: "section.js", 2197 | * sources: ["foo.js", "bar.js"], 2198 | * names: ["src", "maps", "are", "fun"], 2199 | * mappings: "AAAA,E;;ABCDE;" 2200 | * } 2201 | * }], 2202 | * } 2203 | * 2204 | * The second parameter, if given, is a string whose value is the URL 2205 | * at which the source map was found. This URL is used to compute the 2206 | * sources array. 2207 | * 2208 | * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt 2209 | */ 2210 | function IndexedSourceMapConsumer(aSourceMap, aSourceMapURL) { 2211 | var sourceMap = aSourceMap; 2212 | if (typeof aSourceMap === 'string') { 2213 | sourceMap = util.parseSourceMapInput(aSourceMap); 2214 | } 2215 | 2216 | var version = util.getArg(sourceMap, 'version'); 2217 | var sections = util.getArg(sourceMap, 'sections'); 2218 | 2219 | if (version != this._version) { 2220 | throw new Error('Unsupported version: ' + version); 2221 | } 2222 | 2223 | this._sources = new ArraySet(); 2224 | this._names = new ArraySet(); 2225 | 2226 | var lastOffset = { 2227 | line: -1, 2228 | column: 0 2229 | }; 2230 | this._sections = sections.map(function (s) { 2231 | if (s.url) { 2232 | // The url field will require support for asynchronicity. 2233 | // See https://github.com/mozilla/source-map/issues/16 2234 | throw new Error('Support for url field in sections not implemented.'); 2235 | } 2236 | var offset = util.getArg(s, 'offset'); 2237 | var offsetLine = util.getArg(offset, 'line'); 2238 | var offsetColumn = util.getArg(offset, 'column'); 2239 | 2240 | if (offsetLine < lastOffset.line || 2241 | (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) { 2242 | throw new Error('Section offsets must be ordered and non-overlapping.'); 2243 | } 2244 | lastOffset = offset; 2245 | 2246 | return { 2247 | generatedOffset: { 2248 | // The offset fields are 0-based, but we use 1-based indices when 2249 | // encoding/decoding from VLQ. 2250 | generatedLine: offsetLine + 1, 2251 | generatedColumn: offsetColumn + 1 2252 | }, 2253 | consumer: new SourceMapConsumer(util.getArg(s, 'map'), aSourceMapURL) 2254 | } 2255 | }); 2256 | } 2257 | 2258 | IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype); 2259 | IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer; 2260 | 2261 | /** 2262 | * The version of the source mapping spec that we are consuming. 2263 | */ 2264 | IndexedSourceMapConsumer.prototype._version = 3; 2265 | 2266 | /** 2267 | * The list of original sources. 2268 | */ 2269 | Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', { 2270 | get: function () { 2271 | var sources = []; 2272 | for (var i = 0; i < this._sections.length; i++) { 2273 | for (var j = 0; j < this._sections[i].consumer.sources.length; j++) { 2274 | sources.push(this._sections[i].consumer.sources[j]); 2275 | } 2276 | } 2277 | return sources; 2278 | } 2279 | }); 2280 | 2281 | /** 2282 | * Returns the original source, line, and column information for the generated 2283 | * source's line and column positions provided. The only argument is an object 2284 | * with the following properties: 2285 | * 2286 | * - line: The line number in the generated source. The line number 2287 | * is 1-based. 2288 | * - column: The column number in the generated source. The column 2289 | * number is 0-based. 2290 | * 2291 | * and an object is returned with the following properties: 2292 | * 2293 | * - source: The original source file, or null. 2294 | * - line: The line number in the original source, or null. The 2295 | * line number is 1-based. 2296 | * - column: The column number in the original source, or null. The 2297 | * column number is 0-based. 2298 | * - name: The original identifier, or null. 2299 | */ 2300 | IndexedSourceMapConsumer.prototype.originalPositionFor = 2301 | function IndexedSourceMapConsumer_originalPositionFor(aArgs) { 2302 | var needle = { 2303 | generatedLine: util.getArg(aArgs, 'line'), 2304 | generatedColumn: util.getArg(aArgs, 'column') 2305 | }; 2306 | 2307 | // Find the section containing the generated position we're trying to map 2308 | // to an original position. 2309 | var sectionIndex = binarySearch.search(needle, this._sections, 2310 | function(needle, section) { 2311 | var cmp = needle.generatedLine - section.generatedOffset.generatedLine; 2312 | if (cmp) { 2313 | return cmp; 2314 | } 2315 | 2316 | return (needle.generatedColumn - 2317 | section.generatedOffset.generatedColumn); 2318 | }); 2319 | var section = this._sections[sectionIndex]; 2320 | 2321 | if (!section) { 2322 | return { 2323 | source: null, 2324 | line: null, 2325 | column: null, 2326 | name: null 2327 | }; 2328 | } 2329 | 2330 | return section.consumer.originalPositionFor({ 2331 | line: needle.generatedLine - 2332 | (section.generatedOffset.generatedLine - 1), 2333 | column: needle.generatedColumn - 2334 | (section.generatedOffset.generatedLine === needle.generatedLine 2335 | ? section.generatedOffset.generatedColumn - 1 2336 | : 0), 2337 | bias: aArgs.bias 2338 | }); 2339 | }; 2340 | 2341 | /** 2342 | * Return true if we have the source content for every source in the source 2343 | * map, false otherwise. 2344 | */ 2345 | IndexedSourceMapConsumer.prototype.hasContentsOfAllSources = 2346 | function IndexedSourceMapConsumer_hasContentsOfAllSources() { 2347 | return this._sections.every(function (s) { 2348 | return s.consumer.hasContentsOfAllSources(); 2349 | }); 2350 | }; 2351 | 2352 | /** 2353 | * Returns the original source content. The only argument is the url of the 2354 | * original source file. Returns null if no original source content is 2355 | * available. 2356 | */ 2357 | IndexedSourceMapConsumer.prototype.sourceContentFor = 2358 | function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) { 2359 | for (var i = 0; i < this._sections.length; i++) { 2360 | var section = this._sections[i]; 2361 | 2362 | var content = section.consumer.sourceContentFor(aSource, true); 2363 | if (content) { 2364 | return content; 2365 | } 2366 | } 2367 | if (nullOnMissing) { 2368 | return null; 2369 | } 2370 | else { 2371 | throw new Error('"' + aSource + '" is not in the SourceMap.'); 2372 | } 2373 | }; 2374 | 2375 | /** 2376 | * Returns the generated line and column information for the original source, 2377 | * line, and column positions provided. The only argument is an object with 2378 | * the following properties: 2379 | * 2380 | * - source: The filename of the original source. 2381 | * - line: The line number in the original source. The line number 2382 | * is 1-based. 2383 | * - column: The column number in the original source. The column 2384 | * number is 0-based. 2385 | * 2386 | * and an object is returned with the following properties: 2387 | * 2388 | * - line: The line number in the generated source, or null. The 2389 | * line number is 1-based. 2390 | * - column: The column number in the generated source, or null. 2391 | * The column number is 0-based. 2392 | */ 2393 | IndexedSourceMapConsumer.prototype.generatedPositionFor = 2394 | function IndexedSourceMapConsumer_generatedPositionFor(aArgs) { 2395 | for (var i = 0; i < this._sections.length; i++) { 2396 | var section = this._sections[i]; 2397 | 2398 | // Only consider this section if the requested source is in the list of 2399 | // sources of the consumer. 2400 | if (section.consumer._findSourceIndex(util.getArg(aArgs, 'source')) === -1) { 2401 | continue; 2402 | } 2403 | var generatedPosition = section.consumer.generatedPositionFor(aArgs); 2404 | if (generatedPosition) { 2405 | var ret = { 2406 | line: generatedPosition.line + 2407 | (section.generatedOffset.generatedLine - 1), 2408 | column: generatedPosition.column + 2409 | (section.generatedOffset.generatedLine === generatedPosition.line 2410 | ? section.generatedOffset.generatedColumn - 1 2411 | : 0) 2412 | }; 2413 | return ret; 2414 | } 2415 | } 2416 | 2417 | return { 2418 | line: null, 2419 | column: null 2420 | }; 2421 | }; 2422 | 2423 | /** 2424 | * Parse the mappings in a string in to a data structure which we can easily 2425 | * query (the ordered arrays in the `this.__generatedMappings` and 2426 | * `this.__originalMappings` properties). 2427 | */ 2428 | IndexedSourceMapConsumer.prototype._parseMappings = 2429 | function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) { 2430 | this.__generatedMappings = []; 2431 | this.__originalMappings = []; 2432 | for (var i = 0; i < this._sections.length; i++) { 2433 | var section = this._sections[i]; 2434 | var sectionMappings = section.consumer._generatedMappings; 2435 | for (var j = 0; j < sectionMappings.length; j++) { 2436 | var mapping = sectionMappings[j]; 2437 | 2438 | var source = section.consumer._sources.at(mapping.source); 2439 | source = util.computeSourceURL(section.consumer.sourceRoot, source, this._sourceMapURL); 2440 | this._sources.add(source); 2441 | source = this._sources.indexOf(source); 2442 | 2443 | var name = null; 2444 | if (mapping.name) { 2445 | name = section.consumer._names.at(mapping.name); 2446 | this._names.add(name); 2447 | name = this._names.indexOf(name); 2448 | } 2449 | 2450 | // The mappings coming from the consumer for the section have 2451 | // generated positions relative to the start of the section, so we 2452 | // need to offset them to be relative to the start of the concatenated 2453 | // generated file. 2454 | var adjustedMapping = { 2455 | source: source, 2456 | generatedLine: mapping.generatedLine + 2457 | (section.generatedOffset.generatedLine - 1), 2458 | generatedColumn: mapping.generatedColumn + 2459 | (section.generatedOffset.generatedLine === mapping.generatedLine 2460 | ? section.generatedOffset.generatedColumn - 1 2461 | : 0), 2462 | originalLine: mapping.originalLine, 2463 | originalColumn: mapping.originalColumn, 2464 | name: name 2465 | }; 2466 | 2467 | this.__generatedMappings.push(adjustedMapping); 2468 | if (typeof adjustedMapping.originalLine === 'number') { 2469 | this.__originalMappings.push(adjustedMapping); 2470 | } 2471 | } 2472 | } 2473 | 2474 | quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated); 2475 | quickSort(this.__originalMappings, util.compareByOriginalPositions); 2476 | }; 2477 | 2478 | __webpack_unused_export__ = IndexedSourceMapConsumer; 2479 | 2480 | 2481 | /***/ }), 2482 | 2483 | /***/ 341: 2484 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 2485 | 2486 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2487 | /* 2488 | * Copyright 2011 Mozilla Foundation and contributors 2489 | * Licensed under the New BSD license. See LICENSE or: 2490 | * http://opensource.org/licenses/BSD-3-Clause 2491 | */ 2492 | 2493 | var base64VLQ = __webpack_require__(215); 2494 | var util = __webpack_require__(983); 2495 | var ArraySet = __webpack_require__(837)/* .ArraySet */ .I; 2496 | var MappingList = __webpack_require__(740)/* .MappingList */ .H; 2497 | 2498 | /** 2499 | * An instance of the SourceMapGenerator represents a source map which is 2500 | * being built incrementally. You may pass an object with the following 2501 | * properties: 2502 | * 2503 | * - file: The filename of the generated source. 2504 | * - sourceRoot: A root for all relative URLs in this source map. 2505 | */ 2506 | function SourceMapGenerator(aArgs) { 2507 | if (!aArgs) { 2508 | aArgs = {}; 2509 | } 2510 | this._file = util.getArg(aArgs, 'file', null); 2511 | this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); 2512 | this._skipValidation = util.getArg(aArgs, 'skipValidation', false); 2513 | this._sources = new ArraySet(); 2514 | this._names = new ArraySet(); 2515 | this._mappings = new MappingList(); 2516 | this._sourcesContents = null; 2517 | } 2518 | 2519 | SourceMapGenerator.prototype._version = 3; 2520 | 2521 | /** 2522 | * Creates a new SourceMapGenerator based on a SourceMapConsumer 2523 | * 2524 | * @param aSourceMapConsumer The SourceMap. 2525 | */ 2526 | SourceMapGenerator.fromSourceMap = 2527 | function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { 2528 | var sourceRoot = aSourceMapConsumer.sourceRoot; 2529 | var generator = new SourceMapGenerator({ 2530 | file: aSourceMapConsumer.file, 2531 | sourceRoot: sourceRoot 2532 | }); 2533 | aSourceMapConsumer.eachMapping(function (mapping) { 2534 | var newMapping = { 2535 | generated: { 2536 | line: mapping.generatedLine, 2537 | column: mapping.generatedColumn 2538 | } 2539 | }; 2540 | 2541 | if (mapping.source != null) { 2542 | newMapping.source = mapping.source; 2543 | if (sourceRoot != null) { 2544 | newMapping.source = util.relative(sourceRoot, newMapping.source); 2545 | } 2546 | 2547 | newMapping.original = { 2548 | line: mapping.originalLine, 2549 | column: mapping.originalColumn 2550 | }; 2551 | 2552 | if (mapping.name != null) { 2553 | newMapping.name = mapping.name; 2554 | } 2555 | } 2556 | 2557 | generator.addMapping(newMapping); 2558 | }); 2559 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 2560 | var sourceRelative = sourceFile; 2561 | if (sourceRoot !== null) { 2562 | sourceRelative = util.relative(sourceRoot, sourceFile); 2563 | } 2564 | 2565 | if (!generator._sources.has(sourceRelative)) { 2566 | generator._sources.add(sourceRelative); 2567 | } 2568 | 2569 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 2570 | if (content != null) { 2571 | generator.setSourceContent(sourceFile, content); 2572 | } 2573 | }); 2574 | return generator; 2575 | }; 2576 | 2577 | /** 2578 | * Add a single mapping from original source line and column to the generated 2579 | * source's line and column for this source map being created. The mapping 2580 | * object should have the following properties: 2581 | * 2582 | * - generated: An object with the generated line and column positions. 2583 | * - original: An object with the original line and column positions. 2584 | * - source: The original source file (relative to the sourceRoot). 2585 | * - name: An optional original token name for this mapping. 2586 | */ 2587 | SourceMapGenerator.prototype.addMapping = 2588 | function SourceMapGenerator_addMapping(aArgs) { 2589 | var generated = util.getArg(aArgs, 'generated'); 2590 | var original = util.getArg(aArgs, 'original', null); 2591 | var source = util.getArg(aArgs, 'source', null); 2592 | var name = util.getArg(aArgs, 'name', null); 2593 | 2594 | if (!this._skipValidation) { 2595 | this._validateMapping(generated, original, source, name); 2596 | } 2597 | 2598 | if (source != null) { 2599 | source = String(source); 2600 | if (!this._sources.has(source)) { 2601 | this._sources.add(source); 2602 | } 2603 | } 2604 | 2605 | if (name != null) { 2606 | name = String(name); 2607 | if (!this._names.has(name)) { 2608 | this._names.add(name); 2609 | } 2610 | } 2611 | 2612 | this._mappings.add({ 2613 | generatedLine: generated.line, 2614 | generatedColumn: generated.column, 2615 | originalLine: original != null && original.line, 2616 | originalColumn: original != null && original.column, 2617 | source: source, 2618 | name: name 2619 | }); 2620 | }; 2621 | 2622 | /** 2623 | * Set the source content for a source file. 2624 | */ 2625 | SourceMapGenerator.prototype.setSourceContent = 2626 | function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { 2627 | var source = aSourceFile; 2628 | if (this._sourceRoot != null) { 2629 | source = util.relative(this._sourceRoot, source); 2630 | } 2631 | 2632 | if (aSourceContent != null) { 2633 | // Add the source content to the _sourcesContents map. 2634 | // Create a new _sourcesContents map if the property is null. 2635 | if (!this._sourcesContents) { 2636 | this._sourcesContents = Object.create(null); 2637 | } 2638 | this._sourcesContents[util.toSetString(source)] = aSourceContent; 2639 | } else if (this._sourcesContents) { 2640 | // Remove the source file from the _sourcesContents map. 2641 | // If the _sourcesContents map is empty, set the property to null. 2642 | delete this._sourcesContents[util.toSetString(source)]; 2643 | if (Object.keys(this._sourcesContents).length === 0) { 2644 | this._sourcesContents = null; 2645 | } 2646 | } 2647 | }; 2648 | 2649 | /** 2650 | * Applies the mappings of a sub-source-map for a specific source file to the 2651 | * source map being generated. Each mapping to the supplied source file is 2652 | * rewritten using the supplied source map. Note: The resolution for the 2653 | * resulting mappings is the minimium of this map and the supplied map. 2654 | * 2655 | * @param aSourceMapConsumer The source map to be applied. 2656 | * @param aSourceFile Optional. The filename of the source file. 2657 | * If omitted, SourceMapConsumer's file property will be used. 2658 | * @param aSourceMapPath Optional. The dirname of the path to the source map 2659 | * to be applied. If relative, it is relative to the SourceMapConsumer. 2660 | * This parameter is needed when the two source maps aren't in the same 2661 | * directory, and the source map to be applied contains relative source 2662 | * paths. If so, those relative source paths need to be rewritten 2663 | * relative to the SourceMapGenerator. 2664 | */ 2665 | SourceMapGenerator.prototype.applySourceMap = 2666 | function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { 2667 | var sourceFile = aSourceFile; 2668 | // If aSourceFile is omitted, we will use the file property of the SourceMap 2669 | if (aSourceFile == null) { 2670 | if (aSourceMapConsumer.file == null) { 2671 | throw new Error( 2672 | 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + 2673 | 'or the source map\'s "file" property. Both were omitted.' 2674 | ); 2675 | } 2676 | sourceFile = aSourceMapConsumer.file; 2677 | } 2678 | var sourceRoot = this._sourceRoot; 2679 | // Make "sourceFile" relative if an absolute Url is passed. 2680 | if (sourceRoot != null) { 2681 | sourceFile = util.relative(sourceRoot, sourceFile); 2682 | } 2683 | // Applying the SourceMap can add and remove items from the sources and 2684 | // the names array. 2685 | var newSources = new ArraySet(); 2686 | var newNames = new ArraySet(); 2687 | 2688 | // Find mappings for the "sourceFile" 2689 | this._mappings.unsortedForEach(function (mapping) { 2690 | if (mapping.source === sourceFile && mapping.originalLine != null) { 2691 | // Check if it can be mapped by the source map, then update the mapping. 2692 | var original = aSourceMapConsumer.originalPositionFor({ 2693 | line: mapping.originalLine, 2694 | column: mapping.originalColumn 2695 | }); 2696 | if (original.source != null) { 2697 | // Copy mapping 2698 | mapping.source = original.source; 2699 | if (aSourceMapPath != null) { 2700 | mapping.source = util.join(aSourceMapPath, mapping.source) 2701 | } 2702 | if (sourceRoot != null) { 2703 | mapping.source = util.relative(sourceRoot, mapping.source); 2704 | } 2705 | mapping.originalLine = original.line; 2706 | mapping.originalColumn = original.column; 2707 | if (original.name != null) { 2708 | mapping.name = original.name; 2709 | } 2710 | } 2711 | } 2712 | 2713 | var source = mapping.source; 2714 | if (source != null && !newSources.has(source)) { 2715 | newSources.add(source); 2716 | } 2717 | 2718 | var name = mapping.name; 2719 | if (name != null && !newNames.has(name)) { 2720 | newNames.add(name); 2721 | } 2722 | 2723 | }, this); 2724 | this._sources = newSources; 2725 | this._names = newNames; 2726 | 2727 | // Copy sourcesContents of applied map. 2728 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 2729 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 2730 | if (content != null) { 2731 | if (aSourceMapPath != null) { 2732 | sourceFile = util.join(aSourceMapPath, sourceFile); 2733 | } 2734 | if (sourceRoot != null) { 2735 | sourceFile = util.relative(sourceRoot, sourceFile); 2736 | } 2737 | this.setSourceContent(sourceFile, content); 2738 | } 2739 | }, this); 2740 | }; 2741 | 2742 | /** 2743 | * A mapping can have one of the three levels of data: 2744 | * 2745 | * 1. Just the generated position. 2746 | * 2. The Generated position, original position, and original source. 2747 | * 3. Generated and original position, original source, as well as a name 2748 | * token. 2749 | * 2750 | * To maintain consistency, we validate that any new mapping being added falls 2751 | * in to one of these categories. 2752 | */ 2753 | SourceMapGenerator.prototype._validateMapping = 2754 | function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, 2755 | aName) { 2756 | // When aOriginal is truthy but has empty values for .line and .column, 2757 | // it is most likely a programmer error. In this case we throw a very 2758 | // specific error message to try to guide them the right way. 2759 | // For example: https://github.com/Polymer/polymer-bundler/pull/519 2760 | if (aOriginal && typeof aOriginal.line !== 'number' && typeof aOriginal.column !== 'number') { 2761 | throw new Error( 2762 | 'original.line and original.column are not numbers -- you probably meant to omit ' + 2763 | 'the original mapping entirely and only map the generated position. If so, pass ' + 2764 | 'null for the original mapping instead of an object with empty or null values.' 2765 | ); 2766 | } 2767 | 2768 | if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 2769 | && aGenerated.line > 0 && aGenerated.column >= 0 2770 | && !aOriginal && !aSource && !aName) { 2771 | // Case 1. 2772 | return; 2773 | } 2774 | else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 2775 | && aOriginal && 'line' in aOriginal && 'column' in aOriginal 2776 | && aGenerated.line > 0 && aGenerated.column >= 0 2777 | && aOriginal.line > 0 && aOriginal.column >= 0 2778 | && aSource) { 2779 | // Cases 2 and 3. 2780 | return; 2781 | } 2782 | else { 2783 | throw new Error('Invalid mapping: ' + JSON.stringify({ 2784 | generated: aGenerated, 2785 | source: aSource, 2786 | original: aOriginal, 2787 | name: aName 2788 | })); 2789 | } 2790 | }; 2791 | 2792 | /** 2793 | * Serialize the accumulated mappings in to the stream of base 64 VLQs 2794 | * specified by the source map format. 2795 | */ 2796 | SourceMapGenerator.prototype._serializeMappings = 2797 | function SourceMapGenerator_serializeMappings() { 2798 | var previousGeneratedColumn = 0; 2799 | var previousGeneratedLine = 1; 2800 | var previousOriginalColumn = 0; 2801 | var previousOriginalLine = 0; 2802 | var previousName = 0; 2803 | var previousSource = 0; 2804 | var result = ''; 2805 | var next; 2806 | var mapping; 2807 | var nameIdx; 2808 | var sourceIdx; 2809 | 2810 | var mappings = this._mappings.toArray(); 2811 | for (var i = 0, len = mappings.length; i < len; i++) { 2812 | mapping = mappings[i]; 2813 | next = '' 2814 | 2815 | if (mapping.generatedLine !== previousGeneratedLine) { 2816 | previousGeneratedColumn = 0; 2817 | while (mapping.generatedLine !== previousGeneratedLine) { 2818 | next += ';'; 2819 | previousGeneratedLine++; 2820 | } 2821 | } 2822 | else { 2823 | if (i > 0) { 2824 | if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) { 2825 | continue; 2826 | } 2827 | next += ','; 2828 | } 2829 | } 2830 | 2831 | next += base64VLQ.encode(mapping.generatedColumn 2832 | - previousGeneratedColumn); 2833 | previousGeneratedColumn = mapping.generatedColumn; 2834 | 2835 | if (mapping.source != null) { 2836 | sourceIdx = this._sources.indexOf(mapping.source); 2837 | next += base64VLQ.encode(sourceIdx - previousSource); 2838 | previousSource = sourceIdx; 2839 | 2840 | // lines are stored 0-based in SourceMap spec version 3 2841 | next += base64VLQ.encode(mapping.originalLine - 1 2842 | - previousOriginalLine); 2843 | previousOriginalLine = mapping.originalLine - 1; 2844 | 2845 | next += base64VLQ.encode(mapping.originalColumn 2846 | - previousOriginalColumn); 2847 | previousOriginalColumn = mapping.originalColumn; 2848 | 2849 | if (mapping.name != null) { 2850 | nameIdx = this._names.indexOf(mapping.name); 2851 | next += base64VLQ.encode(nameIdx - previousName); 2852 | previousName = nameIdx; 2853 | } 2854 | } 2855 | 2856 | result += next; 2857 | } 2858 | 2859 | return result; 2860 | }; 2861 | 2862 | SourceMapGenerator.prototype._generateSourcesContent = 2863 | function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { 2864 | return aSources.map(function (source) { 2865 | if (!this._sourcesContents) { 2866 | return null; 2867 | } 2868 | if (aSourceRoot != null) { 2869 | source = util.relative(aSourceRoot, source); 2870 | } 2871 | var key = util.toSetString(source); 2872 | return Object.prototype.hasOwnProperty.call(this._sourcesContents, key) 2873 | ? this._sourcesContents[key] 2874 | : null; 2875 | }, this); 2876 | }; 2877 | 2878 | /** 2879 | * Externalize the source map. 2880 | */ 2881 | SourceMapGenerator.prototype.toJSON = 2882 | function SourceMapGenerator_toJSON() { 2883 | var map = { 2884 | version: this._version, 2885 | sources: this._sources.toArray(), 2886 | names: this._names.toArray(), 2887 | mappings: this._serializeMappings() 2888 | }; 2889 | if (this._file != null) { 2890 | map.file = this._file; 2891 | } 2892 | if (this._sourceRoot != null) { 2893 | map.sourceRoot = this._sourceRoot; 2894 | } 2895 | if (this._sourcesContents) { 2896 | map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); 2897 | } 2898 | 2899 | return map; 2900 | }; 2901 | 2902 | /** 2903 | * Render the source map being generated to a string. 2904 | */ 2905 | SourceMapGenerator.prototype.toString = 2906 | function SourceMapGenerator_toString() { 2907 | return JSON.stringify(this.toJSON()); 2908 | }; 2909 | 2910 | exports.h = SourceMapGenerator; 2911 | 2912 | 2913 | /***/ }), 2914 | 2915 | /***/ 990: 2916 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 2917 | 2918 | var __webpack_unused_export__; 2919 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2920 | /* 2921 | * Copyright 2011 Mozilla Foundation and contributors 2922 | * Licensed under the New BSD license. See LICENSE or: 2923 | * http://opensource.org/licenses/BSD-3-Clause 2924 | */ 2925 | 2926 | var SourceMapGenerator = __webpack_require__(341)/* .SourceMapGenerator */ .h; 2927 | var util = __webpack_require__(983); 2928 | 2929 | // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other 2930 | // operating systems these days (capturing the result). 2931 | var REGEX_NEWLINE = /(\r?\n)/; 2932 | 2933 | // Newline character code for charCodeAt() comparisons 2934 | var NEWLINE_CODE = 10; 2935 | 2936 | // Private symbol for identifying `SourceNode`s when multiple versions of 2937 | // the source-map library are loaded. This MUST NOT CHANGE across 2938 | // versions! 2939 | var isSourceNode = "$$$isSourceNode$$$"; 2940 | 2941 | /** 2942 | * SourceNodes provide a way to abstract over interpolating/concatenating 2943 | * snippets of generated JavaScript source code while maintaining the line and 2944 | * column information associated with the original source code. 2945 | * 2946 | * @param aLine The original line number. 2947 | * @param aColumn The original column number. 2948 | * @param aSource The original source's filename. 2949 | * @param aChunks Optional. An array of strings which are snippets of 2950 | * generated JS, or other SourceNodes. 2951 | * @param aName The original identifier. 2952 | */ 2953 | function SourceNode(aLine, aColumn, aSource, aChunks, aName) { 2954 | this.children = []; 2955 | this.sourceContents = {}; 2956 | this.line = aLine == null ? null : aLine; 2957 | this.column = aColumn == null ? null : aColumn; 2958 | this.source = aSource == null ? null : aSource; 2959 | this.name = aName == null ? null : aName; 2960 | this[isSourceNode] = true; 2961 | if (aChunks != null) this.add(aChunks); 2962 | } 2963 | 2964 | /** 2965 | * Creates a SourceNode from generated code and a SourceMapConsumer. 2966 | * 2967 | * @param aGeneratedCode The generated code 2968 | * @param aSourceMapConsumer The SourceMap for the generated code 2969 | * @param aRelativePath Optional. The path that relative sources in the 2970 | * SourceMapConsumer should be relative to. 2971 | */ 2972 | SourceNode.fromStringWithSourceMap = 2973 | function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { 2974 | // The SourceNode we want to fill with the generated code 2975 | // and the SourceMap 2976 | var node = new SourceNode(); 2977 | 2978 | // All even indices of this array are one line of the generated code, 2979 | // while all odd indices are the newlines between two adjacent lines 2980 | // (since `REGEX_NEWLINE` captures its match). 2981 | // Processed fragments are accessed by calling `shiftNextLine`. 2982 | var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); 2983 | var remainingLinesIndex = 0; 2984 | var shiftNextLine = function() { 2985 | var lineContents = getNextLine(); 2986 | // The last line of a file might not have a newline. 2987 | var newLine = getNextLine() || ""; 2988 | return lineContents + newLine; 2989 | 2990 | function getNextLine() { 2991 | return remainingLinesIndex < remainingLines.length ? 2992 | remainingLines[remainingLinesIndex++] : undefined; 2993 | } 2994 | }; 2995 | 2996 | // We need to remember the position of "remainingLines" 2997 | var lastGeneratedLine = 1, lastGeneratedColumn = 0; 2998 | 2999 | // The generate SourceNodes we need a code range. 3000 | // To extract it current and last mapping is used. 3001 | // Here we store the last mapping. 3002 | var lastMapping = null; 3003 | 3004 | aSourceMapConsumer.eachMapping(function (mapping) { 3005 | if (lastMapping !== null) { 3006 | // We add the code from "lastMapping" to "mapping": 3007 | // First check if there is a new line in between. 3008 | if (lastGeneratedLine < mapping.generatedLine) { 3009 | // Associate first line with "lastMapping" 3010 | addMappingWithCode(lastMapping, shiftNextLine()); 3011 | lastGeneratedLine++; 3012 | lastGeneratedColumn = 0; 3013 | // The remaining code is added without mapping 3014 | } else { 3015 | // There is no new line in between. 3016 | // Associate the code between "lastGeneratedColumn" and 3017 | // "mapping.generatedColumn" with "lastMapping" 3018 | var nextLine = remainingLines[remainingLinesIndex] || ''; 3019 | var code = nextLine.substr(0, mapping.generatedColumn - 3020 | lastGeneratedColumn); 3021 | remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn - 3022 | lastGeneratedColumn); 3023 | lastGeneratedColumn = mapping.generatedColumn; 3024 | addMappingWithCode(lastMapping, code); 3025 | // No more remaining code, continue 3026 | lastMapping = mapping; 3027 | return; 3028 | } 3029 | } 3030 | // We add the generated code until the first mapping 3031 | // to the SourceNode without any mapping. 3032 | // Each line is added as separate string. 3033 | while (lastGeneratedLine < mapping.generatedLine) { 3034 | node.add(shiftNextLine()); 3035 | lastGeneratedLine++; 3036 | } 3037 | if (lastGeneratedColumn < mapping.generatedColumn) { 3038 | var nextLine = remainingLines[remainingLinesIndex] || ''; 3039 | node.add(nextLine.substr(0, mapping.generatedColumn)); 3040 | remainingLines[remainingLinesIndex] = nextLine.substr(mapping.generatedColumn); 3041 | lastGeneratedColumn = mapping.generatedColumn; 3042 | } 3043 | lastMapping = mapping; 3044 | }, this); 3045 | // We have processed all mappings. 3046 | if (remainingLinesIndex < remainingLines.length) { 3047 | if (lastMapping) { 3048 | // Associate the remaining code in the current line with "lastMapping" 3049 | addMappingWithCode(lastMapping, shiftNextLine()); 3050 | } 3051 | // and add the remaining lines without any mapping 3052 | node.add(remainingLines.splice(remainingLinesIndex).join("")); 3053 | } 3054 | 3055 | // Copy sourcesContent into SourceNode 3056 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 3057 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 3058 | if (content != null) { 3059 | if (aRelativePath != null) { 3060 | sourceFile = util.join(aRelativePath, sourceFile); 3061 | } 3062 | node.setSourceContent(sourceFile, content); 3063 | } 3064 | }); 3065 | 3066 | return node; 3067 | 3068 | function addMappingWithCode(mapping, code) { 3069 | if (mapping === null || mapping.source === undefined) { 3070 | node.add(code); 3071 | } else { 3072 | var source = aRelativePath 3073 | ? util.join(aRelativePath, mapping.source) 3074 | : mapping.source; 3075 | node.add(new SourceNode(mapping.originalLine, 3076 | mapping.originalColumn, 3077 | source, 3078 | code, 3079 | mapping.name)); 3080 | } 3081 | } 3082 | }; 3083 | 3084 | /** 3085 | * Add a chunk of generated JS to this source node. 3086 | * 3087 | * @param aChunk A string snippet of generated JS code, another instance of 3088 | * SourceNode, or an array where each member is one of those things. 3089 | */ 3090 | SourceNode.prototype.add = function SourceNode_add(aChunk) { 3091 | if (Array.isArray(aChunk)) { 3092 | aChunk.forEach(function (chunk) { 3093 | this.add(chunk); 3094 | }, this); 3095 | } 3096 | else if (aChunk[isSourceNode] || typeof aChunk === "string") { 3097 | if (aChunk) { 3098 | this.children.push(aChunk); 3099 | } 3100 | } 3101 | else { 3102 | throw new TypeError( 3103 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 3104 | ); 3105 | } 3106 | return this; 3107 | }; 3108 | 3109 | /** 3110 | * Add a chunk of generated JS to the beginning of this source node. 3111 | * 3112 | * @param aChunk A string snippet of generated JS code, another instance of 3113 | * SourceNode, or an array where each member is one of those things. 3114 | */ 3115 | SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { 3116 | if (Array.isArray(aChunk)) { 3117 | for (var i = aChunk.length-1; i >= 0; i--) { 3118 | this.prepend(aChunk[i]); 3119 | } 3120 | } 3121 | else if (aChunk[isSourceNode] || typeof aChunk === "string") { 3122 | this.children.unshift(aChunk); 3123 | } 3124 | else { 3125 | throw new TypeError( 3126 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 3127 | ); 3128 | } 3129 | return this; 3130 | }; 3131 | 3132 | /** 3133 | * Walk over the tree of JS snippets in this node and its children. The 3134 | * walking function is called once for each snippet of JS and is passed that 3135 | * snippet and the its original associated source's line/column location. 3136 | * 3137 | * @param aFn The traversal function. 3138 | */ 3139 | SourceNode.prototype.walk = function SourceNode_walk(aFn) { 3140 | var chunk; 3141 | for (var i = 0, len = this.children.length; i < len; i++) { 3142 | chunk = this.children[i]; 3143 | if (chunk[isSourceNode]) { 3144 | chunk.walk(aFn); 3145 | } 3146 | else { 3147 | if (chunk !== '') { 3148 | aFn(chunk, { source: this.source, 3149 | line: this.line, 3150 | column: this.column, 3151 | name: this.name }); 3152 | } 3153 | } 3154 | } 3155 | }; 3156 | 3157 | /** 3158 | * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between 3159 | * each of `this.children`. 3160 | * 3161 | * @param aSep The separator. 3162 | */ 3163 | SourceNode.prototype.join = function SourceNode_join(aSep) { 3164 | var newChildren; 3165 | var i; 3166 | var len = this.children.length; 3167 | if (len > 0) { 3168 | newChildren = []; 3169 | for (i = 0; i < len-1; i++) { 3170 | newChildren.push(this.children[i]); 3171 | newChildren.push(aSep); 3172 | } 3173 | newChildren.push(this.children[i]); 3174 | this.children = newChildren; 3175 | } 3176 | return this; 3177 | }; 3178 | 3179 | /** 3180 | * Call String.prototype.replace on the very right-most source snippet. Useful 3181 | * for trimming whitespace from the end of a source node, etc. 3182 | * 3183 | * @param aPattern The pattern to replace. 3184 | * @param aReplacement The thing to replace the pattern with. 3185 | */ 3186 | SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { 3187 | var lastChild = this.children[this.children.length - 1]; 3188 | if (lastChild[isSourceNode]) { 3189 | lastChild.replaceRight(aPattern, aReplacement); 3190 | } 3191 | else if (typeof lastChild === 'string') { 3192 | this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); 3193 | } 3194 | else { 3195 | this.children.push(''.replace(aPattern, aReplacement)); 3196 | } 3197 | return this; 3198 | }; 3199 | 3200 | /** 3201 | * Set the source content for a source file. This will be added to the SourceMapGenerator 3202 | * in the sourcesContent field. 3203 | * 3204 | * @param aSourceFile The filename of the source file 3205 | * @param aSourceContent The content of the source file 3206 | */ 3207 | SourceNode.prototype.setSourceContent = 3208 | function SourceNode_setSourceContent(aSourceFile, aSourceContent) { 3209 | this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; 3210 | }; 3211 | 3212 | /** 3213 | * Walk over the tree of SourceNodes. The walking function is called for each 3214 | * source file content and is passed the filename and source content. 3215 | * 3216 | * @param aFn The traversal function. 3217 | */ 3218 | SourceNode.prototype.walkSourceContents = 3219 | function SourceNode_walkSourceContents(aFn) { 3220 | for (var i = 0, len = this.children.length; i < len; i++) { 3221 | if (this.children[i][isSourceNode]) { 3222 | this.children[i].walkSourceContents(aFn); 3223 | } 3224 | } 3225 | 3226 | var sources = Object.keys(this.sourceContents); 3227 | for (var i = 0, len = sources.length; i < len; i++) { 3228 | aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); 3229 | } 3230 | }; 3231 | 3232 | /** 3233 | * Return the string representation of this source node. Walks over the tree 3234 | * and concatenates all the various snippets together to one string. 3235 | */ 3236 | SourceNode.prototype.toString = function SourceNode_toString() { 3237 | var str = ""; 3238 | this.walk(function (chunk) { 3239 | str += chunk; 3240 | }); 3241 | return str; 3242 | }; 3243 | 3244 | /** 3245 | * Returns the string representation of this source node along with a source 3246 | * map. 3247 | */ 3248 | SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { 3249 | var generated = { 3250 | code: "", 3251 | line: 1, 3252 | column: 0 3253 | }; 3254 | var map = new SourceMapGenerator(aArgs); 3255 | var sourceMappingActive = false; 3256 | var lastOriginalSource = null; 3257 | var lastOriginalLine = null; 3258 | var lastOriginalColumn = null; 3259 | var lastOriginalName = null; 3260 | this.walk(function (chunk, original) { 3261 | generated.code += chunk; 3262 | if (original.source !== null 3263 | && original.line !== null 3264 | && original.column !== null) { 3265 | if(lastOriginalSource !== original.source 3266 | || lastOriginalLine !== original.line 3267 | || lastOriginalColumn !== original.column 3268 | || lastOriginalName !== original.name) { 3269 | map.addMapping({ 3270 | source: original.source, 3271 | original: { 3272 | line: original.line, 3273 | column: original.column 3274 | }, 3275 | generated: { 3276 | line: generated.line, 3277 | column: generated.column 3278 | }, 3279 | name: original.name 3280 | }); 3281 | } 3282 | lastOriginalSource = original.source; 3283 | lastOriginalLine = original.line; 3284 | lastOriginalColumn = original.column; 3285 | lastOriginalName = original.name; 3286 | sourceMappingActive = true; 3287 | } else if (sourceMappingActive) { 3288 | map.addMapping({ 3289 | generated: { 3290 | line: generated.line, 3291 | column: generated.column 3292 | } 3293 | }); 3294 | lastOriginalSource = null; 3295 | sourceMappingActive = false; 3296 | } 3297 | for (var idx = 0, length = chunk.length; idx < length; idx++) { 3298 | if (chunk.charCodeAt(idx) === NEWLINE_CODE) { 3299 | generated.line++; 3300 | generated.column = 0; 3301 | // Mappings end at eol 3302 | if (idx + 1 === length) { 3303 | lastOriginalSource = null; 3304 | sourceMappingActive = false; 3305 | } else if (sourceMappingActive) { 3306 | map.addMapping({ 3307 | source: original.source, 3308 | original: { 3309 | line: original.line, 3310 | column: original.column 3311 | }, 3312 | generated: { 3313 | line: generated.line, 3314 | column: generated.column 3315 | }, 3316 | name: original.name 3317 | }); 3318 | } 3319 | } else { 3320 | generated.column++; 3321 | } 3322 | } 3323 | }); 3324 | this.walkSourceContents(function (sourceFile, sourceContent) { 3325 | map.setSourceContent(sourceFile, sourceContent); 3326 | }); 3327 | 3328 | return { code: generated.code, map: map }; 3329 | }; 3330 | 3331 | __webpack_unused_export__ = SourceNode; 3332 | 3333 | 3334 | /***/ }), 3335 | 3336 | /***/ 983: 3337 | /***/ ((__unused_webpack_module, exports) => { 3338 | 3339 | /* -*- Mode: js; js-indent-level: 2; -*- */ 3340 | /* 3341 | * Copyright 2011 Mozilla Foundation and contributors 3342 | * Licensed under the New BSD license. See LICENSE or: 3343 | * http://opensource.org/licenses/BSD-3-Clause 3344 | */ 3345 | 3346 | /** 3347 | * This is a helper function for getting values from parameter/options 3348 | * objects. 3349 | * 3350 | * @param args The object we are extracting values from 3351 | * @param name The name of the property we are getting. 3352 | * @param defaultValue An optional value to return if the property is missing 3353 | * from the object. If this is not specified and the property is missing, an 3354 | * error will be thrown. 3355 | */ 3356 | function getArg(aArgs, aName, aDefaultValue) { 3357 | if (aName in aArgs) { 3358 | return aArgs[aName]; 3359 | } else if (arguments.length === 3) { 3360 | return aDefaultValue; 3361 | } else { 3362 | throw new Error('"' + aName + '" is a required argument.'); 3363 | } 3364 | } 3365 | exports.getArg = getArg; 3366 | 3367 | var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.-]*)(?::(\d+))?(.*)$/; 3368 | var dataUrlRegexp = /^data:.+\,.+$/; 3369 | 3370 | function urlParse(aUrl) { 3371 | var match = aUrl.match(urlRegexp); 3372 | if (!match) { 3373 | return null; 3374 | } 3375 | return { 3376 | scheme: match[1], 3377 | auth: match[2], 3378 | host: match[3], 3379 | port: match[4], 3380 | path: match[5] 3381 | }; 3382 | } 3383 | exports.urlParse = urlParse; 3384 | 3385 | function urlGenerate(aParsedUrl) { 3386 | var url = ''; 3387 | if (aParsedUrl.scheme) { 3388 | url += aParsedUrl.scheme + ':'; 3389 | } 3390 | url += '//'; 3391 | if (aParsedUrl.auth) { 3392 | url += aParsedUrl.auth + '@'; 3393 | } 3394 | if (aParsedUrl.host) { 3395 | url += aParsedUrl.host; 3396 | } 3397 | if (aParsedUrl.port) { 3398 | url += ":" + aParsedUrl.port 3399 | } 3400 | if (aParsedUrl.path) { 3401 | url += aParsedUrl.path; 3402 | } 3403 | return url; 3404 | } 3405 | exports.urlGenerate = urlGenerate; 3406 | 3407 | /** 3408 | * Normalizes a path, or the path portion of a URL: 3409 | * 3410 | * - Replaces consecutive slashes with one slash. 3411 | * - Removes unnecessary '.' parts. 3412 | * - Removes unnecessary '/..' parts. 3413 | * 3414 | * Based on code in the Node.js 'path' core module. 3415 | * 3416 | * @param aPath The path or url to normalize. 3417 | */ 3418 | function normalize(aPath) { 3419 | var path = aPath; 3420 | var url = urlParse(aPath); 3421 | if (url) { 3422 | if (!url.path) { 3423 | return aPath; 3424 | } 3425 | path = url.path; 3426 | } 3427 | var isAbsolute = exports.isAbsolute(path); 3428 | 3429 | var parts = path.split(/\/+/); 3430 | for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { 3431 | part = parts[i]; 3432 | if (part === '.') { 3433 | parts.splice(i, 1); 3434 | } else if (part === '..') { 3435 | up++; 3436 | } else if (up > 0) { 3437 | if (part === '') { 3438 | // The first part is blank if the path is absolute. Trying to go 3439 | // above the root is a no-op. Therefore we can remove all '..' parts 3440 | // directly after the root. 3441 | parts.splice(i + 1, up); 3442 | up = 0; 3443 | } else { 3444 | parts.splice(i, 2); 3445 | up--; 3446 | } 3447 | } 3448 | } 3449 | path = parts.join('/'); 3450 | 3451 | if (path === '') { 3452 | path = isAbsolute ? '/' : '.'; 3453 | } 3454 | 3455 | if (url) { 3456 | url.path = path; 3457 | return urlGenerate(url); 3458 | } 3459 | return path; 3460 | } 3461 | exports.normalize = normalize; 3462 | 3463 | /** 3464 | * Joins two paths/URLs. 3465 | * 3466 | * @param aRoot The root path or URL. 3467 | * @param aPath The path or URL to be joined with the root. 3468 | * 3469 | * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a 3470 | * scheme-relative URL: Then the scheme of aRoot, if any, is prepended 3471 | * first. 3472 | * - Otherwise aPath is a path. If aRoot is a URL, then its path portion 3473 | * is updated with the result and aRoot is returned. Otherwise the result 3474 | * is returned. 3475 | * - If aPath is absolute, the result is aPath. 3476 | * - Otherwise the two paths are joined with a slash. 3477 | * - Joining for example 'http://' and 'www.example.com' is also supported. 3478 | */ 3479 | function join(aRoot, aPath) { 3480 | if (aRoot === "") { 3481 | aRoot = "."; 3482 | } 3483 | if (aPath === "") { 3484 | aPath = "."; 3485 | } 3486 | var aPathUrl = urlParse(aPath); 3487 | var aRootUrl = urlParse(aRoot); 3488 | if (aRootUrl) { 3489 | aRoot = aRootUrl.path || '/'; 3490 | } 3491 | 3492 | // `join(foo, '//www.example.org')` 3493 | if (aPathUrl && !aPathUrl.scheme) { 3494 | if (aRootUrl) { 3495 | aPathUrl.scheme = aRootUrl.scheme; 3496 | } 3497 | return urlGenerate(aPathUrl); 3498 | } 3499 | 3500 | if (aPathUrl || aPath.match(dataUrlRegexp)) { 3501 | return aPath; 3502 | } 3503 | 3504 | // `join('http://', 'www.example.com')` 3505 | if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { 3506 | aRootUrl.host = aPath; 3507 | return urlGenerate(aRootUrl); 3508 | } 3509 | 3510 | var joined = aPath.charAt(0) === '/' 3511 | ? aPath 3512 | : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); 3513 | 3514 | if (aRootUrl) { 3515 | aRootUrl.path = joined; 3516 | return urlGenerate(aRootUrl); 3517 | } 3518 | return joined; 3519 | } 3520 | exports.join = join; 3521 | 3522 | exports.isAbsolute = function (aPath) { 3523 | return aPath.charAt(0) === '/' || urlRegexp.test(aPath); 3524 | }; 3525 | 3526 | /** 3527 | * Make a path relative to a URL or another path. 3528 | * 3529 | * @param aRoot The root path or URL. 3530 | * @param aPath The path or URL to be made relative to aRoot. 3531 | */ 3532 | function relative(aRoot, aPath) { 3533 | if (aRoot === "") { 3534 | aRoot = "."; 3535 | } 3536 | 3537 | aRoot = aRoot.replace(/\/$/, ''); 3538 | 3539 | // It is possible for the path to be above the root. In this case, simply 3540 | // checking whether the root is a prefix of the path won't work. Instead, we 3541 | // need to remove components from the root one by one, until either we find 3542 | // a prefix that fits, or we run out of components to remove. 3543 | var level = 0; 3544 | while (aPath.indexOf(aRoot + '/') !== 0) { 3545 | var index = aRoot.lastIndexOf("/"); 3546 | if (index < 0) { 3547 | return aPath; 3548 | } 3549 | 3550 | // If the only part of the root that is left is the scheme (i.e. http://, 3551 | // file:///, etc.), one or more slashes (/), or simply nothing at all, we 3552 | // have exhausted all components, so the path is not relative to the root. 3553 | aRoot = aRoot.slice(0, index); 3554 | if (aRoot.match(/^([^\/]+:\/)?\/*$/)) { 3555 | return aPath; 3556 | } 3557 | 3558 | ++level; 3559 | } 3560 | 3561 | // Make sure we add a "../" for each component we removed from the root. 3562 | return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1); 3563 | } 3564 | exports.relative = relative; 3565 | 3566 | var supportsNullProto = (function () { 3567 | var obj = Object.create(null); 3568 | return !('__proto__' in obj); 3569 | }()); 3570 | 3571 | function identity (s) { 3572 | return s; 3573 | } 3574 | 3575 | /** 3576 | * Because behavior goes wacky when you set `__proto__` on objects, we 3577 | * have to prefix all the strings in our set with an arbitrary character. 3578 | * 3579 | * See https://github.com/mozilla/source-map/pull/31 and 3580 | * https://github.com/mozilla/source-map/issues/30 3581 | * 3582 | * @param String aStr 3583 | */ 3584 | function toSetString(aStr) { 3585 | if (isProtoString(aStr)) { 3586 | return '$' + aStr; 3587 | } 3588 | 3589 | return aStr; 3590 | } 3591 | exports.toSetString = supportsNullProto ? identity : toSetString; 3592 | 3593 | function fromSetString(aStr) { 3594 | if (isProtoString(aStr)) { 3595 | return aStr.slice(1); 3596 | } 3597 | 3598 | return aStr; 3599 | } 3600 | exports.fromSetString = supportsNullProto ? identity : fromSetString; 3601 | 3602 | function isProtoString(s) { 3603 | if (!s) { 3604 | return false; 3605 | } 3606 | 3607 | var length = s.length; 3608 | 3609 | if (length < 9 /* "__proto__".length */) { 3610 | return false; 3611 | } 3612 | 3613 | if (s.charCodeAt(length - 1) !== 95 /* '_' */ || 3614 | s.charCodeAt(length - 2) !== 95 /* '_' */ || 3615 | s.charCodeAt(length - 3) !== 111 /* 'o' */ || 3616 | s.charCodeAt(length - 4) !== 116 /* 't' */ || 3617 | s.charCodeAt(length - 5) !== 111 /* 'o' */ || 3618 | s.charCodeAt(length - 6) !== 114 /* 'r' */ || 3619 | s.charCodeAt(length - 7) !== 112 /* 'p' */ || 3620 | s.charCodeAt(length - 8) !== 95 /* '_' */ || 3621 | s.charCodeAt(length - 9) !== 95 /* '_' */) { 3622 | return false; 3623 | } 3624 | 3625 | for (var i = length - 10; i >= 0; i--) { 3626 | if (s.charCodeAt(i) !== 36 /* '$' */) { 3627 | return false; 3628 | } 3629 | } 3630 | 3631 | return true; 3632 | } 3633 | 3634 | /** 3635 | * Comparator between two mappings where the original positions are compared. 3636 | * 3637 | * Optionally pass in `true` as `onlyCompareGenerated` to consider two 3638 | * mappings with the same original source/line/column, but different generated 3639 | * line and column the same. Useful when searching for a mapping with a 3640 | * stubbed out mapping. 3641 | */ 3642 | function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { 3643 | var cmp = strcmp(mappingA.source, mappingB.source); 3644 | if (cmp !== 0) { 3645 | return cmp; 3646 | } 3647 | 3648 | cmp = mappingA.originalLine - mappingB.originalLine; 3649 | if (cmp !== 0) { 3650 | return cmp; 3651 | } 3652 | 3653 | cmp = mappingA.originalColumn - mappingB.originalColumn; 3654 | if (cmp !== 0 || onlyCompareOriginal) { 3655 | return cmp; 3656 | } 3657 | 3658 | cmp = mappingA.generatedColumn - mappingB.generatedColumn; 3659 | if (cmp !== 0) { 3660 | return cmp; 3661 | } 3662 | 3663 | cmp = mappingA.generatedLine - mappingB.generatedLine; 3664 | if (cmp !== 0) { 3665 | return cmp; 3666 | } 3667 | 3668 | return strcmp(mappingA.name, mappingB.name); 3669 | } 3670 | exports.compareByOriginalPositions = compareByOriginalPositions; 3671 | 3672 | /** 3673 | * Comparator between two mappings with deflated source and name indices where 3674 | * the generated positions are compared. 3675 | * 3676 | * Optionally pass in `true` as `onlyCompareGenerated` to consider two 3677 | * mappings with the same generated line and column, but different 3678 | * source/name/original line and column the same. Useful when searching for a 3679 | * mapping with a stubbed out mapping. 3680 | */ 3681 | function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) { 3682 | var cmp = mappingA.generatedLine - mappingB.generatedLine; 3683 | if (cmp !== 0) { 3684 | return cmp; 3685 | } 3686 | 3687 | cmp = mappingA.generatedColumn - mappingB.generatedColumn; 3688 | if (cmp !== 0 || onlyCompareGenerated) { 3689 | return cmp; 3690 | } 3691 | 3692 | cmp = strcmp(mappingA.source, mappingB.source); 3693 | if (cmp !== 0) { 3694 | return cmp; 3695 | } 3696 | 3697 | cmp = mappingA.originalLine - mappingB.originalLine; 3698 | if (cmp !== 0) { 3699 | return cmp; 3700 | } 3701 | 3702 | cmp = mappingA.originalColumn - mappingB.originalColumn; 3703 | if (cmp !== 0) { 3704 | return cmp; 3705 | } 3706 | 3707 | return strcmp(mappingA.name, mappingB.name); 3708 | } 3709 | exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated; 3710 | 3711 | function strcmp(aStr1, aStr2) { 3712 | if (aStr1 === aStr2) { 3713 | return 0; 3714 | } 3715 | 3716 | if (aStr1 === null) { 3717 | return 1; // aStr2 !== null 3718 | } 3719 | 3720 | if (aStr2 === null) { 3721 | return -1; // aStr1 !== null 3722 | } 3723 | 3724 | if (aStr1 > aStr2) { 3725 | return 1; 3726 | } 3727 | 3728 | return -1; 3729 | } 3730 | 3731 | /** 3732 | * Comparator between two mappings with inflated source and name strings where 3733 | * the generated positions are compared. 3734 | */ 3735 | function compareByGeneratedPositionsInflated(mappingA, mappingB) { 3736 | var cmp = mappingA.generatedLine - mappingB.generatedLine; 3737 | if (cmp !== 0) { 3738 | return cmp; 3739 | } 3740 | 3741 | cmp = mappingA.generatedColumn - mappingB.generatedColumn; 3742 | if (cmp !== 0) { 3743 | return cmp; 3744 | } 3745 | 3746 | cmp = strcmp(mappingA.source, mappingB.source); 3747 | if (cmp !== 0) { 3748 | return cmp; 3749 | } 3750 | 3751 | cmp = mappingA.originalLine - mappingB.originalLine; 3752 | if (cmp !== 0) { 3753 | return cmp; 3754 | } 3755 | 3756 | cmp = mappingA.originalColumn - mappingB.originalColumn; 3757 | if (cmp !== 0) { 3758 | return cmp; 3759 | } 3760 | 3761 | return strcmp(mappingA.name, mappingB.name); 3762 | } 3763 | exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated; 3764 | 3765 | /** 3766 | * Strip any JSON XSSI avoidance prefix from the string (as documented 3767 | * in the source maps specification), and then parse the string as 3768 | * JSON. 3769 | */ 3770 | function parseSourceMapInput(str) { 3771 | return JSON.parse(str.replace(/^\)]}'[^\n]*\n/, '')); 3772 | } 3773 | exports.parseSourceMapInput = parseSourceMapInput; 3774 | 3775 | /** 3776 | * Compute the URL of a source given the the source root, the source's 3777 | * URL, and the source map's URL. 3778 | */ 3779 | function computeSourceURL(sourceRoot, sourceURL, sourceMapURL) { 3780 | sourceURL = sourceURL || ''; 3781 | 3782 | if (sourceRoot) { 3783 | // This follows what Chrome does. 3784 | if (sourceRoot[sourceRoot.length - 1] !== '/' && sourceURL[0] !== '/') { 3785 | sourceRoot += '/'; 3786 | } 3787 | // The spec says: 3788 | // Line 4: An optional source root, useful for relocating source 3789 | // files on a server or removing repeated values in the 3790 | // “sources” entry. This value is prepended to the individual 3791 | // entries in the “source” field. 3792 | sourceURL = sourceRoot + sourceURL; 3793 | } 3794 | 3795 | // Historically, SourceMapConsumer did not take the sourceMapURL as 3796 | // a parameter. This mode is still somewhat supported, which is why 3797 | // this code block is conditional. However, it's preferable to pass 3798 | // the source map URL to SourceMapConsumer, so that this function 3799 | // can implement the source URL resolution algorithm as outlined in 3800 | // the spec. This block is basically the equivalent of: 3801 | // new URL(sourceURL, sourceMapURL).toString() 3802 | // ... except it avoids using URL, which wasn't available in the 3803 | // older releases of node still supported by this library. 3804 | // 3805 | // The spec says: 3806 | // If the sources are not absolute URLs after prepending of the 3807 | // “sourceRoot”, the sources are resolved relative to the 3808 | // SourceMap (like resolving script src in a html document). 3809 | if (sourceMapURL) { 3810 | var parsed = urlParse(sourceMapURL); 3811 | if (!parsed) { 3812 | throw new Error("sourceMapURL could not be parsed"); 3813 | } 3814 | if (parsed.path) { 3815 | // Strip the last path component, but keep the "/". 3816 | var index = parsed.path.lastIndexOf('/'); 3817 | if (index >= 0) { 3818 | parsed.path = parsed.path.substring(0, index + 1); 3819 | } 3820 | } 3821 | sourceURL = join(urlGenerate(parsed), sourceURL); 3822 | } 3823 | 3824 | return normalize(sourceURL); 3825 | } 3826 | exports.computeSourceURL = computeSourceURL; 3827 | 3828 | 3829 | /***/ }), 3830 | 3831 | /***/ 596: 3832 | /***/ ((__unused_webpack_module, exports, __webpack_require__) => { 3833 | 3834 | /* 3835 | * Copyright 2009-2011 Mozilla Foundation and contributors 3836 | * Licensed under the New BSD license. See LICENSE.txt or: 3837 | * http://opensource.org/licenses/BSD-3-Clause 3838 | */ 3839 | /* unused reexport */ __webpack_require__(341)/* .SourceMapGenerator */ .h; 3840 | exports.SourceMapConsumer = __webpack_require__(327).SourceMapConsumer; 3841 | /* unused reexport */ __webpack_require__(990); 3842 | 3843 | 3844 | /***/ }), 3845 | 3846 | /***/ 747: 3847 | /***/ ((module) => { 3848 | 3849 | "use strict"; 3850 | module.exports = require("fs");; 3851 | 3852 | /***/ }), 3853 | 3854 | /***/ 282: 3855 | /***/ ((module) => { 3856 | 3857 | "use strict"; 3858 | module.exports = require("module");; 3859 | 3860 | /***/ }), 3861 | 3862 | /***/ 622: 3863 | /***/ ((module) => { 3864 | 3865 | "use strict"; 3866 | module.exports = require("path");; 3867 | 3868 | /***/ }) 3869 | 3870 | /******/ }); 3871 | /************************************************************************/ 3872 | /******/ // The module cache 3873 | /******/ var __webpack_module_cache__ = {}; 3874 | /******/ 3875 | /******/ // The require function 3876 | /******/ function __webpack_require__(moduleId) { 3877 | /******/ // Check if module is in cache 3878 | /******/ if(__webpack_module_cache__[moduleId]) { 3879 | /******/ return __webpack_module_cache__[moduleId].exports; 3880 | /******/ } 3881 | /******/ // Create a new module (and put it into the cache) 3882 | /******/ var module = __webpack_module_cache__[moduleId] = { 3883 | /******/ // no module.id needed 3884 | /******/ // no module.loaded needed 3885 | /******/ exports: {} 3886 | /******/ }; 3887 | /******/ 3888 | /******/ // Execute the module function 3889 | /******/ var threw = true; 3890 | /******/ try { 3891 | /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); 3892 | /******/ threw = false; 3893 | /******/ } finally { 3894 | /******/ if(threw) delete __webpack_module_cache__[moduleId]; 3895 | /******/ } 3896 | /******/ 3897 | /******/ // Return the exports of the module 3898 | /******/ return module.exports; 3899 | /******/ } 3900 | /******/ 3901 | /************************************************************************/ 3902 | /******/ /* webpack/runtime/compat */ 3903 | /******/ 3904 | /******/ __webpack_require__.ab = __dirname + "/";/************************************************************************/ 3905 | /******/ // module exports must be returned from runtime so entry inlining is disabled 3906 | /******/ // startup 3907 | /******/ // Load entry module and return exports 3908 | /******/ return __webpack_require__(645); 3909 | /******/ })() 3910 | ; --------------------------------------------------------------------------------