@kaspernj/api-maker 1.0.245 → 1.0.246

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 CHANGED
@@ -16,7 +16,7 @@
16
16
  ]
17
17
  },
18
18
  "name": "@kaspernj/api-maker",
19
- "version": "1.0.245",
19
+ "version": "1.0.246",
20
20
  "type": "module",
21
21
  "description": "",
22
22
  "main": "index.js",
@@ -3,7 +3,7 @@ import SourceMapsLoader from "./source-maps-loader.mjs"
3
3
 
4
4
  export default class ErrorLogger {
5
5
  constructor () {
6
- this.debug = true
6
+ this.debugging = true
7
7
  this.errorOccurred = false
8
8
  this.errors = []
9
9
  this.isHandlingError = false
@@ -11,12 +11,16 @@ if (SourceMapConsumer.initialize) {
11
11
 
12
12
  export default class SourceMapsLoader {
13
13
  constructor () {
14
- this.debug = false
14
+ this.debugging = false
15
15
  this.isLoadingSourceMaps = false
16
16
  this.sourceMaps = []
17
17
  this.srcLoaded = {}
18
18
  }
19
19
 
20
+ debug(messageCallback) {
21
+ if (this.debugging) console.log(`API maker / Source maps loader:`, messageCallback.call())
22
+ }
23
+
20
24
  loadSourceMapsForScriptTags (callback) {
21
25
  this.loadSourceMapsForScriptTagsCallback = callback
22
26
  }
@@ -25,15 +29,9 @@ export default class SourceMapsLoader {
25
29
  this.sourceMapForSourceCallback = callback
26
30
  }
27
31
 
28
- getSources(error) {
29
- let sources = this.getSourcesFromScripts()
30
-
31
- if (error) sources = sources.concat(this.getSourcesFromError(error))
32
-
33
- return uniqunize(sources, (source) => source.originalUrl)
34
- }
35
-
36
32
  async loadSourceMaps (error) {
33
+ if (!error) throw new Error("No error was given to SourceMapsLoader#loadSourceMaps")
34
+
37
35
  this.isLoadingSourceMaps = true
38
36
 
39
37
  try {
@@ -55,6 +53,14 @@ export default class SourceMapsLoader {
55
53
  }
56
54
  }
57
55
 
56
+ getSources(error) {
57
+ let sources = this.getSourcesFromScripts()
58
+
59
+ if (error) sources = sources.concat(this.getSourcesFromError(error))
60
+
61
+ return uniqunize(sources, (source) => source.originalUrl)
62
+ }
63
+
58
64
  getSourcesFromError(error) {
59
65
  const stack = stackTraceParser.parse(error.stack)
60
66
  const sources = []
@@ -65,7 +71,13 @@ export default class SourceMapsLoader {
65
71
  if (file != "\u003Canonymous>") {
66
72
  const sourceMapUrl = this.getMapURL({src: file})
67
73
 
68
- if (sourceMapUrl) sources.push({originalUrl: file, sourceMapUrl})
74
+ if (sourceMapUrl) {
75
+ this.debug(() => `Found source map from error: ${sourceMapUrl}`)
76
+
77
+ sources.push({originalUrl: file, sourceMapUrl})
78
+ } else {
79
+ this.debug(() => `Coudn't get source map from: ${file}`)
80
+ }
69
81
  }
70
82
  }
71
83
 
@@ -79,7 +91,10 @@ export default class SourceMapsLoader {
79
91
  for (const script of scripts) {
80
92
  const sourceMapUrl = this.getMapURL({script, src: script.src})
81
93
 
82
- if (sourceMapUrl) sources.push({originalUrl: script.src, sourceMapUrl})
94
+ if (sourceMapUrl) {
95
+ this.debug(() => `Found source map from script: ${sourceMapUrl}`)
96
+ sources.push({originalUrl: script.src, sourceMapUrl})
97
+ }
83
98
  }
84
99
 
85
100
  return sources