@callstack/repack-dev-server 5.0.1 → 5.0.3
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.js +17 -1
- package/dist/plugins/devtools/devtoolsPlugin.d.ts +1 -3
- package/dist/plugins/devtools/devtoolsPlugin.js +33 -6
- package/dist/plugins/wss/servers/WebSocketMessageServer.d.ts +1 -1
- package/dist/utils/devMiddlewareLogger.d.ts +1 -0
- package/dist/utils/devMiddlewareLogger.js +1 -0
- package/package.json +8 -18
package/dist/createServer.js
CHANGED
|
@@ -60,10 +60,26 @@ export async function createServer(config) {
|
|
|
60
60
|
instance.wss.messageServer.broadcast(method, params);
|
|
61
61
|
},
|
|
62
62
|
});
|
|
63
|
+
let handledDevMiddlewareNotice = false;
|
|
63
64
|
const devMiddleware = createDevMiddleware({
|
|
64
65
|
projectRoot: options.rootDir,
|
|
65
66
|
serverBaseUrl: options.url,
|
|
66
|
-
logger:
|
|
67
|
+
logger: {
|
|
68
|
+
error: instance.log.error,
|
|
69
|
+
warn: instance.log.warn,
|
|
70
|
+
info: (...message) => {
|
|
71
|
+
if (!handledDevMiddlewareNotice) {
|
|
72
|
+
if (message.join().includes('JavaScript logs have moved!')) {
|
|
73
|
+
handledDevMiddlewareNotice = true;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
instance.log.info(message);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
},
|
|
67
83
|
unstable_experiments: {
|
|
68
84
|
// @ts-expect-error removed in 0.76, keep this for backkwards compatibility
|
|
69
85
|
enableNewDebugger: true,
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify';
|
|
2
|
-
declare function devtoolsPlugin(instance: FastifyInstance
|
|
3
|
-
rootDir: string;
|
|
4
|
-
}): Promise<void>;
|
|
2
|
+
declare function devtoolsPlugin(instance: FastifyInstance): Promise<void>;
|
|
5
3
|
declare const _default: typeof devtoolsPlugin;
|
|
6
4
|
export default _default;
|
|
@@ -1,10 +1,37 @@
|
|
|
1
|
-
import { openStackFrameInEditorMiddleware, openURLMiddleware, } from '@react-native-community/cli-server-api';
|
|
2
1
|
import fastifyPlugin from 'fastify-plugin';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import launchEditor from 'launch-editor';
|
|
3
|
+
import open from 'open';
|
|
4
|
+
function parseRequestBody(body) {
|
|
5
|
+
if (typeof body === 'object')
|
|
6
|
+
return body;
|
|
7
|
+
if (typeof body === 'string')
|
|
8
|
+
return JSON.parse(body);
|
|
9
|
+
throw new Error(`Unsupported body type: ${typeof body}`);
|
|
10
|
+
}
|
|
11
|
+
async function devtoolsPlugin(instance) {
|
|
12
|
+
// reference implementation in `@react-native-community/cli-server-api`:
|
|
13
|
+
// https://github.com/react-native-community/cli/blob/46436a12478464752999d34ed86adf3212348007/packages/cli-server-api/src/openURLMiddleware.ts
|
|
14
|
+
instance.route({
|
|
15
|
+
method: ['POST'],
|
|
16
|
+
url: '/open-url',
|
|
17
|
+
handler: async (request, reply) => {
|
|
18
|
+
const { url } = parseRequestBody(request.body);
|
|
19
|
+
await open(url);
|
|
20
|
+
reply.send('OK');
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
// reference implementation in `@react-native-community/cli-server-api`:
|
|
24
|
+
// https://github.com/react-native-community/cli/blob/46436a12478464752999d34ed86adf3212348007/packages/cli-server-api/src/openStackFrameMiddleware.ts
|
|
25
|
+
instance.route({
|
|
26
|
+
method: ['POST'],
|
|
27
|
+
url: '/open-stack-frame',
|
|
28
|
+
handler: async (request, reply) => {
|
|
29
|
+
const { file, lineNumber } = parseRequestBody(request.body);
|
|
30
|
+
// TODO fix rewriting of `webpack://` to rootDir of the project
|
|
31
|
+
launchEditor(`${file}:${lineNumber}`, process.env.REACT_EDITOR);
|
|
32
|
+
reply.send('OK');
|
|
33
|
+
},
|
|
34
|
+
});
|
|
8
35
|
instance.route({
|
|
9
36
|
method: ['GET', 'POST', 'PUT'],
|
|
10
37
|
url: '/reload',
|
|
@@ -76,7 +76,7 @@ export declare class WebSocketMessageServer extends WebSocketServer {
|
|
|
76
76
|
* @param clientId Id of the client.
|
|
77
77
|
* @returns WebSocket connection.
|
|
78
78
|
*/
|
|
79
|
-
getClientSocket(clientId: string): WebSocket
|
|
79
|
+
getClientSocket(clientId: string): WebSocket;
|
|
80
80
|
/**
|
|
81
81
|
* Process error by sending an error message to the client whose message caused the error
|
|
82
82
|
* to occur.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@callstack/repack-dev-server",
|
|
3
3
|
"description": "A bundler-agnostic development server for React Native applications as part of @callstack/repack.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "5.0.
|
|
5
|
+
"version": "5.0.3",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
@@ -32,35 +32,25 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/code-frame": "^7.
|
|
35
|
+
"@babel/code-frame": "^7.26.2",
|
|
36
36
|
"@fastify/middie": "^8.3.0",
|
|
37
37
|
"@fastify/sensible": "^5.5.0",
|
|
38
|
-
"@react-native/dev-middleware": "^0.
|
|
38
|
+
"@react-native/dev-middleware": "^0.78.0",
|
|
39
39
|
"fastify": "^4.24.3",
|
|
40
40
|
"fastify-favicon": "^4.3.0",
|
|
41
41
|
"fastify-plugin": "^4.5.1",
|
|
42
|
+
"launch-editor": "^2.10.0",
|
|
43
|
+
"open": "^10.1.0",
|
|
42
44
|
"pretty-format": "^28.1.0",
|
|
43
45
|
"source-map": "^0.7.4",
|
|
44
|
-
"ws": "^8.
|
|
46
|
+
"ws": "^8.18.1"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"@
|
|
48
|
-
"@babel/core": "^7.23.9",
|
|
49
|
-
"@react-native-community/cli-server-api": "15.0.1",
|
|
50
|
-
"@types/babel__code-frame": "^7.0.3",
|
|
49
|
+
"@types/babel__code-frame": "^7.0.6",
|
|
51
50
|
"@types/node": "^18",
|
|
52
|
-
"@types/ws": "^8.
|
|
53
|
-
"babel-plugin-add-import-extension": "^1.6.0",
|
|
51
|
+
"@types/ws": "^8.18.0",
|
|
54
52
|
"typescript": "^5.7.2"
|
|
55
53
|
},
|
|
56
|
-
"peerDependencies": {
|
|
57
|
-
"@react-native-community/cli-server-api": ">=13.6.4"
|
|
58
|
-
},
|
|
59
|
-
"peerDependenciesMeta": {
|
|
60
|
-
"@react-native-community/cli-server-api": {
|
|
61
|
-
"optional": true
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
54
|
"scripts": {
|
|
65
55
|
"build": "tsc -b",
|
|
66
56
|
"typecheck": "tsc --noEmit",
|