peachsim 0.1.795 → 0.1.797
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/cloud-test-tunnel.ts +1 -1
- package/cli/outbound-endpoints.ts +6 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +383 -355
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +357 -336
- 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 +680 -575
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +401 -178
- 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 +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +85 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +976 -851
- package/dist-lib/swift-compile.cjs +18 -4
- package/dist-lib/swift-compile.mjs +18 -4
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +416 -368
- package/dist-lib/vite.cjs +240 -15
- package/package.json +1 -1
- package/scripts/dev-server-scanner.ts +16 -5
- package/src/expo-swift-host.ts +8 -4
- package/src/one-widget-discovery.ts +17 -0
- package/src/one-widget-metadata.ts +208 -0
- package/src/one-widget-package.ts +11 -165
- package/src/oneWidgetContract.ts +122 -0
- package/src/swift-compile.ts +21 -3
- package/src/swift-distribution.lock.json +11 -11
- package/src/swift-host.ts +2 -48
- package/src/swift-source-file.ts +48 -0
- package/src/vite-plugin-one.ts +18 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.797 | (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;
|
|
@@ -691,8 +691,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
691
691
|
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
692
692
|
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
693
693
|
);
|
|
694
|
+
if (spriteKit) {
|
|
695
|
+
reachedFrameworks.add("SpriteKit");
|
|
696
|
+
reachedFrameworks.add("PeachBox2D");
|
|
697
|
+
}
|
|
694
698
|
const distributionObjects = distribution?.objects.filter(
|
|
695
|
-
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
699
|
+
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
696
700
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
697
701
|
)
|
|
698
702
|
);
|
|
@@ -1825,7 +1829,17 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
1825
1829
|
])
|
|
1826
1830
|
],
|
|
1827
1831
|
{
|
|
1828
|
-
env:
|
|
1832
|
+
env: {
|
|
1833
|
+
...BUILD_ENV,
|
|
1834
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
1835
|
+
...process.platform === "linux" ? {
|
|
1836
|
+
LD_LIBRARY_PATH: [
|
|
1837
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
1838
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
1839
|
+
process.env.LD_LIBRARY_PATH
|
|
1840
|
+
].filter(Boolean).join(":")
|
|
1841
|
+
} : {}
|
|
1842
|
+
},
|
|
1829
1843
|
maxBuffer: 64 * 1024 * 1024,
|
|
1830
1844
|
timeout: options.timeoutMs
|
|
1831
1845
|
}
|
|
@@ -1911,7 +1925,7 @@ var init_swift_compile = __esm({
|
|
|
1911
1925
|
);
|
|
1912
1926
|
FOUNDATION_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "PeachObjC", "-Xfrontend", "-import-module", "-Xfrontend", "Dispatch", "-Xfrontend", "-import-module", "-Xfrontend", "FoundationNetworking", "-Xfrontend", "-import-module", "-Xfrontend", "WASILibc", "-Xfrontend", "-import-module", "-Xfrontend", "wasi_pthread"';
|
|
1913
1927
|
ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
1914
|
-
MULTI_MANIFEST_VERSION =
|
|
1928
|
+
MULTI_MANIFEST_VERSION = 12;
|
|
1915
1929
|
DIRECTIVE = /^[ \t]*#(?:if|elseif)\b/;
|
|
1916
1930
|
OS_IOS = /\bos\(\s*iOS\s*\)/g;
|
|
1917
1931
|
OBJC_ATTRIBUTE = /^@(?:objcMembers\b|objc\b(?:(\s*)\(([^()]*)\))?|IBAction\b)/;
|
|
@@ -2099,24 +2113,24 @@ var swift_distribution_lock_default;
|
|
|
2099
2113
|
var init_swift_distribution_lock = __esm({
|
|
2100
2114
|
"src/swift-distribution.lock.json"() {
|
|
2101
2115
|
swift_distribution_lock_default = {
|
|
2102
|
-
id: "
|
|
2116
|
+
id: "1a431e89764e8cfa",
|
|
2103
2117
|
release: "swift-6.3-RELEASE",
|
|
2104
|
-
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
2105
|
-
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-
|
|
2106
|
-
wasmSdkChecksum: "
|
|
2107
|
-
source: "
|
|
2118
|
+
wasmSdkId: "swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4",
|
|
2119
|
+
wasmSdkUrl: "https://r2.sootsim.com/swift-wasm-sdk/swift-6.3-RELEASE_wasm-peach-41921598-peach-f2d7f5d4.artifactbundle.tar.gz",
|
|
2120
|
+
wasmSdkChecksum: "7471b1c145aba62bb9f696aa4d0cd1657cbd9bc7637811b2e6bda1f650553f8d",
|
|
2121
|
+
source: "90d77cf86a77ba84839e5885e1c354a4976f825f",
|
|
2108
2122
|
hosts: {
|
|
2109
2123
|
"darwin-arm64": {
|
|
2110
|
-
sha256: "
|
|
2111
|
-
size:
|
|
2124
|
+
sha256: "ae344e0c60631747c512785d3232be4bc3066d3edbc2916616d43f2a8ee9d759",
|
|
2125
|
+
size: 36453618
|
|
2112
2126
|
},
|
|
2113
2127
|
"linux-x64": {
|
|
2114
|
-
sha256: "
|
|
2115
|
-
size:
|
|
2128
|
+
sha256: "16d8f064eaec39e35ee969719481d1f709e9dd08b7112dd83c7c0b8c0b447922",
|
|
2129
|
+
size: 36458677
|
|
2116
2130
|
},
|
|
2117
2131
|
"linux-arm64": {
|
|
2118
|
-
sha256: "
|
|
2119
|
-
size:
|
|
2132
|
+
sha256: "942892104d80b351b2dc9b414ba72695542ed3b066e0fe9e98d8e42ac760c8df",
|
|
2133
|
+
size: 36457909
|
|
2120
2134
|
}
|
|
2121
2135
|
}
|
|
2122
2136
|
};
|
|
@@ -2302,8 +2316,8 @@ function pickImagesetFile(images) {
|
|
|
2302
2316
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
2303
2317
|
};
|
|
2304
2318
|
}
|
|
2305
|
-
function flatScale(
|
|
2306
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
2319
|
+
function flatScale(path16) {
|
|
2320
|
+
const match = /@([23])x\.[^./]+$/.exec(path16);
|
|
2307
2321
|
return match ? Number(match[1]) : 1;
|
|
2308
2322
|
}
|
|
2309
2323
|
function providesNamespace(text3) {
|
|
@@ -2330,13 +2344,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
2330
2344
|
}
|
|
2331
2345
|
return segments.join("/");
|
|
2332
2346
|
}
|
|
2333
|
-
function isFlatResourceImage(
|
|
2334
|
-
return
|
|
2347
|
+
function isFlatResourceImage(path16) {
|
|
2348
|
+
return path16.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path16));
|
|
2335
2349
|
}
|
|
2336
2350
|
function enumerateBundleImages(paths, readText) {
|
|
2337
2351
|
const table = [];
|
|
2338
2352
|
const seen = /* @__PURE__ */ new Set();
|
|
2339
|
-
const catalogs = paths.filter((
|
|
2353
|
+
const catalogs = paths.filter((path16) => baseOf(path16) === "Contents.json");
|
|
2340
2354
|
for (const contentsPath of catalogs) {
|
|
2341
2355
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
2342
2356
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -2357,12 +2371,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
2357
2371
|
seen.add(name2);
|
|
2358
2372
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
2359
2373
|
}
|
|
2360
|
-
for (const
|
|
2361
|
-
if (!isFlatResourceImage(
|
|
2362
|
-
const name2 = baseOf(
|
|
2374
|
+
for (const path16 of paths) {
|
|
2375
|
+
if (!isFlatResourceImage(path16)) continue;
|
|
2376
|
+
const name2 = baseOf(path16).slice(0, -extOf(path16).length);
|
|
2363
2377
|
if (name2 === "" || seen.has(name2)) continue;
|
|
2364
2378
|
seen.add(name2);
|
|
2365
|
-
table.push({ name: name2, file:
|
|
2379
|
+
table.push({ name: name2, file: path16, scale: flatScale(path16) });
|
|
2366
2380
|
}
|
|
2367
2381
|
return table;
|
|
2368
2382
|
}
|
|
@@ -2391,7 +2405,7 @@ function colorsetValue(color) {
|
|
|
2391
2405
|
}
|
|
2392
2406
|
function enumerateBundleColors(paths, readText) {
|
|
2393
2407
|
const table = {};
|
|
2394
|
-
for (const contentsPath of paths.filter((
|
|
2408
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
2395
2409
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
2396
2410
|
if (name2 === null || name2 in table) continue;
|
|
2397
2411
|
let colors;
|
|
@@ -2455,8 +2469,8 @@ function axisExtremes(points) {
|
|
|
2455
2469
|
function pathBounds(d) {
|
|
2456
2470
|
const xs = [];
|
|
2457
2471
|
const ys = [];
|
|
2458
|
-
for (const
|
|
2459
|
-
(0, import_svgpath.default)(
|
|
2472
|
+
for (const path16 of d)
|
|
2473
|
+
(0, import_svgpath.default)(path16).abs().unshort().unarc().iterate((segment2, _index, x, y) => {
|
|
2460
2474
|
const [command, ...args] = segment2;
|
|
2461
2475
|
if (command === "M" || command === "L") {
|
|
2462
2476
|
xs.push(Number(args[0]));
|
|
@@ -2483,7 +2497,7 @@ function guide(svg, id, axis) {
|
|
|
2483
2497
|
}
|
|
2484
2498
|
function enumerateBundleSymbols(paths, readText) {
|
|
2485
2499
|
const table = {};
|
|
2486
|
-
for (const contentsPath of paths.filter((
|
|
2500
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
2487
2501
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
2488
2502
|
if (name2 === null || name2 in table) continue;
|
|
2489
2503
|
let symbols;
|
|
@@ -2516,8 +2530,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
2516
2530
|
viewBox: "0 0 24 24",
|
|
2517
2531
|
advance,
|
|
2518
2532
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
2519
|
-
layers: d.map((
|
|
2520
|
-
d: (0, import_svgpath.default)(
|
|
2533
|
+
layers: d.map((path16) => ({
|
|
2534
|
+
d: (0, import_svgpath.default)(path16).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
2521
2535
|
}))
|
|
2522
2536
|
};
|
|
2523
2537
|
}
|
|
@@ -2527,7 +2541,7 @@ function enumerateBundleJson(paths) {
|
|
|
2527
2541
|
const found = [];
|
|
2528
2542
|
const seen = /* @__PURE__ */ new Set();
|
|
2529
2543
|
const ordered = [...paths].filter(
|
|
2530
|
-
(
|
|
2544
|
+
(path16) => path16.split("/").includes("Resources") && path16.split("/").every((segment2) => segment2 !== "" && segment2 !== "..") && (extOf(path16) === ".json" || extOf(path16) === ".xcstrings")
|
|
2531
2545
|
).sort((a, b) => {
|
|
2532
2546
|
const aDepth = a.split("/").length;
|
|
2533
2547
|
const bDepth = b.split("/").length;
|
|
@@ -3569,6 +3583,57 @@ var init_swift_packages = __esm({
|
|
|
3569
3583
|
}
|
|
3570
3584
|
});
|
|
3571
3585
|
|
|
3586
|
+
// src/swift-source-file.ts
|
|
3587
|
+
function readPackageFile(root, file, maxBytes) {
|
|
3588
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
3589
|
+
const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
|
|
3590
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
|
|
3591
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3592
|
+
}
|
|
3593
|
+
let ancestor = import_node_path11.default.resolve(file);
|
|
3594
|
+
while (ancestor !== canonicalRoot) {
|
|
3595
|
+
if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
3596
|
+
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
3597
|
+
}
|
|
3598
|
+
const parent = import_node_path11.default.dirname(ancestor);
|
|
3599
|
+
if (parent === ancestor)
|
|
3600
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
3601
|
+
ancestor = parent;
|
|
3602
|
+
}
|
|
3603
|
+
const expected = import_node_fs10.default.statSync(file);
|
|
3604
|
+
const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
|
|
3605
|
+
try {
|
|
3606
|
+
const stat = import_node_fs10.default.fstatSync(fd);
|
|
3607
|
+
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
3608
|
+
throw new Error(`swift input changed while opening: ${file}`);
|
|
3609
|
+
}
|
|
3610
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
3611
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
3612
|
+
}
|
|
3613
|
+
const bytes = Buffer.alloc(stat.size + 1);
|
|
3614
|
+
let offset = 0;
|
|
3615
|
+
while (offset < bytes.length) {
|
|
3616
|
+
const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
3617
|
+
if (count === 0) break;
|
|
3618
|
+
offset += count;
|
|
3619
|
+
}
|
|
3620
|
+
if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
|
|
3621
|
+
throw new Error(`swift input changed while reading: ${file}`);
|
|
3622
|
+
}
|
|
3623
|
+
return bytes.subarray(0, offset);
|
|
3624
|
+
} finally {
|
|
3625
|
+
import_node_fs10.default.closeSync(fd);
|
|
3626
|
+
}
|
|
3627
|
+
}
|
|
3628
|
+
var import_node_fs10, import_node_path11;
|
|
3629
|
+
var init_swift_source_file = __esm({
|
|
3630
|
+
"src/swift-source-file.ts"() {
|
|
3631
|
+
"use strict";
|
|
3632
|
+
import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
3633
|
+
import_node_path11 = __toESM(require("node:path"), 1);
|
|
3634
|
+
}
|
|
3635
|
+
});
|
|
3636
|
+
|
|
3572
3637
|
// src/public-brand.ts
|
|
3573
3638
|
var name, peachPublicBrand, rnxPublicBrand;
|
|
3574
3639
|
var init_public_brand = __esm({
|
|
@@ -3599,7 +3664,7 @@ function getCliVersion() {
|
|
|
3599
3664
|
];
|
|
3600
3665
|
for (const resolve2 of candidates) {
|
|
3601
3666
|
try {
|
|
3602
|
-
const version = JSON.parse((0,
|
|
3667
|
+
const version = JSON.parse((0, import_node_fs11.readFileSync)(resolve2(), "utf8")).version;
|
|
3603
3668
|
if (typeof version === "string" && version) {
|
|
3604
3669
|
cached = version;
|
|
3605
3670
|
return cached;
|
|
@@ -3610,11 +3675,11 @@ function getCliVersion() {
|
|
|
3610
3675
|
cached = "0.0.0";
|
|
3611
3676
|
return cached;
|
|
3612
3677
|
}
|
|
3613
|
-
var
|
|
3678
|
+
var import_node_fs11, import_node_url, import_meta, cached;
|
|
3614
3679
|
var init_cli_version = __esm({
|
|
3615
3680
|
"src/cli-version.ts"() {
|
|
3616
3681
|
"use strict";
|
|
3617
|
-
|
|
3682
|
+
import_node_fs11 = require("node:fs");
|
|
3618
3683
|
import_node_url = require("node:url");
|
|
3619
3684
|
init_public_brand();
|
|
3620
3685
|
import_meta = {};
|
|
@@ -3770,10 +3835,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3770
3835
|
owners.push(...physical.map(() => current));
|
|
3771
3836
|
};
|
|
3772
3837
|
const scoped = (body) => (symbol, ...rest) => {
|
|
3773
|
-
const
|
|
3774
|
-
if (omit.has(
|
|
3838
|
+
const path16 = pathOf(symbol);
|
|
3839
|
+
if (omit.has(path16)) return void skipped.push({ path: path16, reason: omit.get(path16) });
|
|
3775
3840
|
const previous = current;
|
|
3776
|
-
current =
|
|
3841
|
+
current = path16;
|
|
3777
3842
|
try {
|
|
3778
3843
|
body(symbol, ...rest);
|
|
3779
3844
|
} finally {
|
|
@@ -3793,14 +3858,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3793
3858
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
3794
3859
|
const emitMember = scoped(
|
|
3795
3860
|
(member, indent, context) => {
|
|
3796
|
-
const
|
|
3861
|
+
const path16 = pathOf(member);
|
|
3797
3862
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
3798
3863
|
emitType(member, indent);
|
|
3799
3864
|
return;
|
|
3800
3865
|
}
|
|
3801
3866
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
3802
3867
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
3803
|
-
skipped.push({ path:
|
|
3868
|
+
skipped.push({ path: path16, reason: `unhandled ${member.kind.identifier}` });
|
|
3804
3869
|
return;
|
|
3805
3870
|
}
|
|
3806
3871
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -3814,12 +3879,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3814
3879
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
3815
3880
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
3816
3881
|
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
3817
|
-
const override = context.inClass && !options.plain?.has(
|
|
3882
|
+
const override = context.inClass && !options.plain?.has(path16) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path16) || isObjC(member) && path16.endsWith(".init()")) ? "override " : "";
|
|
3818
3883
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
3819
|
-
const measured = behavior.get(
|
|
3820
|
-
if (measured) used.add(
|
|
3884
|
+
const measured = behavior.get(path16);
|
|
3885
|
+
if (measured) used.add(path16);
|
|
3821
3886
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
3822
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
3887
|
+
const body = overloadBody ?? measured?.body ?? trap(path16);
|
|
3823
3888
|
switch (member.kind.identifier) {
|
|
3824
3889
|
case "swift.property":
|
|
3825
3890
|
case "swift.type.property":
|
|
@@ -3840,7 +3905,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3840
3905
|
return;
|
|
3841
3906
|
}
|
|
3842
3907
|
emit(
|
|
3843
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(
|
|
3908
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
3844
3909
|
);
|
|
3845
3910
|
return;
|
|
3846
3911
|
}
|
|
@@ -3893,7 +3958,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3893
3958
|
};
|
|
3894
3959
|
const emitType = scoped(
|
|
3895
3960
|
(symbol, indent) => {
|
|
3896
|
-
const
|
|
3961
|
+
const path16 = pathOf(symbol);
|
|
3897
3962
|
const id = symbol.identifier.precise;
|
|
3898
3963
|
const inner = `${indent} `;
|
|
3899
3964
|
switch (symbol.kind.identifier) {
|
|
@@ -3905,10 +3970,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3905
3970
|
case "swift.class": {
|
|
3906
3971
|
const shape = header(symbol, "class", indent);
|
|
3907
3972
|
if (!shape)
|
|
3908
|
-
return void skipped.push({ path:
|
|
3909
|
-
const parent = options.superclasses?.get(
|
|
3973
|
+
return void skipped.push({ path: path16, reason: `unparsed class ${text(symbol)}` });
|
|
3974
|
+
const parent = options.superclasses?.get(path16) ?? superclass.get(id);
|
|
3910
3975
|
const blocked = classBlocked(id);
|
|
3911
|
-
if (blocked) return void skipped.push({ path:
|
|
3976
|
+
if (blocked) return void skipped.push({ path: path16, reason: blocked });
|
|
3912
3977
|
const ancestors = /* @__PURE__ */ new Set();
|
|
3913
3978
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
3914
3979
|
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
@@ -3924,9 +3989,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3924
3989
|
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
3925
3990
|
);
|
|
3926
3991
|
const members = membersOf(id);
|
|
3927
|
-
const extra = options.behavior?.get(
|
|
3992
|
+
const extra = options.behavior?.get(path16)?.members;
|
|
3928
3993
|
if (extra) {
|
|
3929
|
-
used.add(
|
|
3994
|
+
used.add(path16);
|
|
3930
3995
|
emit(`${inner}${extra}`);
|
|
3931
3996
|
}
|
|
3932
3997
|
for (const member of members)
|
|
@@ -3979,13 +4044,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3979
4044
|
continue;
|
|
3980
4045
|
have.add(witnessKey(member));
|
|
3981
4046
|
have.add(sideLeaf(member));
|
|
3982
|
-
emitWitness(member, inner,
|
|
4047
|
+
emitWitness(member, inner, path16);
|
|
3983
4048
|
}
|
|
3984
4049
|
}
|
|
3985
4050
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
3986
4051
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
3987
4052
|
emit(
|
|
3988
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
4053
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path16}.init(coder:)`)} }`
|
|
3989
4054
|
);
|
|
3990
4055
|
emit(`${indent}}`);
|
|
3991
4056
|
return;
|
|
@@ -3993,7 +4058,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
3993
4058
|
case "swift.struct": {
|
|
3994
4059
|
const shape = header(symbol, "struct", indent);
|
|
3995
4060
|
if (!shape)
|
|
3996
|
-
return void skipped.push({ path:
|
|
4061
|
+
return void skipped.push({ path: path16, reason: `unparsed struct ${text(symbol)}` });
|
|
3997
4062
|
const members = membersOf(id);
|
|
3998
4063
|
const raw2 = rawType(members);
|
|
3999
4064
|
const list2 = inheritance(id);
|
|
@@ -4044,7 +4109,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4044
4109
|
case "swift.enum": {
|
|
4045
4110
|
const shape = header(symbol, "enum", indent);
|
|
4046
4111
|
if (!shape)
|
|
4047
|
-
return void skipped.push({ path:
|
|
4112
|
+
return void skipped.push({ path: path16, reason: `unparsed enum ${text(symbol)}` });
|
|
4048
4113
|
const members = membersOf(id);
|
|
4049
4114
|
const raw2 = rawType(members);
|
|
4050
4115
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -4053,7 +4118,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4053
4118
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
4054
4119
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
4055
4120
|
return void skipped.push({
|
|
4056
|
-
path:
|
|
4121
|
+
path: path16,
|
|
4057
4122
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
4058
4123
|
});
|
|
4059
4124
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
@@ -4094,7 +4159,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4094
4159
|
const shape = header(symbol, "protocol", indent);
|
|
4095
4160
|
if (!shape)
|
|
4096
4161
|
return void skipped.push({
|
|
4097
|
-
path:
|
|
4162
|
+
path: path16,
|
|
4098
4163
|
reason: `unparsed protocol ${text(symbol)}`
|
|
4099
4164
|
});
|
|
4100
4165
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -4119,7 +4184,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4119
4184
|
}
|
|
4120
4185
|
emit(`${indent}}`);
|
|
4121
4186
|
if (defaults.length > 0) {
|
|
4122
|
-
emit(`${indent}extension ${
|
|
4187
|
+
emit(`${indent}extension ${path16} {`);
|
|
4123
4188
|
for (const member of defaults) {
|
|
4124
4189
|
const decl = text(member);
|
|
4125
4190
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -4166,7 +4231,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4166
4231
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
4167
4232
|
};
|
|
4168
4233
|
const emitGlobal = scoped((symbol) => {
|
|
4169
|
-
const
|
|
4234
|
+
const path16 = pathOf(symbol);
|
|
4170
4235
|
const kind = symbol.kind.identifier;
|
|
4171
4236
|
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
4172
4237
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
@@ -4177,17 +4242,17 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4177
4242
|
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
4178
4243
|
spelled = `${fix} ${spelled}`;
|
|
4179
4244
|
}
|
|
4180
|
-
emit(`${attrs}public ${spelled} { ${trap(
|
|
4245
|
+
emit(`${attrs}public ${spelled} { ${trap(path16)} }`);
|
|
4181
4246
|
} else if (kind === "swift.var") {
|
|
4182
4247
|
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
4183
|
-
const measured = behavior.get(
|
|
4184
|
-
if (measured) used.add(
|
|
4185
|
-
emit(`public ${parsed.decl} { ${measured?.body ?? trap(
|
|
4186
|
-
} else skipped.push({ path:
|
|
4248
|
+
const measured = behavior.get(path16);
|
|
4249
|
+
if (measured) used.add(path16);
|
|
4250
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path16)} }`);
|
|
4251
|
+
} else skipped.push({ path: path16, reason: `unhandled top-level ${kind}` });
|
|
4187
4252
|
});
|
|
4188
4253
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
4189
4254
|
for (const symbol of roots) {
|
|
4190
|
-
const
|
|
4255
|
+
const path16 = pathOf(symbol);
|
|
4191
4256
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
4192
4257
|
else emitGlobal(symbol);
|
|
4193
4258
|
}
|
|
@@ -4229,9 +4294,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
4229
4294
|
...imports.map((name2) => `import ${name2}`),
|
|
4230
4295
|
""
|
|
4231
4296
|
];
|
|
4232
|
-
for (const
|
|
4233
|
-
if (!used.has(
|
|
4234
|
-
skipped.push({ path:
|
|
4297
|
+
for (const path16 of behavior.keys())
|
|
4298
|
+
if (!used.has(path16))
|
|
4299
|
+
skipped.push({ path: path16, reason: "behavior names no emitted declaration" });
|
|
4235
4300
|
return {
|
|
4236
4301
|
source: `${[...banner, ...lines].join("\n")}
|
|
4237
4302
|
`,
|
|
@@ -4317,7 +4382,7 @@ var init_swift_standin_emit = __esm({
|
|
|
4317
4382
|
sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
4318
4383
|
isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
4319
4384
|
synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
|
|
4320
|
-
trap = (
|
|
4385
|
+
trap = (path16) => `fatalError("${path16} is a binary framework peach cannot run")`;
|
|
4321
4386
|
KEYWORDS = /* @__PURE__ */ new Set([
|
|
4322
4387
|
"Type",
|
|
4323
4388
|
"Protocol",
|
|
@@ -4375,15 +4440,15 @@ ${"stdout" in error ? String(error.stdout) : ""}` : String(error);
|
|
|
4375
4440
|
function treeDigest(root) {
|
|
4376
4441
|
const names = [];
|
|
4377
4442
|
const walk2 = (dir) => {
|
|
4378
|
-
for (const entry of
|
|
4379
|
-
const full =
|
|
4443
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
4444
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
4380
4445
|
if (entry.isDirectory()) walk2(full);
|
|
4381
|
-
else if (entry.isFile()) names.push(
|
|
4446
|
+
else if (entry.isFile()) names.push(import_node_path12.default.relative(root, full));
|
|
4382
4447
|
}
|
|
4383
4448
|
};
|
|
4384
4449
|
walk2(root);
|
|
4385
4450
|
const stamp = names.map((name2) => {
|
|
4386
|
-
const stat =
|
|
4451
|
+
const stat = import_node_fs12.default.statSync(import_node_path12.default.join(root, name2));
|
|
4387
4452
|
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
4388
4453
|
}).join("\n");
|
|
4389
4454
|
const memo2 = digests.get(`tree\0${root}`);
|
|
@@ -4391,7 +4456,7 @@ function treeDigest(root) {
|
|
|
4391
4456
|
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
4392
4457
|
for (const name2 of names) {
|
|
4393
4458
|
hash.update(`${name2}\0`);
|
|
4394
|
-
hash.update(
|
|
4459
|
+
hash.update(import_node_fs12.default.readFileSync(import_node_path12.default.join(root, name2)));
|
|
4395
4460
|
hash.update("\0");
|
|
4396
4461
|
}
|
|
4397
4462
|
const digest2 = hash.digest("hex");
|
|
@@ -4400,9 +4465,9 @@ function treeDigest(root) {
|
|
|
4400
4465
|
}
|
|
4401
4466
|
function locateXcframework(tree) {
|
|
4402
4467
|
const find = (root, depth) => {
|
|
4403
|
-
for (const entry of
|
|
4468
|
+
for (const entry of import_node_fs12.default.readdirSync(root, { withFileTypes: true })) {
|
|
4404
4469
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
4405
|
-
const full =
|
|
4470
|
+
const full = import_node_path12.default.join(root, entry.name);
|
|
4406
4471
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
4407
4472
|
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
4408
4473
|
if (nested) return nested;
|
|
@@ -4417,66 +4482,66 @@ function xcframework(binary) {
|
|
|
4417
4482
|
if (binary.url && (!binary.checksum || !/^[a-f0-9]{64}$/i.test(binary.checksum)))
|
|
4418
4483
|
throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
|
|
4419
4484
|
const expected = binary.checksum?.toLowerCase();
|
|
4420
|
-
const dir =
|
|
4421
|
-
const archive =
|
|
4422
|
-
const fingerprint =
|
|
4485
|
+
const dir = import_node_path12.default.join(cacheDir3, "archives", key(binary.url ? expected : binary.dir));
|
|
4486
|
+
const archive = import_node_path12.default.join(dir, "archive.zip");
|
|
4487
|
+
const fingerprint = import_node_path12.default.join(dir, ".fingerprint");
|
|
4423
4488
|
const stored = (() => {
|
|
4424
4489
|
try {
|
|
4425
|
-
const parsed = JSON.parse(
|
|
4490
|
+
const parsed = JSON.parse(import_node_fs12.default.readFileSync(fingerprint, "utf8"));
|
|
4426
4491
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
4427
4492
|
} catch {
|
|
4428
4493
|
return null;
|
|
4429
4494
|
}
|
|
4430
4495
|
})();
|
|
4431
4496
|
if (!binary.url) {
|
|
4432
|
-
const stat =
|
|
4497
|
+
const stat = import_node_fs12.default.statSync(binary.dir);
|
|
4433
4498
|
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
4434
4499
|
if (stored?.stamp === stamp) {
|
|
4435
|
-
const found3 = locateXcframework(
|
|
4500
|
+
const found3 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
4436
4501
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
4437
4502
|
}
|
|
4438
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
4439
|
-
if (sha2 !== stored?.sha || !locateXcframework(
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
exec("unzip", ["-q", binary.dir, "-d",
|
|
4503
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(binary.dir)).digest("hex");
|
|
4504
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path12.default.join(dir, "tree"))) {
|
|
4505
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
4506
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
4507
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
4443
4508
|
}
|
|
4444
|
-
|
|
4445
|
-
const found2 = locateXcframework(
|
|
4509
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
4510
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
4446
4511
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
4447
4512
|
return { dir: found2, digest: sha2 };
|
|
4448
4513
|
}
|
|
4449
|
-
if (stored &&
|
|
4450
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
4514
|
+
if (stored && import_node_fs12.default.existsSync(archive)) {
|
|
4515
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
4451
4516
|
if (sha2 !== expected)
|
|
4452
4517
|
throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
|
|
4453
|
-
const found2 = locateXcframework(
|
|
4518
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
4454
4519
|
if (found2) return { dir: found2, digest: sha2 };
|
|
4455
4520
|
}
|
|
4456
|
-
|
|
4457
|
-
|
|
4521
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
4522
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
4458
4523
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
4459
|
-
const sha = (0, import_node_crypto6.createHash)("sha256").update(
|
|
4524
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
4460
4525
|
if (sha !== expected) {
|
|
4461
|
-
|
|
4526
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
4462
4527
|
throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
|
|
4463
4528
|
}
|
|
4464
|
-
exec("unzip", ["-q", archive, "-d",
|
|
4465
|
-
|
|
4466
|
-
const found = locateXcframework(
|
|
4529
|
+
exec("unzip", ["-q", archive, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
4530
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
4531
|
+
const found = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
4467
4532
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
4468
4533
|
return { dir: found, digest: sha };
|
|
4469
4534
|
}
|
|
4470
4535
|
function surfaces(xcframeworkDir) {
|
|
4471
|
-
const slice =
|
|
4536
|
+
const slice = import_node_fs12.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
4472
4537
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
4473
|
-
const root =
|
|
4538
|
+
const root = import_node_path12.default.join(xcframeworkDir, slice);
|
|
4474
4539
|
const found = [];
|
|
4475
|
-
for (const entry of
|
|
4540
|
+
for (const entry of import_node_fs12.default.readdirSync(root).sort()) {
|
|
4476
4541
|
if (!entry.endsWith(".framework")) continue;
|
|
4477
4542
|
const module2 = entry.slice(0, -".framework".length);
|
|
4478
|
-
const framework =
|
|
4479
|
-
const swiftmodule =
|
|
4543
|
+
const framework = import_node_path12.default.join(root, entry);
|
|
4544
|
+
const swiftmodule = import_node_path12.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
4480
4545
|
const interfaces = files(
|
|
4481
4546
|
swiftmodule,
|
|
4482
4547
|
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
@@ -4486,41 +4551,41 @@ function surfaces(xcframeworkDir) {
|
|
|
4486
4551
|
found.push({
|
|
4487
4552
|
kind: "swift",
|
|
4488
4553
|
module: module2,
|
|
4489
|
-
interface:
|
|
4554
|
+
interface: import_node_path12.default.join(swiftmodule, chosen)
|
|
4490
4555
|
});
|
|
4491
4556
|
continue;
|
|
4492
4557
|
}
|
|
4493
|
-
const modulemap =
|
|
4494
|
-
if (
|
|
4558
|
+
const modulemap = import_node_path12.default.join(framework, "Modules", "module.modulemap");
|
|
4559
|
+
if (import_node_fs12.default.existsSync(modulemap))
|
|
4495
4560
|
found.push({
|
|
4496
4561
|
kind: "c",
|
|
4497
4562
|
module: module2,
|
|
4498
4563
|
modulemap,
|
|
4499
|
-
headers:
|
|
4564
|
+
headers: import_node_path12.default.join(framework, "Headers")
|
|
4500
4565
|
});
|
|
4501
4566
|
}
|
|
4502
|
-
const headers =
|
|
4567
|
+
const headers = import_node_path12.default.join(root, "Headers");
|
|
4503
4568
|
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
4504
|
-
const modulemap =
|
|
4505
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
4569
|
+
const modulemap = import_node_path12.default.join(headers, map);
|
|
4570
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs12.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
4506
4571
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
4507
4572
|
}
|
|
4508
4573
|
return found;
|
|
4509
4574
|
}
|
|
4510
4575
|
function peachModuleDirs(toolchain, imports) {
|
|
4511
4576
|
const { moduleRoot, toolchainBin } = toolchain;
|
|
4512
|
-
if (swiftDistributionAt(moduleRoot)) return [
|
|
4577
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path12.default.join(moduleRoot, "modules")];
|
|
4513
4578
|
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
4514
4579
|
const plugins = swiftMacroPlugins(moduleRoot);
|
|
4515
4580
|
if (plugins.stale)
|
|
4516
4581
|
exec("sh", [
|
|
4517
|
-
|
|
4582
|
+
import_node_path12.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
4518
4583
|
toolchainBin,
|
|
4519
4584
|
plugins.libraries[0]
|
|
4520
4585
|
]);
|
|
4521
4586
|
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
4522
4587
|
exec(
|
|
4523
|
-
|
|
4588
|
+
import_node_path12.default.join(toolchainBin, "swift"),
|
|
4524
4589
|
[
|
|
4525
4590
|
"build",
|
|
4526
4591
|
"--swift-sdk",
|
|
@@ -4540,7 +4605,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
4540
4605
|
],
|
|
4541
4606
|
moduleRoot
|
|
4542
4607
|
);
|
|
4543
|
-
return [
|
|
4608
|
+
return [import_node_path12.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
4544
4609
|
}
|
|
4545
4610
|
function swiftInterfaceForWasm(text3) {
|
|
4546
4611
|
return text3.replace(
|
|
@@ -4552,11 +4617,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
4552
4617
|
);
|
|
4553
4618
|
}
|
|
4554
4619
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
4555
|
-
const text3 = swiftInterfaceForWasm(
|
|
4556
|
-
const search =
|
|
4557
|
-
const moduleDir =
|
|
4558
|
-
|
|
4559
|
-
|
|
4620
|
+
const text3 = swiftInterfaceForWasm(import_node_fs12.default.readFileSync(surface.interface, "utf8"));
|
|
4621
|
+
const search = import_node_path12.default.join(work, "interfaces");
|
|
4622
|
+
const moduleDir = import_node_path12.default.join(search, `${surface.module}.swiftmodule`);
|
|
4623
|
+
import_node_fs12.default.mkdirSync(moduleDir, { recursive: true });
|
|
4624
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
4560
4625
|
const imports = [
|
|
4561
4626
|
...text3.matchAll(
|
|
4562
4627
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -4568,9 +4633,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4568
4633
|
);
|
|
4569
4634
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
4570
4635
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
4571
|
-
const out =
|
|
4572
|
-
|
|
4573
|
-
exec(
|
|
4636
|
+
const out = import_node_path12.default.join(work, "graphs");
|
|
4637
|
+
import_node_fs12.default.mkdirSync(out, { recursive: true });
|
|
4638
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
4574
4639
|
"-module-name",
|
|
4575
4640
|
surface.module,
|
|
4576
4641
|
...target,
|
|
@@ -4584,10 +4649,10 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4584
4649
|
"-output-dir",
|
|
4585
4650
|
out
|
|
4586
4651
|
]);
|
|
4587
|
-
const graphs =
|
|
4652
|
+
const graphs = import_node_fs12.default.readdirSync(out).filter((name2) => name2.endsWith(".symbols.json")).sort().map((name2) => JSON.parse(import_node_fs12.default.readFileSync(import_node_path12.default.join(out, name2), "utf8")));
|
|
4588
4653
|
const omit = /* @__PURE__ */ new Map();
|
|
4589
4654
|
const plain = /* @__PURE__ */ new Set();
|
|
4590
|
-
const file =
|
|
4655
|
+
const file = import_node_path12.default.join(work, `${surface.module}.swift`);
|
|
4591
4656
|
for (; ; ) {
|
|
4592
4657
|
const { source, owners } = emitSwiftStandin(graphs, {
|
|
4593
4658
|
module: surface.module,
|
|
@@ -4595,9 +4660,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
4595
4660
|
omit,
|
|
4596
4661
|
plain
|
|
4597
4662
|
});
|
|
4598
|
-
|
|
4663
|
+
import_node_fs12.default.writeFileSync(file, source);
|
|
4599
4664
|
const check = (0, import_node_child_process8.spawnSync)(
|
|
4600
|
-
|
|
4665
|
+
import_node_path12.default.join(toolchain.toolchainBin, "swiftc"),
|
|
4601
4666
|
[
|
|
4602
4667
|
"-typecheck",
|
|
4603
4668
|
"-parse-as-library",
|
|
@@ -4745,21 +4810,21 @@ function splitDeclarators(statement, names) {
|
|
|
4745
4810
|
}
|
|
4746
4811
|
function cStandin(surface, binary, toolchain, work) {
|
|
4747
4812
|
const named = [
|
|
4748
|
-
...
|
|
4813
|
+
...import_node_fs12.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
4749
4814
|
].map((match) => match[1]);
|
|
4750
4815
|
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
4751
4816
|
const texts = new Map(
|
|
4752
4817
|
headers.map((file) => [
|
|
4753
4818
|
file,
|
|
4754
|
-
|
|
4819
|
+
import_node_fs12.default.readFileSync(import_node_path12.default.join(surface.headers, file), "utf8")
|
|
4755
4820
|
])
|
|
4756
4821
|
);
|
|
4757
4822
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
4758
4823
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
4759
|
-
const include =
|
|
4824
|
+
const include = import_node_path12.default.join(work, "include");
|
|
4760
4825
|
for (const [file, text3] of texts) {
|
|
4761
|
-
|
|
4762
|
-
|
|
4826
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(import_node_path12.default.join(include, file)), { recursive: true });
|
|
4827
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(include, file), text3);
|
|
4763
4828
|
}
|
|
4764
4829
|
const roots = named.length > 0 ? named : headers;
|
|
4765
4830
|
const modulemap = `module ${surface.module} {
|
|
@@ -4767,12 +4832,12 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4767
4832
|
`).join("")} export *
|
|
4768
4833
|
}
|
|
4769
4834
|
`;
|
|
4770
|
-
const probe =
|
|
4771
|
-
|
|
4835
|
+
const probe = import_node_path12.default.join(work, "declarations.c");
|
|
4836
|
+
import_node_fs12.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
4772
4837
|
`).join(""));
|
|
4773
4838
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
4774
4839
|
const ast = JSON.parse(
|
|
4775
|
-
exec(
|
|
4840
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
4776
4841
|
"-target",
|
|
4777
4842
|
TRIPLE,
|
|
4778
4843
|
"--sysroot",
|
|
@@ -4785,7 +4850,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4785
4850
|
probe
|
|
4786
4851
|
])
|
|
4787
4852
|
);
|
|
4788
|
-
const byPath = new Map(headers.map((file) => [
|
|
4853
|
+
const byPath = new Map(headers.map((file) => [import_node_path12.default.join(include, file), file]));
|
|
4789
4854
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
4790
4855
|
const groups = /* @__PURE__ */ new Map();
|
|
4791
4856
|
for (const declaration of declarations) {
|
|
@@ -4832,10 +4897,10 @@ ${roots.map((file) => ` header "${file}"
|
|
|
4832
4897
|
"",
|
|
4833
4898
|
...definitions
|
|
4834
4899
|
].join("\n");
|
|
4835
|
-
const out =
|
|
4836
|
-
|
|
4900
|
+
const out = import_node_path12.default.join(work, `${surface.module}.c`);
|
|
4901
|
+
import_node_fs12.default.writeFileSync(out, source);
|
|
4837
4902
|
try {
|
|
4838
|
-
exec(
|
|
4903
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
4839
4904
|
"-target",
|
|
4840
4905
|
TRIPLE,
|
|
4841
4906
|
"--sysroot",
|
|
@@ -4916,25 +4981,25 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
4916
4981
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
4917
4982
|
surface.modulemap,
|
|
4918
4983
|
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
4919
|
-
(file2) =>
|
|
4984
|
+
(file2) => import_node_path12.default.join(surface.headers, file2)
|
|
4920
4985
|
)
|
|
4921
4986
|
])
|
|
4922
|
-
hash.update(
|
|
4987
|
+
hash.update(import_node_fs12.default.readFileSync(file));
|
|
4923
4988
|
}
|
|
4924
4989
|
const id = hash.digest("hex").slice(0, 32);
|
|
4925
4990
|
const memo2 = built.get(id);
|
|
4926
4991
|
if (memo2) return memo2;
|
|
4927
|
-
const cached2 =
|
|
4928
|
-
if (
|
|
4929
|
-
const value = JSON.parse(
|
|
4992
|
+
const cached2 = import_node_path12.default.join(cacheDir3, "standins", `${id}.json`);
|
|
4993
|
+
if (import_node_fs12.default.existsSync(cached2)) {
|
|
4994
|
+
const value = JSON.parse(import_node_fs12.default.readFileSync(cached2, "utf8"));
|
|
4930
4995
|
built.set(id, value);
|
|
4931
4996
|
return value;
|
|
4932
4997
|
}
|
|
4933
|
-
const work =
|
|
4998
|
+
const work = import_node_fs12.default.mkdtempSync(import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
4934
4999
|
let result;
|
|
4935
5000
|
try {
|
|
4936
5001
|
result = found.map((surface) => {
|
|
4937
|
-
const dir =
|
|
5002
|
+
const dir = import_node_path12.default.join(work, surface.module);
|
|
4938
5003
|
try {
|
|
4939
5004
|
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
4940
5005
|
} catch (error) {
|
|
@@ -4943,13 +5008,13 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
4943
5008
|
);
|
|
4944
5009
|
}
|
|
4945
5010
|
});
|
|
4946
|
-
|
|
4947
|
-
|
|
5011
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(cached2), { recursive: true });
|
|
5012
|
+
import_node_fs12.default.writeFileSync(cached2, JSON.stringify(result));
|
|
4948
5013
|
built.set(id, result);
|
|
4949
5014
|
} catch (error) {
|
|
4950
5015
|
result = error instanceof Error ? error.message : String(error);
|
|
4951
5016
|
} finally {
|
|
4952
|
-
|
|
5017
|
+
import_node_fs12.default.rmSync(work, { recursive: true, force: true });
|
|
4953
5018
|
}
|
|
4954
5019
|
return result;
|
|
4955
5020
|
}
|
|
@@ -4963,23 +5028,23 @@ function swiftStandins(binaries, toolchain, provided = /* @__PURE__ */ new Set()
|
|
|
4963
5028
|
}
|
|
4964
5029
|
return { standins, gaps };
|
|
4965
5030
|
}
|
|
4966
|
-
var import_node_child_process8, import_node_crypto6,
|
|
5031
|
+
var import_node_child_process8, import_node_crypto6, import_node_fs12, import_node_os7, import_node_path12, TRIPLE, cacheDir3, key, digests, files, OBJC, identChar, built;
|
|
4967
5032
|
var init_swift_standins = __esm({
|
|
4968
5033
|
"src/swift-standins.ts"() {
|
|
4969
5034
|
"use strict";
|
|
4970
5035
|
import_node_child_process8 = require("node:child_process");
|
|
4971
5036
|
import_node_crypto6 = require("node:crypto");
|
|
4972
|
-
|
|
5037
|
+
import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4973
5038
|
import_node_os7 = __toESM(require("node:os"), 1);
|
|
4974
|
-
|
|
5039
|
+
import_node_path12 = __toESM(require("node:path"), 1);
|
|
4975
5040
|
init_cli_version();
|
|
4976
5041
|
init_swift_compile();
|
|
4977
5042
|
init_swift_standin_emit();
|
|
4978
5043
|
TRIPLE = "wasm32-unknown-wasip1";
|
|
4979
|
-
cacheDir3 =
|
|
5044
|
+
cacheDir3 = import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
4980
5045
|
key = (...parts) => (0, import_node_crypto6.createHash)("sha256").update(parts.join("\0")).digest("hex").slice(0, 32);
|
|
4981
5046
|
digests = /* @__PURE__ */ new Map();
|
|
4982
|
-
files = (dir, test) =>
|
|
5047
|
+
files = (dir, test) => import_node_fs12.default.existsSync(dir) ? import_node_fs12.default.readdirSync(dir, { recursive: true, encoding: "utf8" }).filter((file) => test(import_node_path12.default.basename(file))).sort() : [];
|
|
4983
5048
|
OBJC = /^\s*(?:@interface|@protocol|@class|@import|#import)\b/m;
|
|
4984
5049
|
identChar = (char) => char !== void 0 && /[\w$]/.test(char);
|
|
4985
5050
|
built = /* @__PURE__ */ new Map();
|
|
@@ -6473,7 +6538,7 @@ var require_lib = __commonJS({
|
|
|
6473
6538
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
6474
6539
|
const json = import_json5.default.parse(source);
|
|
6475
6540
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
6476
|
-
const projectDir =
|
|
6541
|
+
const projectDir = import_node_path13.default.dirname(xcodeproj);
|
|
6477
6542
|
const objects = {};
|
|
6478
6543
|
let next = 0;
|
|
6479
6544
|
const add = (entry, id) => {
|
|
@@ -6486,7 +6551,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6486
6551
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
6487
6552
|
if (base) {
|
|
6488
6553
|
if (base[1] === "PROJECT")
|
|
6489
|
-
return { sourceTree: "<absolute>", path:
|
|
6554
|
+
return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
|
|
6490
6555
|
if (base[1] === "PRODUCTS")
|
|
6491
6556
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
6492
6557
|
return null;
|
|
@@ -6494,7 +6559,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6494
6559
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
6495
6560
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
6496
6561
|
if (unescaped.startsWith("~")) return null;
|
|
6497
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
6562
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
|
|
6498
6563
|
};
|
|
6499
6564
|
const memberships = [];
|
|
6500
6565
|
const folders = [];
|
|
@@ -6505,7 +6570,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6505
6570
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
6506
6571
|
const raw2 = text2(entry.path) ?? "";
|
|
6507
6572
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
6508
|
-
const name2 = text2(entry.name) ??
|
|
6573
|
+
const name2 = text2(entry.name) ?? import_node_path13.default.basename(raw2);
|
|
6509
6574
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
6510
6575
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
6511
6576
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -6620,7 +6685,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6620
6685
|
if (!isObject(entry)) continue;
|
|
6621
6686
|
const repository = text2(entry.repository);
|
|
6622
6687
|
const local = text2(entry.path);
|
|
6623
|
-
const name2 = local !== void 0 ?
|
|
6688
|
+
const name2 = local !== void 0 ? import_node_path13.default.basename(import_node_path13.default.resolve(import_node_path13.default.dirname(xcodeproj), local)) : import_node_path13.default.basename(repository ?? "").replace(/\.git$/, "");
|
|
6624
6689
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
6625
6690
|
packageIds.set(name2.toLowerCase(), id);
|
|
6626
6691
|
}
|
|
@@ -6788,11 +6853,11 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6788
6853
|
function isJsonObject(value) {
|
|
6789
6854
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6790
6855
|
}
|
|
6791
|
-
var
|
|
6856
|
+
var import_node_path13, import_json5, isObject, text2, items, PHASE_ISA;
|
|
6792
6857
|
var init_xcode_json_project = __esm({
|
|
6793
6858
|
"src/xcode-json-project.ts"() {
|
|
6794
6859
|
"use strict";
|
|
6795
|
-
|
|
6860
|
+
import_node_path13 = __toESM(require("node:path"), 1);
|
|
6796
6861
|
import_json5 = __toESM(require_lib(), 1);
|
|
6797
6862
|
isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6798
6863
|
text2 = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -6899,27 +6964,27 @@ function parseOpenStepPlist(text3) {
|
|
|
6899
6964
|
return root;
|
|
6900
6965
|
}
|
|
6901
6966
|
function walkFiles(dir) {
|
|
6902
|
-
if (!
|
|
6967
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
6903
6968
|
const out = [];
|
|
6904
|
-
for (const entry of
|
|
6969
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6905
6970
|
if (entry.name.startsWith(".")) continue;
|
|
6906
|
-
const full =
|
|
6971
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
6907
6972
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
6908
6973
|
else if (entry.isFile()) out.push(full);
|
|
6909
6974
|
}
|
|
6910
6975
|
return out;
|
|
6911
6976
|
}
|
|
6912
6977
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
6913
|
-
if (seen.has(file) || !
|
|
6978
|
+
if (seen.has(file) || !import_node_fs13.default.existsSync(file)) return {};
|
|
6914
6979
|
seen.add(file);
|
|
6915
6980
|
const settings = {};
|
|
6916
|
-
for (const raw2 of
|
|
6981
|
+
for (const raw2 of import_node_fs13.default.readFileSync(file, "utf8").split("\n")) {
|
|
6917
6982
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
6918
6983
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
6919
6984
|
if (include) {
|
|
6920
6985
|
Object.assign(
|
|
6921
6986
|
settings,
|
|
6922
|
-
readXcconfig(
|
|
6987
|
+
readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), seen)
|
|
6923
6988
|
);
|
|
6924
6989
|
continue;
|
|
6925
6990
|
}
|
|
@@ -6969,22 +7034,22 @@ function decodeXml(text3) {
|
|
|
6969
7034
|
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
6970
7035
|
}
|
|
6971
7036
|
function workspaceReferences(workspace) {
|
|
6972
|
-
const data =
|
|
6973
|
-
if (!
|
|
7037
|
+
const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
|
|
7038
|
+
if (!import_node_fs13.default.existsSync(data))
|
|
6974
7039
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
6975
|
-
const container =
|
|
7040
|
+
const container = import_node_path14.default.dirname(workspace);
|
|
6976
7041
|
const locate = (location, base) => {
|
|
6977
7042
|
const colon = location.indexOf(":");
|
|
6978
7043
|
const kind = location.slice(0, colon);
|
|
6979
7044
|
const rest = location.slice(colon + 1);
|
|
6980
|
-
if (kind === "group") return
|
|
6981
|
-
if (kind === "container" || kind === "self") return
|
|
6982
|
-
if (kind === "absolute") return
|
|
6983
|
-
throw new Error(`${
|
|
7045
|
+
if (kind === "group") return import_node_path14.default.resolve(base, rest);
|
|
7046
|
+
if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
|
|
7047
|
+
if (kind === "absolute") return import_node_path14.default.resolve(rest);
|
|
7048
|
+
throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
|
|
6984
7049
|
};
|
|
6985
7050
|
const groups = [container];
|
|
6986
7051
|
const references = [];
|
|
6987
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
7052
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs13.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
6988
7053
|
if (closing) {
|
|
6989
7054
|
if (tag === "Group") groups.pop();
|
|
6990
7055
|
continue;
|
|
@@ -6999,8 +7064,8 @@ function workspaceReferences(workspace) {
|
|
|
6999
7064
|
}
|
|
7000
7065
|
function xcodeProjectFile(xcodeproj) {
|
|
7001
7066
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
7002
|
-
const file =
|
|
7003
|
-
if (
|
|
7067
|
+
const file = import_node_path14.default.join(xcodeproj, name2);
|
|
7068
|
+
if (import_node_fs13.default.existsSync(file)) return file;
|
|
7004
7069
|
}
|
|
7005
7070
|
return null;
|
|
7006
7071
|
}
|
|
@@ -7008,10 +7073,10 @@ function loadProject(xcodeproj) {
|
|
|
7008
7073
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
7009
7074
|
if (!projectFile)
|
|
7010
7075
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
7011
|
-
const mtimeMs =
|
|
7076
|
+
const mtimeMs = import_node_fs13.default.statSync(projectFile).mtimeMs;
|
|
7012
7077
|
const cached2 = loaded.get(projectFile);
|
|
7013
7078
|
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
7014
|
-
const source =
|
|
7079
|
+
const source = import_node_fs13.default.readFileSync(projectFile, "utf8");
|
|
7015
7080
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
7016
7081
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
7017
7082
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -7025,8 +7090,8 @@ function loadProject(xcodeproj) {
|
|
|
7025
7090
|
if (!project || project.isa !== "PBXProject") {
|
|
7026
7091
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
7027
7092
|
}
|
|
7028
|
-
const projectDir =
|
|
7029
|
-
|
|
7093
|
+
const projectDir = import_node_fs13.default.realpathSync(
|
|
7094
|
+
import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
7030
7095
|
);
|
|
7031
7096
|
const parent = /* @__PURE__ */ new Map();
|
|
7032
7097
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -7044,11 +7109,11 @@ function loadProject(xcodeproj) {
|
|
|
7044
7109
|
const own = str(entry.path) ?? "";
|
|
7045
7110
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
7046
7111
|
if (tree === "<absolute>") result2 = own;
|
|
7047
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
7112
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path14.default.join(projectDir, own);
|
|
7048
7113
|
else if (tree === "<group>") {
|
|
7049
7114
|
const up = parent.get(id);
|
|
7050
7115
|
const base = up ? resolvePath(up) : projectDir;
|
|
7051
|
-
result2 = base === null ? null :
|
|
7116
|
+
result2 = base === null ? null : import_node_path14.default.join(base, own);
|
|
7052
7117
|
}
|
|
7053
7118
|
}
|
|
7054
7119
|
resolvedPaths.set(id, result2);
|
|
@@ -7148,7 +7213,7 @@ function targetMembers(ref) {
|
|
|
7148
7213
|
const addResource = (file) => {
|
|
7149
7214
|
if (isDirectory(file)) {
|
|
7150
7215
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
7151
|
-
} else if (
|
|
7216
|
+
} else if (import_node_fs13.default.existsSync(file)) resources.add(file);
|
|
7152
7217
|
};
|
|
7153
7218
|
const fileRefPaths = (refId) => {
|
|
7154
7219
|
const entry = project.object(refId);
|
|
@@ -7169,7 +7234,7 @@ function targetMembers(ref) {
|
|
|
7169
7234
|
for (const buildFileId of list(phase.files)) {
|
|
7170
7235
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
7171
7236
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
7172
|
-
if (!
|
|
7237
|
+
if (!import_node_fs13.default.existsSync(file)) continue;
|
|
7173
7238
|
allSources.add(file);
|
|
7174
7239
|
if (file.endsWith(".swift")) sources.add(file);
|
|
7175
7240
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -7177,7 +7242,7 @@ function targetMembers(ref) {
|
|
|
7177
7242
|
}
|
|
7178
7243
|
}
|
|
7179
7244
|
const addSynchronized = (folder, relative) => {
|
|
7180
|
-
const file =
|
|
7245
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7181
7246
|
if (NEVER_MEMBER.test(relative)) return;
|
|
7182
7247
|
if (file.endsWith(".swift")) {
|
|
7183
7248
|
if (!relative.split("/").some((segment2) => BUNDLE_DIR.test(segment2))) {
|
|
@@ -7202,7 +7267,7 @@ function targetMembers(ref) {
|
|
|
7202
7267
|
}
|
|
7203
7268
|
if (owned.has(groupId)) {
|
|
7204
7269
|
for (const file of walkFiles(folder)) {
|
|
7205
|
-
const relative =
|
|
7270
|
+
const relative = import_node_path14.default.relative(folder, file).split(import_node_path14.default.sep).join("/");
|
|
7206
7271
|
if ([...exceptions].some(
|
|
7207
7272
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
7208
7273
|
))
|
|
@@ -7211,14 +7276,14 @@ function targetMembers(ref) {
|
|
|
7211
7276
|
}
|
|
7212
7277
|
} else {
|
|
7213
7278
|
for (const relative of exceptions) {
|
|
7214
|
-
const file =
|
|
7279
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7215
7280
|
if (isDirectory(file)) {
|
|
7216
7281
|
for (const inner of walkFiles(file))
|
|
7217
7282
|
addSynchronized(
|
|
7218
7283
|
folder,
|
|
7219
|
-
|
|
7284
|
+
import_node_path14.default.relative(folder, inner).split(import_node_path14.default.sep).join("/")
|
|
7220
7285
|
);
|
|
7221
|
-
} else if (
|
|
7286
|
+
} else if (import_node_fs13.default.existsSync(file)) addSynchronized(folder, relative);
|
|
7222
7287
|
}
|
|
7223
7288
|
}
|
|
7224
7289
|
}
|
|
@@ -7231,8 +7296,8 @@ function targetMembers(ref) {
|
|
|
7231
7296
|
function commonAncestor(dirs) {
|
|
7232
7297
|
let common = dirs[0];
|
|
7233
7298
|
for (const dir of dirs) {
|
|
7234
|
-
while (common !==
|
|
7235
|
-
common =
|
|
7299
|
+
while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
|
|
7300
|
+
common = import_node_path14.default.dirname(common);
|
|
7236
7301
|
}
|
|
7237
7302
|
return common;
|
|
7238
7303
|
}
|
|
@@ -7241,8 +7306,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7241
7306
|
const projects2 = [];
|
|
7242
7307
|
const projectAt = /* @__PURE__ */ new Map();
|
|
7243
7308
|
const addProject = (xcodeproj) => {
|
|
7244
|
-
const key2 =
|
|
7245
|
-
if (projectAt.has(key2) || key2.split(
|
|
7309
|
+
const key2 = import_node_path14.default.resolve(xcodeproj);
|
|
7310
|
+
if (projectAt.has(key2) || key2.split(import_node_path14.default.sep).includes("Pods")) return;
|
|
7246
7311
|
if (!xcodeProjectFile(key2)) return;
|
|
7247
7312
|
const project = loadProject(key2);
|
|
7248
7313
|
projectAt.set(key2, project);
|
|
@@ -7259,7 +7324,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7259
7324
|
for (const reference of listed)
|
|
7260
7325
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
7261
7326
|
if (projects2.length === 0) {
|
|
7262
|
-
throw new Error(`${
|
|
7327
|
+
throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
7263
7328
|
}
|
|
7264
7329
|
return { listed, projects: projects2, projectAt };
|
|
7265
7330
|
}
|
|
@@ -7280,7 +7345,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7280
7345
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
7281
7346
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
7282
7347
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
7283
|
-
const container =
|
|
7348
|
+
const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
|
|
7284
7349
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
7285
7350
|
if (named.length !== 1) {
|
|
7286
7351
|
throw new Error(
|
|
@@ -7292,14 +7357,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7292
7357
|
for (const ref of allTargets) {
|
|
7293
7358
|
const product = ref.project.object(str(ref.target.productReference));
|
|
7294
7359
|
const file = str(product?.path);
|
|
7295
|
-
if (file && !byProduct.has(
|
|
7296
|
-
byProduct.set(
|
|
7360
|
+
if (file && !byProduct.has(import_node_path14.default.basename(file)))
|
|
7361
|
+
byProduct.set(import_node_path14.default.basename(file), ref);
|
|
7297
7362
|
}
|
|
7298
7363
|
const proxied = (project, proxyId) => {
|
|
7299
7364
|
const proxy = project.object(proxyId);
|
|
7300
7365
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
7301
7366
|
const portal = str(proxy.containerPortal);
|
|
7302
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
7367
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path14.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
7303
7368
|
const remote = str(proxy.remoteGlobalIDString);
|
|
7304
7369
|
if (!owner || !remote) return void 0;
|
|
7305
7370
|
return nativeTargets(owner).find(
|
|
@@ -7320,7 +7385,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7320
7385
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
7321
7386
|
for (const buildFileId of list(phase.files)) {
|
|
7322
7387
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
7323
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
7388
|
+
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(import_node_path14.default.basename(str(file.path) ?? "")) : void 0;
|
|
7324
7389
|
if (resolved) found.push(resolved);
|
|
7325
7390
|
}
|
|
7326
7391
|
}
|
|
@@ -7341,7 +7406,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7341
7406
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
7342
7407
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
7343
7408
|
TARGET_NAME: name2,
|
|
7344
|
-
PROJECT_NAME:
|
|
7409
|
+
PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
7345
7410
|
SRCROOT: ref.project.projectDir,
|
|
7346
7411
|
SOURCE_ROOT: ref.project.projectDir,
|
|
7347
7412
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -7372,8 +7437,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7372
7437
|
}
|
|
7373
7438
|
return value;
|
|
7374
7439
|
};
|
|
7375
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
7376
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
7440
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
7441
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs13.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
7377
7442
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
7378
7443
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
7379
7444
|
}
|
|
@@ -7391,12 +7456,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7391
7456
|
};
|
|
7392
7457
|
}
|
|
7393
7458
|
const localPackageDirs = [
|
|
7394
|
-
...listed.filter((reference) =>
|
|
7459
|
+
...listed.filter((reference) => import_node_fs13.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
|
|
7395
7460
|
...projects2.flatMap(
|
|
7396
7461
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
7397
7462
|
if (!isDict(entry)) return [];
|
|
7398
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
7399
|
-
return candidate &&
|
|
7463
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
7464
|
+
return candidate && import_node_fs13.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
7400
7465
|
})
|
|
7401
7466
|
)
|
|
7402
7467
|
];
|
|
@@ -7420,7 +7485,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7420
7485
|
product,
|
|
7421
7486
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
7422
7487
|
kind: "local",
|
|
7423
|
-
dir:
|
|
7488
|
+
dir: import_node_path14.default.resolve(
|
|
7424
7489
|
project.projectDir,
|
|
7425
7490
|
str(reference.relativePath) ?? ""
|
|
7426
7491
|
)
|
|
@@ -7442,8 +7507,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7442
7507
|
}
|
|
7443
7508
|
}
|
|
7444
7509
|
}
|
|
7445
|
-
const resolvedFile =
|
|
7446
|
-
workspace ??
|
|
7510
|
+
const resolvedFile = import_node_path14.default.join(
|
|
7511
|
+
workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
7447
7512
|
"xcshareddata",
|
|
7448
7513
|
"swiftpm",
|
|
7449
7514
|
"Package.resolved"
|
|
@@ -7453,13 +7518,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7453
7518
|
...module2,
|
|
7454
7519
|
rootDir: commonAncestor(
|
|
7455
7520
|
[
|
|
7456
|
-
workspace ?
|
|
7521
|
+
workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
|
|
7457
7522
|
...used.map((project) => project.projectDir),
|
|
7458
7523
|
...localPackageDirs,
|
|
7459
7524
|
...linkedProducts.flatMap(
|
|
7460
|
-
({ source }) => source.kind === "local" &&
|
|
7525
|
+
({ source }) => source.kind === "local" && import_node_fs13.default.existsSync(source.dir) ? [source.dir] : []
|
|
7461
7526
|
)
|
|
7462
|
-
].map((dir) =>
|
|
7527
|
+
].map((dir) => import_node_fs13.default.realpathSync(dir))
|
|
7463
7528
|
),
|
|
7464
7529
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
7465
7530
|
infoPlist: import_plist.default.build(info),
|
|
@@ -7467,19 +7532,19 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7467
7532
|
frameworks,
|
|
7468
7533
|
linkedProducts,
|
|
7469
7534
|
localPackageDirs: [
|
|
7470
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7535
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs13.default.realpathSync(dir)))
|
|
7471
7536
|
].sort(),
|
|
7472
7537
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
7473
|
-
packageResolved:
|
|
7538
|
+
packageResolved: import_node_fs13.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
7474
7539
|
appTargets: appTargetNames
|
|
7475
7540
|
};
|
|
7476
7541
|
}
|
|
7477
|
-
var
|
|
7542
|
+
var import_node_fs13, import_node_path14, import_plist, isDict, str, list, APPLICATION, MODULE_PRODUCTS, NEVER_MEMBER, BUNDLE_DIR, CONDITIONS, isDirectory, loaded, targetRefs;
|
|
7478
7543
|
var init_xcode_project = __esm({
|
|
7479
7544
|
"src/xcode-project.ts"() {
|
|
7480
7545
|
"use strict";
|
|
7481
|
-
|
|
7482
|
-
|
|
7546
|
+
import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
7547
|
+
import_node_path14 = __toESM(require("node:path"), 1);
|
|
7483
7548
|
import_plist = __toESM(require_plist(), 1);
|
|
7484
7549
|
init_xcode_json_project();
|
|
7485
7550
|
isDict = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -7499,7 +7564,7 @@ var init_xcode_project = __esm({
|
|
|
7499
7564
|
arch: "arm64",
|
|
7500
7565
|
variant: "normal"
|
|
7501
7566
|
};
|
|
7502
|
-
isDirectory = (dir) =>
|
|
7567
|
+
isDirectory = (dir) => import_node_fs13.default.existsSync(dir) && import_node_fs13.default.statSync(dir).isDirectory();
|
|
7503
7568
|
loaded = /* @__PURE__ */ new Map();
|
|
7504
7569
|
targetRefs = /* @__PURE__ */ new WeakMap();
|
|
7505
7570
|
}
|
|
@@ -7507,17 +7572,17 @@ var init_xcode_project = __esm({
|
|
|
7507
7572
|
|
|
7508
7573
|
// src/swift-host.ts
|
|
7509
7574
|
function swiftPackageId(packagePath) {
|
|
7510
|
-
return
|
|
7575
|
+
return import_node_path15.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
7511
7576
|
}
|
|
7512
7577
|
function nativeSourceDescriptor(packagePath) {
|
|
7513
|
-
packagePath =
|
|
7514
|
-
const file =
|
|
7515
|
-
if (!
|
|
7578
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7579
|
+
const file = import_node_path15.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
7580
|
+
if (!import_node_fs14.default.existsSync(file)) return null;
|
|
7516
7581
|
const value = JSON.parse(
|
|
7517
7582
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
7518
7583
|
);
|
|
7519
7584
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
7520
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
7585
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs14.default.existsSync(import_node_path15.default.join(packagePath, NATIVE_GLUE))) {
|
|
7521
7586
|
throw invalid();
|
|
7522
7587
|
}
|
|
7523
7588
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -7526,7 +7591,7 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
7526
7591
|
return value;
|
|
7527
7592
|
}
|
|
7528
7593
|
function projectFor(packagePath, hosted) {
|
|
7529
|
-
packagePath =
|
|
7594
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7530
7595
|
const existing = projects.get(packagePath);
|
|
7531
7596
|
if (existing) {
|
|
7532
7597
|
if (hosted && !existing.hosted) {
|
|
@@ -7547,14 +7612,14 @@ function projectFor(packagePath, hosted) {
|
|
|
7547
7612
|
return created;
|
|
7548
7613
|
}
|
|
7549
7614
|
function swiftPackages(entry, app) {
|
|
7550
|
-
const stamp = (file) => file &&
|
|
7615
|
+
const stamp = (file) => file && import_node_fs14.default.existsSync(file) ? import_node_fs14.default.statSync(file).mtimeMs : 0;
|
|
7551
7616
|
const key2 = JSON.stringify([
|
|
7552
7617
|
app.linkedProducts,
|
|
7553
7618
|
app.packageResolved,
|
|
7554
7619
|
stamp(app.packageResolved),
|
|
7555
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
7620
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path15.default.join(dir, "Package.swift"))),
|
|
7556
7621
|
app.linkedProducts.map(
|
|
7557
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
7622
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path15.default.join(source.dir, "Package.swift")) : 0
|
|
7558
7623
|
)
|
|
7559
7624
|
]);
|
|
7560
7625
|
let cached2 = entry.packages;
|
|
@@ -7603,8 +7668,8 @@ function swiftPackages(entry, app) {
|
|
|
7603
7668
|
}
|
|
7604
7669
|
function xcodeInputKey(layout, file, relative) {
|
|
7605
7670
|
const owner = layout.targetDirs.get(file);
|
|
7606
|
-
if (owner) return
|
|
7607
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
7671
|
+
if (owner) return import_node_path15.default.posix.join(owner, relative);
|
|
7672
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
7608
7673
|
}
|
|
7609
7674
|
function xcodeLayout(root) {
|
|
7610
7675
|
const registered = xcodeProjects.get(root);
|
|
@@ -7615,7 +7680,7 @@ function xcodeLayout(root) {
|
|
|
7615
7680
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
7616
7681
|
const targets = [];
|
|
7617
7682
|
for (const framework of app.frameworks) {
|
|
7618
|
-
const dir =
|
|
7683
|
+
const dir = import_node_path15.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
7619
7684
|
for (const file of framework.sources) {
|
|
7620
7685
|
if (targetDirs.has(file)) continue;
|
|
7621
7686
|
targetDirs.set(file, dir);
|
|
@@ -7635,7 +7700,7 @@ function xcodeLayout(root) {
|
|
|
7635
7700
|
for (const standin of standins)
|
|
7636
7701
|
targets.push({
|
|
7637
7702
|
name: standin.module,
|
|
7638
|
-
path:
|
|
7703
|
+
path: import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
7639
7704
|
executable: false,
|
|
7640
7705
|
resources: false,
|
|
7641
7706
|
exclude: [],
|
|
@@ -7643,19 +7708,19 @@ function xcodeLayout(root) {
|
|
|
7643
7708
|
mainActorIsolation: false
|
|
7644
7709
|
});
|
|
7645
7710
|
for (const target of packages.targets) {
|
|
7646
|
-
const relative =
|
|
7647
|
-
target.remote ?
|
|
7711
|
+
const relative = import_node_path15.default.relative(
|
|
7712
|
+
target.remote ? import_node_path15.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
7648
7713
|
target.dir
|
|
7649
7714
|
);
|
|
7650
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
7715
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path15.default.sep}`) || import_node_path15.default.isAbsolute(relative))
|
|
7651
7716
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
7652
|
-
const posix = relative.split(
|
|
7717
|
+
const posix = relative.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7653
7718
|
targets.push({
|
|
7654
7719
|
...target,
|
|
7655
|
-
path: target.remote ?
|
|
7720
|
+
path: target.remote ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
7656
7721
|
exclude: []
|
|
7657
7722
|
});
|
|
7658
|
-
if (!target.remote) files2.add(
|
|
7723
|
+
if (!target.remote) files2.add(import_node_path15.default.join(target.packageDir, "Package.swift"));
|
|
7659
7724
|
for (const file of target.files) files2.add(file);
|
|
7660
7725
|
}
|
|
7661
7726
|
for (const target of targets) {
|
|
@@ -7685,25 +7750,25 @@ function xcodeManifest(layout) {
|
|
|
7685
7750
|
].join("\n");
|
|
7686
7751
|
}
|
|
7687
7752
|
function packageFiles(root) {
|
|
7688
|
-
const canonicalRoot =
|
|
7753
|
+
const canonicalRoot = import_node_fs14.default.realpathSync(root);
|
|
7689
7754
|
const xcode = xcodeLayout(canonicalRoot);
|
|
7690
7755
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
7691
7756
|
}
|
|
7692
7757
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
7693
7758
|
const found = [];
|
|
7694
7759
|
const walk2 = (dir2) => {
|
|
7695
|
-
for (const entry of
|
|
7760
|
+
for (const entry of import_node_fs14.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
7696
7761
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
7697
7762
|
continue;
|
|
7698
|
-
const full =
|
|
7763
|
+
const full = import_node_path15.default.join(dir2, entry.name);
|
|
7699
7764
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
7700
|
-
const real =
|
|
7701
|
-
const relative =
|
|
7702
|
-
if (relative.startsWith(`..${
|
|
7765
|
+
const real = import_node_fs14.default.realpathSync(full);
|
|
7766
|
+
const relative = import_node_path15.default.relative(canonicalRoot, real);
|
|
7767
|
+
if (relative.startsWith(`..${import_node_path15.default.sep}`) || relative === ".." || import_node_path15.default.isAbsolute(relative)) {
|
|
7703
7768
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
7704
7769
|
}
|
|
7705
7770
|
if (entry.isDirectory()) {
|
|
7706
|
-
if (
|
|
7771
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(full, "Package.swift"))) continue;
|
|
7707
7772
|
walk2(full);
|
|
7708
7773
|
} else if (entry.isFile()) {
|
|
7709
7774
|
found.push(full);
|
|
@@ -7711,63 +7776,22 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
7711
7776
|
}
|
|
7712
7777
|
}
|
|
7713
7778
|
};
|
|
7714
|
-
if (
|
|
7779
|
+
if (import_node_fs14.default.existsSync(dir)) walk2(import_node_fs14.default.realpathSync(dir));
|
|
7715
7780
|
return found;
|
|
7716
7781
|
}
|
|
7717
|
-
function readPackageFile(root, file, maxBytes) {
|
|
7718
|
-
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
7719
|
-
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs13.default.realpathSync(file));
|
|
7720
|
-
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
7721
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7722
|
-
}
|
|
7723
|
-
let ancestor = import_node_path14.default.resolve(file);
|
|
7724
|
-
while (ancestor !== canonicalRoot) {
|
|
7725
|
-
if (import_node_fs13.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
7726
|
-
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
7727
|
-
}
|
|
7728
|
-
const parent = import_node_path14.default.dirname(ancestor);
|
|
7729
|
-
if (parent === ancestor)
|
|
7730
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7731
|
-
ancestor = parent;
|
|
7732
|
-
}
|
|
7733
|
-
const expected = import_node_fs13.default.statSync(file);
|
|
7734
|
-
const fd = import_node_fs13.default.openSync(file, import_node_fs13.default.constants.O_RDONLY | import_node_fs13.default.constants.O_NOFOLLOW);
|
|
7735
|
-
try {
|
|
7736
|
-
const stat = import_node_fs13.default.fstatSync(fd);
|
|
7737
|
-
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
7738
|
-
throw new Error(`swift input changed while opening: ${file}`);
|
|
7739
|
-
}
|
|
7740
|
-
if (!stat.isFile() || stat.size > maxBytes) {
|
|
7741
|
-
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
7742
|
-
}
|
|
7743
|
-
const bytes = Buffer.alloc(stat.size + 1);
|
|
7744
|
-
let offset = 0;
|
|
7745
|
-
while (offset < bytes.length) {
|
|
7746
|
-
const count = import_node_fs13.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
7747
|
-
if (count === 0) break;
|
|
7748
|
-
offset += count;
|
|
7749
|
-
}
|
|
7750
|
-
if (offset !== stat.size || import_node_fs13.default.fstatSync(fd).size !== stat.size) {
|
|
7751
|
-
throw new Error(`swift input changed while reading: ${file}`);
|
|
7752
|
-
}
|
|
7753
|
-
return bytes.subarray(0, offset);
|
|
7754
|
-
} finally {
|
|
7755
|
-
import_node_fs13.default.closeSync(fd);
|
|
7756
|
-
}
|
|
7757
|
-
}
|
|
7758
7782
|
function sourceFiles(root) {
|
|
7759
7783
|
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
7760
7784
|
}
|
|
7761
7785
|
function resourceCandidateFiles(root) {
|
|
7762
7786
|
return packageFiles(root).filter(
|
|
7763
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
7787
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path15.default.basename(file))
|
|
7764
7788
|
);
|
|
7765
7789
|
}
|
|
7766
7790
|
function buildSwiftResourceTable(project, baseUrl) {
|
|
7767
7791
|
const limits = inputLimits(Boolean(project.hosted));
|
|
7768
7792
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
7769
7793
|
const relative = absolute.map(
|
|
7770
|
-
(file) =>
|
|
7794
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7771
7795
|
);
|
|
7772
7796
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
7773
7797
|
const readContents = (candidate) => {
|
|
@@ -7789,16 +7813,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7789
7813
|
for (const { name: name2, file, scale } of found) {
|
|
7790
7814
|
const disk = byRelative.get(file);
|
|
7791
7815
|
if (!disk) continue;
|
|
7792
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7816
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs14.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
7793
7817
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
7794
7818
|
}
|
|
7795
7819
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
7796
7820
|
imageBytes += bytes.length;
|
|
7797
7821
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
7798
|
-
const ext =
|
|
7822
|
+
const ext = import_node_path15.default.posix.extname(file).toLowerCase();
|
|
7799
7823
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7800
7824
|
images[name2] = {
|
|
7801
|
-
file:
|
|
7825
|
+
file: import_node_path15.default.posix.basename(file),
|
|
7802
7826
|
data: bytes.toString("base64")
|
|
7803
7827
|
};
|
|
7804
7828
|
watched.push(file);
|
|
@@ -7822,10 +7846,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7822
7846
|
return { table, images, colors, symbols, watched };
|
|
7823
7847
|
}
|
|
7824
7848
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
7825
|
-
packagePath =
|
|
7849
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7826
7850
|
const limits = inputLimits(hosted);
|
|
7827
7851
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
7828
|
-
(file) =>
|
|
7852
|
+
(file) => import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7829
7853
|
);
|
|
7830
7854
|
const files2 = {};
|
|
7831
7855
|
const watched = [];
|
|
@@ -7839,13 +7863,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7839
7863
|
total += bytes.length;
|
|
7840
7864
|
if (xcode.app.infoPlistFile)
|
|
7841
7865
|
watched.push(
|
|
7842
|
-
|
|
7866
|
+
import_node_path15.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path15.default.sep).join("/")
|
|
7843
7867
|
);
|
|
7844
7868
|
}
|
|
7845
7869
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
7846
7870
|
watched.push(file);
|
|
7847
|
-
const disk =
|
|
7848
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7871
|
+
const disk = import_node_path15.default.join(packagePath, ...file.split("/"));
|
|
7872
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs14.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
7849
7873
|
throw new Error(
|
|
7850
7874
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
7851
7875
|
);
|
|
@@ -7857,12 +7881,12 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7857
7881
|
return { files: files2, watched };
|
|
7858
7882
|
}
|
|
7859
7883
|
function linkedModuleRoots(packagePath) {
|
|
7860
|
-
packagePath =
|
|
7884
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7861
7885
|
let manifest;
|
|
7862
7886
|
try {
|
|
7863
7887
|
manifest = readPackageFile(
|
|
7864
7888
|
packagePath,
|
|
7865
|
-
|
|
7889
|
+
import_node_path15.default.join(packagePath, "Package.swift"),
|
|
7866
7890
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7867
7891
|
).toString("utf8");
|
|
7868
7892
|
} catch {
|
|
@@ -7871,8 +7895,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
7871
7895
|
const roots = /* @__PURE__ */ new Set();
|
|
7872
7896
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
7873
7897
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
7874
|
-
const root =
|
|
7875
|
-
if (
|
|
7898
|
+
const root = import_node_path15.default.resolve(packagePath, match[1]);
|
|
7899
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(root, "Package.swift"))) roots.add(root);
|
|
7876
7900
|
}
|
|
7877
7901
|
return [...roots].sort();
|
|
7878
7902
|
}
|
|
@@ -7881,18 +7905,18 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
7881
7905
|
hash.update(packagePath);
|
|
7882
7906
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
7883
7907
|
for (const file of [...projectInputs].sort()) {
|
|
7884
|
-
hash.update(
|
|
7885
|
-
const stat =
|
|
7908
|
+
hash.update(import_node_path15.default.relative(packagePath, file));
|
|
7909
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
7886
7910
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
7887
7911
|
}
|
|
7888
7912
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7889
|
-
(root) =>
|
|
7913
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7890
7914
|
);
|
|
7891
7915
|
if (moduleRoot) {
|
|
7892
7916
|
hash.update(moduleRoot);
|
|
7893
7917
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
7894
7918
|
hash.update(relative);
|
|
7895
|
-
hash.update(String(
|
|
7919
|
+
hash.update(String(import_node_fs14.default.statSync(import_node_path15.default.join(moduleRoot, relative)).mtimeMs));
|
|
7896
7920
|
}
|
|
7897
7921
|
}
|
|
7898
7922
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -7904,8 +7928,8 @@ function packageSources(packagePath) {
|
|
|
7904
7928
|
const xcode = xcodeLayout(packagePath);
|
|
7905
7929
|
const files2 = {};
|
|
7906
7930
|
for (const file of sourceFiles(packagePath)) {
|
|
7907
|
-
const relative =
|
|
7908
|
-
if (xcode &&
|
|
7931
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7932
|
+
if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
|
|
7909
7933
|
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
7910
7934
|
packagePath,
|
|
7911
7935
|
file,
|
|
@@ -7916,7 +7940,7 @@ function packageSources(packagePath) {
|
|
|
7916
7940
|
files2["Package.swift"] = xcodeManifest(xcode);
|
|
7917
7941
|
for (const standin of xcode.standins)
|
|
7918
7942
|
for (const [file, text3] of Object.entries(standin.files))
|
|
7919
|
-
files2[
|
|
7943
|
+
files2[import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
7920
7944
|
}
|
|
7921
7945
|
return files2;
|
|
7922
7946
|
}
|
|
@@ -7927,7 +7951,7 @@ function packageSnapshot(project) {
|
|
|
7927
7951
|
files: files2,
|
|
7928
7952
|
resourcePaths: swiftImplicitResourcePaths(
|
|
7929
7953
|
resourceCandidateFiles(project.packagePath).map(
|
|
7930
|
-
(file) =>
|
|
7954
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7931
7955
|
)
|
|
7932
7956
|
),
|
|
7933
7957
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -7936,7 +7960,7 @@ function packageSnapshot(project) {
|
|
|
7936
7960
|
...native ? {
|
|
7937
7961
|
glue: readPackageFile(
|
|
7938
7962
|
project.packagePath,
|
|
7939
|
-
|
|
7963
|
+
import_node_path15.default.join(project.packagePath, NATIVE_GLUE),
|
|
7940
7964
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7941
7965
|
).toString("utf8")
|
|
7942
7966
|
} : {}
|
|
@@ -7972,7 +7996,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7972
7996
|
package: content
|
|
7973
7997
|
};
|
|
7974
7998
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7975
|
-
(root) =>
|
|
7999
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7976
8000
|
) ?? await swiftDistributionRoot();
|
|
7977
8001
|
if (!moduleRoot)
|
|
7978
8002
|
return {
|
|
@@ -7999,10 +8023,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7999
8023
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
8000
8024
|
// each app and module checkout gets its own root, which keeps the same
|
|
8001
8025
|
// app's incremental build across restarts.
|
|
8002
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
8026
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path15.default.join(
|
|
8003
8027
|
import_node_os8.default.tmpdir(),
|
|
8004
8028
|
"contrast-swift-build",
|
|
8005
|
-
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${
|
|
8029
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path15.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
8006
8030
|
),
|
|
8007
8031
|
moduleRoot,
|
|
8008
8032
|
...toolchain
|
|
@@ -8095,7 +8119,7 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
8095
8119
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
8096
8120
|
...[...missing].map(([name2, files2]) => {
|
|
8097
8121
|
const gap = gaps.get(name2);
|
|
8098
|
-
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
8122
|
+
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${import_node_path15.default.relative(packagePath, gap.source) || "."}` : gap.source} (${gap.reason})` : ""}`;
|
|
8099
8123
|
})
|
|
8100
8124
|
].join("\n");
|
|
8101
8125
|
}
|
|
@@ -8103,7 +8127,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8103
8127
|
const auth = hosted ? null : resolveCliAuth();
|
|
8104
8128
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
8105
8129
|
throw new Error(
|
|
8106
|
-
`compiling ${
|
|
8130
|
+
`compiling ${import_node_path15.default.basename(packagePath)} for Peach needs \`peach login\` or PEACH_API_KEY: this peachsim has no local SwiftUI module, so Contrast compiles it`
|
|
8107
8131
|
);
|
|
8108
8132
|
}
|
|
8109
8133
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -8122,7 +8146,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8122
8146
|
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
8123
8147
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
8124
8148
|
throw new Error(
|
|
8125
|
-
`${
|
|
8149
|
+
`${import_node_path15.default.basename(packagePath)} has ${sources.length} Swift files (${bytes} bytes), over Contrast's compile limits of ${MAX_SWIFT_COMPILE_FILES} files and ${MAX_SWIFT_COMPILE_SOURCE_BYTES} bytes; compile it on this machine with the Swift distribution instead`
|
|
8126
8150
|
);
|
|
8127
8151
|
}
|
|
8128
8152
|
const descriptor = snapshot.native;
|
|
@@ -8141,7 +8165,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8141
8165
|
);
|
|
8142
8166
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
8143
8167
|
throw new Error(
|
|
8144
|
-
`${
|
|
8168
|
+
`${import_node_path15.default.basename(packagePath)}: Contrast compiled native contract ${address.native?.hash ?? "none"} but one typegen wrote ${descriptor.hash}; the app's One and the compile host's differ, or the compile host is older than this peachsim`
|
|
8145
8169
|
);
|
|
8146
8170
|
}
|
|
8147
8171
|
const response = await fetch(address.url, { signal });
|
|
@@ -8213,14 +8237,14 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
8213
8237
|
project.building = { stamp, promise: fresh };
|
|
8214
8238
|
return fresh;
|
|
8215
8239
|
}
|
|
8216
|
-
var import_node_crypto7,
|
|
8240
|
+
var import_node_crypto7, import_node_fs14, import_node_os8, import_node_path15, RESOURCE_PATH, ICU_PATH, SKIP_SOURCE_DIRS, NATIVE_DESCRIPTOR, NATIVE_GLUE, SwiftMissingModulesError, projects, xcodeProjects, XCODE_APP_DIR, XCODE_FRAMEWORKS_DIR, XCODE_PACKAGES_DIR, XCODE_STANDINS_DIR, CHECKOUTS_PREFIX, HOSTED_LIMITS, LOCAL_LIMITS, inputLimits, RESOURCE_CONTENT_TYPES, API_GAP_PATTERNS, UNPROVIDED_PLATFORM_MODULES, IOS_SDK_FRAMEWORKS;
|
|
8217
8241
|
var init_swift_host = __esm({
|
|
8218
8242
|
"src/swift-host.ts"() {
|
|
8219
8243
|
"use strict";
|
|
8220
8244
|
import_node_crypto7 = require("node:crypto");
|
|
8221
|
-
|
|
8245
|
+
import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
8222
8246
|
import_node_os8 = __toESM(require("node:os"), 1);
|
|
8223
|
-
|
|
8247
|
+
import_node_path15 = __toESM(require("node:path"), 1);
|
|
8224
8248
|
init_bundleAssets();
|
|
8225
8249
|
init_auth();
|
|
8226
8250
|
init_backend_origin();
|
|
@@ -8230,6 +8254,7 @@ var init_swift_host = __esm({
|
|
|
8230
8254
|
init_swift_distribution();
|
|
8231
8255
|
init_swift_package();
|
|
8232
8256
|
init_swift_packages();
|
|
8257
|
+
init_swift_source_file();
|
|
8233
8258
|
init_swift_standins();
|
|
8234
8259
|
init_swift_submit();
|
|
8235
8260
|
init_xcode_project();
|
|
@@ -8253,7 +8278,7 @@ var init_swift_host = __esm({
|
|
|
8253
8278
|
XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
8254
8279
|
XCODE_PACKAGES_DIR = "__packages__";
|
|
8255
8280
|
XCODE_STANDINS_DIR = "__standins__";
|
|
8256
|
-
CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
8281
|
+
CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
|
|
8257
8282
|
HOSTED_LIMITS = {
|
|
8258
8283
|
resources: MAX_SWIFT_COMPILE_RESOURCES,
|
|
8259
8284
|
resourceBytes: MAX_SWIFT_COMPILE_RESOURCE_BYTES,
|
|
@@ -8305,8 +8330,8 @@ var init_swift_host = __esm({
|
|
|
8305
8330
|
|
|
8306
8331
|
// src/expo-swift-host.ts
|
|
8307
8332
|
async function collectExpoSwiftSources(appRoot) {
|
|
8308
|
-
appRoot =
|
|
8309
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
8333
|
+
appRoot = import_node_fs15.default.realpathSync(appRoot);
|
|
8334
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path16.default.join(appRoot, "package.json"));
|
|
8310
8335
|
let autolinker;
|
|
8311
8336
|
try {
|
|
8312
8337
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -8320,7 +8345,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8320
8345
|
(command) => run3(
|
|
8321
8346
|
process.execPath,
|
|
8322
8347
|
[
|
|
8323
|
-
|
|
8348
|
+
import_node_path16.default.join(import_node_path16.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
8324
8349
|
command,
|
|
8325
8350
|
"--platform",
|
|
8326
8351
|
"apple",
|
|
@@ -8351,8 +8376,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8351
8376
|
const sourceRoot = Reflect.get(entry, "path");
|
|
8352
8377
|
if (typeof sourceRoot !== "string")
|
|
8353
8378
|
throw new Error("Expo autolinking entry has no path");
|
|
8354
|
-
const canonical =
|
|
8355
|
-
if (canonical.split(
|
|
8379
|
+
const canonical = import_node_fs15.default.realpathSync(sourceRoot);
|
|
8380
|
+
if (canonical.split(import_node_path16.default.sep).includes("node_modules")) continue;
|
|
8356
8381
|
const resolution = resolutions.find(
|
|
8357
8382
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
8358
8383
|
);
|
|
@@ -8379,12 +8404,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8379
8404
|
registration: `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
8380
8405
|
});
|
|
8381
8406
|
}
|
|
8382
|
-
const ios =
|
|
8383
|
-
if (
|
|
8407
|
+
const ios = import_node_path16.default.join(canonical, "ios");
|
|
8408
|
+
if (import_node_fs15.default.lstatSync(ios).isSymbolicLink())
|
|
8384
8409
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
8385
8410
|
const walk2 = (dir) => {
|
|
8386
|
-
for (const child of
|
|
8387
|
-
const file =
|
|
8411
|
+
for (const child of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8412
|
+
const file = import_node_path16.default.join(dir, child.name);
|
|
8388
8413
|
if (child.isSymbolicLink())
|
|
8389
8414
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
8390
8415
|
if (child.isDirectory()) {
|
|
@@ -8392,13 +8417,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8392
8417
|
continue;
|
|
8393
8418
|
}
|
|
8394
8419
|
if (!child.name.endsWith(".swift")) continue;
|
|
8395
|
-
const size =
|
|
8420
|
+
const size = import_node_fs15.default.statSync(file).size;
|
|
8396
8421
|
bytes += size;
|
|
8397
8422
|
fileCount++;
|
|
8398
8423
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
8399
8424
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
8400
|
-
files2[`Sources/${namespace}/${
|
|
8401
|
-
${
|
|
8425
|
+
files2[`Sources/${namespace}/${import_node_path16.default.relative(ios, file).split(import_node_path16.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
8426
|
+
${import_node_fs15.default.readFileSync(file, "utf8")}`;
|
|
8402
8427
|
}
|
|
8403
8428
|
};
|
|
8404
8429
|
walk2(ios);
|
|
@@ -8482,7 +8507,7 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8482
8507
|
modules: [],
|
|
8483
8508
|
failures: []
|
|
8484
8509
|
};
|
|
8485
|
-
const key2 = (0, import_node_crypto8.createHash)("sha256").update(
|
|
8510
|
+
const key2 = (0, import_node_crypto8.createHash)("sha256").update(import_node_fs15.default.realpathSync(root)).digest("hex");
|
|
8486
8511
|
const linked = [];
|
|
8487
8512
|
for (const unit of units) {
|
|
8488
8513
|
if (!module2) {
|
|
@@ -8492,14 +8517,14 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8492
8517
|
});
|
|
8493
8518
|
continue;
|
|
8494
8519
|
}
|
|
8495
|
-
const packagePath =
|
|
8520
|
+
const packagePath = import_node_path16.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
|
|
8496
8521
|
let stamp;
|
|
8497
8522
|
try {
|
|
8498
8523
|
syncSwiftTree(
|
|
8499
8524
|
packagePath,
|
|
8500
8525
|
new Map(
|
|
8501
8526
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
8502
|
-
|
|
8527
|
+
import_node_path16.default.join(packagePath, name2),
|
|
8503
8528
|
source
|
|
8504
8529
|
])
|
|
8505
8530
|
)
|
|
@@ -8524,10 +8549,13 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8524
8549
|
const file = JSON.parse(match[1]);
|
|
8525
8550
|
return typeof file === "string" ? [file] : [];
|
|
8526
8551
|
});
|
|
8527
|
-
const
|
|
8528
|
-
|
|
8552
|
+
const errors = diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm) ?? [];
|
|
8553
|
+
const sourceErrors = errors.filter(
|
|
8554
|
+
(line) => appPaths.some((file) => line.startsWith(`${file}:`)) && !/external macro implementation type|failed to load library plugin/.test(line)
|
|
8555
|
+
);
|
|
8556
|
+
if (publishArtifact && (sourceErrors.length === 0 || sourceErrors.length !== errors.length) && !(error instanceof SwiftMissingModulesError))
|
|
8529
8557
|
throw error;
|
|
8530
|
-
if (sourceErrors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
8558
|
+
if (sourceErrors.length && sourceErrors.length === errors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
8531
8559
|
failedCompilations.set(packagePath, {
|
|
8532
8560
|
stamp,
|
|
8533
8561
|
diagnostic: sourceErrors.join("\n")
|
|
@@ -8557,12 +8585,12 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8557
8585
|
import PackageDescription
|
|
8558
8586
|
let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.target(name: ${JSON.stringify(name2)}, path: ${JSON.stringify(`Sources/${name2}`)})`).join(", ")}, .executableTarget(name: "PeachExpoApp", path: "Sources/PeachExpoApp")])
|
|
8559
8587
|
`;
|
|
8560
|
-
const packagePath =
|
|
8588
|
+
const packagePath = import_node_path16.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
|
|
8561
8589
|
syncSwiftTree(
|
|
8562
8590
|
packagePath,
|
|
8563
8591
|
new Map(
|
|
8564
8592
|
Object.entries(files2).map(([name2, source]) => [
|
|
8565
|
-
|
|
8593
|
+
import_node_path16.default.join(packagePath, name2),
|
|
8566
8594
|
source
|
|
8567
8595
|
])
|
|
8568
8596
|
)
|
|
@@ -8583,16 +8611,16 @@ let package = Package(name: "PeachExpo", targets: [${targets.map((name2) => `.ta
|
|
|
8583
8611
|
}
|
|
8584
8612
|
return result;
|
|
8585
8613
|
}
|
|
8586
|
-
var import_node_child_process9, import_node_crypto8,
|
|
8614
|
+
var import_node_child_process9, import_node_crypto8, import_node_fs15, import_node_module, import_node_os9, import_node_path16, import_node_util3, run3, scriptEnv, EXPO_SWIFT_ENTRY, failedCompilations;
|
|
8587
8615
|
var init_expo_swift_host = __esm({
|
|
8588
8616
|
"src/expo-swift-host.ts"() {
|
|
8589
8617
|
"use strict";
|
|
8590
8618
|
import_node_child_process9 = require("node:child_process");
|
|
8591
8619
|
import_node_crypto8 = require("node:crypto");
|
|
8592
|
-
|
|
8620
|
+
import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
8593
8621
|
import_node_module = require("node:module");
|
|
8594
8622
|
import_node_os9 = __toESM(require("node:os"), 1);
|
|
8595
|
-
|
|
8623
|
+
import_node_path16 = __toESM(require("node:path"), 1);
|
|
8596
8624
|
import_node_util3 = require("node:util");
|
|
8597
8625
|
init_internal_child();
|
|
8598
8626
|
init_backend_origin();
|
|
@@ -8899,16 +8927,16 @@ function prepareBundleChannel({
|
|
|
8899
8927
|
files2.set(asset.path, asset.bytes);
|
|
8900
8928
|
}
|
|
8901
8929
|
const identity = (0, import_node_crypto9.createHash)("sha256").update(bundle).update(icon);
|
|
8902
|
-
for (const [
|
|
8930
|
+
for (const [path16, bytes] of [...files2].sort(
|
|
8903
8931
|
([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
8904
8932
|
)) {
|
|
8905
|
-
identity.update(JSON.stringify([
|
|
8933
|
+
identity.update(JSON.stringify([path16, digest(bytes)]));
|
|
8906
8934
|
}
|
|
8907
8935
|
if (expoSwift) identity.update(JSON.stringify(expoSwift.metadata));
|
|
8908
8936
|
const releaseKey = `${prefix}/peach/releases/${identity.digest("hex")}`;
|
|
8909
8937
|
const assetBaseUrl = `${origin.origin}/${releaseKey}/`;
|
|
8910
8938
|
const directories = new Set(
|
|
8911
|
-
[...files2.keys()].map((
|
|
8939
|
+
[...files2.keys()].map((path16) => path16.slice(0, path16.lastIndexOf("/")))
|
|
8912
8940
|
);
|
|
8913
8941
|
let locations = 0;
|
|
8914
8942
|
let source = new TextDecoder("utf-8", { fatal: true }).decode(bundle).replace(
|
|
@@ -8919,12 +8947,12 @@ function prepareBundleChannel({
|
|
|
8919
8947
|
const parsed = new URL(location, "https://packaged.invalid");
|
|
8920
8948
|
if (parsed.origin !== "https://packaged.invalid")
|
|
8921
8949
|
throw new Error(`non-packaged asset location: ${location}`);
|
|
8922
|
-
const
|
|
8923
|
-
if (!directories.has(
|
|
8950
|
+
const path16 = (parsed.searchParams.get("unstable_path") ?? parsed.pathname).replace(/^\/+/, "").replace(/\.\.\//g, "_");
|
|
8951
|
+
if (!directories.has(path16)) {
|
|
8924
8952
|
throw new Error(`bundle asset location has no packaged files: ${location}`);
|
|
8925
8953
|
}
|
|
8926
8954
|
locations++;
|
|
8927
|
-
return `${property}${JSON.stringify(new URL(
|
|
8955
|
+
return `${property}${JSON.stringify(new URL(path16, assetBaseUrl).href)}`;
|
|
8928
8956
|
}
|
|
8929
8957
|
);
|
|
8930
8958
|
if (assets2.length && !locations)
|
|
@@ -8963,10 +8991,10 @@ function prepareBundleChannel({
|
|
|
8963
8991
|
contentType: "application/javascript"
|
|
8964
8992
|
},
|
|
8965
8993
|
{ key: `${releaseKey}/icon.png`, bytes: icon, contentType: "image/png" },
|
|
8966
|
-
...[...files2].map(([
|
|
8967
|
-
key: `${releaseKey}/${
|
|
8994
|
+
...[...files2].map(([path16, bytes]) => ({
|
|
8995
|
+
key: `${releaseKey}/${path16}`,
|
|
8968
8996
|
bytes,
|
|
8969
|
-
contentType: expoSwift?.assets.find((asset) => asset.path ===
|
|
8997
|
+
contentType: expoSwift?.assets.find((asset) => asset.path === path16)?.contentType ?? {
|
|
8970
8998
|
png: "image/png",
|
|
8971
8999
|
jpg: "image/jpeg",
|
|
8972
9000
|
jpeg: "image/jpeg",
|
|
@@ -8975,7 +9003,7 @@ function prepareBundleChannel({
|
|
|
8975
9003
|
ttf: "font/ttf",
|
|
8976
9004
|
otf: "font/otf",
|
|
8977
9005
|
wav: "audio/wav"
|
|
8978
|
-
}[
|
|
9006
|
+
}[path16.split(".").pop()] ?? "application/octet-stream"
|
|
8979
9007
|
}))
|
|
8980
9008
|
];
|
|
8981
9009
|
return { prefix, origin: origin.origin, metadata, objects };
|
|
@@ -9054,15 +9082,15 @@ async function snapshotOneDevBundle(projectRoot, env = {}) {
|
|
|
9054
9082
|
for (const [registration] of bundle.toString("utf8").matchAll(/(?<=registerAsset\()\{[^{}]*"__packager_asset": true[^{}]*\}/g)) {
|
|
9055
9083
|
const asset = JSON.parse(registration);
|
|
9056
9084
|
for (const file of asset.files) {
|
|
9057
|
-
const
|
|
9058
|
-
if (!assets2.has(
|
|
9085
|
+
const path16 = `${asset.httpServerLocation.replace(/^\/+/, "")}/${basename2(file)}`;
|
|
9086
|
+
if (!assets2.has(path16)) assets2.set(path16, readFileSync5(file));
|
|
9059
9087
|
}
|
|
9060
9088
|
}
|
|
9061
9089
|
const { buildExpoSwiftBundle: buildExpoSwiftBundle2 } = await Promise.resolve().then(() => (init_expo_swift_bundle(), expo_swift_bundle_exports));
|
|
9062
9090
|
const expoSwift = await buildExpoSwiftBundle2(projectRoot);
|
|
9063
9091
|
return {
|
|
9064
9092
|
bundle,
|
|
9065
|
-
assets: [...assets2].map(([
|
|
9093
|
+
assets: [...assets2].map(([path16, bytes]) => ({ path: path16, bytes })),
|
|
9066
9094
|
expoSwift
|
|
9067
9095
|
};
|
|
9068
9096
|
} finally {
|