peachsim 0.1.1641 → 0.1.1644
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli/app-bundle-resources.ts +57 -0
- package/cli/commands/control.ts +12 -0
- package/cli/drivers/playwright.ts +39 -0
- package/cli/outbound-endpoints.ts +4 -2
- package/detox/motion-change.cjs +7 -5
- package/detox/motion-change.d.cts +1 -0
- package/detox/motion-leg-starts.cjs +20 -0
- package/detox/motion-leg-starts.d.cts +8 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +3 -3
- 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 +719 -572
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +7 -6
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +656 -509
- 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 +811 -658
- 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 +89 -41
- 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 +14 -6
- package/dist-lib/menu.mjs +14 -6
- 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 +88 -41
- package/dist-lib/native-app-identity-project.cjs +90 -41
- package/dist-lib/native-app-identity-project.mjs +89 -41
- 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/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +2 -1
- package/dist-lib/sdk.mjs +2 -1
- package/dist-lib/skills.cjs +1716 -1366
- package/dist-lib/swift-compile.cjs +297 -215
- package/dist-lib/swift-compile.mjs +315 -227
- 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 +620 -473
- package/dist-lib/vite.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/package.json +1 -1
- package/src/appBundleResourcesContract.ts +51 -0
- package/src/backend-origin.ts +3 -1
- package/src/host/bridge-host.ts +17 -11
- package/src/host/staged-host-files.ts +28 -4
- package/src/launchMetadataContract.ts +1 -0
- package/src/menu.ts +12 -4
- package/src/native-app-identity-project.ts +47 -38
- package/src/runtime-delivery.ts +6 -7
- package/src/swift-compile.ts +18 -7
- package/src/swift-compiler-digest.ts +5 -3
- package/src/swift-objc-compile.ts +34 -4
- package/src/swift-root-lock.ts +241 -92
- package/src/xcode-project.ts +67 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.1644 | (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;
|
|
@@ -8,8 +8,8 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
8
8
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
9
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
10
|
var __export = (target, all) => {
|
|
11
|
-
for (var
|
|
12
|
-
__defProp(target,
|
|
11
|
+
for (var name2 in all)
|
|
12
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
13
13
|
};
|
|
14
14
|
var __copyProps = (to, from, except, desc) => {
|
|
15
15
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -113,9 +113,9 @@ function cacheDir() {
|
|
|
113
113
|
}
|
|
114
114
|
function swiftPackageCacheOptions() {
|
|
115
115
|
const root = import_node_path.default.join(cacheDir(), "swiftpm");
|
|
116
|
-
return ["cache", "config", "security"].flatMap((
|
|
117
|
-
`--${
|
|
118
|
-
import_node_path.default.join(root,
|
|
116
|
+
return ["cache", "config", "security"].flatMap((name2) => [
|
|
117
|
+
`--${name2}-path`,
|
|
118
|
+
import_node_path.default.join(root, name2)
|
|
119
119
|
]);
|
|
120
120
|
}
|
|
121
121
|
var DAEMON_LOCKFILE_MAX_BYTES = 16 * 1024;
|
|
@@ -775,7 +775,7 @@ function designTimeDiagnostic(output, files) {
|
|
|
775
775
|
const rewritten = /* @__PURE__ */ new Map();
|
|
776
776
|
const linesOf = (path6) => {
|
|
777
777
|
const file = Object.keys(files).find(
|
|
778
|
-
(
|
|
778
|
+
(name2) => name2.endsWith(".swift") && (path6 === name2 || path6.endsWith(`/${name2}`))
|
|
779
779
|
);
|
|
780
780
|
if (file === void 0) return null;
|
|
781
781
|
let lines = rewritten.get(file);
|
|
@@ -935,7 +935,7 @@ async function load(toolchainBin, sdk) {
|
|
|
935
935
|
icuSegment(archiveMember((0, import_node_fs2.readFileSync)(import_node_path4.default.join(resources, ARCHIVE)), MEMBER))
|
|
936
936
|
);
|
|
937
937
|
}
|
|
938
|
-
function archiveMember(archive,
|
|
938
|
+
function archiveMember(archive, name2) {
|
|
939
939
|
if (archive.toString("latin1", 0, 8) !== "!<arch>\n")
|
|
940
940
|
throw new Error("swift-icu: not an ar archive");
|
|
941
941
|
let names = "";
|
|
@@ -945,10 +945,10 @@ function archiveMember(archive, name) {
|
|
|
945
945
|
const body = archive.subarray(at + 60, at + 60 + size);
|
|
946
946
|
if (raw2 === "//") names = body.toString("latin1");
|
|
947
947
|
const member = /^\/\d+$/.test(raw2) ? names.slice(Number(raw2.slice(1)), names.indexOf("/\n", Number(raw2.slice(1)))) : raw2.replace(/\/$/, "");
|
|
948
|
-
if (member ===
|
|
948
|
+
if (member === name2) return body;
|
|
949
949
|
at += 60 + size + size % 2;
|
|
950
950
|
}
|
|
951
|
-
throw new Error(`swift-icu: ${
|
|
951
|
+
throw new Error(`swift-icu: ${name2} is not in the sdk's icu archive`);
|
|
952
952
|
}
|
|
953
953
|
function icuSegment(object) {
|
|
954
954
|
let at = 8;
|
|
@@ -1082,8 +1082,8 @@ function splitManifestArguments(source) {
|
|
|
1082
1082
|
if (final) arguments_.push(final);
|
|
1083
1083
|
return arguments_;
|
|
1084
1084
|
}
|
|
1085
|
-
function swiftTargetModuleName(
|
|
1086
|
-
return
|
|
1085
|
+
function swiftTargetModuleName(name2) {
|
|
1086
|
+
return name2.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[0-9]/, "_");
|
|
1087
1087
|
}
|
|
1088
1088
|
function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
1089
1089
|
const implicitResources = swiftImplicitResourcePaths(resourcePaths);
|
|
@@ -1095,16 +1095,16 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
1095
1095
|
]);
|
|
1096
1096
|
const targetNames = new Set(
|
|
1097
1097
|
declarations.flatMap(({ flat }) => {
|
|
1098
|
-
const
|
|
1099
|
-
return
|
|
1098
|
+
const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
1099
|
+
return name2 ? [name2] : [];
|
|
1100
1100
|
})
|
|
1101
1101
|
);
|
|
1102
1102
|
for (const { kind, flat, call } of declarations) {
|
|
1103
1103
|
const executable = kind === "executableTarget";
|
|
1104
|
-
const
|
|
1105
|
-
if (!
|
|
1104
|
+
const name2 = /\bname\s*:\s*"([^"]+)"/.exec(flat)?.[1];
|
|
1105
|
+
if (!name2) continue;
|
|
1106
1106
|
const rawPath = /\bpath\s*:\s*"([^"]*)"/.exec(flat)?.[1];
|
|
1107
|
-
const targetPath = rawPath == null || rawPath === "" ? `Sources/${
|
|
1107
|
+
const targetPath = rawPath == null || rawPath === "" ? `Sources/${name2}` : rawPath.replace(/^\.\//, "").replace(/\/+$/, "");
|
|
1108
1108
|
const languageMode = Number(
|
|
1109
1109
|
/\.swiftLanguageMode\(\s*\.v(\d+)\s*\)/.exec(call)?.[1] ?? "5"
|
|
1110
1110
|
);
|
|
@@ -1144,12 +1144,12 @@ function swiftManifestTargets(manifest, resourcePaths = []) {
|
|
|
1144
1144
|
dependencyNames.add(dependencyName);
|
|
1145
1145
|
}
|
|
1146
1146
|
}
|
|
1147
|
-
const dependencies = [...dependencyNames].map((
|
|
1147
|
+
const dependencies = [...dependencyNames].map((name3) => ({
|
|
1148
1148
|
kind: "target",
|
|
1149
|
-
name:
|
|
1149
|
+
name: name3
|
|
1150
1150
|
}));
|
|
1151
1151
|
targets.push({
|
|
1152
|
-
name,
|
|
1152
|
+
name: name2,
|
|
1153
1153
|
path: targetPath,
|
|
1154
1154
|
executable,
|
|
1155
1155
|
...kind === "systemLibrary" ? { systemLibrary: true } : {},
|
|
@@ -1182,38 +1182,55 @@ var import_node_crypto2 = require("node:crypto");
|
|
|
1182
1182
|
var import_node_fs3 = require("node:fs");
|
|
1183
1183
|
var import_node_path5 = __toESM(require("node:path"), 1);
|
|
1184
1184
|
var POLL_MS = 250;
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
encoding: "utf8",
|
|
1189
|
-
stdio: ["ignore", "pipe", "ignore"]
|
|
1190
|
-
}).trim() || null;
|
|
1191
|
-
} catch {
|
|
1192
|
-
return null;
|
|
1193
|
-
}
|
|
1185
|
+
var START_TOLERANCE_MS = 2e3;
|
|
1186
|
+
function errorCode(error) {
|
|
1187
|
+
return error instanceof Error && "code" in error && typeof error.code === "string" ? error.code : void 0;
|
|
1194
1188
|
}
|
|
1195
|
-
function
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
return { pid: value.pid, start: value.start };
|
|
1200
|
-
} catch {
|
|
1201
|
-
}
|
|
1202
|
-
return null;
|
|
1189
|
+
function parseStart(text2) {
|
|
1190
|
+
const start = Date.parse(`${text2} UTC`);
|
|
1191
|
+
if (Number.isNaN(start)) throw new Error(`unreadable process start time "${text2}"`);
|
|
1192
|
+
return start;
|
|
1203
1193
|
}
|
|
1204
|
-
function
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1194
|
+
function processTable() {
|
|
1195
|
+
const result = (0, import_node_child_process4.spawnSync)("ps", ["-A", "-o", "pid=,pgid=,stat=,lstart="], {
|
|
1196
|
+
encoding: "utf8",
|
|
1197
|
+
env: { ...process.env, LC_ALL: "C", TZ: "UTC" },
|
|
1198
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
1199
|
+
timeout: 1e4,
|
|
1200
|
+
killSignal: "SIGKILL"
|
|
1201
|
+
});
|
|
1202
|
+
if (result.error || result.status !== 0) {
|
|
1203
|
+
throw new Error(
|
|
1204
|
+
`swift root lock cannot read the process table: ${result.error?.message || result.stderr.trim() || `ps exited ${result.status}`}`
|
|
1205
|
+
);
|
|
1210
1206
|
}
|
|
1207
|
+
return result.stdout.split("\n").filter((line) => line.trim()).map((line) => {
|
|
1208
|
+
const match = /^\s*(\d+)\s+(\d+)\s+(\S+)\s+(.+?)\s*$/.exec(line);
|
|
1209
|
+
if (!match)
|
|
1210
|
+
throw new Error(`swift root lock cannot parse a process table row: ${line}`);
|
|
1211
|
+
return {
|
|
1212
|
+
pid: Number(match[1]),
|
|
1213
|
+
pgid: Number(match[2]),
|
|
1214
|
+
zombie: match[3].startsWith("Z"),
|
|
1215
|
+
start: parseStart(match[4])
|
|
1216
|
+
};
|
|
1217
|
+
});
|
|
1218
|
+
}
|
|
1219
|
+
function sameProcess(row, identity) {
|
|
1220
|
+
return row.pid === identity.pid && Math.abs(row.start - identity.start) <= START_TOLERANCE_MS;
|
|
1211
1221
|
}
|
|
1212
|
-
function
|
|
1213
|
-
const
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1222
|
+
function ownIdentity(pid) {
|
|
1223
|
+
const row = processTable().find(
|
|
1224
|
+
(candidate) => candidate.pid === pid && !candidate.zombie
|
|
1225
|
+
);
|
|
1226
|
+
if (!row) throw new Error(`swift root lock cannot find process ${pid}`);
|
|
1227
|
+
return { pid, start: row.start };
|
|
1228
|
+
}
|
|
1229
|
+
function parseIdentity(text2) {
|
|
1230
|
+
const value = JSON.parse(text2);
|
|
1231
|
+
if (value && typeof value === "object" && "pid" in value && typeof value.pid === "number" && "start" in value && typeof value.start === "number")
|
|
1232
|
+
return { pid: value.pid, start: value.start };
|
|
1233
|
+
throw new Error(`swift root lock record is not a process identity: ${text2}`);
|
|
1217
1234
|
}
|
|
1218
1235
|
function pause(ms, signal) {
|
|
1219
1236
|
return new Promise((resolve) => {
|
|
@@ -1226,64 +1243,127 @@ function pause(ms, signal) {
|
|
|
1226
1243
|
signal?.addEventListener("abort", done, { once: true });
|
|
1227
1244
|
});
|
|
1228
1245
|
}
|
|
1246
|
+
var name = (number, suffix) => `${String(number).padStart(12, "0")}.${suffix}`;
|
|
1247
|
+
function generationNumbers(directory) {
|
|
1248
|
+
const numbers = /* @__PURE__ */ new Set();
|
|
1249
|
+
for (const entry of (0, import_node_fs3.readdirSync)(directory)) {
|
|
1250
|
+
const match = /^(\d{12})\./.exec(entry);
|
|
1251
|
+
if (match) numbers.add(Number(match[1]));
|
|
1252
|
+
}
|
|
1253
|
+
return [...numbers].sort((a, b) => a - b);
|
|
1254
|
+
}
|
|
1255
|
+
function readGeneration(directory, number) {
|
|
1256
|
+
let owner;
|
|
1257
|
+
try {
|
|
1258
|
+
owner = (0, import_node_fs3.readFileSync)(import_node_path5.default.join(directory, name(number, "owner")), "utf8");
|
|
1259
|
+
} catch (error) {
|
|
1260
|
+
if (errorCode(error) === "ENOENT") return null;
|
|
1261
|
+
throw error;
|
|
1262
|
+
}
|
|
1263
|
+
return {
|
|
1264
|
+
number,
|
|
1265
|
+
holder: parseIdentity(owner),
|
|
1266
|
+
released: (0, import_node_fs3.readdirSync)(directory).includes(name(number, "released"))
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
function readChildren(directory, number) {
|
|
1270
|
+
const prefix = name(number, "child.");
|
|
1271
|
+
return (0, import_node_fs3.readdirSync)(directory).filter((entry) => entry.startsWith(prefix)).map((entry) => parseIdentity((0, import_node_fs3.readFileSync)(import_node_path5.default.join(directory, entry), "utf8")));
|
|
1272
|
+
}
|
|
1273
|
+
function groupAlive(table, leader) {
|
|
1274
|
+
const row = table.find((candidate) => candidate.pid === leader.pid);
|
|
1275
|
+
if (row && !sameProcess(row, leader)) return false;
|
|
1276
|
+
return table.some((candidate) => candidate.pgid === leader.pid && !candidate.zombie);
|
|
1277
|
+
}
|
|
1229
1278
|
async function withSwiftRootLock(root, work, signal) {
|
|
1230
|
-
const directory = import_node_path5.default.join(
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1279
|
+
const directory = import_node_path5.default.join(
|
|
1280
|
+
rnxHomeDir(),
|
|
1281
|
+
"cache",
|
|
1282
|
+
"swift-root-locks",
|
|
1283
|
+
(0, import_node_crypto2.createHash)("sha256").update(root).digest("hex").slice(0, 32)
|
|
1235
1284
|
);
|
|
1285
|
+
(0, import_node_fs3.mkdirSync)(directory, { recursive: true });
|
|
1236
1286
|
const token = (0, import_node_crypto2.randomUUID)();
|
|
1237
|
-
const owner = JSON.stringify(
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
} catch (error) {
|
|
1251
|
-
if (!(error instanceof Error && "code" in error && error.code === "EEXIST"))
|
|
1252
|
-
throw error;
|
|
1287
|
+
const owner = JSON.stringify(ownIdentity(process.pid));
|
|
1288
|
+
const pending = import_node_path5.default.join(directory, `pending.${token}`);
|
|
1289
|
+
let held = 0;
|
|
1290
|
+
for (; ; ) {
|
|
1291
|
+
signal?.throwIfAborted();
|
|
1292
|
+
const newest = generationNumbers(directory).at(-1) ?? 0;
|
|
1293
|
+
const current = newest > 0 ? readGeneration(directory, newest) : null;
|
|
1294
|
+
if (newest > 0 && !current) continue;
|
|
1295
|
+
if (current && !current.released) {
|
|
1296
|
+
const table = processTable();
|
|
1297
|
+
if (table.some((row) => !row.zombie && sameProcess(row, current.holder))) {
|
|
1298
|
+
await pause(POLL_MS, signal);
|
|
1299
|
+
continue;
|
|
1253
1300
|
}
|
|
1254
|
-
const
|
|
1255
|
-
if (
|
|
1256
|
-
if (holderAlive(held)) {
|
|
1301
|
+
const children2 = readChildren(directory, newest);
|
|
1302
|
+
if (children2.some((child) => groupAlive(table, child))) {
|
|
1257
1303
|
await pause(POLL_MS, signal);
|
|
1258
1304
|
continue;
|
|
1259
1305
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1306
|
+
}
|
|
1307
|
+
(0, import_node_fs3.writeFileSync)(pending, owner);
|
|
1308
|
+
try {
|
|
1309
|
+
(0, import_node_fs3.linkSync)(pending, import_node_path5.default.join(directory, name(newest + 1, "owner")));
|
|
1310
|
+
} catch (error) {
|
|
1311
|
+
if (errorCode(error) === "EEXIST") continue;
|
|
1312
|
+
throw error;
|
|
1313
|
+
} finally {
|
|
1314
|
+
(0, import_node_fs3.rmSync)(pending, { force: true });
|
|
1315
|
+
}
|
|
1316
|
+
const numbers = generationNumbers(directory);
|
|
1317
|
+
if (numbers.at(-1) !== newest + 1) {
|
|
1318
|
+
(0, import_node_fs3.rmSync)(import_node_path5.default.join(directory, name(newest + 1, "owner")), { force: true });
|
|
1319
|
+
continue;
|
|
1320
|
+
}
|
|
1321
|
+
held = newest + 1;
|
|
1322
|
+
for (const number of numbers)
|
|
1323
|
+
if (number < held) {
|
|
1324
|
+
for (const entry of (0, import_node_fs3.readdirSync)(directory))
|
|
1325
|
+
if (entry.startsWith(name(number, "")))
|
|
1326
|
+
(0, import_node_fs3.rmSync)(import_node_path5.default.join(directory, entry), { force: true });
|
|
1266
1327
|
}
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
const children = [];
|
|
1331
|
+
const lease = {
|
|
1332
|
+
spawn(command, args, options) {
|
|
1333
|
+
const child = (0, import_node_child_process4.spawn)(
|
|
1334
|
+
"/bin/sh",
|
|
1335
|
+
["-c", 'IFS= read -r go || exit 1; exec "$@" </dev/null', "sh", command, ...args],
|
|
1336
|
+
{ ...options, detached: true, stdio: ["pipe", "pipe", "pipe"] }
|
|
1337
|
+
);
|
|
1338
|
+
child.stdin.on("error", () => {
|
|
1339
|
+
});
|
|
1340
|
+
children.push(child);
|
|
1267
1341
|
try {
|
|
1268
|
-
if (
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1342
|
+
if (child.pid === void 0) {
|
|
1343
|
+
child.once("error", () => {
|
|
1344
|
+
});
|
|
1345
|
+
throw new Error(`could not start ${command}`);
|
|
1346
|
+
}
|
|
1347
|
+
const childPending = `${pending}.child.${child.pid}`;
|
|
1348
|
+
try {
|
|
1349
|
+
(0, import_node_fs3.writeFileSync)(childPending, JSON.stringify(ownIdentity(child.pid)));
|
|
1350
|
+
(0, import_node_fs3.linkSync)(childPending, import_node_path5.default.join(directory, name(held, `child.${child.pid}`)));
|
|
1351
|
+
} finally {
|
|
1352
|
+
(0, import_node_fs3.rmSync)(childPending, { force: true });
|
|
1275
1353
|
}
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1354
|
+
} catch (error) {
|
|
1355
|
+
child.stdin.destroy();
|
|
1356
|
+
throw error;
|
|
1278
1357
|
}
|
|
1358
|
+
child.stdin.end("go\n");
|
|
1359
|
+
return child;
|
|
1279
1360
|
}
|
|
1280
|
-
}
|
|
1281
|
-
(0, import_node_fs3.rmSync)(pending, { force: true });
|
|
1282
|
-
}
|
|
1361
|
+
};
|
|
1283
1362
|
try {
|
|
1284
|
-
return await work();
|
|
1363
|
+
return await work(lease);
|
|
1285
1364
|
} finally {
|
|
1286
|
-
|
|
1365
|
+
await Promise.all(children.map((child) => terminateProcessGroup(child, "SIGKILL", 0)));
|
|
1366
|
+
(0, import_node_fs3.writeFileSync)(import_node_path5.default.join(directory, name(held, "released")), "");
|
|
1287
1367
|
}
|
|
1288
1368
|
}
|
|
1289
1369
|
|
|
@@ -1304,12 +1384,13 @@ function isSwiftResourceBundles(value) {
|
|
|
1304
1384
|
async function runCompiler(command, args, options, stream = false, quiet) {
|
|
1305
1385
|
const { signal } = options;
|
|
1306
1386
|
signal?.throwIfAborted();
|
|
1307
|
-
const
|
|
1387
|
+
const launch = {
|
|
1308
1388
|
cwd: options.cwd,
|
|
1309
1389
|
env: swiftEnvironment(options.env),
|
|
1310
1390
|
detached: true,
|
|
1311
1391
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1312
|
-
}
|
|
1392
|
+
};
|
|
1393
|
+
const child = options.lease ? options.lease.spawn(command, args, launch) : (0, import_node_child_process5.spawn)(command, args, launch);
|
|
1313
1394
|
let stopping;
|
|
1314
1395
|
try {
|
|
1315
1396
|
await new Promise((resolve, reject) => {
|
|
@@ -1323,20 +1404,20 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
1323
1404
|
void stopping.catch(() => {
|
|
1324
1405
|
});
|
|
1325
1406
|
};
|
|
1326
|
-
for (const
|
|
1327
|
-
child[
|
|
1328
|
-
if (stream === true) process[
|
|
1407
|
+
for (const name2 of ["stdout", "stderr"]) {
|
|
1408
|
+
child[name2].on("data", (bytes) => {
|
|
1409
|
+
if (stream === true) process[name2].write(bytes);
|
|
1329
1410
|
else if (stream) {
|
|
1330
|
-
const lines = (partial[
|
|
1331
|
-
partial[
|
|
1411
|
+
const lines = (partial[name2] + bytes.toString()).split("\n");
|
|
1412
|
+
partial[name2] = lines.pop();
|
|
1332
1413
|
for (const line of lines)
|
|
1333
|
-
if (stream.test(line)) process[
|
|
1414
|
+
if (stream.test(line)) process[name2].write(`${line}
|
|
1334
1415
|
`);
|
|
1335
1416
|
}
|
|
1336
|
-
sizes[
|
|
1337
|
-
if (sizes[
|
|
1417
|
+
sizes[name2] += bytes.length;
|
|
1418
|
+
if (sizes[name2] <= (options.maxBuffer ?? 1024 * 1024)) chunks[name2].push(bytes);
|
|
1338
1419
|
else {
|
|
1339
|
-
failure = new Error(`Swift compiler ${
|
|
1420
|
+
failure = new Error(`Swift compiler ${name2} exceeded its output limit`);
|
|
1340
1421
|
stop();
|
|
1341
1422
|
}
|
|
1342
1423
|
});
|
|
@@ -1364,9 +1445,9 @@ async function runCompiler(command, args, options, stream = false, quiet) {
|
|
|
1364
1445
|
);
|
|
1365
1446
|
else {
|
|
1366
1447
|
if (quiet) {
|
|
1367
|
-
for (const
|
|
1368
|
-
for (const line of Buffer.concat(chunks[
|
|
1369
|
-
if (line && !quiet.test(line)) process[
|
|
1448
|
+
for (const name2 of ["stdout", "stderr"])
|
|
1449
|
+
for (const line of Buffer.concat(chunks[name2]).toString().split("\n"))
|
|
1450
|
+
if (line && !quiet.test(line)) process[name2].write(`${line}
|
|
1370
1451
|
`);
|
|
1371
1452
|
}
|
|
1372
1453
|
resolve();
|
|
@@ -1611,11 +1692,11 @@ function swiftCondition(text2, available) {
|
|
|
1611
1692
|
if (token === "false") return false;
|
|
1612
1693
|
const call = /^(\w+)\s*\(\s*([^,()]*?)\s*(?:,[^()]*)?\)$/.exec(token ?? "");
|
|
1613
1694
|
if (!call) return void 0;
|
|
1614
|
-
const [,
|
|
1615
|
-
if (
|
|
1616
|
-
if (
|
|
1617
|
-
if (
|
|
1618
|
-
if (
|
|
1695
|
+
const [, name2, argument] = call;
|
|
1696
|
+
if (name2 === "os") return argument === "iOS" || argument === "WASI";
|
|
1697
|
+
if (name2 === "canImport") return available.has(argument);
|
|
1698
|
+
if (name2 === "targetEnvironment") return false;
|
|
1699
|
+
if (name2 === "arch") return argument === "wasm32";
|
|
1619
1700
|
return void 0;
|
|
1620
1701
|
};
|
|
1621
1702
|
const both = () => {
|
|
@@ -1659,8 +1740,8 @@ function swiftImportNames(contents, available) {
|
|
|
1659
1740
|
continue;
|
|
1660
1741
|
}
|
|
1661
1742
|
if (available && frames.some((frame) => frame.active !== true)) continue;
|
|
1662
|
-
const
|
|
1663
|
-
if (
|
|
1743
|
+
const name2 = SWIFT_IMPORT.exec(line)?.[1];
|
|
1744
|
+
if (name2) names.push(name2);
|
|
1664
1745
|
}
|
|
1665
1746
|
return names;
|
|
1666
1747
|
}
|
|
@@ -1690,9 +1771,9 @@ function swiftSdkPaths(moduleRoot, toolchainBin) {
|
|
|
1690
1771
|
],
|
|
1691
1772
|
{ encoding: "utf8", env: swiftEnvironment(), stdio: ["ignore", "pipe", "pipe"] }
|
|
1692
1773
|
);
|
|
1693
|
-
const field = (
|
|
1694
|
-
const value = new RegExp(`^${
|
|
1695
|
-
if (!value) throw new Error(`swift sdk ${sdk} reports no ${
|
|
1774
|
+
const field = (name2) => {
|
|
1775
|
+
const value = new RegExp(`^${name2}:\\s*(.+)$`, "m").exec(configuration)?.[1]?.trim();
|
|
1776
|
+
if (!value) throw new Error(`swift sdk ${sdk} reports no ${name2}`);
|
|
1696
1777
|
return value;
|
|
1697
1778
|
};
|
|
1698
1779
|
const paths = {
|
|
@@ -1727,9 +1808,9 @@ function missingSwiftModules(files, available) {
|
|
|
1727
1808
|
const missing = /* @__PURE__ */ new Map();
|
|
1728
1809
|
for (const [file, contents] of Object.entries(files)) {
|
|
1729
1810
|
if (!file.endsWith(".swift") || file === "Package.swift") continue;
|
|
1730
|
-
for (const
|
|
1731
|
-
if (available.has(
|
|
1732
|
-
missing.set(
|
|
1811
|
+
for (const name2 of new Set(swiftImportNames(contents, available))) {
|
|
1812
|
+
if (available.has(name2)) continue;
|
|
1813
|
+
missing.set(name2, [...missing.get(name2) ?? [], file]);
|
|
1733
1814
|
}
|
|
1734
1815
|
}
|
|
1735
1816
|
return new Map([...missing].sort(([left], [right]) => left.localeCompare(right)));
|
|
@@ -1750,8 +1831,8 @@ function swiftTargetDependencies(files, targets) {
|
|
|
1750
1831
|
(candidate) => candidate.name !== target.name && candidate.path !== "." && candidate.path.startsWith(prefix) && file.startsWith(`${candidate.path}/`)
|
|
1751
1832
|
))
|
|
1752
1833
|
continue;
|
|
1753
|
-
for (const
|
|
1754
|
-
if (names.has(
|
|
1834
|
+
for (const name2 of swiftImportNames(contents)) {
|
|
1835
|
+
if (names.has(name2) && name2 !== target.name) deps.add(name2);
|
|
1755
1836
|
}
|
|
1756
1837
|
}
|
|
1757
1838
|
siblings.set(target.name, [...deps].sort());
|
|
@@ -1781,7 +1862,7 @@ var EXECUTABLE_LINK_FLAGS = ` "-Xclang-linker", "-O0",
|
|
|
1781
1862
|
`;
|
|
1782
1863
|
var REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
1783
1864
|
var MULTI_MANIFEST_VERSION = 39;
|
|
1784
|
-
var compilerSourceDigest = true ? "
|
|
1865
|
+
var compilerSourceDigest = true ? "c2ab17198fbe6328c75dc09bbe160fe6b0fd74d4b84a08e9f8dfcd2fcf4ca1f0" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
1785
1866
|
function swiftArtifactHash(input, release, moduleRoot) {
|
|
1786
1867
|
const hash = (0, import_node_crypto3.createHash)("sha256");
|
|
1787
1868
|
hash.update(`swift-compile
|
|
@@ -1807,10 +1888,10 @@ ${release}
|
|
|
1807
1888
|
(0, import_node_crypto3.createHash)("sha256").update(input.resources?.[base] ?? "").digest()
|
|
1808
1889
|
);
|
|
1809
1890
|
}
|
|
1810
|
-
for (const
|
|
1811
|
-
const image = input.images?.[
|
|
1891
|
+
for (const name2 of Object.keys(input.images ?? {}).sort()) {
|
|
1892
|
+
const image = input.images?.[name2];
|
|
1812
1893
|
if (!image) continue;
|
|
1813
|
-
hash.update((0, import_node_crypto3.createHash)("sha256").update(
|
|
1894
|
+
hash.update((0, import_node_crypto3.createHash)("sha256").update(name2).digest());
|
|
1814
1895
|
hash.update((0, import_node_crypto3.createHash)("sha256").update(image.file).digest());
|
|
1815
1896
|
hash.update((0, import_node_crypto3.createHash)("sha256").update(image.data).digest());
|
|
1816
1897
|
}
|
|
@@ -1849,17 +1930,17 @@ ${target}
|
|
|
1849
1930
|
function emitSwiftPackageManifest(args) {
|
|
1850
1931
|
const { targets, siblings, moduleRoot, oneModule, spriteKit, distribution } = args;
|
|
1851
1932
|
const reachedFrameworks = /* @__PURE__ */ new Set();
|
|
1852
|
-
const reach = (
|
|
1853
|
-
if (reachedFrameworks.has(
|
|
1854
|
-
reachedFrameworks.add(
|
|
1855
|
-
for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[
|
|
1933
|
+
const reach = (name2) => {
|
|
1934
|
+
if (reachedFrameworks.has(name2)) return;
|
|
1935
|
+
reachedFrameworks.add(name2);
|
|
1936
|
+
for (const dependency of OPTIONAL_FRAMEWORK_DEPENDENCIES[name2] ?? [])
|
|
1856
1937
|
reach(dependency);
|
|
1857
1938
|
};
|
|
1858
|
-
for (const
|
|
1859
|
-
if (OPTIONAL_FRAMEWORKS.has(
|
|
1860
|
-
reach(
|
|
1939
|
+
for (const name2 of [...siblings.values()].flat())
|
|
1940
|
+
if (OPTIONAL_FRAMEWORKS.has(name2) && !targets.some((target) => target.name === name2))
|
|
1941
|
+
reach(name2);
|
|
1861
1942
|
if (spriteKit) {
|
|
1862
|
-
for (const
|
|
1943
|
+
for (const name2 of ["SpriteKit", "PeachBox2D", "simd", "GLKit"]) reach(name2);
|
|
1863
1944
|
}
|
|
1864
1945
|
const distributionLink = args.distributionLink;
|
|
1865
1946
|
if (distribution && !distributionLink)
|
|
@@ -1869,7 +1950,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
1869
1950
|
if (distribution && distributionLink) {
|
|
1870
1951
|
const objects = distribution.objects.filter(
|
|
1871
1952
|
(object) => [...OPTIONAL_FRAMEWORKS, "SpriteKit", "PeachBox2D"].every(
|
|
1872
|
-
(
|
|
1953
|
+
(name2) => !object.startsWith(`lib/${name2}-`) || reachedFrameworks.has(name2)
|
|
1873
1954
|
)
|
|
1874
1955
|
);
|
|
1875
1956
|
distributionLink.files.set(
|
|
@@ -1898,11 +1979,11 @@ function emitSwiftPackageManifest(args) {
|
|
|
1898
1979
|
return ` .systemLibrary(name: ${JSON.stringify(target.name)}, path: ${JSON.stringify(target.path)}),`;
|
|
1899
1980
|
const isolation = target.mainActorIsolation ? " .defaultIsolation(MainActor.self)," : "";
|
|
1900
1981
|
const interoperability = target.cxxInterop ? " .interoperabilityMode(.Cxx)," : "";
|
|
1901
|
-
const defines = (target.defines ?? []).map((
|
|
1982
|
+
const defines = (target.defines ?? []).map((name2) => ` .define(${JSON.stringify(name2)}),`).join("");
|
|
1902
1983
|
const imports = distribution ? `, "-I", ${JSON.stringify(import_node_path6.default.join(moduleRoot, "modules"))}` : "";
|
|
1903
1984
|
const native = args.native?.get(target.name);
|
|
1904
|
-
const nativeImports = (siblings.get(target.name) ?? []).filter((
|
|
1905
|
-
(
|
|
1985
|
+
const nativeImports = (siblings.get(target.name) ?? []).filter((name2) => args.native?.has(name2)).map(
|
|
1986
|
+
(name2) => `, "-Xfrontend", "-import-module", "-Xfrontend", ${JSON.stringify(swiftTargetModuleName(name2))}`
|
|
1906
1987
|
).join("");
|
|
1907
1988
|
const header = args.headerDirectory && [...args.native?.values() ?? []].some(
|
|
1908
1989
|
(value) => value.late?.producers.includes(target.name)
|
|
@@ -1924,7 +2005,7 @@ function emitSwiftPackageManifest(args) {
|
|
|
1924
2005
|
const library = distribution && distributionLink ? ["-Xclang-linker", `--config=${distributionLink.path}`, ...distribution.link].map((flag) => `, ${JSON.stringify(flag)}`).join("") : "";
|
|
1925
2006
|
const kind = target.executable ? ".executableTarget" : ".target";
|
|
1926
2007
|
const linkedLibraries = (target.linkedLibraries ?? []).map(
|
|
1927
|
-
(
|
|
2008
|
+
(name2) => `.linkedLibrary(${JSON.stringify(name2)})`
|
|
1928
2009
|
);
|
|
1929
2010
|
const librarySettings = [
|
|
1930
2011
|
...linkedLibraries,
|
|
@@ -1963,9 +2044,9 @@ function emitSwiftPackageManifest(args) {
|
|
|
1963
2044
|
" targets: [",
|
|
1964
2045
|
...targets.map(stanza),
|
|
1965
2046
|
...[...args.native?.entries() ?? []].flatMap(
|
|
1966
|
-
([
|
|
2047
|
+
([name2, native]) => native.late ? [
|
|
1967
2048
|
` .target(name: ${JSON.stringify(native.late.name)},`,
|
|
1968
|
-
` dependencies: ${JSON.stringify([
|
|
2049
|
+
` dependencies: ${JSON.stringify([name2, ...native.late.producers])},`,
|
|
1969
2050
|
` path: ${JSON.stringify(native.path)},`,
|
|
1970
2051
|
` sources: ${JSON.stringify(native.lateSources)},`,
|
|
1971
2052
|
` publicHeadersPath: "include",`,
|
|
@@ -2218,7 +2299,7 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
|
|
|
2218
2299
|
if (top?.kind !== "extension") continue;
|
|
2219
2300
|
const func = OVERRIDE_FUNC.exec(rest);
|
|
2220
2301
|
if (func) {
|
|
2221
|
-
const
|
|
2302
|
+
const name2 = func[2];
|
|
2222
2303
|
const open = at + func[0].length - 1;
|
|
2223
2304
|
let depth = 0;
|
|
2224
2305
|
let close = open;
|
|
@@ -2231,12 +2312,12 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
|
|
|
2231
2312
|
const clause = source.slice(close + 1, body).trim();
|
|
2232
2313
|
const args = forwardedArguments(source.slice(open + 1, close));
|
|
2233
2314
|
if (args === null) continue;
|
|
2234
|
-
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${
|
|
2235
|
-
const signature = `func ${
|
|
2236
|
-
const nameAt = at + rest.indexOf(
|
|
2315
|
+
const call = (clause.includes("->") ? "return " : "") + (/\b(?:throws|rethrows)\b/.test(clause) ? "try " : "") + (/\basync\b/.test(clause) ? "await " : "") + `__peach_ext_${name2}(${args})`;
|
|
2316
|
+
const signature = `func ${name2}${func[3] ?? ""}${source.slice(open, close + 1)}${clause ? ` ${clause}` : ""}`;
|
|
2317
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("func", "override".length + func[1].length) + 4);
|
|
2237
2318
|
lifted.push({
|
|
2238
2319
|
type: top.name,
|
|
2239
|
-
member:
|
|
2320
|
+
member: name2,
|
|
2240
2321
|
at,
|
|
2241
2322
|
modifiers,
|
|
2242
2323
|
access,
|
|
@@ -2254,16 +2335,16 @@ function extensionOverrideEdits(source, extraObjCExtensions) {
|
|
|
2254
2335
|
if (property) {
|
|
2255
2336
|
const open = at + property[0].length - 1;
|
|
2256
2337
|
if (/\b(?:set|willSet|didSet)\b/.test(source.slice(open, closing(open)))) continue;
|
|
2257
|
-
const
|
|
2258
|
-
const nameAt = at + rest.indexOf(
|
|
2338
|
+
const name2 = property[2];
|
|
2339
|
+
const nameAt = at + rest.indexOf(name2, rest.indexOf("var"));
|
|
2259
2340
|
lifted.push({
|
|
2260
2341
|
type: top.name,
|
|
2261
|
-
member:
|
|
2342
|
+
member: name2,
|
|
2262
2343
|
at,
|
|
2263
2344
|
modifiers,
|
|
2264
2345
|
access,
|
|
2265
|
-
decl: `var ${
|
|
2266
|
-
forward: `{ __peach_ext_${
|
|
2346
|
+
decl: `var ${name2}: ${property[3].trim()}`,
|
|
2347
|
+
forward: `{ __peach_ext_${name2} };`,
|
|
2267
2348
|
nameAt,
|
|
2268
2349
|
edits: [
|
|
2269
2350
|
[at, "override".length, " ".repeat("override".length)],
|
|
@@ -2401,15 +2482,15 @@ function objcRootedClasses(sources) {
|
|
|
2401
2482
|
))
|
|
2402
2483
|
bases.set(match[1], match[2]);
|
|
2403
2484
|
const rooted = /* @__PURE__ */ new Set();
|
|
2404
|
-
for (const
|
|
2405
|
-
const seen = /* @__PURE__ */ new Set([
|
|
2406
|
-
let base = bases.get(
|
|
2485
|
+
for (const name2 of bases.keys()) {
|
|
2486
|
+
const seen = /* @__PURE__ */ new Set([name2]);
|
|
2487
|
+
let base = bases.get(name2);
|
|
2407
2488
|
while (bases.has(base) && !seen.has(base)) {
|
|
2408
2489
|
seen.add(base);
|
|
2409
2490
|
base = bases.get(base);
|
|
2410
2491
|
}
|
|
2411
2492
|
if (!bases.has(base) && APPLE_CLASS.test(base) && !APPLE_PROTOCOL.test(base) && !(base in SDK_OBJC_OPTIONAL))
|
|
2412
|
-
rooted.add(
|
|
2493
|
+
rooted.add(name2);
|
|
2413
2494
|
}
|
|
2414
2495
|
return rooted;
|
|
2415
2496
|
}
|
|
@@ -2552,8 +2633,8 @@ function inheritedTypes(sources) {
|
|
|
2552
2633
|
if (colon === -1) continue;
|
|
2553
2634
|
const inherited = parents.get(owner[1]) ?? /* @__PURE__ */ new Set();
|
|
2554
2635
|
for (const type of splitTopLevel(header.slice(colon + 1).split(/\bwhere\b/)[0])) {
|
|
2555
|
-
const
|
|
2556
|
-
if (
|
|
2636
|
+
const name2 = /^\s*(?:[A-Za-z_]\w*\.)*([A-Za-z_]\w*)/.exec(type)?.[1];
|
|
2637
|
+
if (name2 && !type.includes("<")) inherited.add(name2);
|
|
2557
2638
|
}
|
|
2558
2639
|
parents.set(owner[1], inherited);
|
|
2559
2640
|
}
|
|
@@ -2632,20 +2713,20 @@ var DECLARATION_MODIFIERS = /* @__PURE__ */ new Set([
|
|
|
2632
2713
|
"unowned"
|
|
2633
2714
|
]);
|
|
2634
2715
|
function objcSelectorName(base, labels, isAsync, isThrowing) {
|
|
2635
|
-
let
|
|
2716
|
+
let name2 = base;
|
|
2636
2717
|
labels.forEach((label, index) => {
|
|
2637
|
-
if (index > 0)
|
|
2718
|
+
if (index > 0) name2 += `${label === "_" ? "" : label}:`;
|
|
2638
2719
|
else {
|
|
2639
2720
|
if (label !== "_") {
|
|
2640
2721
|
const firstWord = label[0] + /^[^A-Z_]*/.exec(label.slice(1))[0];
|
|
2641
|
-
|
|
2722
|
+
name2 += `${OBJC_PREPOSITIONS.has(firstWord) ? "" : "With"}${label[0].toUpperCase()}${label.slice(1)}`;
|
|
2642
2723
|
}
|
|
2643
|
-
|
|
2724
|
+
name2 += ":";
|
|
2644
2725
|
}
|
|
2645
2726
|
});
|
|
2646
|
-
if (isAsync)
|
|
2647
|
-
else if (isThrowing)
|
|
2648
|
-
return
|
|
2727
|
+
if (isAsync) name2 += labels.length ? "completionHandler:" : "WithCompletionHandler:";
|
|
2728
|
+
else if (isThrowing) name2 += labels.length ? "error:" : "AndReturnError:";
|
|
2729
|
+
return name2;
|
|
2649
2730
|
}
|
|
2650
2731
|
function declarationStart(code, at, floor) {
|
|
2651
2732
|
let start = at;
|
|
@@ -2707,22 +2788,22 @@ function objcOptionalProtocols(source) {
|
|
|
2707
2788
|
...(attributes.match(/@available\s*\((?:[^()"]|"(?:[^"\\]|\\.)*")*\)/g) ?? []).map((attribute) => attribute.replace(/\s*\n\s*/g, " ")),
|
|
2708
2789
|
access ?? ""
|
|
2709
2790
|
].filter((word) => word !== "").join(" ");
|
|
2710
|
-
const
|
|
2791
|
+
const name2 = member[2];
|
|
2711
2792
|
const after = at + member[0].length;
|
|
2712
2793
|
if (member[1] === "var") {
|
|
2713
2794
|
const typed = /^\s*:\s*([^{\n]+?)\s*\{[^}]*\}/.exec(code.slice(after));
|
|
2714
2795
|
if (!typed) continue;
|
|
2715
|
-
const selector2 = explicit ??
|
|
2796
|
+
const selector2 = explicit ?? name2;
|
|
2716
2797
|
const typeMember2 = /\bstatic\b/.test(code.slice(start, at));
|
|
2717
2798
|
members.push({
|
|
2718
|
-
name,
|
|
2799
|
+
name: name2,
|
|
2719
2800
|
labels: null,
|
|
2720
2801
|
selector: selector2,
|
|
2721
2802
|
start,
|
|
2722
2803
|
end: after + typed[0].length,
|
|
2723
2804
|
result: objcTypeName(typed[1]),
|
|
2724
2805
|
typeMember: typeMember2,
|
|
2725
|
-
helper: `${head} ${typeMember2 ? "static " : ""}var ${
|
|
2806
|
+
helper: `${head} ${typeMember2 ? "static " : ""}var ${name2}: ${optionalResult(typed[1])} { _objcOptionalSend(self, Selector(${JSON.stringify(selector2)}), [], default: nil) }`
|
|
2726
2807
|
});
|
|
2727
2808
|
continue;
|
|
2728
2809
|
}
|
|
@@ -2734,10 +2815,10 @@ function objcOptionalProtocols(source) {
|
|
|
2734
2815
|
const parameters = code.slice(paren + 1, shut);
|
|
2735
2816
|
const names = parameterNames(parameters);
|
|
2736
2817
|
const labels = names.map((parameter) => parameter.label);
|
|
2737
|
-
const selector = explicit ?? objcSelectorName(
|
|
2818
|
+
const selector = explicit ?? objcSelectorName(name2, labels, tail[1] !== void 0, tail[2] !== void 0);
|
|
2738
2819
|
const typeMember = /\bstatic\b/.test(code.slice(start, at));
|
|
2739
2820
|
members.push({
|
|
2740
|
-
name,
|
|
2821
|
+
name: name2,
|
|
2741
2822
|
labels,
|
|
2742
2823
|
typeMember,
|
|
2743
2824
|
selector,
|
|
@@ -2746,12 +2827,12 @@ function objcOptionalProtocols(source) {
|
|
|
2746
2827
|
types: parameterTypes(parameters),
|
|
2747
2828
|
result: objcTypeName(tail[3]?.trim() ?? "Void"),
|
|
2748
2829
|
helper: typeMember && (tail[1] !== void 0 || tail[2] !== void 0) ? null : tail[1] !== void 0 ? objcAsyncOptionalHelper(
|
|
2749
|
-
`${head} func ${
|
|
2830
|
+
`${head} func ${name2}(${parameters.replace(/\s*\n\s*/g, " ")})`,
|
|
2750
2831
|
parameters,
|
|
2751
2832
|
selector,
|
|
2752
2833
|
tail[3]?.trim() ?? "Void",
|
|
2753
2834
|
tail[2] !== void 0
|
|
2754
|
-
) : tail[2] !== void 0 ? null : `@discardableResult ${head} ${typeMember ? "static " : ""}func ${
|
|
2835
|
+
) : tail[2] !== void 0 ? null : `@discardableResult ${head} ${typeMember ? "static " : ""}func ${name2}(${parameters.replace(/\s*\n\s*/g, " ")}) -> ${optionalResult(tail[3]?.trim() ?? "Void")} { ${escapingSend(parameters, `_objcOptionalSend(self, Selector(${JSON.stringify(selector)}), [${names.map((parameter) => parameter.name).join(", ")}], default: nil)`)} }`
|
|
2755
2836
|
});
|
|
2756
2837
|
}
|
|
2757
2838
|
if (members.length) found.push({ name: declared[1], close, members });
|
|
@@ -2768,8 +2849,8 @@ function escapingSend(parameters, send, effects = "") {
|
|
|
2768
2849
|
if (!named || !type?.startsWith("(")) return body;
|
|
2769
2850
|
const shut = closingParen(type, 0);
|
|
2770
2851
|
if (!/^\s*(?:async\b\s*)?(?:throws\b\s*)?->/.test(type.slice(shut + 1))) return body;
|
|
2771
|
-
const
|
|
2772
|
-
return `${effects}withoutActuallyEscaping(${
|
|
2852
|
+
const name2 = named[2] ?? named[1];
|
|
2853
|
+
return `${effects}withoutActuallyEscaping(${name2}) { ${name2} in ${body} }`;
|
|
2773
2854
|
}, send);
|
|
2774
2855
|
}
|
|
2775
2856
|
function objcAsyncOptionalHelper(declaration, parameters, selector, result, throwing) {
|
|
@@ -4219,10 +4300,10 @@ function objcTypeMethods(source, found) {
|
|
|
4219
4300
|
function objcIndex(sources) {
|
|
4220
4301
|
const requirements = /* @__PURE__ */ new Map();
|
|
4221
4302
|
const callable = /* @__PURE__ */ new Map();
|
|
4222
|
-
const callableAs = (
|
|
4223
|
-
const known = callable.get(
|
|
4303
|
+
const callableAs = (name2, member, labels) => {
|
|
4304
|
+
const known = callable.get(name2);
|
|
4224
4305
|
if (known) known.labels.push(labels);
|
|
4225
|
-
else callable.set(
|
|
4306
|
+
else callable.set(name2, { member, labels: [labels] });
|
|
4226
4307
|
};
|
|
4227
4308
|
const typeMethods = /* @__PURE__ */ new Map();
|
|
4228
4309
|
const sdkParents = /* @__PURE__ */ new Map();
|
|
@@ -4240,9 +4321,9 @@ function objcIndex(sources) {
|
|
|
4240
4321
|
requirements.set(
|
|
4241
4322
|
protocol,
|
|
4242
4323
|
sdk.requirements.map(([signature, selector, typed, asyncSignature]) => {
|
|
4243
|
-
const
|
|
4244
|
-
const labels = signature.slice(
|
|
4245
|
-
if (sdk.callers) callableAs(
|
|
4324
|
+
const name2 = signature.slice(0, signature.indexOf("("));
|
|
4325
|
+
const labels = signature.slice(name2.length + 1, -1).split(":").slice(0, -1);
|
|
4326
|
+
if (sdk.callers) callableAs(name2, `_objcOptional_${name2}`, labels);
|
|
4246
4327
|
const arrow = typed?.lastIndexOf("->") ?? -1;
|
|
4247
4328
|
const types = typed?.slice(0, arrow);
|
|
4248
4329
|
const result = typed?.slice(arrow + 2);
|
|
@@ -4253,7 +4334,7 @@ function objcIndex(sources) {
|
|
|
4253
4334
|
const values = handler ? splitTopLevel(handler[1]) : [];
|
|
4254
4335
|
const asyncName = asyncSignature?.slice(0, asyncSignature.indexOf("("));
|
|
4255
4336
|
return {
|
|
4256
|
-
name,
|
|
4337
|
+
name: name2,
|
|
4257
4338
|
labels,
|
|
4258
4339
|
selector,
|
|
4259
4340
|
...parameters !== void 0 && { types: parameters },
|
|
@@ -4279,8 +4360,8 @@ function objcIndex(sources) {
|
|
|
4279
4360
|
for (const protocol of objcOptionalProtocols(source)) {
|
|
4280
4361
|
requirements.set(
|
|
4281
4362
|
protocol.name,
|
|
4282
|
-
protocol.members.map(({ name, labels, selector, types, result, typeMember }) => ({
|
|
4283
|
-
name,
|
|
4363
|
+
protocol.members.map(({ name: name2, labels, selector, types, result, typeMember }) => ({
|
|
4364
|
+
name: name2,
|
|
4284
4365
|
labels,
|
|
4285
4366
|
selector,
|
|
4286
4367
|
...typeMember && { typeMember },
|
|
@@ -4310,18 +4391,18 @@ function objcIndex(sources) {
|
|
|
4310
4391
|
const code = swiftCodeMask(source);
|
|
4311
4392
|
const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
|
|
4312
4393
|
for (const protocol of code.matchAll(/\bprotocol\s+([A-Za-z_]\w*)[^{}]*\{/g)) {
|
|
4313
|
-
const
|
|
4314
|
-
protocols.add(
|
|
4394
|
+
const name2 = protocol[1];
|
|
4395
|
+
protocols.add(name2);
|
|
4315
4396
|
const open = protocol.index + protocol[0].length - 1;
|
|
4316
4397
|
if (/\binit\s*[?!]?\s*\(/.test(code.slice(open + 1, closingBrace(code, braces, open))))
|
|
4317
|
-
initializers.add(
|
|
4398
|
+
initializers.add(name2);
|
|
4318
4399
|
}
|
|
4319
4400
|
}
|
|
4320
4401
|
const rooted = conformingTypes(parents, /* @__PURE__ */ new Set(["NSObject"]));
|
|
4321
4402
|
const initialized = conformingTypes(parents, initializers);
|
|
4322
4403
|
const nsObjectTypes = /* @__PURE__ */ new Set([
|
|
4323
4404
|
"NSObject",
|
|
4324
|
-
...[...protocols].filter((
|
|
4405
|
+
...[...protocols].filter((name2) => rooted.has(name2) && !initialized.has(name2))
|
|
4325
4406
|
]);
|
|
4326
4407
|
return {
|
|
4327
4408
|
requirements,
|
|
@@ -4348,8 +4429,8 @@ function objcAliases(sources) {
|
|
|
4348
4429
|
}
|
|
4349
4430
|
}
|
|
4350
4431
|
const aliases = /* @__PURE__ */ new Map();
|
|
4351
|
-
for (const [
|
|
4352
|
-
for (const [
|
|
4432
|
+
for (const [name2, type] of declared) if (type !== null) aliases.set(name2, type);
|
|
4433
|
+
for (const [name2, type] of aliases) aliases.set(name2, resolveAliases(type, aliases));
|
|
4353
4434
|
return aliases;
|
|
4354
4435
|
}
|
|
4355
4436
|
function resolveAliases(type, aliases) {
|
|
@@ -4357,7 +4438,7 @@ function resolveAliases(type, aliases) {
|
|
|
4357
4438
|
for (let pass = 0; pass < 8 && aliases.size; pass++) {
|
|
4358
4439
|
const next = resolved.replace(
|
|
4359
4440
|
/(?<![\w.])[A-Za-z_]\w*(?![\w.])/g,
|
|
4360
|
-
(
|
|
4441
|
+
(name2) => aliases.get(name2) ?? name2
|
|
4361
4442
|
);
|
|
4362
4443
|
if (next === resolved) break;
|
|
4363
4444
|
resolved = next;
|
|
@@ -4463,17 +4544,17 @@ function lowerObjCOptionalRequirements(source, index) {
|
|
|
4463
4544
|
`; extension ${protocol.name} { ${helpers.join("; ")} }`
|
|
4464
4545
|
]);
|
|
4465
4546
|
}
|
|
4466
|
-
for (const
|
|
4547
|
+
for (const name2 of code.matchAll(
|
|
4467
4548
|
/#selector\(\s*([A-Za-z_]\w*)\.([A-Za-z_]\w*)\(((?:\s*\w+\s*:)+)\s*\)\s*\)/g
|
|
4468
4549
|
)) {
|
|
4469
|
-
const signature = `${
|
|
4470
|
-
const found = SDK_OBJC_OPTIONAL[
|
|
4550
|
+
const signature = `${name2[2]}(${name2[3].replace(/\s+/g, "")})`;
|
|
4551
|
+
const found = SDK_OBJC_OPTIONAL[name2[1]]?.requirements.filter(
|
|
4471
4552
|
([requirement]) => requirement === signature
|
|
4472
4553
|
);
|
|
4473
4554
|
if (found?.length === 1)
|
|
4474
4555
|
edits.push([
|
|
4475
|
-
|
|
4476
|
-
|
|
4556
|
+
name2.index,
|
|
4557
|
+
name2[0].length,
|
|
4477
4558
|
`NSSelectorFromString(${JSON.stringify(found[0][1])})`
|
|
4478
4559
|
]);
|
|
4479
4560
|
}
|
|
@@ -4481,7 +4562,7 @@ function lowerObjCOptionalRequirements(source, index) {
|
|
|
4481
4562
|
const receivesAsProtocol = (dot) => {
|
|
4482
4563
|
const receiver = /([A-Za-z_]\w*)\s*[?!]?\s*$/.exec(code.slice(0, dot))?.[1];
|
|
4483
4564
|
if (!receiver) return false;
|
|
4484
|
-
const
|
|
4565
|
+
const name2 = /^\.\s*([A-Za-z_]\w*)/.exec(code.slice(dot))?.[1];
|
|
4485
4566
|
let innermost;
|
|
4486
4567
|
for (const declared of code.matchAll(
|
|
4487
4568
|
new RegExp(
|
|
@@ -4494,7 +4575,7 @@ function lowerObjCOptionalRequirements(source, index) {
|
|
|
4494
4575
|
if (dot > from && dot < to && (!innermost || from >= innermost.from))
|
|
4495
4576
|
innermost = { from, type: declared[1] };
|
|
4496
4577
|
}
|
|
4497
|
-
return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name ===
|
|
4578
|
+
return innermost?.type !== void 0 && !!index.requirements.get(resolveAliases(innermost.type, index.aliases))?.some((wanted) => wanted.name === name2);
|
|
4498
4579
|
};
|
|
4499
4580
|
for (const call of code.matchAll(/\.\s*([A-Za-z_]\w*)\s*\?(?=\s*[({])/g)) {
|
|
4500
4581
|
const callable = index.callable.get(call[1]);
|
|
@@ -4511,8 +4592,8 @@ function lowerObjCOptionalRequirements(source, index) {
|
|
|
4511
4592
|
continue;
|
|
4512
4593
|
if (callable.member === call[1]) edits.push([mark, 1, " "]);
|
|
4513
4594
|
else {
|
|
4514
|
-
const
|
|
4515
|
-
edits.push([
|
|
4595
|
+
const name2 = call.index + call[0].indexOf(call[1]);
|
|
4596
|
+
edits.push([name2, mark + 1 - name2, callable.member]);
|
|
4516
4597
|
}
|
|
4517
4598
|
}
|
|
4518
4599
|
for (const owner of code.matchAll(
|
|
@@ -4611,8 +4692,8 @@ function lowerObjCRuntimeCalls(source, index) {
|
|
|
4611
4692
|
for (const declared of code.matchAll(
|
|
4612
4693
|
/(?:\b(?:let|var)\s+|[(,]\s*(?:[A-Za-z_]\w*\s+)?)([A-Za-z_]\w*)\s*:\s*(?:(?:any\s+)?([A-Z]\w*(?:\.\w+)*)\s*([?!])?|[[(])|\b(?:let|var|for)\s+([A-Za-z_]\w*)\b(?!\s*:)|[{,]\s*([A-Za-z_]\w*)\s+in\b/g
|
|
4613
4694
|
)) {
|
|
4614
|
-
const
|
|
4615
|
-
const list = declarations.get(
|
|
4695
|
+
const name2 = declared[1] ?? declared[4] ?? declared[5];
|
|
4696
|
+
const list = declarations.get(name2) ?? [];
|
|
4616
4697
|
let type = declared[3] ? "" : declared[2] ?? "";
|
|
4617
4698
|
if (!type && declared[4]) {
|
|
4618
4699
|
const lookup = /^\s*=\s*NSClassFromString\s*\(/.exec(
|
|
@@ -4627,7 +4708,7 @@ function lowerObjCRuntimeCalls(source, index) {
|
|
|
4627
4708
|
}
|
|
4628
4709
|
const resolved = type.endsWith(".Type") ? `${resolveAliases(type.slice(0, -5), index.aliases)}.Type` : resolveAliases(type, index.aliases);
|
|
4629
4710
|
list.push({ at: declared.index, type: resolved });
|
|
4630
|
-
declarations.set(
|
|
4711
|
+
declarations.set(name2, list);
|
|
4631
4712
|
}
|
|
4632
4713
|
for (const pattern of code.matchAll(/\b(?:let|var|for)\s*(?=\(|\.\s*\w+\s*\()/g)) {
|
|
4633
4714
|
const open = code.indexOf("(", pattern.index + pattern[0].length);
|
|
@@ -4640,9 +4721,9 @@ function lowerObjCRuntimeCalls(source, index) {
|
|
|
4640
4721
|
}
|
|
4641
4722
|
for (const list of declarations.values()) list.sort((a, b) => a.at - b.at);
|
|
4642
4723
|
const braces = [...code.matchAll(/[{}]/g)].map((match) => match.index);
|
|
4643
|
-
const receiverType = (
|
|
4724
|
+
const receiverType = (name2, at) => {
|
|
4644
4725
|
let innermost;
|
|
4645
|
-
for (const declared of declarations.get(
|
|
4726
|
+
for (const declared of declarations.get(name2) ?? []) {
|
|
4646
4727
|
if (declared.at > at) break;
|
|
4647
4728
|
const [from, to] = declarationScope(code, braces, declared.at);
|
|
4648
4729
|
if (at > from && at < to && (!innermost || from >= innermost.from))
|
|
@@ -5481,7 +5562,7 @@ var CORE_FOUNDATION_HANDLE_IMPORTS = [
|
|
|
5481
5562
|
"CFSet",
|
|
5482
5563
|
"CFString",
|
|
5483
5564
|
"CFURL"
|
|
5484
|
-
].map((
|
|
5565
|
+
].map((name2) => `import class CoreFoundation.${name2}`).concat([
|
|
5485
5566
|
"import typealias CoreFoundation.CFPropertyList",
|
|
5486
5567
|
"import typealias CoreFoundation.CFTypeRef",
|
|
5487
5568
|
"import CoreGraphics"
|
|
@@ -5675,11 +5756,11 @@ function swiftSourceClosure(files, roots) {
|
|
|
5675
5756
|
continue;
|
|
5676
5757
|
}
|
|
5677
5758
|
if (depth !== 0 || !match[2]) continue;
|
|
5678
|
-
const
|
|
5759
|
+
const name2 = match[2].split(".").pop();
|
|
5679
5760
|
const index = match[1] === "extension" ? extensions : owners;
|
|
5680
|
-
const set = index.get(
|
|
5761
|
+
const set = index.get(name2) ?? /* @__PURE__ */ new Set();
|
|
5681
5762
|
set.add(file);
|
|
5682
|
-
index.set(
|
|
5763
|
+
index.set(name2, set);
|
|
5683
5764
|
}
|
|
5684
5765
|
sources.set(file, references);
|
|
5685
5766
|
}
|
|
@@ -5687,10 +5768,10 @@ function swiftSourceClosure(files, roots) {
|
|
|
5687
5768
|
const pending = [...roots];
|
|
5688
5769
|
const seen = /* @__PURE__ */ new Set();
|
|
5689
5770
|
while (pending.length) {
|
|
5690
|
-
const
|
|
5691
|
-
if (seen.has(
|
|
5692
|
-
seen.add(
|
|
5693
|
-
for (const file of [...owners.get(
|
|
5771
|
+
const name2 = pending.pop();
|
|
5772
|
+
if (seen.has(name2)) continue;
|
|
5773
|
+
seen.add(name2);
|
|
5774
|
+
for (const file of [...owners.get(name2) ?? [], ...extensions.get(name2) ?? []]) {
|
|
5694
5775
|
if (included.has(file)) continue;
|
|
5695
5776
|
included.add(file);
|
|
5696
5777
|
for (const reference of sources.get(file)) pending.push(reference);
|
|
@@ -5985,7 +6066,7 @@ function writeSwiftProject(layout, input, moduleRoot) {
|
|
|
5985
6066
|
[
|
|
5986
6067
|
product,
|
|
5987
6068
|
...optionalProducts.map(
|
|
5988
|
-
(
|
|
6069
|
+
(name2) => `.product(name: "${name2}", package: "sootsim-swift"),`
|
|
5989
6070
|
)
|
|
5990
6071
|
].join("\n ")
|
|
5991
6072
|
);
|
|
@@ -6100,7 +6181,7 @@ function builtArtifact(layout) {
|
|
|
6100
6181
|
}
|
|
6101
6182
|
const file = import_node_path6.default.join(binDir, `${executable.name}.wasm`);
|
|
6102
6183
|
if (!(0, import_node_fs4.existsSync)(file)) {
|
|
6103
|
-
const found = (0, import_node_fs4.existsSync)(binDir) ? (0, import_node_fs4.readdirSync)(binDir).filter((
|
|
6184
|
+
const found = (0, import_node_fs4.existsSync)(binDir) ? (0, import_node_fs4.readdirSync)(binDir).filter((name2) => name2.endsWith(".wasm")).sort() : [];
|
|
6104
6185
|
throw new Error(
|
|
6105
6186
|
`swift-compile: the build produced no ${executable.name}.wasm (found: ${found.join(", ") || "none"})`
|
|
6106
6187
|
);
|
|
@@ -6280,7 +6361,7 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6280
6361
|
}
|
|
6281
6362
|
return withSwiftRootLock(
|
|
6282
6363
|
root,
|
|
6283
|
-
async () => {
|
|
6364
|
+
async (lease) => {
|
|
6284
6365
|
const built = readCompiledArtifact(import_node_path6.default.join(sharedRoot, "artifact"), hash);
|
|
6285
6366
|
if (built) {
|
|
6286
6367
|
report("reusing verified disk artifact");
|
|
@@ -6343,7 +6424,8 @@ function compileSwiftProjectUnit(input, options) {
|
|
|
6343
6424
|
},
|
|
6344
6425
|
maxBuffer: 64 * 1024 * 1024,
|
|
6345
6426
|
timeout: options.timeoutMs,
|
|
6346
|
-
signal: options.signal
|
|
6427
|
+
signal: options.signal,
|
|
6428
|
+
lease
|
|
6347
6429
|
};
|
|
6348
6430
|
report("compiling and linking Swift modules");
|
|
6349
6431
|
try {
|