smipper 17.0.1 → 19.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/package.json +6 -3
- package/index.ts +0 -373
- package/prettier.config.js +0 -6
- package/tsconfig.json +0 -28
- /package/{index.js → smipper} +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smipper",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "19.0.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "
|
|
5
|
+
"main": "smiper",
|
|
6
|
+
"files": [
|
|
7
|
+
"smipper"
|
|
8
|
+
],
|
|
6
9
|
"scripts": {
|
|
7
|
-
"build": "node ./node_modules/.bin/tsc index.ts && chmod +x ./
|
|
10
|
+
"build": "node ./node_modules/.bin/tsc index.ts && mv ./index.js ./smipper && chmod +x ./smipper",
|
|
8
11
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
12
|
},
|
|
10
13
|
"author": "",
|
package/index.ts
DELETED
|
@@ -1,373 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
import * as fs from "fs";
|
|
5
|
-
import * as got from "got";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import * as sourceMap from "source-map";
|
|
8
|
-
import * as url from "url";
|
|
9
|
-
|
|
10
|
-
let verbose = false;
|
|
11
|
-
let stack;
|
|
12
|
-
let json = false;
|
|
13
|
-
let retries = 3;
|
|
14
|
-
let jsc = 0;
|
|
15
|
-
|
|
16
|
-
for (let i = 2; i < process.argv.length; ++i) {
|
|
17
|
-
try {
|
|
18
|
-
const arg = process.argv[i] || "";
|
|
19
|
-
if (verbose) {
|
|
20
|
-
console.error("got arg", arg);
|
|
21
|
-
}
|
|
22
|
-
if (arg === "-f" || arg === "--file") {
|
|
23
|
-
stack = fs.readFileSync(process.argv[++i]).toString();
|
|
24
|
-
} else if (arg.startsWith("-f")) {
|
|
25
|
-
stack = fs.readFileSync(arg.substring(2)).toString();
|
|
26
|
-
} else if (arg.startsWith("--file=")) {
|
|
27
|
-
stack = fs.readFileSync(arg.substring(7)).toString();
|
|
28
|
-
} else if (arg === "--verbose" || arg === "-v") {
|
|
29
|
-
verbose = true;
|
|
30
|
-
} else if (arg === "--version") {
|
|
31
|
-
console.log(JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"), "utf8")).version);
|
|
32
|
-
process.exit(0);
|
|
33
|
-
} else if (arg === "--json") {
|
|
34
|
-
json = true;
|
|
35
|
-
} else if (arg === "--jsc") {
|
|
36
|
-
// jsc has the wrong column for some reason
|
|
37
|
-
jsc = 1;
|
|
38
|
-
} else if (arg.startsWith("--retries")) {
|
|
39
|
-
retries = parseInt(arg.substring(9));
|
|
40
|
-
if (isNaN(retries) || retries < 0) {
|
|
41
|
-
console.error(
|
|
42
|
-
"smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-"
|
|
43
|
-
);
|
|
44
|
-
process.exit(1);
|
|
45
|
-
}
|
|
46
|
-
} else if (arg === "-h" || arg === "--help") {
|
|
47
|
-
console.error(
|
|
48
|
-
"smipper [stack|-h|--help|-v|--verbose|--version|--retries=<number>|--jsc|--json|-f=@FILE@|-"
|
|
49
|
-
);
|
|
50
|
-
process.exit(0);
|
|
51
|
-
} else if (arg === "-") {
|
|
52
|
-
// stdin
|
|
53
|
-
} else {
|
|
54
|
-
stack = arg;
|
|
55
|
-
}
|
|
56
|
-
} catch (err) {
|
|
57
|
-
console.error("Error: " + err.toString());
|
|
58
|
-
process.exit(1);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!stack) {
|
|
63
|
-
stack = fs.readFileSync("/dev/stdin").toString();
|
|
64
|
-
if (!stack) {
|
|
65
|
-
console.error("Nothing to do");
|
|
66
|
-
process.exit(0);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function build(functionName: string, url: string, line: number, column: number): string {
|
|
71
|
-
return `${functionName ? "at " + functionName + " " : ""}${url}:${line}:${column}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function findFile(dir: string, fn: string): string | undefined {
|
|
75
|
-
const list = fs.readdirSync(dir);
|
|
76
|
-
for (let file of list) {
|
|
77
|
-
const match = file === fn;
|
|
78
|
-
file = dir + "/" + file;
|
|
79
|
-
const stat = fs.statSync(file);
|
|
80
|
-
if (stat && stat.isDirectory()) {
|
|
81
|
-
const ret = findFile(file, fn);
|
|
82
|
-
if (ret) {
|
|
83
|
-
return ret;
|
|
84
|
-
}
|
|
85
|
-
} else if (match) {
|
|
86
|
-
return "file://" + file;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function rewriteLocalControl(url: string) {
|
|
93
|
-
const found = findFile(process.cwd(), path.basename(url.substring(6)));
|
|
94
|
-
if (found) {
|
|
95
|
-
return found;
|
|
96
|
-
}
|
|
97
|
-
throw new Error("Couldn't resolve localcontrol " + url);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function load(path: string): Promise<string> {
|
|
101
|
-
return new Promise<string>((resolve, reject) => {
|
|
102
|
-
if (path.startsWith("http://localcontrol.netflix.com/")) {
|
|
103
|
-
try {
|
|
104
|
-
path = rewriteLocalControl(path);
|
|
105
|
-
} catch (err) {
|
|
106
|
-
reject(err);
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (path.startsWith("file:///")) {
|
|
112
|
-
try {
|
|
113
|
-
resolve(fs.readFileSync(path.substring(7), "utf8"));
|
|
114
|
-
} catch (err) {
|
|
115
|
-
reject(err);
|
|
116
|
-
}
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (!path.startsWith("http://") && !path.startsWith("https://")) {
|
|
121
|
-
reject(new Error("Not a url"));
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// let retryIndex = 0;
|
|
126
|
-
async function get(): Promise<string> {
|
|
127
|
-
const response = await got.get(path, { timeout: 10000 });
|
|
128
|
-
console.log(response.headers);
|
|
129
|
-
return response.body || "";
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
get().then(resolve, reject);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
type SourceMapResolve = (res: sourceMap.SourceMapConsumer) => void;
|
|
137
|
-
type Rejecter = (err: Error) => void;
|
|
138
|
-
type SourceMapData = {
|
|
139
|
-
resolvers: SourceMapResolve[];
|
|
140
|
-
rejecters: Rejecter[];
|
|
141
|
-
};
|
|
142
|
-
const sourceMaps: Record<string, SourceMapData> = {};
|
|
143
|
-
function loadUri(path: string): Promise<sourceMap.SourceMapConsumer> {
|
|
144
|
-
if (path[0] === "/") {
|
|
145
|
-
path = "file://" + path;
|
|
146
|
-
}
|
|
147
|
-
return new Promise((resolve: SourceMapResolve, reject: Rejecter) => {
|
|
148
|
-
if (verbose) {
|
|
149
|
-
console.log("loading", path);
|
|
150
|
-
}
|
|
151
|
-
if (!(path in sourceMaps)) {
|
|
152
|
-
sourceMaps[path] = {
|
|
153
|
-
resolvers: [resolve],
|
|
154
|
-
rejecters: [reject]
|
|
155
|
-
};
|
|
156
|
-
load(path)
|
|
157
|
-
.then((jsData: string) => {
|
|
158
|
-
const idx = jsData.lastIndexOf("//# sourceMappingURL=");
|
|
159
|
-
if (verbose) {
|
|
160
|
-
console.error("Got the file", jsData.length, idx);
|
|
161
|
-
}
|
|
162
|
-
if (idx == -1) {
|
|
163
|
-
return path + ".map";
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const mapUrl = jsData.substring(idx + 21);
|
|
167
|
-
const match = /^(data:.+\/.+;)base64,/.exec(mapUrl);
|
|
168
|
-
if (match) {
|
|
169
|
-
return mapUrl.substring(match[1].length);
|
|
170
|
-
}
|
|
171
|
-
if (mapUrl.indexOf("://") != -1) {
|
|
172
|
-
return mapUrl;
|
|
173
|
-
}
|
|
174
|
-
// console.log(mapUrl);
|
|
175
|
-
return new url.URL(mapUrl, path).href;
|
|
176
|
-
})
|
|
177
|
-
.then((mapUrl) => {
|
|
178
|
-
// console.log(mapUrl.substring(0, 20));
|
|
179
|
-
if (mapUrl.startsWith("base64,")) {
|
|
180
|
-
return Buffer.from(mapUrl.substring(7), "base64").toString();
|
|
181
|
-
}
|
|
182
|
-
return load(mapUrl);
|
|
183
|
-
})
|
|
184
|
-
.then(async (sourceMapData: string) => {
|
|
185
|
-
const parsed = JSON.parse(sourceMapData);
|
|
186
|
-
const smap: sourceMap.SourceMapConsumer = await new sourceMap.SourceMapConsumer(parsed);
|
|
187
|
-
const pending = sourceMaps[path];
|
|
188
|
-
// sourceMaps.delete(path);
|
|
189
|
-
if (pending) {
|
|
190
|
-
pending.resolvers.forEach((func: SourceMapResolve) => {
|
|
191
|
-
func(smap);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
})
|
|
195
|
-
.catch((err) => {
|
|
196
|
-
const pending = sourceMaps[path];
|
|
197
|
-
if (!pending) {
|
|
198
|
-
throw new Error("Gotta have pending");
|
|
199
|
-
}
|
|
200
|
-
// sourceMaps.delete(path);
|
|
201
|
-
pending.rejecters.forEach((func: (err: Error) => void) => {
|
|
202
|
-
func(err);
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
} else {
|
|
206
|
-
const cur = sourceMaps[path];
|
|
207
|
-
if (verbose) {
|
|
208
|
-
console.error("path is in source maps already", cur);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (!cur) {
|
|
212
|
-
throw new Error("Gotta have cur");
|
|
213
|
-
}
|
|
214
|
-
cur.resolvers.push(resolve);
|
|
215
|
-
cur.rejecters.push(reject);
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
type Frame = {
|
|
221
|
-
functionName: string;
|
|
222
|
-
sourceURL: string;
|
|
223
|
-
line: number;
|
|
224
|
-
column: number;
|
|
225
|
-
index?: number;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
function processFrame(functionName: string, url: string, line: number, column: number): Promise<Frame | string> {
|
|
229
|
-
if (verbose) {
|
|
230
|
-
console.log("got frame", functionName, url, line, column);
|
|
231
|
-
}
|
|
232
|
-
if (functionName.endsWith("@")) {
|
|
233
|
-
functionName = functionName.substring(0, functionName.length - 1);
|
|
234
|
-
}
|
|
235
|
-
return new Promise((resolve) => {
|
|
236
|
-
let newUrl: string, newLine: number, newColumn: number;
|
|
237
|
-
if (verbose) {
|
|
238
|
-
console.error("calling loadUri", url);
|
|
239
|
-
}
|
|
240
|
-
if (!url.includes("://") && url[0] !== "/" && fs.existsSync(url)) {
|
|
241
|
-
url = `file://${process.cwd()}/${url}`;
|
|
242
|
-
}
|
|
243
|
-
return loadUri(url)
|
|
244
|
-
.then((smap) => {
|
|
245
|
-
if (verbose) {
|
|
246
|
-
console.error("got map", url, Object.keys(smap));
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// it appears that we're supposed to reduce the column
|
|
250
|
-
// number by 1 when we get this from jsc
|
|
251
|
-
const pos = smap.originalPositionFor({ line, column: column - jsc });
|
|
252
|
-
if (!pos.source) {
|
|
253
|
-
if (verbose) {
|
|
254
|
-
console.error("nothing here", pos);
|
|
255
|
-
}
|
|
256
|
-
throw new Error("Mapping not found");
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// smc.sourceContentFor(pos.source);
|
|
260
|
-
|
|
261
|
-
newUrl = pos.source;
|
|
262
|
-
|
|
263
|
-
newLine = pos.line || 0;
|
|
264
|
-
newColumn = pos.column || 0;
|
|
265
|
-
})
|
|
266
|
-
.catch((err) => {
|
|
267
|
-
if (verbose) {
|
|
268
|
-
console.error("didn't get map", url, err);
|
|
269
|
-
}
|
|
270
|
-
// console.error(err);
|
|
271
|
-
})
|
|
272
|
-
.finally(() => {
|
|
273
|
-
if (json) {
|
|
274
|
-
const ret = {
|
|
275
|
-
functionName: functionName,
|
|
276
|
-
sourceURL: newUrl ? newUrl : url,
|
|
277
|
-
line: newUrl ? newLine : line,
|
|
278
|
-
column: newUrl ? newColumn : column
|
|
279
|
-
};
|
|
280
|
-
// if (newUrl) {
|
|
281
|
-
// ret.oldSourceURL = url;
|
|
282
|
-
// ret.oldLine = line;
|
|
283
|
-
// ret.oldColumn = column;
|
|
284
|
-
// }
|
|
285
|
-
// if (newUrl) {
|
|
286
|
-
// ret.newUrl = newUrl;
|
|
287
|
-
// ret.newLine = newLine;
|
|
288
|
-
// ret.newColumn = newColumn;
|
|
289
|
-
// }
|
|
290
|
-
resolve(ret);
|
|
291
|
-
} else {
|
|
292
|
-
let str;
|
|
293
|
-
if (newUrl) {
|
|
294
|
-
str = `${build(functionName, newUrl, newLine, newColumn)} (${build("", url, line, column)})`;
|
|
295
|
-
} else {
|
|
296
|
-
str = build(functionName, url, line, column);
|
|
297
|
-
}
|
|
298
|
-
resolve(str);
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (json) {
|
|
305
|
-
let parsed;
|
|
306
|
-
try {
|
|
307
|
-
parsed = JSON.parse(stack);
|
|
308
|
-
if (!Array.isArray(parsed)) {
|
|
309
|
-
throw new Error("Expected array");
|
|
310
|
-
}
|
|
311
|
-
} catch (err) {
|
|
312
|
-
console.error(`Can't parse json ${err}`);
|
|
313
|
-
process.exit(1);
|
|
314
|
-
}
|
|
315
|
-
Promise.all(
|
|
316
|
-
parsed.map((frame) => {
|
|
317
|
-
if (verbose) {
|
|
318
|
-
console.error("got frame frame", frame);
|
|
319
|
-
}
|
|
320
|
-
return processFrame(frame.functionName || "", frame.sourceURL || "", frame.line, frame.column);
|
|
321
|
-
})
|
|
322
|
-
)
|
|
323
|
-
.then((results) => {
|
|
324
|
-
results.forEach((frame: Frame | string, index: number) => {
|
|
325
|
-
if (typeof frame !== "object") {
|
|
326
|
-
throw new Error("Huh?");
|
|
327
|
-
}
|
|
328
|
-
frame.index = index;
|
|
329
|
-
});
|
|
330
|
-
// console.log("shit", results);
|
|
331
|
-
console.log(JSON.stringify(results, null, 4));
|
|
332
|
-
})
|
|
333
|
-
.catch((error) => {
|
|
334
|
-
console.error("Got an error", error);
|
|
335
|
-
process.exit(2);
|
|
336
|
-
});
|
|
337
|
-
} else {
|
|
338
|
-
Promise.all(
|
|
339
|
-
stack
|
|
340
|
-
.split("\n")
|
|
341
|
-
.filter((x) => x)
|
|
342
|
-
.map((x) => {
|
|
343
|
-
x = x.trim();
|
|
344
|
-
let match = / *at *([^ ]*).* \(?([^ ]+):([0-9]+):([0-9]+)/.exec(x);
|
|
345
|
-
if (!match) {
|
|
346
|
-
match = /([^ ]+@)?(.*):([0-9]+):([0-9]+)/.exec(x);
|
|
347
|
-
}
|
|
348
|
-
if (verbose) {
|
|
349
|
-
console.error(x, " => ", match);
|
|
350
|
-
}
|
|
351
|
-
if (!match) {
|
|
352
|
-
const nolinecol = /([^ ]*)(.*)/.exec(x);
|
|
353
|
-
if (nolinecol) {
|
|
354
|
-
return nolinecol[0];
|
|
355
|
-
}
|
|
356
|
-
return x;
|
|
357
|
-
}
|
|
358
|
-
return processFrame(match[1] || "", match[2], parseInt(match[3]), parseInt(match[4]));
|
|
359
|
-
})
|
|
360
|
-
)
|
|
361
|
-
.then((results) => {
|
|
362
|
-
if (!results.length) {
|
|
363
|
-
throw new Error("Empty output");
|
|
364
|
-
}
|
|
365
|
-
results.forEach((str) => {
|
|
366
|
-
console.log(str);
|
|
367
|
-
});
|
|
368
|
-
})
|
|
369
|
-
.catch((error) => {
|
|
370
|
-
console.error("Got an error", error);
|
|
371
|
-
process.exit(3);
|
|
372
|
-
});
|
|
373
|
-
}
|
package/prettier.config.js
DELETED
package/tsconfig.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"exclude": ["**/.*/", "examples/**", "autobahn/**", "node_modules/**", "dist/**", "*.def.ts"],
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"target": "es2020",
|
|
5
|
-
"typeRoots": ["./src/typings", "./node_modules/@nf-types"],
|
|
6
|
-
"noUncheckedIndexedAccess": true,
|
|
7
|
-
"strictBindCallApply": true,
|
|
8
|
-
"newLine": "LF",
|
|
9
|
-
"module": "es6",
|
|
10
|
-
"declaration": false,
|
|
11
|
-
"moduleResolution": "node",
|
|
12
|
-
"pretty": true,
|
|
13
|
-
"noImplicitAny": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"strictNullChecks": true,
|
|
16
|
-
"strictPropertyInitialization": true,
|
|
17
|
-
"downlevelIteration": true,
|
|
18
|
-
"strict": true,
|
|
19
|
-
"sourceMap": true,
|
|
20
|
-
"incremental": true,
|
|
21
|
-
"lib": ["es2019"],
|
|
22
|
-
"baseUrl": ".",
|
|
23
|
-
"paths": {
|
|
24
|
-
"~/*": ["src/*"]
|
|
25
|
-
},
|
|
26
|
-
"plugins": [{ "transform": "@zerollup/ts-transform-paths" }]
|
|
27
|
-
}
|
|
28
|
-
}
|
/package/{index.js → smipper}
RENAMED
|
File without changes
|