@vxrn/vite-native-hmr 2.0.0-beta.33.1 → 2.0.0-beta.46.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 +4 -4
- package/types/devServerClient.d.ts.map +1 -1
- package/types/index.d.ts.map +1 -1
|
@@ -5,150 +5,134 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
21
|
};
|
|
22
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
26
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
27
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
30
25
|
}) : target, mod));
|
|
31
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
32
|
-
value: true
|
|
33
|
-
}), mod);
|
|
26
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
27
|
var devServerClient_exports = {};
|
|
35
28
|
__export(devServerClient_exports, {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
29
|
+
client: () => client,
|
|
30
|
+
disable: () => disable,
|
|
31
|
+
enable: () => enable,
|
|
32
|
+
log: () => log,
|
|
33
|
+
registerBundle: () => registerBundle,
|
|
34
|
+
setup: () => setup
|
|
42
35
|
});
|
|
43
36
|
module.exports = __toCommonJS(devServerClient_exports);
|
|
44
37
|
var import_pretty_format = __toESM(require("pretty-format"));
|
|
45
38
|
var import_getDevServerLocation = require("./getDevServerLocation.cjs");
|
|
46
39
|
var import_hmr_client = require("./hmr-client.cjs");
|
|
47
40
|
(0, import_hmr_client.loadHMRClient)();
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.buffer.push({
|
|
139
|
-
level,
|
|
140
|
-
data
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
// Mock for React Native 0.79 to prevent native error "getPropertyAsObject: property 'setup' is undefined, expected an Object"
|
|
145
|
-
setup() {}
|
|
146
|
-
}
|
|
41
|
+
var DevServerClient = class {
|
|
42
|
+
socket;
|
|
43
|
+
buffer = [];
|
|
44
|
+
constructor() {
|
|
45
|
+
const initSocket = () => {
|
|
46
|
+
const address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
|
|
47
|
+
this.socket = new WebSocket(address);
|
|
48
|
+
const onClose = (event) => {
|
|
49
|
+
console.warn("Disconnected from the Dev Server:", event.message);
|
|
50
|
+
this.socket = void 0;
|
|
51
|
+
};
|
|
52
|
+
this.socket.onclose = onClose;
|
|
53
|
+
this.socket.onerror = onClose;
|
|
54
|
+
this.socket.onopen = () => {
|
|
55
|
+
this.flushBuffer();
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
if (process.env.NODE_ENV === "development") {
|
|
59
|
+
initSocket();
|
|
60
|
+
}
|
|
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: true,
|
|
69
|
+
highlight: true,
|
|
70
|
+
maxDepth: 3,
|
|
71
|
+
min: true,
|
|
72
|
+
plugins: [import_pretty_format.default.plugins.ReactElement]
|
|
73
|
+
}))
|
|
74
|
+
}));
|
|
75
|
+
} catch {
|
|
76
|
+
try {
|
|
77
|
+
this.socket?.send(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
|
+
} catch (err) {
|
|
89
|
+
try {
|
|
90
|
+
this.socket?.send(JSON.stringify({
|
|
91
|
+
type: "client-log",
|
|
92
|
+
level: "error",
|
|
93
|
+
data: ["error sending client log: " + err]
|
|
94
|
+
}));
|
|
95
|
+
} catch {}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
flushBuffer() {
|
|
100
|
+
if (globalThis["__vxrnTmpLogs"]) {
|
|
101
|
+
globalThis["__vxrnTmpLogs"].forEach(({ level, data }) => {
|
|
102
|
+
this.buffer.push({
|
|
103
|
+
level,
|
|
104
|
+
data
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
delete globalThis["__vxrnTmpLogs"];
|
|
108
|
+
}
|
|
109
|
+
for (const { level, data } of this.buffer) {
|
|
110
|
+
this.send(level, data);
|
|
111
|
+
}
|
|
112
|
+
this.buffer = [];
|
|
113
|
+
}
|
|
114
|
+
log(level, data) {
|
|
115
|
+
if (level === "groupEnd") {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
119
|
+
this.flushBuffer();
|
|
120
|
+
this.send(level, data);
|
|
121
|
+
} else {
|
|
122
|
+
if (globalThis["__vxrnTmpLogs"]) return;
|
|
123
|
+
this.buffer.push({
|
|
124
|
+
level,
|
|
125
|
+
data
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setup() {}
|
|
130
|
+
};
|
|
147
131
|
const client = new DevServerClient();
|
|
148
132
|
const setup = () => {};
|
|
149
133
|
const enable = () => {};
|
|
150
134
|
const disable = () => {};
|
|
151
135
|
const registerBundle = () => {};
|
|
152
136
|
const log = (level, data) => {
|
|
153
|
-
|
|
154
|
-
};
|
|
137
|
+
client.log(level, data);
|
|
138
|
+
};
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __export = (target, all) => {
|
|
10
|
+
for (var name in all) __defProp(target, name, {
|
|
11
|
+
get: all[name],
|
|
12
|
+
enumerable: true
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
var __copyProps = (to, from, except, desc) => {
|
|
16
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
17
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
18
|
+
get: () => from[key],
|
|
19
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
25
|
+
value: mod,
|
|
26
|
+
enumerable: true
|
|
27
|
+
}) : target, mod));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var devServerClient_exports = {};
|
|
30
|
+
__export(devServerClient_exports, {
|
|
31
|
+
client: () => client,
|
|
32
|
+
disable: () => disable,
|
|
33
|
+
enable: () => enable,
|
|
34
|
+
log: () => log,
|
|
35
|
+
registerBundle: () => registerBundle,
|
|
36
|
+
setup: () => setup
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(devServerClient_exports);
|
|
39
|
+
var import_pretty_format = __toESM(require("pretty-format"));
|
|
40
|
+
var import_getDevServerLocation = require("./getDevServerLocation.native.js");
|
|
41
|
+
var import_hmr_client = require("./hmr-client.native.js");
|
|
42
|
+
function _class_call_check(instance, Constructor) {
|
|
43
|
+
if (!(instance instanceof Constructor)) {
|
|
44
|
+
throw new TypeError("Cannot call a class as a function");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function _defineProperties(target, props) {
|
|
48
|
+
for (var i = 0; i < props.length; i++) {
|
|
49
|
+
var descriptor = props[i];
|
|
50
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
51
|
+
descriptor.configurable = true;
|
|
52
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
53
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
57
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
58
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
59
|
+
return Constructor;
|
|
60
|
+
}
|
|
61
|
+
function _define_property(obj, key, value) {
|
|
62
|
+
if (key in obj) {
|
|
63
|
+
Object.defineProperty(obj, key, {
|
|
64
|
+
value,
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true
|
|
68
|
+
});
|
|
69
|
+
} else {
|
|
70
|
+
obj[key] = value;
|
|
71
|
+
}
|
|
72
|
+
return obj;
|
|
73
|
+
}
|
|
74
|
+
(0, import_hmr_client.loadHMRClient)();
|
|
75
|
+
var DevServerClient = /* @__PURE__ */ (function() {
|
|
76
|
+
"use strict";
|
|
77
|
+
function DevServerClient2() {
|
|
78
|
+
var _this = this;
|
|
79
|
+
_class_call_check(this, DevServerClient2);
|
|
80
|
+
_define_property(this, "socket", void 0);
|
|
81
|
+
_define_property(this, "buffer", []);
|
|
82
|
+
var initSocket = function() {
|
|
83
|
+
var address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
|
|
84
|
+
_this.socket = new WebSocket(address);
|
|
85
|
+
var onClose = function(event) {
|
|
86
|
+
console.warn("Disconnected from the Dev Server:", event.message);
|
|
87
|
+
_this.socket = void 0;
|
|
88
|
+
};
|
|
89
|
+
_this.socket.onclose = onClose;
|
|
90
|
+
_this.socket.onerror = onClose;
|
|
91
|
+
_this.socket.onopen = function() {
|
|
92
|
+
_this.flushBuffer();
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
if (process.env.NODE_ENV === "development") {
|
|
96
|
+
initSocket();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
_create_class(DevServerClient2, [
|
|
100
|
+
{
|
|
101
|
+
key: "send",
|
|
102
|
+
value: function send(level, data) {
|
|
103
|
+
try {
|
|
104
|
+
var _this_socket;
|
|
105
|
+
(_this_socket = this.socket) === null || _this_socket === void 0 ? void 0 : _this_socket.send(JSON.stringify({
|
|
106
|
+
type: "client-log",
|
|
107
|
+
level,
|
|
108
|
+
data: data.map(function(item) {
|
|
109
|
+
return typeof item === "string" ? item : (0, import_pretty_format.default)(item, {
|
|
110
|
+
escapeString: true,
|
|
111
|
+
highlight: true,
|
|
112
|
+
maxDepth: 3,
|
|
113
|
+
min: true,
|
|
114
|
+
plugins: [import_pretty_format.default.plugins.ReactElement]
|
|
115
|
+
});
|
|
116
|
+
})
|
|
117
|
+
}));
|
|
118
|
+
} catch (unused) {
|
|
119
|
+
try {
|
|
120
|
+
var _this_socket1;
|
|
121
|
+
(_this_socket1 = this.socket) === null || _this_socket1 === void 0 ? void 0 : _this_socket1.send(JSON.stringify({
|
|
122
|
+
type: "client-log",
|
|
123
|
+
level,
|
|
124
|
+
data: data.map(function(item, index) {
|
|
125
|
+
try {
|
|
126
|
+
return typeof item === "string" ? item : JSON.stringify(item);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
return `Error stringifying item at index ${index} - ${item} - ${err}`;
|
|
129
|
+
}
|
|
130
|
+
})
|
|
131
|
+
}));
|
|
132
|
+
} catch (err) {
|
|
133
|
+
try {
|
|
134
|
+
var _this_socket2;
|
|
135
|
+
(_this_socket2 = this.socket) === null || _this_socket2 === void 0 ? void 0 : _this_socket2.send(JSON.stringify({
|
|
136
|
+
type: "client-log",
|
|
137
|
+
level: "error",
|
|
138
|
+
data: ["error sending client log: " + err]
|
|
139
|
+
}));
|
|
140
|
+
} catch (unused2) {}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
key: "flushBuffer",
|
|
147
|
+
value: function flushBuffer() {
|
|
148
|
+
var _this = this;
|
|
149
|
+
if (globalThis["__vxrnTmpLogs"]) {
|
|
150
|
+
globalThis["__vxrnTmpLogs"].forEach(function(param) {
|
|
151
|
+
var { level: level2, data: data2 } = param;
|
|
152
|
+
_this.buffer.push({
|
|
153
|
+
level: level2,
|
|
154
|
+
data: data2
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
delete globalThis["__vxrnTmpLogs"];
|
|
158
|
+
}
|
|
159
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
160
|
+
try {
|
|
161
|
+
for (var _iterator = this.buffer[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
162
|
+
var { level, data } = _step.value;
|
|
163
|
+
this.send(level, data);
|
|
164
|
+
}
|
|
165
|
+
} catch (err) {
|
|
166
|
+
_didIteratorError = true;
|
|
167
|
+
_iteratorError = err;
|
|
168
|
+
} finally {
|
|
169
|
+
try {
|
|
170
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
171
|
+
_iterator.return();
|
|
172
|
+
}
|
|
173
|
+
} finally {
|
|
174
|
+
if (_didIteratorError) {
|
|
175
|
+
throw _iteratorError;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
this.buffer = [];
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
key: "log",
|
|
184
|
+
value: function log2(level, data) {
|
|
185
|
+
if (level === "groupEnd") {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (this.socket && this.socket.readyState === WebSocket.OPEN) {
|
|
189
|
+
this.flushBuffer();
|
|
190
|
+
this.send(level, data);
|
|
191
|
+
} else {
|
|
192
|
+
if (globalThis["__vxrnTmpLogs"]) return;
|
|
193
|
+
this.buffer.push({
|
|
194
|
+
level,
|
|
195
|
+
data
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: "setup",
|
|
202
|
+
value: function setup2() {}
|
|
203
|
+
}
|
|
204
|
+
]);
|
|
205
|
+
return DevServerClient2;
|
|
206
|
+
})();
|
|
207
|
+
var client = new DevServerClient();
|
|
208
|
+
var setup = function() {};
|
|
209
|
+
var enable = function() {};
|
|
210
|
+
var disable = function() {};
|
|
211
|
+
var registerBundle = function() {};
|
|
212
|
+
var log = function(level, data) {
|
|
213
|
+
client.log(level, data);
|
|
214
|
+
};
|