@vxrn/vite-native-hmr 1.1.308 → 1.1.310
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 +134 -0
- package/dist/cjs/{getDevServerLocation.js → getDevServerLocation.cjs} +27 -15
- package/dist/cjs/{hmr-client.js → hmr-client.cjs} +43 -27
- package/dist/cjs/index.cjs +29 -0
- package/package.json +5 -5
- package/dist/cjs/devServerClient.js +0 -128
- package/dist/cjs/index.js +0 -22
- /package/dist/cjs/{devServerClient.js.map → devServerClient.cjs.map} +0 -0
- /package/dist/cjs/{getDevServerLocation.js.map → getDevServerLocation.cjs.map} +0 -0
- /package/dist/cjs/{hmr-client.js.map → hmr-client.cjs.map} +0 -0
- /package/dist/cjs/{index.js.map → index.cjs.map} +0 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
32
|
+
var devServerClient_exports = {};
|
|
33
|
+
__export(devServerClient_exports, {
|
|
34
|
+
client: () => client,
|
|
35
|
+
disable: () => disable,
|
|
36
|
+
enable: () => enable,
|
|
37
|
+
log: () => log,
|
|
38
|
+
registerBundle: () => registerBundle,
|
|
39
|
+
setup: () => setup
|
|
40
|
+
});
|
|
41
|
+
module.exports = __toCommonJS(devServerClient_exports);
|
|
42
|
+
var import_pretty_format = __toESM(require("pretty-format")),
|
|
43
|
+
import_getDevServerLocation = require("./getDevServerLocation.cjs"),
|
|
44
|
+
import_hmr_client = require("./hmr-client.cjs");
|
|
45
|
+
(0, import_hmr_client.loadHMRClient)();
|
|
46
|
+
class DevServerClient {
|
|
47
|
+
socket;
|
|
48
|
+
buffer = [];
|
|
49
|
+
constructor() {
|
|
50
|
+
const initSocket = () => {
|
|
51
|
+
const address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
|
|
52
|
+
this.socket = new WebSocket(address);
|
|
53
|
+
const onClose = event => {
|
|
54
|
+
console.warn("Disconnected from the Dev Server:", event.message), this.socket = void 0;
|
|
55
|
+
};
|
|
56
|
+
this.socket.onclose = onClose, this.socket.onerror = onClose, this.socket.onopen = () => {
|
|
57
|
+
this.flushBuffer();
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
process.env.NODE_ENV === "development" && initSocket();
|
|
61
|
+
}
|
|
62
|
+
send(level, data) {
|
|
63
|
+
try {
|
|
64
|
+
this.socket?.send(JSON.stringify({
|
|
65
|
+
type: "client-log",
|
|
66
|
+
level,
|
|
67
|
+
data: data.map(item => typeof item == "string" ? item : (0, import_pretty_format.default)(item, {
|
|
68
|
+
escapeString: !0,
|
|
69
|
+
highlight: !0,
|
|
70
|
+
maxDepth: 3,
|
|
71
|
+
min: !0,
|
|
72
|
+
plugins: [
|
|
73
|
+
// @ts-expect-error
|
|
74
|
+
import_pretty_format.default.plugins.ReactElement]
|
|
75
|
+
}))
|
|
76
|
+
}));
|
|
77
|
+
} catch {
|
|
78
|
+
try {
|
|
79
|
+
this.socket?.send(JSON.stringify({
|
|
80
|
+
type: "client-log",
|
|
81
|
+
level,
|
|
82
|
+
data: data.map((item, index) => {
|
|
83
|
+
try {
|
|
84
|
+
return typeof item == "string" ? item : JSON.stringify(item);
|
|
85
|
+
} catch (err) {
|
|
86
|
+
return `Error stringifying item at index ${index} - ${item} - ${err}`;
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
}));
|
|
90
|
+
} catch (err) {
|
|
91
|
+
try {
|
|
92
|
+
this.socket?.send(JSON.stringify({
|
|
93
|
+
type: "client-log",
|
|
94
|
+
level: "error",
|
|
95
|
+
data: ["error sending client log: " + err]
|
|
96
|
+
}));
|
|
97
|
+
} catch {}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
flushBuffer() {
|
|
102
|
+
globalThis.__vxrnTmpLogs && (globalThis.__vxrnTmpLogs.forEach(({
|
|
103
|
+
level,
|
|
104
|
+
data
|
|
105
|
+
}) => {
|
|
106
|
+
this.buffer.push({
|
|
107
|
+
level,
|
|
108
|
+
data
|
|
109
|
+
});
|
|
110
|
+
}), delete globalThis.__vxrnTmpLogs);
|
|
111
|
+
for (const {
|
|
112
|
+
level,
|
|
113
|
+
data
|
|
114
|
+
} of this.buffer) this.send(level, data);
|
|
115
|
+
this.buffer = [];
|
|
116
|
+
}
|
|
117
|
+
log(level, data) {
|
|
118
|
+
if (level !== "groupEnd") if (this.socket && this.socket.readyState === WebSocket.OPEN) this.flushBuffer(), this.send(level, data);else {
|
|
119
|
+
if (globalThis.__vxrnTmpLogs) return;
|
|
120
|
+
this.buffer.push({
|
|
121
|
+
level,
|
|
122
|
+
data
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const client = new DevServerClient(),
|
|
128
|
+
setup = () => {},
|
|
129
|
+
enable = () => {},
|
|
130
|
+
disable = () => {},
|
|
131
|
+
registerBundle = () => {},
|
|
132
|
+
log = (level, data) => {
|
|
133
|
+
client.log(level, data);
|
|
134
|
+
};
|
|
@@ -2,24 +2,33 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf,
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf,
|
|
6
|
+
__hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
7
|
var __export = (target, all) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: !0
|
|
11
|
+
});
|
|
12
|
+
},
|
|
13
|
+
__copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
15
|
+
get: () => from[key],
|
|
16
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
+
});
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
15
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
21
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
22
|
// file that has been converted to a CommonJS file using a Babel-
|
|
18
23
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
24
|
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
26
|
+
value: mod,
|
|
27
|
+
enumerable: !0
|
|
28
|
+
}) : target, mod)),
|
|
29
|
+
__toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
30
|
+
value: !0
|
|
31
|
+
}), mod);
|
|
23
32
|
var getDevServerLocation_exports = {};
|
|
24
33
|
__export(getDevServerLocation_exports, {
|
|
25
34
|
getDevServerLocation: () => getDevServerLocation
|
|
@@ -29,7 +38,11 @@ var import_getDevServer = __toESM(require("react-native/Libraries/Core/Devtools/
|
|
|
29
38
|
let location;
|
|
30
39
|
function getDevServerLocation() {
|
|
31
40
|
if (!location) {
|
|
32
|
-
const {
|
|
41
|
+
const {
|
|
42
|
+
url
|
|
43
|
+
} = (0, import_getDevServer.default)(),
|
|
44
|
+
origin = url.replace(/\/$/, ""),
|
|
45
|
+
host = origin.replace(/https?:\/\//, "");
|
|
33
46
|
location = {
|
|
34
47
|
host,
|
|
35
48
|
hostname: host.split(":")[0],
|
|
@@ -41,5 +54,4 @@ function getDevServerLocation() {
|
|
|
41
54
|
};
|
|
42
55
|
}
|
|
43
56
|
return location;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=getDevServerLocation.js.map
|
|
57
|
+
}
|
|
@@ -3,21 +3,27 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), mod);
|
|
15
21
|
var hmr_client_exports = {};
|
|
16
22
|
__export(hmr_client_exports, {
|
|
17
23
|
loadHMRClient: () => loadHMRClient
|
|
18
24
|
});
|
|
19
25
|
module.exports = __toCommonJS(hmr_client_exports);
|
|
20
|
-
var import_getDevServerLocation = require("./getDevServerLocation");
|
|
26
|
+
var import_getDevServerLocation = require("./getDevServerLocation.cjs");
|
|
21
27
|
class HMRClient {
|
|
22
28
|
constructor(app) {
|
|
23
29
|
this.app = app;
|
|
@@ -26,9 +32,9 @@ class HMRClient {
|
|
|
26
32
|
console.info(" \u24F5 [hmr] connected");
|
|
27
33
|
}, this.socket.onclose = () => {
|
|
28
34
|
console.info(` \u24F5 [hmr] disconnected ${this.url}`);
|
|
29
|
-
}, this.socket.onerror =
|
|
35
|
+
}, this.socket.onerror = event => {
|
|
30
36
|
console.error(" \u24F5 [hmr] error", event);
|
|
31
|
-
}, this.socket.onmessage =
|
|
37
|
+
}, this.socket.onmessage = event => {
|
|
32
38
|
try {
|
|
33
39
|
const data = JSON.parse(event.data.toString());
|
|
34
40
|
this.processMessage(data);
|
|
@@ -63,24 +69,23 @@ class HMRClient {
|
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
71
|
if (message.body.errors?.length) {
|
|
66
|
-
message.body.errors.forEach(
|
|
72
|
+
message.body.errors.forEach(error => {
|
|
67
73
|
console.error("Cannot apply update due to error:", error);
|
|
68
74
|
}), this.app.LoadingView.hide();
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
|
-
message.body.warnings?.length && message.body.warnings.forEach(
|
|
77
|
+
message.body.warnings?.length && message.body.warnings.forEach(warning => {
|
|
72
78
|
console.warn(" \u24F5 [hmr] bundle contains warnings:", warning);
|
|
73
79
|
}), this.applyUpdate(message.body);
|
|
74
80
|
}
|
|
75
81
|
}
|
|
76
82
|
applyUpdate(update) {
|
|
77
|
-
if (!module.hot)
|
|
78
|
-
throw new Error(" \u24F5 [hmr] hot Module Replacement is disabled.");
|
|
83
|
+
if (!module.hot) throw new Error(" \u24F5 [hmr] hot Module Replacement is disabled.");
|
|
79
84
|
!this.upToDate(update.hash) && module.hot.status() === "idle" && (console.info(" \u24F5 [hmr] checking for updates on the server..."), this.checkUpdates(update));
|
|
80
85
|
}
|
|
81
86
|
checkUpdates(update) {
|
|
82
87
|
try {
|
|
83
|
-
this.app.LoadingView.showMessage("Refreshing...", "refresh"), module.hot?.check(!1).then(
|
|
88
|
+
this.app.LoadingView.showMessage("Refreshing...", "refresh"), module.hot?.check(!1).then(updatedModules => {
|
|
84
89
|
if (!updatedModules) {
|
|
85
90
|
console.warn(" \u24F5 [hmr] cannot find update - full reload needed"), this.app.reload();
|
|
86
91
|
return;
|
|
@@ -89,14 +94,14 @@ class HMRClient {
|
|
|
89
94
|
ignoreDeclined: !0,
|
|
90
95
|
ignoreUnaccepted: !1,
|
|
91
96
|
ignoreErrored: !1,
|
|
92
|
-
onDeclined:
|
|
97
|
+
onDeclined: data => {
|
|
93
98
|
console.warn(" \u24F5 [hmr] ignored an update due to declined module", {
|
|
94
99
|
chain: data.chain
|
|
95
100
|
});
|
|
96
101
|
}
|
|
97
|
-
}).then(
|
|
102
|
+
}).then(renewedModules => {
|
|
98
103
|
this.upToDate() || this.checkUpdates(update);
|
|
99
|
-
const unacceptedModules = updatedModules.filter(
|
|
104
|
+
const unacceptedModules = updatedModules.filter(moduleId => renewedModules && renewedModules.indexOf(moduleId) < 0);
|
|
100
105
|
unacceptedModules.length ? (console.warn(" \u24F5 [hmr] not every module was accepted - full reload needed", {
|
|
101
106
|
unacceptedModules
|
|
102
107
|
}), this.app.reload()) : (console.info(" \u24F5 [hmr] renewed modules - app is up to date", {
|
|
@@ -105,16 +110,27 @@ class HMRClient {
|
|
|
105
110
|
});
|
|
106
111
|
});
|
|
107
112
|
} catch (error) {
|
|
108
|
-
module.hot?.status() === "fail" || module.hot?.status() === "abort" ? (console.warn(" \u24F5 [hmr] cannot check for update - full reload needed"), console.warn("[hmr]", error), this.app.reload()) : console.warn(" \u24F5 [hmr] update check failed", {
|
|
113
|
+
module.hot?.status() === "fail" || module.hot?.status() === "abort" ? (console.warn(" \u24F5 [hmr] cannot check for update - full reload needed"), console.warn("[hmr]", error), this.app.reload()) : console.warn(" \u24F5 [hmr] update check failed", {
|
|
114
|
+
error
|
|
115
|
+
});
|
|
109
116
|
} finally {
|
|
110
117
|
this.app.LoadingView.hide();
|
|
111
118
|
}
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
const loadHMRClient = () => {
|
|
115
|
-
const {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
const {
|
|
123
|
+
DevSettings,
|
|
124
|
+
Platform
|
|
125
|
+
} = require("react-native-web"),
|
|
126
|
+
LoadingView = require("react-native/Libraries/Utilities/LoadingView"),
|
|
127
|
+
reload = () => DevSettings.reload(),
|
|
128
|
+
dismissErrors = () => {
|
|
129
|
+
Platform.OS === "ios" ? require("react-native/Libraries/NativeModules/specs/NativeRedBox").default?.dismiss?.() : require("react-native/Libraries/Core/NativeExceptionsManager").default?.dismissRedbox(), require("react-native/Libraries/LogBox/Data/LogBoxData").clear();
|
|
130
|
+
};
|
|
131
|
+
new HMRClient({
|
|
132
|
+
reload,
|
|
133
|
+
dismissErrors,
|
|
134
|
+
LoadingView
|
|
135
|
+
});
|
|
136
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: !0
|
|
9
|
+
});
|
|
10
|
+
},
|
|
11
|
+
__copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, {
|
|
13
|
+
get: () => from[key],
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
return to;
|
|
17
|
+
},
|
|
18
|
+
__reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
|
+
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
20
|
+
value: !0
|
|
21
|
+
}), mod);
|
|
22
|
+
var src_exports = {};
|
|
23
|
+
__export(src_exports, {
|
|
24
|
+
default: () => src_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
__reExport(src_exports, require("./devServerClient.cjs"), module.exports);
|
|
28
|
+
var import_devServerClient = require("./devServerClient.cjs"),
|
|
29
|
+
src_default = import_devServerClient.client;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vxrn/vite-native-hmr",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.310",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./types/index.d.ts",
|
|
22
22
|
"import": "./dist/esm/index.js",
|
|
23
|
-
"require": "./dist/cjs/index.
|
|
23
|
+
"require": "./dist/cjs/index.cjs"
|
|
24
24
|
},
|
|
25
25
|
"./hmr-client": {
|
|
26
26
|
"types": "./types/hmr-client.d.ts",
|
|
27
27
|
"import": "./dist/esm/hmr-client.js",
|
|
28
|
-
"require": "./dist/cjs/hmr-client.
|
|
28
|
+
"require": "./dist/cjs/hmr-client.cjs"
|
|
29
29
|
},
|
|
30
30
|
"./hmr-vite": {
|
|
31
31
|
"types": "./types/client.d.ts",
|
|
32
32
|
"import": "./dist/esm/client.js",
|
|
33
|
-
"require": "./dist/cjs/client.
|
|
33
|
+
"require": "./dist/cjs/client.cjs"
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"pretty-format": "^28.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@tamagui/build": "^1.
|
|
40
|
+
"@tamagui/build": "^1.115.0",
|
|
41
41
|
"react-native": "0.74.5"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
9
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
-
return to;
|
|
14
|
-
};
|
|
15
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
|
|
21
|
-
mod
|
|
22
|
-
)), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
23
|
-
var devServerClient_exports = {};
|
|
24
|
-
__export(devServerClient_exports, {
|
|
25
|
-
client: () => client,
|
|
26
|
-
disable: () => disable,
|
|
27
|
-
enable: () => enable,
|
|
28
|
-
log: () => log,
|
|
29
|
-
registerBundle: () => registerBundle,
|
|
30
|
-
setup: () => setup
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(devServerClient_exports);
|
|
33
|
-
var import_pretty_format = __toESM(require("pretty-format")), import_getDevServerLocation = require("./getDevServerLocation"), import_hmr_client = require("./hmr-client");
|
|
34
|
-
(0, import_hmr_client.loadHMRClient)();
|
|
35
|
-
class DevServerClient {
|
|
36
|
-
socket;
|
|
37
|
-
buffer = [];
|
|
38
|
-
constructor() {
|
|
39
|
-
const initSocket = () => {
|
|
40
|
-
const address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
|
|
41
|
-
this.socket = new WebSocket(address);
|
|
42
|
-
const onClose = (event) => {
|
|
43
|
-
console.warn(
|
|
44
|
-
"Disconnected from the Dev Server:",
|
|
45
|
-
event.message
|
|
46
|
-
), this.socket = void 0;
|
|
47
|
-
};
|
|
48
|
-
this.socket.onclose = onClose, this.socket.onerror = onClose, this.socket.onopen = () => {
|
|
49
|
-
this.flushBuffer();
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
process.env.NODE_ENV === "development" && initSocket();
|
|
53
|
-
}
|
|
54
|
-
send(level, data) {
|
|
55
|
-
try {
|
|
56
|
-
this.socket?.send(
|
|
57
|
-
JSON.stringify({
|
|
58
|
-
type: "client-log",
|
|
59
|
-
level,
|
|
60
|
-
data: data.map(
|
|
61
|
-
(item) => typeof item == "string" ? item : (0, import_pretty_format.default)(item, {
|
|
62
|
-
escapeString: !0,
|
|
63
|
-
highlight: !0,
|
|
64
|
-
maxDepth: 3,
|
|
65
|
-
min: !0,
|
|
66
|
-
plugins: [
|
|
67
|
-
// @ts-expect-error
|
|
68
|
-
import_pretty_format.default.plugins.ReactElement
|
|
69
|
-
]
|
|
70
|
-
})
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
} catch {
|
|
75
|
-
try {
|
|
76
|
-
this.socket?.send(
|
|
77
|
-
JSON.stringify({
|
|
78
|
-
type: "client-log",
|
|
79
|
-
level,
|
|
80
|
-
data: data.map((item, index) => {
|
|
81
|
-
try {
|
|
82
|
-
return typeof item == "string" ? item : JSON.stringify(item);
|
|
83
|
-
} catch (err) {
|
|
84
|
-
return `Error stringifying item at index ${index} - ${item} - ${err}`;
|
|
85
|
-
}
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
);
|
|
89
|
-
} catch (err) {
|
|
90
|
-
try {
|
|
91
|
-
this.socket?.send(
|
|
92
|
-
JSON.stringify({
|
|
93
|
-
type: "client-log",
|
|
94
|
-
level: "error",
|
|
95
|
-
data: ["error sending client log: " + err]
|
|
96
|
-
})
|
|
97
|
-
);
|
|
98
|
-
} catch {
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
flushBuffer() {
|
|
104
|
-
globalThis.__vxrnTmpLogs && (globalThis.__vxrnTmpLogs.forEach(({ level, data }) => {
|
|
105
|
-
this.buffer.push({ level, data });
|
|
106
|
-
}), delete globalThis.__vxrnTmpLogs);
|
|
107
|
-
for (const { level, data } of this.buffer)
|
|
108
|
-
this.send(level, data);
|
|
109
|
-
this.buffer = [];
|
|
110
|
-
}
|
|
111
|
-
log(level, data) {
|
|
112
|
-
if (level !== "groupEnd")
|
|
113
|
-
if (this.socket && this.socket.readyState === WebSocket.OPEN)
|
|
114
|
-
this.flushBuffer(), this.send(level, data);
|
|
115
|
-
else {
|
|
116
|
-
if (globalThis.__vxrnTmpLogs) return;
|
|
117
|
-
this.buffer.push({ level, data });
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const client = new DevServerClient(), setup = () => {
|
|
122
|
-
}, enable = () => {
|
|
123
|
-
}, disable = () => {
|
|
124
|
-
}, registerBundle = () => {
|
|
125
|
-
}, log = (level, data) => {
|
|
126
|
-
client.log(level, data);
|
|
127
|
-
};
|
|
128
|
-
//# sourceMappingURL=devServerClient.js.map
|
package/dist/cjs/index.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
}, __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var src_exports = {};
|
|
16
|
-
__export(src_exports, {
|
|
17
|
-
default: () => src_default
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(src_exports);
|
|
20
|
-
__reExport(src_exports, require("./devServerClient"), module.exports);
|
|
21
|
-
var import_devServerClient = require("./devServerClient"), src_default = import_devServerClient.client;
|
|
22
|
-
//# sourceMappingURL=index.js.map
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|