peachsim 0.1.755 → 0.1.756
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/cli/app-config.ts +4 -29
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +88 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +47 -36
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +13 -5
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +2551 -2220
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +914 -584
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +4 -4
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +94 -69
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1 -1
- package/dist-lib/vite.cjs +10 -4
- package/package.json +1 -1
- package/src/config.ts +92 -0
- package/src/configured-bundle-producer.ts +110 -0
- package/src/host/replacement-module-handler.ts +8 -2
- package/src/metro-plugin.ts +27 -0
package/dist-lib/metro.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.756 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -7,12 +7,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
7
7
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __esm = (fn, res) => function __init() {
|
|
11
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
+
};
|
|
10
13
|
var __commonJS = (cb, mod) => function __require() {
|
|
11
14
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
15
|
};
|
|
13
16
|
var __export = (target, all) => {
|
|
14
|
-
for (var
|
|
15
|
-
__defProp(target,
|
|
17
|
+
for (var name2 in all)
|
|
18
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
16
19
|
};
|
|
17
20
|
var __copyProps = (to, from, except, desc) => {
|
|
18
21
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -32,290 +35,59 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
35
|
));
|
|
33
36
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
37
|
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var COMMENT_NODE = 8;
|
|
43
|
-
function shouldIgnoreNode(node) {
|
|
44
|
-
return node.nodeType === TEXT_NODE || node.nodeType === COMMENT_NODE || node.nodeType === CDATA_NODE;
|
|
45
|
-
}
|
|
46
|
-
function isEmptyNode(node) {
|
|
47
|
-
if (!node.childNodes || node.childNodes.length === 0) {
|
|
48
|
-
return true;
|
|
49
|
-
} else {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function invariant(test, message) {
|
|
54
|
-
if (!test) {
|
|
55
|
-
throw new Error(message);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function parse2(xml) {
|
|
59
|
-
var doc = new DOMParser().parseFromString(xml, "text/xml");
|
|
60
|
-
invariant(
|
|
61
|
-
doc.documentElement.nodeName === "plist",
|
|
62
|
-
"malformed document. First element should be <plist>"
|
|
63
|
-
);
|
|
64
|
-
var plist3 = parsePlistXML(doc.documentElement);
|
|
65
|
-
if (plist3.length == 1) plist3 = plist3[0];
|
|
66
|
-
return plist3;
|
|
67
|
-
}
|
|
68
|
-
function parsePlistXML(node) {
|
|
69
|
-
var i, new_obj, key, val, new_arr, res, counter, type;
|
|
70
|
-
if (!node) return null;
|
|
71
|
-
if (node.nodeName === "plist") {
|
|
72
|
-
new_arr = [];
|
|
73
|
-
if (isEmptyNode(node)) {
|
|
74
|
-
return new_arr;
|
|
75
|
-
}
|
|
76
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
77
|
-
if (!shouldIgnoreNode(node.childNodes[i])) {
|
|
78
|
-
new_arr.push(parsePlistXML(node.childNodes[i]));
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return new_arr;
|
|
82
|
-
} else if (node.nodeName === "dict") {
|
|
83
|
-
new_obj = {};
|
|
84
|
-
key = null;
|
|
85
|
-
counter = 0;
|
|
86
|
-
if (isEmptyNode(node)) {
|
|
87
|
-
return new_obj;
|
|
88
|
-
}
|
|
89
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
90
|
-
if (shouldIgnoreNode(node.childNodes[i])) continue;
|
|
91
|
-
if (counter % 2 === 0) {
|
|
92
|
-
invariant(
|
|
93
|
-
node.childNodes[i].nodeName === "key",
|
|
94
|
-
"Missing key while parsing <dict/>."
|
|
95
|
-
);
|
|
96
|
-
key = parsePlistXML(node.childNodes[i]);
|
|
97
|
-
} else {
|
|
98
|
-
invariant(
|
|
99
|
-
node.childNodes[i].nodeName !== "key",
|
|
100
|
-
'Unexpected key "' + parsePlistXML(node.childNodes[i]) + '" while parsing <dict/>.'
|
|
101
|
-
);
|
|
102
|
-
new_obj[key] = parsePlistXML(node.childNodes[i]);
|
|
103
|
-
}
|
|
104
|
-
counter += 1;
|
|
105
|
-
}
|
|
106
|
-
if (counter % 2 === 1) {
|
|
107
|
-
new_obj[key] = "";
|
|
108
|
-
}
|
|
109
|
-
return new_obj;
|
|
110
|
-
} else if (node.nodeName === "array") {
|
|
111
|
-
new_arr = [];
|
|
112
|
-
if (isEmptyNode(node)) {
|
|
113
|
-
return new_arr;
|
|
114
|
-
}
|
|
115
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
116
|
-
if (!shouldIgnoreNode(node.childNodes[i])) {
|
|
117
|
-
res = parsePlistXML(node.childNodes[i]);
|
|
118
|
-
if (null != res) new_arr.push(res);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return new_arr;
|
|
122
|
-
} else if (node.nodeName === "#text") {
|
|
123
|
-
} else if (node.nodeName === "key") {
|
|
124
|
-
if (isEmptyNode(node)) {
|
|
125
|
-
return "";
|
|
126
|
-
}
|
|
127
|
-
invariant(
|
|
128
|
-
node.childNodes[0].nodeValue !== "__proto__",
|
|
129
|
-
"__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912"
|
|
130
|
-
);
|
|
131
|
-
return node.childNodes[0].nodeValue;
|
|
132
|
-
} else if (node.nodeName === "string") {
|
|
133
|
-
res = "";
|
|
134
|
-
if (isEmptyNode(node)) {
|
|
135
|
-
return res;
|
|
136
|
-
}
|
|
137
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
138
|
-
var type = node.childNodes[i].nodeType;
|
|
139
|
-
if (type === TEXT_NODE || type === CDATA_NODE) {
|
|
140
|
-
res += node.childNodes[i].nodeValue;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return res;
|
|
144
|
-
} else if (node.nodeName === "integer") {
|
|
145
|
-
invariant(!isEmptyNode(node), 'Cannot parse "" as integer.');
|
|
146
|
-
return parseInt(node.childNodes[0].nodeValue, 10);
|
|
147
|
-
} else if (node.nodeName === "real") {
|
|
148
|
-
invariant(!isEmptyNode(node), 'Cannot parse "" as real.');
|
|
149
|
-
res = "";
|
|
150
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
151
|
-
if (node.childNodes[i].nodeType === TEXT_NODE) {
|
|
152
|
-
res += node.childNodes[i].nodeValue;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
return parseFloat(res);
|
|
156
|
-
} else if (node.nodeName === "data") {
|
|
157
|
-
res = "";
|
|
158
|
-
if (isEmptyNode(node)) {
|
|
159
|
-
return Buffer.from(res, "base64");
|
|
160
|
-
}
|
|
161
|
-
for (i = 0; i < node.childNodes.length; i++) {
|
|
162
|
-
if (node.childNodes[i].nodeType === TEXT_NODE) {
|
|
163
|
-
res += node.childNodes[i].nodeValue.replace(/\s+/g, "");
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return Buffer.from(res, "base64");
|
|
167
|
-
} else if (node.nodeName === "date") {
|
|
168
|
-
invariant(!isEmptyNode(node), 'Cannot parse "" as Date.');
|
|
169
|
-
return new Date(node.childNodes[0].nodeValue);
|
|
170
|
-
} else if (node.nodeName === "null") {
|
|
171
|
-
return null;
|
|
172
|
-
} else if (node.nodeName === "true") {
|
|
173
|
-
return true;
|
|
174
|
-
} else if (node.nodeName === "false") {
|
|
175
|
-
return false;
|
|
176
|
-
} else {
|
|
177
|
-
throw new Error("Invalid PLIST tag " + node.nodeName);
|
|
178
|
-
}
|
|
38
|
+
// cli/app-project.ts
|
|
39
|
+
function firstNamedFile(dir, names) {
|
|
40
|
+
for (const name2 of names) {
|
|
41
|
+
const candidate = import_node_path.default.join(dir, name2);
|
|
42
|
+
try {
|
|
43
|
+
if (import_node_fs.default.statSync(candidate).isFile()) return candidate;
|
|
44
|
+
} catch {
|
|
179
45
|
}
|
|
180
46
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
var toString = Object.prototype.toString;
|
|
196
|
-
function type(obj) {
|
|
197
|
-
var m = toString.call(obj).match(/\[object (.*)\]/);
|
|
198
|
-
return m ? m[1] : m;
|
|
199
|
-
}
|
|
200
|
-
function build(obj, opts) {
|
|
201
|
-
var XMLHDR = {
|
|
202
|
-
version: "1.0",
|
|
203
|
-
encoding: "UTF-8"
|
|
204
|
-
};
|
|
205
|
-
var XMLDTD = {
|
|
206
|
-
pubid: "-//Apple//DTD PLIST 1.0//EN",
|
|
207
|
-
sysid: "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
|
|
208
|
-
};
|
|
209
|
-
var doc = xmlbuilder.create("plist");
|
|
210
|
-
doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
|
|
211
|
-
doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
|
|
212
|
-
doc.att("version", "1.0");
|
|
213
|
-
walk_obj(obj, doc);
|
|
214
|
-
if (!opts) opts = {};
|
|
215
|
-
opts.pretty = opts.pretty !== false;
|
|
216
|
-
return doc.end(opts);
|
|
217
|
-
}
|
|
218
|
-
function walk_obj(next, next_child) {
|
|
219
|
-
var tag_type, i, prop;
|
|
220
|
-
var name = type(next);
|
|
221
|
-
if ("Undefined" == name) {
|
|
222
|
-
return;
|
|
223
|
-
} else if (Array.isArray(next)) {
|
|
224
|
-
next_child = next_child.ele("array");
|
|
225
|
-
for (i = 0; i < next.length; i++) {
|
|
226
|
-
walk_obj(next[i], next_child);
|
|
227
|
-
}
|
|
228
|
-
} else if (Buffer.isBuffer(next)) {
|
|
229
|
-
next_child.ele("data").raw(next.toString("base64"));
|
|
230
|
-
} else if ("Object" == name) {
|
|
231
|
-
next_child = next_child.ele("dict");
|
|
232
|
-
for (prop in next) {
|
|
233
|
-
if (next.hasOwnProperty(prop)) {
|
|
234
|
-
next_child.ele("key").txt(prop);
|
|
235
|
-
walk_obj(next[prop], next_child);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
} else if ("Number" == name) {
|
|
239
|
-
tag_type = next % 1 === 0 ? "integer" : "real";
|
|
240
|
-
next_child.ele(tag_type).txt(next.toString());
|
|
241
|
-
} else if ("BigInt" == name) {
|
|
242
|
-
next_child.ele("integer").txt(next);
|
|
243
|
-
} else if ("Date" == name) {
|
|
244
|
-
next_child.ele("date").txt(ISODateString(new Date(next)));
|
|
245
|
-
} else if ("Boolean" == name) {
|
|
246
|
-
next_child.ele(next ? "true" : "false");
|
|
247
|
-
} else if ("String" == name) {
|
|
248
|
-
next_child.ele("string").txt(next);
|
|
249
|
-
} else if ("ArrayBuffer" == name) {
|
|
250
|
-
next_child.ele("data").raw(base64.fromByteArray(next));
|
|
251
|
-
} else if (next && next.buffer && "ArrayBuffer" == type(next.buffer)) {
|
|
252
|
-
next_child.ele("data").raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
|
|
253
|
-
} else if ("Null" === name) {
|
|
254
|
-
next_child.ele("null").txt("");
|
|
255
|
-
}
|
|
256
|
-
}
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
function findExpoAppConfig(dir) {
|
|
50
|
+
return firstNamedFile(dir, EXPO_APP_CONFIG_NAMES);
|
|
51
|
+
}
|
|
52
|
+
function findRNXAppConfig(dir) {
|
|
53
|
+
return firstNamedFile(dir, PEACH_APP_CONFIG_NAMES);
|
|
54
|
+
}
|
|
55
|
+
function resolveAppProject(projectRoot) {
|
|
56
|
+
const appDir = import_node_path.default.resolve(projectRoot);
|
|
57
|
+
try {
|
|
58
|
+
if (!import_node_fs.default.statSync(appDir).isDirectory()) return null;
|
|
59
|
+
} catch {
|
|
60
|
+
return null;
|
|
257
61
|
}
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
62
|
+
const configPath = findRNXAppConfig(appDir);
|
|
63
|
+
if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs.default.existsSync(import_node_path.default.join(appDir, "package.json"))) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
return { appDir, configPath };
|
|
67
|
+
}
|
|
68
|
+
var import_node_fs, import_node_path, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
|
|
69
|
+
var init_app_project = __esm({
|
|
70
|
+
"cli/app-project.ts"() {
|
|
71
|
+
"use strict";
|
|
72
|
+
import_node_fs = __toESM(require("node:fs"), 1);
|
|
73
|
+
import_node_path = __toESM(require("node:path"), 1);
|
|
74
|
+
EXPO_APP_CONFIG_NAMES = [
|
|
75
|
+
"app.config.js",
|
|
76
|
+
"app.config.ts",
|
|
77
|
+
"app.config.cjs",
|
|
78
|
+
"app.config.mjs",
|
|
79
|
+
"app.json"
|
|
80
|
+
];
|
|
81
|
+
PEACH_APP_CONFIG_NAMES = [
|
|
82
|
+
"peach.config.ts",
|
|
83
|
+
"peach.config.js",
|
|
84
|
+
"peach.config.mjs",
|
|
85
|
+
"peach.config.cjs"
|
|
86
|
+
];
|
|
271
87
|
}
|
|
272
88
|
});
|
|
273
89
|
|
|
274
|
-
// src/metro-plugin.ts
|
|
275
|
-
var metro_plugin_exports = {};
|
|
276
|
-
__export(metro_plugin_exports, {
|
|
277
|
-
default: () => metro_plugin_default,
|
|
278
|
-
toRNXDevelopmentBundleUrl: () => toRNXDevelopmentBundleUrl,
|
|
279
|
-
toRNXProductionBundleUrl: () => toRNXProductionBundleUrl,
|
|
280
|
-
withRNX: () => withRNX
|
|
281
|
-
});
|
|
282
|
-
module.exports = __toCommonJS(metro_plugin_exports);
|
|
283
|
-
var import_fs2 = __toESM(require("fs"), 1);
|
|
284
|
-
var import_module = require("module");
|
|
285
|
-
var import_node_crypto2 = require("node:crypto");
|
|
286
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
287
|
-
|
|
288
|
-
// src/dev-server-open.ts
|
|
289
|
-
var import_node_crypto = require("node:crypto");
|
|
290
|
-
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
291
|
-
function tagRnxBundleForPlugin(bundleUrl, replacementOrigin, replacementToken, projectRoot, appName) {
|
|
292
|
-
const absolute = /^[a-z][a-z\d+.-]*:\/\//i.test(bundleUrl);
|
|
293
|
-
const url = new URL(bundleUrl, absolute ? void 0 : "http://peach.local");
|
|
294
|
-
if (appName) {
|
|
295
|
-
url.searchParams.set("rnxAppName", appName);
|
|
296
|
-
url.searchParams.set(
|
|
297
|
-
"rnxProjectId",
|
|
298
|
-
(0, import_node_crypto.createHash)("sha256").update(import_node_fs.default.realpathSync(projectRoot)).digest("hex").slice(0, 32)
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
url.searchParams.set("rnxReplacementOrigin", replacementOrigin);
|
|
302
|
-
url.searchParams.set("rnxReplacementToken", replacementToken);
|
|
303
|
-
return absolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// src/host/replacement-module-handler.ts
|
|
307
|
-
var import_node_fs2 = require("node:fs");
|
|
308
|
-
var import_promises = __toESM(require("node:fs/promises"), 1);
|
|
309
|
-
var import_node_path = __toESM(require("node:path"), 1);
|
|
310
|
-
|
|
311
|
-
// ../contrast-bundler/src/replacementModule.ts
|
|
312
|
-
var import_dist = require("sucrase/dist/index.js");
|
|
313
|
-
var import_parser = require("sucrase/dist/parser/index.js");
|
|
314
|
-
var import_types = require("sucrase/dist/parser/tokenizer/types.js");
|
|
315
|
-
|
|
316
90
|
// ../contrast-bundler/src/posixPath.ts
|
|
317
|
-
var sep = "/";
|
|
318
|
-
var delimiter = ":";
|
|
319
91
|
function isAbsolute(p) {
|
|
320
92
|
return p.charCodeAt(0) === 47;
|
|
321
93
|
}
|
|
@@ -397,28 +169,29 @@ function relative(from, to) {
|
|
|
397
169
|
const up = new Array(fromParts.length - shared).fill("..");
|
|
398
170
|
return [...up, ...toParts.slice(shared)].join("/");
|
|
399
171
|
}
|
|
400
|
-
var posix
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
172
|
+
var sep, delimiter, posix, posixPath_default;
|
|
173
|
+
var init_posixPath = __esm({
|
|
174
|
+
"../contrast-bundler/src/posixPath.ts"() {
|
|
175
|
+
"use strict";
|
|
176
|
+
sep = "/";
|
|
177
|
+
delimiter = ":";
|
|
178
|
+
posix = {
|
|
179
|
+
sep,
|
|
180
|
+
delimiter,
|
|
181
|
+
isAbsolute,
|
|
182
|
+
normalize,
|
|
183
|
+
join,
|
|
184
|
+
resolve,
|
|
185
|
+
dirname,
|
|
186
|
+
basename,
|
|
187
|
+
extname,
|
|
188
|
+
relative
|
|
189
|
+
};
|
|
190
|
+
posixPath_default = { ...posix, posix };
|
|
191
|
+
}
|
|
192
|
+
});
|
|
413
193
|
|
|
414
194
|
// ../contrast-bundler/src/replacementModule.ts
|
|
415
|
-
var REPLACEMENT_MODULE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
416
|
-
var IMPORT_KEYWORD = import_types.TokenType["_import"];
|
|
417
|
-
var EXPORT_KEYWORD = import_types.TokenType["_export"];
|
|
418
|
-
var REACT_BRIDGE = "globalThis.__sootsim_react_bridge";
|
|
419
|
-
var REACT_NATIVE_BRIDGE = "globalThis.__sootsim_components__";
|
|
420
|
-
var PACKAGE_BRIDGES = "globalThis.__sootsim_config_package_modules";
|
|
421
|
-
var JSX_RUNTIME_SPECIFIERS = /* @__PURE__ */ new Set(["react/jsx-runtime", "react/jsx-dev-runtime"]);
|
|
422
195
|
function transformsFor(filePath) {
|
|
423
196
|
switch (extname(filePath).toLowerCase()) {
|
|
424
197
|
case ".ts":
|
|
@@ -445,24 +218,22 @@ function unsupportedSpecifier(specifier) {
|
|
|
445
218
|
`replacement modules may only import react, react-native, peach-kit, the packages rnx stubs for this app, and other project files by relative path; '${specifier}' is none of those. vendor the code into a project file, or add the package to peach.config so the simulator bridges it.`
|
|
446
219
|
);
|
|
447
220
|
}
|
|
448
|
-
function bridgeDeclaration(
|
|
221
|
+
function bridgeDeclaration(name2, specifier) {
|
|
449
222
|
const notReady = (what) => JSON.stringify(`[peach] replacement ${what} bridge is not ready`);
|
|
450
223
|
if (specifier === "react") {
|
|
451
|
-
return `const ${
|
|
224
|
+
return `const ${name2} = ${REACT_BRIDGE}; if (!${name2}) throw new Error(${notReady("React")});`;
|
|
452
225
|
}
|
|
453
226
|
if (specifier === "react-native") {
|
|
454
|
-
return `const ${
|
|
227
|
+
return `const ${name2} = ${REACT_NATIVE_BRIDGE}; if (!${name2}) throw new Error(${notReady("React Native")});`;
|
|
455
228
|
}
|
|
456
229
|
if (isPeachKitSpecifier(specifier)) {
|
|
457
|
-
return `const ${
|
|
230
|
+
return `const ${name2} = (globalThis.__peach_kit_modules && globalThis.__peach_kit_modules[${JSON.stringify(specifier)}]) || (${PACKAGE_BRIDGES} || {})[${JSON.stringify(specifier)}]; if (!${name2}) throw new Error(${JSON.stringify(`[peach] replacement package bridge ${specifier} is not ready`)});`;
|
|
458
231
|
}
|
|
459
232
|
if (JSX_RUNTIME_SPECIFIERS.has(specifier)) {
|
|
460
|
-
return `const ${
|
|
233
|
+
return `const ${name2} = (() => { const react = ${REACT_BRIDGE}; if (!react) throw new Error(${notReady("React")}); const jsx = (type, props, key) => react.createElement(type, key === undefined ? props : { ...props, key }); return { Fragment: react.Fragment, jsx, jsxs: jsx, jsxDEV: jsx }; })();`;
|
|
461
234
|
}
|
|
462
|
-
return `const ${
|
|
235
|
+
return `const ${name2} = (${PACKAGE_BRIDGES} || {})[${JSON.stringify(specifier)}]; if (!${name2}) throw new Error(${JSON.stringify(`[peach] replacement package bridge ${specifier} is not ready`)});`;
|
|
463
236
|
}
|
|
464
|
-
var DEFAULT_INTEROP = "__rnxReplacementDefault";
|
|
465
|
-
var DEFAULT_INTEROP_DECLARATION = `const ${DEFAULT_INTEROP} = (bridge) => (bridge && bridge.__esModule ? bridge.default : bridge);`;
|
|
466
237
|
function compileReplacementModule(input) {
|
|
467
238
|
const transformed = (0, import_dist.transform)(input.source, {
|
|
468
239
|
transforms: transformsFor(input.filePath),
|
|
@@ -485,15 +256,16 @@ function compileReplacementModule(input) {
|
|
|
485
256
|
return code.slice(token.start + 1, token.end - 1);
|
|
486
257
|
};
|
|
487
258
|
const bridgeNames = /* @__PURE__ */ new Map();
|
|
259
|
+
const bareSpecifiers = /* @__PURE__ */ new Set();
|
|
488
260
|
const declarations = [];
|
|
489
261
|
let needsDefaultInterop = false;
|
|
490
262
|
const bridgeFor = (specifier) => {
|
|
491
263
|
const existing = bridgeNames.get(specifier);
|
|
492
264
|
if (existing) return existing;
|
|
493
|
-
const
|
|
494
|
-
bridgeNames.set(specifier,
|
|
495
|
-
declarations.push(bridgeDeclaration(
|
|
496
|
-
return
|
|
265
|
+
const name2 = `__rnxReplacementBridge${bridgeNames.size}`;
|
|
266
|
+
bridgeNames.set(specifier, name2);
|
|
267
|
+
declarations.push(bridgeDeclaration(name2, specifier));
|
|
268
|
+
return name2;
|
|
497
269
|
};
|
|
498
270
|
const edits = [];
|
|
499
271
|
const pointAtLocalModule = (specifierToken, specifier) => {
|
|
@@ -585,6 +357,7 @@ function compileReplacementModule(input) {
|
|
|
585
357
|
if (specifier !== "react" && specifier !== "react-native" && !JSX_RUNTIME_SPECIFIERS.has(specifier) && !isPeachKitSpecifier(specifier) && !input.runtimePackages.has(specifier)) {
|
|
586
358
|
throw unsupportedSpecifier(specifier);
|
|
587
359
|
}
|
|
360
|
+
bareSpecifiers.add(specifier);
|
|
588
361
|
const bridge = bindings.length > 0 ? bridgeFor(specifier) : null;
|
|
589
362
|
const replacement = bindings.map((binding) => {
|
|
590
363
|
if (binding.imported === null) return `const ${binding.local} = ${bridge};`;
|
|
@@ -592,186 +365,728 @@ function compileReplacementModule(input) {
|
|
|
592
365
|
needsDefaultInterop = true;
|
|
593
366
|
return `const ${binding.local} = ${DEFAULT_INTEROP}(${bridge});`;
|
|
594
367
|
}
|
|
595
|
-
return `const ${binding.local} = ${bridge}[${JSON.stringify(binding.imported)}];`;
|
|
596
|
-
}).join(" ");
|
|
597
|
-
const start = token.start;
|
|
598
|
-
const end = specifierToken.end;
|
|
599
|
-
const newlines = code.slice(start, end).split("\n").length - 1;
|
|
600
|
-
edits.push({ start, end, text: replacement + "\n".repeat(newlines) });
|
|
368
|
+
return `const ${binding.local} = ${bridge}[${JSON.stringify(binding.imported)}];`;
|
|
369
|
+
}).join(" ");
|
|
370
|
+
const start = token.start;
|
|
371
|
+
const end = specifierToken.end;
|
|
372
|
+
const newlines = code.slice(start, end).split("\n").length - 1;
|
|
373
|
+
edits.push({ start, end, text: replacement + "\n".repeat(newlines) });
|
|
374
|
+
}
|
|
375
|
+
let out = code;
|
|
376
|
+
for (const edit of edits.reverse()) {
|
|
377
|
+
out = out.slice(0, edit.start) + edit.text + out.slice(edit.end);
|
|
378
|
+
}
|
|
379
|
+
if (needsDefaultInterop) declarations.unshift(DEFAULT_INTEROP_DECLARATION);
|
|
380
|
+
const preamble = declarations.join(" ");
|
|
381
|
+
return {
|
|
382
|
+
code: preamble ? `${preamble} ${out}` : out,
|
|
383
|
+
bareSpecifiers: [...bareSpecifiers],
|
|
384
|
+
sourceMap: { ...sourceMap, sourcesContent: [input.source] }
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
var import_dist, import_parser, import_types, REPLACEMENT_MODULE_EXTENSIONS, IMPORT_KEYWORD, EXPORT_KEYWORD, REACT_BRIDGE, REACT_NATIVE_BRIDGE, PACKAGE_BRIDGES, JSX_RUNTIME_SPECIFIERS, DEFAULT_INTEROP, DEFAULT_INTEROP_DECLARATION;
|
|
388
|
+
var init_replacementModule = __esm({
|
|
389
|
+
"../contrast-bundler/src/replacementModule.ts"() {
|
|
390
|
+
"use strict";
|
|
391
|
+
import_dist = require("sucrase/dist/index.js");
|
|
392
|
+
import_parser = require("sucrase/dist/parser/index.js");
|
|
393
|
+
import_types = require("sucrase/dist/parser/tokenizer/types.js");
|
|
394
|
+
init_posixPath();
|
|
395
|
+
REPLACEMENT_MODULE_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx"];
|
|
396
|
+
IMPORT_KEYWORD = import_types.TokenType["_import"];
|
|
397
|
+
EXPORT_KEYWORD = import_types.TokenType["_export"];
|
|
398
|
+
REACT_BRIDGE = "globalThis.__sootsim_react_bridge";
|
|
399
|
+
REACT_NATIVE_BRIDGE = "globalThis.__sootsim_components__";
|
|
400
|
+
PACKAGE_BRIDGES = "globalThis.__sootsim_config_package_modules";
|
|
401
|
+
JSX_RUNTIME_SPECIFIERS = /* @__PURE__ */ new Set(["react/jsx-runtime", "react/jsx-dev-runtime"]);
|
|
402
|
+
DEFAULT_INTEROP = "__rnxReplacementDefault";
|
|
403
|
+
DEFAULT_INTEROP_DECLARATION = `const ${DEFAULT_INTEROP} = (bridge) => (bridge && bridge.__esModule ? bridge.default : bridge);`;
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
// src/backend-origin.ts
|
|
408
|
+
function normalizeHostname(hostname) {
|
|
409
|
+
return hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
410
|
+
}
|
|
411
|
+
function isLoopbackHost(hostname) {
|
|
412
|
+
const normalized = normalizeHostname(hostname);
|
|
413
|
+
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
|
|
414
|
+
}
|
|
415
|
+
var init_backend_origin = __esm({
|
|
416
|
+
"src/backend-origin.ts"() {
|
|
417
|
+
"use strict";
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
// src/host/replacement-module-handler.ts
|
|
422
|
+
function sendJavaScript(req, res, source) {
|
|
423
|
+
const origin = req.headers.origin;
|
|
424
|
+
let allowedOrigin;
|
|
425
|
+
if (origin) {
|
|
426
|
+
try {
|
|
427
|
+
if (isLoopbackHost(new URL(origin).hostname)) allowedOrigin = origin;
|
|
428
|
+
} catch {
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
res.writeHead(200, {
|
|
432
|
+
"Content-Type": "application/javascript; charset=utf-8",
|
|
433
|
+
"Cache-Control": "no-cache",
|
|
434
|
+
...allowedOrigin ? { "Access-Control-Allow-Origin": allowedOrigin, Vary: "Origin" } : {}
|
|
435
|
+
});
|
|
436
|
+
res.end(req.method === "HEAD" ? void 0 : source);
|
|
437
|
+
}
|
|
438
|
+
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
439
|
+
const base = import_node_path2.default.resolve(import_node_path2.default.dirname(fromFile), specifier);
|
|
440
|
+
const candidates = [
|
|
441
|
+
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
442
|
+
(ext) => ext === import_node_path2.default.extname(base).toLowerCase()
|
|
443
|
+
) ? [base] : [],
|
|
444
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
445
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path2.default.join(base, `index${ext}`))
|
|
446
|
+
];
|
|
447
|
+
const found = candidates.find(
|
|
448
|
+
(candidate) => (0, import_node_fs3.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
449
|
+
);
|
|
450
|
+
if (!found) {
|
|
451
|
+
throw new Error(
|
|
452
|
+
`'${specifier}' imported by ${fromFile} matches no ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")} file`
|
|
453
|
+
);
|
|
454
|
+
}
|
|
455
|
+
return found;
|
|
456
|
+
}
|
|
457
|
+
function isReplacementModuleRequestUrl(rawUrl) {
|
|
458
|
+
if (!rawUrl) return false;
|
|
459
|
+
try {
|
|
460
|
+
const pathname = new URL(rawUrl, "http://peach.local").pathname;
|
|
461
|
+
return pathname === REPLACEMENT_MODULE_ROUTE;
|
|
462
|
+
} catch {
|
|
463
|
+
return false;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
467
|
+
const rawUrl = req.url || "";
|
|
468
|
+
let url;
|
|
469
|
+
try {
|
|
470
|
+
url = new URL(rawUrl, "http://peach.local");
|
|
471
|
+
} catch {
|
|
472
|
+
return false;
|
|
473
|
+
}
|
|
474
|
+
if (options.requireLoopbackOrigin) {
|
|
475
|
+
const origin = req.headers.origin;
|
|
476
|
+
const remoteAddress = req.socket.remoteAddress?.replace(/^::ffff:/, "");
|
|
477
|
+
let allowed = Boolean(remoteAddress && isLoopbackHost(remoteAddress));
|
|
478
|
+
if (allowed && origin) {
|
|
479
|
+
try {
|
|
480
|
+
allowed = isLoopbackHost(new URL(origin).hostname);
|
|
481
|
+
} catch {
|
|
482
|
+
allowed = false;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (!allowed) {
|
|
486
|
+
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
487
|
+
res.end("replacement modules are available only to loopback origins");
|
|
488
|
+
return true;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
if (url.pathname !== REPLACEMENT_MODULE_ROUTE) return false;
|
|
492
|
+
if (options.requestToken && url.searchParams.get("token") !== options.requestToken) {
|
|
493
|
+
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
494
|
+
res.end("replacement module request token is invalid");
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
const targetPath = url.searchParams.get("path");
|
|
498
|
+
if (!targetPath) {
|
|
499
|
+
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
500
|
+
res.end("missing path param");
|
|
501
|
+
return true;
|
|
502
|
+
}
|
|
503
|
+
const extension = import_node_path2.default.extname(targetPath).toLowerCase();
|
|
504
|
+
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
505
|
+
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
506
|
+
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
507
|
+
return true;
|
|
508
|
+
}
|
|
509
|
+
if (!import_node_path2.default.isAbsolute(targetPath)) {
|
|
510
|
+
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
511
|
+
res.end("replacement file path must be absolute");
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
515
|
+
let resolvedProjectRoot;
|
|
516
|
+
if (options.projectRoot) {
|
|
517
|
+
const lexicalProjectRoot = import_node_path2.default.resolve(options.projectRoot);
|
|
518
|
+
resolvedProjectRoot = await import_promises.default.realpath(options.projectRoot);
|
|
519
|
+
const lexicalTarget = import_node_path2.default.relative(lexicalProjectRoot, targetPath);
|
|
520
|
+
if (lexicalTarget.startsWith("..") || import_node_path2.default.isAbsolute(lexicalTarget)) {
|
|
521
|
+
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
522
|
+
res.end("replacement file must be inside the project root");
|
|
523
|
+
return true;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
let resolvedTargetPath;
|
|
527
|
+
try {
|
|
528
|
+
resolvedTargetPath = await import_promises.default.realpath(targetPath);
|
|
529
|
+
} catch (error) {
|
|
530
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
531
|
+
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
532
|
+
res.end(`replacement file not found: ${message}`);
|
|
533
|
+
return true;
|
|
534
|
+
}
|
|
535
|
+
if (resolvedProjectRoot) {
|
|
536
|
+
const relativeTarget = import_node_path2.default.relative(resolvedProjectRoot, resolvedTargetPath);
|
|
537
|
+
if (relativeTarget.startsWith("..") || import_node_path2.default.isAbsolute(relativeTarget)) {
|
|
538
|
+
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
539
|
+
res.end("replacement file must be inside the project root");
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
try {
|
|
544
|
+
const compiled = compileReplacementModule({
|
|
545
|
+
filePath: resolvedTargetPath,
|
|
546
|
+
source: await import_promises.default.readFile(resolvedTargetPath, "utf8"),
|
|
547
|
+
runtimePackages,
|
|
548
|
+
// the imported file's url is this request's with only its path changed,
|
|
549
|
+
// so the token, cache key and runtime packages carry over.
|
|
550
|
+
localModuleUrl: (specifier) => {
|
|
551
|
+
const local = new URL(url.href);
|
|
552
|
+
local.searchParams.set(
|
|
553
|
+
"path",
|
|
554
|
+
resolveReplacementModuleFile(targetPath, specifier)
|
|
555
|
+
);
|
|
556
|
+
return `${local.pathname}${local.search}`;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
const map = Buffer.from(JSON.stringify(compiled.sourceMap), "utf8").toString("base64");
|
|
560
|
+
sendJavaScript(
|
|
561
|
+
req,
|
|
562
|
+
res,
|
|
563
|
+
`${compiled.code}
|
|
564
|
+
//# sourceMappingURL=data:application/json;base64,${map}
|
|
565
|
+
`
|
|
566
|
+
);
|
|
567
|
+
} catch (error) {
|
|
568
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
569
|
+
res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
|
|
570
|
+
res.end(`replacement compile failed: ${message}`);
|
|
571
|
+
}
|
|
572
|
+
return true;
|
|
573
|
+
}
|
|
574
|
+
var import_node_fs3, import_promises, import_node_path2, REPLACEMENT_MODULE_ROUTE;
|
|
575
|
+
var init_replacement_module_handler = __esm({
|
|
576
|
+
"src/host/replacement-module-handler.ts"() {
|
|
577
|
+
"use strict";
|
|
578
|
+
import_node_fs3 = require("node:fs");
|
|
579
|
+
import_promises = __toESM(require("node:fs/promises"), 1);
|
|
580
|
+
import_node_path2 = __toESM(require("node:path"), 1);
|
|
581
|
+
init_replacementModule();
|
|
582
|
+
init_backend_origin();
|
|
583
|
+
REPLACEMENT_MODULE_ROUTE = "/__sootsim-replacement-module";
|
|
584
|
+
}
|
|
585
|
+
});
|
|
586
|
+
|
|
587
|
+
// src/is-record.ts
|
|
588
|
+
function isRecord2(value) {
|
|
589
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
590
|
+
}
|
|
591
|
+
var init_is_record = __esm({
|
|
592
|
+
"src/is-record.ts"() {
|
|
593
|
+
"use strict";
|
|
594
|
+
}
|
|
595
|
+
});
|
|
596
|
+
|
|
597
|
+
// ../../node_modules/plist/lib/parse.js
|
|
598
|
+
var require_parse = __commonJS({
|
|
599
|
+
"../../node_modules/plist/lib/parse.js"(exports2) {
|
|
600
|
+
var { DOMParser } = require("@xmldom/xmldom");
|
|
601
|
+
exports2.parse = parse2;
|
|
602
|
+
var TEXT_NODE = 3;
|
|
603
|
+
var CDATA_NODE = 4;
|
|
604
|
+
var COMMENT_NODE = 8;
|
|
605
|
+
function shouldIgnoreNode(node) {
|
|
606
|
+
return node.nodeType === TEXT_NODE || node.nodeType === COMMENT_NODE || node.nodeType === CDATA_NODE;
|
|
607
|
+
}
|
|
608
|
+
function isEmptyNode(node) {
|
|
609
|
+
if (!node.childNodes || node.childNodes.length === 0) {
|
|
610
|
+
return true;
|
|
611
|
+
} else {
|
|
612
|
+
return false;
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function invariant(test, message) {
|
|
616
|
+
if (!test) {
|
|
617
|
+
throw new Error(message);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
function parse2(xml) {
|
|
621
|
+
var doc = new DOMParser().parseFromString(xml, "text/xml");
|
|
622
|
+
invariant(
|
|
623
|
+
doc.documentElement.nodeName === "plist",
|
|
624
|
+
"malformed document. First element should be <plist>"
|
|
625
|
+
);
|
|
626
|
+
var plist3 = parsePlistXML(doc.documentElement);
|
|
627
|
+
if (plist3.length == 1) plist3 = plist3[0];
|
|
628
|
+
return plist3;
|
|
629
|
+
}
|
|
630
|
+
function parsePlistXML(node) {
|
|
631
|
+
var i, new_obj, key, val, new_arr, res, counter, type;
|
|
632
|
+
if (!node) return null;
|
|
633
|
+
if (node.nodeName === "plist") {
|
|
634
|
+
new_arr = [];
|
|
635
|
+
if (isEmptyNode(node)) {
|
|
636
|
+
return new_arr;
|
|
637
|
+
}
|
|
638
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
639
|
+
if (!shouldIgnoreNode(node.childNodes[i])) {
|
|
640
|
+
new_arr.push(parsePlistXML(node.childNodes[i]));
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
return new_arr;
|
|
644
|
+
} else if (node.nodeName === "dict") {
|
|
645
|
+
new_obj = {};
|
|
646
|
+
key = null;
|
|
647
|
+
counter = 0;
|
|
648
|
+
if (isEmptyNode(node)) {
|
|
649
|
+
return new_obj;
|
|
650
|
+
}
|
|
651
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
652
|
+
if (shouldIgnoreNode(node.childNodes[i])) continue;
|
|
653
|
+
if (counter % 2 === 0) {
|
|
654
|
+
invariant(
|
|
655
|
+
node.childNodes[i].nodeName === "key",
|
|
656
|
+
"Missing key while parsing <dict/>."
|
|
657
|
+
);
|
|
658
|
+
key = parsePlistXML(node.childNodes[i]);
|
|
659
|
+
} else {
|
|
660
|
+
invariant(
|
|
661
|
+
node.childNodes[i].nodeName !== "key",
|
|
662
|
+
'Unexpected key "' + parsePlistXML(node.childNodes[i]) + '" while parsing <dict/>.'
|
|
663
|
+
);
|
|
664
|
+
new_obj[key] = parsePlistXML(node.childNodes[i]);
|
|
665
|
+
}
|
|
666
|
+
counter += 1;
|
|
667
|
+
}
|
|
668
|
+
if (counter % 2 === 1) {
|
|
669
|
+
new_obj[key] = "";
|
|
670
|
+
}
|
|
671
|
+
return new_obj;
|
|
672
|
+
} else if (node.nodeName === "array") {
|
|
673
|
+
new_arr = [];
|
|
674
|
+
if (isEmptyNode(node)) {
|
|
675
|
+
return new_arr;
|
|
676
|
+
}
|
|
677
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
678
|
+
if (!shouldIgnoreNode(node.childNodes[i])) {
|
|
679
|
+
res = parsePlistXML(node.childNodes[i]);
|
|
680
|
+
if (null != res) new_arr.push(res);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
return new_arr;
|
|
684
|
+
} else if (node.nodeName === "#text") {
|
|
685
|
+
} else if (node.nodeName === "key") {
|
|
686
|
+
if (isEmptyNode(node)) {
|
|
687
|
+
return "";
|
|
688
|
+
}
|
|
689
|
+
invariant(
|
|
690
|
+
node.childNodes[0].nodeValue !== "__proto__",
|
|
691
|
+
"__proto__ keys can lead to prototype pollution. More details on CVE-2022-22912"
|
|
692
|
+
);
|
|
693
|
+
return node.childNodes[0].nodeValue;
|
|
694
|
+
} else if (node.nodeName === "string") {
|
|
695
|
+
res = "";
|
|
696
|
+
if (isEmptyNode(node)) {
|
|
697
|
+
return res;
|
|
698
|
+
}
|
|
699
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
700
|
+
var type = node.childNodes[i].nodeType;
|
|
701
|
+
if (type === TEXT_NODE || type === CDATA_NODE) {
|
|
702
|
+
res += node.childNodes[i].nodeValue;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return res;
|
|
706
|
+
} else if (node.nodeName === "integer") {
|
|
707
|
+
invariant(!isEmptyNode(node), 'Cannot parse "" as integer.');
|
|
708
|
+
return parseInt(node.childNodes[0].nodeValue, 10);
|
|
709
|
+
} else if (node.nodeName === "real") {
|
|
710
|
+
invariant(!isEmptyNode(node), 'Cannot parse "" as real.');
|
|
711
|
+
res = "";
|
|
712
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
713
|
+
if (node.childNodes[i].nodeType === TEXT_NODE) {
|
|
714
|
+
res += node.childNodes[i].nodeValue;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
return parseFloat(res);
|
|
718
|
+
} else if (node.nodeName === "data") {
|
|
719
|
+
res = "";
|
|
720
|
+
if (isEmptyNode(node)) {
|
|
721
|
+
return Buffer.from(res, "base64");
|
|
722
|
+
}
|
|
723
|
+
for (i = 0; i < node.childNodes.length; i++) {
|
|
724
|
+
if (node.childNodes[i].nodeType === TEXT_NODE) {
|
|
725
|
+
res += node.childNodes[i].nodeValue.replace(/\s+/g, "");
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
return Buffer.from(res, "base64");
|
|
729
|
+
} else if (node.nodeName === "date") {
|
|
730
|
+
invariant(!isEmptyNode(node), 'Cannot parse "" as Date.');
|
|
731
|
+
return new Date(node.childNodes[0].nodeValue);
|
|
732
|
+
} else if (node.nodeName === "null") {
|
|
733
|
+
return null;
|
|
734
|
+
} else if (node.nodeName === "true") {
|
|
735
|
+
return true;
|
|
736
|
+
} else if (node.nodeName === "false") {
|
|
737
|
+
return false;
|
|
738
|
+
} else {
|
|
739
|
+
throw new Error("Invalid PLIST tag " + node.nodeName);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
// ../../node_modules/plist/lib/build.js
|
|
746
|
+
var require_build = __commonJS({
|
|
747
|
+
"../../node_modules/plist/lib/build.js"(exports2) {
|
|
748
|
+
var base64 = require("base64-js");
|
|
749
|
+
var xmlbuilder = require("xmlbuilder");
|
|
750
|
+
exports2.build = build;
|
|
751
|
+
function ISODateString(d) {
|
|
752
|
+
function pad(n) {
|
|
753
|
+
return n < 10 ? "0" + n : n;
|
|
754
|
+
}
|
|
755
|
+
return d.getUTCFullYear() + "-" + pad(d.getUTCMonth() + 1) + "-" + pad(d.getUTCDate()) + "T" + pad(d.getUTCHours()) + ":" + pad(d.getUTCMinutes()) + ":" + pad(d.getUTCSeconds()) + "Z";
|
|
756
|
+
}
|
|
757
|
+
var toString = Object.prototype.toString;
|
|
758
|
+
function type(obj) {
|
|
759
|
+
var m = toString.call(obj).match(/\[object (.*)\]/);
|
|
760
|
+
return m ? m[1] : m;
|
|
761
|
+
}
|
|
762
|
+
function build(obj, opts) {
|
|
763
|
+
var XMLHDR = {
|
|
764
|
+
version: "1.0",
|
|
765
|
+
encoding: "UTF-8"
|
|
766
|
+
};
|
|
767
|
+
var XMLDTD = {
|
|
768
|
+
pubid: "-//Apple//DTD PLIST 1.0//EN",
|
|
769
|
+
sysid: "http://www.apple.com/DTDs/PropertyList-1.0.dtd"
|
|
770
|
+
};
|
|
771
|
+
var doc = xmlbuilder.create("plist");
|
|
772
|
+
doc.dec(XMLHDR.version, XMLHDR.encoding, XMLHDR.standalone);
|
|
773
|
+
doc.dtd(XMLDTD.pubid, XMLDTD.sysid);
|
|
774
|
+
doc.att("version", "1.0");
|
|
775
|
+
walk_obj(obj, doc);
|
|
776
|
+
if (!opts) opts = {};
|
|
777
|
+
opts.pretty = opts.pretty !== false;
|
|
778
|
+
return doc.end(opts);
|
|
779
|
+
}
|
|
780
|
+
function walk_obj(next, next_child) {
|
|
781
|
+
var tag_type, i, prop;
|
|
782
|
+
var name2 = type(next);
|
|
783
|
+
if ("Undefined" == name2) {
|
|
784
|
+
return;
|
|
785
|
+
} else if (Array.isArray(next)) {
|
|
786
|
+
next_child = next_child.ele("array");
|
|
787
|
+
for (i = 0; i < next.length; i++) {
|
|
788
|
+
walk_obj(next[i], next_child);
|
|
789
|
+
}
|
|
790
|
+
} else if (Buffer.isBuffer(next)) {
|
|
791
|
+
next_child.ele("data").raw(next.toString("base64"));
|
|
792
|
+
} else if ("Object" == name2) {
|
|
793
|
+
next_child = next_child.ele("dict");
|
|
794
|
+
for (prop in next) {
|
|
795
|
+
if (next.hasOwnProperty(prop)) {
|
|
796
|
+
next_child.ele("key").txt(prop);
|
|
797
|
+
walk_obj(next[prop], next_child);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
} else if ("Number" == name2) {
|
|
801
|
+
tag_type = next % 1 === 0 ? "integer" : "real";
|
|
802
|
+
next_child.ele(tag_type).txt(next.toString());
|
|
803
|
+
} else if ("BigInt" == name2) {
|
|
804
|
+
next_child.ele("integer").txt(next);
|
|
805
|
+
} else if ("Date" == name2) {
|
|
806
|
+
next_child.ele("date").txt(ISODateString(new Date(next)));
|
|
807
|
+
} else if ("Boolean" == name2) {
|
|
808
|
+
next_child.ele(next ? "true" : "false");
|
|
809
|
+
} else if ("String" == name2) {
|
|
810
|
+
next_child.ele("string").txt(next);
|
|
811
|
+
} else if ("ArrayBuffer" == name2) {
|
|
812
|
+
next_child.ele("data").raw(base64.fromByteArray(next));
|
|
813
|
+
} else if (next && next.buffer && "ArrayBuffer" == type(next.buffer)) {
|
|
814
|
+
next_child.ele("data").raw(base64.fromByteArray(new Uint8Array(next.buffer), next_child));
|
|
815
|
+
} else if ("Null" === name2) {
|
|
816
|
+
next_child.ele("null").txt("");
|
|
817
|
+
}
|
|
818
|
+
}
|
|
601
819
|
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
// ../../node_modules/plist/index.js
|
|
823
|
+
var require_plist = __commonJS({
|
|
824
|
+
"../../node_modules/plist/index.js"(exports2) {
|
|
825
|
+
var parserFunctions = require_parse();
|
|
826
|
+
Object.keys(parserFunctions).forEach(function(k) {
|
|
827
|
+
exports2[k] = parserFunctions[k];
|
|
828
|
+
});
|
|
829
|
+
var builderFunctions = require_build();
|
|
830
|
+
Object.keys(builderFunctions).forEach(function(k) {
|
|
831
|
+
exports2[k] = builderFunctions[k];
|
|
832
|
+
});
|
|
605
833
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
};
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
// ../contrast-runtime-delivery/src/version.ts
|
|
837
|
+
function isValidRuntimeVersion(value) {
|
|
838
|
+
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
612
839
|
}
|
|
840
|
+
var init_version = __esm({
|
|
841
|
+
"../contrast-runtime-delivery/src/version.ts"() {
|
|
842
|
+
"use strict";
|
|
843
|
+
}
|
|
844
|
+
});
|
|
613
845
|
|
|
614
|
-
// src/
|
|
615
|
-
function
|
|
616
|
-
return
|
|
846
|
+
// src/config.ts
|
|
847
|
+
function collectConfiguredFileModules(config) {
|
|
848
|
+
return [
|
|
849
|
+
...new Set(
|
|
850
|
+
["modules", "turboModules", "nativeModules", "nativeViews"].flatMap((key) => {
|
|
851
|
+
const entries = config && Reflect.get(config, key);
|
|
852
|
+
if (!isRecord2(entries)) return [];
|
|
853
|
+
return Object.values(entries).flatMap(
|
|
854
|
+
(entry) => isRecord2(entry) && typeof entry.file === "string" ? [entry.file] : []
|
|
855
|
+
);
|
|
856
|
+
})
|
|
857
|
+
)
|
|
858
|
+
];
|
|
617
859
|
}
|
|
618
|
-
function
|
|
619
|
-
|
|
620
|
-
return
|
|
860
|
+
function isPeachConfig(value) {
|
|
861
|
+
if (!isRecord2(value)) return false;
|
|
862
|
+
return (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
|
|
863
|
+
"modules",
|
|
864
|
+
"turboModules",
|
|
865
|
+
"nativeModules",
|
|
866
|
+
"nativeViews",
|
|
867
|
+
"env",
|
|
868
|
+
"network",
|
|
869
|
+
"settings",
|
|
870
|
+
"initialState"
|
|
871
|
+
].every((key) => value[key] === void 0 || isRecord2(value[key]));
|
|
872
|
+
}
|
|
873
|
+
function createPeachBundleConfigFooter(config) {
|
|
874
|
+
const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
|
|
875
|
+
return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
|
|
621
876
|
}
|
|
877
|
+
var BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
|
|
878
|
+
var init_config = __esm({
|
|
879
|
+
"src/config.ts"() {
|
|
880
|
+
"use strict";
|
|
881
|
+
init_version();
|
|
882
|
+
init_is_record();
|
|
883
|
+
BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
|
|
884
|
+
PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
|
|
885
|
+
}
|
|
886
|
+
});
|
|
622
887
|
|
|
623
|
-
// src/
|
|
624
|
-
var
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
888
|
+
// src/public-brand.ts
|
|
889
|
+
var name, peachPublicBrand, rnxPublicBrand;
|
|
890
|
+
var init_public_brand = __esm({
|
|
891
|
+
"src/public-brand.ts"() {
|
|
892
|
+
"use strict";
|
|
893
|
+
name = "Peach";
|
|
894
|
+
peachPublicBrand = Object.freeze({
|
|
895
|
+
name,
|
|
896
|
+
packageName: "peachsim",
|
|
897
|
+
commandName: "peach",
|
|
898
|
+
domain: "peachsim.com",
|
|
899
|
+
origin: "https://peachsim.com"
|
|
900
|
+
});
|
|
901
|
+
rnxPublicBrand = peachPublicBrand;
|
|
633
902
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
];
|
|
650
|
-
const found = candidates.find(
|
|
651
|
-
(candidate) => (0, import_node_fs2.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
903
|
+
});
|
|
904
|
+
|
|
905
|
+
// cli/app-config.ts
|
|
906
|
+
var app_config_exports = {};
|
|
907
|
+
__export(app_config_exports, {
|
|
908
|
+
loadRNXAppConfig: () => loadRNXAppConfig,
|
|
909
|
+
resolveRNXAppConfig: () => resolveRNXAppConfig
|
|
910
|
+
});
|
|
911
|
+
function resolveFileEntries(entries, configDir) {
|
|
912
|
+
if (!entries) return entries;
|
|
913
|
+
return Object.fromEntries(
|
|
914
|
+
Object.entries(entries).map(([name2, resolution]) => [
|
|
915
|
+
name2,
|
|
916
|
+
resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path6.default.resolve(configDir, resolution.file) } : resolution
|
|
917
|
+
])
|
|
652
918
|
);
|
|
653
|
-
if (!found) {
|
|
654
|
-
throw new Error(
|
|
655
|
-
`'${specifier}' imported by ${fromFile} matches no ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")} file`
|
|
656
|
-
);
|
|
657
|
-
}
|
|
658
|
-
return found;
|
|
659
919
|
}
|
|
660
|
-
function
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
920
|
+
function resolveConfigReplacementFiles(config, configPath) {
|
|
921
|
+
const configDir = import_node_path6.default.dirname(configPath);
|
|
922
|
+
return {
|
|
923
|
+
...config,
|
|
924
|
+
modules: resolveFileEntries(config.modules, configDir),
|
|
925
|
+
turboModules: resolveFileEntries(config.turboModules, configDir),
|
|
926
|
+
nativeModules: resolveFileEntries(config.nativeModules, configDir),
|
|
927
|
+
nativeViews: resolveFileEntries(config.nativeViews, configDir)
|
|
928
|
+
};
|
|
668
929
|
}
|
|
669
|
-
async function
|
|
670
|
-
|
|
671
|
-
let url;
|
|
930
|
+
async function loadRNXAppConfig(project) {
|
|
931
|
+
if (!project?.configPath) return void 0;
|
|
672
932
|
try {
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
try {
|
|
683
|
-
allowed = isLoopbackHost(new URL(origin).hostname);
|
|
684
|
-
} catch {
|
|
685
|
-
allowed = false;
|
|
933
|
+
const jiti = (0, import_jiti.createJiti)(__sootsim_import_meta_url, {
|
|
934
|
+
interopDefault: true,
|
|
935
|
+
// metro serializes repeatedly in one process; edits must reload the config.
|
|
936
|
+
moduleCache: false,
|
|
937
|
+
tryNative: false,
|
|
938
|
+
alias: {
|
|
939
|
+
[`${rnxPublicBrand.packageName}/config`]: require2.resolve(
|
|
940
|
+
`${rnxPublicBrand.packageName}/config`
|
|
941
|
+
)
|
|
686
942
|
}
|
|
943
|
+
});
|
|
944
|
+
const loaded2 = await jiti.import(project.configPath, { default: true });
|
|
945
|
+
if (!isPeachConfig(loaded2)) {
|
|
946
|
+
throw new Error("the default export must be a peach config object");
|
|
687
947
|
}
|
|
688
|
-
|
|
689
|
-
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
690
|
-
res.end("replacement modules are available only to loopback origins");
|
|
691
|
-
return true;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
if (url.pathname !== REPLACEMENT_MODULE_ROUTE) return false;
|
|
695
|
-
if (options.requestToken && url.searchParams.get("token") !== options.requestToken) {
|
|
696
|
-
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
697
|
-
res.end("replacement module request token is invalid");
|
|
698
|
-
return true;
|
|
699
|
-
}
|
|
700
|
-
const targetPath = url.searchParams.get("path");
|
|
701
|
-
if (!targetPath) {
|
|
702
|
-
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
703
|
-
res.end("missing path param");
|
|
704
|
-
return true;
|
|
705
|
-
}
|
|
706
|
-
const extension = import_node_path.default.extname(targetPath).toLowerCase();
|
|
707
|
-
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
708
|
-
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
709
|
-
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
710
|
-
return true;
|
|
711
|
-
}
|
|
712
|
-
if (!import_node_path.default.isAbsolute(targetPath)) {
|
|
713
|
-
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
714
|
-
res.end("replacement file path must be absolute");
|
|
715
|
-
return true;
|
|
716
|
-
}
|
|
717
|
-
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
718
|
-
let resolvedProjectRoot;
|
|
719
|
-
if (options.projectRoot) {
|
|
720
|
-
const lexicalProjectRoot = import_node_path.default.resolve(options.projectRoot);
|
|
721
|
-
resolvedProjectRoot = await import_promises.default.realpath(options.projectRoot);
|
|
722
|
-
const lexicalTarget = import_node_path.default.relative(lexicalProjectRoot, targetPath);
|
|
723
|
-
if (lexicalTarget.startsWith("..") || import_node_path.default.isAbsolute(lexicalTarget)) {
|
|
724
|
-
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
725
|
-
res.end("replacement file must be inside the project root");
|
|
726
|
-
return true;
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
let resolvedTargetPath;
|
|
730
|
-
try {
|
|
731
|
-
resolvedTargetPath = await import_promises.default.realpath(targetPath);
|
|
948
|
+
return resolveConfigReplacementFiles(loaded2, project.configPath);
|
|
732
949
|
} catch (error) {
|
|
733
950
|
const message = error instanceof Error ? error.message : String(error);
|
|
734
|
-
|
|
735
|
-
res.end(`replacement file not found: ${message}`);
|
|
736
|
-
return true;
|
|
951
|
+
throw new Error(`could not load ${project.configPath}: ${message}`);
|
|
737
952
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
953
|
+
}
|
|
954
|
+
async function resolveRNXAppConfig(startDir = process.cwd()) {
|
|
955
|
+
const project = resolveAppProject(startDir);
|
|
956
|
+
return { project, config: await loadRNXAppConfig(project) };
|
|
957
|
+
}
|
|
958
|
+
var import_node_module2, import_node_path6, import_jiti, require2;
|
|
959
|
+
var init_app_config = __esm({
|
|
960
|
+
"cli/app-config.ts"() {
|
|
961
|
+
"use strict";
|
|
962
|
+
import_node_module2 = require("node:module");
|
|
963
|
+
import_node_path6 = __toESM(require("node:path"), 1);
|
|
964
|
+
import_jiti = require("jiti");
|
|
965
|
+
init_config();
|
|
966
|
+
init_public_brand();
|
|
967
|
+
init_app_project();
|
|
968
|
+
require2 = (0, import_node_module2.createRequire)(__sootsim_import_meta_url);
|
|
745
969
|
}
|
|
746
|
-
|
|
970
|
+
});
|
|
971
|
+
|
|
972
|
+
// src/configured-bundle-producer.ts
|
|
973
|
+
var configured_bundle_producer_exports = {};
|
|
974
|
+
__export(configured_bundle_producer_exports, {
|
|
975
|
+
produceConfiguredBundle: () => produceConfiguredBundle
|
|
976
|
+
});
|
|
977
|
+
async function produceConfiguredBundle(source, config, runtimePackages) {
|
|
978
|
+
if (!config) return source;
|
|
979
|
+
const json = JSON.stringify(config, (_key, value) => {
|
|
980
|
+
if (typeof value === "function" || typeof value === "bigint" || typeof value === "symbol")
|
|
981
|
+
throw new Error(
|
|
982
|
+
"configured bundle values must be JSON; native functions must use file entries"
|
|
983
|
+
);
|
|
984
|
+
return value;
|
|
985
|
+
});
|
|
986
|
+
const packagedConfig = JSON.parse(json);
|
|
987
|
+
if (!isPeachConfig(packagedConfig))
|
|
988
|
+
throw new Error("configured bundle config is malformed");
|
|
989
|
+
const files = /* @__PURE__ */ new Map();
|
|
990
|
+
const neededPackages = /* @__PURE__ */ new Set();
|
|
991
|
+
const factories = [];
|
|
992
|
+
const visit = (filePath) => {
|
|
993
|
+
const real = import_node_fs7.default.realpathSync(filePath);
|
|
994
|
+
const previous = files.get(real);
|
|
995
|
+
if (previous !== void 0) return previous;
|
|
996
|
+
const id = "peach-config-file:" + files.size;
|
|
997
|
+
files.set(real, id);
|
|
747
998
|
const compiled = compileReplacementModule({
|
|
748
|
-
filePath:
|
|
749
|
-
source:
|
|
999
|
+
filePath: real,
|
|
1000
|
+
source: import_node_fs7.default.readFileSync(real, "utf8"),
|
|
750
1001
|
runtimePackages,
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
1002
|
+
localModuleUrl: (specifier) => visit(resolveReplacementModuleFile(real, specifier))
|
|
1003
|
+
});
|
|
1004
|
+
const commonJs = (0, import_sucrase.transform)(compiled.code, { transforms: ["imports"] }).code;
|
|
1005
|
+
for (const specifier of compiled.bareSpecifiers) neededPackages.add(specifier);
|
|
1006
|
+
factories.push(
|
|
1007
|
+
JSON.stringify(id) + ":function(require,module,exports){" + commonJs + "\n}"
|
|
1008
|
+
);
|
|
1009
|
+
return id;
|
|
1010
|
+
};
|
|
1011
|
+
for (const key of ["modules", "turboModules", "nativeModules", "nativeViews"]) {
|
|
1012
|
+
const entries = Reflect.get(packagedConfig, key);
|
|
1013
|
+
if (!entries || typeof entries !== "object") continue;
|
|
1014
|
+
for (const resolution of Object.values(entries)) {
|
|
1015
|
+
if (resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string") {
|
|
1016
|
+
resolution.file = visit(import_node_path7.default.resolve(resolution.file));
|
|
757
1017
|
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
const roots = collectConfiguredFileModules(packagedConfig);
|
|
1021
|
+
let prefix2 = "";
|
|
1022
|
+
if (roots.length > 0) {
|
|
1023
|
+
const code = "(function(){const factories={" + factories.join(",") + '};const cache=Object.create(null);function require(id){if(cache[id])return cache[id].exports;const factory=factories[id];if(!factory)throw new Error("missing configured file "+id);const module={exports:{}};cache[id]=module;try{factory(require,module,module.exports);return module.exports;}catch(error){delete cache[id];throw error;}}const loaded=Object.create(null);for(const id of ' + JSON.stringify(roots) + ")loaded[id]=require(id);const install=globalThis[" + JSON.stringify(PEACH_CONFIGURED_FILES_HOOK) + '];if(typeof install!=="function")throw new Error("runtime cannot install configured bundle files");install(loaded);})();';
|
|
1024
|
+
const compact = await (0, import_terser.minify)(code, {
|
|
1025
|
+
compress: false,
|
|
1026
|
+
mangle: false,
|
|
1027
|
+
format: { comments: false, beautify: false }
|
|
758
1028
|
});
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
1029
|
+
if (!compact.code || /[\n\r]/.test(compact.code))
|
|
1030
|
+
throw new Error("configured bundle prefix must preserve the guest source lines");
|
|
1031
|
+
prefix2 = compact.code;
|
|
1032
|
+
}
|
|
1033
|
+
const footer = createPeachBundleConfigFooter({
|
|
1034
|
+
config: packagedConfig,
|
|
1035
|
+
runtimePackages: [...neededPackages].sort()
|
|
1036
|
+
});
|
|
1037
|
+
const identityStart = source.lastIndexOf("\nglobalThis.__sootsimModulePaths=");
|
|
1038
|
+
return prefix2 + (identityStart < 0 ? source + footer : source.slice(0, identityStart) + footer + source.slice(identityStart));
|
|
1039
|
+
}
|
|
1040
|
+
var import_node_fs7, import_node_path7, import_sucrase, import_terser;
|
|
1041
|
+
var init_configured_bundle_producer = __esm({
|
|
1042
|
+
"src/configured-bundle-producer.ts"() {
|
|
1043
|
+
"use strict";
|
|
1044
|
+
import_node_fs7 = __toESM(require("node:fs"), 1);
|
|
1045
|
+
import_node_path7 = __toESM(require("node:path"), 1);
|
|
1046
|
+
import_sucrase = require("sucrase");
|
|
1047
|
+
import_terser = require("terser");
|
|
1048
|
+
init_replacementModule();
|
|
1049
|
+
init_config();
|
|
1050
|
+
init_replacement_module_handler();
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
// src/metro-plugin.ts
|
|
1055
|
+
var metro_plugin_exports = {};
|
|
1056
|
+
__export(metro_plugin_exports, {
|
|
1057
|
+
default: () => metro_plugin_default,
|
|
1058
|
+
toRNXDevelopmentBundleUrl: () => toRNXDevelopmentBundleUrl,
|
|
1059
|
+
toRNXProductionBundleUrl: () => toRNXProductionBundleUrl,
|
|
1060
|
+
withRNX: () => withRNX
|
|
1061
|
+
});
|
|
1062
|
+
module.exports = __toCommonJS(metro_plugin_exports);
|
|
1063
|
+
var import_fs2 = __toESM(require("fs"), 1);
|
|
1064
|
+
var import_module = require("module");
|
|
1065
|
+
var import_node_crypto2 = require("node:crypto");
|
|
1066
|
+
var import_path2 = __toESM(require("path"), 1);
|
|
1067
|
+
init_app_project();
|
|
1068
|
+
|
|
1069
|
+
// src/dev-server-open.ts
|
|
1070
|
+
var import_node_crypto = require("node:crypto");
|
|
1071
|
+
var import_node_fs2 = __toESM(require("node:fs"), 1);
|
|
1072
|
+
function tagRnxBundleForPlugin(bundleUrl, replacementOrigin, replacementToken, projectRoot, appName) {
|
|
1073
|
+
const absolute = /^[a-z][a-z\d+.-]*:\/\//i.test(bundleUrl);
|
|
1074
|
+
const url = new URL(bundleUrl, absolute ? void 0 : "http://peach.local");
|
|
1075
|
+
if (appName) {
|
|
1076
|
+
url.searchParams.set("rnxAppName", appName);
|
|
1077
|
+
url.searchParams.set(
|
|
1078
|
+
"rnxProjectId",
|
|
1079
|
+
(0, import_node_crypto.createHash)("sha256").update(import_node_fs2.default.realpathSync(projectRoot)).digest("hex").slice(0, 32)
|
|
766
1080
|
);
|
|
767
|
-
} catch (error) {
|
|
768
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
769
|
-
res.writeHead(500, { "Content-Type": "text/plain; charset=utf-8" });
|
|
770
|
-
res.end(`replacement compile failed: ${message}`);
|
|
771
1081
|
}
|
|
772
|
-
|
|
1082
|
+
url.searchParams.set("rnxReplacementOrigin", replacementOrigin);
|
|
1083
|
+
url.searchParams.set("rnxReplacementToken", replacementToken);
|
|
1084
|
+
return absolute ? url.toString() : `${url.pathname}${url.search}${url.hash}`;
|
|
773
1085
|
}
|
|
774
1086
|
|
|
1087
|
+
// src/metro-plugin.ts
|
|
1088
|
+
init_replacement_module_handler();
|
|
1089
|
+
|
|
775
1090
|
// src/metro-production-bundle.ts
|
|
776
1091
|
var RNXSIM_METRO_MODULE_PATHS_PREFIX = "globalThis.__sootsimModulePaths=";
|
|
777
1092
|
var RNX_METRO_MODULE_IDENTITY_VERSION = 2;
|
|
@@ -926,7 +1241,7 @@ function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
|
|
|
926
1241
|
}
|
|
927
1242
|
function nativeAppIdentityFromIos(files, parseInfoPlist) {
|
|
928
1243
|
const pbxprojPath = Object.keys(files).find(
|
|
929
|
-
(
|
|
1244
|
+
(path10) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path10)
|
|
930
1245
|
);
|
|
931
1246
|
if (!pbxprojPath) return null;
|
|
932
1247
|
const pbxproj = files[pbxprojPath];
|
|
@@ -938,7 +1253,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist) {
|
|
|
938
1253
|
].map((match) => match[1])
|
|
939
1254
|
);
|
|
940
1255
|
const appDelegatePattern = /(?:^|\/)ios\/([^/]+)\/AppDelegate\.(?:swift|mm|m)$/;
|
|
941
|
-
const targetName = Object.keys(files).filter((
|
|
1256
|
+
const targetName = Object.keys(files).filter((path10) => !path10.includes("/Pods/")).map((path10) => path10.match(appDelegatePattern)?.[1]).find((name2) => name2 !== void 0 && applicationTargets.has(name2)) ?? null;
|
|
942
1257
|
if (!targetName) return null;
|
|
943
1258
|
const plist3 = files[`ios/${targetName}/Info.plist`];
|
|
944
1259
|
if (!plist3) return null;
|
|
@@ -1013,14 +1328,10 @@ function extractNativeAppIdentityFromFiles(files, platform, parseInfoPlist) {
|
|
|
1013
1328
|
}
|
|
1014
1329
|
|
|
1015
1330
|
// src/native-firebase-config.ts
|
|
1016
|
-
var
|
|
1331
|
+
var import_node_fs5 = __toESM(require("node:fs"), 1);
|
|
1017
1332
|
var import_node_module = require("node:module");
|
|
1018
|
-
var
|
|
1019
|
-
|
|
1020
|
-
// src/is-record.ts
|
|
1021
|
-
function isRecord2(value) {
|
|
1022
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1023
|
-
}
|
|
1333
|
+
var import_node_path4 = __toESM(require("node:path"), 1);
|
|
1334
|
+
init_is_record();
|
|
1024
1335
|
|
|
1025
1336
|
// src/plist.ts
|
|
1026
1337
|
var import_plist = __toESM(require_plist(), 1);
|
|
@@ -1029,8 +1340,8 @@ function parsePlistSource(source) {
|
|
|
1029
1340
|
}
|
|
1030
1341
|
|
|
1031
1342
|
// src/xcode-project.ts
|
|
1032
|
-
var
|
|
1033
|
-
var
|
|
1343
|
+
var import_node_fs4 = __toESM(require("node:fs"), 1);
|
|
1344
|
+
var import_node_path3 = __toESM(require("node:path"), 1);
|
|
1034
1345
|
var import_plist2 = __toESM(require_plist(), 1);
|
|
1035
1346
|
|
|
1036
1347
|
// src/swift-package.ts
|
|
@@ -1141,23 +1452,23 @@ function swiftManifestGraph(manifest) {
|
|
|
1141
1452
|
const url = /\burl\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
1142
1453
|
if (!url) continue;
|
|
1143
1454
|
graph.packageURLs.set(swiftPackageIdentity(url), url);
|
|
1144
|
-
const
|
|
1145
|
-
if (
|
|
1455
|
+
const name3 = NAME.exec(flat)?.[1];
|
|
1456
|
+
if (name3) graph.packageURLs.set(name3.toLowerCase(), url);
|
|
1146
1457
|
continue;
|
|
1147
1458
|
}
|
|
1148
|
-
const
|
|
1149
|
-
if (!
|
|
1459
|
+
const name2 = NAME.exec(flat)?.[1];
|
|
1460
|
+
if (!name2) continue;
|
|
1150
1461
|
if (kind === "library") {
|
|
1151
1462
|
graph.products.set(
|
|
1152
|
-
|
|
1463
|
+
name2,
|
|
1153
1464
|
listArgument(call, "targets").flatMap(
|
|
1154
1465
|
(item) => /^"([^"]+)"$/.exec(item)?.[1] ?? []
|
|
1155
1466
|
)
|
|
1156
1467
|
);
|
|
1157
1468
|
continue;
|
|
1158
1469
|
}
|
|
1159
|
-
if (kind === "binaryTarget") graph.binaryTargets.add(
|
|
1160
|
-
if (kind === "systemLibrary") graph.systemLibraries.add(
|
|
1470
|
+
if (kind === "binaryTarget") graph.binaryTargets.add(name2);
|
|
1471
|
+
if (kind === "systemLibrary") graph.systemLibraries.add(name2);
|
|
1161
1472
|
const dependencies = [];
|
|
1162
1473
|
for (const item of listArgument(call, "dependencies")) {
|
|
1163
1474
|
const platforms = /condition\s*:\s*\.when\(\s*platforms\s*:\s*\[([^\]]*)\]/.exec(
|
|
@@ -1181,7 +1492,7 @@ function swiftManifestGraph(manifest) {
|
|
|
1181
1492
|
});
|
|
1182
1493
|
else if (target) dependencies.push({ kind: "target", name: target });
|
|
1183
1494
|
}
|
|
1184
|
-
graph.dependencies.set(
|
|
1495
|
+
graph.dependencies.set(name2, dependencies);
|
|
1185
1496
|
}
|
|
1186
1497
|
for (const dependencies of graph.dependencies.values()) {
|
|
1187
1498
|
for (const [index, dependency] of dependencies.entries()) {
|
|
@@ -1304,28 +1615,28 @@ var CONDITIONS = {
|
|
|
1304
1615
|
variant: "normal"
|
|
1305
1616
|
};
|
|
1306
1617
|
function walkFiles(dir) {
|
|
1307
|
-
if (!
|
|
1618
|
+
if (!import_node_fs4.default.existsSync(dir)) return [];
|
|
1308
1619
|
const out = [];
|
|
1309
|
-
for (const entry of
|
|
1620
|
+
for (const entry of import_node_fs4.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
1310
1621
|
if (entry.name.startsWith(".")) continue;
|
|
1311
|
-
const full =
|
|
1622
|
+
const full = import_node_path3.default.join(dir, entry.name);
|
|
1312
1623
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
1313
1624
|
else if (entry.isFile()) out.push(full);
|
|
1314
1625
|
}
|
|
1315
1626
|
return out;
|
|
1316
1627
|
}
|
|
1317
|
-
var isDirectory = (dir) =>
|
|
1628
|
+
var isDirectory = (dir) => import_node_fs4.default.existsSync(dir) && import_node_fs4.default.statSync(dir).isDirectory();
|
|
1318
1629
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
1319
|
-
if (seen.has(file) || !
|
|
1630
|
+
if (seen.has(file) || !import_node_fs4.default.existsSync(file)) return {};
|
|
1320
1631
|
seen.add(file);
|
|
1321
1632
|
const settings = {};
|
|
1322
|
-
for (const raw of
|
|
1633
|
+
for (const raw of import_node_fs4.default.readFileSync(file, "utf8").split("\n")) {
|
|
1323
1634
|
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
1324
1635
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
1325
1636
|
if (include) {
|
|
1326
1637
|
Object.assign(
|
|
1327
1638
|
settings,
|
|
1328
|
-
readXcconfig(
|
|
1639
|
+
readXcconfig(import_node_path3.default.resolve(import_node_path3.default.dirname(file), include[1]), seen)
|
|
1329
1640
|
);
|
|
1330
1641
|
continue;
|
|
1331
1642
|
}
|
|
@@ -1345,8 +1656,8 @@ function applyConditions(raw, configuration) {
|
|
|
1345
1656
|
continue;
|
|
1346
1657
|
}
|
|
1347
1658
|
const matches = [...key.slice(bracket).matchAll(/\[([^=\]]+)=([^\]]*)\]/g)].every(
|
|
1348
|
-
([,
|
|
1349
|
-
const actual =
|
|
1659
|
+
([, name2, pattern]) => {
|
|
1660
|
+
const actual = name2 === "config" ? configuration : CONDITIONS[name2];
|
|
1350
1661
|
return actual !== void 0 && new RegExp(
|
|
1351
1662
|
`^${pattern.replace(/[.+^${}()|\\]/g, "\\$&").replaceAll("*", ".*").replaceAll("?", ".")}$`
|
|
1352
1663
|
).test(actual);
|
|
@@ -1375,22 +1686,22 @@ function decodeXml(text) {
|
|
|
1375
1686
|
return text.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
1376
1687
|
}
|
|
1377
1688
|
function workspaceReferences(workspace) {
|
|
1378
|
-
const data =
|
|
1379
|
-
if (!
|
|
1689
|
+
const data = import_node_path3.default.join(workspace, "contents.xcworkspacedata");
|
|
1690
|
+
if (!import_node_fs4.default.existsSync(data))
|
|
1380
1691
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
1381
|
-
const container =
|
|
1692
|
+
const container = import_node_path3.default.dirname(workspace);
|
|
1382
1693
|
const locate = (location, base) => {
|
|
1383
1694
|
const colon = location.indexOf(":");
|
|
1384
1695
|
const kind = location.slice(0, colon);
|
|
1385
1696
|
const rest = location.slice(colon + 1);
|
|
1386
|
-
if (kind === "group") return
|
|
1387
|
-
if (kind === "container" || kind === "self") return
|
|
1388
|
-
if (kind === "absolute") return
|
|
1389
|
-
throw new Error(`${
|
|
1697
|
+
if (kind === "group") return import_node_path3.default.resolve(base, rest);
|
|
1698
|
+
if (kind === "container" || kind === "self") return import_node_path3.default.resolve(container, rest);
|
|
1699
|
+
if (kind === "absolute") return import_node_path3.default.resolve(rest);
|
|
1700
|
+
throw new Error(`${import_node_path3.default.basename(workspace)} has an unsupported location ${location}`);
|
|
1390
1701
|
};
|
|
1391
1702
|
const groups = [container];
|
|
1392
1703
|
const references = [];
|
|
1393
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
1704
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs4.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
1394
1705
|
if (closing) {
|
|
1395
1706
|
if (tag === "Group") groups.pop();
|
|
1396
1707
|
continue;
|
|
@@ -1405,12 +1716,12 @@ function workspaceReferences(workspace) {
|
|
|
1405
1716
|
}
|
|
1406
1717
|
var loaded = /* @__PURE__ */ new Map();
|
|
1407
1718
|
function loadProject(xcodeproj) {
|
|
1408
|
-
const pbxproj =
|
|
1409
|
-
if (!
|
|
1410
|
-
const mtimeMs =
|
|
1719
|
+
const pbxproj = import_node_path3.default.join(xcodeproj, "project.pbxproj");
|
|
1720
|
+
if (!import_node_fs4.default.existsSync(pbxproj)) throw new Error(`${xcodeproj} has no project.pbxproj`);
|
|
1721
|
+
const mtimeMs = import_node_fs4.default.statSync(pbxproj).mtimeMs;
|
|
1411
1722
|
const cached = loaded.get(pbxproj);
|
|
1412
1723
|
if (cached?.mtimeMs === mtimeMs) return cached.project;
|
|
1413
|
-
const root = parseOpenStepPlist(
|
|
1724
|
+
const root = parseOpenStepPlist(import_node_fs4.default.readFileSync(pbxproj, "utf8"));
|
|
1414
1725
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
1415
1726
|
throw new Error(`${pbxproj} has no objects table`);
|
|
1416
1727
|
}
|
|
@@ -1423,8 +1734,8 @@ function loadProject(xcodeproj) {
|
|
|
1423
1734
|
if (!project || project.isa !== "PBXProject") {
|
|
1424
1735
|
throw new Error(`${pbxproj} has no PBXProject root`);
|
|
1425
1736
|
}
|
|
1426
|
-
const projectDir =
|
|
1427
|
-
|
|
1737
|
+
const projectDir = import_node_fs4.default.realpathSync(
|
|
1738
|
+
import_node_path3.default.resolve(import_node_path3.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
1428
1739
|
);
|
|
1429
1740
|
const parent = /* @__PURE__ */ new Map();
|
|
1430
1741
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -1442,11 +1753,11 @@ function loadProject(xcodeproj) {
|
|
|
1442
1753
|
const own = str(entry.path) ?? "";
|
|
1443
1754
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
1444
1755
|
if (tree === "<absolute>") result2 = own;
|
|
1445
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
1756
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path3.default.join(projectDir, own);
|
|
1446
1757
|
else if (tree === "<group>") {
|
|
1447
1758
|
const up = parent.get(id);
|
|
1448
1759
|
const base = up ? resolvePath(up) : projectDir;
|
|
1449
|
-
result2 = base === null ? null :
|
|
1760
|
+
result2 = base === null ? null : import_node_path3.default.join(base, own);
|
|
1450
1761
|
}
|
|
1451
1762
|
}
|
|
1452
1763
|
resolvedPaths.set(id, result2);
|
|
@@ -1462,18 +1773,18 @@ function targetSettings(ref, builtins) {
|
|
|
1462
1773
|
const configs = list(project.object(listId)?.buildConfigurations).map(project.object);
|
|
1463
1774
|
const config = configs.find((entry) => entry?.name === "Debug") ?? configs.find(Boolean);
|
|
1464
1775
|
if (!config) return [];
|
|
1465
|
-
const
|
|
1776
|
+
const name2 = str(config.name) ?? "Debug";
|
|
1466
1777
|
const base = str(config.baseConfigurationReference);
|
|
1467
1778
|
const own = isDict(config.buildSettings) ? config.buildSettings : {};
|
|
1468
1779
|
return [
|
|
1469
|
-
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {},
|
|
1780
|
+
applyConditions(base ? readXcconfig(project.resolvePath(base) ?? "") : {}, name2),
|
|
1470
1781
|
applyConditions(
|
|
1471
1782
|
Object.fromEntries(
|
|
1472
1783
|
Object.entries(own).flatMap(
|
|
1473
1784
|
([key, value]) => typeof value === "string" ? [[key, value]] : Array.isArray(value) ? [[key, list(value).join(" ")]] : []
|
|
1474
1785
|
)
|
|
1475
1786
|
),
|
|
1476
|
-
|
|
1787
|
+
name2
|
|
1477
1788
|
)
|
|
1478
1789
|
];
|
|
1479
1790
|
};
|
|
@@ -1493,13 +1804,13 @@ function targetSettings(ref, builtins) {
|
|
|
1493
1804
|
resolving.add(marker);
|
|
1494
1805
|
const value = expand(
|
|
1495
1806
|
levels[at][key],
|
|
1496
|
-
(
|
|
1807
|
+
(name2) => name2 === "inherited" ? valueAt(key, at - 1) : valueAt(name2, levels.length - 1)
|
|
1497
1808
|
);
|
|
1498
1809
|
resolving.delete(marker);
|
|
1499
1810
|
return value;
|
|
1500
1811
|
};
|
|
1501
1812
|
const derived = (key) => {
|
|
1502
|
-
const get = (
|
|
1813
|
+
const get = (name2) => valueAt(name2, levels.length - 1);
|
|
1503
1814
|
switch (key) {
|
|
1504
1815
|
case "PRODUCT_NAME":
|
|
1505
1816
|
return get("TARGET_NAME");
|
|
@@ -1524,9 +1835,9 @@ function expand(value, lookup) {
|
|
|
1524
1835
|
return value.replace(
|
|
1525
1836
|
/\$(?:\(([A-Za-z_][A-Za-z0-9_]*)((?::[^)]*)?)\)|\{([A-Za-z_][A-Za-z0-9_]*)((?::[^}]*)?)\}|([A-Za-z_][A-Za-z0-9_]*))/g,
|
|
1526
1837
|
(_match, paren, parenOps, brace, braceOps, bare) => {
|
|
1527
|
-
const
|
|
1838
|
+
const name2 = paren ?? brace ?? bare;
|
|
1528
1839
|
const operators = parenOps ?? braceOps ?? "";
|
|
1529
|
-
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(
|
|
1840
|
+
return operators.split(":").slice(1).reduce((current, operator) => applyOperator(current, operator), lookup(name2));
|
|
1530
1841
|
}
|
|
1531
1842
|
);
|
|
1532
1843
|
}
|
|
@@ -1538,7 +1849,7 @@ function targetMembers(ref) {
|
|
|
1538
1849
|
const addResource = (file) => {
|
|
1539
1850
|
if (isDirectory(file)) {
|
|
1540
1851
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
1541
|
-
} else if (
|
|
1852
|
+
} else if (import_node_fs4.default.existsSync(file)) resources.add(file);
|
|
1542
1853
|
};
|
|
1543
1854
|
const fileRefPaths = (refId) => {
|
|
1544
1855
|
const entry = project.object(refId);
|
|
@@ -1559,7 +1870,7 @@ function targetMembers(ref) {
|
|
|
1559
1870
|
for (const buildFileId of list(phase.files)) {
|
|
1560
1871
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
1561
1872
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
1562
|
-
if (!
|
|
1873
|
+
if (!import_node_fs4.default.existsSync(file)) continue;
|
|
1563
1874
|
allSources.add(file);
|
|
1564
1875
|
if (file.endsWith(".swift")) sources.add(file);
|
|
1565
1876
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -1567,7 +1878,7 @@ function targetMembers(ref) {
|
|
|
1567
1878
|
}
|
|
1568
1879
|
}
|
|
1569
1880
|
const addSynchronized = (folder, relative2) => {
|
|
1570
|
-
const file =
|
|
1881
|
+
const file = import_node_path3.default.join(folder, relative2);
|
|
1571
1882
|
if (NEVER_MEMBER.test(relative2)) return;
|
|
1572
1883
|
if (file.endsWith(".swift")) {
|
|
1573
1884
|
if (!relative2.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -1592,7 +1903,7 @@ function targetMembers(ref) {
|
|
|
1592
1903
|
}
|
|
1593
1904
|
if (owned.has(groupId)) {
|
|
1594
1905
|
for (const file of walkFiles(folder)) {
|
|
1595
|
-
const relative2 =
|
|
1906
|
+
const relative2 = import_node_path3.default.relative(folder, file).split(import_node_path3.default.sep).join("/");
|
|
1596
1907
|
if ([...exceptions].some(
|
|
1597
1908
|
(exception) => relative2 === exception || relative2.startsWith(`${exception}/`)
|
|
1598
1909
|
))
|
|
@@ -1601,14 +1912,14 @@ function targetMembers(ref) {
|
|
|
1601
1912
|
}
|
|
1602
1913
|
} else {
|
|
1603
1914
|
for (const relative2 of exceptions) {
|
|
1604
|
-
const file =
|
|
1915
|
+
const file = import_node_path3.default.join(folder, relative2);
|
|
1605
1916
|
if (isDirectory(file)) {
|
|
1606
1917
|
for (const inner of walkFiles(file))
|
|
1607
1918
|
addSynchronized(
|
|
1608
1919
|
folder,
|
|
1609
|
-
|
|
1920
|
+
import_node_path3.default.relative(folder, inner).split(import_node_path3.default.sep).join("/")
|
|
1610
1921
|
);
|
|
1611
|
-
} else if (
|
|
1922
|
+
} else if (import_node_fs4.default.existsSync(file)) addSynchronized(folder, relative2);
|
|
1612
1923
|
}
|
|
1613
1924
|
}
|
|
1614
1925
|
}
|
|
@@ -1621,8 +1932,8 @@ function targetMembers(ref) {
|
|
|
1621
1932
|
function commonAncestor(dirs) {
|
|
1622
1933
|
let common = dirs[0];
|
|
1623
1934
|
for (const dir of dirs) {
|
|
1624
|
-
while (common !==
|
|
1625
|
-
common =
|
|
1935
|
+
while (common !== import_node_path3.default.dirname(common) && import_node_path3.default.relative(common, dir).startsWith(".."))
|
|
1936
|
+
common = import_node_path3.default.dirname(common);
|
|
1626
1937
|
}
|
|
1627
1938
|
return common;
|
|
1628
1939
|
}
|
|
@@ -1631,9 +1942,9 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
1631
1942
|
const projects = [];
|
|
1632
1943
|
const projectAt = /* @__PURE__ */ new Map();
|
|
1633
1944
|
const addProject = (xcodeproj) => {
|
|
1634
|
-
const key =
|
|
1635
|
-
if (projectAt.has(key) || key.split(
|
|
1636
|
-
if (!
|
|
1945
|
+
const key = import_node_path3.default.resolve(xcodeproj);
|
|
1946
|
+
if (projectAt.has(key) || key.split(import_node_path3.default.sep).includes("Pods")) return;
|
|
1947
|
+
if (!import_node_fs4.default.existsSync(import_node_path3.default.join(key, "project.pbxproj"))) return;
|
|
1637
1948
|
const project = loadProject(key);
|
|
1638
1949
|
projectAt.set(key, project);
|
|
1639
1950
|
projects.push(project);
|
|
@@ -1649,7 +1960,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
1649
1960
|
for (const reference of listed)
|
|
1650
1961
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
1651
1962
|
if (projects.length === 0) {
|
|
1652
|
-
throw new Error(`${
|
|
1963
|
+
throw new Error(`${import_node_path3.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
1653
1964
|
}
|
|
1654
1965
|
return { listed, projects, projectAt };
|
|
1655
1966
|
}
|
|
@@ -1666,7 +1977,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1666
1977
|
const allTargets = projects.flatMap(nativeTargets);
|
|
1667
1978
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
1668
1979
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
1669
|
-
const container =
|
|
1980
|
+
const container = import_node_path3.default.basename(xcodeprojOrWorkspace);
|
|
1670
1981
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
1671
1982
|
if (named.length !== 1) {
|
|
1672
1983
|
throw new Error(
|
|
@@ -1678,14 +1989,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1678
1989
|
for (const ref of allTargets) {
|
|
1679
1990
|
const product = ref.project.object(str(ref.target.productReference));
|
|
1680
1991
|
const file = str(product?.path);
|
|
1681
|
-
if (file && !byProduct.has(
|
|
1682
|
-
byProduct.set(
|
|
1992
|
+
if (file && !byProduct.has(import_node_path3.default.basename(file)))
|
|
1993
|
+
byProduct.set(import_node_path3.default.basename(file), ref);
|
|
1683
1994
|
}
|
|
1684
1995
|
const proxied = (project, proxyId) => {
|
|
1685
1996
|
const proxy = project.object(proxyId);
|
|
1686
1997
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
1687
1998
|
const portal = str(proxy.containerPortal);
|
|
1688
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
1999
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path3.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
1689
2000
|
const remote = str(proxy.remoteGlobalIDString);
|
|
1690
2001
|
if (!owner || !remote) return void 0;
|
|
1691
2002
|
return nativeTargets(owner).find(
|
|
@@ -1706,7 +2017,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1706
2017
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
1707
2018
|
for (const buildFileId of list(phase.files)) {
|
|
1708
2019
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
1709
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
2020
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path3.default.basename(str(file.path) ?? "")) : void 0;
|
|
1710
2021
|
if (resolved) found.push(resolved);
|
|
1711
2022
|
}
|
|
1712
2023
|
}
|
|
@@ -1724,10 +2035,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1724
2035
|
};
|
|
1725
2036
|
visit(app);
|
|
1726
2037
|
const moduleTarget = (ref) => {
|
|
1727
|
-
const
|
|
2038
|
+
const name2 = str(ref.target.name) ?? ref.id;
|
|
1728
2039
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
1729
|
-
TARGET_NAME:
|
|
1730
|
-
PROJECT_NAME:
|
|
2040
|
+
TARGET_NAME: name2,
|
|
2041
|
+
PROJECT_NAME: import_node_path3.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
1731
2042
|
SRCROOT: ref.project.projectDir,
|
|
1732
2043
|
SOURCE_ROOT: ref.project.projectDir,
|
|
1733
2044
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -1738,7 +2049,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1738
2049
|
settings: settings2,
|
|
1739
2050
|
keys,
|
|
1740
2051
|
module: {
|
|
1741
|
-
name,
|
|
2052
|
+
name: name2,
|
|
1742
2053
|
moduleName: applyOperator(settings2("PRODUCT_MODULE_NAME"), "c99extidentifier"),
|
|
1743
2054
|
...targetMembers(ref),
|
|
1744
2055
|
languageMode: swiftVersion >= 6 ? 6 : 5,
|
|
@@ -1758,8 +2069,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1758
2069
|
}
|
|
1759
2070
|
return value;
|
|
1760
2071
|
};
|
|
1761
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
1762
|
-
const sourceInfo = infoPlistFile ? import_plist2.default.parse(
|
|
2072
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path3.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
2073
|
+
const sourceInfo = infoPlistFile ? import_plist2.default.parse(import_node_fs4.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
1763
2074
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
1764
2075
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
1765
2076
|
}
|
|
@@ -1777,12 +2088,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1777
2088
|
};
|
|
1778
2089
|
}
|
|
1779
2090
|
const localPackageDirs = [
|
|
1780
|
-
...listed.filter((reference) =>
|
|
2091
|
+
...listed.filter((reference) => import_node_fs4.default.existsSync(import_node_path3.default.join(reference, "Package.swift"))),
|
|
1781
2092
|
...projects.flatMap(
|
|
1782
2093
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
1783
2094
|
if (!isDict(entry)) return [];
|
|
1784
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
1785
|
-
return candidate &&
|
|
2095
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path3.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
2096
|
+
return candidate && import_node_fs4.default.existsSync(import_node_path3.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
1786
2097
|
})
|
|
1787
2098
|
)
|
|
1788
2099
|
];
|
|
@@ -1791,7 +2102,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1791
2102
|
const cached = graphs.get(dir);
|
|
1792
2103
|
if (cached) return cached;
|
|
1793
2104
|
const graph = swiftManifestGraph(
|
|
1794
|
-
|
|
2105
|
+
import_node_fs4.default.readFileSync(import_node_path3.default.join(dir, "Package.swift"), "utf8")
|
|
1795
2106
|
);
|
|
1796
2107
|
graphs.set(dir, graph);
|
|
1797
2108
|
return graph;
|
|
@@ -1826,7 +2137,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1826
2137
|
});
|
|
1827
2138
|
} else if (reference?.isa === "XCLocalSwiftPackageReference") {
|
|
1828
2139
|
localPackages.add(
|
|
1829
|
-
|
|
2140
|
+
import_node_path3.default.resolve(project.projectDir, str(reference.relativePath) ?? "")
|
|
1830
2141
|
);
|
|
1831
2142
|
} else if (localProducts.has(product)) {
|
|
1832
2143
|
localPackages.add(localProducts.get(product));
|
|
@@ -1838,8 +2149,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1838
2149
|
const dir = pending.pop();
|
|
1839
2150
|
const graph = graphOf(dir);
|
|
1840
2151
|
for (const relative2 of graph.packagePaths) {
|
|
1841
|
-
const next =
|
|
1842
|
-
if (localPackages.has(next) || !
|
|
2152
|
+
const next = import_node_path3.default.resolve(dir, relative2);
|
|
2153
|
+
if (localPackages.has(next) || !import_node_fs4.default.existsSync(import_node_path3.default.join(next, "Package.swift")))
|
|
1843
2154
|
continue;
|
|
1844
2155
|
localPackages.add(next);
|
|
1845
2156
|
pending.push(next);
|
|
@@ -1853,8 +2164,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1853
2164
|
}
|
|
1854
2165
|
}
|
|
1855
2166
|
}
|
|
1856
|
-
const resolvedFile =
|
|
1857
|
-
workspace ??
|
|
2167
|
+
const resolvedFile = import_node_path3.default.join(
|
|
2168
|
+
workspace ?? import_node_path3.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
1858
2169
|
"xcshareddata",
|
|
1859
2170
|
"swiftpm",
|
|
1860
2171
|
"Package.resolved"
|
|
@@ -1864,18 +2175,18 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1864
2175
|
...module2,
|
|
1865
2176
|
rootDir: commonAncestor(
|
|
1866
2177
|
[
|
|
1867
|
-
workspace ?
|
|
2178
|
+
workspace ? import_node_path3.default.dirname(workspace) : app.project.projectDir,
|
|
1868
2179
|
...used.map((project) => project.projectDir),
|
|
1869
2180
|
...localPackages
|
|
1870
|
-
].map((dir) =>
|
|
2181
|
+
].map((dir) => import_node_fs4.default.realpathSync(dir))
|
|
1871
2182
|
),
|
|
1872
2183
|
pbxprojs: [...new Set(used.map((project) => project.pbxproj))].sort(),
|
|
1873
2184
|
infoPlist: import_plist2.default.build(info),
|
|
1874
2185
|
infoPlistFile,
|
|
1875
2186
|
frameworks,
|
|
1876
|
-
localPackages: [...localPackages].map((dir) =>
|
|
2187
|
+
localPackages: [...localPackages].map((dir) => import_node_fs4.default.realpathSync(dir)).sort(),
|
|
1877
2188
|
remoteProducts,
|
|
1878
|
-
packageResolved:
|
|
2189
|
+
packageResolved: import_node_fs4.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
1879
2190
|
unresolvedProducts,
|
|
1880
2191
|
appTargets: appTargetNames
|
|
1881
2192
|
};
|
|
@@ -1885,8 +2196,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
1885
2196
|
function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
|
|
1886
2197
|
const result = {};
|
|
1887
2198
|
let config = {};
|
|
1888
|
-
const appJsonPath =
|
|
1889
|
-
const appJson =
|
|
2199
|
+
const appJsonPath = import_node_path4.default.join(projectRoot, "app.json");
|
|
2200
|
+
const appJson = import_node_fs5.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs5.default.readFileSync(appJsonPath, "utf8")) : null;
|
|
1890
2201
|
const staticExpo = isRecord2(appJson) && (isRecord2(appJson.expo) || [appJson.ios, appJson.android].some(
|
|
1891
2202
|
(value) => isRecord2(value) && typeof value.googleServicesFile === "string"
|
|
1892
2203
|
));
|
|
@@ -1895,10 +2206,10 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
|
|
|
1895
2206
|
"app.config.ts",
|
|
1896
2207
|
"app.config.cjs",
|
|
1897
2208
|
"app.config.mjs"
|
|
1898
|
-
].some((
|
|
2209
|
+
].some((name2) => import_node_fs5.default.existsSync(import_node_path4.default.join(projectRoot, name2)));
|
|
1899
2210
|
if (staticExpo || dynamicExpo) {
|
|
1900
|
-
const
|
|
1901
|
-
const configModule =
|
|
2211
|
+
const require3 = (0, import_node_module.createRequire)(import_node_path4.default.join(projectRoot, "package.json"));
|
|
2212
|
+
const configModule = require3("@expo/config");
|
|
1902
2213
|
if (!isRecord2(configModule) || typeof configModule.getConfig !== "function")
|
|
1903
2214
|
throw new Error("Expo native configuration is unavailable.");
|
|
1904
2215
|
const resolved = Reflect.apply(configModule.getConfig, configModule, [
|
|
@@ -1909,23 +2220,23 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
|
|
|
1909
2220
|
}
|
|
1910
2221
|
const ios = config.ios;
|
|
1911
2222
|
if (platforms.includes("ios") && (!isRecord2(ios) || typeof ios.googleServicesFile !== "string")) {
|
|
1912
|
-
const iosRoot =
|
|
1913
|
-
if (
|
|
1914
|
-
const projects =
|
|
2223
|
+
const iosRoot = import_node_path4.default.join(projectRoot, "ios");
|
|
2224
|
+
if (import_node_fs5.default.existsSync(iosRoot)) {
|
|
2225
|
+
const projects = import_node_fs5.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
|
|
1915
2226
|
if (projects.length > 1)
|
|
1916
2227
|
throw new Error("native Firebase configuration requires a selected Xcode project");
|
|
1917
2228
|
if (projects.length === 1) {
|
|
1918
|
-
const xcodeproj =
|
|
2229
|
+
const xcodeproj = import_node_path4.default.join(iosRoot, projects[0].name);
|
|
1919
2230
|
const appTargets = listXcodeAppTargets(xcodeproj);
|
|
1920
2231
|
if (appTargets.length > 1)
|
|
1921
2232
|
throw new Error("native Firebase configuration requires a selected app target");
|
|
1922
2233
|
if (appTargets.length === 1) {
|
|
1923
2234
|
const app = readXcodeAppTarget(xcodeproj, appTargets[0]);
|
|
1924
2235
|
const delegates = app.allSources.filter(
|
|
1925
|
-
(file) => /^AppDelegate\.(swift|mm|m)$/.test(
|
|
2236
|
+
(file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path4.default.basename(file))
|
|
1926
2237
|
);
|
|
1927
2238
|
const defaultConfigured = delegates.some((file) => {
|
|
1928
|
-
const source =
|
|
2239
|
+
const source = import_node_fs5.default.readFileSync(file, "utf8").replace(
|
|
1929
2240
|
/\/\*[\s\S]*?\*\/|\/\/[^\n]*|"(?:\\.|[^"\\])*"/g,
|
|
1930
2241
|
(token) => token.startsWith('"') ? '""' : token.replace(/[^\n]/g, " ")
|
|
1931
2242
|
);
|
|
@@ -1953,15 +2264,15 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
|
|
|
1953
2264
|
});
|
|
1954
2265
|
if (defaultConfigured) {
|
|
1955
2266
|
const resources = app.resources.filter(
|
|
1956
|
-
(file) => /^GoogleService-Info\.plist$/.test(
|
|
2267
|
+
(file) => /^GoogleService-Info\.plist$/.test(import_node_path4.default.basename(file))
|
|
1957
2268
|
);
|
|
1958
2269
|
if (resources.length !== 1)
|
|
1959
2270
|
throw new Error(
|
|
1960
2271
|
"native Firebase default initialization requires one GoogleService-Info.plist build resource"
|
|
1961
2272
|
);
|
|
1962
2273
|
config.ios = {
|
|
1963
|
-
googleServicesFile:
|
|
1964
|
-
|
|
2274
|
+
googleServicesFile: import_node_path4.default.relative(
|
|
2275
|
+
import_node_fs5.default.realpathSync(projectRoot),
|
|
1965
2276
|
resources[0]
|
|
1966
2277
|
)
|
|
1967
2278
|
};
|
|
@@ -1974,8 +2285,8 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"]) {
|
|
|
1974
2285
|
const native = config[platform];
|
|
1975
2286
|
if (!isRecord2(native) || typeof native.googleServicesFile !== "string") continue;
|
|
1976
2287
|
try {
|
|
1977
|
-
const source =
|
|
1978
|
-
|
|
2288
|
+
const source = import_node_fs5.default.readFileSync(
|
|
2289
|
+
import_node_path4.default.resolve(projectRoot, native.googleServicesFile),
|
|
1979
2290
|
"utf8"
|
|
1980
2291
|
);
|
|
1981
2292
|
const parsed = platform === "ios" ? parsePlistSource(source) : JSON.parse(source);
|
|
@@ -2036,7 +2347,7 @@ function readNativeFirebaseMetadata(value) {
|
|
|
2036
2347
|
if (value === null || value === void 0) return null;
|
|
2037
2348
|
if (typeof value !== "object" || Array.isArray(value))
|
|
2038
2349
|
throw new Error("native Firebase configuration is malformed");
|
|
2039
|
-
if (Object.keys(value).some((key) => !PLATFORMS.some((
|
|
2350
|
+
if (Object.keys(value).some((key) => !PLATFORMS.some((name2) => name2 === key)))
|
|
2040
2351
|
throw new Error("native Firebase configuration has an invalid platform");
|
|
2041
2352
|
const result = {};
|
|
2042
2353
|
for (const platform of PLATFORMS) {
|
|
@@ -2112,33 +2423,31 @@ var import_path = __toESM(require("path"), 1);
|
|
|
2112
2423
|
var import_url = require("url");
|
|
2113
2424
|
|
|
2114
2425
|
// ../contrast-runtime-delivery/src/product.ts
|
|
2115
|
-
|
|
2116
|
-
return value.length <= 100 && /^[0-9A-Za-z][0-9A-Za-z._+-]*$/.test(value);
|
|
2117
|
-
}
|
|
2426
|
+
init_version();
|
|
2118
2427
|
|
|
2119
2428
|
// src/home-paths.ts
|
|
2120
|
-
var
|
|
2429
|
+
var import_node_fs6 = __toESM(require("node:fs"), 1);
|
|
2121
2430
|
var import_node_os = require("node:os");
|
|
2122
|
-
var
|
|
2431
|
+
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
2123
2432
|
var PEACH_HOME_ENV = "PEACH_HOME";
|
|
2124
2433
|
var ACTIVE_RUNTIME_FILE = "active";
|
|
2125
2434
|
function rnxHomeDir() {
|
|
2126
2435
|
const override = process.env[PEACH_HOME_ENV];
|
|
2127
|
-
if (override && override.length > 0) return
|
|
2128
|
-
return
|
|
2436
|
+
if (override && override.length > 0) return import_node_path5.default.resolve(override);
|
|
2437
|
+
return import_node_path5.default.join((0, import_node_os.homedir)(), ".peach");
|
|
2129
2438
|
}
|
|
2130
2439
|
function runtimesDir() {
|
|
2131
|
-
return
|
|
2440
|
+
return import_node_path5.default.join(rnxHomeDir(), "runtimes");
|
|
2132
2441
|
}
|
|
2133
2442
|
function runtimeDir(version) {
|
|
2134
|
-
return
|
|
2443
|
+
return import_node_path5.default.join(runtimesDir(), version);
|
|
2135
2444
|
}
|
|
2136
2445
|
function activeRuntimeFile() {
|
|
2137
|
-
return
|
|
2446
|
+
return import_node_path5.default.join(runtimesDir(), ACTIVE_RUNTIME_FILE);
|
|
2138
2447
|
}
|
|
2139
2448
|
function readActiveRuntime() {
|
|
2140
2449
|
try {
|
|
2141
|
-
const value =
|
|
2450
|
+
const value = import_node_fs6.default.readFileSync(activeRuntimeFile(), "utf8").trim();
|
|
2142
2451
|
return value.length > 0 ? value : null;
|
|
2143
2452
|
} catch {
|
|
2144
2453
|
return null;
|
|
@@ -2434,8 +2743,8 @@ function withRNX(config) {
|
|
|
2434
2743
|
for (const entry of import_fs2.default.readdirSync(iosRoot, { withFileTypes: true })) {
|
|
2435
2744
|
if (!entry.isDirectory() || entry.name === "Pods") continue;
|
|
2436
2745
|
const names = entry.name.endsWith(".xcodeproj") ? ["project.pbxproj"] : ["Info.plist", "AppDelegate.swift", "AppDelegate.mm", "AppDelegate.m"];
|
|
2437
|
-
for (const
|
|
2438
|
-
const relative2 = `ios/${entry.name}/${
|
|
2746
|
+
for (const name2 of names) {
|
|
2747
|
+
const relative2 = `ios/${entry.name}/${name2}`;
|
|
2439
2748
|
const file = import_path2.default.join(cfgProjectRoot, relative2);
|
|
2440
2749
|
if (import_fs2.default.existsSync(file)) files[relative2] = import_fs2.default.readFileSync(file, "utf8");
|
|
2441
2750
|
}
|
|
@@ -2467,6 +2776,27 @@ function withRNX(config) {
|
|
|
2467
2776
|
code: insertNativeFirebaseFooter(annotated.code, firebase)
|
|
2468
2777
|
};
|
|
2469
2778
|
}
|
|
2779
|
+
const project = resolveAppProject(cfgProjectRoot);
|
|
2780
|
+
const appConfig = project?.configPath ? await (await Promise.resolve().then(() => (init_app_config(), app_config_exports))).loadRNXAppConfig(project) : void 0;
|
|
2781
|
+
if (appConfig) {
|
|
2782
|
+
const { produceConfiguredBundle: produceConfiguredBundle2 } = await Promise.resolve().then(() => (init_configured_bundle_producer(), configured_bundle_producer_exports));
|
|
2783
|
+
const runtimePackages = /* @__PURE__ */ new Set();
|
|
2784
|
+
for (const module2 of graph.dependencies?.values() ?? []) {
|
|
2785
|
+
for (const [key, dependency] of module2.dependencies ?? []) {
|
|
2786
|
+
const specifier = dependency.data?.name ?? key;
|
|
2787
|
+
if (!specifier.startsWith(".") && !specifier.startsWith("/"))
|
|
2788
|
+
runtimePackages.add(specifier);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
annotated = typeof annotated === "string" ? await produceConfiguredBundle2(annotated, appConfig, runtimePackages) : {
|
|
2792
|
+
...annotated,
|
|
2793
|
+
code: await produceConfiguredBundle2(
|
|
2794
|
+
annotated.code,
|
|
2795
|
+
appConfig,
|
|
2796
|
+
runtimePackages
|
|
2797
|
+
)
|
|
2798
|
+
};
|
|
2799
|
+
}
|
|
2470
2800
|
return annotated;
|
|
2471
2801
|
}
|
|
2472
2802
|
}
|