@vxrn/vite-native-hmr 2.0.0-beta.33.1 → 2.0.0-beta.45.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 +2 -2
- package/types/devServerClient.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var hmr_client_exports = {};
|
|
24
|
+
__export(hmr_client_exports, { loadHMRClient: () => loadHMRClient });
|
|
25
|
+
module.exports = __toCommonJS(hmr_client_exports);
|
|
26
|
+
var import_getDevServerLocation = require("./getDevServerLocation.native.js");
|
|
27
|
+
function _class_call_check(instance, Constructor) {
|
|
28
|
+
if (!(instance instanceof Constructor)) {
|
|
29
|
+
throw new TypeError("Cannot call a class as a function");
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function _defineProperties(target, props) {
|
|
33
|
+
for (var i = 0; i < props.length; i++) {
|
|
34
|
+
var descriptor = props[i];
|
|
35
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
36
|
+
descriptor.configurable = true;
|
|
37
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
38
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
42
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
43
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
44
|
+
return Constructor;
|
|
45
|
+
}
|
|
46
|
+
function _define_property(obj, key, value) {
|
|
47
|
+
if (key in obj) {
|
|
48
|
+
Object.defineProperty(obj, key, {
|
|
49
|
+
value,
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true,
|
|
52
|
+
writable: true
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
obj[key] = value;
|
|
56
|
+
}
|
|
57
|
+
return obj;
|
|
58
|
+
}
|
|
59
|
+
var HMRClient = /* @__PURE__ */ (function() {
|
|
60
|
+
"use strict";
|
|
61
|
+
function HMRClient2(app) {
|
|
62
|
+
var _this = this;
|
|
63
|
+
_class_call_check(this, HMRClient2);
|
|
64
|
+
_define_property(this, "app", void 0);
|
|
65
|
+
_define_property(this, "url", void 0);
|
|
66
|
+
_define_property(this, "socket", void 0);
|
|
67
|
+
_define_property(this, "lastHash", void 0);
|
|
68
|
+
this.app = app;
|
|
69
|
+
this.lastHash = "";
|
|
70
|
+
var port = process.env.REACT_NATIVE_SERVER_PUBLIC_PORT || 8081;
|
|
71
|
+
this.url = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().hostname}:${port}/__hmr?platform=${process.env.REACT_NATIVE_PLATFORM || "ios"}`;
|
|
72
|
+
this.socket = new WebSocket(this.url);
|
|
73
|
+
console.info(" ⓵ [hmr] connecting...");
|
|
74
|
+
this.socket.onopen = function() {
|
|
75
|
+
console.info(" ⓵ [hmr] connected");
|
|
76
|
+
};
|
|
77
|
+
this.socket.onclose = function() {
|
|
78
|
+
console.info(` \u24F5 [hmr] disconnected ${_this.url}`);
|
|
79
|
+
};
|
|
80
|
+
this.socket.onerror = function(event) {
|
|
81
|
+
console.error(" ⓵ [hmr] error", event);
|
|
82
|
+
};
|
|
83
|
+
this.socket.onmessage = function(event) {
|
|
84
|
+
try {
|
|
85
|
+
var data = JSON.parse(event.data.toString());
|
|
86
|
+
_this.processMessage(data);
|
|
87
|
+
} catch (error) {
|
|
88
|
+
console.warn(" ⓵ [hmr] invalid message", error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
_create_class(HMRClient2, [
|
|
93
|
+
{
|
|
94
|
+
key: "upToDate",
|
|
95
|
+
value: function upToDate(hash) {
|
|
96
|
+
if (hash) {
|
|
97
|
+
this.lastHash = hash;
|
|
98
|
+
}
|
|
99
|
+
return this.lastHash === __webpack_hash__;
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
key: "processMessage",
|
|
104
|
+
value: function processMessage(message) {
|
|
105
|
+
switch (message.action) {
|
|
106
|
+
case "building":
|
|
107
|
+
var _message_body;
|
|
108
|
+
this.app.LoadingView.showMessage("Rebuilding...", "refresh");
|
|
109
|
+
console.info(" ⓵ [hmr] bundle rebuilding", { name: (_message_body = message.body) === null || _message_body === void 0 ? void 0 : _message_body.name });
|
|
110
|
+
break;
|
|
111
|
+
case "built":
|
|
112
|
+
var _message_body1, _message_body2;
|
|
113
|
+
console.info(" ⓵ [hmr] bundle rebuilt", {
|
|
114
|
+
name: (_message_body1 = message.body) === null || _message_body1 === void 0 ? void 0 : _message_body1.name,
|
|
115
|
+
time: (_message_body2 = message.body) === null || _message_body2 === void 0 ? void 0 : _message_body2.time
|
|
116
|
+
});
|
|
117
|
+
case "sync":
|
|
118
|
+
var _message_body_errors, _message_body_warnings;
|
|
119
|
+
if (!message.body) {
|
|
120
|
+
console.warn(" ⓵ [hmr] message body is empty");
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if ((_message_body_errors = message.body.errors) === null || _message_body_errors === void 0 ? void 0 : _message_body_errors.length) {
|
|
124
|
+
message.body.errors.forEach(function(error) {
|
|
125
|
+
console.error("Cannot apply update due to error:", error);
|
|
126
|
+
});
|
|
127
|
+
this.app.LoadingView.hide();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if ((_message_body_warnings = message.body.warnings) === null || _message_body_warnings === void 0 ? void 0 : _message_body_warnings.length) {
|
|
131
|
+
message.body.warnings.forEach(function(warning) {
|
|
132
|
+
console.warn(" ⓵ [hmr] bundle contains warnings:", warning);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
this.applyUpdate(message.body);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
key: "applyUpdate",
|
|
141
|
+
value: function applyUpdate(update) {
|
|
142
|
+
if (!module.hot) {
|
|
143
|
+
throw new Error(" ⓵ [hmr] hot Module Replacement is disabled.");
|
|
144
|
+
}
|
|
145
|
+
if (!this.upToDate(update.hash) && module.hot.status() === "idle") {
|
|
146
|
+
console.info(" ⓵ [hmr] checking for updates on the server...");
|
|
147
|
+
this.checkUpdates(update);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: "checkUpdates",
|
|
153
|
+
value: function checkUpdates(update) {
|
|
154
|
+
var _this = this;
|
|
155
|
+
try {
|
|
156
|
+
var _module_hot;
|
|
157
|
+
this.app.LoadingView.showMessage("Refreshing...", "refresh");
|
|
158
|
+
(_module_hot = module.hot) === null || _module_hot === void 0 ? void 0 : _module_hot.check(false).then(function(updatedModules) {
|
|
159
|
+
var _module_hot3;
|
|
160
|
+
if (!updatedModules) {
|
|
161
|
+
console.warn(" ⓵ [hmr] cannot find update - full reload needed");
|
|
162
|
+
_this.app.reload();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
(_module_hot3 = module.hot) === null || _module_hot3 === void 0 ? void 0 : _module_hot3.apply({
|
|
166
|
+
ignoreDeclined: true,
|
|
167
|
+
ignoreUnaccepted: false,
|
|
168
|
+
ignoreErrored: false,
|
|
169
|
+
onDeclined: function(data) {
|
|
170
|
+
console.warn(" ⓵ [hmr] ignored an update due to declined module", { chain: data.chain });
|
|
171
|
+
}
|
|
172
|
+
}).then(function(renewedModules) {
|
|
173
|
+
if (!_this.upToDate()) {
|
|
174
|
+
_this.checkUpdates(update);
|
|
175
|
+
}
|
|
176
|
+
var unacceptedModules = updatedModules.filter(function(moduleId) {
|
|
177
|
+
return renewedModules && renewedModules.indexOf(moduleId) < 0;
|
|
178
|
+
});
|
|
179
|
+
if (unacceptedModules.length) {
|
|
180
|
+
console.warn(" ⓵ [hmr] not every module was accepted - full reload needed", { unacceptedModules });
|
|
181
|
+
_this.app.reload();
|
|
182
|
+
} else {
|
|
183
|
+
console.info(" ⓵ [hmr] renewed modules - app is up to date", { renewedModules });
|
|
184
|
+
_this.app.dismissErrors();
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
} catch (error) {
|
|
189
|
+
var _module_hot1, _module_hot2;
|
|
190
|
+
if (((_module_hot1 = module.hot) === null || _module_hot1 === void 0 ? void 0 : _module_hot1.status()) === "fail" || ((_module_hot2 = module.hot) === null || _module_hot2 === void 0 ? void 0 : _module_hot2.status()) === "abort") {
|
|
191
|
+
console.warn(" ⓵ [hmr] cannot check for update - full reload needed");
|
|
192
|
+
console.warn("[hmr]", error);
|
|
193
|
+
this.app.reload();
|
|
194
|
+
} else {
|
|
195
|
+
console.warn(" ⓵ [hmr] update check failed", { error });
|
|
196
|
+
}
|
|
197
|
+
} finally {
|
|
198
|
+
this.app.LoadingView.hide();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
]);
|
|
203
|
+
return HMRClient2;
|
|
204
|
+
})();
|
|
205
|
+
var loadHMRClient = function() {
|
|
206
|
+
var { DevSettings, Platform } = require("react-native");
|
|
207
|
+
var LoadingView = {
|
|
208
|
+
showMessage: function() {},
|
|
209
|
+
hide: function() {}
|
|
210
|
+
};
|
|
211
|
+
var reload = function() {
|
|
212
|
+
return DevSettings.reload();
|
|
213
|
+
};
|
|
214
|
+
var dismissErrors = function() {
|
|
215
|
+
if (Platform.OS === "ios") {
|
|
216
|
+
var _NativeRedBox_dismiss;
|
|
217
|
+
var NativeRedBox = require("react-native/Libraries/NativeModules/specs/NativeRedBox").default;
|
|
218
|
+
NativeRedBox === null || NativeRedBox === void 0 ? void 0 : (_NativeRedBox_dismiss = NativeRedBox.dismiss) === null || _NativeRedBox_dismiss === void 0 ? void 0 : _NativeRedBox_dismiss.call(NativeRedBox);
|
|
219
|
+
} else {
|
|
220
|
+
var NativeExceptionsManager = require("react-native/Libraries/Core/NativeExceptionsManager").default;
|
|
221
|
+
NativeExceptionsManager === null || NativeExceptionsManager === void 0 ? void 0 : NativeExceptionsManager.dismissRedbox();
|
|
222
|
+
}
|
|
223
|
+
var LogBoxData = require("react-native/Libraries/LogBox/Data/LogBoxData");
|
|
224
|
+
LogBoxData.clear();
|
|
225
|
+
};
|
|
226
|
+
new HMRClient({
|
|
227
|
+
reload,
|
|
228
|
+
dismissErrors,
|
|
229
|
+
LoadingView
|
|
230
|
+
});
|
|
231
|
+
};
|