├── .gitignore
├── README.md
├── package.json
├── LICENSE
├── unmap.js
└── pnpm-lock.yaml
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | out
3 | *.tgz
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Source map file unpacker
2 |
3 | Turn a source map into its original source files.
4 | Install by running `npm i -g source-map-unpacker`
5 |
6 | # Usage
7 |
8 | ```
9 | Usage: unmap [options]
10 |
11 | Options:
12 | -p, --path
input source map file
13 | -f, --filter filter out file names
14 | -o, --output output folder (default: "./")
15 | -h, --help display help for command
16 | ```
17 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "source-map-unpacker",
3 | "version": "2.0.0",
4 | "description": "",
5 | "main": "unmap.js",
6 | "bin": {
7 | "unpack": "unmap.js"
8 | },
9 | "type": "module",
10 | "engines": {
11 | "node": ">10"
12 | },
13 | "scripts": {
14 | "test": "node . -p test/gistfile1.js.map -o out"
15 | },
16 | "repository": {
17 | "type": "git",
18 | "url": "https://github.com/Anthonyzou/Sourcemap-Unpack"
19 | },
20 | "keywords": [
21 | "source map",
22 | "source-map",
23 | "unpack source maps",
24 | "recreate source maps",
25 | "source map to original structure"
26 | ],
27 | "author": "Anthony Ou",
28 | "license": "MIT",
29 | "dependencies": {
30 | "commander": "9.3.0",
31 | "filenamify": "5.1.1",
32 | "fs-extra": "10.1.0"
33 | },
34 | "devDependencies": {
35 | "@types/fs-extra": "9.0.13",
36 | "@types/node": "18.0.0"
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Anthony Ou
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/unmap.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | import fs from "fs-extra";
4 | import filenamify from "filenamify";
5 | import os from "os";
6 | import { resolve } from "path";
7 | import { Command } from "commander";
8 | const program = new Command();
9 | const isWindows = os.platform() == "win32";
10 |
11 | const opts = program
12 | .name("unmap")
13 | .requiredOption("-p, --path ", "Input source map file")
14 | .option("-f, --filter ", "Filter out file names")
15 | .option("-o, --output ", "Output folder", "./")
16 | .parse(process.argv)
17 | .opts();
18 |
19 | fs.readFile(opts.path)
20 | .catch(async (e) => {
21 | if (e.errno == -13) {
22 | console.log("Insufficient permissions to read the input file.");
23 | }
24 | if (e.errno == -2) {
25 | console.log("Input file does not exists.");
26 | }
27 | process.exit(1);
28 | })
29 | .then((js) => {
30 | js = JSON.parse(js.toString());
31 |
32 | const files = js.sources
33 | .filter((path) => (opts.filter ? path.includes(opts.filter) : true))
34 | .map((path, idx) => {
35 | const outpath = resolve(
36 | opts.output,
37 | isWindows ? filenamify(path) : path
38 | );
39 | return fs.outputFile(outpath, js.sourcesContent[idx]);
40 | });
41 | return Promise.all(files);
42 | })
43 | .then(() => console.log(`${opts.path} unpacked`));
44 |
--------------------------------------------------------------------------------
/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 | lockfileVersion: 5.4
2 |
3 | specifiers:
4 | '@types/fs-extra': 9.0.13
5 | '@types/node': 18.0.0
6 | commander: 9.3.0
7 | filenamify: 5.1.1
8 | fs-extra: 10.1.0
9 |
10 | dependencies:
11 | commander: 9.3.0
12 | filenamify: 5.1.1
13 | fs-extra: 10.1.0
14 |
15 | devDependencies:
16 | '@types/fs-extra': 9.0.13
17 | '@types/node': 18.0.0
18 |
19 | packages:
20 |
21 | /@types/fs-extra/9.0.13:
22 | resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==}
23 | dependencies:
24 | '@types/node': 18.0.0
25 | dev: true
26 |
27 | /@types/node/18.0.0:
28 | resolution: {integrity: sha512-cHlGmko4gWLVI27cGJntjs/Sj8th9aYwplmZFwmmgYQQvL5NUsgVJG7OddLvNfLqYS31KFN0s3qlaD9qCaxACA==}
29 | dev: true
30 |
31 | /commander/9.3.0:
32 | resolution: {integrity: sha512-hv95iU5uXPbK83mjrJKuZyFM/LBAoCV/XhVGkS5Je6tl7sxr6A0ITMw5WoRV46/UaJ46Nllm3Xt7IaJhXTIkzw==}
33 | engines: {node: ^12.20.0 || >=14}
34 | dev: false
35 |
36 | /escape-string-regexp/5.0.0:
37 | resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
38 | engines: {node: '>=12'}
39 | dev: false
40 |
41 | /filename-reserved-regex/3.0.0:
42 | resolution: {integrity: sha512-hn4cQfU6GOT/7cFHXBqeBg2TbrMBgdD0kcjLhvSQYYwm3s4B6cjvBfb7nBALJLAXqmU5xajSa7X2NnUud/VCdw==}
43 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
44 | dev: false
45 |
46 | /filenamify/5.1.1:
47 | resolution: {integrity: sha512-M45CbrJLGACfrPOkrTp3j2EcO9OBkKUYME0eiqOCa7i2poaklU0jhlIaMlr8ijLorT0uLAzrn3qXOp5684CkfA==}
48 | engines: {node: '>=12.20'}
49 | dependencies:
50 | filename-reserved-regex: 3.0.0
51 | strip-outer: 2.0.0
52 | trim-repeated: 2.0.0
53 | dev: false
54 |
55 | /fs-extra/10.1.0:
56 | resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==}
57 | engines: {node: '>=12'}
58 | dependencies:
59 | graceful-fs: 4.2.10
60 | jsonfile: 6.1.0
61 | universalify: 2.0.0
62 | dev: false
63 |
64 | /graceful-fs/4.2.10:
65 | resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==}
66 | dev: false
67 |
68 | /jsonfile/6.1.0:
69 | resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
70 | dependencies:
71 | universalify: 2.0.0
72 | optionalDependencies:
73 | graceful-fs: 4.2.10
74 | dev: false
75 |
76 | /strip-outer/2.0.0:
77 | resolution: {integrity: sha512-A21Xsm1XzUkK0qK1ZrytDUvqsQWict2Cykhvi0fBQntGG5JSprESasEyV1EZ/4CiR5WB5KjzLTrP/bO37B0wPg==}
78 | engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
79 | dev: false
80 |
81 | /trim-repeated/2.0.0:
82 | resolution: {integrity: sha512-QUHBFTJGdOwmp0tbOG505xAgOp/YliZP/6UgafFXYZ26WT1bvQmSMJUvkeVSASuJJHbqsFbynTvkd5W8RBTipg==}
83 | engines: {node: '>=12'}
84 | dependencies:
85 | escape-string-regexp: 5.0.0
86 | dev: false
87 |
88 | /universalify/2.0.0:
89 | resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
90 | engines: {node: '>= 10.0.0'}
91 | dev: false
92 |
--------------------------------------------------------------------------------