smipper 32.0.0 → 34.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/load.js +23 -10
- package/dist/loadUri.js +10 -8
- package/dist/processFrame.js +0 -7
- package/dist/rewriteLocalControl.js +12 -2
- package/package.json +1 -1
package/dist/load.js
CHANGED
|
@@ -7,19 +7,32 @@ exports.load = void 0;
|
|
|
7
7
|
const rewriteLocalControl_1 = require("./rewriteLocalControl");
|
|
8
8
|
const fs_1 = __importDefault(require("fs"));
|
|
9
9
|
const got_1 = __importDefault(require("got"));
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const process_1 = __importDefault(require("process"));
|
|
12
|
+
async function load(smipper, filePath) {
|
|
13
|
+
smipper.verbose("load", filePath);
|
|
14
|
+
if (filePath.startsWith("http://localcontrol.netflix.com/")) {
|
|
15
|
+
filePath = (0, rewriteLocalControl_1.rewriteLocalControl)(smipper, filePath);
|
|
14
16
|
}
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
+
if (!filePath.includes("://")) {
|
|
18
|
+
if (filePath[0] === "/" && fs_1.default.existsSync(filePath)) {
|
|
19
|
+
filePath = `file://${filePath}`;
|
|
20
|
+
}
|
|
21
|
+
else if (fs_1.default.existsSync(filePath)) {
|
|
22
|
+
filePath = `file://${path_1.default.join(process_1.default.cwd(), filePath)}`;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
filePath = (0, rewriteLocalControl_1.rewriteLocalControl)(smipper, filePath);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (filePath.startsWith("file:///")) {
|
|
29
|
+
return fs_1.default.readFileSync(filePath.substring(7), "utf8");
|
|
17
30
|
}
|
|
18
|
-
if (!
|
|
31
|
+
if (!filePath.startsWith("http://") && !filePath.startsWith("https://")) {
|
|
19
32
|
throw new Error("Not a url");
|
|
20
33
|
}
|
|
21
34
|
if (smipper.cache && smipper.cacheKey) {
|
|
22
|
-
const response = smipper.cache.get(smipper.cacheKey,
|
|
35
|
+
const response = smipper.cache.get(smipper.cacheKey, filePath);
|
|
23
36
|
if (response) {
|
|
24
37
|
return response;
|
|
25
38
|
}
|
|
@@ -29,13 +42,13 @@ async function load(smipper, path) {
|
|
|
29
42
|
}
|
|
30
43
|
// let retryIndex = 0;
|
|
31
44
|
async function get() {
|
|
32
|
-
const response = await got_1.default.get(
|
|
45
|
+
const response = await got_1.default.get(filePath, { timeout: 10000 });
|
|
33
46
|
smipper.verbose(response.headers);
|
|
34
47
|
return response.body || "";
|
|
35
48
|
}
|
|
36
49
|
const response = await get();
|
|
37
50
|
if (smipper.cacheEntry) {
|
|
38
|
-
smipper.cacheEntry.add(
|
|
51
|
+
smipper.cacheEntry.add(filePath, response);
|
|
39
52
|
}
|
|
40
53
|
return response;
|
|
41
54
|
}
|
package/dist/loadUri.js
CHANGED
|
@@ -8,9 +8,6 @@ const load_1 = require("./load");
|
|
|
8
8
|
const assert_1 = __importDefault(require("assert"));
|
|
9
9
|
const source_map_1 = __importDefault(require("source-map"));
|
|
10
10
|
function loadUri(smipper, path) {
|
|
11
|
-
if (path[0] === "/") {
|
|
12
|
-
path = "file://" + path;
|
|
13
|
-
}
|
|
14
11
|
return new Promise((resolve, reject) => {
|
|
15
12
|
smipper.verbose("loading", path);
|
|
16
13
|
if (!(path in smipper.sourceMaps)) {
|
|
@@ -22,20 +19,25 @@ function loadUri(smipper, path) {
|
|
|
22
19
|
.then((jsData) => {
|
|
23
20
|
const idx = jsData.lastIndexOf("//# sourceMappingURL=");
|
|
24
21
|
smipper.verbose("Got the file", jsData.length, idx);
|
|
25
|
-
if (idx
|
|
22
|
+
if (idx === -1) {
|
|
26
23
|
return path + ".map";
|
|
27
24
|
}
|
|
28
|
-
const mapUrl = jsData.substring(idx + 21);
|
|
25
|
+
const mapUrl = jsData.substring(idx + 21).trim();
|
|
29
26
|
const match = /^(data:.+\/.+;)base64,/.exec(mapUrl);
|
|
30
27
|
if (match) {
|
|
31
28
|
(0, assert_1.default)(match[1] !== undefined);
|
|
32
29
|
return mapUrl.substring(match[1].length);
|
|
33
30
|
}
|
|
34
|
-
if (mapUrl.indexOf("://")
|
|
31
|
+
if (mapUrl.indexOf("://") !== -1) {
|
|
32
|
+
return mapUrl;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
return new URL(mapUrl, path).href;
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
smipper.verbose("Got error parsing url", err.message);
|
|
35
39
|
return mapUrl;
|
|
36
40
|
}
|
|
37
|
-
// console.log(mapUrl);
|
|
38
|
-
return new URL(mapUrl, path).href;
|
|
39
41
|
})
|
|
40
42
|
.then((mapUrl) => {
|
|
41
43
|
// console.log(mapUrl.substring(0, 20));
|
package/dist/processFrame.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.processFrame = void 0;
|
|
7
4
|
const loadUri_1 = require("./loadUri");
|
|
8
5
|
const buildStackLine_1 = require("./buildStackLine");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
6
|
function processFrame(smipper, functionName, url, line, column) {
|
|
11
7
|
smipper.verbose("got frame", functionName, url, line, column);
|
|
12
8
|
if (functionName.endsWith("@")) {
|
|
@@ -15,9 +11,6 @@ function processFrame(smipper, functionName, url, line, column) {
|
|
|
15
11
|
return new Promise((resolve) => {
|
|
16
12
|
let newUrl, newLine, newColumn;
|
|
17
13
|
smipper.verbose("calling loadUri", url);
|
|
18
|
-
if (!url.includes("://") && url[0] !== "/" && fs_1.default.existsSync(url)) {
|
|
19
|
-
url = `file://${process.cwd()}/${url}`;
|
|
20
|
-
}
|
|
21
14
|
return (0, loadUri_1.loadUri)(smipper, url)
|
|
22
15
|
.then((smap) => {
|
|
23
16
|
smipper.verbose("got map", url, Object.keys(smap));
|
|
@@ -10,7 +10,7 @@ function findFile(dir, fn) {
|
|
|
10
10
|
const list = fs_1.default.readdirSync(dir);
|
|
11
11
|
for (let file of list) {
|
|
12
12
|
const match = file === fn;
|
|
13
|
-
file = dir
|
|
13
|
+
file = path_1.default.join(dir, file);
|
|
14
14
|
const stat = fs_1.default.statSync(file);
|
|
15
15
|
if (stat && stat.isDirectory()) {
|
|
16
16
|
const ret = findFile(file, fn);
|
|
@@ -25,7 +25,17 @@ function findFile(dir, fn) {
|
|
|
25
25
|
return undefined;
|
|
26
26
|
}
|
|
27
27
|
function rewriteLocalControl(smipper, url) {
|
|
28
|
-
|
|
28
|
+
let file;
|
|
29
|
+
if (url.startsWith("http://")) {
|
|
30
|
+
file = url.substring(7);
|
|
31
|
+
}
|
|
32
|
+
else if (url.startsWith("https://")) {
|
|
33
|
+
file = url.substring(8);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
file = url;
|
|
37
|
+
}
|
|
38
|
+
const found = findFile(process.cwd(), path_1.default.basename(file));
|
|
29
39
|
smipper.verbose("Rewriting", url, "in", process.cwd(), "=>", found);
|
|
30
40
|
if (found) {
|
|
31
41
|
return found;
|