@kaspernj/api-maker 1.0.371 → 1.0.373
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/commands-pool.mjs +9 -2
- package/src/source-maps-loader.mjs +11 -12
package/package.json
CHANGED
package/src/commands-pool.mjs
CHANGED
|
@@ -53,6 +53,8 @@ export default class ApiMakerCommandsPool {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
addCommand(data) {
|
|
56
|
+
const stack = Error().stack
|
|
57
|
+
|
|
56
58
|
return new Promise((resolve, reject) => {
|
|
57
59
|
const id = this.currentId
|
|
58
60
|
this.currentId += 1
|
|
@@ -61,7 +63,7 @@ export default class ApiMakerCommandsPool {
|
|
|
61
63
|
const commandName = data.command
|
|
62
64
|
const collectionName = data.collectionName
|
|
63
65
|
|
|
64
|
-
this.pool[id] = {resolve, reject}
|
|
66
|
+
this.pool[id] = {resolve, reject, stack}
|
|
65
67
|
|
|
66
68
|
if (!this.poolData[commandType]) this.poolData[commandType] = {}
|
|
67
69
|
if (!this.poolData[commandType][collectionName]) this.poolData[commandType][collectionName] = {}
|
|
@@ -154,7 +156,12 @@ export default class ApiMakerCommandsPool {
|
|
|
154
156
|
if (responseType == "success") {
|
|
155
157
|
commandData.resolve(commandResponseData)
|
|
156
158
|
} else if (responseType == "error") {
|
|
157
|
-
|
|
159
|
+
const error = new CustomError("Command error", {response: commandResponseData})
|
|
160
|
+
|
|
161
|
+
error.stack += "\n"
|
|
162
|
+
error.stack += commandData.stack.split("\n").slice(1).join("\n")
|
|
163
|
+
|
|
164
|
+
commandData.reject(error)
|
|
158
165
|
} else if (responseType == "failed") {
|
|
159
166
|
this.handleFailedResponse(commandData, commandResponseData)
|
|
160
167
|
} else {
|
|
@@ -13,21 +13,21 @@ if (SourceMapConsumer.initialize) {
|
|
|
13
13
|
const logger = new Logger({name: "ApiMaker / SourceMapsLoader"})
|
|
14
14
|
|
|
15
15
|
export default class SourceMapsLoader {
|
|
16
|
-
constructor
|
|
16
|
+
constructor() {
|
|
17
17
|
this.isLoadingSourceMaps = false
|
|
18
18
|
this.sourceMaps = []
|
|
19
19
|
this.srcLoaded = {}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
loadSourceMapsForScriptTags
|
|
22
|
+
loadSourceMapsForScriptTags(callback) {
|
|
23
23
|
this.loadSourceMapsForScriptTagsCallback = callback
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
sourceMapForSource
|
|
26
|
+
sourceMapForSource(callback) {
|
|
27
27
|
this.sourceMapForSourceCallback = callback
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
async loadSourceMaps
|
|
30
|
+
async loadSourceMaps(error) {
|
|
31
31
|
if (!error) throw new Error("No error was given to SourceMapsLoader#loadSourceMaps")
|
|
32
32
|
|
|
33
33
|
this.isLoadingSourceMaps = true
|
|
@@ -111,11 +111,9 @@ export default class SourceMapsLoader {
|
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
includeMapURL(src)
|
|
115
|
-
return src.includes("/packs/")
|
|
116
|
-
}
|
|
114
|
+
includeMapURL = (src) => src.includes("/packs/")
|
|
117
115
|
|
|
118
|
-
async loadSourceMapForSource
|
|
116
|
+
async loadSourceMapForSource({originalUrl, sourceMapUrl}) {
|
|
119
117
|
const xhr = new XMLHttpRequest()
|
|
120
118
|
|
|
121
119
|
xhr.open("GET", sourceMapUrl, true)
|
|
@@ -127,26 +125,27 @@ export default class SourceMapsLoader {
|
|
|
127
125
|
this.sourceMaps.push({consumer, originalUrl})
|
|
128
126
|
}
|
|
129
127
|
|
|
130
|
-
loadUrl
|
|
128
|
+
loadUrl(url) {
|
|
131
129
|
const parser = document.createElement("a")
|
|
130
|
+
|
|
132
131
|
parser.href = url
|
|
133
132
|
|
|
134
133
|
return parser
|
|
135
134
|
}
|
|
136
135
|
|
|
137
|
-
loadXhr
|
|
136
|
+
loadXhr(xhr, postData) {
|
|
138
137
|
return new Promise((resolve) => {
|
|
139
138
|
xhr.onload = () => resolve()
|
|
140
139
|
xhr.send(postData)
|
|
141
140
|
})
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
parseStackTrace
|
|
143
|
+
parseStackTrace(stackTrace) {
|
|
145
144
|
return this.getStackTraceData(stackTrace)
|
|
146
145
|
.map((traceData) => `at ${traceData.methodName} (${traceData.fileString})`)
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
getStackTraceData
|
|
148
|
+
getStackTraceData(stackTrace) {
|
|
150
149
|
const stack = stackTraceParser.parse(stackTrace)
|
|
151
150
|
const newSourceMap = []
|
|
152
151
|
|