@vxrn/vite-native-hmr 0.0.6 → 0.1.0
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.js +3 -12
- package/dist/cjs/devServerClient.js.map +1 -1
- package/dist/cjs/devServerClient.native.js +127 -75
- package/dist/cjs/devServerClient.native.js.map +3 -3
- package/dist/cjs/getDevServerLocation.js +0 -4
- package/dist/cjs/getDevServerLocation.native.js +6 -4
- package/dist/cjs/getDevServerLocation.native.js.map +3 -3
- package/dist/cjs/hmr-client.js +20 -33
- package/dist/cjs/hmr-client.js.map +1 -1
- package/dist/cjs/hmr-client.native.js +276 -87
- package/dist/cjs/hmr-client.native.js.map +3 -3
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/index.native.js.map +2 -2
- package/dist/esm/devServerClient.mjs +88 -0
- package/dist/esm/devServerClient.native.js +127 -74
- package/dist/esm/devServerClient.native.js.map +3 -3
- package/dist/esm/getDevServerLocation.mjs +22 -0
- package/dist/esm/getDevServerLocation.native.js +6 -3
- package/dist/esm/getDevServerLocation.native.js.map +3 -3
- package/dist/esm/hmr-client.js +9 -8
- package/dist/esm/hmr-client.js.map +1 -1
- package/dist/esm/hmr-client.mjs +109 -0
- package/dist/esm/hmr-client.native.js +280 -81
- package/dist/esm/hmr-client.native.js.map +3 -3
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +3 -3
- package/src/hmr-client.ts +12 -11
- package/types/hmr-client.d.ts.map +1 -1
|
@@ -1,96 +1,295 @@
|
|
|
1
1
|
import { getDevServerLocation } from "./getDevServerLocation";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
2
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3
|
+
try {
|
|
4
|
+
var info = gen[key](arg), value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
info.done ? resolve(value) : Promise.resolve(value).then(_next, _throw);
|
|
10
|
+
}
|
|
11
|
+
function _async_to_generator(fn) {
|
|
12
|
+
return function() {
|
|
13
|
+
var self = this, args = arguments;
|
|
14
|
+
return new Promise(function(resolve, reject) {
|
|
15
|
+
var gen = fn.apply(self, args);
|
|
16
|
+
function _next(value) {
|
|
17
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
18
|
+
}
|
|
19
|
+
function _throw(err) {
|
|
20
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
21
|
+
}
|
|
22
|
+
_next(void 0);
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function _class_call_check(instance, Constructor) {
|
|
27
|
+
if (!(instance instanceof Constructor))
|
|
28
|
+
throw new TypeError("Cannot call a class as a function");
|
|
29
|
+
}
|
|
30
|
+
function _defineProperties(target, props) {
|
|
31
|
+
for (var i = 0; i < props.length; i++) {
|
|
32
|
+
var descriptor = props[i];
|
|
33
|
+
descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
37
|
+
return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor;
|
|
38
|
+
}
|
|
39
|
+
function _define_property(obj, key, value) {
|
|
40
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
41
|
+
value,
|
|
42
|
+
enumerable: !0,
|
|
43
|
+
configurable: !0,
|
|
44
|
+
writable: !0
|
|
45
|
+
}) : obj[key] = value, obj;
|
|
46
|
+
}
|
|
47
|
+
function _ts_generator(thisArg, body) {
|
|
48
|
+
var f, y, t, g, _ = {
|
|
49
|
+
label: 0,
|
|
50
|
+
sent: function() {
|
|
51
|
+
if (t[0] & 1)
|
|
52
|
+
throw t[1];
|
|
53
|
+
return t[1];
|
|
54
|
+
},
|
|
55
|
+
trys: [],
|
|
56
|
+
ops: []
|
|
57
|
+
};
|
|
58
|
+
return g = {
|
|
59
|
+
next: verb(0),
|
|
60
|
+
throw: verb(1),
|
|
61
|
+
return: verb(2)
|
|
62
|
+
}, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
|
63
|
+
return this;
|
|
64
|
+
}), g;
|
|
65
|
+
function verb(n) {
|
|
66
|
+
return function(v) {
|
|
67
|
+
return step([
|
|
68
|
+
n,
|
|
69
|
+
v
|
|
70
|
+
]);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function step(op) {
|
|
74
|
+
if (f)
|
|
75
|
+
throw new TypeError("Generator is already executing.");
|
|
76
|
+
for (; _; )
|
|
77
|
+
try {
|
|
78
|
+
if (f = 1, y && (t = op[0] & 2 ? y.return : op[0] ? y.throw || ((t = y.return) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
|
|
79
|
+
return t;
|
|
80
|
+
switch (y = 0, t && (op = [
|
|
81
|
+
op[0] & 2,
|
|
82
|
+
t.value
|
|
83
|
+
]), op[0]) {
|
|
84
|
+
case 0:
|
|
85
|
+
case 1:
|
|
86
|
+
t = op;
|
|
87
|
+
break;
|
|
88
|
+
case 4:
|
|
89
|
+
return _.label++, {
|
|
90
|
+
value: op[1],
|
|
91
|
+
done: !1
|
|
92
|
+
};
|
|
93
|
+
case 5:
|
|
94
|
+
_.label++, y = op[1], op = [
|
|
95
|
+
0
|
|
96
|
+
];
|
|
97
|
+
continue;
|
|
98
|
+
case 7:
|
|
99
|
+
op = _.ops.pop(), _.trys.pop();
|
|
100
|
+
continue;
|
|
101
|
+
default:
|
|
102
|
+
if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
103
|
+
_ = 0;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
107
|
+
_.label = op[1];
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
111
|
+
_.label = t[1], t = op;
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
if (t && _.label < t[2]) {
|
|
115
|
+
_.label = t[2], _.ops.push(op);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
t[2] && _.ops.pop(), _.trys.pop();
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
op = body.call(thisArg, _);
|
|
122
|
+
} catch (e) {
|
|
123
|
+
op = [
|
|
124
|
+
6,
|
|
125
|
+
e
|
|
126
|
+
], y = 0;
|
|
127
|
+
} finally {
|
|
128
|
+
f = t = 0;
|
|
129
|
+
}
|
|
130
|
+
if (op[0] & 5)
|
|
131
|
+
throw op[1];
|
|
132
|
+
return {
|
|
133
|
+
value: op[0] ? op[1] : void 0,
|
|
134
|
+
done: !0
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
var HMRClient = /* @__PURE__ */ function() {
|
|
139
|
+
"use strict";
|
|
140
|
+
function HMRClient2(app) {
|
|
141
|
+
var _this = this;
|
|
142
|
+
_class_call_check(this, HMRClient2), _define_property(this, "app", void 0), _define_property(this, "url", void 0), _define_property(this, "socket", void 0), _define_property(this, "lastHash", void 0), this.app = app, this.lastHash = "";
|
|
143
|
+
var port = process.env.REACT_NATIVE_SERVER_PUBLIC_PORT || 8081;
|
|
144
|
+
this.url = "ws://".concat(getDevServerLocation().hostname, ":").concat(port, "/__hmr?platform=").concat(process.env.REACT_NATIVE_PLATFORM || "ios"), this.socket = new WebSocket(this.url), console.info("[HMRClient] Connecting..."), this.socket.onopen = function() {
|
|
145
|
+
console.info("[HMRClient] Connected");
|
|
146
|
+
}, this.socket.onclose = function() {
|
|
147
|
+
console.info("[HMRClient] Disconnected ".concat(_this.url));
|
|
148
|
+
}, this.socket.onerror = function(event) {
|
|
149
|
+
console.error("[HMRClient] Error", event);
|
|
150
|
+
}, this.socket.onmessage = function(event) {
|
|
13
151
|
try {
|
|
14
|
-
|
|
15
|
-
|
|
152
|
+
var data = JSON.parse(event.data.toString());
|
|
153
|
+
_this.processMessage(data);
|
|
16
154
|
} catch (error) {
|
|
17
155
|
console.warn("[HMRClient] Invalid HMR message", error);
|
|
18
156
|
}
|
|
19
157
|
};
|
|
20
158
|
}
|
|
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
|
-
|
|
159
|
+
return _create_class(HMRClient2, [
|
|
160
|
+
{
|
|
161
|
+
key: "upToDate",
|
|
162
|
+
value: function(hash) {
|
|
163
|
+
return hash && (this.lastHash = hash), this.lastHash === __webpack_hash__;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
key: "processMessage",
|
|
168
|
+
value: function(message) {
|
|
169
|
+
switch (message.action) {
|
|
170
|
+
case "building":
|
|
171
|
+
var _message_body;
|
|
172
|
+
this.app.LoadingView.showMessage("Rebuilding...", "refresh"), console.info("[HMRClient] Bundle rebuilding", {
|
|
173
|
+
name: (_message_body = message.body) === null || _message_body === void 0 ? void 0 : _message_body.name
|
|
174
|
+
});
|
|
175
|
+
break;
|
|
176
|
+
case "built":
|
|
177
|
+
var _message_body1, _message_body2;
|
|
178
|
+
console.info("[HMRClient] Bundle rebuilt", {
|
|
179
|
+
name: (_message_body1 = message.body) === null || _message_body1 === void 0 ? void 0 : _message_body1.name,
|
|
180
|
+
time: (_message_body2 = message.body) === null || _message_body2 === void 0 ? void 0 : _message_body2.time
|
|
181
|
+
});
|
|
182
|
+
case "sync":
|
|
183
|
+
var _message_body_errors, _message_body_warnings;
|
|
184
|
+
if (!message.body) {
|
|
185
|
+
console.warn("[HMRClient] HMR message body is empty");
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (!((_message_body_errors = message.body.errors) === null || _message_body_errors === void 0) && _message_body_errors.length) {
|
|
189
|
+
message.body.errors.forEach(function(error) {
|
|
190
|
+
console.error("Cannot apply update due to error:", error);
|
|
191
|
+
}), this.app.LoadingView.hide();
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
!((_message_body_warnings = message.body.warnings) === null || _message_body_warnings === void 0) && _message_body_warnings.length && message.body.warnings.forEach(function(warning) {
|
|
195
|
+
console.warn("[HMRClient] Bundle contains warnings:", warning);
|
|
196
|
+
}), this.applyUpdate(message.body);
|
|
46
197
|
}
|
|
47
|
-
message.body.warnings?.length && message.body.warnings.forEach((warning) => {
|
|
48
|
-
console.warn("[HMRClient] Bundle contains warnings:", warning);
|
|
49
|
-
}), this.applyUpdate(message.body);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
applyUpdate(update) {
|
|
53
|
-
if (!module.hot)
|
|
54
|
-
throw new Error("[HMRClient] Hot Module Replacement is disabled.");
|
|
55
|
-
!this.upToDate(update.hash) && module.hot.status() === "idle" && (console.log("[HMRClient] Checking for updates on the server..."), this.checkUpdates(update));
|
|
56
|
-
}
|
|
57
|
-
async checkUpdates(update) {
|
|
58
|
-
try {
|
|
59
|
-
this.app.LoadingView.showMessage("Refreshing...", "refresh");
|
|
60
|
-
const updatedModules = await module.hot?.check(!1);
|
|
61
|
-
if (!updatedModules) {
|
|
62
|
-
console.warn("[HMRClient] Cannot find update - full reload needed"), this.app.reload();
|
|
63
|
-
return;
|
|
64
198
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "applyUpdate",
|
|
202
|
+
value: function(update) {
|
|
203
|
+
if (!module.hot)
|
|
204
|
+
throw new Error("[HMRClient] Hot Module Replacement is disabled.");
|
|
205
|
+
!this.upToDate(update.hash) && module.hot.status() === "idle" && (console.info("[HMRClient] Checking for updates on the server..."), this.checkUpdates(update));
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: "checkUpdates",
|
|
210
|
+
value: function(update) {
|
|
211
|
+
var _this = this;
|
|
212
|
+
return _async_to_generator(function() {
|
|
213
|
+
var _module_hot, _module_hot1, updatedModules, renewedModules, unacceptedModules, error, _module_hot2, _module_hot3;
|
|
214
|
+
return _ts_generator(this, function(_state) {
|
|
215
|
+
switch (_state.label) {
|
|
216
|
+
case 0:
|
|
217
|
+
return _state.trys.push([
|
|
218
|
+
0,
|
|
219
|
+
3,
|
|
220
|
+
4,
|
|
221
|
+
5
|
|
222
|
+
]), _this.app.LoadingView.showMessage("Refreshing...", "refresh"), [
|
|
223
|
+
4,
|
|
224
|
+
(_module_hot = module.hot) === null || _module_hot === void 0 ? void 0 : _module_hot.check(!1)
|
|
225
|
+
];
|
|
226
|
+
case 1:
|
|
227
|
+
return updatedModules = _state.sent(), updatedModules ? [
|
|
228
|
+
4,
|
|
229
|
+
(_module_hot1 = module.hot) === null || _module_hot1 === void 0 ? void 0 : _module_hot1.apply({
|
|
230
|
+
ignoreDeclined: !0,
|
|
231
|
+
ignoreUnaccepted: !1,
|
|
232
|
+
ignoreErrored: !1,
|
|
233
|
+
onDeclined: function(data) {
|
|
234
|
+
console.warn("[HMRClient] Ignored an update due to declined module", {
|
|
235
|
+
chain: data.chain
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
] : (console.warn("[HMRClient] Cannot find update - full reload needed"), _this.app.reload(), [
|
|
240
|
+
2
|
|
241
|
+
]);
|
|
242
|
+
case 2:
|
|
243
|
+
return renewedModules = _state.sent(), _this.upToDate() || _this.checkUpdates(update), unacceptedModules = updatedModules.filter(function(moduleId) {
|
|
244
|
+
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
|
245
|
+
}), unacceptedModules.length ? (console.warn("[HMRClient] Not every module was accepted - full reload needed", {
|
|
246
|
+
unacceptedModules
|
|
247
|
+
}), _this.app.reload()) : (console.info("[HMRClient] Renewed modules - app is up to date", {
|
|
248
|
+
renewedModules
|
|
249
|
+
}), _this.app.dismissErrors()), [
|
|
250
|
+
3,
|
|
251
|
+
5
|
|
252
|
+
];
|
|
253
|
+
case 3:
|
|
254
|
+
return error = _state.sent(), ((_module_hot2 = module.hot) === null || _module_hot2 === void 0 ? void 0 : _module_hot2.status()) === "fail" || ((_module_hot3 = module.hot) === null || _module_hot3 === void 0 ? void 0 : _module_hot3.status()) === "abort" ? (console.warn("[HMRClient] Cannot check for update - full reload needed"), console.warn("[HMRClient]", error), _this.app.reload()) : console.warn("[HMRClient] Update check failed", {
|
|
255
|
+
error
|
|
256
|
+
}), [
|
|
257
|
+
3,
|
|
258
|
+
5
|
|
259
|
+
];
|
|
260
|
+
case 4:
|
|
261
|
+
return _this.app.LoadingView.hide(), [
|
|
262
|
+
7
|
|
263
|
+
];
|
|
264
|
+
case 5:
|
|
265
|
+
return [
|
|
266
|
+
2
|
|
267
|
+
];
|
|
268
|
+
}
|
|
72
269
|
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
this.upToDate() || this.checkUpdates(update);
|
|
76
|
-
const unacceptedModules = updatedModules.filter((moduleId) => renewedModules && renewedModules.indexOf(moduleId) < 0);
|
|
77
|
-
unacceptedModules.length ? (console.warn("[HMRClient] Not every module was accepted - full reload needed", {
|
|
78
|
-
unacceptedModules
|
|
79
|
-
}), this.app.reload()) : (console.log("[HMRClient] Renewed modules - app is up to date", {
|
|
80
|
-
renewedModules
|
|
81
|
-
}), this.app.dismissErrors());
|
|
82
|
-
} catch (error) {
|
|
83
|
-
module.hot?.status() === "fail" || module.hot?.status() === "abort" ? (console.warn("[HMRClient] Cannot check for update - full reload needed"), console.warn("[HMRClient]", error), this.app.reload()) : console.warn("[HMRClient] Update check failed", { error });
|
|
84
|
-
} finally {
|
|
85
|
-
this.app.LoadingView.hide();
|
|
270
|
+
})();
|
|
271
|
+
}
|
|
86
272
|
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
273
|
+
]), HMRClient2;
|
|
274
|
+
}(), loadHMRClient = function() {
|
|
275
|
+
var _require = require("react-native"), DevSettings = _require.DevSettings, Platform = _require.Platform, LoadingView = require("react-native/Libraries/Utilities/LoadingView"), reload = function() {
|
|
276
|
+
return DevSettings.reload();
|
|
277
|
+
}, dismissErrors = function() {
|
|
278
|
+
if (Platform.OS === "ios") {
|
|
279
|
+
var _NativeRedBox_dismiss, NativeRedBox = require("react-native/Libraries/NativeModules/specs/NativeRedBox").default;
|
|
280
|
+
NativeRedBox == null || (_NativeRedBox_dismiss = NativeRedBox.dismiss) === null || _NativeRedBox_dismiss === void 0 || _NativeRedBox_dismiss.call(NativeRedBox);
|
|
281
|
+
} else {
|
|
282
|
+
var NativeExceptionsManager = require("react-native/Libraries/Core/NativeExceptionsManager").default;
|
|
283
|
+
NativeExceptionsManager == null || NativeExceptionsManager.dismissRedbox();
|
|
284
|
+
}
|
|
285
|
+
var LogBoxData = require("react-native/Libraries/LogBox/Data/LogBoxData");
|
|
286
|
+
LogBoxData.clear();
|
|
92
287
|
};
|
|
93
|
-
new HMRClient({
|
|
288
|
+
new HMRClient({
|
|
289
|
+
reload,
|
|
290
|
+
dismissErrors,
|
|
291
|
+
LoadingView
|
|
292
|
+
});
|
|
94
293
|
};
|
|
95
294
|
export {
|
|
96
295
|
loadHMRClient
|
|
@@ -1,6 +1,6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,MAAKjD,IAAI8D,cAAa;;;;;AAEjB7C,+BAAAA,OAAAA,KAAAA,KACH0B,eAAAA,OAAOC,SAAG,QAAVD,iBAAAA,SAAAA,SAAAA,aAAYG,OAAM,OAAO,YAAUH,eAAAA,OAAOC,SAAG,QAAVD,iBAAAA,SAAAA,SAAAA,aAAYG,OAAM,OAAO,WAC9DnC,QAAQa,KAAK,0DAAA,GACbb,QAAQa,KAAK,eAAeP,KAAAA,GAC5B,MAAKjB,IAAI0D,OAAM,KAEf/C,QAAQa,KAAK,mCAAmC;kBAAEP;gBAAM,CAAA;;;;;AAG1D,6BAAKjB,IAAI8B,YAAYQ,KAAI;;;;;;;;;QAE7B,CAAA,EAAA;;;MA5JIvC;KA+JOgE,gBAAgB,WAAA;AAC3B,MAAkCC,WAAAA,QAAQ,cAAA,GAAlCC,cAA0BD,SAA1BC,aAAaC,WAAaF,SAAbE,UACfpC,cAAckC,QAAQ,8CAAA,GAEtBN,SAAS,WAAA;WAAMO,YAAYP,OAAM;KACjCI,gBAAgB,WAAA;AACpB,QAAII,SAASC,OAAO,OAAO;UAGzBC,uBAFMA,eACJJ,QAAQ,yDAAA,EAA2DK;AACrED,sBAAAA,SAAAA,wBAAAA,aAAcE,aAAO,QAArBF,0BAAAA,UAAAA,sBAAAA,KAAAA,YAAAA;IACF,OAAO;AACL,UAAMG,0BACJP,QAAQ,qDAAA,EAAuDK;AACjEE,iCAAAA,QAAAA,wBAAyBC,cAAa;IACxC;AAEA,QAAMC,aAAaT,QAAQ,+CAAA;AAC3BS,eAAWC,MAAK;EAClB;AAEA,MAAI3E,UAAU;IAAE2D;IAAQI;IAAehC;EAAY,CAAA;AACrD;",
|
|
5
|
+
"names": ["getDevServerLocation", "HMRClient", "app", "url", "socket", "lastHash", "port", "process", "env", "REACT_NATIVE_SERVER_PUBLIC_PORT", "hostname", "REACT_NATIVE_PLATFORM", "WebSocket", "console", "info", "onopen", "onclose", "onerror", "event", "error", "onmessage", "data", "JSON", "parse", "toString", "processMessage", "warn", "upToDate", "hash", "__webpack_hash__", "message", "action", "LoadingView", "showMessage", "name", "body", "time", "errors", "length", "forEach", "hide", "warnings", "warning", "applyUpdate", "update", "module", "hot", "Error", "status", "checkUpdates", "updatedModules", "renewedModules", "unacceptedModules", "check", "apply", "ignoreDeclined", "ignoreUnaccepted", "ignoreErrored", "onDeclined", "chain", "reload", "filter", "moduleId", "indexOf", "dismissErrors", "loadHMRClient", "require", "DevSettings", "Platform", "OS", "NativeRedBox", "default", "dismiss", "NativeExceptionsManager", "dismissRedbox", "LogBoxData", "clear"]
|
|
6
6
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./devServerClient.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/vite-native-hmr",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"pretty-format": "^28.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@tamagui/build": "
|
|
41
|
-
"react-native": "
|
|
40
|
+
"@tamagui/build": "^1.94.4",
|
|
41
|
+
"react-native": "0.73.2"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"react-native": "*"
|
package/src/hmr-client.ts
CHANGED
|
@@ -39,24 +39,25 @@ class HMRClient {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
const port = process.env.REACT_NATIVE_SERVER_PUBLIC_PORT || 8081
|
|
43
|
+
this.url = `ws://${getDevServerLocation().hostname}:${port}/__hmr?platform=${
|
|
44
|
+
process.env.REACT_NATIVE_PLATFORM || 'ios'
|
|
45
|
+
}`
|
|
45
46
|
|
|
46
47
|
this.socket = new WebSocket(this.url)
|
|
47
48
|
|
|
48
|
-
console.
|
|
49
|
+
console.info('[HMRClient] Connecting...')
|
|
49
50
|
|
|
50
51
|
this.socket.onopen = () => {
|
|
51
|
-
console.
|
|
52
|
+
console.info('[HMRClient] Connected')
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
this.socket.onclose = () => {
|
|
55
|
-
console.
|
|
56
|
+
console.info(`[HMRClient] Disconnected ${this.url}`)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
this.socket.onerror = (event) => {
|
|
59
|
-
console.
|
|
60
|
+
console.error('[HMRClient] Error', event)
|
|
60
61
|
}
|
|
61
62
|
|
|
62
63
|
this.socket.onmessage = (event) => {
|
|
@@ -81,12 +82,12 @@ class HMRClient {
|
|
|
81
82
|
switch (message.action) {
|
|
82
83
|
case 'building':
|
|
83
84
|
this.app.LoadingView.showMessage('Rebuilding...', 'refresh')
|
|
84
|
-
console.
|
|
85
|
+
console.info('[HMRClient] Bundle rebuilding', {
|
|
85
86
|
name: message.body?.name,
|
|
86
87
|
})
|
|
87
88
|
break
|
|
88
89
|
case 'built':
|
|
89
|
-
console.
|
|
90
|
+
console.info('[HMRClient] Bundle rebuilt', {
|
|
90
91
|
name: message.body?.name,
|
|
91
92
|
time: message.body?.time,
|
|
92
93
|
})
|
|
@@ -121,7 +122,7 @@ class HMRClient {
|
|
|
121
122
|
}
|
|
122
123
|
|
|
123
124
|
if (!this.upToDate(update.hash) && module.hot.status() === 'idle') {
|
|
124
|
-
console.
|
|
125
|
+
console.info('[HMRClient] Checking for updates on the server...')
|
|
125
126
|
this.checkUpdates(update)
|
|
126
127
|
}
|
|
127
128
|
}
|
|
@@ -163,7 +164,7 @@ class HMRClient {
|
|
|
163
164
|
})
|
|
164
165
|
this.app.reload()
|
|
165
166
|
} else {
|
|
166
|
-
console.
|
|
167
|
+
console.info('[HMRClient] Renewed modules - app is up to date', {
|
|
167
168
|
renewedModules,
|
|
168
169
|
})
|
|
169
170
|
this.app.dismissErrors()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hmr-client.d.ts","sourceRoot":"","sources":["../src/hmr-client.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,GAAG,EAAE,CAAA;IACf,MAAM,EAAE,GAAG,EAAE,CAAA;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;IACrC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;CAC5B;
|
|
1
|
+
{"version":3,"file":"hmr-client.d.ts","sourceRoot":"","sources":["../src/hmr-client.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,GAAG,EAAE,CAAA;IACf,MAAM,EAAE,GAAG,EAAE,CAAA;IACb,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAChC;AAED;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,UAAU,GAAG,OAAO,GAAG,MAAM,CAAA;IACrC,IAAI,EAAE,cAAc,GAAG,IAAI,CAAA;CAC5B;AAiKD,eAAO,MAAM,aAAa,YAqBzB,CAAA"}
|