smipper 34.0.0 → 36.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/loadUri.js CHANGED
@@ -8,6 +8,9 @@ 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
+ }
11
14
  return new Promise((resolve, reject) => {
12
15
  smipper.verbose("loading", path);
13
16
  if (!(path in smipper.sourceMaps)) {
@@ -19,25 +22,20 @@ function loadUri(smipper, path) {
19
22
  .then((jsData) => {
20
23
  const idx = jsData.lastIndexOf("//# sourceMappingURL=");
21
24
  smipper.verbose("Got the file", jsData.length, idx);
22
- if (idx === -1) {
25
+ if (idx == -1) {
23
26
  return path + ".map";
24
27
  }
25
- const mapUrl = jsData.substring(idx + 21).trim();
28
+ const mapUrl = jsData.substring(idx + 21);
26
29
  const match = /^(data:.+\/.+;)base64,/.exec(mapUrl);
27
30
  if (match) {
28
31
  (0, assert_1.default)(match[1] !== undefined);
29
32
  return mapUrl.substring(match[1].length);
30
33
  }
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);
34
+ if (mapUrl.indexOf("://") != -1) {
39
35
  return mapUrl;
40
36
  }
37
+ // console.log(mapUrl);
38
+ return new URL(mapUrl, path).href;
41
39
  })
42
40
  .then((mapUrl) => {
43
41
  // console.log(mapUrl.substring(0, 20));
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.processFrame = void 0;
4
7
  const loadUri_1 = require("./loadUri");
5
8
  const buildStackLine_1 = require("./buildStackLine");
9
+ const fs_1 = __importDefault(require("fs"));
6
10
  function processFrame(smipper, functionName, url, line, column) {
7
11
  smipper.verbose("got frame", functionName, url, line, column);
8
12
  if (functionName.endsWith("@")) {
@@ -11,6 +15,9 @@ function processFrame(smipper, functionName, url, line, column) {
11
15
  return new Promise((resolve) => {
12
16
  let newUrl, newLine, newColumn;
13
17
  smipper.verbose("calling loadUri", url);
18
+ if (!url.includes("://") && url[0] !== "/" && fs_1.default.existsSync(url)) {
19
+ url = `file://${process.cwd()}/${url}`;
20
+ }
14
21
  return (0, loadUri_1.loadUri)(smipper, url)
15
22
  .then((smap) => {
16
23
  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 = path_1.default.join(dir, file);
13
+ file = 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,18 +25,13 @@ function findFile(dir, fn) {
25
25
  return undefined;
26
26
  }
27
27
  function rewriteLocalControl(smipper, url) {
28
- let file;
29
- if (url.startsWith("http://")) {
30
- file = url.substring(7);
28
+ let file = path_1.default.basename(url.substring(6));
29
+ const q = file.indexOf("?");
30
+ if (q !== -1) {
31
+ file = file.substring(0, q);
31
32
  }
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));
39
- smipper.verbose("Rewriting", url, "in", process.cwd(), "=>", found);
33
+ const found = findFile(process.cwd(), file);
34
+ smipper.verbose(`Rewriting ${url} in ${process.cwd()} (${file}) => ${found}`);
40
35
  if (found) {
41
36
  return found;
42
37
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "smipper",
3
- "version": "34.0.0",
3
+ "version": "36.0.0",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "bin": {
7
- "smipper": "./dist/index.js"
7
+ "smipper": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist"