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
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -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;
|
|
@@ -1401,8 +1401,8 @@ __export(vite_plugin_swift_exports, {
|
|
|
1401
1401
|
swiftPlugin: () => swiftPlugin
|
|
1402
1402
|
});
|
|
1403
1403
|
module.exports = __toCommonJS(vite_plugin_swift_exports);
|
|
1404
|
-
var
|
|
1405
|
-
var
|
|
1404
|
+
var import_node_fs17 = __toESM(require("node:fs"), 1);
|
|
1405
|
+
var import_node_path18 = __toESM(require("node:path"), 1);
|
|
1406
1406
|
|
|
1407
1407
|
// ../sootsim-swift/src/entryModule.ts
|
|
1408
1408
|
function nativeExportLines(args, commonjs) {
|
|
@@ -2030,7 +2030,7 @@ var importsSpriteKit = (files2) => Object.entries(files2).some(
|
|
|
2030
2030
|
);
|
|
2031
2031
|
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"';
|
|
2032
2032
|
var ONE_IMPLICIT_FLAGS = ', "-Xfrontend", "-import-module", "-Xfrontend", "One"';
|
|
2033
|
-
var MULTI_MANIFEST_VERSION =
|
|
2033
|
+
var MULTI_MANIFEST_VERSION = 12;
|
|
2034
2034
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
2035
2035
|
const hash = (0, import_node_crypto2.createHash)("sha256");
|
|
2036
2036
|
hash.update(`swift-compile/v18
|
|
@@ -2081,8 +2081,12 @@ function emitSwiftPackageManifest(args) {
|
|
|
2081
2081
|
(name2) => OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2)
|
|
2082
2082
|
).flatMap((name2) => [name2, ...OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? []])
|
|
2083
2083
|
);
|
|
2084
|
+
if (spriteKit) {
|
|
2085
|
+
reachedFrameworks.add("SpriteKit");
|
|
2086
|
+
reachedFrameworks.add("PeachBox2D");
|
|
2087
|
+
}
|
|
2084
2088
|
const distributionObjects = distribution?.objects.filter(
|
|
2085
|
-
(object) => [...OPTIONAL_FRAMEWORKS].every(
|
|
2089
|
+
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
2086
2090
|
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
2087
2091
|
)
|
|
2088
2092
|
);
|
|
@@ -3209,7 +3213,17 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
3209
3213
|
])
|
|
3210
3214
|
],
|
|
3211
3215
|
{
|
|
3212
|
-
env:
|
|
3216
|
+
env: {
|
|
3217
|
+
...BUILD_ENV,
|
|
3218
|
+
// shipped host plugins resolve against the selected compiler's runtime.
|
|
3219
|
+
...process.platform === "linux" ? {
|
|
3220
|
+
LD_LIBRARY_PATH: [
|
|
3221
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/linux"),
|
|
3222
|
+
import_node_path2.default.resolve(options.toolchainBin, "../lib/swift/host"),
|
|
3223
|
+
process.env.LD_LIBRARY_PATH
|
|
3224
|
+
].filter(Boolean).join(":")
|
|
3225
|
+
} : {}
|
|
3226
|
+
},
|
|
3213
3227
|
maxBuffer: 64 * 1024 * 1024,
|
|
3214
3228
|
timeout: options.timeoutMs
|
|
3215
3229
|
}
|
|
@@ -3229,9 +3243,9 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
3229
3243
|
|
|
3230
3244
|
// src/swift-host.ts
|
|
3231
3245
|
var import_node_crypto7 = require("node:crypto");
|
|
3232
|
-
var
|
|
3246
|
+
var import_node_fs14 = __toESM(require("node:fs"), 1);
|
|
3233
3247
|
var import_node_os8 = __toESM(require("node:os"), 1);
|
|
3234
|
-
var
|
|
3248
|
+
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
3235
3249
|
|
|
3236
3250
|
// ../sootsim-swift/src/bundleAssets.ts
|
|
3237
3251
|
var import_svgpath = __toESM(require("svgpath"), 1);
|
|
@@ -3265,8 +3279,8 @@ function pickImagesetFile(images) {
|
|
|
3265
3279
|
scale: pick.scale === "2x" ? 2 : pick.scale === "3x" ? 3 : 1
|
|
3266
3280
|
};
|
|
3267
3281
|
}
|
|
3268
|
-
function flatScale(
|
|
3269
|
-
const match = /@([23])x\.[^./]+$/.exec(
|
|
3282
|
+
function flatScale(path18) {
|
|
3283
|
+
const match = /@([23])x\.[^./]+$/.exec(path18);
|
|
3270
3284
|
return match ? Number(match[1]) : 1;
|
|
3271
3285
|
}
|
|
3272
3286
|
function providesNamespace(text3) {
|
|
@@ -3293,13 +3307,13 @@ function catalogEntryName(contentsPath, kind, readText) {
|
|
|
3293
3307
|
}
|
|
3294
3308
|
return segments.join("/");
|
|
3295
3309
|
}
|
|
3296
|
-
function isFlatResourceImage(
|
|
3297
|
-
return
|
|
3310
|
+
function isFlatResourceImage(path18) {
|
|
3311
|
+
return path18.split("/").includes("Resources") && RASTER_EXTENSIONS.has(extOf(path18));
|
|
3298
3312
|
}
|
|
3299
3313
|
function enumerateBundleImages(paths, readText) {
|
|
3300
3314
|
const table = [];
|
|
3301
3315
|
const seen = /* @__PURE__ */ new Set();
|
|
3302
|
-
const catalogs = paths.filter((
|
|
3316
|
+
const catalogs = paths.filter((path18) => baseOf(path18) === "Contents.json");
|
|
3303
3317
|
for (const contentsPath of catalogs) {
|
|
3304
3318
|
const name2 = catalogEntryName(contentsPath, ".imageset", readText);
|
|
3305
3319
|
if (name2 === null || seen.has(name2)) continue;
|
|
@@ -3320,12 +3334,12 @@ function enumerateBundleImages(paths, readText) {
|
|
|
3320
3334
|
seen.add(name2);
|
|
3321
3335
|
table.push({ name: name2, file: `${dir}/${pick.filename}`, scale: pick.scale });
|
|
3322
3336
|
}
|
|
3323
|
-
for (const
|
|
3324
|
-
if (!isFlatResourceImage(
|
|
3325
|
-
const name2 = baseOf(
|
|
3337
|
+
for (const path18 of paths) {
|
|
3338
|
+
if (!isFlatResourceImage(path18)) continue;
|
|
3339
|
+
const name2 = baseOf(path18).slice(0, -extOf(path18).length);
|
|
3326
3340
|
if (name2 === "" || seen.has(name2)) continue;
|
|
3327
3341
|
seen.add(name2);
|
|
3328
|
-
table.push({ name: name2, file:
|
|
3342
|
+
table.push({ name: name2, file: path18, scale: flatScale(path18) });
|
|
3329
3343
|
}
|
|
3330
3344
|
return table;
|
|
3331
3345
|
}
|
|
@@ -3354,7 +3368,7 @@ function colorsetValue(color) {
|
|
|
3354
3368
|
}
|
|
3355
3369
|
function enumerateBundleColors(paths, readText) {
|
|
3356
3370
|
const table = {};
|
|
3357
|
-
for (const contentsPath of paths.filter((
|
|
3371
|
+
for (const contentsPath of paths.filter((path18) => baseOf(path18) === "Contents.json")) {
|
|
3358
3372
|
const name2 = catalogEntryName(contentsPath, ".colorset", readText);
|
|
3359
3373
|
if (name2 === null || name2 in table) continue;
|
|
3360
3374
|
let colors;
|
|
@@ -3419,8 +3433,8 @@ function axisExtremes(points) {
|
|
|
3419
3433
|
function pathBounds(d) {
|
|
3420
3434
|
const xs = [];
|
|
3421
3435
|
const ys = [];
|
|
3422
|
-
for (const
|
|
3423
|
-
(0, import_svgpath.default)(
|
|
3436
|
+
for (const path18 of d)
|
|
3437
|
+
(0, import_svgpath.default)(path18).abs().unshort().unarc().iterate((segment, _index, x, y) => {
|
|
3424
3438
|
const [command, ...args] = segment;
|
|
3425
3439
|
if (command === "M" || command === "L") {
|
|
3426
3440
|
xs.push(Number(args[0]));
|
|
@@ -3447,7 +3461,7 @@ function guide(svg, id, axis) {
|
|
|
3447
3461
|
}
|
|
3448
3462
|
function enumerateBundleSymbols(paths, readText) {
|
|
3449
3463
|
const table = {};
|
|
3450
|
-
for (const contentsPath of paths.filter((
|
|
3464
|
+
for (const contentsPath of paths.filter((path18) => baseOf(path18) === "Contents.json")) {
|
|
3451
3465
|
const name2 = catalogEntryName(contentsPath, ".symbolset", readText);
|
|
3452
3466
|
if (name2 === null || name2 in table) continue;
|
|
3453
3467
|
let symbols;
|
|
@@ -3480,8 +3494,8 @@ function enumerateBundleSymbols(paths, readText) {
|
|
|
3480
3494
|
viewBox: "0 0 24 24",
|
|
3481
3495
|
advance,
|
|
3482
3496
|
box: [12 - advance / 2, 12 - tall / 2, advance, tall],
|
|
3483
|
-
layers: d.map((
|
|
3484
|
-
d: (0, import_svgpath.default)(
|
|
3497
|
+
layers: d.map((path18) => ({
|
|
3498
|
+
d: (0, import_svgpath.default)(path18).abs().scale(scale).translate(translateX, translateY).round(3).toString()
|
|
3485
3499
|
}))
|
|
3486
3500
|
};
|
|
3487
3501
|
}
|
|
@@ -3491,7 +3505,7 @@ function enumerateBundleJson(paths) {
|
|
|
3491
3505
|
const found = [];
|
|
3492
3506
|
const seen = /* @__PURE__ */ new Set();
|
|
3493
3507
|
const ordered = [...paths].filter(
|
|
3494
|
-
(
|
|
3508
|
+
(path18) => path18.split("/").includes("Resources") && path18.split("/").every((segment) => segment !== "" && segment !== "..") && (extOf(path18) === ".json" || extOf(path18) === ".xcstrings")
|
|
3495
3509
|
).sort((a, b) => {
|
|
3496
3510
|
const aDepth = a.split("/").length;
|
|
3497
3511
|
const bDepth = b.split("/").length;
|
|
@@ -4777,15 +4791,60 @@ function resolveSwiftPackages(options) {
|
|
|
4777
4791
|
return result;
|
|
4778
4792
|
}
|
|
4779
4793
|
|
|
4794
|
+
// src/swift-source-file.ts
|
|
4795
|
+
var import_node_fs10 = __toESM(require("node:fs"), 1);
|
|
4796
|
+
var import_node_path11 = __toESM(require("node:path"), 1);
|
|
4797
|
+
function readPackageFile(root, file, maxBytes) {
|
|
4798
|
+
const canonicalRoot = import_node_fs10.default.realpathSync(root);
|
|
4799
|
+
const relative = import_node_path11.default.relative(canonicalRoot, import_node_fs10.default.realpathSync(file));
|
|
4800
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path11.default.sep}`) || import_node_path11.default.isAbsolute(relative)) {
|
|
4801
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4802
|
+
}
|
|
4803
|
+
let ancestor = import_node_path11.default.resolve(file);
|
|
4804
|
+
while (ancestor !== canonicalRoot) {
|
|
4805
|
+
if (import_node_fs10.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
4806
|
+
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
4807
|
+
}
|
|
4808
|
+
const parent = import_node_path11.default.dirname(ancestor);
|
|
4809
|
+
if (parent === ancestor)
|
|
4810
|
+
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
4811
|
+
ancestor = parent;
|
|
4812
|
+
}
|
|
4813
|
+
const expected = import_node_fs10.default.statSync(file);
|
|
4814
|
+
const fd = import_node_fs10.default.openSync(file, import_node_fs10.default.constants.O_RDONLY | import_node_fs10.default.constants.O_NOFOLLOW);
|
|
4815
|
+
try {
|
|
4816
|
+
const stat = import_node_fs10.default.fstatSync(fd);
|
|
4817
|
+
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
4818
|
+
throw new Error(`swift input changed while opening: ${file}`);
|
|
4819
|
+
}
|
|
4820
|
+
if (!stat.isFile() || stat.size > maxBytes) {
|
|
4821
|
+
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
4822
|
+
}
|
|
4823
|
+
const bytes = Buffer.alloc(stat.size + 1);
|
|
4824
|
+
let offset = 0;
|
|
4825
|
+
while (offset < bytes.length) {
|
|
4826
|
+
const count = import_node_fs10.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
4827
|
+
if (count === 0) break;
|
|
4828
|
+
offset += count;
|
|
4829
|
+
}
|
|
4830
|
+
if (offset !== stat.size || import_node_fs10.default.fstatSync(fd).size !== stat.size) {
|
|
4831
|
+
throw new Error(`swift input changed while reading: ${file}`);
|
|
4832
|
+
}
|
|
4833
|
+
return bytes.subarray(0, offset);
|
|
4834
|
+
} finally {
|
|
4835
|
+
import_node_fs10.default.closeSync(fd);
|
|
4836
|
+
}
|
|
4837
|
+
}
|
|
4838
|
+
|
|
4780
4839
|
// src/swift-standins.ts
|
|
4781
4840
|
var import_node_child_process7 = require("node:child_process");
|
|
4782
4841
|
var import_node_crypto6 = require("node:crypto");
|
|
4783
|
-
var
|
|
4842
|
+
var import_node_fs12 = __toESM(require("node:fs"), 1);
|
|
4784
4843
|
var import_node_os7 = __toESM(require("node:os"), 1);
|
|
4785
|
-
var
|
|
4844
|
+
var import_node_path12 = __toESM(require("node:path"), 1);
|
|
4786
4845
|
|
|
4787
4846
|
// src/cli-version.ts
|
|
4788
|
-
var
|
|
4847
|
+
var import_node_fs11 = require("node:fs");
|
|
4789
4848
|
var import_node_url = require("node:url");
|
|
4790
4849
|
|
|
4791
4850
|
// src/public-brand.ts
|
|
@@ -4814,7 +4873,7 @@ function getCliVersion() {
|
|
|
4814
4873
|
];
|
|
4815
4874
|
for (const resolve2 of candidates) {
|
|
4816
4875
|
try {
|
|
4817
|
-
const version = JSON.parse((0,
|
|
4876
|
+
const version = JSON.parse((0, import_node_fs11.readFileSync)(resolve2(), "utf8")).version;
|
|
4818
4877
|
if (typeof version === "string" && version) {
|
|
4819
4878
|
cached = version;
|
|
4820
4879
|
return cached;
|
|
@@ -4884,7 +4943,7 @@ var witnessKey = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.")
|
|
|
4884
4943
|
var sideLeaf = (symbol) => `${symbol.kind.identifier.startsWith("swift.type.") ? "type" : "instance"}|leaf|${leaf(symbol)}`;
|
|
4885
4944
|
var isObjC = (symbol) => symbol.identifier.precise.startsWith("c:");
|
|
4886
4945
|
var synthesizedEquality = (symbol, conforms) => conforms.includes("Hashable") ? ["==(_:_:)", "hash(into:)", "hashValue"].includes(leaf(symbol)) : conforms.includes("Equatable") && leaf(symbol) === "==(_:_:)";
|
|
4887
|
-
var trap = (
|
|
4946
|
+
var trap = (path18) => `fatalError("${path18} is a binary framework peach cannot run")`;
|
|
4888
4947
|
function emitSwiftStandin(graphs, options) {
|
|
4889
4948
|
const skipped = [];
|
|
4890
4949
|
const behavior = options.behavior ?? /* @__PURE__ */ new Map();
|
|
@@ -5021,10 +5080,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5021
5080
|
owners.push(...physical.map(() => current));
|
|
5022
5081
|
};
|
|
5023
5082
|
const scoped = (body) => (symbol, ...rest) => {
|
|
5024
|
-
const
|
|
5025
|
-
if (omit.has(
|
|
5083
|
+
const path18 = pathOf(symbol);
|
|
5084
|
+
if (omit.has(path18)) return void skipped.push({ path: path18, reason: omit.get(path18) });
|
|
5026
5085
|
const previous = current;
|
|
5027
|
-
current =
|
|
5086
|
+
current = path18;
|
|
5028
5087
|
try {
|
|
5029
5088
|
body(symbol, ...rest);
|
|
5030
5089
|
} finally {
|
|
@@ -5044,14 +5103,14 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5044
5103
|
const access = (symbol, openOwner) => symbol.accessLevel === "open" && openOwner ? "open" : "public";
|
|
5045
5104
|
const emitMember = scoped(
|
|
5046
5105
|
(member, indent, context) => {
|
|
5047
|
-
const
|
|
5106
|
+
const path18 = pathOf(member);
|
|
5048
5107
|
if (TYPE_KINDS.has(member.kind.identifier)) {
|
|
5049
5108
|
emitType(member, indent);
|
|
5050
5109
|
return;
|
|
5051
5110
|
}
|
|
5052
5111
|
if (member.kind.identifier === "swift.enum.case") return;
|
|
5053
5112
|
if (!MEMBER_KINDS.has(member.kind.identifier)) {
|
|
5054
|
-
skipped.push({ path:
|
|
5113
|
+
skipped.push({ path: path18, reason: `unhandled ${member.kind.identifier}` });
|
|
5055
5114
|
return;
|
|
5056
5115
|
}
|
|
5057
5116
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(member));
|
|
@@ -5065,12 +5124,12 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5065
5124
|
const final = context.inClass && flags.has("final") ? "final " : "";
|
|
5066
5125
|
const mutating = flags.has("mutating") ? "mutating " : flags.has("nonmutating") ? "nonmutating " : "";
|
|
5067
5126
|
let core = `${flags.has("convenience") ? "convenience " : ""}${modifiers[2]}`;
|
|
5068
|
-
const override = context.inClass && !options.plain?.has(
|
|
5127
|
+
const override = context.inClass && !options.plain?.has(path18) && (flags.has("override") || overrides.has(member.identifier.precise) || options.forcedOverride?.has(path18) || isObjC(member) && path18.endsWith(".init()")) ? "override " : "";
|
|
5069
5128
|
const head = `${indent}${attrs}${access(member, context.openOwner)} ${required ? "required " : ""}${final}${override}${mutating}`;
|
|
5070
|
-
const measured = behavior.get(
|
|
5071
|
-
if (measured) used.add(
|
|
5129
|
+
const measured = behavior.get(path18);
|
|
5130
|
+
if (measured) used.add(path18);
|
|
5072
5131
|
const overloadBody = /\basync\b/.test(core) ? measured?.asyncBody : /\bResult</.test(core) ? measured?.resultBody : void 0;
|
|
5073
|
-
const body = overloadBody ?? measured?.body ?? trap(
|
|
5132
|
+
const body = overloadBody ?? measured?.body ?? trap(path18);
|
|
5074
5133
|
switch (member.kind.identifier) {
|
|
5075
5134
|
case "swift.property":
|
|
5076
5135
|
case "swift.type.property":
|
|
@@ -5091,7 +5150,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5091
5150
|
return;
|
|
5092
5151
|
}
|
|
5093
5152
|
emit(
|
|
5094
|
-
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(
|
|
5153
|
+
`${head}${computed} { get${effects} { ${body} }${settable && !effects ? ` ${parsed.nonmutating ? "nonmutating " : ""}set { ${measured?.set ?? trap(path18)} }` : ""} }`
|
|
5095
5154
|
);
|
|
5096
5155
|
return;
|
|
5097
5156
|
}
|
|
@@ -5144,7 +5203,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5144
5203
|
};
|
|
5145
5204
|
const emitType = scoped(
|
|
5146
5205
|
(symbol, indent) => {
|
|
5147
|
-
const
|
|
5206
|
+
const path18 = pathOf(symbol);
|
|
5148
5207
|
const id = symbol.identifier.precise;
|
|
5149
5208
|
const inner = `${indent} `;
|
|
5150
5209
|
switch (symbol.kind.identifier) {
|
|
@@ -5156,10 +5215,10 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5156
5215
|
case "swift.class": {
|
|
5157
5216
|
const shape = header(symbol, "class", indent);
|
|
5158
5217
|
if (!shape)
|
|
5159
|
-
return void skipped.push({ path:
|
|
5160
|
-
const parent = options.superclasses?.get(
|
|
5218
|
+
return void skipped.push({ path: path18, reason: `unparsed class ${text(symbol)}` });
|
|
5219
|
+
const parent = options.superclasses?.get(path18) ?? superclass.get(id);
|
|
5161
5220
|
const blocked = classBlocked(id);
|
|
5162
|
-
if (blocked) return void skipped.push({ path:
|
|
5221
|
+
if (blocked) return void skipped.push({ path: path18, reason: blocked });
|
|
5163
5222
|
const ancestors = /* @__PURE__ */ new Set();
|
|
5164
5223
|
for (let at = superId.get(id); at; at = superId.get(at))
|
|
5165
5224
|
for (const name2 of conforms.get(at) ?? []) ancestors.add(name2);
|
|
@@ -5175,9 +5234,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5175
5234
|
`${indent}${shape.attrs}${open ? "open" : "public"} class ${shape.name}${shape.generics}${list2.length ? `: ${list2.join(", ")}` : ""}${selfConforming(shape.where)} {`
|
|
5176
5235
|
);
|
|
5177
5236
|
const members = membersOf(id);
|
|
5178
|
-
const extra = options.behavior?.get(
|
|
5237
|
+
const extra = options.behavior?.get(path18)?.members;
|
|
5179
5238
|
if (extra) {
|
|
5180
|
-
used.add(
|
|
5239
|
+
used.add(path18);
|
|
5181
5240
|
emit(`${inner}${extra}`);
|
|
5182
5241
|
}
|
|
5183
5242
|
for (const member of members)
|
|
@@ -5230,13 +5289,13 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5230
5289
|
continue;
|
|
5231
5290
|
have.add(witnessKey(member));
|
|
5232
5291
|
have.add(sideLeaf(member));
|
|
5233
|
-
emitWitness(member, inner,
|
|
5292
|
+
emitWitness(member, inner, path18);
|
|
5234
5293
|
}
|
|
5235
5294
|
}
|
|
5236
5295
|
const coder = members.some((member) => leaf(member) === "init(coder:)");
|
|
5237
5296
|
if (designated && !coder && externalRoot(id) !== "NSObject" && externalRoot(id) !== null)
|
|
5238
5297
|
emit(
|
|
5239
|
-
`${inner}public required init?(coder: NSCoder) { ${trap(`${
|
|
5298
|
+
`${inner}public required init?(coder: NSCoder) { ${trap(`${path18}.init(coder:)`)} }`
|
|
5240
5299
|
);
|
|
5241
5300
|
emit(`${indent}}`);
|
|
5242
5301
|
return;
|
|
@@ -5244,7 +5303,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5244
5303
|
case "swift.struct": {
|
|
5245
5304
|
const shape = header(symbol, "struct", indent);
|
|
5246
5305
|
if (!shape)
|
|
5247
|
-
return void skipped.push({ path:
|
|
5306
|
+
return void skipped.push({ path: path18, reason: `unparsed struct ${text(symbol)}` });
|
|
5248
5307
|
const members = membersOf(id);
|
|
5249
5308
|
const raw2 = rawType(members);
|
|
5250
5309
|
const list2 = inheritance(id);
|
|
@@ -5295,7 +5354,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5295
5354
|
case "swift.enum": {
|
|
5296
5355
|
const shape = header(symbol, "enum", indent);
|
|
5297
5356
|
if (!shape)
|
|
5298
|
-
return void skipped.push({ path:
|
|
5357
|
+
return void skipped.push({ path: path18, reason: `unparsed enum ${text(symbol)}` });
|
|
5299
5358
|
const members = membersOf(id);
|
|
5300
5359
|
const raw2 = rawType(members);
|
|
5301
5360
|
const cases = (children.get(id) ?? []).filter(
|
|
@@ -5304,7 +5363,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5304
5363
|
const missing = raw2 ? cases.filter((member) => !values.has(member.identifier.precise)) : [];
|
|
5305
5364
|
if (raw2 && isObjC(symbol) && missing.length > 0)
|
|
5306
5365
|
return void skipped.push({
|
|
5307
|
-
path:
|
|
5366
|
+
path: path18,
|
|
5308
5367
|
reason: `no header value for ${missing.map(leaf).join(", ")}`
|
|
5309
5368
|
});
|
|
5310
5369
|
const list2 = inheritance(id, raw2 ?? void 0).filter(
|
|
@@ -5345,7 +5404,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5345
5404
|
const shape = header(symbol, "protocol", indent);
|
|
5346
5405
|
if (!shape)
|
|
5347
5406
|
return void skipped.push({
|
|
5348
|
-
path:
|
|
5407
|
+
path: path18,
|
|
5349
5408
|
reason: `unparsed protocol ${text(symbol)}`
|
|
5350
5409
|
});
|
|
5351
5410
|
const list2 = [...isObjC(symbol) ? ["AnyObject"] : [], ...inheritance(id)];
|
|
@@ -5370,7 +5429,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5370
5429
|
}
|
|
5371
5430
|
emit(`${indent}}`);
|
|
5372
5431
|
if (defaults.length > 0) {
|
|
5373
|
-
emit(`${indent}extension ${
|
|
5432
|
+
emit(`${indent}extension ${path18} {`);
|
|
5374
5433
|
for (const member of defaults) {
|
|
5375
5434
|
const decl = text(member);
|
|
5376
5435
|
if (optional.has(member.identifier.precise) && member.kind.identifier === "swift.method" && !decl.replace(/\([^)]*\)/g, "").includes("->") && !/ async\b/.test(decl))
|
|
@@ -5417,7 +5476,7 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5417
5476
|
return init ? /rawValue:\s*([^)]+)\)/.exec(text(init))?.[1]?.trim() ?? null : null;
|
|
5418
5477
|
};
|
|
5419
5478
|
const emitGlobal = scoped((symbol) => {
|
|
5420
|
-
const
|
|
5479
|
+
const path18 = pathOf(symbol);
|
|
5421
5480
|
const kind = symbol.kind.identifier;
|
|
5422
5481
|
if (kind === "swift.func" || kind === "swift.func.op" || kind === "swift.method" || kind === "swift.type.method") {
|
|
5423
5482
|
const { 1: attrs, 2: rest } = LEADING_ATTRS.exec(text(symbol));
|
|
@@ -5428,17 +5487,17 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5428
5487
|
if (fix && !/^(?:prefix|infix|postfix)\b/.test(spelled))
|
|
5429
5488
|
spelled = `${fix} ${spelled}`;
|
|
5430
5489
|
}
|
|
5431
|
-
emit(`${attrs}public ${spelled} { ${trap(
|
|
5490
|
+
emit(`${attrs}public ${spelled} { ${trap(path18)} }`);
|
|
5432
5491
|
} else if (kind === "swift.var") {
|
|
5433
5492
|
const parsed = splitAccessors(text(symbol).replace(/^let /, "var "));
|
|
5434
|
-
const measured = behavior.get(
|
|
5435
|
-
if (measured) used.add(
|
|
5436
|
-
emit(`public ${parsed.decl} { ${measured?.body ?? trap(
|
|
5437
|
-
} else skipped.push({ path:
|
|
5493
|
+
const measured = behavior.get(path18);
|
|
5494
|
+
if (measured) used.add(path18);
|
|
5495
|
+
emit(`public ${parsed.decl} { ${measured?.body ?? trap(path18)} }`);
|
|
5496
|
+
} else skipped.push({ path: path18, reason: `unhandled top-level ${kind}` });
|
|
5438
5497
|
});
|
|
5439
5498
|
const roots = [...byId.values()].filter((symbol) => !owner.has(symbol.identifier.precise) && !unavailable(symbol)).sort((a, b) => pathOf(a).localeCompare(pathOf(b)));
|
|
5440
5499
|
for (const symbol of roots) {
|
|
5441
|
-
const
|
|
5500
|
+
const path18 = pathOf(symbol);
|
|
5442
5501
|
if (TYPE_KINDS.has(symbol.kind.identifier)) emitType(symbol, "");
|
|
5443
5502
|
else emitGlobal(symbol);
|
|
5444
5503
|
}
|
|
@@ -5480,9 +5539,9 @@ function emitSwiftStandin(graphs, options) {
|
|
|
5480
5539
|
...imports.map((name2) => `import ${name2}`),
|
|
5481
5540
|
""
|
|
5482
5541
|
];
|
|
5483
|
-
for (const
|
|
5484
|
-
if (!used.has(
|
|
5485
|
-
skipped.push({ path:
|
|
5542
|
+
for (const path18 of behavior.keys())
|
|
5543
|
+
if (!used.has(path18))
|
|
5544
|
+
skipped.push({ path: path18, reason: "behavior names no emitted declaration" });
|
|
5486
5545
|
return {
|
|
5487
5546
|
source: `${[...banner, ...lines].join("\n")}
|
|
5488
5547
|
`,
|
|
@@ -5557,7 +5616,7 @@ function stripDefaults(decl) {
|
|
|
5557
5616
|
|
|
5558
5617
|
// src/swift-standins.ts
|
|
5559
5618
|
var TRIPLE = "wasm32-unknown-wasip1";
|
|
5560
|
-
var cacheDir3 =
|
|
5619
|
+
var cacheDir3 = import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-swift-standins");
|
|
5561
5620
|
function exec(file, args, cwd) {
|
|
5562
5621
|
return (0, import_node_child_process7.execFileSync)(file, args, {
|
|
5563
5622
|
cwd,
|
|
@@ -5577,15 +5636,15 @@ var digests = /* @__PURE__ */ new Map();
|
|
|
5577
5636
|
function treeDigest(root) {
|
|
5578
5637
|
const names = [];
|
|
5579
5638
|
const walk2 = (dir) => {
|
|
5580
|
-
for (const entry of
|
|
5581
|
-
const full =
|
|
5639
|
+
for (const entry of import_node_fs12.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name < right.name ? -1 : 1)) {
|
|
5640
|
+
const full = import_node_path12.default.join(dir, entry.name);
|
|
5582
5641
|
if (entry.isDirectory()) walk2(full);
|
|
5583
|
-
else if (entry.isFile()) names.push(
|
|
5642
|
+
else if (entry.isFile()) names.push(import_node_path12.default.relative(root, full));
|
|
5584
5643
|
}
|
|
5585
5644
|
};
|
|
5586
5645
|
walk2(root);
|
|
5587
5646
|
const stamp = names.map((name2) => {
|
|
5588
|
-
const stat =
|
|
5647
|
+
const stat = import_node_fs12.default.statSync(import_node_path12.default.join(root, name2));
|
|
5589
5648
|
return `${name2}\0${stat.size}:${stat.mtimeMs}`;
|
|
5590
5649
|
}).join("\n");
|
|
5591
5650
|
const memo2 = digests.get(`tree\0${root}`);
|
|
@@ -5593,7 +5652,7 @@ function treeDigest(root) {
|
|
|
5593
5652
|
const hash = (0, import_node_crypto6.createHash)("sha256");
|
|
5594
5653
|
for (const name2 of names) {
|
|
5595
5654
|
hash.update(`${name2}\0`);
|
|
5596
|
-
hash.update(
|
|
5655
|
+
hash.update(import_node_fs12.default.readFileSync(import_node_path12.default.join(root, name2)));
|
|
5597
5656
|
hash.update("\0");
|
|
5598
5657
|
}
|
|
5599
5658
|
const digest = hash.digest("hex");
|
|
@@ -5602,9 +5661,9 @@ function treeDigest(root) {
|
|
|
5602
5661
|
}
|
|
5603
5662
|
function locateXcframework(tree) {
|
|
5604
5663
|
const find = (root, depth) => {
|
|
5605
|
-
for (const entry of
|
|
5664
|
+
for (const entry of import_node_fs12.default.readdirSync(root, { withFileTypes: true })) {
|
|
5606
5665
|
if (!entry.isDirectory() || entry.name === "__MACOSX") continue;
|
|
5607
|
-
const full =
|
|
5666
|
+
const full = import_node_path12.default.join(root, entry.name);
|
|
5608
5667
|
if (entry.name.endsWith(".xcframework")) return full;
|
|
5609
5668
|
const nested = depth > 0 ? find(full, depth - 1) : null;
|
|
5610
5669
|
if (nested) return nested;
|
|
@@ -5619,67 +5678,67 @@ function xcframework(binary) {
|
|
|
5619
5678
|
if (binary.url && (!binary.checksum || !/^[a-f0-9]{64}$/i.test(binary.checksum)))
|
|
5620
5679
|
throw new Error("remote binary archive requires its Package.swift SHA-256 checksum");
|
|
5621
5680
|
const expected = binary.checksum?.toLowerCase();
|
|
5622
|
-
const dir =
|
|
5623
|
-
const archive =
|
|
5624
|
-
const fingerprint =
|
|
5681
|
+
const dir = import_node_path12.default.join(cacheDir3, "archives", key(binary.url ? expected : binary.dir));
|
|
5682
|
+
const archive = import_node_path12.default.join(dir, "archive.zip");
|
|
5683
|
+
const fingerprint = import_node_path12.default.join(dir, ".fingerprint");
|
|
5625
5684
|
const stored = (() => {
|
|
5626
5685
|
try {
|
|
5627
|
-
const parsed = JSON.parse(
|
|
5686
|
+
const parsed = JSON.parse(import_node_fs12.default.readFileSync(fingerprint, "utf8"));
|
|
5628
5687
|
return parsed && typeof parsed === "object" && "sha" in parsed ? parsed : null;
|
|
5629
5688
|
} catch {
|
|
5630
5689
|
return null;
|
|
5631
5690
|
}
|
|
5632
5691
|
})();
|
|
5633
5692
|
if (!binary.url) {
|
|
5634
|
-
const stat =
|
|
5693
|
+
const stat = import_node_fs12.default.statSync(binary.dir);
|
|
5635
5694
|
const stamp = `${stat.size}:${stat.mtimeMs}`;
|
|
5636
5695
|
if (stored?.stamp === stamp) {
|
|
5637
|
-
const found3 = locateXcframework(
|
|
5696
|
+
const found3 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5638
5697
|
if (found3) return { dir: found3, digest: stored.sha };
|
|
5639
5698
|
}
|
|
5640
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5641
|
-
if (sha2 !== stored?.sha || !locateXcframework(
|
|
5642
|
-
|
|
5643
|
-
|
|
5644
|
-
exec("unzip", ["-q", binary.dir, "-d",
|
|
5699
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(binary.dir)).digest("hex");
|
|
5700
|
+
if (sha2 !== stored?.sha || !locateXcframework(import_node_path12.default.join(dir, "tree"))) {
|
|
5701
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5702
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5703
|
+
exec("unzip", ["-q", binary.dir, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5645
5704
|
}
|
|
5646
|
-
|
|
5647
|
-
const found2 = locateXcframework(
|
|
5705
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ stamp, sha: sha2 }));
|
|
5706
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5648
5707
|
if (!found2) throw new Error("its archive holds no .xcframework");
|
|
5649
5708
|
return { dir: found2, digest: sha2 };
|
|
5650
5709
|
}
|
|
5651
|
-
if (stored &&
|
|
5652
|
-
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5710
|
+
if (stored && import_node_fs12.default.existsSync(archive)) {
|
|
5711
|
+
const sha2 = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5653
5712
|
if (sha2 !== expected)
|
|
5654
5713
|
throw new Error(`archive checksum ${sha2} is not the declared checksum ${expected}`);
|
|
5655
|
-
const found2 = locateXcframework(
|
|
5714
|
+
const found2 = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5656
5715
|
if (found2) return { dir: found2, digest: sha2 };
|
|
5657
5716
|
}
|
|
5658
|
-
|
|
5659
|
-
|
|
5717
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5718
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.join(dir, "tree"), { recursive: true });
|
|
5660
5719
|
exec("curl", ["-fsSL", "--retry", "2", "-o", archive, binary.url]);
|
|
5661
|
-
const sha = (0, import_node_crypto6.createHash)("sha256").update(
|
|
5720
|
+
const sha = (0, import_node_crypto6.createHash)("sha256").update(import_node_fs12.default.readFileSync(archive)).digest("hex");
|
|
5662
5721
|
if (sha !== expected) {
|
|
5663
|
-
|
|
5722
|
+
import_node_fs12.default.rmSync(dir, { recursive: true, force: true });
|
|
5664
5723
|
throw new Error(`archive checksum ${sha} is not the declared checksum ${expected}`);
|
|
5665
5724
|
}
|
|
5666
|
-
exec("unzip", ["-q", archive, "-d",
|
|
5667
|
-
|
|
5668
|
-
const found = locateXcframework(
|
|
5725
|
+
exec("unzip", ["-q", archive, "-d", import_node_path12.default.join(dir, "tree")]);
|
|
5726
|
+
import_node_fs12.default.writeFileSync(fingerprint, JSON.stringify({ sha }));
|
|
5727
|
+
const found = locateXcframework(import_node_path12.default.join(dir, "tree"));
|
|
5669
5728
|
if (!found) throw new Error("its archive holds no .xcframework");
|
|
5670
5729
|
return { dir: found, digest: sha };
|
|
5671
5730
|
}
|
|
5672
|
-
var files = (dir, test) =>
|
|
5731
|
+
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() : [];
|
|
5673
5732
|
function surfaces(xcframeworkDir) {
|
|
5674
|
-
const slice =
|
|
5733
|
+
const slice = import_node_fs12.default.readdirSync(xcframeworkDir).filter((name2) => /^ios-.+-simulator$/.test(name2)).sort()[0];
|
|
5675
5734
|
if (!slice) throw new Error("it has no iOS simulator slice");
|
|
5676
|
-
const root =
|
|
5735
|
+
const root = import_node_path12.default.join(xcframeworkDir, slice);
|
|
5677
5736
|
const found = [];
|
|
5678
|
-
for (const entry of
|
|
5737
|
+
for (const entry of import_node_fs12.default.readdirSync(root).sort()) {
|
|
5679
5738
|
if (!entry.endsWith(".framework")) continue;
|
|
5680
5739
|
const module2 = entry.slice(0, -".framework".length);
|
|
5681
|
-
const framework =
|
|
5682
|
-
const swiftmodule =
|
|
5740
|
+
const framework = import_node_path12.default.join(root, entry);
|
|
5741
|
+
const swiftmodule = import_node_path12.default.join(framework, "Modules", `${module2}.swiftmodule`);
|
|
5683
5742
|
const interfaces = files(
|
|
5684
5743
|
swiftmodule,
|
|
5685
5744
|
(name2) => name2.endsWith(".swiftinterface") && !name2.endsWith(".private.swiftinterface") && !name2.endsWith(".package.swiftinterface")
|
|
@@ -5689,41 +5748,41 @@ function surfaces(xcframeworkDir) {
|
|
|
5689
5748
|
found.push({
|
|
5690
5749
|
kind: "swift",
|
|
5691
5750
|
module: module2,
|
|
5692
|
-
interface:
|
|
5751
|
+
interface: import_node_path12.default.join(swiftmodule, chosen)
|
|
5693
5752
|
});
|
|
5694
5753
|
continue;
|
|
5695
5754
|
}
|
|
5696
|
-
const modulemap =
|
|
5697
|
-
if (
|
|
5755
|
+
const modulemap = import_node_path12.default.join(framework, "Modules", "module.modulemap");
|
|
5756
|
+
if (import_node_fs12.default.existsSync(modulemap))
|
|
5698
5757
|
found.push({
|
|
5699
5758
|
kind: "c",
|
|
5700
5759
|
module: module2,
|
|
5701
5760
|
modulemap,
|
|
5702
|
-
headers:
|
|
5761
|
+
headers: import_node_path12.default.join(framework, "Headers")
|
|
5703
5762
|
});
|
|
5704
5763
|
}
|
|
5705
|
-
const headers =
|
|
5764
|
+
const headers = import_node_path12.default.join(root, "Headers");
|
|
5706
5765
|
for (const map of files(headers, (name2) => name2 === "module.modulemap")) {
|
|
5707
|
-
const modulemap =
|
|
5708
|
-
const module2 = /(?:^|\s)module\s+(\w+)/.exec(
|
|
5766
|
+
const modulemap = import_node_path12.default.join(headers, map);
|
|
5767
|
+
const module2 = /(?:^|\s)module\s+(\w+)/.exec(import_node_fs12.default.readFileSync(modulemap, "utf8"))?.[1];
|
|
5709
5768
|
if (module2) found.push({ kind: "c", module: module2, modulemap, headers });
|
|
5710
5769
|
}
|
|
5711
5770
|
return found;
|
|
5712
5771
|
}
|
|
5713
5772
|
function peachModuleDirs(toolchain, imports) {
|
|
5714
5773
|
const { moduleRoot, toolchainBin } = toolchain;
|
|
5715
|
-
if (swiftDistributionAt(moduleRoot)) return [
|
|
5774
|
+
if (swiftDistributionAt(moduleRoot)) return [import_node_path12.default.join(moduleRoot, "modules")];
|
|
5716
5775
|
const peach = new Set(swiftPeachModules(moduleRoot));
|
|
5717
5776
|
const plugins = swiftMacroPlugins(moduleRoot);
|
|
5718
5777
|
if (plugins.stale)
|
|
5719
5778
|
exec("sh", [
|
|
5720
|
-
|
|
5779
|
+
import_node_path12.default.join(moduleRoot, "scripts/build-preview-plugin.sh"),
|
|
5721
5780
|
toolchainBin,
|
|
5722
5781
|
plugins.libraries[0]
|
|
5723
5782
|
]);
|
|
5724
5783
|
for (const target of imports.filter((name2) => peach.has(name2)))
|
|
5725
5784
|
exec(
|
|
5726
|
-
|
|
5785
|
+
import_node_path12.default.join(toolchainBin, "swift"),
|
|
5727
5786
|
[
|
|
5728
5787
|
"build",
|
|
5729
5788
|
"--swift-sdk",
|
|
@@ -5743,7 +5802,7 @@ function peachModuleDirs(toolchain, imports) {
|
|
|
5743
5802
|
],
|
|
5744
5803
|
moduleRoot
|
|
5745
5804
|
);
|
|
5746
|
-
return [
|
|
5805
|
+
return [import_node_path12.default.join(moduleRoot, ".build", TRIPLE, "release", "Modules")];
|
|
5747
5806
|
}
|
|
5748
5807
|
function swiftInterfaceForWasm(text3) {
|
|
5749
5808
|
return text3.replace(
|
|
@@ -5755,11 +5814,11 @@ function swiftInterfaceForWasm(text3) {
|
|
|
5755
5814
|
);
|
|
5756
5815
|
}
|
|
5757
5816
|
function swiftStandin(surface, binary, toolchain, work) {
|
|
5758
|
-
const text3 = swiftInterfaceForWasm(
|
|
5759
|
-
const search =
|
|
5760
|
-
const moduleDir =
|
|
5761
|
-
|
|
5762
|
-
|
|
5817
|
+
const text3 = swiftInterfaceForWasm(import_node_fs12.default.readFileSync(surface.interface, "utf8"));
|
|
5818
|
+
const search = import_node_path12.default.join(work, "interfaces");
|
|
5819
|
+
const moduleDir = import_node_path12.default.join(search, `${surface.module}.swiftmodule`);
|
|
5820
|
+
import_node_fs12.default.mkdirSync(moduleDir, { recursive: true });
|
|
5821
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(moduleDir, `${TRIPLE}.swiftinterface`), text3);
|
|
5763
5822
|
const imports = [
|
|
5764
5823
|
...text3.matchAll(
|
|
5765
5824
|
/^(?:@_exported[ \t]+)?import[ \t]+(?:(?:struct|class|enum|protocol|typealias|func|var|let)[ \t]+)?(\w+)/gm
|
|
@@ -5771,9 +5830,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5771
5830
|
);
|
|
5772
5831
|
const target = ["-target", TRIPLE, "-sdk", sysroot, "-resource-dir", resources];
|
|
5773
5832
|
const peach = peachModuleDirs(toolchain, imports).flatMap((dir) => ["-I", dir]);
|
|
5774
|
-
const out =
|
|
5775
|
-
|
|
5776
|
-
exec(
|
|
5833
|
+
const out = import_node_path12.default.join(work, "graphs");
|
|
5834
|
+
import_node_fs12.default.mkdirSync(out, { recursive: true });
|
|
5835
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "swift-symbolgraph-extract"), [
|
|
5777
5836
|
"-module-name",
|
|
5778
5837
|
surface.module,
|
|
5779
5838
|
...target,
|
|
@@ -5787,10 +5846,10 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5787
5846
|
"-output-dir",
|
|
5788
5847
|
out
|
|
5789
5848
|
]);
|
|
5790
|
-
const graphs =
|
|
5849
|
+
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")));
|
|
5791
5850
|
const omit = /* @__PURE__ */ new Map();
|
|
5792
5851
|
const plain = /* @__PURE__ */ new Set();
|
|
5793
|
-
const file =
|
|
5852
|
+
const file = import_node_path12.default.join(work, `${surface.module}.swift`);
|
|
5794
5853
|
for (; ; ) {
|
|
5795
5854
|
const { source, owners } = emitSwiftStandin(graphs, {
|
|
5796
5855
|
module: surface.module,
|
|
@@ -5798,9 +5857,9 @@ function swiftStandin(surface, binary, toolchain, work) {
|
|
|
5798
5857
|
omit,
|
|
5799
5858
|
plain
|
|
5800
5859
|
});
|
|
5801
|
-
|
|
5860
|
+
import_node_fs12.default.writeFileSync(file, source);
|
|
5802
5861
|
const check = (0, import_node_child_process7.spawnSync)(
|
|
5803
|
-
|
|
5862
|
+
import_node_path12.default.join(toolchain.toolchainBin, "swiftc"),
|
|
5804
5863
|
[
|
|
5805
5864
|
"-typecheck",
|
|
5806
5865
|
"-parse-as-library",
|
|
@@ -5950,21 +6009,21 @@ function splitDeclarators(statement, names) {
|
|
|
5950
6009
|
}
|
|
5951
6010
|
function cStandin(surface, binary, toolchain, work) {
|
|
5952
6011
|
const named = [
|
|
5953
|
-
...
|
|
6012
|
+
...import_node_fs12.default.readFileSync(surface.modulemap, "utf8").matchAll(/(?:umbrella\s+)?header\s+"([^"]+)"/g)
|
|
5954
6013
|
].map((match) => match[1]);
|
|
5955
6014
|
const headers = files(surface.headers, (name2) => name2.endsWith(".h"));
|
|
5956
6015
|
const texts = new Map(
|
|
5957
6016
|
headers.map((file) => [
|
|
5958
6017
|
file,
|
|
5959
|
-
|
|
6018
|
+
import_node_fs12.default.readFileSync(import_node_path12.default.join(surface.headers, file), "utf8")
|
|
5960
6019
|
])
|
|
5961
6020
|
);
|
|
5962
6021
|
const objc = headers.find((file) => OBJC.test(texts.get(file)));
|
|
5963
6022
|
if (objc) throw new Error(`its header ${objc} is Objective-C`);
|
|
5964
|
-
const include =
|
|
6023
|
+
const include = import_node_path12.default.join(work, "include");
|
|
5965
6024
|
for (const [file, text3] of texts) {
|
|
5966
|
-
|
|
5967
|
-
|
|
6025
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(import_node_path12.default.join(include, file)), { recursive: true });
|
|
6026
|
+
import_node_fs12.default.writeFileSync(import_node_path12.default.join(include, file), text3);
|
|
5968
6027
|
}
|
|
5969
6028
|
const roots = named.length > 0 ? named : headers;
|
|
5970
6029
|
const modulemap = `module ${surface.module} {
|
|
@@ -5972,12 +6031,12 @@ ${roots.map((file) => ` header "${file}"
|
|
|
5972
6031
|
`).join("")} export *
|
|
5973
6032
|
}
|
|
5974
6033
|
`;
|
|
5975
|
-
const probe =
|
|
5976
|
-
|
|
6034
|
+
const probe = import_node_path12.default.join(work, "declarations.c");
|
|
6035
|
+
import_node_fs12.default.writeFileSync(probe, roots.map((file) => `#include "${file}"
|
|
5977
6036
|
`).join(""));
|
|
5978
6037
|
const { sysroot } = swiftSdkPaths(toolchain.moduleRoot, toolchain.toolchainBin);
|
|
5979
6038
|
const ast = JSON.parse(
|
|
5980
|
-
exec(
|
|
6039
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
5981
6040
|
"-target",
|
|
5982
6041
|
TRIPLE,
|
|
5983
6042
|
"--sysroot",
|
|
@@ -5990,7 +6049,7 @@ ${roots.map((file) => ` header "${file}"
|
|
|
5990
6049
|
probe
|
|
5991
6050
|
])
|
|
5992
6051
|
);
|
|
5993
|
-
const byPath = new Map(headers.map((file) => [
|
|
6052
|
+
const byPath = new Map(headers.map((file) => [import_node_path12.default.join(include, file), file]));
|
|
5994
6053
|
const declarations = functionDeclarations(ast, new Set(byPath.keys()));
|
|
5995
6054
|
const groups = /* @__PURE__ */ new Map();
|
|
5996
6055
|
for (const declaration of declarations) {
|
|
@@ -6037,10 +6096,10 @@ ${roots.map((file) => ` header "${file}"
|
|
|
6037
6096
|
"",
|
|
6038
6097
|
...definitions
|
|
6039
6098
|
].join("\n");
|
|
6040
|
-
const out =
|
|
6041
|
-
|
|
6099
|
+
const out = import_node_path12.default.join(work, `${surface.module}.c`);
|
|
6100
|
+
import_node_fs12.default.writeFileSync(out, source);
|
|
6042
6101
|
try {
|
|
6043
|
-
exec(
|
|
6102
|
+
exec(import_node_path12.default.join(toolchain.toolchainBin, "clang"), [
|
|
6044
6103
|
"-target",
|
|
6045
6104
|
TRIPLE,
|
|
6046
6105
|
"--sysroot",
|
|
@@ -6122,25 +6181,25 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6122
6181
|
for (const file of surface.kind === "swift" ? [surface.interface] : [
|
|
6123
6182
|
surface.modulemap,
|
|
6124
6183
|
...files(surface.headers, (name2) => name2.endsWith(".h")).map(
|
|
6125
|
-
(file2) =>
|
|
6184
|
+
(file2) => import_node_path12.default.join(surface.headers, file2)
|
|
6126
6185
|
)
|
|
6127
6186
|
])
|
|
6128
|
-
hash.update(
|
|
6187
|
+
hash.update(import_node_fs12.default.readFileSync(file));
|
|
6129
6188
|
}
|
|
6130
6189
|
const id = hash.digest("hex").slice(0, 32);
|
|
6131
6190
|
const memo2 = built.get(id);
|
|
6132
6191
|
if (memo2) return memo2;
|
|
6133
|
-
const cached2 =
|
|
6134
|
-
if (
|
|
6135
|
-
const value = JSON.parse(
|
|
6192
|
+
const cached2 = import_node_path12.default.join(cacheDir3, "standins", `${id}.json`);
|
|
6193
|
+
if (import_node_fs12.default.existsSync(cached2)) {
|
|
6194
|
+
const value = JSON.parse(import_node_fs12.default.readFileSync(cached2, "utf8"));
|
|
6136
6195
|
built.set(id, value);
|
|
6137
6196
|
return value;
|
|
6138
6197
|
}
|
|
6139
|
-
const work =
|
|
6198
|
+
const work = import_node_fs12.default.mkdtempSync(import_node_path12.default.join(import_node_os7.default.tmpdir(), "peach-standin-"));
|
|
6140
6199
|
let result;
|
|
6141
6200
|
try {
|
|
6142
6201
|
result = found.map((surface) => {
|
|
6143
|
-
const dir =
|
|
6202
|
+
const dir = import_node_path12.default.join(work, surface.module);
|
|
6144
6203
|
try {
|
|
6145
6204
|
return surface.kind === "swift" ? swiftStandin(surface, binary, toolchain, dir) : cStandin(surface, binary, toolchain, dir);
|
|
6146
6205
|
} catch (error) {
|
|
@@ -6149,13 +6208,13 @@ function binaryStandins(binary, toolchain, provided) {
|
|
|
6149
6208
|
);
|
|
6150
6209
|
}
|
|
6151
6210
|
});
|
|
6152
|
-
|
|
6153
|
-
|
|
6211
|
+
import_node_fs12.default.mkdirSync(import_node_path12.default.dirname(cached2), { recursive: true });
|
|
6212
|
+
import_node_fs12.default.writeFileSync(cached2, JSON.stringify(result));
|
|
6154
6213
|
built.set(id, result);
|
|
6155
6214
|
} catch (error) {
|
|
6156
6215
|
result = error instanceof Error ? error.message : String(error);
|
|
6157
6216
|
} finally {
|
|
6158
|
-
|
|
6217
|
+
import_node_fs12.default.rmSync(work, { recursive: true, force: true });
|
|
6159
6218
|
}
|
|
6160
6219
|
return result;
|
|
6161
6220
|
}
|
|
@@ -6307,12 +6366,12 @@ async function compileSwiftProject(submit, work, origin, signal) {
|
|
|
6307
6366
|
}
|
|
6308
6367
|
|
|
6309
6368
|
// src/xcode-project.ts
|
|
6310
|
-
var
|
|
6311
|
-
var
|
|
6369
|
+
var import_node_fs13 = __toESM(require("node:fs"), 1);
|
|
6370
|
+
var import_node_path14 = __toESM(require("node:path"), 1);
|
|
6312
6371
|
var import_plist = __toESM(require_plist(), 1);
|
|
6313
6372
|
|
|
6314
6373
|
// src/xcode-json-project.ts
|
|
6315
|
-
var
|
|
6374
|
+
var import_node_path13 = __toESM(require("node:path"), 1);
|
|
6316
6375
|
var import_json5 = __toESM(require_lib(), 1);
|
|
6317
6376
|
var isObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6318
6377
|
var text2 = (value) => typeof value === "string" ? value : void 0;
|
|
@@ -6328,7 +6387,7 @@ var PHASE_ISA = {
|
|
|
6328
6387
|
function readXcodeJsonProject(xcodeproj, source) {
|
|
6329
6388
|
const json = import_json5.default.parse(source);
|
|
6330
6389
|
if (!isJsonObject(json)) throw new Error(`${xcodeproj}/project.xcproj is not an object`);
|
|
6331
|
-
const projectDir =
|
|
6390
|
+
const projectDir = import_node_path13.default.dirname(xcodeproj);
|
|
6332
6391
|
const objects = {};
|
|
6333
6392
|
let next = 0;
|
|
6334
6393
|
const add = (entry, id) => {
|
|
@@ -6341,7 +6400,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6341
6400
|
const base = /^<([A-Z]+)>\/(.*)$/.exec(raw2);
|
|
6342
6401
|
if (base) {
|
|
6343
6402
|
if (base[1] === "PROJECT")
|
|
6344
|
-
return { sourceTree: "<absolute>", path:
|
|
6403
|
+
return { sourceTree: "<absolute>", path: import_node_path13.default.join(projectDir, base[2]) };
|
|
6345
6404
|
if (base[1] === "PRODUCTS")
|
|
6346
6405
|
return { sourceTree: "BUILT_PRODUCTS_DIR", path: base[2] };
|
|
6347
6406
|
return null;
|
|
@@ -6349,7 +6408,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6349
6408
|
const unescaped = raw2.replaceAll("\\<", "<");
|
|
6350
6409
|
if (unescaped.startsWith("/")) return { sourceTree: "<absolute>", path: unescaped };
|
|
6351
6410
|
if (unescaped.startsWith("~")) return null;
|
|
6352
|
-
return groupDir === null ? null : { sourceTree: "<absolute>", path:
|
|
6411
|
+
return groupDir === null ? null : { sourceTree: "<absolute>", path: import_node_path13.default.join(groupDir, unescaped) };
|
|
6353
6412
|
};
|
|
6354
6413
|
const memberships = [];
|
|
6355
6414
|
const folders = [];
|
|
@@ -6360,7 +6419,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6360
6419
|
const kind = text2(entry.kind) ?? "file-reference";
|
|
6361
6420
|
const raw2 = text2(entry.path) ?? "";
|
|
6362
6421
|
const located = raw2 === "" ? null : locate(raw2, parent.dir);
|
|
6363
|
-
const name2 = text2(entry.name) ??
|
|
6422
|
+
const name2 = text2(entry.name) ?? import_node_path13.default.basename(raw2);
|
|
6364
6423
|
const node = { id: "", name: name2, dir: null, parent, children: [] };
|
|
6365
6424
|
if (kind === "group" || kind === "variant-group" || kind === "version-group") {
|
|
6366
6425
|
node.dir = raw2 === "" ? parent.dir : located?.sourceTree === "<absolute>" ? located.path : null;
|
|
@@ -6475,7 +6534,7 @@ function readXcodeJsonProject(xcodeproj, source) {
|
|
|
6475
6534
|
if (!isObject(entry)) continue;
|
|
6476
6535
|
const repository = text2(entry.repository);
|
|
6477
6536
|
const local = text2(entry.path);
|
|
6478
|
-
const name2 = local !== void 0 ?
|
|
6537
|
+
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$/, "");
|
|
6479
6538
|
const id = text2(entry.kind) === "local" && local !== void 0 ? add({ isa: "XCLocalSwiftPackageReference", relativePath: local }) : add({ isa: "XCRemoteSwiftPackageReference", repositoryURL: repository ?? "" });
|
|
6480
6539
|
packageIds.set(name2.toLowerCase(), id);
|
|
6481
6540
|
}
|
|
@@ -6752,28 +6811,28 @@ var CONDITIONS = {
|
|
|
6752
6811
|
variant: "normal"
|
|
6753
6812
|
};
|
|
6754
6813
|
function walkFiles(dir) {
|
|
6755
|
-
if (!
|
|
6814
|
+
if (!import_node_fs13.default.existsSync(dir)) return [];
|
|
6756
6815
|
const out = [];
|
|
6757
|
-
for (const entry of
|
|
6816
|
+
for (const entry of import_node_fs13.default.readdirSync(dir, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
6758
6817
|
if (entry.name.startsWith(".")) continue;
|
|
6759
|
-
const full =
|
|
6818
|
+
const full = import_node_path14.default.join(dir, entry.name);
|
|
6760
6819
|
if (entry.isDirectory()) out.push(...walkFiles(full));
|
|
6761
6820
|
else if (entry.isFile()) out.push(full);
|
|
6762
6821
|
}
|
|
6763
6822
|
return out;
|
|
6764
6823
|
}
|
|
6765
|
-
var isDirectory = (dir) =>
|
|
6824
|
+
var isDirectory = (dir) => import_node_fs13.default.existsSync(dir) && import_node_fs13.default.statSync(dir).isDirectory();
|
|
6766
6825
|
function readXcconfig(file, seen = /* @__PURE__ */ new Set()) {
|
|
6767
|
-
if (seen.has(file) || !
|
|
6826
|
+
if (seen.has(file) || !import_node_fs13.default.existsSync(file)) return {};
|
|
6768
6827
|
seen.add(file);
|
|
6769
6828
|
const settings = {};
|
|
6770
|
-
for (const raw2 of
|
|
6829
|
+
for (const raw2 of import_node_fs13.default.readFileSync(file, "utf8").split("\n")) {
|
|
6771
6830
|
const line = raw2.replace(/\/\/.*$/, "").trim();
|
|
6772
6831
|
const include = /^#include\??\s+"([^"]+)"/.exec(line);
|
|
6773
6832
|
if (include) {
|
|
6774
6833
|
Object.assign(
|
|
6775
6834
|
settings,
|
|
6776
|
-
readXcconfig(
|
|
6835
|
+
readXcconfig(import_node_path14.default.resolve(import_node_path14.default.dirname(file), include[1]), seen)
|
|
6777
6836
|
);
|
|
6778
6837
|
continue;
|
|
6779
6838
|
}
|
|
@@ -6823,22 +6882,22 @@ function decodeXml(text3) {
|
|
|
6823
6882
|
return text3.replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
6824
6883
|
}
|
|
6825
6884
|
function workspaceReferences(workspace) {
|
|
6826
|
-
const data =
|
|
6827
|
-
if (!
|
|
6885
|
+
const data = import_node_path14.default.join(workspace, "contents.xcworkspacedata");
|
|
6886
|
+
if (!import_node_fs13.default.existsSync(data))
|
|
6828
6887
|
throw new Error(`${workspace} has no contents.xcworkspacedata`);
|
|
6829
|
-
const container =
|
|
6888
|
+
const container = import_node_path14.default.dirname(workspace);
|
|
6830
6889
|
const locate = (location, base) => {
|
|
6831
6890
|
const colon = location.indexOf(":");
|
|
6832
6891
|
const kind = location.slice(0, colon);
|
|
6833
6892
|
const rest = location.slice(colon + 1);
|
|
6834
|
-
if (kind === "group") return
|
|
6835
|
-
if (kind === "container" || kind === "self") return
|
|
6836
|
-
if (kind === "absolute") return
|
|
6837
|
-
throw new Error(`${
|
|
6893
|
+
if (kind === "group") return import_node_path14.default.resolve(base, rest);
|
|
6894
|
+
if (kind === "container" || kind === "self") return import_node_path14.default.resolve(container, rest);
|
|
6895
|
+
if (kind === "absolute") return import_node_path14.default.resolve(rest);
|
|
6896
|
+
throw new Error(`${import_node_path14.default.basename(workspace)} has an unsupported location ${location}`);
|
|
6838
6897
|
};
|
|
6839
6898
|
const groups = [container];
|
|
6840
6899
|
const references = [];
|
|
6841
|
-
for (const [, closing, tag, attributes, selfClosing] of
|
|
6900
|
+
for (const [, closing, tag, attributes, selfClosing] of import_node_fs13.default.readFileSync(data, "utf8").matchAll(/<(\/?)(Group|FileRef)\b([^>]*?)(\/?)>/g)) {
|
|
6842
6901
|
if (closing) {
|
|
6843
6902
|
if (tag === "Group") groups.pop();
|
|
6844
6903
|
continue;
|
|
@@ -6854,8 +6913,8 @@ function workspaceReferences(workspace) {
|
|
|
6854
6913
|
var loaded = /* @__PURE__ */ new Map();
|
|
6855
6914
|
function xcodeProjectFile(xcodeproj) {
|
|
6856
6915
|
for (const name2 of ["project.pbxproj", "project.xcproj"]) {
|
|
6857
|
-
const file =
|
|
6858
|
-
if (
|
|
6916
|
+
const file = import_node_path14.default.join(xcodeproj, name2);
|
|
6917
|
+
if (import_node_fs13.default.existsSync(file)) return file;
|
|
6859
6918
|
}
|
|
6860
6919
|
return null;
|
|
6861
6920
|
}
|
|
@@ -6863,10 +6922,10 @@ function loadProject(xcodeproj) {
|
|
|
6863
6922
|
const projectFile = xcodeProjectFile(xcodeproj);
|
|
6864
6923
|
if (!projectFile)
|
|
6865
6924
|
throw new Error(`${xcodeproj} has no project.pbxproj or project.xcproj`);
|
|
6866
|
-
const mtimeMs =
|
|
6925
|
+
const mtimeMs = import_node_fs13.default.statSync(projectFile).mtimeMs;
|
|
6867
6926
|
const cached2 = loaded.get(projectFile);
|
|
6868
6927
|
if (cached2?.mtimeMs === mtimeMs) return cached2.project;
|
|
6869
|
-
const source =
|
|
6928
|
+
const source = import_node_fs13.default.readFileSync(projectFile, "utf8");
|
|
6870
6929
|
const root = projectFile.endsWith(".xcproj") ? readXcodeJsonProject(xcodeproj, source) : parseOpenStepPlist(source);
|
|
6871
6930
|
if (!isDict(root) || !isDict(root.objects)) {
|
|
6872
6931
|
throw new Error(`${projectFile} has no objects table`);
|
|
@@ -6880,8 +6939,8 @@ function loadProject(xcodeproj) {
|
|
|
6880
6939
|
if (!project || project.isa !== "PBXProject") {
|
|
6881
6940
|
throw new Error(`${projectFile} has no PBXProject root`);
|
|
6882
6941
|
}
|
|
6883
|
-
const projectDir =
|
|
6884
|
-
|
|
6942
|
+
const projectDir = import_node_fs13.default.realpathSync(
|
|
6943
|
+
import_node_path14.default.resolve(import_node_path14.default.dirname(xcodeproj), str(project.projectDirPath) ?? "")
|
|
6885
6944
|
);
|
|
6886
6945
|
const parent = /* @__PURE__ */ new Map();
|
|
6887
6946
|
for (const [id, entry] of Object.entries(objects)) {
|
|
@@ -6899,11 +6958,11 @@ function loadProject(xcodeproj) {
|
|
|
6899
6958
|
const own = str(entry.path) ?? "";
|
|
6900
6959
|
const tree = str(entry.sourceTree) ?? "<group>";
|
|
6901
6960
|
if (tree === "<absolute>") result2 = own;
|
|
6902
|
-
else if (tree === "SOURCE_ROOT") result2 =
|
|
6961
|
+
else if (tree === "SOURCE_ROOT") result2 = import_node_path14.default.join(projectDir, own);
|
|
6903
6962
|
else if (tree === "<group>") {
|
|
6904
6963
|
const up = parent.get(id);
|
|
6905
6964
|
const base = up ? resolvePath(up) : projectDir;
|
|
6906
|
-
result2 = base === null ? null :
|
|
6965
|
+
result2 = base === null ? null : import_node_path14.default.join(base, own);
|
|
6907
6966
|
}
|
|
6908
6967
|
}
|
|
6909
6968
|
resolvedPaths.set(id, result2);
|
|
@@ -7003,7 +7062,7 @@ function targetMembers(ref) {
|
|
|
7003
7062
|
const addResource = (file) => {
|
|
7004
7063
|
if (isDirectory(file)) {
|
|
7005
7064
|
for (const inner of walkFiles(file)) resources.add(inner);
|
|
7006
|
-
} else if (
|
|
7065
|
+
} else if (import_node_fs13.default.existsSync(file)) resources.add(file);
|
|
7007
7066
|
};
|
|
7008
7067
|
const fileRefPaths = (refId) => {
|
|
7009
7068
|
const entry = project.object(refId);
|
|
@@ -7024,7 +7083,7 @@ function targetMembers(ref) {
|
|
|
7024
7083
|
for (const buildFileId of list(phase.files)) {
|
|
7025
7084
|
for (const file of fileRefPaths(str(project.object(buildFileId)?.fileRef) ?? "")) {
|
|
7026
7085
|
if (phase.isa === "PBXSourcesBuildPhase") {
|
|
7027
|
-
if (!
|
|
7086
|
+
if (!import_node_fs13.default.existsSync(file)) continue;
|
|
7028
7087
|
allSources.add(file);
|
|
7029
7088
|
if (file.endsWith(".swift")) sources.add(file);
|
|
7030
7089
|
} else if (phase.isa === "PBXResourcesBuildPhase") addResource(file);
|
|
@@ -7032,7 +7091,7 @@ function targetMembers(ref) {
|
|
|
7032
7091
|
}
|
|
7033
7092
|
}
|
|
7034
7093
|
const addSynchronized = (folder, relative) => {
|
|
7035
|
-
const file =
|
|
7094
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7036
7095
|
if (NEVER_MEMBER.test(relative)) return;
|
|
7037
7096
|
if (file.endsWith(".swift")) {
|
|
7038
7097
|
if (!relative.split("/").some((segment) => BUNDLE_DIR.test(segment))) {
|
|
@@ -7057,7 +7116,7 @@ function targetMembers(ref) {
|
|
|
7057
7116
|
}
|
|
7058
7117
|
if (owned.has(groupId)) {
|
|
7059
7118
|
for (const file of walkFiles(folder)) {
|
|
7060
|
-
const relative =
|
|
7119
|
+
const relative = import_node_path14.default.relative(folder, file).split(import_node_path14.default.sep).join("/");
|
|
7061
7120
|
if ([...exceptions].some(
|
|
7062
7121
|
(exception) => relative === exception || relative.startsWith(`${exception}/`)
|
|
7063
7122
|
))
|
|
@@ -7066,14 +7125,14 @@ function targetMembers(ref) {
|
|
|
7066
7125
|
}
|
|
7067
7126
|
} else {
|
|
7068
7127
|
for (const relative of exceptions) {
|
|
7069
|
-
const file =
|
|
7128
|
+
const file = import_node_path14.default.join(folder, relative);
|
|
7070
7129
|
if (isDirectory(file)) {
|
|
7071
7130
|
for (const inner of walkFiles(file))
|
|
7072
7131
|
addSynchronized(
|
|
7073
7132
|
folder,
|
|
7074
|
-
|
|
7133
|
+
import_node_path14.default.relative(folder, inner).split(import_node_path14.default.sep).join("/")
|
|
7075
7134
|
);
|
|
7076
|
-
} else if (
|
|
7135
|
+
} else if (import_node_fs13.default.existsSync(file)) addSynchronized(folder, relative);
|
|
7077
7136
|
}
|
|
7078
7137
|
}
|
|
7079
7138
|
}
|
|
@@ -7086,8 +7145,8 @@ function targetMembers(ref) {
|
|
|
7086
7145
|
function commonAncestor(dirs) {
|
|
7087
7146
|
let common = dirs[0];
|
|
7088
7147
|
for (const dir of dirs) {
|
|
7089
|
-
while (common !==
|
|
7090
|
-
common =
|
|
7148
|
+
while (common !== import_node_path14.default.dirname(common) && import_node_path14.default.relative(common, dir).startsWith(".."))
|
|
7149
|
+
common = import_node_path14.default.dirname(common);
|
|
7091
7150
|
}
|
|
7092
7151
|
return common;
|
|
7093
7152
|
}
|
|
@@ -7096,8 +7155,8 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7096
7155
|
const projects2 = [];
|
|
7097
7156
|
const projectAt = /* @__PURE__ */ new Map();
|
|
7098
7157
|
const addProject = (xcodeproj) => {
|
|
7099
|
-
const key2 =
|
|
7100
|
-
if (projectAt.has(key2) || key2.split(
|
|
7158
|
+
const key2 = import_node_path14.default.resolve(xcodeproj);
|
|
7159
|
+
if (projectAt.has(key2) || key2.split(import_node_path14.default.sep).includes("Pods")) return;
|
|
7101
7160
|
if (!xcodeProjectFile(key2)) return;
|
|
7102
7161
|
const project = loadProject(key2);
|
|
7103
7162
|
projectAt.set(key2, project);
|
|
@@ -7114,7 +7173,7 @@ function workspaceProjects(xcodeprojOrWorkspace) {
|
|
|
7114
7173
|
for (const reference of listed)
|
|
7115
7174
|
if (reference.endsWith(".xcodeproj")) addProject(reference);
|
|
7116
7175
|
if (projects2.length === 0) {
|
|
7117
|
-
throw new Error(`${
|
|
7176
|
+
throw new Error(`${import_node_path14.default.basename(xcodeprojOrWorkspace)} lists no Xcode project`);
|
|
7118
7177
|
}
|
|
7119
7178
|
return { listed, projects: projects2, projectAt };
|
|
7120
7179
|
}
|
|
@@ -7136,7 +7195,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7136
7195
|
const allTargets = projects2.flatMap(nativeTargets);
|
|
7137
7196
|
const appTargets = allTargets.filter((ref) => ref.target.productType === APPLICATION);
|
|
7138
7197
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id);
|
|
7139
|
-
const container =
|
|
7198
|
+
const container = import_node_path14.default.basename(xcodeprojOrWorkspace);
|
|
7140
7199
|
const named = targetName ? appTargets.filter((ref) => ref.target.name === targetName) : appTargets;
|
|
7141
7200
|
if (named.length !== 1) {
|
|
7142
7201
|
throw new Error(
|
|
@@ -7148,14 +7207,14 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7148
7207
|
for (const ref of allTargets) {
|
|
7149
7208
|
const product = ref.project.object(str(ref.target.productReference));
|
|
7150
7209
|
const file = str(product?.path);
|
|
7151
|
-
if (file && !byProduct.has(
|
|
7152
|
-
byProduct.set(
|
|
7210
|
+
if (file && !byProduct.has(import_node_path14.default.basename(file)))
|
|
7211
|
+
byProduct.set(import_node_path14.default.basename(file), ref);
|
|
7153
7212
|
}
|
|
7154
7213
|
const proxied = (project, proxyId) => {
|
|
7155
7214
|
const proxy = project.object(proxyId);
|
|
7156
7215
|
if (proxy?.isa !== "PBXContainerItemProxy") return void 0;
|
|
7157
7216
|
const portal = str(proxy.containerPortal);
|
|
7158
|
-
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(
|
|
7217
|
+
const owner = project.object(portal)?.isa === "PBXProject" ? project : projectAt.get(import_node_path14.default.resolve(project.resolvePath(portal ?? "") ?? ""));
|
|
7159
7218
|
const remote = str(proxy.remoteGlobalIDString);
|
|
7160
7219
|
if (!owner || !remote) return void 0;
|
|
7161
7220
|
return nativeTargets(owner).find(
|
|
@@ -7176,7 +7235,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7176
7235
|
if (phase?.isa !== "PBXFrameworksBuildPhase") continue;
|
|
7177
7236
|
for (const buildFileId of list(phase.files)) {
|
|
7178
7237
|
const file = project.object(str(project.object(buildFileId)?.fileRef));
|
|
7179
|
-
const resolved = file?.isa === "PBXReferenceProxy" ? proxied(project, str(file.remoteRef)) : file && str(file.sourceTree) === "BUILT_PRODUCTS_DIR" ? byProduct.get(
|
|
7238
|
+
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;
|
|
7180
7239
|
if (resolved) found.push(resolved);
|
|
7181
7240
|
}
|
|
7182
7241
|
}
|
|
@@ -7197,7 +7256,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7197
7256
|
const name2 = str(ref.target.name) ?? ref.id;
|
|
7198
7257
|
const { get: settings2, keys } = targetSettings(ref, {
|
|
7199
7258
|
TARGET_NAME: name2,
|
|
7200
|
-
PROJECT_NAME:
|
|
7259
|
+
PROJECT_NAME: import_node_path14.default.basename(ref.project.xcodeproj, ".xcodeproj"),
|
|
7201
7260
|
SRCROOT: ref.project.projectDir,
|
|
7202
7261
|
SOURCE_ROOT: ref.project.projectDir,
|
|
7203
7262
|
PROJECT_DIR: ref.project.projectDir,
|
|
@@ -7228,8 +7287,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7228
7287
|
}
|
|
7229
7288
|
return value;
|
|
7230
7289
|
};
|
|
7231
|
-
const infoPlistFile = settings("INFOPLIST_FILE") ?
|
|
7232
|
-
const sourceInfo = infoPlistFile ? import_plist.default.parse(
|
|
7290
|
+
const infoPlistFile = settings("INFOPLIST_FILE") ? import_node_path14.default.resolve(app.project.projectDir, settings("INFOPLIST_FILE")) : null;
|
|
7291
|
+
const sourceInfo = infoPlistFile ? import_plist.default.parse(import_node_fs13.default.readFileSync(infoPlistFile, "utf8")) : {};
|
|
7233
7292
|
if (!sourceInfo || typeof sourceInfo !== "object" || Array.isArray(sourceInfo) || sourceInfo instanceof Date || Buffer.isBuffer(sourceInfo)) {
|
|
7234
7293
|
throw new Error(`${module2.name} Info.plist must contain a dictionary`);
|
|
7235
7294
|
}
|
|
@@ -7247,12 +7306,12 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7247
7306
|
};
|
|
7248
7307
|
}
|
|
7249
7308
|
const localPackageDirs = [
|
|
7250
|
-
...listed.filter((reference) =>
|
|
7309
|
+
...listed.filter((reference) => import_node_fs13.default.existsSync(import_node_path14.default.join(reference, "Package.swift"))),
|
|
7251
7310
|
...projects2.flatMap(
|
|
7252
7311
|
(project) => Object.entries(project.objects).flatMap(([id, entry]) => {
|
|
7253
7312
|
if (!isDict(entry)) return [];
|
|
7254
|
-
const candidate = entry.isa === "XCLocalSwiftPackageReference" ?
|
|
7255
|
-
return candidate &&
|
|
7313
|
+
const candidate = entry.isa === "XCLocalSwiftPackageReference" ? import_node_path14.default.resolve(project.projectDir, str(entry.relativePath) ?? "") : entry.isa === "PBXFileReference" ? project.resolvePath(id) : null;
|
|
7314
|
+
return candidate && import_node_fs13.default.existsSync(import_node_path14.default.join(candidate, "Package.swift")) ? [candidate] : [];
|
|
7256
7315
|
})
|
|
7257
7316
|
)
|
|
7258
7317
|
];
|
|
@@ -7276,7 +7335,7 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7276
7335
|
product,
|
|
7277
7336
|
source: reference?.isa === "XCRemoteSwiftPackageReference" ? { kind: "remote", url: str(reference.repositoryURL) ?? "" } : reference?.isa === "XCLocalSwiftPackageReference" ? {
|
|
7278
7337
|
kind: "local",
|
|
7279
|
-
dir:
|
|
7338
|
+
dir: import_node_path14.default.resolve(
|
|
7280
7339
|
project.projectDir,
|
|
7281
7340
|
str(reference.relativePath) ?? ""
|
|
7282
7341
|
)
|
|
@@ -7298,8 +7357,8 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7298
7357
|
}
|
|
7299
7358
|
}
|
|
7300
7359
|
}
|
|
7301
|
-
const resolvedFile =
|
|
7302
|
-
workspace ??
|
|
7360
|
+
const resolvedFile = import_node_path14.default.join(
|
|
7361
|
+
workspace ?? import_node_path14.default.join(xcodeprojOrWorkspace, "project.xcworkspace"),
|
|
7303
7362
|
"xcshareddata",
|
|
7304
7363
|
"swiftpm",
|
|
7305
7364
|
"Package.resolved"
|
|
@@ -7309,13 +7368,13 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7309
7368
|
...module2,
|
|
7310
7369
|
rootDir: commonAncestor(
|
|
7311
7370
|
[
|
|
7312
|
-
workspace ?
|
|
7371
|
+
workspace ? import_node_path14.default.dirname(workspace) : app.project.projectDir,
|
|
7313
7372
|
...used.map((project) => project.projectDir),
|
|
7314
7373
|
...localPackageDirs,
|
|
7315
7374
|
...linkedProducts.flatMap(
|
|
7316
|
-
({ source }) => source.kind === "local" &&
|
|
7375
|
+
({ source }) => source.kind === "local" && import_node_fs13.default.existsSync(source.dir) ? [source.dir] : []
|
|
7317
7376
|
)
|
|
7318
|
-
].map((dir) =>
|
|
7377
|
+
].map((dir) => import_node_fs13.default.realpathSync(dir))
|
|
7319
7378
|
),
|
|
7320
7379
|
projectFiles: [...new Set(used.map((project) => project.projectFile))].sort(),
|
|
7321
7380
|
infoPlist: import_plist.default.build(info),
|
|
@@ -7323,10 +7382,10 @@ function readXcodeAppTarget(xcodeprojOrWorkspace, targetName) {
|
|
|
7323
7382
|
frameworks,
|
|
7324
7383
|
linkedProducts,
|
|
7325
7384
|
localPackageDirs: [
|
|
7326
|
-
...new Set(localPackageDirs.map((dir) =>
|
|
7385
|
+
...new Set(localPackageDirs.map((dir) => import_node_fs13.default.realpathSync(dir)))
|
|
7327
7386
|
].sort(),
|
|
7328
7387
|
binaryFrameworks: [...binaryFrameworks].sort(),
|
|
7329
|
-
packageResolved:
|
|
7388
|
+
packageResolved: import_node_fs13.default.existsSync(resolvedFile) ? resolvedFile : null,
|
|
7330
7389
|
appTargets: appTargetNames
|
|
7331
7390
|
};
|
|
7332
7391
|
}
|
|
@@ -7346,17 +7405,17 @@ var SKIP_SOURCE_DIRS = /* @__PURE__ */ new Set([
|
|
|
7346
7405
|
var NATIVE_DESCRIPTOR = ".one-native-source.json";
|
|
7347
7406
|
var NATIVE_GLUE = ".one-native-source.swift.txt";
|
|
7348
7407
|
function swiftPackageId(packagePath) {
|
|
7349
|
-
return
|
|
7408
|
+
return import_node_path15.default.basename(packagePath).replace(/[^A-Za-z0-9_]/g, "_").replace(/^(\d)/, "_$1");
|
|
7350
7409
|
}
|
|
7351
7410
|
function nativeSourceDescriptor(packagePath) {
|
|
7352
|
-
packagePath =
|
|
7353
|
-
const file =
|
|
7354
|
-
if (!
|
|
7411
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7412
|
+
const file = import_node_path15.default.join(packagePath, NATIVE_DESCRIPTOR);
|
|
7413
|
+
if (!import_node_fs14.default.existsSync(file)) return null;
|
|
7355
7414
|
const value = JSON.parse(
|
|
7356
7415
|
readPackageFile(packagePath, file, MAX_SWIFT_COMPILE_SOURCE_BYTES).toString("utf8")
|
|
7357
7416
|
);
|
|
7358
7417
|
const invalid = () => new Error(`${file}: invalid One native source descriptor; run one typegen`);
|
|
7359
|
-
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !
|
|
7418
|
+
if (!value || typeof value !== "object" || Reflect.get(value, "generatedBy") !== "one typegen" || !import_node_fs14.default.existsSync(import_node_path15.default.join(packagePath, NATIVE_GLUE))) {
|
|
7360
7419
|
throw invalid();
|
|
7361
7420
|
}
|
|
7362
7421
|
if (!isSwiftNativeModules(value) || value.packageId !== swiftPackageId(packagePath)) {
|
|
@@ -7365,14 +7424,14 @@ function nativeSourceDescriptor(packagePath) {
|
|
|
7365
7424
|
return value;
|
|
7366
7425
|
}
|
|
7367
7426
|
function nativeSourceFiles(packagePath) {
|
|
7368
|
-
packagePath =
|
|
7369
|
-
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) =>
|
|
7427
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7428
|
+
return [NATIVE_DESCRIPTOR, NATIVE_GLUE].map((name2) => import_node_path15.default.join(packagePath, name2)).filter((file) => import_node_fs14.default.existsSync(file));
|
|
7370
7429
|
}
|
|
7371
7430
|
var SwiftMissingModulesError = class extends Error {
|
|
7372
7431
|
};
|
|
7373
7432
|
var projects = /* @__PURE__ */ new Map();
|
|
7374
7433
|
function projectFor(packagePath, hosted) {
|
|
7375
|
-
packagePath =
|
|
7434
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7376
7435
|
const existing = projects.get(packagePath);
|
|
7377
7436
|
if (existing) {
|
|
7378
7437
|
if (hosted && !existing.hosted) {
|
|
@@ -7394,14 +7453,14 @@ function projectFor(packagePath, hosted) {
|
|
|
7394
7453
|
}
|
|
7395
7454
|
var xcodeProjects = /* @__PURE__ */ new Map();
|
|
7396
7455
|
function swiftPackages(entry, app) {
|
|
7397
|
-
const stamp = (file) => file &&
|
|
7456
|
+
const stamp = (file) => file && import_node_fs14.default.existsSync(file) ? import_node_fs14.default.statSync(file).mtimeMs : 0;
|
|
7398
7457
|
const key2 = JSON.stringify([
|
|
7399
7458
|
app.linkedProducts,
|
|
7400
7459
|
app.packageResolved,
|
|
7401
7460
|
stamp(app.packageResolved),
|
|
7402
|
-
app.localPackageDirs.map((dir) => stamp(
|
|
7461
|
+
app.localPackageDirs.map((dir) => stamp(import_node_path15.default.join(dir, "Package.swift"))),
|
|
7403
7462
|
app.linkedProducts.map(
|
|
7404
|
-
({ source }) => source.kind === "local" ? stamp(
|
|
7463
|
+
({ source }) => source.kind === "local" ? stamp(import_node_path15.default.join(source.dir, "Package.swift")) : 0
|
|
7405
7464
|
)
|
|
7406
7465
|
]);
|
|
7407
7466
|
let cached2 = entry.packages;
|
|
@@ -7452,11 +7511,11 @@ var XCODE_APP_DIR = "__app__";
|
|
|
7452
7511
|
var XCODE_FRAMEWORKS_DIR = "__frameworks__";
|
|
7453
7512
|
var XCODE_PACKAGES_DIR = "__packages__";
|
|
7454
7513
|
var XCODE_STANDINS_DIR = "__standins__";
|
|
7455
|
-
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(
|
|
7514
|
+
var CHECKOUTS_PREFIX = `${REMOTE_CHECKOUTS.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)}/`;
|
|
7456
7515
|
function xcodeInputKey(layout, file, relative) {
|
|
7457
7516
|
const owner = layout.targetDirs.get(file);
|
|
7458
|
-
if (owner) return
|
|
7459
|
-
return relative.startsWith(CHECKOUTS_PREFIX) ?
|
|
7517
|
+
if (owner) return import_node_path15.default.posix.join(owner, relative);
|
|
7518
|
+
return relative.startsWith(CHECKOUTS_PREFIX) ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, relative.slice(CHECKOUTS_PREFIX.length)) : relative;
|
|
7460
7519
|
}
|
|
7461
7520
|
function xcodeLayout(root) {
|
|
7462
7521
|
const registered = xcodeProjects.get(root);
|
|
@@ -7467,7 +7526,7 @@ function xcodeLayout(root) {
|
|
|
7467
7526
|
const targetDirs = new Map(app.sources.map((file) => [file, XCODE_APP_DIR]));
|
|
7468
7527
|
const targets = [];
|
|
7469
7528
|
for (const framework of app.frameworks) {
|
|
7470
|
-
const dir =
|
|
7529
|
+
const dir = import_node_path15.default.posix.join(XCODE_FRAMEWORKS_DIR, framework.moduleName);
|
|
7471
7530
|
for (const file of framework.sources) {
|
|
7472
7531
|
if (targetDirs.has(file)) continue;
|
|
7473
7532
|
targetDirs.set(file, dir);
|
|
@@ -7487,7 +7546,7 @@ function xcodeLayout(root) {
|
|
|
7487
7546
|
for (const standin of standins)
|
|
7488
7547
|
targets.push({
|
|
7489
7548
|
name: standin.module,
|
|
7490
|
-
path:
|
|
7549
|
+
path: import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module),
|
|
7491
7550
|
executable: false,
|
|
7492
7551
|
resources: false,
|
|
7493
7552
|
exclude: [],
|
|
@@ -7495,19 +7554,19 @@ function xcodeLayout(root) {
|
|
|
7495
7554
|
mainActorIsolation: false
|
|
7496
7555
|
});
|
|
7497
7556
|
for (const target of packages.targets) {
|
|
7498
|
-
const relative =
|
|
7499
|
-
target.remote ?
|
|
7557
|
+
const relative = import_node_path15.default.relative(
|
|
7558
|
+
target.remote ? import_node_path15.default.join(root, REMOTE_CHECKOUTS) : root,
|
|
7500
7559
|
target.dir
|
|
7501
7560
|
);
|
|
7502
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
7561
|
+
if (relative === ".." || relative.startsWith(`..${import_node_path15.default.sep}`) || import_node_path15.default.isAbsolute(relative))
|
|
7503
7562
|
throw new Error(`swift input escapes the selected package: ${target.dir}`);
|
|
7504
|
-
const posix = relative.split(
|
|
7563
|
+
const posix = relative.split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7505
7564
|
targets.push({
|
|
7506
7565
|
...target,
|
|
7507
|
-
path: target.remote ?
|
|
7566
|
+
path: target.remote ? import_node_path15.default.posix.join(XCODE_PACKAGES_DIR, posix) : posix,
|
|
7508
7567
|
exclude: []
|
|
7509
7568
|
});
|
|
7510
|
-
if (!target.remote) files2.add(
|
|
7569
|
+
if (!target.remote) files2.add(import_node_path15.default.join(target.packageDir, "Package.swift"));
|
|
7511
7570
|
for (const file of target.files) files2.add(file);
|
|
7512
7571
|
}
|
|
7513
7572
|
for (const target of targets) {
|
|
@@ -7537,25 +7596,25 @@ function xcodeManifest(layout) {
|
|
|
7537
7596
|
].join("\n");
|
|
7538
7597
|
}
|
|
7539
7598
|
function packageFiles(root) {
|
|
7540
|
-
const canonicalRoot =
|
|
7599
|
+
const canonicalRoot = import_node_fs14.default.realpathSync(root);
|
|
7541
7600
|
const xcode = xcodeLayout(canonicalRoot);
|
|
7542
7601
|
return xcode ? xcode.files : sourceTreeFiles(canonicalRoot, canonicalRoot);
|
|
7543
7602
|
}
|
|
7544
7603
|
function sourceTreeFiles(dir, canonicalRoot) {
|
|
7545
7604
|
const found = [];
|
|
7546
7605
|
const walk2 = (dir2) => {
|
|
7547
|
-
for (const entry of
|
|
7606
|
+
for (const entry of import_node_fs14.default.readdirSync(dir2, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name))) {
|
|
7548
7607
|
if (entry.name.startsWith(".") && entry.name !== NATIVE_DESCRIPTOR && entry.name !== NATIVE_GLUE || SKIP_SOURCE_DIRS.has(entry.name))
|
|
7549
7608
|
continue;
|
|
7550
|
-
const full =
|
|
7609
|
+
const full = import_node_path15.default.join(dir2, entry.name);
|
|
7551
7610
|
if (entry.isSymbolicLink()) throw new Error(`swift input is a symlink: ${full}`);
|
|
7552
|
-
const real =
|
|
7553
|
-
const relative =
|
|
7554
|
-
if (relative.startsWith(`..${
|
|
7611
|
+
const real = import_node_fs14.default.realpathSync(full);
|
|
7612
|
+
const relative = import_node_path15.default.relative(canonicalRoot, real);
|
|
7613
|
+
if (relative.startsWith(`..${import_node_path15.default.sep}`) || relative === ".." || import_node_path15.default.isAbsolute(relative)) {
|
|
7555
7614
|
throw new Error(`swift input escapes the selected package: ${full}`);
|
|
7556
7615
|
}
|
|
7557
7616
|
if (entry.isDirectory()) {
|
|
7558
|
-
if (
|
|
7617
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(full, "Package.swift"))) continue;
|
|
7559
7618
|
walk2(full);
|
|
7560
7619
|
} else if (entry.isFile()) {
|
|
7561
7620
|
found.push(full);
|
|
@@ -7563,56 +7622,15 @@ function sourceTreeFiles(dir, canonicalRoot) {
|
|
|
7563
7622
|
}
|
|
7564
7623
|
}
|
|
7565
7624
|
};
|
|
7566
|
-
if (
|
|
7625
|
+
if (import_node_fs14.default.existsSync(dir)) walk2(import_node_fs14.default.realpathSync(dir));
|
|
7567
7626
|
return found;
|
|
7568
7627
|
}
|
|
7569
|
-
function readPackageFile(root, file, maxBytes) {
|
|
7570
|
-
const canonicalRoot = import_node_fs13.default.realpathSync(root);
|
|
7571
|
-
const relative = import_node_path14.default.relative(canonicalRoot, import_node_fs13.default.realpathSync(file));
|
|
7572
|
-
if (relative === ".." || relative.startsWith(`..${import_node_path14.default.sep}`) || import_node_path14.default.isAbsolute(relative)) {
|
|
7573
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7574
|
-
}
|
|
7575
|
-
let ancestor = import_node_path14.default.resolve(file);
|
|
7576
|
-
while (ancestor !== canonicalRoot) {
|
|
7577
|
-
if (import_node_fs13.default.lstatSync(ancestor).isSymbolicLink()) {
|
|
7578
|
-
throw new Error(`swift input is a symlink: ${ancestor}`);
|
|
7579
|
-
}
|
|
7580
|
-
const parent = import_node_path14.default.dirname(ancestor);
|
|
7581
|
-
if (parent === ancestor)
|
|
7582
|
-
throw new Error(`swift input escapes the selected package: ${file}`);
|
|
7583
|
-
ancestor = parent;
|
|
7584
|
-
}
|
|
7585
|
-
const expected = import_node_fs13.default.statSync(file);
|
|
7586
|
-
const fd = import_node_fs13.default.openSync(file, import_node_fs13.default.constants.O_RDONLY | import_node_fs13.default.constants.O_NOFOLLOW);
|
|
7587
|
-
try {
|
|
7588
|
-
const stat = import_node_fs13.default.fstatSync(fd);
|
|
7589
|
-
if (stat.dev !== expected.dev || stat.ino !== expected.ino) {
|
|
7590
|
-
throw new Error(`swift input changed while opening: ${file}`);
|
|
7591
|
-
}
|
|
7592
|
-
if (!stat.isFile() || stat.size > maxBytes) {
|
|
7593
|
-
throw new Error(`swift input exceeds ${maxBytes} bytes: ${file}`);
|
|
7594
|
-
}
|
|
7595
|
-
const bytes = Buffer.alloc(stat.size + 1);
|
|
7596
|
-
let offset = 0;
|
|
7597
|
-
while (offset < bytes.length) {
|
|
7598
|
-
const count = import_node_fs13.default.readSync(fd, bytes, offset, bytes.length - offset, null);
|
|
7599
|
-
if (count === 0) break;
|
|
7600
|
-
offset += count;
|
|
7601
|
-
}
|
|
7602
|
-
if (offset !== stat.size || import_node_fs13.default.fstatSync(fd).size !== stat.size) {
|
|
7603
|
-
throw new Error(`swift input changed while reading: ${file}`);
|
|
7604
|
-
}
|
|
7605
|
-
return bytes.subarray(0, offset);
|
|
7606
|
-
} finally {
|
|
7607
|
-
import_node_fs13.default.closeSync(fd);
|
|
7608
|
-
}
|
|
7609
|
-
}
|
|
7610
7628
|
function sourceFiles(root) {
|
|
7611
7629
|
return packageFiles(root).filter((file) => file.endsWith(".swift"));
|
|
7612
7630
|
}
|
|
7613
7631
|
function resourceCandidateFiles(root) {
|
|
7614
7632
|
return packageFiles(root).filter(
|
|
7615
|
-
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(
|
|
7633
|
+
(file) => !file.endsWith(".swift") && !["project.pbxproj", "project.xcproj"].includes(import_node_path15.default.basename(file))
|
|
7616
7634
|
);
|
|
7617
7635
|
}
|
|
7618
7636
|
var HOSTED_LIMITS = {
|
|
@@ -7646,7 +7664,7 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7646
7664
|
const limits = inputLimits(Boolean(project.hosted));
|
|
7647
7665
|
const absolute = resourceCandidateFiles(project.packagePath);
|
|
7648
7666
|
const relative = absolute.map(
|
|
7649
|
-
(file) =>
|
|
7667
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7650
7668
|
);
|
|
7651
7669
|
const byRelative = new Map(absolute.map((file, index) => [relative[index], file]));
|
|
7652
7670
|
const readContents = (candidate) => {
|
|
@@ -7668,16 +7686,16 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7668
7686
|
for (const { name: name2, file, scale } of found) {
|
|
7669
7687
|
const disk = byRelative.get(file);
|
|
7670
7688
|
if (!disk) continue;
|
|
7671
|
-
if (Object.keys(images).length >= limits.images || imageBytes +
|
|
7689
|
+
if (Object.keys(images).length >= limits.images || imageBytes + import_node_fs14.default.statSync(disk).size > limits.imageTotalBytes) {
|
|
7672
7690
|
throw new Error("swift image pack exceeds the compile service caps");
|
|
7673
7691
|
}
|
|
7674
7692
|
const bytes = readPackageFile(project.packagePath, disk, limits.imageBytes);
|
|
7675
7693
|
imageBytes += bytes.length;
|
|
7676
7694
|
const hash = (0, import_node_crypto7.createHash)("sha256").update(bytes).digest("hex").slice(0, 16);
|
|
7677
|
-
const ext =
|
|
7695
|
+
const ext = import_node_path15.default.posix.extname(file).toLowerCase();
|
|
7678
7696
|
table[name2] = { uri: `${baseUrl}${RESOURCE_PATH}${hash}${ext}`, scale };
|
|
7679
7697
|
images[name2] = {
|
|
7680
|
-
file:
|
|
7698
|
+
file: import_node_path15.default.posix.basename(file),
|
|
7681
7699
|
data: bytes.toString("base64")
|
|
7682
7700
|
};
|
|
7683
7701
|
watched.push(file);
|
|
@@ -7701,10 +7719,10 @@ function buildSwiftResourceTable(project, baseUrl) {
|
|
|
7701
7719
|
return { table, images, colors, symbols, watched };
|
|
7702
7720
|
}
|
|
7703
7721
|
function buildSwiftBundleFiles(packagePath, hosted) {
|
|
7704
|
-
packagePath =
|
|
7722
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7705
7723
|
const limits = inputLimits(hosted);
|
|
7706
7724
|
const relative = resourceCandidateFiles(packagePath).map(
|
|
7707
|
-
(file) =>
|
|
7725
|
+
(file) => import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7708
7726
|
);
|
|
7709
7727
|
const files2 = {};
|
|
7710
7728
|
const watched = [];
|
|
@@ -7718,13 +7736,13 @@ function buildSwiftBundleFiles(packagePath, hosted) {
|
|
|
7718
7736
|
total += bytes.length;
|
|
7719
7737
|
if (xcode.app.infoPlistFile)
|
|
7720
7738
|
watched.push(
|
|
7721
|
-
|
|
7739
|
+
import_node_path15.default.relative(packagePath, xcode.app.infoPlistFile).split(import_node_path15.default.sep).join("/")
|
|
7722
7740
|
);
|
|
7723
7741
|
}
|
|
7724
7742
|
for (const { base, file } of enumerateBundleJson(relative)) {
|
|
7725
7743
|
watched.push(file);
|
|
7726
|
-
const disk =
|
|
7727
|
-
if (Object.keys(files2).length >= limits.resources || total +
|
|
7744
|
+
const disk = import_node_path15.default.join(packagePath, ...file.split("/"));
|
|
7745
|
+
if (Object.keys(files2).length >= limits.resources || total + import_node_fs14.default.statSync(disk).size > limits.resourceTotalBytes) {
|
|
7728
7746
|
throw new Error(
|
|
7729
7747
|
`swift bundle pack exceeds ${limits.resources} files / ${limits.resourceTotalBytes} bytes`
|
|
7730
7748
|
);
|
|
@@ -7739,12 +7757,12 @@ function serveSwiftResource(project, key2) {
|
|
|
7739
7757
|
return project.resourceFiles.get(key2) ?? project.resourcesPrevious.get(key2) ?? null;
|
|
7740
7758
|
}
|
|
7741
7759
|
function linkedModuleRoots(packagePath) {
|
|
7742
|
-
packagePath =
|
|
7760
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
7743
7761
|
let manifest;
|
|
7744
7762
|
try {
|
|
7745
7763
|
manifest = readPackageFile(
|
|
7746
7764
|
packagePath,
|
|
7747
|
-
|
|
7765
|
+
import_node_path15.default.join(packagePath, "Package.swift"),
|
|
7748
7766
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7749
7767
|
).toString("utf8");
|
|
7750
7768
|
} catch {
|
|
@@ -7753,8 +7771,8 @@ function linkedModuleRoots(packagePath) {
|
|
|
7753
7771
|
const roots = /* @__PURE__ */ new Set();
|
|
7754
7772
|
const dependency = /\.package\(\s*path:\s*"([^"]+)"\s*\)/g;
|
|
7755
7773
|
for (const match of manifest.replace(/^\s*\/\/.*$/gm, "").matchAll(dependency)) {
|
|
7756
|
-
const root =
|
|
7757
|
-
if (
|
|
7774
|
+
const root = import_node_path15.default.resolve(packagePath, match[1]);
|
|
7775
|
+
if (import_node_fs14.default.existsSync(import_node_path15.default.join(root, "Package.swift"))) roots.add(root);
|
|
7758
7776
|
}
|
|
7759
7777
|
return [...roots].sort();
|
|
7760
7778
|
}
|
|
@@ -7763,25 +7781,25 @@ function sourceStamp(packagePath, moduleRootOverride, hosted = false) {
|
|
|
7763
7781
|
hash.update(packagePath);
|
|
7764
7782
|
const projectInputs = new Set(packageFiles(packagePath));
|
|
7765
7783
|
for (const file of [...projectInputs].sort()) {
|
|
7766
|
-
hash.update(
|
|
7767
|
-
const stat =
|
|
7784
|
+
hash.update(import_node_path15.default.relative(packagePath, file));
|
|
7785
|
+
const stat = import_node_fs14.default.statSync(file);
|
|
7768
7786
|
hash.update(`${stat.mtimeMs}/${stat.ctimeMs}/${stat.size}`);
|
|
7769
7787
|
}
|
|
7770
7788
|
const moduleRoot = hosted ? void 0 : moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7771
|
-
(root) =>
|
|
7789
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7772
7790
|
);
|
|
7773
7791
|
if (moduleRoot) {
|
|
7774
7792
|
hash.update(moduleRoot);
|
|
7775
7793
|
for (const relative of swiftModuleInputFiles(moduleRoot)) {
|
|
7776
7794
|
hash.update(relative);
|
|
7777
|
-
hash.update(String(
|
|
7795
|
+
hash.update(String(import_node_fs14.default.statSync(import_node_path15.default.join(moduleRoot, relative)).mtimeMs));
|
|
7778
7796
|
}
|
|
7779
7797
|
}
|
|
7780
7798
|
return hash.digest("hex").slice(0, 16);
|
|
7781
7799
|
}
|
|
7782
7800
|
function entryRootId(packagePath, file) {
|
|
7783
|
-
const relative =
|
|
7784
|
-
return `${
|
|
7801
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7802
|
+
return `${import_node_path15.default.basename(packagePath)}${import_node_path15.default.posix.sep}${relative}`;
|
|
7785
7803
|
}
|
|
7786
7804
|
function icuUrl(origin, artifact) {
|
|
7787
7805
|
return "url" in artifact.icu ? artifact.icu.url : `${origin}${ICU_PATH}${artifact.icu.sha256}`;
|
|
@@ -7790,8 +7808,8 @@ function packageSources(packagePath) {
|
|
|
7790
7808
|
const xcode = xcodeLayout(packagePath);
|
|
7791
7809
|
const files2 = {};
|
|
7792
7810
|
for (const file of sourceFiles(packagePath)) {
|
|
7793
|
-
const relative =
|
|
7794
|
-
if (xcode &&
|
|
7811
|
+
const relative = import_node_path15.default.relative(packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep);
|
|
7812
|
+
if (xcode && import_node_path15.default.basename(file) === "Package.swift") continue;
|
|
7795
7813
|
files2[xcode ? xcodeInputKey(xcode, file, relative) : relative] = readPackageFile(
|
|
7796
7814
|
packagePath,
|
|
7797
7815
|
file,
|
|
@@ -7802,7 +7820,7 @@ function packageSources(packagePath) {
|
|
|
7802
7820
|
files2["Package.swift"] = xcodeManifest(xcode);
|
|
7803
7821
|
for (const standin of xcode.standins)
|
|
7804
7822
|
for (const [file, text3] of Object.entries(standin.files))
|
|
7805
|
-
files2[
|
|
7823
|
+
files2[import_node_path15.default.posix.join(XCODE_STANDINS_DIR, standin.module, file)] = text3;
|
|
7806
7824
|
}
|
|
7807
7825
|
return files2;
|
|
7808
7826
|
}
|
|
@@ -7813,7 +7831,7 @@ function packageSnapshot(project) {
|
|
|
7813
7831
|
files: files2,
|
|
7814
7832
|
resourcePaths: swiftImplicitResourcePaths(
|
|
7815
7833
|
resourceCandidateFiles(project.packagePath).map(
|
|
7816
|
-
(file) =>
|
|
7834
|
+
(file) => import_node_path15.default.relative(project.packagePath, file).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep)
|
|
7817
7835
|
)
|
|
7818
7836
|
),
|
|
7819
7837
|
resources: buildSwiftResourceTable(project, ""),
|
|
@@ -7822,7 +7840,7 @@ function packageSnapshot(project) {
|
|
|
7822
7840
|
...native ? {
|
|
7823
7841
|
glue: readPackageFile(
|
|
7824
7842
|
project.packagePath,
|
|
7825
|
-
|
|
7843
|
+
import_node_path15.default.join(project.packagePath, NATIVE_GLUE),
|
|
7826
7844
|
MAX_SWIFT_COMPILE_SOURCE_BYTES
|
|
7827
7845
|
).toString("utf8")
|
|
7828
7846
|
} : {}
|
|
@@ -7861,7 +7879,7 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7861
7879
|
package: content
|
|
7862
7880
|
};
|
|
7863
7881
|
const moduleRoot = moduleRootOverride ?? linkedModuleRoots(packagePath).find(
|
|
7864
|
-
(root) =>
|
|
7882
|
+
(root) => import_node_fs14.default.existsSync(import_node_path15.default.join(root, "toolchain.json"))
|
|
7865
7883
|
) ?? await swiftDistributionRoot();
|
|
7866
7884
|
if (!moduleRoot)
|
|
7867
7885
|
return {
|
|
@@ -7888,10 +7906,10 @@ async function compile(packagePath, entry, stamp, moduleRootOverride, hosted, sn
|
|
|
7888
7906
|
// server and a capture, or two checkouts) build each other's sources. so
|
|
7889
7907
|
// each app and module checkout gets its own root, which keeps the same
|
|
7890
7908
|
// app's incremental build across restarts.
|
|
7891
|
-
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ??
|
|
7909
|
+
buildRoot: process.env.CONTRAST_SWIFT_BUILD_ROOT ?? import_node_path15.default.join(
|
|
7892
7910
|
import_node_os8.default.tmpdir(),
|
|
7893
7911
|
"contrast-swift-build",
|
|
7894
|
-
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${
|
|
7912
|
+
(0, import_node_crypto7.createHash)("sha256").update(`${moduleRoot}\0${import_node_path15.default.resolve(packagePath)}`).digest("hex").slice(0, 16)
|
|
7895
7913
|
),
|
|
7896
7914
|
moduleRoot,
|
|
7897
7915
|
...toolchain
|
|
@@ -8003,7 +8021,7 @@ async function missingModulesMessage(packagePath, missing) {
|
|
|
8003
8021
|
`Peach does not provide ${missing.size} module${missing.size === 1 ? "" : "s"} this app imports:`,
|
|
8004
8022
|
...[...missing].map(([name2, files2]) => {
|
|
8005
8023
|
const gap = gaps.get(name2);
|
|
8006
|
-
return ` ${name2.padEnd(width)} ${files2.length} file${files2.length === 1 ? "" : "s"}${gap ? `, ${gap.source.includes("://") ? `package ${gap.source}` : gap.source.startsWith("/") ? `package ${
|
|
8024
|
+
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})` : ""}`;
|
|
8007
8025
|
})
|
|
8008
8026
|
].join("\n");
|
|
8009
8027
|
}
|
|
@@ -8011,7 +8029,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8011
8029
|
const auth = hosted ? null : resolveCliAuth();
|
|
8012
8030
|
if (!hosted && (!auth || auth.kind === "github")) {
|
|
8013
8031
|
throw new Error(
|
|
8014
|
-
`compiling ${
|
|
8032
|
+
`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`
|
|
8015
8033
|
);
|
|
8016
8034
|
}
|
|
8017
8035
|
const origin = hosted?.origin ?? resolveContrastBackendOrigin(auth?.kind === "session" ? auth.origin : null);
|
|
@@ -8030,7 +8048,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8030
8048
|
const bytes = sources.reduce((total2, text3) => total2 + Buffer.byteLength(text3), 0);
|
|
8031
8049
|
if (sources.length > MAX_SWIFT_COMPILE_FILES || bytes > MAX_SWIFT_COMPILE_SOURCE_BYTES) {
|
|
8032
8050
|
throw new Error(
|
|
8033
|
-
`${
|
|
8051
|
+
`${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`
|
|
8034
8052
|
);
|
|
8035
8053
|
}
|
|
8036
8054
|
const descriptor = snapshot.native;
|
|
@@ -8049,7 +8067,7 @@ async function compileRemote(packagePath, entry, snapshot, hosted) {
|
|
|
8049
8067
|
);
|
|
8050
8068
|
if (descriptor && address.native?.hash !== descriptor.hash) {
|
|
8051
8069
|
throw new Error(
|
|
8052
|
-
`${
|
|
8070
|
+
`${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`
|
|
8053
8071
|
);
|
|
8054
8072
|
}
|
|
8055
8073
|
const response = await fetch(address.url, { signal });
|
|
@@ -8122,17 +8140,17 @@ function artifactFor(project, entry, moduleRoot) {
|
|
|
8122
8140
|
return fresh;
|
|
8123
8141
|
}
|
|
8124
8142
|
function swiftPackageWatchFiles(packagePath, moduleRoot) {
|
|
8125
|
-
packagePath =
|
|
8143
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
8126
8144
|
return [
|
|
8127
|
-
...xcodeProjects.has(packagePath) ? [] : [
|
|
8145
|
+
...xcodeProjects.has(packagePath) ? [] : [import_node_path15.default.join(packagePath, "Package.swift")],
|
|
8128
8146
|
...sourceFiles(packagePath),
|
|
8129
8147
|
...nativeSourceFiles(packagePath),
|
|
8130
8148
|
...resourceCandidateFiles(packagePath),
|
|
8131
|
-
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) =>
|
|
8149
|
+
...moduleRoot ? swiftModuleInputFiles(moduleRoot).map((file) => import_node_path15.default.join(moduleRoot, file)) : []
|
|
8132
8150
|
];
|
|
8133
8151
|
}
|
|
8134
8152
|
async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin, hosted) {
|
|
8135
|
-
packagePath =
|
|
8153
|
+
packagePath = import_node_fs14.default.realpathSync(packagePath);
|
|
8136
8154
|
const mains = sourceFiles(packagePath).filter(
|
|
8137
8155
|
(file) => swiftApplicationEntry(
|
|
8138
8156
|
file,
|
|
@@ -8146,7 +8164,7 @@ async function swiftPackageMetadata(packagePath, packageName, moduleRoot, origin
|
|
|
8146
8164
|
);
|
|
8147
8165
|
}
|
|
8148
8166
|
const project = projectFor(packagePath, hosted);
|
|
8149
|
-
const entry = mains.length === 1 ?
|
|
8167
|
+
const entry = mains.length === 1 ? import_node_path15.default.relative(packagePath, mains[0]).split(import_node_path15.default.sep).join(import_node_path15.default.posix.sep) : Object.entries(native?.files ?? {}).find(
|
|
8150
8168
|
([_file, names]) => names.length > 0
|
|
8151
8169
|
)?.[0];
|
|
8152
8170
|
if (!entry) throw new Error(`swift package ${packageName} has no native module source`);
|
|
@@ -8222,18 +8240,23 @@ function serveSwiftPackageAsset(pathname, res) {
|
|
|
8222
8240
|
}
|
|
8223
8241
|
|
|
8224
8242
|
// src/one-widget-package.ts
|
|
8243
|
+
var import_node_crypto9 = require("node:crypto");
|
|
8244
|
+
var import_node_fs16 = __toESM(require("node:fs"), 1);
|
|
8245
|
+
var import_node_os9 = __toESM(require("node:os"), 1);
|
|
8246
|
+
var import_node_path17 = __toESM(require("node:path"), 1);
|
|
8247
|
+
|
|
8248
|
+
// src/one-widget-metadata.ts
|
|
8225
8249
|
var import_node_child_process8 = require("node:child_process");
|
|
8226
8250
|
var import_node_crypto8 = require("node:crypto");
|
|
8227
|
-
var
|
|
8251
|
+
var import_node_fs15 = __toESM(require("node:fs"), 1);
|
|
8228
8252
|
var import_node_module = require("node:module");
|
|
8229
|
-
var
|
|
8230
|
-
var import_node_path15 = __toESM(require("node:path"), 1);
|
|
8253
|
+
var import_node_path16 = __toESM(require("node:path"), 1);
|
|
8231
8254
|
var import_node_util3 = require("node:util");
|
|
8232
8255
|
|
|
8233
8256
|
// cli/internal-child.ts
|
|
8234
8257
|
var RNX_FORKED_SCRIPT_ENV = "PEACH_RUNS_FORKED_SCRIPTS";
|
|
8235
8258
|
|
|
8236
|
-
// src/one-widget-
|
|
8259
|
+
// src/one-widget-metadata.ts
|
|
8237
8260
|
var run3 = (0, import_node_util3.promisify)(import_node_child_process8.execFile);
|
|
8238
8261
|
var ONE_WIDGET_PACKAGE = "OneWidgets";
|
|
8239
8262
|
var configs = /* @__PURE__ */ new Map();
|
|
@@ -8248,14 +8271,15 @@ fs.writeFileSync(process.argv[2], JSON.stringify({
|
|
|
8248
8271
|
widget: widgets ? { appName: app.name, bundleId: app.ios.bundleId,
|
|
8249
8272
|
suite: widgets.appGroup, kind: widgets.kind, displayName: widgets.displayName,
|
|
8250
8273
|
description: widgets.description } : null,
|
|
8274
|
+
urlSchemes: app?.scheme === undefined ? [] : Array.isArray(app.scheme) ? app.scheme : [app.scheme],
|
|
8251
8275
|
watched: [config.path, ...config.dependencies]
|
|
8252
8276
|
}));
|
|
8253
8277
|
`;
|
|
8254
8278
|
function configStamp(files2) {
|
|
8255
8279
|
return JSON.stringify(
|
|
8256
8280
|
files2.map((file) => {
|
|
8257
|
-
if (!
|
|
8258
|
-
const stat =
|
|
8281
|
+
if (!import_node_fs15.default.existsSync(file)) return [file, null];
|
|
8282
|
+
const stat = import_node_fs15.default.statSync(file);
|
|
8259
8283
|
return [file, stat.mtimeMs, stat.ctimeMs, stat.size];
|
|
8260
8284
|
})
|
|
8261
8285
|
);
|
|
@@ -8266,13 +8290,13 @@ async function readConfig(root) {
|
|
|
8266
8290
|
const reading = reads.get(root);
|
|
8267
8291
|
if (reading) return reading;
|
|
8268
8292
|
const promise = (async () => {
|
|
8269
|
-
(0, import_node_module.createRequire)(
|
|
8270
|
-
const cache =
|
|
8271
|
-
|
|
8272
|
-
const directory =
|
|
8273
|
-
const script =
|
|
8274
|
-
const result =
|
|
8275
|
-
|
|
8293
|
+
(0, import_node_module.createRequire)(import_node_path16.default.join(root, "package.json")).resolve("one/vite");
|
|
8294
|
+
const cache = import_node_path16.default.join(root, "node_modules/.cache/peach-widget-config");
|
|
8295
|
+
import_node_fs15.default.mkdirSync(cache, { recursive: true });
|
|
8296
|
+
const directory = import_node_fs15.default.mkdtempSync(import_node_path16.default.join(cache, "read-"));
|
|
8297
|
+
const script = import_node_path16.default.join(directory, "read.mjs");
|
|
8298
|
+
const result = import_node_path16.default.join(directory, "result.json");
|
|
8299
|
+
import_node_fs15.default.writeFileSync(script, CONFIG_CHILD);
|
|
8276
8300
|
try {
|
|
8277
8301
|
await run3(process.execPath, [script, result], {
|
|
8278
8302
|
cwd: root,
|
|
@@ -8280,9 +8304,13 @@ async function readConfig(root) {
|
|
|
8280
8304
|
timeout: 3e4,
|
|
8281
8305
|
maxBuffer: 1024 * 1024
|
|
8282
8306
|
});
|
|
8283
|
-
const value = JSON.parse(
|
|
8307
|
+
const value = JSON.parse(import_node_fs15.default.readFileSync(result, "utf8"));
|
|
8284
8308
|
if (!isRecord(value) || !Array.isArray(value.watched) || !value.watched.every((file) => typeof file === "string"))
|
|
8285
8309
|
throw new Error("One config loader returned invalid dependencies");
|
|
8310
|
+
if (!Array.isArray(value.urlSchemes) || !value.urlSchemes.every(
|
|
8311
|
+
(scheme) => typeof scheme === "string" && /^[A-Za-z][A-Za-z0-9+.-]*$/.test(scheme)
|
|
8312
|
+
))
|
|
8313
|
+
throw new Error("One config loader returned invalid native.app.scheme");
|
|
8286
8314
|
let widget = null;
|
|
8287
8315
|
if (value.widget !== null) {
|
|
8288
8316
|
const entry = value.widget;
|
|
@@ -8299,15 +8327,20 @@ async function readConfig(root) {
|
|
|
8299
8327
|
}
|
|
8300
8328
|
const watched = [
|
|
8301
8329
|
.../* @__PURE__ */ new Set([
|
|
8302
|
-
|
|
8303
|
-
...value.watched.map((file) =>
|
|
8330
|
+
import_node_path16.default.join(root, "package.json"),
|
|
8331
|
+
...value.watched.map((file) => import_node_path16.default.resolve(root, file))
|
|
8304
8332
|
])
|
|
8305
8333
|
];
|
|
8306
|
-
const loaded2 = {
|
|
8334
|
+
const loaded2 = {
|
|
8335
|
+
widget,
|
|
8336
|
+
urlSchemes: value.urlSchemes,
|
|
8337
|
+
watched,
|
|
8338
|
+
stamp: configStamp(watched)
|
|
8339
|
+
};
|
|
8307
8340
|
configs.set(root, loaded2);
|
|
8308
8341
|
return loaded2;
|
|
8309
8342
|
} finally {
|
|
8310
|
-
|
|
8343
|
+
import_node_fs15.default.rmSync(directory, { recursive: true, force: true });
|
|
8311
8344
|
}
|
|
8312
8345
|
})();
|
|
8313
8346
|
reads.set(root, promise);
|
|
@@ -8317,14 +8350,14 @@ async function readConfig(root) {
|
|
|
8317
8350
|
reads.delete(root);
|
|
8318
8351
|
}
|
|
8319
8352
|
}
|
|
8320
|
-
async function
|
|
8321
|
-
const root =
|
|
8353
|
+
async function readOneWidgetSources(appRoot) {
|
|
8354
|
+
const root = import_node_fs15.default.realpathSync(appRoot);
|
|
8322
8355
|
const config = await readConfig(root);
|
|
8323
8356
|
if (!config.widget) return null;
|
|
8324
8357
|
const widget = config.widget;
|
|
8325
8358
|
const sourceFiles2 = {
|
|
8326
|
-
"OneWidget.swift":
|
|
8327
|
-
"OneWidgetContract.swift":
|
|
8359
|
+
"OneWidget.swift": import_node_path16.default.join(root, "ios/OneWidgets/OneWidget.swift"),
|
|
8360
|
+
"OneWidgetContract.swift": import_node_path16.default.join(
|
|
8328
8361
|
root,
|
|
8329
8362
|
"ios",
|
|
8330
8363
|
widget.appName,
|
|
@@ -8334,14 +8367,14 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8334
8367
|
const files2 = /* @__PURE__ */ new Map();
|
|
8335
8368
|
const sources = {};
|
|
8336
8369
|
for (const [name2, file] of Object.entries(sourceFiles2)) {
|
|
8337
|
-
if (!
|
|
8370
|
+
if (!import_node_fs15.default.existsSync(file))
|
|
8338
8371
|
throw new Error(`missing One widget prebuild source ${file}; run one prebuild`);
|
|
8339
8372
|
const bytes = readPackageFile(root, file, MAX_SWIFT_COMPILE_SOURCE_BYTES);
|
|
8340
8373
|
const text3 = bytes.toString("utf8");
|
|
8341
8374
|
if (!Buffer.from(text3).equals(bytes))
|
|
8342
8375
|
throw new Error(`One widget prebuild source is not UTF-8: ${file}`);
|
|
8343
8376
|
files2.set(name2, text3);
|
|
8344
|
-
sources[
|
|
8377
|
+
sources[import_node_path16.default.relative(root, file).split(import_node_path16.default.sep).join("/")] = (0, import_node_crypto8.createHash)("sha256").update(bytes).digest("hex");
|
|
8345
8378
|
}
|
|
8346
8379
|
const contract = files2.get("OneWidgetContract.swift") ?? "";
|
|
8347
8380
|
const source = files2.get("OneWidget.swift") ?? "";
|
|
@@ -8351,11 +8384,26 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8351
8384
|
throw new Error(
|
|
8352
8385
|
"One widget prebuild sources disagree with native.app.ios.widgets; run one prebuild"
|
|
8353
8386
|
);
|
|
8387
|
+
return {
|
|
8388
|
+
root,
|
|
8389
|
+
files: files2,
|
|
8390
|
+
watched: [...config.watched, ...Object.values(sourceFiles2)],
|
|
8391
|
+
widget: { ...widget, sources },
|
|
8392
|
+
urlSchemes: config.urlSchemes
|
|
8393
|
+
};
|
|
8394
|
+
}
|
|
8395
|
+
|
|
8396
|
+
// src/one-widget-package.ts
|
|
8397
|
+
async function oneWidgetPackage(appRoot) {
|
|
8398
|
+
const source = await readOneWidgetSources(appRoot);
|
|
8399
|
+
if (!source) return null;
|
|
8400
|
+
const { root, files: files2, watched, widget } = source;
|
|
8401
|
+
const { sources: _sources, ...config } = widget;
|
|
8354
8402
|
files2.set(
|
|
8355
8403
|
"Package.swift",
|
|
8356
8404
|
[
|
|
8357
8405
|
"// swift-tools-version: 6.2",
|
|
8358
|
-
`// One widget config ${JSON.stringify(
|
|
8406
|
+
`// One widget config ${JSON.stringify(config)}`,
|
|
8359
8407
|
"import PackageDescription",
|
|
8360
8408
|
'let package = Package(name: "OneWidgets", targets: [',
|
|
8361
8409
|
' .executableTarget(name: "OneWidgets", path: ".", swiftSettings: [.swiftLanguageMode(.v5)]),',
|
|
@@ -8363,21 +8411,21 @@ async function oneWidgetPackage(appRoot) {
|
|
|
8363
8411
|
""
|
|
8364
8412
|
].join("\n")
|
|
8365
8413
|
);
|
|
8366
|
-
const packagePath =
|
|
8414
|
+
const packagePath = import_node_path17.default.join(
|
|
8367
8415
|
import_node_os9.default.tmpdir(),
|
|
8368
8416
|
"peach-one-widgets",
|
|
8369
|
-
(0,
|
|
8417
|
+
(0, import_node_crypto9.createHash)("sha256").update(root).digest("hex"),
|
|
8370
8418
|
ONE_WIDGET_PACKAGE
|
|
8371
8419
|
);
|
|
8372
|
-
|
|
8420
|
+
import_node_fs16.default.mkdirSync(packagePath, { recursive: true });
|
|
8373
8421
|
syncSwiftTree(
|
|
8374
8422
|
packagePath,
|
|
8375
|
-
new Map([...files2].map(([file, text3]) => [
|
|
8423
|
+
new Map([...files2].map(([file, text3]) => [import_node_path17.default.join(packagePath, file), text3]))
|
|
8376
8424
|
);
|
|
8377
8425
|
return {
|
|
8378
8426
|
packagePath,
|
|
8379
|
-
watched
|
|
8380
|
-
widget
|
|
8427
|
+
watched,
|
|
8428
|
+
widget
|
|
8381
8429
|
};
|
|
8382
8430
|
}
|
|
8383
8431
|
|
|
@@ -8395,12 +8443,12 @@ function artifactUrl(project, artifact) {
|
|
|
8395
8443
|
return `${serverOrigin()}${ARTIFACT_PATH2}${artifact.hash}.wasm`;
|
|
8396
8444
|
}
|
|
8397
8445
|
function packageFor(file) {
|
|
8398
|
-
let dir =
|
|
8446
|
+
let dir = import_node_path18.default.dirname(file);
|
|
8399
8447
|
const stop = devServer?.config.root;
|
|
8400
8448
|
for (; ; ) {
|
|
8401
|
-
if (
|
|
8402
|
-
if (stop !== void 0 && dir === stop ||
|
|
8403
|
-
dir =
|
|
8449
|
+
if (import_node_fs17.default.existsSync(import_node_path18.default.join(dir, "Package.swift"))) return dir;
|
|
8450
|
+
if (stop !== void 0 && dir === stop || import_node_path18.default.dirname(dir) === dir) break;
|
|
8451
|
+
dir = import_node_path18.default.dirname(dir);
|
|
8404
8452
|
}
|
|
8405
8453
|
throw new Error(
|
|
8406
8454
|
`no Package.swift above ${file}${stop === void 0 ? "" : ` (searched up to ${stop})`}; a .swift import needs a swiftpm package like the one in packages/sootsim-swift/example`
|
|
@@ -8421,9 +8469,9 @@ function swiftPlugin(options = {}) {
|
|
|
8421
8469
|
if (!resolved) throw new Error(`cannot resolve swift source ${source}`);
|
|
8422
8470
|
let id = resolved.id;
|
|
8423
8471
|
if (importer && (source.startsWith("./") || source.startsWith("../"))) {
|
|
8424
|
-
const raw2 =
|
|
8472
|
+
const raw2 = import_node_path18.default.resolve(import_node_path18.default.dirname(importer.split("?")[0] ?? importer), source);
|
|
8425
8473
|
try {
|
|
8426
|
-
if (
|
|
8474
|
+
if (import_node_fs17.default.realpathSync(raw2) === import_node_fs17.default.realpathSync(resolved.id)) id = raw2;
|
|
8427
8475
|
} catch {
|
|
8428
8476
|
}
|
|
8429
8477
|
}
|
|
@@ -8432,22 +8480,22 @@ function swiftPlugin(options = {}) {
|
|
|
8432
8480
|
async load(id) {
|
|
8433
8481
|
if (!id.startsWith(VIRTUAL_PREFIX)) return null;
|
|
8434
8482
|
const file = id.slice(VIRTUAL_PREFIX.length);
|
|
8435
|
-
if (!
|
|
8483
|
+
if (!import_node_fs17.default.existsSync(file)) throw new Error(`swift source ${file} no longer exists`);
|
|
8436
8484
|
const packagePath = options.packagePath ?? packageFor(file);
|
|
8437
8485
|
const project = projectFor(packagePath);
|
|
8438
|
-
const entry =
|
|
8486
|
+
const entry = import_node_path18.default.relative(packagePath, file).split(import_node_path18.default.sep).join(import_node_path18.default.posix.sep);
|
|
8439
8487
|
for (const source of [
|
|
8440
8488
|
...sourceFiles(packagePath),
|
|
8441
8489
|
...nativeSourceFiles(packagePath)
|
|
8442
8490
|
])
|
|
8443
8491
|
this.addWatchFile(source);
|
|
8444
|
-
this.addWatchFile(
|
|
8492
|
+
this.addWatchFile(import_node_path18.default.join(packagePath, "Package.swift"));
|
|
8445
8493
|
const moduleRoot = linkedModuleRoots(packagePath).find(
|
|
8446
|
-
(root) =>
|
|
8494
|
+
(root) => import_node_fs17.default.existsSync(import_node_path18.default.join(root, "toolchain.json"))
|
|
8447
8495
|
);
|
|
8448
8496
|
if (moduleRoot)
|
|
8449
8497
|
for (const relative of swiftModuleInputFiles(moduleRoot))
|
|
8450
|
-
this.addWatchFile(
|
|
8498
|
+
this.addWatchFile(import_node_path18.default.join(moduleRoot, relative));
|
|
8451
8499
|
let artifact;
|
|
8452
8500
|
try {
|
|
8453
8501
|
artifact = await artifactFor(project, entry);
|
|
@@ -8466,7 +8514,7 @@ function swiftPlugin(options = {}) {
|
|
|
8466
8514
|
...artifact.package.resources.watched,
|
|
8467
8515
|
...artifact.package.bundleFiles.watched
|
|
8468
8516
|
])
|
|
8469
|
-
this.addWatchFile(
|
|
8517
|
+
this.addWatchFile(import_node_path18.default.join(packagePath, ...watched.split(import_node_path18.default.posix.sep)));
|
|
8470
8518
|
const colors = artifact.package.resources.colors;
|
|
8471
8519
|
const symbols = artifact.package.resources.symbols;
|
|
8472
8520
|
const bundleFiles = artifact.package.bundleFiles.files;
|