@vxrn/vite-native-hmr 0.0.3

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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/devServerClient.js +132 -0
  3. package/dist/cjs/devServerClient.js.map +6 -0
  4. package/dist/cjs/devServerClient.native.js +132 -0
  5. package/dist/cjs/devServerClient.native.js.map +6 -0
  6. package/dist/cjs/getDevServerLocation.js +49 -0
  7. package/dist/cjs/getDevServerLocation.js.map +6 -0
  8. package/dist/cjs/getDevServerLocation.native.js +50 -0
  9. package/dist/cjs/getDevServerLocation.native.js.map +6 -0
  10. package/dist/cjs/hmr-client.js +130 -0
  11. package/dist/cjs/hmr-client.js.map +6 -0
  12. package/dist/cjs/hmr-client.native.js +129 -0
  13. package/dist/cjs/hmr-client.native.js.map +6 -0
  14. package/dist/cjs/index.js +19 -0
  15. package/dist/cjs/index.js.map +6 -0
  16. package/dist/cjs/index.native.js +20 -0
  17. package/dist/cjs/index.native.js.map +6 -0
  18. package/dist/esm/devServerClient.js +101 -0
  19. package/dist/esm/devServerClient.js.map +6 -0
  20. package/dist/esm/devServerClient.native.js +100 -0
  21. package/dist/esm/devServerClient.native.js.map +6 -0
  22. package/dist/esm/getDevServerLocation.js +21 -0
  23. package/dist/esm/getDevServerLocation.js.map +6 -0
  24. package/dist/esm/getDevServerLocation.native.js +21 -0
  25. package/dist/esm/getDevServerLocation.native.js.map +6 -0
  26. package/dist/esm/hmr-client.js +100 -0
  27. package/dist/esm/hmr-client.js.map +6 -0
  28. package/dist/esm/hmr-client.native.js +98 -0
  29. package/dist/esm/hmr-client.native.js.map +6 -0
  30. package/dist/esm/index.js +2 -0
  31. package/dist/esm/index.js.map +6 -0
  32. package/dist/esm/index.native.js +2 -0
  33. package/dist/esm/index.native.js.map +6 -0
  34. package/package.json +49 -0
  35. package/src/devServerClient.ts +132 -0
  36. package/src/getDevServerLocation.ts +33 -0
  37. package/src/globals.d.ts +33 -0
  38. package/src/hmr-client.ts +206 -0
  39. package/src/index.ts +1 -0
  40. package/types/devServerClient.d.ts +6 -0
  41. package/types/devServerClient.d.ts.map +1 -0
  42. package/types/getDevServerLocation.d.ts +11 -0
  43. package/types/getDevServerLocation.d.ts.map +1 -0
  44. package/types/hmr-client.d.ts +24 -0
  45. package/types/hmr-client.d.ts.map +1 -0
  46. package/types/index.d.ts +2 -0
  47. package/types/index.d.ts.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Callstack
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,132 @@
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
+ disable: () => disable,
26
+ enable: () => enable,
27
+ log: () => log,
28
+ registerBundle: () => registerBundle,
29
+ setup: () => setup
30
+ });
31
+ module.exports = __toCommonJS(devServerClient_exports);
32
+ var import_pretty_format = __toESM(require("pretty-format")), import_getDevServerLocation = require("./getDevServerLocation"), import_hmr_client = require("./hmr-client");
33
+ (0, import_hmr_client.loadHMRClient)();
34
+ class DevServerClient {
35
+ socket;
36
+ buffer = [];
37
+ constructor() {
38
+ const initSocket = () => {
39
+ const address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
40
+ this.socket = new WebSocket(address);
41
+ const onClose = (event) => {
42
+ console.warn(
43
+ "Disconnected from the Dev Server:",
44
+ event.message
45
+ ), this.socket = void 0;
46
+ };
47
+ this.socket.onclose = onClose, this.socket.onerror = onClose, this.socket.onopen = () => {
48
+ this.flushBuffer();
49
+ };
50
+ };
51
+ process.env.NODE_ENV === "development" && initSocket();
52
+ }
53
+ send(level, data) {
54
+ var _a, _b, _c;
55
+ try {
56
+ (_a = this.socket) == null || _a.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
+ (_b = this.socket) == null || _b.send(
77
+ JSON.stringify({
78
+ type: "client-log",
79
+ level,
80
+ data: data.map(
81
+ (item) => typeof item == "string" ? item : JSON.stringify(item)
82
+ )
83
+ })
84
+ );
85
+ } catch (err) {
86
+ try {
87
+ (_c = this.socket) == null || _c.send(
88
+ JSON.stringify({
89
+ type: "client-log",
90
+ level: "error",
91
+ data: ["error sending client log: " + err]
92
+ })
93
+ );
94
+ } catch {
95
+ }
96
+ }
97
+ }
98
+ }
99
+ flushBuffer() {
100
+ console._tmpLogs && (console._tmpLogs.forEach(({ level, data }) => {
101
+ this.buffer.push({ level, data });
102
+ }), delete console._tmpLogs);
103
+ for (const { level, data } of this.buffer)
104
+ this.send(level, data);
105
+ this.buffer = [];
106
+ }
107
+ log(level, data) {
108
+ if (this.socket && this.socket.readyState === WebSocket.OPEN)
109
+ this.flushBuffer(), this.send(level, data);
110
+ else {
111
+ if (console._tmpLogs)
112
+ return;
113
+ this.buffer.push({ level, data });
114
+ }
115
+ }
116
+ }
117
+ const client = new DevServerClient(), setup = () => {
118
+ }, enable = () => {
119
+ }, disable = () => {
120
+ }, registerBundle = () => {
121
+ }, log = (level, data) => {
122
+ client.log(level, data);
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ disable,
127
+ enable,
128
+ log,
129
+ registerBundle,
130
+ setup
131
+ });
132
+ //# sourceMappingURL=devServerClient.js.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KAAK;AAAA,cAAI,CAAC,SACd,OAAO,QAAS,WAAW,OAAO,KAAK,UAAU,IAAI;AAAA,YACvD;AAAA,UACF,CAAC;AAAA;AAAA,MAEL,SAAS,KAAK;AACZ,YAAI;AACF,qBAAK,WAAL,WAAa;AAAA,YACX,KAAK,UAAU;AAAA,cACb,MAAM;AAAA,cACN,OAAO;AAAA,cACP,MAAM,CAAC,+BAA+B,GAAG;AAAA,YAC3C,CAAC;AAAA;AAAA,QAEL,QAAQ;AAAA,QAER;AAAA,MACF;AAAA,IAEF;AAAA,EACF;AAAA,EAEA,cAAc;AACZ,IAAI,QAAQ,aACV,QAAQ,SAAY,QAAQ,CAAC,EAAE,OAAO,KAAK,MAAM;AAC/C,WAAK,OAAO,KAAK,EAAE,OAAO,KAAK,CAAC;AAAA,IAClC,CAAC,GACD,OAAO,QAAQ;AAGjB,eAAW,EAAE,OAAO,KAAK,KAAK,KAAK;AACjC,WAAK,KAAK,OAAO,IAAI;AAEvB,SAAK,SAAS,CAAC;AAAA,EACjB;AAAA,EAEA,IAAI,OAAe,MAAa;AAC9B,QAAI,KAAK,UAAU,KAAK,OAAO,eAAe,UAAU;AACtD,WAAK,YAAY,GACjB,KAAK,KAAK,OAAO,IAAI;AAAA,SAChB;AACL,UAAI,QAAQ;AAAa;AACzB,WAAK,OAAO,KAAK,EAAE,OAAO,KAAK,CAAC;AAAA,IAClC;AAAA,EACF;AACF;AAEA,MAAM,SAAS,IAAI,gBAAgB,GAEtB,QAAQ,MAAM;AAAC,GACf,SAAS,MAAM;AAAC,GAChB,UAAU,MAAM;AAAC,GACjB,iBAAiB,MAAM;AAAC,GACxB,MAAM,CAAC,OAAe,SAAgB;AACjD,SAAO,IAAI,OAAO,IAAI;AACxB;",
5
+ "names": ["prettyFormat"]
6
+ }
@@ -0,0 +1,132 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var devServerClient_exports = {};
25
+ __export(devServerClient_exports, {
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
+ constructor() {
37
+ this.buffer = [];
38
+ const initSocket = () => {
39
+ const address = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().host}/__client`;
40
+ this.socket = new WebSocket(address);
41
+ const onClose = (event) => {
42
+ console.warn(
43
+ "Disconnected from the Dev Server:",
44
+ event.message
45
+ ), this.socket = void 0;
46
+ };
47
+ this.socket.onclose = onClose, this.socket.onerror = onClose, this.socket.onopen = () => {
48
+ this.flushBuffer();
49
+ };
50
+ };
51
+ process.env.NODE_ENV === "development" && initSocket();
52
+ }
53
+ send(level, data) {
54
+ var _a, _b, _c;
55
+ try {
56
+ (_a = this.socket) == null || _a.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
+ (_b = this.socket) == null || _b.send(
77
+ JSON.stringify({
78
+ type: "client-log",
79
+ level,
80
+ data: data.map(
81
+ (item) => typeof item == "string" ? item : JSON.stringify(item)
82
+ )
83
+ })
84
+ );
85
+ } catch (err) {
86
+ try {
87
+ (_c = this.socket) == null || _c.send(
88
+ JSON.stringify({
89
+ type: "client-log",
90
+ level: "error",
91
+ data: ["error sending client log: " + err]
92
+ })
93
+ );
94
+ } catch {
95
+ }
96
+ }
97
+ }
98
+ }
99
+ flushBuffer() {
100
+ console._tmpLogs && (console._tmpLogs.forEach(({ level, data }) => {
101
+ this.buffer.push({ level, data });
102
+ }), delete console._tmpLogs);
103
+ for (const { level, data } of this.buffer)
104
+ this.send(level, data);
105
+ this.buffer = [];
106
+ }
107
+ log(level, data) {
108
+ if (this.socket && this.socket.readyState === WebSocket.OPEN)
109
+ this.flushBuffer(), this.send(level, data);
110
+ else {
111
+ if (console._tmpLogs)
112
+ return;
113
+ this.buffer.push({ level, data });
114
+ }
115
+ }
116
+ }
117
+ const client = new DevServerClient(), setup = () => {
118
+ }, enable = () => {
119
+ }, disable = () => {
120
+ }, registerBundle = () => {
121
+ }, log = (level, data) => {
122
+ client.log(level, data);
123
+ };
124
+ // Annotate the CommonJS export names for ESM import in node:
125
+ 0 && (module.exports = {
126
+ disable,
127
+ enable,
128
+ log,
129
+ registerBundle,
130
+ setup
131
+ });
132
+ //# sourceMappingURL=devServerClient.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/devServerClient.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAyB,mCAEzB,8BAAqC,mCACrC,oBAA8B;AAAA,IAG9B,iCAAc;AAad,MAAM,gBAAgB;AAAA,EAIpB,cAAc;AAFd,kBAAgD,CAAC;AAG/C,UAAM,aAAa,MAAM;AACvB,YAAM,UAAU,YAAQ,kDAAqB,EAAE,IAAI;AACnD,WAAK,SAAS,IAAI,UAAU,OAAO;AAEnC,YAAM,UAAU,CAAC,UAAiB;AAChC,gBAAQ;AAAA,UACN;AAAA,UACC,MAAgD;AAAA,QACnD,GACA,KAAK,SAAS;AAAA,MAChB;AAEA,WAAK,OAAO,UAAU,SACtB,KAAK,OAAO,UAAU,SACtB,KAAK,OAAO,SAAS,MAAM;AACzB,aAAK,YAAY;AAAA,MACnB;AAAA,IACF;AAEA,IAAI,QAAQ,IAAI,aAAa,iBAC3B,WAAW;AAAA,EAEf;AAAA,EAEA,KAAK,OAAe,MAAa;AAhDnC;AAiDI,QAAI;AACF,iBAAK,WAAL,WAAa;AAAA,QACX,KAAK,UAAU;AAAA,UACb,MAAM;AAAA,UACN;AAAA,UACA,MAAM,KAAK;AAAA,YAAI,CAAC,SACd,OAAO,QAAS,WACZ,WACA,qBAAAA,SAAa,MAAM;AAAA,cACjB,cAAc;AAAA,cACd,WAAW;AAAA,cACX,UAAU;AAAA,cACV,KAAK;AAAA,cACL,SAAS;AAAA;AAAA,gBAEP,qBAAAA,QAAa,QAAQ;AAAA,cACvB;AAAA,YACF,CAAC;AAAA,UACP;AAAA,QACF,CAAC;AAAA;AAAA,IAEL,QAAQ;AACN,UAAI;AACF,mBAAK,WAAL,WAAa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perty;
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 getDevServerLocation_exports = {};
24
+ __export(getDevServerLocation_exports, {
25
+ getDevServerLocation: () => getDevServerLocation
26
+ });
27
+ module.exports = __toCommonJS(getDevServerLocation_exports);
28
+ var import_getDevServer = __toESM(require("react-native/Libraries/Core/Devtools/getDevServer"));
29
+ let location;
30
+ function getDevServerLocation() {
31
+ if (!location) {
32
+ const { url } = (0, import_getDevServer.default)(), origin = url.replace(/\/$/, ""), host = origin.replace(/https?:\/\//, "");
33
+ location = {
34
+ host,
35
+ hostname: host.split(":")[0],
36
+ href: url,
37
+ origin,
38
+ pathname: url.split(host)[1],
39
+ port: host.split(":")[1],
40
+ protocol: (url.match(/^([a-z])+:\/\//) || [void 0, void 0])[1]
41
+ };
42
+ }
43
+ return location;
44
+ }
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ getDevServerLocation
48
+ });
49
+ //# sourceMappingURL=getDevServerLocation.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/getDevServerLocation.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAyB;AAYzB,IAAI;AAEG,SAAS,uBAA0C;AACxD,MAAI,CAAC,UAAU;AACb,UAAM,EAAE,IAAI,QAAI,oBAAAA,SAAa,GACvB,SAAS,IAAI,QAAQ,OAAO,EAAE,GAC9B,OAAO,OAAO,QAAQ,eAAe,EAAE;AAC7C,eAAW;AAAA,MACT;AAAA,MACA,UAAU,KAAK,MAAM,GAAG,EAAE,CAAC;AAAA,MAC3B,MAAM;AAAA,MACN;AAAA,MACA,UAAU,IAAI,MAAM,IAAI,EAAE,CAAC;AAAA,MAC3B,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC;AAAA,MACvB,WAAW,IAAI,MAAM,gBAAgB,KAAK,CAAC,QAAW,MAAS,GAAG,CAAC;AAAA,IACrE;AAAA,EACF;AAEA,SAAO;AACT;",
5
+ "names": ["getDevServer"]
6
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var getDevServerLocation_exports = {};
25
+ __export(getDevServerLocation_exports, {
26
+ getDevServerLocation: () => getDevServerLocation
27
+ });
28
+ module.exports = __toCommonJS(getDevServerLocation_exports);
29
+ var import_getDevServer = __toESM(require("react-native/Libraries/Core/Devtools/getDevServer"));
30
+ let location;
31
+ function getDevServerLocation() {
32
+ if (!location) {
33
+ const { url } = (0, import_getDevServer.default)(), origin = url.replace(/\/$/, ""), host = origin.replace(/https?:\/\//, "");
34
+ location = {
35
+ host,
36
+ hostname: host.split(":")[0],
37
+ href: url,
38
+ origin,
39
+ pathname: url.split(host)[1],
40
+ port: host.split(":")[1],
41
+ protocol: (url.match(/^([a-z])+:\/\//) || [void 0, void 0])[1]
42
+ };
43
+ }
44
+ return location;
45
+ }
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ getDevServerLocation
49
+ });
50
+ //# sourceMappingURL=getDevServerLocation.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/getDevServerLocation.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,0BAAyB;AAYzB,IAAI;AAEG,SAAS,uBAA0C;AACxD,MAAI,CAAC,UAAU;AACb,UAAM,EAAE,IAAI,QAAI,oBAAAA,SAAa,GACvB,SAAS,IAAI,QAAQ,OAAO,EAAE,GAC9B,OAAO,OAAO,QAAQ,eAAe,EAAE;AAC7C,eAAW;AAAA,MACT;AAAA,MACA,UAAU,KAAK,MAAM,GAAG,EAAE,CAAC;AAAA,MAC3B,MAAM;AAAA,MACN;AAAA,MACA,UAAU,IAAI,MAAM,IAAI,EAAE,CAAC;AAAA,MAC3B,MAAM,KAAK,MAAM,GAAG,EAAE,CAAC;AAAA,MACvB,WAAW,IAAI,MAAM,gBAAgB,KAAK,CAAC,QAAW,MAAS,GAAG,CAAC;AAAA,IACrE;AAAA,EACF;AAEA,SAAO;AACT;",
5
+ "names": ["getDevServer"]
6
+ }
@@ -0,0 +1,130 @@
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
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
15
+ var hmr_client_exports = {};
16
+ __export(hmr_client_exports, {
17
+ loadHMRClient: () => loadHMRClient
18
+ });
19
+ module.exports = __toCommonJS(hmr_client_exports);
20
+ var import_getDevServerLocation = require("./getDevServerLocation");
21
+ class HMRClient {
22
+ constructor(app) {
23
+ this.app = app;
24
+ this.url = `ws://${(0, import_getDevServerLocation.getDevServerLocation)().hostname}:${process.env.REACT_NATIVE_SERVER_PUBLIC_PORT}/__hmr?platform=${process.env.REACT_NATIVE_PLATFORM || "ios"}`, this.socket = new WebSocket(this.url), console.log("[HMRClient] Connecting..."), this.socket.onopen = () => {
25
+ console.log("[HMRClient] Connected");
26
+ }, this.socket.onclose = () => {
27
+ console.log(`[HMRClient] Disconnected ${this.url}`);
28
+ }, this.socket.onerror = (event) => {
29
+ console.log("[HMRClient] Error", event);
30
+ }, this.socket.onmessage = (event) => {
31
+ try {
32
+ const data = JSON.parse(event.data.toString());
33
+ this.processMessage(data);
34
+ } catch (error) {
35
+ console.warn("[HMRClient] Invalid HMR message", error);
36
+ }
37
+ };
38
+ }
39
+ url;
40
+ socket;
41
+ lastHash = "";
42
+ upToDate(hash) {
43
+ return hash && (this.lastHash = hash), this.lastHash === __webpack_hash__;
44
+ }
45
+ processMessage(message) {
46
+ var _a, _b, _c, _d, _e;
47
+ switch (message.action) {
48
+ case "building":
49
+ this.app.LoadingView.showMessage("Rebuilding...", "refresh"), console.log("[HMRClient] Bundle rebuilding", {
50
+ name: (_a = message.body) == null ? void 0 : _a.name
51
+ });
52
+ break;
53
+ case "built":
54
+ console.log("[HMRClient] Bundle rebuilt", {
55
+ name: (_b = message.body) == null ? void 0 : _b.name,
56
+ time: (_c = message.body) == null ? void 0 : _c.time
57
+ });
58
+ case "sync":
59
+ if (!message.body) {
60
+ console.warn("[HMRClient] HMR message body is empty");
61
+ return;
62
+ }
63
+ if ((_d = message.body.errors) != null && _d.length) {
64
+ message.body.errors.forEach((error) => {
65
+ console.error("Cannot apply update due to error:", error);
66
+ }), this.app.LoadingView.hide();
67
+ return;
68
+ }
69
+ (_e = message.body.warnings) != null && _e.length && message.body.warnings.forEach((warning) => {
70
+ console.warn("[HMRClient] Bundle contains warnings:", warning);
71
+ }), this.applyUpdate(message.body);
72
+ }
73
+ }
74
+ applyUpdate(update) {
75
+ if (!module.hot)
76
+ throw new Error("[HMRClient] Hot Module Replacement is disabled.");
77
+ !this.upToDate(update.hash) && module.hot.status() === "idle" && (console.log("[HMRClient] Checking for updates on the server..."), this.checkUpdates(update));
78
+ }
79
+ async checkUpdates(update) {
80
+ var _a, _b, _c, _d;
81
+ try {
82
+ this.app.LoadingView.showMessage("Refreshing...", "refresh");
83
+ const updatedModules = await ((_a = module.hot) == null ? void 0 : _a.check(!1));
84
+ if (!updatedModules) {
85
+ console.warn("[HMRClient] Cannot find update - full reload needed"), this.app.reload();
86
+ return;
87
+ }
88
+ const renewedModules = await ((_b = module.hot) == null ? void 0 : _b.apply({
89
+ ignoreDeclined: !0,
90
+ ignoreUnaccepted: !1,
91
+ ignoreErrored: !1,
92
+ onDeclined: (data) => {
93
+ console.warn("[HMRClient] Ignored an update due to declined module", {
94
+ chain: data.chain
95
+ });
96
+ }
97
+ }));
98
+ this.upToDate() || this.checkUpdates(update);
99
+ const unacceptedModules = updatedModules.filter((moduleId) => renewedModules && renewedModules.indexOf(moduleId) < 0);
100
+ unacceptedModules.length ? (console.warn("[HMRClient] Not every module was accepted - full reload needed", {
101
+ unacceptedModules
102
+ }), this.app.reload()) : (console.log("[HMRClient] Renewed modules - app is up to date", {
103
+ renewedModules
104
+ }), this.app.dismissErrors());
105
+ } catch (error) {
106
+ ((_c = module.hot) == null ? void 0 : _c.status()) === "fail" || ((_d = module.hot) == null ? void 0 : _d.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 });
107
+ } finally {
108
+ this.app.LoadingView.hide();
109
+ }
110
+ }
111
+ }
112
+ const loadHMRClient = () => {
113
+ const { DevSettings, Platform } = require("react-native"), LoadingView = require("react-native/Libraries/Utilities/LoadingView"), reload = () => DevSettings.reload(), dismissErrors = () => {
114
+ var _a;
115
+ if (Platform.OS === "ios") {
116
+ const NativeRedBox = require("react-native/Libraries/NativeModules/specs/NativeRedBox").default;
117
+ (_a = NativeRedBox == null ? void 0 : NativeRedBox.dismiss) == null || _a.call(NativeRedBox);
118
+ } else {
119
+ const NativeExceptionsManager = require("react-native/Libraries/Core/NativeExceptionsManager").default;
120
+ NativeExceptionsManager == null || NativeExceptionsManager.dismissRedbox();
121
+ }
122
+ require("react-native/Libraries/LogBox/Data/LogBoxData").clear();
123
+ };
124
+ new HMRClient({ reload, dismissErrors, LoadingView });
125
+ };
126
+ // Annotate the CommonJS export names for ESM import in node:
127
+ 0 && (module.exports = {
128
+ loadHMRClient
129
+ });
130
+ //# sourceMappingURL=hmr-client.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/hmr-client.ts"],
4
+ "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kCAAqC;AA0BrC,MAAM,UAAU;AAAA,EAKd,YACU,KAQR;AARQ;AASR,SAAK,MAAM,YAAQ,kDAAqB,EAAE,QAAQ,IAChD,QAAQ,IAAI,+BACd,mBAAmB,QAAQ,IAAI,yBAAyB,KAAK,IAE7D,KAAK,SAAS,IAAI,UAAU,KAAK,GAAG,GAEpC,QAAQ,IAAI,2BAA2B,GAEvC,KAAK,OAAO,SAAS,MAAM;AACzB,cAAQ,IAAI,uBAAuB;AAAA,IACrC,GAEA,KAAK,OAAO,UAAU,MAAM;AAC1B,cAAQ,IAAI,4BAA4B,KAAK,GAAG,EAAE;AAAA,IACpD,GAEA,KAAK,OAAO,UAAU,CAAC,UAAU;AAC/B,cAAQ,IAAI,qBAAqB,KAAK;AAAA,IACxC,GAEA,KAAK,OAAO,YAAY,CAAC,UAAU;AACjC,UAAI;AACF,cAAM,OAAO,KAAK,MAAM,MAAM,KAAK,SAAS,CAAC;AAC7C,aAAK,eAAe,IAAI;AAAA,MAC1B,SAAS,OAAO;AACd,gBAAQ,KAAK,mCAAmC,KAAK;AAAA,MACvD;AAAA,IACF;AAAA,EACF;AAAA,EA1CA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EA0CX,SAAS,MAAe;AACtB,WAAI,SACF,KAAK,WAAW,OAGX,KAAK,aAAa;AAAA,EAC3B;AAAA,EAEA,eAAe,SAAqB;AA/EtC;AAgFI,YAAQ,QAAQ,QAAQ;AAAA,MACt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