@react-native/dev-middleware 0.74.0-nightly-20231107-bc68794c6 → 0.74.0-nightly-20231108-05d92bf2a

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.
@@ -44,6 +44,7 @@ declare class Device {
44
44
  _scriptIdToSourcePathMapping: Map<string, string>;
45
45
  _projectRoot: string;
46
46
  _deviceEventReporter: null | undefined | DeviceEventReporter;
47
+ _pagesPollingIntervalId: ReturnType<typeof setInterval>;
47
48
  constructor(
48
49
  id: string,
49
50
  name: string,
@@ -63,7 +64,6 @@ declare class Device {
63
64
  handleDuplicateDeviceConnection(newDevice: Device): void;
64
65
  _handleMessageFromDevice(message: MessageFromDevice): void;
65
66
  _sendMessageToDevice(message: MessageToDevice): void;
66
- _setPagesPolling(): void;
67
67
  _newReactNativePage(page: Page): void;
68
68
  _processMessageFromDevice(
69
69
  payload: { method: string; params: { sourceMapURL: string; url: string } },
@@ -142,6 +142,14 @@ class Device {
142
142
  }
143
143
  this._handleMessageFromDevice(parsedMessage);
144
144
  });
145
+ // Sends 'getPages' request to device every PAGES_POLLING_INTERVAL milliseconds.
146
+ this._pagesPollingIntervalId = setInterval(
147
+ () =>
148
+ this._sendMessageToDevice({
149
+ event: "getPages",
150
+ }),
151
+ PAGES_POLLING_INTERVAL
152
+ );
145
153
  this._deviceSocket.on("close", () => {
146
154
  this._deviceEventReporter?.logDisconnection("device");
147
155
  // Device disconnected - close debugger connection.
@@ -149,8 +157,8 @@ class Device {
149
157
  this._debuggerConnection.socket.close();
150
158
  this._debuggerConnection = null;
151
159
  }
160
+ clearInterval(this._pagesPollingIntervalId);
152
161
  });
153
- this._setPagesPolling();
154
162
  }
155
163
  getName() {
156
164
  return this._name;
@@ -371,17 +379,6 @@ class Device {
371
379
  } catch (error) {}
372
380
  }
373
381
 
374
- // Sends 'getPages' request to device every PAGES_POLLING_INTERVAL milliseconds.
375
- _setPagesPolling() {
376
- setInterval(
377
- () =>
378
- this._sendMessageToDevice({
379
- event: "getPages",
380
- }),
381
- PAGES_POLLING_INTERVAL
382
- );
383
- }
384
-
385
382
  // We received new React Native Page ID.
386
383
  _newReactNativePage(page) {
387
384
  debug(`React Native page updated to ${page.id}`);
@@ -686,6 +683,9 @@ class Device {
686
683
 
687
684
  // $FlowFixMe[incompatible-call] Suppress arvr node-fetch flow error
688
685
  const response = await (0, _nodeFetch.default)(url);
686
+ if (!response.ok) {
687
+ throw new Error("HTTP " + response.status + " " + response.statusText);
688
+ }
689
689
  const text = await response.text();
690
690
  // Restrict the length to well below the 500MB limit for nodejs (leaving
691
691
  // room some some later manipulation, e.g. base64 or wrapping in JSON)
@@ -50,6 +50,7 @@ declare export default class Device {
50
50
  _scriptIdToSourcePathMapping: Map<string, string>;
51
51
  _projectRoot: string;
52
52
  _deviceEventReporter: ?DeviceEventReporter;
53
+ _pagesPollingIntervalId: ReturnType<typeof setInterval>;
53
54
  constructor(
54
55
  id: string,
55
56
  name: string,
@@ -71,7 +72,6 @@ declare export default class Device {
71
72
  handleDuplicateDeviceConnection(newDevice: Device): void;
72
73
  _handleMessageFromDevice(message: MessageFromDevice): void;
73
74
  _sendMessageToDevice(message: MessageToDevice): void;
74
- _setPagesPolling(): void;
75
75
  _newReactNativePage(page: Page): void;
76
76
  _processMessageFromDevice(
77
77
  payload: { method: string, params: { sourceMapURL: string, url: string } },
@@ -90,3 +90,10 @@ export type ErrorResponse = Readonly<{ error: Readonly<{ message: string }> }>;
90
90
  export type DebuggerRequest =
91
91
  | SetBreakpointByUrlRequest
92
92
  | GetScriptSourceRequest;
93
+ export type JSONSerializable =
94
+ | boolean
95
+ | number
96
+ | string
97
+ | null
98
+ | ReadonlyArray<JSONSerializable>
99
+ | { readonly [$$Key$$: string]: JSONSerializable };
@@ -132,3 +132,11 @@ export type ErrorResponse = $ReadOnly<{
132
132
  export type DebuggerRequest =
133
133
  | SetBreakpointByUrlRequest
134
134
  | GetScriptSourceRequest;
135
+
136
+ export type JSONSerializable =
137
+ | boolean
138
+ | number
139
+ | string
140
+ | null
141
+ | $ReadOnlyArray<JSONSerializable>
142
+ | { +[string]: JSONSerializable };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/dev-middleware",
3
- "version": "0.74.0-nightly-20231107-bc68794c6",
3
+ "version": "0.74.0-nightly-20231108-05d92bf2a",
4
4
  "description": "Dev server middleware for React Native",
5
5
  "keywords": [
6
6
  "react-native",
@@ -23,17 +23,23 @@
23
23
  ],
24
24
  "dependencies": {
25
25
  "@isaacs/ttlcache": "^1.4.1",
26
- "@react-native/debugger-frontend": "0.74.0-nightly-20231107-bc68794c6",
26
+ "@react-native/debugger-frontend": "0.74.0-nightly-20231108-05d92bf2a",
27
27
  "chrome-launcher": "^0.15.2",
28
28
  "chromium-edge-launcher": "^1.0.0",
29
29
  "connect": "^3.6.5",
30
30
  "debug": "^2.2.0",
31
31
  "node-fetch": "^2.2.0",
32
32
  "open": "^7.0.3",
33
+ "selfsigned": "^2.4.1",
33
34
  "serve-static": "^1.13.1",
34
35
  "temp-dir": "^2.0.0"
35
36
  },
36
37
  "engines": {
37
38
  "node": ">=18"
39
+ },
40
+ "devDependencies": {
41
+ "data-uri-to-buffer": "^6.0.1",
42
+ "undici": "^5.27.2",
43
+ "wait-for-expect": "^3.0.2"
38
44
  }
39
45
  }