@kaspernj/api-maker 1.0.244 → 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 +1 -1
- package/src/compose.js +11 -0
- package/src/error-logger.mjs +1 -1
- package/src/source-maps-loader.mjs +26 -11
package/package.json
CHANGED
package/src/compose.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default function apiMakerCompose(wrappedComponentClass, ...funcs) {
|
|
2
|
+
if (!wrappedComponentClass) throw new Error("No 'wrappedComponentClass' given")
|
|
3
|
+
|
|
4
|
+
let currentComponentClass = wrappedComponentClass
|
|
5
|
+
|
|
6
|
+
for (const func of funcs) {
|
|
7
|
+
currentComponentClass = func(currentComponentClass)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return currentComponentClass
|
|
11
|
+
}
|
package/src/error-logger.mjs
CHANGED
|
@@ -11,12 +11,16 @@ if (SourceMapConsumer.initialize) {
|
|
|
11
11
|
|
|
12
12
|
export default class SourceMapsLoader {
|
|
13
13
|
constructor () {
|
|
14
|
-
this.
|
|
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)
|
|
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)
|
|
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
|