vxrn 0.1.20 → 0.1.21
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/cli.js +77 -3
- package/dist/cjs/cli.js.map +2 -2
- package/dist/cjs/cli.native.js +268 -2
- package/dist/cjs/cli.native.js.map +2 -2
- package/dist/cjs/constants.js +21 -0
- package/dist/cjs/constants.js.map +6 -0
- package/dist/cjs/constants.native.js +26 -0
- package/dist/cjs/constants.native.js.map +6 -0
- package/dist/cjs/dispose.js +28 -0
- package/dist/cjs/dispose.js.map +6 -0
- package/dist/cjs/dispose.native.js +36 -0
- package/dist/cjs/dispose.native.js.map +6 -0
- package/dist/cjs/exports/build.js +145 -0
- package/dist/cjs/exports/build.js.map +6 -0
- package/dist/cjs/exports/build.native.js +409 -0
- package/dist/cjs/exports/build.native.js.map +6 -0
- package/dist/cjs/exports/checkPatches.js +62 -0
- package/dist/cjs/exports/checkPatches.js.map +6 -0
- package/dist/cjs/exports/checkPatches.native.js +289 -0
- package/dist/cjs/exports/checkPatches.native.js.map +6 -0
- package/dist/cjs/exports/dev.js +568 -0
- package/dist/cjs/exports/dev.js.map +6 -0
- package/dist/cjs/exports/dev.native.js +1111 -0
- package/dist/cjs/exports/dev.native.js.map +6 -0
- package/dist/cjs/exports/serve.js +55 -0
- package/dist/cjs/exports/serve.js.map +6 -0
- package/dist/cjs/exports/serve.native.js +236 -0
- package/dist/cjs/exports/serve.native.js.map +6 -0
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.native.js +3 -5
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/plugins/clientInjectPlugin.js +66 -0
- package/dist/cjs/plugins/clientInjectPlugin.js.map +6 -0
- package/dist/cjs/plugins/clientInjectPlugin.native.js +190 -0
- package/dist/cjs/plugins/clientInjectPlugin.native.js.map +6 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.js +89 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.js.map +6 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js +346 -0
- package/dist/cjs/plugins/reactNativeCommonJsPlugin.native.js.map +6 -0
- package/dist/cjs/utils/checkPatches.js +62 -0
- package/dist/cjs/utils/checkPatches.js.map +6 -0
- package/dist/cjs/utils/checkPatches.native.js +289 -0
- package/dist/cjs/utils/checkPatches.native.js.map +6 -0
- package/dist/cjs/utils/dispose.js +28 -0
- package/dist/cjs/utils/dispose.js.map +6 -0
- package/dist/cjs/utils/dispose.native.js +36 -0
- package/dist/cjs/utils/dispose.native.js.map +6 -0
- package/dist/cjs/utils/getBaseViteConfig.js +2 -2
- package/dist/cjs/utils/getBaseViteConfig.js.map +1 -1
- package/dist/cjs/utils/getBaseViteConfig.native.js +2 -2
- package/dist/cjs/utils/getBaseViteConfig.native.js.map +1 -1
- package/dist/cjs/utils/patches.js +62 -0
- package/dist/cjs/utils/patches.js.map +6 -0
- package/dist/cjs/utils/patches.native.js +289 -0
- package/dist/cjs/utils/patches.native.js.map +6 -0
- package/dist/cjs/utils/prerender.js +1 -0
- package/dist/cjs/utils/prerender.js.map +6 -0
- package/dist/cjs/utils/prerender.native.js +2 -0
- package/dist/cjs/utils/prerender.native.js.map +6 -0
- package/dist/cjs/vendor/createExpoServer.js +34 -0
- package/dist/cjs/vendor/createExpoServer.js.map +6 -0
- package/dist/cjs/vendor/createExpoServer.native.js +42 -0
- package/dist/cjs/vendor/createExpoServer.native.js.map +6 -0
- package/dist/esm/cli.js +58 -3
- package/dist/esm/cli.js.map +2 -2
- package/dist/esm/cli.mjs +81 -9
- package/dist/esm/cli.native.js +249 -3
- package/dist/esm/cli.native.js.map +2 -2
- package/dist/esm/constants.js +5 -0
- package/dist/esm/constants.js.map +6 -0
- package/dist/esm/constants.mjs +2 -0
- package/dist/esm/constants.native.js +5 -0
- package/dist/esm/constants.native.js.map +6 -0
- package/dist/esm/dispose.js +12 -0
- package/dist/esm/dispose.js.map +6 -0
- package/dist/esm/dispose.mjs +8 -0
- package/dist/esm/dispose.native.js +14 -0
- package/dist/esm/dispose.native.js.map +6 -0
- package/dist/esm/exports/build.js +128 -0
- package/dist/esm/exports/build.js.map +6 -0
- package/dist/esm/exports/build.mjs +119 -0
- package/dist/esm/exports/build.native.js +385 -0
- package/dist/esm/exports/build.native.js.map +6 -0
- package/dist/esm/exports/checkPatches.js +40 -0
- package/dist/esm/exports/checkPatches.js.map +6 -0
- package/dist/esm/exports/checkPatches.mjs +31 -0
- package/dist/esm/exports/checkPatches.native.js +262 -0
- package/dist/esm/exports/checkPatches.native.js.map +6 -0
- package/dist/esm/exports/dev.js +581 -0
- package/dist/esm/exports/dev.js.map +6 -0
- package/dist/esm/exports/dev.mjs +543 -0
- package/dist/esm/exports/dev.native.js +1102 -0
- package/dist/esm/exports/dev.native.js.map +6 -0
- package/dist/esm/exports/serve.js +33 -0
- package/dist/esm/exports/serve.js.map +6 -0
- package/dist/esm/exports/serve.mjs +38 -0
- package/dist/esm/exports/serve.native.js +209 -0
- package/dist/esm/exports/serve.native.js.map +6 -0
- package/dist/esm/index.js +3 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.mjs +3 -4
- package/dist/esm/index.native.js +3 -5
- package/dist/esm/index.native.js.map +2 -2
- package/dist/esm/plugins/clientInjectPlugin.js +42 -0
- package/dist/esm/plugins/clientInjectPlugin.js.map +6 -0
- package/dist/esm/plugins/clientInjectPlugin.mjs +56 -0
- package/dist/esm/plugins/clientInjectPlugin.native.js +161 -0
- package/dist/esm/plugins/clientInjectPlugin.native.js.map +6 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.js +75 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.js.map +6 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.mjs +55 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js +327 -0
- package/dist/esm/plugins/reactNativeCommonJsPlugin.native.js.map +6 -0
- package/dist/esm/utils/checkPatches.js +40 -0
- package/dist/esm/utils/checkPatches.js.map +6 -0
- package/dist/esm/utils/checkPatches.mjs +31 -0
- package/dist/esm/utils/checkPatches.native.js +262 -0
- package/dist/esm/utils/checkPatches.native.js.map +6 -0
- package/dist/esm/utils/dispose.js +12 -0
- package/dist/esm/utils/dispose.js.map +6 -0
- package/dist/esm/utils/dispose.mjs +8 -0
- package/dist/esm/utils/dispose.native.js +14 -0
- package/dist/esm/utils/dispose.native.js.map +6 -0
- package/dist/esm/utils/getBaseViteConfig.js +1 -1
- package/dist/esm/utils/getBaseViteConfig.mjs +1 -1
- package/dist/esm/utils/getBaseViteConfig.native.js +1 -1
- package/dist/esm/utils/patches.js +40 -0
- package/dist/esm/utils/patches.js.map +6 -0
- package/dist/esm/utils/patches.mjs +31 -0
- package/dist/esm/utils/patches.native.js +262 -0
- package/dist/esm/utils/patches.native.js.map +6 -0
- package/dist/esm/utils/prerender.js +1 -0
- package/dist/esm/utils/prerender.js.map +6 -0
- package/dist/esm/utils/prerender.mjs +0 -0
- package/dist/esm/utils/prerender.native.js +1 -0
- package/dist/esm/utils/prerender.native.js.map +6 -0
- package/dist/esm/vendor/createExpoServer.js +20 -0
- package/dist/esm/vendor/createExpoServer.js.map +6 -0
- package/dist/esm/vendor/createExpoServer.mjs +17 -0
- package/dist/esm/vendor/createExpoServer.native.js +22 -0
- package/dist/esm/vendor/createExpoServer.native.js.map +6 -0
- package/package.json +8 -7
- package/src/cli.ts +78 -2
- package/src/{build.ts → exports/build.ts} +5 -4
- package/src/{createDevServer.ts → exports/dev.ts} +13 -63
- package/src/exports/serve.ts +51 -0
- package/src/index.ts +3 -3
- package/src/{dev → plugins}/clientInjectPlugin.ts +1 -12
- package/src/{nativePlugin.ts → plugins/reactNativeCommonJsPlugin.ts} +3 -26
- package/src/utils/getBaseViteConfig.ts +1 -1
- package/src/utils/patches.ts +54 -0
- package/types/build.d.ts +4 -4
- package/types/constants.d.ts +2 -0
- package/types/dispose.d.ts +3 -0
- package/types/exports/build.d.ts +4 -0
- package/types/exports/dev.d.ts +13 -0
- package/types/exports/serve.d.ts +3 -0
- package/types/index.d.ts +2 -3
- package/types/plugins/clientInjectPlugin.d.ts +7 -0
- package/types/plugins/reactNativeCommonJsPlugin.d.ts +7 -0
- package/types/utils/checkPatches.d.ts +3 -0
- package/types/utils/dispose.d.ts +3 -0
- package/types/utils/patches.d.ts +3 -0
- package/types/utils/prerender.d.ts +1 -0
- package/types/vendor/createExpoServer.d.ts +4 -0
- package/src/commands/cli-build.ts +0 -25
- package/src/commands/cli-dev.ts +0 -47
- package/src/commands/index.ts +0 -10
- package/src/dev/createDevServer.ts +0 -234
- /package/src/{utils/constants.ts → constants.ts} +0 -0
- /package/src/{utils.ts → utils/dispose.ts} +0 -0
- /package/src/{createExpoServer.ts → vendor/createExpoServer.ts} +0 -0
|
@@ -0,0 +1,1102 @@
|
|
|
1
|
+
import wsAdapter from "crossws/adapters/node";
|
|
2
|
+
import { createApp, createRouter, defineEventHandler, defineWebSocketHandler, eventHandler, getQuery, toNodeListener } from "h3";
|
|
3
|
+
import { createProxyEventHandler } from "h3-proxy";
|
|
4
|
+
import { readFile } from "node:fs/promises";
|
|
5
|
+
import { createServer as nodeCreateServer } from "node:http";
|
|
6
|
+
import { dirname, join, relative, resolve } from "node:path";
|
|
7
|
+
import readline from "node:readline";
|
|
8
|
+
import { WebSocket } from "ws";
|
|
9
|
+
import * as babel from "@babel/core";
|
|
10
|
+
import { buildReact, buildReactJSX, buildReactNative } from "@vxrn/react-native-prebuilt";
|
|
11
|
+
import viteReactPlugin, { swcTransform, transformForBuild } from "@vxrn/vite-native-swc";
|
|
12
|
+
import { parse } from "es-module-lexer";
|
|
13
|
+
import FSExtra from "fs-extra";
|
|
14
|
+
import { build, createServer, mergeConfig, resolveConfig, transformWithEsbuild } from "vite";
|
|
15
|
+
import createViteFlow from "@vxrn/vite-flow";
|
|
16
|
+
import { resolve as importMetaResolve } from "import-meta-resolve";
|
|
17
|
+
import { clientBundleTreeShakePlugin } from "../plugins/clientBundleTreeShakePlugin";
|
|
18
|
+
import { clientInjectionsPlugin } from "../plugins/clientInjectPlugin";
|
|
19
|
+
import { reactNativeCommonJsPlugin } from "../plugins/reactNativeCommonJsPlugin";
|
|
20
|
+
import { getBaseViteConfig } from "../utils/getBaseViteConfig";
|
|
21
|
+
import { getOptionsFilled } from "../utils/getOptionsFilled";
|
|
22
|
+
import { getVitePath } from "../utils/getVitePath";
|
|
23
|
+
import { checkPatches } from "../utils/patches";
|
|
24
|
+
import { createExpoServer } from "../vendor/createExpoServer";
|
|
25
|
+
function _array_like_to_array(arr, len) {
|
|
26
|
+
(len == null || len > arr.length) && (len = arr.length);
|
|
27
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++)
|
|
28
|
+
arr2[i] = arr[i];
|
|
29
|
+
return arr2;
|
|
30
|
+
}
|
|
31
|
+
function _array_with_holes(arr) {
|
|
32
|
+
if (Array.isArray(arr))
|
|
33
|
+
return arr;
|
|
34
|
+
}
|
|
35
|
+
function _array_without_holes(arr) {
|
|
36
|
+
if (Array.isArray(arr))
|
|
37
|
+
return _array_like_to_array(arr);
|
|
38
|
+
}
|
|
39
|
+
function asyncGeneratorStep(gen, resolve2, reject, _next, _throw, key, arg) {
|
|
40
|
+
try {
|
|
41
|
+
var info = gen[key](arg), value = info.value;
|
|
42
|
+
} catch (error) {
|
|
43
|
+
reject(error);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
info.done ? resolve2(value) : Promise.resolve(value).then(_next, _throw);
|
|
47
|
+
}
|
|
48
|
+
function _async_to_generator(fn) {
|
|
49
|
+
return function() {
|
|
50
|
+
var self = this, args = arguments;
|
|
51
|
+
return new Promise(function(resolve2, reject) {
|
|
52
|
+
var gen = fn.apply(self, args);
|
|
53
|
+
function _next(value) {
|
|
54
|
+
asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "next", value);
|
|
55
|
+
}
|
|
56
|
+
function _throw(err) {
|
|
57
|
+
asyncGeneratorStep(gen, resolve2, reject, _next, _throw, "throw", err);
|
|
58
|
+
}
|
|
59
|
+
_next(void 0);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function _define_property(obj, key, value) {
|
|
64
|
+
return key in obj ? Object.defineProperty(obj, key, {
|
|
65
|
+
value,
|
|
66
|
+
enumerable: !0,
|
|
67
|
+
configurable: !0,
|
|
68
|
+
writable: !0
|
|
69
|
+
}) : obj[key] = value, obj;
|
|
70
|
+
}
|
|
71
|
+
function _iterable_to_array(iter) {
|
|
72
|
+
if (typeof Symbol < "u" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
|
|
73
|
+
return Array.from(iter);
|
|
74
|
+
}
|
|
75
|
+
function _iterable_to_array_limit(arr, i) {
|
|
76
|
+
var _i = arr == null ? null : typeof Symbol < "u" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
77
|
+
if (_i != null) {
|
|
78
|
+
var _arr = [], _n = !0, _d = !1, _s, _e;
|
|
79
|
+
try {
|
|
80
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done) && (_arr.push(_s.value), !(i && _arr.length === i)); _n = !0)
|
|
81
|
+
;
|
|
82
|
+
} catch (err) {
|
|
83
|
+
_d = !0, _e = err;
|
|
84
|
+
} finally {
|
|
85
|
+
try {
|
|
86
|
+
!_n && _i.return != null && _i.return();
|
|
87
|
+
} finally {
|
|
88
|
+
if (_d)
|
|
89
|
+
throw _e;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return _arr;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function _non_iterable_rest() {
|
|
96
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
97
|
+
}
|
|
98
|
+
function _non_iterable_spread() {
|
|
99
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
100
|
+
}
|
|
101
|
+
function _object_spread(target) {
|
|
102
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
103
|
+
var source = arguments[i] != null ? arguments[i] : {}, ownKeys2 = Object.keys(source);
|
|
104
|
+
typeof Object.getOwnPropertySymbols == "function" && (ownKeys2 = ownKeys2.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
105
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
106
|
+
}))), ownKeys2.forEach(function(key) {
|
|
107
|
+
_define_property(target, key, source[key]);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
return target;
|
|
111
|
+
}
|
|
112
|
+
function ownKeys(object, enumerableOnly) {
|
|
113
|
+
var keys = Object.keys(object);
|
|
114
|
+
if (Object.getOwnPropertySymbols) {
|
|
115
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
116
|
+
enumerableOnly && (symbols = symbols.filter(function(sym) {
|
|
117
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
118
|
+
})), keys.push.apply(keys, symbols);
|
|
119
|
+
}
|
|
120
|
+
return keys;
|
|
121
|
+
}
|
|
122
|
+
function _object_spread_props(target, source) {
|
|
123
|
+
return source = source ?? {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
|
|
124
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
125
|
+
}), target;
|
|
126
|
+
}
|
|
127
|
+
function _sliced_to_array(arr, i) {
|
|
128
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
129
|
+
}
|
|
130
|
+
function _to_consumable_array(arr) {
|
|
131
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
132
|
+
}
|
|
133
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
134
|
+
if (o) {
|
|
135
|
+
if (typeof o == "string")
|
|
136
|
+
return _array_like_to_array(o, minLen);
|
|
137
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
138
|
+
if (n === "Object" && o.constructor && (n = o.constructor.name), n === "Map" || n === "Set")
|
|
139
|
+
return Array.from(n);
|
|
140
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
141
|
+
return _array_like_to_array(o, minLen);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function _ts_generator(thisArg, body) {
|
|
145
|
+
var f, y, t, g, _ = {
|
|
146
|
+
label: 0,
|
|
147
|
+
sent: function() {
|
|
148
|
+
if (t[0] & 1)
|
|
149
|
+
throw t[1];
|
|
150
|
+
return t[1];
|
|
151
|
+
},
|
|
152
|
+
trys: [],
|
|
153
|
+
ops: []
|
|
154
|
+
};
|
|
155
|
+
return g = {
|
|
156
|
+
next: verb(0),
|
|
157
|
+
throw: verb(1),
|
|
158
|
+
return: verb(2)
|
|
159
|
+
}, typeof Symbol == "function" && (g[Symbol.iterator] = function() {
|
|
160
|
+
return this;
|
|
161
|
+
}), g;
|
|
162
|
+
function verb(n) {
|
|
163
|
+
return function(v) {
|
|
164
|
+
return step([
|
|
165
|
+
n,
|
|
166
|
+
v
|
|
167
|
+
]);
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
function step(op) {
|
|
171
|
+
if (f)
|
|
172
|
+
throw new TypeError("Generator is already executing.");
|
|
173
|
+
for (; _; )
|
|
174
|
+
try {
|
|
175
|
+
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)
|
|
176
|
+
return t;
|
|
177
|
+
switch (y = 0, t && (op = [
|
|
178
|
+
op[0] & 2,
|
|
179
|
+
t.value
|
|
180
|
+
]), op[0]) {
|
|
181
|
+
case 0:
|
|
182
|
+
case 1:
|
|
183
|
+
t = op;
|
|
184
|
+
break;
|
|
185
|
+
case 4:
|
|
186
|
+
return _.label++, {
|
|
187
|
+
value: op[1],
|
|
188
|
+
done: !1
|
|
189
|
+
};
|
|
190
|
+
case 5:
|
|
191
|
+
_.label++, y = op[1], op = [
|
|
192
|
+
0
|
|
193
|
+
];
|
|
194
|
+
continue;
|
|
195
|
+
case 7:
|
|
196
|
+
op = _.ops.pop(), _.trys.pop();
|
|
197
|
+
continue;
|
|
198
|
+
default:
|
|
199
|
+
if (t = _.trys, !(t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
200
|
+
_ = 0;
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
204
|
+
_.label = op[1];
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
208
|
+
_.label = t[1], t = op;
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (t && _.label < t[2]) {
|
|
212
|
+
_.label = t[2], _.ops.push(op);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
t[2] && _.ops.pop(), _.trys.pop();
|
|
216
|
+
continue;
|
|
217
|
+
}
|
|
218
|
+
op = body.call(thisArg, _);
|
|
219
|
+
} catch (e) {
|
|
220
|
+
op = [
|
|
221
|
+
6,
|
|
222
|
+
e
|
|
223
|
+
], y = 0;
|
|
224
|
+
} finally {
|
|
225
|
+
f = t = 0;
|
|
226
|
+
}
|
|
227
|
+
if (op[0] & 5)
|
|
228
|
+
throw op[1];
|
|
229
|
+
return {
|
|
230
|
+
value: op[0] ? op[1] : void 0,
|
|
231
|
+
done: !0
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
var resolveFile = function(path) {
|
|
236
|
+
try {
|
|
237
|
+
return importMetaResolve(path, import.meta.url).replace("file://", "");
|
|
238
|
+
} catch {
|
|
239
|
+
return require.resolve(path);
|
|
240
|
+
}
|
|
241
|
+
}, nativeExtensions = [
|
|
242
|
+
".native.tsx",
|
|
243
|
+
".native.jsx",
|
|
244
|
+
".native.js",
|
|
245
|
+
".tsx",
|
|
246
|
+
".ts",
|
|
247
|
+
".js",
|
|
248
|
+
".css",
|
|
249
|
+
".json"
|
|
250
|
+
], extensions = [
|
|
251
|
+
".web.tsx",
|
|
252
|
+
".tsx",
|
|
253
|
+
".web.ts",
|
|
254
|
+
".ts",
|
|
255
|
+
".web.jsx",
|
|
256
|
+
".jsx",
|
|
257
|
+
".web.js",
|
|
258
|
+
".js",
|
|
259
|
+
".css",
|
|
260
|
+
".json"
|
|
261
|
+
], ensureDir = FSExtra.ensureDir, pathExists = FSExtra.pathExists, pathExistsSync = FSExtra.pathExistsSync, dev = function() {
|
|
262
|
+
var _ref = _async_to_generator(function(optionsIn) {
|
|
263
|
+
var options, host, port, root, cacheDir, entryRoot, prebuilds, viteFlow, templateFile, hotUpdatedCJSFiles, jsxRuntime, _tmp, virtualModules, _tmp1, _, _tmp2, _tmp3, swapRnPlugin, depsToOptimize, reactNativeHMRPlugin, serverConfig, resolvedConfig, viteRNClientPlugin, viteServer, isBuilding, vitePort, router, app, handleUpgrade, clients, socket, proxyEventHandler, server;
|
|
264
|
+
function getBundleCode() {
|
|
265
|
+
return _getBundleCode.apply(this, arguments);
|
|
266
|
+
}
|
|
267
|
+
function _getBundleCode() {
|
|
268
|
+
return _getBundleCode = _async_to_generator(function() {
|
|
269
|
+
var tmpBundle, res, done, buildConfig, buildOutput, appCode, appRootParent, template, out;
|
|
270
|
+
function babelReanimated(input, filename) {
|
|
271
|
+
return _babelReanimated.apply(this, arguments);
|
|
272
|
+
}
|
|
273
|
+
function _babelReanimated() {
|
|
274
|
+
return _babelReanimated = _async_to_generator(function(input, filename) {
|
|
275
|
+
return _ts_generator(this, function(_state) {
|
|
276
|
+
switch (_state.label) {
|
|
277
|
+
case 0:
|
|
278
|
+
return [
|
|
279
|
+
4,
|
|
280
|
+
new Promise(function(res2, rej) {
|
|
281
|
+
babel.transform(input, {
|
|
282
|
+
plugins: [
|
|
283
|
+
"react-native-reanimated/plugin"
|
|
284
|
+
],
|
|
285
|
+
filename
|
|
286
|
+
}, function(err, result) {
|
|
287
|
+
(!result || err) && rej(err || "no res"), res2(result.code);
|
|
288
|
+
});
|
|
289
|
+
})
|
|
290
|
+
];
|
|
291
|
+
case 1:
|
|
292
|
+
return [
|
|
293
|
+
2,
|
|
294
|
+
_state.sent()
|
|
295
|
+
];
|
|
296
|
+
}
|
|
297
|
+
});
|
|
298
|
+
}), _babelReanimated.apply(this, arguments);
|
|
299
|
+
}
|
|
300
|
+
return _ts_generator(this, function(_state) {
|
|
301
|
+
switch (_state.label) {
|
|
302
|
+
case 0:
|
|
303
|
+
return process.env.LOAD_TMP_BUNDLE ? (tmpBundle = join(process.cwd(), "bundle.tmp.js"), [
|
|
304
|
+
4,
|
|
305
|
+
pathExists(tmpBundle)
|
|
306
|
+
]) : [
|
|
307
|
+
3,
|
|
308
|
+
3
|
|
309
|
+
];
|
|
310
|
+
case 1:
|
|
311
|
+
return _state.sent() ? (console.info("\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F returning temp bundle \u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F\u26A0\uFE0F", tmpBundle), [
|
|
312
|
+
4,
|
|
313
|
+
readFile(tmpBundle, "utf-8")
|
|
314
|
+
]) : [
|
|
315
|
+
3,
|
|
316
|
+
3
|
|
317
|
+
];
|
|
318
|
+
case 2:
|
|
319
|
+
return [
|
|
320
|
+
2,
|
|
321
|
+
_state.sent()
|
|
322
|
+
];
|
|
323
|
+
case 3:
|
|
324
|
+
return isBuilding ? [
|
|
325
|
+
4,
|
|
326
|
+
isBuilding
|
|
327
|
+
] : [
|
|
328
|
+
3,
|
|
329
|
+
5
|
|
330
|
+
];
|
|
331
|
+
case 4:
|
|
332
|
+
return res = _state.sent(), [
|
|
333
|
+
2,
|
|
334
|
+
res
|
|
335
|
+
];
|
|
336
|
+
case 5:
|
|
337
|
+
return isBuilding = new Promise(function(res2) {
|
|
338
|
+
done = res2;
|
|
339
|
+
}), buildConfig = {
|
|
340
|
+
plugins: [
|
|
341
|
+
viteFlow,
|
|
342
|
+
swapRnPlugin,
|
|
343
|
+
{
|
|
344
|
+
name: "reanimated",
|
|
345
|
+
transform: function(code, id) {
|
|
346
|
+
return _async_to_generator(function() {
|
|
347
|
+
var out2;
|
|
348
|
+
return _ts_generator(this, function(_state2) {
|
|
349
|
+
switch (_state2.label) {
|
|
350
|
+
case 0:
|
|
351
|
+
return code.includes("worklet") ? [
|
|
352
|
+
4,
|
|
353
|
+
babelReanimated(code, id)
|
|
354
|
+
] : [
|
|
355
|
+
3,
|
|
356
|
+
2
|
|
357
|
+
];
|
|
358
|
+
case 1:
|
|
359
|
+
return out2 = _state2.sent(), [
|
|
360
|
+
2,
|
|
361
|
+
out2
|
|
362
|
+
];
|
|
363
|
+
case 2:
|
|
364
|
+
return [
|
|
365
|
+
2
|
|
366
|
+
];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
})();
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
clientBundleTreeShakePlugin({}),
|
|
373
|
+
viteRNClientPlugin,
|
|
374
|
+
reactNativeCommonJsPlugin({
|
|
375
|
+
root,
|
|
376
|
+
port,
|
|
377
|
+
mode: "build"
|
|
378
|
+
}),
|
|
379
|
+
viteReactPlugin({
|
|
380
|
+
tsDecorators: !0,
|
|
381
|
+
mode: "build"
|
|
382
|
+
}),
|
|
383
|
+
{
|
|
384
|
+
name: "treat-js-files-as-jsx",
|
|
385
|
+
transform: function(code, id) {
|
|
386
|
+
return _async_to_generator(function() {
|
|
387
|
+
return _ts_generator(this, function(_state2) {
|
|
388
|
+
return id.match(/expo-status-bar/) ? [
|
|
389
|
+
2,
|
|
390
|
+
transformWithEsbuild(code, id, {
|
|
391
|
+
loader: "jsx",
|
|
392
|
+
jsx: "automatic"
|
|
393
|
+
})
|
|
394
|
+
] : [
|
|
395
|
+
2,
|
|
396
|
+
null
|
|
397
|
+
];
|
|
398
|
+
});
|
|
399
|
+
})();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
].filter(Boolean),
|
|
403
|
+
appType: "custom",
|
|
404
|
+
root,
|
|
405
|
+
clearScreen: !1,
|
|
406
|
+
optimizeDeps: {
|
|
407
|
+
include: depsToOptimize,
|
|
408
|
+
esbuildOptions: {
|
|
409
|
+
jsx: "automatic"
|
|
410
|
+
}
|
|
411
|
+
},
|
|
412
|
+
resolve: {
|
|
413
|
+
extensions: nativeExtensions
|
|
414
|
+
},
|
|
415
|
+
mode: "development",
|
|
416
|
+
define: {
|
|
417
|
+
"process.env.NODE_ENV": '"development"'
|
|
418
|
+
},
|
|
419
|
+
build: {
|
|
420
|
+
ssr: !1,
|
|
421
|
+
minify: !1,
|
|
422
|
+
commonjsOptions: {
|
|
423
|
+
transformMixedEsModules: !0
|
|
424
|
+
},
|
|
425
|
+
rollupOptions: {
|
|
426
|
+
treeshake: !1,
|
|
427
|
+
preserveEntrySignatures: "strict",
|
|
428
|
+
output: {
|
|
429
|
+
preserveModules: !0,
|
|
430
|
+
format: "cjs"
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
}, options.buildConfig && (buildConfig = mergeConfig(buildConfig, options.buildConfig)), [
|
|
435
|
+
4,
|
|
436
|
+
resolveConfig(buildConfig, "build")
|
|
437
|
+
];
|
|
438
|
+
case 6:
|
|
439
|
+
return _state.sent(), [
|
|
440
|
+
4,
|
|
441
|
+
build(buildConfig)
|
|
442
|
+
];
|
|
443
|
+
case 7:
|
|
444
|
+
if (buildOutput = _state.sent(), !("output" in buildOutput) || (appCode = buildOutput.output.sort(function(a, b) {
|
|
445
|
+
return a.isEntry ? 1 : -1;
|
|
446
|
+
}).map(function(outputModule) {
|
|
447
|
+
if (outputModule.type == "chunk") {
|
|
448
|
+
var importsMap = {
|
|
449
|
+
currentPath: outputModule.fileName
|
|
450
|
+
}, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
451
|
+
try {
|
|
452
|
+
for (var _iterator = outputModule.imports[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
453
|
+
var imp = _step.value, relativePath = relative(dirname(outputModule.fileName), imp);
|
|
454
|
+
importsMap[relativePath[0] === "." ? relativePath : "./" + relativePath] = imp;
|
|
455
|
+
}
|
|
456
|
+
} catch (err) {
|
|
457
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
458
|
+
} finally {
|
|
459
|
+
try {
|
|
460
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
461
|
+
} finally {
|
|
462
|
+
if (_didIteratorError)
|
|
463
|
+
throw _iteratorError;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
return outputModule.isEntry && (entryRoot = dirname(outputModule.fileName)), `
|
|
467
|
+
___modules___["`.concat(outputModule.fileName, `"] = ((exports, module) => {
|
|
468
|
+
const require = createRequire(`).concat(JSON.stringify(importsMap, null, 2), `)
|
|
469
|
+
|
|
470
|
+
`).concat(outputModule.code, `
|
|
471
|
+
})
|
|
472
|
+
|
|
473
|
+
`).concat(outputModule.isEntry ? `
|
|
474
|
+
// run entry
|
|
475
|
+
const __require = createRequire({})
|
|
476
|
+
__require("react-native")
|
|
477
|
+
__require("`.concat(outputModule.fileName, `")
|
|
478
|
+
`) : "", `
|
|
479
|
+
`);
|
|
480
|
+
}
|
|
481
|
+
}).join(`
|
|
482
|
+
`), !appCode))
|
|
483
|
+
throw "\u274C";
|
|
484
|
+
return appCode = appCode.replaceAll("undefined.accept(() => {})", "").replaceAll("undefined.accept(function() {});", "").replaceAll("(void 0).accept(() => {})", "").replaceAll("(void 0).accept(function() {});", "").replaceAll('dist/esm/index.mjs"', 'dist/esm/index.js"'), appRootParent = join(root, "..", ".."), [
|
|
485
|
+
4,
|
|
486
|
+
readFile(templateFile, "utf-8")
|
|
487
|
+
];
|
|
488
|
+
case 8:
|
|
489
|
+
return template = _state.sent().replace("_virtual/virtual_react-native.js", relative(appRootParent, prebuilds.reactNative)).replace("_virtual/virtual_react.js", relative(appRootParent, prebuilds.react)).replaceAll("_virtual/virtual_react-jsx.js", relative(appRootParent, prebuilds.reactJSX)), out = template + appCode, done(out), isBuilding = null, [
|
|
490
|
+
2,
|
|
491
|
+
out
|
|
492
|
+
];
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
}), _getBundleCode.apply(this, arguments);
|
|
496
|
+
}
|
|
497
|
+
return _ts_generator(this, function(_state) {
|
|
498
|
+
switch (_state.label) {
|
|
499
|
+
case 0:
|
|
500
|
+
return [
|
|
501
|
+
4,
|
|
502
|
+
getOptionsFilled(optionsIn)
|
|
503
|
+
];
|
|
504
|
+
case 1:
|
|
505
|
+
return options = _state.sent(), host = options.host, port = options.port, root = options.root, cacheDir = options.cacheDir, bindKeypressInput(), entryRoot = "", checkPatches(options).catch(function(err) {
|
|
506
|
+
console.error(`
|
|
507
|
+
\u{1F97A} couldn't patch`, err);
|
|
508
|
+
}), [
|
|
509
|
+
4,
|
|
510
|
+
ensureDir(cacheDir)
|
|
511
|
+
];
|
|
512
|
+
case 2:
|
|
513
|
+
return _state.sent(), prebuilds = {
|
|
514
|
+
reactJSX: join(cacheDir, "react-jsx-runtime.js"),
|
|
515
|
+
react: join(cacheDir, "react.js"),
|
|
516
|
+
reactNative: join(cacheDir, "react-native.js")
|
|
517
|
+
}, [
|
|
518
|
+
4,
|
|
519
|
+
pathExists(prebuilds.reactNative)
|
|
520
|
+
];
|
|
521
|
+
case 3:
|
|
522
|
+
return _state.sent() ? [
|
|
523
|
+
3,
|
|
524
|
+
5
|
|
525
|
+
] : (console.info("Pre-building react, react-native react/jsx-runtime (one time cost)..."), [
|
|
526
|
+
4,
|
|
527
|
+
Promise.all([
|
|
528
|
+
buildReactNative({
|
|
529
|
+
entryPoints: [
|
|
530
|
+
resolveFile("react-native")
|
|
531
|
+
],
|
|
532
|
+
outfile: prebuilds.reactNative
|
|
533
|
+
}),
|
|
534
|
+
buildReact({
|
|
535
|
+
entryPoints: [
|
|
536
|
+
resolveFile("react")
|
|
537
|
+
],
|
|
538
|
+
outfile: prebuilds.react
|
|
539
|
+
}),
|
|
540
|
+
buildReactJSX({
|
|
541
|
+
entryPoints: [
|
|
542
|
+
resolveFile("react/jsx-dev-runtime")
|
|
543
|
+
],
|
|
544
|
+
outfile: prebuilds.reactJSX
|
|
545
|
+
})
|
|
546
|
+
])
|
|
547
|
+
]);
|
|
548
|
+
case 4:
|
|
549
|
+
_state.sent(), _state.label = 5;
|
|
550
|
+
case 5:
|
|
551
|
+
return viteFlow = options.flow ? createViteFlow(options.flow) : null, templateFile = resolveFile("vxrn/react-native-template.js"), hotUpdatedCJSFiles = /* @__PURE__ */ new Map(), _tmp = {
|
|
552
|
+
// alias: 'virtual:react-jsx',
|
|
553
|
+
alias: prebuilds.reactJSX
|
|
554
|
+
}, [
|
|
555
|
+
4,
|
|
556
|
+
readFile(prebuilds.reactJSX, "utf-8")
|
|
557
|
+
];
|
|
558
|
+
case 6:
|
|
559
|
+
return jsxRuntime = (_tmp.contents = _state.sent(), _tmp), _tmp1 = {}, _ = "react-native", _tmp2 = {
|
|
560
|
+
// alias: 'virtual:react-native',
|
|
561
|
+
alias: prebuilds.reactNative
|
|
562
|
+
}, [
|
|
563
|
+
4,
|
|
564
|
+
readFile(prebuilds.reactNative, "utf-8")
|
|
565
|
+
];
|
|
566
|
+
case 7:
|
|
567
|
+
return _tmp1[_] = (_tmp2.contents = _state.sent(), _tmp2), _tmp3 = {
|
|
568
|
+
// alias: 'virtual:react',
|
|
569
|
+
alias: prebuilds.react
|
|
570
|
+
}, [
|
|
571
|
+
4,
|
|
572
|
+
readFile(prebuilds.react, "utf-8")
|
|
573
|
+
];
|
|
574
|
+
case 8:
|
|
575
|
+
return virtualModules = (_tmp1.react = (_tmp3.contents = _state.sent(), _tmp3), _tmp1["react/jsx-runtime"] = jsxRuntime, _tmp1["react/jsx-dev-runtime"] = jsxRuntime, _tmp1), swapRnPlugin = {
|
|
576
|
+
name: "swap-react-native",
|
|
577
|
+
enforce: "pre",
|
|
578
|
+
resolveId: function(id) {
|
|
579
|
+
var importer = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
580
|
+
if (id.startsWith("react-native/Libraries"))
|
|
581
|
+
return "virtual:rn-internals:".concat(id);
|
|
582
|
+
if (id === "react-native-web")
|
|
583
|
+
return prebuilds.reactNative;
|
|
584
|
+
for (var targetId in virtualModules)
|
|
585
|
+
if (id === targetId || id.includes("node_modules/".concat(targetId, "/"))) {
|
|
586
|
+
var info = virtualModules[targetId];
|
|
587
|
+
return info.alias;
|
|
588
|
+
}
|
|
589
|
+
if (id[0] === ".") {
|
|
590
|
+
var absolutePath = resolve(dirname(importer), id), nativePath = absolutePath.replace(/(.m?js)/, ".native.js");
|
|
591
|
+
if (nativePath === id)
|
|
592
|
+
return;
|
|
593
|
+
try {
|
|
594
|
+
var directoryPath = absolutePath + "/index.native.js", directoryNonNativePath = absolutePath + "/index.js";
|
|
595
|
+
if (pathExistsSync(directoryPath))
|
|
596
|
+
return directoryPath;
|
|
597
|
+
if (pathExistsSync(directoryNonNativePath))
|
|
598
|
+
return directoryNonNativePath;
|
|
599
|
+
if (pathExistsSync(nativePath))
|
|
600
|
+
return nativePath;
|
|
601
|
+
} catch (err) {
|
|
602
|
+
console.warn("error probably fine", err);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
load: function(id) {
|
|
607
|
+
if (id.startsWith("virtual:rn-internals")) {
|
|
608
|
+
var idOut = id.replace("virtual:rn-internals:", ""), out = 'const ___val = __cachedModules["'.concat(idOut, `"]
|
|
609
|
+
const ___defaultVal = ___val ? ___val.default || ___val : ___val
|
|
610
|
+
export default ___defaultVal`);
|
|
611
|
+
return out;
|
|
612
|
+
}
|
|
613
|
+
for (var targetId in virtualModules) {
|
|
614
|
+
var info = virtualModules[targetId];
|
|
615
|
+
if (id === info.alias)
|
|
616
|
+
return info.contents;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}, depsToOptimize = [
|
|
620
|
+
"react",
|
|
621
|
+
"react-dom",
|
|
622
|
+
"@react-native/normalize-color"
|
|
623
|
+
], reactNativeHMRPlugin = {
|
|
624
|
+
name: "client-transform",
|
|
625
|
+
handleHotUpdate: function(param) {
|
|
626
|
+
var read = param.read, modules = param.modules, file = param.file;
|
|
627
|
+
return _async_to_generator(function() {
|
|
628
|
+
var _this, _this1, _modules, module, id, code, source, importsMap, _parse, imports, accumulatedSliceOffset, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, specifier, importName, start, id1, len, extraLen, err, hotUpdateSource, err1;
|
|
629
|
+
return _ts_generator(this, function(_state2) {
|
|
630
|
+
switch (_state2.label) {
|
|
631
|
+
case 0:
|
|
632
|
+
return _state2.trys.push([
|
|
633
|
+
0,
|
|
634
|
+
12,
|
|
635
|
+
,
|
|
636
|
+
13
|
|
637
|
+
]), isWithin(root, file) ? (_modules = _sliced_to_array(modules, 1), module = _modules[0], module ? (id = (module == null ? void 0 : module.url) || file.replace(root, ""), [
|
|
638
|
+
4,
|
|
639
|
+
read()
|
|
640
|
+
]) : [
|
|
641
|
+
2
|
|
642
|
+
]) : [
|
|
643
|
+
2
|
|
644
|
+
];
|
|
645
|
+
case 1:
|
|
646
|
+
return code = _state2.sent(), code.startsWith("'use strict';") ? [
|
|
647
|
+
2
|
|
648
|
+
] : code ? (source = code, [
|
|
649
|
+
4,
|
|
650
|
+
transformForBuild(id, source)
|
|
651
|
+
]) : [
|
|
652
|
+
2
|
|
653
|
+
];
|
|
654
|
+
case 2:
|
|
655
|
+
source = ((_this = _state2.sent()) === null || _this === void 0 ? void 0 : _this.code) || "", importsMap = {}, _parse = _sliced_to_array(parse(source), 1), imports = _parse[0], accumulatedSliceOffset = 0, _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0, _state2.label = 3;
|
|
656
|
+
case 3:
|
|
657
|
+
_state2.trys.push([
|
|
658
|
+
3,
|
|
659
|
+
8,
|
|
660
|
+
9,
|
|
661
|
+
10
|
|
662
|
+
]), _iterator = imports[Symbol.iterator](), _state2.label = 4;
|
|
663
|
+
case 4:
|
|
664
|
+
return (_iteratorNormalCompletion = (_step = _iterator.next()).done) ? [
|
|
665
|
+
3,
|
|
666
|
+
7
|
|
667
|
+
] : (specifier = _step.value, importName = specifier.n, start = specifier.s, importName ? [
|
|
668
|
+
4,
|
|
669
|
+
getVitePath(entryRoot, file, importName)
|
|
670
|
+
] : [
|
|
671
|
+
3,
|
|
672
|
+
6
|
|
673
|
+
]);
|
|
674
|
+
case 5:
|
|
675
|
+
if (id1 = _state2.sent(), !id1)
|
|
676
|
+
return console.warn("???"), [
|
|
677
|
+
3,
|
|
678
|
+
6
|
|
679
|
+
];
|
|
680
|
+
importsMap[id1] = id1.replace(/^(\.\.\/)+/, ""), len = importName.length, extraLen = id1.length - len, source = source.slice(0, start + accumulatedSliceOffset) + id1 + source.slice(start + accumulatedSliceOffset + len), accumulatedSliceOffset += extraLen, _state2.label = 6;
|
|
681
|
+
case 6:
|
|
682
|
+
return _iteratorNormalCompletion = !0, [
|
|
683
|
+
3,
|
|
684
|
+
4
|
|
685
|
+
];
|
|
686
|
+
case 7:
|
|
687
|
+
return [
|
|
688
|
+
3,
|
|
689
|
+
10
|
|
690
|
+
];
|
|
691
|
+
case 8:
|
|
692
|
+
return err = _state2.sent(), _didIteratorError = !0, _iteratorError = err, [
|
|
693
|
+
3,
|
|
694
|
+
10
|
|
695
|
+
];
|
|
696
|
+
case 9:
|
|
697
|
+
try {
|
|
698
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
699
|
+
} finally {
|
|
700
|
+
if (_didIteratorError)
|
|
701
|
+
throw _iteratorError;
|
|
702
|
+
}
|
|
703
|
+
return [
|
|
704
|
+
7
|
|
705
|
+
];
|
|
706
|
+
case 10:
|
|
707
|
+
return [
|
|
708
|
+
4,
|
|
709
|
+
swcTransform(id, source, {
|
|
710
|
+
mode: "serve-cjs"
|
|
711
|
+
})
|
|
712
|
+
];
|
|
713
|
+
case 11:
|
|
714
|
+
if (source = ((_this1 = _state2.sent()) === null || _this1 === void 0 ? void 0 : _this1.code) || "", !source)
|
|
715
|
+
throw "\u274C no source";
|
|
716
|
+
return importsMap.currentPath = id, hotUpdateSource = `exports = ((exports) => {
|
|
717
|
+
const require = createRequire(`.concat(JSON.stringify(importsMap, null, 2), `)
|
|
718
|
+
`).concat(source.replace("import.meta.hot.accept(() => {})", "").replaceAll(/import.meta.glob\(.*\)/gi, "globalThis['__importMetaGlobbed'] || {}"), `;
|
|
719
|
+
return exports })({})`), process.env.DEBUG && console.info("Sending hot update", hotUpdateSource), hotUpdatedCJSFiles.set(id, hotUpdateSource), [
|
|
720
|
+
3,
|
|
721
|
+
13
|
|
722
|
+
];
|
|
723
|
+
case 12:
|
|
724
|
+
return err1 = _state2.sent(), console.error("Error processing hmr update:", err1), [
|
|
725
|
+
3,
|
|
726
|
+
13
|
|
727
|
+
];
|
|
728
|
+
case 13:
|
|
729
|
+
return [
|
|
730
|
+
2
|
|
731
|
+
];
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
})();
|
|
735
|
+
}
|
|
736
|
+
}, serverConfig = mergeConfig(getBaseViteConfig({
|
|
737
|
+
mode: "development"
|
|
738
|
+
}), {
|
|
739
|
+
root,
|
|
740
|
+
clearScreen: !1,
|
|
741
|
+
plugins: [
|
|
742
|
+
reactNativeHMRPlugin,
|
|
743
|
+
clientBundleTreeShakePlugin({})
|
|
744
|
+
],
|
|
745
|
+
optimizeDeps: {
|
|
746
|
+
include: depsToOptimize,
|
|
747
|
+
exclude: Object.values(virtualModules).map(function(v) {
|
|
748
|
+
return v.alias;
|
|
749
|
+
}),
|
|
750
|
+
force: !0,
|
|
751
|
+
esbuildOptions: {
|
|
752
|
+
resolveExtensions: extensions
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
server: {
|
|
756
|
+
hmr: {
|
|
757
|
+
path: "/__vxrnhmr"
|
|
758
|
+
},
|
|
759
|
+
cors: !0,
|
|
760
|
+
host
|
|
761
|
+
}
|
|
762
|
+
}), options.webConfig && (serverConfig = mergeConfig(serverConfig, options.webConfig)), [
|
|
763
|
+
4,
|
|
764
|
+
resolveConfig(serverConfig, "serve")
|
|
765
|
+
];
|
|
766
|
+
case 9:
|
|
767
|
+
return resolvedConfig = _state.sent(), viteRNClientPlugin = clientInjectionsPlugin(resolvedConfig), serverConfig = _object_spread_props(_object_spread({}, serverConfig), {
|
|
768
|
+
plugins: _to_consumable_array(serverConfig.plugins)
|
|
769
|
+
}), [
|
|
770
|
+
4,
|
|
771
|
+
createServer(serverConfig)
|
|
772
|
+
];
|
|
773
|
+
case 10:
|
|
774
|
+
return viteServer = _state.sent(), viteServer.watcher.addListener("change", function() {
|
|
775
|
+
var _ref2 = _async_to_generator(function(path) {
|
|
776
|
+
var id;
|
|
777
|
+
return _ts_generator(this, function(_state2) {
|
|
778
|
+
if (id = path.replace(process.cwd(), ""), !id.endsWith("tsx") && !id.endsWith("jsx"))
|
|
779
|
+
return [
|
|
780
|
+
2
|
|
781
|
+
];
|
|
782
|
+
try {
|
|
783
|
+
viteServer.transformRequest(id);
|
|
784
|
+
} catch (err) {
|
|
785
|
+
console.info("err", err);
|
|
786
|
+
}
|
|
787
|
+
return [
|
|
788
|
+
2
|
|
789
|
+
];
|
|
790
|
+
});
|
|
791
|
+
});
|
|
792
|
+
return function(path) {
|
|
793
|
+
return _ref2.apply(this, arguments);
|
|
794
|
+
};
|
|
795
|
+
}()), isBuilding = null, [
|
|
796
|
+
4,
|
|
797
|
+
viteServer.listen()
|
|
798
|
+
];
|
|
799
|
+
case 11:
|
|
800
|
+
return _state.sent(), vitePort = viteServer.config.server.port, console.info("vite running on", vitePort), router = createRouter(), app = createApp({
|
|
801
|
+
onError: function(error) {
|
|
802
|
+
console.error(error);
|
|
803
|
+
},
|
|
804
|
+
onRequest: function(event) {
|
|
805
|
+
console.info(" \u2192", event.path);
|
|
806
|
+
}
|
|
807
|
+
}), createExpoServer(root, app), router.get("/file", defineEventHandler(function(e) {
|
|
808
|
+
var query = getQuery(e);
|
|
809
|
+
if (typeof query.file == "string") {
|
|
810
|
+
var source = hotUpdatedCJSFiles.get(query.file);
|
|
811
|
+
return new Response(source, {
|
|
812
|
+
headers: {
|
|
813
|
+
"content-type": "text/javascript"
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
})), router.get("/index.bundle", defineEventHandler(function() {
|
|
818
|
+
var _ref2 = _async_to_generator(function(e) {
|
|
819
|
+
var _2;
|
|
820
|
+
return _ts_generator(this, function(_state2) {
|
|
821
|
+
switch (_state2.label) {
|
|
822
|
+
case 0:
|
|
823
|
+
return _2 = Response.bind, [
|
|
824
|
+
4,
|
|
825
|
+
getBundleCode()
|
|
826
|
+
];
|
|
827
|
+
case 1:
|
|
828
|
+
return [
|
|
829
|
+
2,
|
|
830
|
+
new (_2.apply(Response, [
|
|
831
|
+
void 0,
|
|
832
|
+
_state2.sent(),
|
|
833
|
+
{
|
|
834
|
+
headers: {
|
|
835
|
+
"content-type": "text/javascript"
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
]))()
|
|
839
|
+
];
|
|
840
|
+
}
|
|
841
|
+
});
|
|
842
|
+
});
|
|
843
|
+
return function(e) {
|
|
844
|
+
return _ref2.apply(this, arguments);
|
|
845
|
+
};
|
|
846
|
+
}())), router.get("/status", defineEventHandler(function() {
|
|
847
|
+
return "packager-status:running";
|
|
848
|
+
})), app.use(router), app.use(defineEventHandler(function() {
|
|
849
|
+
var _ref2 = _async_to_generator(function(param) {
|
|
850
|
+
var req, _req_headers_useragent, _req_url;
|
|
851
|
+
return _ts_generator(this, function(_state2) {
|
|
852
|
+
return req = param.node.req, !((_req_headers_useragent = req.headers["user-agent"]) === null || _req_headers_useragent === void 0) && _req_headers_useragent.match(/Expo|React/) ? req.url === "/" || !((_req_url = req.url) === null || _req_url === void 0) && _req_url.startsWith("/?platform=") ? [
|
|
853
|
+
2,
|
|
854
|
+
getIndexJsonResponse({
|
|
855
|
+
port,
|
|
856
|
+
root
|
|
857
|
+
})
|
|
858
|
+
] : [
|
|
859
|
+
2
|
|
860
|
+
] : [
|
|
861
|
+
2
|
|
862
|
+
];
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
return function(_2) {
|
|
866
|
+
return _ref2.apply(this, arguments);
|
|
867
|
+
};
|
|
868
|
+
}())), handleUpgrade = wsAdapter(app.websocket).handleUpgrade, vitePort && (clients = /* @__PURE__ */ new Set(), socket = new WebSocket("ws://localhost:".concat(vitePort, "/__vxrnhmr"), "vite-hmr"), console.info("connecting to vite..."), socket.on("open", function() {
|
|
869
|
+
console.info("...connected to vite!");
|
|
870
|
+
}), socket.on("message", function(msg) {
|
|
871
|
+
var message = msg.toString();
|
|
872
|
+
console.info(clients.size, "message", message);
|
|
873
|
+
var _iteratorNormalCompletion = !0, _didIteratorError = !1, _iteratorError = void 0;
|
|
874
|
+
try {
|
|
875
|
+
for (var _iterator = _to_consumable_array(clients)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = !0) {
|
|
876
|
+
var listener = _step.value;
|
|
877
|
+
listener.send(message);
|
|
878
|
+
}
|
|
879
|
+
} catch (err) {
|
|
880
|
+
_didIteratorError = !0, _iteratorError = err;
|
|
881
|
+
} finally {
|
|
882
|
+
try {
|
|
883
|
+
!_iteratorNormalCompletion && _iterator.return != null && _iterator.return();
|
|
884
|
+
} finally {
|
|
885
|
+
if (_didIteratorError)
|
|
886
|
+
throw _iteratorError;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}), socket.on("error", function(err) {
|
|
890
|
+
console.info("err", err);
|
|
891
|
+
}), app.use("/__vxrnhmr", defineWebSocketHandler({
|
|
892
|
+
open: function(peer) {
|
|
893
|
+
console.debug("[hmr:web] open", peer), clients.add(peer);
|
|
894
|
+
},
|
|
895
|
+
message: function(peer, message) {
|
|
896
|
+
socket.send(message.rawData);
|
|
897
|
+
},
|
|
898
|
+
close: function(peer, event) {
|
|
899
|
+
console.info("[hmr:web] close", peer, event), clients.delete(peer);
|
|
900
|
+
},
|
|
901
|
+
error: function(peer, error) {
|
|
902
|
+
console.error("[hmr:web] error", peer, error);
|
|
903
|
+
}
|
|
904
|
+
}))), app.use("/__hmr", defineWebSocketHandler({
|
|
905
|
+
open: function(peer) {
|
|
906
|
+
console.debug("[hmr] open", peer);
|
|
907
|
+
},
|
|
908
|
+
message: function(peer, message) {
|
|
909
|
+
console.info("[hmr] message", peer, message), message.text().includes("ping") && peer.send("pong");
|
|
910
|
+
},
|
|
911
|
+
close: function(peer, event) {
|
|
912
|
+
console.info("[hmr] close", peer, event);
|
|
913
|
+
},
|
|
914
|
+
error: function(peer, error) {
|
|
915
|
+
console.error("[hmr] error", peer, error);
|
|
916
|
+
}
|
|
917
|
+
})), app.use("/__client", defineWebSocketHandler({
|
|
918
|
+
open: function(peer) {
|
|
919
|
+
console.info("[client] open", peer);
|
|
920
|
+
},
|
|
921
|
+
message: function(peer, messageRaw) {
|
|
922
|
+
var message2 = JSON.parse(messageRaw.text());
|
|
923
|
+
switch (message2.type) {
|
|
924
|
+
case "client-log": {
|
|
925
|
+
var _console;
|
|
926
|
+
(_console = console).info.apply(_console, [
|
|
927
|
+
"\u{1FAB5} [".concat(message2.level, "]")
|
|
928
|
+
].concat(_to_consumable_array(message2.data)));
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
default:
|
|
932
|
+
console.warn("[client] Unknown message type", message2);
|
|
933
|
+
}
|
|
934
|
+
},
|
|
935
|
+
close: function(peer, event) {
|
|
936
|
+
console.info("[client] close", peer, event);
|
|
937
|
+
},
|
|
938
|
+
error: function(peer, error) {
|
|
939
|
+
console.error("[client] error", peer, error);
|
|
940
|
+
}
|
|
941
|
+
})), proxyEventHandler = createProxyEventHandler({
|
|
942
|
+
target: "http://127.0.0.1:".concat(vitePort),
|
|
943
|
+
enableLogger: !!process.env.DEBUG
|
|
944
|
+
}), app.use(eventHandler(proxyEventHandler)), server = nodeCreateServer(toNodeListener(app)), server.on("upgrade", handleUpgrade), [
|
|
945
|
+
2,
|
|
946
|
+
{
|
|
947
|
+
server,
|
|
948
|
+
viteServer,
|
|
949
|
+
start: function() {
|
|
950
|
+
return _async_to_generator(function() {
|
|
951
|
+
return _ts_generator(this, function(_state2) {
|
|
952
|
+
return server.listen(port), console.info("Server running on http://localhost:".concat(port)), [
|
|
953
|
+
2,
|
|
954
|
+
{
|
|
955
|
+
closePromise: new Promise(function(res) {
|
|
956
|
+
var _viteServer_httpServer;
|
|
957
|
+
return (_viteServer_httpServer = viteServer.httpServer) === null || _viteServer_httpServer === void 0 ? void 0 : _viteServer_httpServer.on("close", res);
|
|
958
|
+
})
|
|
959
|
+
}
|
|
960
|
+
];
|
|
961
|
+
});
|
|
962
|
+
})();
|
|
963
|
+
},
|
|
964
|
+
stop: /* @__PURE__ */ _async_to_generator(function() {
|
|
965
|
+
return _ts_generator(this, function(_state2) {
|
|
966
|
+
switch (_state2.label) {
|
|
967
|
+
case 0:
|
|
968
|
+
return [
|
|
969
|
+
4,
|
|
970
|
+
Promise.all([
|
|
971
|
+
server.close(),
|
|
972
|
+
viteServer.close()
|
|
973
|
+
])
|
|
974
|
+
];
|
|
975
|
+
case 1:
|
|
976
|
+
return _state2.sent(), [
|
|
977
|
+
2
|
|
978
|
+
];
|
|
979
|
+
}
|
|
980
|
+
});
|
|
981
|
+
})
|
|
982
|
+
}
|
|
983
|
+
];
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
});
|
|
987
|
+
return function(optionsIn) {
|
|
988
|
+
return _ref.apply(this, arguments);
|
|
989
|
+
};
|
|
990
|
+
}();
|
|
991
|
+
function getIndexJsonResponse(param) {
|
|
992
|
+
var port = param.port, root = param.root;
|
|
993
|
+
return {
|
|
994
|
+
name: "myapp",
|
|
995
|
+
slug: "myapp",
|
|
996
|
+
scheme: "myapp",
|
|
997
|
+
version: "1.0.0",
|
|
998
|
+
jsEngine: "jsc",
|
|
999
|
+
orientation: "portrait",
|
|
1000
|
+
icon: "./assets/icon.png",
|
|
1001
|
+
userInterfaceStyle: "light",
|
|
1002
|
+
splash: {
|
|
1003
|
+
image: "./assets/splash.png",
|
|
1004
|
+
resizeMode: "contain",
|
|
1005
|
+
backgroundColor: "#ffffff",
|
|
1006
|
+
imageUrl: "http://127.0.0.1:8081/assets/./assets/splash.png"
|
|
1007
|
+
},
|
|
1008
|
+
updates: {
|
|
1009
|
+
fallbackToCacheTimeout: 0
|
|
1010
|
+
},
|
|
1011
|
+
assetBundlePatterns: [
|
|
1012
|
+
"**/*"
|
|
1013
|
+
],
|
|
1014
|
+
ios: {
|
|
1015
|
+
supportsTablet: !0,
|
|
1016
|
+
bundleIdentifier: "com.natew.myapp"
|
|
1017
|
+
},
|
|
1018
|
+
android: {
|
|
1019
|
+
package: "com.tamagui.myapp",
|
|
1020
|
+
adaptiveIcon: {
|
|
1021
|
+
foregroundImage: "./assets/adaptive-icon.png",
|
|
1022
|
+
backgroundColor: "#FFFFFF",
|
|
1023
|
+
foregroundImageUrl: "http://127.0.0.1:8081/assets/./assets/adaptive-icon.png"
|
|
1024
|
+
}
|
|
1025
|
+
},
|
|
1026
|
+
web: {
|
|
1027
|
+
favicon: "./assets/favicon.png"
|
|
1028
|
+
},
|
|
1029
|
+
extra: {
|
|
1030
|
+
eas: {
|
|
1031
|
+
projectId: "061b4470-78c7-4d6a-b850-8167fb0a3434"
|
|
1032
|
+
}
|
|
1033
|
+
},
|
|
1034
|
+
_internal: {
|
|
1035
|
+
isDebug: !1,
|
|
1036
|
+
projectRoot: root,
|
|
1037
|
+
dynamicConfigPath: null,
|
|
1038
|
+
staticConfigPath: join(root, "app.json"),
|
|
1039
|
+
packageJsonPath: join(root, "package.json")
|
|
1040
|
+
},
|
|
1041
|
+
sdkVersion: "50.0.0",
|
|
1042
|
+
platforms: [
|
|
1043
|
+
"ios",
|
|
1044
|
+
"android",
|
|
1045
|
+
"web"
|
|
1046
|
+
],
|
|
1047
|
+
iconUrl: "http://127.0.0.1:".concat(port, "/assets/./assets/icon.png"),
|
|
1048
|
+
debuggerHost: "127.0.0.1:".concat(port),
|
|
1049
|
+
logUrl: "http://127.0.0.1:".concat(port, "/logs"),
|
|
1050
|
+
developer: {
|
|
1051
|
+
tool: "expo-cli",
|
|
1052
|
+
projectRoot: root
|
|
1053
|
+
},
|
|
1054
|
+
packagerOpts: {
|
|
1055
|
+
dev: !0
|
|
1056
|
+
},
|
|
1057
|
+
mainModuleName: "index",
|
|
1058
|
+
__flipperHack: "React Native packager is running",
|
|
1059
|
+
hostUri: "127.0.0.1:".concat(port),
|
|
1060
|
+
bundleUrl: "http://127.0.0.1:".concat(port, "/index.bundle?platform=ios&dev=true&hot=false&lazy=true"),
|
|
1061
|
+
id: "@anonymous/myapp-473c4543-3c36-4786-9db1-c66a62ac9b78"
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
function bindKeypressInput() {
|
|
1065
|
+
if (!process.stdin.setRawMode) {
|
|
1066
|
+
console.warn({
|
|
1067
|
+
msg: "Interactive mode is not supported in this environment"
|
|
1068
|
+
});
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
readline.emitKeypressEvents(process.stdin), process.stdin.setRawMode(!0), process.stdin.on("keypress", function(_key, data) {
|
|
1072
|
+
var ctrl = data.ctrl, name = data.name;
|
|
1073
|
+
if (ctrl === !0)
|
|
1074
|
+
switch (name) {
|
|
1075
|
+
case "c":
|
|
1076
|
+
process.exit();
|
|
1077
|
+
case "z":
|
|
1078
|
+
process.emit("SIGTSTP", "SIGTSTP");
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
else
|
|
1082
|
+
switch (name) {
|
|
1083
|
+
case "r":
|
|
1084
|
+
break;
|
|
1085
|
+
case "d":
|
|
1086
|
+
break;
|
|
1087
|
+
case "c":
|
|
1088
|
+
process.stdout.write("\x1B[2J\x1B[0;0H");
|
|
1089
|
+
break;
|
|
1090
|
+
}
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
function isWithin(outer, inner) {
|
|
1094
|
+
var rel = relative(outer, inner);
|
|
1095
|
+
return !rel.startsWith("../") && rel !== "..";
|
|
1096
|
+
}
|
|
1097
|
+
export {
|
|
1098
|
+
bindKeypressInput,
|
|
1099
|
+
dev,
|
|
1100
|
+
resolveFile
|
|
1101
|
+
};
|
|
1102
|
+
//# sourceMappingURL=dev.js.map
|