@vxrn/vite-native-hmr 2.0.0-beta.33.1 → 2.0.0-beta.362.1
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/cjs/devServerClient.cjs +113 -129
- package/dist/cjs/devServerClient.native.cjs +214 -0
- package/dist/cjs/devServerClient.native.js +184 -199
- package/dist/cjs/devServerClient.native.js.map +1 -1
- package/dist/cjs/getDevServerLocation.cjs +32 -43
- package/dist/cjs/getDevServerLocation.native.cjs +50 -0
- package/dist/cjs/getDevServerLocation.native.js +32 -42
- package/dist/cjs/getDevServerLocation.native.js.map +1 -1
- package/dist/cjs/hmr-client.cjs +155 -175
- package/dist/cjs/hmr-client.native.cjs +231 -0
- package/dist/cjs/hmr-client.native.js +210 -224
- package/dist/cjs/hmr-client.native.js.map +1 -1
- package/dist/cjs/index.cjs +14 -18
- package/dist/cjs/index.native.cjs +29 -0
- package/dist/cjs/index.native.js +14 -17
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/devServerClient.mjs +93 -100
- package/dist/esm/devServerClient.mjs.map +1 -1
- package/dist/esm/devServerClient.native.js +164 -171
- package/dist/esm/devServerClient.native.js.map +1 -1
- package/dist/esm/getDevServerLocation.mjs +17 -17
- package/dist/esm/getDevServerLocation.mjs.map +1 -1
- package/dist/esm/getDevServerLocation.native.js +17 -17
- package/dist/esm/getDevServerLocation.native.js.map +1 -1
- package/dist/esm/hmr-client.mjs +143 -157
- package/dist/esm/hmr-client.mjs.map +1 -1
- package/dist/esm/hmr-client.native.js +198 -207
- package/dist/esm/hmr-client.native.js.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +4 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +4 -1
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +5 -4
- package/types/devServerClient.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"devServerClient.native.js","names":[],"sources":["esm/devServerClient.native.js"],"sourcesContent":["import prettyFormat from \"pretty-format\";\nimport { getDevServerLocation } from \"./getDevServerLocation\";\nimport { loadHMRClient } from \"./hmr-client\";\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n return Constructor;\n}\nfunction _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nloadHMRClient();\nvar DevServerClient = /* @__PURE__ */ (function() {\n \"use strict\";\n function DevServerClient2() {\n var _this = this;\n _class_call_check(this, DevServerClient2);\n _define_property(this, \"socket\", void 0);\n _define_property(this, \"buffer\", []);\n var initSocket = function() {\n var address = `ws://${getDevServerLocation().host}/__client`;\n _this.socket = new WebSocket(address);\n var onClose = function(event) {\n console.warn(\"Disconnected from the Dev Server:\", event.message);\n _this.socket = void 0;\n };\n _this.socket.onclose = onClose;\n _this.socket.onerror = onClose;\n _this.socket.onopen = function() {\n _this.flushBuffer();\n };\n };\n if (process.env.NODE_ENV === \"development\") {\n initSocket();\n }\n }\n _create_class(DevServerClient2, [\n {\n key: \"send\",\n value: function send(level, data) {\n try {\n var _this_socket;\n (_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.send(JSON.stringify({\n type: \"client-log\",\n level,\n data: data.map(function(item) {\n return typeof item === \"string\" ? item : prettyFormat(item, {\n escapeString: true,\n highlight: true,\n maxDepth: 3,\n min: true,\n plugins: [\n // @ts-expect-error\n prettyFormat.plugins.ReactElement\n ]\n });\n })\n }));\n } catch (unused) {\n try {\n var _this_socket1;\n (_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.send(JSON.stringify({\n type: \"client-log\",\n level,\n data: data.map(function(item, index) {\n try {\n return typeof item === \"string\" ? item : JSON.stringify(item);\n } catch (err) {\n return `Error stringifying item at index ${index} - ${item} - ${err}`;\n }\n })\n }));\n } catch (err) {\n try {\n var _this_socket2;\n (_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.send(JSON.stringify({\n type: \"client-log\",\n level: \"error\",\n data: [\n \"error sending client log: \" + err\n ]\n }));\n } catch (unused2) {\n }\n }\n }\n }\n },\n {\n // final err\n // Ignore error\n key: \"flushBuffer\",\n value: function flushBuffer() {\n var _this = this;\n if (globalThis[\"__vxrnTmpLogs\"]) {\n globalThis[\"__vxrnTmpLogs\"].forEach(function(param) {\n var { level: level2, data: data2 } = param;\n _this.buffer.push({\n level: level2,\n data: data2\n });\n });\n delete globalThis[\"__vxrnTmpLogs\"];\n }\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = this.buffer[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var { level, data } = _step.value;\n this.send(level, data);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n this.buffer = [];\n }\n },\n {\n key: \"log\",\n value: function log2(level, data) {\n if (level === \"groupEnd\") {\n return;\n }\n if (this.socket && this.socket.readyState === WebSocket.OPEN) {\n this.flushBuffer();\n this.send(level, data);\n } else {\n if (globalThis[\"__vxrnTmpLogs\"]) return;\n this.buffer.push({\n level,\n data\n });\n }\n }\n },\n {\n // Mock for React Native 0.79 to prevent native error \"getPropertyAsObject: property 'setup' is undefined, expected an Object\"\n key: \"setup\",\n value: function setup2() {\n }\n }\n ]);\n return DevServerClient2;\n})();\nvar client = new DevServerClient();\nvar setup = function() {\n};\nvar enable = function() {\n};\nvar disable = function() {\n};\nvar registerBundle = function() {\n};\nvar log = function(level, data) {\n client.log(level, data);\n};\nexport {\n client,\n disable,\n enable,\n log,\n registerBundle,\n setup\n};\n//# sourceMappingURL=devServerClient.js.map\n"],"mappings":";;;;;AAGA,SAAS,kBAAkB,UAAU,aAAa;CAChD,IAAI,EAAE,oBAAoB,cAAc;EACtC,MAAM,IAAI,UAAU,mCAAmC;CACzD;AACF;AACA,SAAS,kBAAkB,QAAQ,OAAO;CACxC,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,IAAI,aAAa,MAAM;EACvB,WAAW,aAAa,WAAW,cAAc;EACjD,WAAW,eAAe;EAC1B,IAAI,WAAW,YAAY,WAAW,WAAW;EACjD,OAAO,eAAe,QAAQ,WAAW,KAAK,UAAU;CAC1D;AACF;AACA,SAAS,cAAc,aAAa,YAAY,aAAa;CAC3D,IAAI,YAAY,kBAAkB,YAAY,WAAW,UAAU;CACnE,IAAI,aAAa,kBAAkB,aAAa,WAAW;CAC3D,OAAO;AACT;AACA,SAAS,iBAAiB,KAAK,KAAK,OAAO;CACzC,IAAI,OAAO,KAAK;EACd,OAAO,eAAe,KAAK,KAAK;GAC9B;GACA,YAAY;GACZ,cAAc;GACd,UAAU;EACZ,CAAC;CACH,OAAO;EACL,IAAI,OAAO;CACb;CACA,OAAO;AACT;AACA,cAAc;AACd,IAAI,kBAAkC,iBAAC,WAAW;CAChD;CACA,SAAS,mBAAmB;EAC1B,IAAI,QAAQ;EACZ,kBAAkB,MAAM,gBAAgB;EACxC,iBAAiB,MAAM,UAAU,KAAK,CAAC;E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ACA;KACF,CAAC;IACH;GACF;EACF;EACA;GAEE,KAAK;GACL,OAAO,SAAS,SAAS,CACzB;EACF;CACF,CAAC;CACD,OAAO;AACT,EAAC,CAAE;AACH,IAAI,SAAS,IAAI,gBAAgB;AACjC,IAAI,QAAQ,WAAW,CACvB;AACA,IAAI,SAAS,WAAW,CACxB;AACA,IAAI,UAAU,WAAW,CACzB;AACA,IAAI,iBAAiB,WAAW,CAChC;AACA,IAAI,MAAM,SAAS,OAAO,MAAM;CAC9B,OAAO,IAAI,OAAO,IAAI;AACxB"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";
|
|
2
|
+
|
|
2
3
|
let location;
|
|
3
4
|
function getDevServerLocation() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return location;
|
|
5
|
+
if (!location) {
|
|
6
|
+
const { url } = getDevServer();
|
|
7
|
+
const origin = url.replace(/\/$/, "");
|
|
8
|
+
const host = origin.replace(/https?:\/\//, "");
|
|
9
|
+
location = {
|
|
10
|
+
host,
|
|
11
|
+
hostname: host.split(":")[0],
|
|
12
|
+
href: url,
|
|
13
|
+
origin,
|
|
14
|
+
pathname: url.split(host)[1],
|
|
15
|
+
port: host.split(":")[1],
|
|
16
|
+
protocol: (url.match(/^([a-z])+:\/\//) || [void 0, void 0])[1]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return location;
|
|
21
20
|
}
|
|
21
|
+
|
|
22
22
|
export { getDevServerLocation };
|
|
23
23
|
//# sourceMappingURL=getDevServerLocation.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getDevServerLocation.js","names":[],"sources":["esm/getDevServerLocation.js"],"sourcesContent":["import getDevServer from \"react-native/Libraries/Core/Devtools/getDevServer\";\nlet location;\nfunction getDevServerLocation() {\n if (!location) {\n const { url } = getDevServer();\n const origin = url.replace(/\\/$/, \"\");\n const host = origin.replace(/https?:\\/\\//, \"\");\n location = {\n host,\n hostname: host.split(\":\")[0],\n href: url,\n origin,\n pathname: url.split(host)[1],\n port: host.split(\":\")[1],\n protocol: (url.match(/^([a-z])+:\\/\\//) || [void 0, void 0])[1]\n };\n }\n return location;\n}\nexport {\n getDevServerLocation\n};\n//# sourceMappingURL=getDevServerLocation.js.map\n"],"mappings":";;;AACA,IAAI;AACJ,SAAS,uBAAuB;CAC9B,IAAI,CAAC,UAAU;EACb,MAAM,EAAE,QAAQ,aAAa;EAC7B,MAAM,SAAS,IAAI,QAAQ,OAAO,EAAE;EACpC,MAAM,OAAO,OAAO,QAAQ,eAAe,EAAE;EAC7C,WAAW;GACT;GACA,UAAU,KAAK,MAAM,GAAG,CAAC,CAAC;GAC1B,MAAM;GACN;GACA,UAAU,IAAI,MAAM,IAAI,CAAC,CAAC;GAC1B,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC;GACtB,WAAW,IAAI,MAAM,gBAAgB,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,EAAC,CAAE;EAC9D;CACF;CACA,OAAO;AACT"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import getDevServer from "react-native/Libraries/Core/Devtools/getDevServer";
|
|
2
|
+
|
|
2
3
|
var location;
|
|
3
4
|
function getDevServerLocation() {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
return location;
|
|
5
|
+
if (!location) {
|
|
6
|
+
var { url } = getDevServer();
|
|
7
|
+
var origin = url.replace(/\/$/, "");
|
|
8
|
+
var host = origin.replace(/https?:\/\//, "");
|
|
9
|
+
location = {
|
|
10
|
+
host,
|
|
11
|
+
hostname: host.split(":")[0],
|
|
12
|
+
href: url,
|
|
13
|
+
origin,
|
|
14
|
+
pathname: url.split(host)[1],
|
|
15
|
+
port: host.split(":")[1],
|
|
16
|
+
protocol: (url.match(/^([a-z])+:\/\//) || [void 0, void 0])[1]
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return location;
|
|
21
20
|
}
|
|
21
|
+
|
|
22
22
|
export { getDevServerLocation };
|
|
23
23
|
//# sourceMappingURL=getDevServerLocation.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getDevServerLocation.native.js","names":[],"sources":["esm/getDevServerLocation.native.js"],"sourcesContent":["import getDevServer from \"react-native/Libraries/Core/Devtools/getDevServer\";\nvar location;\nfunction getDevServerLocation() {\n if (!location) {\n var { url } = getDevServer();\n var origin = url.replace(/\\/$/, \"\");\n var host = origin.replace(/https?:\\/\\//, \"\");\n location = {\n host,\n hostname: host.split(\":\")[0],\n href: url,\n origin,\n pathname: url.split(host)[1],\n port: host.split(\":\")[1],\n protocol: (url.match(/^([a-z])+:\\/\\//) || [\n void 0,\n void 0\n ])[1]\n };\n }\n return location;\n}\nexport {\n getDevServerLocation\n};\n//# sourceMappingURL=getDevServerLocation.js.map\n"],"mappings":";;;AACA,IAAI;AACJ,SAAS,uBAAuB;CAC9B,IAAI,CAAC,UAAU;EACb,IAAI,EAAE,QAAQ,aAAa;EAC3B,IAAI,SAAS,IAAI,QAAQ,OAAO,EAAE;EAClC,IAAI,OAAO,OAAO,QAAQ,eAAe,EAAE;EAC3C,WAAW;GACT;GACA,UAAU,KAAK,MAAM,GAAG,CAAC,CAAC;GAC1B,MAAM;GACN;GACA,UAAU,IAAI,MAAM,IAAI,CAAC,CAAC;GAC1B,MAAM,KAAK,MAAM,GAAG,CAAC,CAAC;GACtB,WAAW,IAAI,MAAM,gBAAgB,KAAK,CACxC,KAAK,GACL,KAAK,CACP,EAAC,CAAE;EACL;CACF;CACA,OAAO;AACT"}
|
package/dist/esm/hmr-client.mjs
CHANGED
|
@@ -1,162 +1,148 @@
|
|
|
1
1
|
import { getDevServerLocation } from "./getDevServerLocation.mjs";
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
console.warn("[hmr]", error);
|
|
123
|
-
this.app.reload();
|
|
124
|
-
} else {
|
|
125
|
-
console.warn(" \u24F5 [hmr] update check failed", {
|
|
126
|
-
error
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
} finally {
|
|
130
|
-
this.app.LoadingView.hide();
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
2
|
+
|
|
3
|
+
var HMRClient = class {
|
|
4
|
+
constructor(app) {
|
|
5
|
+
this.app = app;
|
|
6
|
+
const port = process.env.REACT_NATIVE_SERVER_PUBLIC_PORT || 8081;
|
|
7
|
+
this.url = `ws://${getDevServerLocation().hostname}:${port}/__hmr?platform=${process.env.REACT_NATIVE_PLATFORM || "ios"}`;
|
|
8
|
+
this.socket = new WebSocket(this.url);
|
|
9
|
+
console.info(" ⓵ [hmr] connecting...");
|
|
10
|
+
this.socket.onopen = () => {
|
|
11
|
+
console.info(" ⓵ [hmr] connected");
|
|
12
|
+
};
|
|
13
|
+
this.socket.onclose = () => {
|
|
14
|
+
console.info(` \u24F5 [hmr] disconnected ${this.url}`);
|
|
15
|
+
};
|
|
16
|
+
this.socket.onerror = (event) => {
|
|
17
|
+
console.error(" ⓵ [hmr] error", event);
|
|
18
|
+
};
|
|
19
|
+
this.socket.onmessage = (event) => {
|
|
20
|
+
try {
|
|
21
|
+
const data = JSON.parse(event.data.toString());
|
|
22
|
+
this.processMessage(data);
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.warn(" ⓵ [hmr] invalid message", error);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
app;
|
|
29
|
+
url;
|
|
30
|
+
socket;
|
|
31
|
+
lastHash = "";
|
|
32
|
+
upToDate(hash) {
|
|
33
|
+
if (hash) {
|
|
34
|
+
this.lastHash = hash;
|
|
35
|
+
}
|
|
36
|
+
return this.lastHash === __webpack_hash__;
|
|
37
|
+
}
|
|
38
|
+
processMessage(message) {
|
|
39
|
+
switch (message.action) {
|
|
40
|
+
case "building":
|
|
41
|
+
this.app.LoadingView.showMessage("Rebuilding...", "refresh");
|
|
42
|
+
console.info(" ⓵ [hmr] bundle rebuilding", { name: message.body?.name });
|
|
43
|
+
break;
|
|
44
|
+
case "built": console.info(" ⓵ [hmr] bundle rebuilt", {
|
|
45
|
+
name: message.body?.name,
|
|
46
|
+
time: message.body?.time
|
|
47
|
+
});
|
|
48
|
+
case "sync":
|
|
49
|
+
if (!message.body) {
|
|
50
|
+
console.warn(" ⓵ [hmr] message body is empty");
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (message.body.errors?.length) {
|
|
54
|
+
message.body.errors.forEach((error) => {
|
|
55
|
+
console.error("Cannot apply update due to error:", error);
|
|
56
|
+
});
|
|
57
|
+
this.app.LoadingView.hide();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (message.body.warnings?.length) {
|
|
61
|
+
message.body.warnings.forEach((warning) => {
|
|
62
|
+
console.warn(" ⓵ [hmr] bundle contains warnings:", warning);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
this.applyUpdate(message.body);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
applyUpdate(update) {
|
|
69
|
+
if (!module.hot) {
|
|
70
|
+
throw new Error(" ⓵ [hmr] hot Module Replacement is disabled.");
|
|
71
|
+
}
|
|
72
|
+
if (!this.upToDate(update.hash) && module.hot.status() === "idle") {
|
|
73
|
+
console.info(" ⓵ [hmr] checking for updates on the server...");
|
|
74
|
+
this.checkUpdates(update);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
checkUpdates(update) {
|
|
78
|
+
try {
|
|
79
|
+
this.app.LoadingView.showMessage("Refreshing...", "refresh");
|
|
80
|
+
module.hot?.check(false).then((updatedModules) => {
|
|
81
|
+
if (!updatedModules) {
|
|
82
|
+
console.warn(" ⓵ [hmr] cannot find update - full reload needed");
|
|
83
|
+
this.app.reload();
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
module.hot?.apply({
|
|
87
|
+
ignoreDeclined: true,
|
|
88
|
+
ignoreUnaccepted: false,
|
|
89
|
+
ignoreErrored: false,
|
|
90
|
+
onDeclined: (data) => {
|
|
91
|
+
console.warn(" ⓵ [hmr] ignored an update due to declined module", { chain: data.chain });
|
|
92
|
+
}
|
|
93
|
+
}).then((renewedModules) => {
|
|
94
|
+
if (!this.upToDate()) {
|
|
95
|
+
this.checkUpdates(update);
|
|
96
|
+
}
|
|
97
|
+
const unacceptedModules = updatedModules.filter((moduleId) => {
|
|
98
|
+
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
|
99
|
+
});
|
|
100
|
+
if (unacceptedModules.length) {
|
|
101
|
+
console.warn(" ⓵ [hmr] not every module was accepted - full reload needed", { unacceptedModules });
|
|
102
|
+
this.app.reload();
|
|
103
|
+
} else {
|
|
104
|
+
console.info(" ⓵ [hmr] renewed modules - app is up to date", { renewedModules });
|
|
105
|
+
this.app.dismissErrors();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (module.hot?.status() === "fail" || module.hot?.status() === "abort") {
|
|
111
|
+
console.warn(" ⓵ [hmr] cannot check for update - full reload needed");
|
|
112
|
+
console.warn("[hmr]", error);
|
|
113
|
+
this.app.reload();
|
|
114
|
+
} else {
|
|
115
|
+
console.warn(" ⓵ [hmr] update check failed", { error });
|
|
116
|
+
}
|
|
117
|
+
} finally {
|
|
118
|
+
this.app.LoadingView.hide();
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
134
122
|
const loadHMRClient = () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
dismissErrors,
|
|
158
|
-
LoadingView
|
|
159
|
-
});
|
|
123
|
+
const { DevSettings, Platform } = require("react-native");
|
|
124
|
+
const LoadingView = {
|
|
125
|
+
showMessage: () => {},
|
|
126
|
+
hide: () => {}
|
|
127
|
+
};
|
|
128
|
+
const reload = () => DevSettings.reload();
|
|
129
|
+
const dismissErrors = () => {
|
|
130
|
+
if (Platform.OS === "ios") {
|
|
131
|
+
const NativeRedBox = require("react-native/Libraries/NativeModules/specs/NativeRedBox").default;
|
|
132
|
+
NativeRedBox?.dismiss?.();
|
|
133
|
+
} else {
|
|
134
|
+
const NativeExceptionsManager = require("react-native/Libraries/Core/NativeExceptionsManager").default;
|
|
135
|
+
NativeExceptionsManager?.dismissRedbox();
|
|
136
|
+
}
|
|
137
|
+
const LogBoxData = require("react-native/Libraries/LogBox/Data/LogBoxData");
|
|
138
|
+
LogBoxData.clear();
|
|
139
|
+
};
|
|
140
|
+
new HMRClient({
|
|
141
|
+
reload,
|
|
142
|
+
dismissErrors,
|
|
143
|
+
LoadingView
|
|
144
|
+
});
|
|
160
145
|
};
|
|
146
|
+
|
|
161
147
|
export { loadHMRClient };
|
|
162
148
|
//# sourceMappingURL=hmr-client.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"hmr-client.js","names":[],"sources":["esm/hmr-client.js"],"sourcesContent":["import { getDevServerLocation } from \"./getDevServerLocation\";\nclass HMRClient {\n constructor(app) {\n this.app = app;\n const port = process.env.REACT_NATIVE_SERVER_PUBLIC_PORT || 8081;\n this.url = `ws://${getDevServerLocation().hostname}:${port}/__hmr?platform=${process.env.REACT_NATIVE_PLATFORM || \"ios\"}`;\n this.socket = new WebSocket(this.url);\n console.info(\" \\u24F5 [hmr] connecting...\");\n this.socket.onopen = () => {\n console.info(\" \\u24F5 [hmr] connected\");\n };\n this.socket.onclose = () => {\n console.info(` \\u24F5 [hmr] disconnected ${this.url}`);\n };\n this.socket.onerror = (event) => {\n console.error(\" \\u24F5 [hmr] error\", event);\n };\n this.socket.onmessage = (event) => {\n try {\n const data = JSON.parse(event.data.toString());\n this.processMessage(data);\n } catch (error) {\n console.warn(\" \\u24F5 [hmr] invalid message\", error);\n }\n };\n }\n app;\n url;\n socket;\n lastHash = \"\";\n upToDate(hash) {\n if (hash) {\n this.lastHash = hash;\n }\n return this.lastHash === __webpack_hash__;\n }\n processMessage(message) {\n switch (message.action) {\n case \"building\":\n this.app.LoadingView.showMessage(\"Rebuilding...\", \"refresh\");\n console.info(\" \\u24F5 [hmr] bundle rebuilding\", {\n name: message.body?.name\n });\n break;\n // biome-ignore lint/suspicious/noFallthroughSwitchClause: <explanation>\n case \"built\":\n console.info(\" \\u24F5 [hmr] bundle rebuilt\", {\n name: message.body?.name,\n time: message.body?.time\n });\n // Fall through\n case \"sync\":\n if (!message.body) {\n console.warn(\" \\u24F5 [hmr] message body is empty\");\n return;\n }\n if (message.body.errors?.length) {\n message.body.errors.forEach((error) => {\n console.error(\"Cannot apply update due to error:\", error);\n });\n this.app.LoadingView.hide();\n return;\n }\n if (message.body.warnings?.length) {\n message.body.warnings.forEach((warning) => {\n console.warn(\" \\u24F5 [hmr] bundle contains warnings:\", warning);\n });\n }\n this.applyUpdate(message.body);\n }\n }\n applyUpdate(update) {\n if (!module.hot) {\n throw new Error(\" \\u24F5 [hmr] hot Module Replacement is disabled.\");\n }\n if (!this.upToDate(update.hash) && module.hot.status() === \"idle\") {\n console.info(\" \\u24F5 [hmr] checking for updates on the server...\");\n this.checkUpdates(update);\n }\n }\n checkUpdates(update) {\n try {\n this.app.LoadingView.showMessage(\"Refreshing...\", \"refresh\");\n module.hot?.check(false).then((updatedModules) => {\n if (!updatedModules) {\n console.warn(\" \\u24F5 [hmr] cannot find update - full reload needed\");\n this.app.reload();\n return;\n }\n module.hot?.apply({\n ignoreDeclined: true,\n ignoreUnaccepted: false,\n ignoreErrored: false,\n onDeclined: (data) => {\n console.warn(\" \\u24F5 [hmr] ignored an update due to declined module\", {\n chain: data.chain\n });\n }\n }).then((renewedModules) => {\n if (!this.upToDate()) {\n this.checkUpdates(update);\n }\n const unacceptedModules = updatedModules.filter((moduleId) => {\n return renewedModules && renewedModules.indexOf(moduleId) < 0;\n });\n if (unacceptedModules.length) {\n console.warn(\n \" \\u24F5 [hmr] not every module was accepted - full reload needed\",\n {\n unacceptedModules\n }\n );\n this.app.reload();\n } else {\n console.info(\" \\u24F5 [hmr] renewed modules - app is up to date\", {\n renewedModules\n });\n this.app.dismissErrors();\n }\n });\n });\n } catch (error) {\n if (module.hot?.status() === \"fail\" || module.hot?.status() === \"abort\") {\n console.warn(\" \\u24F5 [hmr] cannot check for update - full reload needed\");\n console.warn(\"[hmr]\", error);\n this.app.reload();\n } else {\n console.warn(\" \\u24F5 [hmr] update check failed\", { error });\n }\n } finally {\n this.app.LoadingView.hide();\n }\n }\n}\nconst loadHMRClient = () => {\n const { DevSettings, Platform } = require(\"react-native\");\n const LoadingView = {\n showMessage: () => {\n },\n hide: () => {\n }\n };\n const reload = () => DevSettings.reload();\n const dismissErrors = () => {\n if (Platform.OS === \"ios\") {\n const NativeRedBox = require(\"react-native/Libraries/NativeModules/specs/NativeRedBox\").default;\n NativeRedBox?.dismiss?.();\n } else {\n const NativeExceptionsManager = require(\"react-native/Libraries/Core/NativeExceptionsManager\").default;\n NativeExceptionsManager?.dismissRedbox();\n }\n const LogBoxData = require(\"react-native/Libraries/LogBox/Data/LogBoxData\");\n LogBoxData.clear();\n };\n new HMRClient({ reload, dismissErrors, LoadingView });\n};\nexport {\n loadHMRClient\n};\n//# sourceMappingURL=hmr-client.js.map\n"],"mappings":";;;;;;;;;;AACA,IAAM,YAAN,MAAgB;CACd,YAAY,KAAK;EACf,KAAK,MAAM;EACX,MAAM,OAAO,QAAQ,IAAI,mCAAmC;EAC5D,KAAK,MAAM,QAAQ,qBAAqB,CAAC,CAAC,SAAS,GAAG,KAAK,kBAAkB,QAAQ,IAAI,yBAAyB;EAClH,KAAK,SAAS,IAAI,UAAU,KAAK,GAAG;EACpC,QAAQ,KAAK,wBAA6B;EAC1C,KAAK,OAAO,eAAe;GACzB,QAAQ,KAAK,oBAAyB;EACxC;EACA,KAAK,OAAO,gBAAgB;GAC1B,QAAQ,KAAK,8BAA8B,KAAK,KAAK;EACvD;EACA,KAAK,OAAO,WAAW,UAAU;GAC/B,QAAQ,MAAM,kBAAuB,KAAK;EAC5C;EACA,KAAK,OAAO,aAAa,UAAU;GACjC,IAAI;IACF,MAAM,OAAO,KAAK,MAAM,MAAM,KAAK,SAAS,CAAC;IAC7C,KAAK,eAAe,IAAI;GAC1B,SAAS,OAAO;IACd,QAAQ,KAAK,4BAAiC,KAAK;GACrD;EACF;CACF;CACA;CACA;CACA;CACA,WAAW;CACX,SAAS,MAAM;EACb,IAAI,MAAM;GACR,KAAK,WAAW;EAClB;EACA,OAAO,KAAK,aAAa;CAC3B;CACA,eAAe,SAAS;EACtB,QAAQ,QAAQ,QAAhB;GACE,KAAK;IACH,KAAK,IAAI,YAAY,YAAY,iBAAiB,SAAS;IAC3D,QAAQ,KAAK,8BAAmC,EAC9C,MAAM,QAAQ,MAAM,KACtB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