@callstack/repack-dev-server 5.0.0-rc.2 → 5.0.0-rc.4
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/createServer.d.ts +3 -2
- package/dist/createServer.js +110 -123
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/plugins/api/apiPlugin.d.ts +1 -1
- package/dist/plugins/api/apiPlugin.js +21 -28
- package/dist/plugins/api/index.d.ts +1 -1
- package/dist/plugins/api/index.js +1 -2
- package/dist/plugins/compiler/compilerPlugin.d.ts +1 -1
- package/dist/plugins/compiler/compilerPlugin.js +53 -62
- package/dist/plugins/compiler/index.d.ts +2 -2
- package/dist/plugins/compiler/index.js +2 -3
- package/dist/plugins/compiler/types.d.ts +1 -1
- package/dist/plugins/compiler/types.js +0 -1
- package/dist/plugins/devtools/devtoolsPlugin.d.ts +1 -1
- package/dist/plugins/devtools/devtoolsPlugin.js +16 -19
- package/dist/plugins/devtools/index.d.ts +1 -1
- package/dist/plugins/devtools/index.js +1 -2
- package/dist/plugins/favicon/faviconPlugin.js +3 -7
- package/dist/plugins/favicon/index.d.ts +1 -1
- package/dist/plugins/favicon/index.js +1 -2
- package/dist/plugins/multipart/index.d.ts +2 -2
- package/dist/plugins/multipart/index.js +2 -3
- package/dist/plugins/multipart/multipartPlugin.js +44 -42
- package/dist/plugins/multipart/types.js +0 -1
- package/dist/plugins/symbolicate/Symbolicator.d.ts +1 -1
- package/dist/plugins/symbolicate/Symbolicator.js +172 -190
- package/dist/plugins/symbolicate/index.d.ts +3 -3
- package/dist/plugins/symbolicate/index.js +3 -4
- package/dist/plugins/symbolicate/sybmolicatePlugin.d.ts +1 -1
- package/dist/plugins/symbolicate/sybmolicatePlugin.js +29 -40
- package/dist/plugins/symbolicate/types.js +0 -1
- package/dist/plugins/wss/WebSocketRouter.d.ts +1 -1
- package/dist/plugins/wss/WebSocketRouter.js +39 -44
- package/dist/plugins/wss/WebSocketServer.d.ts +1 -1
- package/dist/plugins/wss/WebSocketServer.js +23 -38
- package/dist/plugins/wss/WebSocketServerAdapter.d.ts +1 -1
- package/dist/plugins/wss/WebSocketServerAdapter.js +16 -19
- package/dist/plugins/wss/index.d.ts +3 -3
- package/dist/plugins/wss/index.js +3 -4
- package/dist/plugins/wss/servers/WebSocketApiServer.d.ts +1 -1
- package/dist/plugins/wss/servers/WebSocketApiServer.js +47 -53
- package/dist/plugins/wss/servers/WebSocketDevClientServer.d.ts +1 -1
- package/dist/plugins/wss/servers/WebSocketDevClientServer.js +58 -80
- package/dist/plugins/wss/servers/WebSocketEventsServer.d.ts +2 -2
- package/dist/plugins/wss/servers/WebSocketEventsServer.js +146 -164
- package/dist/plugins/wss/servers/WebSocketHMRServer.d.ts +2 -2
- package/dist/plugins/wss/servers/WebSocketHMRServer.js +72 -79
- package/dist/plugins/wss/servers/WebSocketMessageServer.d.ts +1 -1
- package/dist/plugins/wss/servers/WebSocketMessageServer.js +309 -326
- package/dist/plugins/wss/types.js +0 -1
- package/dist/plugins/wss/wssPlugin.d.ts +8 -8
- package/dist/plugins/wss/wssPlugin.js +37 -42
- package/dist/types.d.ts +6 -6
- package/dist/types.js +8 -18
- package/package.json +4 -8
- package/CHANGELOG.md +0 -160
- package/dist/createServer.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/plugins/api/apiPlugin.js.map +0 -1
- package/dist/plugins/api/index.js.map +0 -1
- package/dist/plugins/compiler/compilerPlugin.js.map +0 -1
- package/dist/plugins/compiler/index.js.map +0 -1
- package/dist/plugins/compiler/types.js.map +0 -1
- package/dist/plugins/devtools/devtoolsPlugin.js.map +0 -1
- package/dist/plugins/devtools/index.js.map +0 -1
- package/dist/plugins/favicon/faviconPlugin.js.map +0 -1
- package/dist/plugins/favicon/index.js.map +0 -1
- package/dist/plugins/multipart/index.js.map +0 -1
- package/dist/plugins/multipart/multipartPlugin.js.map +0 -1
- package/dist/plugins/multipart/types.js.map +0 -1
- package/dist/plugins/symbolicate/Symbolicator.js.map +0 -1
- package/dist/plugins/symbolicate/index.js.map +0 -1
- package/dist/plugins/symbolicate/sybmolicatePlugin.js.map +0 -1
- package/dist/plugins/symbolicate/types.js.map +0 -1
- package/dist/plugins/wss/WebSocketRouter.js.map +0 -1
- package/dist/plugins/wss/WebSocketServer.js.map +0 -1
- package/dist/plugins/wss/WebSocketServerAdapter.js.map +0 -1
- package/dist/plugins/wss/index.js.map +0 -1
- package/dist/plugins/wss/servers/WebSocketApiServer.js.map +0 -1
- package/dist/plugins/wss/servers/WebSocketDevClientServer.js.map +0 -1
- package/dist/plugins/wss/servers/WebSocketEventsServer.js.map +0 -1
- package/dist/plugins/wss/servers/WebSocketHMRServer.js.map +0 -1
- package/dist/plugins/wss/servers/WebSocketMessageServer.js.map +0 -1
- package/dist/plugins/wss/types.js.map +0 -1
- package/dist/plugins/wss/wssPlugin.js.map +0 -1
- package/dist/types.js.map +0 -1
- /package/{dist/img → static}/favicon.ico +0 -0
|
@@ -4,52 +4,54 @@ import fastifyPlugin from 'fastify-plugin';
|
|
|
4
4
|
* Implementation is based on:
|
|
5
5
|
* https://github.com/facebook/metro/blob/347b1d7ed87995d7951aaa9fd597c04b06013dac/packages/metro/src/Server/MultipartResponse.js
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
7
|
const CRLF = '\r\n';
|
|
9
8
|
const BOUNDARY = '3beqjf3apnqeu3h5jqorms4i';
|
|
10
9
|
async function multipartPlugin(instance) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
function asMultipart() {
|
|
11
|
+
// We should check if is included in accept or if accept has multipart/* or */*,
|
|
12
|
+
// but React Native will set accept to exactly `multipart/mixed`, so a simple check
|
|
13
|
+
// will suffice.
|
|
14
|
+
if (this.request.headers.accept !== 'multipart/mixed') {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
const headers = {};
|
|
18
|
+
const stream = new PassThrough();
|
|
19
|
+
this.code(200)
|
|
20
|
+
.header('Content-Type', `multipart/mixed; boundary="${BOUNDARY}"`)
|
|
21
|
+
.send(stream);
|
|
22
|
+
function serializeHeaders(headers) {
|
|
23
|
+
return Object.keys(headers)
|
|
24
|
+
.map((key) => `${key}: ${headers[key]}`)
|
|
25
|
+
.join(CRLF);
|
|
26
|
+
}
|
|
27
|
+
function writeChunk(headers, data, isLast) {
|
|
28
|
+
let chunk = `${CRLF}--${BOUNDARY}${CRLF}`;
|
|
29
|
+
if (headers) {
|
|
30
|
+
chunk += serializeHeaders(headers) + CRLF + CRLF;
|
|
31
|
+
}
|
|
32
|
+
if (data) {
|
|
33
|
+
chunk += data;
|
|
34
|
+
}
|
|
35
|
+
if (isLast) {
|
|
36
|
+
chunk += `${CRLF}--${BOUNDARY}--${CRLF}`;
|
|
37
|
+
}
|
|
38
|
+
stream.write(chunk);
|
|
39
|
+
}
|
|
40
|
+
function setHeader(name, value) {
|
|
41
|
+
headers[name] = value;
|
|
42
|
+
}
|
|
43
|
+
function end(data) {
|
|
44
|
+
writeChunk(headers, data, true);
|
|
45
|
+
stream.end();
|
|
46
|
+
}
|
|
47
|
+
return {
|
|
48
|
+
writeChunk,
|
|
49
|
+
setHeader,
|
|
50
|
+
end,
|
|
51
|
+
};
|
|
17
52
|
}
|
|
18
|
-
|
|
19
|
-
const stream = new PassThrough();
|
|
20
|
-
this.code(200).header('Content-Type', `multipart/mixed; boundary="${BOUNDARY}"`).send(stream);
|
|
21
|
-
function serializeHeaders(headers) {
|
|
22
|
-
return Object.keys(headers).map(key => `${key}: ${headers[key]}`).join(CRLF);
|
|
23
|
-
}
|
|
24
|
-
function writeChunk(headers, data, isLast) {
|
|
25
|
-
let chunk = `${CRLF}--${BOUNDARY}${CRLF}`;
|
|
26
|
-
if (headers) {
|
|
27
|
-
chunk += serializeHeaders(headers) + CRLF + CRLF;
|
|
28
|
-
}
|
|
29
|
-
if (data) {
|
|
30
|
-
chunk += data;
|
|
31
|
-
}
|
|
32
|
-
if (isLast) {
|
|
33
|
-
chunk += `${CRLF}--${BOUNDARY}--${CRLF}`;
|
|
34
|
-
}
|
|
35
|
-
stream.write(chunk);
|
|
36
|
-
}
|
|
37
|
-
function setHeader(name, value) {
|
|
38
|
-
headers[name] = value;
|
|
39
|
-
}
|
|
40
|
-
function end(data) {
|
|
41
|
-
writeChunk(headers, data, true);
|
|
42
|
-
stream.end();
|
|
43
|
-
}
|
|
44
|
-
return {
|
|
45
|
-
writeChunk,
|
|
46
|
-
setHeader,
|
|
47
|
-
end
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
instance.decorateReply('asMultipart', asMultipart);
|
|
53
|
+
instance.decorateReply('asMultipart', asMultipart);
|
|
51
54
|
}
|
|
52
55
|
export default fastifyPlugin(multipartPlugin, {
|
|
53
|
-
|
|
56
|
+
name: 'multipart-plugin',
|
|
54
57
|
});
|
|
55
|
-
//# sourceMappingURL=multipartPlugin.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { FastifyLoggerInstance } from 'fastify';
|
|
2
2
|
import { SourceMapConsumer } from 'source-map';
|
|
3
|
-
import type { ReactNativeStackFrame, SymbolicatorDelegate, SymbolicatorResults } from './types';
|
|
3
|
+
import type { ReactNativeStackFrame, SymbolicatorDelegate, SymbolicatorResults } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Class for transforming stack traces from React Native application with using Source Map.
|
|
6
6
|
* Raw stack frames produced by React Native, points to some location from the bundle
|
|
@@ -8,201 +8,183 @@ import { SourceMapConsumer } from 'source-map';
|
|
|
8
8
|
* produces frames that point to source code inside your project eg `Hello.tsx:10:9`.
|
|
9
9
|
*/
|
|
10
10
|
export class Symbolicator {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (extension) {
|
|
35
|
-
return platformOrExtension;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Cache with initialized `SourceMapConsumer` to improve symbolication performance.
|
|
42
|
-
*/
|
|
43
|
-
sourceMapConsumerCache = {};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Constructs new `Symbolicator` instance.
|
|
47
|
-
*
|
|
48
|
-
* @param delegate Delegate instance with symbolication functions.
|
|
49
|
-
*/
|
|
50
|
-
constructor(delegate) {
|
|
51
|
-
this.delegate = delegate;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Process raw React Native stack frames and transform them using Source Maps.
|
|
56
|
-
* Method will try to symbolicate as much data as possible, but if the Source Maps
|
|
57
|
-
* are not available, invalid or the original positions/data is not found in Source Maps,
|
|
58
|
-
* the method will return raw values - the same as supplied with `stack` parameter.
|
|
59
|
-
* For example out of 10 frames, it's possible that only first 7 will be symbolicated and the
|
|
60
|
-
* remaining 3 will be unchanged.
|
|
61
|
-
*
|
|
62
|
-
* @param logger Fastify logger instance.
|
|
63
|
-
* @param stack Raw stack frames.
|
|
64
|
-
* @returns Symbolicated stack frames.
|
|
65
|
-
*/
|
|
66
|
-
async process(logger, stack) {
|
|
67
|
-
logger.debug({
|
|
68
|
-
msg: 'Filtering out unnecessary frames'
|
|
69
|
-
});
|
|
70
|
-
const frames = [];
|
|
71
|
-
for (const frame of stack) {
|
|
72
|
-
const {
|
|
73
|
-
file
|
|
74
|
-
} = frame;
|
|
75
|
-
if (file?.startsWith('http')) {
|
|
76
|
-
frames.push(frame);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
try {
|
|
80
|
-
logger.debug({
|
|
81
|
-
msg: 'Processing frames',
|
|
82
|
-
frames
|
|
83
|
-
});
|
|
84
|
-
const processedFrames = [];
|
|
85
|
-
for (const frame of frames) {
|
|
86
|
-
if (!this.sourceMapConsumerCache[frame.file]) {
|
|
87
|
-
logger.debug({
|
|
88
|
-
msg: 'Loading raw source map data',
|
|
89
|
-
fileUrl: frame.file
|
|
90
|
-
});
|
|
91
|
-
const rawSourceMap = await this.delegate.getSourceMap(frame.file);
|
|
92
|
-
logger.debug({
|
|
93
|
-
msg: 'Creating source map instance',
|
|
94
|
-
fileUrl: frame.file,
|
|
95
|
-
sourceMapLength: rawSourceMap.length
|
|
96
|
-
});
|
|
97
|
-
const sourceMapConsumer = await new SourceMapConsumer(rawSourceMap.toString());
|
|
98
|
-
logger.debug({
|
|
99
|
-
msg: 'Saving source map instance into cache',
|
|
100
|
-
fileUrl: frame.file
|
|
101
|
-
});
|
|
102
|
-
this.sourceMapConsumerCache[frame.file] = sourceMapConsumer;
|
|
11
|
+
/**
|
|
12
|
+
* Infer platform from stack frames.
|
|
13
|
+
* Usually at least one frame has `file` field with the bundle URL eg:
|
|
14
|
+
* `http://localhost:8081/index.bundle?platform=ios&...`, which can be used to infer platform.
|
|
15
|
+
*
|
|
16
|
+
* @param stack Array of stack frames.
|
|
17
|
+
* @returns Inferred platform or `undefined` if cannot infer.
|
|
18
|
+
*/
|
|
19
|
+
static inferPlatformFromStack(stack) {
|
|
20
|
+
for (const frame of stack) {
|
|
21
|
+
if (!frame.file) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const { searchParams, pathname } = new URL(frame.file, 'file://');
|
|
25
|
+
const platform = searchParams.get('platform');
|
|
26
|
+
if (platform) {
|
|
27
|
+
return platform;
|
|
28
|
+
}
|
|
29
|
+
const [bundleFilename] = pathname.split('/').reverse();
|
|
30
|
+
const [, platformOrExtension, extension] = bundleFilename.split('.');
|
|
31
|
+
if (extension) {
|
|
32
|
+
return platformOrExtension;
|
|
33
|
+
}
|
|
103
34
|
}
|
|
104
|
-
logger.debug({
|
|
105
|
-
msg: 'Symbolicating frame',
|
|
106
|
-
frame
|
|
107
|
-
});
|
|
108
|
-
const processedFrame = this.processFrame(frame);
|
|
109
|
-
logger.debug({
|
|
110
|
-
msg: 'Finished symbolicating frame',
|
|
111
|
-
frame
|
|
112
|
-
});
|
|
113
|
-
processedFrames.push(processedFrame);
|
|
114
|
-
}
|
|
115
|
-
const codeFrame = (await this.getCodeFrame(logger, processedFrames)) ?? null;
|
|
116
|
-
logger.debug({
|
|
117
|
-
msg: 'Finished symbolicating frames',
|
|
118
|
-
processedFrames,
|
|
119
|
-
codeFrame
|
|
120
|
-
});
|
|
121
|
-
return {
|
|
122
|
-
stack: processedFrames,
|
|
123
|
-
codeFrame
|
|
124
|
-
};
|
|
125
|
-
} finally {
|
|
126
|
-
for (const key in this.sourceMapConsumerCache) {
|
|
127
|
-
this.sourceMapConsumerCache[key].destroy();
|
|
128
|
-
delete this.sourceMapConsumerCache[key];
|
|
129
|
-
}
|
|
130
35
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Constructs new `Symbolicator` instance.
|
|
38
|
+
*
|
|
39
|
+
* @param delegate Delegate instance with symbolication functions.
|
|
40
|
+
*/
|
|
41
|
+
constructor(delegate) {
|
|
42
|
+
this.delegate = delegate;
|
|
43
|
+
/**
|
|
44
|
+
* Cache with initialized `SourceMapConsumer` to improve symbolication performance.
|
|
45
|
+
*/
|
|
46
|
+
this.sourceMapConsumerCache = {};
|
|
138
47
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Process raw React Native stack frames and transform them using Source Maps.
|
|
50
|
+
* Method will try to symbolicate as much data as possible, but if the Source Maps
|
|
51
|
+
* are not available, invalid or the original positions/data is not found in Source Maps,
|
|
52
|
+
* the method will return raw values - the same as supplied with `stack` parameter.
|
|
53
|
+
* For example out of 10 frames, it's possible that only first 7 will be symbolicated and the
|
|
54
|
+
* remaining 3 will be unchanged.
|
|
55
|
+
*
|
|
56
|
+
* @param logger Fastify logger instance.
|
|
57
|
+
* @param stack Raw stack frames.
|
|
58
|
+
* @returns Symbolicated stack frames.
|
|
59
|
+
*/
|
|
60
|
+
async process(logger, stack) {
|
|
61
|
+
logger.debug({ msg: 'Filtering out unnecessary frames' });
|
|
62
|
+
const frames = [];
|
|
63
|
+
for (const frame of stack) {
|
|
64
|
+
const { file } = frame;
|
|
65
|
+
if (file?.startsWith('http')) {
|
|
66
|
+
frames.push(frame);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
logger.debug({ msg: 'Processing frames', frames });
|
|
71
|
+
const processedFrames = [];
|
|
72
|
+
for (const frame of frames) {
|
|
73
|
+
if (!this.sourceMapConsumerCache[frame.file]) {
|
|
74
|
+
logger.debug({
|
|
75
|
+
msg: 'Loading raw source map data',
|
|
76
|
+
fileUrl: frame.file,
|
|
77
|
+
});
|
|
78
|
+
const rawSourceMap = await this.delegate.getSourceMap(frame.file);
|
|
79
|
+
logger.debug({
|
|
80
|
+
msg: 'Creating source map instance',
|
|
81
|
+
fileUrl: frame.file,
|
|
82
|
+
sourceMapLength: rawSourceMap.length,
|
|
83
|
+
});
|
|
84
|
+
const sourceMapConsumer = await new SourceMapConsumer(rawSourceMap.toString());
|
|
85
|
+
logger.debug({
|
|
86
|
+
msg: 'Saving source map instance into cache',
|
|
87
|
+
fileUrl: frame.file,
|
|
88
|
+
});
|
|
89
|
+
this.sourceMapConsumerCache[frame.file] = sourceMapConsumer;
|
|
90
|
+
}
|
|
91
|
+
logger.debug({
|
|
92
|
+
msg: 'Symbolicating frame',
|
|
93
|
+
frame,
|
|
94
|
+
});
|
|
95
|
+
const processedFrame = this.processFrame(frame);
|
|
96
|
+
logger.debug({
|
|
97
|
+
msg: 'Finished symbolicating frame',
|
|
98
|
+
frame,
|
|
99
|
+
});
|
|
100
|
+
processedFrames.push(processedFrame);
|
|
101
|
+
}
|
|
102
|
+
const codeFrame = (await this.getCodeFrame(logger, processedFrames)) ?? null;
|
|
103
|
+
logger.debug({
|
|
104
|
+
msg: 'Finished symbolicating frames',
|
|
105
|
+
processedFrames,
|
|
106
|
+
codeFrame,
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
stack: processedFrames,
|
|
110
|
+
codeFrame,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
finally {
|
|
114
|
+
for (const key in this.sourceMapConsumerCache) {
|
|
115
|
+
this.sourceMapConsumerCache[key].destroy();
|
|
116
|
+
delete this.sourceMapConsumerCache[key];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
161
119
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
120
|
+
processFrame(frame) {
|
|
121
|
+
if (!frame.lineNumber || !frame.column) {
|
|
122
|
+
return {
|
|
123
|
+
...frame,
|
|
124
|
+
collapse: false,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const consumer = this.sourceMapConsumerCache[frame.file];
|
|
128
|
+
if (!consumer) {
|
|
129
|
+
return {
|
|
130
|
+
...frame,
|
|
131
|
+
collapse: false,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const lookup = consumer.originalPositionFor({
|
|
135
|
+
line: frame.lineNumber,
|
|
136
|
+
column: frame.column,
|
|
137
|
+
bias: SourceMapConsumer.LEAST_UPPER_BOUND,
|
|
138
|
+
});
|
|
139
|
+
// If lookup fails, we get the same shape object, but with
|
|
140
|
+
// all values set to null
|
|
141
|
+
if (!lookup.source) {
|
|
142
|
+
// It is better to gracefully return the original frame
|
|
143
|
+
// than to throw an exception
|
|
144
|
+
return {
|
|
145
|
+
...frame,
|
|
146
|
+
collapse: false,
|
|
147
|
+
};
|
|
148
|
+
}
|
|
183
149
|
return {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}, {
|
|
190
|
-
forceColor: true
|
|
191
|
-
}),
|
|
192
|
-
location: {
|
|
193
|
-
row: frame.lineNumber,
|
|
194
|
-
column: frame.column
|
|
195
|
-
},
|
|
196
|
-
fileName: frame.file
|
|
150
|
+
lineNumber: lookup.line || frame.lineNumber,
|
|
151
|
+
column: lookup.column || frame.column,
|
|
152
|
+
file: lookup.source,
|
|
153
|
+
methodName: lookup.name || frame.methodName,
|
|
154
|
+
collapse: false,
|
|
197
155
|
};
|
|
198
|
-
} catch (error) {
|
|
199
|
-
logger.error({
|
|
200
|
-
msg: 'Failed to create code frame',
|
|
201
|
-
error: error.message
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
return undefined;
|
|
205
156
|
}
|
|
206
|
-
|
|
157
|
+
async getCodeFrame(logger, processedFrames) {
|
|
158
|
+
for (const frame of processedFrames) {
|
|
159
|
+
if (frame.collapse || !frame.lineNumber || !frame.column) {
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (!this.delegate.shouldIncludeFrame(frame)) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
logger.debug({
|
|
166
|
+
msg: 'Generating code frame',
|
|
167
|
+
frame,
|
|
168
|
+
});
|
|
169
|
+
try {
|
|
170
|
+
return {
|
|
171
|
+
content: codeFrameColumns((await this.delegate.getSource(frame.file)).toString(), {
|
|
172
|
+
start: { column: frame.column, line: frame.lineNumber },
|
|
173
|
+
}, { forceColor: true }),
|
|
174
|
+
location: {
|
|
175
|
+
row: frame.lineNumber,
|
|
176
|
+
column: frame.column,
|
|
177
|
+
},
|
|
178
|
+
fileName: frame.file,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
logger.error({
|
|
183
|
+
msg: 'Failed to create code frame',
|
|
184
|
+
error: error.message,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
207
190
|
}
|
|
208
|
-
//# sourceMappingURL=Symbolicator.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './sybmolicatePlugin';
|
|
2
|
-
export * from './Symbolicator';
|
|
3
|
-
export * from './types';
|
|
1
|
+
export { default } from './sybmolicatePlugin.js';
|
|
2
|
+
export * from './Symbolicator.js';
|
|
3
|
+
export * from './types.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { default } from './sybmolicatePlugin.js';
|
|
2
|
+
export * from './Symbolicator.js';
|
|
3
|
+
export * from './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
import type { Server } from '../../types';
|
|
2
|
+
import type { Server } from '../../types.js';
|
|
3
3
|
declare function symbolicatePlugin(instance: FastifyInstance, { delegate, }: {
|
|
4
4
|
delegate: Server.Delegate;
|
|
5
5
|
}): Promise<void>;
|
|
@@ -1,44 +1,33 @@
|
|
|
1
1
|
import fastifyPlugin from 'fastify-plugin';
|
|
2
|
-
import { Symbolicator } from
|
|
3
|
-
async function symbolicatePlugin(instance, {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
reply.send(results);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
request.log.error({
|
|
33
|
-
msg: 'Failed to symbolicate',
|
|
34
|
-
error: error.message
|
|
35
|
-
});
|
|
36
|
-
reply.internalServerError();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
2
|
+
import { Symbolicator } from './Symbolicator.js';
|
|
3
|
+
async function symbolicatePlugin(instance, { delegate, }) {
|
|
4
|
+
const symbolicator = new Symbolicator(delegate.symbolicator);
|
|
5
|
+
instance.post('/symbolicate', async (request, reply) => {
|
|
6
|
+
// React Native sends stack as JSON but tests content-type to text/plain, so
|
|
7
|
+
// we cannot use JSON schema to validate the body.
|
|
8
|
+
try {
|
|
9
|
+
const { stack } = JSON.parse(request.body);
|
|
10
|
+
const platform = Symbolicator.inferPlatformFromStack(stack);
|
|
11
|
+
if (!platform) {
|
|
12
|
+
request.log.debug({ msg: 'Received stack', stack });
|
|
13
|
+
reply.badRequest('Cannot infer platform from stack trace');
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
request.log.debug({ msg: 'Starting symbolication', platform, stack });
|
|
17
|
+
const results = await symbolicator.process(request.log, stack);
|
|
18
|
+
reply.send(results);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
request.log.error({
|
|
23
|
+
msg: 'Failed to symbolicate',
|
|
24
|
+
error: error.message,
|
|
25
|
+
});
|
|
26
|
+
reply.internalServerError();
|
|
27
|
+
}
|
|
28
|
+
});
|
|
39
29
|
}
|
|
40
30
|
export default fastifyPlugin(symbolicatePlugin, {
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
name: 'symbolicate-plugin',
|
|
32
|
+
dependencies: ['@fastify/sensible'],
|
|
43
33
|
});
|
|
44
|
-
//# sourceMappingURL=sybmolicatePlugin.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
import type { WebSocketServerInterface } from './types';
|
|
2
|
+
import type { WebSocketServerInterface } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Class for creating a WebSocket router to forward connections to the
|
|
5
5
|
* respective {@link WebSocketServer} as long as the connection is accepted for the upgrade by the
|