peachsim 0.1.796 → 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 +372 -344
- 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 +346 -325
- 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 +669 -564
- 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 +965 -840
- 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 +405 -357
- 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-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;
|
|
@@ -1393,10 +1393,10 @@ module.exports = __toCommonJS(expo_swift_bundle_exports);
|
|
|
1393
1393
|
// src/expo-swift-host.ts
|
|
1394
1394
|
var import_node_child_process8 = require("node:child_process");
|
|
1395
1395
|
var import_node_crypto8 = require("node:crypto");
|
|
1396
|
-
var
|
|
1396
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
1397
1397
|
var import_node_module = require("node:module");
|
|
1398
1398
|
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
1399
|
-
var
|
|
1399
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
1400
1400
|
var import_node_util3 = require("node:util");
|
|
1401
1401
|
|
|
1402
1402
|
// cli/internal-child.ts
|
|
@@ -2033,7 +2033,7 @@ var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
|
2033
2033
|
);
|
|
2034
2034
|
var 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"';
|
|
2035
2035
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
2036
|
-
var MULTI_MANIFEST_VERSION =
|
|
2036
|
+
var MULTI_MANIFEST_VERSION = 12;
|
|
2037
2037
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
2038
2038
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
2039
2039
|
hash.update(`swift-compile/v18
|
|
@@ -2084,8 +2084,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
2084
2084
|
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
2085
2085
|
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
2086
2086
|
);
|
|
2087
|
+
if (spriteKit) {
|
|
2088
|
+
reachedFrameworks.add("SpriteKit");
|
|
2089
|
+
reachedFrameworks.add("PeachBox2D");
|
|
2090
|
+
}
|
|
2087
2091
|
const distributionObjects = distribution?.objects.filter(
|
|
2088
|
-
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
2092
|
+
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
2089
2093
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
2090
2094
|
)
|
|
2091
2095
|
);
|
|
@@ -3242,7 +3246,17 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
3242
3246
|
])
|
|
3243
3247
|
],
|
|
3244
3248
|
{
|
|
3245
|
-
env:
|
|
3249
|
+
env: {
|
|
3250
|
+
...BUILD_ENV,
|
|
3251
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
3252
|
+
...process.platform === "linux" ? {
|
|
3253
|
+
LD_LIBRARY_PATH: [
|
|
3254
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
3255
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
3256
|
+
process.env.LD_LIBRARY_PATH
|
|
3257
|
+
].filter(Boolean).join(":")
|
|
3258
|
+
} : {}
|
|
3259
|
+
},
|
|
3246
3260
|
maxBuffer: 64 * 1024 * 1024,
|
|
3247
3261
|
timeout: options.timeoutMs
|
|
3248
3262
|
}
|
|
@@ -3554,9 +3568,9 @@ function swiftModuleToolchain(root) {
|
|
|
3554
3568
|
|
|
3555
3569
|
// src/swift-host.ts
|
|
3556
3570
|
var import_node_crypto7 = require("node:crypto");
|
|
3557
|
-
var
|
|
3571
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
3558
3572
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
3559
|
-
var
|
|
3573
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
3560
3574
|
|
|
3561
3575
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
3562
3576
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -3590,8 +3604,8 @@ function pickImagesetFile(images) {
|
|
|
3590
3604
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
3591
3605
|
};
|
|
3592
3606
|
}
|
|
3593
|
-
function flatScale(
|
|
3594
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
3607
|
+
function flatScale(path16) {
|
|
3608
|
+
const match = /@([23])x\.[^./]+$/.exec(path16);
|
|
3595
3609
|
return match ? Number(match[1]) : 1;
|
|
3596
3610
|
}
|
|
3597
3611
|
function providesNamespace(text3) {
|
|
@@ -3618,13 +3632,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
3618
3632
|
}
|
|
3619
3633
|
return segments.join("/");
|
|
3620
3634
|
}
|
|
3621
|
-
function isFlatResourceImage(
|
|
3622
|
-
return
|
|
3635
|
+
function isFlatResourceImage(path16) {
|
|
3636
|
+
return path16.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path16));
|
|
3623
3637
|
}
|
|
3624
3638
|
function enumerateBundleImages(paths, readText) {
|
|
3625
3639
|
const table = [];
|
|
3626
3640
|
const seen = /* @__PURE__ */ new Set();
|
|
3627
|
-
const catalogs = paths.filter((
|
|
3641
|
+
const catalogs = paths.filter((path16) => baseOf(path16) === "Contents.json");
|
|
3628
3642
|
for (const contentsPath of catalogs) {
|
|
3629
3643
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
3630
3644
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -3645,12 +3659,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
3645
3659
|
seen.add(name2);
|
|
3646
3660
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
3647
3661
|
}
|
|
3648
|
-
for (const
|
|
3649
|
-
if (!isFlatResourceImage(
|
|
3650
|
-
const name2 = baseOf(
|
|
3662
|
+
for (const path16 of paths) {
|
|
3663
|
+
if (!isFlatResourceImage(path16)) continue;
|
|
3664
|
+
const name2 = baseOf(path16).slice(0, -extOf(path16).length);
|
|
3651
3665
|
if (name2 === "" || seen.has(name2)) continue;
|
|
3652
3666
|
seen.add(name2);
|
|
3653
|
-
table.push({ name: name2, file:
|
|
3667
|
+
table.push({ name: name2, file: path16, scale: flatScale(path16) });
|
|
3654
3668
|
}
|
|
3655
3669
|
return table;
|
|
3656
3670
|
}
|
|
@@ -3679,7 +3693,7 @@ function colorsetValue(color) {
|
|
|
3679
3693
|
}
|
|
3680
3694
|
function enumerateBundleColors(paths, readText) {
|
|
3681
3695
|
const table = {};
|
|
3682
|
-
for (const contentsPath of paths.filter((
|
|
3696
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
3683
3697
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
3684
3698
|
if (name2 === null || name2 in table) continue;
|
|
3685
3699
|
let colors;
|
|
@@ -3744,8 +3758,8 @@ function axisExtremes(points) {
|
|
|
3744
3758
|
function pathBounds(d) {
|
|
3745
3759
|
const xs = [];
|
|
3746
3760
|
const ys = [];
|
|
3747
|
-
for (const
|
|
3748
|
-
(0, import_svgpath.default)(
|
|
3761
|
+
for (const path16 of d)
|
|
3762
|
+
(0, import_svgpath.default)(path16).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
3749
3763
|
const [command, ...args] = segment;
|
|
3750
3764
|
if (command === "M" || command === "L") {
|
|
3751
3765
|
xs.push(Number(args[0]));
|
|
@@ -3772,7 +3786,7 @@ function guide(svg, id, axis) {
|
|
|
3772
3786
|
}
|
|
3773
3787
|
function enumerateBundleSymbols(paths, readText) {
|
|
3774
3788
|
const table = {};
|
|
3775
|
-
for (const contentsPath of paths.filter((
|
|
3789
|
+
for (const contentsPath of paths.filter((path16) => baseOf(path16) === "Contents.json")) {
|
|
3776
3790
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
3777
3791
|
if (name2 === null || name2 in table) continue;
|
|
3778
3792
|
let symbols;
|
|
@@ -3805,8 +3819,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
3805
3819
|
viewBox: "0 0 24 24",
|
|
3806
3820
|
advance,
|
|
3807
3821
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
3808
|
-
layers: d.map((
|
|
3809
|
-
d: (0, import_svgpath.default)(
|
|
3822
|
+
layers: d.map((path16) => ({
|
|
3823
|
+
d: (0, import_svgpath.default)(path16).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
3810
3824
|
}))
|
|
3811
3825
|
};
|
|
3812
3826
|
}
|
|
@@ -3816,7 +3830,7 @@ function enumerateBundleJson(paths) {
|
|
|
3816
3830
|
const found = [];
|
|
3817
3831
|
const seen = /* @__PURE__ */ new Set();
|
|
3818
3832
|
const ordered = [...paths].filter(
|
|
3819
|
-
(
|
|
3833
|
+
(path16) => path16.split("/").includes("Resources") && path16.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path16) === ".json" || extOf(path16) === ".xcstrings")
|
|
3820
3834
|
).sort((a, b) => {
|
|
3821
3835
|
const aDepth = a.split("/").length;
|
|
3822
3836
|
const bDepth = b.split("/").length;
|
|
@@ -4794,15 +4808,60 @@ function resolveSwiftPackages(options) {
|
|
|
4794
4808
|
return result;
|
|
4795
4809
|
}
|
|
4796
4810
|
|
|
4811
|
+
// src/swift-source-file.ts
|
|
4812
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
4813
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
4814
|
+
function readPackageFile(root, file, maxBytes) {
|
|
4815
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
4816
|
+
const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
|
|
4817
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
|
|
4818
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4819
|
+
}
|
|
4820
|
+
let ancestor = import_node_path11.default.resolve(file);
|
|
4821
|
+
while (ancestor !== canonicalRoot) {
|
|
4822
|
+
if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4823
|
+
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4824
|
+
}
|
|
4825
|
+
const parent = import_node_path11.default.dirname(ancestor);
|
|
4826
|
+
if (parent === ancestor)
|
|
4827
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4828
|
+
ancestor = parent;
|
|
4829
|
+
}
|
|
4830
|
+
const expected = import_node_fs10.default.statSync(file);
|
|
4831
|
+
const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
|
|
4832
|
+
try {
|
|
4833
|
+
const stat = import_node_fs10.default.fstatSync(fd);
|
|
4834
|
+
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4835
|
+
throw new Error(`swift input changed while opening: ${file}`);
|
|
4836
|
+
}
|
|
4837
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
4838
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
4839
|
+
}
|
|
4840
|
+
const bytes = Buffer.alloc(stat.size + 1);
|
|
4841
|
+
let offset = 0;
|
|
4842
|
+
while (offset < bytes.length) {
|
|
4843
|
+
const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4844
|
+
if (count === 0) break;
|
|
4845
|
+
offset += count;
|
|
4846
|
+
}
|
|
4847
|
+
if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
|
|
4848
|
+
throw new Error(`swift input changed while reading: ${file}`);
|
|
4849
|
+
}
|
|
4850
|
+
return bytes.subarray(0, offset);
|
|
4851
|
+
} finally {
|
|
4852
|
+
import_node_fs10.default.closeSync(fd);
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4797
4856
|
// src/swift-standins.ts
|
|
4798
4857
|
var import_node_child_process7 = require("node:child_process");
|
|
4799
4858
|
var import_node_crypto6 = require("node:crypto");
|
|
4800
|
-
var
|
|
4859
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4801
4860
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
4802
|
-
var
|
|
4861
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4803
4862
|
|
|
4804
4863
|
// src/cli-version.ts
|
|
4805
|
-
var
|
|
4864
|
+
var import_node_fs11 = require("node:fs");
|
|
4806
4865
|
var import_node_url = require("node:url");
|
|
4807
4866
|
|
|
4808
4867
|
// src/public-brand.ts
|
|
@@ -4831,7 +4890,7 @@ function getCliVersion() {
|
|
|
4831
4890
|
];
|
|
4832
4891
|
for (const resolve2 of candidates) {
|
|
4833
4892
|
try {
|
|
4834
|
-
const version = JSON.parse((0,
|
|
4893
|
+
const version = JSON.parse((0, import_node_fs11.readFileSync)(resolve2(), "utf8")).version;
|
|
4835
4894
|
if (typeof version === "string" && version) {
|
|
4836
4895
|
cached = version;
|
|
4837
4896
|
return cached;
|
|
@@ -4901,7 +4960,7 @@ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.")
|
|
|
4901
4960
|
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
4902
4961
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
4903
4962
|
var synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
|
|
4904
|
-
var trap = (
|
|
4963
|
+
var trap = (path16) => `fatalError("${path16} is a binary framework peach cannot run")`;
|
|
4905
4964
|
function emitSwiftStandin(graphs, options) {
|
|
4906
4965
|
const skipped = [];
|
|
4907
4966
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -5038,10 +5097,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5038
5097
|
owners.push(...physical.map(() => current));
|
|
5039
5098
|
};
|
|
5040
5099
|
const scoped = (body) => (symbol, ...rest) => {
|
|
5041
|
-
const
|
|
5042
|
-
if (omit.has(
|
|
5100
|
+
const path16 = pathOf(symbol);
|
|
5101
|
+
if (omit.has(path16)) return void skipped.push({ path: path16, reason: omit.get(path16) });
|
|
5043
5102
|
const previous = current;
|
|
5044
|
-
current =
|
|
5103
|
+
current = path16;
|
|
5045
5104
|
try {
|
|
5046
5105
|
body(symbol, ...rest);
|
|
5047
5106
|
} finally {
|
|
@@ -5061,14 +5120,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5061
5120
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
5062
5121
|
const emitMember = scoped(
|
|
5063
5122
|
(member, indent, context) => {
|
|
5064
|
-
const
|
|
5123
|
+
const path16 = pathOf(member);
|
|
5065
5124
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
5066
5125
|
emitType(member, indent);
|
|
5067
5126
|
return;
|
|
5068
5127
|
}
|
|
5069
5128
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
5070
5129
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
5071
|
-
skipped.push({ path:
|
|
5130
|
+
skipped.push({ path: path16, reason: `unhandled ${member.kind.identifier}` });
|
|
5072
5131
|
return;
|
|
5073
5132
|
}
|
|
5074
5133
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -5082,12 +5141,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5082
5141
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
5083
5142
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
5084
5143
|
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
5085
|
-
const override = context.inClass && !options.plain?.has(
|
|
5144
|
+
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 " : "";
|
|
5086
5145
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
5087
|
-
const measured = behavior.get(
|
|
5088
|
-
if (measured) used.add(
|
|
5146
|
+
const measured = behavior.get(path16);
|
|
5147
|
+
if (measured) used.add(path16);
|
|
5089
5148
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
5090
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
5149
|
+
const body = overloadBody ?? measured?.body ?? trap(path16);
|
|
5091
5150
|
switch (member.kind.identifier) {
|
|
5092
5151
|
case "swift.property":
|
|
5093
5152
|
case "swift.type.property":
|
|
@@ -5108,7 +5167,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5108
5167
|
return;
|
|
5109
5168
|
}
|
|
5110
5169
|
emit(
|
|
5111
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(
|
|
5170
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path16)} }` : ""} }`
|
|
5112
5171
|
);
|
|
5113
5172
|
return;
|
|
5114
5173
|
}
|
|
@@ -5161,7 +5220,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5161
5220
|
};
|
|
5162
5221
|
const emitType = scoped(
|
|
5163
5222
|
(symbol, indent) => {
|
|
5164
|
-
const
|
|
5223
|
+
const path16 = pathOf(symbol);
|
|
5165
5224
|
const id = symbol.identifier.precise;
|
|
5166
5225
|
const inner = `${indent} `;
|
|
5167
5226
|
switch (symbol.kind.identifier) {
|
|
@@ -5173,10 +5232,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5173
5232
|
case "swift.class": {
|
|
5174
5233
|
const shape = header(symbol, "class", indent);
|
|
5175
5234
|
if (!shape)
|
|
5176
|
-
return void skipped.push({ path:
|
|
5177
|
-
const parent = options.superclasses?.get(
|
|
5235
|
+
return void skipped.push({ path: path16, reason: `unparsed class ${text(symbol)}` });
|
|
5236
|
+
const parent = options.superclasses?.get(path16) ?? superclass.get(id);
|
|
5178
5237
|
const blocked = classBlocked(id);
|
|
5179
|
-
if (blocked) return void skipped.push({ path:
|
|
5238
|
+
if (blocked) return void skipped.push({ path: path16, reason: blocked });
|
|
5180
5239
|
const ancestors = /* @__PURE__ */ new Set();
|
|
5181
5240
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5182
5241
|
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
@@ -5192,9 +5251,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5192
5251
|
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
5193
5252
|
);
|
|
5194
5253
|
const members = membersOf(id);
|
|
5195
|
-
const extra = options.behavior?.get(
|
|
5254
|
+
const extra = options.behavior?.get(path16)?.members;
|
|
5196
5255
|
if (extra) {
|
|
5197
|
-
used.add(
|
|
5256
|
+
used.add(path16);
|
|
5198
5257
|
emit(`${inner}${extra}`);
|
|
5199
5258
|
}
|
|
5200
5259
|
for (const member of members)
|
|
@@ -5247,13 +5306,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5247
5306
|
continue;
|
|
5248
5307
|
have.add(witnessKey(member));
|
|
5249
5308
|
have.add(sideLeaf(member));
|
|
5250
|
-
emitWitness(member, inner,
|
|
5309
|
+
emitWitness(member, inner, path16);
|
|
5251
5310
|
}
|
|
5252
5311
|
}
|
|
5253
5312
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
5254
5313
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
5255
5314
|
emit(
|
|
5256
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
5315
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path16}.init(coder:)`)} }`
|
|
5257
5316
|
);
|
|
5258
5317
|
emit(`${indent}}`);
|
|
5259
5318
|
return;
|
|
@@ -5261,7 +5320,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5261
5320
|
case "swift.struct": {
|
|
5262
5321
|
const shape = header(symbol, "struct", indent);
|
|
5263
5322
|
if (!shape)
|
|
5264
|
-
return void skipped.push({ path:
|
|
5323
|
+
return void skipped.push({ path: path16, reason: `unparsed struct ${text(symbol)}` });
|
|
5265
5324
|
const members = membersOf(id);
|
|
5266
5325
|
const raw2 = rawType(members);
|
|
5267
5326
|
const list2 = inheritance(id);
|
|
@@ -5312,7 +5371,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5312
5371
|
case "swift.enum": {
|
|
5313
5372
|
const shape = header(symbol, "enum", indent);
|
|
5314
5373
|
if (!shape)
|
|
5315
|
-
return void skipped.push({ path:
|
|
5374
|
+
return void skipped.push({ path: path16, reason: `unparsed enum ${text(symbol)}` });
|
|
5316
5375
|
const members = membersOf(id);
|
|
5317
5376
|
const raw2 = rawType(members);
|
|
5318
5377
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -5321,7 +5380,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5321
5380
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
5322
5381
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
5323
5382
|
return void skipped.push({
|
|
5324
|
-
path:
|
|
5383
|
+
path: path16,
|
|
5325
5384
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
5326
5385
|
});
|
|
5327
5386
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
@@ -5362,7 +5421,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5362
5421
|
const shape = header(symbol, "protocol", indent);
|
|
5363
5422
|
if (!shape)
|
|
5364
5423
|
return void skipped.push({
|
|
5365
|
-
path:
|
|
5424
|
+
path: path16,
|
|
5366
5425
|
reason: `unparsed protocol ${text(symbol)}`
|
|
5367
5426
|
});
|
|
5368
5427
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -5387,7 +5446,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5387
5446
|
}
|
|
5388
5447
|
emit(`${indent}}`);
|
|
5389
5448
|
if (defaults.length > 0) {
|
|
5390
|
-
emit(`${indent}extension ${
|
|
5449
|
+
emit(`${indent}extension ${path16} {`);
|
|
5391
5450
|
for (const member of defaults) {
|
|
5392
5451
|
const decl = text(member);
|
|
5393
5452
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -5434,7 +5493,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5434
5493
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
5435
5494
|
};
|
|
5436
5495
|
const emitGlobal = scoped((symbol) => {
|
|
5437
|
-
const
|
|
5496
|
+
const path16 = pathOf(symbol);
|
|
5438
5497
|
const kind = symbol.kind.identifier;
|
|
5439
5498
|
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
5440
5499
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
@@ -5445,17 +5504,17 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5445
5504
|
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
5446
5505
|
spelled = `${fix} ${spelled}`;
|
|
5447
5506
|
}
|
|
5448
|
-
emit(`${attrs}public ${spelled} { ${trap(
|
|
5507
|
+
emit(`${attrs}public ${spelled} { ${trap(path16)} }`);
|
|
5449
5508
|
} else if (kind === "swift.var") {
|
|
5450
5509
|
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
5451
|
-
const measured = behavior.get(
|
|
5452
|
-
if (measured) used.add(
|
|
5453
|
-
emit(`public ${parsed.decl} { ${measured?.body ?? trap(
|
|
5454
|
-
} else skipped.push({ path:
|
|
5510
|
+
const measured = behavior.get(path16);
|
|
5511
|
+
if (measured) used.add(path16);
|
|
5512
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path16)} }`);
|
|
5513
|
+
} else skipped.push({ path: path16, reason: `unhandled top-level ${kind}` });
|
|
5455
5514
|
});
|
|
5456
5515
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
5457
5516
|
for (const symbol of roots) {
|
|
5458
|
-
const
|
|
5517
|
+
const path16 = pathOf(symbol);
|
|
5459
5518
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
5460
5519
|
else emitGlobal(symbol);
|
|
5461
5520
|
}
|
|
@@ -5497,9 +5556,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5497
5556
|
...imports.map((name2) => `import ${name2}`),
|
|
5498
5557
|
""
|
|
5499
5558
|
];
|
|
5500
|
-
for (const
|
|
5501
|
-
if (!used.has(
|
|
5502
|
-
skipped.push({ path:
|
|
5559
|
+
for (const path16 of behavior.keys())
|
|
5560
|
+
if (!used.has(path16))
|
|
5561
|
+
skipped.push({ path: path16, reason: "behavior names no emitted declaration" });
|
|
5503
5562
|
return {
|
|
5504
5563
|
source: `${[...banner, ...lines].join("\n")}
|
|
5505
5564
|
`,
|
|
@@ -5574,7 +5633,7 @@ function stripDefaults(decl) {
|
|
|
5574
5633
|
|
|
5575
5634
|
// src/swift-standins.ts
|
|
5576
5635
|
var TRIPLE = "wasm32-unknown-wasip1";
|
|
5577
|
-
var cacheDir3 =
|
|
5636
|
+
var cacheDir3 = import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
5578
5637
|
function exec(file, args, cwd) {
|
|
5579
5638
|
return (0, import_node_child_process7.execFileSync)(file, args, {
|
|
5580
5639
|
cwd,
|
|
@@ -5594,15 +5653,15 @@ var digests = /* @__PURE__ */ new Map();
|
|
|
5594
5653
|
function treeDigest(root) {
|
|
5595
5654
|
const names = [];
|
|
5596
5655
|
const walk2 = (dir) => {
|
|
5597
|
-
for (const entry of
|
|
5598
|
-
const full =
|
|
5656
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
5657
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
5599
5658
|
if (entry.isDirectory()) walk2(full);
|
|
5600
|
-
else if (entry.isFile()) names.push(
|
|
5659
|
+
else if (entry.isFile()) names.push(import_node_path12.default.relative(root, full));
|
|
5601
5660
|
}
|
|
5602
5661
|
};
|
|
5603
5662
|
walk2(root);
|
|
5604
5663
|
const stamp = names.map((name2) => {
|
|
5605
|
-
const stat =
|
|
5664
|
+
const stat = import_node_fs12.default.statSync(import_node_path12.default.join(root, name2));
|
|
5606
5665
|
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
5607
5666
|
}).join("\n");
|
|
5608
5667
|
const memo2 = digests.get(`tree\0${root}`);
|
|
@@ -5610,7 +5669,7 @@ function treeDigest(root) {
|
|
|
5610
5669
|
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
5611
5670
|
for (const name2 of names) {
|
|
5612
5671
|
hash.update(`${name2}\0`);
|
|
5613
|
-
hash.update(
|
|
5672
|
+
hash.update(import_node_fs12.default.readFileSync(import_node_path12.default.join(root, name2)));
|
|
5614
5673
|
hash.update("\0");
|
|
5615
5674
|
}
|
|
5616
5675
|
const digest = hash.digest("hex");
|
|
@@ -5619,9 +5678,9 @@ function treeDigest(root) {
|
|
|
5619
5678
|
}
|
|
5620
5679
|
function locateXcframework(tree) {
|
|
5621
5680
|
const find = (root, depth) => {
|
|
5622
|
-
for (const entry of
|
|
5681
|
+
for (const entry of import_node_fs12.default.readdirSync(root, { withFileTypes: true })) {
|
|
5623
5682
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
5624
|
-
const full =
|
|
5683
|
+
const full = import_node_path12.default.join(root, entry.name);
|
|
5625
5684
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
5626
5685
|
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
5627
5686
|
if (nested) return nested;
|
|
@@ -5636,67 +5695,67 @@ function xcframework(binary) {
|
|
|
5636
5695
|
if (binary.url && (!binary.checksum || !/^[a-f0-9]{64}$/i.test(binary.checksum)))
|
|
5637
5696
|
throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
|
|
5638
5697
|
const expected = binary.checksum?.toLowerCase();
|
|
5639
|
-
const dir =
|
|
5640
|
-
const archive =
|
|
5641
|
-
const fingerprint =
|
|
5698
|
+
const dir = import_node_path12.default.join(cacheDir3, "archives", key(binary.url ? expected : binary.dir));
|
|
5699
|
+
const archive = import_node_path12.default.join(dir, "archive.zip");
|
|
5700
|
+
const fingerprint = import_node_path12.default.join(dir, ".fingerprint");
|
|
5642
5701
|
const stored = (() => {
|
|
5643
5702
|
try {
|
|
5644
|
-
const parsed = JSON.parse(
|
|
5703
|
+
const parsed = JSON.parse(import_node_fs12.default.readFileSync(fingerprint, "utf8"));
|
|
5645
5704
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
5646
5705
|
} catch {
|
|
5647
5706
|
return null;
|
|
5648
5707
|
}
|
|
5649
5708
|
})();
|
|
5650
5709
|
if (!binary.url) {
|
|
5651
|
-
const stat =
|
|
5710
|
+
const stat = import_node_fs12.default.statSync(binary.dir);
|
|
5652
5711
|
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
5653
5712
|
if (stored?.stamp === stamp) {
|
|
5654
|
-
const found3 = locateXcframework(
|
|
5713
|
+
const found3 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5655
5714
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
5656
5715
|
}
|
|
5657
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5658
|
-
if (sha2 !== stored?.sha || !locateXcframework(
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
exec("unzip", ["-q", binary.dir, "-d",
|
|
5716
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(binary.dir)).digest("hex");
|
|
5717
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path12.default.join(dir, "tree"))) {
|
|
5718
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5719
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5720
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5662
5721
|
}
|
|
5663
|
-
|
|
5664
|
-
const found2 = locateXcframework(
|
|
5722
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
5723
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5665
5724
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
5666
5725
|
return { dir: found2, digest: sha2 };
|
|
5667
5726
|
}
|
|
5668
|
-
if (stored &&
|
|
5669
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5727
|
+
if (stored && import_node_fs12.default.existsSync(archive)) {
|
|
5728
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5670
5729
|
if (sha2 !== expected)
|
|
5671
5730
|
throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
|
|
5672
|
-
const found2 = locateXcframework(
|
|
5731
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5673
5732
|
if (found2) return { dir: found2, digest: sha2 };
|
|
5674
5733
|
}
|
|
5675
|
-
|
|
5676
|
-
|
|
5734
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5735
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5677
5736
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
5678
|
-
const sha = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5737
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5679
5738
|
if (sha !== expected) {
|
|
5680
|
-
|
|
5739
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5681
5740
|
throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
|
|
5682
5741
|
}
|
|
5683
|
-
exec("unzip", ["-q", archive, "-d",
|
|
5684
|
-
|
|
5685
|
-
const found = locateXcframework(
|
|
5742
|
+
exec("unzip", ["-q", archive, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5743
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
5744
|
+
const found = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5686
5745
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
5687
5746
|
return { dir: found, digest: sha };
|
|
5688
5747
|
}
|
|
5689
|
-
var files = (dir, test) =>
|
|
5748
|
+
var 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() : [];
|
|
5690
5749
|
function surfaces(xcframeworkDir) {
|
|
5691
|
-
const slice =
|
|
5750
|
+
const slice = import_node_fs12.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
5692
5751
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
5693
|
-
const root =
|
|
5752
|
+
const root = import_node_path12.default.join(xcframeworkDir, slice);
|
|
5694
5753
|
const found = [];
|
|
5695
|
-
for (const entry of
|
|
5754
|
+
for (const entry of import_node_fs12.default.readdirSync(root).sort()) {
|
|
5696
5755
|
if (!entry.endsWith(".framework")) continue;
|
|
5697
5756
|
const module2 = entry.slice(0, -".framework".length);
|
|
5698
|
-
const framework =
|
|
5699
|
-
const swiftmodule =
|
|
5757
|
+
const framework = import_node_path12.default.join(root, entry);
|
|
5758
|
+
const swiftmodule = import_node_path12.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
5700
5759
|
const interfaces = files(
|
|
5701
5760
|
swiftmodule,
|
|
5702
5761
|
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
@@ -5706,41 +5765,41 @@ function surfaces(xcframeworkDir) {
|
|
|
5706
5765
|
found.push({
|
|
5707
5766
|
kind: "swift",
|
|
5708
5767
|
module: module2,
|
|
5709
|
-
interface:
|
|
5768
|
+
interface: import_node_path12.default.join(swiftmodule, chosen)
|
|
5710
5769
|
});
|
|
5711
5770
|
continue;
|
|
5712
5771
|
}
|
|
5713
|
-
const modulemap =
|
|
5714
|
-
if (
|
|
5772
|
+
const modulemap = import_node_path12.default.join(framework, "Modules", "module.modulemap");
|
|
5773
|
+
if (import_node_fs12.default.existsSync(modulemap))
|
|
5715
5774
|
found.push({
|
|
5716
5775
|
kind: "c",
|
|
5717
5776
|
module: module2,
|
|
5718
5777
|
modulemap,
|
|
5719
|
-
headers:
|
|
5778
|
+
headers: import_node_path12.default.join(framework, "Headers")
|
|
5720
5779
|
});
|
|
5721
5780
|
}
|
|
5722
|
-
const headers =
|
|
5781
|
+
const headers = import_node_path12.default.join(root, "Headers");
|
|
5723
5782
|
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
5724
|
-
const modulemap =
|
|
5725
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
5783
|
+
const modulemap = import_node_path12.default.join(headers, map);
|
|
5784
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs12.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
5726
5785
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
5727
5786
|
}
|
|
5728
5787
|
return found;
|
|
5729
5788
|
}
|
|
5730
5789
|
function peachModuleDirs(toolchain, imports) {
|
|
5731
5790
|
const { moduleRoot, toolchainBin } = toolchain;
|
|
5732
|
-
if (swiftDistributionAt(moduleRoot)) return [
|
|
5791
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path12.default.join(moduleRoot, "modules")];
|
|
5733
5792
|
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
5734
5793
|
const plugins = swiftMacroPlugins(moduleRoot);
|
|
5735
5794
|
if (plugins.stale)
|
|
5736
5795
|
exec("sh", [
|
|
5737
|
-
|
|
5796
|
+
import_node_path12.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
5738
5797
|
toolchainBin,
|
|
5739
5798
|
plugins.libraries[0]
|
|
5740
5799
|
]);
|
|
5741
5800
|
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
5742
5801
|
exec(
|
|
5743
|
-
|
|
5802
|
+
import_node_path12.default.join(toolchainBin, "swift"),
|
|
5744
5803
|
[
|
|
5745
5804
|
"build",
|
|
5746
5805
|
"--swift-sdk",
|
|
@@ -5760,7 +5819,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
5760
5819
|
],
|
|
5761
5820
|
moduleRoot
|
|
5762
5821
|
);
|
|
5763
|
-
return [
|
|
5822
|
+
return [import_node_path12.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
5764
5823
|
}
|
|
5765
5824
|
function swiftInterfaceForWasm(text3) {
|
|
5766
5825
|
return text3.replace(
|
|
@@ -5772,11 +5831,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
5772
5831
|
);
|
|
5773
5832
|
}
|
|
5774
5833
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
5775
|
-
const text3 = swiftInterfaceForWasm(
|
|
5776
|
-
const search =
|
|
5777
|
-
const moduleDir =
|
|
5778
|
-
|
|
5779
|
-
|
|
5834
|
+
const text3 = swiftInterfaceForWasm(import_node_fs12.default.readFileSync(surface.interface, "utf8"));
|
|
5835
|
+
const search = import_node_path12.default.join(work, "interfaces");
|
|
5836
|
+
const moduleDir = import_node_path12.default.join(search, `${surface.module}.swiftmodule`);
|
|
5837
|
+
import_node_fs12.default.mkdirSync(moduleDir, { recursive: true });
|
|
5838
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
5780
5839
|
const imports = [
|
|
5781
5840
|
...text3.matchAll(
|
|
5782
5841
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -5788,9 +5847,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5788
5847
|
);
|
|
5789
5848
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
5790
5849
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
5791
|
-
const out =
|
|
5792
|
-
|
|
5793
|
-
exec(
|
|
5850
|
+
const out = import_node_path12.default.join(work, "graphs");
|
|
5851
|
+
import_node_fs12.default.mkdirSync(out, { recursive: true });
|
|
5852
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
5794
5853
|
"-module-name",
|
|
5795
5854
|
surface.module,
|
|
5796
5855
|
...target,
|
|
@@ -5804,10 +5863,10 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5804
5863
|
"-output-dir",
|
|
5805
5864
|
out
|
|
5806
5865
|
]);
|
|
5807
|
-
const graphs =
|
|
5866
|
+
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")));
|
|
5808
5867
|
const omit = /* @__PURE__ */ new Map();
|
|
5809
5868
|
const plain = /* @__PURE__ */ new Set();
|
|
5810
|
-
const file =
|
|
5869
|
+
const file = import_node_path12.default.join(work, `${surface.module}.swift`);
|
|
5811
5870
|
for (; ; ) {
|
|
5812
5871
|
const { source, owners } = emitSwiftStandin(graphs, {
|
|
5813
5872
|
module: surface.module,
|
|
@@ -5815,9 +5874,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5815
5874
|
omit,
|
|
5816
5875
|
plain
|
|
5817
5876
|
});
|
|
5818
|
-
|
|
5877
|
+
import_node_fs12.default.writeFileSync(file, source);
|
|
5819
5878
|
const check = (0, import_node_child_process7.spawnSync)(
|
|
5820
|
-
|
|
5879
|
+
import_node_path12.default.join(toolchain.toolchainBin, "swiftc"),
|
|
5821
5880
|
[
|
|
5822
5881
|
"-typecheck",
|
|
5823
5882
|
"-parse-as-library",
|
|
@@ -5967,21 +6026,21 @@ function splitDeclarators(statement, names) {
|
|
|
5967
6026
|
}
|
|
5968
6027
|
function cStandin(surface, binary, toolchain, work) {
|
|
5969
6028
|
const named = [
|
|
5970
|
-
...
|
|
6029
|
+
...import_node_fs12.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
5971
6030
|
].map((match) => match[1]);
|
|
5972
6031
|
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
5973
6032
|
const texts = new Map(
|
|
5974
6033
|
headers.map((file) => [
|
|
5975
6034
|
file,
|
|
5976
|
-
|
|
6035
|
+
import_node_fs12.default.readFileSync(import_node_path12.default.join(surface.headers, file), "utf8")
|
|
5977
6036
|
])
|
|
5978
6037
|
);
|
|
5979
6038
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
5980
6039
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
5981
|
-
const include =
|
|
6040
|
+
const include = import_node_path12.default.join(work, "include");
|
|
5982
6041
|
for (const [file, text3] of texts) {
|
|
5983
|
-
|
|
5984
|
-
|
|
6042
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(import_node_path12.default.join(include, file)), { recursive: true });
|
|
6043
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(include, file), text3);
|
|
5985
6044
|
}
|
|
5986
6045
|
const roots = named.length > 0 ? named : headers;
|
|
5987
6046
|
const modulemap = `module ${surface.module} {
|
|
@@ -5989,12 +6048,12 @@ ${roots.map((file) => ` header "${file}"
|
|
|
5989
6048
|
`).join("")} export *
|
|
5990
6049
|
}
|
|
5991
6050
|
`;
|
|
5992
|
-
const probe =
|
|
5993
|
-
|
|
6051
|
+
const probe = import_node_path12.default.join(work, "declarations.c");
|
|
6052
|
+
import_node_fs12.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
5994
6053
|
`).join(""));
|
|
5995
6054
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
5996
6055
|
const ast = JSON.parse(
|
|
5997
|
-
exec(
|
|
6056
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
5998
6057
|
"-target",
|
|
5999
6058
|
TRIPLE,
|
|
6000
6059
|
"--sysroot",
|
|
@@ -6007,7 +6066,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
6007
6066
|
probe
|
|
6008
6067
|
])
|
|
6009
6068
|
);
|
|
6010
|
-
const byPath = new Map(headers.map((file) => [
|
|
6069
|
+
const byPath = new Map(headers.map((file) => [import_node_path12.default.join(include, file), file]));
|
|
6011
6070
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
6012
6071
|
const groups = /* @__PURE__ */ new Map();
|
|
6013
6072
|
for (const declaration of declarations) {
|
|
@@ -6054,10 +6113,10 @@ ${roots.map((file) => ` header "${file}"
|
|
|
6054
6113
|
"",
|
|
6055
6114
|
...definitions
|
|
6056
6115
|
].join("\n");
|
|
6057
|
-
const out =
|
|
6058
|
-
|
|
6116
|
+
const out = import_node_path12.default.join(work, `${surface.module}.c`);
|
|
6117
|
+
import_node_fs12.default.writeFileSync(out, source);
|
|
6059
6118
|
try {
|
|
6060
|
-
exec(
|
|
6119
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
6061
6120
|
"-target",
|
|
6062
6121
|
TRIPLE,
|
|
6063
6122
|
"--sysroot",
|
|
@@ -6139,25 +6198,25 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6139
6198
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
6140
6199
|
surface.modulemap,
|
|
6141
6200
|
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
6142
|
-
(file2) =>
|
|
6201
|
+
(file2) => import_node_path12.default.join(surface.headers, file2)
|
|
6143
6202
|
)
|
|
6144
6203
|
])
|
|
6145
|
-
hash.update(
|
|
6204
|
+
hash.update(import_node_fs12.default.readFileSync(file));
|
|
6146
6205
|
}
|
|
6147
6206
|
const id = hash.digest("hex").slice(0, 32);
|
|
6148
6207
|
const memo2 = built.get(id);
|
|
6149
6208
|
if (memo2) return memo2;
|
|
6150
|
-
const cached2 =
|
|
6151
|
-
if (
|
|
6152
|
-
const value = JSON.parse(
|
|
6209
|
+
const cached2 = import_node_path12.default.join(cacheDir3, "standins", `${id}.json`);
|
|
6210
|
+
if (import_node_fs12.default.existsSync(cached2)) {
|
|
6211
|
+
const value = JSON.parse(import_node_fs12.default.readFileSync(cached2, "utf8"));
|
|
6153
6212
|
built.set(id, value);
|
|
6154
6213
|
return value;
|
|
6155
6214
|
}
|
|
6156
|
-
const work =
|
|
6215
|
+
const work = import_node_fs12.default.mkdtempSync(import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
6157
6216
|
let result;
|
|
6158
6217
|
try {
|
|
6159
6218
|
result = found.map((surface) => {
|
|
6160
|
-
const dir =
|
|
6219
|
+
const dir = import_node_path12.default.join(work, surface.module);
|
|
6161
6220
|
try {
|
|
6162
6221
|
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
6163
6222
|
} catch (error) {
|
|
@@ -6166,13 +6225,13 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6166
6225
|
);
|
|
6167
6226
|
}
|
|
6168
6227
|
});
|
|
6169
|
-
|
|
6170
|
-
|
|
6228
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(cached2), { recursive: true });
|
|
6229
|
+
import_node_fs12.default.writeFileSync(cached2, JSON.stringify(result));
|
|
6171
6230
|
built.set(id, result);
|
|
6172
6231
|
} catch (error) {
|
|
6173
6232
|
result = error instanceof Error ? error.message : String(error);
|
|
6174
6233
|
} finally {
|
|
6175
|
-
|
|
6234
|
+
import_node_fs12.default.rmSync(work, { recursive: true, force: true });
|
|
6176
6235
|
}
|
|
6177
6236
|
return result;
|
|
6178
6237
|
}
|
|
@@ -6314,12 +6373,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
6314
6373
|
}
|
|
6315
6374
|
|
|
6316
6375
|
// src/xcode-project.ts
|
|
6317
|
-
var
|
|
6318
|
-
var
|
|
6376
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
6377
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
6319
6378
|
var import_plist = __toESM(require_plist(), 1);
|
|
6320
6379
|
|
|
6321
6380
|
// src/xcode-json-project.ts
|
|
6322
|
-
var
|
|
6381
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
6323
6382
|
var import_json5 = __toESM(require_lib(), 1);
|
|
6324
6383
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6325
6384
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -6335,7 +6394,7 @@ var PHASE_ISA = {
|
|
|
6335
6394
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
6336
6395
|
const json = import_json5.default.parse(source);
|
|
6337
6396
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
6338
|
-
const projectDir =
|
|
6397
|
+
const projectDir = import_node_path13.default.dirname(xcodeproj);
|
|
6339
6398
|
const objects = {};
|
|
6340
6399
|
let next = 0;
|
|
6341
6400
|
const add = (entry, id) => {
|
|
@@ -6348,7 +6407,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6348
6407
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
6349
6408
|
if (base) {
|
|
6350
6409
|
if (base[1] === "PROJECT")
|
|
6351
|
-
return { sourceTree: "<absolute>", path:
|
|
6410
|
+
return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
|
|
6352
6411
|
if (base[1] === "PRODUCTS")
|
|
6353
6412
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
6354
6413
|
return null;
|
|
@@ -6356,7 +6415,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6356
6415
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
6357
6416
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
6358
6417
|
if (unescaped.startsWith("~")) return null;
|
|
6359
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
6418
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
|
|
6360
6419
|
};
|
|
6361
6420
|
const memberships = [];
|
|
6362
6421
|
const folders = [];
|
|
@@ -6367,7 +6426,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6367
6426
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
6368
6427
|
const raw2 = text2(entry.path) ?? "";
|
|
6369
6428
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
6370
|
-
const name2 = text2(entry.name) ??
|
|
6429
|
+
const name2 = text2(entry.name) ?? import_node_path13.default.basename(raw2);
|
|
6371
6430
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
6372
6431
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
6373
6432
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -6482,7 +6541,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6482
6541
|
if (!isObject(entry)) continue;
|
|
6483
6542
|
const repository = text2(entry.repository);
|
|
6484
6543
|
const local = text2(entry.path);
|
|
6485
|
-
const name2 = local !== void 0 ?
|
|
6544
|
+
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$/, "");
|
|
6486
6545
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
6487
6546
|
packageIds.set(name2.toLowerCase(), id);
|
|
6488
6547
|
}
|
|
@@ -6759,28 +6818,28 @@ var CONDITIONS = {
|
|
|
6759
6818
|
variant: "normal"
|
|
6760
6819
|
};
|
|
6761
6820
|
function walkFiles(dir) {
|
|
6762
|
-
if (!
|
|
6821
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
6763
6822
|
const out = [];
|
|
6764
|
-
for (const entry of
|
|
6823
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6765
6824
|
if (entry.name.startsWith(".")) continue;
|
|
6766
|
-
const full =
|
|
6825
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
6767
6826
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
6768
6827
|
else if (entry.isFile()) out.push(full);
|
|
6769
6828
|
}
|
|
6770
6829
|
return out;
|
|
6771
6830
|
}
|
|
6772
|
-
var isDirectory = (dir) =>
|
|
6831
|
+
var isDirectory = (dir) => import_node_fs13.default.existsSync(dir) && import_node_fs13.default.statSync(dir).isDirectory();
|
|
6773
6832
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
6774
|
-
if (seen.has(file) || !
|
|
6833
|
+
if (seen.has(file) || !import_node_fs13.default.existsSync(file)) return {};
|
|
6775
6834
|
seen.add(file);
|
|
6776
6835
|
const settings = {};
|
|
6777
|
-
for (const raw2 of
|
|
6836
|
+
for (const raw2 of import_node_fs13.default.readFileSync(file, "utf8").split("\n")) {
|
|
6778
6837
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
6779
6838
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
6780
6839
|
if (include) {
|
|
6781
6840
|
Object.assign(
|
|
6782
6841
|
settings,
|
|
6783
|
-
readXcconfig(
|
|
6842
|
+
readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), seen)
|
|
6784
6843
|
);
|
|
6785
6844
|
continue;
|
|
6786
6845
|
}
|
|
@@ -6830,22 +6889,22 @@ function decodeXml(text3) {
|
|
|
6830
6889
|
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
6831
6890
|
}
|
|
6832
6891
|
function workspaceReferences(workspace) {
|
|
6833
|
-
const data =
|
|
6834
|
-
if (!
|
|
6892
|
+
const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
|
|
6893
|
+
if (!import_node_fs13.default.existsSync(data))
|
|
6835
6894
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
6836
|
-
const container =
|
|
6895
|
+
const container = import_node_path14.default.dirname(workspace);
|
|
6837
6896
|
const locate = (location, base) => {
|
|
6838
6897
|
const colon = location.indexOf(":");
|
|
6839
6898
|
const kind = location.slice(0, colon);
|
|
6840
6899
|
const rest = location.slice(colon + 1);
|
|
6841
|
-
if (kind === "group") return
|
|
6842
|
-
if (kind === "container" || kind === "self") return
|
|
6843
|
-
if (kind === "absolute") return
|
|
6844
|
-
throw new Error(`${
|
|
6900
|
+
if (kind === "group") return import_node_path14.default.resolve(base, rest);
|
|
6901
|
+
if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
|
|
6902
|
+
if (kind === "absolute") return import_node_path14.default.resolve(rest);
|
|
6903
|
+
throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
|
|
6845
6904
|
};
|
|
6846
6905
|
const groups = [container];
|
|
6847
6906
|
const references = [];
|
|
6848
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
6907
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs13.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
6849
6908
|
if (closing) {
|
|
6850
6909
|
if (tag === "Group") groups.pop();
|
|
6851
6910
|
continue;
|
|
@@ -6861,8 +6920,8 @@ function workspaceReferences(workspace) {
|
|
|
6861
6920
|
var loaded = /* @__PURE__ */ new Map();
|
|
6862
6921
|
function xcodeProjectFile(xcodeproj) {
|
|
6863
6922
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
6864
|
-
const file =
|
|
6865
|
-
if (
|
|
6923
|
+
const file = import_node_path14.default.join(xcodeproj, name2);
|
|
6924
|
+
if (import_node_fs13.default.existsSync(file)) return file;
|
|
6866
6925
|
}
|
|
6867
6926
|
return null;
|
|
6868
6927
|
}
|
|
@@ -6870,10 +6929,10 @@ function loadProject(xcodeproj) {
|
|
|
6870
6929
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
6871
6930
|
if (!projectFile)
|
|
6872
6931
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
6873
|
-
const mtimeMs =
|
|
6932
|
+
const mtimeMs = import_node_fs13.default.statSync(projectFile).mtimeMs;
|
|
6874
6933
|
const cached2 = loaded.get(projectFile);
|
|
6875
6934
|
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
6876
|
-
const source =
|
|
6935
|
+
const source = import_node_fs13.default.readFileSync(projectFile, "utf8");
|
|
6877
6936
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
6878
6937
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
6879
6938
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -6887,8 +6946,8 @@ function loadProject(xcodeproj) {
|
|
|
6887
6946
|
if (!project || project.isa !== "PBXProject") {
|
|
6888
6947
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
6889
6948
|
}
|
|
6890
|
-
const projectDir =
|
|
6891
|
-
|
|
6949
|
+
const projectDir = import_node_fs13.default.realpathSync(
|
|
6950
|
+
import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
6892
6951
|
);
|
|
6893
6952
|
const parent = /* @__PURE__ */ new Map();
|
|
6894
6953
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -6906,11 +6965,11 @@ function loadProject(xcodeproj) {
|
|
|
6906
6965
|
const own = str(entry.path) ?? "";
|
|
6907
6966
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
6908
6967
|
if (tree === "<absolute>") result2 = own;
|
|
6909
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
6968
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path14.default.join(projectDir, own);
|
|
6910
6969
|
else if (tree === "<group>") {
|
|
6911
6970
|
const up = parent.get(id);
|
|
6912
6971
|
const base = up ? resolvePath(up) : projectDir;
|
|
6913
|
-
result2 = base === null ? null :
|
|
6972
|
+
result2 = base === null ? null : import_node_path14.default.join(base, own);
|
|
6914
6973
|
}
|
|
6915
6974
|
}
|
|
6916
6975
|
resolvedPaths.set(id, result2);
|
|
@@ -7010,7 +7069,7 @@ function targetMembers(ref) {
|
|
|
7010
7069
|
const addResource = (file) => {
|
|
7011
7070
|
if (isDirectory(file)) {
|
|
7012
7071
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
7013
|
-
} else if (
|
|
7072
|
+
} else if (import_node_fs13.default.existsSync(file)) resources.add(file);
|
|
7014
7073
|
};
|
|
7015
7074
|
const fileRefPaths = (refId) => {
|
|
7016
7075
|
const entry = project.object(refId);
|
|
@@ -7031,7 +7090,7 @@ function targetMembers(ref) {
|
|
|
7031
7090
|
for (const buildFileId of list(phase.files)) {
|
|
7032
7091
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
7033
7092
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
7034
|
-
if (!
|
|
7093
|
+
if (!import_node_fs13.default.existsSync(file)) continue;
|
|
7035
7094
|
allSources.add(file);
|
|
7036
7095
|
if (file.endsWith(".swift")) sources.add(file);
|
|
7037
7096
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -7039,7 +7098,7 @@ function targetMembers(ref) {
|
|
|
7039
7098
|
}
|
|
7040
7099
|
}
|
|
7041
7100
|
const addSynchronized = (folder, relative) => {
|
|
7042
|
-
const file =
|
|
7101
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7043
7102
|
if (NEVER_MEMBER.test(relative)) return;
|
|
7044
7103
|
if (file.endsWith(".swift")) {
|
|
7045
7104
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -7064,7 +7123,7 @@ function targetMembers(ref) {
|
|
|
7064
7123
|
}
|
|
7065
7124
|
if (owned.has(groupId)) {
|
|
7066
7125
|
for (const file of walkFiles(folder)) {
|
|
7067
|
-
const relative =
|
|
7126
|
+
const relative = import_node_path14.default.relative(folder, file).split(import_node_path14.default.sep).join("/");
|
|
7068
7127
|
if ([...exceptions].some(
|
|
7069
7128
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
7070
7129
|
))
|
|
@@ -7073,14 +7132,14 @@ function targetMembers(ref) {
|
|
|
7073
7132
|
}
|
|
7074
7133
|
} else {
|
|
7075
7134
|
for (const relative of exceptions) {
|
|
7076
|
-
const file =
|
|
7135
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7077
7136
|
if (isDirectory(file)) {
|
|
7078
7137
|
for (const inner of walkFiles(file))
|
|
7079
7138
|
addSynchronized(
|
|
7080
7139
|
folder,
|
|
7081
|
-
|
|
7140
|
+
import_node_path14.default.relative(folder, inner).split(import_node_path14.default.sep).join("/")
|
|
7082
7141
|
);
|
|
7083
|
-
} else if (
|
|
7142
|
+
} else if (import_node_fs13.default.existsSync(file)) addSynchronized(folder, relative);
|
|
7084
7143
|
}
|
|
7085
7144
|
}
|
|
7086
7145
|
}
|
|
@@ -7093,8 +7152,8 @@ function targetMembers(ref) {
|
|
|
7093
7152
|
function commonAncestor(dirs) {
|
|
7094
7153
|
let common = dirs[0];
|
|
7095
7154
|
for (const dir of dirs) {
|
|
7096
|
-
while (common !==
|
|
7097
|
-
common =
|
|
7155
|
+
while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
|
|
7156
|
+
common = import_node_path14.default.dirname(common);
|
|
7098
7157
|
}
|
|
7099
7158
|
return common;
|
|
7100
7159
|
}
|
|
@@ -7103,8 +7162,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7103
7162
|
const projects2 = [];
|
|
7104
7163
|
const projectAt = /* @__PURE__ */ new Map();
|
|
7105
7164
|
const addProject = (xcodeproj) => {
|
|
7106
|
-
const key2 =
|
|
7107
|
-
if (projectAt.has(key2) || key2.split(
|
|
7165
|
+
const key2 = import_node_path14.default.resolve(xcodeproj);
|
|
7166
|
+
if (projectAt.has(key2) || key2.split(import_node_path14.default.sep).includes("Pods")) return;
|
|
7108
7167
|
if (!xcodeProjectFile(key2)) return;
|
|
7109
7168
|
const project = loadProject(key2);
|
|
7110
7169
|
projectAt.set(key2, project);
|
|
@@ -7121,7 +7180,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7121
7180
|
for (const reference of listed)
|
|
7122
7181
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
7123
7182
|
if (projects2.length === 0) {
|
|
7124
|
-
throw new Error(`${
|
|
7183
|
+
throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
7125
7184
|
}
|
|
7126
7185
|
return { listed, projects: projects2, projectAt };
|
|
7127
7186
|
}
|
|
@@ -7143,7 +7202,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7143
7202
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
7144
7203
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
7145
7204
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
7146
|
-
const container =
|
|
7205
|
+
const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
|
|
7147
7206
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
7148
7207
|
if (named.length !== 1) {
|
|
7149
7208
|
throw new Error(
|
|
@@ -7155,14 +7214,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7155
7214
|
for (const ref of allTargets) {
|
|
7156
7215
|
const product = ref.project.object(str(ref.target.productReference));
|
|
7157
7216
|
const file = str(product?.path);
|
|
7158
|
-
if (file && !byProduct.has(
|
|
7159
|
-
byProduct.set(
|
|
7217
|
+
if (file && !byProduct.has(import_node_path14.default.basename(file)))
|
|
7218
|
+
byProduct.set(import_node_path14.default.basename(file), ref);
|
|
7160
7219
|
}
|
|
7161
7220
|
const proxied = (project, proxyId) => {
|
|
7162
7221
|
const proxy = project.object(proxyId);
|
|
7163
7222
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
7164
7223
|
const portal = str(proxy.containerPortal);
|
|
7165
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
7224
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path14.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
7166
7225
|
const remote = str(proxy.remoteGlobalIDString);
|
|
7167
7226
|
if (!owner || !remote) return void 0;
|
|
7168
7227
|
return nativeTargets(owner).find(
|
|
@@ -7183,7 +7242,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7183
7242
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
7184
7243
|
for (const buildFileId of list(phase.files)) {
|
|
7185
7244
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
7186
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
7245
|
+
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;
|
|
7187
7246
|
if (resolved) found.push(resolved);
|
|
7188
7247
|
}
|
|
7189
7248
|
}
|
|
@@ -7204,7 +7263,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7204
7263
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
7205
7264
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
7206
7265
|
TARGET_NAME: name2,
|
|
7207
|
-
PROJECT_NAME:
|
|
7266
|
+
PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
7208
7267
|
SRCROOT: ref.project.projectDir,
|
|
7209
7268
|
SOURCE_ROOT: ref.project.projectDir,
|
|
7210
7269
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -7235,8 +7294,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7235
7294
|
}
|
|
7236
7295
|
return value;
|
|
7237
7296
|
};
|
|
7238
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
7239
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
7297
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
7298
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs13.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
7240
7299
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
7241
7300
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
7242
7301
|
}
|
|
@@ -7254,12 +7313,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7254
7313
|
};
|
|
7255
7314
|
}
|
|
7256
7315
|
const localPackageDirs = [
|
|
7257
|
-
...listed.filter((reference) =>
|
|
7316
|
+
...listed.filter((reference) => import_node_fs13.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
|
|
7258
7317
|
...projects2.flatMap(
|
|
7259
7318
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
7260
7319
|
if (!isDict(entry)) return [];
|
|
7261
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
7262
|
-
return candidate &&
|
|
7320
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
7321
|
+
return candidate && import_node_fs13.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
7263
7322
|
})
|
|
7264
7323
|
)
|
|
7265
7324
|
];
|
|
@@ -7283,7 +7342,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7283
7342
|
product,
|
|
7284
7343
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
7285
7344
|
kind: "local",
|
|
7286
|
-
dir:
|
|
7345
|
+
dir: import_node_path14.default.resolve(
|
|
7287
7346
|
project.projectDir,
|
|
7288
7347
|
str(reference.relativePath) ?? ""
|
|
7289
7348
|
)
|
|
@@ -7305,8 +7364,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7305
7364
|
}
|
|
7306
7365
|
}
|
|
7307
7366
|
}
|
|
7308
|
-
const resolvedFile =
|
|
7309
|
-
workspace ??
|
|
7367
|
+
const resolvedFile = import_node_path14.default.join(
|
|
7368
|
+
workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
7310
7369
|
"xcshareddata",
|
|
7311
7370
|
"swiftpm",
|
|
7312
7371
|
"Package.resolved"
|
|
@@ -7316,13 +7375,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7316
7375
|
...module2,
|
|
7317
7376
|
rootDir: commonAncestor(
|
|
7318
7377
|
[
|
|
7319
|
-
workspace ?
|
|
7378
|
+
workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
|
|
7320
7379
|
...used.map((project) => project.projectDir),
|
|
7321
7380
|
...localPackageDirs,
|
|
7322
7381
|
...linkedProducts.flatMap(
|
|
7323
|
-
({ source }) => source.kind === "local" &&
|
|
7382
|
+
({ source }) => source.kind === "local" && import_node_fs13.default.existsSync(source.dir) ? [source.dir] : []
|
|
7324
7383
|
)
|
|
7325
|
-
].map((dir) =>
|
|
7384
|
+
].map((dir) => import_node_fs13.default.realpathSync(dir))
|
|
7326
7385
|
),
|
|
7327
7386
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
7328
7387
|
infoPlist: import_plist.default.build(info),
|
|
@@ -7330,10 +7389,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7330
7389
|
frameworks,
|
|
7331
7390
|
linkedProducts,
|
|
7332
7391
|
localPackageDirs: [
|
|
7333
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7392
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs13.default.realpathSync(dir)))
|
|
7334
7393
|
].sort(),
|
|
7335
7394
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
7336
|
-
packageResolved:
|
|
7395
|
+
packageResolved: import_node_fs13.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
7337
7396
|
appTargets: appTargetNames
|
|
7338
7397
|
};
|
|
7339
7398
|
}
|
|
@@ -7352,17 +7411,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
7352
7411
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
7353
7412
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
7354
7413
|
function swiftPackageId(packagePath) {
|
|
7355
|
-
return
|
|
7414
|
+
return import_node_path15.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
7356
7415
|
}
|
|
7357
7416
|
function nativeSourceDescriptor(packagePath) {
|
|
7358
|
-
packagePath =
|
|
7359
|
-
const file =
|
|
7360
|
-
if (!
|
|
7417
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7418
|
+
const file = import_node_path15.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
7419
|
+
if (!import_node_fs14.default.existsSync(file)) return null;
|
|
7361
7420
|
const value = JSON.parse(
|
|
7362
7421
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
7363
7422
|
);
|
|
7364
7423
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
7365
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
7424
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs14.default.existsSync(import_node_path15.default.join(packagePath, NATIVE_GLUE))) {
|
|
7366
7425
|
throw invalid();
|
|
7367
7426
|
}
|
|
7368
7427
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -7374,7 +7433,7 @@ var SwiftMissingModulesError = class extends Error {
|
|
|
7374
7433
|
};
|
|
7375
7434
|
var projects = /* @__PURE__ */ new Map();
|
|
7376
7435
|
function projectFor(packagePath, hosted) {
|
|
7377
|
-
packagePath =
|
|
7436
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7378
7437
|
const existing = projects.get(packagePath);
|
|
7379
7438
|
if (existing) {
|
|
7380
7439
|
if (hosted && !existing.hosted) {
|
|
@@ -7396,14 +7455,14 @@ function projectFor(packagePath, hosted) {
|
|
|
7396
7455
|
}
|
|
7397
7456
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
7398
7457
|
function swiftPackages(entry, app) {
|
|
7399
|
-
const stamp = (file) => file &&
|
|
7458
|
+
const stamp = (file) => file && import_node_fs14.default.existsSync(file) ? import_node_fs14.default.statSync(file).mtimeMs : 0;
|
|
7400
7459
|
const key2 = JSON.stringify([
|
|
7401
7460
|
app.linkedProducts,
|
|
7402
7461
|
app.packageResolved,
|
|
7403
7462
|
stamp(app.packageResolved),
|
|
7404
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
7463
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path15.default.join(dir, "Package.swift"))),
|
|
7405
7464
|
app.linkedProducts.map(
|
|
7406
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
7465
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path15.default.join(source.dir, "Package.swift")) : 0
|
|
7407
7466
|
)
|
|
7408
7467
|
]);
|
|
7409
7468
|
let cached2 = entry.packages;
|
|
@@ -7454,11 +7513,11 @@ var XCODE_APP_DIR = "__app__";
|
|
|
7454
7513
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
7455
7514
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
7456
7515
|
var XCODE_STANDINS_DIR = "__standins__";
|
|
7457
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
7516
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
|
|
7458
7517
|
function xcodeInputKey(layout, file, relative) {
|
|
7459
7518
|
const owner = layout.targetDirs.get(file);
|
|
7460
|
-
if (owner) return
|
|
7461
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
7519
|
+
if (owner) return import_node_path15.default.posix.join(owner, relative);
|
|
7520
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
7462
7521
|
}
|
|
7463
7522
|
function xcodeLayout(root) {
|
|
7464
7523
|
const registered = xcodeProjects.get(root);
|
|
@@ -7469,7 +7528,7 @@ function xcodeLayout(root) {
|
|
|
7469
7528
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
7470
7529
|
const targets = [];
|
|
7471
7530
|
for (const framework of app.frameworks) {
|
|
7472
|
-
const dir =
|
|
7531
|
+
const dir = import_node_path15.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
7473
7532
|
for (const file of framework.sources) {
|
|
7474
7533
|
if (targetDirs.has(file)) continue;
|
|
7475
7534
|
targetDirs.set(file, dir);
|
|
@@ -7489,7 +7548,7 @@ function xcodeLayout(root) {
|
|
|
7489
7548
|
for (const standin of standins)
|
|
7490
7549
|
targets.push({
|
|
7491
7550
|
name: standin.module,
|
|
7492
|
-
path:
|
|
7551
|
+
path: import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
7493
7552
|
executable: false,
|
|
7494
7553
|
resources: false,
|
|
7495
7554
|
exclude: [],
|
|
@@ -7497,19 +7556,19 @@ function xcodeLayout(root) {
|
|
|
7497
7556
|
mainActorIsolation: false
|
|
7498
7557
|
});
|
|
7499
7558
|
for (const target of packages.targets) {
|
|
7500
|
-
const relative =
|
|
7501
|
-
target.remote ?
|
|
7559
|
+
const relative = import_node_path15.default.relative(
|
|
7560
|
+
target.remote ? import_node_path15.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
7502
7561
|
target.dir
|
|
7503
7562
|
);
|
|
7504
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
7563
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path15.default.sep}`) || import_node_path15.default.isAbsolute(relative))
|
|
7505
7564
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
7506
|
-
const posix = relative.split(
|
|
7565
|
+
const posix = relative.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7507
7566
|
targets.push({
|
|
7508
7567
|
...target,
|
|
7509
|
-
path: target.remote ?
|
|
7568
|
+
path: target.remote ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
7510
7569
|
exclude: []
|
|
7511
7570
|
});
|
|
7512
|
-
if (!target.remote) files2.add(
|
|
7571
|
+
if (!target.remote) files2.add(import_node_path15.default.join(target.packageDir, "Package.swift"));
|
|
7513
7572
|
for (const file of target.files) files2.add(file);
|
|
7514
7573
|
}
|
|
7515
7574
|
for (const target of targets) {
|
|
@@ -7539,25 +7598,25 @@ function xcodeManifest(layout) {
|
|
|
7539
7598
|
].join("\n");
|
|
7540
7599
|
}
|
|
7541
7600
|
function packageFiles(root) {
|
|
7542
|
-
const canonicalRoot =
|
|
7601
|
+
const canonicalRoot = import_node_fs14.default.realpathSync(root);
|
|
7543
7602
|
const xcode = xcodeLayout(canonicalRoot);
|
|
7544
7603
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
7545
7604
|
}
|
|
7546
7605
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
7547
7606
|
const found = [];
|
|
7548
7607
|
const walk2 = (dir2) => {
|
|
7549
|
-
for (const entry of
|
|
7608
|
+
for (const entry of import_node_fs14.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
7550
7609
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
7551
7610
|
continue;
|
|
7552
|
-
const full =
|
|
7611
|
+
const full = import_node_path15.default.join(dir2, entry.name);
|
|
7553
7612
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
7554
|
-
const real =
|
|
7555
|
-
const relative =
|
|
7556
|
-
if (relative.startsWith(`..${
|
|
7613
|
+
const real = import_node_fs14.default.realpathSync(full);
|
|
7614
|
+
const relative = import_node_path15.default.relative(canonicalRoot, real);
|
|
7615
|
+
if (relative.startsWith(`..${import_node_path15.default.sep}`) || relative === ".." || import_node_path15.default.isAbsolute(relative)) {
|
|
7557
7616
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
7558
7617
|
}
|
|
7559
7618
|
if (entry.isDirectory()) {
|
|
7560
|
-
if (
|
|
7619
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(full, "Package.swift"))) continue;
|
|
7561
7620
|
walk2(full);
|
|
7562
7621
|
} else if (entry.isFile()) {
|
|
7563
7622
|
found.push(full);
|
|
@@ -7565,56 +7624,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
7565
7624
|
}
|
|
7566
7625
|
}
|
|
7567
7626
|
};
|
|
7568
|
-
if (
|
|
7627
|
+
if (import_node_fs14.default.existsSync(dir)) walk2(import_node_fs14.default.realpathSync(dir));
|
|
7569
7628
|
return found;
|
|
7570
7629
|
}
|
|
7571
|
-
function readPackageFile(root, file, maxBytes) {
|
|
7572
|
-
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
7573
|
-
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs13.default.realpathSync(file));
|
|
7574
|
-
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
7575
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7576
|
-
}
|
|
7577
|
-
let ancestor = import_node_path14.default.resolve(file);
|
|
7578
|
-
while (ancestor !== canonicalRoot) {
|
|
7579
|
-
if (import_node_fs13.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
7580
|
-
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
7581
|
-
}
|
|
7582
|
-
const parent = import_node_path14.default.dirname(ancestor);
|
|
7583
|
-
if (parent === ancestor)
|
|
7584
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7585
|
-
ancestor = parent;
|
|
7586
|
-
}
|
|
7587
|
-
const expected = import_node_fs13.default.statSync(file);
|
|
7588
|
-
const fd = import_node_fs13.default.openSync(file, import_node_fs13.default.constants.O_RDONLY | import_node_fs13.default.constants.O_NOFOLLOW);
|
|
7589
|
-
try {
|
|
7590
|
-
const stat = import_node_fs13.default.fstatSync(fd);
|
|
7591
|
-
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
7592
|
-
throw new Error(`swift input changed while opening: ${file}`);
|
|
7593
|
-
}
|
|
7594
|
-
if (!stat.isFile() || stat.size > maxBytes) {
|
|
7595
|
-
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
7596
|
-
}
|
|
7597
|
-
const bytes = Buffer.alloc(stat.size + 1);
|
|
7598
|
-
let offset = 0;
|
|
7599
|
-
while (offset < bytes.length) {
|
|
7600
|
-
const count = import_node_fs13.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
7601
|
-
if (count === 0) break;
|
|
7602
|
-
offset += count;
|
|
7603
|
-
}
|
|
7604
|
-
if (offset !== stat.size || import_node_fs13.default.fstatSync(fd).size !== stat.size) {
|
|
7605
|
-
throw new Error(`swift input changed while reading: ${file}`);
|
|
7606
|
-
}
|
|
7607
|
-
return bytes.subarray(0, offset);
|
|
7608
|
-
} finally {
|
|
7609
|
-
import_node_fs13.default.closeSync(fd);
|
|
7610
|
-
}
|
|
7611
|
-
}
|
|
7612
7630
|
function sourceFiles(root) {
|
|
7613
7631
|
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
7614
7632
|
}
|
|
7615
7633
|
function resourceCandidateFiles(root) {
|
|
7616
7634
|
return packageFiles(root).filter(
|
|
7617
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
7635
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path15.default.basename(file))
|
|
7618
7636
|
);
|
|
7619
7637
|
}
|
|
7620
7638
|
var HOSTED_LIMITS = {
|
|
@@ -7648,7 +7666,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7648
7666
|
const limits = inputLimits(Boolean(project.hosted));
|
|
7649
7667
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
7650
7668
|
const relative = absolute.map(
|
|
7651
|
-
(file) =>
|
|
7669
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7652
7670
|
);
|
|
7653
7671
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
7654
7672
|
const readContents = (candidate) => {
|
|
@@ -7670,16 +7688,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7670
7688
|
for (const { name: name2, file, scale } of found) {
|
|
7671
7689
|
const disk = byRelative.get(file);
|
|
7672
7690
|
if (!disk) continue;
|
|
7673
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7691
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs14.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
7674
7692
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
7675
7693
|
}
|
|
7676
7694
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
7677
7695
|
imageBytes += bytes.length;
|
|
7678
7696
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
7679
|
-
const ext =
|
|
7697
|
+
const ext = import_node_path15.default.posix.extname(file).toLowerCase();
|
|
7680
7698
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7681
7699
|
images[name2] = {
|
|
7682
|
-
file:
|
|
7700
|
+
file: import_node_path15.default.posix.basename(file),
|
|
7683
7701
|
data: bytes.toString("base64")
|
|
7684
7702
|
};
|
|
7685
7703
|
watched.push(file);
|
|
@@ -7703,10 +7721,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7703
7721
|
return { table, images, colors, symbols, watched };
|
|
7704
7722
|
}
|
|
7705
7723
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
7706
|
-
packagePath =
|
|
7724
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7707
7725
|
const limits = inputLimits(hosted);
|
|
7708
7726
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
7709
|
-
(file) =>
|
|
7727
|
+
(file) => import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7710
7728
|
);
|
|
7711
7729
|
const files2 = {};
|
|
7712
7730
|
const watched = [];
|
|
@@ -7720,13 +7738,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7720
7738
|
total += bytes.length;
|
|
7721
7739
|
if (xcode.app.infoPlistFile)
|
|
7722
7740
|
watched.push(
|
|
7723
|
-
|
|
7741
|
+
import_node_path15.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path15.default.sep).join("/")
|
|
7724
7742
|
);
|
|
7725
7743
|
}
|
|
7726
7744
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
7727
7745
|
watched.push(file);
|
|
7728
|
-
const disk =
|
|
7729
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7746
|
+
const disk = import_node_path15.default.join(packagePath, ...file.split("/"));
|
|
7747
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs14.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
7730
7748
|
throw new Error(
|
|
7731
7749
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
7732
7750
|
);
|
|
@@ -7738,12 +7756,12 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7738
7756
|
return { files: files2, watched };
|
|
7739
7757
|
}
|
|
7740
7758
|
function linkedModuleRoots(packagePath) {
|
|
7741
|
-
packagePath =
|
|
7759
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7742
7760
|
let manifest;
|
|
7743
7761
|
try {
|
|
7744
7762
|
manifest = readPackageFile(
|
|
7745
7763
|
packagePath,
|
|
7746
|
-
|
|
7764
|
+
import_node_path15.default.join(packagePath, "Package.swift"),
|
|
7747
7765
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7748
7766
|
).toString("utf8");
|
|
7749
7767
|
} catch {
|
|
@@ -7752,8 +7770,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
7752
7770
|
const roots = /* @__PURE__ */ new Set();
|
|
7753
7771
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
7754
7772
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
7755
|
-
const root =
|
|
7756
|
-
if (
|
|
7773
|
+
const root = import_node_path15.default.resolve(packagePath, match[1]);
|
|
7774
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(root, "Package.swift"))) roots.add(root);
|
|
7757
7775
|
}
|
|
7758
7776
|
return [...roots].sort();
|
|
7759
7777
|
}
|
|
@@ -7762,18 +7780,18 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
7762
7780
|
hash.update(packagePath);
|
|
7763
7781
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
7764
7782
|
for (const file of [...projectInputs].sort()) {
|
|
7765
|
-
hash.update(
|
|
7766
|
-
const stat =
|
|
7783
|
+
hash.update(import_node_path15.default.relative(packagePath, file));
|
|
7784
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
7767
7785
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
7768
7786
|
}
|
|
7769
7787
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7770
|
-
(root) =>
|
|
7788
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7771
7789
|
);
|
|
7772
7790
|
if (moduleRoot) {
|
|
7773
7791
|
hash.update(moduleRoot);
|
|
7774
7792
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
7775
7793
|
hash.update(relative);
|
|
7776
|
-
hash.update(String(
|
|
7794
|
+
hash.update(String(import_node_fs14.default.statSync(import_node_path15.default.join(moduleRoot, relative)).mtimeMs));
|
|
7777
7795
|
}
|
|
7778
7796
|
}
|
|
7779
7797
|
return hash.digest("hex").slice(0, 16);
|
|
@@ -7785,8 +7803,8 @@ function packageSources(packagePath) {
|
|
|
7785
7803
|
const xcode = xcodeLayout(packagePath);
|
|
7786
7804
|
const files2 = {};
|
|
7787
7805
|
for (const file of sourceFiles(packagePath)) {
|
|
7788
|
-
const relative =
|
|
7789
|
-
if (xcode &&
|
|
7806
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7807
|
+
if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
|
|
7790
7808
|
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
7791
7809
|
packagePath,
|
|
7792
7810
|
file,
|
|
@@ -7797,7 +7815,7 @@ function packageSources(packagePath) {
|
|
|
7797
7815
|
files2["Package.swift"] = xcodeManifest(xcode);
|
|
7798
7816
|
for (const standin of xcode.standins)
|
|
7799
7817
|
for (const [file, text3] of Object.entries(standin.files))
|
|
7800
|
-
files2[
|
|
7818
|
+
files2[import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
7801
7819
|
}
|
|
7802
7820
|
return files2;
|
|
7803
7821
|
}
|
|
@@ -7808,7 +7826,7 @@ function packageSnapshot(project) {
|
|
|
7808
7826
|
files: files2,
|
|
7809
7827
|
resourcePaths: swiftImplicitResourcePaths(
|
|
7810
7828
|
resourceCandidateFiles(project.packagePath).map(
|
|
7811
|
-
(file) =>
|
|
7829
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7812
7830
|
)
|
|
7813
7831
|
),
|
|
7814
7832
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -7817,7 +7835,7 @@ function packageSnapshot(project) {
|
|
|
7817
7835
|
...native ? {
|
|
7818
7836
|
glue: readPackageFile(
|
|
7819
7837
|
project.packagePath,
|
|
7820
|
-
|
|
7838
|
+
import_node_path15.default.join(project.packagePath, NATIVE_GLUE),
|
|
7821
7839
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7822
7840
|
).toString("utf8")
|
|
7823
7841
|
} : {}
|
|
@@ -7853,7 +7871,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7853
7871
|
package: content
|
|
7854
7872
|
};
|
|
7855
7873
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7856
|
-
(root) =>
|
|
7874
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7857
7875
|
) ?? await swiftDistributionRoot();
|
|
7858
7876
|
if (!moduleRoot)
|
|
7859
7877
|
return {
|
|
@@ -7880,10 +7898,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7880
7898
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
7881
7899
|
// each app and module checkout gets its own root, which keeps the same
|
|
7882
7900
|
// app's incremental build across restarts.
|
|
7883
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
7901
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path15.default.join(
|
|
7884
7902
|
import_node_os8.default.tmpdir(),
|
|
7885
7903
|
"contrast-swift-build",
|
|
7886
|
-
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${
|
|
7904
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path15.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
7887
7905
|
),
|
|
7888
7906
|
moduleRoot,
|
|
7889
7907
|
...toolchain
|
|
@@ -7995,7 +8013,7 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
7995
8013
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
7996
8014
|
...[...missing].map(([name2, files2]) => {
|
|
7997
8015
|
const gap = gaps.get(name2);
|
|
7998
|
-
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
8016
|
+
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})` : ""}`;
|
|
7999
8017
|
})
|
|
8000
8018
|
].join("\n");
|
|
8001
8019
|
}
|
|
@@ -8003,7 +8021,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8003
8021
|
const auth = hosted ? null : resolveCliAuth();
|
|
8004
8022
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
8005
8023
|
throw new Error(
|
|
8006
|
-
`compiling ${
|
|
8024
|
+
`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`
|
|
8007
8025
|
);
|
|
8008
8026
|
}
|
|
8009
8027
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -8022,7 +8040,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8022
8040
|
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
8023
8041
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
8024
8042
|
throw new Error(
|
|
8025
|
-
`${
|
|
8043
|
+
`${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`
|
|
8026
8044
|
);
|
|
8027
8045
|
}
|
|
8028
8046
|
const descriptor = snapshot.native;
|
|
@@ -8041,7 +8059,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8041
8059
|
);
|
|
8042
8060
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
8043
8061
|
throw new Error(
|
|
8044
|
-
`${
|
|
8062
|
+
`${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`
|
|
8045
8063
|
);
|
|
8046
8064
|
}
|
|
8047
8065
|
const response = await fetch(address.url, { signal });
|
|
@@ -8119,8 +8137,8 @@ var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile)
|
|
|
8119
8137
|
var scriptEnv = { ...process.env, [RNX_FORKED_SCRIPT_ENV]: "1" };
|
|
8120
8138
|
var EXPO_SWIFT_ENTRY = "Sources/PeachExpoApp/PeachExpoEntry.swift";
|
|
8121
8139
|
async function collectExpoSwiftSources(appRoot) {
|
|
8122
|
-
appRoot =
|
|
8123
|
-
const appRequire = (0, import_node_module.createRequire)(
|
|
8140
|
+
appRoot = import_node_fs15.default.realpathSync(appRoot);
|
|
8141
|
+
const appRequire = (0, import_node_module.createRequire)(import_node_path16.default.join(appRoot, "package.json"));
|
|
8124
8142
|
let autolinker;
|
|
8125
8143
|
try {
|
|
8126
8144
|
autolinker = appRequire.resolve("expo-modules-autolinking/package.json");
|
|
@@ -8134,7 +8152,7 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8134
8152
|
(command) => run3(
|
|
8135
8153
|
process.execPath,
|
|
8136
8154
|
[
|
|
8137
|
-
|
|
8155
|
+
import_node_path16.default.join(import_node_path16.default.dirname(autolinker), "bin/expo-modules-autolinking.js"),
|
|
8138
8156
|
command,
|
|
8139
8157
|
"--platform",
|
|
8140
8158
|
"apple",
|
|
@@ -8165,8 +8183,8 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8165
8183
|
const sourceRoot = Reflect.get(entry, "path");
|
|
8166
8184
|
if (typeof sourceRoot !== "string")
|
|
8167
8185
|
throw new Error("Expo autolinking entry has no path");
|
|
8168
|
-
const canonical =
|
|
8169
|
-
if (canonical.split(
|
|
8186
|
+
const canonical = import_node_fs15.default.realpathSync(sourceRoot);
|
|
8187
|
+
if (canonical.split(import_node_path16.default.sep).includes("node_modules")) continue;
|
|
8170
8188
|
const resolution = resolutions.find(
|
|
8171
8189
|
(candidate) => candidate && typeof candidate === "object" && Reflect.get(candidate, "packageName") === Reflect.get(entry, "name")
|
|
8172
8190
|
);
|
|
@@ -8193,12 +8211,12 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8193
8211
|
registration: `(${className.includes(".") ? className : `${namespace}.${className}`}.self, ${name2 === null ? "nil" : JSON.stringify(name2)})`
|
|
8194
8212
|
});
|
|
8195
8213
|
}
|
|
8196
|
-
const ios =
|
|
8197
|
-
if (
|
|
8214
|
+
const ios = import_node_path16.default.join(canonical, "ios");
|
|
8215
|
+
if (import_node_fs15.default.lstatSync(ios).isSymbolicLink())
|
|
8198
8216
|
throw new Error(`Expo Swift source directory is a symlink: ${ios}`);
|
|
8199
8217
|
const walk2 = (dir) => {
|
|
8200
|
-
for (const child of
|
|
8201
|
-
const file =
|
|
8218
|
+
for (const child of import_node_fs15.default.readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
8219
|
+
const file = import_node_path16.default.join(dir, child.name);
|
|
8202
8220
|
if (child.isSymbolicLink())
|
|
8203
8221
|
throw new Error(`Expo Swift source is a symlink: ${file}`);
|
|
8204
8222
|
if (child.isDirectory()) {
|
|
@@ -8206,13 +8224,13 @@ async function collectExpoSwiftSources(appRoot) {
|
|
|
8206
8224
|
continue;
|
|
8207
8225
|
}
|
|
8208
8226
|
if (!child.name.endsWith(".swift")) continue;
|
|
8209
|
-
const size =
|
|
8227
|
+
const size = import_node_fs15.default.statSync(file).size;
|
|
8210
8228
|
bytes += size;
|
|
8211
8229
|
fileCount++;
|
|
8212
8230
|
if (fileCount > MAX_SWIFT_COMPILE_FILES - 2 || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES)
|
|
8213
8231
|
throw new Error("Expo Swift sources exceed compile service caps");
|
|
8214
|
-
files2[`Sources/${namespace}/${
|
|
8215
|
-
${
|
|
8232
|
+
files2[`Sources/${namespace}/${import_node_path16.default.relative(ios, file).split(import_node_path16.default.sep).join("/")}`] = `#sourceLocation(file: ${JSON.stringify(file)}, line: 1)
|
|
8233
|
+
${import_node_fs15.default.readFileSync(file, "utf8")}`;
|
|
8216
8234
|
}
|
|
8217
8235
|
};
|
|
8218
8236
|
walk2(ios);
|
|
@@ -8297,7 +8315,7 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8297
8315
|
modules: [],
|
|
8298
8316
|
failures: []
|
|
8299
8317
|
};
|
|
8300
|
-
const key2 = (0, import_node_crypto8.createHash)("sha256").update(
|
|
8318
|
+
const key2 = (0, import_node_crypto8.createHash)("sha256").update(import_node_fs15.default.realpathSync(root)).digest("hex");
|
|
8301
8319
|
const linked = [];
|
|
8302
8320
|
for (const unit of units) {
|
|
8303
8321
|
if (!module2) {
|
|
@@ -8307,14 +8325,14 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8307
8325
|
});
|
|
8308
8326
|
continue;
|
|
8309
8327
|
}
|
|
8310
|
-
const packagePath =
|
|
8328
|
+
const packagePath = import_node_path16.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, unit.moduleId);
|
|
8311
8329
|
let stamp;
|
|
8312
8330
|
try {
|
|
8313
8331
|
syncSwiftTree(
|
|
8314
8332
|
packagePath,
|
|
8315
8333
|
new Map(
|
|
8316
8334
|
Object.entries(unit.files).map(([name2, source]) => [
|
|
8317
|
-
|
|
8335
|
+
import_node_path16.default.join(packagePath, name2),
|
|
8318
8336
|
source
|
|
8319
8337
|
])
|
|
8320
8338
|
)
|
|
@@ -8339,10 +8357,13 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8339
8357
|
const file = JSON.parse(match[1]);
|
|
8340
8358
|
return typeof file === "string" ? [file] : [];
|
|
8341
8359
|
});
|
|
8342
|
-
const
|
|
8343
|
-
|
|
8360
|
+
const errors = diagnostic.match(/^.+:\d+(?::\d+)?: error:.*$/gm) ?? [];
|
|
8361
|
+
const sourceErrors = errors.filter(
|
|
8362
|
+
(line) => appPaths.some((file) => line.startsWith(`${file}:`)) && !/external macro implementation type|failed to load library plugin/.test(line)
|
|
8363
|
+
);
|
|
8364
|
+
if (publishArtifact && (sourceErrors.length === 0 || sourceErrors.length !== errors.length) && !(error instanceof SwiftMissingModulesError))
|
|
8344
8365
|
throw error;
|
|
8345
|
-
if (sourceErrors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
8366
|
+
if (sourceErrors.length && sourceErrors.length === errors.length && module2 && stamp && sourceStamp(packagePath, module2.root) === stamp) {
|
|
8346
8367
|
failedCompilations.set(packagePath, {
|
|
8347
8368
|
stamp,
|
|
8348
8369
|
diagnostic: sourceErrors.join("\n")
|
|
@@ -8372,12 +8393,12 @@ async function compileExpoSwiftModules(root, base, publishArtifact) {
|
|
|
8372
8393
|
import PackageDescription
|
|
8373
8394
|
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")])
|
|
8374
8395
|
`;
|
|
8375
|
-
const packagePath =
|
|
8396
|
+
const packagePath = import_node_path16.default.join(import_node_os9.default.tmpdir(), "peach-expo-swift", key2, "linked-app");
|
|
8376
8397
|
syncSwiftTree(
|
|
8377
8398
|
packagePath,
|
|
8378
8399
|
new Map(
|
|
8379
8400
|
Object.entries(files2).map(([name2, source]) => [
|
|
8380
|
-
|
|
8401
|
+
import_node_path16.default.join(packagePath, name2),
|
|
8381
8402
|
source
|
|
8382
8403
|
])
|
|
8383
8404
|
)
|