├── .github
├── FUNDING.yml
├── renovate.json
└── workflows
│ ├── ci.yml
│ └── publish.yml
├── .gitignore
├── LICENSE
├── README.md
├── action.yml
├── dist
├── index.js
├── index.js.map
├── licenses.txt
└── sourcemap-register.js
├── package.json
├── src
└── main.ts
├── tsconfig.json
└── yarn.lock
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [pocket-apps]
4 |
--------------------------------------------------------------------------------
/.github/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": ["config:base"],
3 | "schedule": ["every month"]
4 | }
5 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 | on:
3 | push
4 |
5 | jobs:
6 | ci:
7 | runs-on: ubuntu-latest
8 | steps:
9 | - name: Checkout
10 | uses: actions/checkout@v2
11 | - name: Setup Node
12 | uses: actions/setup-node@v1
13 | with:
14 | node-version: 12
15 | - name: Install Dependencies
16 | run: yarn install
17 | - name: Run Linters
18 | run: yarn lint
19 | - name: Build Package
20 | run: yarn build
21 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 | on:
3 | release:
4 | types: [published]
5 |
6 | jobs:
7 | publish:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - name: Checkout
11 | uses: actions/checkout@v2
12 | - name: Setup Node
13 | uses: actions/setup-node@v1
14 | with:
15 | node-version: 12
16 | - name: Install Dependencies
17 | run: yarn install
18 | - name: Build Package
19 | run: yarn build
20 | - name: Run Action
21 | uses: ./
22 | with:
23 | version-regexp: '\d'
24 | repo-token: ${{ secrets.GITHUB_TOKEN }}
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Dependency directory
2 | node_modules
3 |
4 | # Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
5 | # Logs
6 | logs
7 | *.log
8 | npm-debug.log*
9 | yarn-debug.log*
10 | yarn-error.log*
11 | lerna-debug.log*
12 |
13 | # Diagnostic reports (https://nodejs.org/api/report.html)
14 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
15 |
16 | # Runtime data
17 | pids
18 | *.pid
19 | *.seed
20 | *.pid.lock
21 |
22 | # Directory for instrumented libs generated by jscoverage/JSCover
23 | lib-cov
24 |
25 | # Coverage directory used by tools like istanbul
26 | coverage
27 | *.lcov
28 |
29 | # nyc test coverage
30 | .nyc_output
31 |
32 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
33 | .grunt
34 |
35 | # Bower dependency directory (https://bower.io/)
36 | bower_components
37 |
38 | # node-waf configuration
39 | .lock-wscript
40 |
41 | # Compiled binary addons (https://nodejs.org/api/addons.html)
42 | build/Release
43 |
44 | # Dependency directories
45 | jspm_packages/
46 |
47 | # TypeScript v1 declaration files
48 | typings/
49 |
50 | # TypeScript cache
51 | *.tsbuildinfo
52 |
53 | # Optional npm cache directory
54 | .npm
55 |
56 | # Optional eslint cache
57 | .eslintcache
58 |
59 | # Optional REPL history
60 | .node_repl_history
61 |
62 | # Output of 'npm pack'
63 | *.tgz
64 |
65 | # Yarn Integrity file
66 | .yarn-integrity
67 |
68 | # dotenv environment variables file
69 | .env
70 | .env.test
71 |
72 | # parcel-bundler cache (https://parceljs.org/)
73 | .cache
74 |
75 | # next.js build output
76 | .next
77 |
78 | # nuxt.js build output
79 | .nuxt
80 |
81 | # vuepress build output
82 | .vuepress/dist
83 |
84 | # Serverless directories
85 | .serverless/
86 |
87 | # FuseBox cache
88 | .fusebox/
89 |
90 | # DynamoDB Local files
91 | .dynamodb/
92 |
93 | # OS metadata
94 | .DS_Store
95 | Thumbs.db
96 |
97 | # Ignore built ts files
98 | tests/runner/*
99 | lib/**/*
100 |
101 | # Editors
102 | .vscode
103 | .idea
104 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Pocket Apps, Inc. and contributors
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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
🏷 update-version
3 |
Update your files version field on new releases
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | ## 🧠 Why
12 |
13 | - Most actions related to version upgrade do it backwards:
14 | when you push a commit with version change in a specific branch a release is created.
15 |
16 | - This action does the opposite: when you create a release the
17 | specified files will get updated with the new version, so you don't forget to update them.
18 |
19 | This comes in handy when working with git workflows such as [trunk-base-development](https://trunkbaseddevelopment.com/) or [master-only](https://www.youtube.com/watch?v=MWz-9uyHP4s).
20 |
21 | ## 🚀 Usage
22 |
23 | With the following example after creating a new release with tag `v2.0.1` on branch `release`,
24 | a new commit will appear in that same branch with both `package.json` and `app.yaml` updated
25 | with the version field to `2.0.1`.
26 |
27 | ```yaml
28 | name: Upgrade Version
29 | on:
30 | release:
31 | types: [published]
32 |
33 | jobs:
34 | upgrade-version:
35 | runs-on: ubuntu-latest
36 | steps:
37 | - uses: actions/checkout@v2
38 | - uses: pocket-apps/action-update-version@v1
39 | with:
40 | files: 'package.json, app.yaml'
41 | version-regexp: '\d+.\d+.\d+'
42 | repo-token: ${{ secrets.GITHUB_TOKEN }}
43 | ```
44 |
45 | The action will fail if:
46 | - Both `repo-token` and `branch-name` are not supplied
47 | - The tag cannot be found by `octokit`
48 | - The regular expression cannot match the release tag
49 | - You specify a file with unsupported extension
50 |
51 | - Supported file extensions: `json`, `yaml` and `yml`. To add one simply submit a PR with a new parser on the `main.ts` file.
52 |
53 | ## ⚙ Inputs
54 |
55 | By supplying the `repo-token` the commit will use the release information: author and branch.
56 |
57 | You can change the branch commit target and the commit author if you want.
58 |
59 | **Name**|**Description**|**Default**
60 | -----|-----|-----
61 | files|Comma separated list of files to update its version field|package.json
62 | version-regexp|Regular expression to match release tag name|\d+.\d+.\d+
63 | repo-token|GitHub token to get the release information in order to push to branch|`null`
64 | commit-message|Commit message for files update. The %version% will get substituted|ci: update version to v%version%
65 | spacing-level|Number of spaces for formatted files|`2`
66 | branch-name|Default branch name to push changes if not repo-token is provided|*Release target branch*
67 | author-name|Commit author name|*Release author name*
68 | author-email|Commit author email|*Release author email*
69 |
70 | ## 👋 Support
71 |
72 | If you find our work useful, you can [support our work](https://github.com/sponsors/pocket-apps) and win a burrito 🌯
73 |
--------------------------------------------------------------------------------
/action.yml:
--------------------------------------------------------------------------------
1 | name: Update Files Version Field
2 | description: Update your files version field on new releases
3 | author: Pocket Apps
4 | branding:
5 | color: blue
6 | icon: arrow-up-circle
7 | runs:
8 | using: 'node12'
9 | main: 'dist/index.js'
10 | inputs:
11 | files:
12 | required: false
13 | description: Comma separated list of files to update its version field
14 | default: package.json
15 | version-regexp:
16 | required: false
17 | description: Regex to match release tag name
18 | default: '\d+.\d+.\d+'
19 | author-name:
20 | required: false
21 | description: Commit author name
22 | author-email:
23 | required: false
24 | description: Commit author email
25 | branch-name:
26 | required: false
27 | description: Default branch name to push changes if not repo-token is provided
28 | repo-token:
29 | required: false
30 | description: GitHub token to get the latest release in order to push to branch
31 | commit-message:
32 | required: false
33 | description: Commit message for files update
34 | default: 'ci: update version to v%version%'
35 | spacing-level:
36 | required: false
37 | description: Spacing level for formatted files
38 | default: '2'
39 |
--------------------------------------------------------------------------------
/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/exec
14 | MIT
15 |
16 | @actions/github
17 | MIT
18 |
19 | @actions/http-client
20 | MIT
21 | Actions Http Client for Node.js
22 |
23 | Copyright (c) GitHub, Inc.
24 |
25 | All rights reserved.
26 |
27 | MIT License
28 |
29 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
30 | associated documentation files (the "Software"), to deal in the Software without restriction,
31 | including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
32 | and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
33 | subject to the following conditions:
34 |
35 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
36 |
37 | THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
38 | LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
39 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
40 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
41 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 |
43 |
44 | @actions/io
45 | MIT
46 |
47 | @octokit/auth-token
48 | MIT
49 | The MIT License
50 |
51 | Copyright (c) 2019 Octokit contributors
52 |
53 | Permission is hereby granted, free of charge, to any person obtaining a copy
54 | of this software and associated documentation files (the "Software"), to deal
55 | in the Software without restriction, including without limitation the rights
56 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
57 | copies of the Software, and to permit persons to whom the Software is
58 | furnished to do so, subject to the following conditions:
59 |
60 | The above copyright notice and this permission notice shall be included in
61 | all copies or substantial portions of the Software.
62 |
63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
69 | THE SOFTWARE.
70 |
71 |
72 | @octokit/core
73 | MIT
74 | The MIT License
75 |
76 | Copyright (c) 2019 Octokit contributors
77 |
78 | Permission is hereby granted, free of charge, to any person obtaining a copy
79 | of this software and associated documentation files (the "Software"), to deal
80 | in the Software without restriction, including without limitation the rights
81 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
82 | copies of the Software, and to permit persons to whom the Software is
83 | furnished to do so, subject to the following conditions:
84 |
85 | The above copyright notice and this permission notice shall be included in
86 | all copies or substantial portions of the Software.
87 |
88 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
89 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
90 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
91 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
92 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
93 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
94 | THE SOFTWARE.
95 |
96 |
97 | @octokit/endpoint
98 | MIT
99 | The MIT License
100 |
101 | Copyright (c) 2018 Octokit contributors
102 |
103 | Permission is hereby granted, free of charge, to any person obtaining a copy
104 | of this software and associated documentation files (the "Software"), to deal
105 | in the Software without restriction, including without limitation the rights
106 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
107 | copies of the Software, and to permit persons to whom the Software is
108 | furnished to do so, subject to the following conditions:
109 |
110 | The above copyright notice and this permission notice shall be included in
111 | all copies or substantial portions of the Software.
112 |
113 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
114 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
115 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
116 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
117 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
118 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
119 | THE SOFTWARE.
120 |
121 |
122 | @octokit/graphql
123 | MIT
124 | The MIT License
125 |
126 | Copyright (c) 2018 Octokit contributors
127 |
128 | Permission is hereby granted, free of charge, to any person obtaining a copy
129 | of this software and associated documentation files (the "Software"), to deal
130 | in the Software without restriction, including without limitation the rights
131 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
132 | copies of the Software, and to permit persons to whom the Software is
133 | furnished to do so, subject to the following conditions:
134 |
135 | The above copyright notice and this permission notice shall be included in
136 | all copies or substantial portions of the Software.
137 |
138 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
139 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
140 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
141 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
142 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
143 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
144 | THE SOFTWARE.
145 |
146 |
147 | @octokit/plugin-paginate-rest
148 | MIT
149 | MIT License Copyright (c) 2019 Octokit contributors
150 |
151 | 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:
152 |
153 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
154 |
155 | 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.
156 |
157 |
158 | @octokit/plugin-rest-endpoint-methods
159 | MIT
160 | MIT License Copyright (c) 2019 Octokit contributors
161 |
162 | 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:
163 |
164 | The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software.
165 |
166 | 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.
167 |
168 |
169 | @octokit/request
170 | MIT
171 | The MIT License
172 |
173 | Copyright (c) 2018 Octokit contributors
174 |
175 | Permission is hereby granted, free of charge, to any person obtaining a copy
176 | of this software and associated documentation files (the "Software"), to deal
177 | in the Software without restriction, including without limitation the rights
178 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
179 | copies of the Software, and to permit persons to whom the Software is
180 | furnished to do so, subject to the following conditions:
181 |
182 | The above copyright notice and this permission notice shall be included in
183 | all copies or substantial portions of the Software.
184 |
185 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
186 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
187 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
188 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
189 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
190 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
191 | THE SOFTWARE.
192 |
193 |
194 | @octokit/request-error
195 | MIT
196 | The MIT License
197 |
198 | Copyright (c) 2019 Octokit contributors
199 |
200 | Permission is hereby granted, free of charge, to any person obtaining a copy
201 | of this software and associated documentation files (the "Software"), to deal
202 | in the Software without restriction, including without limitation the rights
203 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
204 | copies of the Software, and to permit persons to whom the Software is
205 | furnished to do so, subject to the following conditions:
206 |
207 | The above copyright notice and this permission notice shall be included in
208 | all copies or substantial portions of the Software.
209 |
210 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
211 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
212 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
213 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
214 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
215 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
216 | THE SOFTWARE.
217 |
218 |
219 | @vercel/ncc
220 | MIT
221 | Copyright 2018 ZEIT, Inc.
222 |
223 | 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:
224 |
225 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
226 |
227 | 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.
228 |
229 | before-after-hook
230 | Apache-2.0
231 | Apache License
232 | Version 2.0, January 2004
233 | http://www.apache.org/licenses/
234 |
235 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
236 |
237 | 1. Definitions.
238 |
239 | "License" shall mean the terms and conditions for use, reproduction,
240 | and distribution as defined by Sections 1 through 9 of this document.
241 |
242 | "Licensor" shall mean the copyright owner or entity authorized by
243 | the copyright owner that is granting the License.
244 |
245 | "Legal Entity" shall mean the union of the acting entity and all
246 | other entities that control, are controlled by, or are under common
247 | control with that entity. For the purposes of this definition,
248 | "control" means (i) the power, direct or indirect, to cause the
249 | direction or management of such entity, whether by contract or
250 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
251 | outstanding shares, or (iii) beneficial ownership of such entity.
252 |
253 | "You" (or "Your") shall mean an individual or Legal Entity
254 | exercising permissions granted by this License.
255 |
256 | "Source" form shall mean the preferred form for making modifications,
257 | including but not limited to software source code, documentation
258 | source, and configuration files.
259 |
260 | "Object" form shall mean any form resulting from mechanical
261 | transformation or translation of a Source form, including but
262 | not limited to compiled object code, generated documentation,
263 | and conversions to other media types.
264 |
265 | "Work" shall mean the work of authorship, whether in Source or
266 | Object form, made available under the License, as indicated by a
267 | copyright notice that is included in or attached to the work
268 | (an example is provided in the Appendix below).
269 |
270 | "Derivative Works" shall mean any work, whether in Source or Object
271 | form, that is based on (or derived from) the Work and for which the
272 | editorial revisions, annotations, elaborations, or other modifications
273 | represent, as a whole, an original work of authorship. For the purposes
274 | of this License, Derivative Works shall not include works that remain
275 | separable from, or merely link (or bind by name) to the interfaces of,
276 | the Work and Derivative Works thereof.
277 |
278 | "Contribution" shall mean any work of authorship, including
279 | the original version of the Work and any modifications or additions
280 | to that Work or Derivative Works thereof, that is intentionally
281 | submitted to Licensor for inclusion in the Work by the copyright owner
282 | or by an individual or Legal Entity authorized to submit on behalf of
283 | the copyright owner. For the purposes of this definition, "submitted"
284 | means any form of electronic, verbal, or written communication sent
285 | to the Licensor or its representatives, including but not limited to
286 | communication on electronic mailing lists, source code control systems,
287 | and issue tracking systems that are managed by, or on behalf of, the
288 | Licensor for the purpose of discussing and improving the Work, but
289 | excluding communication that is conspicuously marked or otherwise
290 | designated in writing by the copyright owner as "Not a Contribution."
291 |
292 | "Contributor" shall mean Licensor and any individual or Legal Entity
293 | on behalf of whom a Contribution has been received by Licensor and
294 | subsequently incorporated within the Work.
295 |
296 | 2. Grant of Copyright License. Subject to the terms and conditions of
297 | this License, each Contributor hereby grants to You a perpetual,
298 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
299 | copyright license to reproduce, prepare Derivative Works of,
300 | publicly display, publicly perform, sublicense, and distribute the
301 | Work and such Derivative Works in Source or Object form.
302 |
303 | 3. Grant of Patent License. Subject to the terms and conditions of
304 | this License, each Contributor hereby grants to You a perpetual,
305 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
306 | (except as stated in this section) patent license to make, have made,
307 | use, offer to sell, sell, import, and otherwise transfer the Work,
308 | where such license applies only to those patent claims licensable
309 | by such Contributor that are necessarily infringed by their
310 | Contribution(s) alone or by combination of their Contribution(s)
311 | with the Work to which such Contribution(s) was submitted. If You
312 | institute patent litigation against any entity (including a
313 | cross-claim or counterclaim in a lawsuit) alleging that the Work
314 | or a Contribution incorporated within the Work constitutes direct
315 | or contributory patent infringement, then any patent licenses
316 | granted to You under this License for that Work shall terminate
317 | as of the date such litigation is filed.
318 |
319 | 4. Redistribution. You may reproduce and distribute copies of the
320 | Work or Derivative Works thereof in any medium, with or without
321 | modifications, and in Source or Object form, provided that You
322 | meet the following conditions:
323 |
324 | (a) You must give any other recipients of the Work or
325 | Derivative Works a copy of this License; and
326 |
327 | (b) You must cause any modified files to carry prominent notices
328 | stating that You changed the files; and
329 |
330 | (c) You must retain, in the Source form of any Derivative Works
331 | that You distribute, all copyright, patent, trademark, and
332 | attribution notices from the Source form of the Work,
333 | excluding those notices that do not pertain to any part of
334 | the Derivative Works; and
335 |
336 | (d) If the Work includes a "NOTICE" text file as part of its
337 | distribution, then any Derivative Works that You distribute must
338 | include a readable copy of the attribution notices contained
339 | within such NOTICE file, excluding those notices that do not
340 | pertain to any part of the Derivative Works, in at least one
341 | of the following places: within a NOTICE text file distributed
342 | as part of the Derivative Works; within the Source form or
343 | documentation, if provided along with the Derivative Works; or,
344 | within a display generated by the Derivative Works, if and
345 | wherever such third-party notices normally appear. The contents
346 | of the NOTICE file are for informational purposes only and
347 | do not modify the License. You may add Your own attribution
348 | notices within Derivative Works that You distribute, alongside
349 | or as an addendum to the NOTICE text from the Work, provided
350 | that such additional attribution notices cannot be construed
351 | as modifying the License.
352 |
353 | You may add Your own copyright statement to Your modifications and
354 | may provide additional or different license terms and conditions
355 | for use, reproduction, or distribution of Your modifications, or
356 | for any such Derivative Works as a whole, provided Your use,
357 | reproduction, and distribution of the Work otherwise complies with
358 | the conditions stated in this License.
359 |
360 | 5. Submission of Contributions. Unless You explicitly state otherwise,
361 | any Contribution intentionally submitted for inclusion in the Work
362 | by You to the Licensor shall be under the terms and conditions of
363 | this License, without any additional terms or conditions.
364 | Notwithstanding the above, nothing herein shall supersede or modify
365 | the terms of any separate license agreement you may have executed
366 | with Licensor regarding such Contributions.
367 |
368 | 6. Trademarks. This License does not grant permission to use the trade
369 | names, trademarks, service marks, or product names of the Licensor,
370 | except as required for reasonable and customary use in describing the
371 | origin of the Work and reproducing the content of the NOTICE file.
372 |
373 | 7. Disclaimer of Warranty. Unless required by applicable law or
374 | agreed to in writing, Licensor provides the Work (and each
375 | Contributor provides its Contributions) on an "AS IS" BASIS,
376 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
377 | implied, including, without limitation, any warranties or conditions
378 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
379 | PARTICULAR PURPOSE. You are solely responsible for determining the
380 | appropriateness of using or redistributing the Work and assume any
381 | risks associated with Your exercise of permissions under this License.
382 |
383 | 8. Limitation of Liability. In no event and under no legal theory,
384 | whether in tort (including negligence), contract, or otherwise,
385 | unless required by applicable law (such as deliberate and grossly
386 | negligent acts) or agreed to in writing, shall any Contributor be
387 | liable to You for damages, including any direct, indirect, special,
388 | incidental, or consequential damages of any character arising as a
389 | result of this License or out of the use or inability to use the
390 | Work (including but not limited to damages for loss of goodwill,
391 | work stoppage, computer failure or malfunction, or any and all
392 | other commercial damages or losses), even if such Contributor
393 | has been advised of the possibility of such damages.
394 |
395 | 9. Accepting Warranty or Additional Liability. While redistributing
396 | the Work or Derivative Works thereof, You may choose to offer,
397 | and charge a fee for, acceptance of support, warranty, indemnity,
398 | or other liability obligations and/or rights consistent with this
399 | License. However, in accepting such obligations, You may act only
400 | on Your own behalf and on Your sole responsibility, not on behalf
401 | of any other Contributor, and only if You agree to indemnify,
402 | defend, and hold each Contributor harmless for any liability
403 | incurred by, or claims asserted against, such Contributor by reason
404 | of your accepting any such warranty or additional liability.
405 |
406 | END OF TERMS AND CONDITIONS
407 |
408 | APPENDIX: How to apply the Apache License to your work.
409 |
410 | To apply the Apache License to your work, attach the following
411 | boilerplate notice, with the fields enclosed by brackets "{}"
412 | replaced with your own identifying information. (Don't include
413 | the brackets!) The text should be enclosed in the appropriate
414 | comment syntax for the file format. We also recommend that a
415 | file or class name and description of purpose be included on the
416 | same "printed page" as the copyright notice for easier
417 | identification within third-party archives.
418 |
419 | Copyright 2018 Gregor Martynus and other contributors.
420 |
421 | Licensed under the Apache License, Version 2.0 (the "License");
422 | you may not use this file except in compliance with the License.
423 | You may obtain a copy of the License at
424 |
425 | http://www.apache.org/licenses/LICENSE-2.0
426 |
427 | Unless required by applicable law or agreed to in writing, software
428 | distributed under the License is distributed on an "AS IS" BASIS,
429 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
430 | See the License for the specific language governing permissions and
431 | limitations under the License.
432 |
433 |
434 | deprecation
435 | ISC
436 | The ISC License
437 |
438 | Copyright (c) Gregor Martynus and contributors
439 |
440 | Permission to use, copy, modify, and/or distribute this software for any
441 | purpose with or without fee is hereby granted, provided that the above
442 | copyright notice and this permission notice appear in all copies.
443 |
444 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
445 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
446 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
447 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
448 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
449 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
450 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
451 |
452 |
453 | is-plain-object
454 | MIT
455 | The MIT License (MIT)
456 |
457 | Copyright (c) 2014-2017, Jon Schlinkert.
458 |
459 | Permission is hereby granted, free of charge, to any person obtaining a copy
460 | of this software and associated documentation files (the "Software"), to deal
461 | in the Software without restriction, including without limitation the rights
462 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
463 | copies of the Software, and to permit persons to whom the Software is
464 | furnished to do so, subject to the following conditions:
465 |
466 | The above copyright notice and this permission notice shall be included in
467 | all copies or substantial portions of the Software.
468 |
469 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
470 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
471 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
472 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
473 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
474 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
475 | THE SOFTWARE.
476 |
477 |
478 | node-fetch
479 | MIT
480 | The MIT License (MIT)
481 |
482 | Copyright (c) 2016 David Frank
483 |
484 | Permission is hereby granted, free of charge, to any person obtaining a copy
485 | of this software and associated documentation files (the "Software"), to deal
486 | in the Software without restriction, including without limitation the rights
487 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
488 | copies of the Software, and to permit persons to whom the Software is
489 | furnished to do so, subject to the following conditions:
490 |
491 | The above copyright notice and this permission notice shall be included in all
492 | copies or substantial portions of the Software.
493 |
494 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
495 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
496 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
497 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
498 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
499 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
500 | SOFTWARE.
501 |
502 |
503 |
504 | once
505 | ISC
506 | The ISC License
507 |
508 | Copyright (c) Isaac Z. Schlueter and Contributors
509 |
510 | Permission to use, copy, modify, and/or distribute this software for any
511 | purpose with or without fee is hereby granted, provided that the above
512 | copyright notice and this permission notice appear in all copies.
513 |
514 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
515 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
516 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
517 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
518 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
519 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
520 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
521 |
522 |
523 | tunnel
524 | MIT
525 | The MIT License (MIT)
526 |
527 | Copyright (c) 2012 Koichi Kobayashi
528 |
529 | Permission is hereby granted, free of charge, to any person obtaining a copy
530 | of this software and associated documentation files (the "Software"), to deal
531 | in the Software without restriction, including without limitation the rights
532 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
533 | copies of the Software, and to permit persons to whom the Software is
534 | furnished to do so, subject to the following conditions:
535 |
536 | The above copyright notice and this permission notice shall be included in
537 | all copies or substantial portions of the Software.
538 |
539 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
540 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
541 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
542 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
543 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
544 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
545 | THE SOFTWARE.
546 |
547 |
548 | universal-user-agent
549 | ISC
550 | # [ISC License](https://spdx.org/licenses/ISC)
551 |
552 | Copyright (c) 2018, Gregor Martynus (https://github.com/gr2m)
553 |
554 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
555 |
556 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
557 |
558 |
559 | wrappy
560 | ISC
561 | The ISC License
562 |
563 | Copyright (c) Isaac Z. Schlueter and Contributors
564 |
565 | Permission to use, copy, modify, and/or distribute this software for any
566 | purpose with or without fee is hereby granted, provided that the above
567 | copyright notice and this permission notice appear in all copies.
568 |
569 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
570 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
571 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
572 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
573 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
574 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
575 | IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
576 |
577 |
578 | yaml
579 | ISC
580 | Copyright 2018 Eemeli Aro
581 |
582 | Permission to use, copy, modify, and/or distribute this software for any purpose
583 | with or without fee is hereby granted, provided that the above copyright notice
584 | and this permission notice appear in all copies.
585 |
586 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
587 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
588 | FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
589 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
590 | OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
591 | TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
592 | THIS SOFTWARE.
593 |
--------------------------------------------------------------------------------
/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 | ;
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "action-update-version",
3 | "version": "1",
4 | "description": "Update your files version field on new releases",
5 | "main": "lib/main.js",
6 | "scripts": {
7 | "build": "tsc && yarn run package",
8 | "lint": "eslint src --ext .tsx,.js,.ts",
9 | "lint:fix": "yarn lint --fix",
10 | "package": "ncc build --source-map --license licenses.txt",
11 | "test": "jest"
12 | },
13 | "repository": {
14 | "type": "git",
15 | "url": "git+https://github.com/pocket-apps/action-version-update.git"
16 | },
17 | "keywords": [
18 | "actions",
19 | "version",
20 | "release",
21 | "update",
22 | "tag"
23 | ],
24 | "author": "Victor Navarro ",
25 | "license": "MIT",
26 | "dependencies": {
27 | "@actions/core": "1.2.6",
28 | "@actions/exec": "1.0.4",
29 | "@actions/github": "4.0.0",
30 | "yaml": "1.10.0"
31 | },
32 | "devDependencies": {
33 | "@pocket-apps/eslint-config": "3.0.0",
34 | "@types/node": "14.11.2",
35 | "@typescript-eslint/eslint-plugin": "4.1.0",
36 | "@typescript-eslint/parser": "4.1.0",
37 | "@vercel/ncc": "0.24.1",
38 | "eslint": "6.8.0",
39 | "eslint-config-airbnb": "18.2.0",
40 | "eslint-plugin-cypress": "2.11.2",
41 | "eslint-plugin-import": "2.22.0",
42 | "eslint-plugin-jest": "23.20.0",
43 | "eslint-plugin-jsx-a11y": "6.3.1",
44 | "eslint-plugin-react": "7.21.3",
45 | "eslint-plugin-react-hooks": "4.1.2",
46 | "eslint-plugin-replace-relative-imports": "^1.0.0",
47 | "eslint-plugin-unused-imports": "0.1.3",
48 | "husky": "4.2.5",
49 | "lint-staged": "10.2.13",
50 | "typescript": "4.0.2"
51 | },
52 | "eslintConfig": {
53 | "extends": [
54 | "@pocket-apps/eslint-config"
55 | ]
56 | },
57 | "husky": {
58 | "hooks": {
59 | "pre-push": "lint-staged"
60 | }
61 | },
62 | "lint-staged": {
63 | "*.{ts,js,tsx}": [
64 | "yarn lint:fix",
65 | "yarn lint"
66 | ]
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/main.ts:
--------------------------------------------------------------------------------
1 | import path from 'path';
2 | import fs from 'fs';
3 | import * as core from '@actions/core';
4 | import * as exec from '@actions/exec';
5 | import * as github from '@actions/github';
6 | import YAML from 'yaml';
7 |
8 | const getParser = (file: string, options: { spacing: number }) => {
9 | const extension = path.extname(file).replace('.', '');
10 |
11 | switch (extension) {
12 | case 'json':
13 | return {
14 | read: JSON.parse,
15 | write: (data: any) => JSON.stringify(data, null, options.spacing),
16 | };
17 | case 'yaml':
18 | case 'yml':
19 | return {
20 | read: YAML.parse,
21 | write: (data: any) => YAML.stringify(data, { indent: options.spacing }),
22 | };
23 | default:
24 | throw new Error(`Unsupported file extension "${extension}".\nTo add it you can simply submit a PR adding a new parser.`);
25 | }
26 | };
27 |
28 | const run = async () => {
29 | core.info('Setting input and environment variables');
30 | const root = process.env.GITHUB_WORKSPACE as string;
31 | const tag = (process.env.GITHUB_REF as string).replace('refs/tags/', '');
32 | const token = core.getInput('repo-token');
33 | const regex = new RegExp(core.getInput('version-regexp'));
34 | const files = core.getInput('files').replace(' ', '').split(',');
35 | const message = core.getInput('commit-message');
36 | const spacing = parseInt(core.getInput('spacing-level'), 10);
37 | let branch = core.getInput('branch-name');
38 | let author = core.getInput('author-name');
39 | let email = core.getInput('author-email');
40 |
41 | if (!token && !branch) {
42 | throw new Error('Either repo-token or branch-name must be supplied.');
43 | }
44 |
45 | if (token) {
46 | core.info('Setting up Octokit and context');
47 | const octokit = github.getOctokit(token);
48 | const { owner, repo } = github.context.repo;
49 |
50 | core.info('Fetching repo task history');
51 | const release = await octokit.repos.getReleaseByTag({ owner, repo, tag });
52 |
53 | if (release.data.tag_name !== tag) {
54 | throw new Error(`Release with name "${tag}" was not found`);
55 | }
56 |
57 | branch = release.data.target_commitish;
58 |
59 | if (!author && !email) {
60 | core.info('Getting author and email from release information');
61 | const username = release.data.author.login;
62 | const user = await octokit.users.getByUsername({ username });
63 |
64 | author = user.data.name;
65 | email = user.data.email;
66 | core.info(`👋 Nice to meet you ${author} (${email})!`);
67 | }
68 | } else {
69 | core.info('Skipping getting the latest release since not "repo-token" was provided');
70 | }
71 |
72 | core.info(`Checking latest tag "${tag}" against input regexp`);
73 | if (!regex.test(tag)) {
74 | throw new Error(`RegExp could not be matched to latest tag "${tag}"`);
75 | }
76 |
77 | const version = (tag.match(regex) as string[])[0];
78 | core.info(`Extracted new version "${version}" from "${tag}"`);
79 |
80 | // Forgive me for the unnecessary fanciness 🙏
81 | core.info('Updating files version field');
82 | const changed = files.reduce((change, file) => {
83 | const dir = path.join(root, file);
84 | const buffer = fs.readFileSync(dir, 'utf-8');
85 | const parser = getParser(file, { spacing });
86 | const content = parser.read(buffer);
87 |
88 | if (content.version === version) {
89 | core.info(` - ${file}: Skip since equal versions`);
90 | return change;
91 | }
92 |
93 | core.info(` - ${file}: Update version from "${content.version}" to "${version}"`);
94 | content.version = version;
95 | fs.writeFileSync(dir, parser.write(content));
96 | return true;
97 | }, false);
98 |
99 | if (!changed) {
100 | core.info('Skipped commit since no files were changed');
101 | return;
102 | }
103 |
104 | core.info('Committing file changes');
105 | await exec.exec('git', ['config', '--global', 'user.name', author]);
106 | await exec.exec('git', ['config', '--global', 'user.email', email]);
107 | await exec.exec('git', ['commit', '-am', message.replace('%version%', version)]);
108 | await exec.exec('git', ['push', '-u', 'origin', `HEAD:${branch}`]);
109 | };
110 |
111 | run()
112 | .then(() => core.info('Updated files version successfully'))
113 | .catch(error => core.setFailed(error.message));
114 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es6",
4 | "module": "commonjs",
5 | "outDir": "./lib",
6 | "rootDir": "./src",
7 | "strict": true,
8 | "noImplicitAny": true,
9 | "esModuleInterop": true
10 | },
11 | "exclude": ["node_modules", "**/*.test.ts"]
12 | }
13 |
--------------------------------------------------------------------------------