peachsim 0.1.1674 → 0.1.1684
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/commands/control.ts +13 -1
- package/cli/commands/coverage-swift.ts +83 -27
- package/cli/commands/coverage.ts +219 -20
- package/cli/commands/detect.ts +10 -6
- package/cli/commands/inspect/core.ts +2 -0
- package/cli/commands/inspect/wait-ready.ts +7 -0
- package/cli/outbound-endpoints.ts +12 -0
- package/detox/index.ts +11 -1
- package/detox/jest-environment.cjs +14 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.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/bundle-channel.cjs +3274 -1663
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +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 +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +6 -4
- package/dist-lib/detox/jest-environment.cjs +14 -0
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +2407 -1126
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +2879 -1598
- package/dist-lib/host/fetch-proxy-handler.cjs +18 -5
- 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 +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1904 -741
- 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 +6215 -4283
- package/dist-lib/native-app-identity-project.cjs +31 -6
- package/dist-lib/native-app-identity-project.mjs +31 -6
- 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/public-origins-lib-esm.json +24 -23
- package/dist-lib/public-origins-lib-static.json +1 -1
- package/dist-lib/public-origins-lib.json +134 -78
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/reap-browser.cjs +2 -2
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -1
- package/dist-lib/sdk.mjs +2 -1
- package/dist-lib/skills.cjs +3570 -2160
- package/dist-lib/swift-compile.cjs +473 -351
- package/dist-lib/swift-compile.mjs +471 -349
- package/dist-lib/swift-package.cjs +36 -6
- package/dist-lib/swift-package.mjs +35 -6
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +26 -11
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +2418 -1132
- package/dist-lib/vite.cjs +1907 -766
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-engine/src/engine/canvaskit-api.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/engine/clipboardContract.d.ts +9 -1
- package/dist-types/packages/peach-engine/src/preview/upload-protocol.d.ts +11 -3
- package/dist-types/packages/peach-engine/src/webview-automation-host.d.ts +6 -0
- package/dist-types/packages/peach-globals/src/clipboardBridgeContract.d.ts +2 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h +51 -2
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +21 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFComposeAssistantViewController.h +29 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeControllerDeferredAction.h +14 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailComposeViewController.h +162 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMailDraft.h +24 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController+UPI.h +31 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MFMessageComposeViewController.h +169 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Headers/MessageUI.h +13 -0
- package/sdk/ios/System/Library/Frameworks/MessageUI.framework/Modules/module.modulemap +11 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +10 -0
- package/sdk/ios/usr/include/arm/param.h +151 -0
- package/sdk/ios/usr/include/dispatch/dispatch.h +3 -0
- package/sdk/ios/usr/include/dlfcn.h +1 -2
- package/sdk/ios/usr/include/machine/param.h +42 -0
- package/sdk/ios/usr/include/net/if.h +1 -2
- package/sdk/ios/usr/include/peach/pthread.h +4 -4
- package/sdk/ios/usr/include/pthread/qos.h +304 -0
- package/sdk/ios/usr/include/sys/_types/_fd_clr.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_copy.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_def.h +121 -0
- package/sdk/ios/usr/include/sys/_types/_fd_isset.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_set.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_setsize.h +31 -0
- package/sdk/ios/usr/include/sys/_types/_fd_zero.h +31 -0
- package/sdk/ios/usr/include/sys/cdefs.h +3 -0
- package/sdk/ios/usr/include/sys/param.h +235 -0
- package/sdk/ios/usr/include/sys/proc.h +1 -0
- package/sdk/ios/usr/include/sys/qos.h +151 -12
- package/sdk/ios/wasm/include/__typedef_sigset_t.h +7 -0
- package/sdk/ios/wasm/include/fcntl.h +11 -0
- package/sdk/ios/wasm/include/mach/machine/boolean.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/exception.h +5 -0
- package/sdk/ios/wasm/include/mach/machine/kern_return.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/processor_info.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/rpc.h +2 -0
- package/sdk/ios/wasm/include/mach/machine/thread_state.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/thread_status.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_param.h +3 -0
- package/sdk/ios/wasm/include/mach/machine/vm_types.h +18 -0
- package/sdk/ios/wasm/include/machine/_types.h +153 -0
- package/sdk/ios/wasm/include/machine/endian.h +2 -0
- package/sdk/ios/wasm/include/machine/limits.h +2 -0
- package/sdk/ios/wasm/include/machine/types.h +30 -0
- package/sdk/ios/wasm/include/poll.h +8 -0
- package/sdk/ios/wasm/include/pthread.h +50 -0
- package/sdk/ios/wasm/include/signal.h +72 -0
- package/sdk/ios/wasm/include/stdlib.h +3 -0
- package/sdk/ios/wasm/include/string.h +10 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_attr_t.h +7 -0
- package/sdk/ios/wasm/include/sys/_pthread/_pthread_t.h +7 -0
- package/sdk/ios/wasm/include/sys/mman.h +122 -0
- package/sdk/ios/wasm/include/sys/select.h +37 -0
- package/sdk/ios/wasm/include/sys/signal.h +259 -0
- package/sdk/ios/wasm/include/sys/socket.h +8 -0
- package/sdk/ios/wasm/include/sys/types.h +14 -0
- package/sdk/ios/wasm/include/sys/ucontext.h +1 -0
- package/sdk/ios/wasm/include/sys/uio.h +11 -0
- package/sdk/ios/wasm/include/sys/wait.h +89 -0
- package/sdk/ios/wasm/include/time.h +8 -0
- package/sdk/ios/wasm/include/unistd.h +17 -0
- package/src/bridge-contract.ts +2 -0
- package/src/chromium-admission.ts +10 -5
- package/src/device-catalog.ts +4 -4
- package/src/host/fetch-proxy-handler.ts +20 -0
- package/src/metro-plugin.ts +5 -2
- package/src/nitro-adapter.lock.json +6 -6
- package/src/nitro-compile.ts +63 -2
- package/src/numbered-lock.ts +72 -0
- package/src/react-native-coverage/capability-reference-resolution.ts +62 -5
- package/src/react-native-coverage/capability-source-references.ts +50 -13
- package/src/react-native-coverage/native-source-credit.ts +126 -0
- package/src/react-native-coverage/native-source-ranges-file.ts +38 -0
- package/src/react-native-coverage/native-surface.ts +49 -0
- package/src/react-native-coverage/verified-reach.ts +22 -2
- package/src/runtime-assets.ts +17 -0
- package/src/swift-compile.ts +84 -48
- package/src/swift-coverage/indexing.ts +17 -1
- package/src/swift-coverage/sdk.ts +71 -0
- package/src/swift-coverage/source.ts +74 -2
- package/src/swift-coverage/types.ts +6 -0
- package/src/swift-distribution.lock.json +12 -12
- package/src/swift-host.ts +133 -14
- package/src/swift-objc-compile.ts +6 -21
- package/src/swift-objc-metadata.ts +2 -8
- package/src/swift-objc-platform.ts +53 -0
- package/src/swift-objc-standin.ts +45 -1
- package/src/swift-package-manifest.ts +48 -3
- package/src/swift-package.ts +59 -9
- package/src/swift-packages.ts +157 -44
- package/src/swift-source-pods.ts +288 -0
- package/src/swift-toolchain.ts +32 -10
- package/src/vite-plugin-one.ts +5 -4
- package/src/worker-system-chunks.ts +7 -1
- package/src/xcode-project.ts +40 -11
package/dist-lib/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1684 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -98,7 +98,7 @@ var init_bundleGlobalFooter = __esm({
|
|
|
98
98
|
var runtime_companion_default;
|
|
99
99
|
var init_runtime_companion = __esm({
|
|
100
100
|
"runtime-companion.json"() {
|
|
101
|
-
runtime_companion_default = { abi: 1, sha256: "
|
|
101
|
+
runtime_companion_default = { abi: 1, sha256: "0aa1bb93377f2ed084f869ab161285ff9e1c638510065738c97f0cbe806bb630", file: "node/cli-0aa1bb93377f2ed084f869ab161285ff9e1c638510065738c97f0cbe806bb630.cjs" };
|
|
102
102
|
}
|
|
103
103
|
});
|
|
104
104
|
|
|
@@ -356,7 +356,18 @@ function resolveRuntimeFilePath(runtimeRoot, pathname) {
|
|
|
356
356
|
if (!import_fs.default.existsSync(fullPath) || !import_fs.default.statSync(fullPath).isFile()) return null;
|
|
357
357
|
return fullPath;
|
|
358
358
|
}
|
|
359
|
+
function setRuntimeIsolationHeaders(res) {
|
|
360
|
+
res.setHeader("cross-origin-opener-policy", "same-origin");
|
|
361
|
+
res.setHeader("cross-origin-embedder-policy", "require-corp");
|
|
362
|
+
res.setHeader("cross-origin-resource-policy", "cross-origin");
|
|
363
|
+
}
|
|
364
|
+
function sendShellHtml(res, html) {
|
|
365
|
+
setRuntimeIsolationHeaders(res);
|
|
366
|
+
res.setHeader("content-type", "text/html");
|
|
367
|
+
res.end(html);
|
|
368
|
+
}
|
|
359
369
|
function serveRuntimeFile(req, res, fullPath) {
|
|
370
|
+
setRuntimeIsolationHeaders(res);
|
|
360
371
|
const ext = import_path.default.extname(fullPath);
|
|
361
372
|
const stat = import_fs.default.statSync(fullPath);
|
|
362
373
|
const lastModified = stat.mtime.toUTCString();
|
|
@@ -526,6 +537,26 @@ function isLoopbackHost(hostname) {
|
|
|
526
537
|
const normalized = normalizeHostname(hostname);
|
|
527
538
|
return normalized === "localhost" || normalized.endsWith(".localhost") || normalized === "0.0.0.0" || normalized === "::1" || /^127(?:\.\d{1,3}){3}$/.test(normalized);
|
|
528
539
|
}
|
|
540
|
+
function isTrustedBridgeRequest(headers) {
|
|
541
|
+
const origin = headers.origin;
|
|
542
|
+
if (origin === void 0) return true;
|
|
543
|
+
try {
|
|
544
|
+
const { hostname, host } = new URL(String(origin));
|
|
545
|
+
return isLoopbackHost(hostname) || [headers.host, headers[":authority"], headers["x-forwarded-host"]].some(
|
|
546
|
+
(value) => typeof value === "string" && value.toLowerCase() === host
|
|
547
|
+
);
|
|
548
|
+
} catch {
|
|
549
|
+
return false;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function loopbackOriginOf(value) {
|
|
553
|
+
try {
|
|
554
|
+
const url = new URL(value);
|
|
555
|
+
return isLoopbackHost(url.hostname) ? url.origin : null;
|
|
556
|
+
} catch {
|
|
557
|
+
return null;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
529
560
|
var init_backend_origin = __esm({
|
|
530
561
|
"src/backend-origin.ts"() {
|
|
531
562
|
"use strict";
|
|
@@ -1732,17 +1763,17 @@ function visit(node, visitor) {
|
|
|
1732
1763
|
} else
|
|
1733
1764
|
visit_(null, node, visitor_, Object.freeze([]));
|
|
1734
1765
|
}
|
|
1735
|
-
function visit_(key, node, visitor,
|
|
1736
|
-
const ctrl = callVisitor(key, node, visitor,
|
|
1766
|
+
function visit_(key, node, visitor, path22) {
|
|
1767
|
+
const ctrl = callVisitor(key, node, visitor, path22);
|
|
1737
1768
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
1738
|
-
replaceNode(key,
|
|
1739
|
-
return visit_(key, ctrl, visitor,
|
|
1769
|
+
replaceNode(key, path22, ctrl);
|
|
1770
|
+
return visit_(key, ctrl, visitor, path22);
|
|
1740
1771
|
}
|
|
1741
1772
|
if (typeof ctrl !== "symbol") {
|
|
1742
1773
|
if (isCollection(node)) {
|
|
1743
|
-
|
|
1774
|
+
path22 = Object.freeze(path22.concat(node));
|
|
1744
1775
|
for (let i = 0; i < node.items.length; ++i) {
|
|
1745
|
-
const ci = visit_(i, node.items[i], visitor,
|
|
1776
|
+
const ci = visit_(i, node.items[i], visitor, path22);
|
|
1746
1777
|
if (typeof ci === "number")
|
|
1747
1778
|
i = ci - 1;
|
|
1748
1779
|
else if (ci === BREAK)
|
|
@@ -1753,13 +1784,13 @@ function visit_(key, node, visitor, path21) {
|
|
|
1753
1784
|
}
|
|
1754
1785
|
}
|
|
1755
1786
|
} else if (isPair(node)) {
|
|
1756
|
-
|
|
1757
|
-
const ck = visit_("key", node.key, visitor,
|
|
1787
|
+
path22 = Object.freeze(path22.concat(node));
|
|
1788
|
+
const ck = visit_("key", node.key, visitor, path22);
|
|
1758
1789
|
if (ck === BREAK)
|
|
1759
1790
|
return BREAK;
|
|
1760
1791
|
else if (ck === REMOVE)
|
|
1761
1792
|
node.key = null;
|
|
1762
|
-
const cv = visit_("value", node.value, visitor,
|
|
1793
|
+
const cv = visit_("value", node.value, visitor, path22);
|
|
1763
1794
|
if (cv === BREAK)
|
|
1764
1795
|
return BREAK;
|
|
1765
1796
|
else if (cv === REMOVE)
|
|
@@ -1777,17 +1808,17 @@ async function visitAsync(node, visitor) {
|
|
|
1777
1808
|
} else
|
|
1778
1809
|
await visitAsync_(null, node, visitor_, Object.freeze([]));
|
|
1779
1810
|
}
|
|
1780
|
-
async function visitAsync_(key, node, visitor,
|
|
1781
|
-
const ctrl = await callVisitor(key, node, visitor,
|
|
1811
|
+
async function visitAsync_(key, node, visitor, path22) {
|
|
1812
|
+
const ctrl = await callVisitor(key, node, visitor, path22);
|
|
1782
1813
|
if (isNode(ctrl) || isPair(ctrl)) {
|
|
1783
|
-
replaceNode(key,
|
|
1784
|
-
return visitAsync_(key, ctrl, visitor,
|
|
1814
|
+
replaceNode(key, path22, ctrl);
|
|
1815
|
+
return visitAsync_(key, ctrl, visitor, path22);
|
|
1785
1816
|
}
|
|
1786
1817
|
if (typeof ctrl !== "symbol") {
|
|
1787
1818
|
if (isCollection(node)) {
|
|
1788
|
-
|
|
1819
|
+
path22 = Object.freeze(path22.concat(node));
|
|
1789
1820
|
for (let i = 0; i < node.items.length; ++i) {
|
|
1790
|
-
const ci = await visitAsync_(i, node.items[i], visitor,
|
|
1821
|
+
const ci = await visitAsync_(i, node.items[i], visitor, path22);
|
|
1791
1822
|
if (typeof ci === "number")
|
|
1792
1823
|
i = ci - 1;
|
|
1793
1824
|
else if (ci === BREAK)
|
|
@@ -1798,13 +1829,13 @@ async function visitAsync_(key, node, visitor, path21) {
|
|
|
1798
1829
|
}
|
|
1799
1830
|
}
|
|
1800
1831
|
} else if (isPair(node)) {
|
|
1801
|
-
|
|
1802
|
-
const ck = await visitAsync_("key", node.key, visitor,
|
|
1832
|
+
path22 = Object.freeze(path22.concat(node));
|
|
1833
|
+
const ck = await visitAsync_("key", node.key, visitor, path22);
|
|
1803
1834
|
if (ck === BREAK)
|
|
1804
1835
|
return BREAK;
|
|
1805
1836
|
else if (ck === REMOVE)
|
|
1806
1837
|
node.key = null;
|
|
1807
|
-
const cv = await visitAsync_("value", node.value, visitor,
|
|
1838
|
+
const cv = await visitAsync_("value", node.value, visitor, path22);
|
|
1808
1839
|
if (cv === BREAK)
|
|
1809
1840
|
return BREAK;
|
|
1810
1841
|
else if (cv === REMOVE)
|
|
@@ -1831,23 +1862,23 @@ function initVisitor(visitor) {
|
|
|
1831
1862
|
}
|
|
1832
1863
|
return visitor;
|
|
1833
1864
|
}
|
|
1834
|
-
function callVisitor(key, node, visitor,
|
|
1865
|
+
function callVisitor(key, node, visitor, path22) {
|
|
1835
1866
|
if (typeof visitor === "function")
|
|
1836
|
-
return visitor(key, node,
|
|
1867
|
+
return visitor(key, node, path22);
|
|
1837
1868
|
if (isMap(node))
|
|
1838
|
-
return visitor.Map?.(key, node,
|
|
1869
|
+
return visitor.Map?.(key, node, path22);
|
|
1839
1870
|
if (isSeq(node))
|
|
1840
|
-
return visitor.Seq?.(key, node,
|
|
1871
|
+
return visitor.Seq?.(key, node, path22);
|
|
1841
1872
|
if (isPair(node))
|
|
1842
|
-
return visitor.Pair?.(key, node,
|
|
1873
|
+
return visitor.Pair?.(key, node, path22);
|
|
1843
1874
|
if (isScalar(node))
|
|
1844
|
-
return visitor.Scalar?.(key, node,
|
|
1875
|
+
return visitor.Scalar?.(key, node, path22);
|
|
1845
1876
|
if (isAlias(node))
|
|
1846
|
-
return visitor.Alias?.(key, node,
|
|
1877
|
+
return visitor.Alias?.(key, node, path22);
|
|
1847
1878
|
return void 0;
|
|
1848
1879
|
}
|
|
1849
|
-
function replaceNode(key,
|
|
1850
|
-
const parent =
|
|
1880
|
+
function replaceNode(key, path22, node) {
|
|
1881
|
+
const parent = path22[path22.length - 1];
|
|
1851
1882
|
if (isCollection(parent)) {
|
|
1852
1883
|
parent.items[key] = node;
|
|
1853
1884
|
} else if (isPair(parent)) {
|
|
@@ -2407,10 +2438,10 @@ var init_createNode = __esm({
|
|
|
2407
2438
|
});
|
|
2408
2439
|
|
|
2409
2440
|
// ../../node_modules/yaml/browser/dist/nodes/Collection.js
|
|
2410
|
-
function collectionFromPath(schema4,
|
|
2441
|
+
function collectionFromPath(schema4, path22, value) {
|
|
2411
2442
|
let v = value;
|
|
2412
|
-
for (let i =
|
|
2413
|
-
const k =
|
|
2443
|
+
for (let i = path22.length - 1; i >= 0; --i) {
|
|
2444
|
+
const k = path22[i];
|
|
2414
2445
|
if (typeof k === "number" && Number.isInteger(k) && k >= 0) {
|
|
2415
2446
|
const a = [];
|
|
2416
2447
|
a[k] = v;
|
|
@@ -2436,7 +2467,7 @@ var init_Collection = __esm({
|
|
|
2436
2467
|
init_createNode();
|
|
2437
2468
|
init_identity();
|
|
2438
2469
|
init_Node();
|
|
2439
|
-
isEmptyPath = (
|
|
2470
|
+
isEmptyPath = (path22) => path22 == null || typeof path22 === "object" && !!path22[Symbol.iterator]().next().done;
|
|
2440
2471
|
Collection = class extends NodeBase {
|
|
2441
2472
|
constructor(type, schema4) {
|
|
2442
2473
|
super(type);
|
|
@@ -2466,11 +2497,11 @@ var init_Collection = __esm({
|
|
|
2466
2497
|
* be a Pair instance or a `{ key, value }` object, which may not have a key
|
|
2467
2498
|
* that already exists in the map.
|
|
2468
2499
|
*/
|
|
2469
|
-
addIn(
|
|
2470
|
-
if (isEmptyPath(
|
|
2500
|
+
addIn(path22, value) {
|
|
2501
|
+
if (isEmptyPath(path22))
|
|
2471
2502
|
this.add(value);
|
|
2472
2503
|
else {
|
|
2473
|
-
const [key, ...rest] =
|
|
2504
|
+
const [key, ...rest] = path22;
|
|
2474
2505
|
const node = this.get(key, true);
|
|
2475
2506
|
if (isCollection(node))
|
|
2476
2507
|
node.addIn(rest, value);
|
|
@@ -2484,8 +2515,8 @@ var init_Collection = __esm({
|
|
|
2484
2515
|
* Removes a value from the collection.
|
|
2485
2516
|
* @returns `true` if the item was found and removed.
|
|
2486
2517
|
*/
|
|
2487
|
-
deleteIn(
|
|
2488
|
-
const [key, ...rest] =
|
|
2518
|
+
deleteIn(path22) {
|
|
2519
|
+
const [key, ...rest] = path22;
|
|
2489
2520
|
if (rest.length === 0)
|
|
2490
2521
|
return this.delete(key);
|
|
2491
2522
|
const node = this.get(key, true);
|
|
@@ -2499,8 +2530,8 @@ var init_Collection = __esm({
|
|
|
2499
2530
|
* scalar values from their surrounding node; to disable set `keepScalar` to
|
|
2500
2531
|
* `true` (collections are always returned intact).
|
|
2501
2532
|
*/
|
|
2502
|
-
getIn(
|
|
2503
|
-
const [key, ...rest] =
|
|
2533
|
+
getIn(path22, keepScalar) {
|
|
2534
|
+
const [key, ...rest] = path22;
|
|
2504
2535
|
const node = this.get(key, true);
|
|
2505
2536
|
if (rest.length === 0)
|
|
2506
2537
|
return !keepScalar && isScalar(node) ? node.value : node;
|
|
@@ -2518,8 +2549,8 @@ var init_Collection = __esm({
|
|
|
2518
2549
|
/**
|
|
2519
2550
|
* Checks if the collection includes a value with the key `key`.
|
|
2520
2551
|
*/
|
|
2521
|
-
hasIn(
|
|
2522
|
-
const [key, ...rest] =
|
|
2552
|
+
hasIn(path22) {
|
|
2553
|
+
const [key, ...rest] = path22;
|
|
2523
2554
|
if (rest.length === 0)
|
|
2524
2555
|
return this.has(key);
|
|
2525
2556
|
const node = this.get(key, true);
|
|
@@ -2529,8 +2560,8 @@ var init_Collection = __esm({
|
|
|
2529
2560
|
* Sets a value in this collection. For `!!set`, `value` needs to be a
|
|
2530
2561
|
* boolean to add/remove the item from the set.
|
|
2531
2562
|
*/
|
|
2532
|
-
setIn(
|
|
2533
|
-
const [key, ...rest] =
|
|
2563
|
+
setIn(path22, value) {
|
|
2564
|
+
const [key, ...rest] = path22;
|
|
2534
2565
|
if (rest.length === 0) {
|
|
2535
2566
|
this.set(key, value);
|
|
2536
2567
|
} else {
|
|
@@ -4503,15 +4534,15 @@ function visit2(cst, visitor) {
|
|
|
4503
4534
|
cst = { start: cst.start, value: cst.value };
|
|
4504
4535
|
_visit(Object.freeze([]), cst, visitor);
|
|
4505
4536
|
}
|
|
4506
|
-
function _visit(
|
|
4507
|
-
let ctrl = visitor(item,
|
|
4537
|
+
function _visit(path22, item, visitor) {
|
|
4538
|
+
let ctrl = visitor(item, path22);
|
|
4508
4539
|
if (typeof ctrl === "symbol")
|
|
4509
4540
|
return ctrl;
|
|
4510
4541
|
for (const field of ["key", "value"]) {
|
|
4511
4542
|
const token = item[field];
|
|
4512
4543
|
if (token && "items" in token) {
|
|
4513
4544
|
for (let i = 0; i < token.items.length; ++i) {
|
|
4514
|
-
const ci = _visit(Object.freeze(
|
|
4545
|
+
const ci = _visit(Object.freeze(path22.concat([[field, i]])), token.items[i], visitor);
|
|
4515
4546
|
if (typeof ci === "number")
|
|
4516
4547
|
i = ci - 1;
|
|
4517
4548
|
else if (ci === BREAK2)
|
|
@@ -4522,10 +4553,10 @@ function _visit(path21, item, visitor) {
|
|
|
4522
4553
|
}
|
|
4523
4554
|
}
|
|
4524
4555
|
if (typeof ctrl === "function" && field === "key")
|
|
4525
|
-
ctrl = ctrl(item,
|
|
4556
|
+
ctrl = ctrl(item, path22);
|
|
4526
4557
|
}
|
|
4527
4558
|
}
|
|
4528
|
-
return typeof ctrl === "function" ? ctrl(item,
|
|
4559
|
+
return typeof ctrl === "function" ? ctrl(item, path22) : ctrl;
|
|
4529
4560
|
}
|
|
4530
4561
|
var BREAK2, SKIP2, REMOVE2;
|
|
4531
4562
|
var init_cst_visit = __esm({
|
|
@@ -4537,9 +4568,9 @@ var init_cst_visit = __esm({
|
|
|
4537
4568
|
visit2.BREAK = BREAK2;
|
|
4538
4569
|
visit2.SKIP = SKIP2;
|
|
4539
4570
|
visit2.REMOVE = REMOVE2;
|
|
4540
|
-
visit2.itemAtPath = (cst,
|
|
4571
|
+
visit2.itemAtPath = (cst, path22) => {
|
|
4541
4572
|
let item = cst;
|
|
4542
|
-
for (const [field, index] of
|
|
4573
|
+
for (const [field, index] of path22) {
|
|
4543
4574
|
const tok = item?.[field];
|
|
4544
4575
|
if (tok && "items" in tok) {
|
|
4545
4576
|
item = tok.items[index];
|
|
@@ -4548,9 +4579,9 @@ var init_cst_visit = __esm({
|
|
|
4548
4579
|
}
|
|
4549
4580
|
return item;
|
|
4550
4581
|
};
|
|
4551
|
-
visit2.parentCollection = (cst,
|
|
4552
|
-
const parent = visit2.itemAtPath(cst,
|
|
4553
|
-
const field =
|
|
4582
|
+
visit2.parentCollection = (cst, path22) => {
|
|
4583
|
+
const parent = visit2.itemAtPath(cst, path22.slice(0, -1));
|
|
4584
|
+
const field = path22[path22.length - 1][0];
|
|
4554
4585
|
const coll = parent?.[field];
|
|
4555
4586
|
if (coll && "items" in coll)
|
|
4556
4587
|
return coll;
|
|
@@ -4720,8 +4751,8 @@ function metadataValue(value, key) {
|
|
|
4720
4751
|
if (!value || typeof value !== "object") return void 0;
|
|
4721
4752
|
return Object.getOwnPropertyDescriptor(value, key)?.value;
|
|
4722
4753
|
}
|
|
4723
|
-
function readProjectJson(
|
|
4724
|
-
const text2 = readProjectMetadata(
|
|
4754
|
+
function readProjectJson(path22, files = nodeRepoFileReader) {
|
|
4755
|
+
const text2 = readProjectMetadata(path22, files);
|
|
4725
4756
|
if (text2 === null) return null;
|
|
4726
4757
|
try {
|
|
4727
4758
|
const value = JSON.parse(text2);
|
|
@@ -4778,6 +4809,227 @@ var init_detect = __esm({
|
|
|
4778
4809
|
}
|
|
4779
4810
|
});
|
|
4780
4811
|
|
|
4812
|
+
// src/nativeViewSourceContract.ts
|
|
4813
|
+
function isNativeViewSource(value) {
|
|
4814
|
+
if (!isRecord(value)) return false;
|
|
4815
|
+
if (value.type === "placeholder")
|
|
4816
|
+
return (value.uri === void 0 || typeof value.uri === "string" && value.uri.length > 0) && (value.color === void 0 || typeof value.color === "string");
|
|
4817
|
+
if (value.type === "web") {
|
|
4818
|
+
if (typeof value.uri !== "string") return false;
|
|
4819
|
+
try {
|
|
4820
|
+
const url = new URL(value.uri);
|
|
4821
|
+
return url.protocol === "http:" || url.protocol === "https:";
|
|
4822
|
+
} catch {
|
|
4823
|
+
return false;
|
|
4824
|
+
}
|
|
4825
|
+
}
|
|
4826
|
+
return value.type === "video" && typeof value.uri === "string" && value.uri.length > 0 && ["paused", "loop", "muted"].every(
|
|
4827
|
+
(key) => value[key] === void 0 || typeof value[key] === "boolean"
|
|
4828
|
+
) && (value.currentTime === void 0 || typeof value.currentTime === "number" && Number.isFinite(value.currentTime) && value.currentTime >= 0) && (value.resizeMode === void 0 || value.resizeMode === "contain" || value.resizeMode === "cover" || value.resizeMode === "stretch");
|
|
4829
|
+
}
|
|
4830
|
+
var init_nativeViewSourceContract = __esm({
|
|
4831
|
+
"src/nativeViewSourceContract.ts"() {
|
|
4832
|
+
"use strict";
|
|
4833
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
4834
|
+
init_is_record();
|
|
4835
|
+
}
|
|
4836
|
+
});
|
|
4837
|
+
|
|
4838
|
+
// src/config.ts
|
|
4839
|
+
var config_exports = {};
|
|
4840
|
+
__export(config_exports, {
|
|
4841
|
+
PEACH_CONFIGURED_FILES_HOOK: () => PEACH_CONFIGURED_FILES_HOOK,
|
|
4842
|
+
PEACH_CONFIG_QUERY_PARAM: () => PEACH_CONFIG_QUERY_PARAM,
|
|
4843
|
+
applyPeachConfigToUrl: () => applyPeachConfigToUrl,
|
|
4844
|
+
collectConfiguredFileModules: () => collectConfiguredFileModules,
|
|
4845
|
+
createPeachBundleConfigFooter: () => createPeachBundleConfigFooter,
|
|
4846
|
+
defineConfig: () => defineConfig,
|
|
4847
|
+
detachPeachBundleConfigFooter: () => detachPeachBundleConfigFooter,
|
|
4848
|
+
hasPeachConfig: () => hasPeachConfig,
|
|
4849
|
+
isPackageStubs: () => isPackageStubs,
|
|
4850
|
+
isPeachConfig: () => isPeachConfig,
|
|
4851
|
+
mergePeachConfig: () => mergePeachConfig,
|
|
4852
|
+
readNativeRenderer: () => readNativeRenderer,
|
|
4853
|
+
readPeachBundleConfig: () => readPeachBundleConfig,
|
|
4854
|
+
readPeachBundleConfigFooter: () => readPeachBundleConfigFooter,
|
|
4855
|
+
readPeachConfigFromSearchParams: () => readPeachConfigFromSearchParams
|
|
4856
|
+
});
|
|
4857
|
+
function readNativeRenderer(value) {
|
|
4858
|
+
if (value === void 0) return void 0;
|
|
4859
|
+
if (value === "paper" || value === "fabric") return value;
|
|
4860
|
+
throw new Error("nativeRenderer must be paper or fabric");
|
|
4861
|
+
}
|
|
4862
|
+
function isHybridObjectAnswer(answer) {
|
|
4863
|
+
return answer === "unsupported" || isRecord(answer) && typeof answer.file === "string" && answer.file.length > 0;
|
|
4864
|
+
}
|
|
4865
|
+
function isHybridObjects(value) {
|
|
4866
|
+
return isRecord(value) && Object.entries(value).every(
|
|
4867
|
+
([name2, answer]) => name2.length > 0 && isHybridObjectAnswer(answer)
|
|
4868
|
+
);
|
|
4869
|
+
}
|
|
4870
|
+
function isPackageHybridObjects(value) {
|
|
4871
|
+
return isRecord(value) && Object.entries(value).every(
|
|
4872
|
+
([name2, answer]) => name2.length > 0 && typeof answer === "string" && answer.length > 0 && answer !== "noop"
|
|
4873
|
+
);
|
|
4874
|
+
}
|
|
4875
|
+
function isPackageStubs(value) {
|
|
4876
|
+
if (value === "noop") return true;
|
|
4877
|
+
if (!isRecord(value)) return false;
|
|
4878
|
+
return (value.modules === void 0 || isRecord(value.modules) && Object.values(value.modules).every(
|
|
4879
|
+
(stub) => typeof stub === "string" && stub.length > 0
|
|
4880
|
+
)) && (value.views === void 0 || isRecord(value.views) && Object.values(value.views).every(
|
|
4881
|
+
(stub) => typeof stub === "string" && stub.length > 0 || isNativeViewSource(stub)
|
|
4882
|
+
)) && (value.hybridObjects === void 0 || isPackageHybridObjects(value.hybridObjects));
|
|
4883
|
+
}
|
|
4884
|
+
function collectConfiguredFileModules(config) {
|
|
4885
|
+
return [
|
|
4886
|
+
...new Set(
|
|
4887
|
+
[
|
|
4888
|
+
"modules",
|
|
4889
|
+
"turboModules",
|
|
4890
|
+
"nativeModules",
|
|
4891
|
+
"nativeViews",
|
|
4892
|
+
"nativeHybridObjects"
|
|
4893
|
+
].flatMap((key) => {
|
|
4894
|
+
const entries = config && Reflect.get(config, key);
|
|
4895
|
+
if (!isRecord(entries)) return [];
|
|
4896
|
+
return Object.values(entries).flatMap(
|
|
4897
|
+
(entry) => isRecord(entry) && typeof entry.file === "string" ? [entry.file] : []
|
|
4898
|
+
);
|
|
4899
|
+
})
|
|
4900
|
+
)
|
|
4901
|
+
];
|
|
4902
|
+
}
|
|
4903
|
+
function isPeachConfig(value) {
|
|
4904
|
+
if (!isRecord(value)) return false;
|
|
4905
|
+
return (value.nativeRenderer === void 0 || value.nativeRenderer === "paper" || value.nativeRenderer === "fabric") && (value.mapKit === void 0 || isRecord(value.mapKit) && typeof value.mapKit.token === "string" && value.mapKit.token.length > 0 && value.mapKit.token === value.mapKit.token.trim()) && (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
|
|
4906
|
+
"modules",
|
|
4907
|
+
"packages",
|
|
4908
|
+
"turboModules",
|
|
4909
|
+
"nativeModules",
|
|
4910
|
+
"nativeViews",
|
|
4911
|
+
"nativeHybridObjects",
|
|
4912
|
+
"env",
|
|
4913
|
+
"network",
|
|
4914
|
+
"settings",
|
|
4915
|
+
"initialProps",
|
|
4916
|
+
"initialState"
|
|
4917
|
+
].every((key) => value[key] === void 0 || isRecord(value[key])) && (value.packages === void 0 || isRecord(value.packages) && Object.values(value.packages).every(isPackageStubs)) && (value.nativeHybridObjects === void 0 || isHybridObjects(value.nativeHybridObjects)) && (value.nativeViews === void 0 || isRecord(value.nativeViews) && Object.values(value.nativeViews).every(
|
|
4918
|
+
(entry) => entry === "noop" || isNativeViewSource(entry) || isRecord(entry) && typeof entry.file === "string" && entry.file.length > 0
|
|
4919
|
+
));
|
|
4920
|
+
}
|
|
4921
|
+
function readPeachBundleConfig(value) {
|
|
4922
|
+
if (value === void 0 || value === null) return null;
|
|
4923
|
+
if (!isRecord(value) || !isPeachConfig(value.config) || !Array.isArray(value.runtimePackages) || !value.runtimePackages.every((name2) => typeof name2 === "string")) {
|
|
4924
|
+
throw new Error("configured bundle metadata is malformed");
|
|
4925
|
+
}
|
|
4926
|
+
return { config: value.config, runtimePackages: [...value.runtimePackages] };
|
|
4927
|
+
}
|
|
4928
|
+
function readPeachBundleConfigFooter(source) {
|
|
4929
|
+
const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
|
|
4930
|
+
if (start < 0) return null;
|
|
4931
|
+
const end = source.indexOf("\n", start + 1);
|
|
4932
|
+
const line = source.slice(start + 1, end < 0 ? void 0 : end);
|
|
4933
|
+
if (!line.endsWith(";")) throw new Error("configured bundle footer is truncated");
|
|
4934
|
+
const result = readPeachBundleConfig(
|
|
4935
|
+
JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1))
|
|
4936
|
+
);
|
|
4937
|
+
if (!result) throw new Error("configured bundle footer is empty");
|
|
4938
|
+
return result;
|
|
4939
|
+
}
|
|
4940
|
+
function createPeachBundleConfigFooter(config) {
|
|
4941
|
+
const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
|
|
4942
|
+
return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
|
|
4943
|
+
}
|
|
4944
|
+
function detachPeachBundleConfigFooter(source) {
|
|
4945
|
+
const configuredBundle = readPeachBundleConfigFooter(source);
|
|
4946
|
+
if (!configuredBundle) return { source, configuredBundle };
|
|
4947
|
+
const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
|
|
4948
|
+
const end = source.indexOf("\n", start + 1);
|
|
4949
|
+
return {
|
|
4950
|
+
source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
|
|
4951
|
+
configuredBundle
|
|
4952
|
+
};
|
|
4953
|
+
}
|
|
4954
|
+
function defineConfig(config) {
|
|
4955
|
+
return config;
|
|
4956
|
+
}
|
|
4957
|
+
function hasOwnKeys(value) {
|
|
4958
|
+
return !!value && Object.keys(value).length > 0;
|
|
4959
|
+
}
|
|
4960
|
+
function hasPeachConfig(config) {
|
|
4961
|
+
if (!config) return false;
|
|
4962
|
+
return config.nativeRenderer !== void 0 || config.mapKit !== void 0 || typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.nativeHybridObjects) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialProps) || hasOwnKeys(config.initialState);
|
|
4963
|
+
}
|
|
4964
|
+
function mergePeachConfig(base, override) {
|
|
4965
|
+
if (!hasPeachConfig(base) && !hasPeachConfig(override)) return void 0;
|
|
4966
|
+
if (!hasPeachConfig(base)) return override ? { ...override } : void 0;
|
|
4967
|
+
if (!hasPeachConfig(override)) return base ? { ...base } : void 0;
|
|
4968
|
+
return {
|
|
4969
|
+
runtimeVersion: override.runtimeVersion ?? base.runtimeVersion,
|
|
4970
|
+
nativeRenderer: override.nativeRenderer ?? base.nativeRenderer,
|
|
4971
|
+
mapKit: override.mapKit ?? base.mapKit,
|
|
4972
|
+
modules: { ...base.modules || {}, ...override.modules || {} },
|
|
4973
|
+
turboModules: { ...base.turboModules || {}, ...override.turboModules || {} },
|
|
4974
|
+
nativeModules: {
|
|
4975
|
+
...base.nativeModules || {},
|
|
4976
|
+
...override.nativeModules || {}
|
|
4977
|
+
},
|
|
4978
|
+
nativeViews: { ...base.nativeViews || {}, ...override.nativeViews || {} },
|
|
4979
|
+
nativeHybridObjects: {
|
|
4980
|
+
...base.nativeHybridObjects || {},
|
|
4981
|
+
...override.nativeHybridObjects || {}
|
|
4982
|
+
},
|
|
4983
|
+
env: { ...base.env || {}, ...override.env || {} },
|
|
4984
|
+
network: {
|
|
4985
|
+
remap: { ...base.network?.remap || {}, ...override.network?.remap || {} }
|
|
4986
|
+
},
|
|
4987
|
+
settings: {
|
|
4988
|
+
...base.settings || {},
|
|
4989
|
+
...override.settings || {}
|
|
4990
|
+
},
|
|
4991
|
+
initialProps: { ...base.initialProps || {}, ...override.initialProps || {} },
|
|
4992
|
+
initialState: { ...base.initialState || {}, ...override.initialState || {} }
|
|
4993
|
+
};
|
|
4994
|
+
}
|
|
4995
|
+
function readPeachConfigFromSearchParams(searchParams) {
|
|
4996
|
+
const raw = searchParams.get(PEACH_CONFIG_QUERY_PARAM);
|
|
4997
|
+
if (!raw) return void 0;
|
|
4998
|
+
let parsed;
|
|
4999
|
+
try {
|
|
5000
|
+
parsed = JSON.parse(raw);
|
|
5001
|
+
} catch (error) {
|
|
5002
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5003
|
+
console.warn(`[peach] invalid ${PEACH_CONFIG_QUERY_PARAM}: ${message}`);
|
|
5004
|
+
return void 0;
|
|
5005
|
+
}
|
|
5006
|
+
if (isRecord(parsed)) readNativeRenderer(parsed.nativeRenderer);
|
|
5007
|
+
return isPeachConfig(parsed) && hasPeachConfig(parsed) ? parsed : void 0;
|
|
5008
|
+
}
|
|
5009
|
+
function applyPeachConfigToUrl(url, config) {
|
|
5010
|
+
const parsed = new URL(url);
|
|
5011
|
+
if (hasPeachConfig(config)) {
|
|
5012
|
+
parsed.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
|
|
5013
|
+
} else {
|
|
5014
|
+
parsed.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
|
|
5015
|
+
}
|
|
5016
|
+
return parsed.toString();
|
|
5017
|
+
}
|
|
5018
|
+
var PEACH_CONFIG_QUERY_PARAM, BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
|
|
5019
|
+
var init_config = __esm({
|
|
5020
|
+
"src/config.ts"() {
|
|
5021
|
+
"use strict";
|
|
5022
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5023
|
+
init_version();
|
|
5024
|
+
init_bundleGlobalFooter();
|
|
5025
|
+
init_is_record();
|
|
5026
|
+
init_nativeViewSourceContract();
|
|
5027
|
+
PEACH_CONFIG_QUERY_PARAM = "peachConfig";
|
|
5028
|
+
BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
|
|
5029
|
+
PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
|
|
5030
|
+
}
|
|
5031
|
+
});
|
|
5032
|
+
|
|
4781
5033
|
// ../contrast-bundler/src/posixPath.ts
|
|
4782
5034
|
function isAbsolute(p) {
|
|
4783
5035
|
return p.charCodeAt(0) === 47;
|
|
@@ -4808,12 +5060,12 @@ function normalize(p) {
|
|
|
4808
5060
|
if (trailingSlash) joined += "/";
|
|
4809
5061
|
return absolute ? "/" + joined : joined;
|
|
4810
5062
|
}
|
|
4811
|
-
function
|
|
5063
|
+
function join5(...parts) {
|
|
4812
5064
|
const present = parts.filter((part) => part.length > 0);
|
|
4813
5065
|
if (present.length === 0) return ".";
|
|
4814
5066
|
return normalize(present.join("/"));
|
|
4815
5067
|
}
|
|
4816
|
-
function
|
|
5068
|
+
function resolve3(...parts) {
|
|
4817
5069
|
let resolved = "";
|
|
4818
5070
|
let absolute = false;
|
|
4819
5071
|
for (let i = parts.length - 1; i >= 0 && !absolute; i--) {
|
|
@@ -4872,8 +5124,8 @@ var init_posixPath = __esm({
|
|
|
4872
5124
|
delimiter,
|
|
4873
5125
|
isAbsolute,
|
|
4874
5126
|
normalize,
|
|
4875
|
-
join:
|
|
4876
|
-
resolve:
|
|
5127
|
+
join: join5,
|
|
5128
|
+
resolve: resolve3,
|
|
4877
5129
|
dirname: dirname4,
|
|
4878
5130
|
basename: basename3,
|
|
4879
5131
|
extname,
|
|
@@ -5115,16 +5367,16 @@ function sendJavaScript(req, res, source) {
|
|
|
5115
5367
|
res.end(req.method === "HEAD" ? void 0 : source);
|
|
5116
5368
|
}
|
|
5117
5369
|
function resolveReplacementModuleFile(fromFile, specifier) {
|
|
5118
|
-
const base =
|
|
5370
|
+
const base = import_node_path9.default.resolve(import_node_path9.default.dirname(fromFile), specifier);
|
|
5119
5371
|
const candidates = [
|
|
5120
5372
|
...REPLACEMENT_MODULE_EXTENSIONS.some(
|
|
5121
|
-
(ext) => ext ===
|
|
5373
|
+
(ext) => ext === import_node_path9.default.extname(base).toLowerCase()
|
|
5122
5374
|
) ? [base] : [],
|
|
5123
5375
|
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => base + ext),
|
|
5124
|
-
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) =>
|
|
5376
|
+
...REPLACEMENT_MODULE_EXTENSIONS.map((ext) => import_node_path9.default.join(base, `index${ext}`))
|
|
5125
5377
|
];
|
|
5126
5378
|
const found = candidates.find(
|
|
5127
|
-
(candidate) => (0,
|
|
5379
|
+
(candidate) => (0, import_node_fs10.statSync)(candidate, { throwIfNoEntry: false })?.isFile()
|
|
5128
5380
|
);
|
|
5129
5381
|
if (!found) {
|
|
5130
5382
|
throw new Error(
|
|
@@ -5135,8 +5387,8 @@ function resolveReplacementModuleFile(fromFile, specifier) {
|
|
|
5135
5387
|
}
|
|
5136
5388
|
function isInsideAny(roots, file) {
|
|
5137
5389
|
return roots.some((root) => {
|
|
5138
|
-
const relative3 =
|
|
5139
|
-
return !relative3.startsWith("..") && !
|
|
5390
|
+
const relative3 = import_node_path9.default.relative(root, file);
|
|
5391
|
+
return !relative3.startsWith("..") && !import_node_path9.default.isAbsolute(relative3);
|
|
5140
5392
|
});
|
|
5141
5393
|
}
|
|
5142
5394
|
function isReplacementModuleRequestUrl(rawUrl) {
|
|
@@ -5185,19 +5437,19 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
5185
5437
|
res.end("missing path param");
|
|
5186
5438
|
return true;
|
|
5187
5439
|
}
|
|
5188
|
-
const extension =
|
|
5440
|
+
const extension = import_node_path9.default.extname(targetPath).toLowerCase();
|
|
5189
5441
|
if (!REPLACEMENT_MODULE_EXTENSIONS.some((allowed) => allowed === extension)) {
|
|
5190
5442
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
5191
5443
|
res.end(`replacement files must be ${REPLACEMENT_MODULE_EXTENSIONS.join(", ")}`);
|
|
5192
5444
|
return true;
|
|
5193
5445
|
}
|
|
5194
|
-
if (!
|
|
5446
|
+
if (!import_node_path9.default.isAbsolute(targetPath)) {
|
|
5195
5447
|
res.writeHead(400, { "Content-Type": "text/plain; charset=utf-8" });
|
|
5196
5448
|
res.end("replacement file path must be absolute");
|
|
5197
5449
|
return true;
|
|
5198
5450
|
}
|
|
5199
5451
|
const runtimePackages = new Set(url.searchParams.getAll("runtimePackage"));
|
|
5200
|
-
const servedRoots = options.servedRoots?.map((root) =>
|
|
5452
|
+
const servedRoots = options.servedRoots?.map((root) => import_node_path9.default.resolve(root));
|
|
5201
5453
|
if (servedRoots && !isInsideAny(servedRoots, targetPath)) {
|
|
5202
5454
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
5203
5455
|
res.end("replacement file must be inside a folder the bundler serves");
|
|
@@ -5205,7 +5457,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
5205
5457
|
}
|
|
5206
5458
|
let resolvedTargetPath;
|
|
5207
5459
|
try {
|
|
5208
|
-
resolvedTargetPath = await
|
|
5460
|
+
resolvedTargetPath = await import_promises4.default.realpath(targetPath);
|
|
5209
5461
|
} catch (error) {
|
|
5210
5462
|
const message = error instanceof Error ? error.message : String(error);
|
|
5211
5463
|
res.writeHead(404, { "Content-Type": "text/plain; charset=utf-8" });
|
|
@@ -5213,7 +5465,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
5213
5465
|
return true;
|
|
5214
5466
|
}
|
|
5215
5467
|
if (servedRoots) {
|
|
5216
|
-
const realRoots = (await Promise.all(servedRoots.map((root) =>
|
|
5468
|
+
const realRoots = (await Promise.all(servedRoots.map((root) => import_promises4.default.realpath(root).catch(() => null)))).filter((root) => root !== null);
|
|
5217
5469
|
if (!isInsideAny(realRoots, resolvedTargetPath)) {
|
|
5218
5470
|
res.writeHead(403, { "Content-Type": "text/plain; charset=utf-8" });
|
|
5219
5471
|
res.end("replacement file must be inside a folder the bundler serves");
|
|
@@ -5223,7 +5475,7 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
5223
5475
|
try {
|
|
5224
5476
|
const compiled = compileReplacementModule({
|
|
5225
5477
|
filePath: resolvedTargetPath,
|
|
5226
|
-
source: await
|
|
5478
|
+
source: await import_promises4.default.readFile(resolvedTargetPath, "utf8"),
|
|
5227
5479
|
runtimePackages,
|
|
5228
5480
|
// the imported file's url is this request's with only its path changed,
|
|
5229
5481
|
// so the token, cache key and runtime packages carry over.
|
|
@@ -5249,14 +5501,14 @@ async function handleReplacementModuleRequest(req, res, options = {}) {
|
|
|
5249
5501
|
}
|
|
5250
5502
|
return true;
|
|
5251
5503
|
}
|
|
5252
|
-
var
|
|
5504
|
+
var import_node_fs10, import_promises4, import_node_path9, REPLACEMENT_MODULE_ROUTE;
|
|
5253
5505
|
var init_replacement_module_handler = __esm({
|
|
5254
5506
|
"src/host/replacement-module-handler.ts"() {
|
|
5255
5507
|
"use strict";
|
|
5256
5508
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5257
|
-
|
|
5258
|
-
|
|
5259
|
-
|
|
5509
|
+
import_node_fs10 = require("node:fs");
|
|
5510
|
+
import_promises4 = __toESM(require("node:fs/promises"), 1);
|
|
5511
|
+
import_node_path9 = __toESM(require("node:path"), 1);
|
|
5260
5512
|
init_replacementModule();
|
|
5261
5513
|
init_backend_origin();
|
|
5262
5514
|
REPLACEMENT_MODULE_ROUTE = "/__sootsim-replacement-module";
|
|
@@ -5265,25 +5517,25 @@ var init_replacement_module_handler = __esm({
|
|
|
5265
5517
|
|
|
5266
5518
|
// src/swift-source-file.ts
|
|
5267
5519
|
function readPackageFile(root, file, maxBytes) {
|
|
5268
|
-
const canonicalRoot =
|
|
5269
|
-
const relative3 =
|
|
5270
|
-
if (relative3 === ".." || relative3.startsWith(`..${
|
|
5520
|
+
const canonicalRoot = import_node_fs11.default.realpathSync(root);
|
|
5521
|
+
const relative3 = import_node_path10.default.relative(canonicalRoot, import_node_fs11.default.realpathSync(file));
|
|
5522
|
+
if (relative3 === ".." || relative3.startsWith(`..${import_node_path10.default.sep}`) || import_node_path10.default.isAbsolute(relative3)) {
|
|
5271
5523
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
5272
5524
|
}
|
|
5273
|
-
let ancestor =
|
|
5525
|
+
let ancestor = import_node_path10.default.resolve(file);
|
|
5274
5526
|
while (ancestor !== canonicalRoot) {
|
|
5275
|
-
if (
|
|
5527
|
+
if (import_node_fs11.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
5276
5528
|
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
5277
5529
|
}
|
|
5278
|
-
const parent =
|
|
5530
|
+
const parent = import_node_path10.default.dirname(ancestor);
|
|
5279
5531
|
if (parent === ancestor)
|
|
5280
5532
|
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
5281
5533
|
ancestor = parent;
|
|
5282
5534
|
}
|
|
5283
|
-
const expected =
|
|
5284
|
-
const fd =
|
|
5535
|
+
const expected = import_node_fs11.default.statSync(file);
|
|
5536
|
+
const fd = import_node_fs11.default.openSync(file, import_node_fs11.default.constants.O_RDONLY | import_node_fs11.default.constants.O_NOFOLLOW);
|
|
5285
5537
|
try {
|
|
5286
|
-
const stat =
|
|
5538
|
+
const stat = import_node_fs11.default.fstatSync(fd);
|
|
5287
5539
|
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
5288
5540
|
throw new Error(`swift input changed while opening: ${file}`);
|
|
5289
5541
|
}
|
|
@@ -5293,25 +5545,25 @@ function readPackageFile(root, file, maxBytes) {
|
|
|
5293
5545
|
const bytes = Buffer.alloc(stat.size + 1);
|
|
5294
5546
|
let offset = 0;
|
|
5295
5547
|
while (offset < bytes.length) {
|
|
5296
|
-
const count =
|
|
5548
|
+
const count = import_node_fs11.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
5297
5549
|
if (count === 0) break;
|
|
5298
5550
|
offset += count;
|
|
5299
5551
|
}
|
|
5300
|
-
if (offset !== stat.size ||
|
|
5552
|
+
if (offset !== stat.size || import_node_fs11.default.fstatSync(fd).size !== stat.size) {
|
|
5301
5553
|
throw new Error(`swift input changed while reading: ${file}`);
|
|
5302
5554
|
}
|
|
5303
5555
|
return bytes.subarray(0, offset);
|
|
5304
5556
|
} finally {
|
|
5305
|
-
|
|
5557
|
+
import_node_fs11.default.closeSync(fd);
|
|
5306
5558
|
}
|
|
5307
5559
|
}
|
|
5308
|
-
var
|
|
5560
|
+
var import_node_fs11, import_node_path10;
|
|
5309
5561
|
var init_swift_source_file = __esm({
|
|
5310
5562
|
"src/swift-source-file.ts"() {
|
|
5311
5563
|
"use strict";
|
|
5312
5564
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5313
|
-
|
|
5314
|
-
|
|
5565
|
+
import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
5566
|
+
import_node_path10 = __toESM(require("node:path"), 1);
|
|
5315
5567
|
}
|
|
5316
5568
|
});
|
|
5317
5569
|
|
|
@@ -5357,9 +5609,9 @@ var init_swift_submit = __esm({
|
|
|
5357
5609
|
// cli/app-project.ts
|
|
5358
5610
|
function firstNamedFile(dir, names) {
|
|
5359
5611
|
for (const name2 of names) {
|
|
5360
|
-
const candidate =
|
|
5612
|
+
const candidate = import_node_path12.default.join(dir, name2);
|
|
5361
5613
|
try {
|
|
5362
|
-
if (
|
|
5614
|
+
if (import_node_fs13.default.statSync(candidate).isFile()) return candidate;
|
|
5363
5615
|
} catch {
|
|
5364
5616
|
}
|
|
5365
5617
|
}
|
|
@@ -5372,25 +5624,25 @@ function findRNXAppConfig(dir) {
|
|
|
5372
5624
|
return firstNamedFile(dir, PEACH_APP_CONFIG_NAMES);
|
|
5373
5625
|
}
|
|
5374
5626
|
function resolveAppProject(projectRoot) {
|
|
5375
|
-
const appDir =
|
|
5627
|
+
const appDir = import_node_path12.default.resolve(projectRoot);
|
|
5376
5628
|
try {
|
|
5377
|
-
if (!
|
|
5629
|
+
if (!import_node_fs13.default.statSync(appDir).isDirectory()) return null;
|
|
5378
5630
|
} catch {
|
|
5379
5631
|
return null;
|
|
5380
5632
|
}
|
|
5381
5633
|
const configPath = findRNXAppConfig(appDir);
|
|
5382
|
-
if (!configPath && !findExpoAppConfig(appDir) && !
|
|
5634
|
+
if (!configPath && !findExpoAppConfig(appDir) && !import_node_fs13.default.existsSync(import_node_path12.default.join(appDir, "package.json"))) {
|
|
5383
5635
|
return null;
|
|
5384
5636
|
}
|
|
5385
5637
|
return { appDir, configPath };
|
|
5386
5638
|
}
|
|
5387
|
-
var
|
|
5639
|
+
var import_node_fs13, import_node_path12, EXPO_APP_CONFIG_NAMES, PEACH_APP_CONFIG_NAMES;
|
|
5388
5640
|
var init_app_project = __esm({
|
|
5389
5641
|
"cli/app-project.ts"() {
|
|
5390
5642
|
"use strict";
|
|
5391
5643
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5392
|
-
|
|
5393
|
-
|
|
5644
|
+
import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
5645
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
5394
5646
|
EXPO_APP_CONFIG_NAMES = [
|
|
5395
5647
|
"app.config.js",
|
|
5396
5648
|
"app.config.ts",
|
|
@@ -5407,248 +5659,27 @@ var init_app_project = __esm({
|
|
|
5407
5659
|
}
|
|
5408
5660
|
});
|
|
5409
5661
|
|
|
5410
|
-
// src/
|
|
5411
|
-
function
|
|
5412
|
-
|
|
5413
|
-
if (value.type === "placeholder")
|
|
5414
|
-
return (value.uri === void 0 || typeof value.uri === "string" && value.uri.length > 0) && (value.color === void 0 || typeof value.color === "string");
|
|
5415
|
-
if (value.type === "web") {
|
|
5416
|
-
if (typeof value.uri !== "string") return false;
|
|
5417
|
-
try {
|
|
5418
|
-
const url = new URL(value.uri);
|
|
5419
|
-
return url.protocol === "http:" || url.protocol === "https:";
|
|
5420
|
-
} catch {
|
|
5421
|
-
return false;
|
|
5422
|
-
}
|
|
5423
|
-
}
|
|
5424
|
-
return value.type === "video" && typeof value.uri === "string" && value.uri.length > 0 && ["paused", "loop", "muted"].every(
|
|
5425
|
-
(key) => value[key] === void 0 || typeof value[key] === "boolean"
|
|
5426
|
-
) && (value.currentTime === void 0 || typeof value.currentTime === "number" && Number.isFinite(value.currentTime) && value.currentTime >= 0) && (value.resizeMode === void 0 || value.resizeMode === "contain" || value.resizeMode === "cover" || value.resizeMode === "stretch");
|
|
5427
|
-
}
|
|
5428
|
-
var init_nativeViewSourceContract = __esm({
|
|
5429
|
-
"src/nativeViewSourceContract.ts"() {
|
|
5430
|
-
"use strict";
|
|
5431
|
-
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5432
|
-
init_is_record();
|
|
5433
|
-
}
|
|
5434
|
-
});
|
|
5435
|
-
|
|
5436
|
-
// src/config.ts
|
|
5437
|
-
var config_exports = {};
|
|
5438
|
-
__export(config_exports, {
|
|
5439
|
-
PEACH_CONFIGURED_FILES_HOOK: () => PEACH_CONFIGURED_FILES_HOOK,
|
|
5440
|
-
PEACH_CONFIG_QUERY_PARAM: () => PEACH_CONFIG_QUERY_PARAM,
|
|
5441
|
-
applyPeachConfigToUrl: () => applyPeachConfigToUrl,
|
|
5442
|
-
collectConfiguredFileModules: () => collectConfiguredFileModules,
|
|
5443
|
-
createPeachBundleConfigFooter: () => createPeachBundleConfigFooter,
|
|
5444
|
-
defineConfig: () => defineConfig,
|
|
5445
|
-
detachPeachBundleConfigFooter: () => detachPeachBundleConfigFooter,
|
|
5446
|
-
hasPeachConfig: () => hasPeachConfig,
|
|
5447
|
-
isPackageStubs: () => isPackageStubs,
|
|
5448
|
-
isPeachConfig: () => isPeachConfig,
|
|
5449
|
-
mergePeachConfig: () => mergePeachConfig,
|
|
5450
|
-
readNativeRenderer: () => readNativeRenderer,
|
|
5451
|
-
readPeachBundleConfig: () => readPeachBundleConfig,
|
|
5452
|
-
readPeachBundleConfigFooter: () => readPeachBundleConfigFooter,
|
|
5453
|
-
readPeachConfigFromSearchParams: () => readPeachConfigFromSearchParams
|
|
5454
|
-
});
|
|
5455
|
-
function readNativeRenderer(value) {
|
|
5456
|
-
if (value === void 0) return void 0;
|
|
5457
|
-
if (value === "paper" || value === "fabric") return value;
|
|
5458
|
-
throw new Error("nativeRenderer must be paper or fabric");
|
|
5459
|
-
}
|
|
5460
|
-
function isHybridObjectAnswer(answer) {
|
|
5461
|
-
return answer === "unsupported" || isRecord(answer) && typeof answer.file === "string" && answer.file.length > 0;
|
|
5462
|
-
}
|
|
5463
|
-
function isHybridObjects(value) {
|
|
5464
|
-
return isRecord(value) && Object.entries(value).every(
|
|
5465
|
-
([name2, answer]) => name2.length > 0 && isHybridObjectAnswer(answer)
|
|
5466
|
-
);
|
|
5467
|
-
}
|
|
5468
|
-
function isPackageHybridObjects(value) {
|
|
5469
|
-
return isRecord(value) && Object.entries(value).every(
|
|
5470
|
-
([name2, answer]) => name2.length > 0 && typeof answer === "string" && answer.length > 0 && answer !== "noop"
|
|
5471
|
-
);
|
|
5472
|
-
}
|
|
5473
|
-
function isPackageStubs(value) {
|
|
5474
|
-
if (value === "noop") return true;
|
|
5475
|
-
if (!isRecord(value)) return false;
|
|
5476
|
-
return (value.modules === void 0 || isRecord(value.modules) && Object.values(value.modules).every(
|
|
5477
|
-
(stub) => typeof stub === "string" && stub.length > 0
|
|
5478
|
-
)) && (value.views === void 0 || isRecord(value.views) && Object.values(value.views).every(
|
|
5479
|
-
(stub) => typeof stub === "string" && stub.length > 0 || isNativeViewSource(stub)
|
|
5480
|
-
)) && (value.hybridObjects === void 0 || isPackageHybridObjects(value.hybridObjects));
|
|
5481
|
-
}
|
|
5482
|
-
function collectConfiguredFileModules(config) {
|
|
5483
|
-
return [
|
|
5484
|
-
...new Set(
|
|
5485
|
-
[
|
|
5486
|
-
"modules",
|
|
5487
|
-
"turboModules",
|
|
5488
|
-
"nativeModules",
|
|
5489
|
-
"nativeViews",
|
|
5490
|
-
"nativeHybridObjects"
|
|
5491
|
-
].flatMap((key) => {
|
|
5492
|
-
const entries = config && Reflect.get(config, key);
|
|
5493
|
-
if (!isRecord(entries)) return [];
|
|
5494
|
-
return Object.values(entries).flatMap(
|
|
5495
|
-
(entry) => isRecord(entry) && typeof entry.file === "string" ? [entry.file] : []
|
|
5496
|
-
);
|
|
5497
|
-
})
|
|
5498
|
-
)
|
|
5499
|
-
];
|
|
5500
|
-
}
|
|
5501
|
-
function isPeachConfig(value) {
|
|
5502
|
-
if (!isRecord(value)) return false;
|
|
5503
|
-
return (value.nativeRenderer === void 0 || value.nativeRenderer === "paper" || value.nativeRenderer === "fabric") && (value.mapKit === void 0 || isRecord(value.mapKit) && typeof value.mapKit.token === "string" && value.mapKit.token.length > 0 && value.mapKit.token === value.mapKit.token.trim()) && (value.runtimeVersion === void 0 || typeof value.runtimeVersion === "string" && value.runtimeVersion === value.runtimeVersion.trim() && isValidRuntimeVersion(value.runtimeVersion)) && [
|
|
5504
|
-
"modules",
|
|
5505
|
-
"packages",
|
|
5506
|
-
"turboModules",
|
|
5507
|
-
"nativeModules",
|
|
5508
|
-
"nativeViews",
|
|
5509
|
-
"nativeHybridObjects",
|
|
5510
|
-
"env",
|
|
5511
|
-
"network",
|
|
5512
|
-
"settings",
|
|
5513
|
-
"initialProps",
|
|
5514
|
-
"initialState"
|
|
5515
|
-
].every((key) => value[key] === void 0 || isRecord(value[key])) && (value.packages === void 0 || isRecord(value.packages) && Object.values(value.packages).every(isPackageStubs)) && (value.nativeHybridObjects === void 0 || isHybridObjects(value.nativeHybridObjects)) && (value.nativeViews === void 0 || isRecord(value.nativeViews) && Object.values(value.nativeViews).every(
|
|
5516
|
-
(entry) => entry === "noop" || isNativeViewSource(entry) || isRecord(entry) && typeof entry.file === "string" && entry.file.length > 0
|
|
5517
|
-
));
|
|
5518
|
-
}
|
|
5519
|
-
function readPeachBundleConfig(value) {
|
|
5520
|
-
if (value === void 0 || value === null) return null;
|
|
5521
|
-
if (!isRecord(value) || !isPeachConfig(value.config) || !Array.isArray(value.runtimePackages) || !value.runtimePackages.every((name2) => typeof name2 === "string")) {
|
|
5522
|
-
throw new Error("configured bundle metadata is malformed");
|
|
5523
|
-
}
|
|
5524
|
-
return { config: value.config, runtimePackages: [...value.runtimePackages] };
|
|
5525
|
-
}
|
|
5526
|
-
function readPeachBundleConfigFooter(source) {
|
|
5527
|
-
const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
|
|
5528
|
-
if (start < 0) return null;
|
|
5529
|
-
const end = source.indexOf("\n", start + 1);
|
|
5530
|
-
const line = source.slice(start + 1, end < 0 ? void 0 : end);
|
|
5531
|
-
if (!line.endsWith(";")) throw new Error("configured bundle footer is truncated");
|
|
5532
|
-
const result = readPeachBundleConfig(
|
|
5533
|
-
JSON.parse(line.slice(BUNDLE_CONFIG_PREFIX.length, -1))
|
|
5534
|
-
);
|
|
5535
|
-
if (!result) throw new Error("configured bundle footer is empty");
|
|
5536
|
-
return result;
|
|
5537
|
-
}
|
|
5538
|
-
function createPeachBundleConfigFooter(config) {
|
|
5539
|
-
const json = JSON.stringify(config).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029").replace(/<\//g, "<\\/");
|
|
5540
|
-
return "\n" + BUNDLE_CONFIG_PREFIX + json + ";";
|
|
5541
|
-
}
|
|
5542
|
-
function detachPeachBundleConfigFooter(source) {
|
|
5543
|
-
const configuredBundle = readPeachBundleConfigFooter(source);
|
|
5544
|
-
if (!configuredBundle) return { source, configuredBundle };
|
|
5545
|
-
const start = findBundleFooter(source, BUNDLE_CONFIG_PREFIX);
|
|
5546
|
-
const end = source.indexOf("\n", start + 1);
|
|
5547
|
-
return {
|
|
5548
|
-
source: source.slice(0, start) + source.slice(end < 0 ? source.length : end),
|
|
5549
|
-
configuredBundle
|
|
5550
|
-
};
|
|
5551
|
-
}
|
|
5552
|
-
function defineConfig(config) {
|
|
5553
|
-
return config;
|
|
5554
|
-
}
|
|
5555
|
-
function hasOwnKeys(value) {
|
|
5556
|
-
return !!value && Object.keys(value).length > 0;
|
|
5557
|
-
}
|
|
5558
|
-
function hasPeachConfig(config) {
|
|
5559
|
-
if (!config) return false;
|
|
5560
|
-
return config.nativeRenderer !== void 0 || config.mapKit !== void 0 || typeof config.runtimeVersion === "string" && config.runtimeVersion.length > 0 || hasOwnKeys(config.modules) || hasOwnKeys(config.turboModules) || hasOwnKeys(config.nativeModules) || hasOwnKeys(config.nativeViews) || hasOwnKeys(config.nativeHybridObjects) || hasOwnKeys(config.env) || hasOwnKeys(config.network?.remap) || hasOwnKeys(config.settings) || hasOwnKeys(config.initialProps) || hasOwnKeys(config.initialState);
|
|
5561
|
-
}
|
|
5562
|
-
function mergePeachConfig(base, override) {
|
|
5563
|
-
if (!hasPeachConfig(base) && !hasPeachConfig(override)) return void 0;
|
|
5564
|
-
if (!hasPeachConfig(base)) return override ? { ...override } : void 0;
|
|
5565
|
-
if (!hasPeachConfig(override)) return base ? { ...base } : void 0;
|
|
5566
|
-
return {
|
|
5567
|
-
runtimeVersion: override.runtimeVersion ?? base.runtimeVersion,
|
|
5568
|
-
nativeRenderer: override.nativeRenderer ?? base.nativeRenderer,
|
|
5569
|
-
mapKit: override.mapKit ?? base.mapKit,
|
|
5570
|
-
modules: { ...base.modules || {}, ...override.modules || {} },
|
|
5571
|
-
turboModules: { ...base.turboModules || {}, ...override.turboModules || {} },
|
|
5572
|
-
nativeModules: {
|
|
5573
|
-
...base.nativeModules || {},
|
|
5574
|
-
...override.nativeModules || {}
|
|
5575
|
-
},
|
|
5576
|
-
nativeViews: { ...base.nativeViews || {}, ...override.nativeViews || {} },
|
|
5577
|
-
nativeHybridObjects: {
|
|
5578
|
-
...base.nativeHybridObjects || {},
|
|
5579
|
-
...override.nativeHybridObjects || {}
|
|
5580
|
-
},
|
|
5581
|
-
env: { ...base.env || {}, ...override.env || {} },
|
|
5582
|
-
network: {
|
|
5583
|
-
remap: { ...base.network?.remap || {}, ...override.network?.remap || {} }
|
|
5584
|
-
},
|
|
5585
|
-
settings: {
|
|
5586
|
-
...base.settings || {},
|
|
5587
|
-
...override.settings || {}
|
|
5588
|
-
},
|
|
5589
|
-
initialProps: { ...base.initialProps || {}, ...override.initialProps || {} },
|
|
5590
|
-
initialState: { ...base.initialState || {}, ...override.initialState || {} }
|
|
5591
|
-
};
|
|
5592
|
-
}
|
|
5593
|
-
function readPeachConfigFromSearchParams(searchParams) {
|
|
5594
|
-
const raw = searchParams.get(PEACH_CONFIG_QUERY_PARAM);
|
|
5595
|
-
if (!raw) return void 0;
|
|
5596
|
-
let parsed;
|
|
5597
|
-
try {
|
|
5598
|
-
parsed = JSON.parse(raw);
|
|
5599
|
-
} catch (error) {
|
|
5600
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
5601
|
-
console.warn(`[peach] invalid ${PEACH_CONFIG_QUERY_PARAM}: ${message}`);
|
|
5602
|
-
return void 0;
|
|
5603
|
-
}
|
|
5604
|
-
if (isRecord(parsed)) readNativeRenderer(parsed.nativeRenderer);
|
|
5605
|
-
return isPeachConfig(parsed) && hasPeachConfig(parsed) ? parsed : void 0;
|
|
5606
|
-
}
|
|
5607
|
-
function applyPeachConfigToUrl(url, config) {
|
|
5608
|
-
const parsed = new URL(url);
|
|
5609
|
-
if (hasPeachConfig(config)) {
|
|
5610
|
-
parsed.searchParams.set(PEACH_CONFIG_QUERY_PARAM, JSON.stringify(config));
|
|
5611
|
-
} else {
|
|
5612
|
-
parsed.searchParams.delete(PEACH_CONFIG_QUERY_PARAM);
|
|
5613
|
-
}
|
|
5614
|
-
return parsed.toString();
|
|
5615
|
-
}
|
|
5616
|
-
var PEACH_CONFIG_QUERY_PARAM, BUNDLE_CONFIG_PREFIX, PEACH_CONFIGURED_FILES_HOOK;
|
|
5617
|
-
var init_config = __esm({
|
|
5618
|
-
"src/config.ts"() {
|
|
5619
|
-
"use strict";
|
|
5620
|
-
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5621
|
-
init_version();
|
|
5622
|
-
init_bundleGlobalFooter();
|
|
5623
|
-
init_is_record();
|
|
5624
|
-
init_nativeViewSourceContract();
|
|
5625
|
-
PEACH_CONFIG_QUERY_PARAM = "peachConfig";
|
|
5626
|
-
BUNDLE_CONFIG_PREFIX = "globalThis.__peachBundleConfig=";
|
|
5627
|
-
PEACH_CONFIGURED_FILES_HOOK = "__peachInstallConfiguredFiles";
|
|
5628
|
-
}
|
|
5629
|
-
});
|
|
5630
|
-
|
|
5631
|
-
// src/nitro-source.ts
|
|
5632
|
-
function object(value) {
|
|
5633
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5662
|
+
// src/nitro-source.ts
|
|
5663
|
+
function object(value) {
|
|
5664
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
5634
5665
|
}
|
|
5635
5666
|
function readJson(root, relative3) {
|
|
5636
5667
|
return JSON.parse(
|
|
5637
5668
|
readPackageFile(
|
|
5638
5669
|
root,
|
|
5639
|
-
|
|
5670
|
+
import_node_path18.default.join(root, relative3),
|
|
5640
5671
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5641
5672
|
).toString("utf8")
|
|
5642
5673
|
);
|
|
5643
5674
|
}
|
|
5644
5675
|
function registrations(root) {
|
|
5645
|
-
const directory =
|
|
5646
|
-
const initializers =
|
|
5676
|
+
const directory = import_node_path18.default.join(root, "nitrogen/generated/ios");
|
|
5677
|
+
const initializers = import_node_fs18.default.readdirSync(directory).filter((file) => file.endsWith("Autolinking.mm"));
|
|
5647
5678
|
if (initializers.length !== 1)
|
|
5648
5679
|
throw new Error(`${root}: expected one generated Nitro iOS initializer`);
|
|
5649
5680
|
const source = readPackageFile(
|
|
5650
5681
|
root,
|
|
5651
|
-
|
|
5682
|
+
import_node_path18.default.join(directory, initializers[0]),
|
|
5652
5683
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
5653
5684
|
).toString("utf8");
|
|
5654
5685
|
const namespaces = [
|
|
@@ -5690,12 +5721,12 @@ function registrations(root) {
|
|
|
5690
5721
|
return { namespace, swiftModule, classes, views: viewNames(root, classes) };
|
|
5691
5722
|
}
|
|
5692
5723
|
function viewNames(root, classes) {
|
|
5693
|
-
const directory =
|
|
5694
|
-
if (!
|
|
5724
|
+
const directory = import_node_path18.default.join(root, "nitrogen/generated/shared/json");
|
|
5725
|
+
if (!import_node_fs18.default.existsSync(directory)) return /* @__PURE__ */ new Set();
|
|
5695
5726
|
const views = /* @__PURE__ */ new Set();
|
|
5696
|
-
for (const file of
|
|
5727
|
+
for (const file of import_node_fs18.default.readdirSync(directory)) {
|
|
5697
5728
|
if (!file.endsWith("Config.json")) continue;
|
|
5698
|
-
const config = readJson(root,
|
|
5729
|
+
const config = readJson(root, import_node_path18.default.join("nitrogen/generated/shared/json", file));
|
|
5699
5730
|
const name2 = object(config) ? config.uiViewClassName : void 0;
|
|
5700
5731
|
if (typeof name2 === "string" && classes.some((entry) => entry.name === name2))
|
|
5701
5732
|
views.add(name2);
|
|
@@ -5703,21 +5734,21 @@ function viewNames(root, classes) {
|
|
|
5703
5734
|
return views;
|
|
5704
5735
|
}
|
|
5705
5736
|
function hasNitroIosInitializer(root) {
|
|
5706
|
-
const generated =
|
|
5707
|
-
return
|
|
5737
|
+
const generated = import_node_path18.default.join(root, "nitrogen/generated/ios");
|
|
5738
|
+
return import_node_fs18.default.existsSync(generated) && import_node_fs18.default.readdirSync(generated).some((file) => file.endsWith("Autolinking.mm"));
|
|
5708
5739
|
}
|
|
5709
5740
|
function nitroRegisteredNames(root) {
|
|
5710
5741
|
if (!hasNitroIosInitializer(root)) return null;
|
|
5711
5742
|
const { classes, views } = registrations(root);
|
|
5712
5743
|
return { names: classes.map(({ name: name2 }) => name2), views: [...views].sort() };
|
|
5713
5744
|
}
|
|
5714
|
-
var
|
|
5745
|
+
var import_node_fs18, import_node_path18;
|
|
5715
5746
|
var init_nitro_source = __esm({
|
|
5716
5747
|
"src/nitro-source.ts"() {
|
|
5717
5748
|
"use strict";
|
|
5718
5749
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
5719
|
-
|
|
5720
|
-
|
|
5750
|
+
import_node_fs18 = __toESM(require("node:fs"), 1);
|
|
5751
|
+
import_node_path18 = __toESM(require("node:path"), 1);
|
|
5721
5752
|
init_swift_source_file();
|
|
5722
5753
|
init_swift_submit();
|
|
5723
5754
|
}
|
|
@@ -5839,7 +5870,7 @@ function resolveAppStubs(appDir, config, configDir) {
|
|
|
5839
5870
|
const { modules, views, hybridObjects } = expandStubs(appDir, source);
|
|
5840
5871
|
assertRegisteredHybridObjects(appDir, source, hybridObjects);
|
|
5841
5872
|
for (const [name2, answer] of Object.entries(hybridObjects))
|
|
5842
|
-
nativeHybridObjects[name2] = answer === "unsupported" ? answer : { file: (0,
|
|
5873
|
+
nativeHybridObjects[name2] = answer === "unsupported" ? answer : { file: (0, import_node_path19.resolve)(source.baseDir, answer) };
|
|
5843
5874
|
for (const [name2, stub] of Object.entries(modules))
|
|
5844
5875
|
nativeModules[name2] = lowerStub(stub, source.baseDir);
|
|
5845
5876
|
for (const [name2, stub] of Object.entries(views))
|
|
@@ -5903,10 +5934,10 @@ function assertRegisteredHybridObjects(appDir, source, hybridObjects) {
|
|
|
5903
5934
|
);
|
|
5904
5935
|
}
|
|
5905
5936
|
function lowerStub(stub, baseDir) {
|
|
5906
|
-
return stub === "noop" ? stub : { file: (0,
|
|
5937
|
+
return stub === "noop" ? stub : { file: (0, import_node_path19.resolve)(baseDir, stub) };
|
|
5907
5938
|
}
|
|
5908
5939
|
function readPackageJson(dir) {
|
|
5909
|
-
const text2 = readSmallFile((0,
|
|
5940
|
+
const text2 = readSmallFile((0, import_node_path19.join)(dir, "package.json"));
|
|
5910
5941
|
if (!text2) return null;
|
|
5911
5942
|
try {
|
|
5912
5943
|
const parsed = JSON.parse(text2);
|
|
@@ -5918,9 +5949,9 @@ function readPackageJson(dir) {
|
|
|
5918
5949
|
function installedPackageDir(appDir, name2) {
|
|
5919
5950
|
let current = appDir;
|
|
5920
5951
|
while (true) {
|
|
5921
|
-
const dir = (0,
|
|
5922
|
-
if ((0,
|
|
5923
|
-
const parent = (0,
|
|
5952
|
+
const dir = (0, import_node_path19.join)(current, "node_modules", name2);
|
|
5953
|
+
if ((0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, "package.json"))) return (0, import_node_fs19.realpathSync)(dir);
|
|
5954
|
+
const parent = (0, import_node_path19.dirname)(current);
|
|
5924
5955
|
if (parent === current) return null;
|
|
5925
5956
|
current = parent;
|
|
5926
5957
|
}
|
|
@@ -6012,7 +6043,7 @@ function mergeRequests(previous, next) {
|
|
|
6012
6043
|
function packageNativeRequests(dir) {
|
|
6013
6044
|
const found = /* @__PURE__ */ new Map();
|
|
6014
6045
|
const directories = scanRepository(dir).directories.filter((sub) => {
|
|
6015
|
-
const segments = (0,
|
|
6046
|
+
const segments = (0, import_node_path19.relative)(dir, sub).split("/");
|
|
6016
6047
|
return !NATIVE_SOURCE_DIRS.has(segments[0]) && !segments.some((segment) => PACKAGE_SKIP_DIRS.has(segment));
|
|
6017
6048
|
});
|
|
6018
6049
|
let files = 0;
|
|
@@ -6020,7 +6051,7 @@ function packageNativeRequests(dir) {
|
|
|
6020
6051
|
for (const name2 of listDir(sub)) {
|
|
6021
6052
|
if (!SOURCE_FILE.test(name2) || name2.endsWith(".d.ts") || files >= 2e3) continue;
|
|
6022
6053
|
files++;
|
|
6023
|
-
const file = (0,
|
|
6054
|
+
const file = (0, import_node_path19.join)(sub, name2);
|
|
6024
6055
|
const text2 = readSmallFile(file);
|
|
6025
6056
|
if (!text2) continue;
|
|
6026
6057
|
for (const { line: _line, ...request } of sourceNativeRequests(file, text2, true))
|
|
@@ -6139,27 +6170,27 @@ function wireSlotMigration(appDir, configPath, wire, kept = []) {
|
|
|
6139
6170
|
}
|
|
6140
6171
|
function listDir(dir) {
|
|
6141
6172
|
try {
|
|
6142
|
-
return (0,
|
|
6173
|
+
return (0, import_node_fs19.readdirSync)(dir);
|
|
6143
6174
|
} catch {
|
|
6144
6175
|
return [];
|
|
6145
6176
|
}
|
|
6146
6177
|
}
|
|
6147
6178
|
function readSmallFile(file) {
|
|
6148
6179
|
try {
|
|
6149
|
-
return (0,
|
|
6180
|
+
return (0, import_node_fs19.statSync)(file).size <= 1024 * 1024 ? (0, import_node_fs19.readFileSync)(file, "utf8") : null;
|
|
6150
6181
|
} catch {
|
|
6151
6182
|
return null;
|
|
6152
6183
|
}
|
|
6153
6184
|
}
|
|
6154
6185
|
function hasNativeCode(dir, platform) {
|
|
6155
|
-
const expoConfig = (0,
|
|
6186
|
+
const expoConfig = (0, import_node_path19.join)(dir, "expo-module.config.json");
|
|
6156
6187
|
const platforms = metadataValue(readProjectJson(expoConfig), "platforms");
|
|
6157
6188
|
if (Array.isArray(platforms))
|
|
6158
6189
|
return platforms.includes(platform) || platform === "ios" && platforms.includes("apple");
|
|
6159
|
-
if ([platform, "expo-module.config.json"].some((entry) => (0,
|
|
6190
|
+
if ([platform, "expo-module.config.json"].some((entry) => (0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, entry))))
|
|
6160
6191
|
return true;
|
|
6161
6192
|
if (listDir(dir).some((name2) => name2.endsWith(".podspec"))) return true;
|
|
6162
|
-
const manifest = readSmallFile((0,
|
|
6193
|
+
const manifest = readSmallFile((0, import_node_path19.join)(dir, "package.json"));
|
|
6163
6194
|
return manifest !== null && manifest.includes('"codegenConfig"');
|
|
6164
6195
|
}
|
|
6165
6196
|
function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__PURE__ */ new Set(), includeLegacy = false, providers) {
|
|
@@ -6172,7 +6203,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
|
|
|
6172
6203
|
(excluded) => dir === excluded || dir.startsWith(`${excluded}/`)
|
|
6173
6204
|
))
|
|
6174
6205
|
continue;
|
|
6175
|
-
if ((0,
|
|
6206
|
+
if ((0, import_node_fs19.existsSync)((0, import_node_path19.join)(dir, "expo-module.config.json"))) {
|
|
6176
6207
|
if (platform && !hasNativeCode(dir, platform)) {
|
|
6177
6208
|
excludedModuleDirs.push(dir);
|
|
6178
6209
|
continue;
|
|
@@ -6181,7 +6212,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
|
|
|
6181
6212
|
}
|
|
6182
6213
|
for (const name2 of listDir(dir)) {
|
|
6183
6214
|
if (SOURCE_FILE.test(name2) && !name2.endsWith(".d.ts"))
|
|
6184
|
-
sourceFiles.push((0,
|
|
6215
|
+
sourceFiles.push((0, import_node_path19.join)(dir, name2));
|
|
6185
6216
|
}
|
|
6186
6217
|
}
|
|
6187
6218
|
}
|
|
@@ -6191,7 +6222,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
|
|
|
6191
6222
|
scanRepository(dir).directories.flatMap(
|
|
6192
6223
|
(sub) => listDir(sub).filter(
|
|
6193
6224
|
(name2) => NATIVE_SOURCE_FILE.test(name2) && (!platform || (platform === "ios" ? name2.endsWith(".swift") : name2.endsWith(".kt")))
|
|
6194
|
-
).map((name2) => (0,
|
|
6225
|
+
).map((name2) => (0, import_node_path19.join)(sub, name2))
|
|
6195
6226
|
)
|
|
6196
6227
|
])
|
|
6197
6228
|
);
|
|
@@ -6200,7 +6231,7 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
|
|
|
6200
6231
|
const known = owners.get(dir);
|
|
6201
6232
|
if (known) return known;
|
|
6202
6233
|
const name2 = readPackageJson(dir)?.name;
|
|
6203
|
-
const parent = (0,
|
|
6234
|
+
const parent = (0, import_node_path19.dirname)(dir);
|
|
6204
6235
|
const result = typeof name2 === "string" ? name2 : parent === dir ? pkg.name ?? "app" : owner(parent);
|
|
6205
6236
|
owners.set(dir, result);
|
|
6206
6237
|
return result;
|
|
@@ -6214,18 +6245,18 @@ function scanLocalNative(appDir, pkg, answered, platform, knownPackages = /* @__
|
|
|
6214
6245
|
return;
|
|
6215
6246
|
}
|
|
6216
6247
|
providers ??= dependencyNativeOwners(appDir, pkg);
|
|
6217
|
-
const packageName = providers.get(key) ?? owner((0,
|
|
6248
|
+
const packageName = providers.get(key) ?? owner((0, import_node_path19.dirname)(file));
|
|
6218
6249
|
if (knownPackages.has(packageName)) return;
|
|
6219
6250
|
const moduleDir = expoModuleDirs.find((dir) => file.startsWith(`${dir}/`)) ?? null;
|
|
6220
6251
|
found.set(key, {
|
|
6221
6252
|
kind,
|
|
6222
6253
|
name: name2,
|
|
6223
6254
|
package: packageName,
|
|
6224
|
-
path: `${(0,
|
|
6225
|
-
expoModule: moduleDir ? (0,
|
|
6255
|
+
path: `${(0, import_node_path19.relative)(appDir, file)}:${line}`,
|
|
6256
|
+
expoModule: moduleDir ? (0, import_node_path19.relative)(appDir, moduleDir) || "." : null,
|
|
6226
6257
|
optional,
|
|
6227
6258
|
swift: moduleDir ? (nativeFilesByModule.get(moduleDir) ?? []).some(
|
|
6228
|
-
(
|
|
6259
|
+
(path22) => path22.endsWith(".swift") && [...(readSmallFile(path22) ?? "").matchAll(/\bName\(\s*"(\w+)"\s*\)/g)].some(
|
|
6229
6260
|
(match) => match[1] === name2
|
|
6230
6261
|
)
|
|
6231
6262
|
) : false,
|
|
@@ -6266,30 +6297,30 @@ function workspacePackageDirs(appDir, pkg) {
|
|
|
6266
6297
|
for (const name2 of Object.keys({ ...pkg.dependencies, ...pkg.devDependencies })) {
|
|
6267
6298
|
let current = appDir;
|
|
6268
6299
|
while (true) {
|
|
6269
|
-
const link = (0,
|
|
6270
|
-
if ((0,
|
|
6271
|
-
if ((0,
|
|
6272
|
-
const target = (0,
|
|
6300
|
+
const link = (0, import_node_path19.join)(current, "node_modules", name2);
|
|
6301
|
+
if ((0, import_node_fs19.existsSync)(link)) {
|
|
6302
|
+
if ((0, import_node_fs19.lstatSync)(link).isSymbolicLink()) {
|
|
6303
|
+
const target = (0, import_node_fs19.realpathSync)(link);
|
|
6273
6304
|
if (!target.split("/").includes("node_modules") && !target.startsWith(`${appDir}/`)) {
|
|
6274
6305
|
dirs.add(target);
|
|
6275
6306
|
}
|
|
6276
6307
|
}
|
|
6277
6308
|
break;
|
|
6278
6309
|
}
|
|
6279
|
-
const parent = (0,
|
|
6310
|
+
const parent = (0, import_node_path19.dirname)(current);
|
|
6280
6311
|
if (parent === current) break;
|
|
6281
6312
|
current = parent;
|
|
6282
6313
|
}
|
|
6283
6314
|
}
|
|
6284
6315
|
return [...dirs];
|
|
6285
6316
|
}
|
|
6286
|
-
var
|
|
6317
|
+
var import_node_fs19, import_node_path19, import_version_range, import_oxc_parser2, import_sucrase, SOURCE_FILE, NATIVE_LOOKUP, NATIVE_SOURCE_DIRS, PACKAGE_SKIP_DIRS, NATIVE_SOURCE_FILE;
|
|
6287
6318
|
var init_app_stubs = __esm({
|
|
6288
6319
|
"cli/app-stubs.ts"() {
|
|
6289
6320
|
"use strict";
|
|
6290
6321
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
6291
|
-
|
|
6292
|
-
|
|
6322
|
+
import_node_fs19 = require("node:fs");
|
|
6323
|
+
import_node_path19 = require("node:path");
|
|
6293
6324
|
import_version_range = require("@peach/compat/version-range");
|
|
6294
6325
|
import_oxc_parser2 = require("oxc-parser");
|
|
6295
6326
|
import_sucrase = require("sucrase");
|
|
@@ -6325,12 +6356,12 @@ function resolveFileEntries(entries, configDir) {
|
|
|
6325
6356
|
return Object.fromEntries(
|
|
6326
6357
|
Object.entries(entries).map(([name2, resolution]) => [
|
|
6327
6358
|
name2,
|
|
6328
|
-
resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file:
|
|
6359
|
+
resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string" ? { ...resolution, file: import_node_path20.default.resolve(configDir, resolution.file) } : resolution
|
|
6329
6360
|
])
|
|
6330
6361
|
);
|
|
6331
6362
|
}
|
|
6332
6363
|
function resolveConfigReplacementFiles(config, configPath) {
|
|
6333
|
-
const configDir =
|
|
6364
|
+
const configDir = import_node_path20.default.dirname(configPath);
|
|
6334
6365
|
return {
|
|
6335
6366
|
...config,
|
|
6336
6367
|
modules: resolveFileEntries(config.modules, configDir)
|
|
@@ -6346,7 +6377,7 @@ async function loadRNXAppStubs(project) {
|
|
|
6346
6377
|
return resolveAppStubs(
|
|
6347
6378
|
project.appDir,
|
|
6348
6379
|
config,
|
|
6349
|
-
project.configPath ?
|
|
6380
|
+
project.configPath ? import_node_path20.default.dirname(project.configPath) : project.appDir
|
|
6350
6381
|
);
|
|
6351
6382
|
} catch (error) {
|
|
6352
6383
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -6365,7 +6396,7 @@ async function loadConfigFile(project) {
|
|
|
6365
6396
|
[`${rnxPublicBrand.packageName}/config`]: config_exports
|
|
6366
6397
|
}
|
|
6367
6398
|
});
|
|
6368
|
-
const loaded3 = project.configPath.endsWith(".json") ? JSON.parse((0,
|
|
6399
|
+
const loaded3 = project.configPath.endsWith(".json") ? JSON.parse((0, import_node_fs20.readFileSync)(project.configPath, "utf8")) : await jiti.import(project.configPath, { default: true });
|
|
6369
6400
|
if (!isPeachConfig(loaded3)) {
|
|
6370
6401
|
throw new Error("the default export must be a peach config object");
|
|
6371
6402
|
}
|
|
@@ -6401,13 +6432,13 @@ async function resolveRNXAppConfig(startDir = process.cwd()) {
|
|
|
6401
6432
|
const project = resolveAppProject(startDir);
|
|
6402
6433
|
return { project, ...await loadRNXAppStubs(project) };
|
|
6403
6434
|
}
|
|
6404
|
-
var
|
|
6435
|
+
var import_node_fs20, import_node_path20, import_jiti, WIRE_SLOTS;
|
|
6405
6436
|
var init_app_config = __esm({
|
|
6406
6437
|
"cli/app-config.ts"() {
|
|
6407
6438
|
"use strict";
|
|
6408
6439
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
6409
|
-
|
|
6410
|
-
|
|
6440
|
+
import_node_fs20 = require("node:fs");
|
|
6441
|
+
import_node_path20 = __toESM(require("node:path"), 1);
|
|
6411
6442
|
import_jiti = require("jiti");
|
|
6412
6443
|
init_config();
|
|
6413
6444
|
init_config();
|
|
@@ -6504,14 +6535,14 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
|
|
|
6504
6535
|
const neededPackages = /* @__PURE__ */ new Set();
|
|
6505
6536
|
const factories = [];
|
|
6506
6537
|
const visit3 = (filePath) => {
|
|
6507
|
-
const real =
|
|
6538
|
+
const real = import_node_fs21.default.realpathSync(filePath);
|
|
6508
6539
|
const previous = files.get(real);
|
|
6509
6540
|
if (previous !== void 0) return previous;
|
|
6510
6541
|
const id = "peach-config-file:" + files.size;
|
|
6511
6542
|
files.set(real, id);
|
|
6512
6543
|
const compiled = compileReplacementModule({
|
|
6513
6544
|
filePath: real,
|
|
6514
|
-
source:
|
|
6545
|
+
source: import_node_fs21.default.readFileSync(real, "utf8"),
|
|
6515
6546
|
runtimePackages,
|
|
6516
6547
|
localModuleUrl: (specifier) => visit3(resolveReplacementModuleFile(real, specifier))
|
|
6517
6548
|
});
|
|
@@ -6535,7 +6566,7 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
|
|
|
6535
6566
|
if (!entries || typeof entries !== "object") continue;
|
|
6536
6567
|
for (const resolution of Object.values(entries)) {
|
|
6537
6568
|
if (resolution && typeof resolution === "object" && "file" in resolution && typeof resolution.file === "string") {
|
|
6538
|
-
resolution.file = visit3(
|
|
6569
|
+
resolution.file = visit3(import_node_path21.default.resolve(resolution.file));
|
|
6539
6570
|
}
|
|
6540
6571
|
}
|
|
6541
6572
|
}
|
|
@@ -6559,13 +6590,13 @@ async function produceConfiguredBundle(source, config, runtimePackages) {
|
|
|
6559
6590
|
const identityStart = findBundleFooter(source, "globalThis.__sootsimModulePaths=");
|
|
6560
6591
|
return prefix2 + (identityStart < 0 ? source + footer : source.slice(0, identityStart) + footer + source.slice(identityStart));
|
|
6561
6592
|
}
|
|
6562
|
-
var
|
|
6593
|
+
var import_node_fs21, import_node_path21, import_sucrase2, import_terser;
|
|
6563
6594
|
var init_configured_bundle_producer = __esm({
|
|
6564
6595
|
"src/configured-bundle-producer.ts"() {
|
|
6565
6596
|
"use strict";
|
|
6566
6597
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
6567
|
-
|
|
6568
|
-
|
|
6598
|
+
import_node_fs21 = __toESM(require("node:fs"), 1);
|
|
6599
|
+
import_node_path21 = __toESM(require("node:path"), 1);
|
|
6569
6600
|
import_sucrase2 = require("sucrase");
|
|
6570
6601
|
import_terser = require("terser");
|
|
6571
6602
|
init_dependencies();
|
|
@@ -7897,7 +7928,7 @@ function createBridge(wsPort, opts = {}) {
|
|
|
7897
7928
|
const identity = getCliIdentity();
|
|
7898
7929
|
const ownerPid = getStableOwnerPid();
|
|
7899
7930
|
let terminalError;
|
|
7900
|
-
const ready = new Promise((
|
|
7931
|
+
const ready = new Promise((resolve5, reject) => {
|
|
7901
7932
|
const handshakeTimer = setTimeout(() => {
|
|
7902
7933
|
reject(
|
|
7903
7934
|
new Error(
|
|
@@ -7926,7 +7957,7 @@ function createBridge(wsPort, opts = {}) {
|
|
|
7926
7957
|
);
|
|
7927
7958
|
} catch {
|
|
7928
7959
|
}
|
|
7929
|
-
|
|
7960
|
+
resolve5();
|
|
7930
7961
|
});
|
|
7931
7962
|
ws.on("close", (code, reason) => {
|
|
7932
7963
|
clearTimeout(handshakeTimer);
|
|
@@ -8022,7 +8053,7 @@ function createBridge(wsPort, opts = {}) {
|
|
|
8022
8053
|
await ready;
|
|
8023
8054
|
if (terminalError) throw terminalError;
|
|
8024
8055
|
const id = nextId++;
|
|
8025
|
-
return new Promise((
|
|
8056
|
+
return new Promise((resolve5, reject) => {
|
|
8026
8057
|
const payload = { ...cmdOverride ?? cmd, id };
|
|
8027
8058
|
if (payload.simId === void 0 && defaultSimId) {
|
|
8028
8059
|
payload.simId = defaultSimId;
|
|
@@ -8038,7 +8069,7 @@ function createBridge(wsPort, opts = {}) {
|
|
|
8038
8069
|
pending.set(id, {
|
|
8039
8070
|
resolve: (v) => {
|
|
8040
8071
|
clearTimeoutFn();
|
|
8041
|
-
|
|
8072
|
+
resolve5(v);
|
|
8042
8073
|
},
|
|
8043
8074
|
reject: (e) => {
|
|
8044
8075
|
clearTimeoutFn();
|
|
@@ -8964,6 +8995,7 @@ function waitReadyStatus(result, ready) {
|
|
|
8964
8995
|
externalError: probe?.externalError ?? "",
|
|
8965
8996
|
suppressedEntryError: probe?.suppressedEntryError ?? "",
|
|
8966
8997
|
errors: probe?.errors ?? 0,
|
|
8998
|
+
startup: probe?.startup,
|
|
8967
8999
|
bridgeError: result.error ?? "",
|
|
8968
9000
|
paintedAppContent: probe?.paintedAppContent ?? false,
|
|
8969
9001
|
treeQuietMs: probe?.treeQuietMs ?? 0,
|
|
@@ -9993,7 +10025,7 @@ async function tapResolvedTarget(bridge, args) {
|
|
|
9993
10025
|
motionOnly: true
|
|
9994
10026
|
});
|
|
9995
10027
|
} catch {
|
|
9996
|
-
await new Promise((
|
|
10028
|
+
await new Promise((resolve5) => setTimeout(resolve5, Math.min(120, remaining)));
|
|
9997
10029
|
}
|
|
9998
10030
|
}
|
|
9999
10031
|
return {
|
|
@@ -10249,7 +10281,7 @@ var LAUNCH_METADATA_KEYS = [
|
|
|
10249
10281
|
// src/sleep.ts
|
|
10250
10282
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
10251
10283
|
function sleep(ms) {
|
|
10252
|
-
return new Promise((
|
|
10284
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
10253
10285
|
}
|
|
10254
10286
|
|
|
10255
10287
|
// src/sim-client.ts
|
|
@@ -11111,13 +11143,13 @@ function isRnxCaptureRegionAtlas(value) {
|
|
|
11111
11143
|
|
|
11112
11144
|
// src/vite-plugin-one.ts
|
|
11113
11145
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
11114
|
-
var
|
|
11146
|
+
var import_fs6 = __toESM(require("fs"), 1);
|
|
11115
11147
|
var import_node_crypto6 = require("node:crypto");
|
|
11116
11148
|
var import_node_http = __toESM(require("node:http"), 1);
|
|
11117
11149
|
var import_node_https = __toESM(require("node:https"), 1);
|
|
11118
11150
|
var import_node_url = require("node:url");
|
|
11119
|
-
var
|
|
11120
|
-
var
|
|
11151
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
11152
|
+
var import_promises5 = require("stream/promises");
|
|
11121
11153
|
var import_ws2 = require("ws");
|
|
11122
11154
|
init_cli_runtime();
|
|
11123
11155
|
|
|
@@ -11194,61 +11226,19 @@ function launchRnxDesktop(bundleUrl, appName) {
|
|
|
11194
11226
|
|
|
11195
11227
|
// src/vite-plugin-one.ts
|
|
11196
11228
|
init_home_paths();
|
|
11197
|
-
init_replacement_module_handler();
|
|
11198
11229
|
|
|
11199
|
-
// src/host/
|
|
11230
|
+
// src/host/fetch-proxy-handler.ts
|
|
11200
11231
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
11201
|
-
var
|
|
11202
|
-
var
|
|
11203
|
-
|
|
11204
|
-
var
|
|
11205
|
-
|
|
11206
|
-
|
|
11207
|
-
|
|
11208
|
-
|
|
11209
|
-
|
|
11210
|
-
|
|
11211
|
-
const contentType = typeof upstream.headers["content-type"] === "string" ? upstream.headers["content-type"] : "";
|
|
11212
|
-
const inventory = getCliRuntime().rolldown_bundle_inventory;
|
|
11213
|
-
res.removeHeader("content-length");
|
|
11214
|
-
const annotate = async function* () {
|
|
11215
|
-
const decoder = new TextDecoder();
|
|
11216
|
-
let payload = "";
|
|
11217
|
-
let sent = 0;
|
|
11218
|
-
let bundleStarted = false;
|
|
11219
|
-
for await (const chunk of upstream) {
|
|
11220
|
-
payload += decoder.decode(chunk, { stream: true });
|
|
11221
|
-
if (bundleStarted) continue;
|
|
11222
|
-
const releasable = inventory.releasableMultipartPrefix(payload, contentType);
|
|
11223
|
-
bundleStarted = releasable.bundleStarted;
|
|
11224
|
-
if (releasable.length > sent) {
|
|
11225
|
-
yield Buffer.from(payload.slice(sent, releasable.length), "utf8");
|
|
11226
|
-
sent = releasable.length;
|
|
11227
|
-
}
|
|
11228
|
-
}
|
|
11229
|
-
payload += decoder.decode();
|
|
11230
|
-
let annotated;
|
|
11231
|
-
try {
|
|
11232
|
-
annotated = await inventory.attachRolldownBundleHttpPayload(payload, contentType);
|
|
11233
|
-
} catch (error) {
|
|
11234
|
-
const message = `could not attach the rolldown bundle inventory: ${error instanceof Error ? error.message : String(error)}`;
|
|
11235
|
-
console.error(`[peach] ${message}`);
|
|
11236
|
-
if (contentType.toLowerCase().includes("multipart/mixed")) {
|
|
11237
|
-
yield Buffer.from(
|
|
11238
|
-
inventory.multipartFailurePart(contentType, message, payload.slice(0, sent)),
|
|
11239
|
-
"utf8"
|
|
11240
|
-
);
|
|
11241
|
-
return;
|
|
11242
|
-
}
|
|
11243
|
-
res.statusCode = 500;
|
|
11244
|
-
res.setHeader("content-type", "application/json");
|
|
11245
|
-
yield Buffer.from(JSON.stringify({ message }), "utf8");
|
|
11246
|
-
return;
|
|
11247
|
-
}
|
|
11248
|
-
yield Buffer.from(annotated.slice(sent), "utf8");
|
|
11249
|
-
};
|
|
11250
|
-
await (0, import_promises2.pipeline)(import_stream.Readable.from(annotate(), { objectMode: false }), res);
|
|
11251
|
-
}
|
|
11232
|
+
var import_http = __toESM(require("http"), 1);
|
|
11233
|
+
var import_https = __toESM(require("https"), 1);
|
|
11234
|
+
var import_node_http2 = require("node:http2");
|
|
11235
|
+
var import_promises3 = require("stream/promises");
|
|
11236
|
+
init_backend_origin();
|
|
11237
|
+
|
|
11238
|
+
// src/host/dev-server-package-versions.ts
|
|
11239
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
11240
|
+
var import_fs5 = __toESM(require("fs"), 1);
|
|
11241
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
11252
11242
|
|
|
11253
11243
|
// src/installed-package-versions.ts
|
|
11254
11244
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
@@ -12637,6 +12627,7 @@ var NATIVE_STUB_PACKAGE_NAMES = [
|
|
|
12637
12627
|
"expo-quick-actions",
|
|
12638
12628
|
"expo-rich-input",
|
|
12639
12629
|
"expo-roomplan",
|
|
12630
|
+
"expo-router",
|
|
12640
12631
|
"expo-screen-capture",
|
|
12641
12632
|
"expo-screen-corner-radius",
|
|
12642
12633
|
"expo-screen-orientation",
|
|
@@ -13236,7 +13227,6 @@ var NATIVE_RUNTIME_PACKAGE_NAMES = [
|
|
|
13236
13227
|
"@tamagui/native-registry",
|
|
13237
13228
|
"@uniswap/ethers-rs-mobile",
|
|
13238
13229
|
"@valora/react-native-keychain",
|
|
13239
|
-
"expo-router",
|
|
13240
13230
|
"react-native-app-control",
|
|
13241
13231
|
"react-native-blue-crypto",
|
|
13242
13232
|
"react-native-nitro-base64",
|
|
@@ -14159,12 +14149,32 @@ function answerSync(step) {
|
|
|
14159
14149
|
throw error;
|
|
14160
14150
|
}
|
|
14161
14151
|
}
|
|
14152
|
+
async function answerAsync(step) {
|
|
14153
|
+
if (step.op === "exists")
|
|
14154
|
+
return import_fs4.default.promises.access(step.path).then(
|
|
14155
|
+
() => true,
|
|
14156
|
+
() => false
|
|
14157
|
+
);
|
|
14158
|
+
if (step.op === "realpath") return import_fs4.default.promises.realpath(step.path);
|
|
14159
|
+
try {
|
|
14160
|
+
return parseManifest(await import_fs4.default.promises.readFile(step.path, "utf8"));
|
|
14161
|
+
} catch (error) {
|
|
14162
|
+
if (isMissing(error)) return null;
|
|
14163
|
+
throw error;
|
|
14164
|
+
}
|
|
14165
|
+
}
|
|
14162
14166
|
function runSync(walk) {
|
|
14163
14167
|
for (let step = walk.next(); ; ) {
|
|
14164
14168
|
if (step.done) return step.value;
|
|
14165
14169
|
step = walk.next(answerSync(step.value));
|
|
14166
14170
|
}
|
|
14167
14171
|
}
|
|
14172
|
+
async function runAsync(walk) {
|
|
14173
|
+
for (let step = walk.next(); ; ) {
|
|
14174
|
+
if (step.done) return step.value;
|
|
14175
|
+
step = walk.next(await answerAsync(step.value));
|
|
14176
|
+
}
|
|
14177
|
+
}
|
|
14168
14178
|
function createInstalledPackageReader() {
|
|
14169
14179
|
const hasModules = /* @__PURE__ */ new Map();
|
|
14170
14180
|
const manifests = /* @__PURE__ */ new Map();
|
|
@@ -14258,31 +14268,94 @@ function* nativePackageVersionsWalk(projectRoot) {
|
|
|
14258
14268
|
function readInstalledNativePackageVersions(projectRoot) {
|
|
14259
14269
|
return runSync(nativePackageVersionsWalk(projectRoot));
|
|
14260
14270
|
}
|
|
14271
|
+
var INSTALL_RECORD_FILES = [
|
|
14272
|
+
"package.json",
|
|
14273
|
+
"bun.lock",
|
|
14274
|
+
"bun.lockb",
|
|
14275
|
+
"package-lock.json",
|
|
14276
|
+
"yarn.lock",
|
|
14277
|
+
"pnpm-lock.yaml",
|
|
14278
|
+
"node_modules",
|
|
14279
|
+
"node_modules/.package-lock.json",
|
|
14280
|
+
"node_modules/.yarn-integrity",
|
|
14281
|
+
"node_modules/.modules.yaml"
|
|
14282
|
+
];
|
|
14283
|
+
async function installFingerprint(projectRoot) {
|
|
14284
|
+
const appRoot = await import_fs4.default.promises.realpath(projectRoot);
|
|
14285
|
+
const targets = [];
|
|
14286
|
+
for (let dir = appRoot; ; ) {
|
|
14287
|
+
if (import_path3.default.basename(dir) !== "node_modules")
|
|
14288
|
+
for (const file of INSTALL_RECORD_FILES) targets.push(import_path3.default.join(dir, file));
|
|
14289
|
+
const parent = import_path3.default.dirname(dir);
|
|
14290
|
+
if (parent === dir) break;
|
|
14291
|
+
dir = parent;
|
|
14292
|
+
}
|
|
14293
|
+
const stats = await Promise.all(
|
|
14294
|
+
targets.map(
|
|
14295
|
+
(target) => import_fs4.default.promises.stat(target).then(
|
|
14296
|
+
(stat) => `${stat.ino}:${stat.size}:${stat.mtimeMs}`,
|
|
14297
|
+
() => ""
|
|
14298
|
+
)
|
|
14299
|
+
)
|
|
14300
|
+
);
|
|
14301
|
+
return `${appRoot}
|
|
14302
|
+
${stats.join("\n")}`;
|
|
14303
|
+
}
|
|
14304
|
+
var scans = /* @__PURE__ */ new Map();
|
|
14305
|
+
async function readInstalledNativePackageVersionsAsync(projectRoot) {
|
|
14306
|
+
const fingerprint = await installFingerprint(projectRoot);
|
|
14307
|
+
const cached2 = scans.get(projectRoot);
|
|
14308
|
+
if (cached2?.fingerprint === fingerprint) return cached2.versions;
|
|
14309
|
+
const versions = runAsync(nativePackageVersionsWalk(projectRoot));
|
|
14310
|
+
scans.set(projectRoot, { fingerprint, versions });
|
|
14311
|
+
versions.catch(() => {
|
|
14312
|
+
if (scans.get(projectRoot)?.versions === versions) scans.delete(projectRoot);
|
|
14313
|
+
});
|
|
14314
|
+
return versions;
|
|
14315
|
+
}
|
|
14261
14316
|
|
|
14262
|
-
// src/
|
|
14317
|
+
// src/metro-project-root.ts
|
|
14263
14318
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14264
|
-
var import_node_child_process3 = require("node:child_process");
|
|
14265
|
-
var import_node_crypto5 = require("node:crypto");
|
|
14266
|
-
var import_node_fs11 = __toESM(require("node:fs"), 1);
|
|
14267
|
-
var import_node_module2 = require("node:module");
|
|
14268
|
-
var import_node_path10 = __toESM(require("node:path"), 1);
|
|
14269
|
-
var import_node_util = require("node:util");
|
|
14270
14319
|
|
|
14271
|
-
//
|
|
14320
|
+
// scripts/dev-server-scanner.ts
|
|
14272
14321
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14273
|
-
var
|
|
14322
|
+
var import_child_process2 = require("child_process");
|
|
14323
|
+
var import_promises = require("fs/promises");
|
|
14324
|
+
var import_node_fs9 = require("node:fs");
|
|
14325
|
+
var import_node_os3 = require("node:os");
|
|
14326
|
+
var import_node_path8 = require("node:path");
|
|
14327
|
+
init_backend_origin();
|
|
14328
|
+
init_config();
|
|
14274
14329
|
|
|
14275
|
-
// src/
|
|
14276
|
-
|
|
14330
|
+
// src/dev-bundle-resolution.ts
|
|
14331
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14332
|
+
init_backend_origin();
|
|
14277
14333
|
|
|
14278
|
-
// src/
|
|
14334
|
+
// src/expo-manifest-body.ts
|
|
14279
14335
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14336
|
+
function parseExpoManifestBody(body) {
|
|
14337
|
+
const opening = /^(--[^\r\n]+)\r?\n/.exec(body);
|
|
14338
|
+
if (!opening) return JSON.parse(body);
|
|
14339
|
+
for (const part of body.split(opening[1])) {
|
|
14340
|
+
const headerEnd = part.search(/\r?\n\r?\n/);
|
|
14341
|
+
if (headerEnd < 0 || !/\bname="manifest"/.test(part.slice(0, headerEnd))) continue;
|
|
14342
|
+
return JSON.parse(part.slice(headerEnd).trim());
|
|
14343
|
+
}
|
|
14344
|
+
throw new Error("Expo manifest response has no manifest part");
|
|
14345
|
+
}
|
|
14280
14346
|
|
|
14281
14347
|
// src/native-dev-bundle-url.ts
|
|
14282
14348
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14283
14349
|
init_backend_origin();
|
|
14284
14350
|
|
|
14351
|
+
// src/dev-bundle-resolution.ts
|
|
14352
|
+
var MANIFEST_PROBE_TIMEOUT_MS = 3e4;
|
|
14353
|
+
|
|
14354
|
+
// src/kotlinDiscoveryContract.ts
|
|
14355
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14356
|
+
|
|
14285
14357
|
// src/oneWidgetContract.ts
|
|
14358
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14286
14359
|
var HOME_WIDGET_FAMILIES = [
|
|
14287
14360
|
"systemSmall",
|
|
14288
14361
|
"systemMedium",
|
|
@@ -14293,7 +14366,1080 @@ function isHomeWidgetFamily(value) {
|
|
|
14293
14366
|
return HOME_WIDGET_FAMILIES.some((family) => family === value);
|
|
14294
14367
|
}
|
|
14295
14368
|
|
|
14369
|
+
// src/settings-bundle.ts
|
|
14370
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14371
|
+
init_is_record();
|
|
14372
|
+
|
|
14373
|
+
// src/plist.ts
|
|
14374
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14375
|
+
var import_plist = __toESM(require("plist"), 1);
|
|
14376
|
+
function parsePlistSource(source) {
|
|
14377
|
+
return import_plist.default.parse(source);
|
|
14378
|
+
}
|
|
14379
|
+
|
|
14380
|
+
// src/swiftDiscoveryContract.ts
|
|
14381
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14382
|
+
|
|
14383
|
+
// scripts/optional-demo-registry.ts
|
|
14384
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14385
|
+
|
|
14386
|
+
// scripts/dev-server-scanner.ts
|
|
14387
|
+
var LISTENER_LOCK_PATH = (0, import_node_path8.join)((0, import_node_os3.tmpdir)(), "peach-listener-scan.lock");
|
|
14388
|
+
var LISTENER_RESULT_PATH = (0, import_node_path8.join)((0, import_node_os3.tmpdir)(), "peach-listener-scan.result");
|
|
14389
|
+
var LISTENER_LOCK_STALE_MS = 25e3;
|
|
14390
|
+
var LISTENER_LOCK_WAIT_MS = 8e3;
|
|
14391
|
+
function sleep2(ms) {
|
|
14392
|
+
return new Promise((resolve5) => setTimeout(resolve5, ms));
|
|
14393
|
+
}
|
|
14394
|
+
function pidIsAlive(pid) {
|
|
14395
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
14396
|
+
try {
|
|
14397
|
+
process.kill(pid, 0);
|
|
14398
|
+
return true;
|
|
14399
|
+
} catch (error) {
|
|
14400
|
+
const code = error && typeof error === "object" && "code" in error ? String(error.code) : "";
|
|
14401
|
+
return code !== "ESRCH";
|
|
14402
|
+
}
|
|
14403
|
+
}
|
|
14404
|
+
function readLockOwner() {
|
|
14405
|
+
try {
|
|
14406
|
+
const raw = (0, import_node_fs9.readFileSync)(LISTENER_LOCK_PATH, "utf8");
|
|
14407
|
+
const mtimeMs = (0, import_node_fs9.statSync)(LISTENER_LOCK_PATH).mtimeMs;
|
|
14408
|
+
const pid = Number(raw.split("-")[0]);
|
|
14409
|
+
return { raw, pid: Number.isInteger(pid) ? pid : -1, mtimeMs };
|
|
14410
|
+
} catch {
|
|
14411
|
+
return null;
|
|
14412
|
+
}
|
|
14413
|
+
}
|
|
14414
|
+
function lockIsAbandoned(owner) {
|
|
14415
|
+
if (owner.pid <= 0 || !pidIsAlive(owner.pid)) return true;
|
|
14416
|
+
return Date.now() - owner.mtimeMs > LISTENER_LOCK_STALE_MS;
|
|
14417
|
+
}
|
|
14418
|
+
function clearLock(raw) {
|
|
14419
|
+
try {
|
|
14420
|
+
if ((0, import_node_fs9.readFileSync)(LISTENER_LOCK_PATH, "utf8") !== raw) return;
|
|
14421
|
+
(0, import_node_fs9.unlinkSync)(LISTENER_LOCK_PATH);
|
|
14422
|
+
} catch {
|
|
14423
|
+
}
|
|
14424
|
+
}
|
|
14425
|
+
function readResult() {
|
|
14426
|
+
try {
|
|
14427
|
+
const parsed = JSON.parse(
|
|
14428
|
+
(0, import_node_fs9.readFileSync)(LISTENER_RESULT_PATH, "utf8")
|
|
14429
|
+
);
|
|
14430
|
+
if (!parsed || typeof parsed.token !== "string" || typeof parsed.key !== "string")
|
|
14431
|
+
return null;
|
|
14432
|
+
return parsed;
|
|
14433
|
+
} catch {
|
|
14434
|
+
return null;
|
|
14435
|
+
}
|
|
14436
|
+
}
|
|
14437
|
+
function publishResult(payload) {
|
|
14438
|
+
const tmp = `${LISTENER_RESULT_PATH}.${process.pid}.tmp`;
|
|
14439
|
+
(0, import_node_fs9.writeFileSync)(tmp, JSON.stringify(payload));
|
|
14440
|
+
(0, import_node_fs9.renameSync)(tmp, LISTENER_RESULT_PATH);
|
|
14441
|
+
}
|
|
14442
|
+
function throwPublished(payload) {
|
|
14443
|
+
throw Object.assign(new Error(payload.message || "listener scan failed"), {
|
|
14444
|
+
killed: payload.killed === true
|
|
14445
|
+
});
|
|
14446
|
+
}
|
|
14447
|
+
async function waitForSharedResult(owner, key) {
|
|
14448
|
+
const cap = Date.now() + LISTING_TIMEOUT_MS;
|
|
14449
|
+
let current = owner;
|
|
14450
|
+
while (Date.now() < cap) {
|
|
14451
|
+
const published = readResult();
|
|
14452
|
+
if (published && published.token === current.raw) {
|
|
14453
|
+
if (published.key !== key) return { kind: "retry" };
|
|
14454
|
+
if (!published.ok) throwPublished(published);
|
|
14455
|
+
return { kind: "value", value: published.value };
|
|
14456
|
+
}
|
|
14457
|
+
const latest = readLockOwner();
|
|
14458
|
+
if (!latest) {
|
|
14459
|
+
const again = readResult();
|
|
14460
|
+
if (again && again.token === current.raw && again.key === key) {
|
|
14461
|
+
if (!again.ok) throwPublished(again);
|
|
14462
|
+
return { kind: "value", value: again.value };
|
|
14463
|
+
}
|
|
14464
|
+
return { kind: "retry" };
|
|
14465
|
+
}
|
|
14466
|
+
if (latest.raw !== current.raw) current = latest;
|
|
14467
|
+
if (lockIsAbandoned(latest)) {
|
|
14468
|
+
clearLock(latest.raw);
|
|
14469
|
+
return { kind: "retry" };
|
|
14470
|
+
}
|
|
14471
|
+
await sleep2(25);
|
|
14472
|
+
}
|
|
14473
|
+
throw Object.assign(new Error("listener scan lock was held past the wait"), {
|
|
14474
|
+
killed: true
|
|
14475
|
+
});
|
|
14476
|
+
}
|
|
14477
|
+
async function withListenerLock(key, body) {
|
|
14478
|
+
const token = `${process.pid}-${Date.now()}-${Math.random()}`;
|
|
14479
|
+
const deadline = Date.now() + LISTENER_LOCK_WAIT_MS;
|
|
14480
|
+
for (; ; ) {
|
|
14481
|
+
let fd = null;
|
|
14482
|
+
try {
|
|
14483
|
+
fd = (0, import_node_fs9.openSync)(LISTENER_LOCK_PATH, "wx");
|
|
14484
|
+
} catch (error) {
|
|
14485
|
+
const code = error instanceof Error && "code" in error ? error.code : "";
|
|
14486
|
+
if (code !== "EEXIST") throw error;
|
|
14487
|
+
const owner = readLockOwner();
|
|
14488
|
+
if (!owner || lockIsAbandoned(owner)) {
|
|
14489
|
+
if (owner) clearLock(owner.raw);
|
|
14490
|
+
else {
|
|
14491
|
+
try {
|
|
14492
|
+
(0, import_node_fs9.unlinkSync)(LISTENER_LOCK_PATH);
|
|
14493
|
+
} catch {
|
|
14494
|
+
}
|
|
14495
|
+
}
|
|
14496
|
+
continue;
|
|
14497
|
+
}
|
|
14498
|
+
if (Date.now() >= deadline) {
|
|
14499
|
+
const shared = await waitForSharedResult(owner, key);
|
|
14500
|
+
if (shared.kind === "value") return shared.value;
|
|
14501
|
+
continue;
|
|
14502
|
+
}
|
|
14503
|
+
await sleep2(25);
|
|
14504
|
+
continue;
|
|
14505
|
+
}
|
|
14506
|
+
if (fd === null) continue;
|
|
14507
|
+
try {
|
|
14508
|
+
(0, import_node_fs9.writeSync)(fd, token);
|
|
14509
|
+
try {
|
|
14510
|
+
const value = await body();
|
|
14511
|
+
publishResult({ token, key, ok: true, value });
|
|
14512
|
+
return value;
|
|
14513
|
+
} catch (error) {
|
|
14514
|
+
publishResult({
|
|
14515
|
+
token,
|
|
14516
|
+
key,
|
|
14517
|
+
ok: false,
|
|
14518
|
+
message: error instanceof Error ? error.message : String(error),
|
|
14519
|
+
killed: !!(error && typeof error === "object" && error.killed)
|
|
14520
|
+
});
|
|
14521
|
+
throw error;
|
|
14522
|
+
}
|
|
14523
|
+
} finally {
|
|
14524
|
+
try {
|
|
14525
|
+
(0, import_node_fs9.closeSync)(fd);
|
|
14526
|
+
} catch {
|
|
14527
|
+
}
|
|
14528
|
+
clearLock(token);
|
|
14529
|
+
}
|
|
14530
|
+
}
|
|
14531
|
+
}
|
|
14532
|
+
function spawnReaped(file, args, timeoutMs, maxBuffer = 1024 * 1024) {
|
|
14533
|
+
return withListenerLock(
|
|
14534
|
+
`${file}\0${args.join("\0")}`,
|
|
14535
|
+
() => new Promise((resolvePromise, reject) => {
|
|
14536
|
+
const child = (0, import_child_process2.spawn)(file, args, {
|
|
14537
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
14538
|
+
});
|
|
14539
|
+
let stdout = "";
|
|
14540
|
+
let settled = false;
|
|
14541
|
+
let timedOut = false;
|
|
14542
|
+
let overflow = false;
|
|
14543
|
+
let spawnError = null;
|
|
14544
|
+
const timeoutError = () => Object.assign(new Error(`\`${file}\` did not exit within ${timeoutMs}ms`), {
|
|
14545
|
+
killed: true
|
|
14546
|
+
});
|
|
14547
|
+
const finish = (err, code) => {
|
|
14548
|
+
if (settled) return;
|
|
14549
|
+
settled = true;
|
|
14550
|
+
clearTimeout(deadline);
|
|
14551
|
+
clearTimeout(backup);
|
|
14552
|
+
if (err) reject(err);
|
|
14553
|
+
else resolvePromise({ stdout, code });
|
|
14554
|
+
};
|
|
14555
|
+
const killChild = () => {
|
|
14556
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
14557
|
+
try {
|
|
14558
|
+
child.kill("SIGKILL");
|
|
14559
|
+
} catch {
|
|
14560
|
+
}
|
|
14561
|
+
};
|
|
14562
|
+
let backup;
|
|
14563
|
+
const deadline = setTimeout(() => {
|
|
14564
|
+
timedOut = true;
|
|
14565
|
+
killChild();
|
|
14566
|
+
backup = setTimeout(() => finish(timeoutError(), null), 1e3);
|
|
14567
|
+
}, timeoutMs);
|
|
14568
|
+
child.stdout?.setEncoding("utf8");
|
|
14569
|
+
child.stderr?.on("data", () => {
|
|
14570
|
+
});
|
|
14571
|
+
child.stdout?.on("data", (chunk) => {
|
|
14572
|
+
stdout += chunk;
|
|
14573
|
+
if (stdout.length > maxBuffer) {
|
|
14574
|
+
overflow = true;
|
|
14575
|
+
killChild();
|
|
14576
|
+
}
|
|
14577
|
+
});
|
|
14578
|
+
child.on("error", (err) => {
|
|
14579
|
+
spawnError = err;
|
|
14580
|
+
killChild();
|
|
14581
|
+
});
|
|
14582
|
+
child.on("close", (code) => {
|
|
14583
|
+
if (timedOut) finish(timeoutError(), code);
|
|
14584
|
+
else if (overflow)
|
|
14585
|
+
finish(new Error(`\`${file}\` exceeded maxBuffer ${maxBuffer}`), code);
|
|
14586
|
+
else if (spawnError && !stdout) finish(spawnError, code);
|
|
14587
|
+
else finish(null, code);
|
|
14588
|
+
});
|
|
14589
|
+
})
|
|
14590
|
+
);
|
|
14591
|
+
}
|
|
14592
|
+
var FALLBACK_PORTS = [
|
|
14593
|
+
8081,
|
|
14594
|
+
8082,
|
|
14595
|
+
8083,
|
|
14596
|
+
8084,
|
|
14597
|
+
8085,
|
|
14598
|
+
8086,
|
|
14599
|
+
3e3,
|
|
14600
|
+
3001,
|
|
14601
|
+
19e3
|
|
14602
|
+
].map((port) => ({ port, pid: 0 }));
|
|
14603
|
+
var LISTING_TIMEOUT_MS = 1e4;
|
|
14604
|
+
function wasKilledByTimeout(err) {
|
|
14605
|
+
return !!(err && typeof err === "object" && err.killed);
|
|
14606
|
+
}
|
|
14607
|
+
var LISTENER_CACHE_MS = 2e3;
|
|
14608
|
+
var listenerCache = null;
|
|
14609
|
+
var inflightListing = null;
|
|
14610
|
+
var listenerHolds = 0;
|
|
14611
|
+
function cachedPidsAlive(scan) {
|
|
14612
|
+
if (scan.state !== "looked") return true;
|
|
14613
|
+
return scan.processes.every((entry) => entry.pid <= 0 || pidIsAlive(entry.pid));
|
|
14614
|
+
}
|
|
14615
|
+
async function cachedPortsStillHeld(scan) {
|
|
14616
|
+
if (scan.state !== "looked") return true;
|
|
14617
|
+
const owned = scan.processes.filter((entry) => entry.pid > 0);
|
|
14618
|
+
if (owned.length === 0) return true;
|
|
14619
|
+
const pids = [...new Set(owned.map((entry) => entry.pid))];
|
|
14620
|
+
try {
|
|
14621
|
+
const { stdout, code } = await spawnReaped(
|
|
14622
|
+
"lsof",
|
|
14623
|
+
["-nP", "-b", "-w", "-a", "-p", pids.join(","), "-iTCP", "-sTCP:LISTEN", "-Fpcn"],
|
|
14624
|
+
8e3,
|
|
14625
|
+
16 * 1024 * 1024
|
|
14626
|
+
);
|
|
14627
|
+
if (code !== 0 && code !== 1) return false;
|
|
14628
|
+
const live = new Set(
|
|
14629
|
+
parseLsofListeners(stdout).map((entry) => `${entry.port}:${entry.pid}`)
|
|
14630
|
+
);
|
|
14631
|
+
return owned.every((entry) => live.has(`${entry.port}:${entry.pid}`));
|
|
14632
|
+
} catch {
|
|
14633
|
+
return false;
|
|
14634
|
+
}
|
|
14635
|
+
}
|
|
14636
|
+
function listListenersShared() {
|
|
14637
|
+
inflightListing ??= loadListeners().finally(() => {
|
|
14638
|
+
inflightListing = null;
|
|
14639
|
+
});
|
|
14640
|
+
return inflightListing;
|
|
14641
|
+
}
|
|
14642
|
+
async function loadListeners() {
|
|
14643
|
+
const cached2 = listenerCache;
|
|
14644
|
+
if (cached2 && (listenerHolds > 0 || Date.now() - cached2.at < LISTENER_CACHE_MS) && cachedPidsAlive(cached2.scan) && await cachedPortsStillHeld(cached2.scan)) {
|
|
14645
|
+
return cached2.scan;
|
|
14646
|
+
}
|
|
14647
|
+
listenerCache = null;
|
|
14648
|
+
const scan = await listListeners();
|
|
14649
|
+
listenerCache = { at: Date.now(), scan };
|
|
14650
|
+
return scan;
|
|
14651
|
+
}
|
|
14652
|
+
function isSpawnMissing(err) {
|
|
14653
|
+
return !!(err && typeof err === "object" && err.code === "ENOENT");
|
|
14654
|
+
}
|
|
14655
|
+
function parseLsofListeners(stdout) {
|
|
14656
|
+
const seen = /* @__PURE__ */ new Map();
|
|
14657
|
+
let pid = 0;
|
|
14658
|
+
let command = "";
|
|
14659
|
+
for (const line of stdout.split("\n")) {
|
|
14660
|
+
if (line.startsWith("p")) {
|
|
14661
|
+
pid = Number(line.slice(1));
|
|
14662
|
+
command = "";
|
|
14663
|
+
continue;
|
|
14664
|
+
}
|
|
14665
|
+
if (line.startsWith("c")) {
|
|
14666
|
+
command = line.slice(1);
|
|
14667
|
+
continue;
|
|
14668
|
+
}
|
|
14669
|
+
if (!line.startsWith("n") || pid <= 0) continue;
|
|
14670
|
+
if (!/^(node|bun|peach|vite)/.test(command)) continue;
|
|
14671
|
+
const match = line.match(/:(\d+)$/);
|
|
14672
|
+
if (!match) continue;
|
|
14673
|
+
const port = Number(match[1]);
|
|
14674
|
+
if (!seen.has(port)) seen.set(port, pid);
|
|
14675
|
+
}
|
|
14676
|
+
return [...seen.entries()].map(([port, owner]) => ({ port, pid: owner }));
|
|
14677
|
+
}
|
|
14678
|
+
function parseSsListeners(stdout) {
|
|
14679
|
+
const seen = /* @__PURE__ */ new Map();
|
|
14680
|
+
for (const line of stdout.split("\n")) {
|
|
14681
|
+
if (!/"(node|bun|peach|vite)/.test(line)) continue;
|
|
14682
|
+
const portMatch = line.match(/:(\d+)\s/);
|
|
14683
|
+
const pidMatch = line.match(/pid=(\d+)/);
|
|
14684
|
+
if (!portMatch) continue;
|
|
14685
|
+
const port = Number(portMatch[1]);
|
|
14686
|
+
const pid = pidMatch ? Number(pidMatch[1]) : 0;
|
|
14687
|
+
if (!seen.has(port)) seen.set(port, pid);
|
|
14688
|
+
}
|
|
14689
|
+
return [...seen.entries()].map(([port, pid]) => ({ port, pid }));
|
|
14690
|
+
}
|
|
14691
|
+
async function listListeners() {
|
|
14692
|
+
let timedOut = false;
|
|
14693
|
+
try {
|
|
14694
|
+
const { stdout, code } = await spawnReaped(
|
|
14695
|
+
"lsof",
|
|
14696
|
+
[
|
|
14697
|
+
"-nP",
|
|
14698
|
+
"-b",
|
|
14699
|
+
"-w",
|
|
14700
|
+
"-a",
|
|
14701
|
+
"-c",
|
|
14702
|
+
"node",
|
|
14703
|
+
"-c",
|
|
14704
|
+
"bun",
|
|
14705
|
+
"-c",
|
|
14706
|
+
"peach",
|
|
14707
|
+
"-c",
|
|
14708
|
+
"vite",
|
|
14709
|
+
"-iTCP",
|
|
14710
|
+
"-sTCP:LISTEN",
|
|
14711
|
+
"-Fpcn"
|
|
14712
|
+
],
|
|
14713
|
+
LISTING_TIMEOUT_MS,
|
|
14714
|
+
16 * 1024 * 1024
|
|
14715
|
+
);
|
|
14716
|
+
if (code === 0 || code === 1) {
|
|
14717
|
+
return { state: "looked", processes: parseLsofListeners(stdout) };
|
|
14718
|
+
}
|
|
14719
|
+
} catch (err) {
|
|
14720
|
+
if (wasKilledByTimeout(err)) timedOut = true;
|
|
14721
|
+
else if (!isSpawnMissing(err)) return { state: "could-not-look" };
|
|
14722
|
+
}
|
|
14723
|
+
if (!timedOut) {
|
|
14724
|
+
try {
|
|
14725
|
+
const { stdout, code } = await spawnReaped(
|
|
14726
|
+
"ss",
|
|
14727
|
+
["-H", "-ltnp"],
|
|
14728
|
+
LISTING_TIMEOUT_MS,
|
|
14729
|
+
16 * 1024 * 1024
|
|
14730
|
+
);
|
|
14731
|
+
if (code === 0 || code === 1) {
|
|
14732
|
+
return { state: "looked", processes: parseSsListeners(stdout) };
|
|
14733
|
+
}
|
|
14734
|
+
} catch (err) {
|
|
14735
|
+
if (wasKilledByTimeout(err)) timedOut = true;
|
|
14736
|
+
else if (!isSpawnMissing(err)) return { state: "could-not-look" };
|
|
14737
|
+
}
|
|
14738
|
+
}
|
|
14739
|
+
if (timedOut) return { state: "could-not-look" };
|
|
14740
|
+
return { state: "looked", processes: FALLBACK_PORTS };
|
|
14741
|
+
}
|
|
14742
|
+
async function resolveListeningPid(port) {
|
|
14743
|
+
if (!Number.isInteger(port) || port <= 0) return null;
|
|
14744
|
+
const scan = await listListenersShared();
|
|
14745
|
+
if (scan.state !== "looked") return null;
|
|
14746
|
+
const pids = [
|
|
14747
|
+
...new Set(
|
|
14748
|
+
scan.processes.filter((entry) => entry.port === port && entry.pid > 0).map((entry) => entry.pid)
|
|
14749
|
+
)
|
|
14750
|
+
];
|
|
14751
|
+
return pids.length === 1 && pids[0] !== void 0 ? pids[0] : null;
|
|
14752
|
+
}
|
|
14753
|
+
var cwdByPid = /* @__PURE__ */ new Map();
|
|
14754
|
+
var cwdQueue = [];
|
|
14755
|
+
var cwdFlushing = false;
|
|
14756
|
+
function kickCwdFlush() {
|
|
14757
|
+
if (cwdFlushing || cwdQueue.length === 0) return;
|
|
14758
|
+
cwdFlushing = true;
|
|
14759
|
+
void flushCwdQueue().finally(() => {
|
|
14760
|
+
cwdFlushing = false;
|
|
14761
|
+
kickCwdFlush();
|
|
14762
|
+
});
|
|
14763
|
+
}
|
|
14764
|
+
async function flushCwdQueue() {
|
|
14765
|
+
await Promise.resolve();
|
|
14766
|
+
while (cwdQueue.length > 0) {
|
|
14767
|
+
const batch = cwdQueue.splice(0, cwdQueue.length);
|
|
14768
|
+
const pending = [...new Set(batch.map((waiter) => waiter.pid))].filter(
|
|
14769
|
+
(pid) => !cwdByPid.has(pid)
|
|
14770
|
+
);
|
|
14771
|
+
const needLsof = [];
|
|
14772
|
+
for (const pid of pending) {
|
|
14773
|
+
try {
|
|
14774
|
+
const cwd = await (0, import_promises.readlink)(`/proc/${pid}/cwd`);
|
|
14775
|
+
if (cwd) {
|
|
14776
|
+
cwdByPid.set(pid, cwd);
|
|
14777
|
+
continue;
|
|
14778
|
+
}
|
|
14779
|
+
} catch {
|
|
14780
|
+
}
|
|
14781
|
+
needLsof.push(pid);
|
|
14782
|
+
}
|
|
14783
|
+
if (needLsof.length > 0) {
|
|
14784
|
+
let looked = false;
|
|
14785
|
+
try {
|
|
14786
|
+
const { stdout, code } = await spawnReaped(
|
|
14787
|
+
"lsof",
|
|
14788
|
+
["-b", "-w", "-nP", "-a", "-d", "cwd", "-p", needLsof.join(","), "-Fn"],
|
|
14789
|
+
8e3,
|
|
14790
|
+
4 * 1024 * 1024
|
|
14791
|
+
);
|
|
14792
|
+
if (code === 0 || code === 1) {
|
|
14793
|
+
looked = true;
|
|
14794
|
+
let current = 0;
|
|
14795
|
+
for (const line of stdout.split("\n")) {
|
|
14796
|
+
if (line.startsWith("p")) {
|
|
14797
|
+
current = Number(line.slice(1));
|
|
14798
|
+
continue;
|
|
14799
|
+
}
|
|
14800
|
+
if (!line.startsWith("n") || line.length <= 1 || !needLsof.includes(current))
|
|
14801
|
+
continue;
|
|
14802
|
+
const cwd = line.slice(1).trim();
|
|
14803
|
+
if (cwd) cwdByPid.set(current, cwd);
|
|
14804
|
+
}
|
|
14805
|
+
}
|
|
14806
|
+
} catch {
|
|
14807
|
+
}
|
|
14808
|
+
if (looked) {
|
|
14809
|
+
for (const pid of needLsof) {
|
|
14810
|
+
if (!cwdByPid.has(pid)) cwdByPid.set(pid, null);
|
|
14811
|
+
}
|
|
14812
|
+
}
|
|
14813
|
+
}
|
|
14814
|
+
for (const waiter of batch) waiter.resolve(cwdByPid.get(waiter.pid) ?? null);
|
|
14815
|
+
}
|
|
14816
|
+
}
|
|
14817
|
+
function resolveProcessCwd(pid) {
|
|
14818
|
+
if (pid <= 0) return Promise.resolve(null);
|
|
14819
|
+
if (cwdByPid.has(pid)) return Promise.resolve(cwdByPid.get(pid) ?? null);
|
|
14820
|
+
return new Promise((resolveCwd) => {
|
|
14821
|
+
cwdQueue.push({ pid, resolve: resolveCwd });
|
|
14822
|
+
kickCwdFlush();
|
|
14823
|
+
});
|
|
14824
|
+
}
|
|
14825
|
+
|
|
14826
|
+
// src/metro-project-root.ts
|
|
14827
|
+
init_backend_origin();
|
|
14828
|
+
async function resolveMetroProjectRoot(bundleUrl) {
|
|
14829
|
+
const origin = loopbackOriginOf(bundleUrl);
|
|
14830
|
+
if (!origin) return null;
|
|
14831
|
+
const controller = new AbortController();
|
|
14832
|
+
const timer = setTimeout(() => controller.abort(), MANIFEST_PROBE_TIMEOUT_MS);
|
|
14833
|
+
let servedManifest = false;
|
|
14834
|
+
let metroRunning = false;
|
|
14835
|
+
try {
|
|
14836
|
+
const status = await fetch(`${origin}/status`, { signal: controller.signal });
|
|
14837
|
+
const advertisedRoot = status.headers.get("X-React-Native-Project-Root");
|
|
14838
|
+
if (status.ok && advertisedRoot) return decodeURI(advertisedRoot);
|
|
14839
|
+
metroRunning = status.ok && (await status.text()).trim() === "packager-status:running";
|
|
14840
|
+
const res = await fetch(`${origin}/`, {
|
|
14841
|
+
headers: { "expo-platform": "ios", Accept: "application/json" },
|
|
14842
|
+
signal: controller.signal
|
|
14843
|
+
});
|
|
14844
|
+
if (res.ok) {
|
|
14845
|
+
const manifest = parseExpoManifestBody(await res.text());
|
|
14846
|
+
servedManifest = true;
|
|
14847
|
+
let root = manifest;
|
|
14848
|
+
for (const key of ["extra", "expoClient", "_internal", "projectRoot"]) {
|
|
14849
|
+
root = typeof root === "object" && root !== null ? Reflect.get(root, key) : void 0;
|
|
14850
|
+
}
|
|
14851
|
+
if (typeof root === "string" && root.length > 0) return root;
|
|
14852
|
+
}
|
|
14853
|
+
} catch {
|
|
14854
|
+
if (controller.signal.aborted)
|
|
14855
|
+
throw new Error(
|
|
14856
|
+
`Metro project root request timed out after ${MANIFEST_PROBE_TIMEOUT_MS / 1e3}s: ${origin}. Wait for the dev server to finish starting or pass --project-root.`
|
|
14857
|
+
);
|
|
14858
|
+
} finally {
|
|
14859
|
+
clearTimeout(timer);
|
|
14860
|
+
}
|
|
14861
|
+
if (servedManifest || !metroRunning) return null;
|
|
14862
|
+
const port = Number(new URL(origin).port);
|
|
14863
|
+
if (!Number.isFinite(port) || port <= 0) return null;
|
|
14864
|
+
const pid = await resolveListeningPid(port);
|
|
14865
|
+
return pid === null ? null : resolveProcessCwd(pid);
|
|
14866
|
+
}
|
|
14867
|
+
|
|
14868
|
+
// src/host/dev-server-package-versions.ts
|
|
14869
|
+
async function readDevServerPackageVersions(bundleUrl) {
|
|
14870
|
+
if (!bundleUrl.pathname.endsWith(".bundle")) return null;
|
|
14871
|
+
const projectRoot = await resolveMetroProjectRoot(bundleUrl.href);
|
|
14872
|
+
if (!projectRoot) return null;
|
|
14873
|
+
try {
|
|
14874
|
+
await import_fs5.default.promises.access(import_path4.default.join(projectRoot, "package.json"));
|
|
14875
|
+
} catch {
|
|
14876
|
+
return null;
|
|
14877
|
+
}
|
|
14878
|
+
return readInstalledNativePackageVersionsAsync(projectRoot);
|
|
14879
|
+
}
|
|
14880
|
+
|
|
14881
|
+
// src/host/fetch-proxy-overrides.ts
|
|
14882
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14883
|
+
var FETCH_PROXY_NATIVE_USER_AGENT_HEADER = "x-sootsim-native-user-agent";
|
|
14884
|
+
var FETCH_PROXY_FAILURE_PARAM = "peachFailure";
|
|
14885
|
+
var FETCH_PROXY_FAILURE_HEADER = "x-peach-upstream-failure";
|
|
14886
|
+
var FETCH_PROXY_RESPONSE_URL_HEADER = "x-peach-response-url";
|
|
14887
|
+
var FETCH_PROXY_NATIVE_COOKIE_HEADER = "x-peach-native-cookie";
|
|
14888
|
+
var FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER = "x-peach-native-cookie-response";
|
|
14889
|
+
function nativeCookieHopHeader(hop) {
|
|
14890
|
+
return encodeURIComponent(JSON.stringify(hop));
|
|
14891
|
+
}
|
|
14892
|
+
function isNativeCookieRedirect(hop) {
|
|
14893
|
+
return hop.location !== null && [301, 302, 303, 307, 308].includes(hop.status);
|
|
14894
|
+
}
|
|
14895
|
+
function resolveRedirectUrl(location, from) {
|
|
14896
|
+
const next = new URL(location, from);
|
|
14897
|
+
if (!location.includes("#")) next.hash = from.hash;
|
|
14898
|
+
return next;
|
|
14899
|
+
}
|
|
14900
|
+
var HOST_HEADER_OVERRIDES = [
|
|
14901
|
+
{
|
|
14902
|
+
hostSuffix: "uniswap.org",
|
|
14903
|
+
headers: {
|
|
14904
|
+
origin: "https://app.uniswap.org",
|
|
14905
|
+
referer: "https://app.uniswap.org/"
|
|
14906
|
+
}
|
|
14907
|
+
}
|
|
14908
|
+
];
|
|
14909
|
+
function headerOverridesFor(hostname) {
|
|
14910
|
+
const host = hostname.toLowerCase();
|
|
14911
|
+
for (const override of HOST_HEADER_OVERRIDES) {
|
|
14912
|
+
if (host === override.hostSuffix || host.endsWith(`.${override.hostSuffix}`)) {
|
|
14913
|
+
return override;
|
|
14914
|
+
}
|
|
14915
|
+
}
|
|
14916
|
+
return void 0;
|
|
14917
|
+
}
|
|
14918
|
+
var PUBLIC_RPC_TENANT = "rnx-public-rpc";
|
|
14919
|
+
var QUICKNODE_HOST_SUFFIX = ".quiknode.pro";
|
|
14920
|
+
var PUBLIC_RPC_BY_QUICKNODE_CHAIN = {
|
|
14921
|
+
"": "https://ethereum-rpc.publicnode.com",
|
|
14922
|
+
"arbitrum-mainnet": "https://arbitrum-one-rpc.publicnode.com",
|
|
14923
|
+
"avalanche-mainnet": "https://avalanche-c-chain-rpc.publicnode.com",
|
|
14924
|
+
"base-mainnet": "https://base-rpc.publicnode.com",
|
|
14925
|
+
"blast-mainnet": "https://blast-rpc.publicnode.com",
|
|
14926
|
+
bsc: "https://bsc-rpc.publicnode.com",
|
|
14927
|
+
"celo-mainnet": "https://celo-rpc.publicnode.com",
|
|
14928
|
+
matic: "https://polygon-bor-rpc.publicnode.com",
|
|
14929
|
+
optimism: "https://optimism-rpc.publicnode.com",
|
|
14930
|
+
"soneium-mainnet": "https://soneium-rpc.publicnode.com",
|
|
14931
|
+
"unichain-mainnet": "https://unichain-rpc.publicnode.com"
|
|
14932
|
+
};
|
|
14933
|
+
function resolveFetchProxyTargetUrl(requested) {
|
|
14934
|
+
const host = requested.hostname.toLowerCase();
|
|
14935
|
+
if (!host.endsWith(QUICKNODE_HOST_SUFFIX)) return requested;
|
|
14936
|
+
const tenant = host.slice(0, -QUICKNODE_HOST_SUFFIX.length);
|
|
14937
|
+
if (tenant !== PUBLIC_RPC_TENANT && !tenant.startsWith(`${PUBLIC_RPC_TENANT}.`)) {
|
|
14938
|
+
return requested;
|
|
14939
|
+
}
|
|
14940
|
+
const chain = tenant === PUBLIC_RPC_TENANT ? "" : tenant.slice(PUBLIC_RPC_TENANT.length + 1);
|
|
14941
|
+
const replacement = PUBLIC_RPC_BY_QUICKNODE_CHAIN[chain];
|
|
14942
|
+
return replacement ? new URL(replacement) : requested;
|
|
14943
|
+
}
|
|
14944
|
+
var STRIP_FETCH_PROXY_REQUEST_HEADERS = /* @__PURE__ */ new Set([
|
|
14945
|
+
"host",
|
|
14946
|
+
"x-forwarded",
|
|
14947
|
+
"x-real-ip",
|
|
14948
|
+
"forwarded",
|
|
14949
|
+
"origin",
|
|
14950
|
+
"referer",
|
|
14951
|
+
"user-agent",
|
|
14952
|
+
"accept-encoding",
|
|
14953
|
+
"cookie",
|
|
14954
|
+
"connection",
|
|
14955
|
+
"keep-alive",
|
|
14956
|
+
"transfer-encoding",
|
|
14957
|
+
"upgrade",
|
|
14958
|
+
"content-length",
|
|
14959
|
+
"sec-fetch-site",
|
|
14960
|
+
"sec-fetch-mode",
|
|
14961
|
+
"sec-fetch-dest",
|
|
14962
|
+
"sec-ch-ua",
|
|
14963
|
+
"sec-ch-ua-mobile",
|
|
14964
|
+
"sec-ch-ua-platform",
|
|
14965
|
+
FETCH_PROXY_NATIVE_USER_AGENT_HEADER,
|
|
14966
|
+
FETCH_PROXY_NATIVE_COOKIE_HEADER,
|
|
14967
|
+
FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER
|
|
14968
|
+
]);
|
|
14969
|
+
function buildFetchProxyUpstreamHeaders(requestHeaders, targetUrl) {
|
|
14970
|
+
const headers = {};
|
|
14971
|
+
let nativeUserAgent;
|
|
14972
|
+
let nativeCookie;
|
|
14973
|
+
for (const [rawKey, value] of requestHeaders) {
|
|
14974
|
+
const key = rawKey.toLowerCase();
|
|
14975
|
+
if (key === FETCH_PROXY_NATIVE_USER_AGENT_HEADER) nativeUserAgent = value;
|
|
14976
|
+
if (key === FETCH_PROXY_NATIVE_COOKIE_HEADER) nativeCookie = decodeURIComponent(value);
|
|
14977
|
+
if (key.startsWith(":") || STRIP_FETCH_PROXY_REQUEST_HEADERS.has(key) || key.startsWith("x-forwarded-")) {
|
|
14978
|
+
continue;
|
|
14979
|
+
}
|
|
14980
|
+
headers[key] = value;
|
|
14981
|
+
}
|
|
14982
|
+
if (!targetUrl) return headers;
|
|
14983
|
+
return {
|
|
14984
|
+
...headers,
|
|
14985
|
+
"accept-encoding": "identity",
|
|
14986
|
+
...nativeUserAgent ? { "user-agent": nativeUserAgent } : {},
|
|
14987
|
+
...nativeCookie ? { cookie: nativeCookie } : {},
|
|
14988
|
+
...headerOverridesFor(targetUrl.hostname)?.headers
|
|
14989
|
+
};
|
|
14990
|
+
}
|
|
14991
|
+
function nodeRequestHeaderEntries(headers) {
|
|
14992
|
+
const entries = [];
|
|
14993
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
14994
|
+
if (!value) continue;
|
|
14995
|
+
entries.push([key, Array.isArray(value) ? value.join(", ") : value]);
|
|
14996
|
+
}
|
|
14997
|
+
return entries;
|
|
14998
|
+
}
|
|
14999
|
+
|
|
15000
|
+
// src/host/loopback-ports.ts
|
|
15001
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15002
|
+
init_backend_origin();
|
|
15003
|
+
var LOOPBACK_PORTS = /* @__PURE__ */ new Map();
|
|
15004
|
+
for (const pair of process.env.PEACH_LOOPBACK_PORTS?.split(",").filter(Boolean) ?? []) {
|
|
15005
|
+
const match = /^\s*([1-9][0-9]{0,4}):([1-9][0-9]{0,4})\s*$/.exec(pair);
|
|
15006
|
+
const from = Number(match?.[1]);
|
|
15007
|
+
const to = Number(match?.[2]);
|
|
15008
|
+
if (!match || from > 65535 || to > 65535 || LOOPBACK_PORTS.has(from)) {
|
|
15009
|
+
throw new Error(`PEACH_LOOPBACK_PORTS has an invalid entry: ${JSON.stringify(pair)}`);
|
|
15010
|
+
}
|
|
15011
|
+
LOOPBACK_PORTS.set(from, to);
|
|
15012
|
+
}
|
|
15013
|
+
function projectLoopbackPort(hostname, port) {
|
|
15014
|
+
return isLoopbackHost(hostname) ? LOOPBACK_PORTS.get(port) ?? port : port;
|
|
15015
|
+
}
|
|
15016
|
+
|
|
15017
|
+
// src/host/rolldown-bundle-forward.ts
|
|
15018
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15019
|
+
var import_stream = require("stream");
|
|
15020
|
+
var import_promises2 = require("stream/promises");
|
|
15021
|
+
init_cli_runtime();
|
|
15022
|
+
var ROLLDOWN_INVENTORY_HEADER = "x-peach-rolldown-inventory";
|
|
15023
|
+
async function forwardRolldownBundleResponse(upstream, res) {
|
|
15024
|
+
res.setHeader(ROLLDOWN_INVENTORY_HEADER, "1");
|
|
15025
|
+
if (upstream.headers[ROLLDOWN_INVENTORY_HEADER] === "1") {
|
|
15026
|
+
await (0, import_promises2.pipeline)(upstream, res);
|
|
15027
|
+
return;
|
|
15028
|
+
}
|
|
15029
|
+
const contentType = typeof upstream.headers["content-type"] === "string" ? upstream.headers["content-type"] : "";
|
|
15030
|
+
const inventory = getCliRuntime().rolldown_bundle_inventory;
|
|
15031
|
+
res.removeHeader("content-length");
|
|
15032
|
+
const annotate = async function* () {
|
|
15033
|
+
const decoder = new TextDecoder();
|
|
15034
|
+
let payload = "";
|
|
15035
|
+
let sent = 0;
|
|
15036
|
+
let bundleStarted = false;
|
|
15037
|
+
for await (const chunk of upstream) {
|
|
15038
|
+
payload += decoder.decode(chunk, { stream: true });
|
|
15039
|
+
if (bundleStarted) continue;
|
|
15040
|
+
const releasable = inventory.releasableMultipartPrefix(payload, contentType);
|
|
15041
|
+
bundleStarted = releasable.bundleStarted;
|
|
15042
|
+
if (releasable.length > sent) {
|
|
15043
|
+
yield Buffer.from(payload.slice(sent, releasable.length), "utf8");
|
|
15044
|
+
sent = releasable.length;
|
|
15045
|
+
}
|
|
15046
|
+
}
|
|
15047
|
+
payload += decoder.decode();
|
|
15048
|
+
let annotated;
|
|
15049
|
+
try {
|
|
15050
|
+
annotated = await inventory.attachRolldownBundleHttpPayload(payload, contentType);
|
|
15051
|
+
} catch (error) {
|
|
15052
|
+
const message = `could not attach the rolldown bundle inventory: ${error instanceof Error ? error.message : String(error)}`;
|
|
15053
|
+
console.error(`[peach] ${message}`);
|
|
15054
|
+
if (contentType.toLowerCase().includes("multipart/mixed")) {
|
|
15055
|
+
yield Buffer.from(
|
|
15056
|
+
inventory.multipartFailurePart(contentType, message, payload.slice(0, sent)),
|
|
15057
|
+
"utf8"
|
|
15058
|
+
);
|
|
15059
|
+
return;
|
|
15060
|
+
}
|
|
15061
|
+
res.statusCode = 500;
|
|
15062
|
+
res.setHeader("content-type", "application/json");
|
|
15063
|
+
yield Buffer.from(JSON.stringify({ message }), "utf8");
|
|
15064
|
+
return;
|
|
15065
|
+
}
|
|
15066
|
+
yield Buffer.from(annotated.slice(sent), "utf8");
|
|
15067
|
+
};
|
|
15068
|
+
await (0, import_promises2.pipeline)(import_stream.Readable.from(annotate(), { objectMode: false }), res);
|
|
15069
|
+
}
|
|
15070
|
+
|
|
15071
|
+
// src/host/fetch-proxy-handler.ts
|
|
15072
|
+
var fetchProxyHttpAgent = new import_http.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
15073
|
+
var fetchProxyHttpsAgent = new import_https.default.Agent({ keepAlive: true, maxSockets: 256 });
|
|
15074
|
+
function fetchProxyAgentFor(targetUrl) {
|
|
15075
|
+
return targetUrl.protocol === "https:" ? fetchProxyHttpsAgent : fetchProxyHttpAgent;
|
|
15076
|
+
}
|
|
15077
|
+
var FETCH_PROXY_CORS_HEADERS = {
|
|
15078
|
+
"access-control-allow-methods": "GET,HEAD,POST,PUT,DELETE,PATCH,OPTIONS",
|
|
15079
|
+
"access-control-max-age": "3600"
|
|
15080
|
+
};
|
|
15081
|
+
var APP_API_HEADER_REWRITES = /* @__PURE__ */ new Set([
|
|
15082
|
+
"host",
|
|
15083
|
+
"origin",
|
|
15084
|
+
"referer",
|
|
15085
|
+
"sec-fetch-site",
|
|
15086
|
+
"sec-fetch-mode",
|
|
15087
|
+
"sec-fetch-dest"
|
|
15088
|
+
]);
|
|
15089
|
+
function loopbackTlsOptions(targetUrl) {
|
|
15090
|
+
if (targetUrl.protocol !== "https:") return {};
|
|
15091
|
+
return isLoopbackHost(targetUrl.hostname) ? { rejectUnauthorized: false } : {};
|
|
15092
|
+
}
|
|
15093
|
+
function applyFetchProxyCors(req, res) {
|
|
15094
|
+
for (const [key, value] of Object.entries(FETCH_PROXY_CORS_HEADERS)) {
|
|
15095
|
+
res.setHeader(key, value);
|
|
15096
|
+
}
|
|
15097
|
+
res.setHeader("access-control-allow-origin", req.headers.origin ?? "*");
|
|
15098
|
+
res.setHeader("access-control-allow-credentials", "true");
|
|
15099
|
+
res.setHeader(
|
|
15100
|
+
"access-control-allow-headers",
|
|
15101
|
+
req.headers["access-control-request-headers"] ?? "*"
|
|
15102
|
+
);
|
|
15103
|
+
res.setHeader(
|
|
15104
|
+
"access-control-expose-headers",
|
|
15105
|
+
[
|
|
15106
|
+
...Object.keys(res.getHeaders()).filter(
|
|
15107
|
+
(name2) => !name2.startsWith("access-control-")
|
|
15108
|
+
),
|
|
15109
|
+
"x-sootsim-set-cookie"
|
|
15110
|
+
].join(", ")
|
|
15111
|
+
);
|
|
15112
|
+
const vary = res.getHeader("vary");
|
|
15113
|
+
res.setHeader(
|
|
15114
|
+
"vary",
|
|
15115
|
+
vary ? `${Array.isArray(vary) ? vary.join(", ") : vary}, Origin` : "Origin"
|
|
15116
|
+
);
|
|
15117
|
+
}
|
|
15118
|
+
function buildFetchProxyHeaders(reqHeaders, targetUrl) {
|
|
15119
|
+
return buildFetchProxyUpstreamHeaders(nodeRequestHeaderEntries(reqHeaders), targetUrl);
|
|
15120
|
+
}
|
|
15121
|
+
function buildAppApiProxyHeaders(reqHeaders, targetUrl) {
|
|
15122
|
+
const headers = {};
|
|
15123
|
+
for (const [key, value] of Object.entries(reqHeaders)) {
|
|
15124
|
+
if (!value) continue;
|
|
15125
|
+
if (key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_HEADER || key.toLowerCase() === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || reqHeaders[FETCH_PROXY_NATIVE_COOKIE_HEADER] !== void 0 && key.toLowerCase() === "cookie" || APP_API_HEADER_REWRITES.has(key.toLowerCase()))
|
|
15126
|
+
continue;
|
|
15127
|
+
headers[key] = value;
|
|
15128
|
+
}
|
|
15129
|
+
const nativeCookie = reqHeaders[FETCH_PROXY_NATIVE_COOKIE_HEADER];
|
|
15130
|
+
if (typeof nativeCookie === "string" && nativeCookie)
|
|
15131
|
+
headers.cookie = decodeURIComponent(nativeCookie);
|
|
15132
|
+
headers.host = targetUrl.host;
|
|
15133
|
+
if (!Object.keys(headers).some((name2) => name2.toLowerCase() === "mobile-origin")) {
|
|
15134
|
+
headers.origin = targetUrl.origin;
|
|
15135
|
+
headers.referer = `${targetUrl.origin}/`;
|
|
15136
|
+
}
|
|
15137
|
+
return headers;
|
|
15138
|
+
}
|
|
15139
|
+
function rejectUntrustedBridgeOrigin(req, res) {
|
|
15140
|
+
if (isTrustedBridgeRequest(req.headers)) return false;
|
|
15141
|
+
res.statusCode = 403;
|
|
15142
|
+
res.setHeader("Content-Type", "text/plain; charset=utf-8");
|
|
15143
|
+
res.end(`peach bridge: origin ${req.headers.origin} may not use this bridge`);
|
|
15144
|
+
return true;
|
|
15145
|
+
}
|
|
15146
|
+
function isFetchProxyRequestUrl(rawUrl) {
|
|
15147
|
+
return rawUrl?.startsWith("/__fetch-proxy?") || rawUrl?.startsWith("/__proxy?") || false;
|
|
15148
|
+
}
|
|
15149
|
+
function isBundleProxyRequestUrl(rawUrl) {
|
|
15150
|
+
return rawUrl?.startsWith("/__bundle-proxy?") ?? false;
|
|
15151
|
+
}
|
|
15152
|
+
function isAppApiRequestUrl(rawUrl) {
|
|
15153
|
+
if (!rawUrl) return false;
|
|
15154
|
+
if (rawUrl.startsWith("/__app-api?")) return true;
|
|
15155
|
+
if (rawUrl.startsWith("/__app-api/")) return true;
|
|
15156
|
+
return false;
|
|
15157
|
+
}
|
|
15158
|
+
async function handleFetchProxyRequest(req, res) {
|
|
15159
|
+
if (req.method === "OPTIONS") {
|
|
15160
|
+
applyFetchProxyCors(req, res);
|
|
15161
|
+
res.statusCode = 204;
|
|
15162
|
+
res.end();
|
|
15163
|
+
return;
|
|
15164
|
+
}
|
|
15165
|
+
const params = new URLSearchParams((req.url || "").split("?")[1] || "");
|
|
15166
|
+
const targetUrl = params.get("url");
|
|
15167
|
+
if (!targetUrl) {
|
|
15168
|
+
applyFetchProxyCors(req, res);
|
|
15169
|
+
res.statusCode = 400;
|
|
15170
|
+
res.setHeader("Content-Type", "text/plain");
|
|
15171
|
+
res.end("missing url param");
|
|
15172
|
+
return;
|
|
15173
|
+
}
|
|
15174
|
+
let upstreamUrl;
|
|
15175
|
+
try {
|
|
15176
|
+
upstreamUrl = resolveFetchProxyTargetUrl(new URL(targetUrl));
|
|
15177
|
+
} catch {
|
|
15178
|
+
applyFetchProxyCors(req, res);
|
|
15179
|
+
res.statusCode = 400;
|
|
15180
|
+
res.setHeader("Content-Type", "text/plain");
|
|
15181
|
+
res.end("invalid url param");
|
|
15182
|
+
return;
|
|
15183
|
+
}
|
|
15184
|
+
const packageVersionsRead = isBundleProxyRequestUrl(req.url) && req.method === "GET" ? readDevServerPackageVersions(upstreamUrl) : null;
|
|
15185
|
+
packageVersionsRead?.catch(() => {
|
|
15186
|
+
});
|
|
15187
|
+
await proxyUpstream(req, res, upstreamUrl, params.has(FETCH_PROXY_FAILURE_PARAM), {
|
|
15188
|
+
requestHeaders: (target) => buildFetchProxyHeaders(req.headers, target),
|
|
15189
|
+
respond: async (upstream, setCookies) => {
|
|
15190
|
+
for (const [key, value] of Object.entries(upstream.headers)) {
|
|
15191
|
+
const lowerKey = key.toLowerCase();
|
|
15192
|
+
if (value === void 0 || lowerKey === "set-cookie" || lowerKey === "connection" || lowerKey === "keep-alive" || lowerKey === "proxy-authenticate" || lowerKey === "proxy-authorization" || lowerKey === "te" || lowerKey === "trailer" || lowerKey === "transfer-encoding" || lowerKey === "upgrade" || lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER || lowerKey.startsWith("access-control-")) {
|
|
15193
|
+
continue;
|
|
15194
|
+
}
|
|
15195
|
+
res.setHeader(key, value);
|
|
15196
|
+
}
|
|
15197
|
+
if (packageVersionsRead && upstream.statusCode === 200 && !res.hasHeader(PACKAGE_VERSIONS_HEADER)) {
|
|
15198
|
+
const packageVersions = await packageVersionsRead;
|
|
15199
|
+
if (packageVersions)
|
|
15200
|
+
res.setHeader(PACKAGE_VERSIONS_HEADER, JSON.stringify(packageVersions));
|
|
15201
|
+
}
|
|
15202
|
+
applyFetchProxyCors(req, res);
|
|
15203
|
+
if (setCookies.length > 0)
|
|
15204
|
+
res.setHeader("x-sootsim-set-cookie", setCookies.join(", "));
|
|
15205
|
+
}
|
|
15206
|
+
});
|
|
15207
|
+
}
|
|
15208
|
+
function handleAppApiRequest(req, res) {
|
|
15209
|
+
const reqUrl = req.url || "";
|
|
15210
|
+
let targetPath = "";
|
|
15211
|
+
let targetOrigin = "";
|
|
15212
|
+
let reportFailure = false;
|
|
15213
|
+
if (reqUrl.startsWith("/__app-api?")) {
|
|
15214
|
+
const parsed = new URL(reqUrl, "http://sootsim.local");
|
|
15215
|
+
targetPath = parsed.searchParams.get("path") || "";
|
|
15216
|
+
targetOrigin = parsed.searchParams.get("origin")?.trim() || "";
|
|
15217
|
+
reportFailure = parsed.searchParams.has(FETCH_PROXY_FAILURE_PARAM);
|
|
15218
|
+
} else if (reqUrl.startsWith("/__app-api/")) {
|
|
15219
|
+
targetPath = reqUrl.slice("/__app-api".length);
|
|
15220
|
+
} else {
|
|
15221
|
+
return false;
|
|
15222
|
+
}
|
|
15223
|
+
if (!targetOrigin) {
|
|
15224
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
15225
|
+
res.end("app-api: missing origin query param");
|
|
15226
|
+
return true;
|
|
15227
|
+
}
|
|
15228
|
+
if (req.method === "OPTIONS") {
|
|
15229
|
+
res.writeHead(204, {
|
|
15230
|
+
"Access-Control-Allow-Origin": req.headers.origin || "*",
|
|
15231
|
+
"Access-Control-Allow-Methods": "GET,POST,PUT,PATCH,DELETE,OPTIONS",
|
|
15232
|
+
"Access-Control-Allow-Headers": req.headers["access-control-request-headers"] || "*",
|
|
15233
|
+
"Access-Control-Allow-Credentials": "true",
|
|
15234
|
+
"Access-Control-Max-Age": "86400"
|
|
15235
|
+
});
|
|
15236
|
+
res.end();
|
|
15237
|
+
return true;
|
|
15238
|
+
}
|
|
15239
|
+
let targetUrl;
|
|
15240
|
+
try {
|
|
15241
|
+
targetUrl = new URL(targetPath, targetOrigin);
|
|
15242
|
+
} catch {
|
|
15243
|
+
res.writeHead(400, { "Content-Type": "text/plain" });
|
|
15244
|
+
res.end("app-api: invalid origin or path");
|
|
15245
|
+
return true;
|
|
15246
|
+
}
|
|
15247
|
+
void proxyUpstream(req, res, targetUrl, reportFailure, {
|
|
15248
|
+
requestHeaders: (target) => buildAppApiProxyHeaders(req.headers, target),
|
|
15249
|
+
respond: (upstream, setCookies) => {
|
|
15250
|
+
for (const [key, value] of Object.entries(upstream.headers)) {
|
|
15251
|
+
const lowerKey = key.toLowerCase();
|
|
15252
|
+
if (value === void 0 || lowerKey === "set-cookie" || lowerKey === FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER || lowerKey === FETCH_PROXY_RESPONSE_URL_HEADER) {
|
|
15253
|
+
continue;
|
|
15254
|
+
}
|
|
15255
|
+
res.setHeader(key, value);
|
|
15256
|
+
}
|
|
15257
|
+
if (setCookies.length > 0 && req.headers[FETCH_PROXY_NATIVE_COOKIE_HEADER] === void 0)
|
|
15258
|
+
res.setHeader("set-cookie", setCookies);
|
|
15259
|
+
res.setHeader("access-control-allow-origin", req.headers.origin || "*");
|
|
15260
|
+
res.setHeader("access-control-allow-credentials", "true");
|
|
15261
|
+
res.setHeader(
|
|
15262
|
+
"access-control-expose-headers",
|
|
15263
|
+
Object.keys(res.getHeaders()).filter((name2) => !name2.startsWith("access-control-") && name2 !== "set-cookie").join(", ")
|
|
15264
|
+
);
|
|
15265
|
+
}
|
|
15266
|
+
});
|
|
15267
|
+
return true;
|
|
15268
|
+
}
|
|
15269
|
+
function serveBrowserProxyRoute(req, res) {
|
|
15270
|
+
if (isBundleProxyRequestUrl(req.url) || isFetchProxyRequestUrl(req.url)) {
|
|
15271
|
+
if (!rejectUntrustedBridgeOrigin(req, res)) void handleFetchProxyRequest(req, res);
|
|
15272
|
+
return true;
|
|
15273
|
+
}
|
|
15274
|
+
if (isAppApiRequestUrl(req.url)) {
|
|
15275
|
+
if (rejectUntrustedBridgeOrigin(req, res)) return true;
|
|
15276
|
+
return handleAppApiRequest(req, res);
|
|
15277
|
+
}
|
|
15278
|
+
return false;
|
|
15279
|
+
}
|
|
15280
|
+
async function proxyUpstream(req, res, upstreamUrl, reportFailure, route) {
|
|
15281
|
+
const originalMethod = req.method || "GET";
|
|
15282
|
+
const proxy = async (targetUrl, method, nextBody, redirects, setCookies) => {
|
|
15283
|
+
const transport = targetUrl.protocol === "https:" ? import_https.default : import_http.default;
|
|
15284
|
+
const targetHeaders = route.requestHeaders(targetUrl);
|
|
15285
|
+
if (targetUrl.origin !== upstreamUrl.origin) {
|
|
15286
|
+
delete targetHeaders.authorization;
|
|
15287
|
+
delete targetHeaders["proxy-authorization"];
|
|
15288
|
+
}
|
|
15289
|
+
if (method === "GET" || method === "HEAD") {
|
|
15290
|
+
delete targetHeaders["content-length"];
|
|
15291
|
+
delete targetHeaders["content-type"];
|
|
15292
|
+
} else if (nextBody) {
|
|
15293
|
+
delete targetHeaders["transfer-encoding"];
|
|
15294
|
+
targetHeaders["content-length"] = String(nextBody.byteLength);
|
|
15295
|
+
}
|
|
15296
|
+
const port = projectLoopbackPort(
|
|
15297
|
+
targetUrl.hostname,
|
|
15298
|
+
Number(targetUrl.port || (targetUrl.protocol === "https:" ? 443 : 80))
|
|
15299
|
+
);
|
|
15300
|
+
let clientAborted = false;
|
|
15301
|
+
const markAborted = () => {
|
|
15302
|
+
clientAborted = true;
|
|
15303
|
+
};
|
|
15304
|
+
req.once("aborted", markAborted);
|
|
15305
|
+
const send = () => new Promise((resolve5, reject) => {
|
|
15306
|
+
let responded = false;
|
|
15307
|
+
const proxyReq = transport.request(
|
|
15308
|
+
{
|
|
15309
|
+
hostname: normalizeHostname(targetUrl.hostname),
|
|
15310
|
+
port,
|
|
15311
|
+
path: targetUrl.pathname + targetUrl.search,
|
|
15312
|
+
method,
|
|
15313
|
+
headers: targetHeaders,
|
|
15314
|
+
agent: fetchProxyAgentFor(targetUrl),
|
|
15315
|
+
...loopbackTlsOptions(targetUrl)
|
|
15316
|
+
},
|
|
15317
|
+
(upstream) => {
|
|
15318
|
+
responded = true;
|
|
15319
|
+
resolve5(upstream);
|
|
15320
|
+
}
|
|
15321
|
+
);
|
|
15322
|
+
const abort = () => proxyReq.destroy();
|
|
15323
|
+
req.once("aborted", abort);
|
|
15324
|
+
proxyReq.once("close", () => req.off("aborted", abort));
|
|
15325
|
+
let failed = false;
|
|
15326
|
+
proxyReq.on("error", (err) => {
|
|
15327
|
+
if (failed) return;
|
|
15328
|
+
failed = true;
|
|
15329
|
+
if (proxyReq.reusedSocket && !responded && !clientAborted && err.code === "ECONNRESET")
|
|
15330
|
+
resolve5(send());
|
|
15331
|
+
else reject(err);
|
|
15332
|
+
});
|
|
15333
|
+
if (nextBody === void 0) proxyReq.end();
|
|
15334
|
+
else proxyReq.end(nextBody);
|
|
15335
|
+
});
|
|
15336
|
+
const proxyRes = await send().finally(() => req.off("aborted", markAborted));
|
|
15337
|
+
const status = proxyRes.statusCode ?? 502;
|
|
15338
|
+
const location = proxyRes.headers.location;
|
|
15339
|
+
const hopCookies = [...setCookies, ...proxyRes.headers["set-cookie"] ?? []];
|
|
15340
|
+
if (req.headers[FETCH_PROXY_NATIVE_COOKIE_HEADER] !== void 0) {
|
|
15341
|
+
const hop = {
|
|
15342
|
+
url: upstreamUrl.href,
|
|
15343
|
+
status,
|
|
15344
|
+
location: location ?? null,
|
|
15345
|
+
cookies: hopCookies,
|
|
15346
|
+
redirectLimit: 10
|
|
15347
|
+
};
|
|
15348
|
+
res.setHeader(FETCH_PROXY_NATIVE_COOKIE_RESPONSE_HEADER, nativeCookieHopHeader(hop));
|
|
15349
|
+
await route.respond(proxyRes, hopCookies);
|
|
15350
|
+
if (isNativeCookieRedirect(hop)) res.removeHeader("location");
|
|
15351
|
+
res.statusCode = isNativeCookieRedirect(hop) ? 200 : status;
|
|
15352
|
+
await (0, import_promises3.pipeline)(proxyRes, res);
|
|
15353
|
+
return;
|
|
15354
|
+
}
|
|
15355
|
+
if (location && (status === 301 || status === 302 || status === 303 || status === 307 || status === 308)) {
|
|
15356
|
+
if (redirects >= 10) {
|
|
15357
|
+
proxyRes.destroy();
|
|
15358
|
+
throw new Error("too many redirects");
|
|
15359
|
+
}
|
|
15360
|
+
const switchToGet = (status === 301 || status === 302) && method === "POST" || status === 303 && method !== "GET" && method !== "HEAD";
|
|
15361
|
+
const redirectUrl = resolveRedirectUrl(location, targetUrl);
|
|
15362
|
+
proxyRes.resume();
|
|
15363
|
+
await (0, import_promises3.finished)(proxyRes);
|
|
15364
|
+
await proxy(
|
|
15365
|
+
redirectUrl,
|
|
15366
|
+
switchToGet ? "GET" : method,
|
|
15367
|
+
switchToGet ? void 0 : nextBody,
|
|
15368
|
+
redirects + 1,
|
|
15369
|
+
hopCookies
|
|
15370
|
+
);
|
|
15371
|
+
return;
|
|
15372
|
+
}
|
|
15373
|
+
if (redirects > 0) res.setHeader(FETCH_PROXY_RESPONSE_URL_HEADER, targetUrl.href);
|
|
15374
|
+
await route.respond(proxyRes, hopCookies);
|
|
15375
|
+
res.statusCode = status;
|
|
15376
|
+
if (isBundleProxyRequestUrl(req.url) && method === "GET" && status === 200 && targetUrl.pathname.endsWith(".bundle")) {
|
|
15377
|
+
await forwardRolldownBundleResponse(proxyRes, res);
|
|
15378
|
+
return;
|
|
15379
|
+
}
|
|
15380
|
+
await (0, import_promises3.pipeline)(proxyRes, res);
|
|
15381
|
+
};
|
|
15382
|
+
let body;
|
|
15383
|
+
try {
|
|
15384
|
+
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
15385
|
+
const chunks = [];
|
|
15386
|
+
for await (const chunk of req) {
|
|
15387
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
15388
|
+
}
|
|
15389
|
+
if (chunks.length > 0) {
|
|
15390
|
+
body = Buffer.concat(chunks);
|
|
15391
|
+
}
|
|
15392
|
+
}
|
|
15393
|
+
await proxy(upstreamUrl, originalMethod, body, 0, []);
|
|
15394
|
+
} catch (err) {
|
|
15395
|
+
const norm = normalizeHostname(upstreamUrl.hostname);
|
|
15396
|
+
if (!res.headersSent && isLoopbackHost(norm) && err?.code === "ECONNREFUSED") {
|
|
15397
|
+
const altHosts = norm === "::1" ? ["127.0.0.1"] : norm === "127.0.0.1" ? ["[::1]"] : ["[::1]", "127.0.0.1"];
|
|
15398
|
+
for (const altHost of altHosts) {
|
|
15399
|
+
try {
|
|
15400
|
+
const altUrl = new URL(upstreamUrl.href);
|
|
15401
|
+
altUrl.hostname = altHost;
|
|
15402
|
+
await proxy(altUrl, originalMethod, body, 0, []);
|
|
15403
|
+
return;
|
|
15404
|
+
} catch {
|
|
15405
|
+
}
|
|
15406
|
+
}
|
|
15407
|
+
}
|
|
15408
|
+
if (!res.headersSent && reportFailure) {
|
|
15409
|
+
const code = err?.code;
|
|
15410
|
+
res.statusCode = 502;
|
|
15411
|
+
res.setHeader(
|
|
15412
|
+
FETCH_PROXY_FAILURE_HEADER,
|
|
15413
|
+
typeof code === "string" ? code : "unknown"
|
|
15414
|
+
);
|
|
15415
|
+
applyFetchProxyCors(req, res);
|
|
15416
|
+
res.end();
|
|
15417
|
+
return;
|
|
15418
|
+
}
|
|
15419
|
+
if (req instanceof import_node_http2.Http2ServerRequest)
|
|
15420
|
+
req.stream.destroy(new Error("fetch proxy upstream failed", { cause: err }));
|
|
15421
|
+
else req.socket.destroy();
|
|
15422
|
+
}
|
|
15423
|
+
}
|
|
15424
|
+
|
|
15425
|
+
// src/vite-plugin-one.ts
|
|
15426
|
+
init_replacement_module_handler();
|
|
15427
|
+
|
|
15428
|
+
// src/one-widget-metadata.ts
|
|
15429
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15430
|
+
var import_node_child_process3 = require("node:child_process");
|
|
15431
|
+
var import_node_crypto5 = require("node:crypto");
|
|
15432
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
15433
|
+
var import_node_module2 = require("node:module");
|
|
15434
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
15435
|
+
var import_node_util = require("node:util");
|
|
15436
|
+
|
|
15437
|
+
// cli/internal-child.ts
|
|
15438
|
+
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15439
|
+
var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
15440
|
+
|
|
14296
15441
|
// src/one-widget-metadata.ts
|
|
15442
|
+
init_is_record();
|
|
14297
15443
|
init_swift_source_file();
|
|
14298
15444
|
init_swift_submit();
|
|
14299
15445
|
var run = (0, import_node_util.promisify)(import_node_child_process3.execFile);
|
|
@@ -14316,8 +15462,8 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
|
14316
15462
|
function configStamp(files) {
|
|
14317
15463
|
return JSON.stringify(
|
|
14318
15464
|
files.map((file) => {
|
|
14319
|
-
if (!
|
|
14320
|
-
const stat =
|
|
15465
|
+
if (!import_node_fs12.default.existsSync(file)) return [file, null];
|
|
15466
|
+
const stat = import_node_fs12.default.statSync(file);
|
|
14321
15467
|
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
14322
15468
|
})
|
|
14323
15469
|
);
|
|
@@ -14328,13 +15474,13 @@ async function readConfig(root) {
|
|
|
14328
15474
|
const reading = reads.get(root);
|
|
14329
15475
|
if (reading) return reading;
|
|
14330
15476
|
const promise = (async () => {
|
|
14331
|
-
(0, import_node_module2.createRequire)(
|
|
14332
|
-
const cache =
|
|
14333
|
-
|
|
14334
|
-
const directory =
|
|
14335
|
-
const script =
|
|
14336
|
-
const result =
|
|
14337
|
-
|
|
15477
|
+
(0, import_node_module2.createRequire)(import_node_path11.default.join(root, "package.json")).resolve("one/vite");
|
|
15478
|
+
const cache = import_node_path11.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
15479
|
+
import_node_fs12.default.mkdirSync(cache, { recursive: true });
|
|
15480
|
+
const directory = import_node_fs12.default.mkdtempSync(import_node_path11.default.join(cache, "read-"));
|
|
15481
|
+
const script = import_node_path11.default.join(directory, "read.mjs");
|
|
15482
|
+
const result = import_node_path11.default.join(directory, "result.json");
|
|
15483
|
+
import_node_fs12.default.writeFileSync(script, CONFIG_CHILD);
|
|
14338
15484
|
try {
|
|
14339
15485
|
await run(process.execPath, [script, result], {
|
|
14340
15486
|
cwd: root,
|
|
@@ -14342,7 +15488,7 @@ async function readConfig(root) {
|
|
|
14342
15488
|
timeout: 3e4,
|
|
14343
15489
|
maxBuffer: 1024 * 1024
|
|
14344
15490
|
});
|
|
14345
|
-
const value = JSON.parse(
|
|
15491
|
+
const value = JSON.parse(import_node_fs12.default.readFileSync(result, "utf8"));
|
|
14346
15492
|
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
14347
15493
|
throw new Error("One config loader returned invalid dependencies");
|
|
14348
15494
|
if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
|
|
@@ -14365,8 +15511,8 @@ async function readConfig(root) {
|
|
|
14365
15511
|
}
|
|
14366
15512
|
const watched = [
|
|
14367
15513
|
.../* @__PURE__ */ new Set([
|
|
14368
|
-
|
|
14369
|
-
...value.watched.map((file) =>
|
|
15514
|
+
import_node_path11.default.join(root, "package.json"),
|
|
15515
|
+
...value.watched.map((file) => import_node_path11.default.resolve(root, file))
|
|
14370
15516
|
])
|
|
14371
15517
|
];
|
|
14372
15518
|
const loaded3 = {
|
|
@@ -14378,7 +15524,7 @@ async function readConfig(root) {
|
|
|
14378
15524
|
configs.set(root, loaded3);
|
|
14379
15525
|
return loaded3;
|
|
14380
15526
|
} finally {
|
|
14381
|
-
|
|
15527
|
+
import_node_fs12.default.rmSync(directory, { recursive: true, force: true });
|
|
14382
15528
|
}
|
|
14383
15529
|
})();
|
|
14384
15530
|
reads.set(root, promise);
|
|
@@ -14399,13 +15545,13 @@ function declaredFamilies(source) {
|
|
|
14399
15545
|
return home;
|
|
14400
15546
|
}
|
|
14401
15547
|
async function readOneWidgetSources(appRoot) {
|
|
14402
|
-
const root =
|
|
15548
|
+
const root = import_node_fs12.default.realpathSync(appRoot);
|
|
14403
15549
|
const config = await readConfig(root);
|
|
14404
15550
|
if (!config.widget) return null;
|
|
14405
15551
|
const widget = config.widget;
|
|
14406
15552
|
const sourceFiles = {
|
|
14407
|
-
"OneWidget.swift":
|
|
14408
|
-
"OneWidgetContract.swift":
|
|
15553
|
+
"OneWidget.swift": import_node_path11.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
15554
|
+
"OneWidgetContract.swift": import_node_path11.default.join(
|
|
14409
15555
|
root,
|
|
14410
15556
|
"ios",
|
|
14411
15557
|
widget.appName,
|
|
@@ -14415,14 +15561,14 @@ async function readOneWidgetSources(appRoot) {
|
|
|
14415
15561
|
const files = /* @__PURE__ */ new Map();
|
|
14416
15562
|
const sources = {};
|
|
14417
15563
|
for (const [name2, file] of Object.entries(sourceFiles)) {
|
|
14418
|
-
if (!
|
|
15564
|
+
if (!import_node_fs12.default.existsSync(file))
|
|
14419
15565
|
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
14420
15566
|
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
14421
15567
|
const text2 = bytes.toString("utf8");
|
|
14422
15568
|
if (!Buffer.from(text2).equals(bytes))
|
|
14423
15569
|
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
14424
15570
|
files.set(name2, text2);
|
|
14425
|
-
sources[
|
|
15571
|
+
sources[import_node_path11.default.relative(root, file).split(import_node_path11.default.sep).join("/")] = (0, import_node_crypto5.createHash)("sha256").update(bytes).digest("hex");
|
|
14426
15572
|
}
|
|
14427
15573
|
const contract = files.get("OneWidgetContract.swift") ?? "";
|
|
14428
15574
|
const source = files.get("OneWidget.swift") ?? "";
|
|
@@ -14590,7 +15736,7 @@ function peachPlugin(options = {}) {
|
|
|
14590
15736
|
}
|
|
14591
15737
|
res.setHeader(key, value);
|
|
14592
15738
|
}
|
|
14593
|
-
const forward = res.statusCode === 200 ? forwardRolldownBundleResponse(upstream, res) : (0,
|
|
15739
|
+
const forward = res.statusCode === 200 ? forwardRolldownBundleResponse(upstream, res) : (0, import_promises5.pipeline)(upstream, res);
|
|
14594
15740
|
forward.catch(
|
|
14595
15741
|
(error) => res.destroy(error instanceof Error ? error : new Error(String(error)))
|
|
14596
15742
|
);
|
|
@@ -14609,11 +15755,11 @@ function peachPlugin(options = {}) {
|
|
|
14609
15755
|
let swiftModuleRoot;
|
|
14610
15756
|
const moduleRootFor = () => {
|
|
14611
15757
|
if (swiftModuleRoot === void 0) {
|
|
14612
|
-
const moduleRoot =
|
|
14613
|
-
|
|
15758
|
+
const moduleRoot = import_path5.default.resolve(
|
|
15759
|
+
import_path5.default.dirname((0, import_node_url.fileURLToPath)(__sootsim_import_meta_url)),
|
|
14614
15760
|
"../../sootsim-swift"
|
|
14615
15761
|
);
|
|
14616
|
-
swiftModuleRoot =
|
|
15762
|
+
swiftModuleRoot = import_fs6.default.existsSync(import_path5.default.join(moduleRoot, "toolchain.json")) ? moduleRoot : null;
|
|
14617
15763
|
}
|
|
14618
15764
|
return swiftModuleRoot ?? void 0;
|
|
14619
15765
|
};
|
|
@@ -14698,15 +15844,15 @@ function peachPlugin(options = {}) {
|
|
|
14698
15844
|
});
|
|
14699
15845
|
}
|
|
14700
15846
|
server.watcher.on("add", (file) => {
|
|
14701
|
-
if (
|
|
15847
|
+
if (import_path5.default.basename(file) === "Package.swift") swiftPackages = void 0;
|
|
14702
15848
|
});
|
|
14703
15849
|
server.watcher.on("unlink", (file) => {
|
|
14704
|
-
if (
|
|
15850
|
+
if (import_path5.default.basename(file) === "Package.swift") swiftPackages = void 0;
|
|
14705
15851
|
});
|
|
14706
15852
|
let kotlinModuleRoot;
|
|
14707
15853
|
server.watcher.on("all", (_event, file) => {
|
|
14708
15854
|
if (!kotlinModuleRoot) return;
|
|
14709
|
-
if (file.endsWith(".kt") || file.startsWith(`${kotlinModuleRoot}${
|
|
15855
|
+
if (file.endsWith(".kt") || file.startsWith(`${kotlinModuleRoot}${import_path5.default.sep}`))
|
|
14710
15856
|
sendSwiftChange({ type: "kotlin", packageName: "kotlin" });
|
|
14711
15857
|
});
|
|
14712
15858
|
server.middlewares.use((req, res, next) => {
|
|
@@ -14717,7 +15863,7 @@ function peachPlugin(options = {}) {
|
|
|
14717
15863
|
const root = host.peachKotlinModuleRoot();
|
|
14718
15864
|
kotlinModuleRoot = root;
|
|
14719
15865
|
server.watcher.add(
|
|
14720
|
-
["sdk.tar.gz", "toolchain.json"].map((file) =>
|
|
15866
|
+
["sdk.tar.gz", "toolchain.json"].map((file) => import_path5.default.join(root, file))
|
|
14721
15867
|
);
|
|
14722
15868
|
}
|
|
14723
15869
|
const served = await host.serveKotlinRequest(pathname, res, {
|
|
@@ -14748,7 +15894,7 @@ function peachPlugin(options = {}) {
|
|
|
14748
15894
|
for (const packageName of activeSwiftPackages) {
|
|
14749
15895
|
const packagePath = packages.get(packageName);
|
|
14750
15896
|
const widgetChanged = packageName === "OneWidgets" && widgetPackage?.watched.includes(file);
|
|
14751
|
-
if (!widgetChanged && !(packagePath && file.startsWith(`${packagePath}${
|
|
15897
|
+
if (!widgetChanged && !(packagePath && file.startsWith(`${packagePath}${import_path5.default.sep}`)) && !(moduleRoot && file.startsWith(`${moduleRoot}${import_path5.default.sep}`)))
|
|
14752
15898
|
continue;
|
|
14753
15899
|
void packageMetadata(packageName, moduleRoot).then((metadata) => {
|
|
14754
15900
|
sendSwiftChange({
|
|
@@ -14818,7 +15964,7 @@ function peachPlugin(options = {}) {
|
|
|
14818
15964
|
);
|
|
14819
15965
|
};
|
|
14820
15966
|
const buildShellHtml = (runtimeRoot, origin) => {
|
|
14821
|
-
const html =
|
|
15967
|
+
const html = import_fs6.default.readFileSync(import_path5.default.join(runtimeRoot, "index.html"), "utf8");
|
|
14822
15968
|
const lock = readDaemonLockfile();
|
|
14823
15969
|
const bridgePort = lock && isDaemonLockfileFresh(lock) && lock.bridgePort > 0 ? lock.bridgePort : DEFAULT_SOOTSIM_BRIDGE_PORT;
|
|
14824
15970
|
const inject = `<script>(function(){var u=new URL(location.href);var b=${JSON.stringify(bundleForOrigin(origin))};if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',b);window.__sootsimBridgePort=${bridgePort};window.__peachPageServingAuthority='contributor';history.replaceState(null,'','${prefix2}/'+u.search)})()</script>`;
|
|
@@ -14883,6 +16029,7 @@ function peachPlugin(options = {}) {
|
|
|
14883
16029
|
});
|
|
14884
16030
|
});
|
|
14885
16031
|
server.middlewares.use((req, res, next) => {
|
|
16032
|
+
if (serveBrowserProxyRoute(req, res)) return;
|
|
14886
16033
|
const url = req.url || "";
|
|
14887
16034
|
const pathname = url.split("?")[0];
|
|
14888
16035
|
const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers.host);
|
|
@@ -14903,8 +16050,7 @@ function peachPlugin(options = {}) {
|
|
|
14903
16050
|
}
|
|
14904
16051
|
}
|
|
14905
16052
|
if (pathname === prefix2 || pathname === prefix2 + "/") {
|
|
14906
|
-
res
|
|
14907
|
-
res.end(buildShellHtml(runtimeRoot, requestOrigin(req)));
|
|
16053
|
+
sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)));
|
|
14908
16054
|
return;
|
|
14909
16055
|
}
|
|
14910
16056
|
if (pathname.startsWith(prefix2 + "/")) {
|
|
@@ -14916,10 +16062,9 @@ function peachPlugin(options = {}) {
|
|
|
14916
16062
|
serveRuntimeFile(req, res, fullPath);
|
|
14917
16063
|
return;
|
|
14918
16064
|
}
|
|
14919
|
-
const ext =
|
|
16065
|
+
const ext = import_path5.default.extname(pathname);
|
|
14920
16066
|
if (!ext) {
|
|
14921
|
-
res
|
|
14922
|
-
res.end(buildShellHtml(runtimeRoot, requestOrigin(req)));
|
|
16067
|
+
sendShellHtml(res, buildShellHtml(runtimeRoot, requestOrigin(req)));
|
|
14923
16068
|
return;
|
|
14924
16069
|
}
|
|
14925
16070
|
}
|
|
@@ -14943,24 +16088,24 @@ function peachPlugin(options = {}) {
|
|
|
14943
16088
|
|
|
14944
16089
|
// src/metro-plugin.ts
|
|
14945
16090
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14946
|
-
var
|
|
16091
|
+
var import_fs7 = __toESM(require("fs"), 1);
|
|
14947
16092
|
var import_module2 = require("module");
|
|
14948
16093
|
var import_node_crypto8 = require("node:crypto");
|
|
14949
|
-
var
|
|
16094
|
+
var import_path6 = __toESM(require("path"), 1);
|
|
14950
16095
|
init_app_project();
|
|
14951
16096
|
|
|
14952
16097
|
// src/android-autolinking.ts
|
|
14953
16098
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
14954
16099
|
var import_node_child_process4 = require("node:child_process");
|
|
14955
|
-
var
|
|
16100
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
14956
16101
|
var import_node_module3 = require("node:module");
|
|
14957
|
-
var
|
|
16102
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
14958
16103
|
var import_node_util2 = require("node:util");
|
|
14959
16104
|
init_is_record();
|
|
14960
16105
|
var run2 = (0, import_node_util2.promisify)(import_node_child_process4.execFile);
|
|
14961
16106
|
var resolving = /* @__PURE__ */ new Map();
|
|
14962
16107
|
async function resolveExpoAndroidAutolinking(appRoot) {
|
|
14963
|
-
const root =
|
|
16108
|
+
const root = import_node_fs14.default.realpathSync(appRoot);
|
|
14964
16109
|
const existing = resolving.get(root);
|
|
14965
16110
|
if (existing) return existing;
|
|
14966
16111
|
const pending = resolveAndroidModules(root);
|
|
@@ -14974,7 +16119,7 @@ async function resolveExpoAndroidAutolinking(appRoot) {
|
|
|
14974
16119
|
async function resolveAndroidModules(appRoot) {
|
|
14975
16120
|
let autolinker;
|
|
14976
16121
|
try {
|
|
14977
|
-
autolinker = (0, import_node_module3.createRequire)(
|
|
16122
|
+
autolinker = (0, import_node_module3.createRequire)(import_node_path13.default.join(appRoot, "package.json")).resolve(
|
|
14978
16123
|
"expo-modules-autolinking/package.json"
|
|
14979
16124
|
);
|
|
14980
16125
|
} catch (error) {
|
|
@@ -14984,7 +16129,7 @@ async function resolveAndroidModules(appRoot) {
|
|
|
14984
16129
|
const { stdout } = await run2(
|
|
14985
16130
|
process.execPath,
|
|
14986
16131
|
[
|
|
14987
|
-
|
|
16132
|
+
import_node_path13.default.join(import_node_path13.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
14988
16133
|
"resolve",
|
|
14989
16134
|
"--platform",
|
|
14990
16135
|
"android",
|
|
@@ -15219,7 +16364,7 @@ function resolveNativeAppIconArtwork(resources, readText, resourceUri, icons, pr
|
|
|
15219
16364
|
isRecord(dictionary.CFBundleAlternateIcons) ? dictionary.CFBundleAlternateIcons : {}
|
|
15220
16365
|
).map(([name2, declaration]) => [resolveReference(name2), declaration])
|
|
15221
16366
|
);
|
|
15222
|
-
const
|
|
16367
|
+
const resolve5 = (declaration, defaultName) => {
|
|
15223
16368
|
const entry = isRecord(declaration) ? declaration : {};
|
|
15224
16369
|
const name2 = typeof entry.CFBundleIconName === "string" ? resolveReference(entry.CFBundleIconName) : resolveReference(defaultName);
|
|
15225
16370
|
const catalogs = resources.filter(
|
|
@@ -15270,12 +16415,12 @@ function resolveNativeAppIconArtwork(resources, readText, resourceUri, icons, pr
|
|
|
15270
16415
|
return uri ? [{ uri, scale }] : [];
|
|
15271
16416
|
}).sort((a, b) => a.scale - b.scale);
|
|
15272
16417
|
};
|
|
15273
|
-
const primary =
|
|
16418
|
+
const primary = resolve5(dictionary.CFBundlePrimaryIcon, primaryName);
|
|
15274
16419
|
return {
|
|
15275
16420
|
...primary.length ? { primary } : {},
|
|
15276
16421
|
alternates: Object.fromEntries(
|
|
15277
16422
|
alternateNames.flatMap((name2) => {
|
|
15278
|
-
const images =
|
|
16423
|
+
const images = resolve5(alternates[name2], name2);
|
|
15279
16424
|
return images.length ? [[name2, images]] : [];
|
|
15280
16425
|
})
|
|
15281
16426
|
)
|
|
@@ -15382,7 +16527,7 @@ function parseOpenStepPlist(text2) {
|
|
|
15382
16527
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15383
16528
|
var NEVER_MEMBER = /(?:^|\/)(?:Info\.plist|[^/]+\.entitlements|[^/]+\.xcconfig|\.DS_Store)$/;
|
|
15384
16529
|
var BUNDLE_DIR = /\.(xcassets|bundle|lproj|xcdatamodeld|scnassets|spriteatlas|rcproject|storyboardc|icon)$/;
|
|
15385
|
-
function xcodePathResolver(objects, projectDir,
|
|
16530
|
+
function xcodePathResolver(objects, projectDir, join7) {
|
|
15386
16531
|
const parents = /* @__PURE__ */ new Map();
|
|
15387
16532
|
for (const [id, entry] of Object.entries(objects)) {
|
|
15388
16533
|
if (!isDict(entry)) continue;
|
|
@@ -15391,7 +16536,7 @@ function xcodePathResolver(objects, projectDir, join6) {
|
|
|
15391
16536
|
}
|
|
15392
16537
|
}
|
|
15393
16538
|
const paths = /* @__PURE__ */ new Map();
|
|
15394
|
-
const
|
|
16539
|
+
const resolve5 = (id) => {
|
|
15395
16540
|
if (paths.has(id)) return paths.get(id);
|
|
15396
16541
|
paths.set(id, null);
|
|
15397
16542
|
const entry = objects[id];
|
|
@@ -15400,19 +16545,19 @@ function xcodePathResolver(objects, projectDir, join6) {
|
|
|
15400
16545
|
const own = str(entry.path) ?? "";
|
|
15401
16546
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
15402
16547
|
if (tree === "<absolute>") result = own;
|
|
15403
|
-
else if (tree === "SOURCE_ROOT") result =
|
|
16548
|
+
else if (tree === "SOURCE_ROOT") result = join7(projectDir, own);
|
|
15404
16549
|
else if (tree === "<group>") {
|
|
15405
16550
|
const parent = parents.get(id);
|
|
15406
|
-
const base = parent ?
|
|
15407
|
-
if (base !== null) result =
|
|
16551
|
+
const base = parent ? resolve5(parent) : projectDir;
|
|
16552
|
+
if (base !== null) result = join7(base, own);
|
|
15408
16553
|
}
|
|
15409
16554
|
}
|
|
15410
16555
|
paths.set(id, result);
|
|
15411
16556
|
return result;
|
|
15412
16557
|
};
|
|
15413
|
-
return
|
|
16558
|
+
return resolve5;
|
|
15414
16559
|
}
|
|
15415
|
-
function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder,
|
|
16560
|
+
function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, join7, visit3) {
|
|
15416
16561
|
const target = objects[targetId];
|
|
15417
16562
|
if (!isDict(target)) return;
|
|
15418
16563
|
for (const phaseId of list(target.buildPhases)) {
|
|
@@ -15448,7 +16593,7 @@ function visitXcodeTargetMembers(objects, targetId, resolvePath, filesUnder, joi
|
|
|
15448
16593
|
for (const relative3 of list(exception.membershipExceptions))
|
|
15449
16594
|
exceptions.add(relative3);
|
|
15450
16595
|
}
|
|
15451
|
-
const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(
|
|
16596
|
+
const members = owned.has(groupId) ? filesUnder(folder) : [...exceptions].flatMap((relative3) => filesUnder(join7(folder, relative3)));
|
|
15452
16597
|
for (const file of members) {
|
|
15453
16598
|
const relative3 = file.slice(prefix2.length);
|
|
15454
16599
|
const excepted = [...exceptions].some(
|
|
@@ -15602,10 +16747,10 @@ function appTargetReleaseSettings(pbxproj, targetName, infoPlistRelativePath) {
|
|
|
15602
16747
|
var APP_DELEGATE_PATH_RE = /(?:^|\/)ios\/([^/]+)\/AppDelegate\.(?:swift|mm|m)$/;
|
|
15603
16748
|
function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri) {
|
|
15604
16749
|
const pbxprojPath = Object.keys(files).find(
|
|
15605
|
-
(
|
|
16750
|
+
(path22) => /(?:^|\/)ios\/[^/]+\.xcodeproj\/project\.pbxproj$/.test(path22)
|
|
15606
16751
|
) ?? Object.keys(files).find(
|
|
15607
|
-
(
|
|
15608
|
-
) ?? Object.keys(files).find((
|
|
16752
|
+
(path22) => /(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/.test(path22)
|
|
16753
|
+
) ?? Object.keys(files).find((path22) => /(?:^|\/)project\.pbxproj$/.test(path22));
|
|
15609
16754
|
if (!pbxprojPath) return null;
|
|
15610
16755
|
const pbxproj = files[pbxprojPath];
|
|
15611
16756
|
let objects = {};
|
|
@@ -15647,7 +16792,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
|
|
|
15647
16792
|
} else if (applicationTargetNames.size === 1) {
|
|
15648
16793
|
targetName = [...applicationTargetNames][0];
|
|
15649
16794
|
} else if (applicationTargetNames.size > 1) {
|
|
15650
|
-
const delegateTargets = Object.keys(files).filter((
|
|
16795
|
+
const delegateTargets = Object.keys(files).filter((path22) => !path22.includes("/Pods/")).map((path22) => path22.match(APP_DELEGATE_PATH_RE)?.[1]).filter(
|
|
15651
16796
|
(name2) => typeof name2 === "string" && applicationTargetNames.has(name2)
|
|
15652
16797
|
);
|
|
15653
16798
|
if (delegateTargets.length === 1) {
|
|
@@ -15845,7 +16990,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
|
|
|
15845
16990
|
if (resourceUri) {
|
|
15846
16991
|
if (!selectedTarget)
|
|
15847
16992
|
throw new Error("native app icon target membership is unresolved");
|
|
15848
|
-
const
|
|
16993
|
+
const join7 = (base, own) => {
|
|
15849
16994
|
const segments = [];
|
|
15850
16995
|
for (const segment of `${base}/${own}`.split("/")) {
|
|
15851
16996
|
if (segment === "" || segment === ".") continue;
|
|
@@ -15858,7 +17003,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
|
|
|
15858
17003
|
const project = Object.values(objects).find(
|
|
15859
17004
|
(object2) => isRecord(object2) && object2.isa === "PBXProject"
|
|
15860
17005
|
);
|
|
15861
|
-
const projectDir =
|
|
17006
|
+
const projectDir = join7(
|
|
15862
17007
|
pbxprojPath.replace(/(?:^|\/)[^/]+\.xcodeproj\/project\.pbxproj$/, ""),
|
|
15863
17008
|
isRecord(project) && typeof project.projectDirPath === "string" ? project.projectDirPath : ""
|
|
15864
17009
|
);
|
|
@@ -15866,15 +17011,15 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
|
|
|
15866
17011
|
visitXcodeTargetMembers(
|
|
15867
17012
|
objects,
|
|
15868
17013
|
selectedTarget.id,
|
|
15869
|
-
xcodePathResolver(objects, projectDir,
|
|
17014
|
+
xcodePathResolver(objects, projectDir, join7),
|
|
15870
17015
|
(file) => {
|
|
15871
17016
|
if (Object.hasOwn(files, file)) return [file];
|
|
15872
17017
|
const prefix2 = file === "" ? "" : `${file.replace(/\/$/, "")}/`;
|
|
15873
17018
|
return paths.filter(
|
|
15874
|
-
(
|
|
17019
|
+
(path22) => path22.startsWith(prefix2) && !/(?:^|\/)\./.test(path22.slice(prefix2.length))
|
|
15875
17020
|
);
|
|
15876
17021
|
},
|
|
15877
|
-
|
|
17022
|
+
join7,
|
|
15878
17023
|
(file, kind) => {
|
|
15879
17024
|
if (kind === "resource") resources.add(file);
|
|
15880
17025
|
}
|
|
@@ -15882,7 +17027,7 @@ function nativeAppIdentityFromIos(files, parseInfoPlist, iosTarget, resourceUri)
|
|
|
15882
17027
|
}
|
|
15883
17028
|
const rootModuleName = readRootModuleName(
|
|
15884
17029
|
Object.entries(files).filter(
|
|
15885
|
-
([
|
|
17030
|
+
([path22]) => !path22.includes("/Pods/") && (/(?:^|\/)ios\/AppDelegate\.(?:swift|mm|m)$/.test(path22) || path22.match(APP_DELEGATE_PATH_RE)?.[1] === targetName)
|
|
15886
17031
|
).map(([, source]) => source)
|
|
15887
17032
|
);
|
|
15888
17033
|
return {
|
|
@@ -15968,29 +17113,22 @@ function extractNativeAppIdentityFromFiles(files, platform, parseInfoPlist, iosT
|
|
|
15968
17113
|
|
|
15969
17114
|
// src/native-app-identity-project.ts
|
|
15970
17115
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15971
|
-
var
|
|
17116
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
15972
17117
|
var import_node_module4 = require("node:module");
|
|
15973
|
-
var
|
|
17118
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
15974
17119
|
init_is_record();
|
|
15975
17120
|
|
|
15976
|
-
// src/plist.ts
|
|
15977
|
-
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15978
|
-
var import_plist = __toESM(require("plist"), 1);
|
|
15979
|
-
function parsePlistSource(source) {
|
|
15980
|
-
return import_plist.default.parse(source);
|
|
15981
|
-
}
|
|
15982
|
-
|
|
15983
17121
|
// src/xcode-project.ts
|
|
15984
17122
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15985
17123
|
var import_node_child_process5 = require("node:child_process");
|
|
15986
17124
|
var import_node_crypto7 = require("node:crypto");
|
|
15987
|
-
var
|
|
15988
|
-
var
|
|
15989
|
-
var
|
|
17125
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
17126
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
17127
|
+
var import_plist3 = __toESM(require("plist"), 1);
|
|
15990
17128
|
|
|
15991
17129
|
// src/xcode-json-project.ts
|
|
15992
17130
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
15993
|
-
var
|
|
17131
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
15994
17132
|
var import_json52 = __toESM(require_lib(), 1);
|
|
15995
17133
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
15996
17134
|
var text = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -16006,7 +17144,7 @@ var PHASE_ISA = {
|
|
|
16006
17144
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
16007
17145
|
const json = import_json52.default.parse(source);
|
|
16008
17146
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
16009
|
-
const projectDir =
|
|
17147
|
+
const projectDir = import_node_path14.default.dirname(xcodeproj);
|
|
16010
17148
|
const objects = {};
|
|
16011
17149
|
let next = 0;
|
|
16012
17150
|
const add = (entry, id) => {
|
|
@@ -16019,7 +17157,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
16019
17157
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw);
|
|
16020
17158
|
if (base) {
|
|
16021
17159
|
if (base[1] === "PROJECT")
|
|
16022
|
-
return { sourceTree: "<absolute>", path:
|
|
17160
|
+
return { sourceTree: "<absolute>", path: import_node_path14.default.join(projectDir, base[2]) };
|
|
16023
17161
|
if (base[1] === "PRODUCTS")
|
|
16024
17162
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
16025
17163
|
return null;
|
|
@@ -16027,7 +17165,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
16027
17165
|
const unescaped = raw.replaceAll("\\<", "<");
|
|
16028
17166
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
16029
17167
|
if (unescaped.startsWith("~")) return null;
|
|
16030
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
17168
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path14.default.join(groupDir, unescaped) };
|
|
16031
17169
|
};
|
|
16032
17170
|
const memberships = [];
|
|
16033
17171
|
const folders = [];
|
|
@@ -16038,7 +17176,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
16038
17176
|
const kind = text(entry.kind) ?? "file-reference";
|
|
16039
17177
|
const raw = text(entry.path) ?? "";
|
|
16040
17178
|
const located = raw === "" ? null : locate(raw, parent.dir);
|
|
16041
|
-
const name2 = text(entry.name) ??
|
|
17179
|
+
const name2 = text(entry.name) ?? import_node_path14.default.basename(raw);
|
|
16042
17180
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
16043
17181
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
16044
17182
|
node.dir = raw === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -16153,7 +17291,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
16153
17291
|
if (!isObject(entry)) continue;
|
|
16154
17292
|
const repository = text(entry.repository);
|
|
16155
17293
|
const local = text(entry.path);
|
|
16156
|
-
const name2 = local !== void 0 ?
|
|
17294
|
+
const name2 = local !== void 0 ? import_node_path14.default.basename(import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), local)) : import_node_path14.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
16157
17295
|
const id = text(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
16158
17296
|
packageIds.set(name2.toLowerCase(), id);
|
|
16159
17297
|
}
|
|
@@ -16341,28 +17479,28 @@ var CONDITIONS = {
|
|
|
16341
17479
|
variant: "normal"
|
|
16342
17480
|
};
|
|
16343
17481
|
function walkFiles(dir) {
|
|
16344
|
-
if (!
|
|
17482
|
+
if (!import_node_fs15.default.existsSync(dir)) return [];
|
|
16345
17483
|
const out = [];
|
|
16346
|
-
for (const entry of
|
|
17484
|
+
for (const entry of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
16347
17485
|
if (entry.name.startsWith(".")) continue;
|
|
16348
|
-
const full =
|
|
17486
|
+
const full = import_node_path15.default.join(dir, entry.name);
|
|
16349
17487
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
16350
17488
|
else if (entry.isFile()) out.push(full);
|
|
16351
17489
|
}
|
|
16352
17490
|
return out;
|
|
16353
17491
|
}
|
|
16354
|
-
var isDirectory = (dir) =>
|
|
17492
|
+
var isDirectory = (dir) => import_node_fs15.default.existsSync(dir) && import_node_fs15.default.statSync(dir).isDirectory();
|
|
16355
17493
|
function readXcconfig(file, read) {
|
|
16356
|
-
if (read.includes(file) || !
|
|
17494
|
+
if (read.includes(file) || !import_node_fs15.default.existsSync(file)) return {};
|
|
16357
17495
|
read.push(file);
|
|
16358
17496
|
const settings = {};
|
|
16359
|
-
for (const raw of
|
|
17497
|
+
for (const raw of import_node_fs15.default.readFileSync(file, "utf8").split("\n")) {
|
|
16360
17498
|
const line = raw.replace(/\/\/.*$/, "").trim();
|
|
16361
17499
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
16362
17500
|
if (include) {
|
|
16363
17501
|
Object.assign(
|
|
16364
17502
|
settings,
|
|
16365
|
-
readXcconfig(
|
|
17503
|
+
readXcconfig(import_node_path15.default.resolve(import_node_path15.default.dirname(file), include[1]), read)
|
|
16366
17504
|
);
|
|
16367
17505
|
continue;
|
|
16368
17506
|
}
|
|
@@ -16412,22 +17550,22 @@ function decodeXml(text2) {
|
|
|
16412
17550
|
return text2.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
16413
17551
|
}
|
|
16414
17552
|
function workspaceReferences(workspace) {
|
|
16415
|
-
const data =
|
|
16416
|
-
if (!
|
|
17553
|
+
const data = import_node_path15.default.join(workspace, "contents.xcworkspacedata");
|
|
17554
|
+
if (!import_node_fs15.default.existsSync(data))
|
|
16417
17555
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
16418
|
-
const container =
|
|
17556
|
+
const container = import_node_path15.default.dirname(workspace);
|
|
16419
17557
|
const locate = (location, base) => {
|
|
16420
17558
|
const colon = location.indexOf(":");
|
|
16421
17559
|
const kind = location.slice(0, colon);
|
|
16422
17560
|
const rest = location.slice(colon + 1);
|
|
16423
|
-
if (kind === "group") return
|
|
16424
|
-
if (kind === "container" || kind === "self") return
|
|
16425
|
-
if (kind === "absolute") return
|
|
16426
|
-
throw new Error(`${
|
|
17561
|
+
if (kind === "group") return import_node_path15.default.resolve(base, rest);
|
|
17562
|
+
if (kind === "container" || kind === "self") return import_node_path15.default.resolve(container, rest);
|
|
17563
|
+
if (kind === "absolute") return import_node_path15.default.resolve(rest);
|
|
17564
|
+
throw new Error(`${import_node_path15.default.basename(workspace)} has an unsupported location ${location}`);
|
|
16427
17565
|
};
|
|
16428
17566
|
const groups = [container];
|
|
16429
17567
|
const references = [];
|
|
16430
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
17568
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs15.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
16431
17569
|
if (closing) {
|
|
16432
17570
|
if (tag === "Group") groups.pop();
|
|
16433
17571
|
continue;
|
|
@@ -16443,8 +17581,8 @@ function workspaceReferences(workspace) {
|
|
|
16443
17581
|
var loaded2 = /* @__PURE__ */ new Map();
|
|
16444
17582
|
function xcodeProjectFile(xcodeproj) {
|
|
16445
17583
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
16446
|
-
const file =
|
|
16447
|
-
if (
|
|
17584
|
+
const file = import_node_path15.default.join(xcodeproj, name2);
|
|
17585
|
+
if (import_node_fs15.default.existsSync(file)) return file;
|
|
16448
17586
|
}
|
|
16449
17587
|
return null;
|
|
16450
17588
|
}
|
|
@@ -16452,7 +17590,7 @@ function loadProject(xcodeproj) {
|
|
|
16452
17590
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
16453
17591
|
if (!projectFile)
|
|
16454
17592
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
16455
|
-
const source =
|
|
17593
|
+
const source = import_node_fs15.default.readFileSync(projectFile, "utf8");
|
|
16456
17594
|
const digest = (0, import_node_crypto7.createHash)("sha256").update(source).digest("hex");
|
|
16457
17595
|
const cached2 = loaded2.get(projectFile);
|
|
16458
17596
|
if (cached2?.digest === digest) return cached2.project;
|
|
@@ -16469,10 +17607,10 @@ function loadProject(xcodeproj) {
|
|
|
16469
17607
|
if (!project || project.isa !== "PBXProject") {
|
|
16470
17608
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
16471
17609
|
}
|
|
16472
|
-
const projectDir =
|
|
16473
|
-
|
|
17610
|
+
const projectDir = import_node_fs15.default.realpathSync(
|
|
17611
|
+
import_node_path15.default.resolve(import_node_path15.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
16474
17612
|
);
|
|
16475
|
-
const resolvePath = xcodePathResolver(objects, projectDir,
|
|
17613
|
+
const resolvePath = xcodePathResolver(objects, projectDir, import_node_path15.default.join);
|
|
16476
17614
|
const result = {
|
|
16477
17615
|
xcodeproj,
|
|
16478
17616
|
projectFile,
|
|
@@ -16506,8 +17644,8 @@ function targetSettings(ref, configuration, builtins, options = {}, overrides =
|
|
|
16506
17644
|
const relative3 = str(config.baseConfigurationReferenceRelativePath);
|
|
16507
17645
|
const own = isDict(config.buildSettings) ? config.buildSettings : {};
|
|
16508
17646
|
const directory = anchor ? project.resolvePath(anchor) : null;
|
|
16509
|
-
const baseFile = base ? project.resolvePath(base) : directory && relative3 ?
|
|
16510
|
-
if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !
|
|
17647
|
+
const baseFile = base ? project.resolvePath(base) : directory && relative3 ? import_node_path15.default.resolve(directory, relative3) : null;
|
|
17648
|
+
if (options.requireSources !== false && (base || anchor || relative3) && (!baseFile || !import_node_fs15.default.existsSync(baseFile)))
|
|
16511
17649
|
throw new Error(
|
|
16512
17650
|
`Unable to open base configuration reference file '${baseFile ?? base ?? relative3 ?? anchor}'`
|
|
16513
17651
|
);
|
|
@@ -16583,26 +17721,26 @@ function settingList(value) {
|
|
|
16583
17721
|
return items2;
|
|
16584
17722
|
}
|
|
16585
17723
|
function expandSearchPath(directory, rules) {
|
|
16586
|
-
if (
|
|
17724
|
+
if (import_node_path15.default.basename(directory) !== "**") return [directory];
|
|
16587
17725
|
const expanded = [];
|
|
16588
17726
|
const seen = /* @__PURE__ */ new Set();
|
|
16589
|
-
const queue = [
|
|
17727
|
+
const queue = [import_node_path15.default.dirname(directory)];
|
|
16590
17728
|
for (let at = 0; at < queue.length; at++) {
|
|
16591
17729
|
const current = queue[at];
|
|
16592
17730
|
let real;
|
|
16593
17731
|
try {
|
|
16594
|
-
real =
|
|
17732
|
+
real = import_node_fs15.default.realpathSync(current);
|
|
16595
17733
|
} catch {
|
|
16596
17734
|
continue;
|
|
16597
17735
|
}
|
|
16598
|
-
if (!
|
|
17736
|
+
if (!import_node_fs15.default.statSync(real).isDirectory() || seen.has(real)) continue;
|
|
16599
17737
|
seen.add(real);
|
|
16600
17738
|
expanded.push(current);
|
|
16601
|
-
for (const entry of
|
|
17739
|
+
for (const entry of import_node_fs15.default.readdirSync(real, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)) {
|
|
16602
17740
|
if (entry.isSymbolicLink() ? !rules.followLinks : !entry.isDirectory()) continue;
|
|
16603
17741
|
if (rules.excluded.some((pattern) => pattern.test(entry.name)) && !rules.included.some((pattern) => pattern.test(entry.name)))
|
|
16604
17742
|
continue;
|
|
16605
|
-
queue.push(
|
|
17743
|
+
queue.push(import_node_path15.default.join(current, entry.name));
|
|
16606
17744
|
}
|
|
16607
17745
|
}
|
|
16608
17746
|
return expanded;
|
|
@@ -16656,7 +17794,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
|
|
|
16656
17794
|
const phase = project.object(phaseId);
|
|
16657
17795
|
if (phase?.isa !== "PBXShellScriptBuildPhase") continue;
|
|
16658
17796
|
const script = str(phase.name) ?? phaseId;
|
|
16659
|
-
const absolute = (raw) =>
|
|
17797
|
+
const absolute = (raw) => import_node_path15.default.resolve(project.projectDir, expand(raw, settings));
|
|
16660
17798
|
const inputs = list(phase.inputPaths).map(absolute);
|
|
16661
17799
|
const outputs = list(phase.outputPaths).map(absolute);
|
|
16662
17800
|
const fileLists = /* @__PURE__ */ new Map();
|
|
@@ -16665,10 +17803,10 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
|
|
|
16665
17803
|
kind === "INPUT" ? phase.inputFileListPaths : phase.outputFileListPaths
|
|
16666
17804
|
).map((raw) => {
|
|
16667
17805
|
const file = absolute(raw);
|
|
16668
|
-
if (!
|
|
17806
|
+
if (!import_node_fs15.default.existsSync(file)) {
|
|
16669
17807
|
return { file, entries: [] };
|
|
16670
17808
|
}
|
|
16671
|
-
const entries =
|
|
17809
|
+
const entries = import_node_fs15.default.readFileSync(file, "utf8").split(/\r?\n/).map((line) => line.trim()).filter((line) => line !== "" && !line.startsWith("#")).map(absolute);
|
|
16672
17810
|
return { file, entries };
|
|
16673
17811
|
});
|
|
16674
17812
|
fileLists.set(kind, lists);
|
|
@@ -16686,13 +17824,13 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
|
|
|
16686
17824
|
...fileLists.get("OUTPUT").map((item) => item.file)
|
|
16687
17825
|
];
|
|
16688
17826
|
if (allOutputs.some((file) => file.endsWith(".swift"))) {
|
|
16689
|
-
for (const file of inputFiles) if (
|
|
17827
|
+
for (const file of inputFiles) if (import_node_fs15.default.existsSync(file)) projectInputs.add(file);
|
|
16690
17828
|
}
|
|
16691
17829
|
if (options.prepareGeneratedSources && options.requireSources !== false && allOutputs.some((file) => file.endsWith(".swift"))) {
|
|
16692
|
-
const phaseDir =
|
|
17830
|
+
const phaseDir = import_node_path15.default.join(settings("TARGET_TEMP_DIR"), `Script-${phaseId}`);
|
|
16693
17831
|
for (const lists of fileLists.values())
|
|
16694
17832
|
for (const { file } of lists)
|
|
16695
|
-
if (!
|
|
17833
|
+
if (!import_node_fs15.default.existsSync(file))
|
|
16696
17834
|
throw new Error(
|
|
16697
17835
|
`${targetName}: Run Script "${script}" missing file list ${file}`
|
|
16698
17836
|
);
|
|
@@ -16711,7 +17849,7 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
|
|
|
16711
17849
|
const lists = fileLists.get(kind);
|
|
16712
17850
|
env[`SCRIPT_${kind}_FILE_LIST_COUNT`] = String(lists.length);
|
|
16713
17851
|
lists.forEach((_item, index) => {
|
|
16714
|
-
env[`SCRIPT_${kind}_FILE_LIST_${index}`] =
|
|
17852
|
+
env[`SCRIPT_${kind}_FILE_LIST_${index}`] = import_node_path15.default.join(
|
|
16715
17853
|
phaseDir,
|
|
16716
17854
|
`${kind}-${index}.xcfilelist`
|
|
16717
17855
|
);
|
|
@@ -16722,21 +17860,21 @@ function targetMembers(ref, settings, options, settingKeys, projectInputs) {
|
|
|
16722
17860
|
);
|
|
16723
17861
|
for (const file of inputFiles) {
|
|
16724
17862
|
signature.update(file);
|
|
16725
|
-
if (
|
|
16726
|
-
const stat =
|
|
17863
|
+
if (import_node_fs15.default.existsSync(file)) {
|
|
17864
|
+
const stat = import_node_fs15.default.statSync(file);
|
|
16727
17865
|
signature.update(`${stat.mtimeMs}:${stat.ctimeMs}:${stat.size}`);
|
|
16728
17866
|
} else signature.update("missing");
|
|
16729
17867
|
}
|
|
16730
17868
|
const stamp = signature.digest("hex");
|
|
16731
17869
|
const key = `${project.projectFile}:${targetId}:${phaseId}:${settings("CONFIGURATION")}`;
|
|
16732
|
-
if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) =>
|
|
17870
|
+
if (preparedSourcePhases.get(key) === stamp && allOutputs.every((file) => import_node_fs15.default.existsSync(file)))
|
|
16733
17871
|
continue;
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
17872
|
+
import_node_fs15.default.mkdirSync(phaseDir, { recursive: true });
|
|
17873
|
+
import_node_fs15.default.mkdirSync(settings("BUILT_PRODUCTS_DIR"), { recursive: true });
|
|
17874
|
+
import_node_fs15.default.mkdirSync(settings("DERIVED_FILE_DIR"), { recursive: true });
|
|
16737
17875
|
for (const [kind, lists] of fileLists)
|
|
16738
17876
|
lists.forEach((item, index) => {
|
|
16739
|
-
|
|
17877
|
+
import_node_fs15.default.writeFileSync(
|
|
16740
17878
|
env[`SCRIPT_${kind}_FILE_LIST_${index}`],
|
|
16741
17879
|
`${item.entries.join("\n")}
|
|
16742
17880
|
`
|
|
@@ -16762,7 +17900,7 @@ ${output}`
|
|
|
16762
17900
|
);
|
|
16763
17901
|
}
|
|
16764
17902
|
const missing = allOutputs.filter(
|
|
16765
|
-
(file) => file.endsWith(".swift") && !
|
|
17903
|
+
(file) => file.endsWith(".swift") && !import_node_fs15.default.existsSync(file)
|
|
16766
17904
|
);
|
|
16767
17905
|
if (missing.length > 0)
|
|
16768
17906
|
throw new Error(
|
|
@@ -16775,8 +17913,8 @@ ${output}`
|
|
|
16775
17913
|
project.objects,
|
|
16776
17914
|
targetId,
|
|
16777
17915
|
project.resolvePath,
|
|
16778
|
-
(file) => isDirectory(file) ? walkFiles(file) :
|
|
16779
|
-
|
|
17916
|
+
(file) => isDirectory(file) ? walkFiles(file) : import_node_fs15.default.existsSync(file) ? [file] : [],
|
|
17917
|
+
import_node_path15.default.join,
|
|
16780
17918
|
(file, kind) => {
|
|
16781
17919
|
if (kind === "header") {
|
|
16782
17920
|
headers.add(file);
|
|
@@ -16786,9 +17924,9 @@ ${output}`
|
|
|
16786
17924
|
resources.add(file);
|
|
16787
17925
|
return;
|
|
16788
17926
|
}
|
|
16789
|
-
if (!
|
|
17927
|
+
if (!import_node_fs15.default.existsSync(file)) {
|
|
16790
17928
|
if (options.requireSources === false) return;
|
|
16791
|
-
const script = scriptForOutput.get(
|
|
17929
|
+
const script = scriptForOutput.get(import_node_path15.default.normalize(file));
|
|
16792
17930
|
throw new Error(
|
|
16793
17931
|
script ? `${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)` : `${targetName}: missing source ${file}`
|
|
16794
17932
|
);
|
|
@@ -16799,7 +17937,7 @@ ${output}`
|
|
|
16799
17937
|
);
|
|
16800
17938
|
for (const [file, script] of scriptForOutput) {
|
|
16801
17939
|
if (sources.has(file) || allSources.has(file)) continue;
|
|
16802
|
-
if (!
|
|
17940
|
+
if (!import_node_fs15.default.existsSync(file)) {
|
|
16803
17941
|
if (options.requireSources === false) continue;
|
|
16804
17942
|
throw new Error(
|
|
16805
17943
|
`${targetName}: missing generated source ${file} (Run Script "${script}" declares it in outputPaths; run the script or check in its output)`
|
|
@@ -16818,37 +17956,37 @@ ${output}`
|
|
|
16818
17956
|
function commonAncestor(dirs) {
|
|
16819
17957
|
let common = dirs[0];
|
|
16820
17958
|
for (const dir of dirs) {
|
|
16821
|
-
while (common !==
|
|
16822
|
-
common =
|
|
17959
|
+
while (common !== import_node_path15.default.dirname(common) && import_node_path15.default.relative(common, dir).startsWith(".."))
|
|
17960
|
+
common = import_node_path15.default.dirname(common);
|
|
16823
17961
|
}
|
|
16824
17962
|
return common;
|
|
16825
17963
|
}
|
|
16826
|
-
var isPodsProject = (xcodeproj) =>
|
|
17964
|
+
var isPodsProject = (xcodeproj) => import_node_path15.default.basename(xcodeproj) === "Pods.xcodeproj" && import_node_path15.default.basename(import_node_path15.default.dirname(xcodeproj)) === "Pods";
|
|
16827
17965
|
function installedPodsSandbox(pods) {
|
|
16828
|
-
const podfileLock =
|
|
16829
|
-
const manifestLock =
|
|
16830
|
-
if (!
|
|
17966
|
+
const podfileLock = import_node_path15.default.join(import_node_path15.default.dirname(pods), "Podfile.lock");
|
|
17967
|
+
const manifestLock = import_node_path15.default.join(pods, "Manifest.lock");
|
|
17968
|
+
if (!import_node_fs15.default.existsSync(podfileLock))
|
|
16831
17969
|
throw new Error(
|
|
16832
|
-
`${pods} has no ${podfileLock}: run \`pod install\` in ${
|
|
17970
|
+
`${pods} has no ${podfileLock}: run \`pod install\` in ${import_node_path15.default.dirname(pods)}`
|
|
16833
17971
|
);
|
|
16834
|
-
if (!
|
|
17972
|
+
if (!import_node_fs15.default.existsSync(manifestLock) || !import_node_fs15.default.readFileSync(manifestLock).equals(import_node_fs15.default.readFileSync(podfileLock)))
|
|
16835
17973
|
throw new Error(
|
|
16836
|
-
`The sandbox is not in sync with the Podfile.lock: ${manifestLock} differs from ${podfileLock}. Run \`pod install\` in ${
|
|
17974
|
+
`The sandbox is not in sync with the Podfile.lock: ${manifestLock} differs from ${podfileLock}. Run \`pod install\` in ${import_node_path15.default.dirname(pods)}`
|
|
16837
17975
|
);
|
|
16838
17976
|
const specChecksums = {};
|
|
16839
|
-
const lines =
|
|
17977
|
+
const lines = import_node_fs15.default.readFileSync(manifestLock, "utf8").split("\n");
|
|
16840
17978
|
const start = lines.indexOf("SPEC CHECKSUMS:");
|
|
16841
17979
|
for (const line of start === -1 ? [] : lines.slice(start + 1)) {
|
|
16842
17980
|
const entry = /^ {2}"?([^":]+)"?: ([0-9a-f]+)$/.exec(line);
|
|
16843
17981
|
if (!entry) break;
|
|
16844
17982
|
specChecksums[entry[1]] = entry[2];
|
|
16845
17983
|
}
|
|
16846
|
-
const specs =
|
|
17984
|
+
const specs = import_node_path15.default.join(pods, "Local Podspecs");
|
|
16847
17985
|
return {
|
|
16848
17986
|
podfileLock,
|
|
16849
17987
|
manifestLock,
|
|
16850
17988
|
specChecksums,
|
|
16851
|
-
localPodspecs: isDirectory(specs) ?
|
|
17989
|
+
localPodspecs: isDirectory(specs) ? import_node_fs15.default.readdirSync(specs).filter((name2) => name2.endsWith(".podspec.json")).sort().map((name2) => import_node_path15.default.join(specs, name2)) : []
|
|
16852
17990
|
};
|
|
16853
17991
|
}
|
|
16854
17992
|
function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
|
|
@@ -16860,14 +17998,14 @@ function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
|
|
|
16860
17998
|
if (!xcodeProjectFile(xcodeproj)) {
|
|
16861
17999
|
if (installedPods && isPodsProject(xcodeproj))
|
|
16862
18000
|
throw new Error(
|
|
16863
|
-
`${
|
|
18001
|
+
`${import_node_path15.default.basename(xcodeprojOrWorkspace)} builds ${xcodeproj}, which is not installed: run \`pod install\` in ${import_node_path15.default.dirname(import_node_path15.default.dirname(xcodeproj))}`
|
|
16864
18002
|
);
|
|
16865
18003
|
return;
|
|
16866
18004
|
}
|
|
16867
|
-
const key =
|
|
16868
|
-
if (projectAt.has(key) || !installedPods && key.split(
|
|
18005
|
+
const key = import_node_fs15.default.realpathSync(xcodeproj);
|
|
18006
|
+
if (projectAt.has(key) || !installedPods && key.split(import_node_path15.default.sep).includes("Pods"))
|
|
16869
18007
|
return;
|
|
16870
|
-
if (isPodsProject(key)) cocoapods = installedPodsSandbox(
|
|
18008
|
+
if (isPodsProject(key)) cocoapods = installedPodsSandbox(import_node_path15.default.dirname(key));
|
|
16871
18009
|
const project = loadProject(key);
|
|
16872
18010
|
projectAt.set(key, project);
|
|
16873
18011
|
projects.push(project);
|
|
@@ -16883,12 +18021,12 @@ function workspaceProjects(xcodeprojOrWorkspace, installedPods = false) {
|
|
|
16883
18021
|
for (const reference of listed)
|
|
16884
18022
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
16885
18023
|
if (projects.length === 0) {
|
|
16886
|
-
throw new Error(`${
|
|
18024
|
+
throw new Error(`${import_node_path15.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
16887
18025
|
}
|
|
16888
|
-
const podfile =
|
|
16889
|
-
if (installedPods && !cocoapods &&
|
|
18026
|
+
const podfile = import_node_path15.default.join(import_node_path15.default.dirname(xcodeprojOrWorkspace), "Podfile");
|
|
18027
|
+
if (installedPods && !cocoapods && import_node_fs15.default.existsSync(podfile))
|
|
16890
18028
|
throw new Error(
|
|
16891
|
-
`${podfile} is not installed into ${
|
|
18029
|
+
`${podfile} is not installed into ${import_node_path15.default.basename(xcodeprojOrWorkspace)}: run \`pod install\` in ${import_node_path15.default.dirname(podfile)} and open the workspace it writes`
|
|
16892
18030
|
);
|
|
16893
18031
|
return { listed, projects, projectAt, cocoapods };
|
|
16894
18032
|
}
|
|
@@ -16924,7 +18062,7 @@ function listXcodeAppTargets(xcodeprojOrWorkspace, options = {}) {
|
|
|
16924
18062
|
return workspaceProjects(xcodeprojOrWorkspace).projects.flatMap(nativeTargets).filter((ref) => isIosAppTarget(ref, options)).map((ref) => str(ref.target.name) ?? ref.id);
|
|
16925
18063
|
}
|
|
16926
18064
|
function readXcodeAppTarget(input, targetName, configurationName, options = {}) {
|
|
16927
|
-
const xcodeprojOrWorkspace =
|
|
18065
|
+
const xcodeprojOrWorkspace = import_node_fs15.default.realpathSync(input);
|
|
16928
18066
|
const workspace = xcodeprojOrWorkspace.endsWith(".xcworkspace") ? xcodeprojOrWorkspace : null;
|
|
16929
18067
|
const { listed, projects, projectAt, cocoapods } = workspaceProjects(
|
|
16930
18068
|
xcodeprojOrWorkspace,
|
|
@@ -16933,7 +18071,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
16933
18071
|
const allTargets = projects.flatMap(nativeTargets);
|
|
16934
18072
|
const appTargets = allTargets.filter((ref) => isIosAppTarget(ref, options));
|
|
16935
18073
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
16936
|
-
const container =
|
|
18074
|
+
const container = import_node_path15.default.basename(xcodeprojOrWorkspace);
|
|
16937
18075
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
16938
18076
|
if (named.length !== 1) {
|
|
16939
18077
|
throw new Error(
|
|
@@ -16946,15 +18084,15 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
16946
18084
|
for (const ref of allTargets) {
|
|
16947
18085
|
const product = ref.project.object(str(ref.target.productReference));
|
|
16948
18086
|
const file = str(product?.path);
|
|
16949
|
-
if (file && !byProduct.has(
|
|
16950
|
-
byProduct.set(
|
|
18087
|
+
if (file && !byProduct.has(import_node_path15.default.basename(file)))
|
|
18088
|
+
byProduct.set(import_node_path15.default.basename(file), ref);
|
|
16951
18089
|
}
|
|
16952
18090
|
const proxied = (project, proxyId) => {
|
|
16953
18091
|
const proxy = project.object(proxyId);
|
|
16954
18092
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
16955
18093
|
const portal = str(proxy.containerPortal);
|
|
16956
18094
|
const portalPath = project.resolvePath(portal ?? "");
|
|
16957
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : portalPath &&
|
|
18095
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : portalPath && import_node_fs15.default.existsSync(portalPath) ? projectAt.get(import_node_fs15.default.realpathSync(portalPath)) : void 0;
|
|
16958
18096
|
const remote = str(proxy.remoteGlobalIDString);
|
|
16959
18097
|
if (!owner || !remote) return void 0;
|
|
16960
18098
|
return nativeTargets(owner).find(
|
|
@@ -16975,7 +18113,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
16975
18113
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
16976
18114
|
for (const buildFileId of list(phase.files)) {
|
|
16977
18115
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
16978
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
18116
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path15.default.basename(str(file.path) ?? "")) : void 0;
|
|
16979
18117
|
if (resolved) found.push(resolved);
|
|
16980
18118
|
}
|
|
16981
18119
|
}
|
|
@@ -17023,7 +18161,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17023
18161
|
const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? "");
|
|
17024
18162
|
const product = framework ? productName(ref) : "";
|
|
17025
18163
|
for (const { file, visibility } of headerPhase(ref)) {
|
|
17026
|
-
const name2 =
|
|
18164
|
+
const name2 = import_node_path15.default.basename(file);
|
|
17027
18165
|
if (!entries.has(name2))
|
|
17028
18166
|
entries.set(
|
|
17029
18167
|
name2,
|
|
@@ -17034,18 +18172,18 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17034
18172
|
for (const id of Object.keys(project.objects)) {
|
|
17035
18173
|
if (project.object(id)?.isa !== "PBXFileReference") continue;
|
|
17036
18174
|
const file = project.resolvePath(id);
|
|
17037
|
-
if (file && HEADER_FILE.test(file) && !entries.has(
|
|
17038
|
-
entries.set(
|
|
18175
|
+
if (file && HEADER_FILE.test(file) && !entries.has(import_node_path15.default.basename(file)))
|
|
18176
|
+
entries.set(import_node_path15.default.basename(file), file);
|
|
17039
18177
|
}
|
|
17040
18178
|
const map2 = [...entries];
|
|
17041
18179
|
projectHeaderMaps.set(project, map2);
|
|
17042
18180
|
return map2;
|
|
17043
18181
|
};
|
|
17044
18182
|
const xcconfigs = /* @__PURE__ */ new Set();
|
|
17045
|
-
const buildDir = (project) =>
|
|
18183
|
+
const buildDir = (project) => import_node_path15.default.join(project.projectDir, ".build/peach-xcode/Build");
|
|
17046
18184
|
const podsBuild = {
|
|
17047
|
-
SYMROOT:
|
|
17048
|
-
OBJROOT:
|
|
18185
|
+
SYMROOT: import_node_path15.default.join(buildDir(app.project), "Products"),
|
|
18186
|
+
OBJROOT: import_node_path15.default.join(buildDir(app.project), "Intermediates.noindex")
|
|
17049
18187
|
};
|
|
17050
18188
|
const moduleTarget = (ref) => {
|
|
17051
18189
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
@@ -17058,13 +18196,13 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17058
18196
|
configuration,
|
|
17059
18197
|
{
|
|
17060
18198
|
TARGET_NAME: name2,
|
|
17061
|
-
PROJECT_NAME:
|
|
18199
|
+
PROJECT_NAME: import_node_path15.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
17062
18200
|
SRCROOT: ref.project.projectDir,
|
|
17063
18201
|
SOURCE_ROOT: ref.project.projectDir,
|
|
17064
18202
|
PROJECT_DIR: ref.project.projectDir,
|
|
17065
|
-
SYMROOT:
|
|
18203
|
+
SYMROOT: import_node_path15.default.join(buildDir(ref.project), "Products"),
|
|
17066
18204
|
BUILD_DIR: "$(SYMROOT)",
|
|
17067
|
-
OBJROOT:
|
|
18205
|
+
OBJROOT: import_node_path15.default.join(buildDir(ref.project), "Intermediates.noindex"),
|
|
17068
18206
|
CONFIGURATION_BUILD_DIR: "$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)",
|
|
17069
18207
|
BUILT_PRODUCTS_DIR: "$(CONFIGURATION_BUILD_DIR)",
|
|
17070
18208
|
TARGET_BUILD_DIR: "$(CONFIGURATION_BUILD_DIR)",
|
|
@@ -17093,11 +18231,11 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17093
18231
|
xcconfigs
|
|
17094
18232
|
);
|
|
17095
18233
|
const searchRules = recursiveSearchRules(settings2);
|
|
17096
|
-
const absolute = (file) =>
|
|
18234
|
+
const absolute = (file) => import_node_path15.default.resolve(ref.project.projectDir, file);
|
|
17097
18235
|
const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? "");
|
|
17098
18236
|
const product = settings2("PRODUCT_NAME");
|
|
17099
18237
|
const building = options.prepareGeneratedSources && options.requireSources !== false;
|
|
17100
|
-
const versioning = building && allSources.length > 0 && settings2("VERSIONING_SYSTEM") === "apple-generic" ?
|
|
18238
|
+
const versioning = building && allSources.length > 0 && settings2("VERSIONING_SYSTEM") === "apple-generic" ? import_node_path15.default.join(settings2("DERIVED_FILE_DIR"), `${product}_vers.c`) : null;
|
|
17101
18239
|
if (versioning) {
|
|
17102
18240
|
const version = settings2("CURRENT_PROJECT_VERSION");
|
|
17103
18241
|
const custom = [
|
|
@@ -17110,7 +18248,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17110
18248
|
].filter((key) => settings2(key));
|
|
17111
18249
|
if (!/^\d+$/.test(version) || !/^[A-Za-z_]\w*$/.test(product) || custom.length)
|
|
17112
18250
|
throw new Error(
|
|
17113
|
-
`${name2}: Xcode generates ${
|
|
18251
|
+
`${name2}: Xcode generates ${import_node_path15.default.basename(versioning)} for VERSIONING_SYSTEM=apple-generic; peach writes it only for an integer CURRENT_PROJECT_VERSION (${JSON.stringify(version)}), an identifier PRODUCT_NAME (${JSON.stringify(product)}) and no ${custom.length ? custom.join(", ") : "VERSION_INFO_* override"}`
|
|
17114
18252
|
);
|
|
17115
18253
|
const unit = [
|
|
17116
18254
|
` extern const unsigned char ${product}VersionString[];`,
|
|
@@ -17120,9 +18258,9 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17120
18258
|
` const double ${product}VersionNumber __attribute__ ((used)) = (double)${version}.;`,
|
|
17121
18259
|
""
|
|
17122
18260
|
].join("\n");
|
|
17123
|
-
if (!
|
|
17124
|
-
|
|
17125
|
-
|
|
18261
|
+
if (!import_node_fs15.default.existsSync(versioning) || import_node_fs15.default.readFileSync(versioning, "utf8") !== unit) {
|
|
18262
|
+
import_node_fs15.default.mkdirSync(import_node_path15.default.dirname(versioning), { recursive: true });
|
|
18263
|
+
import_node_fs15.default.writeFileSync(versioning, unit);
|
|
17126
18264
|
}
|
|
17127
18265
|
allSources.push(versioning);
|
|
17128
18266
|
}
|
|
@@ -17154,14 +18292,14 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17154
18292
|
const headerFiles = headerPhase(ref);
|
|
17155
18293
|
const ownHeaders = /* @__PURE__ */ new Map();
|
|
17156
18294
|
for (const { file, visibility } of headerFiles) {
|
|
17157
|
-
const name3 =
|
|
18295
|
+
const name3 = import_node_path15.default.basename(file);
|
|
17158
18296
|
const published = framework && visibility !== "Project";
|
|
17159
18297
|
if (!ownHeaders.has(name3))
|
|
17160
18298
|
ownHeaders.set(name3, published ? `${product}/${name3}` : file);
|
|
17161
18299
|
if (framework && !published && !ownHeaders.has(`${product}/${name3}`))
|
|
17162
18300
|
ownHeaders.set(`${product}/${name3}`, file);
|
|
17163
18301
|
}
|
|
17164
|
-
const wrapper =
|
|
18302
|
+
const wrapper = import_node_path15.default.join(settings2("BUILT_PRODUCTS_DIR"), `${product}.framework`);
|
|
17165
18303
|
const moduleMap = settings2("DEFINES_MODULE") === "YES" && settings2("MODULEMAP_FILE") ? absolute(settings2("MODULEMAP_FILE")) : null;
|
|
17166
18304
|
const fileFlags = {};
|
|
17167
18305
|
for (const phaseId of list(ref.target.buildPhases)) {
|
|
@@ -17201,7 +18339,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17201
18339
|
...headers,
|
|
17202
18340
|
...Object.keys(ref.project.objects).flatMap((id) => {
|
|
17203
18341
|
const file = ref.project.resolvePath(id);
|
|
17204
|
-
return file && HEADER_FILE.test(file) &&
|
|
18342
|
+
return file && HEADER_FILE.test(file) && import_node_fs15.default.existsSync(file) ? [file] : [];
|
|
17205
18343
|
})
|
|
17206
18344
|
])
|
|
17207
18345
|
],
|
|
@@ -17210,15 +18348,15 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17210
18348
|
// xcode searches its products' include directory before
|
|
17211
18349
|
// HEADER_SEARCH_PATHS and the target's derived sources after.
|
|
17212
18350
|
headerSearchPaths: [
|
|
17213
|
-
|
|
18351
|
+
import_node_path15.default.join(settings2("BUILT_PRODUCTS_DIR"), "include"),
|
|
17214
18352
|
...settingList(settings2("HEADER_SEARCH_PATHS")).flatMap(
|
|
17215
18353
|
(raw) => expandSearchPath(absolute(raw), searchRules)
|
|
17216
18354
|
),
|
|
17217
|
-
|
|
18355
|
+
import_node_path15.default.join(
|
|
17218
18356
|
`${settings2("DERIVED_FILE_DIR")}-normal`,
|
|
17219
18357
|
settings2("CURRENT_ARCH")
|
|
17220
18358
|
),
|
|
17221
|
-
|
|
18359
|
+
import_node_path15.default.join(settings2("DERIVED_FILE_DIR"), settings2("CURRENT_ARCH")),
|
|
17222
18360
|
settings2("DERIVED_FILE_DIR")
|
|
17223
18361
|
],
|
|
17224
18362
|
userHeaderSearchPaths: settingList(
|
|
@@ -17257,16 +18395,16 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17257
18395
|
...headerFiles.flatMap(
|
|
17258
18396
|
({ file, visibility }) => visibility === "Project" ? [] : [
|
|
17259
18397
|
[
|
|
17260
|
-
|
|
18398
|
+
import_node_path15.default.join(
|
|
17261
18399
|
wrapper,
|
|
17262
18400
|
visibility === "Public" ? "Headers" : "PrivateHeaders",
|
|
17263
|
-
|
|
18401
|
+
import_node_path15.default.basename(file)
|
|
17264
18402
|
),
|
|
17265
18403
|
file
|
|
17266
18404
|
]
|
|
17267
18405
|
]
|
|
17268
18406
|
),
|
|
17269
|
-
...moduleMap ? [[
|
|
18407
|
+
...moduleMap ? [[import_node_path15.default.join(wrapper, "Modules", "module.modulemap"), moduleMap]] : []
|
|
17270
18408
|
]) : {}
|
|
17271
18409
|
}
|
|
17272
18410
|
} : {}
|
|
@@ -17277,7 +18415,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17277
18415
|
const frameworkTargets = order.slice(0, -1).map((ref) => ({ ref, framework: moduleTarget(ref).module }));
|
|
17278
18416
|
const frameworks = frameworkTargets.map(({ framework }) => framework);
|
|
17279
18417
|
const podSourceDirs = frameworkTargets.flatMap(
|
|
17280
|
-
({ ref, framework }) => isPodsProject(ref.project.xcodeproj) ? [...framework.allSources, ...framework.objc?.headers ?? []].map((file) =>
|
|
18418
|
+
({ ref, framework }) => isPodsProject(ref.project.xcodeproj) ? [...framework.allSources, ...framework.objc?.headers ?? []].map((file) => import_node_path15.default.dirname(file)).filter((dir) => import_node_fs15.default.existsSync(dir)) : []
|
|
17281
18419
|
);
|
|
17282
18420
|
const expandValue = (value) => {
|
|
17283
18421
|
if (typeof value === "string") return expand(value, settings);
|
|
@@ -17289,8 +18427,8 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17289
18427
|
}
|
|
17290
18428
|
return value;
|
|
17291
18429
|
};
|
|
17292
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
17293
|
-
const sourceInfo = infoPlistFile ?
|
|
18430
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path15.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
18431
|
+
const sourceInfo = infoPlistFile ? import_plist3.default.parse(import_node_fs15.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
17294
18432
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
17295
18433
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
17296
18434
|
}
|
|
@@ -17318,7 +18456,7 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17318
18456
|
};
|
|
17319
18457
|
}
|
|
17320
18458
|
const localPackageDirs = [
|
|
17321
|
-
...listed.filter((reference) =>
|
|
18459
|
+
...listed.filter((reference) => import_node_fs15.default.existsSync(import_node_path15.default.join(reference, "Package.swift"))),
|
|
17322
18460
|
...projects.flatMap(
|
|
17323
18461
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
17324
18462
|
if (!isDict(entry)) return [];
|
|
@@ -17328,23 +18466,37 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17328
18466
|
const packages = [];
|
|
17329
18467
|
while (pending.length > 0) {
|
|
17330
18468
|
const dir = pending.pop();
|
|
17331
|
-
if (
|
|
18469
|
+
if (import_node_fs15.default.existsSync(import_node_path15.default.join(dir, "Package.swift"))) {
|
|
17332
18470
|
packages.push(dir);
|
|
17333
18471
|
continue;
|
|
17334
18472
|
}
|
|
17335
18473
|
if (!isDirectory(dir)) continue;
|
|
17336
|
-
for (const child of
|
|
18474
|
+
for (const child of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }))
|
|
17337
18475
|
if (child.isDirectory() && !child.name.startsWith("."))
|
|
17338
|
-
pending.push(
|
|
18476
|
+
pending.push(import_node_path15.default.join(dir, child.name));
|
|
17339
18477
|
}
|
|
17340
18478
|
return packages;
|
|
17341
18479
|
}
|
|
17342
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
17343
|
-
return candidate &&
|
|
18480
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path15.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
18481
|
+
return candidate && import_node_fs15.default.existsSync(import_node_path15.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
17344
18482
|
})
|
|
17345
18483
|
)
|
|
17346
18484
|
];
|
|
18485
|
+
const remotePackageUrls = [
|
|
18486
|
+
...new Set(
|
|
18487
|
+
projects.flatMap(
|
|
18488
|
+
(project) => list(project.project.packageReferences).flatMap((id) => {
|
|
18489
|
+
const reference = project.object(id);
|
|
18490
|
+
const url = str(reference?.repositoryURL);
|
|
18491
|
+
return reference?.isa === "XCRemoteSwiftPackageReference" && url ? [url] : [];
|
|
18492
|
+
})
|
|
18493
|
+
)
|
|
18494
|
+
)
|
|
18495
|
+
];
|
|
17347
18496
|
const linkedProducts = [];
|
|
18497
|
+
const productReferences = [];
|
|
18498
|
+
const qualifiedProductKeys = /* @__PURE__ */ new Set();
|
|
18499
|
+
const linkedProductKeys = /* @__PURE__ */ new Set();
|
|
17348
18500
|
const binaryFrameworks = /* @__PURE__ */ new Map();
|
|
17349
18501
|
for (const { project, target } of order) {
|
|
17350
18502
|
const productDependencies = [
|
|
@@ -17357,19 +18509,21 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17357
18509
|
for (const dependencyId of productDependencies) {
|
|
17358
18510
|
const dependency = project.object(dependencyId);
|
|
17359
18511
|
const product = str(dependency?.productName)?.replace(/^plugin:/, "");
|
|
17360
|
-
if (!dependency || !product
|
|
17361
|
-
continue;
|
|
18512
|
+
if (!dependency || !product) continue;
|
|
17362
18513
|
const reference = project.object(str(dependency.package));
|
|
17363
|
-
|
|
18514
|
+
const linked = {
|
|
17364
18515
|
product,
|
|
17365
18516
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
17366
18517
|
kind: "local",
|
|
17367
|
-
dir:
|
|
18518
|
+
dir: import_node_path15.default.resolve(
|
|
17368
18519
|
project.projectDir,
|
|
17369
18520
|
str(reference.relativePath) ?? ""
|
|
17370
18521
|
)
|
|
17371
|
-
} : { kind: "unnamed" }
|
|
17372
|
-
}
|
|
18522
|
+
} : { kind: "unnamed", remoteUrls: remotePackageUrls }
|
|
18523
|
+
};
|
|
18524
|
+
productReferences.push({ project: project.projectFile, linked });
|
|
18525
|
+
if (linked.source.kind !== "unnamed")
|
|
18526
|
+
qualifiedProductKeys.add(`${project.projectFile}\0${product}`);
|
|
17373
18527
|
}
|
|
17374
18528
|
for (const phaseId of list(target.buildPhases)) {
|
|
17375
18529
|
const phase = project.object(phaseId);
|
|
@@ -17387,26 +18541,34 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17387
18541
|
}
|
|
17388
18542
|
}
|
|
17389
18543
|
}
|
|
17390
|
-
const
|
|
17391
|
-
|
|
18544
|
+
for (const { project, linked } of productReferences) {
|
|
18545
|
+
if (linked.source.kind === "unnamed" && qualifiedProductKeys.has(`${project}\0${linked.product}`))
|
|
18546
|
+
continue;
|
|
18547
|
+
const key = JSON.stringify(linked);
|
|
18548
|
+
if (linkedProductKeys.has(key)) continue;
|
|
18549
|
+
linkedProductKeys.add(key);
|
|
18550
|
+
linkedProducts.push(linked);
|
|
18551
|
+
}
|
|
18552
|
+
const resolvedFile = import_node_path15.default.join(
|
|
18553
|
+
workspace ?? import_node_path15.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
17392
18554
|
"xcshareddata",
|
|
17393
18555
|
"swiftpm",
|
|
17394
18556
|
"Package.resolved"
|
|
17395
18557
|
);
|
|
17396
|
-
const packageResolved =
|
|
18558
|
+
const packageResolved = import_node_fs15.default.existsSync(resolvedFile) ? [import_node_fs15.default.realpathSync(resolvedFile)] : [...new Set(localPackageDirs.map((dir) => import_node_path15.default.join(dir, "Package.resolved")))].filter((file) => import_node_fs15.default.existsSync(file)).map((file) => import_node_fs15.default.realpathSync(file)).sort();
|
|
17397
18559
|
const used = order.map((ref) => ref.project);
|
|
17398
18560
|
return {
|
|
17399
18561
|
...module2,
|
|
17400
18562
|
rootDir: commonAncestor(
|
|
17401
18563
|
[
|
|
17402
|
-
workspace ?
|
|
18564
|
+
workspace ? import_node_path15.default.dirname(workspace) : app.project.projectDir,
|
|
17403
18565
|
...used.map((project) => project.projectDir),
|
|
17404
18566
|
...localPackageDirs,
|
|
17405
18567
|
...linkedProducts.flatMap(
|
|
17406
|
-
({ source }) => source.kind === "local" &&
|
|
18568
|
+
({ source }) => source.kind === "local" && import_node_fs15.default.existsSync(source.dir) ? [source.dir] : []
|
|
17407
18569
|
),
|
|
17408
18570
|
...new Set(podSourceDirs)
|
|
17409
|
-
].map((dir) =>
|
|
18571
|
+
].map((dir) => import_node_fs15.default.realpathSync(dir))
|
|
17410
18572
|
),
|
|
17411
18573
|
projectFiles: [
|
|
17412
18574
|
.../* @__PURE__ */ new Set([
|
|
@@ -17415,13 +18577,14 @@ function readXcodeAppTarget(input, targetName, configurationName, options = {})
|
|
|
17415
18577
|
...cocoapods ? [cocoapods.podfileLock, cocoapods.manifestLock, ...cocoapods.localPodspecs] : []
|
|
17416
18578
|
])
|
|
17417
18579
|
].sort(),
|
|
18580
|
+
projectDirs: [...new Set(used.map((project) => project.projectDir))].sort(),
|
|
17418
18581
|
appIconName: settings("ASSETCATALOG_COMPILER_APPICON_NAME"),
|
|
17419
|
-
infoPlist:
|
|
18582
|
+
infoPlist: import_plist3.default.build(info),
|
|
17420
18583
|
infoPlistFile,
|
|
17421
18584
|
frameworks,
|
|
17422
18585
|
linkedProducts,
|
|
17423
18586
|
localPackageDirs: [
|
|
17424
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
18587
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs15.default.realpathSync(dir)))
|
|
17425
18588
|
].sort(),
|
|
17426
18589
|
binaryFrameworks: [...binaryFrameworks].map(([name2, file]) => ({ name: name2, path: file })).sort((left, right) => left.name.localeCompare(right.name)),
|
|
17427
18590
|
packageResolved,
|
|
@@ -17496,7 +18659,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
|
|
|
17496
18659
|
const rtcAppGroupIdentifier = nonEmptyString2(dictionary.RTCAppGroupIdentifier);
|
|
17497
18660
|
const screenShareExtensionBundleId = typeof dictionary.ScreenShareExtensionBundleId === "string" ? dictionary.ScreenShareExtensionBundleId : void 0;
|
|
17498
18661
|
const rootModuleName = readRootModuleName(
|
|
17499
|
-
app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) &&
|
|
18662
|
+
app.allSources.filter((file) => /\.(?:swift|mm|m)$/.test(file) && import_node_fs16.default.existsSync(file)).map((file) => import_node_fs16.default.readFileSync(file, "utf8"))
|
|
17500
18663
|
);
|
|
17501
18664
|
return {
|
|
17502
18665
|
applicationName,
|
|
@@ -17517,7 +18680,7 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
|
|
|
17517
18680
|
googleSignIn: readGoogleSignInConfiguration(
|
|
17518
18681
|
dictionary,
|
|
17519
18682
|
Object.fromEntries(
|
|
17520
|
-
app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(
|
|
18683
|
+
app.resources.filter((file) => file.endsWith(".plist")).map((file) => [file, parseInfoPlist(import_node_fs16.default.readFileSync(file, "utf8"))])
|
|
17521
18684
|
)
|
|
17522
18685
|
),
|
|
17523
18686
|
supportedInterfaceOrientations,
|
|
@@ -17526,11 +18689,11 @@ function readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist = parsePlistSo
|
|
|
17526
18689
|
alternateIconNames: [...alternateIconNames],
|
|
17527
18690
|
appIconArtwork: resolveNativeAppIconArtwork(
|
|
17528
18691
|
app.resources,
|
|
17529
|
-
(file) =>
|
|
18692
|
+
(file) => import_node_fs16.default.readFileSync(file, "utf8"),
|
|
17530
18693
|
(file) => {
|
|
17531
|
-
const extension =
|
|
18694
|
+
const extension = import_node_path16.default.extname(file).toLowerCase();
|
|
17532
18695
|
const contentType = extension === ".jpg" || extension === ".jpeg" ? "image/jpeg" : extension === ".webp" ? "image/webp" : "image/png";
|
|
17533
|
-
return `data:${contentType};base64,${
|
|
18696
|
+
return `data:${contentType};base64,${import_node_fs16.default.readFileSync(file).toString("base64")}`;
|
|
17534
18697
|
},
|
|
17535
18698
|
icons,
|
|
17536
18699
|
app.appIconName,
|
|
@@ -17561,22 +18724,22 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
|
|
|
17561
18724
|
const read = selectNativeAppIdentityReader(platform, {
|
|
17562
18725
|
android: () => null,
|
|
17563
18726
|
ios: () => {
|
|
17564
|
-
const iosRoot =
|
|
17565
|
-
if (!
|
|
18727
|
+
const iosRoot = import_node_path16.default.join(projectRoot, "ios");
|
|
18728
|
+
if (!import_node_fs16.default.existsSync(iosRoot)) return null;
|
|
17566
18729
|
const files = {};
|
|
17567
|
-
for (const entry of
|
|
18730
|
+
for (const entry of import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true })) {
|
|
17568
18731
|
if (entry.name === "Pods") continue;
|
|
17569
18732
|
if (entry.isDirectory()) {
|
|
17570
18733
|
const names = entry.name.endsWith(".xcodeproj") ? ["project.pbxproj"] : ["Info.plist", "AppDelegate.swift", "AppDelegate.mm", "AppDelegate.m"];
|
|
17571
18734
|
for (const name2 of names) {
|
|
17572
18735
|
const relative3 = `ios/${entry.name}/${name2}`;
|
|
17573
|
-
const file =
|
|
17574
|
-
if (
|
|
18736
|
+
const file = import_node_path16.default.join(projectRoot, relative3);
|
|
18737
|
+
if (import_node_fs16.default.existsSync(file)) files[relative3] = import_node_fs16.default.readFileSync(file, "utf8");
|
|
17575
18738
|
}
|
|
17576
18739
|
} else if (/AppDelegate\.(?:swift|mm|m)$/.test(entry.name)) {
|
|
17577
18740
|
const relative3 = `ios/${entry.name}`;
|
|
17578
|
-
const file =
|
|
17579
|
-
if (
|
|
18741
|
+
const file = import_node_path16.default.join(projectRoot, relative3);
|
|
18742
|
+
if (import_node_fs16.default.existsSync(file)) files[relative3] = import_node_fs16.default.readFileSync(file, "utf8");
|
|
17580
18743
|
}
|
|
17581
18744
|
}
|
|
17582
18745
|
return extractNativeAppIdentityFromFiles(files, "ios", parseInfoPlist, iosTarget);
|
|
@@ -17587,41 +18750,41 @@ function readNativeAppIdentityFromSources(projectRoot, platform, parseInfoPlist,
|
|
|
17587
18750
|
function readAndroidNativeAppIdentity(projectRoot, androidMergedManifest) {
|
|
17588
18751
|
const files = {};
|
|
17589
18752
|
if (androidMergedManifest) {
|
|
17590
|
-
const file =
|
|
17591
|
-
if (!
|
|
17592
|
-
files[androidMergedManifest] =
|
|
18753
|
+
const file = import_node_path16.default.resolve(projectRoot, androidMergedManifest);
|
|
18754
|
+
if (!import_node_fs16.default.existsSync(file)) return null;
|
|
18755
|
+
files[androidMergedManifest] = import_node_fs16.default.readFileSync(file, "utf8");
|
|
17593
18756
|
} else {
|
|
17594
|
-
const androidRoot =
|
|
17595
|
-
if (!
|
|
18757
|
+
const androidRoot = import_node_path16.default.join(projectRoot, "android");
|
|
18758
|
+
if (!import_node_fs16.default.existsSync(androidRoot)) return null;
|
|
17596
18759
|
const collect = (directory) => {
|
|
17597
|
-
for (const entry of
|
|
17598
|
-
const file =
|
|
18760
|
+
for (const entry of import_node_fs16.default.readdirSync(directory, { withFileTypes: true })) {
|
|
18761
|
+
const file = import_node_path16.default.join(directory, entry.name);
|
|
17599
18762
|
if (entry.isDirectory()) collect(file);
|
|
17600
18763
|
else if (entry.isFile() && entry.name === "AndroidManifest.xml")
|
|
17601
|
-
files[
|
|
18764
|
+
files[import_node_path16.default.relative(projectRoot, file).split(import_node_path16.default.sep).join("/")] = import_node_fs16.default.readFileSync(file, "utf8");
|
|
17602
18765
|
}
|
|
17603
18766
|
};
|
|
17604
|
-
for (const module2 of
|
|
18767
|
+
for (const module2 of import_node_fs16.default.readdirSync(androidRoot, { withFileTypes: true })) {
|
|
17605
18768
|
if (!module2.isDirectory()) continue;
|
|
17606
|
-
const outputs =
|
|
18769
|
+
const outputs = import_node_path16.default.join(
|
|
17607
18770
|
androidRoot,
|
|
17608
18771
|
module2.name,
|
|
17609
18772
|
"build/intermediates/merged_manifests"
|
|
17610
18773
|
);
|
|
17611
|
-
if (
|
|
18774
|
+
if (import_node_fs16.default.existsSync(outputs)) collect(outputs);
|
|
17612
18775
|
}
|
|
17613
18776
|
}
|
|
17614
18777
|
for (const manifest of Object.keys(files)) {
|
|
17615
18778
|
const resourceDirectory = androidMergedResourceValuesDirectory(manifest);
|
|
17616
18779
|
if (!resourceDirectory) continue;
|
|
17617
|
-
const absolute =
|
|
17618
|
-
if (!
|
|
17619
|
-
for (const entry of
|
|
18780
|
+
const absolute = import_node_path16.default.resolve(projectRoot, resourceDirectory);
|
|
18781
|
+
if (!import_node_fs16.default.existsSync(absolute)) continue;
|
|
18782
|
+
for (const entry of import_node_fs16.default.readdirSync(absolute, { withFileTypes: true })) {
|
|
17620
18783
|
if (!entry.isDirectory() || !/^values(?:-|$)/.test(entry.name)) continue;
|
|
17621
|
-
for (const resource of
|
|
18784
|
+
for (const resource of import_node_fs16.default.readdirSync(import_node_path16.default.join(absolute, entry.name))) {
|
|
17622
18785
|
if (!resource.endsWith(".xml")) continue;
|
|
17623
18786
|
const file = `${resourceDirectory}/${entry.name}/${resource}`;
|
|
17624
|
-
files[file] =
|
|
18787
|
+
files[file] = import_node_fs16.default.readFileSync(import_node_path16.default.resolve(projectRoot, file), "utf8");
|
|
17625
18788
|
}
|
|
17626
18789
|
}
|
|
17627
18790
|
}
|
|
@@ -17638,7 +18801,7 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
|
|
|
17638
18801
|
const app = readIosAppTarget(projectRoot, iosTarget);
|
|
17639
18802
|
if (!app) return null;
|
|
17640
18803
|
const identity = readNativeAppIdentityFromXcodeTarget(app, parseInfoPlist);
|
|
17641
|
-
const projectManifestPath =
|
|
18804
|
+
const projectManifestPath = import_node_path16.default.join(projectRoot, "package.json");
|
|
17642
18805
|
const projectRequire = (0, import_node_module4.createRequire)(projectManifestPath);
|
|
17643
18806
|
let reanimatedManifestPath;
|
|
17644
18807
|
try {
|
|
@@ -17652,22 +18815,22 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
|
|
|
17652
18815
|
throw error;
|
|
17653
18816
|
}
|
|
17654
18817
|
const installedManifest = JSON.parse(
|
|
17655
|
-
|
|
18818
|
+
import_node_fs16.default.readFileSync(reanimatedManifestPath, "utf8")
|
|
17656
18819
|
);
|
|
17657
18820
|
const installedVersion = isRecord(installedManifest) ? nonEmptyString2(installedManifest.version) : void 0;
|
|
17658
18821
|
if (!installedVersion) throw new Error("Reanimated package version is malformed");
|
|
17659
18822
|
if (Number.parseInt(installedVersion, 10) < 4) return identity;
|
|
17660
18823
|
const defaults = JSON.parse(
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
|
|
18824
|
+
import_node_fs16.default.readFileSync(
|
|
18825
|
+
import_node_path16.default.join(
|
|
18826
|
+
import_node_path16.default.dirname(reanimatedManifestPath),
|
|
17664
18827
|
"src/featureFlags/staticFlags.json"
|
|
17665
18828
|
),
|
|
17666
18829
|
"utf8"
|
|
17667
18830
|
)
|
|
17668
18831
|
);
|
|
17669
18832
|
if (!isRecord(defaults)) throw new Error("Reanimated static flags are malformed");
|
|
17670
|
-
const manifest = JSON.parse(
|
|
18833
|
+
const manifest = JSON.parse(import_node_fs16.default.readFileSync(projectManifestPath, "utf8"));
|
|
17671
18834
|
const reanimated = isRecord(manifest) ? manifest.reanimated : void 0;
|
|
17672
18835
|
const overrides = isRecord(reanimated) ? reanimated.staticFeatureFlags : void 0;
|
|
17673
18836
|
if (overrides !== void 0 && !isRecord(overrides)) {
|
|
@@ -17690,9 +18853,9 @@ function readIosNativeAppIdentity(projectRoot, parseInfoPlist, iosTarget) {
|
|
|
17690
18853
|
return { ...identity, reanimatedStaticFeatureFlags: flags };
|
|
17691
18854
|
}
|
|
17692
18855
|
function readIosAppTarget(projectRoot, iosTarget) {
|
|
17693
|
-
const iosRoot =
|
|
17694
|
-
if (!
|
|
17695
|
-
const projects =
|
|
18856
|
+
const iosRoot = import_node_path16.default.join(projectRoot, "ios");
|
|
18857
|
+
if (!import_node_fs16.default.existsSync(iosRoot)) return null;
|
|
18858
|
+
const projects = import_node_fs16.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
|
|
17696
18859
|
if (projects.length === 0) return null;
|
|
17697
18860
|
if (projects.length > 1 && !iosTarget) {
|
|
17698
18861
|
throw new NativeAppTargetSelectionError(
|
|
@@ -17702,7 +18865,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
|
|
|
17702
18865
|
let project = projects[0];
|
|
17703
18866
|
if (iosTarget && projects.length > 1) {
|
|
17704
18867
|
const matches = projects.filter(
|
|
17705
|
-
(entry) => listXcodeAppTargets(
|
|
18868
|
+
(entry) => listXcodeAppTargets(import_node_path16.default.join(iosRoot, entry.name), {
|
|
17706
18869
|
requireSources: false
|
|
17707
18870
|
}).includes(iosTarget)
|
|
17708
18871
|
);
|
|
@@ -17716,7 +18879,7 @@ function readIosAppTarget(projectRoot, iosTarget) {
|
|
|
17716
18879
|
}
|
|
17717
18880
|
project = matches[0];
|
|
17718
18881
|
}
|
|
17719
|
-
const xcodeproj =
|
|
18882
|
+
const xcodeproj = import_node_path16.default.join(iosRoot, project.name);
|
|
17720
18883
|
const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
|
|
17721
18884
|
if (!iosTarget && appTargets.length > 1) {
|
|
17722
18885
|
throw new NativeAppTargetSelectionError(
|
|
@@ -17731,9 +18894,9 @@ function readIosAppTarget(projectRoot, iosTarget) {
|
|
|
17731
18894
|
// src/native-firebase-config.ts
|
|
17732
18895
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
17733
18896
|
var import_node_child_process6 = require("node:child_process");
|
|
17734
|
-
var
|
|
17735
|
-
var
|
|
17736
|
-
var
|
|
18897
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
18898
|
+
var import_node_os4 = __toESM(require("node:os"), 1);
|
|
18899
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
17737
18900
|
init_is_record();
|
|
17738
18901
|
var EXPO_CONFIG_SCRIPT = `const { createRequire } = require('node:module');
|
|
17739
18902
|
const { writeFileSync } = require('node:fs');
|
|
@@ -17744,13 +18907,13 @@ const result = JSON.stringify(getConfig(root, { skipSDKVersionRequirement: true
|
|
|
17744
18907
|
if (Buffer.byteLength(result) > 1024 * 1024) throw new Error('Expo native configuration exceeds 1 MiB.');
|
|
17745
18908
|
writeFileSync(process.argv[2], result, { mode: 0o600 });`;
|
|
17746
18909
|
function hasExpoConfig(projectRoot) {
|
|
17747
|
-
const appJsonPath =
|
|
17748
|
-
const appJson =
|
|
18910
|
+
const appJsonPath = import_node_path17.default.join(projectRoot, "app.json");
|
|
18911
|
+
const appJson = import_node_fs17.default.existsSync(appJsonPath) ? JSON.parse(import_node_fs17.default.readFileSync(appJsonPath, "utf8")) : null;
|
|
17749
18912
|
const staticExpo = isRecord(appJson) && (isRecord(appJson.expo) || [appJson.ios, appJson.android].some(
|
|
17750
18913
|
(value) => isRecord(value) && typeof value.googleServicesFile === "string"
|
|
17751
18914
|
));
|
|
17752
18915
|
return staticExpo || ["app.config.js", "app.config.ts", "app.config.cjs", "app.config.mjs"].some(
|
|
17753
|
-
(name2) =>
|
|
18916
|
+
(name2) => import_node_fs17.default.existsSync(import_node_path17.default.join(projectRoot, name2))
|
|
17754
18917
|
);
|
|
17755
18918
|
}
|
|
17756
18919
|
function expoConfigArgs(projectRoot, resultPath) {
|
|
@@ -17758,22 +18921,22 @@ function expoConfigArgs(projectRoot, resultPath) {
|
|
|
17758
18921
|
"--input-type=commonjs",
|
|
17759
18922
|
"-e",
|
|
17760
18923
|
EXPO_CONFIG_SCRIPT,
|
|
17761
|
-
|
|
18924
|
+
import_node_path17.default.resolve(projectRoot),
|
|
17762
18925
|
resultPath
|
|
17763
18926
|
];
|
|
17764
18927
|
}
|
|
17765
18928
|
function readExpoConfigResult(resultPath, status, stderr) {
|
|
17766
18929
|
if (status !== 0)
|
|
17767
18930
|
throw new Error(stderr || "Expo native configuration evaluation failed.");
|
|
17768
|
-
const resolved = JSON.parse(
|
|
18931
|
+
const resolved = JSON.parse(import_node_fs17.default.readFileSync(resultPath, "utf8"));
|
|
17769
18932
|
if (!isRecord(resolved)) throw new Error("Expo native configuration is unavailable.");
|
|
17770
18933
|
return resolved;
|
|
17771
18934
|
}
|
|
17772
|
-
var resultDirectory = () =>
|
|
18935
|
+
var resultDirectory = () => import_node_fs17.default.mkdtempSync(import_node_path17.default.join(import_node_os4.default.tmpdir(), "peach-expo-config-"));
|
|
17773
18936
|
function readExpoConfig(projectRoot) {
|
|
17774
18937
|
if (!hasExpoConfig(projectRoot)) return {};
|
|
17775
18938
|
const directory = resultDirectory();
|
|
17776
|
-
const resultPath =
|
|
18939
|
+
const resultPath = import_node_path17.default.join(directory, "config.json");
|
|
17777
18940
|
try {
|
|
17778
18941
|
const child = (0, import_node_child_process6.spawnSync)("node", expoConfigArgs(projectRoot, resultPath), {
|
|
17779
18942
|
cwd: projectRoot,
|
|
@@ -17785,7 +18948,7 @@ function readExpoConfig(projectRoot) {
|
|
|
17785
18948
|
if (child.error) throw child.error;
|
|
17786
18949
|
return readExpoConfigResult(resultPath, child.status, child.stderr);
|
|
17787
18950
|
} finally {
|
|
17788
|
-
|
|
18951
|
+
import_node_fs17.default.rmSync(directory, { recursive: true, force: true });
|
|
17789
18952
|
}
|
|
17790
18953
|
}
|
|
17791
18954
|
function evaluateFirebaseGuard(header, resources) {
|
|
@@ -17807,7 +18970,7 @@ function evaluateFirebaseGuard(header, resources) {
|
|
|
17807
18970
|
}
|
|
17808
18971
|
clauses.push(condition.slice(start).trim());
|
|
17809
18972
|
const sources = resources.filter(
|
|
17810
|
-
(file) =>
|
|
18973
|
+
(file) => import_node_path17.default.basename(file) === "GoogleService-Info.plist"
|
|
17811
18974
|
);
|
|
17812
18975
|
const bound = /* @__PURE__ */ new Map();
|
|
17813
18976
|
for (const clause of clauses) {
|
|
@@ -17823,7 +18986,7 @@ function evaluateFirebaseGuard(header, resources) {
|
|
|
17823
18986
|
const dictionary = /^let\s+(\w+)\s*=\s*NSDictionary\s*\(\s*contentsOfFile:\s*(\w+)\s*\)$/.exec(clause);
|
|
17824
18987
|
if (dictionary && typeof bound.get(dictionary[2]) === "string") {
|
|
17825
18988
|
const parsed = parsePlistSource(
|
|
17826
|
-
|
|
18989
|
+
import_node_fs17.default.readFileSync(String(bound.get(dictionary[2])), "utf8")
|
|
17827
18990
|
);
|
|
17828
18991
|
if (!isRecord(parsed)) return false;
|
|
17829
18992
|
bound.set(dictionary[1], parsed);
|
|
@@ -17905,7 +19068,7 @@ function findDefaultConfigureCall(body, sources) {
|
|
|
17905
19068
|
const [, type, name2] = call;
|
|
17906
19069
|
for (const file of sources) {
|
|
17907
19070
|
if (!file.endsWith(".swift")) continue;
|
|
17908
|
-
const source = blankSwiftObjcLiterals(
|
|
19071
|
+
const source = blankSwiftObjcLiterals(import_node_fs17.default.readFileSync(file, "utf8"));
|
|
17909
19072
|
const declaration = new RegExp(
|
|
17910
19073
|
`\\b(?:enum|struct|class)\\s+${type}\\b[^{]*\\{`
|
|
17911
19074
|
).exec(source);
|
|
@@ -17926,10 +19089,10 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
|
|
|
17926
19089
|
requireSources: false
|
|
17927
19090
|
});
|
|
17928
19091
|
const delegates = app.allSources.filter(
|
|
17929
|
-
(file) => /^AppDelegate\.(swift|mm|m)$/.test(
|
|
19092
|
+
(file) => /^AppDelegate\.(swift|mm|m)$/.test(import_node_path17.default.basename(file))
|
|
17930
19093
|
);
|
|
17931
19094
|
const defaultConfigured = delegates.some((file) => {
|
|
17932
|
-
const raw =
|
|
19095
|
+
const raw = import_node_fs17.default.readFileSync(file, "utf8");
|
|
17933
19096
|
const source = blankSwiftObjcLiterals(raw);
|
|
17934
19097
|
const launch = /(?:\bfunc\s+application\s*\([\s\S]*?didFinishLaunchingWithOptions[\s\S]*?\)\s*->\s*Bool|^-\s*\(BOOL\)\s*application\s*:[\s\S]*?didFinishLaunchingWithOptions[^{]*)\s*\{/m.exec(
|
|
17935
19098
|
source
|
|
@@ -17995,27 +19158,27 @@ function readTargetGoogleServicesFile(projectRoot, xcodeproj, target) {
|
|
|
17995
19158
|
});
|
|
17996
19159
|
if (!defaultConfigured) return null;
|
|
17997
19160
|
const resources = app.resources.filter(
|
|
17998
|
-
(file) => /^GoogleService-Info\.plist$/.test(
|
|
19161
|
+
(file) => /^GoogleService-Info\.plist$/.test(import_node_path17.default.basename(file))
|
|
17999
19162
|
);
|
|
18000
19163
|
if (resources.length !== 1)
|
|
18001
19164
|
throw new Error(
|
|
18002
19165
|
"native Firebase default initialization requires one GoogleService-Info.plist build resource"
|
|
18003
19166
|
);
|
|
18004
|
-
return
|
|
19167
|
+
return import_node_path17.default.relative(import_node_fs17.default.realpathSync(projectRoot), resources[0]);
|
|
18005
19168
|
}
|
|
18006
19169
|
function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], iosTarget, config = readExpoConfig(projectRoot)) {
|
|
18007
19170
|
const result = {};
|
|
18008
19171
|
const ios = config.ios;
|
|
18009
19172
|
if (platforms.includes("ios") && (!isRecord(ios) || typeof ios.googleServicesFile !== "string")) {
|
|
18010
|
-
const iosRoot =
|
|
18011
|
-
if (
|
|
18012
|
-
const projects =
|
|
19173
|
+
const iosRoot = import_node_path17.default.join(projectRoot, "ios");
|
|
19174
|
+
if (import_node_fs17.default.existsSync(iosRoot)) {
|
|
19175
|
+
const projects = import_node_fs17.default.readdirSync(iosRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && entry.name.endsWith(".xcodeproj"));
|
|
18013
19176
|
if (projects.length > 1)
|
|
18014
19177
|
throw new Error(
|
|
18015
19178
|
`native Firebase configuration requires a selected Xcode project; set withPeach's iosTarget to an app target in one of: ${projects.map((entry) => entry.name).join(", ")}`
|
|
18016
19179
|
);
|
|
18017
19180
|
if (projects.length === 1) {
|
|
18018
|
-
const xcodeproj =
|
|
19181
|
+
const xcodeproj = import_node_path17.default.join(iosRoot, projects[0].name);
|
|
18019
19182
|
const appTargets = listXcodeAppTargets(xcodeproj, { requireSources: false });
|
|
18020
19183
|
const files = new Set(
|
|
18021
19184
|
(iosTarget ? [iosTarget] : appTargets).map(
|
|
@@ -18035,8 +19198,8 @@ function readNativeFirebaseConfig(projectRoot, platforms = ["ios", "android"], i
|
|
|
18035
19198
|
const native = config[platform];
|
|
18036
19199
|
if (!isRecord(native) || typeof native.googleServicesFile !== "string") continue;
|
|
18037
19200
|
try {
|
|
18038
|
-
const source =
|
|
18039
|
-
|
|
19201
|
+
const source = import_node_fs17.default.readFileSync(
|
|
19202
|
+
import_node_path17.default.resolve(projectRoot, native.googleServicesFile),
|
|
18040
19203
|
"utf8"
|
|
18041
19204
|
);
|
|
18042
19205
|
const parsed = platform === "ios" ? parsePlistSource(source) : JSON.parse(source);
|
|
@@ -18229,13 +19392,13 @@ function readCallableMetroExport(moduleValue, label) {
|
|
|
18229
19392
|
}
|
|
18230
19393
|
function createMetroDefaultSerializer(asyncRequireModulePath) {
|
|
18231
19394
|
const projectRequire = (0, import_module2.createRequire)(asyncRequireModulePath);
|
|
18232
|
-
const metroRoot =
|
|
19395
|
+
const metroRoot = import_path6.default.dirname(projectRequire.resolve("metro/package.json"));
|
|
18233
19396
|
const baseJSBundle = readCallableMetroExport(
|
|
18234
|
-
projectRequire(
|
|
19397
|
+
projectRequire(import_path6.default.join(metroRoot, "src/DeltaBundler/Serializers/baseJSBundle.js")),
|
|
18235
19398
|
"baseJSBundle"
|
|
18236
19399
|
);
|
|
18237
19400
|
const bundleToString = readCallableMetroExport(
|
|
18238
|
-
projectRequire(
|
|
19401
|
+
projectRequire(import_path6.default.join(metroRoot, "src/lib/bundleToString.js")),
|
|
18239
19402
|
"bundleToString"
|
|
18240
19403
|
);
|
|
18241
19404
|
return (entryPoint, preModules, graph, options) => {
|
|
@@ -18257,7 +19420,7 @@ async function appendRNXModulePaths(result, graph, options, projectRoot, emptyMo
|
|
|
18257
19420
|
}
|
|
18258
19421
|
const modulePaths = {};
|
|
18259
19422
|
for (const module2 of dependencies.values()) {
|
|
18260
|
-
modulePaths[String(createModuleId(module2.path))] =
|
|
19423
|
+
modulePaths[String(createModuleId(module2.path))] = import_path6.default.relative(projectRoot, module2.path).replaceAll(import_path6.default.sep, "/");
|
|
18261
19424
|
}
|
|
18262
19425
|
if (Object.keys(modulePaths).length !== dependencies.size) {
|
|
18263
19426
|
throw new Error("peachsim: bundle module IDs were not unique");
|
|
@@ -18347,8 +19510,8 @@ function withPeach(config, options = {}) {
|
|
|
18347
19510
|
graph,
|
|
18348
19511
|
serializerOptions,
|
|
18349
19512
|
cfgProjectRoot,
|
|
18350
|
-
configuredEmptyModulePath ??
|
|
18351
|
-
|
|
19513
|
+
configuredEmptyModulePath ?? import_path6.default.join(
|
|
19514
|
+
import_path6.default.dirname(serializerOptions.asyncRequireModulePath),
|
|
18352
19515
|
"empty-module.js"
|
|
18353
19516
|
)
|
|
18354
19517
|
);
|
|
@@ -18459,6 +19622,7 @@ function withPeach(config, options = {}) {
|
|
|
18459
19622
|
}
|
|
18460
19623
|
return;
|
|
18461
19624
|
}
|
|
19625
|
+
if (serveBrowserProxyRoute(req, res)) return;
|
|
18462
19626
|
const url = req.url || "";
|
|
18463
19627
|
const pathname = url.split("?")[0];
|
|
18464
19628
|
const runtimeRoot = resolveRuntimeRootForRequestHost(req.headers?.host);
|
|
@@ -18489,14 +19653,13 @@ function withPeach(config, options = {}) {
|
|
|
18489
19653
|
}
|
|
18490
19654
|
}
|
|
18491
19655
|
if (pathname === prefix || pathname === prefix + "/" || pathname.startsWith(prefix + "/")) {
|
|
18492
|
-
const ext =
|
|
19656
|
+
const ext = import_path6.default.extname(pathname);
|
|
18493
19657
|
if (!ext) {
|
|
18494
|
-
const htmlPath =
|
|
18495
|
-
let html =
|
|
19658
|
+
const htmlPath = import_path6.default.join(runtimeRoot, "index.html");
|
|
19659
|
+
let html = import_fs7.default.readFileSync(htmlPath, "utf8");
|
|
18496
19660
|
const script = `<script>(function(){var u=new URL(location.href);if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',${JSON.stringify(bundleUrl)});history.replaceState(null,'','${prefix}/'+u.search)})()</script>`;
|
|
18497
19661
|
html = html.includes("</head>") ? html.replace("</head>", `${script}</head>`) : `${html}${script}`;
|
|
18498
|
-
res
|
|
18499
|
-
res.end(html);
|
|
19662
|
+
sendShellHtml(res, html);
|
|
18500
19663
|
return;
|
|
18501
19664
|
}
|
|
18502
19665
|
}
|
|
@@ -18528,13 +19691,13 @@ var metro_plugin_default = withPeach;
|
|
|
18528
19691
|
|
|
18529
19692
|
// src/jump-to-source-babel.ts
|
|
18530
19693
|
init_define_SWIFT_COVERAGE_SOURCE_DIGESTS();
|
|
18531
|
-
function normalizeSourcePath(
|
|
18532
|
-
const queryStart =
|
|
18533
|
-
const clean = queryStart >= 0 ?
|
|
19694
|
+
function normalizeSourcePath(path22) {
|
|
19695
|
+
const queryStart = path22.indexOf("?");
|
|
19696
|
+
const clean = queryStart >= 0 ? path22.slice(0, queryStart) : path22;
|
|
18534
19697
|
return clean.replace(/\\/g, "/");
|
|
18535
19698
|
}
|
|
18536
|
-
function matchesPath(
|
|
18537
|
-
return typeof matcher === "string" ?
|
|
19699
|
+
function matchesPath(path22, matcher) {
|
|
19700
|
+
return typeof matcher === "string" ? path22.includes(matcher) : matcher.test(path22);
|
|
18538
19701
|
}
|
|
18539
19702
|
function shouldStampFile(filename, options) {
|
|
18540
19703
|
const normalized = normalizeSourcePath(filename);
|
|
@@ -18554,11 +19717,11 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
|
18554
19717
|
name: "sootsim-jump-to-source",
|
|
18555
19718
|
visitor: {
|
|
18556
19719
|
JSXElement: {
|
|
18557
|
-
exit(
|
|
19720
|
+
exit(path22, state) {
|
|
18558
19721
|
if (options.enabled === false) return;
|
|
18559
19722
|
const filename = state.filename;
|
|
18560
19723
|
if (!filename || !shouldStampFile(filename, options)) return;
|
|
18561
|
-
const node =
|
|
19724
|
+
const node = path22.node;
|
|
18562
19725
|
if (stamped.has(node)) return;
|
|
18563
19726
|
stamped.add(node);
|
|
18564
19727
|
const opening = node.openingElement;
|
|
@@ -18577,12 +19740,12 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
|
18577
19740
|
);
|
|
18578
19741
|
return;
|
|
18579
19742
|
}
|
|
18580
|
-
const fn =
|
|
19743
|
+
const fn = path22.getFunctionParent();
|
|
18581
19744
|
const parameterDefault = Boolean(
|
|
18582
19745
|
fn && opening.start != null && fn.node.body.start != null && opening.start < fn.node.body.start
|
|
18583
19746
|
);
|
|
18584
|
-
const type =
|
|
18585
|
-
if (!parameterDefault)
|
|
19747
|
+
const type = path22.scope.generateUidIdentifier("PeachSourceType");
|
|
19748
|
+
if (!parameterDefault) path22.scope.push({ id: type });
|
|
18586
19749
|
function expression(tag) {
|
|
18587
19750
|
return t.isJSXIdentifier(tag) ? t.identifier(tag.name) : t.memberExpression(
|
|
18588
19751
|
expression(tag.object),
|
|
@@ -18617,10 +19780,10 @@ function sootsimJumpToSourceBabelPlugin(api, options = {}) {
|
|
|
18617
19780
|
),
|
|
18618
19781
|
node
|
|
18619
19782
|
);
|
|
18620
|
-
if (
|
|
18621
|
-
|
|
19783
|
+
if (path22.parentPath.isJSXElement() || path22.parentPath.isJSXFragment()) {
|
|
19784
|
+
path22.replaceWith(t.jsxExpressionContainer(replacement));
|
|
18622
19785
|
} else {
|
|
18623
|
-
|
|
19786
|
+
path22.replaceWith(replacement);
|
|
18624
19787
|
}
|
|
18625
19788
|
}
|
|
18626
19789
|
}
|