metro-runtime 0.73.2 → 0.73.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/package.json
CHANGED
package/src/modules/HMRClient.js
CHANGED
|
@@ -51,9 +51,9 @@ class HMRClient extends EventEmitter {
|
|
|
51
51
|
this.emit("connection-error", error);
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
this._ws.onclose = () => {
|
|
54
|
+
this._ws.onclose = (closeEvent) => {
|
|
55
55
|
this._state = "closed";
|
|
56
|
-
this.emit("close");
|
|
56
|
+
this.emit("close", closeEvent);
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
this._ws.onmessage = (message) => {
|
|
@@ -55,9 +55,9 @@ class HMRClient extends EventEmitter {
|
|
|
55
55
|
this._ws.onerror = error => {
|
|
56
56
|
this.emit('connection-error', error);
|
|
57
57
|
};
|
|
58
|
-
this._ws.onclose =
|
|
58
|
+
this._ws.onclose = closeEvent => {
|
|
59
59
|
this._state = 'closed';
|
|
60
|
-
this.emit('close');
|
|
60
|
+
this.emit('close', closeEvent);
|
|
61
61
|
};
|
|
62
62
|
this._ws.onmessage = message => {
|
|
63
63
|
const data: HmrMessage = JSON.parse(String(message.data));
|
|
@@ -147,9 +147,9 @@ class HMRClient extends EventEmitter {
|
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
function mergeUpdates(base: HmrUpdate, next: HmrUpdate): HmrUpdate {
|
|
150
|
-
const addedIDs = new Set();
|
|
151
|
-
const deletedIDs = new Set();
|
|
152
|
-
const moduleMap = new Map();
|
|
150
|
+
const addedIDs = new Set<number>();
|
|
151
|
+
const deletedIDs = new Set<number>();
|
|
152
|
+
const moduleMap = new Map<number, HmrModule>();
|
|
153
153
|
|
|
154
154
|
// Fill in the temporary maps and sets from both updates in their order.
|
|
155
155
|
applyUpdateLocally(base);
|
|
@@ -184,9 +184,9 @@ function mergeUpdates(base: HmrUpdate, next: HmrUpdate): HmrUpdate {
|
|
|
184
184
|
const result = {
|
|
185
185
|
isInitialUpdate: next.isInitialUpdate,
|
|
186
186
|
revisionId: next.revisionId,
|
|
187
|
-
added: [],
|
|
188
|
-
modified: [],
|
|
189
|
-
deleted: [],
|
|
187
|
+
added: ([]: Array<HmrModule>),
|
|
188
|
+
modified: ([]: Array<HmrModule>),
|
|
189
|
+
deleted: ([]: Array<number>),
|
|
190
190
|
};
|
|
191
191
|
deletedIDs.forEach(id => {
|
|
192
192
|
result.deleted.push(id);
|
|
@@ -213,7 +213,9 @@ function shouldPrintRequireCycle(modules: $ReadOnlyArray<?string>): boolean {
|
|
|
213
213
|
return modules.every(module => !isIgnored(module));
|
|
214
214
|
}
|
|
215
215
|
|
|
216
|
-
function metroImportDefault(
|
|
216
|
+
function metroImportDefault(
|
|
217
|
+
moduleId: ModuleID | VerboseModuleNameForDev,
|
|
218
|
+
): any | Exports {
|
|
217
219
|
if (__DEV__ && typeof moduleId === 'string') {
|
|
218
220
|
const verboseName = moduleId;
|
|
219
221
|
moduleId = verboseNamesToModuleIds[verboseName];
|
|
@@ -229,8 +231,8 @@ function metroImportDefault(moduleId: ModuleID | VerboseModuleNameForDev) {
|
|
|
229
231
|
return modules[moduleIdReallyIsNumber].importedDefault;
|
|
230
232
|
}
|
|
231
233
|
|
|
232
|
-
const exports = metroRequire(moduleIdReallyIsNumber);
|
|
233
|
-
const importedDefault =
|
|
234
|
+
const exports: Exports = metroRequire(moduleIdReallyIsNumber);
|
|
235
|
+
const importedDefault: any | Exports =
|
|
234
236
|
exports && exports.__esModule ? exports.default : exports;
|
|
235
237
|
|
|
236
238
|
// $FlowFixMe The metroRequire call above will throw if modules[id] is null
|
|
@@ -238,7 +240,9 @@ function metroImportDefault(moduleId: ModuleID | VerboseModuleNameForDev) {
|
|
|
238
240
|
}
|
|
239
241
|
metroRequire.importDefault = metroImportDefault;
|
|
240
242
|
|
|
241
|
-
function metroImportAll(
|
|
243
|
+
function metroImportAll(
|
|
244
|
+
moduleId: ModuleID | VerboseModuleNameForDev | number,
|
|
245
|
+
): any | Exports | {[string]: any} {
|
|
242
246
|
if (__DEV__ && typeof moduleId === 'string') {
|
|
243
247
|
const verboseName = moduleId;
|
|
244
248
|
moduleId = verboseNamesToModuleIds[verboseName];
|
|
@@ -254,8 +258,8 @@ function metroImportAll(moduleId: ModuleID | VerboseModuleNameForDev | number) {
|
|
|
254
258
|
return modules[moduleIdReallyIsNumber].importedAll;
|
|
255
259
|
}
|
|
256
260
|
|
|
257
|
-
const exports = metroRequire(moduleIdReallyIsNumber);
|
|
258
|
-
let importedAll;
|
|
261
|
+
const exports: Exports = metroRequire(moduleIdReallyIsNumber);
|
|
262
|
+
let importedAll: Exports | {[string]: any};
|
|
259
263
|
|
|
260
264
|
if (exports && exports.__esModule) {
|
|
261
265
|
importedAll = exports;
|
|
@@ -264,7 +268,7 @@ function metroImportAll(moduleId: ModuleID | VerboseModuleNameForDev | number) {
|
|
|
264
268
|
|
|
265
269
|
// Refrain from using Object.assign, it has to work in ES3 environments.
|
|
266
270
|
if (exports) {
|
|
267
|
-
for (const key in exports) {
|
|
271
|
+
for (const key: string in exports) {
|
|
268
272
|
if (hasOwnProperty.call(exports, key)) {
|
|
269
273
|
importedAll[key] = exports[key];
|
|
270
274
|
}
|
|
@@ -532,7 +536,7 @@ if (__DEV__) {
|
|
|
532
536
|
return hot;
|
|
533
537
|
};
|
|
534
538
|
|
|
535
|
-
let reactRefreshTimeout = null;
|
|
539
|
+
let reactRefreshTimeout: null | TimeoutID = null;
|
|
536
540
|
|
|
537
541
|
const metroHotUpdateModule = function (
|
|
538
542
|
id: ModuleID,
|
|
@@ -558,7 +562,7 @@ if (__DEV__) {
|
|
|
558
562
|
}
|
|
559
563
|
|
|
560
564
|
const Refresh = requireRefresh();
|
|
561
|
-
const refreshBoundaryIDs = new Set();
|
|
565
|
+
const refreshBoundaryIDs = new Set<ModuleID>();
|
|
562
566
|
|
|
563
567
|
// In this loop, we will traverse the dependency tree upwards from the
|
|
564
568
|
// changed module. Updates "bubble" up to the closest accepted parent.
|
|
@@ -646,7 +650,7 @@ if (__DEV__) {
|
|
|
646
650
|
|
|
647
651
|
// If we reached here, it is likely that hot reload will be successful.
|
|
648
652
|
// Run the actual factories.
|
|
649
|
-
const seenModuleIDs = new Set();
|
|
653
|
+
const seenModuleIDs = new Set<ModuleID>();
|
|
650
654
|
for (let i = 0; i < updatedModuleIDs.length; i++) {
|
|
651
655
|
const updatedID = updatedModuleIDs[i];
|
|
652
656
|
if (seenModuleIDs.has(updatedID)) {
|
|
@@ -754,9 +758,9 @@ if (__DEV__) {
|
|
|
754
758
|
earlyStop: T => boolean,
|
|
755
759
|
): Array<T> {
|
|
756
760
|
const result = [];
|
|
757
|
-
const visited = new Set();
|
|
758
|
-
const stack = new Set();
|
|
759
|
-
function traverseDependentNodes(node: T) {
|
|
761
|
+
const visited = new Set<mixed>();
|
|
762
|
+
const stack = new Set<mixed>();
|
|
763
|
+
function traverseDependentNodes(node: T): void {
|
|
760
764
|
if (stack.has(node)) {
|
|
761
765
|
throw CYCLE_DETECTED;
|
|
762
766
|
}
|
|
@@ -902,7 +906,7 @@ if (__DEV__) {
|
|
|
902
906
|
if (key === '__esModule') {
|
|
903
907
|
continue;
|
|
904
908
|
}
|
|
905
|
-
const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
909
|
+
const desc = Object.getOwnPropertyDescriptor<any>(moduleExports, key);
|
|
906
910
|
if (desc && desc.get) {
|
|
907
911
|
// Don't invoke getters as they may have side effects.
|
|
908
912
|
return false;
|
|
@@ -949,7 +953,7 @@ if (__DEV__) {
|
|
|
949
953
|
if (key === '__esModule') {
|
|
950
954
|
continue;
|
|
951
955
|
}
|
|
952
|
-
const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
956
|
+
const desc = Object.getOwnPropertyDescriptor<any>(moduleExports, key);
|
|
953
957
|
if (desc && desc.get) {
|
|
954
958
|
continue;
|
|
955
959
|
}
|
|
@@ -972,7 +976,7 @@ if (__DEV__) {
|
|
|
972
976
|
return;
|
|
973
977
|
}
|
|
974
978
|
for (const key in moduleExports) {
|
|
975
|
-
const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
|
|
979
|
+
const desc = Object.getOwnPropertyDescriptor<any>(moduleExports, key);
|
|
976
980
|
if (desc && desc.get) {
|
|
977
981
|
// Don't invoke getters as they may have side effects.
|
|
978
982
|
continue;
|